index.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. window.onload = function(){
  2. if(screen.width < 900){
  3. window.location.href = "https://m3.hhh.com.tw/";
  4. }
  5. }
  6. let result;
  7. $.ajax({
  8. method: "GET",
  9. url: "../json/realtime.json",
  10. dataType: "json",
  11. }).done(function (msg) {
  12. result = [...msg];
  13. renderSec00(result);
  14. renderSec02(result);
  15. renderSec05(result);
  16. renderSec06(result);
  17. renderSec07(result);
  18. renderSec08(result);
  19. renderSec09(result);
  20. renderSec10(result);
  21. renderVideo(result);
  22. renderTrending(result);
  23. });
  24. function renderSec00(data) {
  25. let temp = data[0]['data'];
  26. renderBannerStr('sec-00__slider', temp);
  27. $(".sec-00__slider").slick({
  28. dots: false,
  29. speed: 800,
  30. autoplay: true,
  31. autoplaySpeed: 5000,
  32. arrows: true,
  33. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  34. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>'
  35. });
  36. }
  37. function renderSec02(data) {
  38. let temp = data[1]['data'];
  39. renderBannerStr('sec-02__slider', temp);
  40. $(".sec-02__slider").slick({
  41. dots: false,
  42. autoplay: true,
  43. arrows: true,
  44. fade: true,
  45. autoplaySpeed: 4000,
  46. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 33px;color: white;transform: translateY(-10px);"></i></button>',
  47. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 33px;color: white;transform: translateY(-10px);"></i></button>'
  48. });
  49. }
  50. function renderBannerStr(sec, data) {
  51. let str = '';
  52. for(let i = 0; i < data.length; i++){
  53. str+= `<div class="${sec}-${i+1} slide-item" onclick="window.open('${data[i]['link']}');" style="background-image: url('${data[i]['DimgUrl']}');" data-bg="${data[i]['DimgUrl']}"></div>`
  54. }
  55. $(`.${sec}`).html(str);
  56. }
  57. function renderSec05(data) {
  58. let randomIdx = Math.floor(Math.random()*3);
  59. const ran = $('.sec-05__tabdiv .nav-pills li').eq(randomIdx);
  60. const ranDiv = $('.sec-05tab-content>div').eq(randomIdx);
  61. $('.sec-05tab-content>div').hide();
  62. ranDiv.show();
  63. ran.addClass('active');
  64. ran.children().addClass('active');
  65. $('.sec-05 .morelink').attr('href', $('.sec-05__tabdiv .nav-item-link.active').data('link'));
  66. let temp = data[2]['data'];
  67. for(let i = 0; i < temp.length; i++){
  68. if(temp[i]["tab"] == '最夯設計'){
  69. let str = '';
  70. let sub = temp[i]["data"];
  71. for(let j = 0; j < sub.length; j++){
  72. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
  73. <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
  74. <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
  75. <p class="mt-2">${sub[j]['description']}</p>
  76. </div>`;
  77. }
  78. $('#pills-hot-tab .tabpar').html(str);
  79. }
  80. if(temp[i]["tab"] == '影音實錄'){
  81. let str = '';
  82. let sub = temp[i]["data"];
  83. for(let j = 0; j < sub.length; j++){
  84. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
  85. <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"><img data-src="images/Play-Button.webp" alt="" class="tabpar__card__play lazyload"></div>
  86. <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
  87. <p class="mt-2">${sub[j]['description']}</p>
  88. </div>`;
  89. }
  90. $('#pills-video-tab .tabpar').html(str);
  91. }
  92. if(temp[i]["tab"] == '專欄文章'){
  93. let str = '';
  94. let sub = temp[i]["data"];
  95. for(let j = 0; j < sub.length; j++){
  96. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
  97. <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
  98. <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
  99. <p class="mt-2">${sub[j]['description']}</p>
  100. </div>`;
  101. }
  102. $('#pills-blog-tab .tabpar').html(str);
  103. }
  104. }
  105. const cardText = document.querySelectorAll('.tabpar__card p');
  106. cardText.forEach((item, i) => {
  107. let len = item.textContent.length;
  108. if(len > 18) {
  109. let str = item.textContent.substring(0, 18) + '...';
  110. item.textContent = str;
  111. }
  112. })
  113. $('.sec-05__tabdiv .nav-pills button').on('click', function(event){
  114. event.preventDefault();
  115. $('.sec-05__tabdiv .nav-pills li').removeClass('active');
  116. $('.sec-05__tabdiv .nav-pills li button').removeClass('active');
  117. $(this).addClass('active');
  118. $(this).parent().addClass('active');
  119. $('.sec-05tab-content>div').hide();
  120. var target = $(this).attr('id');
  121. $(`#pills-tab #${target}`).show();
  122. $('.sec-05tab-content .tabpar').slick('setPosition');
  123. });
  124. $(`.sec-05tab-content .tabpar`).slick({
  125. arrows: true,
  126. slidesToShow: 3,
  127. infinite: false,
  128. dots: false,
  129. slidesToScroll: 1,
  130. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
  131. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
  132. });
  133. $('.sec-05__tabdiv .nav-item-link').click(function() {
  134. $('.sec-05 .morelink').attr('href',$('.sec-05__tabdiv .nav-item-link.active').data('link'));
  135. });
  136. }
  137. function renderSec06(data) {
  138. let temp = data[3]['data'];
  139. let str = '';
  140. for(let i = 0; i < temp.length; i++){
  141. if(temp[i].video == 'true'){
  142. str+= `<div class="sec-06__card" onclick="window.open('${temp[i]['link']}');">
  143. <div class="sec-06__card__outer"><div class="sec-06__card__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-06__card__play lazyload" data-src="images/Play-Button.webp"></div></div>
  144. <h5 class="mb-2 mt-2">${temp[i]['title']}</h5>
  145. <p class="mt-2">${temp[i]['description']}</p>
  146. </div>`;
  147. } else {
  148. str+= `<div class="sec-06__card" onclick="window.open('${temp[i]['link']}');">
  149. <div class="sec-06__card__outer"><div class="sec-06__card__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div></div>
  150. <h5 class="mb-2 mt-2">${temp[i]['title']}</h5>
  151. <p class="mt-2">${temp[i]['description']}</p>
  152. </div>`;
  153. }
  154. }
  155. $('.sec-06 .sec-06__slider').html(str);
  156. $('.sec-06__slider').slick({
  157. arrows: true,
  158. dots: false,
  159. speed: 800,
  160. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 30px;color: white;"></i></button>',
  161. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 30px;color: white;"></i></button>'
  162. });
  163. const cardText = document.querySelectorAll('.sec-06__card p');
  164. cardText.forEach((item, i) => {
  165. let len = item.textContent.length;
  166. if(len > 20) {
  167. let str = item.textContent.substring(0, 40) + '...';
  168. item.textContent = str;
  169. }
  170. });
  171. }
  172. function renderSec07(data) {
  173. let temp = data[5]['data'];
  174. let str = '';
  175. for(let i = 0; i < temp.length; i++){
  176. str+= `<div class="sec-07__slider-${i+1} slide-item" onclick="window.open('${temp[i]['link']}');" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>`
  177. }
  178. $(`.sec-07__slider`).html(str);
  179. $(".sec-07__slider").slick({
  180. dots: false,
  181. autoplay: true,
  182. arrows: false,
  183. slidesToShow: 4,
  184. slidesToScroll: 1,
  185. autoplaySpeed: 7000,
  186. initialSlide: 0,
  187. infinite: true,
  188. });
  189. }
  190. function renderSec08(data) {
  191. let temp = data[4]['data'];
  192. let str = '';
  193. for(let i = 0; i < temp.length; i++){
  194. if(temp[i].video == 'true'){
  195. str+= `<div class="sec-08__slider-${i+1} sec-08__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  196. <div class="sec-08__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-08__card__play lazyload" data-src="images/Play-Button.webp"></div>
  197. <h5 class="mb-2 me-2">${temp[i]['title']}</h5>
  198. <p class="mb-2 me-2">${temp[i]['description']}</p>
  199. </div>`;
  200. } else {
  201. str+= `<div class="sec-08__slider-${i+1} sec-08__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  202. <div class="sec-08__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>
  203. <h5 class="mb-2 me-2">${temp[i]['title']}</h5>
  204. <p class="mb-2 me-2">${temp[i]['description']}</p>
  205. </div>`;
  206. }
  207. }
  208. $('.sec-08__slider').html(str);
  209. $(".sec-08__slider").slick({
  210. arrows: true,
  211. slidesToShow: 1,
  212. infinite: false,
  213. dots: false,
  214. slidesToShow: 3,
  215. centerPadding: '12px',
  216. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
  217. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
  218. });
  219. const cardText = document.querySelectorAll('.sec-08__card p');
  220. cardText.forEach((item, i) => {
  221. let len = item.textContent.length;
  222. if(len > 20) {
  223. let str = item.textContent.substring(0, 20) + '...';
  224. item.textContent = str;
  225. }
  226. })
  227. }
  228. function renderSec09(data) {
  229. let temp = data[6]['data'];
  230. let str = '';
  231. for(let i = 0; i < temp.length; i++){
  232. if(temp[i].video !== 'false') {
  233. str+= `<div class="sec-09__slider-1 sec-09__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  234. <div class="sec-09__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-09__card__play lazyload" data-src="images/Play-Button.webp"></div>
  235. <p class="sec-09__cardtxt">${temp[i]['title']}</p>
  236. </div>`
  237. } else {
  238. str+= `<div class="sec-09__slider-1 sec-09__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  239. <div class="sec-09__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>
  240. <p class="sec-09__cardtxt">${temp[i]['title']}</p>
  241. </div>`
  242. }
  243. }
  244. $('.sec-09__slider').html(str);
  245. $(".sec-09__slider").slick({
  246. autoplay: true,
  247. autoplaySpeed: 7000,
  248. arrows: true,
  249. slidesToShow: 4,
  250. infinite: true,
  251. dots: false,
  252. slidesToScroll: 1,
  253. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
  254. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
  255. });
  256. }
  257. function renderSec10(data) {
  258. renderRecStr("sec-10", data[7]['data'].slice(0, 6));
  259. renderRecStr("sec-11", data[8]['data'].slice(0, 6));
  260. }
  261. function renderRecStr(sec, data) {
  262. let str = '';
  263. for(let i = 0; i < data.length; i++){
  264. //console.log(data[i]['description'].length);
  265. if(data[i]['description'].length > 0) {
  266. data[i]['description'].split(',');
  267. data[i]['description'] = data[i]['description'].split(',').slice(1).join("");
  268. }
  269. if(data[i].video !== 'false') {
  270. str+= `<div class="${sec}__card col-4 mb-3" onclick="window.open('${data[i]['link']}');">
  271. <div class="${sec}__card-img mb-2" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"><img class="${sec}__card__play lazyload" data-src="images/Play-Button.webp"></div>
  272. <h5 class="me-2">${data[i]['title']}</h5>
  273. <p class="${sec}__cardtxt me-2">${data[i]['description']}</p>
  274. </div>`
  275. } else {
  276. str+= `<div class="${sec}__card col-4 mb-3" onclick="window.open('${data[i]['link']}');">
  277. <div class="${sec}__card-img mb-2" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"></div>
  278. <h5 class="me-2">${data[i]['title']}</h5>
  279. <p class="${sec}__cardtxt me-2">${data[i]['description']}</p>
  280. </div>`
  281. }
  282. }
  283. $(`.${sec} .row`).html(str);
  284. const cardText = document.querySelectorAll(`.${sec}__card p`);
  285. cardText.forEach((item, i) => {
  286. let len = item.textContent.length;
  287. if(len > 18) {
  288. let str = item.textContent.substring(0, 18) + '...';
  289. item.textContent = str;
  290. }
  291. })
  292. }
  293. function renderVideo(data) {
  294. let temp = data[9];
  295. console.log(data[9]);
  296. $('.sec-06__videotxt').text(temp['title']);
  297. console.log('test');
  298. $('.sec-06__video__imgfr').css('background-image', `url(https://img.youtube.com/vi/${temp['yt']}/hqdefault.jpg)`);
  299. $('#videoModal').on('shown.bs.modal', function () {
  300. $('#videoModal iframe').attr('src', `https://www.youtube.com/embed/${temp['yt']}?controls=0&autoplay=1&amp;enablejsapi=1&amp;origin=https%3A%2F%2Fm.hhh.com.tw&amp;widgetid=1`);
  301. });
  302. $('#videoModal').on('hidden.bs.modal', function () {
  303. $('#videoModal iframe').removeAttr('src');
  304. });
  305. }
  306. function renderTrending(result){
  307. let temp = result[10]['data'];
  308. let str = '';
  309. for(let i = 0; i < temp.length; i++){
  310. str += `<a class="dropbox__hots__link" href="https://hhh.com.tw/search/lists/case/${temp[i]}-keyword/">${temp[i]}</a>`
  311. }
  312. $('.dropbox__hots').html(`<strong class="dropbox__hots__title">熱搜關鍵字:</strong>${str}`);
  313. }
  314. function tab2 () {
  315. if(('.dropbox__tabdiv').length){
  316. // Show the first tab by default
  317. $('.dropbox-tab-content>div').hide();
  318. $('.dropbox-tab-content>div:first').show();
  319. $('.dropbox__tabdiv .nav-pills li:first').addClass('active');
  320. $('.dropbox__tabdiv .nav-pills li:first button').addClass('active');
  321. // Change tab class and display content
  322. $('.dropbox__tabdiv .nav-pills button').on('click', function(event){
  323. event.preventDefault();
  324. $('.dropbox__tabdiv .nav-pills li').removeClass('active');
  325. $('.dropbox__tabdiv .nav-pills li button').removeClass('active');
  326. $(this).addClass('active');
  327. $(this).parent().addClass('active');
  328. $('.dropbox-tab-content>div').hide();
  329. var target = $(this).attr('id');
  330. $(`#pills-tab-2 #${target}`).show();
  331. });
  332. }
  333. }
  334. tab2();
  335. let sticky = document.querySelector('.sec-00').offsetHeight;
  336. window.addEventListener('scroll', fixedOnScroll);
  337. const navbar = document.querySelector('.navbar-main');
  338. function fixedOnScroll() {
  339. if(window.pageYOffset >= sticky){
  340. navbar.classList.add('sticky');
  341. } else {
  342. navbar.classList.remove('sticky');
  343. }
  344. }
  345. $(window).scroll(function() {
  346. if ( $(this).scrollTop() > 800 ){
  347. $('.fixed-btn').fadeIn(222);
  348. } else {
  349. $('.fixed-btn').stop().fadeOut(222);
  350. }
  351. }).scroll();
  352. $('.btn-gotop').click(function () {
  353. $('html, body').animate({
  354. scrollTop: 0
  355. }, 500)
  356. });
  357. $('.navbar-search img').click(function(){
  358. $('.navbar-search .dropbox').toggleClass('open');
  359. if($('.navbar-search .dropbox').hasClass('open')) {
  360. $('.navbar-nav .nav-item>.dropbox').addClass('d-none');
  361. } else {
  362. $('.navbar-nav .nav-item>.dropbox').removeClass('d-none');
  363. }
  364. });
  365. $('.sec-00__close').click(function(){
  366. $(this).css('display', 'none');
  367. $('.sec-00').addClass('bannerClose');
  368. //$('.sec-02').css('padding-top', '53px');
  369. sticky = 0;
  370. });
  371. // search
  372. const imageSearch = document.querySelector('.image-search');
  373. const imagesSelect = document.querySelectorAll('#pills-img-tab select');
  374. imageSearch.addEventListener("click", function() {
  375. searchQueryStr(imagesSelect, 'photos');
  376. })
  377. const newsSearch = document.querySelector('.news-search');
  378. const newsSelect = document.querySelectorAll('#pills-news-tab select');
  379. newsSearch.addEventListener("click", function() {
  380. searchQueryStr(newsSelect, 'builder');
  381. });
  382. const caseSearch= document.querySelector('.case-search');
  383. const caseSelect = document.querySelectorAll('#pills-case-tab select');
  384. caseSearch.addEventListener("click", function() {
  385. let query = ''
  386. let str = 'https://hhh.com.tw/cases/lists/1-page/new-sort/';
  387. if($('#case-shui').val() == '風水') {
  388. caseSelect.forEach((item, i) => {
  389. if(i < 2) {
  390. if(item.value !== ''){
  391. query += `/${item.value}`;
  392. }
  393. }
  394. });
  395. str = `https://hhh.com.tw/cases/lists${query}/風水-keyword/1-page/`;
  396. window.open(str);
  397. return;
  398. }
  399. caseSelect.forEach((item, i) => {
  400. if(item.value !== ''){
  401. query += `/${item.value}`;
  402. }
  403. });
  404. str = `https://hhh.com.tw/cases/lists${query}/1-page/`;
  405. window.open(str);
  406. })
  407. const designerSearch = document.querySelector('.designer-search');
  408. const designerSelect = document.querySelectorAll('#pills-designer-tab select');
  409. designerSearch.addEventListener("click", function() {
  410. searchQueryStr(designerSelect, 'designers');
  411. })
  412. function searchQueryStr(block, link){
  413. let query = ''
  414. let str = `https://hhh.com.tw/${link}/lists/1-page/`;
  415. block.forEach((item, i) => {
  416. if(item.value !== ''){
  417. query += `/${item.value}`;
  418. }
  419. });
  420. str = `https://hhh.com.tw/${link}/lists${query}/1-page/`;
  421. window.location.href = str;
  422. }
  423. const searchBtn = document.querySelector('.dropbox__searchBar__submit');
  424. const searchBar = document.querySelector('.dropbox__searchBar__input');
  425. searchBtn.addEventListener('click', search);
  426. searchBar.addEventListener('keyup', pressSearch);
  427. function search() {
  428. if(searchBar.value == '') {
  429. window.location.href = 'https://m.hhh.com.tw/search/lists/case/';
  430. } else {
  431. window.location.href = `https://m.hhh.com.tw/search/lists/case/${searchBar.value}-keyword/`;
  432. console.log(`https://m.hhh.com.tw/search/lists/case/${searchBar.value}-keyword/`)
  433. }
  434. }
  435. function pressSearch(e) {
  436. if (e.keyCode === 13) {
  437. e.preventDefault();
  438. search();
  439. }
  440. }
  441. function todayTV() {
  442. var utc = new Date().toJSON().slice(0,10).replace(/-/g,'-');
  443. window.location.href=`https://hhh.com.tw/program/?tv=gstv&date=${utc}&type=tv`;
  444. }
  445. document.addEventListener('lazybeforeunveil', function(e){
  446. var bg = e.target.getAttribute('data-bg');
  447. if(bg){
  448. e.target.style.backgroundImage = 'url(' + bg + ')';
  449. }
  450. });
  451. // city result
  452. let cityResult;
  453. $.ajax({
  454. method: "GET",
  455. url: "../json/taiwan_districts.json",
  456. dataType: "json",
  457. }).done(function (msg) {
  458. cityResult = [...msg];
  459. let str = '';
  460. for(let i = 0; i < cityResult.length; i++){
  461. str += `<option value="${cityResult[i]['zip']}-city">${cityResult[i]['name']}</option>`;
  462. }
  463. $('#designer-city').html(`<option value="" selected="selected" disabled>所在縣市</option>${str}`);
  464. $('#designer-city').on('change', function() {
  465. let selected = $(this).val().split('-')[0];
  466. let countyStr = '';
  467. for(let i = 0; i < cityResult.length; i++){
  468. if(cityResult[i]['zip'] == selected) {
  469. for(let j = 0; j < cityResult[i]['districts'].length; j++){
  470. countyStr += `<option value="${cityResult[i]['districts'][j]['zip']}-county">${cityResult[i]['districts'][j]['name']}</option>`;
  471. }
  472. }
  473. }
  474. $('#designer-country').html(`<option value="" selected="selected" disabled>所在地區</option>${countyStr}`);
  475. });
  476. });
  477. //jQuery time
  478. var current_fs, next_fs, previous_fs; //fieldsets
  479. var left, opacity, scale; //fieldset properties which we will animate
  480. var animating; //flag to prevent quick multi-click glitches
  481. $(".next").click(function(){
  482. if(animating) return false;
  483. animating = true;
  484. current_fs = $(this).parent().parent();
  485. next_fs = $(this).parent().parent().next();
  486. //activate next step on progressbar using the index of next_fs
  487. $(".form-progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
  488. //show the next fieldset
  489. next_fs.animate({opacity: 1}, {
  490. step: function(now, mx) {
  491. //as the opacity of current_fs reduces to 0 - stored in "now"
  492. //1. scale current_fs down to 80%
  493. scale = 0 + (1 + now) * .5 ;
  494. //2. bring next_fs from the right(50%)
  495. left = (now * 50)+"%";
  496. //3. increase opacity of next_fs to 1 as it moves in
  497. opacity = 0 + now;
  498. next_fs.css({
  499. 'transform': 'scale('+scale+')',
  500. });
  501. next_fs.css({'opacity': opacity});
  502. },
  503. duration: 400,
  504. complete: function(){
  505. next_fs.show();
  506. animating = false;
  507. },
  508. //this comes from the custom easing plugin
  509. easing: 'easeInOutBack'
  510. });
  511. //hide the current fieldset with style
  512. current_fs.animate({opacity: 0}, {
  513. step: function(now, mx) {
  514. //as the opacity of current_fs reduces to 0 - stored in "now"
  515. //1. scale current_fs down to 80%
  516. scale = 1 - (1 - now) * 0.2;
  517. //2. bring next_fs from the right(50%)
  518. left = (now * 50)+"%";
  519. //3. increase opacity of next_fs to 1 as it moves in
  520. opacity = 1 - now;
  521. current_fs.css({
  522. 'transform': 'scale('+scale+')',
  523. });
  524. next_fs.css({'opacity': opacity});
  525. },
  526. duration: 400,
  527. complete: function(){
  528. current_fs.hide();
  529. animating = false;
  530. },
  531. //this comes from the custom easing plugin
  532. easing: 'easeInOutBack'
  533. });
  534. });
  535. /* const sec = document.querySelectorAll('.sec');
  536. const title = document.querySelectorAll('.title');
  537. const cover = document.querySelectorAll('.cover');
  538. const test_content = document.querySelectorAll('.test_content');
  539. function checkSlide() {
  540. console.log('pass');
  541. sec.forEach((block, i) => {
  542. // half way through the image
  543. //const test = document.querySelector('.test');
  544. const slideInAt = window.scrollY + window.innerHeight;
  545. console.log(slideInAt);
  546. //console.log(test.offsetTop);
  547. // bottom of the image
  548. const isHalfShown = slideInAt > block.offsetTop;
  549. if (isHalfShown) {
  550. console.log('active');
  551. title[i].style.bottom = '0em';
  552. cover[i].classList.add('slidein');
  553. test_content[i].classList.add('fadein');
  554. }
  555. })
  556. };
  557. window.addEventListener('scroll', checkSlide); */