From b896ee9da9982fecaf06e66c8424670814ecd6a4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 12 Oct 2012 07:07:12 -0400 Subject: [PATCH] Added function jsLoadOnLoad, thet loads js files one-by-one, and then calls callback if needed --- ChangeLog | 3 +++ client.js | 73 +++++++++++++++++++++++++++++++++++++---------------- config.json | 4 +-- 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c544232..59ff7f0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,9 @@ started. * Fixed bug with menu itmes edit and view. +* Added function jsLoadOnLoad, thet loads js files +one-by-one, and then calls callback if needed. + 2012.10.01, Version 0.1.7 diff --git a/client.js b/client.js index e2a7c42e..2f1c5199 100644 --- a/client.js +++ b/client.js @@ -1,8 +1,6 @@ /* Функция которая возвратит обьект CloudCommander - * @window - обьект window - * @document - обьект document * @CloudFunc - обьект содержащий общий функционал - * клиентский и серверный + * клиентский и серверный */ var CloudCommander = (function(){ @@ -165,8 +163,7 @@ CloudClient.Util = (function(){ }; this.ajax = function(pParams){ - /* if on webkit - */ + /* if on webkit */ if(window.XMLHttpRequest){ if(!lXMLHTTP) lXMLHTTP = new XMLHttpRequest(); @@ -177,7 +174,7 @@ CloudClient.Util = (function(){ lXMLHTTP.open(lMethod, pParams.url, true); lXMLHTTP.send(null); - + var lSuccess_f = pParams.success; if(typeof lSuccess_f !== 'function') console.log('error in Util.ajax onSuccess:', pParams); @@ -251,7 +248,7 @@ CloudClient.Util = (function(){ }, this.loadOnload = function(pFunc_a){ - if(pFunc_a instanceof Array) { + if( this.isArray(pFunc_a) ) { var lFunc_f = pFunc_a.pop(); @@ -265,16 +262,36 @@ CloudClient.Util = (function(){ }; this.anyLoadOnload = function(pParams_a){ - if(pParams_a instanceof Array) { + if( this.isArray(pParams_a) ) { + var lParam = pParams_a.pop(); + + if(lParam && !lParam.func) + lParam.func = function(){ + lThis.anyLoadOnload(pParams_a); + }; - var lParams_o = pParams_a.pop(); - - if(!lParams_o.func) - lParams_o.func = function(){ - lThis.anyLoadOnload(pParams_a); - }; - - return this.anyload(lParams_o); + this.anyload(lParam); + } + }; + + /** + * function loads a couple js files one-by-one + * @pSrc_a ([String1, ..., StringN]) + * @pCallBack (functin) + */ + this.jsLoadOnLoad = function (pSrc_a, pCallBack){ + if( this.isArray(pSrc_a) ) { + var n = pSrc_a.length; + + for(var i=0; i= 0 ); }; + /** + * functions check is pVarible is array + * @param pVarible + */ + this.isArray = function(pVarible){ + return pVarible instanceof Array; + }; + /** * functions check is pVarible is boolean * @param pVarible diff --git a/config.json b/config.json index 8ce7879f..75bcf6c6 100644 --- a/config.json +++ b/config.json @@ -1,8 +1,8 @@ { - "cache" : {"allowed" : true}, + "cache" : {"allowed" : false}, "appcache" : false, "minification" : { - "js" : true, + "js" : false, "css" : true, "html" : true, "img" : true