/** ***** BEGIN LICENSE BLOCK *****
* |------------------------------------------------------------------------------|
* | O2OA 活力办公 创意无限 o2.core.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 ******/
(function (){
var _Class = {
create: function(options) {
var newClass = function() {
this.initialize.apply(this, arguments);
};
_copyPrototype(newClass, 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){
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(/\