goto.js 6.2 KB

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