]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/heartbeat.min.js
Wordpress 3.7
[autoinstalls/wordpress.git] / wp-includes / js / heartbeat.min.js
index 215802869fe6e040907af7c3b2c872b352771d69..81039d4f9f8b01e1f1531f1d36e825c473ef83a7 100644 (file)
@@ -1 +1 @@
-window.wp=window.wp||{};(function(a){var b=function(){var t=this,e,c,q=typeof pagenow!="undefined"?pagenow:"",h=typeof ajaxurl!="undefined"?ajaxurl:"",C,B=0,x={},D,i,r=0,A=0,y,f=true,p,j,g,w=-1,l=false;this.hasConnectionError=function(){return l};if(typeof(window.heartbeatSettings)=="object"){C=a.extend({},window.heartbeatSettings);h=C.ajaxurl||h;delete C.ajaxurl;delete C.nonce;D=C.interval||15;delete C.interval;if(D<15){D=15}else{if(D>60){D=60}}D=D*1000;q=q||C.screenId||"front";delete C.screenId;a.extend(this,C)}function k(F){if(F){return parseInt((new Date()).getTime()/1000)}return(new Date()).getTime()}function z(I){var F,H=I.src;if(H&&/^https?:\/\//.test(H)){F=window.location.origin?window.location.origin:window.location.protocol+"//"+window.location.host;if(H.indexOf(F)!==0){return false}}try{if(I.contentWindow.document){return true}}catch(G){}return false}function v(G){var F;if(G){switch(G){case"abort":break;case"timeout":F=true;break;case"parsererror":case"error":case"empty":case"unknown":A++;if(A>2){F=true}break}if(F&&!t.hasConnectionError()){l=true;a(document).trigger("heartbeat-connection-lost",[G])}}else{if(t.hasConnectionError()){A=0;l=false;a(document).trigger("heartbeat-connection-restored")}}}function d(){var J={},I,F,H=true,G=typeof window.heartbeatSettings=="object"?window.heartbeatSettings.nonce:"";B=k();I=a.extend({},x);x={};a(document).trigger("heartbeat-send",[I]);for(F in I){if(I.hasOwnProperty(F)){H=false;break}}if(H&&!t.hasConnectionError()){i=false;u();return}J.data=I;J.interval=D/1000;J._nonce=G;J.action="heartbeat";J.screen_id=q;J.has_focus=f;i=true;t.xhr=a.ajax({url:h,type:"post",timeout:30000,data:J,dataType:"json"}).done(function(K,N,L){var M;if(!K){return v("empty")}if(t.hasConnectionError()){v()}if(K.nonces_expired){a(document).trigger("heartbeat-nonces-expired");return}if(K.heartbeat_interval){M=K.heartbeat_interval;delete K.heartbeat_interval}t.tick(K,N,L);if(M){t.interval.call(t,M)}}).always(function(){i=false;u()}).fail(function(L,M,K){v(M||"unknown");t.error(L,M,K)})}function u(){var G=k()-B,F=D;if(!e){return}if(!f){F=100000}else{if(r>0&&y){F=y;r--}}window.clearTimeout(c);if(G<F){c=window.setTimeout(function(){if(e){d()}},F-G)}else{d()}}function o(){window.clearTimeout(g);window.clearTimeout(w);g=w=0;f=false}function n(){window.clearTimeout(g);window.clearTimeout(w);g=w=0;p=k();if(f){return}f=true;window.clearTimeout(c);if(!i){u()}}function s(){a("iframe").each(function(F,G){if(!z(G)){return}if(a.data(G,"wp-heartbeat-focus")){return}a.data(G,"wp-heartbeat-focus",1);a(G.contentWindow).on("focus.wp-heartbeat-focus",function(H){n()}).on("blur.wp-heartbeat-focus",function(H){s();w=window.setTimeout(function(){o()},500)})})}a(window).on("blur.wp-heartbeat-focus",function(F){s();g=window.setTimeout(function(){o()},500)}).on("focus.wp-heartbeat-focus",function(){a("iframe").each(function(F,G){if(!z(G)){return}a.removeData(G,"wp-heartbeat-focus");a(G.contentWindow).off(".wp-heartbeat-focus")});n()});function E(){j=false;a(document).off(".wp-heartbeat-active");a("iframe").each(function(F,G){if(!z(G)){return}a(G.contentWindow).off(".wp-heartbeat-active")});n()}function m(){var F=p?k()-p:0;if(F>300000&&f){o()}if(!j){a(document).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active",function(){E()});a("iframe").each(function(G,H){if(!z(H)){return}a(H.contentWindow).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active",function(){E()})});j=true}}window.setInterval(function(){m()},30000);a(document).ready(function(){e=true;B=k();u()});this.hasFocus=function(){return f};this.interval=function(H,G){var F,I;G=parseInt(G,10)||30;G=G<1||G>30?30:G;if(H){switch(H){case"fast":I=5;r=G;break;case"slow":I=60;r=0;break;case"long-polling":D=0;return 0;break;default:I=15;r=0}F=I*1000<D;if(r>0){y=I*1000}else{D=I*1000;y=0}if(F){u()}}if(!f){return 120}return y?y/1000:D/1000};this.enqueue=function(H,G,F){if(H){if(x.hasOwnProperty(H)&&F){return false}x[H]=G;return true}return false};this.isQueued=function(F){return x[F]}};a.extend(b.prototype,{tick:function(d,e,c){a(document).trigger("heartbeat-tick",[d,e,c])},error:function(d,e,c){a(document).trigger("heartbeat-error",[d,e,c])}});wp.heartbeat=new b()}(jQuery));
\ No newline at end of file
+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