@wibetter/json-editor 3.5.10 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/lib/index.css +7 -0
- package/lib/index.js +2 -0
- package/lib/index.js.LICENSE.txt +7 -0
- package/package.json +16 -16
- package/dist/index.css +0 -7
- package/dist/index.umd.js +0 -328
- package/public/css/base.css +0 -283
- package/public/css/text-editor.min.css +0 -1
- package/public/img/loadding.gif +0 -0
- package/public/scripts/app/bluebird.js +0 -5619
- package/public/scripts/app/flexible.js +0 -1
- package/public/scripts/app/scrollToBottom.js +0 -72
- package/public/scripts/app/visibility.js +0 -345
- package/public/scripts/lib/jquery.11.3.min.js +0 -6
- package/public/scss/text-editor.scss +0 -130
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(n,t){function e(n){var t=parseFloat(n)*u;return"string"==typeof n&&n.match(/rem$/)&&(t+="px"),t}function i(n){var t=parseFloat(n)/u;return"string"==typeof n&&n.match(/px$/)&&(t+="rem"),t}function o(){var t=s.getBoundingClientRect(),e=t.width,o=s.clientHeight;d.maxAspectRatio!==1/0&&d.maxAspectRatio<e/o&&(e=o),e=Math.min(e,d.maxWidth),u=100*e/d.designWidth,s.style.fontSize=u+"px";var r=n.getComputedStyle(s)["font-size"].replace(/px/gi,"");u!==r&&(s.style.fontSize=u*u/r+"px"),d.rem=u,d.info={dpr:c,rem:u,width:e,height:o,remWidth:i(e),remHeight:i(o)};for(var a=0,p=f.length;a<p;a++)f[a](d.info)}var r,a=n.document,s=a.documentElement,c=0,u="12px",f=[],d=t.flexible||(t.flexible={});d.info={},d.resize=function(n){f.push(n),n(d.info)};var p=n.navigator.appVersion.match(/iphone/gi),l=n.devicePixelRatio;c=p?l>=3&&(!c||c>=3)?3:l>=2&&(!c||c>=2)?2:1:1,d.dpr=n.dpr=c,d.refreshRem=o,d.rem2px=e,d.px2rem=i,d.init=function(t){var e={designWidth:750,maxWidth:1/0,maxAspectRatio:1/0};t=t||{};for(var i in e)d[i]=t[i]||e[i];s.setAttribute("data-dpr",c),"complete"===a.readyState?a.body.style.fontSize="12px":a.addEventListener("DOMContentLoaded",function(){a.body.style.fontSize="12px"},!1);var u="onorientationchange"in window?"orientationchange":"resize";n.addEventListener(u,function(){clearTimeout(r),r=setTimeout(o,100)},!1),n.addEventListener("pageshow",function(n){n.persisted&&(clearTimeout(r),r=setTimeout(o,100))},!1),o()}}(window,window.PAGECTRL||(window.PAGECTRL={})),function(n,t){function e(n,t,e,i){var o=n._historyData;o[t]=o[t]||[],o[t].push(e),i&&(i.done&&i.historyDataLength<1&&(i.historyDataLength=1),o[t].length>i.historyDataLength&&o[t].splice(0,o[t].length-i.historyDataLength))}function i(n,t){return n.hasOwnProperty(t)}function o(n,t,e){var i=n._historyData;if(e.done&&i[t])for(var o=i[t],r=0,s=o.length;r<s;r++){var c=o[r];a(n,t,c,e)}}function r(){this.clear()}var a=function(n,t,e,i){var o=n._historyData;i.listener.apply(i.context,[e,o[t]]),i.once&&n.off(t,i.listener)};r.prototype={clear:function(){var n=this;n._optionsMap={},n._historyData={}},on:function(n,t,e){var r=this,a=r._optionsMap;e=e||{};var s={done:!1,historyDataLength:0,context:r,once:!1,listener:t};for(var c in s)i(e,c)||(e[c]=s[c]);a[n]=a[n]||[],a[n].push(e),o(r,n,e)},once:function(n,t,e){var i=this;e=e||{},e.once=!0,i.on(n,t,e)},off:function(n,t){var e=this,o=e._optionsMap;if(void 0===t)delete o[n];else if(i(e._optionsMap,n)){for(var r=o[n],a=[],s=r.length;s--;)r[s].listener!==t&&a.unshift(r[s]);o[n]=a}},trigger:function(n,t){var o,r=this,s=r._optionsMap;if(i(r._optionsMap,n)){var c=s[n];e(r,n,t,c[0]);for(var u=0,f=c.length;u<f;u++)o=c[u],a(r,n,t,o)}else e(r,n,t,o)}},t.Event=t,t.event=new r}(window,window.PAGECTRL||(window.PAGECTRL={})),function(n,t){var e=function(){if(!/micromessenger/i.test(navigator.userAgent))return function(){};var n,t,e=function(){function n(n,t){for(var e=0,i=n.length;e<i;++e)if(!t(n[e]))return c;return 1}function t(t,e){n(t,function(n){return e(n),1})}function e(r,a,s){function c(n){return n.call?n():p[n]}function f(){if(!--w){p[v]=1,m&&m();for(var e in h)n(e.split("|"),c)&&!t(h[e],c)&&(h[e]=[])}}r=r[u]?r:[r];var d=a&&a.call,m=d?a:s,v=d?r.join(""):a,w=r.length;return setTimeout(function(){t(r,function n(t,e){return null===t?f():(e||/^https?:\/\//.test(t)||!o||(t=-1===t.indexOf(".js")?o+t+".js":o+t),g[t]?(v&&(l[v]=1),2==g[t]?f():setTimeout(function(){n(t,!0)},0)):(g[t]=1,v&&(l[v]=1),void i(t,f)))})},0),e}function i(n,t){var e,i=a.createElement("script");i.onload=i.onerror=i[d]=function(){i[f]&&!/^c|loade/.test(i[f])||e||(i.onload=i[d]=null,e=1,g[n]=2,t())},i.async=1,i.src=r?n+(-1===n.indexOf("?")?"?":"&")+r:n,s.insertBefore(i,s.lastChild)}var o,r,a=document,s=a.getElementsByTagName("head")[0],c=!1,u="push",f="readyState",d="onreadystatechange",p={},l={},h={},g={};return e.get=i,e.order=function(n,t,i){!function o(r){r=n.shift(),n.length?e(r,o):e(r,t,i)}()},e.path=function(n){o=n},e.urlArgs=function(n){r=n},e.ready=function(i,o,r){i=i[u]?i:[i];var a=[];return!t(i,function(n){p[n]||a[u](n)})&&n(i,function(n){return p[n]})?o():function(n){h[n]=h[n]||[],h[n][u](o),r&&r(a)}(i.join("|")),e},e.done=function(n){e([null],n)},e}(),i=!1,o="cb_3eb0d6a6_7dae_e792_47d6_379feae19526",r=document.location.protocol,a=[r+"//mp.sina.cn/aj/wechat/gettoken?callback="+o+"&url="+encodeURIComponent(window.location.href),r+"//res.wx.qq.com/open/js/jweixin-1.0.0.js"];return function(r){function s(e){t=e,i=!0,"function"==typeof r?r(t,n):(t.config({appId:n.appid,timestamp:n.time,nonceStr:n.nonceStr,signature:n.signature,jsApiList:["onMenuShareAppMessage","onMenuShareTimeline","onMenuShareQQ"]}),t.ready(function(){t.onMenuShareAppMessage(r),t.onMenuShareTimeline(r),t.onMenuShareQQ(r)}))}window[o]=function(t){n=t.data},i?s(t):"function"==typeof define&&"function"==typeof require&&define.amd?require(a,function(n,t){s(t)}):(e(a,"all"),e.ready("all",function(){s(wx)}))}}();t.wxReady=e}(window,window.PAGECTRL||(window.PAGECTRL={})),function(n,t){var e=window.navigator.userAgent.toLowerCase();t.viewInfo={ua:e,isSports:/sinasports?/i.test(e),isNews:/sinanews?/i.test(e),isWX:/micromessenger?/i.test(e)}}(window,window.PAGEDATA||(window.PAGEDATA={}));
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
scrollToBottom({
|
|
3
|
-
container: window,
|
|
4
|
-
target: '#j_demo',
|
|
5
|
-
triggerDistance: 0,
|
|
6
|
-
callBack: function(){
|
|
7
|
-
// 滚动到底部了
|
|
8
|
-
},
|
|
9
|
-
time: 300
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
define( ['core', 'jQuery'], function(youYi ) {
|
|
14
|
-
'use strict';
|
|
15
|
-
var scrollToBottom = function( config ) {
|
|
16
|
-
var container = config.container || window;
|
|
17
|
-
var target = config.target;
|
|
18
|
-
var triggerDistance = config.triggerDistance || 0;
|
|
19
|
-
var callBack = config.callBack || $.noop;
|
|
20
|
-
var time = config.time || 300;
|
|
21
|
-
container = $( container );
|
|
22
|
-
target = $( target );
|
|
23
|
-
triggerDistance = triggerDistance || 0;
|
|
24
|
-
|
|
25
|
-
// var containerNode = container[0];
|
|
26
|
-
var timer;
|
|
27
|
-
var uuid = '_f35d0b75_5a21_0781_405a_b189f1f946c3';
|
|
28
|
-
|
|
29
|
-
function onScrollToBottom() {
|
|
30
|
-
|
|
31
|
-
/*var scrollHeight;
|
|
32
|
-
if (containerNode == window) {
|
|
33
|
-
scrollHeight = $(document).height();
|
|
34
|
-
} else {
|
|
35
|
-
scrollHeight = containerNode.scrollHeight;
|
|
36
|
-
}*/
|
|
37
|
-
var scrollTop = container.scrollTop();
|
|
38
|
-
if (scrollTop <= 0) return; // 判断当前是否有滚动
|
|
39
|
-
|
|
40
|
-
var scrollPosition = container.height() + scrollTop;
|
|
41
|
-
var bottomPosition = target.height() + target.offset().top;
|
|
42
|
-
if ( ( scrollPosition - bottomPosition ) + triggerDistance > 0 ) {
|
|
43
|
-
|
|
44
|
-
// 到达底部
|
|
45
|
-
if ( $.isFunction( callBack ) ) {
|
|
46
|
-
callBack();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
var stop = function() {
|
|
52
|
-
container.off( 'scroll.' + uuid );
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
var start = function() {
|
|
56
|
-
stop();
|
|
57
|
-
container.on( 'scroll.' + uuid, function() {
|
|
58
|
-
clearTimeout( timer );
|
|
59
|
-
timer = setTimeout( function() {
|
|
60
|
-
onScrollToBottom();
|
|
61
|
-
}, time );
|
|
62
|
-
} );
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
stop: stop,
|
|
67
|
-
start: start
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
youYi.scrollToBottom = scrollToBottom;
|
|
71
|
-
return scrollToBottom;
|
|
72
|
-
} );
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
window.visibility = (function() {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var lastId = -1;
|
|
5
|
-
|
|
6
|
-
// Visibility.js allow you to know, that your web page is in the background
|
|
7
|
-
// tab and thus not visible to the user. This library is wrap under
|
|
8
|
-
// Page Visibility API. It fix problems with different vendor prefixes and
|
|
9
|
-
// add high-level useful functions.
|
|
10
|
-
var self = {
|
|
11
|
-
|
|
12
|
-
// Call callback only when page become to visible for user or
|
|
13
|
-
// call it now if page is visible now or Page Visibility API
|
|
14
|
-
// doesn’t supported.
|
|
15
|
-
//
|
|
16
|
-
// Return false if API isn’t supported, true if page is already visible
|
|
17
|
-
// or listener ID (you can use it in `unbind` method) if page isn’t
|
|
18
|
-
// visible now.
|
|
19
|
-
//
|
|
20
|
-
// Visibility.onVisible(function () {
|
|
21
|
-
// startIntroAnimation();
|
|
22
|
-
// });
|
|
23
|
-
onVisible: function (callback) {
|
|
24
|
-
var support = self.isSupported();
|
|
25
|
-
if ( !support || !self.hidden() ) {
|
|
26
|
-
callback();
|
|
27
|
-
return support;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var listener = self.change(function (e, state) {
|
|
31
|
-
if ( !self.hidden() ) {
|
|
32
|
-
self.unbind(listener);
|
|
33
|
-
callback();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return listener;
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
// Call callback when visibility will be changed. First argument for
|
|
40
|
-
// callback will be original event object, second will be visibility
|
|
41
|
-
// state name.
|
|
42
|
-
//
|
|
43
|
-
// Return listener ID to unbind listener by `unbind` method.
|
|
44
|
-
//
|
|
45
|
-
// If Page Visibility API doesn’t supported method will be return false
|
|
46
|
-
// and callback never will be called.
|
|
47
|
-
//
|
|
48
|
-
// Visibility.change(function(e, state) {
|
|
49
|
-
// Statistics.visibilityChange(state);
|
|
50
|
-
// });
|
|
51
|
-
//
|
|
52
|
-
// It is just proxy to `visibilitychange` event, but use vendor prefix.
|
|
53
|
-
change: function (callback) {
|
|
54
|
-
if ( !self.isSupported() ) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
lastId += 1;
|
|
58
|
-
var number = lastId;
|
|
59
|
-
self._callbacks[number] = callback;
|
|
60
|
-
self._listen();
|
|
61
|
-
return number;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
// Remove `change` listener by it ID.
|
|
65
|
-
//
|
|
66
|
-
// var id = Visibility.change(function(e, state) {
|
|
67
|
-
// firstChangeCallback();
|
|
68
|
-
// Visibility.unbind(id);
|
|
69
|
-
// });
|
|
70
|
-
unbind: function (id) {
|
|
71
|
-
delete self._callbacks[id];
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
// Call `callback` in any state, expect “prerender”. If current state
|
|
75
|
-
// is “prerender” it will wait until state will be changed.
|
|
76
|
-
// If Page Visibility API doesn’t supported, it will call `callback`
|
|
77
|
-
// immediately.
|
|
78
|
-
//
|
|
79
|
-
// Return false if API isn’t supported, true if page is already after
|
|
80
|
-
// prerendering or listener ID (you can use it in `unbind` method)
|
|
81
|
-
// if page is prerended now.
|
|
82
|
-
//
|
|
83
|
-
// Visibility.afterPrerendering(function () {
|
|
84
|
-
// Statistics.countVisitor();
|
|
85
|
-
// });
|
|
86
|
-
afterPrerendering: function (callback) {
|
|
87
|
-
var support = self.isSupported();
|
|
88
|
-
var prerender = 'prerender';
|
|
89
|
-
|
|
90
|
-
if ( !support || prerender != self.state() ) {
|
|
91
|
-
callback();
|
|
92
|
-
return support;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
var listener = self.change(function (e, state) {
|
|
96
|
-
if ( prerender != state ) {
|
|
97
|
-
self.unbind(listener);
|
|
98
|
-
callback();
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
return listener;
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
// Return true if page now isn’t visible to user.
|
|
105
|
-
//
|
|
106
|
-
// if ( !Visibility.hidden() ) {
|
|
107
|
-
// VideoPlayer.play();
|
|
108
|
-
// }
|
|
109
|
-
//
|
|
110
|
-
// It is just proxy to `document.hidden`, but use vendor prefix.
|
|
111
|
-
hidden: function () {
|
|
112
|
-
return !!(self._doc.hidden || self._doc.webkitHidden);
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
// Return visibility state: 'visible', 'hidden' or 'prerender'.
|
|
116
|
-
//
|
|
117
|
-
// if ( 'prerender' == Visibility.state() ) {
|
|
118
|
-
// Statistics.pageIsPrerendering();
|
|
119
|
-
// }
|
|
120
|
-
//
|
|
121
|
-
// Don’t use `Visibility.state()` to detect, is page visible, because
|
|
122
|
-
// visibility states can extend in next API versions.
|
|
123
|
-
// Use more simpler and general `Visibility.hidden()` for this cases.
|
|
124
|
-
//
|
|
125
|
-
// It is just proxy to `document.visibilityState`, but use
|
|
126
|
-
// vendor prefix.
|
|
127
|
-
state: function () {
|
|
128
|
-
return self._doc.visibilityState ||
|
|
129
|
-
self._doc.webkitVisibilityState ||
|
|
130
|
-
'visible';
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
// Return true if browser support Page Visibility API.
|
|
134
|
-
//
|
|
135
|
-
// if ( Visibility.isSupported() ) {
|
|
136
|
-
// Statistics.startTrackingVisibility();
|
|
137
|
-
// Visibility.change(function(e, state)) {
|
|
138
|
-
// Statistics.trackVisibility(state);
|
|
139
|
-
// });
|
|
140
|
-
// }
|
|
141
|
-
isSupported: function () {
|
|
142
|
-
return !!(self._doc.visibilityState ||
|
|
143
|
-
self._doc.webkitVisibilityState);
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
// Link to document object to change it in tests.
|
|
147
|
-
_doc: document || {},
|
|
148
|
-
|
|
149
|
-
// Callbacks from `change` method, that wait visibility changes.
|
|
150
|
-
_callbacks: { },
|
|
151
|
-
|
|
152
|
-
// Listener for `visibilitychange` event.
|
|
153
|
-
_change: function(event) {
|
|
154
|
-
var state = self.state();
|
|
155
|
-
|
|
156
|
-
for ( var i in self._callbacks ) {
|
|
157
|
-
self._callbacks[i].call(self._doc, event, state);
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
// Set listener for `visibilitychange` event.
|
|
162
|
-
_listen: function () {
|
|
163
|
-
if ( self._init ) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
var event = 'visibilitychange';
|
|
168
|
-
if ( self._doc.webkitVisibilityState ) {
|
|
169
|
-
event = 'webkit' + event;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
var listener = function () {
|
|
173
|
-
self._change.apply(self, arguments);
|
|
174
|
-
};
|
|
175
|
-
if ( self._doc.addEventListener ) {
|
|
176
|
-
self._doc.addEventListener(event, listener);
|
|
177
|
-
} else {
|
|
178
|
-
self._doc.attachEvent(event, listener);
|
|
179
|
-
}
|
|
180
|
-
self._init = true;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// visibility.timers;
|
|
186
|
-
|
|
187
|
-
var lastTimer = -1;
|
|
188
|
-
|
|
189
|
-
var install = function (Visibility) {
|
|
190
|
-
|
|
191
|
-
// Run callback every `interval` milliseconds if page is visible and
|
|
192
|
-
// every `hiddenInterval` milliseconds if page is hidden.
|
|
193
|
-
//
|
|
194
|
-
// Visibility.every(60 * 1000, 5 * 60 * 1000, function () {
|
|
195
|
-
// checkNewMails();
|
|
196
|
-
// });
|
|
197
|
-
//
|
|
198
|
-
// You can skip `hiddenInterval` and callback will be called only if
|
|
199
|
-
// page is visible.
|
|
200
|
-
//
|
|
201
|
-
// Visibility.every(1000, function () {
|
|
202
|
-
// updateCountdown();
|
|
203
|
-
// });
|
|
204
|
-
//
|
|
205
|
-
// It is analog of `setInterval(callback, interval)` but use visibility
|
|
206
|
-
// state.
|
|
207
|
-
//
|
|
208
|
-
// It return timer ID, that you can use in `Visibility.stop(id)` to stop
|
|
209
|
-
// timer (`clearInterval` analog).
|
|
210
|
-
// Warning: timer ID is different from interval ID from `setInterval`,
|
|
211
|
-
// so don’t use it in `clearInterval`.
|
|
212
|
-
//
|
|
213
|
-
// On change state from hidden to visible timers will be execute.
|
|
214
|
-
Visibility.every = function (interval, hiddenInterval, callback) {
|
|
215
|
-
Visibility._time();
|
|
216
|
-
|
|
217
|
-
if ( !callback ) {
|
|
218
|
-
callback = hiddenInterval;
|
|
219
|
-
hiddenInterval = null;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
lastTimer += 1;
|
|
223
|
-
var number = lastTimer;
|
|
224
|
-
|
|
225
|
-
Visibility._timers[number] = {
|
|
226
|
-
visible: interval,
|
|
227
|
-
hidden: hiddenInterval,
|
|
228
|
-
callback: callback
|
|
229
|
-
};
|
|
230
|
-
Visibility._run(number, false);
|
|
231
|
-
|
|
232
|
-
if ( Visibility.isSupported() ) {
|
|
233
|
-
Visibility._listen();
|
|
234
|
-
}
|
|
235
|
-
return number;
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
// Stop timer from `every` method by it ID (`every` method return it).
|
|
239
|
-
//
|
|
240
|
-
// slideshow = Visibility.every(5 * 1000, function () {
|
|
241
|
-
// changeSlide();
|
|
242
|
-
// });
|
|
243
|
-
// $('.stopSlideshow').click(function () {
|
|
244
|
-
// Visibility.stop(slideshow);
|
|
245
|
-
// });
|
|
246
|
-
Visibility.stop = function(id) {
|
|
247
|
-
if ( !Visibility._timers[id] ) {
|
|
248
|
-
return false;
|
|
249
|
-
}
|
|
250
|
-
Visibility._stop(id);
|
|
251
|
-
delete Visibility._timers[id];
|
|
252
|
-
return true;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// Callbacks and intervals added by `every` method.
|
|
256
|
-
Visibility._timers = { };
|
|
257
|
-
|
|
258
|
-
// Initialize variables on page loading.
|
|
259
|
-
Visibility._time = function () {
|
|
260
|
-
if ( Visibility._timed ) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
Visibility._timed = true;
|
|
264
|
-
Visibility._wasHidden = Visibility.hidden();
|
|
265
|
-
|
|
266
|
-
Visibility.change(function () {
|
|
267
|
-
Visibility._stopRun();
|
|
268
|
-
Visibility._wasHidden = Visibility.hidden();
|
|
269
|
-
});
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
// Try to run timer from every method by it’s ID. It will be use
|
|
273
|
-
// `interval` or `hiddenInterval` depending on visibility state.
|
|
274
|
-
// If page is hidden and `hiddenInterval` is null,
|
|
275
|
-
// it will not run timer.
|
|
276
|
-
//
|
|
277
|
-
// Argument `runNow` say, that timers must be execute now too.
|
|
278
|
-
Visibility._run = function (id, runNow) {
|
|
279
|
-
var interval,
|
|
280
|
-
timer = Visibility._timers[id];
|
|
281
|
-
|
|
282
|
-
if ( Visibility.hidden() ) {
|
|
283
|
-
if ( null === timer.hidden ) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
interval = timer.hidden;
|
|
287
|
-
} else {
|
|
288
|
-
interval = timer.visible;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
var runner = function () {
|
|
292
|
-
timer.last = new Date();
|
|
293
|
-
timer.callback.call(window);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if ( runNow ) {
|
|
297
|
-
var now = new Date();
|
|
298
|
-
var last = now - timer.last ;
|
|
299
|
-
|
|
300
|
-
if ( interval > last ) {
|
|
301
|
-
timer.delay = setTimeout(function () {
|
|
302
|
-
timer.id = setInterval(runner, interval);
|
|
303
|
-
runner();
|
|
304
|
-
}, interval - last);
|
|
305
|
-
} else {
|
|
306
|
-
timer.id = setInterval(runner, interval);
|
|
307
|
-
runner();
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
} else {
|
|
311
|
-
timer.id = setInterval(runner, interval);
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
// Stop timer from `every` method by it’s ID.
|
|
316
|
-
Visibility._stop = function (id) {
|
|
317
|
-
var timer = Visibility._timers[id];
|
|
318
|
-
clearInterval(timer.id);
|
|
319
|
-
clearTimeout(timer.delay);
|
|
320
|
-
delete timer.id;
|
|
321
|
-
delete timer.delay;
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
// Listener for `visibilitychange` event.
|
|
325
|
-
Visibility._stopRun = function (event) {
|
|
326
|
-
var isHidden = Visibility.hidden(),
|
|
327
|
-
wasHidden = Visibility._wasHidden;
|
|
328
|
-
|
|
329
|
-
if ( (isHidden && !wasHidden) || (!isHidden && wasHidden) ) {
|
|
330
|
-
for ( var i in Visibility._timers ) {
|
|
331
|
-
Visibility._stop(i);
|
|
332
|
-
Visibility._run(i, !isHidden);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
return Visibility;
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
install( self );
|
|
341
|
-
|
|
342
|
-
var visibility = self;
|
|
343
|
-
|
|
344
|
-
return visibility;
|
|
345
|
-
})();
|