custom.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /****************************************************************
  2. * *
  3. * 代码库 *
  4. * www.dmaku.com *
  5. * 努力创建完善、持续更新插件以及模板 *
  6. * *
  7. ****************************************************************/
  8. function goTop(){
  9. $(window).scroll(function(e) {
  10. if($(window).scrollTop()>100)
  11. $(".gotop").fadeIn(350).css("display","block");
  12. else
  13. $(".gotop").fadeOut(350).css("display","none");
  14. });
  15. $(".gotop").click(function(e) {
  16. $('body,html').animate({scrollTop:0},500);
  17. return false;
  18. });
  19. };
  20. $(document).ready(function() {
  21. //底部固定区域占位
  22. if( $(".fixed-bottom").is(":visible") ){
  23. $("#wrapper").css( "paddingBottom",$(".fixed-bottom").height() );
  24. }else{
  25. }
  26. //返回顶部
  27. goTop();
  28. //内容加载后的运动效果
  29. dataAnimate();
  30. // 多语言
  31. $('.language ul.sf-menu').superfish({
  32. delay: 500,
  33. animation: {opacity:'fast',height:'show'},
  34. speed: 'fast',
  35. autoArrows: true,
  36. dropShadows: false
  37. });
  38. // 导航菜单
  39. $('.main-nav ul.sf-menu').superfish({
  40. delay: 500,
  41. animation: {opacity:'fast',height:'show'},
  42. speed: 'fast',
  43. autoArrows: true,
  44. dropShadows: false
  45. });
  46. $('.main-nav ul.sf-menu > li').last().addClass('last').end().hover(function(){ $(this).addClass('nav-hover'); },function(){ $(this).removeClass('nav-hover'); });
  47. //菜单动态切换页面效果
  48. $(".main-nav li a, .logo a").click(function(){
  49. if( $(this).attr("target") != "_blank"){
  50. if( $(this).attr("href") != "javascript:;" && $(this).attr("href") != "#" )
  51. return openwork($(this).attr("href"));
  52. }
  53. });
  54. function openwork(url){
  55. $("#wrapper").css({'-webkit-animation':"bounceIn 0.5s .25s ease both",'-moz-animation':'bounceIn 1s .25s ease both','animation':'bounceIn 0.5s .25s ease both'});
  56. $("body").append("<div class='page-cover'></div>").css("position","relative");
  57. $(".page-cover").delay(600).animate({"height":$(document).height()},800,null,function(){
  58. location.href = url;
  59. });
  60. return false
  61. };
  62. //tab
  63. $(".tabs-nav").tabs(" > .tabs-panes > div");
  64. //scrollable in tab
  65. $(".tabs-nav > li > a").click(function(){
  66. var _tabIndex = $(this).parents(".tabs-nav").find("li").index($(this).parent());
  67. if( $(this).parents(".tabs-default").find(".tab-box").eq(_tabIndex).find(".scrollable-default").length > 0 ){
  68. $(".scrollable-default").carouFredSel({
  69. width : '100%',
  70. infinite : false,
  71. circular : false,
  72. auto : { pauseOnHover: true, timeoutDuration:3500 },
  73. swipe : { onTouch:true, onMouse:true },
  74. prev : { button:function() { return $(this).parent().next('.carousel-direction').find(".carousel-prev"); }},
  75. next : { button:function() { return $(this).parent().next('.carousel-direction').find(".carousel-next"); }}
  76. });
  77. $(".scrollable-default").parents(".scrollable").css("overflow","visible");
  78. }
  79. if( $(this).parents(".tabs-default").find(".tab-box").eq(_tabIndex).find(".full-scrollable-default").length > 0 ){
  80. $(".full-scrollable-default").carouFredSel({
  81. infinite : false,
  82. circular : false,
  83. auto : false,
  84. swipe : { onTouch:true, onMouse:true },
  85. responsive : true,
  86. items : {
  87. visible : {
  88. min : 2,
  89. max : 8
  90. }
  91. },
  92. prev : { button:function() { return $(this).parent().next('.carousel-direction').find(".carousel-prev"); }},
  93. next : { button:function() { return $(this).parent().next('.carousel-direction').find(".carousel-next"); }}
  94. });
  95. //重置高度
  96. /*$(".full-scrollable-default").parents('.caroufredsel_wrapper').css({
  97. 'height': ($(".full-scrollable-default").find('li').outerHeight()) + 'px'
  98. });*/
  99. }
  100. });
  101. // accordion
  102. $(".accordion").tabs(".accordion .accordion-pane", {tabs: '.accordion-handle', effect: 'slide',initialIndex: 0});
  103. $.tools.tabs.addEffect("slide", function(tabIndex, done) {
  104. this.getPanes().slideUp("fast").eq(tabIndex).slideDown("fast");
  105. done.call();
  106. });
  107. // tab-round
  108. $('.tab-round > .tabs-nav > li > a').click(function(){
  109. $(this).nextAll('.line-v').addClass('line-v-c');
  110. $(this).parent('li').siblings('li').find('.line-v').removeClass('line-v-c');
  111. });
  112. //图库切换
  113. $('.pgwSlideshow-gallery').pgwSlideshow({
  114. mainClassName : 'pgwSlideshow-gallery pgwSlideshow'
  115. });
  116. $('.pgwSlideshow-gallery-simple').pgwSlideshow({
  117. mainClassName : 'pgwSlideshow-gallery-simple pgwSlideshow',
  118. displayList : false
  119. });
  120. $('.pgwSlideshow-gallery-zoom').pgwSlideshow({
  121. mainClassName : 'pgwSlideshow-gallery-zoom pgwSlideshow',
  122. displayControls : false
  123. });
  124. //table
  125. //$(".qhd-content table tbody>tr:odd").addClass("odd-row");
  126. //$(".qhd-content table tbody>tr:even").addClass("even-row");
  127. $(".qhd-content table tbody>tr").hover(function(){
  128. $(this).addClass("trhover");
  129. },function(){
  130. $(this).removeClass("trhover");
  131. });
  132. //增加响应式表格外层div
  133. $(".qhd-content table").each(function(){
  134. if( !$(this).parent().hasClass("table-responsive") ){
  135. $(this).wrap("<div class='table-responsive'></div>");
  136. }
  137. });
  138. //左右悬浮
  139. $(".fixed-left").fixed({halfTop : true});
  140. $(".fixed-right").fixed({halfTop : true});
  141. //
  142. $(".service-close-btn").click(function(){
  143. var serviceMax = $(this).parents(".service-max"),
  144. serviceMin = serviceMax.next(".service-min");
  145. serviceMin.show();
  146. serviceMax.hide();
  147. });
  148. $(".service-open-btn").click(function(){
  149. var serviceMax = $(this).prev(".service-max"),
  150. fixedELement = $(this).parents(".fixed");
  151. $(this).hide();
  152. serviceMax.show();
  153. });
  154. //图标-名称-单列链接
  155. $(".link-fixed-side > ul > li").each(function(){
  156. $(this).hover(function(){
  157. $(this).addClass("active").find(".link-summary").show();
  158. },function(){
  159. $(this).removeClass("active").find(".link-summary").hide();
  160. });
  161. if( $(this).find('a').attr('href').indexOf("#popup") != -1 ){
  162. $(this).find('a').addClass('popup-show-btn');
  163. }
  164. });
  165. //弹窗视频
  166. $('.fancybox-video-play').fancybox({
  167. 'autoScale' : false,
  168. 'transitionIn' : 'elastic',
  169. 'transitionOut' : 'elastic',
  170. 'hideOnOverlayClick': false,
  171. 'centerOnScroll' : true,
  172. 'overlayColor' : '#000',
  173. 'padding' : '5'
  174. });
  175. //弹出窗口区域
  176. $("a").each(function(){
  177. if( typeof($(this).attr('href'))!="undefined" && $(this).attr('href').indexOf("#popup") != -1 ){
  178. $(this).addClass('popup-show-btn');
  179. }
  180. });
  181. $('.popup-show-btn').click(function(){
  182. $('.popup').show();
  183. $('.popup-overlay').height($(document).height());
  184. $('.popup-content').css({marginLeft:-($('.popup-content').outerWidth()/2), marginTop:-($('.popup-content').outerHeight()/2)});
  185. $('.popup-close-btn').click(function(){
  186. $(this).parents('.popup').hide();
  187. });
  188. return false;
  189. });
  190. //设置弹窗视频的宽度
  191. var touchWindowWidth = $(window).width();
  192. if( touchWindowWidth < 1000 ){
  193. $('.article-detail-fancybox').css("width", touchWindowWidth-80);
  194. }
  195. //移动端 JS
  196. var isMobile = device.mobile(),
  197. isTable = device.tablet(),
  198. isiPhone = device.iphone(),
  199. isiPad = device.ipad();
  200. if(isMobile || isTable || isiPhone || isiPad){
  201. //移除新窗口打开
  202. $('a').not('[data-mobile-target="_blank"]').removeAttr('target');
  203. }
  204. });
  205. $(window).load(function() {
  206. //scrollable-default
  207. $(".scrollable-default").carouFredSel({
  208. width : '100%',
  209. infinite : false,
  210. //circular : false,
  211. auto : { pauseOnHover: true, timeoutDuration:3500 },
  212. swipe : { onTouch:true, onMouse:true },
  213. prev : { button:function() { return $(this).parent().next('.carousel-direction').find(".carousel-prev"); }},
  214. next : { button:function() { return $(this).parent().next('.carousel-direction').find(".carousel-next"); }}
  215. });
  216. $(".scrollable-default").parents(".scrollable").css("overflow","visible");
  217. //full-scrollable-default
  218. $(".full-scrollable-default").carouFredSel({
  219. infinite : false,
  220. circular : false,
  221. auto : false,
  222. swipe : { onTouch:true, onMouse:true },
  223. responsive : true,
  224. items : {
  225. visible : {
  226. min : 2,
  227. max : 8
  228. }
  229. },
  230. prev : { button:function() { return $(this).parent().next('.carousel-direction').find(".carousel-prev"); }},
  231. next : { button:function() { return $(this).parent().next('.carousel-direction').find(".carousel-next"); }}
  232. });
  233. //重置高度
  234. $(".full-scrollable-default").parents('.caroufredsel_wrapper').css({
  235. 'height': ($(".full-scrollable-default").find('li').outerHeight()) + 'px'
  236. });
  237. //不规则多列
  238. if ($('.izotope-container').length) {
  239. $('.izotope-container').isotope({
  240. itemSelector: '.izotope-item',
  241. layoutMode: 'masonry',
  242. masonry: { columnWidth: '.grid-sizer' }
  243. });
  244. };
  245. });
  246. $(window).bind("load resize", function() {
  247. var postList = $(".post-list");
  248. postList.each(function(){
  249. var postImg = $(this).find(".post-img");
  250. var postTextBox = $(this).find(".post-text-box");
  251. var postText = $(this).find(".post-text");
  252. var postTextSummary = $(this).find(".post-text-summary");
  253. var postMaxHeight = postImg.eq(0).height();
  254. var summaryMaxHeight = 0;
  255. postImg.each(function(){
  256. postMaxHeight = $(this).height() > postMaxHeight ? $(this).height() : postMaxHeight;
  257. }).find("img").height( postMaxHeight );
  258. postTextBox.each(function(){
  259. $(this).height( postMaxHeight - parseInt($(this).css("paddingTop")) - parseInt($(this).css("paddingBottom")) );
  260. });
  261. postTextSummary.each(function(){
  262. summaryMaxHeight = postMaxHeight - $(this).prev("h2").height() - parseInt($(this).prev("h2").css("marginBottom")) - parseInt($(this).parent(".post-text").css("paddingBottom"))*2 - $(this).next(".post-text-detail").height() - 10;
  263. if( $(this).height() > summaryMaxHeight ){
  264. $(this).height( summaryMaxHeight );
  265. }
  266. });
  267. //三列 - 特殊处理第二列
  268. if( $(this).hasClass("post-list-3col") ){
  269. $(this).find(".post-list-item-spec").find(".post-img").css("top", postMaxHeight);
  270. $(this).find(".post-list-item-spec").find(".post-text-box").css("top", -postMaxHeight);
  271. }
  272. });
  273. });