/** ***** BEGIN LICENSE BLOCK *****
* |------------------------------------------------------------------------------|
* | O2OA 活力办公 创意无限 o2.js |
* |------------------------------------------------------------------------------|
* | Distributed under the AGPL license: |
* |------------------------------------------------------------------------------|
* | Copyright © 2018, o2oa.net, o2server.io O2 Team |
* | All rights reserved. |
* |------------------------------------------------------------------------------|
*
* This file is part of O2OA.
*
* O2OA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* O2OA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see .
*
* ***** END LICENSE BLOCK ******/
/* load o2 Core
* |------------------------------------------------------------------------------|
* |addReady: o2.addReady(fn), |
* |------------------------------------------------------------------------------|
* |load: o2.load(urls, callback, reload) |
* |loadCss: o2.loadCss(urls, dom, callback, reload, doc) |
* |------------------------------------------------------------------------------|
* |typeOf: o2.typeOf(o) |
* |------------------------------------------------------------------------------|
* |uuid: o2.uuid() |
* |------------------------------------------------------------------------------|
*/
//Element.firstElementChild Polyfill
(function(constructor) {
if (constructor &&
constructor.prototype &&
constructor.prototype.firstElementChild == null) {
Object.defineProperty(constructor.prototype, 'firstElementChild', {
get: function() {
var node, nodes = this.childNodes, i = 0;
while (node = nodes[i++]) {
if (node.nodeType === 1) {
return node;
}
}
return null;
}
});
}
})(window.Node || window.Element);
(function(){
var _href = window.location.href;
var _debug = (_href.indexOf("debugger")!==-1);
var _par = _href.substr(_href.lastIndexOf("?")+1, _href.length);
var _lp = "zh-cn";
if (_par){
var _parList = _par.split("&");
for (var i=0; i<_parList.length; i++){
var _v = _parList[i];
var _kv = _v.split("=");
if (_kv[0].toLowerCase()==="lg") _lp = _kv[1];
if (_kv[0].toLowerCase()==="lp") _lp = _kv[1];
}
}
this.o2 = window.o2 || {};
this.o2.version = {
"v": "5.1.1",
"build": "2020.06.12",
"info": "O2OA 活力办公 创意无限. Copyright © 2020, o2oa.net O2 Team All rights reserved."
};
if (!this.o2.session) this.o2.session ={
"isDebugger": _debug,
"path": "../o2_core/o2"
};
this.o2.language = _lp;
this.o2.splitStr = /\s*(?:,|;)\s*/;
// this.o2 = {
// "version": {
// "v": "2.3.1",
// "build": "2019.07.31",
// "info": "O2OA 活力办公 创意无限. Copyright © 2018, o2oa.net O2 Team All rights reserved."
// },
// "session": {
// "isDebugger": _debug,
// "path": "../o2_core/o2"
// },
// "language": _lp,
// "splitStr": /\s*(?:,|;)\s*/
// };
this.wrdp = this.o2;
var debug = function(reload){
if (reload){
window.location.assign(_href + ((_href.indexOf("?")==-1) ? "?" : "&")+"debugger");
}else{
if (!o2.session.isDebugger){
o2.session.isDebugger = true;
if (o2.session.isMobile || layout.mobile) o2.load("../o2_lib/eruda/eruda.js");
}
}
};
this.o2.debug = debug;
var _attempt = function(){
for (var i = 0, l = arguments.length; i < l; i++){
try {
arguments[i]();
return arguments[i];
} catch (e){}
}
return null;
};
var _typeOf = function(item){
if (item == null) return 'null';
if (item.$family != null) return item.$family();
if (item.constructor == window.Array) return "array";
if (item.nodeName){
if (item.nodeType == 1) return 'element';
if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';
} else if (typeof item.length == 'number'){
if (item.callee) return 'arguments';
}
return typeof item;
};
this.o2.typeOf = _typeOf;
var _addListener = function(dom, type, fn){
if (type == 'unload'){
var old = fn, self = this;
fn = function(){
_removeListener(dom, 'unload', fn);
old();
};
}
if (dom.addEventListener) dom.addEventListener(type, fn, !!arguments[2]);
else dom.attachEvent('on' + type, fn);
};
var _removeListener = function(dom, type, fn){
if (dom.removeEventListener) dom.removeEventListener(type, fn, !!arguments[2]);
else dom.detachEvent('on' + type, fn);
};
//http request class
var _request = (function(){
var XMLHTTP = function(){ return new XMLHttpRequest(); };
var MSXML2 = function(){ return new ActiveXObject('MSXML2.XMLHTTP'); };
var MSXML = function(){ return new ActiveXObject('Microsoft.XMLHTTP'); };
return _attempt(XMLHTTP, MSXML2, MSXML);
})();
this.o2.request = _request;
var _returnBase = function(number, base) {
return (number).toString(base).toUpperCase();
};
var _getIntegerBits = function(val, start, end){
var base16 = _returnBase(val, 16);
var quadArray = new Array();
var quadString = '';
var i = 0;
for (i = 0; i < base16.length; i++) {
quadArray.push(base16.substring(i, i + 1));
}
for (i = Math.floor(start / 4); i <= Math.floor(end / 4); i++) {
if (!quadArray[i] || quadArray[i] == '')
quadString += '0';
else
quadString += quadArray[i];
}
return quadString;
};
var _rand = function(max) {
return Math.floor(Math.random() * (max + 1));
};
this.o2.addListener = _addListener;
this.o2.removeListener = _removeListener;
//uuid
var _uuid = function(){
var dg = new Date(1582, 10, 15, 0, 0, 0, 0);
var dc = new Date();
var t = dc.getTime() - dg.getTime();
var tl = _getIntegerBits(t, 0, 31);
var tm = _getIntegerBits(t, 32, 47);
var thv = _getIntegerBits(t, 48, 59) + '1';
var csar = _getIntegerBits(_rand(4095), 0, 7);
var csl = _getIntegerBits(_rand(4095), 0, 7);
var n = _getIntegerBits(_rand(8191), 0, 7)
+ _getIntegerBits(_rand(8191), 8, 15)
+ _getIntegerBits(_rand(8191), 0, 7)
+ _getIntegerBits(_rand(8191), 8, 15)
+ _getIntegerBits(_rand(8191), 0, 15);
return tl + tm + thv + csar + csl + n;
};
this.o2.uuid = _uuid;
var _runCallback = function(callback, key, par, bind){
var b = bind || callback;
var type = o2.typeOf(callback).toLowerCase();
if (!key) key = "success";
if (key.toLowerCase()==="success" && (type==="function" || type==="o2_async_function")){
callback.apply(b, par);
}else{
if (type==="function" || type==="object" || type==="o2_async_function"){
var name = ("on-"+key).camelCase();
if (callback[name]){
callback[name].apply(b, par);
}else{
if (callback[key]) callback[key].apply(b, par);
}
}
}
// if (typeOf(callback).toLowerCase() === 'function'){
// if (key.toLowerCase()==="success"){
// callback.apply(b, par);
// }else{
// if (callback[key]){
// callback[key].apply(b, par);
// }else{
// var name = ("on-"+key).camelCase();
// if (callback[name]) callback[name].apply(b, par);
// }
// }
// }else{
// if (typeOf(callback).toLowerCase()==='object'){
// if (callback[key]){
// callback[key].apply(b, par);
// }else{
// var name = ("on-"+key).camelCase();
// if (callback[name]) callback[name].apply(b, par);
// }
// }
// }
};
this.o2.runCallback = _runCallback;
//load js, css, html adn all.
var _getAllOptions = function(options){
var doc = (options && options.doc) || document;
if (!doc.unid) doc.unid = _uuid();
var type = (options && options.type) || "text/javascript";
return {
"noCache": !!(options && options.nocache),
"reload": !!(options && options.reload),
"sequence": !!(options && options.sequence),
"type": type,
"doc": doc,
"dom": (options && options.dom) || document.body,
"module": (options && options.module) || null,
"noConflict": (options && options.noConflict) || false,
"bind": (options && options.bind) || null,
"position": (options && options.position) || "beforeend" //'beforebegin' 'afterbegin' 'beforeend' 'afterend'debugger
}
};
var _getCssOptions = function(options){
var doc = (options && options.doc) || document;
if (!doc.unid) doc.unid = _uuid();
return {
"noCache": !!(options && options.nocache),
"reload": !!(options && options.reload),
"sequence": !!(options && options.sequence),
"doc": doc,
"dom": (options && options.dom) || null
}
};
var _getJsOptions = function(options){
var doc = (options && options.doc) || document;
if (!doc.unid) doc.unid = _uuid();
var type = (options && options.type) || "text/javascript";
return {
"noCache": !!(options && options.nocache),
"reload": !!(options && options.reload),
"sequence": (!(options && options.sequence == false)),
"type": type,
"doc": doc
}
};
var _getHtmlOptions = function(options){
var doc = (options && options.doc) || document;
if (!doc.unid) doc.unid = _uuid();
return {
"noCache": !!(options && options.nocache),
"reload": !!(options && options.reload),
"sequence": !!(options && options.sequence),
"doc": doc,
"dom": (options && options.dom) || null,
"module": (options && options.module) || null,
"noConflict": (options && options.noConflict) || false,
"bind": (options && options.bind) || null,
"position": (options && options.position) || "beforeend" //'beforebegin' 'afterbegin' 'beforeend' 'afterend'
}
};
_filterUrl = function(url){
if (o2.base){
if (url.indexOf(":")===-1){
var s = url.substring(0, url.indexOf("/")+1);
var r = url.substring(url.indexOf("/")+1, url.length);
if ("../"===s || "./"===s || "/"===s){
return s+o2.base+r;
}else{
return o2.base+url
}
}
}
// if (!window.layout) window.layout = {};
// if (!window.layout.config){
// new Request.JSON({
// url: "../x_desktop/res/config/config.json",
// secure: false,
// method: "get",
// noCache: true,
// async: false,
// onSuccess: function(responseJSON, responseText){
// window.layout.config = responseJSON;
// }.bind(this),
// }).send();
// }
if (window.layout && layout.config && layout.config.urlMapping){
for (var k in layout.config.urlMapping){
var regex = new RegExp(k);
if (regex.test(url)){
return url.replace(regex, layout.config.urlMapping[k]);
}
}
}
return url;
};
this.o2.filterUrl = _filterUrl;
var _xhr_get = function(url, success, failure, completed){
var xhr = new _request();
url = _filterUrl(url);
xhr.open("GET", url, true);
var _checkCssLoaded= function(_, err){
if (!(xhr.readyState == 4)) return;
if (err){
if (completed) completed(xhr);
return;
}
_removeListener(xhr, 'readystatechange', _checkCssLoaded);
_removeListener(xhr, 'load', _checkCssLoaded);
_removeListener(xhr, 'error', _checkCssErrorLoaded);
if (err) {if (failure) failure(xhr); return}
var status = xhr.status;
status = (status == 1223) ? 204 : status;
if ((status >= 200 && status < 300))
if (success) success(xhr);
else if ((status >= 300 && status < 400))
if (failure) failure(xhr);
else
failure(xhr);
if (completed) completed(xhr);
};
var _checkCssErrorLoaded= function(err){ _checkCssLoaded(err) };
if ("load" in xhr) _addListener(xhr, "load", _checkCssLoaded);
if ("error" in xhr) _addListener(xhr, "load", _checkCssErrorLoaded);
_addListener(xhr, "readystatechange", _checkCssLoaded);
xhr.send();
};
this.o2.xhr_get = _xhr_get;
var _loadSequence = function(ms, cb, op, n, thisLoaded, loadSingle, uuid, fun){
loadSingle(ms[n], function(module){
if (module) thisLoaded.push(module);
n++;
if (fun) fun(module);
if (n===ms.length){
if (cb) cb(thisLoaded);
}else{
_loadSequence(ms, cb, op, n, thisLoaded, loadSingle, uuid, fun);
}
}, op, uuid);
};
var _loadDisarray = function(ms, cb, op, thisLoaded, loadSingle, uuid, fun){
var count=0;
for (var i=0; i1){
node.addEventListener(evs[0], function(e){
if (m[evs[1]]) m[evs[1]].apply(m, [e]);
}, false);
}
});
}
var _bindToModule = function(m, node, name){
// if (m[name]){
// if (o2.typeOf(m[name])!=="array"){
// var tmp = m[name];
// m[name] = [];
// m[name].push(tmp);
// }
// m[name].push(node);
// }else{
m[name] = node;
// }
};
var _loadHtml = function(modules, options, callback){
var ms = (_typeOf(modules)==="array") ? modules : [modules];
var op = (_typeOf(options)==="object") ? _getHtmlOptions(options) : _getHtmlOptions(null);
var cb = (_typeOf(options)==="function") ? options : callback;
var thisLoaded = [];
if (op.sequence){
_loadSequence(ms, cb, op, 0, thisLoaded, _loadSingleHtml, null, function(html){ if (html) _injectHtml(op, html.data ); });
}else{
_loadDisarray(ms, cb, op, thisLoaded, _loadSingleHtml, null, function(html){ if (html) _injectHtml(op, html.data ); });
}
};
this.o2.loadHtml = _loadHtml;
if (window.Element) Element.prototype.loadHtml = function(modules, options, callback){
var op = (_typeOf(options)==="object") ? options : {};
var cb = (_typeOf(options)==="function") ? options : callback;
op.dom = this;
_loadHtml(modules, op, cb);
};
this.o2.injectHtml = function(html, op){
_injectHtml(op, html);
};
if (window.Element) Element.prototype.injectHtml = function(html, options){
var op = (_typeOf(options)==="object") ? options : {};
op.dom = this;
op.position = (options && options.position) || "beforeend"
_injectHtml(op, html);
};
//load all
_loadAll = function(modules, options, callback){
//var ms = (_typeOf(modules)==="array") ? modules : [modules];
var op = (_typeOf(options)==="object") ? _getAllOptions(options) : _getAllOptions(null);
var cb = (_typeOf(options)==="function") ? options : callback;
var ms, htmls, styles, sctipts;
var _htmlLoaded=(!modules.html), _cssLoaded=(!modules.css), _jsLoaded=(!modules.js);
var _checkloaded = function(){
if (_htmlLoaded && _cssLoaded && _jsLoaded) if (cb) cb(htmls, styles, sctipts);
};
if (modules.html){
_loadHtml(modules.html, op, function(h){
htmls = h;
_htmlLoaded = true;
_checkloaded();
});
}
if (modules.css){
_loadCss(modules.css, op, function(s){
styles = s;
_cssLoaded = true;
_checkloaded();
});
}
if (modules.js){
_load(modules.js, op, function(s){
sctipts = s;
_jsLoaded = true;
_checkloaded();
});
}
};
this.o2.loadAll = _loadAll;
if (window.Element) Element.prototype.loadAll = function(modules, options, callback){
var op = (_typeOf(options)==="object") ? options : {};
var cb = (_typeOf(options)==="function") ? options : callback;
op.dom = this;
_loadAll(modules, op, cb);
};
var _getIfBlockEnd = function(v){
var rex = /(\{\{if\s+)|(\{\{\s*end if\s*\}\})/gmi;
var rexEnd = /\{\{\s*end if\s*\}\}/gmi;
var subs = 1;
while ((match = rex.exec(v)) !== null) {
var fullMatch = match[0];
if (fullMatch.search(rexEnd)!==-1){
subs--;
if (subs==0) break;
}else{
subs++
}
}
if (match) return {"codeIndex": match.index, "lastIndex": rex.lastIndex};
return {"codeIndex": v.length-1, "lastIndex": v.length-1};
}
var _getEachBlockEnd = function(v){
var rex = /(\{\{each\s+)|(\{\{\s*end each\s*\}\})/gmi;
var rexEnd = /\{\{\s*end each\s*\}\}/gmi;
var subs = 1;
while ((match = rex.exec(v)) !== null) {
var fullMatch = match[0];
if (fullMatch.search(rexEnd)!==-1){
subs--;
if (subs==0) break;
}else{
subs++;
}
}
if (match) return {"codeIndex": match.index, "lastIndex": rex.lastIndex};
return {"codeIndex": v.length-1, "lastIndex": v.length-1};
}
var _parseHtml = function(str, json){
var v = str;
var rex = /(\{\{\s*)[\s\S]*?(\s*\}\})/gmi;
var match;
while ((match = rex.exec(v)) !== null) {
var fullMatch = match[0];
var offset = 0;
//if statement begin
if (fullMatch.search(/\{\{if\s+/i)!==-1){
//找到对应的end if
var condition = fullMatch.replace(/^\{\{if\s*/i, "");
condition = condition.replace(/\s*\}\}$/i, "");
var flag = _jsonText(json, condition, "boolean");
var tmpStr = v.substring(rex.lastIndex, v.length);
var endIfIndex = _getIfBlockEnd(tmpStr);
if (flag){ //if 为 true
var parseStr = _parseHtml(tmpStr.substring(0, endIfIndex.codeIndex), json);
var vLeft = v.substring(0, match.index);
var vRight = v.substring(rex.lastIndex+endIfIndex.lastIndex, v.length);
v = vLeft + parseStr + vRight;
offset = parseStr.length - fullMatch.length;
}else{
v = v.substring(0, match.index) + v.substring(rex.lastIndex+endIfIndex.lastIndex, v.length);
offset = 0-fullMatch.length;
}
}else if (fullMatch.search(/\{\{each\s+/)!==-1) { //each statement
var itemString = fullMatch.replace(/^\{\{each\s*/, "");
itemString = itemString.replace(/\s*\}\}$/, "");
var eachValue = _jsonText(json, itemString, "object");
var tmpEachStr = v.substring(rex.lastIndex, v.length);
var endEachIndex = _getEachBlockEnd(tmpEachStr);
var parseEachStr = tmpEachStr.substring(0, endEachIndex.codeIndex);
var eachResult = "";
if (eachValue && _typeOf(eachValue)==="array"){
for (var i=0; i/g, ">");
returnValue = returnValue.replace(/.
*
* ***** END LICENSE BLOCK ******/
(function (){
var _Class = {
create: function(options) {
// var newClass = function() {
// this.initialize.apply(this, arguments);
// };
return _copyPrototype(function() {
return this.initialize.apply(this, arguments) || this;
}, options);
//return newClass;
}
};
var _copyPrototype = function (currentNS, props){
if (!props){return currentNS;}
if (!currentNS){return currentNS;}
if ((typeof currentNS).toLowerCase()==="object"){
for (var prop in props){
currentNS[prop] = props[prop];
}
}
if ((typeof currentNS).toLowerCase()==="function"){
for (var propfun in props){
currentNS.prototype[propfun] = props[propfun];
}
}
return currentNS;
};
var _loaded = {};
var _requireJs = function(url, callback, async, compression, module){
var key = encodeURIComponent(url);
if (_loaded[key]){o2.runCallback(callback, "success", [module]); return "";}
var jsPath = (compression || !this.o2.session.isDebugger) ? url.replace(/\.js/, ".min.js") : url;
jsPath = (jsPath.indexOf("?")!==-1) ? jsPath+"&v="+this.o2.version.v : jsPath+"?v="+this.o2.version.v;
var xhr = new Request({
url: o2.filterUrl(jsPath), async: async, method: "get",
onSuccess: function(){
//try{
_loaded[key] = true;
o2.runCallback(callback, "success", [module]);
//}catch (e){
// o2.runCallback(callback, "failure", [e]);
//}
},
onFailure: function(r){
var rex = /lp\/.+\.js/;
if (rex.test(url)){
var zhcnUrl = url.replace(rex, "lp/zh-cn.js");
if (zhcnUrl!==url){
_requireJs(zhcnUrl, callback, async, compression, module)
}else{
o2.runCallback(callback, "failure", [r]);
}
}else{
o2.runCallback(callback, "failure", [r]);
}
}
});
xhr.send();
};
var _requireSingle = function(module, callback, async, compression){
if (o2.typeOf(module)==="array"){
_requireAppSingle(module, callback, async, compression);
}else{
module = module.replace("MWF.", "o2.");
var levels = module.split(".");
if (levels[levels.length-1]==="*") levels[levels.length-1] = "package";
levels.shift();
var o = o2;
var i = 0;
while (o && i>> 0;
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var thisArg = arguments[1];
var k = 0;
while (k < len) {
var kValue = o[k];
if (predicate.call(thisArg, kValue, k, o)) {
return k;
}
k++;
}
return -1;
}
});
}
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
value: function(predicate) {
if (this == null) {
throw new TypeError('"this" is null or not defined');
}
var o = Object(this);
var len = o.length >>> 0;
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var thisArg = arguments[1];
var k = 0;
while (k < len) {
var kValue = o[k];
if (predicate.call(thisArg, kValue, k, o)) {
return kValue;
}
k++;
}
return undefined;
}
});
}
var _txt = function(v){
var t = v.replace(/\.
*
* ***** END LICENSE BLOCK ******/
(function (){
o2.getCenterPosition = function(el, width, height){
var elPositon = $(el).getPosition();
var elSize = $(el).getSize();
var node = $("layout");
var size = (node) ? $(node).getSize() : $(document.body).getSize();
var top = (elPositon.y+elSize.y)/2 - (height/2);
var left = (elPositon.x+elSize.x)/2-(width/2);
if ((left+width)>size.x){
left = size.x-width-10;
}
if ((top+height)>size.y){
top = size.y-height-10;
}
return {"x": left, "y": top};
};
o2.getMarkSize = function(node){
var size;
if (!node){
size = $(document.body).getSize();
var winSize = $(window).getSize();
var height = size.y;
var width = size.x;
if (height=0 && p.y-srcoll.y>=0) && (p.x+nodeSize.x=0 && p.y>=0) && (p.x+nodeSize.x (elementCoords.left + elementCoords.width)) ||
(e.page.y < elementCoords.top || e.page.y > (elementCoords.top + elementCoords.height))) &&
((e.page.x < targetCoords.left || e.page.x > (targetCoords.left + targetCoords.width)) ||
(e.page.y < targetCoords.top || e.page.y > (targetCoords.top + targetCoords.height))) ) return true;
return false;
},
"getAbsolutePosition":function(){
var styleLeft = 0;
var styleTop = 0;
var node = this;
styleLeft = node.offsetLeft;
styleTop = node.offsetTop;
node = node.parentElement;
while (node && node.tagName.toString().toLowerCase()!=="body"){
styleLeft += node.offsetLeft;
styleTop += node.offsetTop;
node = node.offsetParent;
}
return {x: styleLeft, y: styleTop};
},
"tweenScroll": function(to, time){
if (!this.tweenScrollQueue){
this.tweenScrollQueue = [];
}
if (this.tweenScrollQueue.length){
this.tweenScrollQueue.push(to);
}else{
this.tweenScrollQueue.push(to);
this.doTweenScrollQueue(time);
}
},
"doTweenScrollQueue": function(time){
if (this.tweenScrollQueue.length){
var i = this.tweenScrollQueue.length;
var to = this.tweenScrollQueue[this.tweenScrollQueue.length-1];
var scroll = this.getScroll();
var dy = to - scroll.y;
var step = dy/time;
var count = 0;
var move = 0;
var id = window.setInterval(function(){
this.scrollTo(0, scroll.y+count*step);
count++;
if (count>time){
window.clearInterval(id);
for (var x=1; x<=i; x++) this.tweenScrollQueue.shift();
if (this.tweenScrollQueue.length) this.doTweenScrollQueue(time);
}
}.bind(this), 1);
}
},
"isPointIn": function(px, py, offX, offY, el){
if (!offX) offX = 0;
if (!offY) offY = 0;
var position = this.getPosition(el);
var size = this.getSize();
return (position.x-offX<=px && position.x+size.x+offX>=px && position.y-offY<=py && position.y+size.y+offY>=py);
},
"isInPointInRect": function(sx, sy, ex, ey){
var position = this.getPosition();
var size = this.getSize();
var p1 = {"x": position.x, "y": position.y};
var p2 = {"x": position.x+size.x, "y": position.y};
var p3 = {"x": position.x+size.x, "y": position.y+size.y};
var p4 = {"x": position.x, "y": position.y+size.y};
var sp = {"x": Math.min(sx, ex), "y": Math.min(sy, ey)};
var ep = {"x": Math.max(sx, ex), "y": Math.max(sy, ey)};
if (p1.x>=sp.x && p1.y>=sp.y && p1.x<=ep.x && p1.y<=ep.y) return true;
if (p2.x>=sp.x && p2.y>=sp.y && p2.x<=ep.x && p2.y<=ep.y) return true;
if (p3.x>=sp.x && p3.y>=sp.y && p3.x<=ep.x && p3.y<=ep.y) return true;
if (p4.x>=sp.x && p4.y>=sp.y && p4.x<=ep.x && p4.y<=ep.y) return true;
if (p3.x>=sp.x && p3.y>=sp.y && p1.x<=sp.x && p1.y<=sp.y) return true;
if (p3.x>=ep.x && p3.y>=ep.y && p1.x<=ep.x && p1.y<=ep.y) return true;
if (p1.x<=sp.x && p2.x>=sp.x && p1.y>=sp.y && p4.y<=ep.y) return true;
if (p1.y<=sp.y && p4.y>=sp.y && p1.x>=sp.x && p2.x<=ep.x) return true;
return false;
},
"isOverlap": function(node){
var p = node.getPosition();
var s = node.getSize();
return this.isInPointInRect(p.x, p.y, p.x+s.x, p.y+s.y);
},
"getUsefulSize": function(){
var size = this.getSize();
var borderLeft = this.getStyle("border-left").toInt();
var borderBottom = this.getStyle("border-bottom").toInt();
var borderTop = this.getStyle("border-top").toInt();
var borderRight = this.getStyle("border-right").toInt();
var paddingLeft = this.getStyle("padding-left").toInt();
var paddingBottom = this.getStyle("padding-bottom").toInt();
var paddingTop = this.getStyle("padding-top").toInt();
var paddingRight = this.getStyle("padding-right").toInt();
var x = size.x-paddingLeft-paddingRight;
var y = size.y-paddingTop-paddingBottom;
return {"x": x, "y": y};
},
"clearStyles": function(isChild){
this.removeProperty("style");
if (isChild){
var subNode = this.getFirst();
while (subNode){
subNode.clearStyles(isChild);
subNode = subNode.getNext();
}
}
},
"maskIf": function(styles, click){
var style = {
"background-color": "#666666",
"opacity": 0.4,
"z-index":100
};
if (styles){
style = Object.merge(style, styles);
}
var position = this.getPosition(this.getOffsetParent());
this.mask({
"destroyOnHide": true,
"style": style,
"useIframeShim": true,
"iframeShimOptions": {"browsers": true},
"onShow": function(){
this.shim.shim.setStyles({
"opacity": 0,
"top": ""+position.y+"px",
"left": ""+position.x+"px"
});
},
"onClick": click
});
},
"scrollIn": function(where){
var wh = (where) ? where.toString().toLowerCase() : "center";
if (Browser.name=="ie" || Browser.name=="safari"){
var scrollNode = this.getParentSrcollNode();
var scrollFx = new Fx.Scroll(scrollNode);
var scroll = scrollNode.getScroll();
var size = scrollNode.getSize();
var thisSize = this.getComputedSize();
var p = this.getPosition(scrollNode);
if (wh=="start"){
var top = 0;
scrollFx.start(scroll.x, p.y-top+scroll.y);
}else if (wh=="end"){
var bottom = size.y-thisSize.totalHeight;
scrollFx.start(scroll.x, p.y-bottom+scroll.y);
}else{
var center = size.y/2-thisSize.totalHeight/2;
scrollFx.start(scroll.x, p.y-center+scroll.y);
}
}else{
if (wh!=="start" && wh!=="end") wh = "center"
this.scrollIntoView({"behavior": "smooth", "block": wh, "inline": "nearest"});
}
},
scrollToNode: function(el, where){
var scrollSize = this.getScrollSize();
if (!scrollSize.y) return true;
var wh = (where) ? where.toString().toLowerCase() : "bottom";
var node = $(el);
var size = node.getComputedSize();
var p = node.getPosition(this);
var thisSize = this.getComputedSize();
var scroll = this.getScroll();
if (wh==="top"){
var n = (p.y-thisSize.computedTop);
if (n<0) this.scrollTo(scroll.x, scroll.y+n);
n = (size.totalHeight+p.y-thisSize.computedTop)-thisSize.height;
if (n>0) this.scrollTo(scroll.x, scroll.y+n);
}else{
var n = (size.totalHeight+p.y-thisSize.computedTop)-thisSize.height;
if (n>0) this.scrollTo(scroll.x, scroll.y+n);
n = p.y-thisSize.computedTop;
if (n<0) this.scrollTo(scroll.x, scroll.y+n);
}
},
"getInnerStyles": function(){
var styles = {};
style = this.get("style");
if (style){
var styleArr = style.split(/\s*\;\s*/g);
styleArr.each(function(s){
if (s){
var sarr = s.split(/\s*\:\s*/g);
styles[sarr[0]] = (sarr.length>1) ? sarr[1]: ""
}
}.bind(this));
}
return styles;
},
"getInnerProperties": function(){
var properties = {};
if (this.attributes.length){
for (var i=0; ii) ? idx.toFloat()+1 : 0;
break;
}
n = n.getParent();
}
return i;
},
"getParentSrcollNode": function(){
var node = this.getParent();
while (node && (node.getScrollSize().y-2<=node.getSize().y || (node.getStyle("overflow")!=="auto" && node.getStyle("overflow-y")!=="auto"))){
node = node.getParent();
}
return node || null;
},
"getEdgeHeight": function(notMargin){
var h = 0;
h += (this.getStyle("border-top-width").toFloat() || 0)+ (this.getStyle("border-bottom-width").toFloat() || 0);
h += (this.getStyle("padding-top").toFloat() || 0)+ (this.getStyle("padding-bottom").toFloat() || 0);
if (!notMargin) h += (this.getStyle("margin-top").toFloat() || 0)+ (this.getStyle("margin-bottom").toFloat() || 0);
return h;
},
"getEdgeWidth": function(notMargin){
var h = 0;
h += (this.getStyle("border-left-width").toFloat() || 0)+ (this.getStyle("border-right-width").toFloat() || 0);
h += (this.getStyle("padding-left").toFloat() || 0)+ (this.getStyle("padding-right").toFloat() || 0);
if (!notMargin) h += (this.getStyle("margin-left").toFloat() || 0)+ (this.getStyle("margin-right").toFloat() || 0);
return h;
}
});
Object.copy = function(from, to){
Object.each(from, function(value, key){
switch (typeOf(value)){
case "object":
if (!to[key]) to[key]={};
Object.copy(value, to[key]);
break;
default:
to[key] = value;
}
});
};
if (window.JSON) JSON.format = JSON.encode;
if (window.Slick) {
Slick.definePseudo('src', function (value) {
return Element.get(this, "src").indexOf(value) !== -1;
});
Slick.definePseudo('srcarr', function (value) {
var vList = value.split(",");
var src = Element.get(this, "src");
var flag = false;
for (var i = 0; i < vList.length; i++) {
if (src.indexOf(vList[i]) !== -1) {
flag = true;
break;
}
}
return flag;
});
Slick.definePseudo('ahref', function (value) {
var href = Element.get(this, "href");
if (!href) href = "";
href = href.toString().toLowerCase();
return (href.indexOf(value) !== -1);
});
Slick.definePseudo('rowspanBefore', function (line) {
var tr = MWF.getParent(this, "tr");
var rowspan = this.get("rowspan").toInt() || 1;
var currentRowIndex = tr.rowIndex.toInt();
return rowspan > 1 && currentRowIndex < line.toInt() && currentRowIndex + rowspan - 1 >= line;
});
Slick.definePseudo('rowspan', function () {
var rowspan = this.get("rowspan").toInt() || 1;
return rowspan > 1;
});
Slick.definePseudo('colspanBefore', function (col) {
var tr = MWF.getParent(this, "tr");
var colspan = this.get("colspan").toInt() || 1;
var currentColIndex = this.cellIndex.toInt();
return colspan > 1 && currentColIndex < col.toInt() && currentColIndex + colspan - 1 >= col.toInt();
});
Slick.definePseudo('colspan', function () {
var colspan = this.get("colspan").toInt() || 1;
return colspan > 1;
});
}
o2.common = o2.common || {};
o2.common.encodeHtml = function(str){
str = str.toString();
str = str.replace(/\&/g, "&");
str = str.replace(/>/g, ">");
str = str.replace(/*/
// doScroll technique by Diego Perini http://javascript.nwbox.com/IEContentLoaded/
// testElement.doScroll() throws when the DOM is not ready, only in the top window
doScrollWorks: function(){
try {
_dom.testElement.doScroll();
return true;
} catch (e){}
return false;
},
/**/
onReady: function(){
for (var i=0; i<_dom.readys.length; i++){
this.readys[i].apply(window);
}
},
addReady: function(fn){
if (_dom.loaded){
if (fn) fn.apply(window);
}else{
if (fn) _dom.readys.push(fn);
}
return _dom;
},
checkReady: function(){
_dom.checks.push(function(){return true});
_dom.check();
}
};
var _loadO2 = function(){
(!o2.core) ? this.o2.load("o2.core", _dom.check) : _dom.check();
(!o2.more) ? this.o2.load("o2.more", _dom.check) : _dom.check();
};
o2.addListener(document, 'DOMContentLoaded', _dom.checkReady);
/**/
// If doScroll works already, it can't be used to determine domready
// e.g. in an iframe
if (_dom.testElement.doScroll && !_dom.doScrollWorks()){
_dom.checks.push(_dom.doScrollWorks);
_dom.shouldPoll = true;
}
/**/
if (document.readyState) _dom.checks.push(function(){
var state = document.readyState;
return (state == 'loaded' || state == 'complete');
});
if ('onreadystatechange' in document) o2.addListener(document, 'readystatechange', _dom.check);
else _dom.shouldPoll = true;
if (_dom.shouldPoll) _dom.poll();
if (!window.MooTools){
this.o2.load("mootools", function(){ _loadO2(); _dom.check(); });
}else{
_loadO2();
}
this.o2.addReady = function(fn){ _dom.addReady.call(_dom, fn); };
})();
//compatible
COMMON = {
"DOM":{},
"setContentPath": function(path){
COMMON.contentPath = path;
},
"JSON": o2.JSON,
"Browser": Browser,
"Class": o2.Class,
"XML": o2.xml,
"AjaxModule": {
"load": function(urls, callback, async, reload){
o2.load(urls, callback, reload, document);
},
"loadDom": function(urls, callback, async, reload){
o2.load(urls, callback, reload, document);
},
"loadCss": function(urls, callback, async, reload, sourceDoc){
o2.loadCss(urls, document.body, callback, reload, sourceDoc);
}
},
"Request": Request,
"typeOf": o2.typeOf
};
COMMON.Browser.Platform.isMobile = o2.session.isMobile;
COMMON.DOM.addReady = o2.addReady;
MWF = o2;
MWF.getJSON = o2.JSON.get;
MWF.getJSONP = o2.JSON.getJsonp;
MWF.defaultPath = o2.session.path;