// Lazy Load - jQuery plugin for lazy loading images Version: 1.9.0 !function(a,b,c,d){var e=a(b);a.fn.lazyload=function(f){function g(){var b=0;i.each(function(){var c=a(this);if(!j.skip_invisible||c.is(":visible"))if(a.abovethetop(this,j)||a.leftofbegin(this,j));else if(a.belowthefold(this,j)||a.rightoffold(this,j)){if(++b>j.failure_limit)return!1}else c.trigger("appear"),b=0})}var h,i=this,j={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!0,appear:null,load:null,placeholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"};return f&&(d!==f.failurelimit&&(f.failure_limit=f.failurelimit,delete f.failurelimit),d!==f.effectspeed&&(f.effect_speed=f.effectspeed,delete f.effectspeed),a.extend(j,f)),h=j.container===d||j.container===b?e:a(j.container),0===j.event.indexOf("scroll")&&h.bind(j.event,function(){return g()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,(c.attr("src")===d||c.attr("src")===!1)&&c.attr("src",j.placeholder),c.one("appear",function(){if(!this.loaded){if(j.appear){var d=i.length;j.appear.call(b,d,j)}a("").bind("load",function(){var d=c.data(j.data_attribute);c.hide(),c.is("img")?c.attr("src",d):c.css("background-image","url('"+d+"')"),c[j.effect](j.effect_speed),b.loaded=!0;var e=a.grep(i,function(a){return!a.loaded});if(i=a(e),j.load){var f=i.length;j.load.call(b,f,j)}}).attr("src",c.data(j.data_attribute))}}),0!==j.event.indexOf("scroll")&&c.bind(j.event,function(){b.loaded||c.trigger("appear")})}),e.bind("resize",function(){g()}),/iphone|ipod|ipad.*os 5/gi.test(navigator.appVersion)&&e.bind("pageshow",function(b){b.originalEvent&&b.originalEvent.persisted&&i.each(function(){a(this).trigger("appear")})}),a(c).ready(function(){g()}),this},a.belowthefold=function(c,f){var g;return g=f.container===d||f.container===b?(b.innerHeight?b.innerHeight:e.height())+e.scrollTop():a(f.container).offset().top+a(f.container).height(),g<=a(c).offset().top-f.threshold},a.rightoffold=function(c,f){var g;return g=f.container===d||f.container===b?e.width()+e.scrollLeft():a(f.container).offset().left+a(f.container).width(),g<=a(c).offset().left-f.threshold},a.abovethetop=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollTop():a(f.container).offset().top,g>=a(c).offset().top+f.threshold+a(c).height()},a.leftofbegin=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollLeft():a(f.container).offset().left,g>=a(c).offset().left+f.threshold+a(c).width()},a.inviewport=function(b,c){return!(a.rightoffold(b,c)||a.leftofbegin(b,c)||a.belowthefold(b,c)||a.abovethetop(b,c))},a.extend(a.expr[":"],{"below-the-fold":function(b){return a.belowthefold(b,{threshold:0})},"above-the-top":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-screen":function(b){return a.rightoffold(b,{threshold:0})},"left-of-screen":function(b){return!a.rightoffold(b,{threshold:0})},"in-viewport":function(b){return a.inviewport(b,{threshold:0})},"above-the-fold":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-fold":function(b){return a.rightoffold(b,{threshold:0})},"left-of-fold":function(b){return!a.rightoffold(b,{threshold:0})}})}(jQuery,window,document); !function(){var a=jQuery.event.special,b="D"+ +new Date,c="D"+(+new Date+1);a.scrollstart={setup:function(){var c,d=function(b){var d=this,e=arguments;c?clearTimeout(c):(b.type="scrollstart",jQuery.event.dispatch.apply(d,e)),c=setTimeout(function(){c=null},a.scrollstop.latency)};jQuery(this).bind("scroll",d).data(b,d)},teardown:function(){jQuery(this).unbind("scroll",jQuery(this).data(b))}},a.scrollstop={latency:300,setup:function(){var b,d=function(c){var d=this,e=arguments;b&&clearTimeout(b),b=setTimeout(function(){b=null,c.type="scrollstop",jQuery.event.dispatch.apply(d,e)},a.scrollstop.latency)};jQuery(this).bind("scroll",d).data(c,d)},teardown:function(){jQuery(this).unbind("scroll",jQuery(this).data(c))}}}(); // Infinite Ajax Scroll, a jQuery plugin 1.0.2 (function(e){"use strict";Date.now=Date.now||function(){return+(new Date)},e.ias=function(t){function u(){var t;i.onChangePage(function(e,t,r){s&&s.setPage(e,r),n.onPageChange.call(this,e,r,t)});if(n.triggerPageThreshold>0)a();else if(e(n.next).attr("href")){var u=r.getCurrentScrollOffset(n.scrollContainer);E(function(){p(u)})}return s&&s.havePage()&&(l(),t=s.getPage(),r.forceScrollTop(function(){var n;t>1?(v(t),n=h(!0),e("html, body").scrollTop(n)):a()})),o}function a(){c(),n.scrollContainer.scroll(f)}function f(){var e,t;e=r.getCurrentScrollOffset(n.scrollContainer),t=h(),e>=t&&(m()>=n.triggerPageThreshold?(l(),E(function(){p(e)})):p(e))}function l(){n.scrollContainer.unbind("scroll",f)}function c(){e(n.pagination).hide()}function h(t){var r,i;return r=e(n.container).find(n.item).last(),r.size()===0?0:(i=r.offset().top+r.height(),t||(i+=n.thresholdMargin),i)}function p(t,r){var s;s=e(n.next).attr("href");if(!s)return n.noneleft&&e(n.container).find(n.item).last().after(n.noneleft),l();if(n.beforePageChange&&e.isFunction(n.beforePageChange)&&n.beforePageChange(t,s)===!1)return;i.pushPages(t,s),l(),y(),d(s,function(t,i){var o=n.onLoadItems.call(this,i),u;o!==!1&&(e(i).hide(),u=e(n.container).find(n.item).last(),u.after(i),e(i).fadeIn()),s=e(n.next,t).attr("href"),e(n.pagination).replaceWith(e(n.pagination,t)),b(),c(),s?a():l(),n.onRenderComplete.call(this,i),r&&r.call(this)})}function d(t,r,i){var s=[],o,u=Date.now(),a,f;i=i||n.loaderDelay,e.get(t,null,function(t){o=e(n.container,t).eq(0),0===o.length&&(o=e(t).filter(n.container).eq(0)),o&&o.find(n.item).each(function(){s.push(this)}),r&&(f=this,a=Date.now()-u,a0&&p(n,function(){l(),i.getCurPageNum(n)+1'+n.loader+""),t.hide()),t}function y(){var t=g(),r;n.customLoaderProc!==!1?n.customLoaderProc(t):(r=e(n.container).find(n.item).last(),r.after(t),t.fadeIn())}function b(){var e=g();e.remove()}function w(t){var r=e(".ias_trigger");return r.size()===0&&(r=e('"),r.hide()),e("a",r).unbind("click").bind("click",function(){return S(),t.call(),!1}),r}function E(t){var r=w(t),i;n.customTriggerProc!==!1?n.customTriggerProc(r):(i=e(n.container).find(n.item).last(),i.after(r),r.fadeIn())}function S(){var e=w();e.remove()}var n=e.extend({},e.ias.defaults,t),r=new e.ias.util,i=new e.ias.paging(n.scrollContainer),s=n.history?new e.ias.history:!1,o=this;u()},e.ias.defaults={container:"#container",scrollContainer:e(window),item:".item",pagination:"#pagination",next:".next",noneleft:!1,loader:'',loaderDelay:600,triggerPageThreshold:3,trigger:"Load more items",thresholdMargin:0,history:!0,onPageChange:function(){},beforePageChange:function(){},onLoadItems:function(){},onRenderComplete:function(){},customLoaderProc:!1,customTriggerProc:!1},e.ias.util=function(){function i(){e(window).load(function(){t=!0})}var t=!1,n=!1,r=this;i(),this.forceScrollTop=function(i){e("html,body").scrollTop(0),n||(t?(i.call(),n=!0):setTimeout(function(){r.forceScrollTop(i)},1))},this.getCurrentScrollOffset=function(e){var t,n;return e.get(0)===window?t=e.scrollTop():t=e.offset().top,n=e.height(),t+n}},e.ias.paging=function(){function s(){e(window).scroll(o)}function o(){var t,s,o,f,l;t=i.getCurrentScrollOffset(e(window)),s=u(t),o=a(t),r!==s&&(f=o[0],l=o[1],n.call({},s,f,l)),r=s}function u(e){for(var n=t.length-1;n>0;n--)if(e>t[n][0])return n+1;return 1}function a(e){for(var n=t.length-1;n>=0;n--)if(e>t[n][0])return t[n];return null}var t=[[0,document.location.toString()]],n=function(){},r=1,i=new e.ias.util;s(),this.getCurPageNum=function(t){return t=t||i.getCurrentScrollOffset(e(window)),u(t)},this.onChangePage=function(e){n=e},this.pushPages=function(e,n){t.push([e,n])}},e.ias.history=function(){function n(){t=!!(window.history&&history.pushState&&history.replaceState),t=!1}var e=!1,t=!1;n(),this.setPage=function(e,t){this.updateState({page:e},"",t)},this.havePage=function(){return this.getState()!==!1},this.getPage=function(){var e;return this.havePage()?(e=this.getState(),e.page):1},this.getState=function(){var e,n,r;if(t){n=history.state;if(n&&n.ias)return n.ias}else{e=window.location.hash.substring(0,7)==="#/page/";if(e)return r=parseInt(window.location.hash.replace("#/page/",""),10),{page:r}}return!1},this.updateState=function(t,n,r){e?this.replaceState(t,n,r):this.pushState(t,n,r)},this.pushState=function(n,r,i){var s;t?history.pushState({ias:n},r,i):(s=n.page>0?"#/page/"+n.page:"",window.location.hash=s),e=!0},this.replaceState=function(e,n,r){t?history.replaceState({ias:e},n,r):this.pushState(e,n,r)}}})(jQuery); jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { // name and value given, set cookie options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE } var path = options.path ? '; path=' + options.path : ''; var domain = options.domain ? '; domain=' + options.domain : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { // only name given, get cookie var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } }; +(function($) { var LS={ get:function(dataKey){ if(window.localStorage){ return localStorage.getItem(dataKey); }else{ return $.cookie(dataKey); } }, set:function(key,value){ if(window.localStorage){ localStorage[key]=value; }else{ $.cookie(key,value); } }, remove:function(key){ if(window.localStorage){ localStorage.removeItem(key); }else{ $.cookie(key,undefined); } } } $('[data-event="rewards"]').on('click', function(){ $('.rewards-popover-mask, .rewards-popover').fadeIn() }) $('[data-event="rewards-close"]').on('click', function(){ $('.rewards-popover-mask, .rewards-popover').fadeOut() }) var el_carousel = $('.carousel') el_carousel.carousel({ interval: 4000 }) if( el_carousel.length && $('body').hasClass('focusslide_s_m') ){ var mc = new Hammer(el_carousel[0]); mc.on("panleft panright swipeleft swiperight", function(ev) { if( ev.type == 'swipeleft' || ev.type == 'panleft' ){ el_carousel.carousel('next') }else if( ev.type == 'swiperight' || ev.type == 'panright' ){ el_carousel.carousel('prev') } // el_carousel[0].textContent = ev.type +" gesture detected."; }); } /* * * ==================================================================================================== */ $('.m-search').on('click', function(){ $('.search-form').slideToggle(200, function(){ if( $('.m-search').css('display') == 'block' ){ $('.search-form .form-control').focus() } }) }) $('.navmore').on('click', function(){ $('body').toggleClass('navshows'); }) $('body').append('
') // lazy avatar $('.content .avatar').lazyload({ placeholder: jui.uri + '/../img/avatar-default.png', event: 'scrollstop' }); $('.sidebar .avatar').lazyload({ placeholder: jui.uri + '/../img/avatar-default.png', event: 'scrollstop' }); $('.content .thumb').lazyload({ placeholder: jui.uri + '/../img/thumbnail.png', event: 'scrollstop' }); $('.sidebar .thumb').lazyload({ placeholder: jui.uri + '/../img/thumbnail.png', event: 'scrollstop' }); $('.content .wp-smiley').lazyload({ event: 'scrollstop' }); $('.sidebar .wp-smiley').lazyload({ event: 'scrollstop' }); $('#postcomments img').lazyload({ event: 'scrollstop' }); var elments = { sidebar: $('.sidebar'), footer: $('.footer') } $('.feed-weixin').popover({ placement: $('body').hasClass('ui-navtop')?'bottom':'right', trigger: 'hover', container: 'body', html: true }) if( Number(jui.ajaxpager) ){ $.ias({ triggerPageThreshold: jui.ajaxpager?Number(jui.ajaxpager)+1:5, history: false, container : '.content', item: '.excerpt', pagination: '.pagination', next: '.next-page a', loader: '
', trigger: 'More', onRenderComplete: function() { $('.excerpt .thumb').lazyload({ placeholder: jui.uri + '/../img/thumbnail.png', threshold: 400 }); } }); } /* * page search * ==================================================== */ if( $('body').hasClass('search-results') ){ var val = $('.search-form .form-control').val() var reg = eval('/'+val+'/i') $('.excerpt h2 a, .excerpt .note').each(function(){ $(this).html( $(this).text().replace(reg, function(w){ return ''+w+'' }) ) }) } if( elments.sidebar.length && jui.roll ){ jui.roll = jui.roll.split(' ') var h1 = 20, h2 = 40, h3 = 20 if( $('body').hasClass('ui-navtop') ){ h1 = 100, h2 = 120 } var rollFirst = elments.sidebar.find('.widget:eq('+(Number(jui.roll[0])-1)+')') if( rollFirst.length ){ var sheight = rollFirst[0].offsetHeight if( sheight ){ rollFirst.on('affix-top.bs.affix', function(){ rollFirst.css({top: 0}) sheight = rollFirst[0].offsetHeight for (var i = 1; i < jui.roll.length; i++) { var item = Number(jui.roll[i])-1 var current = elments.sidebar.find('.widget:eq('+item+')') current.removeClass('affix').css({top: 0}) }; }) rollFirst.on('affix.bs.affix', function(){ rollFirst.css({top: h1}) for (var i = 1; i < jui.roll.length; i++) { var item = Number(jui.roll[i])-1 var current = elments.sidebar.find('.widget:eq('+item+')') current.addClass('affix').css({top: sheight+h2}) sheight += current[0].offsetHeight + h3 }; }) rollFirst.affix({ offset: { top: elments.sidebar.height(), bottom: (elments.footer.height()||0) + 10 } }) } } } $('.widget_tags a').tooltip({ container: 'body' }) $('.readers a, .widget_comments a').tooltip({ container: 'body', placement: 'top' }) $('.article-meta li:eq(1) a').tooltip({ container: 'body', placement: 'bottom' }) if ($('.article-content').length){ $('.article-content img').attr('data-tag', 'bdshare') video_ok() $(window).resize(function(event) { video_ok() }); } function video_ok(){ $('.article-content embed, .article-content video, .article-content iframe').each(function(){ var w = $(this).attr('width'), h = $(this).attr('height') if( h ){ $(this).css('height', $(this).width()/(w/h)) } }) } $('.rollto a').on('click', function() { scrollTo() }) $(window).scroll(function() { var scroller = $('.rollto'); document.documentElement.scrollTop + document.body.scrollTop > 200 ? scroller.fadeIn() : scroller.fadeOut(); }) /* functions * ==================================================== */ function scrollTo(name, speed) { if (!speed) speed = 300 if (!name) { $('html,body').animate({ scrollTop: 0 }, speed) } else { if ($(name).length > 0) { $('html,body').animate({ scrollTop: $(name).offset().top }, speed) } } } var islogin = false if( $('body').hasClass('logged-in') ) islogin = true /* event click * ==================================================== */ $(document).on('click', function(e) { e = e || window.event; var target = e.target || e.srcElement, _ta = $(target) if (_ta.hasClass('disabled')) return if (_ta.parent().attr('data-event')) _ta = $(_ta.parent()[0]) if (_ta.parent().parent().attr('data-event')) _ta = $(_ta.parent().parent()[0]) var type = _ta.attr('data-event') switch (type) { case 'like': var pid = _ta.attr('data-pid') if ( !pid || !/^\d{1,}$/.test(pid) ) return; if( !islogin ){ var lslike = LS.get('_likes') || '' if( lslike.indexOf(','+pid+',')!==-1 ) return alert('你已赞!') if( !lslike ){ LS.set('_likes', ','+pid+',') }else{ if( lslike.length >= 160 ){ lslike = lslike.substring(0,lslike.length-1) lslike = lslike.substr(1).split(',') lslike.splice(0,1) lslike.push(pid) lslike = lslike.join(',') LS.set('_likes', ','+lslike+',') }else{ LS.set('_likes', lslike+pid+',') } } } $.ajax({ url: jui.uri + '/actions/index.php', type: 'POST', dataType: 'json', data: { key: 'like', pid: pid }, success: function(data, textStatus, xhr) { //called when successful // console.log(data) if (data.error) return false; // console.log( data.response ) // if( data.type === 1 ){ _ta.toggleClass('actived') _ta.find('span').html(data.response) // } }, error: function(xhr, textStatus, errorThrown) { //called when there is an error console.log(xhr) } }); break; case 'comment-user-change': $('#comment-author-info').slideDown(300) $('#comment-author-info input:first').focus() break; case 'login': $('#modal-login').modal('show') break; } }) $('.commentlist .url').attr('target','_blank') /*$('#comment-author-info p input').focus(function() { $(this).parent('p').addClass('on') }) $('#comment-author-info p input').blur(function() { $(this).parent('p').removeClass('on') }) $('#comment').focus(function(){ if( $('#author').val()=='' || $('#email').val()=='' ) $('.comt-comterinfo').slideDown(300) })*/ var edit_mode = '0', txt1 = '
正在提交, 请稍候...
', txt2 = '
#
', txt3 = '">', cancel_edit = '取消编辑', edit, num = 1, comm_array = []; comm_array.push(''); $comments = $('#comments-title'); $cancel = $('#cancel-comment-reply-link'); cancel_text = $cancel.text(); $submit = $('#commentform #submit'); $submit.attr('disabled', false); $('.comt-tips').append(txt1 + txt2); $('.comt-loading').hide(); $('.comt-error').hide(); $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body'); $('#commentform').submit(function() { $('.comt-loading').show(); $submit.attr('disabled', true).fadeTo('slow', 0.5); if (edit) $('#comment').after(''); $.ajax({ url: jui.uri+'/modules/comment.php', data: $(this).serialize(), type: $(this).attr('method'), error: function(request) { $('.comt-loading').hide(); $('.comt-error').show().html(request.responseText); setTimeout(function() { $submit.attr('disabled', false).fadeTo('slow', 1); $('.comt-error').fadeOut() }, 3000) }, success: function(data) { $('.comt-loading').hide(); comm_array.push($('#comment').val()); $('textarea').each(function() { this.value = '' }); var t = addComment, cancel = t.I('cancel-comment-reply-link'), temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId), post = t.I('comment_post_ID').value, parent = t.I('comment_parent').value; if (!edit && $comments.length) { n = parseInt($comments.text().match(/\d+/)); $comments.text($comments.text().replace(n, n + 1)) } new_htm = '" id="new_comm_' + num + '">') : ('\n
0) { $submit.val(wait); wait--; setTimeout(countdown, 1000) } else { $submit.val(submit_val).attr('disabled', false).fadeTo('slow', 1); wait = 15 } } })(jQuery)