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