jquery_image_gallery 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/.idea/workspace.xml +265 -39
- data/app/assets/images/browser-icons.png +0 -0
- data/app/assets/javascripts/jquery_image_gallery.js +2775 -0
- data/app/assets/javascripts/jquery_image_gallery_initializer.js +178 -0
- data/app/assets/javascripts/jquery_image_gallery_main.js +1 -0
- data/app/assets/javascripts/jquery_image_gallery_slider.js +4198 -0
- data/app/assets/stylesheets/jquery_image_gallery.css +36 -0
- data/lib/jquery_image_gallery/version.rb +1 -1
- metadata +8 -2
@@ -0,0 +1,2775 @@
|
|
1
|
+
/*
|
2
|
+
* Jssor 19.0
|
3
|
+
* http://www.jssor.com/
|
4
|
+
*
|
5
|
+
* Licensed under the MIT license:
|
6
|
+
* http://www.opensource.org/licenses/MIT
|
7
|
+
*
|
8
|
+
* TERMS OF USE - Jssor
|
9
|
+
*
|
10
|
+
* Copyright 2014 Jssor
|
11
|
+
*
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
13
|
+
* a copy of this software and associated documentation files (the
|
14
|
+
* "Software"), to deal in the Software without restriction, including
|
15
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
16
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
17
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
18
|
+
* the following conditions:
|
19
|
+
*
|
20
|
+
* The above copyright notice and this permission notice shall be
|
21
|
+
* included in all copies or substantial portions of the Software.
|
22
|
+
*
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
27
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
28
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
29
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
30
|
+
*/
|
31
|
+
|
32
|
+
/*! Jssor */
|
33
|
+
|
34
|
+
//$JssorDebug$
|
35
|
+
var $JssorDebug$ = new function () {
|
36
|
+
|
37
|
+
this.$DebugMode = true;
|
38
|
+
|
39
|
+
// Methods
|
40
|
+
|
41
|
+
this.$Log = function (msg, important) {
|
42
|
+
var console = window.console || {};
|
43
|
+
var debug = this.$DebugMode;
|
44
|
+
|
45
|
+
if (debug && console.log) {
|
46
|
+
console.log(msg);
|
47
|
+
} else if (debug && important) {
|
48
|
+
alert(msg);
|
49
|
+
}
|
50
|
+
};
|
51
|
+
|
52
|
+
this.$Error = function (msg, e) {
|
53
|
+
var console = window.console || {};
|
54
|
+
var debug = this.$DebugMode;
|
55
|
+
|
56
|
+
if (debug && console.error) {
|
57
|
+
console.error(msg);
|
58
|
+
} else if (debug) {
|
59
|
+
alert(msg);
|
60
|
+
}
|
61
|
+
|
62
|
+
if (debug) {
|
63
|
+
// since we're debugging, fail fast by crashing
|
64
|
+
throw e || new Error(msg);
|
65
|
+
}
|
66
|
+
};
|
67
|
+
|
68
|
+
this.$Fail = function (msg) {
|
69
|
+
throw new Error(msg);
|
70
|
+
};
|
71
|
+
|
72
|
+
this.$Assert = function (value, msg) {
|
73
|
+
var debug = this.$DebugMode;
|
74
|
+
if (debug) {
|
75
|
+
if (!value)
|
76
|
+
throw new Error("Assert failed " + msg || "");
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
this.$Trace = function (msg) {
|
81
|
+
var console = window.console || {};
|
82
|
+
var debug = this.$DebugMode;
|
83
|
+
|
84
|
+
if (debug && console.log) {
|
85
|
+
console.log(msg);
|
86
|
+
}
|
87
|
+
};
|
88
|
+
|
89
|
+
this.$Execute = function (func) {
|
90
|
+
var debug = this.$DebugMode;
|
91
|
+
if (debug)
|
92
|
+
func();
|
93
|
+
};
|
94
|
+
|
95
|
+
this.$LiveStamp = function (obj, id) {
|
96
|
+
var debug = this.$DebugMode;
|
97
|
+
if (debug) {
|
98
|
+
var stamp = document.createElement("DIV");
|
99
|
+
stamp.setAttribute("id", id);
|
100
|
+
|
101
|
+
obj.$Live = stamp;
|
102
|
+
}
|
103
|
+
};
|
104
|
+
|
105
|
+
this.$C_AbstractProperty = function () {
|
106
|
+
/// <summary>
|
107
|
+
/// Tells compiler the property is abstract, it should be implemented by subclass.
|
108
|
+
/// </summary>
|
109
|
+
|
110
|
+
throw new Error("The property is abstract, it should be implemented by subclass.");
|
111
|
+
};
|
112
|
+
|
113
|
+
this.$C_AbstractMethod = function () {
|
114
|
+
/// <summary>
|
115
|
+
/// Tells compiler the method is abstract, it should be implemented by subclass.
|
116
|
+
/// </summary>
|
117
|
+
|
118
|
+
throw new Error("The method is abstract, it should be implemented by subclass.");
|
119
|
+
};
|
120
|
+
|
121
|
+
function C_AbstractClass(instance) {
|
122
|
+
/// <summary>
|
123
|
+
/// Tells compiler the class is abstract, it should be implemented by subclass.
|
124
|
+
/// </summary>
|
125
|
+
|
126
|
+
if (instance.constructor === C_AbstractClass.caller)
|
127
|
+
throw new Error("Cannot create instance of an abstract class.");
|
128
|
+
}
|
129
|
+
|
130
|
+
this.$C_AbstractClass = C_AbstractClass;
|
131
|
+
};
|
132
|
+
|
133
|
+
//$JssorEasing$
|
134
|
+
var $JssorEasing$ = window.$JssorEasing$ = {
|
135
|
+
$EaseSwing: function (t) {
|
136
|
+
return -Math.cos(t * Math.PI) / 2 + .5;
|
137
|
+
},
|
138
|
+
$EaseLinear: function (t) {
|
139
|
+
return t;
|
140
|
+
},
|
141
|
+
$EaseInQuad: function (t) {
|
142
|
+
return t * t;
|
143
|
+
},
|
144
|
+
$EaseOutQuad: function (t) {
|
145
|
+
return -t * (t - 2);
|
146
|
+
},
|
147
|
+
$EaseInOutQuad: function (t) {
|
148
|
+
return (t *= 2) < 1 ? 1 / 2 * t * t : -1 / 2 * (--t * (t - 2) - 1);
|
149
|
+
},
|
150
|
+
$EaseInCubic: function (t) {
|
151
|
+
return t * t * t;
|
152
|
+
},
|
153
|
+
$EaseOutCubic: function (t) {
|
154
|
+
return (t -= 1) * t * t + 1;
|
155
|
+
},
|
156
|
+
$EaseInOutCubic: function (t) {
|
157
|
+
return (t *= 2) < 1 ? 1 / 2 * t * t * t : 1 / 2 * ((t -= 2) * t * t + 2);
|
158
|
+
},
|
159
|
+
$EaseInQuart: function (t) {
|
160
|
+
return t * t * t * t;
|
161
|
+
},
|
162
|
+
$EaseOutQuart: function (t) {
|
163
|
+
return -((t -= 1) * t * t * t - 1);
|
164
|
+
},
|
165
|
+
$EaseInOutQuart: function (t) {
|
166
|
+
return (t *= 2) < 1 ? 1 / 2 * t * t * t * t : -1 / 2 * ((t -= 2) * t * t * t - 2);
|
167
|
+
},
|
168
|
+
$EaseInQuint: function (t) {
|
169
|
+
return t * t * t * t * t;
|
170
|
+
},
|
171
|
+
$EaseOutQuint: function (t) {
|
172
|
+
return (t -= 1) * t * t * t * t + 1;
|
173
|
+
},
|
174
|
+
$EaseInOutQuint: function (t) {
|
175
|
+
return (t *= 2) < 1 ? 1 / 2 * t * t * t * t * t : 1 / 2 * ((t -= 2) * t * t * t * t + 2);
|
176
|
+
},
|
177
|
+
$EaseInSine: function (t) {
|
178
|
+
return 1 - Math.cos(t * Math.PI / 2);
|
179
|
+
},
|
180
|
+
$EaseOutSine: function (t) {
|
181
|
+
return Math.sin(t * Math.PI / 2);
|
182
|
+
},
|
183
|
+
$EaseInOutSine: function (t) {
|
184
|
+
return -1 / 2 * (Math.cos(Math.PI * t) - 1);
|
185
|
+
},
|
186
|
+
$EaseInExpo: function (t) {
|
187
|
+
return t == 0 ? 0 : Math.pow(2, 10 * (t - 1));
|
188
|
+
},
|
189
|
+
$EaseOutExpo: function (t) {
|
190
|
+
return t == 1 ? 1 : -Math.pow(2, -10 * t) + 1;
|
191
|
+
},
|
192
|
+
$EaseInOutExpo: function (t) {
|
193
|
+
return t == 0 || t == 1 ? t : (t *= 2) < 1 ? 1 / 2 * Math.pow(2, 10 * (t - 1)) : 1 / 2 * (-Math.pow(2, -10 * --t) + 2);
|
194
|
+
},
|
195
|
+
$EaseInCirc: function (t) {
|
196
|
+
return -(Math.sqrt(1 - t * t) - 1);
|
197
|
+
},
|
198
|
+
$EaseOutCirc: function (t) {
|
199
|
+
return Math.sqrt(1 - (t -= 1) * t);
|
200
|
+
},
|
201
|
+
$EaseInOutCirc: function (t) {
|
202
|
+
return (t *= 2) < 1 ? -1 / 2 * (Math.sqrt(1 - t * t) - 1) : 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1);
|
203
|
+
},
|
204
|
+
$EaseInElastic: function (t) {
|
205
|
+
if (!t || t == 1)
|
206
|
+
return t;
|
207
|
+
var p = .3, s = .075;
|
208
|
+
return -(Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * 2 * Math.PI / p));
|
209
|
+
},
|
210
|
+
$EaseOutElastic: function (t) {
|
211
|
+
if (!t || t == 1)
|
212
|
+
return t;
|
213
|
+
var p = .3, s = .075;
|
214
|
+
return Math.pow(2, -10 * t) * Math.sin((t - s) * 2 * Math.PI / p) + 1;
|
215
|
+
},
|
216
|
+
$EaseInOutElastic: function (t) {
|
217
|
+
if (!t || t == 1)
|
218
|
+
return t;
|
219
|
+
var p = .45, s = .1125;
|
220
|
+
return (t *= 2) < 1 ? -.5 * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * 2 * Math.PI / p) : Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * 2 * Math.PI / p) * .5 + 1;
|
221
|
+
},
|
222
|
+
$EaseInBack: function (t) {
|
223
|
+
var s = 1.70158;
|
224
|
+
return t * t * ((s + 1) * t - s);
|
225
|
+
},
|
226
|
+
$EaseOutBack: function (t) {
|
227
|
+
var s = 1.70158;
|
228
|
+
return (t -= 1) * t * ((s + 1) * t + s) + 1;
|
229
|
+
},
|
230
|
+
$EaseInOutBack: function (t) {
|
231
|
+
var s = 1.70158;
|
232
|
+
return (t *= 2) < 1 ? 1 / 2 * t * t * (((s *= 1.525) + 1) * t - s) : 1 / 2 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2);
|
233
|
+
},
|
234
|
+
$EaseInBounce: function (t) {
|
235
|
+
return 1 - $JssorEasing$.$EaseOutBounce(1 - t)
|
236
|
+
},
|
237
|
+
$EaseOutBounce: function (t) {
|
238
|
+
return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
|
239
|
+
},
|
240
|
+
$EaseInOutBounce: function (t) {
|
241
|
+
return t < 1 / 2 ? $JssorEasing$.$EaseInBounce(t * 2) * .5 : $JssorEasing$.$EaseOutBounce(t * 2 - 1) * .5 + .5;
|
242
|
+
},
|
243
|
+
$EaseGoBack: function (t) {
|
244
|
+
return 1 - Math.abs((t *= 2) - 1);
|
245
|
+
},
|
246
|
+
$EaseInWave: function (t) {
|
247
|
+
return 1 - Math.cos(t * Math.PI * 2)
|
248
|
+
},
|
249
|
+
$EaseOutWave: function (t) {
|
250
|
+
return Math.sin(t * Math.PI * 2);
|
251
|
+
},
|
252
|
+
$EaseOutJump: function (t) {
|
253
|
+
return 1 - (((t *= 2) < 1) ? (t = 1 - t) * t * t : (t -= 1) * t * t);
|
254
|
+
},
|
255
|
+
$EaseInJump: function (t) {
|
256
|
+
return ((t *= 2) < 1) ? t * t * t : (t = 2 - t) * t * t;
|
257
|
+
}
|
258
|
+
};
|
259
|
+
|
260
|
+
var $JssorDirection$ = window.$JssorDirection$ = {
|
261
|
+
$TO_LEFT: 0x0001,
|
262
|
+
$TO_RIGHT: 0x0002,
|
263
|
+
$TO_TOP: 0x0004,
|
264
|
+
$TO_BOTTOM: 0x0008,
|
265
|
+
$HORIZONTAL: 0x0003,
|
266
|
+
$VERTICAL: 0x000C,
|
267
|
+
//$LEFTRIGHT: 0x0003,
|
268
|
+
//$TOPBOTOM: 0x000C,
|
269
|
+
//$TOPLEFT: 0x0005,
|
270
|
+
//$TOPRIGHT: 0x0006,
|
271
|
+
//$BOTTOMLEFT: 0x0009,
|
272
|
+
//$BOTTOMRIGHT: 0x000A,
|
273
|
+
//$AROUND: 0x000F,
|
274
|
+
|
275
|
+
$GetDirectionHorizontal: function (direction) {
|
276
|
+
return direction & 0x0003;
|
277
|
+
},
|
278
|
+
$GetDirectionVertical: function (direction) {
|
279
|
+
return direction & 0x000C;
|
280
|
+
},
|
281
|
+
//$ChessHorizontal: function (direction) {
|
282
|
+
// return (~direction & 0x0003) + (direction & 0x000C);
|
283
|
+
//},
|
284
|
+
//$ChessVertical: function (direction) {
|
285
|
+
// return (~direction & 0x000C) + (direction & 0x0003);
|
286
|
+
//},
|
287
|
+
//$IsToLeft: function (direction) {
|
288
|
+
// return (direction & 0x0003) == 0x0001;
|
289
|
+
//},
|
290
|
+
//$IsToRight: function (direction) {
|
291
|
+
// return (direction & 0x0003) == 0x0002;
|
292
|
+
//},
|
293
|
+
//$IsToTop: function (direction) {
|
294
|
+
// return (direction & 0x000C) == 0x0004;
|
295
|
+
//},
|
296
|
+
//$IsToBottom: function (direction) {
|
297
|
+
// return (direction & 0x000C) == 0x0008;
|
298
|
+
//},
|
299
|
+
$IsHorizontal: function (direction) {
|
300
|
+
return direction & 0x0003;
|
301
|
+
},
|
302
|
+
$IsVertical: function (direction) {
|
303
|
+
return direction & 0x000C;
|
304
|
+
}
|
305
|
+
};
|
306
|
+
|
307
|
+
var $JssorKeyCode$ = {
|
308
|
+
$BACKSPACE: 8,
|
309
|
+
$COMMA: 188,
|
310
|
+
$DELETE: 46,
|
311
|
+
$DOWN: 40,
|
312
|
+
$END: 35,
|
313
|
+
$ENTER: 13,
|
314
|
+
$ESCAPE: 27,
|
315
|
+
$HOME: 36,
|
316
|
+
$LEFT: 37,
|
317
|
+
$NUMPAD_ADD: 107,
|
318
|
+
$NUMPAD_DECIMAL: 110,
|
319
|
+
$NUMPAD_DIVIDE: 111,
|
320
|
+
$NUMPAD_ENTER: 108,
|
321
|
+
$NUMPAD_MULTIPLY: 106,
|
322
|
+
$NUMPAD_SUBTRACT: 109,
|
323
|
+
$PAGE_DOWN: 34,
|
324
|
+
$PAGE_UP: 33,
|
325
|
+
$PERIOD: 190,
|
326
|
+
$RIGHT: 39,
|
327
|
+
$SPACE: 32,
|
328
|
+
$TAB: 9,
|
329
|
+
$UP: 38
|
330
|
+
};
|
331
|
+
|
332
|
+
// $Jssor$ is a static class, so make it singleton instance
|
333
|
+
var $Jssor$ = window.$Jssor$ = new function () {
|
334
|
+
var _This = this;
|
335
|
+
|
336
|
+
//#region Constants
|
337
|
+
var REGEX_WHITESPACE_GLOBAL = /\S+/g;
|
338
|
+
var ROWSER_OTHER = -1;
|
339
|
+
var ROWSER_UNKNOWN = 0;
|
340
|
+
var BROWSER_IE = 1;
|
341
|
+
var BROWSER_FIREFOX = 2;
|
342
|
+
var BROWSER_SAFARI = 3;
|
343
|
+
var BROWSER_CHROME = 4;
|
344
|
+
var BROWSER_OPERA = 5;
|
345
|
+
//var arrActiveX = ["Msxml2.XMLHTTP", "Msxml3.XMLHTTP", "Microsoft.XMLHTTP"];
|
346
|
+
//#endregion
|
347
|
+
|
348
|
+
//#region Variables
|
349
|
+
var _Device;
|
350
|
+
var _Browser = 0;
|
351
|
+
var _BrowserRuntimeVersion = 0;
|
352
|
+
var _BrowserEngineVersion = 0;
|
353
|
+
var _BrowserJavascriptVersion = 0;
|
354
|
+
var _WebkitVersion = 0;
|
355
|
+
|
356
|
+
var _Navigator = navigator;
|
357
|
+
var _AppName = _Navigator.appName;
|
358
|
+
var _AppVersion = _Navigator.appVersion;
|
359
|
+
var _UserAgent = _Navigator.userAgent;
|
360
|
+
|
361
|
+
var _DocElmt = document.documentElement;
|
362
|
+
var _TransformProperty;
|
363
|
+
//#endregion
|
364
|
+
|
365
|
+
function Device() {
|
366
|
+
if (!_Device) {
|
367
|
+
_Device = { $Touchable: "ontouchstart" in window || "createTouch" in document };
|
368
|
+
|
369
|
+
var msPrefix;
|
370
|
+
if ((_Navigator.pointerEnabled || (msPrefix = _Navigator.msPointerEnabled))) {
|
371
|
+
_Device.$TouchActionAttr = msPrefix ? "msTouchAction" : "touchAction";
|
372
|
+
}
|
373
|
+
}
|
374
|
+
|
375
|
+
return _Device;
|
376
|
+
}
|
377
|
+
|
378
|
+
function DetectBrowser(browser) {
|
379
|
+
if (!_Browser) {
|
380
|
+
_Browser = -1;
|
381
|
+
|
382
|
+
if (_AppName == "Microsoft Internet Explorer" &&
|
383
|
+
!!window.attachEvent && !!window.ActiveXObject) {
|
384
|
+
|
385
|
+
var ieOffset = _UserAgent.indexOf("MSIE");
|
386
|
+
_Browser = BROWSER_IE;
|
387
|
+
_BrowserEngineVersion = ParseFloat(_UserAgent.substring(ieOffset + 5, _UserAgent.indexOf(";", ieOffset)));
|
388
|
+
|
389
|
+
//check IE javascript version
|
390
|
+
/*@cc_on
|
391
|
+
_BrowserJavascriptVersion = @_jscript_version;
|
392
|
+
@*/
|
393
|
+
|
394
|
+
// update: for intranet sites and compat view list sites, IE sends
|
395
|
+
// an IE7 User-Agent to the server to be interoperable, and even if
|
396
|
+
// the page requests a later IE version, IE will still report the
|
397
|
+
// IE7 UA to JS. we should be robust to self
|
398
|
+
//var docMode = document.documentMode;
|
399
|
+
//if (typeof docMode !== "undefined") {
|
400
|
+
// _BrowserRuntimeVersion = docMode;
|
401
|
+
//}
|
402
|
+
|
403
|
+
_BrowserRuntimeVersion = document.documentMode || _BrowserEngineVersion;
|
404
|
+
|
405
|
+
}
|
406
|
+
else if (_AppName == "Netscape" && !!window.addEventListener) {
|
407
|
+
|
408
|
+
var ffOffset = _UserAgent.indexOf("Firefox");
|
409
|
+
var saOffset = _UserAgent.indexOf("Safari");
|
410
|
+
var chOffset = _UserAgent.indexOf("Chrome");
|
411
|
+
var webkitOffset = _UserAgent.indexOf("AppleWebKit");
|
412
|
+
|
413
|
+
if (ffOffset >= 0) {
|
414
|
+
_Browser = BROWSER_FIREFOX;
|
415
|
+
_BrowserRuntimeVersion = ParseFloat(_UserAgent.substring(ffOffset + 8));
|
416
|
+
}
|
417
|
+
else if (saOffset >= 0) {
|
418
|
+
var slash = _UserAgent.substring(0, saOffset).lastIndexOf("/");
|
419
|
+
_Browser = (chOffset >= 0) ? BROWSER_CHROME : BROWSER_SAFARI;
|
420
|
+
_BrowserRuntimeVersion = ParseFloat(_UserAgent.substring(slash + 1, saOffset));
|
421
|
+
}
|
422
|
+
else {
|
423
|
+
//(/Trident.*rv[ :]*11\./i
|
424
|
+
var match = /Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/i.exec(_UserAgent);
|
425
|
+
if (match) {
|
426
|
+
_Browser = BROWSER_IE;
|
427
|
+
_BrowserRuntimeVersion = _BrowserEngineVersion = ParseFloat(match[1]);
|
428
|
+
}
|
429
|
+
}
|
430
|
+
|
431
|
+
if (webkitOffset >= 0)
|
432
|
+
_WebkitVersion = ParseFloat(_UserAgent.substring(webkitOffset + 12));
|
433
|
+
}
|
434
|
+
else {
|
435
|
+
var match = /(opera)(?:.*version|)[ \/]([\w.]+)/i.exec(_UserAgent);
|
436
|
+
if (match) {
|
437
|
+
_Browser = BROWSER_OPERA;
|
438
|
+
_BrowserRuntimeVersion = ParseFloat(match[2]);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
}
|
442
|
+
|
443
|
+
return browser == _Browser;
|
444
|
+
}
|
445
|
+
|
446
|
+
function IsBrowserIE() {
|
447
|
+
return DetectBrowser(BROWSER_IE);
|
448
|
+
}
|
449
|
+
|
450
|
+
function IsBrowserIeQuirks() {
|
451
|
+
return IsBrowserIE() && (_BrowserRuntimeVersion < 6 || document.compatMode == "BackCompat"); //Composite to "CSS1Compat"
|
452
|
+
}
|
453
|
+
|
454
|
+
function IsBrowserFireFox() {
|
455
|
+
return DetectBrowser(BROWSER_FIREFOX);
|
456
|
+
}
|
457
|
+
|
458
|
+
function IsBrowserSafari() {
|
459
|
+
return DetectBrowser(BROWSER_SAFARI);
|
460
|
+
}
|
461
|
+
|
462
|
+
function IsBrowserChrome() {
|
463
|
+
return DetectBrowser(BROWSER_CHROME);
|
464
|
+
}
|
465
|
+
|
466
|
+
function IsBrowserOpera() {
|
467
|
+
return DetectBrowser(BROWSER_OPERA);
|
468
|
+
}
|
469
|
+
|
470
|
+
function IsBrowserBadTransform() {
|
471
|
+
return IsBrowserSafari() && (_WebkitVersion > 534) && (_WebkitVersion < 535);
|
472
|
+
}
|
473
|
+
|
474
|
+
function IsBrowserIe9Earlier() {
|
475
|
+
return IsBrowserIE() && _BrowserRuntimeVersion < 9;
|
476
|
+
}
|
477
|
+
|
478
|
+
function GetTransformProperty(elmt) {
|
479
|
+
|
480
|
+
if (!_TransformProperty) {
|
481
|
+
// Note that in some versions of IE9 it is critical that
|
482
|
+
// msTransform appear in this list before MozTransform
|
483
|
+
|
484
|
+
Each(['transform', 'WebkitTransform', 'msTransform', 'MozTransform', 'OTransform'], function (property) {
|
485
|
+
if (elmt.style[property] != undefined) {
|
486
|
+
_TransformProperty = property;
|
487
|
+
return true;
|
488
|
+
}
|
489
|
+
});
|
490
|
+
|
491
|
+
_TransformProperty = _TransformProperty || "transform";
|
492
|
+
}
|
493
|
+
|
494
|
+
return _TransformProperty;
|
495
|
+
}
|
496
|
+
|
497
|
+
// Helpers
|
498
|
+
function getOffsetParent(elmt, isFixed) {
|
499
|
+
// IE and Opera "fixed" position elements don't have offset parents.
|
500
|
+
// regardless, if it's fixed, its offset parent is the body.
|
501
|
+
if (isFixed && elmt != document.body) {
|
502
|
+
return document.body;
|
503
|
+
} else {
|
504
|
+
return elmt.offsetParent;
|
505
|
+
}
|
506
|
+
}
|
507
|
+
|
508
|
+
function toString(obj) {
|
509
|
+
return {}.toString.call(obj);
|
510
|
+
}
|
511
|
+
|
512
|
+
// [[Class]] -> type pairs
|
513
|
+
var _Class2type;
|
514
|
+
|
515
|
+
function GetClass2Type() {
|
516
|
+
if (!_Class2type) {
|
517
|
+
_Class2type = {};
|
518
|
+
Each(["Boolean", "Number", "String", "Function", "Array", "Date", "RegExp", "Object"], function (name) {
|
519
|
+
_Class2type["[object " + name + "]"] = name.toLowerCase();
|
520
|
+
});
|
521
|
+
}
|
522
|
+
|
523
|
+
return _Class2type;
|
524
|
+
}
|
525
|
+
|
526
|
+
function Each(obj, callback) {
|
527
|
+
if (toString(obj) == "[object Array]") {
|
528
|
+
for (var i = 0; i < obj.length; i++) {
|
529
|
+
if (callback(obj[i], i, obj)) {
|
530
|
+
return true;
|
531
|
+
}
|
532
|
+
}
|
533
|
+
}
|
534
|
+
else {
|
535
|
+
for (var name in obj) {
|
536
|
+
if (callback(obj[name], name, obj)) {
|
537
|
+
return true;
|
538
|
+
}
|
539
|
+
}
|
540
|
+
}
|
541
|
+
}
|
542
|
+
|
543
|
+
function Type(obj) {
|
544
|
+
return obj == null ? String(obj) : GetClass2Type()[toString(obj)] || "object";
|
545
|
+
}
|
546
|
+
|
547
|
+
function IsNotEmpty(obj) {
|
548
|
+
for(var name in obj)
|
549
|
+
return true;
|
550
|
+
}
|
551
|
+
|
552
|
+
function IsPlainObject(obj) {
|
553
|
+
// Not plain objects:
|
554
|
+
// - Any object or value whose internal [[Class]] property is not "[object Object]"
|
555
|
+
// - DOM nodes
|
556
|
+
// - window
|
557
|
+
try {
|
558
|
+
return Type(obj) == "object"
|
559
|
+
&& !obj.nodeType
|
560
|
+
&& obj != obj.window
|
561
|
+
&& (!obj.constructor || { }.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf"));
|
562
|
+
}
|
563
|
+
catch (e) { }
|
564
|
+
}
|
565
|
+
|
566
|
+
function Point(x, y) {
|
567
|
+
return { x: x, y: y };
|
568
|
+
}
|
569
|
+
|
570
|
+
function Delay(code, delay) {
|
571
|
+
setTimeout(code, delay || 0);
|
572
|
+
}
|
573
|
+
|
574
|
+
function RemoveByReg(str, reg) {
|
575
|
+
var m = reg.exec(str);
|
576
|
+
|
577
|
+
if (m) {
|
578
|
+
var header = str.substr(0, m.index);
|
579
|
+
var tailer = str.substr(m.lastIndex + 1, str.length - (m.lastIndex + 1));
|
580
|
+
str = header + tailer;
|
581
|
+
}
|
582
|
+
|
583
|
+
return str;
|
584
|
+
}
|
585
|
+
|
586
|
+
function BuildNewCss(oldCss, removeRegs, replaceValue) {
|
587
|
+
var css = (!oldCss || oldCss == "inherit") ? "" : oldCss;
|
588
|
+
|
589
|
+
Each(removeRegs, function (removeReg) {
|
590
|
+
var m = removeReg.exec(css);
|
591
|
+
|
592
|
+
if (m) {
|
593
|
+
var header = css.substr(0, m.index);
|
594
|
+
var tailer = css.substr(m.lastIndex + 1, css.length - (m.lastIndex + 1));
|
595
|
+
css = header + tailer;
|
596
|
+
}
|
597
|
+
});
|
598
|
+
|
599
|
+
css = replaceValue + (css.indexOf(" ") != 0 ? " " : "") + css;
|
600
|
+
|
601
|
+
return css;
|
602
|
+
}
|
603
|
+
|
604
|
+
function SetStyleFilterIE(elmt, value) {
|
605
|
+
if (_BrowserRuntimeVersion < 9) {
|
606
|
+
elmt.style.filter = value;
|
607
|
+
}
|
608
|
+
}
|
609
|
+
|
610
|
+
function SetStyleMatrixIE(elmt, matrix, offset) {
|
611
|
+
//matrix is not for ie9+ running in ie8- mode
|
612
|
+
if (_BrowserJavascriptVersion < 9) {
|
613
|
+
var oldFilterValue = elmt.style.filter;
|
614
|
+
var matrixReg = new RegExp(/[\s]*progid:DXImageTransform\.Microsoft\.Matrix\([^\)]*\)/g);
|
615
|
+
var matrixValue = matrix ? "progid:DXImageTransform.Microsoft.Matrix(" + "M11=" + matrix[0][0] + ", M12=" + matrix[0][1] + ", M21=" + matrix[1][0] + ", M22=" + matrix[1][1] + ", SizingMethod='auto expand')" : "";
|
616
|
+
|
617
|
+
var newFilterValue = BuildNewCss(oldFilterValue, [matrixReg], matrixValue);
|
618
|
+
|
619
|
+
SetStyleFilterIE(elmt, newFilterValue);
|
620
|
+
|
621
|
+
_This.$CssMarginTop(elmt, offset.y);
|
622
|
+
_This.$CssMarginLeft(elmt, offset.x);
|
623
|
+
}
|
624
|
+
}
|
625
|
+
|
626
|
+
// Methods
|
627
|
+
|
628
|
+
_This.$Device = Device;
|
629
|
+
|
630
|
+
_This.$IsBrowserIE = IsBrowserIE;
|
631
|
+
|
632
|
+
_This.$IsBrowserIeQuirks = IsBrowserIeQuirks;
|
633
|
+
|
634
|
+
_This.$IsBrowserFireFox = IsBrowserFireFox;
|
635
|
+
|
636
|
+
_This.$IsBrowserSafari = IsBrowserSafari;
|
637
|
+
|
638
|
+
_This.$IsBrowserChrome = IsBrowserChrome;
|
639
|
+
|
640
|
+
_This.$IsBrowserOpera = IsBrowserOpera;
|
641
|
+
|
642
|
+
_This.$IsBrowserBadTransform = IsBrowserBadTransform;
|
643
|
+
|
644
|
+
_This.$IsBrowserIe9Earlier = IsBrowserIe9Earlier;
|
645
|
+
|
646
|
+
_This.$BrowserVersion = function () {
|
647
|
+
return _BrowserRuntimeVersion;
|
648
|
+
};
|
649
|
+
|
650
|
+
_This.$BrowserEngineVersion = function () {
|
651
|
+
return _BrowserEngineVersion || _BrowserRuntimeVersion;
|
652
|
+
};
|
653
|
+
|
654
|
+
_This.$WebKitVersion = function () {
|
655
|
+
DetectBrowser();
|
656
|
+
|
657
|
+
return _WebkitVersion;
|
658
|
+
};
|
659
|
+
|
660
|
+
_This.$Delay = Delay;
|
661
|
+
|
662
|
+
_This.$Inherit = function (instance, baseClass) {
|
663
|
+
baseClass.call(instance);
|
664
|
+
return Extend({}, instance);
|
665
|
+
};
|
666
|
+
|
667
|
+
function Construct(instance) {
|
668
|
+
instance.constructor === Construct.caller && instance.$Construct && instance.$Construct.apply(instance, Construct.caller.arguments);
|
669
|
+
}
|
670
|
+
|
671
|
+
_This.$Construct = Construct;
|
672
|
+
|
673
|
+
_This.$GetElement = function (elmt) {
|
674
|
+
if (_This.$IsString(elmt)) {
|
675
|
+
elmt = document.getElementById(elmt);
|
676
|
+
}
|
677
|
+
|
678
|
+
return elmt;
|
679
|
+
};
|
680
|
+
|
681
|
+
function GetEvent(event) {
|
682
|
+
return event || window.event;
|
683
|
+
}
|
684
|
+
|
685
|
+
_This.$GetEvent = GetEvent;
|
686
|
+
|
687
|
+
_This.$EvtSrc = function (event) {
|
688
|
+
event = GetEvent(event);
|
689
|
+
return event.target || event.srcElement || document;
|
690
|
+
};
|
691
|
+
|
692
|
+
_This.$EvtTarget = function (event) {
|
693
|
+
event = GetEvent(event);
|
694
|
+
return event.relatedTarget || event.toElement;
|
695
|
+
};
|
696
|
+
|
697
|
+
_This.$EvtWhich = function (event) {
|
698
|
+
event = GetEvent(event);
|
699
|
+
return event.which || [0, 1, 3, 0, 2][event.button] || event.charCode || event.keyCode;
|
700
|
+
};
|
701
|
+
|
702
|
+
_This.$MousePosition = function (event) {
|
703
|
+
event = GetEvent(event);
|
704
|
+
//var body = document.body;
|
705
|
+
|
706
|
+
return {
|
707
|
+
x: event.pageX || event.clientX/* + (_DocElmt.scrollLeft || body.scrollLeft || 0) - (_DocElmt.clientLeft || body.clientLeft || 0)*/ || 0,
|
708
|
+
y: event.pageY || event.clientY/* + (_DocElmt.scrollTop || body.scrollTop || 0) - (_DocElmt.clientTop || body.clientTop || 0)*/ || 0
|
709
|
+
};
|
710
|
+
};
|
711
|
+
|
712
|
+
_This.$PageScroll = function () {
|
713
|
+
var body = document.body;
|
714
|
+
|
715
|
+
return {
|
716
|
+
x: (window.pageXOffset || _DocElmt.scrollLeft || body.scrollLeft || 0) - (_DocElmt.clientLeft || body.clientLeft || 0),
|
717
|
+
y: (window.pageYOffset || _DocElmt.scrollTop || body.scrollTop || 0) - (_DocElmt.clientTop || body.clientTop || 0)
|
718
|
+
};
|
719
|
+
};
|
720
|
+
|
721
|
+
_This.$WindowSize = function () {
|
722
|
+
var body = document.body;
|
723
|
+
|
724
|
+
return {
|
725
|
+
x: body.clientWidth || _DocElmt.clientWidth,
|
726
|
+
y: body.clientHeight || _DocElmt.clientHeight
|
727
|
+
};
|
728
|
+
};
|
729
|
+
|
730
|
+
//_This.$GetElementPosition = function (elmt) {
|
731
|
+
// elmt = _This.$GetElement(elmt);
|
732
|
+
// var result = Point();
|
733
|
+
|
734
|
+
// // technique from:
|
735
|
+
// // http://www.quirksmode.org/js/findpos.html
|
736
|
+
// // with special check for "fixed" elements.
|
737
|
+
|
738
|
+
// while (elmt) {
|
739
|
+
// result.x += elmt.offsetLeft;
|
740
|
+
// result.y += elmt.offsetTop;
|
741
|
+
|
742
|
+
// var isFixed = _This.$GetElementStyle(elmt).position == "fixed";
|
743
|
+
|
744
|
+
// if (isFixed) {
|
745
|
+
// result = result.$Plus(_This.$PageScroll(window));
|
746
|
+
// }
|
747
|
+
|
748
|
+
// elmt = getOffsetParent(elmt, isFixed);
|
749
|
+
// }
|
750
|
+
|
751
|
+
// return result;
|
752
|
+
//};
|
753
|
+
|
754
|
+
//_This.$GetMouseScroll = function (event) {
|
755
|
+
// event = GetEvent(event);
|
756
|
+
// var delta = 0; // default value
|
757
|
+
|
758
|
+
// // technique from:
|
759
|
+
// // http://blog.paranoidferret.com/index.php/2007/10/31/javascript-tutorial-the-scroll-wheel/
|
760
|
+
|
761
|
+
// if (typeof (event.wheelDelta) == "number") {
|
762
|
+
// delta = event.wheelDelta;
|
763
|
+
// } else if (typeof (event.detail) == "number") {
|
764
|
+
// delta = event.detail * -1;
|
765
|
+
// } else {
|
766
|
+
// $JssorDebug$.$Fail("Unknown event mouse scroll, no known technique.");
|
767
|
+
// }
|
768
|
+
|
769
|
+
// // normalize value to [-1, 1]
|
770
|
+
// return delta ? delta / Math.abs(delta) : 0;
|
771
|
+
//};
|
772
|
+
|
773
|
+
//_This.$MakeAjaxRequest = function (url, callback) {
|
774
|
+
// var async = typeof (callback) == "function";
|
775
|
+
// var req = null;
|
776
|
+
|
777
|
+
// if (async) {
|
778
|
+
// var actual = callback;
|
779
|
+
// var callback = function () {
|
780
|
+
// Delay($Jssor$.$CreateCallback(null, actual, req), 1);
|
781
|
+
// };
|
782
|
+
// }
|
783
|
+
|
784
|
+
// if (window.ActiveXObject) {
|
785
|
+
// for (var i = 0; i < arrActiveX.length; i++) {
|
786
|
+
// try {
|
787
|
+
// req = new ActiveXObject(arrActiveX[i]);
|
788
|
+
// break;
|
789
|
+
// } catch (e) {
|
790
|
+
// continue;
|
791
|
+
// }
|
792
|
+
// }
|
793
|
+
// } else if (window.XMLHttpRequest) {
|
794
|
+
// req = new XMLHttpRequest();
|
795
|
+
// }
|
796
|
+
|
797
|
+
// if (!req) {
|
798
|
+
// $JssorDebug$.$Fail("Browser doesn't support XMLHttpRequest.");
|
799
|
+
// }
|
800
|
+
|
801
|
+
// if (async) {
|
802
|
+
// req.onreadystatechange = function () {
|
803
|
+
// if (req.readyState == 4) {
|
804
|
+
// // prevent memory leaks by breaking circular reference now
|
805
|
+
// req.onreadystatechange = new Function();
|
806
|
+
// callback();
|
807
|
+
// }
|
808
|
+
// };
|
809
|
+
// }
|
810
|
+
|
811
|
+
// try {
|
812
|
+
// req.open("GET", url, async);
|
813
|
+
// req.send(null);
|
814
|
+
// } catch (e) {
|
815
|
+
// $JssorDebug$.$Log(e.name + " while making AJAX request: " + e.message);
|
816
|
+
|
817
|
+
// req.onreadystatechange = null;
|
818
|
+
// req = null;
|
819
|
+
|
820
|
+
// if (async) {
|
821
|
+
// callback();
|
822
|
+
// }
|
823
|
+
// }
|
824
|
+
|
825
|
+
// return async ? null : req;
|
826
|
+
//};
|
827
|
+
|
828
|
+
//_This.$ParseXml = function (string) {
|
829
|
+
// var xmlDoc = null;
|
830
|
+
|
831
|
+
// if (window.ActiveXObject) {
|
832
|
+
// try {
|
833
|
+
// xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
|
834
|
+
// xmlDoc.async = false;
|
835
|
+
// xmlDoc.loadXML(string);
|
836
|
+
// } catch (e) {
|
837
|
+
// $JssorDebug$.$Log(e.name + " while parsing XML (ActiveX): " + e.message);
|
838
|
+
// }
|
839
|
+
// } else if (window.DOMParser) {
|
840
|
+
// try {
|
841
|
+
// var parser = new DOMParser();
|
842
|
+
// xmlDoc = parser.parseFromString(string, "text/xml");
|
843
|
+
// } catch (e) {
|
844
|
+
// $JssorDebug$.$Log(e.name + " while parsing XML (DOMParser): " + e.message);
|
845
|
+
// }
|
846
|
+
// } else {
|
847
|
+
// $JssorDebug$.$Fail("Browser doesn't support XML DOM.");
|
848
|
+
// }
|
849
|
+
|
850
|
+
// return xmlDoc;
|
851
|
+
//};
|
852
|
+
|
853
|
+
function Css(elmt, name, value) {
|
854
|
+
/// <summary>
|
855
|
+
/// access css
|
856
|
+
/// $Jssor$.$Css(elmt, name); //get css value
|
857
|
+
/// $Jssor$.$Css(elmt, name, value); //set css value
|
858
|
+
/// </summary>
|
859
|
+
/// <param name="elmt" type="HTMLElement">
|
860
|
+
/// the element to access css
|
861
|
+
/// </param>
|
862
|
+
/// <param name="name" type="String">
|
863
|
+
/// the name of css property
|
864
|
+
/// </param>
|
865
|
+
/// <param name="value" optional="true">
|
866
|
+
/// the value to set
|
867
|
+
/// </param>
|
868
|
+
if (value != undefined) {
|
869
|
+
elmt.style[name] = value;
|
870
|
+
}
|
871
|
+
else {
|
872
|
+
var style = elmt.currentStyle || elmt.style;
|
873
|
+
value = style[name];
|
874
|
+
|
875
|
+
if (value == "" && window.getComputedStyle) {
|
876
|
+
style = elmt.ownerDocument.defaultView.getComputedStyle(elmt, null);
|
877
|
+
|
878
|
+
style && (value = style.getPropertyValue(name) || style[name]);
|
879
|
+
}
|
880
|
+
|
881
|
+
return value;
|
882
|
+
}
|
883
|
+
}
|
884
|
+
|
885
|
+
function CssN(elmt, name, value, isDimensional) {
|
886
|
+
/// <summary>
|
887
|
+
/// access css as numeric
|
888
|
+
/// $Jssor$.$CssN(elmt, name); //get css value
|
889
|
+
/// $Jssor$.$CssN(elmt, name, value); //set css value
|
890
|
+
/// </summary>
|
891
|
+
/// <param name="elmt" type="HTMLElement">
|
892
|
+
/// the element to access css
|
893
|
+
/// </param>
|
894
|
+
/// <param name="name" type="String">
|
895
|
+
/// the name of css property
|
896
|
+
/// </param>
|
897
|
+
/// <param name="value" type="Number" optional="true">
|
898
|
+
/// the value to set
|
899
|
+
/// </param>
|
900
|
+
if (value != undefined) {
|
901
|
+
isDimensional && (value += "px");
|
902
|
+
Css(elmt, name, value);
|
903
|
+
}
|
904
|
+
else {
|
905
|
+
return ParseFloat(Css(elmt, name));
|
906
|
+
}
|
907
|
+
}
|
908
|
+
|
909
|
+
function CssP(elmt, name, value) {
|
910
|
+
/// <summary>
|
911
|
+
/// access css in pixel as numeric, like 'top', 'left', 'width', 'height'
|
912
|
+
/// $Jssor$.$CssP(elmt, name); //get css value
|
913
|
+
/// $Jssor$.$CssP(elmt, name, value); //set css value
|
914
|
+
/// </summary>
|
915
|
+
/// <param name="elmt" type="HTMLElement">
|
916
|
+
/// the element to access css
|
917
|
+
/// </param>
|
918
|
+
/// <param name="name" type="String">
|
919
|
+
/// the name of css property
|
920
|
+
/// </param>
|
921
|
+
/// <param name="value" type="Number" optional="true">
|
922
|
+
/// the value to set
|
923
|
+
/// </param>
|
924
|
+
return CssN(elmt, name, value, true);
|
925
|
+
}
|
926
|
+
|
927
|
+
function CssProxy(name, numericOrDimension) {
|
928
|
+
/// <summary>
|
929
|
+
/// create proxy to access css, CssProxy(name[, numericOrDimension]);
|
930
|
+
/// </summary>
|
931
|
+
/// <param name="elmt" type="HTMLElement">
|
932
|
+
/// the element to access css
|
933
|
+
/// </param>
|
934
|
+
/// <param name="numericOrDimension" type="Number" optional="true">
|
935
|
+
/// not set: access original css, 1: access css as numeric, 2: access css in pixel as numeric
|
936
|
+
/// </param>
|
937
|
+
var isDimensional = numericOrDimension & 2;
|
938
|
+
var cssAccessor = numericOrDimension ? CssN : Css;
|
939
|
+
return function (elmt, value) {
|
940
|
+
return cssAccessor(elmt, name, value, isDimensional);
|
941
|
+
};
|
942
|
+
}
|
943
|
+
|
944
|
+
function GetStyleOpacity(elmt) {
|
945
|
+
if (IsBrowserIE() && _BrowserEngineVersion < 9) {
|
946
|
+
var match = /opacity=([^)]*)/.exec(elmt.style.filter || "");
|
947
|
+
return match ? (ParseFloat(match[1]) / 100) : 1;
|
948
|
+
}
|
949
|
+
else
|
950
|
+
return ParseFloat(elmt.style.opacity || "1");
|
951
|
+
}
|
952
|
+
|
953
|
+
function SetStyleOpacity(elmt, opacity, ie9EarlierForce) {
|
954
|
+
|
955
|
+
if (IsBrowserIE() && _BrowserEngineVersion < 9) {
|
956
|
+
//var filterName = "filter"; // _BrowserEngineVersion < 8 ? "filter" : "-ms-filter";
|
957
|
+
var finalFilter = elmt.style.filter || "";
|
958
|
+
|
959
|
+
// for CSS filter browsers (IE), remove alpha filter if it's unnecessary.
|
960
|
+
// update: doing _This always since IE9 beta seems to have broken the
|
961
|
+
// behavior if we rely on the programmatic filters collection.
|
962
|
+
var alphaReg = new RegExp(/[\s]*alpha\([^\)]*\)/g);
|
963
|
+
|
964
|
+
// important: note the lazy star! _This protects against
|
965
|
+
// multiple filters; we don't want to delete the other ones.
|
966
|
+
// update: also trimming extra whitespace around filter.
|
967
|
+
|
968
|
+
var ieOpacity = Math.round(100 * opacity);
|
969
|
+
var alphaFilter = "";
|
970
|
+
if (ieOpacity < 100 || ie9EarlierForce) {
|
971
|
+
alphaFilter = "alpha(opacity=" + ieOpacity + ") ";
|
972
|
+
}
|
973
|
+
|
974
|
+
var newFilterValue = BuildNewCss(finalFilter, [alphaReg], alphaFilter);
|
975
|
+
|
976
|
+
SetStyleFilterIE(elmt, newFilterValue);
|
977
|
+
}
|
978
|
+
else {
|
979
|
+
elmt.style.opacity = opacity == 1 ? "" : Math.round(opacity * 100) / 100;
|
980
|
+
}
|
981
|
+
}
|
982
|
+
|
983
|
+
function SetStyleTransformInternal(elmt, transform) {
|
984
|
+
var rotate = transform.$Rotate || 0;
|
985
|
+
var scale = transform.$Scale == undefined ? 1 : transform.$Scale;
|
986
|
+
|
987
|
+
if (IsBrowserIe9Earlier()) {
|
988
|
+
var matrix = _This.$CreateMatrix(rotate / 180 * Math.PI, scale, scale);
|
989
|
+
SetStyleMatrixIE(elmt, (!rotate && scale == 1) ? null : matrix, _This.$GetMatrixOffset(matrix, transform.$OriginalWidth, transform.$OriginalHeight));
|
990
|
+
}
|
991
|
+
else {
|
992
|
+
//rotate(15deg) scale(.5) translateZ(0)
|
993
|
+
var transformProperty = GetTransformProperty(elmt);
|
994
|
+
if (transformProperty) {
|
995
|
+
var transformValue = "rotate(" + rotate % 360 + "deg) scale(" + scale + ")";
|
996
|
+
|
997
|
+
//needed for touch device, no need for desktop device
|
998
|
+
if (IsBrowserChrome() && _WebkitVersion > 535 && "ontouchstart" in window)
|
999
|
+
transformValue += " perspective(2000px)";
|
1000
|
+
|
1001
|
+
elmt.style[transformProperty] = transformValue;
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
_This.$SetStyleTransform = function (elmt, transform) {
|
1007
|
+
if (IsBrowserBadTransform()) {
|
1008
|
+
Delay(_This.$CreateCallback(null, SetStyleTransformInternal, elmt, transform));
|
1009
|
+
}
|
1010
|
+
else {
|
1011
|
+
SetStyleTransformInternal(elmt, transform);
|
1012
|
+
}
|
1013
|
+
};
|
1014
|
+
|
1015
|
+
_This.$SetStyleTransformOrigin = function (elmt, transformOrigin) {
|
1016
|
+
var transformProperty = GetTransformProperty(elmt);
|
1017
|
+
|
1018
|
+
if (transformProperty)
|
1019
|
+
elmt.style[transformProperty + "Origin"] = transformOrigin;
|
1020
|
+
};
|
1021
|
+
|
1022
|
+
_This.$CssScale = function (elmt, scale) {
|
1023
|
+
|
1024
|
+
if (IsBrowserIE() && _BrowserEngineVersion < 9 || (_BrowserEngineVersion < 10 && IsBrowserIeQuirks())) {
|
1025
|
+
elmt.style.zoom = (scale == 1) ? "" : scale;
|
1026
|
+
}
|
1027
|
+
else {
|
1028
|
+
var transformProperty = GetTransformProperty(elmt);
|
1029
|
+
|
1030
|
+
if (transformProperty) {
|
1031
|
+
//rotate(15deg) scale(.5)
|
1032
|
+
var transformValue = "scale(" + scale + ")";
|
1033
|
+
|
1034
|
+
var oldTransformValue = elmt.style[transformProperty];
|
1035
|
+
var scaleReg = new RegExp(/[\s]*scale\(.*?\)/g);
|
1036
|
+
|
1037
|
+
var newTransformValue = BuildNewCss(oldTransformValue, [scaleReg], transformValue);
|
1038
|
+
|
1039
|
+
elmt.style[transformProperty] = newTransformValue;
|
1040
|
+
}
|
1041
|
+
}
|
1042
|
+
};
|
1043
|
+
|
1044
|
+
_This.$EnableHWA = function (elmt) {
|
1045
|
+
if (!elmt.style[GetTransformProperty(elmt)] || elmt.style[GetTransformProperty(elmt)] == "none")
|
1046
|
+
elmt.style[GetTransformProperty(elmt)] = "perspective(2000px)";
|
1047
|
+
};
|
1048
|
+
|
1049
|
+
_This.$DisableHWA = function (elmt) {
|
1050
|
+
elmt.style[GetTransformProperty(elmt)] = "none";
|
1051
|
+
};
|
1052
|
+
|
1053
|
+
var ie8OffsetWidth = 0;
|
1054
|
+
var ie8OffsetHeight = 0;
|
1055
|
+
|
1056
|
+
_This.$WindowResizeFilter = function (window, handler) {
|
1057
|
+
return IsBrowserIe9Earlier() ? function () {
|
1058
|
+
|
1059
|
+
var trigger = true;
|
1060
|
+
|
1061
|
+
var checkElement = (IsBrowserIeQuirks() ? window.document.body : window.document.documentElement);
|
1062
|
+
if (checkElement) {
|
1063
|
+
var widthChange = checkElement.offsetWidth - ie8OffsetWidth;
|
1064
|
+
var heightChange = checkElement.offsetHeight - ie8OffsetHeight;
|
1065
|
+
if (widthChange || heightChange) {
|
1066
|
+
ie8OffsetWidth += widthChange;
|
1067
|
+
ie8OffsetHeight += heightChange;
|
1068
|
+
}
|
1069
|
+
else
|
1070
|
+
trigger = false;
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
trigger && handler();
|
1074
|
+
|
1075
|
+
} : handler;
|
1076
|
+
};
|
1077
|
+
|
1078
|
+
_This.$MouseOverOutFilter = function (handler, target) {
|
1079
|
+
/// <param name="target" type="HTMLDomElement">
|
1080
|
+
/// The target element to detect mouse over/out events. (for ie < 9 compatibility)
|
1081
|
+
/// </param>
|
1082
|
+
|
1083
|
+
$JssorDebug$.$Execute(function () {
|
1084
|
+
if (!target) {
|
1085
|
+
throw new Error("Null reference, parameter \"target\".");
|
1086
|
+
}
|
1087
|
+
});
|
1088
|
+
|
1089
|
+
return function (event) {
|
1090
|
+
event = GetEvent(event);
|
1091
|
+
|
1092
|
+
var eventName = event.type;
|
1093
|
+
var related = event.relatedTarget || (eventName == "mouseout" ? event.toElement : event.fromElement);
|
1094
|
+
|
1095
|
+
if (!related || (related !== target && !_This.$IsChild(target, related))) {
|
1096
|
+
handler(event);
|
1097
|
+
}
|
1098
|
+
};
|
1099
|
+
};
|
1100
|
+
|
1101
|
+
_This.$AddEvent = function (elmt, eventName, handler, useCapture) {
|
1102
|
+
elmt = _This.$GetElement(elmt);
|
1103
|
+
|
1104
|
+
$JssorDebug$.$Execute(function () {
|
1105
|
+
if (!elmt) {
|
1106
|
+
$JssorDebug$.$Fail("Parameter 'elmt' not specified.");
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
if (!handler) {
|
1110
|
+
$JssorDebug$.$Fail("Parameter 'handler' not specified.");
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
if (!elmt.addEventListener && !elmt.attachEvent) {
|
1114
|
+
$JssorDebug$.$Fail("Unable to attach event handler, no known technique.");
|
1115
|
+
}
|
1116
|
+
});
|
1117
|
+
|
1118
|
+
// technique from:
|
1119
|
+
// http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
|
1120
|
+
|
1121
|
+
if (elmt.addEventListener) {
|
1122
|
+
if (eventName == "mousewheel") {
|
1123
|
+
elmt.addEventListener("DOMMouseScroll", handler, useCapture);
|
1124
|
+
}
|
1125
|
+
// we are still going to add the mousewheel -- not a mistake!
|
1126
|
+
// _This is for opera, since it uses onmousewheel but needs addEventListener.
|
1127
|
+
elmt.addEventListener(eventName, handler, useCapture);
|
1128
|
+
}
|
1129
|
+
else if (elmt.attachEvent) {
|
1130
|
+
elmt.attachEvent("on" + eventName, handler);
|
1131
|
+
if (useCapture && elmt.setCapture) {
|
1132
|
+
elmt.setCapture();
|
1133
|
+
}
|
1134
|
+
}
|
1135
|
+
};
|
1136
|
+
|
1137
|
+
_This.$RemoveEvent = function (elmt, eventName, handler, useCapture) {
|
1138
|
+
elmt = _This.$GetElement(elmt);
|
1139
|
+
|
1140
|
+
// technique from:
|
1141
|
+
// http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
|
1142
|
+
|
1143
|
+
if (elmt.removeEventListener) {
|
1144
|
+
if (eventName == "mousewheel") {
|
1145
|
+
elmt.removeEventListener("DOMMouseScroll", handler, useCapture);
|
1146
|
+
}
|
1147
|
+
// we are still going to remove the mousewheel -- not a mistake!
|
1148
|
+
// _This is for opera, since it uses onmousewheel but needs removeEventListener.
|
1149
|
+
elmt.removeEventListener(eventName, handler, useCapture);
|
1150
|
+
}
|
1151
|
+
else if (elmt.detachEvent) {
|
1152
|
+
elmt.detachEvent("on" + eventName, handler);
|
1153
|
+
if (useCapture && elmt.releaseCapture) {
|
1154
|
+
elmt.releaseCapture();
|
1155
|
+
}
|
1156
|
+
}
|
1157
|
+
};
|
1158
|
+
|
1159
|
+
_This.$FireEvent = function (elmt, eventName) {
|
1160
|
+
//var document = elmt.document;
|
1161
|
+
|
1162
|
+
$JssorDebug$.$Execute(function () {
|
1163
|
+
if (!document.createEvent && !document.createEventObject) {
|
1164
|
+
$JssorDebug$.$Fail("Unable to fire event, no known technique.");
|
1165
|
+
}
|
1166
|
+
|
1167
|
+
if (!elmt.dispatchEvent && !elmt.fireEvent) {
|
1168
|
+
$JssorDebug$.$Fail("Unable to fire event, no known technique.");
|
1169
|
+
}
|
1170
|
+
});
|
1171
|
+
|
1172
|
+
var evento;
|
1173
|
+
|
1174
|
+
if (document.createEvent) {
|
1175
|
+
evento = document.createEvent("HTMLEvents");
|
1176
|
+
evento.initEvent(eventName, false, false);
|
1177
|
+
elmt.dispatchEvent(evento);
|
1178
|
+
}
|
1179
|
+
else {
|
1180
|
+
var ieEventName = "on" + eventName;
|
1181
|
+
evento = document.createEventObject();
|
1182
|
+
|
1183
|
+
elmt.fireEvent(ieEventName, evento);
|
1184
|
+
}
|
1185
|
+
};
|
1186
|
+
|
1187
|
+
_This.$CancelEvent = function (event) {
|
1188
|
+
event = GetEvent(event);
|
1189
|
+
|
1190
|
+
// technique from:
|
1191
|
+
// http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
|
1192
|
+
|
1193
|
+
if (event.preventDefault) {
|
1194
|
+
event.preventDefault(); // W3C for preventing default
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
event.cancel = true; // legacy for preventing default
|
1198
|
+
event.returnValue = false; // IE for preventing default
|
1199
|
+
};
|
1200
|
+
|
1201
|
+
_This.$StopEvent = function (event) {
|
1202
|
+
event = GetEvent(event);
|
1203
|
+
|
1204
|
+
// technique from:
|
1205
|
+
// http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
|
1206
|
+
|
1207
|
+
if (event.stopPropagation) {
|
1208
|
+
event.stopPropagation(); // W3C for stopping propagation
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
event.cancelBubble = true; // IE for stopping propagation
|
1212
|
+
};
|
1213
|
+
|
1214
|
+
_This.$CreateCallback = function (object, method) {
|
1215
|
+
// create callback args
|
1216
|
+
var initialArgs = [].slice.call(arguments, 2);
|
1217
|
+
|
1218
|
+
// create closure to apply method
|
1219
|
+
var callback = function () {
|
1220
|
+
// concatenate new args, but make a copy of initialArgs first
|
1221
|
+
var args = initialArgs.concat([].slice.call(arguments, 0));
|
1222
|
+
|
1223
|
+
return method.apply(object, args);
|
1224
|
+
};
|
1225
|
+
|
1226
|
+
//$JssorDebug$.$LiveStamp(callback, "callback_" + ($Jssor$.$GetNow() & 0xFFFFFF));
|
1227
|
+
|
1228
|
+
return callback;
|
1229
|
+
};
|
1230
|
+
|
1231
|
+
_This.$InnerText = function (elmt, text) {
|
1232
|
+
if (text == undefined)
|
1233
|
+
return elmt.textContent || elmt.innerText;
|
1234
|
+
|
1235
|
+
var textNode = document.createTextNode(text);
|
1236
|
+
_This.$Empty(elmt);
|
1237
|
+
elmt.appendChild(textNode);
|
1238
|
+
};
|
1239
|
+
|
1240
|
+
_This.$InnerHtml = function (elmt, html) {
|
1241
|
+
if (html == undefined)
|
1242
|
+
return elmt.innerHTML;
|
1243
|
+
|
1244
|
+
elmt.innerHTML = html;
|
1245
|
+
};
|
1246
|
+
|
1247
|
+
_This.$GetClientRect = function (elmt) {
|
1248
|
+
var rect = elmt.getBoundingClientRect();
|
1249
|
+
|
1250
|
+
return { x: rect.left, y: rect.top, w: rect.right - rect.left, h: rect.bottom - rect.top };
|
1251
|
+
};
|
1252
|
+
|
1253
|
+
_This.$ClearInnerHtml = function (elmt) {
|
1254
|
+
elmt.innerHTML = "";
|
1255
|
+
};
|
1256
|
+
|
1257
|
+
_This.$EncodeHtml = function (text) {
|
1258
|
+
var div = _This.$CreateDiv();
|
1259
|
+
_This.$InnerText(div, text);
|
1260
|
+
return _This.$InnerHtml(div);
|
1261
|
+
};
|
1262
|
+
|
1263
|
+
_This.$DecodeHtml = function (html) {
|
1264
|
+
var div = _This.$CreateDiv();
|
1265
|
+
_This.$InnerHtml(div, html);
|
1266
|
+
return _This.$InnerText(div);
|
1267
|
+
};
|
1268
|
+
|
1269
|
+
_This.$SelectElement = function (elmt) {
|
1270
|
+
var userSelection;
|
1271
|
+
if (window.getSelection) {
|
1272
|
+
//W3C default
|
1273
|
+
userSelection = window.getSelection();
|
1274
|
+
}
|
1275
|
+
var theRange = null;
|
1276
|
+
if (document.createRange) {
|
1277
|
+
theRange = document.createRange();
|
1278
|
+
theRange.selectNode(elmt);
|
1279
|
+
}
|
1280
|
+
else {
|
1281
|
+
theRange = document.body.createTextRange();
|
1282
|
+
theRange.moveToElementText(elmt);
|
1283
|
+
theRange.select();
|
1284
|
+
}
|
1285
|
+
//set user selection
|
1286
|
+
if (userSelection)
|
1287
|
+
userSelection.addRange(theRange);
|
1288
|
+
};
|
1289
|
+
|
1290
|
+
_This.$DeselectElements = function () {
|
1291
|
+
if (document.selection) {
|
1292
|
+
document.selection.empty();
|
1293
|
+
} else if (window.getSelection) {
|
1294
|
+
window.getSelection().removeAllRanges();
|
1295
|
+
}
|
1296
|
+
};
|
1297
|
+
|
1298
|
+
_This.$Children = function (elmt, includeAll) {
|
1299
|
+
var children = [];
|
1300
|
+
|
1301
|
+
for (var tmpEl = elmt.firstChild; tmpEl; tmpEl = tmpEl.nextSibling) {
|
1302
|
+
if (includeAll || tmpEl.nodeType == 1) {
|
1303
|
+
children.push(tmpEl);
|
1304
|
+
}
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
return children;
|
1308
|
+
};
|
1309
|
+
|
1310
|
+
function FindChild(elmt, attrValue, noDeep, attrName) {
|
1311
|
+
attrName = attrName || "u";
|
1312
|
+
|
1313
|
+
for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
|
1314
|
+
if (elmt.nodeType == 1) {
|
1315
|
+
if (AttributeEx(elmt, attrName) == attrValue)
|
1316
|
+
return elmt;
|
1317
|
+
|
1318
|
+
if (!noDeep) {
|
1319
|
+
var childRet = FindChild(elmt, attrValue, noDeep, attrName);
|
1320
|
+
if (childRet)
|
1321
|
+
return childRet;
|
1322
|
+
}
|
1323
|
+
}
|
1324
|
+
}
|
1325
|
+
}
|
1326
|
+
|
1327
|
+
_This.$FindChild = FindChild;
|
1328
|
+
|
1329
|
+
function FindChildren(elmt, attrValue, noDeep, attrName) {
|
1330
|
+
attrName = attrName || "u";
|
1331
|
+
|
1332
|
+
var ret = [];
|
1333
|
+
|
1334
|
+
for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
|
1335
|
+
if (elmt.nodeType == 1) {
|
1336
|
+
if (AttributeEx(elmt, attrName) == attrValue)
|
1337
|
+
ret.push(elmt);
|
1338
|
+
|
1339
|
+
if (!noDeep) {
|
1340
|
+
var childRet = FindChildren(elmt, attrValue, noDeep, attrName);
|
1341
|
+
if (childRet.length)
|
1342
|
+
ret = ret.concat(childRet);
|
1343
|
+
}
|
1344
|
+
}
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
return ret;
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
_This.$FindChildren = FindChildren;
|
1351
|
+
|
1352
|
+
function FindChildByTag(elmt, tagName, noDeep) {
|
1353
|
+
|
1354
|
+
for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
|
1355
|
+
if (elmt.nodeType == 1) {
|
1356
|
+
if (elmt.tagName == tagName)
|
1357
|
+
return elmt;
|
1358
|
+
|
1359
|
+
if (!noDeep) {
|
1360
|
+
var childRet = FindChildByTag(elmt, tagName, noDeep);
|
1361
|
+
if (childRet)
|
1362
|
+
return childRet;
|
1363
|
+
}
|
1364
|
+
}
|
1365
|
+
}
|
1366
|
+
}
|
1367
|
+
|
1368
|
+
_This.$FindChildByTag = FindChildByTag;
|
1369
|
+
|
1370
|
+
function FindChildrenByTag(elmt, tagName, noDeep) {
|
1371
|
+
var ret = [];
|
1372
|
+
|
1373
|
+
for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
|
1374
|
+
if (elmt.nodeType == 1) {
|
1375
|
+
if (!tagName || elmt.tagName == tagName)
|
1376
|
+
ret.push(elmt);
|
1377
|
+
|
1378
|
+
if (!noDeep) {
|
1379
|
+
var childRet = FindChildrenByTag(elmt, tagName, noDeep);
|
1380
|
+
if (childRet.length)
|
1381
|
+
ret = ret.concat(childRet);
|
1382
|
+
}
|
1383
|
+
}
|
1384
|
+
}
|
1385
|
+
|
1386
|
+
return ret;
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
_This.$FindChildrenByTag = FindChildrenByTag;
|
1390
|
+
|
1391
|
+
_This.$GetElementsByTag = function (elmt, tagName) {
|
1392
|
+
return elmt.getElementsByTagName(tagName);
|
1393
|
+
};
|
1394
|
+
|
1395
|
+
//function Extend() {
|
1396
|
+
// var args = arguments;
|
1397
|
+
// var target;
|
1398
|
+
// var options;
|
1399
|
+
// var propName;
|
1400
|
+
// var propValue;
|
1401
|
+
// var targetPropValue;
|
1402
|
+
// var purpose = 7 & args[0];
|
1403
|
+
// var deep = 1 & purpose;
|
1404
|
+
// var unextend = 2 & purpose;
|
1405
|
+
// var i = purpose ? 2 : 1;
|
1406
|
+
// target = args[i - 1] || {};
|
1407
|
+
|
1408
|
+
// for (; i < args.length; i++) {
|
1409
|
+
// // Only deal with non-null/undefined values
|
1410
|
+
// if (options = args[i]) {
|
1411
|
+
// // Extend the base object
|
1412
|
+
// for (propName in options) {
|
1413
|
+
// propValue = options[propName];
|
1414
|
+
|
1415
|
+
// if (propValue !== undefined) {
|
1416
|
+
// propValue = options[propName];
|
1417
|
+
|
1418
|
+
// if (unextend) {
|
1419
|
+
// targetPropValue = target[propName];
|
1420
|
+
// if (propValue === targetPropValue)
|
1421
|
+
// delete target[propName];
|
1422
|
+
// else if (deep && IsPlainObject(targetPropValue)) {
|
1423
|
+
// Extend(purpose, targetPropValue, propValue);
|
1424
|
+
// }
|
1425
|
+
// }
|
1426
|
+
// else {
|
1427
|
+
// target[propName] = (deep && IsPlainObject(target[propName])) ? Extend(purpose | 4, {}, propValue) : propValue;
|
1428
|
+
// }
|
1429
|
+
// }
|
1430
|
+
// }
|
1431
|
+
// }
|
1432
|
+
// }
|
1433
|
+
|
1434
|
+
// // Return the modified object
|
1435
|
+
// return target;
|
1436
|
+
//}
|
1437
|
+
|
1438
|
+
//function Unextend() {
|
1439
|
+
// var args = arguments;
|
1440
|
+
// var newArgs = [].slice.call(arguments);
|
1441
|
+
// var purpose = 1 & args[0];
|
1442
|
+
|
1443
|
+
// purpose && newArgs.shift();
|
1444
|
+
// newArgs.unshift(purpose | 2);
|
1445
|
+
|
1446
|
+
// return Extend.apply(null, newArgs);
|
1447
|
+
//}
|
1448
|
+
|
1449
|
+
function Extend() {
|
1450
|
+
var args = arguments;
|
1451
|
+
var target;
|
1452
|
+
var options;
|
1453
|
+
var propName;
|
1454
|
+
var propValue;
|
1455
|
+
var deep = 1 & args[0];
|
1456
|
+
var i = 1 + deep;
|
1457
|
+
target = args[i - 1] || {};
|
1458
|
+
|
1459
|
+
for (; i < args.length; i++) {
|
1460
|
+
// Only deal with non-null/undefined values
|
1461
|
+
if (options = args[i]) {
|
1462
|
+
// Extend the base object
|
1463
|
+
for (propName in options) {
|
1464
|
+
propValue = options[propName];
|
1465
|
+
|
1466
|
+
if (propValue !== undefined) {
|
1467
|
+
propValue = options[propName];
|
1468
|
+
target[propName] = (deep && IsPlainObject(target[propName])) ? Extend(deep, {}, propValue) : propValue;
|
1469
|
+
}
|
1470
|
+
}
|
1471
|
+
}
|
1472
|
+
}
|
1473
|
+
|
1474
|
+
// Return the modified object
|
1475
|
+
return target;
|
1476
|
+
}
|
1477
|
+
|
1478
|
+
_This.$Extend = Extend;
|
1479
|
+
|
1480
|
+
function Unextend(target, option) {
|
1481
|
+
$JssorDebug$.$Assert(option);
|
1482
|
+
|
1483
|
+
var unextended = {};
|
1484
|
+
var name;
|
1485
|
+
var targetProp;
|
1486
|
+
var optionProp;
|
1487
|
+
|
1488
|
+
// Extend the base object
|
1489
|
+
for (name in target) {
|
1490
|
+
targetProp = target[name];
|
1491
|
+
optionProp = option[name];
|
1492
|
+
|
1493
|
+
if (targetProp !== optionProp) {
|
1494
|
+
var exclude;
|
1495
|
+
|
1496
|
+
if (IsPlainObject(targetProp) && IsPlainObject(optionProp)) {
|
1497
|
+
targetProp = Unextend(optionProp);
|
1498
|
+
exclude = !IsNotEmpty(targetProp);
|
1499
|
+
}
|
1500
|
+
|
1501
|
+
!exclude && (unextended[name] = targetProp);
|
1502
|
+
}
|
1503
|
+
}
|
1504
|
+
|
1505
|
+
// Return the modified object
|
1506
|
+
return unextended;
|
1507
|
+
}
|
1508
|
+
|
1509
|
+
_This.$Unextend = Unextend;
|
1510
|
+
|
1511
|
+
_This.$IsFunction = function (obj) {
|
1512
|
+
return Type(obj) == "function";
|
1513
|
+
};
|
1514
|
+
|
1515
|
+
_This.$IsArray = function (obj) {
|
1516
|
+
return Type(obj) == "array";
|
1517
|
+
};
|
1518
|
+
|
1519
|
+
_This.$IsString = function (obj) {
|
1520
|
+
return Type(obj) == "string";
|
1521
|
+
};
|
1522
|
+
|
1523
|
+
_This.$IsNumeric = function (obj) {
|
1524
|
+
return !isNaN(ParseFloat(obj)) && isFinite(obj);
|
1525
|
+
};
|
1526
|
+
|
1527
|
+
_This.$Type = Type;
|
1528
|
+
|
1529
|
+
// args is for internal usage only
|
1530
|
+
_This.$Each = Each;
|
1531
|
+
|
1532
|
+
_This.$IsNotEmpty = IsNotEmpty;
|
1533
|
+
|
1534
|
+
_This.$IsPlainObject = IsPlainObject;
|
1535
|
+
|
1536
|
+
function CreateElement(tagName) {
|
1537
|
+
return document.createElement(tagName);
|
1538
|
+
}
|
1539
|
+
|
1540
|
+
_This.$CreateElement = CreateElement;
|
1541
|
+
|
1542
|
+
_This.$CreateDiv = function () {
|
1543
|
+
return CreateElement("DIV");
|
1544
|
+
};
|
1545
|
+
|
1546
|
+
_This.$CreateSpan = function () {
|
1547
|
+
return CreateElement("SPAN");
|
1548
|
+
};
|
1549
|
+
|
1550
|
+
_This.$EmptyFunction = function () { };
|
1551
|
+
|
1552
|
+
function Attribute(elmt, name, value) {
|
1553
|
+
if (value == undefined)
|
1554
|
+
return elmt.getAttribute(name);
|
1555
|
+
|
1556
|
+
elmt.setAttribute(name, value);
|
1557
|
+
}
|
1558
|
+
|
1559
|
+
function AttributeEx(elmt, name) {
|
1560
|
+
return Attribute(elmt, name) || Attribute(elmt, "data-" + name);
|
1561
|
+
}
|
1562
|
+
|
1563
|
+
_This.$Attribute = Attribute;
|
1564
|
+
_This.$AttributeEx = AttributeEx;
|
1565
|
+
|
1566
|
+
function ClassName(elmt, className) {
|
1567
|
+
if (className == undefined)
|
1568
|
+
return elmt.className;
|
1569
|
+
|
1570
|
+
elmt.className = className;
|
1571
|
+
}
|
1572
|
+
|
1573
|
+
_This.$ClassName = ClassName;
|
1574
|
+
|
1575
|
+
function ToHash(array) {
|
1576
|
+
var hash = {};
|
1577
|
+
|
1578
|
+
Each(array, function (item) {
|
1579
|
+
hash[item] = item;
|
1580
|
+
});
|
1581
|
+
|
1582
|
+
return hash;
|
1583
|
+
}
|
1584
|
+
|
1585
|
+
function Split(str, separator) {
|
1586
|
+
return str.match(separator || REGEX_WHITESPACE_GLOBAL);
|
1587
|
+
}
|
1588
|
+
|
1589
|
+
function StringToHashObject(str, regExp) {
|
1590
|
+
return ToHash(Split(str || "", regExp));
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
_This.$ToHash = ToHash;
|
1594
|
+
_This.$Split = Split;
|
1595
|
+
|
1596
|
+
function Join(separator, strings) {
|
1597
|
+
/// <param name="separator" type="String">
|
1598
|
+
/// </param>
|
1599
|
+
/// <param name="strings" type="Array" value="['1']">
|
1600
|
+
/// </param>
|
1601
|
+
|
1602
|
+
var joined = "";
|
1603
|
+
|
1604
|
+
Each(strings, function (str) {
|
1605
|
+
joined && (joined += separator);
|
1606
|
+
joined += str;
|
1607
|
+
});
|
1608
|
+
|
1609
|
+
return joined;
|
1610
|
+
}
|
1611
|
+
|
1612
|
+
function ReplaceClass(elmt, oldClassName, newClassName) {
|
1613
|
+
ClassName(elmt, Join(" ", Extend(Unextend(StringToHashObject(ClassName(elmt)), StringToHashObject(oldClassName)), StringToHashObject(newClassName))));
|
1614
|
+
}
|
1615
|
+
|
1616
|
+
_This.$Join = Join;
|
1617
|
+
|
1618
|
+
_This.$AddClass = function (elmt, className) {
|
1619
|
+
ReplaceClass(elmt, null, className);
|
1620
|
+
};
|
1621
|
+
|
1622
|
+
_This.$RemoveClass = ReplaceClass;
|
1623
|
+
|
1624
|
+
_This.$ReplaceClass = ReplaceClass;
|
1625
|
+
|
1626
|
+
_This.$ParentNode = function (elmt) {
|
1627
|
+
return elmt.parentNode;
|
1628
|
+
};
|
1629
|
+
|
1630
|
+
_This.$HideElement = function (elmt) {
|
1631
|
+
_This.$CssDisplay(elmt, "none");
|
1632
|
+
};
|
1633
|
+
|
1634
|
+
_This.$EnableElement = function (elmt, notEnable) {
|
1635
|
+
if (notEnable) {
|
1636
|
+
_This.$Attribute(elmt, "disabled", true);
|
1637
|
+
}
|
1638
|
+
else {
|
1639
|
+
_This.$RemoveAttribute(elmt, "disabled");
|
1640
|
+
}
|
1641
|
+
};
|
1642
|
+
|
1643
|
+
_This.$HideElements = function (elmts) {
|
1644
|
+
for (var i = 0; i < elmts.length; i++) {
|
1645
|
+
_This.$HideElement(elmts[i]);
|
1646
|
+
}
|
1647
|
+
};
|
1648
|
+
|
1649
|
+
_This.$ShowElement = function (elmt, hide) {
|
1650
|
+
_This.$CssDisplay(elmt, hide ? "none" : "");
|
1651
|
+
};
|
1652
|
+
|
1653
|
+
_This.$ShowElements = function (elmts, hide) {
|
1654
|
+
for (var i = 0; i < elmts.length; i++) {
|
1655
|
+
_This.$ShowElement(elmts[i], hide);
|
1656
|
+
}
|
1657
|
+
};
|
1658
|
+
|
1659
|
+
_This.$RemoveAttribute = function (elmt, attrbuteName) {
|
1660
|
+
elmt.removeAttribute(attrbuteName);
|
1661
|
+
};
|
1662
|
+
|
1663
|
+
_This.$CanClearClip = function () {
|
1664
|
+
return IsBrowserIE() && _BrowserRuntimeVersion < 10;
|
1665
|
+
};
|
1666
|
+
|
1667
|
+
_This.$SetStyleClip = function (elmt, clip) {
|
1668
|
+
if (clip) {
|
1669
|
+
elmt.style.clip = "rect(" + Math.round(clip.$Top) + "px " + Math.round(clip.$Right) + "px " + Math.round(clip.$Bottom) + "px " + Math.round(clip.$Left) + "px)";
|
1670
|
+
}
|
1671
|
+
else {
|
1672
|
+
var cssText = elmt.style.cssText;
|
1673
|
+
var clipRegs = [
|
1674
|
+
new RegExp(/[\s]*clip: rect\(.*?\)[;]?/i),
|
1675
|
+
new RegExp(/[\s]*cliptop: .*?[;]?/i),
|
1676
|
+
new RegExp(/[\s]*clipright: .*?[;]?/i),
|
1677
|
+
new RegExp(/[\s]*clipbottom: .*?[;]?/i),
|
1678
|
+
new RegExp(/[\s]*clipleft: .*?[;]?/i)
|
1679
|
+
];
|
1680
|
+
|
1681
|
+
var newCssText = BuildNewCss(cssText, clipRegs, "");
|
1682
|
+
|
1683
|
+
$Jssor$.$CssCssText(elmt, newCssText);
|
1684
|
+
}
|
1685
|
+
};
|
1686
|
+
|
1687
|
+
_This.$GetNow = function () {
|
1688
|
+
return new Date().getTime();
|
1689
|
+
};
|
1690
|
+
|
1691
|
+
_This.$AppendChild = function (elmt, child) {
|
1692
|
+
elmt.appendChild(child);
|
1693
|
+
};
|
1694
|
+
|
1695
|
+
_This.$AppendChildren = function (elmt, children) {
|
1696
|
+
Each(children, function (child) {
|
1697
|
+
_This.$AppendChild(elmt, child);
|
1698
|
+
});
|
1699
|
+
};
|
1700
|
+
|
1701
|
+
_This.$InsertBefore = function (newNode, refNode, pNode) {
|
1702
|
+
/// <summary>
|
1703
|
+
/// Insert a node before a reference node
|
1704
|
+
/// </summary>
|
1705
|
+
/// <param name="newNode" type="HTMLElement">
|
1706
|
+
/// A new node to insert
|
1707
|
+
/// </param>
|
1708
|
+
/// <param name="refNode" type="HTMLElement">
|
1709
|
+
/// The reference node to insert a new node before
|
1710
|
+
/// </param>
|
1711
|
+
/// <param name="pNode" type="HTMLElement" optional="true">
|
1712
|
+
/// The parent node to insert node to
|
1713
|
+
/// </param>
|
1714
|
+
|
1715
|
+
(pNode || refNode.parentNode).insertBefore(newNode, refNode);
|
1716
|
+
};
|
1717
|
+
|
1718
|
+
_This.$InsertAfter = function (newNode, refNode, pNode) {
|
1719
|
+
/// <summary>
|
1720
|
+
/// Insert a node after a reference node
|
1721
|
+
/// </summary>
|
1722
|
+
/// <param name="newNode" type="HTMLElement">
|
1723
|
+
/// A new node to insert
|
1724
|
+
/// </param>
|
1725
|
+
/// <param name="refNode" type="HTMLElement">
|
1726
|
+
/// The reference node to insert a new node after
|
1727
|
+
/// </param>
|
1728
|
+
/// <param name="pNode" type="HTMLElement" optional="true">
|
1729
|
+
/// The parent node to insert node to
|
1730
|
+
/// </param>
|
1731
|
+
|
1732
|
+
_This.$InsertBefore(newNode, refNode.nextSibling, pNode || refNode.parentNode);
|
1733
|
+
};
|
1734
|
+
|
1735
|
+
_This.$InsertAdjacentHtml = function (elmt, where, html) {
|
1736
|
+
elmt.insertAdjacentHTML(where, html);
|
1737
|
+
};
|
1738
|
+
|
1739
|
+
_This.$RemoveElement = function (elmt, pNode) {
|
1740
|
+
/// <summary>
|
1741
|
+
/// Remove element from parent node
|
1742
|
+
/// </summary>
|
1743
|
+
/// <param name="elmt" type="HTMLElement">
|
1744
|
+
/// The element to remove
|
1745
|
+
/// </param>
|
1746
|
+
/// <param name="pNode" type="HTMLElement" optional="true">
|
1747
|
+
/// The parent node to remove elment from
|
1748
|
+
/// </param>
|
1749
|
+
(pNode || elmt.parentNode).removeChild(elmt);
|
1750
|
+
};
|
1751
|
+
|
1752
|
+
_This.$RemoveElements = function (elmts, pNode) {
|
1753
|
+
Each(elmts, function (elmt) {
|
1754
|
+
_This.$RemoveElement(elmt, pNode);
|
1755
|
+
});
|
1756
|
+
};
|
1757
|
+
|
1758
|
+
_This.$Empty = function (elmt) {
|
1759
|
+
_This.$RemoveElements(_This.$Children(elmt, true), elmt);
|
1760
|
+
};
|
1761
|
+
|
1762
|
+
_This.$ParseInt = function (str, radix) {
|
1763
|
+
return parseInt(str, radix || 10);
|
1764
|
+
};
|
1765
|
+
|
1766
|
+
var ParseFloat = parseFloat;
|
1767
|
+
|
1768
|
+
_This.$ParseFloat = ParseFloat;
|
1769
|
+
|
1770
|
+
_This.$IsChild = function (elmtA, elmtB) {
|
1771
|
+
var body = document.body;
|
1772
|
+
|
1773
|
+
while (elmtB && elmtA !== elmtB && body !== elmtB) {
|
1774
|
+
try {
|
1775
|
+
elmtB = elmtB.parentNode;
|
1776
|
+
} catch (e) {
|
1777
|
+
// Firefox sometimes fires events for XUL elements, which throws
|
1778
|
+
// a "permission denied" error. so this is not a child.
|
1779
|
+
return false;
|
1780
|
+
}
|
1781
|
+
}
|
1782
|
+
|
1783
|
+
return elmtA === elmtB;
|
1784
|
+
};
|
1785
|
+
|
1786
|
+
function CloneNode(elmt, noDeep, keepId) {
|
1787
|
+
var clone = elmt.cloneNode(!noDeep);
|
1788
|
+
if (!keepId) {
|
1789
|
+
_This.$RemoveAttribute(clone, "id");
|
1790
|
+
}
|
1791
|
+
|
1792
|
+
return clone;
|
1793
|
+
}
|
1794
|
+
|
1795
|
+
_This.$CloneNode = CloneNode;
|
1796
|
+
|
1797
|
+
_This.$LoadImage = function (src, callback) {
|
1798
|
+
var image = new Image();
|
1799
|
+
|
1800
|
+
function LoadImageCompleteHandler(event, abort) {
|
1801
|
+
_This.$RemoveEvent(image, "load", LoadImageCompleteHandler);
|
1802
|
+
_This.$RemoveEvent(image, "abort", ErrorOrAbortHandler);
|
1803
|
+
_This.$RemoveEvent(image, "error", ErrorOrAbortHandler);
|
1804
|
+
|
1805
|
+
if (callback)
|
1806
|
+
callback(image, abort);
|
1807
|
+
}
|
1808
|
+
|
1809
|
+
function ErrorOrAbortHandler(event) {
|
1810
|
+
LoadImageCompleteHandler(event, true);
|
1811
|
+
}
|
1812
|
+
|
1813
|
+
if (IsBrowserOpera() && _BrowserRuntimeVersion < 11.6 || !src) {
|
1814
|
+
LoadImageCompleteHandler(!src);
|
1815
|
+
}
|
1816
|
+
else {
|
1817
|
+
|
1818
|
+
_This.$AddEvent(image, "load", LoadImageCompleteHandler);
|
1819
|
+
_This.$AddEvent(image, "abort", ErrorOrAbortHandler);
|
1820
|
+
_This.$AddEvent(image, "error", ErrorOrAbortHandler);
|
1821
|
+
|
1822
|
+
image.src = src;
|
1823
|
+
}
|
1824
|
+
};
|
1825
|
+
|
1826
|
+
_This.$LoadImages = function (imageElmts, mainImageElmt, callback) {
|
1827
|
+
|
1828
|
+
var _ImageLoading = imageElmts.length + 1;
|
1829
|
+
|
1830
|
+
function LoadImageCompleteEventHandler(image, abort) {
|
1831
|
+
|
1832
|
+
_ImageLoading--;
|
1833
|
+
if (mainImageElmt && image && image.src == mainImageElmt.src)
|
1834
|
+
mainImageElmt = image;
|
1835
|
+
!_ImageLoading && callback && callback(mainImageElmt);
|
1836
|
+
}
|
1837
|
+
|
1838
|
+
Each(imageElmts, function (imageElmt) {
|
1839
|
+
_This.$LoadImage(imageElmt.src, LoadImageCompleteEventHandler);
|
1840
|
+
});
|
1841
|
+
|
1842
|
+
LoadImageCompleteEventHandler();
|
1843
|
+
};
|
1844
|
+
|
1845
|
+
_This.$BuildElement = function (template, tagName, replacer, createCopy) {
|
1846
|
+
if (createCopy)
|
1847
|
+
template = CloneNode(template);
|
1848
|
+
|
1849
|
+
var templateHolders = FindChildren(template, tagName);
|
1850
|
+
if (!templateHolders.length)
|
1851
|
+
templateHolders = $Jssor$.$GetElementsByTag(template, tagName);
|
1852
|
+
|
1853
|
+
for (var j = templateHolders.length - 1; j > -1; j--) {
|
1854
|
+
var templateHolder = templateHolders[j];
|
1855
|
+
var replaceItem = CloneNode(replacer);
|
1856
|
+
ClassName(replaceItem, ClassName(templateHolder));
|
1857
|
+
$Jssor$.$CssCssText(replaceItem, templateHolder.style.cssText);
|
1858
|
+
|
1859
|
+
$Jssor$.$InsertBefore(replaceItem, templateHolder);
|
1860
|
+
$Jssor$.$RemoveElement(templateHolder);
|
1861
|
+
}
|
1862
|
+
|
1863
|
+
return template;
|
1864
|
+
};
|
1865
|
+
|
1866
|
+
function JssorButtonEx(elmt) {
|
1867
|
+
var _Self = this;
|
1868
|
+
|
1869
|
+
var _OriginClassName = "";
|
1870
|
+
var _ToggleClassSuffixes = ["av", "pv", "ds", "dn"];
|
1871
|
+
var _ToggleClasses = [];
|
1872
|
+
var _ToggleClassName;
|
1873
|
+
|
1874
|
+
var _IsMouseDown = 0; //class name 'dn'
|
1875
|
+
var _IsSelected = 0; //class name 1(active): 'av', 2(passive): 'pv'
|
1876
|
+
var _IsDisabled = 0; //class name 'ds'
|
1877
|
+
|
1878
|
+
function Highlight() {
|
1879
|
+
ReplaceClass(elmt, _ToggleClassName, _ToggleClasses[_IsDisabled || _IsMouseDown || (_IsSelected & 2) || _IsSelected]);
|
1880
|
+
}
|
1881
|
+
|
1882
|
+
function MouseUpOrCancelEventHandler(event) {
|
1883
|
+
_IsMouseDown = 0;
|
1884
|
+
|
1885
|
+
Highlight();
|
1886
|
+
|
1887
|
+
_This.$RemoveEvent(document, "mouseup", MouseUpOrCancelEventHandler);
|
1888
|
+
_This.$RemoveEvent(document, "touchend", MouseUpOrCancelEventHandler);
|
1889
|
+
_This.$RemoveEvent(document, "touchcancel", MouseUpOrCancelEventHandler);
|
1890
|
+
}
|
1891
|
+
|
1892
|
+
function MouseDownEventHandler(event) {
|
1893
|
+
if (_IsDisabled) {
|
1894
|
+
_This.$CancelEvent(event);
|
1895
|
+
}
|
1896
|
+
else {
|
1897
|
+
|
1898
|
+
_IsMouseDown = 4;
|
1899
|
+
|
1900
|
+
Highlight();
|
1901
|
+
|
1902
|
+
_This.$AddEvent(document, "mouseup", MouseUpOrCancelEventHandler);
|
1903
|
+
_This.$AddEvent(document, "touchend", MouseUpOrCancelEventHandler);
|
1904
|
+
_This.$AddEvent(document, "touchcancel", MouseUpOrCancelEventHandler);
|
1905
|
+
}
|
1906
|
+
}
|
1907
|
+
|
1908
|
+
_Self.$Selected = function (activate) {
|
1909
|
+
if (activate != undefined) {
|
1910
|
+
_IsSelected = (activate & 2) || (activate & 1);
|
1911
|
+
|
1912
|
+
Highlight();
|
1913
|
+
}
|
1914
|
+
else {
|
1915
|
+
return _IsSelected;
|
1916
|
+
}
|
1917
|
+
};
|
1918
|
+
|
1919
|
+
_Self.$Enable = function (enable) {
|
1920
|
+
if (enable == undefined) {
|
1921
|
+
return !_IsDisabled;
|
1922
|
+
}
|
1923
|
+
|
1924
|
+
_IsDisabled = enable ? 0 : 3;
|
1925
|
+
|
1926
|
+
Highlight();
|
1927
|
+
};
|
1928
|
+
|
1929
|
+
//JssorButtonEx Constructor
|
1930
|
+
{
|
1931
|
+
elmt = _This.$GetElement(elmt);
|
1932
|
+
|
1933
|
+
var originalClassNameArray = $Jssor$.$Split(ClassName(elmt));
|
1934
|
+
if (originalClassNameArray)
|
1935
|
+
_OriginClassName = originalClassNameArray.shift();
|
1936
|
+
|
1937
|
+
Each(_ToggleClassSuffixes, function (toggleClassSuffix) {
|
1938
|
+
_ToggleClasses.push(_OriginClassName +toggleClassSuffix);
|
1939
|
+
});
|
1940
|
+
|
1941
|
+
_ToggleClassName = Join(" ", _ToggleClasses);
|
1942
|
+
|
1943
|
+
_ToggleClasses.unshift("");
|
1944
|
+
|
1945
|
+
_This.$AddEvent(elmt, "mousedown", MouseDownEventHandler);
|
1946
|
+
_This.$AddEvent(elmt, "touchstart", MouseDownEventHandler);
|
1947
|
+
}
|
1948
|
+
}
|
1949
|
+
|
1950
|
+
_This.$Buttonize = function (elmt) {
|
1951
|
+
return new JssorButtonEx(elmt);
|
1952
|
+
};
|
1953
|
+
|
1954
|
+
_This.$Css = Css;
|
1955
|
+
_This.$CssN = CssN;
|
1956
|
+
_This.$CssP = CssP;
|
1957
|
+
|
1958
|
+
_This.$CssOverflow = CssProxy("overflow");
|
1959
|
+
|
1960
|
+
_This.$CssTop = CssProxy("top", 2);
|
1961
|
+
_This.$CssLeft = CssProxy("left", 2);
|
1962
|
+
_This.$CssWidth = CssProxy("width", 2);
|
1963
|
+
_This.$CssHeight = CssProxy("height", 2);
|
1964
|
+
_This.$CssMarginLeft = CssProxy("marginLeft", 2);
|
1965
|
+
_This.$CssMarginTop = CssProxy("marginTop", 2);
|
1966
|
+
_This.$CssPosition = CssProxy("position");
|
1967
|
+
_This.$CssDisplay = CssProxy("display");
|
1968
|
+
_This.$CssZIndex = CssProxy("zIndex", 1);
|
1969
|
+
_This.$CssFloat = function (elmt, floatValue) {
|
1970
|
+
return Css(elmt, IsBrowserIE() ? "styleFloat" : "cssFloat", floatValue);
|
1971
|
+
};
|
1972
|
+
_This.$CssOpacity = function (elmt, opacity, ie9EarlierForce) {
|
1973
|
+
if (opacity != undefined) {
|
1974
|
+
SetStyleOpacity(elmt, opacity, ie9EarlierForce);
|
1975
|
+
}
|
1976
|
+
else {
|
1977
|
+
return GetStyleOpacity(elmt);
|
1978
|
+
}
|
1979
|
+
};
|
1980
|
+
|
1981
|
+
_This.$CssCssText = function (elmt, text) {
|
1982
|
+
if (text != undefined) {
|
1983
|
+
elmt.style.cssText = text;
|
1984
|
+
}
|
1985
|
+
else {
|
1986
|
+
return elmt.style.cssText;
|
1987
|
+
}
|
1988
|
+
};
|
1989
|
+
|
1990
|
+
var _StyleGetter = {
|
1991
|
+
$Opacity: _This.$CssOpacity,
|
1992
|
+
$Top: _This.$CssTop,
|
1993
|
+
$Left: _This.$CssLeft,
|
1994
|
+
$Width: _This.$CssWidth,
|
1995
|
+
$Height: _This.$CssHeight,
|
1996
|
+
$Position: _This.$CssPosition,
|
1997
|
+
$Display: _This.$CssDisplay,
|
1998
|
+
$ZIndex: _This.$CssZIndex
|
1999
|
+
};
|
2000
|
+
|
2001
|
+
var _StyleSetterReserved;
|
2002
|
+
|
2003
|
+
function StyleSetter() {
|
2004
|
+
if (!_StyleSetterReserved) {
|
2005
|
+
_StyleSetterReserved = Extend({
|
2006
|
+
$MarginTop: _This.$CssMarginTop,
|
2007
|
+
$MarginLeft: _This.$CssMarginLeft,
|
2008
|
+
$Clip: _This.$SetStyleClip,
|
2009
|
+
$Transform: _This.$SetStyleTransform
|
2010
|
+
}, _StyleGetter);
|
2011
|
+
}
|
2012
|
+
return _StyleSetterReserved;
|
2013
|
+
}
|
2014
|
+
|
2015
|
+
function StyleSetterEx() {
|
2016
|
+
StyleSetter();
|
2017
|
+
|
2018
|
+
//For Compression Only
|
2019
|
+
_StyleSetterReserved.$Transform = _StyleSetterReserved.$Transform;
|
2020
|
+
|
2021
|
+
return _StyleSetterReserved;
|
2022
|
+
}
|
2023
|
+
|
2024
|
+
_This.$StyleSetter = StyleSetter;
|
2025
|
+
|
2026
|
+
_This.$StyleSetterEx = StyleSetterEx;
|
2027
|
+
|
2028
|
+
_This.$GetStyles = function (elmt, originStyles) {
|
2029
|
+
StyleSetter();
|
2030
|
+
|
2031
|
+
var styles = {};
|
2032
|
+
|
2033
|
+
Each(originStyles, function (value, key) {
|
2034
|
+
if (_StyleGetter[key]) {
|
2035
|
+
styles[key] = _StyleGetter[key](elmt);
|
2036
|
+
}
|
2037
|
+
});
|
2038
|
+
|
2039
|
+
return styles;
|
2040
|
+
};
|
2041
|
+
|
2042
|
+
_This.$SetStyles = function (elmt, styles) {
|
2043
|
+
var styleSetter = StyleSetter();
|
2044
|
+
|
2045
|
+
Each(styles, function (value, key) {
|
2046
|
+
styleSetter[key] && styleSetter[key](elmt, value);
|
2047
|
+
});
|
2048
|
+
};
|
2049
|
+
|
2050
|
+
_This.$SetStylesEx = function (elmt, styles) {
|
2051
|
+
StyleSetterEx();
|
2052
|
+
|
2053
|
+
_This.$SetStyles(elmt, styles);
|
2054
|
+
};
|
2055
|
+
|
2056
|
+
var $JssorMatrix$ = new function () {
|
2057
|
+
var _ThisMatrix = this;
|
2058
|
+
|
2059
|
+
function Multiply(ma, mb) {
|
2060
|
+
var acs = ma[0].length;
|
2061
|
+
var rows = ma.length;
|
2062
|
+
var cols = mb[0].length;
|
2063
|
+
|
2064
|
+
var matrix = [];
|
2065
|
+
|
2066
|
+
for (var r = 0; r < rows; r++) {
|
2067
|
+
var row = matrix[r] = [];
|
2068
|
+
for (var c = 0; c < cols; c++) {
|
2069
|
+
var unitValue = 0;
|
2070
|
+
|
2071
|
+
for (var ac = 0; ac < acs; ac++) {
|
2072
|
+
unitValue += ma[r][ac] * mb[ac][c];
|
2073
|
+
}
|
2074
|
+
|
2075
|
+
row[c] = unitValue;
|
2076
|
+
}
|
2077
|
+
}
|
2078
|
+
|
2079
|
+
return matrix;
|
2080
|
+
}
|
2081
|
+
|
2082
|
+
_ThisMatrix.$ScaleX = function (matrix, sx) {
|
2083
|
+
return _ThisMatrix.$ScaleXY(matrix, sx, 0);
|
2084
|
+
};
|
2085
|
+
|
2086
|
+
_ThisMatrix.$ScaleY = function (matrix, sy) {
|
2087
|
+
return _ThisMatrix.$ScaleXY(matrix, 0, sy);
|
2088
|
+
};
|
2089
|
+
|
2090
|
+
_ThisMatrix.$ScaleXY = function (matrix, sx, sy) {
|
2091
|
+
return Multiply(matrix, [[sx, 0], [0, sy]]);
|
2092
|
+
};
|
2093
|
+
|
2094
|
+
_ThisMatrix.$TransformPoint = function (matrix, p) {
|
2095
|
+
var pMatrix = Multiply(matrix, [[p.x], [p.y]]);
|
2096
|
+
|
2097
|
+
return Point(pMatrix[0][0], pMatrix[1][0]);
|
2098
|
+
};
|
2099
|
+
};
|
2100
|
+
|
2101
|
+
_This.$CreateMatrix = function (alpha, scaleX, scaleY) {
|
2102
|
+
var cos = Math.cos(alpha);
|
2103
|
+
var sin = Math.sin(alpha);
|
2104
|
+
//var r11 = cos;
|
2105
|
+
//var r21 = sin;
|
2106
|
+
//var r12 = -sin;
|
2107
|
+
//var r22 = cos;
|
2108
|
+
|
2109
|
+
//var m11 = cos * scaleX;
|
2110
|
+
//var m12 = -sin * scaleY;
|
2111
|
+
//var m21 = sin * scaleX;
|
2112
|
+
//var m22 = cos * scaleY;
|
2113
|
+
|
2114
|
+
return [[cos * scaleX, -sin * scaleY], [sin * scaleX, cos * scaleY]];
|
2115
|
+
};
|
2116
|
+
|
2117
|
+
_This.$GetMatrixOffset = function (matrix, width, height) {
|
2118
|
+
var p1 = $JssorMatrix$.$TransformPoint(matrix, Point(-width / 2, -height / 2));
|
2119
|
+
var p2 = $JssorMatrix$.$TransformPoint(matrix, Point(width / 2, -height / 2));
|
2120
|
+
var p3 = $JssorMatrix$.$TransformPoint(matrix, Point(width / 2, height / 2));
|
2121
|
+
var p4 = $JssorMatrix$.$TransformPoint(matrix, Point(-width / 2, height / 2));
|
2122
|
+
|
2123
|
+
return Point(Math.min(p1.x, p2.x, p3.x, p4.x) + width / 2, Math.min(p1.y, p2.y, p3.y, p4.y) + height / 2);
|
2124
|
+
};
|
2125
|
+
|
2126
|
+
_This.$Cast = function (fromStyles, difStyles, interPosition, easings, durings, rounds, options) {
|
2127
|
+
|
2128
|
+
var currentStyles = difStyles;
|
2129
|
+
|
2130
|
+
if (fromStyles) {
|
2131
|
+
currentStyles = {};
|
2132
|
+
|
2133
|
+
for (var key in difStyles) {
|
2134
|
+
|
2135
|
+
var round = rounds[key] || 1;
|
2136
|
+
var during = durings[key] || [0, 1];
|
2137
|
+
var propertyInterPosition = (interPosition - during[0]) / during[1];
|
2138
|
+
propertyInterPosition = Math.min(Math.max(propertyInterPosition, 0), 1);
|
2139
|
+
propertyInterPosition = propertyInterPosition * round;
|
2140
|
+
var floorPosition = Math.floor(propertyInterPosition);
|
2141
|
+
if (propertyInterPosition != floorPosition)
|
2142
|
+
propertyInterPosition -= floorPosition;
|
2143
|
+
|
2144
|
+
var easing = easings[key] || easings.$Default || $JssorEasing$.$EaseSwing;
|
2145
|
+
var easingValue = easing(propertyInterPosition);
|
2146
|
+
var currentPropertyValue;
|
2147
|
+
var value = fromStyles[key];
|
2148
|
+
var toValue = difStyles[key];
|
2149
|
+
var difValue = difStyles[key];
|
2150
|
+
|
2151
|
+
if ($Jssor$.$IsNumeric(difValue)) {
|
2152
|
+
currentPropertyValue = value + difValue * easingValue;
|
2153
|
+
}
|
2154
|
+
else {
|
2155
|
+
currentPropertyValue = $Jssor$.$Extend({ $Offset: {} }, fromStyles[key]);
|
2156
|
+
|
2157
|
+
$Jssor$.$Each(difValue.$Offset, function (rectX, n) {
|
2158
|
+
var offsetValue = rectX * easingValue;
|
2159
|
+
currentPropertyValue.$Offset[n] = offsetValue;
|
2160
|
+
currentPropertyValue[n] += offsetValue;
|
2161
|
+
});
|
2162
|
+
}
|
2163
|
+
currentStyles[key] = currentPropertyValue;
|
2164
|
+
}
|
2165
|
+
|
2166
|
+
if (difStyles.$Zoom || difStyles.$Rotate) {
|
2167
|
+
currentStyles.$Transform = { $Rotate: currentStyles.$Rotate || 0, $Scale: currentStyles.$Zoom, $OriginalWidth: options.$OriginalWidth, $OriginalHeight: options.$OriginalHeight };
|
2168
|
+
}
|
2169
|
+
}
|
2170
|
+
|
2171
|
+
if (difStyles.$Clip && options.$Move) {
|
2172
|
+
var styleFrameNClipOffset = currentStyles.$Clip.$Offset;
|
2173
|
+
|
2174
|
+
var offsetY = (styleFrameNClipOffset.$Top || 0) + (styleFrameNClipOffset.$Bottom || 0);
|
2175
|
+
var offsetX = (styleFrameNClipOffset.$Left || 0) + (styleFrameNClipOffset.$Right || 0);
|
2176
|
+
|
2177
|
+
currentStyles.$Left = (currentStyles.$Left || 0) + offsetX;
|
2178
|
+
currentStyles.$Top = (currentStyles.$Top || 0) + offsetY;
|
2179
|
+
currentStyles.$Clip.$Left -= offsetX;
|
2180
|
+
currentStyles.$Clip.$Right -= offsetX;
|
2181
|
+
currentStyles.$Clip.$Top -= offsetY;
|
2182
|
+
currentStyles.$Clip.$Bottom -= offsetY;
|
2183
|
+
}
|
2184
|
+
|
2185
|
+
if (currentStyles.$Clip && $Jssor$.$CanClearClip() && !currentStyles.$Clip.$Top && !currentStyles.$Clip.$Left && (currentStyles.$Clip.$Right == options.$OriginalWidth) && (currentStyles.$Clip.$Bottom == options.$OriginalHeight))
|
2186
|
+
currentStyles.$Clip = null;
|
2187
|
+
|
2188
|
+
return currentStyles;
|
2189
|
+
};
|
2190
|
+
};
|
2191
|
+
|
2192
|
+
//$JssorObject$
|
2193
|
+
function $JssorObject$() {
|
2194
|
+
var _ThisObject = this;
|
2195
|
+
// Fields
|
2196
|
+
|
2197
|
+
var _Listeners = []; // dictionary of eventName --> array of handlers
|
2198
|
+
var _Listenees = [];
|
2199
|
+
|
2200
|
+
// Private Methods
|
2201
|
+
function AddListener(eventName, handler) {
|
2202
|
+
|
2203
|
+
$JssorDebug$.$Execute(function () {
|
2204
|
+
if (eventName == undefined || eventName == null)
|
2205
|
+
throw new Error("param 'eventName' is null or empty.");
|
2206
|
+
|
2207
|
+
if (typeof (handler) != "function") {
|
2208
|
+
throw "param 'handler' must be a function.";
|
2209
|
+
}
|
2210
|
+
|
2211
|
+
$Jssor$.$Each(_Listeners, function (listener) {
|
2212
|
+
if (listener.$EventName == eventName && listener.$Handler === handler) {
|
2213
|
+
throw new Error("The handler listened to the event already, cannot listen to the same event of the same object with the same handler twice.");
|
2214
|
+
}
|
2215
|
+
});
|
2216
|
+
});
|
2217
|
+
|
2218
|
+
_Listeners.push({ $EventName: eventName, $Handler: handler });
|
2219
|
+
}
|
2220
|
+
|
2221
|
+
function RemoveListener(eventName, handler) {
|
2222
|
+
|
2223
|
+
$JssorDebug$.$Execute(function () {
|
2224
|
+
if (eventName == undefined || eventName == null)
|
2225
|
+
throw new Error("param 'eventName' is null or empty.");
|
2226
|
+
|
2227
|
+
if (typeof (handler) != "function") {
|
2228
|
+
throw "param 'handler' must be a function.";
|
2229
|
+
}
|
2230
|
+
});
|
2231
|
+
|
2232
|
+
$Jssor$.$Each(_Listeners, function (listener, index) {
|
2233
|
+
if (listener.$EventName == eventName && listener.$Handler === handler) {
|
2234
|
+
_Listeners.splice(index, 1);
|
2235
|
+
}
|
2236
|
+
});
|
2237
|
+
}
|
2238
|
+
|
2239
|
+
function ClearListeners() {
|
2240
|
+
_Listeners = [];
|
2241
|
+
}
|
2242
|
+
|
2243
|
+
function ClearListenees() {
|
2244
|
+
|
2245
|
+
$Jssor$.$Each(_Listenees, function (listenee) {
|
2246
|
+
$Jssor$.$RemoveEvent(listenee.$Obj, listenee.$EventName, listenee.$Handler);
|
2247
|
+
});
|
2248
|
+
|
2249
|
+
_Listenees = [];
|
2250
|
+
}
|
2251
|
+
|
2252
|
+
//Protected Methods
|
2253
|
+
_ThisObject.$Listen = function (obj, eventName, handler, useCapture) {
|
2254
|
+
|
2255
|
+
$JssorDebug$.$Execute(function () {
|
2256
|
+
if (!obj)
|
2257
|
+
throw new Error("param 'obj' is null or empty.");
|
2258
|
+
|
2259
|
+
if (eventName == undefined || eventName == null)
|
2260
|
+
throw new Error("param 'eventName' is null or empty.");
|
2261
|
+
|
2262
|
+
if (typeof (handler) != "function") {
|
2263
|
+
throw "param 'handler' must be a function.";
|
2264
|
+
}
|
2265
|
+
|
2266
|
+
$Jssor$.$Each(_Listenees, function (listenee) {
|
2267
|
+
if (listenee.$Obj === obj && listenee.$EventName == eventName && listenee.$Handler === handler) {
|
2268
|
+
throw new Error("The handler listened to the event already, cannot listen to the same event of the same object with the same handler twice.");
|
2269
|
+
}
|
2270
|
+
});
|
2271
|
+
});
|
2272
|
+
|
2273
|
+
$Jssor$.$AddEvent(obj, eventName, handler, useCapture);
|
2274
|
+
_Listenees.push({ $Obj: obj, $EventName: eventName, $Handler: handler });
|
2275
|
+
};
|
2276
|
+
|
2277
|
+
_ThisObject.$Unlisten = function (obj, eventName, handler) {
|
2278
|
+
|
2279
|
+
$JssorDebug$.$Execute(function () {
|
2280
|
+
if (!obj)
|
2281
|
+
throw new Error("param 'obj' is null or empty.");
|
2282
|
+
|
2283
|
+
if (eventName == undefined || eventName == null)
|
2284
|
+
throw new Error("param 'eventName' is null or empty.");
|
2285
|
+
|
2286
|
+
if (typeof (handler) != "function") {
|
2287
|
+
throw "param 'handler' must be a function.";
|
2288
|
+
}
|
2289
|
+
});
|
2290
|
+
|
2291
|
+
$Jssor$.$Each(_Listenees, function (listenee, index) {
|
2292
|
+
if (listenee.$Obj === obj && listenee.$EventName == eventName && listenee.$Handler === handler) {
|
2293
|
+
$Jssor$.$RemoveEvent(obj, eventName, handler);
|
2294
|
+
_Listenees.splice(index, 1);
|
2295
|
+
}
|
2296
|
+
});
|
2297
|
+
};
|
2298
|
+
|
2299
|
+
_ThisObject.$UnlistenAll = ClearListenees;
|
2300
|
+
|
2301
|
+
// Public Methods
|
2302
|
+
_ThisObject.$On = _ThisObject.addEventListener = AddListener;
|
2303
|
+
|
2304
|
+
_ThisObject.$Off = _ThisObject.removeEventListener = RemoveListener;
|
2305
|
+
|
2306
|
+
_ThisObject.$TriggerEvent = function (eventName) {
|
2307
|
+
|
2308
|
+
var args = [].slice.call(arguments, 1);
|
2309
|
+
|
2310
|
+
$Jssor$.$Each(_Listeners, function (listener) {
|
2311
|
+
listener.$EventName == eventName && listener.$Handler.apply(window, args);
|
2312
|
+
});
|
2313
|
+
};
|
2314
|
+
|
2315
|
+
_ThisObject.$Destroy = function () {
|
2316
|
+
ClearListenees();
|
2317
|
+
ClearListeners();
|
2318
|
+
|
2319
|
+
for (var name in _ThisObject)
|
2320
|
+
delete _ThisObject[name];
|
2321
|
+
};
|
2322
|
+
|
2323
|
+
$JssorDebug$.$C_AbstractClass(_ThisObject);
|
2324
|
+
};
|
2325
|
+
|
2326
|
+
function $JssorAnimator$(delay, duration, options, elmt, fromStyles, difStyles) {
|
2327
|
+
delay = delay || 0;
|
2328
|
+
|
2329
|
+
var _ThisAnimator = this;
|
2330
|
+
var _AutoPlay;
|
2331
|
+
var _Hiden;
|
2332
|
+
var _CombineMode;
|
2333
|
+
var _PlayToPosition;
|
2334
|
+
var _PlayDirection;
|
2335
|
+
var _NoStop;
|
2336
|
+
var _TimeStampLastFrame = 0;
|
2337
|
+
|
2338
|
+
var _SubEasings;
|
2339
|
+
var _SubRounds;
|
2340
|
+
var _SubDurings;
|
2341
|
+
var _Callback;
|
2342
|
+
|
2343
|
+
var _Shift = 0;
|
2344
|
+
var _Position_Current = 0;
|
2345
|
+
var _Position_Display = 0;
|
2346
|
+
var _Hooked;
|
2347
|
+
|
2348
|
+
var _Position_InnerBegin = delay;
|
2349
|
+
var _Position_InnerEnd = delay + duration;
|
2350
|
+
var _Position_OuterBegin;
|
2351
|
+
var _Position_OuterEnd;
|
2352
|
+
var _LoopLength;
|
2353
|
+
|
2354
|
+
var _NestedAnimators = [];
|
2355
|
+
var _StyleSetter;
|
2356
|
+
|
2357
|
+
function GetPositionRange(position, begin, end) {
|
2358
|
+
var range = 0;
|
2359
|
+
|
2360
|
+
if (position < begin)
|
2361
|
+
range = -1;
|
2362
|
+
|
2363
|
+
else if (position > end)
|
2364
|
+
range = 1;
|
2365
|
+
|
2366
|
+
return range;
|
2367
|
+
}
|
2368
|
+
|
2369
|
+
function GetInnerPositionRange(position) {
|
2370
|
+
return GetPositionRange(position, _Position_InnerBegin, _Position_InnerEnd);
|
2371
|
+
}
|
2372
|
+
|
2373
|
+
function GetOuterPositionRange(position) {
|
2374
|
+
return GetPositionRange(position, _Position_OuterBegin, _Position_OuterEnd);
|
2375
|
+
}
|
2376
|
+
|
2377
|
+
function Shift(offset) {
|
2378
|
+
_Position_OuterBegin += offset;
|
2379
|
+
_Position_OuterEnd += offset;
|
2380
|
+
_Position_InnerBegin += offset;
|
2381
|
+
_Position_InnerEnd += offset;
|
2382
|
+
|
2383
|
+
_Position_Current += offset;
|
2384
|
+
_Position_Display += offset;
|
2385
|
+
|
2386
|
+
_Shift = offset;
|
2387
|
+
}
|
2388
|
+
|
2389
|
+
function Locate(position, relative) {
|
2390
|
+
var offset = position - _Position_OuterBegin + delay * relative;
|
2391
|
+
|
2392
|
+
Shift(offset);
|
2393
|
+
|
2394
|
+
//$JssorDebug$.$Execute(function () {
|
2395
|
+
// _ThisAnimator.$Position_InnerBegin = _Position_InnerBegin;
|
2396
|
+
// _ThisAnimator.$Position_InnerEnd = _Position_InnerEnd;
|
2397
|
+
// _ThisAnimator.$Position_OuterBegin = _Position_OuterBegin;
|
2398
|
+
// _ThisAnimator.$Position_OuterEnd = _Position_OuterEnd;
|
2399
|
+
//});
|
2400
|
+
|
2401
|
+
return _Position_OuterEnd;
|
2402
|
+
}
|
2403
|
+
|
2404
|
+
function GoToPosition(positionOuter, force) {
|
2405
|
+
var trimedPositionOuter = positionOuter;
|
2406
|
+
|
2407
|
+
if (_LoopLength && (trimedPositionOuter >= _Position_OuterEnd || trimedPositionOuter <= _Position_OuterBegin)) {
|
2408
|
+
trimedPositionOuter = ((trimedPositionOuter - _Position_OuterBegin) % _LoopLength + _LoopLength) % _LoopLength + _Position_OuterBegin;
|
2409
|
+
}
|
2410
|
+
|
2411
|
+
if (!_Hooked || _NoStop || force || _Position_Current != trimedPositionOuter) {
|
2412
|
+
|
2413
|
+
var positionToDisplay = Math.min(trimedPositionOuter, _Position_OuterEnd);
|
2414
|
+
positionToDisplay = Math.max(positionToDisplay, _Position_OuterBegin);
|
2415
|
+
|
2416
|
+
if (!_Hooked || _NoStop || force || positionToDisplay != _Position_Display) {
|
2417
|
+
|
2418
|
+
if (difStyles) {
|
2419
|
+
|
2420
|
+
var interPosition = (positionToDisplay - _Position_InnerBegin) / (duration || 1);
|
2421
|
+
|
2422
|
+
if (options.$Reverse)
|
2423
|
+
interPosition = 1 - interPosition;
|
2424
|
+
|
2425
|
+
var currentStyles = $Jssor$.$Cast(fromStyles, difStyles, interPosition, _SubEasings, _SubDurings, _SubRounds, options);
|
2426
|
+
|
2427
|
+
$Jssor$.$Each(currentStyles, function (value, key) {
|
2428
|
+
_StyleSetter[key] && _StyleSetter[key](elmt, value);
|
2429
|
+
});
|
2430
|
+
}
|
2431
|
+
|
2432
|
+
_ThisAnimator.$OnInnerOffsetChange(_Position_Display - _Position_InnerBegin, positionToDisplay - _Position_InnerBegin);
|
2433
|
+
|
2434
|
+
_Position_Display = positionToDisplay;
|
2435
|
+
|
2436
|
+
$Jssor$.$Each(_NestedAnimators, function (animator, i) {
|
2437
|
+
var nestedAnimator = positionOuter < _Position_Current ? _NestedAnimators[_NestedAnimators.length - i - 1] : animator;
|
2438
|
+
nestedAnimator.$GoToPosition(_Position_Display - _Shift, force);
|
2439
|
+
});
|
2440
|
+
|
2441
|
+
var positionOld = _Position_Current;
|
2442
|
+
var positionNew = _Position_Display;
|
2443
|
+
|
2444
|
+
_Position_Current = trimedPositionOuter;
|
2445
|
+
_Hooked = true;
|
2446
|
+
|
2447
|
+
_ThisAnimator.$OnPositionChange(positionOld, positionNew);
|
2448
|
+
}
|
2449
|
+
}
|
2450
|
+
}
|
2451
|
+
|
2452
|
+
function Join(animator, combineMode, noExpand) {
|
2453
|
+
/// <summary>
|
2454
|
+
/// Combine another animator as nested animator
|
2455
|
+
/// </summary>
|
2456
|
+
/// <param name="animator" type="$JssorAnimator$">
|
2457
|
+
/// An instance of $JssorAnimator$
|
2458
|
+
/// </param>
|
2459
|
+
/// <param name="combineMode" type="int">
|
2460
|
+
/// 0: parallel - place the animator parallel to this animator.
|
2461
|
+
/// 1: chain - chain the animator at the _Position_InnerEnd of this animator.
|
2462
|
+
/// </param>
|
2463
|
+
$JssorDebug$.$Execute(function () {
|
2464
|
+
if (combineMode !== 0 && combineMode !== 1)
|
2465
|
+
$JssorDebug$.$Fail("Argument out of range, the value of 'combineMode' should be either 0 or 1.");
|
2466
|
+
});
|
2467
|
+
|
2468
|
+
if (combineMode)
|
2469
|
+
animator.$Locate(_Position_OuterEnd, 1);
|
2470
|
+
|
2471
|
+
if (!noExpand) {
|
2472
|
+
_Position_OuterBegin = Math.min(_Position_OuterBegin, animator.$GetPosition_OuterBegin() + _Shift);
|
2473
|
+
_Position_OuterEnd = Math.max(_Position_OuterEnd, animator.$GetPosition_OuterEnd() + _Shift);
|
2474
|
+
}
|
2475
|
+
_NestedAnimators.push(animator);
|
2476
|
+
}
|
2477
|
+
|
2478
|
+
var RequestAnimationFrame = window.requestAnimationFrame
|
2479
|
+
|| window.webkitRequestAnimationFrame
|
2480
|
+
|| window.mozRequestAnimationFrame
|
2481
|
+
|| window.msRequestAnimationFrame;
|
2482
|
+
|
2483
|
+
if ($Jssor$.$IsBrowserSafari() && $Jssor$.$BrowserVersion() < 7) {
|
2484
|
+
RequestAnimationFrame = null;
|
2485
|
+
|
2486
|
+
//$JssorDebug$.$Log("Custom animation frame for safari before 7.");
|
2487
|
+
}
|
2488
|
+
|
2489
|
+
RequestAnimationFrame = RequestAnimationFrame || function (callback) {
|
2490
|
+
$Jssor$.$Delay(callback, options.$Interval);
|
2491
|
+
};
|
2492
|
+
|
2493
|
+
function ShowFrame() {
|
2494
|
+
if (_AutoPlay) {
|
2495
|
+
var now = $Jssor$.$GetNow();
|
2496
|
+
var timeOffset = Math.min(now - _TimeStampLastFrame, options.$IntervalMax);
|
2497
|
+
var timePosition = _Position_Current + timeOffset * _PlayDirection;
|
2498
|
+
_TimeStampLastFrame = now;
|
2499
|
+
|
2500
|
+
if (timePosition * _PlayDirection >= _PlayToPosition * _PlayDirection)
|
2501
|
+
timePosition = _PlayToPosition;
|
2502
|
+
|
2503
|
+
GoToPosition(timePosition);
|
2504
|
+
|
2505
|
+
if (!_NoStop && timePosition * _PlayDirection >= _PlayToPosition * _PlayDirection) {
|
2506
|
+
Stop(_Callback);
|
2507
|
+
}
|
2508
|
+
else {
|
2509
|
+
RequestAnimationFrame(ShowFrame);
|
2510
|
+
}
|
2511
|
+
}
|
2512
|
+
}
|
2513
|
+
|
2514
|
+
function PlayToPosition(toPosition, callback, noStop) {
|
2515
|
+
if (!_AutoPlay) {
|
2516
|
+
_AutoPlay = true;
|
2517
|
+
_NoStop = noStop
|
2518
|
+
_Callback = callback;
|
2519
|
+
toPosition = Math.max(toPosition, _Position_OuterBegin);
|
2520
|
+
toPosition = Math.min(toPosition, _Position_OuterEnd);
|
2521
|
+
_PlayToPosition = toPosition;
|
2522
|
+
_PlayDirection = _PlayToPosition < _Position_Current ? -1 : 1;
|
2523
|
+
_ThisAnimator.$OnStart();
|
2524
|
+
_TimeStampLastFrame = $Jssor$.$GetNow();
|
2525
|
+
RequestAnimationFrame(ShowFrame);
|
2526
|
+
}
|
2527
|
+
}
|
2528
|
+
|
2529
|
+
function Stop(callback) {
|
2530
|
+
if (_AutoPlay) {
|
2531
|
+
_NoStop = _AutoPlay = _Callback = false;
|
2532
|
+
_ThisAnimator.$OnStop();
|
2533
|
+
|
2534
|
+
if (callback)
|
2535
|
+
callback();
|
2536
|
+
}
|
2537
|
+
}
|
2538
|
+
|
2539
|
+
_ThisAnimator.$Play = function (positionLength, callback, noStop) {
|
2540
|
+
PlayToPosition(positionLength ? _Position_Current + positionLength : _Position_OuterEnd, callback, noStop);
|
2541
|
+
};
|
2542
|
+
|
2543
|
+
_ThisAnimator.$PlayToPosition = PlayToPosition;
|
2544
|
+
|
2545
|
+
_ThisAnimator.$PlayToBegin = function (callback, noStop) {
|
2546
|
+
PlayToPosition(_Position_OuterBegin, callback, noStop);
|
2547
|
+
};
|
2548
|
+
|
2549
|
+
_ThisAnimator.$PlayToEnd = function (callback, noStop) {
|
2550
|
+
PlayToPosition(_Position_OuterEnd, callback, noStop);
|
2551
|
+
};
|
2552
|
+
|
2553
|
+
_ThisAnimator.$Stop = Stop;
|
2554
|
+
|
2555
|
+
_ThisAnimator.$Continue = function (toPosition) {
|
2556
|
+
PlayToPosition(toPosition);
|
2557
|
+
};
|
2558
|
+
|
2559
|
+
_ThisAnimator.$GetPosition = function () {
|
2560
|
+
return _Position_Current;
|
2561
|
+
};
|
2562
|
+
|
2563
|
+
_ThisAnimator.$GetPlayToPosition = function () {
|
2564
|
+
return _PlayToPosition;
|
2565
|
+
};
|
2566
|
+
|
2567
|
+
_ThisAnimator.$GetPosition_Display = function () {
|
2568
|
+
return _Position_Display;
|
2569
|
+
};
|
2570
|
+
|
2571
|
+
_ThisAnimator.$GoToPosition = GoToPosition;
|
2572
|
+
|
2573
|
+
_ThisAnimator.$GoToBegin = function () {
|
2574
|
+
GoToPosition(_Position_OuterBegin, true);
|
2575
|
+
};
|
2576
|
+
|
2577
|
+
_ThisAnimator.$GoToEnd = function () {
|
2578
|
+
GoToPosition(_Position_OuterEnd, true);
|
2579
|
+
};
|
2580
|
+
|
2581
|
+
_ThisAnimator.$Move = function (offset) {
|
2582
|
+
GoToPosition(_Position_Current + offset);
|
2583
|
+
};
|
2584
|
+
|
2585
|
+
_ThisAnimator.$CombineMode = function () {
|
2586
|
+
return _CombineMode;
|
2587
|
+
};
|
2588
|
+
|
2589
|
+
_ThisAnimator.$GetDuration = function () {
|
2590
|
+
return duration;
|
2591
|
+
};
|
2592
|
+
|
2593
|
+
_ThisAnimator.$IsPlaying = function () {
|
2594
|
+
return _AutoPlay;
|
2595
|
+
};
|
2596
|
+
|
2597
|
+
_ThisAnimator.$IsOnTheWay = function () {
|
2598
|
+
return _Position_Current > _Position_InnerBegin && _Position_Current <= _Position_InnerEnd;
|
2599
|
+
};
|
2600
|
+
|
2601
|
+
_ThisAnimator.$SetLoopLength = function (length) {
|
2602
|
+
_LoopLength = length;
|
2603
|
+
};
|
2604
|
+
|
2605
|
+
_ThisAnimator.$Locate = Locate;
|
2606
|
+
|
2607
|
+
_ThisAnimator.$Shift = Shift;
|
2608
|
+
|
2609
|
+
_ThisAnimator.$Join = Join;
|
2610
|
+
|
2611
|
+
_ThisAnimator.$Combine = function (animator) {
|
2612
|
+
/// <summary>
|
2613
|
+
/// Combine another animator parallel to this animator
|
2614
|
+
/// </summary>
|
2615
|
+
/// <param name="animator" type="$JssorAnimator$">
|
2616
|
+
/// An instance of $JssorAnimator$
|
2617
|
+
/// </param>
|
2618
|
+
Join(animator, 0);
|
2619
|
+
};
|
2620
|
+
|
2621
|
+
_ThisAnimator.$Chain = function (animator) {
|
2622
|
+
/// <summary>
|
2623
|
+
/// Chain another animator at the _Position_InnerEnd of this animator
|
2624
|
+
/// </summary>
|
2625
|
+
/// <param name="animator" type="$JssorAnimator$">
|
2626
|
+
/// An instance of $JssorAnimator$
|
2627
|
+
/// </param>
|
2628
|
+
Join(animator, 1);
|
2629
|
+
};
|
2630
|
+
|
2631
|
+
_ThisAnimator.$GetPosition_InnerBegin = function () {
|
2632
|
+
/// <summary>
|
2633
|
+
/// Internal member function, do not use it.
|
2634
|
+
/// </summary>
|
2635
|
+
/// <private />
|
2636
|
+
/// <returns type="int" />
|
2637
|
+
return _Position_InnerBegin;
|
2638
|
+
};
|
2639
|
+
|
2640
|
+
_ThisAnimator.$GetPosition_InnerEnd = function () {
|
2641
|
+
/// <summary>
|
2642
|
+
/// Internal member function, do not use it.
|
2643
|
+
/// </summary>
|
2644
|
+
/// <private />
|
2645
|
+
/// <returns type="int" />
|
2646
|
+
return _Position_InnerEnd;
|
2647
|
+
};
|
2648
|
+
|
2649
|
+
_ThisAnimator.$GetPosition_OuterBegin = function () {
|
2650
|
+
/// <summary>
|
2651
|
+
/// Internal member function, do not use it.
|
2652
|
+
/// </summary>
|
2653
|
+
/// <private />
|
2654
|
+
/// <returns type="int" />
|
2655
|
+
return _Position_OuterBegin;
|
2656
|
+
};
|
2657
|
+
|
2658
|
+
_ThisAnimator.$GetPosition_OuterEnd = function () {
|
2659
|
+
/// <summary>
|
2660
|
+
/// Internal member function, do not use it.
|
2661
|
+
/// </summary>
|
2662
|
+
/// <private />
|
2663
|
+
/// <returns type="int" />
|
2664
|
+
return _Position_OuterEnd;
|
2665
|
+
};
|
2666
|
+
|
2667
|
+
_ThisAnimator.$OnPositionChange = _ThisAnimator.$OnStart = _ThisAnimator.$OnStop = _ThisAnimator.$OnInnerOffsetChange = $Jssor$.$EmptyFunction;
|
2668
|
+
_ThisAnimator.$Version = $Jssor$.$GetNow();
|
2669
|
+
|
2670
|
+
//Constructor 1
|
2671
|
+
{
|
2672
|
+
options = $Jssor$.$Extend({
|
2673
|
+
$Interval: 16,
|
2674
|
+
$IntervalMax: 50
|
2675
|
+
}, options);
|
2676
|
+
|
2677
|
+
//Sodo statement, for development time intellisence only
|
2678
|
+
$JssorDebug$.$Execute(function () {
|
2679
|
+
options = $Jssor$.$Extend({
|
2680
|
+
$LoopLength: undefined,
|
2681
|
+
$Setter: undefined,
|
2682
|
+
$Easing: undefined
|
2683
|
+
}, options);
|
2684
|
+
});
|
2685
|
+
|
2686
|
+
_LoopLength = options.$LoopLength;
|
2687
|
+
|
2688
|
+
_StyleSetter = $Jssor$.$Extend({}, $Jssor$.$StyleSetter(), options.$Setter);
|
2689
|
+
|
2690
|
+
_Position_OuterBegin = _Position_InnerBegin = delay;
|
2691
|
+
_Position_OuterEnd = _Position_InnerEnd = delay + duration;
|
2692
|
+
|
2693
|
+
_SubRounds = options.$Round || {};
|
2694
|
+
_SubDurings = options.$During || {};
|
2695
|
+
_SubEasings = $Jssor$.$Extend({ $Default: $Jssor$.$IsFunction(options.$Easing) && options.$Easing || $JssorEasing$.$EaseSwing }, options.$Easing);
|
2696
|
+
}
|
2697
|
+
};
|
2698
|
+
|
2699
|
+
function $JssorPlayerClass$() {
|
2700
|
+
|
2701
|
+
var _ThisPlayer = this;
|
2702
|
+
var _PlayerControllers = [];
|
2703
|
+
|
2704
|
+
function PlayerController(playerElement) {
|
2705
|
+
var _SelfPlayerController = this;
|
2706
|
+
var _PlayerInstance;
|
2707
|
+
var _PlayerInstantces = [];
|
2708
|
+
|
2709
|
+
function OnPlayerInstanceDataAvailable(event) {
|
2710
|
+
var srcElement = $Jssor$.$EvtSrc(event);
|
2711
|
+
_PlayerInstance = srcElement.pInstance;
|
2712
|
+
|
2713
|
+
$Jssor$.$RemoveEvent(srcElement, "dataavailable", OnPlayerInstanceDataAvailable);
|
2714
|
+
$Jssor$.$Each(_PlayerInstantces, function (playerInstance) {
|
2715
|
+
if (playerInstance != _PlayerInstance) {
|
2716
|
+
playerInstance.$Remove();
|
2717
|
+
}
|
2718
|
+
});
|
2719
|
+
|
2720
|
+
playerElement.pTagName = _PlayerInstance.tagName;
|
2721
|
+
_PlayerInstantces = null;
|
2722
|
+
}
|
2723
|
+
|
2724
|
+
function HandlePlayerInstance(playerInstanceElement) {
|
2725
|
+
var playerHandler;
|
2726
|
+
|
2727
|
+
if (!playerInstanceElement.pInstance) {
|
2728
|
+
var playerHandlerAttribute = $Jssor$.$AttributeEx(playerInstanceElement, "pHandler");
|
2729
|
+
|
2730
|
+
if ($JssorPlayer$[playerHandlerAttribute]) {
|
2731
|
+
$Jssor$.$AddEvent(playerInstanceElement, "dataavailable", OnPlayerInstanceDataAvailable);
|
2732
|
+
playerHandler = new $JssorPlayer$[playerHandlerAttribute](playerElement, playerInstanceElement);
|
2733
|
+
_PlayerInstantces.push(playerHandler);
|
2734
|
+
|
2735
|
+
$JssorDebug$.$Execute(function () {
|
2736
|
+
if ($Jssor$.$Type(playerHandler.$Remove) != "function") {
|
2737
|
+
$JssorDebug$.$Fail("'pRemove' interface not implemented for player handler '" + playerHandlerAttribute + "'.");
|
2738
|
+
}
|
2739
|
+
});
|
2740
|
+
}
|
2741
|
+
}
|
2742
|
+
|
2743
|
+
return playerHandler;
|
2744
|
+
}
|
2745
|
+
|
2746
|
+
_SelfPlayerController.$InitPlayerController = function () {
|
2747
|
+
if (!playerElement.pInstance && !HandlePlayerInstance(playerElement)) {
|
2748
|
+
|
2749
|
+
var playerInstanceElements = $Jssor$.$Children(playerElement);
|
2750
|
+
|
2751
|
+
$Jssor$.$Each(playerInstanceElements, function (playerInstanceElement) {
|
2752
|
+
HandlePlayerInstance(playerInstanceElement);
|
2753
|
+
});
|
2754
|
+
}
|
2755
|
+
};
|
2756
|
+
}
|
2757
|
+
|
2758
|
+
_ThisPlayer.$EVT_SWITCH = 21;
|
2759
|
+
|
2760
|
+
_ThisPlayer.$FetchPlayers = function (elmt) {
|
2761
|
+
elmt = elmt || document.body;
|
2762
|
+
|
2763
|
+
var playerElements = $Jssor$.$FindChildren(elmt, "player");
|
2764
|
+
|
2765
|
+
$Jssor$.$Each(playerElements, function (playerElement) {
|
2766
|
+
if (!_PlayerControllers[playerElement.pId]) {
|
2767
|
+
playerElement.pId = _PlayerControllers.length;
|
2768
|
+
_PlayerControllers.push(new PlayerController(playerElement));
|
2769
|
+
}
|
2770
|
+
var playerController = _PlayerControllers[playerElement.pId];
|
2771
|
+
playerController.$InitPlayerController();
|
2772
|
+
});
|
2773
|
+
};
|
2774
|
+
}
|
2775
|
+
|