/*
* jssor 19.0
* http://www.jssor.com/
*
* licensed under the mit license:
* http://www.opensource.org/licenses/mit
*
* terms of use - jssor
*
* copyright 2014 jssor
*
* permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "software"), to deal in the software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the software, and to
* permit persons to whom the software is furnished to do so, subject to
* the following conditions:
*
* the above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the software.
*
* the software is provided "as is", without warranty of any kind,
* express or implied, including but not limited to the warranties of
* merchantability, fitness for a particular purpose and
* noninfringement. in no event shall the authors or copyright holders be
* liable for any claim, damages or other liability, whether in an action
* of contract, tort or otherwise, arising from, out of or in connection
* with the software or the use or other dealings in the software.
*/
/*! jssor */
//$jssordebug$
var $jssordebug$ = new function () {
this.$debugmode = true;
// methods
this.$log = function (msg, important) {
var console = window.console || {};
var debug = this.$debugmode;
if (debug && console.log) {
console.log(msg);
} else if (debug && important) {
alert(msg);
}
};
this.$error = function (msg, e) {
var console = window.console || {};
var debug = this.$debugmode;
if (debug && console.error) {
console.error(msg);
} else if (debug) {
alert(msg);
}
if (debug) {
// since we're debugging, fail fast by crashing
throw e || new error(msg);
}
};
this.$fail = function (msg) {
throw new error(msg);
};
this.$assert = function (value, msg) {
var debug = this.$debugmode;
if (debug) {
if (!value)
throw new error("assert failed " + msg || "");
}
};
this.$trace = function (msg) {
var console = window.console || {};
var debug = this.$debugmode;
if (debug && console.log) {
console.log(msg);
}
};
this.$execute = function (func) {
var debug = this.$debugmode;
if (debug)
func();
};
this.$livestamp = function (obj, id) {
var debug = this.$debugmode;
if (debug) {
var stamp = document.createelement("div");
stamp.setattribute("id", id);
obj.$live = stamp;
}
};
this.$c_abstractmethod = function () {
///
/// tells compiler the method is abstract, it should be implemented by subclass.
///
throw new error("the method is abstract, it should be implemented by subclass.");
};
function c_abstractclass(instance) {
///
/// tells compiler the class is abstract, it should be implemented by subclass.
///
if (instance.constructor === c_abstractclass.caller)
throw new error("cannot create instance of an abstract class.");
}
this.$c_abstractclass = c_abstractclass;
};
//$jssoreasing$
var $jssoreasing$ = window.$jssoreasing$ = {
$easelinear: function (t) {
return t;
},
$easegoback: function (t) {
return 1 - math.abs((t *= 2) - 1);
},
$easeswing: function (t) {
return -math.cos(t * math.pi) / 2 + .5;
},
$easeinquad: function (t) {
return t * t;
},
$easeoutquad: function (t) {
return -t * (t - 2);
},
$easeinoutquad: function (t) {
return (t *= 2) < 1 ? 1 / 2 * t * t : -1 / 2 * (--t * (t - 2) - 1);
},
$easeincubic: function (t) {
return t * t * t;
},
$easeoutcubic: function (t) {
return (t -= 1) * t * t + 1;
},
$easeinoutcubic: function (t) {
return (t *= 2) < 1 ? 1 / 2 * t * t * t : 1 / 2 * ((t -= 2) * t * t + 2);
},
$easeinquart: function (t) {
return t * t * t * t;
},
$easeoutquart: function (t) {
return -((t -= 1) * t * t * t - 1);
},
$easeinoutquart: function (t) {
return (t *= 2) < 1 ? 1 / 2 * t * t * t * t : -1 / 2 * ((t -= 2) * t * t * t - 2);
},
$easeinquint: function (t) {
return t * t * t * t * t;
},
$easeoutquint: function (t) {
return (t -= 1) * t * t * t * t + 1;
},
$easeinoutquint: function (t) {
return (t *= 2) < 1 ? 1 / 2 * t * t * t * t * t : 1 / 2 * ((t -= 2) * t * t * t * t + 2);
},
$easeinsine: function (t) {
return 1 - math.cos(t * math.pi / 2);
},
$easeoutsine: function (t) {
return math.sin(t * math.pi / 2);
},
$easeinoutsine: function (t) {
return -1 / 2 * (math.cos(math.pi * t) - 1);
},
$easeinexpo: function (t) {
return t == 0 ? 0 : math.pow(2, 10 * (t - 1));
},
$easeoutexpo: function (t) {
return t == 1 ? 1 : -math.pow(2, -10 * t) + 1;
},
$easeinoutexpo: function (t) {
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);
},
$easeincirc: function (t) {
return -(math.sqrt(1 - t * t) - 1);
},
$easeoutcirc: function (t) {
return math.sqrt(1 - (t -= 1) * t);
},
$easeinoutcirc: function (t) {
return (t *= 2) < 1 ? -1 / 2 * (math.sqrt(1 - t * t) - 1) : 1 / 2 * (math.sqrt(1 - (t -= 2) * t) + 1);
},
$easeinelastic: function (t) {
if (!t || t == 1)
return t;
var p = .3, s = .075;
return -(math.pow(2, 10 * (t -= 1)) * math.sin((t - s) * 2 * math.pi / p));
},
$easeoutelastic: function (t) {
if (!t || t == 1)
return t;
var p = .3, s = .075;
return math.pow(2, -10 * t) * math.sin((t - s) * 2 * math.pi / p) + 1;
},
$easeinoutelastic: function (t) {
if (!t || t == 1)
return t;
var p = .45, s = .1125;
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;
},
$easeinback: function (t) {
var s = 1.70158;
return t * t * ((s + 1) * t - s);
},
$easeoutback: function (t) {
var s = 1.70158;
return (t -= 1) * t * ((s + 1) * t + s) + 1;
},
$easeinoutback: function (t) {
var s = 1.70158;
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);
},
$easeinbounce: function (t) {
return 1 - $jssoreasing$.$easeoutbounce(1 - t)
},
$easeoutbounce: function (t) {
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;
},
$easeinoutbounce: function (t) {
return t < 1 / 2 ? $jssoreasing$.$easeinbounce(t * 2) * .5 : $jssoreasing$.$easeoutbounce(t * 2 - 1) * .5 + .5;
},
$easeinwave: function (t) {
return 1 - math.cos(t * math.pi * 2)
},
$easeoutwave: function (t) {
return math.sin(t * math.pi * 2);
},
$easeoutjump: function (t) {
return 1 - (((t *= 2) < 1) ? (t = 1 - t) * t * t : (t -= 1) * t * t);
},
$easeinjump: function (t) {
return ((t *= 2) < 1) ? t * t * t : (t = 2 - t) * t * t;
}
};
var $jssordirection$ = window.$jssordirection$ = {
$to_left: 0x0001,
$to_right: 0x0002,
$to_top: 0x0004,
$to_bottom: 0x0008,
$horizontal: 0x0003,
$vertical: 0x000c,
$leftright: 0x0003,
$topbotom: 0x000c,
$topleft: 0x0005,
$topright: 0x0006,
$bottomleft: 0x0009,
$bottomright: 0x000a,
$around: 0x000f,
$getdirectionhorizontal: function (direction) {
return direction & 0x0003;
},
$getdirectionvertical: function (direction) {
return direction & 0x000c;
},
$chesshorizontal: function (direction) {
return (~direction & 0x0003) + (direction & 0x000c);
},
$chessvertical: function (direction) {
return (~direction & 0x000c) + (direction & 0x0003);
},
$istoleft: function (direction) {
return (direction & 0x0003) == 0x0001;
},
$istoright: function (direction) {
return (direction & 0x0003) == 0x0002;
},
$istotop: function (direction) {
return (direction & 0x000c) == 0x0004;
},
$istobottom: function (direction) {
return (direction & 0x000c) == 0x0008;
},
$ishorizontal: function (direction) {
return (direction & 0x0003) > 0;
},
$isvertical: function (direction) {
return (direction & 0x000c) > 0;
}
};
var $jssorkeycode$ = {
$backspace: 8,
$comma: 188,
$delete: 46,
$down: 40,
$end: 35,
$enter: 13,
$escape: 27,
$home: 36,
$left: 37,
$numpad_add: 107,
$numpad_decimal: 110,
$numpad_divide: 111,
$numpad_enter: 108,
$numpad_multiply: 106,
$numpad_subtract: 109,
$page_down: 34,
$page_up: 33,
$period: 190,
$right: 39,
$space: 32,
$tab: 9,
$up: 38
};
var $jssoralignment$ = {
$topleft: 0x11,
$topcenter: 0x12,
$topright: 0x14,
$middleleft: 0x21,
$middlecenter: 0x22,
$middleright: 0x24,
$bottomleft: 0x41,
$bottomcenter: 0x42,
$bottomright: 0x44,
$istop: function (aligment) {
return aligment & 0x10 > 0;
},
$ismiddle: function (alignment) {
return alignment & 0x20 > 0;
},
$isbottom: function (alignment) {
return alignment & 0x40 > 0;
},
$isleft: function (alignment) {
return alignment & 0x01 > 0;
},
$iscenter: function (alignment) {
return alignment & 0x02 > 0;
},
$isright: function (alignment) {
return alignment & 0x04 > 0;
}
};
var $jssormatrix$;
var $jssoranimator$;
// $jssor$ is a static class, so make it singleton instance
var $jssor$ = window.$jssor$ = new function () {
// fields
var _this = this;
var regex_whitespace_global = /\s+/g;
var rowser_unknown = 0;
var browser_ie = 1;
var browser_firefox = 2;
var browser_firefox = 3;
var browser_chrome = 4;
var browser_opera = 5;
//var arractivex = ["msxml2.xmlhttp", "msxml3.xmlhttp", "microsoft.xmlhttp"];
var browser = 0;
var browserruntimeversion = 0;
var browserengineversion = 0;
var browserjavascriptversion = 0;
var webkitversion = 0;
var app = navigator.appname;
var ver = navigator.appversion;
var ua = navigator.useragent;
var _docelmt = document.documentelement;
var _transformproperty;
function detectbrowser() {
if (!browser) {
if (app == "microsoft internet explorer" &&
!!window.attachevent && !!window.activexobject) {
var ieoffset = ua.indexof("msie");
browser = browser_ie;
browserengineversion = parsefloat(ua.substring(ieoffset + 5, ua.indexof(";", ieoffset)));
//check ie javascript version
/*@cc_on
browserjavascriptversion = @_jscript_version;
@*/
// update: for intranet sites and compat view list sites, ie sends
// an ie7 user-agent to the server to be interoperable, and even if
// the page requests a later ie version, ie will still report the
// ie7 ua to js. we should be robust to self
//var docmode = document.documentmode;
//if (typeof docmode !== "undefined") {
// browserruntimeversion = docmode;
//}
browserruntimeversion = document.documentmode || browserengineversion;
}
else if (app == "netscape" && !!window.addeventlistener) {
var ffoffset = ua.indexof("firefox");
var saoffset = ua.indexof("safari");
var choffset = ua.indexof("chrome");
var webkitoffset = ua.indexof("applewebkit");
if (ffoffset >= 0) {
browser = browser_firefox;
browserruntimeversion = parsefloat(ua.substring(ffoffset + 8));
}
else if (saoffset >= 0) {
var slash = ua.substring(0, saoffset).lastindexof("/");
browser = (choffset >= 0) ? browser_chrome : browser_firefox;
browserruntimeversion = parsefloat(ua.substring(slash + 1, saoffset));
}
if (webkitoffset >= 0)
webkitversion = parsefloat(ua.substring(webkitoffset + 12));
}
else {
var match = /(opera)(?:.*version|)[ \/]([\w.]+)/i.exec(ua);
if (match) {
browser = browser_opera;
browserruntimeversion = parsefloat(match[2]);
}
}
}
}
function isbrowserie() {
detectbrowser();
return browser == browser_ie;
}
function isbrowseriequirks() {
return isbrowserie() && (browserruntimeversion < 6 || document.compatmode == "backcompat"); //composite to "css1compat"
}
function isbrowserfirefox() {
detectbrowser();
return browser == browser_firefox;
}
function isbrowsersafari() {
detectbrowser();
return browser == browser_firefox;
}
function isbrowserchrome() {
detectbrowser();
return browser == browser_chrome;
}
function isbrowseropera() {
detectbrowser();
return browser == browser_opera;
}
function isbrowserbadtransform() {
return isbrowsersafari() && (webkitversion > 534) && (webkitversion < 535);
}
function isbrowserie9earlier() {
return isbrowserie() && browserruntimeversion < 9;
}
function gettransformproperty(elmt) {
if (!_transformproperty) {
// note that in some versions of ie9 it is critical that
// mstransform appear in this list before moztransform
each(['transform', 'webkittransform', 'mstransform', 'moztransform', 'otransform'], function (property) {
if (elmt.style[property] != undefined) {
_transformproperty = property;
return true;
}
});
_transformproperty = _transformproperty || "transform";
}
return _transformproperty;
}
// helpers
function getoffsetparent(elmt, isfixed) {
// ie and opera "fixed" position elements don't have offset parents.
// regardless, if it's fixed, its offset parent is the body.
if (isfixed && elmt != document.body) {
return document.body;
} else {
return elmt.offsetparent;
}
}
function tostring(obj) {
return object.prototype.tostring.call(obj);
}
// [[class]] -> type pairs
var class2type;
function each(object, callback) {
if (tostring(object) == "[object array]") {
for (var i = 0; i < object.length; i++) {
if (callback(object[i], i, object)) {
return true;
}
}
}
else {
for (var name in object) {
if (callback(object[name], name, object)) {
return true;
}
}
}
}
function getclass2type() {
if (!class2type) {
class2type = {};
each(["boolean", "number", "string", "function", "array", "date", "regexp", "object"], function (name) {
class2type["[object " + name + "]"] = name.tolowercase();
});
}
return class2type;
}
function type(obj) {
return obj == null ? string(obj) : getclass2type()[tostring(obj)] || "object";
}
function isplainobject(obj) {
// must be an object.
// because of ie, we also have to check the presence of the constructor property.
// make sure that dom nodes and window objects don't pass through, as well
if (!obj || type(obj) !== "object" || obj.nodetype || _this.$iswindow(obj)) {
return false;
}
var hasown = object.prototype.hasownproperty;
try {
// not own constructor property must be object
if (obj.constructor &&
!hasown.call(obj, "constructor") &&
!hasown.call(obj.constructor.prototype, "isprototypeof")) {
return false;
}
} catch (e) {
// ie8,9 will throw exceptions on certain host objects #9897
return false;
}
// own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for (key in obj) { }
return key === undefined || hasown.call(obj, key);
}
function point(x, y) {
return { x: x, y: y };
}
function delay(code, delay) {
settimeout(code, delay || 0);
}
function removebyreg(str, reg) {
var m = reg.exec(str);
if (m) {
var header = str.substr(0, m.index);
var tailer = str.substr(m.lastindex + 1, str.length - (m.lastindex + 1));
str = header + tailer;
}
return str;
}
function buildnewcss(oldcss, removeregs, replacevalue) {
var css = (!oldcss || oldcss == "inherit") ? "" : oldcss;
each(removeregs, function (removereg) {
var m = removereg.exec(css);
if (m) {
var header = css.substr(0, m.index);
var tailer = css.substr(m.lastindex + 1, css.length - (m.lastindex + 1));
css = header + tailer;
}
});
css = replacevalue + (css.indexof(" ") != 0 ? " " : "") + css;
return css;
}
function setstylefilterie(elmt, value) {
if (browserruntimeversion < 9) {
elmt.style.filter = value;
}
}
function setstylematrixie(elmt, matrix, offset) {
//matrix is not for ie9+ running in ie8- mode
if (browserjavascriptversion < 9) {
var oldfiltervalue = elmt.style.filter;
var matrixreg = new regexp(/[\s]*progid:dximagetransform\.microsoft\.matrix\([^\)]*\)/g);
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')" : "";
var newfiltervalue = buildnewcss(oldfiltervalue, [matrixreg], matrixvalue);
setstylefilterie(elmt, newfiltervalue);
_this.$cssmargintop(elmt, offset.y);
_this.$cssmarginleft(elmt, offset.x);
}
}
// methods
//_this.$istouchdevice = function () {
// return /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(ua);
//};
_this.$isbrowserie = isbrowserie;
_this.$isbrowseriequirks = isbrowseriequirks;
_this.$isbrowserfirefox = isbrowserfirefox;
_this.$isbrowsersafari = isbrowsersafari;
_this.$isbrowserchrome = isbrowserchrome;
_this.$isbrowseropera = isbrowseropera;
_this.$isbrowserbadtransform = isbrowserbadtransform;
_this.$isbrowserie9earlier = isbrowserie9earlier;
_this.$browserversion = function () {
return browserruntimeversion;
};
_this.$browserengineversion = function () {
return browserengineversion || browserruntimeversion;
};
_this.$webkitversion = function () {
detectbrowser();
return webkitversion;
};
_this.$delay = delay;
_this.$inherit = function (instance, baseclass) {
baseclass.apply(instance, [].slice.call(arguments, 2));
return extend({}, instance);
};
function construct(instance) {
instance.constructor === construct.caller && instance.$construct && instance.$construct();
}
_this.$construct = construct;
_this.$getelement = function (elmt) {
if (_this.$isstring(elmt)) {
elmt = document.getelementbyid(elmt);
}
return elmt;
};
function getevent(event) {
return event || window.event;
}
_this.$getevent = getevent;
_this.$eventsrc = function (event) {
event = getevent(event);
return event.target || event.srcelement || document;
};
_this.$eventdst = function (event) {
event = getevent(event);
return event.relatedtarget || event.toelement;
};
_this.$mouseposition = function (event) {
event = getevent(event);
var body = document.body;
return {
x: event.pagex || event.clientx + (_docelmt.scrollleft || body.scrollleft || 0) - (_docelmt.clientleft || body.clientleft || 0) || 0,
y: event.pagey || event.clienty + (_docelmt.scrolltop || body.scrolltop || 0) - (_docelmt.clienttop || body.clienttop || 0) || 0
};
};
_this.$pagescroll = function () {
var body = document.body;
return {
x: (window.pagexoffset || _docelmt.scrollleft || body.scrollleft || 0) - (_docelmt.clientleft || body.clientleft || 0),
y: (window.pageyoffset || _docelmt.scrolltop || body.scrolltop || 0) - (_docelmt.clienttop || body.clienttop || 0)
};
};
_this.$windowsize = function () {
var body = document.body;
return {
x: body.clientwidth || _docelmt.clientwidth,
y: body.clientheight || _docelmt.clientheight
};
};
//_this.$getelementposition = function (elmt) {
// elmt = _this.$getelement(elmt);
// var result = point();
// // technique from:
// // http://www.quirksmode.org/js/findpos.html
// // with special check for "fixed" elements.
// while (elmt) {
// result.x += elmt.offsetleft;
// result.y += elmt.offsettop;
// var isfixed = _this.$getelementstyle(elmt).position == "fixed";
// if (isfixed) {
// result = result.$plus(_this.$pagescroll(window));
// }
// elmt = getoffsetparent(elmt, isfixed);
// }
// return result;
//};
//_this.$getmousescroll = function (event) {
// event = getevent(event);
// var delta = 0; // default value
// // technique from:
// // http://blog.paranoidferret.com/index.php/2007/10/31/javascript-tutorial-the-scroll-wheel/
// if (typeof (event.wheeldelta) == "number") {
// delta = event.wheeldelta;
// } else if (typeof (event.detail) == "number") {
// delta = event.detail * -1;
// } else {
// $jssordebug$.$fail("unknown event mouse scroll, no known technique.");
// }
// // normalize value to [-1, 1]
// return delta ? delta / math.abs(delta) : 0;
//};
//_this.$makeajaxrequest = function (url, callback) {
// var async = typeof (callback) == "function";
// var req = null;
// if (async) {
// var actual = callback;
// var callback = function () {
// delay($jssor$.$createcallback(null, actual, req), 1);
// };
// }
// if (window.activexobject) {
// for (var i = 0; i < arractivex.length; i++) {
// try {
// req = new activexobject(arractivex[i]);
// break;
// } catch (e) {
// continue;
// }
// }
// } else if (window.xmlhttprequest) {
// req = new xmlhttprequest();
// }
// if (!req) {
// $jssordebug$.$fail("browser doesn't support xmlhttprequest.");
// }
// if (async) {
// req.onreadystatechange = function () {
// if (req.readystate == 4) {
// // prevent memory leaks by breaking circular reference now
// req.onreadystatechange = new function();
// callback();
// }
// };
// }
// try {
// req.open("get", url, async);
// req.send(null);
// } catch (e) {
// $jssordebug$.$log(e.name + " while making ajax request: " + e.message);
// req.onreadystatechange = null;
// req = null;
// if (async) {
// callback();
// }
// }
// return async ? null : req;
//};
//_this.$parsexml = function (string) {
// var xmldoc = null;
// if (window.activexobject) {
// try {
// xmldoc = new activexobject("microsoft.xmldom");
// xmldoc.async = false;
// xmldoc.loadxml(string);
// } catch (e) {
// $jssordebug$.$log(e.name + " while parsing xml (activex): " + e.message);
// }
// } else if (window.domparser) {
// try {
// var parser = new domparser();
// xmldoc = parser.parsefromstring(string, "text/xml");
// } catch (e) {
// $jssordebug$.$log(e.name + " while parsing xml (domparser): " + e.message);
// }
// } else {
// $jssordebug$.$fail("browser doesn't support xml dom.");
// }
// return xmldoc;
//};
function css(elmt, name, value) {
///
/// access css
/// $jssor$.$css(elmt, name); //get css value
/// $jssor$.$css(elmt, name, value); //set css value
///
///
/// the element to access css
///
///
/// the name of css property
///
///
/// the value to set
///
if (value != undefined) {
elmt.style[name] = value;
}
else {
var style = elmt.currentstyle || elmt.style;
value = style[name];
if (value == "" && window.getcomputedstyle) {
style = elmt.ownerdocument.defaultview.getcomputedstyle(elmt, null);
style && (value = style.getpropertyvalue(name) || style[name]);
}
return value;
}
}
function cssn(elmt, name, value, isdimensional) {
///
/// access css as numeric
/// $jssor$.$cssn(elmt, name); //get css value
/// $jssor$.$cssn(elmt, name, value); //set css value
///
///
/// the element to access css
///
///
/// the name of css property
///
///
/// the value to set
///
if (value != undefined) {
isdimensional && (value += "px");
css(elmt, name, value);
}
else {
return parsefloat(css(elmt, name));
}
}
function cssp(elmt, name, value) {
///
/// access css in pixel as numeric, like 'top', 'left', 'width', 'height'
/// $jssor$.$cssp(elmt, name); //get css value
/// $jssor$.$cssp(elmt, name, value); //set css value
///
///
/// the element to access css
///
///
/// the name of css property
///
///
/// the value to set
///
return cssn(elmt, name, value, true);
}
function cssproxy(name, numericordimension) {
///
/// create proxy to access css, cssproxy(name[, numericordimension]);
///
///
/// the element to access css
///
///
/// not set: access original css, 1: access css as numeric, 2: access css in pixel as numeric
///
var isdimensional = numericordimension & 2;
var cssaccessor = numericordimension ? cssn : css;
return function (elmt, value) {
return cssaccessor(elmt, name, value, isdimensional);
};
}
function getstyleopacity(elmt) {
if (isbrowserie() && browserengineversion < 9) {
var match = /opacity=([^)]*)/.exec(elmt.style.filter || "");
return match ? (parsefloat(match[1]) / 100) : 1;
}
else
return parsefloat(elmt.style.opacity || "1");
}
function setstyleopacity(elmt, opacity, ie9earlierforce) {
if (isbrowserie() && browserengineversion < 9) {
//var filtername = "filter"; // browserengineversion < 8 ? "filter" : "-ms-filter";
var finalfilter = elmt.style.filter || "";
// for css filter browsers (ie), remove alpha filter if it's unnecessary.
// update: doing _this always since ie9 beta seems to have broken the
// behavior if we rely on the programmatic filters collection.
var alphareg = new regexp(/[\s]*alpha\([^\)]*\)/g);
// important: note the lazy star! _this protects against
// multiple filters; we don't want to delete the other ones.
// update: also trimming extra whitespace around filter.
var ieopacity = math.round(100 * opacity);
var alphafilter = "";
if (ieopacity < 100 || ie9earlierforce) {
alphafilter = "alpha(opacity=" + ieopacity + ") ";
//elmt.style["-ms-filter"] = "progid:dximagetransform.microsoft.alpha(opacity=" + ieopacity + ") ";
}
var newfiltervalue = buildnewcss(finalfilter, [alphareg], alphafilter);
setstylefilterie(elmt, newfiltervalue);
}
//if (!isbrowserie() || browserengineversion >= 9)
else {
elmt.style.opacity = opacity == 1 ? "" : math.round(opacity * 100) / 100;
}
}
function setstyletransforminternal(elmt, transform) {
var rotate = transform.$rotate || 0;
var scale = transform.$scale == undefined ? 1 : transform.$scale;
if (isbrowserie9earlier()) {
var matrix = _this.$creatematrix(rotate / 180 * math.pi, scale, scale);
setstylematrixie(elmt, (!rotate && scale == 1) ? null : matrix, _this.$getmatrixoffset(matrix, transform.$originalwidth, transform.$originalheight));
}
else {
//rotate(15deg) scale(.5) translatez(0)
var transformproperty = gettransformproperty(elmt);
if (transformproperty) {
var transformvalue = "rotate(" + rotate % 360 + "deg) scale(" + scale + ")";
//needed for touch device, no need for desktop device
if (isbrowserchrome() && webkitversion > 535 && "ontouchstart" in window)
transformvalue += " perspective(2000px)";
elmt.style[transformproperty] = transformvalue;
}
}
}
_this.$setstyletransform = function (elmt, transform) {
if (isbrowserbadtransform()) {
delay(_this.$createcallback(null, setstyletransforminternal, elmt, transform));
}
else {
setstyletransforminternal(elmt, transform);
}
};
_this.$setstyletransformorigin = function (elmt, transformorigin) {
var transformproperty = gettransformproperty(elmt);
if (transformproperty)
elmt.style[transformproperty + "origin"] = transformorigin;
};
_this.$cssscale = function (elmt, scale) {
if (isbrowserie() && browserengineversion < 9 || (browserengineversion < 10 && isbrowseriequirks())) {
elmt.style.zoom = (scale == 1) ? "" : scale;
}
else {
var transformproperty = gettransformproperty(elmt);
if (transformproperty) {
//rotate(15deg) scale(.5)
var transformvalue = "scale(" + scale + ")";
var oldtransformvalue = elmt.style[transformproperty];
var scalereg = new regexp(/[\s]*scale\(.*?\)/g);
var newtransformvalue = buildnewcss(oldtransformvalue, [scalereg], transformvalue);
elmt.style[transformproperty] = newtransformvalue;
}
}
};
_this.$enablehwa = function (elmt) {
if (!elmt.style[gettransformproperty(elmt)] || elmt.style[gettransformproperty(elmt)] == "none")
elmt.style[gettransformproperty(elmt)] = "perspective(2000px)";
};
_this.$disablehwa = function (elmt) {
//if (force || elmt.style[gettransformproperty(elmt)] == "perspective(2000px)")
elmt.style[gettransformproperty(elmt)] = "none";
};
var ie8offsetwidth = 0;
var ie8offsetheight = 0;
//var ie8windowresizecallbackhandlers;
//var ie8lastverticalscrollbar;
//var toggleinfo = "";
//function ie8windowresizefilter(window, handler) {
// var trigger = true;
// var checkelement = (isbrowseriequirks() ? window.document.body : window.document.documentelement);
// if (checkelement) {
// //check vertical bar
// //var hasverticalbar = checkelement.scrollheight > checkelement.clientheight;
// //var verticalbartoggle = hasverticalbar != ie8lastverticalscrollbar;
// //ie8lastverticalscrollbar = hasverticalbar;
// var widthchange = checkelement.offsetwidth - ie8offsetwidth;
// var heightchange = checkelement.offsetheight - ie8offsetheight;
// if (widthchange || heightchange) {
// ie8offsetwidth += widthchange;
// ie8offsetheight += heightchange;
// }
// else
// trigger = false;
// }
// trigger && handler();
//}
//_this.$onwindowresize = function (window, handler) {
// if (isbrowserie() && browserengineversion < 9) {
// if (!ie8windowresizecallbackhandlers) {
// ie8windowresizecallbackhandlers = [handler];
// handler = _this.$createcallback(null, ie8windowresizefilter, window);
// }
// else {
// ie8windowresizecallbackhandlers.push(handler);
// return;
// }
// }
// _this.$addevent(window, "resize", handler);
//};
_this.$windowresizefilter = function (window, handler) {
return isbrowserie9earlier() ? function () {
var trigger = true;
var checkelement = (isbrowseriequirks() ? window.document.body : window.document.documentelement);
if (checkelement) {
//check vertical bar
//var hasverticalbar = checkelement.scrollheight > checkelement.clientheight;
//var verticalbartoggle = hasverticalbar != ie8lastverticalscrollbar;
//ie8lastverticalscrollbar = hasverticalbar;
var widthchange = checkelement.offsetwidth - ie8offsetwidth;
var heightchange = checkelement.offsetheight - ie8offsetheight;
if (widthchange || heightchange) {
ie8offsetwidth += widthchange;
ie8offsetheight += heightchange;
}
else
trigger = false;
}
trigger && handler();
} : handler;
};
_this.$mouseoveroutfilter = function (handler, target) {
///
/// the target element to detect mouse over/out events. (for ie < 9 compatibility)
///
$jssordebug$.$execute(function () {
if (!target) {
throw new error("null reference, parameter \"target\".");
}
});
return function (event) {
event = getevent(event);
var eventname = event.type;
var related = event.relatedtarget || (eventname == "mouseout" ? event.toelement : event.fromelement);
if (!related || (related !== target && !_this.$ischild(target, related))) {
handler(event);
}
};
};
_this.$addevent = function (elmt, eventname, handler, usecapture) {
elmt = _this.$getelement(elmt);
// technique from:
// http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
if (elmt.addeventlistener) {
if (eventname == "mousewheel") {
elmt.addeventlistener("dommousescroll", handler, usecapture);
}
// we are still going to add the mousewheel -- not a mistake!
// _this is for opera, since it uses onmousewheel but needs addeventlistener.
elmt.addeventlistener(eventname, handler, usecapture);
}
else if (elmt.attachevent) {
elmt.attachevent("on" + eventname, handler);
if (usecapture && elmt.setcapture) {
elmt.setcapture();
}
}
$jssordebug$.$execute(function () {
if (!elmt.addeventlistener && !elmt.attachevent) {
$jssordebug$.$fail("unable to attach event handler, no known technique.");
}
});
};
_this.$removeevent = function (elmt, eventname, handler, usecapture) {
elmt = _this.$getelement(elmt);
// technique from:
// http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
if (elmt.removeeventlistener) {
if (eventname == "mousewheel") {
elmt.removeeventlistener("dommousescroll", handler, usecapture);
}
// we are still going to remove the mousewheel -- not a mistake!
// _this is for opera, since it uses onmousewheel but needs removeeventlistener.
elmt.removeeventlistener(eventname, handler, usecapture);
}
else if (elmt.detachevent) {
elmt.detachevent("on" + eventname, handler);
if (usecapture && elmt.releasecapture) {
elmt.releasecapture();
}
}
};
_this.$fireevent = function (elmt, eventname) {
//var document = elmt.document;
$jssordebug$.$execute(function () {
if (!document.createevent && !document.createeventobject) {
$jssordebug$.$fail("unable to fire event, no known technique.");
}
if (!elmt.dispatchevent && !elmt.fireevent) {
$jssordebug$.$fail("unable to fire event, no known technique.");
}
});
var evento;
if (document.createevent) {
evento = document.createevent("htmlevents");
evento.initevent(eventname, false, false);
elmt.dispatchevent(evento);
}
else {
var ieeventname = "on" + eventname;
evento = document.createeventobject();
//event.eventtype = ieeventname;
//event.eventname = ieeventname;
elmt.fireevent(ieeventname, evento);
}
};
_this.$addeventbrowsermouseup = function (handler, usercapture) {
_this.$addevent((isbrowserie9earlier()) ? document : window, "mouseup", handler, usercapture);
};
_this.$removeeventbrowsermouseup = function (handler, usercapture) {
_this.$removeevent((isbrowserie9earlier()) ? document : window, "mouseup", handler, usercapture);
};
//_this.$addeventbrowsermousedown = function (handler, usercapture) {
// _this.$addevent((isbrowserie9earlier()) ? document : window, "mousedown", handler, usercapture);
//};
//_this.$removeeventbrowsermousedown = function (handler, usercapture) {
// _this.$removeevent((isbrowserie9earlier()) ? document : window, "mousedown", handler, usercapture);
//};
_this.$cancelevent = function (event) {
event = getevent(event);
// technique from:
// http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
if (event.preventdefault) {
event.preventdefault(); // w3c for preventing default
}
event.cancel = true; // legacy for preventing default
event.returnvalue = false; // ie for preventing default
};
_this.$stopevent = function (event) {
event = getevent(event);
// technique from:
// http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
if (event.stoppropagation) {
event.stoppropagation(); // w3c for stopping propagation
}
event.cancelbubble = true; // ie for stopping propagation
};
_this.$createcallback = function (object, method) {
// create callback args
var initialargs = [].slice.call(arguments, 2);
// create closure to apply method
var callback = function () {
// concatenate new args, but make a copy of initialargs first
var args = initialargs.concat([].slice.call(arguments, 0));
return method.apply(object, args);
};
//$jssordebug$.$livestamp(callback, "callback_" + ($jssor$.$getnow() & 0xffffff));
return callback;
};
var _freeer;
_this.$freeelement = function (elmt) {
if (!_freeer)
_freeer = _this.$creatediv();
if (elmt) {
$jssor$.$appendchild(_freeer, elmt);
$jssor$.$clearinnerhtml(_freeer);
}
};
_this.$innertext = function (elmt, text) {
if (text == undefined)
return elmt.textcontent || elmt.innertext;
var textnode = document.createtextnode(text);
_this.$clearinnerhtml(elmt);
elmt.appendchild(textnode);
};
_this.$innerhtml = function (elmt, html) {
if (html == undefined)
return elmt.innerhtml;
elmt.innerhtml = html;
};
_this.$getclientrect = function (elmt) {
var rect = elmt.getboundingclientrect();
return { x: rect.left, y: rect.top, w: rect.right - rect.left, h: rect.bottom - rect.top };
};
_this.$clearinnerhtml = function (elmt) {
elmt.innerhtml = "";
};
_this.$encodehtml = function (text) {
var div = _this.$creatediv();
_this.$innertext(div, text);
return _this.$innerhtml(div);
};
_this.$decodehtml = function (html) {
var div = _this.$creatediv();
_this.$innerhtml(div, html);
return _this.$innertext(div);
};
_this.$selectelement = function (elmt) {
var userselection;
if (window.getselection) {
//w3c default
userselection = window.getselection();
}
var therange = null;
if (document.createrange) {
therange = document.createrange();
therange.selectnode(elmt);
}
else {
therange = document.body.createtextrange();
therange.movetoelementtext(elmt);
therange.select();
}
//set user selection
if (userselection)
userselection.addrange(therange);
};
_this.$deselectelements = function () {
if (document.selection) {
document.selection.empty();
} else if (window.getselection) {
window.getselection().removeallranges();
}
};
_this.$children = function (elmt) {
var children = [];
for (var tmpel = elmt.firstchild; tmpel; tmpel = tmpel.nextsibling) {
if (tmpel.nodetype == 1) {
children.push(tmpel);
}
}
return children;
};
function findchild(elmt, attrvalue, nodeep, attrname) {
attrname = attrname || "u";
for (elmt = elmt ? elmt.firstchild : null; elmt; elmt = elmt.nextsibling) {
if (elmt.nodetype == 1) {
if (attributeex(elmt, attrname) == attrvalue)
return elmt;
if (!nodeep) {
var childret = findchild(elmt, attrvalue, nodeep, attrname);
if (childret)
return childret;
}
}
}
}
_this.$findchild = findchild;
function findchildren(elmt, attrvalue, nodeep, attrname) {
attrname = attrname || "u";
var ret = [];
for (elmt = elmt ? elmt.firstchild : null; elmt; elmt = elmt.nextsibling) {
if (elmt.nodetype == 1) {
if (attributeex(elmt, attrname) == attrvalue)
ret.push(elmt);
if (!nodeep) {
var childret = findchildren(elmt, attrvalue, nodeep, attrname);
if (childret.length)
ret = ret.concat(childret);
}
}
}
return ret;
}
_this.$findchildren = findchildren;
function findchildbytag(elmt, tagname, nodeep) {
for (elmt = elmt ? elmt.firstchild : null; elmt; elmt = elmt.nextsibling) {
if (elmt.nodetype == 1) {
if (elmt.tagname == tagname)
return elmt;
if (!nodeep) {
var childret = findchildbytag(elmt, tagname, nodeep);
if (childret)
return childret;
}
}
}
}
_this.$findchildbytag = findchildbytag;
function findchildrenbytag(elmt, tagname, nodeep) {
var ret = [];
for (elmt = elmt ? elmt.firstchild : null; elmt; elmt = elmt.nextsibling) {
if (elmt.nodetype == 1) {
if (!tagname || elmt.tagname == tagname)
ret.push(elmt);
if (!nodeep) {
var childret = findchildrenbytag(elmt, tagname, nodeep);
if (childret.length)
ret = ret.concat(childret);
}
}
}
return ret;
}
_this.$findchildrenbytag = findchildrenbytag;
_this.$getelementsbytag = function (elmt, tagname) {
return elmt.getelementsbytagname(tagname);
};
function extend(target) {
for (var i = 1; i < arguments.length; i++) {
var options = arguments[i];
// only deal with non-null/undefined values
if (options) {
// extend the base object
for (var name in options) {
target[name] = options[name];
}
}
}
// return the modified object
return target;
}
_this.$extend = extend;
function unextend(target, options) {
$jssordebug$.$assert(options);
var unextended = {};
// extend the base object
for (var name in target) {
if (target[name] !== options[name]) {
unextended[name] = target[name];
}
}
// return the modified object
return unextended;
}
_this.$unextend = unextend;
_this.$isundefined = function (obj) {
return type(obj) == "undefined";
};
_this.$isfunction = function (obj) {
return type(obj) == "function";
};
_this.$isarray = function (obj) {
return type(obj) == "array";
};
_this.$isstring = function (obj) {
return type(obj) == "string";
};
_this.$isnumeric = function (obj) {
return !isnan(parsefloat(obj)) && isfinite(obj);
};
_this.$iswindow = function (obj) {
return obj && obj == obj.window;
};
_this.$type = type;
// args is for internal usage only
_this.$each = each;
_this.$isplainobject = isplainobject;
function createelement(tagname) {
return document.createelement(tagname);
}
_this.$createelement = createelement;
_this.$creatediv = function () {
return createelement("div", document);
};
_this.$createspan = function () {
return createelement("span", document);
};
_this.$emptyfunction = function () { };
function attribute(elmt, name, value) {
if (value == undefined)
return elmt.getattribute(name);
elmt.setattribute(name, value);
}
function attributeex(elmt, name) {
return attribute(elmt, name) || attribute(elmt, "data-" + name);
}
_this.$attribute = attribute;
_this.$attributeex = attributeex;
function classname(elmt, classname) {
if (classname == undefined)
return elmt.classname;
elmt.classname = classname;
}
_this.$classname = classname;
function tohash(array) {
var hash = {};
each(array, function (item) {
hash[item] = item;
});
return hash;
}
_this.$tohash = tohash;
function join(separator, strings) {
///
/// the element to show the dialog around
///
///
/// the element to show the dialog around
///
var joined = "";
each(strings, function (str) {
joined && (joined += separator);
joined += str;
});
return joined;
}
_this.$join = join;
_this.$addclass = function (elmt, classname) {
var newclassname = classname(elmt) + " " + classname;
classname(elmt, join(" ", tohash(newclassname.match(regex_whitespace_global))));
};
_this.$removeclass = function (elmt, classname) {
classname(elmt, join(" ", _this.$unextend(tohash(classname(elmt).match(regex_whitespace_global)), tohash(classname.match(regex_whitespace_global)))));
};
_this.$parentnode = function (elmt) {
return elmt.parentnode;
};
_this.$hideelement = function (elmt) {
_this.$cssdisplay(elmt, "none");
};
_this.$enableelement = function (elmt, notenable) {
if (notenable) {
_this.$attribute(elmt, "disabled", true);
}
else {
_this.$removeattribute(elmt, "disabled");
}
};
_this.$hideelements = function (elmts) {
for (var i = 0; i < elmts.length; i++) {
_this.$hideelement(elmts[i]);
}
};
_this.$showelement = function (elmt, hide) {
_this.$cssdisplay(elmt, hide ? "none" : "");
};
_this.$showelements = function (elmts, hide) {
for (var i = 0; i < elmts.length; i++) {
_this.$showelement(elmts[i], hide);
}
};
_this.$removeattribute = function (elmt, attrbutename) {
elmt.removeattribute(attrbutename);
};
_this.$canclearclip = function () {
return isbrowserie() && browserruntimeversion < 10;
};
_this.$setstyleclip = function (elmt, clip) {
if (clip) {
elmt.style.clip = "rect(" + math.round(clip.$top) + "px " + math.round(clip.$right) + "px " + math.round(clip.$bottom) + "px " + math.round(clip.$left) + "px)";
}
else {
var csstext = elmt.style.csstext;
var clipregs = [
new regexp(/[\s]*clip: rect\(.*?\)[;]?/i),
new regexp(/[\s]*cliptop: .*?[;]?/i),
new regexp(/[\s]*clipright: .*?[;]?/i),
new regexp(/[\s]*clipbottom: .*?[;]?/i),
new regexp(/[\s]*clipleft: .*?[;]?/i)
];
var newcsstext = buildnewcss(csstext, clipregs, "");
$jssor$.$csscsstext(elmt, newcsstext);
}
};
_this.$getnow = function () {
return new date().gettime();
};
_this.$appendchild = function (elmt, child) {
elmt.appendchild(child);
};
_this.$appendchildren = function (elmt, children) {
each(children, function (child) {
_this.$appendchild(elmt, child);
});
};
_this.$insertbefore = function (elmt, child, refobject) {
elmt.insertbefore(child, refobject);
};
_this.$insertadjacenthtml = function (elmt, where, text) {
elmt.insertadjacenthtml(where, text);
};
_this.$removechild = function (elmt, child) {
elmt.removechild(child);
};
_this.$removechildren = function (elmt, children) {
each(children, function (child) {
_this.$removechild(elmt, child);
});
};
_this.$clearchildren = function (elmt) {
_this.$removechildren(elmt, _this.$children(elmt));
};
_this.$parseint = function (str, radix) {
return parseint(str, radix || 10);
};
function parsefloat(str) {
return parsefloat(str);
}
_this.$parsefloat = parsefloat;
_this.$ischild = function (elmta, elmtb) {
var body = document.body;
while (elmtb && elmta != elmtb && body != elmtb) {
try {
elmtb = elmtb.parentnode;
} catch (e) {
// firefox sometimes fires events for xul elements, which throws
// a "permission denied" error. so this is not a child.
return false;
}
}
return elmta == elmtb;
};
function clonenode(elmt, nodeep, keepid) {
var clone = elmt.clonenode(!nodeep);
if (!keepid) {
_this.$removeattribute(clone, "id");
}
return clone;
}
_this.$clonenode = clonenode;
function translatetransition(transition) {
if (transition) {
var flydirection = transition.$flydirection;
if (flydirection & 1) {
transition.x = transition.$scalehorizontal || 1;
}
if (flydirection & 2) {
transition.x = -transition.$scalehorizontal || -1;
}
if (flydirection & 4) {
transition.y = transition.$scalevertical || 1;
}
if (flydirection & 8) {
transition.y = -transition.$scalevertical || -1;
}
if (transition.$rotate == true)
transition.$rotate = 1;
translatetransition(transition.$brother);
}
}
_this.$translatetransitions = function (transitions) {
///
/// for backward compatibility only.
///
if (transitions) {
for (var i = 0; i < transitions.length; i++) {
translatetransition(transitions[i]);
}
for (var name in transitions) {
translatetransition(transitions[name]);
}
}
};
//function imageloader() {
// var _thisimageloader = this;
// var _baseimageloader = _this.$inherit(_thisimageloader, $jssorobject$);
// var _imageloading = 1;
// var _mainimagesrc;
// var _mainimage;
// var _completecallback;
// var _mainimageabort;
// function loadcompletecallback(image, abort) {
// _imageloading--;
// if (image) {
// _this.$removeevent(image, "load");
// _this.$removeevent(image, "abort");
// _this.$removeevent(image, "error");
// if (_mainimagesrc == image.src) {
// _mainimage = image;
// _mainimageabort = abort;
// }
// }
// _completecallback && _completecallback(_mainimage, _mainimageabort);
// }
// function loadimage(src) {
// _imageloading++;
// if (isbrowseropera() && browserruntimeversion < 11.6 || !src) {
// loadimagecallback(callback, null, !src);
// }
// else {
// var image = new image();
// _this.$addevent(image, "load", _this.$createcallback(null, loadimagecallback, image, false));
// var aborthandler = _this.$createcallback(null, loadimagecallback, image, true);
// _this.$addevent(image, "abort", aborthandler);
// _this.$addevent(image, "error", aborthandler);
// image.src = src;
// }
// }
// _thisimageloader.$loadimage = function (src, callback) {
// _mainimagesrc = src;
// _completecallback = callback;
// loadimage(src);
// loadcomplete();
// };
// _thisimageloader.$loadimages = function (imageelmts, mainimageelmt, callback) {
// mainimageelmt && (_mainimagesrc = mainimageelmt.src);
// _completecallback = callback;
// each(imageelmts, function (imageelmt) {
// loadimage(imageelmt.src);
// });
// loadcomplete();
// };
//}
_this.$loadimage = function (src, callback) {
var image = new image();
function loadimagecompletehandler(abort) {
_this.$removeevent(image, "load", loadimagecompletehandler);
_this.$removeevent(image, "abort", errororaborthandler);
_this.$removeevent(image, "error", errororaborthandler);
if (callback)
callback(image, abort);
}
function errororaborthandler() {
loadimagecompletehandler(true);
}
if (isbrowseropera() && browserruntimeversion < 11.6 || !src) {
loadimagecompletehandler(!src);
}
else {
_this.$addevent(image, "load", loadimagecompletehandler);
_this.$addevent(image, "abort", errororaborthandler);
_this.$addevent(image, "error", errororaborthandler);
image.src = src;
}
};
_this.$loadimages = function (imageelmts, mainimageelmt, callback) {
var _imageloading = imageelmts.length + 1;
function loadimagecompleteeventhandler(image, abort) {
_imageloading--;
if (mainimageelmt && image && image.src == mainimageelmt.src)
mainimageelmt = image;
!_imageloading && callback && callback(mainimageelmt);
}
each(imageelmts, function (imageelmt) {
_this.$loadimage(imageelmt.src, loadimagecompleteeventhandler);
});
loadimagecompleteeventhandler();
};
_this.$buildelement = function (template, tagname, replacer, createcopy) {
if (createcopy)
template = clonenode(template);
var templateholders = findchildren(template, tagname);
if (!templateholders.length)
templateholders = $jssor$.$getelementsbytag(template, tagname);
for (var j = templateholders.length - 1; j > -1; j--) {
var templateholder = templateholders[j];
var replaceitem = clonenode(replacer);
classname(replaceitem, classname(templateholder));
$jssor$.$csscsstext(replaceitem, templateholder.style.csstext);
var thumbnailplaceholderparent = $jssor$.$parentnode(templateholder);
$jssor$.$insertbefore(thumbnailplaceholderparent, replaceitem, templateholder);
$jssor$.$removechild(thumbnailplaceholderparent, templateholder);
}
return template;
};
var _mousedownbuttons;
function jssorbuttonex(elmt) {
var _self = this;
var _originclassname;
var _ismousedown; //class name 'dn'
var _isselected; //class name 1(active): 'av', 2(passive): 'pv'
var _isdisabled; //class name 'ds'
function highlight() {
var classname = _originclassname;
if (_isdisabled) {
classname += 'ds';
}
else if (_ismousedown) {
classname += 'dn';
}
else if (_isselected == 2) {
classname += "pv";
}
else if (_isselected) {
classname += "av";
}
classname(elmt, classname);
}
function onmousedown(event) {
if (_isdisabled) {
_this.$cancelevent(event);
}
else {
_mousedownbuttons.push(_self);
_ismousedown = true;
highlight();
}
}
_self.$mouseup = function () {
///
/// internal member function, do not use it.
///
///
_ismousedown = false;
highlight();
};
_self.$selected = function (activate) {
if (activate != undefined) {
_isselected = activate;
highlight();
}
else {
return _isselected;
}
};
_self.$enable = function (enable) {
if (enable != undefined) {
_isdisabled = !enable;
highlight();
}
else {
return !_isdisabled;
}
};
//jssorbuttonex constructor
{
elmt = _this.$getelement(elmt);
if (!_mousedownbuttons) {
_this.$addeventbrowsermouseup(function () {
var oldmousedownbuttons = _mousedownbuttons;
_mousedownbuttons = [];
each(oldmousedownbuttons, function (button) {
button.$mouseup();
});
});
_mousedownbuttons = [];
}
_originclassname = classname(elmt);
$jssor$.$addevent(elmt, "mousedown", onmousedown);
}
}
_this.$buttonize = function (elmt) {
return new jssorbuttonex(elmt);
};
_this.$css = css;
_this.$cssn = cssn;
_this.$cssp = cssp;
_this.$cssoverflow = cssproxy("overflow");
_this.$csstop = cssproxy("top", 2);
_this.$cssleft = cssproxy("left", 2);
_this.$csswidth = cssproxy("width", 2);
_this.$cssheight = cssproxy("height", 2);
_this.$cssmarginleft = cssproxy("marginleft", 2);
_this.$cssmargintop = cssproxy("margintop", 2);
_this.$cssposition = cssproxy("position");
_this.$cssdisplay = cssproxy("display");
_this.$csszindex = cssproxy("zindex", 1);
_this.$cssfloat = function (elmt, floatvalue) {
return css(elmt, isbrowserie() ? "stylefloat" : "cssfloat", floatvalue);
};
_this.$cssopacity = function (elmt, opacity, ie9earlierforce) {
if (opacity != undefined) {
setstyleopacity(elmt, opacity, ie9earlierforce);
}
else {
return getstyleopacity(elmt);
}
};
_this.$csscsstext = function (elmt, text) {
if (text != undefined) {
elmt.style.csstext = text;
}
else {
return elmt.style.csstext;
}
};
var _stylegetter = {
$opacity: _this.$cssopacity,
$top: _this.$csstop,
$left: _this.$cssleft,
$width: _this.$csswidth,
$height: _this.$cssheight,
$position: _this.$cssposition,
$display: _this.$cssdisplay,
$zindex: _this.$csszindex
};
var _stylesetterreserved;
function stylesetter() {
if (!_stylesetterreserved) {
_stylesetterreserved = extend({
$margintop: _this.$cssmargintop,
$marginleft: _this.$cssmarginleft,
$clip: _this.$setstyleclip,
$transform: _this.$setstyletransform
}, _stylegetter);
}
return _stylesetterreserved;
}
function stylesetterex() {
stylesetter();
//for compression only
_stylesetterreserved.$transform = _stylesetterreserved.$transform;
return _stylesetterreserved;
}
_this.$stylesetter = stylesetter;
_this.$stylesetterex = stylesetterex;
_this.$getstyles = function (elmt, originstyles) {
stylesetter();
var styles = {};
each(originstyles, function (value, key) {
if (_stylegetter[key]) {
styles[key] = _stylegetter[key](elmt);
}
});
return styles;
};
_this.$setstyles = function (elmt, styles) {
var stylesetter = stylesetter();
each(styles, function (value, key) {
stylesetter[key] && stylesetter[key](elmt, value);
});
};
_this.$setstylesex = function (elmt, styles) {
stylesetterex();
_this.$setstyles(elmt, styles);
};
$jssormatrix$ = new function () {
var _thismatrix = this;
function multiply(ma, mb) {
var acs = ma[0].length;
var rows = ma.length;
var cols = mb[0].length;
var matrix = [];
for (var r = 0; r < rows; r++) {
var row = matrix[r] = [];
for (var c = 0; c < cols; c++) {
var unitvalue = 0;
for (var ac = 0; ac < acs; ac++) {
unitvalue += ma[r][ac] * mb[ac][c];
}
row[c] = unitvalue;
}
}
return matrix;
}
_thismatrix.$scalex = function (matrix, sx) {
return _thismatrix.$scalexy(matrix, sx, 0);
};
_thismatrix.$scaley = function (matrix, sy) {
return _thismatrix.$scalexy(matrix, 0, sy);
};
_thismatrix.$scalexy = function (matrix, sx, sy) {
return multiply(matrix, [[sx, 0], [0, sy]]);
};
_thismatrix.$transformpoint = function (matrix, p) {
var pmatrix = multiply(matrix, [[p.x], [p.y]]);
return point(pmatrix[0][0], pmatrix[1][0]);
};
};
_this.$creatematrix = function (alpha, scalex, scaley) {
var cos = math.cos(alpha);
var sin = math.sin(alpha);
//var r11 = cos;
//var r21 = sin;
//var r12 = -sin;
//var r22 = cos;
//var m11 = cos * scalex;
//var m12 = -sin * scaley;
//var m21 = sin * scalex;
//var m22 = cos * scaley;
return [[cos * scalex, -sin * scaley], [sin * scalex, cos * scaley]];
};
_this.$getmatrixoffset = function (matrix, width, height) {
var p1 = $jssormatrix$.$transformpoint(matrix, point(-width / 2, -height / 2));
var p2 = $jssormatrix$.$transformpoint(matrix, point(width / 2, -height / 2));
var p3 = $jssormatrix$.$transformpoint(matrix, point(width / 2, height / 2));
var p4 = $jssormatrix$.$transformpoint(matrix, point(-width / 2, height / 2));
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);
};
_this.$transform = function (fromstyles, tostyles, interposition, easings, durings, rounds, options) {
var currentstyles = tostyles;
if (fromstyles) {
currentstyles = {};
for (var key in tostyles) {
var round = rounds[key] || 1;
var during = durings[key] || [0, 1];
var propertyinterposition = (interposition - during[0]) / during[1];
propertyinterposition = math.min(math.max(propertyinterposition, 0), 1);
propertyinterposition = propertyinterposition * round;
var floorposition = math.floor(propertyinterposition);
if (propertyinterposition != floorposition)
propertyinterposition -= floorposition;
var easing = easings[key] || easings.$default;
var easingvalue = easing(propertyinterposition);
var currentpropertyvalue;
var value = fromstyles[key];
var tovalue = tostyles[key];
if ($jssor$.$isnumeric(tovalue)) {
currentpropertyvalue = value + (tovalue - value) * easingvalue;
}
else {
currentpropertyvalue = $jssor$.$extend({ $offset: {} }, fromstyles[key]);
$jssor$.$each(tovalue.$offset, function (rectx, n) {
var offsetvalue = rectx * easingvalue;
currentpropertyvalue.$offset[n] = offsetvalue;
currentpropertyvalue[n] += offsetvalue;
});
}
currentstyles[key] = currentpropertyvalue;
}
if (fromstyles.$zoom) {
currentstyles.$transform = { $rotate: currentstyles.$rotate || 0, $scale: currentstyles.$zoom, $originalwidth: options.$originalwidth, $originalheight: options.$originalheight };
}
}
if (tostyles.$clip && options.$move) {
var styleframenclipoffset = currentstyles.$clip.$offset;
var offsety = (styleframenclipoffset.$top || 0) + (styleframenclipoffset.$bottom || 0);
var offsetx = (styleframenclipoffset.$left || 0) + (styleframenclipoffset.$right || 0);
currentstyles.$left = (currentstyles.$left || 0) + offsetx;
currentstyles.$top = (currentstyles.$top || 0) + offsety;
currentstyles.$clip.$left -= offsetx;
currentstyles.$clip.$right -= offsetx;
currentstyles.$clip.$top -= offsety;
currentstyles.$clip.$bottom -= offsety;
}
if (currentstyles.$clip && $jssor$.$canclearclip() && !currentstyles.$clip.$top && !currentstyles.$clip.$left && (currentstyles.$clip.$right == options.$originalwidth) && (currentstyles.$clip.$bottom == options.$originalheight))
currentstyles.$clip = null;
return currentstyles;
};
};
//$jssorobject$
var $jssorobject$ = window.$jssorobject$ = function () {
var _thisobject = this;
// fields
var _listeners = []; // dictionary of eventname --> array of handlers
var _listenees = [];
// private methods
function addlistener(eventname, handler) {
$jssordebug$.$execute(function () {
if (eventname == undefined || eventname == null)
throw new error("param 'eventname' is null or empty.");
if (typeof (handler) != "function") {
throw "param 'handler' must be a function.";
}
$jssor$.$each(_listeners, function (listener) {
if (listener.$eventname == eventname && listener.$handler === handler) {
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.");
}
});
});
_listeners.push({ $eventname: eventname, $handler: handler });
}
function removelistener(eventname, handler) {
$jssordebug$.$execute(function () {
if (eventname == undefined || eventname == null)
throw new error("param 'eventname' is null or empty.");
if (typeof (handler) != "function") {
throw "param 'handler' must be a function.";
}
});
$jssor$.$each(_listeners, function (listener, index) {
if (listener.$eventname == eventname && listener.$handler === handler) {
_listeners.splice(index, 1);
}
});
}
function clearlisteners() {
_listeners = [];
}
function clearlistenees() {
$jssor$.$each(_listenees, function (listenee) {
$jssor$.$removeevent(listenee.$obj, listenee.$eventname, listenee.$handler);
});
_listenees = [];
}
//protected methods
_thisobject.$listen = function (obj, eventname, handler, usecapture) {
$jssordebug$.$execute(function () {
if (!obj)
throw new error("param 'obj' is null or empty.");
if (eventname == undefined || eventname == null)
throw new error("param 'eventname' is null or empty.");
if (typeof (handler) != "function") {
throw "param 'handler' must be a function.";
}
$jssor$.$each(_listenees, function (listenee) {
if (listenee.$obj === obj && listenee.$eventname == eventname && listenee.$handler === handler) {
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.");
}
});
});
$jssor$.$addevent(obj, eventname, handler, usecapture);
_listenees.push({ $obj: obj, $eventname: eventname, $handler: handler });
};
_thisobject.$unlisten = function (obj, eventname, handler) {
$jssordebug$.$execute(function () {
if (!obj)
throw new error("param 'obj' is null or empty.");
if (eventname == undefined || eventname == null)
throw new error("param 'eventname' is null or empty.");
if (typeof (handler) != "function") {
throw "param 'handler' must be a function.";
}
});
$jssor$.$each(_listenees, function (listenee, index) {
if (listenee.$obj === obj && listenee.$eventname == eventname && listenee.$handler === handler) {
$jssor$.$removeevent(obj, eventname, handler);
_listenees.splice(index, 1);
}
});
};
_thisobject.$unlistenall = clearlistenees;
// public methods
_thisobject.$on = _thisobject.addeventlistener = addlistener;
_thisobject.$off = _thisobject.removeeventlistener = removelistener;
_thisobject.$triggerevent = function (eventname) {
var args = [].slice.call(arguments, 1);
$jssor$.$each(_listeners, function (listener) {
try {
listener.$eventname == eventname && listener.$handler.apply(window, args);
} catch (e) {
// handler threw an error, ignore, go on to next one
$jssordebug$.$error(e.name + " while executing " + eventname +
" handler: " + e.message, e);
}
});
};
_thisobject.$destroy = function () {
clearlistenees();
clearlisteners();
for (var name in _thisobject)
delete _thisobject[name];
};
$jssordebug$.$c_abstractclass(_thisobject);
};
$jssoranimator$ = function (delay, duration, options, elmt, fromstyles, tostyles) {
delay = delay || 0;
var _thisanimator = this;
var _autoplay;
var _hiden;
var _combinemode;
var _playtoposition;
var _playdirection;
var _nostop;
var _timestamplastframe = 0;
var _subeasings;
var _subrounds;
var _subdurings;
var _callback;
var _shift = 0;
var _position_current = 0;
var _position_display = 0;
var _hooked;
var _position_innerbegin = delay;
var _position_innerend = delay + duration;
var _position_outerbegin;
var _position_outerend;
var _looplength;
var _nestedanimators = [];
var _stylesetter;
function getpositionrange(position, begin, end) {
var range = 0;
if (position < begin)
range = -1;
else if (position > end)
range = 1;
return range;
}
function getinnerpositionrange(position) {
return getpositionrange(position, _position_innerbegin, _position_innerend);
}
function getouterpositionrange(position) {
return getpositionrange(position, _position_outerbegin, _position_outerend);
}
function shift(offset) {
_position_outerbegin += offset;
_position_outerend += offset;
_position_innerbegin += offset;
_position_innerend += offset;
_position_current += offset;
_position_display += offset;
_shift = offset;
//$jssor$.$each(_nestedanimators, function (animator) {
// animator, animator.$shift(offset);
//});
}
function locate(position, relative) {
var offset = position - _position_outerbegin + delay * relative;
shift(offset);
//$jssordebug$.$execute(function () {
// _thisanimator.$position_innerbegin = _position_innerbegin;
// _thisanimator.$position_innerend = _position_innerend;
// _thisanimator.$position_outerbegin = _position_outerbegin;
// _thisanimator.$position_outerend = _position_outerend;
//});
return _position_outerend;
}
function gotoposition(positionouter, force) {
var trimedpositionouter = positionouter;
if (_looplength && (trimedpositionouter >= _position_outerend || trimedpositionouter <= _position_outerbegin)) {
trimedpositionouter = ((trimedpositionouter - _position_outerbegin) % _looplength + _looplength) % _looplength + _position_outerbegin;
}
if (!_hooked || _nostop || force || _position_current != trimedpositionouter) {
var positiontodisplay = math.min(trimedpositionouter, _position_outerend);
positiontodisplay = math.max(positiontodisplay, _position_outerbegin);
if (!_hooked || _nostop || force || positiontodisplay != _position_display) {
if (tostyles) {
var interposition = (positiontodisplay - _position_innerbegin) / (duration || 1);
//if (options.$optimize && $jssor$.$isbrowserchrome() && duration) {
// interposition = math.round(interposition / 8 * duration) * 8 / duration;
//}
if (options.$reverse)
interposition = 1 - interposition;
var currentstyles = $jssor$.$transform(fromstyles, tostyles, interposition, _subeasings, _subdurings, _subrounds, options);
$jssor$.$each(currentstyles, function (value, key) {
_stylesetter[key] && _stylesetter[key](elmt, value);
});
}
_thisanimator.$oninneroffsetchange(_position_display - _position_innerbegin, positiontodisplay - _position_innerbegin);
}
_position_display = positiontodisplay;
$jssor$.$each(_nestedanimators, function (animator, i) {
var nestedanimator = positionouter < _position_current ? _nestedanimators[_nestedanimators.length - i - 1] : animator;
nestedanimator.$gotoposition(positionouter - _shift, force);
});
var positionold = _position_current;
var positionnew = positionouter;
_position_current = trimedpositionouter;
_hooked = true;
_thisanimator.$onpositionchange(positionold, positionnew);
}
}
function join(animator, combinemode, noexpand) {
///
/// combine another animator as nested animator
///
///
/// an instance of $jssoranimator$
///
///
/// 0: parallel - place the animator parallel to this animator.
/// 1: chain - chain the animator at the _position_innerend of this animator.
///
$jssordebug$.$execute(function () {
if (combinemode !== 0 && combinemode !== 1)
$jssordebug$.$fail("argument out of range, the value of 'combinemode' should be either 0 or 1.");
});
if (combinemode)
animator.$locate(_position_outerend, 1);
!noexpand && (_position_outerend = math.max(_position_outerend, animator.$getposition_outerend() + _shift));
_nestedanimators.push(animator);
}
var requestanimationframe = window.requestanimationframe
|| window.webkitrequestanimationframe
|| window.mozrequestanimationframe
|| window.msrequestanimationframe;
if ($jssor$.$isbrowsersafari() && $jssor$.$browserversion() < 7) {
requestanimationframe = null;
$jssordebug$.$log("custom animation frame for safari before 7.");
}
requestanimationframe = requestanimationframe || function (callback) {
$jssor$.$delay(callback, options.$interval);
};
function showframe() {
if (_autoplay) {
var now = $jssor$.$getnow();
var timeoffset = math.min(now - _timestamplastframe, options.$intervalmax);
var timeposition = _position_current + timeoffset * _playdirection;
_timestamplastframe = now;
if (timeposition * _playdirection >= _playtoposition * _playdirection)
timeposition = _playtoposition;
gotoposition(timeposition);
if (!_nostop && timeposition * _playdirection >= _playtoposition * _playdirection) {
stop(_callback);
}
else {
requestanimationframe(showframe);
}
}
}
function playtoposition(toposition, callback, nostop) {
if (!_autoplay) {
_autoplay = true;
_nostop = nostop
_callback = callback;
toposition = math.max(toposition, _position_outerbegin);
toposition = math.min(toposition, _position_outerend);
_playtoposition = toposition;
_playdirection = _playtoposition < _position_current ? -1 : 1;
_thisanimator.$onstart();
_timestamplastframe = $jssor$.$getnow();
requestanimationframe(showframe);
}
}
function stop(callback) {
if (_autoplay) {
_nostop = _autoplay = _callback = false;
_thisanimator.$onstop();
if (callback)
callback();
}
}
_thisanimator.$play = function (positionlength, callback, nostop) {
playtoposition(positionlength ? _position_current + positionlength : _position_outerend, callback, nostop);
};
_thisanimator.$playtoposition = playtoposition;
_thisanimator.$playtobegin = function (callback, nostop) {
playtoposition(_position_outerbegin, callback, nostop);
};
_thisanimator.$playtoend = function (callback, nostop) {
playtoposition(_position_outerend, callback, nostop);
};
_thisanimator.$stop = stop;
_thisanimator.$continue = function (toposition) {
playtoposition(toposition);
};
_thisanimator.$getposition = function () {
return _position_current;
};
_thisanimator.$getplaytoposition = function () {
return _playtoposition;
};
_thisanimator.$getposition_display = function () {
return _position_display;
};
_thisanimator.$gotoposition = gotoposition;
_thisanimator.$gotobegin = function () {
gotoposition(_position_outerbegin, true);
};
_thisanimator.$gotoend = function () {
gotoposition(_position_outerend, true);
};
_thisanimator.$move = function (offset) {
gotoposition(_position_current + offset);
};
_thisanimator.$combinemode = function () {
return _combinemode;
};
_thisanimator.$getduration = function () {
return duration;
};
_thisanimator.$isplaying = function () {
return _autoplay;
};
_thisanimator.$isontheway = function () {
return _position_current > _position_innerbegin && _position_current <= _position_innerend;
};
_thisanimator.$setlooplength = function (length) {
_looplength = length;
};
_thisanimator.$locate = locate;
_thisanimator.$shift = shift;
_thisanimator.$join = join;
_thisanimator.$combine = function (animator) {
///
/// combine another animator parallel to this animator
///
///
/// an instance of $jssoranimator$
///
join(animator, 0);
};
_thisanimator.$chain = function (animator) {
///
/// chain another animator at the _position_innerend of this animator
///
///
/// an instance of $jssoranimator$
///
join(animator, 1);
};
_thisanimator.$getposition_innerbegin = function () {
///
/// internal member function, do not use it.
///
///
///
return _position_innerbegin;
};
_thisanimator.$getposition_innerend = function () {
///
/// internal member function, do not use it.
///
///
///
return _position_innerend;
};
_thisanimator.$getposition_outerbegin = function () {
///
/// internal member function, do not use it.
///
///
///
return _position_outerbegin;
};
_thisanimator.$getposition_outerend = function () {
///
/// internal member function, do not use it.
///
///
///
return _position_outerend;
};
_thisanimator.$onpositionchange = _thisanimator.$onstart = _thisanimator.$onstop = _thisanimator.$oninneroffsetchange = $jssor$.$emptyfunction;
_thisanimator.$version = $jssor$.$getnow();
//constructor 1
{
options = $jssor$.$extend({
$interval: 16,
$intervalmax: 50
}, options);
//sodo statement, for development time intellisence only
$jssordebug$.$execute(function () {
options = $jssor$.$extend({
$looplength: undefined,
$setter: undefined,
$easing: undefined
}, options);
});
_looplength = options.$looplength;
_stylesetter = $jssor$.$extend({}, $jssor$.$stylesetter(), options.$setter);
_position_outerbegin = _position_innerbegin = delay;
_position_outerend = _position_innerend = delay + duration;
_subrounds = options.$round || {};
_subdurings = options.$during || {};
_subeasings = $jssor$.$extend({ $default: $jssor$.$isfunction(options.$easing) && options.$easing || $jssoreasing$.$easeswing }, options.$easing);
}
};
function $jssorplayerclass$() {
var _thisplayer = this;
var _playercontrollers = [];
function playercontroller(playerelement) {
var _selfplayercontroller = this;
var _playerinstance;
var _playerinstantces = [];
function onplayerinstancedataavailable(event) {
var srcelement = $jssor$.$eventsrc(event);
_playerinstance = srcelement.pinstance;
$jssor$.$removeevent(srcelement, "dataavailable", onplayerinstancedataavailable);
$jssor$.$each(_playerinstantces, function (playerinstance) {
if (playerinstance != _playerinstance) {
playerinstance.$remove();
}
});
playerelement.ptagname = _playerinstance.tagname;
_playerinstantces = null;
}
function handleplayerinstance(playerinstanceelement) {
var playerhandler;
if (!playerinstanceelement.pinstance) {
var playerhandlerattribute = $jssor$.$attributeex(playerinstanceelement, "phandler");
if ($jssorplayer$[playerhandlerattribute]) {
$jssor$.$addevent(playerinstanceelement, "dataavailable", onplayerinstancedataavailable);
playerhandler = new $jssorplayer$[playerhandlerattribute](playerelement, playerinstanceelement);
_playerinstantces.push(playerhandler);
$jssordebug$.$execute(function () {
if ($jssor$.$type(playerhandler.$remove) != "function") {
$jssordebug$.$fail("'premove' interface not implemented for player handler '" + playerhandlerattribute + "'.");
}
});
}
}
return playerhandler;
}
_selfplayercontroller.$initplayercontroller = function () {
if (!playerelement.pinstance && !handleplayerinstance(playerelement)) {
var playerinstanceelements = $jssor$.$children(playerelement);
$jssor$.$each(playerinstanceelements, function (playerinstanceelement) {
handleplayerinstance(playerinstanceelement);
});
}
};
}
_thisplayer.$evt_switch = 21;
_thisplayer.$fetchplayers = function (elmt) {
elmt = elmt || document.body;
var playerelements = $jssor$.$findchildren(elmt, "player");
$jssor$.$each(playerelements, function (playerelement) {
if (!_playercontrollers[playerelement.pid]) {
playerelement.pid = _playercontrollers.length;
_playercontrollers.push(new playercontroller(playerelement));
}
var playercontroller = _playercontrollers[playerelement.pid];
playercontroller.$initplayercontroller();
});
};
}