]> scripts.mit.edu Git - autoinstallsdev/wordpress.git/blobdiff - wp-includes/js/heartbeat.min.js
WordPress 3.8
[autoinstallsdev/wordpress.git] / wp-includes / js / heartbeat.min.js
index 81039d4f9f8b01e1f1531f1d36e825c473ef83a7..2e36d6fd120fc0a8be704db23e194e9c1a34bba6 100644 (file)
@@ -1 +1 @@
-window.wp=window.wp||{},function(a){var b=function(){function b(a){return a?parseInt((new Date).getTime()/1e3):(new Date).getTime()}function c(a){var b,c=a.src;if(c&&/^https?:\/\//.test(c)&&(b=window.location.origin?window.location.origin:window.location.protocol+"//"+window.location.host,0!==c.indexOf(b)))return!1;try{if(a.contentWindow.document)return!0}catch(d){}return!1}function d(b,c){var d;if(b){switch(b){case"abort":break;case"timeout":d=!0;break;case"parsererror":case"error":case"empty":case"unknown":A++,A>2&&(d=!0)}503==c&&!1===D&&(d=!0),d&&!u.hasConnectionError()&&(D=!0,a(document).trigger("heartbeat-connection-lost",[b,c]))}else u.hasConnectionError()?(A=0,D=!1,a(document).trigger("heartbeat-connection-restored")):null===D&&(D=!1)}function e(){var c,e,g={},h=!0,i="object"==typeof window.heartbeatSettings?window.heartbeatSettings.nonce:"";x=b(),c=a.extend({},y),y={},a(document).trigger("heartbeat-send",[c]);for(e in c)if(c.hasOwnProperty(e)){h=!1;break}return h&&!u.hasConnectionError()?(p=!1,f(),void 0):(g.data=c,g.interval=o/1e3,g._nonce=i,g.action="heartbeat",g.screen_id=v,g.has_focus=B,p=!0,u.xhr=a.ajax({url:w,type:"post",timeout:3e4,data:g,dataType:"json"}).done(function(b,c,e){var f;return b?(u.hasConnectionError()&&d(),b.nonces_expired?(a(document).trigger("heartbeat-nonces-expired"),void 0):(b.heartbeat_interval&&(f=b.heartbeat_interval,delete b.heartbeat_interval),u.tick(b,c,e),f&&u.interval.call(u,f),void 0)):d("empty")}).always(function(){p=!1,f()}).fail(function(a,b,c){d(b||"unknown",a.status),u.error(a,b,c)}),void 0)}function f(){var a=b()-x,c=o;l&&(B?z>0&&q&&(c=q,z--):c=1e5,window.clearTimeout(m),c>a?m=window.setTimeout(function(){l&&e()},c-a):e())}function g(){window.clearTimeout(t),window.clearTimeout(C),t=C=0,B=!1}function h(){window.clearTimeout(t),window.clearTimeout(C),t=C=0,r=b(),B||(B=!0,window.clearTimeout(m),p||f())}function i(){a("iframe").each(function(b,d){c(d)&&(a.data(d,"wp-heartbeat-focus")||(a.data(d,"wp-heartbeat-focus",1),a(d.contentWindow).on("focus.wp-heartbeat-focus",function(){h()}).on("blur.wp-heartbeat-focus",function(){i(),C=window.setTimeout(function(){g()},500)})))})}function j(){s=!1,a(document).off(".wp-heartbeat-active"),a("iframe").each(function(b,d){c(d)&&a(d.contentWindow).off(".wp-heartbeat-active")}),h()}function k(){var d=r?b()-r:0;d>3e5&&B&&g(),s||(a(document).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active",function(){j()}),a("iframe").each(function(b,d){c(d)&&a(d.contentWindow).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active",function(){j()})}),s=!0)}var l,m,n,o,p,q,r,s,t,u=this,v="undefined"!=typeof pagenow?pagenow:"",w="undefined"!=typeof ajaxurl?ajaxurl:"",x=0,y={},z=0,A=0,B=!0,C=-1,D=null;this.hasConnectionError=function(){return!!D},"object"==typeof window.heartbeatSettings&&(n=a.extend({},window.heartbeatSettings),w=n.ajaxurl||w,delete n.ajaxurl,delete n.nonce,o=n.interval||15,delete n.interval,15>o?o=15:o>60&&(o=60),o=1e3*o,v=v||n.screenId||"front",delete n.screenId,a.extend(this,n)),a(window).on("blur.wp-heartbeat-focus",function(){i(),t=window.setTimeout(function(){g()},500)}).on("focus.wp-heartbeat-focus",function(){a("iframe").each(function(b,d){c(d)&&(a.removeData(d,"wp-heartbeat-focus"),a(d.contentWindow).off(".wp-heartbeat-focus"))}),h()}),window.setInterval(function(){k()},3e4),a(document).ready(function(){l=!0,x=b(),f()}),this.hasFocus=function(){return B},this.interval=function(a,b){var c,d;if(b=parseInt(b,10)||30,b=1>b||b>30?30:b,a){switch(a){case"fast":d=5,z=b;break;case"slow":d=60,z=0;break;case"long-polling":return o=0,0;default:d=15,z=0}c=o>1e3*d,z>0?q=1e3*d:(o=1e3*d,q=0),c&&f()}return B?q?q/1e3:o/1e3:120},this.enqueue=function(a,b,c){return a?c&&this.isQueued(a)?!1:(y[a]=b,!0):!1},this.isQueued=function(a){return a?y.hasOwnProperty(a):void 0},this.dequeue=function(a){a&&delete y[a]},this.getQueuedItem=function(a){return a?this.isQueued(a)?y[a]:void 0:void 0}};a.extend(b.prototype,{tick:function(b,c,d){a(document).trigger("heartbeat-tick",[b,c,d])},error:function(b,c,d){a(document).trigger("heartbeat-error",[b,c,d])}}),wp.heartbeat=new b}(jQuery);
\ No newline at end of file
+!function(a,b,c){var d=function(){function d(){if("string"==typeof b.pagenow&&(B.screenId=b.pagenow),"string"==typeof b.ajaxurl&&(B.url=b.ajaxurl),"object"==typeof b.heartbeatSettings){var c=b.heartbeatSettings;!B.url&&c.ajaxurl&&(B.url=c.ajaxurl),c.interval&&(B.mainInterval=c.interval,B.mainInterval<15?B.mainInterval=15:B.mainInterval>60&&(B.mainInterval=60)),B.screenId||(B.screenId=c.screenId||"front"),"disable"===c.suspension&&(B.suspendEnabled=!1)}B.mainInterval=1e3*B.mainInterval,B.originalInterval=B.mainInterval,a(b).on("blur.wp-heartbeat-focus",function(){m(),B.winBlurTimer=b.setTimeout(function(){k()},500)}).on("focus.wp-heartbeat-focus",function(){n(),l()}).on("unload.wp-heartbeat",function(){B.suspend=!0,B.xhr&&4!==B.xhr.readyState&&B.xhr.abort()}),b.setInterval(function(){q()},3e4),A.ready(function(){B.lastTick=e(),j()})}function e(){return(new Date).getTime()}function f(a){var c,d=a.src;if(d&&/^https?:\/\//.test(d)&&(c=b.location.origin?b.location.origin:b.location.protocol+"//"+b.location.host,0!==d.indexOf(c)))return!1;try{if(a.contentWindow.document)return!0}catch(e){}return!1}function g(a,b){var c;if(a){switch(a){case"abort":break;case"timeout":c=!0;break;case"error":if(503===b&&B.hasConnected){c=!0;break}case"parsererror":case"empty":case"unknown":B.errorcount++,B.errorcount>2&&B.hasConnected&&(c=!0)}c&&!s()&&(B.connectionError=!0,A.trigger("heartbeat-connection-lost",[a,b]))}}function h(){B.hasConnected=!0,s()&&(B.errorcount=0,B.connectionError=!1,A.trigger("heartbeat-connection-restored"))}function i(){var c,d;B.connecting||B.suspend||(B.lastTick=e(),d=a.extend({},B.queue),B.queue={},A.trigger("heartbeat-send",[d]),c={data:d,interval:B.tempInterval?B.tempInterval/1e3:B.mainInterval/1e3,_nonce:"object"==typeof b.heartbeatSettings?b.heartbeatSettings.nonce:"",action:"heartbeat",screen_id:B.screenId,has_focus:B.hasFocus},B.connecting=!0,B.xhr=a.ajax({url:B.url,type:"post",timeout:3e4,data:c,dataType:"json"}).always(function(){B.connecting=!1,j()}).done(function(a,b,c){var d;return a?(h(),a.nonces_expired?(A.trigger("heartbeat-nonces-expired"),void 0):(a.heartbeat_interval&&(d=a.heartbeat_interval,delete a.heartbeat_interval),A.trigger("heartbeat-tick",[a,b,c]),d&&v(d),void 0)):(g("empty"),void 0)}).fail(function(a,b,c){g(b||"unknown",a.status),A.trigger("heartbeat-error",[a,b,c])}))}function j(){var a=e()-B.lastTick,c=B.mainInterval;B.suspend||(B.hasFocus?B.countdown>0&&B.tempInterval&&(c=B.tempInterval,B.countdown--,B.countdown<1&&(B.tempInterval=0)):c=12e4,b.clearTimeout(B.beatTimer),c>a?B.beatTimer=b.setTimeout(function(){i()},c-a):i())}function k(){o(),B.hasFocus=!1}function l(){o(),B.userActivity=e(),B.suspend=!1,B.hasFocus||(B.hasFocus=!0,j())}function m(){a("iframe").each(function(c,d){f(d)&&(a.data(d,"wp-heartbeat-focus")||(a.data(d,"wp-heartbeat-focus",1),a(d.contentWindow).on("focus.wp-heartbeat-focus",function(){l()}).on("blur.wp-heartbeat-focus",function(){m(),B.frameBlurTimer=b.setTimeout(function(){k()},500)})))})}function n(){a("iframe").each(function(b,c){f(c)&&(a.removeData(c,"wp-heartbeat-focus"),a(c.contentWindow).off(".wp-heartbeat-focus"))})}function o(){b.clearTimeout(B.winBlurTimer),b.clearTimeout(B.frameBlurTimer)}function p(){B.userActivityEvents=!1,A.off(".wp-heartbeat-active"),a("iframe").each(function(b,c){f(c)&&a(c.contentWindow).off(".wp-heartbeat-active")}),l()}function q(){var b=B.userActivity?e()-B.userActivity:0;b>3e5&&B.hasFocus&&k(),B.suspendEnabled&&b>12e5&&(B.suspend=!0),B.userActivityEvents||(A.on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active",function(){p()}),a("iframe").each(function(b,c){f(c)&&a(c.contentWindow).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active",function(){p()})}),B.userActivityEvents=!0)}function r(){return B.hasFocus}function s(){return B.connectionError}function t(){B.lastTick=0,j()}function u(){B.suspendEnabled=!1}function v(a,b){var c,d=B.tempInterval?B.tempInterval:B.mainInterval;if(a){switch(a){case"fast":case 5:c=5e3;break;case 15:c=15e3;break;case 30:c=3e4;break;case 60:c=6e4;break;case"long-polling":return B.mainInterval=0,0;default:c=B.originalInterval}5e3===c?(b=parseInt(b,10)||30,b=1>b||b>30?30:b,B.countdown=b,B.tempInterval=c):(B.countdown=0,B.tempInterval=0,B.mainInterval=c),c!==d&&j()}return B.tempInterval?B.tempInterval/1e3:B.mainInterval/1e3}function w(a,b,c){return a?c&&this.isQueued(a)?!1:(B.queue[a]=b,!0):!1}function x(a){return a?B.queue.hasOwnProperty(a):void 0}function y(a){a&&delete B.queue[a]}function z(a){return a?this.isQueued(a)?B.queue[a]:c:void 0}var A=a(document),B={suspend:!1,suspendEnabled:!0,screenId:"",url:"",lastTick:0,queue:{},mainInterval:60,tempInterval:0,originalInterval:0,countdown:0,connecting:!1,connectionError:!1,errorcount:0,hasConnected:!1,hasFocus:!0,userActivity:0,userActivityEvents:!1,beatTimer:0,winBlurTimer:0,frameBlurTimer:0};return d(),{hasFocus:r,connectNow:t,disableSuspend:u,interval:v,hasConnectionError:s,enqueue:w,dequeue:y,isQueued:x,getQueuedItem:z}};b.wp=b.wp||{},b.wp.heartbeat=new d}(jQuery,window);
\ No newline at end of file