/** ***** 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 O2OA. If not, see . * * ***** END LICENSE BLOCK ******/ /*polyfill-Promise*/ if (!window.Promise){ (function(self, undefined) {function Call(t,l){var n=arguments.length>2?arguments[2]:[];if(!1===IsCallable(t))throw new TypeError(Object.prototype.toString.call(t)+"is not a function.");return t.apply(l,n)}function CreateMethodProperty(e,r,t){var a={value:t,writable:!0,enumerable:!1,configurable:!0};Object.defineProperty(e,r,a)}function Get(n,t){return n[t]}function HasOwnProperty(r,t){return Object.prototype.hasOwnProperty.call(r,t)}function IsCallable(n){return"function"==typeof n}function SameValueNonNumber(e,n){return e===n}function ToInteger(n){var i=Number(n);return isNaN(i)?0:1/i===Infinity||1/i==-Infinity||i===Infinity||i===-Infinity?i:(i<0?-1:1)*Math.floor(Math.abs(i))}function ToLength(n){var t=ToInteger(n);return t<=0?0:Math.min(t,Math.pow(2,53)-1)}function ToObject(e){if(null===e||e===undefined)throw TypeError();return Object(e)}function GetV(t,e){return ToObject(t)[e]}function GetMethod(e,n){var r=GetV(e,n);if(null===r||r===undefined)return undefined;if(!1===IsCallable(r))throw new TypeError("Method not callable: "+n);return r}function Type(e){switch(typeof e){case"undefined":return"undefined";case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"symbol":return"symbol";default:return null===e?"null":"Symbol"in self&&(e instanceof self.Symbol||e.constructor===self.Symbol)?"symbol":"object"}}function OrdinaryToPrimitive(r,t){if("string"===t)var e=["toString","valueOf"];else e=["valueOf","toString"];for(var i=0;i1?arguments[1]:undefined;if("object"===Type(e)){if(arguments.length<2)var i="default";else t===String?i="string":t===Number&&(i="number");var r="function"==typeof self.Symbol&&"symbol"==typeof self.Symbol.toPrimitive?GetMethod(e,self.Symbol.toPrimitive):undefined;if(r!==undefined){var n=Call(r,e,[i]);if("object"!==Type(n))return n;throw new TypeError("Cannot convert exotic object to primitive.")}return"default"===i&&(i="number"),OrdinaryToPrimitive(e,i)}return e}function ToString(t){switch(Type(t)){case"symbol":throw new TypeError("Cannot convert a Symbol value to a string");case"object":return ToString(ToPrimitive(t,String));default:return String(t)}}function ToPropertyKey(r){var i=ToPrimitive(r,String);return"symbol"===Type(i)?i:ToString(i)}CreateMethodProperty(Array.prototype,"includes",function e(r){"use strict";var t=ToObject(this),o=ToLength(Get(t,"length"));if(0===o)return!1;var n=ToInteger(arguments[1]);if(n>=0)var a=n;else(a=o+n)<0&&(a=0);for(;a=0&&"[object Function]"===r.call(t.callee)),n}var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=Object.prototype.propertyIsEnumerable,o=!n.call({toString:null},"toString"),l=n.call(function(){},"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],i=function(t){var e=t.constructor;return e&&e.prototype===t},u={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},a=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!u["$"+t]&&e.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{i(window[t])}catch(r){return!0}}catch(r){return!0}return!1}(),f=function(t){if("undefined"==typeof window||!a)return i(t);try{return i(t)}catch(e){return!1}};return function p(n){var i="[object Function]"===r.call(n),u=t(n),a="[object String]"===r.call(n),p=[];if(n===undefined||null===n)throw new TypeError("Cannot convert undefined or null to object");var s=l&&i;if(a&&n.length>0&&!e.call(n,0))for(var y=0;y0)for(var g=0;gn&&(r.length=n)}var r=L(n),o=0;return function(n,t){r[o++]=n,r[o++]=t,2===o&&tn.nextTick(e)}}function s(n,t){var o,i,u,f,s=0;if(!n)throw a(N);var l=n[tn[q][z]];if(e(l))i=l.call(n);else{if(!e(n.next)){if(r(n,L)){for(o=n.length;s= 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,data]); }, 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 _parseDataCache = {}; var _parseHtml = function(str, json, i){ var v = str; if (i){ var r = (Math.random()*1000000).toInt().toString(); while (_parseDataCache[r]) r = (Math.random()*1000000).toInt().toString(); _parseDataCache[r] = json; v = (i) ? "
"+str+"
" : 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; if (window.importScripts){ window.importScripts(o2.filterUrl(jsPath)); o2.runCallback(callback, "success", [module]); }else{ 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; }, "getSize": function(){ if ((/^(?:body|html)$/i).test(this.tagName)) return this.getWindow().getSize(); if (!window.getComputedStyle) return {x: this.offsetWidth, y: this.offsetHeight}; if (this.get('tag') == 'svg') return svgCalculateSize(this); try { if (!layout || !layout.userLayout || !layout.userLayout.scale || layout.userLayout.scale==1){ var bounds = this.getBoundingClientRect(); return {x: bounds.width, y: bounds.height}; }else{ return {"x": this.offsetWidth.toFloat(), "y": this.offsetHeight.toFloat()}; } } catch (e){ return {x: 0, y: 0}; } }, "getScaleOffsets": function(){ var hasGetBoundingClientRect = this.getBoundingClientRect; //<1.4compat> hasGetBoundingClientRect = hasGetBoundingClientRect && !Browser.Platform.ios; // if (hasGetBoundingClientRect){ var bound = this.getBoundingClientRect(); var boundLeft = bound.left; var boundTop = bound.top; if (!layout || !layout.userLayout || !layout.userLayout.scale || layout.userLayout.scale==1){ }else{ boundLeft= boundLeft/layout.userLayout.scale; boundTop = boundTop/layout.userLayout.scale; } var html = document.id(this.getDocument().documentElement); var htmlScroll = html.getScroll(); var elemScrolls = this.getScrolls(); var isFixed = (Element.getComputedStyle(this, 'position') == 'fixed'); return { x: boundLeft.toFloat() + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft, y: boundTop.toFloat() + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop }; } var element = this, position = {x: 0, y: 0}; if (isBody(this)) return position; while (element && !isBody(element)){ position.x += element.offsetLeft; position.y += element.offsetTop; //<1.4compat> if (Browser.firefox){ if (!borderBox(element)){ position.x += leftBorder(element); position.y += topBorder(element); } var parent = element.parentNode; if (parent && styleString(parent, 'overflow') != 'visible'){ position.x += leftBorder(parent); position.y += topBorder(parent); } } else if (element != this && Browser.safari){ position.x += leftBorder(element); position.y += topBorder(element); } // element = element.offsetParent; } //<1.4compat> if (Browser.firefox && !borderBox(this)){ position.x -= leftBorder(this); position.y -= topBorder(this); } // return position; }, getPosition: function(relative){ var offset = this.getScaleOffsets(), scroll = this.getScrolls(); var position = { x: offset.x - scroll.x, y: offset.y - scroll.y }; if (relative && (relative = document.id(relative))){ var relativePosition = relative.getPosition(); return {x: position.x - relativePosition.x - leftBorder(relative), y: position.y - relativePosition.y - topBorder(relative)}; } return position; } }); 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(); } }; 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(); }else{ _dom = { ready: false, loaded: false, checks: [], shouldPoll: false, timer: null, readys: [], domready: function(){ clearTimeout(_dom.timer); if (_dom.ready) return; _dom.loaded = _dom.ready = true; _dom.onReady(); }, check: function(){ if (window.MooTools && o2.core && o2.more){ _dom.domready(); return true; } 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(); }; 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": window.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 }; if (COMMON.Browser) 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;