/** ***** 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){
var key = encodeURIComponent(url);
if (_loaded[key]){o2.runCallback(callback, "success"); 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: jsPath, async: async, method: "get",
onSuccess: function(){
//try{
_loaded[key] = true;
o2.runCallback(callback, "success");
//}catch (e){
// o2.runCallback(callback, "failure", [e]);
//}
},
onFailure: function(r){
o2.runCallback(callback, "failure", [r]);
}
});
xhr.send();
};
var _requireSingle = function(module, callback, async, compression){
module = module.replace("MWF", "o2");
var levels = module.split(".");
if (levels[levels.length-1]==="*") levels[levels.length-1] = "package";
levels.shift();
var jsPath = this.o2.session.path;
jsPath +="/"+levels.join("/")+".js";
var loadAsync = (async!==false);
_requireJs(jsPath, callback, loadAsync, compression);
};
var _requireSequence = function(fun, module, thisLoaded, thisErrorLoaded, callback, async, compression){
var m = module.shift();
fun(m, {
"onSuccess": function(){
thisLoaded.push(module[i]);
if (module.length){
_requireSequence(module, thisLoaded, thisErrorLoaded, callback);
}else{
if (thisErrorLoaded.length){
o2.runCallback(callback, "failure", [thisLoaded, thisErrorLoaded]);
}else{
o2.runCallback(callback, "success", [thisLoaded, thisErrorLoaded]);
}
}
},
"onFailure": function(){
thisErrorLoaded.push(module[i]);
o2.runCallback(callback, "failure", [thisLoaded, thisErrorLoaded]);
}
}, async, compression);
};
var _requireDisarray = function(fun, module, thisLoaded, thisErrorLoaded, callback, async, compression){
for (var i=0; i