goto.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. // menu彈跳視窗
  2. $("#menu-box2").hide();
  3. $("#menu-box").hide();
  4. $("#menu-btn1").click(function () {
  5. $("#menu-box").slideToggle("slow");
  6. $("#menu-box2").slideToggle("slow");
  7. });
  8. $(".link").click(function () {
  9. $("#menu-box").slideUp("slow", function () {
  10. $("#menu-box2").slideUp("slow");
  11. // Animation complete.
  12. });
  13. });
  14. $(".feedback-slider1").slick({
  15. dots: true,
  16. dotsClass: 'slick-dots',
  17. speed: 1000,
  18. swipe: true,
  19. arrows: false,
  20. });
  21. $(".banner-slider").slick({
  22. dots: true,
  23. dotsClass: 'slick-dots',
  24. speed: 1000,
  25. swipe: true,
  26. autoplay: true,
  27. });
  28. $.fn.serializeObject = function () {
  29. var o = {};
  30. var a = this.serializeArray();
  31. o["id"] = 0;
  32. o["time_stamp"] = "";
  33. $.each(a, function () {
  34. if (o[this.name]) {
  35. if (!o[this.name].push) {
  36. o[this.name] = [o[this.name]];
  37. }
  38. o[this.name].push(this.value || '');
  39. } else {
  40. o[this.name] = this.value || '';
  41. }
  42. });
  43. return o;
  44. };
  45. $(".contact-form1").submit(function (e) {
  46. /* var formRef = $('#form1').serializeArray();
  47. var jsonString = JSON.stringify(formRef);*/
  48. var jsonInfo = $('.contact-form1').serializeObject();
  49. var jsonString = JSON.stringify(jsonInfo);
  50. console.log(jsonString);
  51. $.ajax({
  52. type: 'POST',
  53. url: 'https://go.hhh.com.tw:8002/deco_request_detail',
  54. data: jsonString,
  55. dataType: 'json',
  56. success: function (data) {
  57. console.log('送出成功: ' + data);
  58. if (data == 0) {
  59. alert("送出成功");
  60. } else if (data == 1) {
  61. alert("此email已填過表單");
  62. } else if (data == 2) {
  63. alert("此phone已填過表單");
  64. } else if (data == 3) {
  65. alert("此email、phone已填過表單");
  66. }
  67. location.href ="./index_complete_line.html";
  68. },
  69. beforeSend: function () {
  70. console.log('beforeSend');
  71. },
  72. complete: function () {
  73. console.log('complete');
  74. },
  75. error: function (jqXHR, textStatus, errorThrown) {
  76. console.log(JSON.stringify(jqXHR));
  77. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  78. console.log('送出失敗: ' + jqXHR.responseText);
  79. }
  80. });
  81. return false;
  82. });
  83. $("*").each(function (index, element) {
  84. // 此元素被點選後執行
  85. $(this).click(function (e) {
  86. // 取得被點選元素的屬性:data-gt-target
  87. var target = $(this).attr("data-gt-target");
  88. var duration = $(this).attr("data-gt-duration");
  89. var offset = $(this).attr("data-gt-offset");
  90. // JS 語法:判斷式
  91. // if (條件) {程式區塊}
  92. // 當條件成立,會執行程式區塊
  93. // 如果 目標有資料 才會執行 { } 內的程式
  94. // 避免出現 undefine (未定義 - 不存在的資料)
  95. if (target) {
  96. //console.log("目標:" + target);
  97. //console.log("時間:" + duration);
  98. //console.log("位移:" + offset);
  99. // 上方位置 = 目標區塊.位移().上方位置
  100. var top = $(target).offset().top;
  101. //console.log("要前往元素的上方位置:" + top);
  102. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  103. // parseInt() 將文字轉為數字
  104. $("html").stop().animate({
  105. scrollTop: top - offset
  106. }, parseInt(duration));
  107. }
  108. });
  109. });
  110. // 避免動畫與使用者滾輪衝突
  111. // html 在滾動滾輪時 停止 html 所有效果
  112. $("html").on("mousewheel", function () {
  113. $("html").stop();
  114. });
  115. $(document).ready(function () {
  116. $("#date").datepicker();
  117. });
  118. // // gototop 下滑效果
  119. $(".arrow").hide();
  120. $(window).scroll(function(){
  121. var y = window.scrollY;
  122. if(y>10){
  123. $(".arrow").show();
  124. }else{
  125. $(".arrow").hide();
  126. }
  127. });
  128. window.fbAsyncInit = function () {
  129. FB.init({
  130. appId: '1388696554848391', // 填入 FB APP ID
  131. cookie: true,
  132. xfbml: true,
  133. version: 'v11.0'
  134. });
  135. FB.getLoginStatus(function (response) {
  136. statusChangeCallback(response);
  137. });
  138. };
  139. // 處理各種登入身份
  140. function statusChangeCallback(response) {
  141. console.log(response);
  142. var target = document.getElementById("FB_STATUS_2"),
  143. html = "";
  144. // 登入 FB 且已加入會員
  145. if (response.status === 'connected') {
  146. html = "已登入 FB,並加入 WFU BLOG DEMO 應用程式<br/>";
  147. FB.api('/me?fields=id,name,email', function (response) {
  148. console.log('FB API回傳資料: ' + JSON.stringify(response));
  149. if (response.id) {
  150. // 設定欄位預設值
  151. document.getElementById("email").value = response.email;
  152. document.getElementById("name").value = response.name;
  153. // 隱藏FB登入按鈕
  154. document.getElementById("fb_login").style.display = 'none';
  155. }
  156. });
  157. }
  158. // 登入 FB, 未偵測到加入會員
  159. // else if (response.status === "not_authorized") {
  160. // target.innerHTML = "已登入 FB,但未加入 WFU BLOG DEMO 應用程式";
  161. // }
  162. // 未登入 FB
  163. // else {
  164. // target.innerHTML = "未登入 FB";
  165. // }
  166. }
  167. // 點擊登入
  168. $("#fb_login").click(function () {
  169. // 進行登入程序
  170. FB.login(function (response) {
  171. statusChangeCallback(response);
  172. }, {
  173. scope: 'public_profile,email'
  174. },
  175. );
  176. });
  177. // 點擊登出
  178. // $("#FB_logout").click(function() {
  179. // FB.logout(function(response) {
  180. // statusChangeCallback(response);
  181. // });
  182. // });
  183. // 載入 FB SDK
  184. (function (d, s, id) {
  185. var js, fjs = d.getElementsByTagName(s)[0];
  186. if (d.getElementById(id)) return;
  187. js = d.createElement(s);
  188. js.id = id;
  189. js.src = "https://connect.facebook.net/zh_TW/sdk.js";
  190. fjs.parentNode.insertBefore(js, fjs);
  191. }(document, 'script', 'facebook-jssdk'));