From 7ad33a4617f8a9e433e9075d0264bd9bf602537b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 3 Sep 2012 05:52:28 -0400 Subject: [PATCH] From now jquery not necessary for Cloud Commander, so start load get faster --- ChangeLog | 4 ++++ client.js | 52 +++++++++++++++++++++++--------------------- lib/client/ie.js | 2 ++ lib/client/viewer.js | 2 ++ 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4fb7755c..fa72a11c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,10 @@ would be doing on-a-fly * Added ability to use ajax without jquery. +* From now jquery not necessary for Cloud Commander +work, (so start load get faster), but it could be +loaded any time by any extension. + 2012.08.24, Version 0.1.6 diff --git a/client.js b/client.js index e00ce5ea..229af0ea 100644 --- a/client.js +++ b/client.js @@ -421,6 +421,32 @@ CloudClient.Utils = (function(){ return this.anyload(pParams_o); }; + this.jqueryLoad = function(){ + /* загружаем jquery: */ + Util.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js',{ + onload: function(){ + $ = window.jQuery; + }, + + onerror: function(){ + Util.jsload('lib/client/jquery.js'); + + /* + * if could not load jquery from google server + * maybe we offline, load font from local + * directory + */ + Util.cssSet({id:'local-droids-font', + element : document.head, + inner : '@font-face {font-family: "Droid Sans Mono";' + + 'font-style: normal;font-weight: normal;' + + 'src: local("Droid Sans Mono"), local("DroidSansMono"),'+ + ' url("font/DroidSansMono.woff") format("woff");}' + }); + } + }); + }; + this.getByTag = function(pTag, pElement){ return (pElement || document).getElementsByTagName(pTag); }; @@ -995,31 +1021,7 @@ CloudClient.init = (function() */ var lTitle=document.getElementsByTagName('title'); if(lTitle.length>0)lTitle[0].textContent='Cloud Commander'; - - /* загружаем jquery: */ - Util.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js',{ - onload: function(){ - $ = window.jQuery; - }, - - onerror: function(){ - Util.jsload('lib/client/jquery.js'); - - /* - * if could not load jquery from google server - * maybe we offline, load font from local - * directory - */ - Util.cssSet({id:'local-droids-font', - element : document.head, - inner : '@font-face {font-family: "Droid Sans Mono";' + - 'font-style: normal;font-weight: normal;' + - 'src: local("Droid Sans Mono"), local("DroidSansMono"),'+ - ' url("font/DroidSansMono.woff") format("woff");}' - }); - } - }); - + /* загружаем общие функции для клиента и сервера*/ Util.jsload(CloudClient.LIBDIR+'cloudfunc.js',function(){ /* берём из обьекта window общий с сервером функционал */ diff --git a/lib/client/ie.js b/lib/client/ie.js index 24b1b7b6..06942853 100644 --- a/lib/client/ie.js +++ b/lib/client/ie.js @@ -13,6 +13,8 @@ var CloudCommander, $; /* setting head ie6 - ie8 */ var lUtil = CloudCommander.Util; + lUtil.jqueryLoad(); + /* setting function context (this) */ lUtil.bind = function(pFunction, pContext){ return $.proxy(pFunction, pContext); diff --git a/lib/client/viewer.js b/lib/client/viewer.js index 78c655be..58979aff 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -61,6 +61,8 @@ var CloudCommander, CloudFunc, $; * @pCallBack - executes, when everything loaded */ CloudCommander.Viewer.FancyBox.load = (function(pThis, pCallBack){ + Util.jqueryLoad(); + var ljsLoad_f = function(){ var lSrc = pThis.dir + 'jquery.fancybox.js'; Util.jsload(lSrc,{