From 53c416bcf4d6b068c55fe9bf1fa8d8ed042968eb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 14 Nov 2012 06:20:49 -0500 Subject: [PATCH] fixed bug with config file, when no need to minification --- ChangeLog | 2 + client.js | 19 +++++++++ config.json | 2 +- lib/server/minify.js | 99 +++++++++++++++++++++----------------------- 4 files changed, 70 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0c0edc0..2f7f07de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -81,6 +81,8 @@ dom.js and util.js. * Added buttons panel. +* Fixed bug with config file, when no need to minification. + 2012.10.01, Version 0.1.7 diff --git a/client.js b/client.js index a067f7d0..29bca5fe 100644 --- a/client.js +++ b/client.js @@ -382,6 +382,7 @@ CloudClient._currentToParent = function(pDirName){ CloudClient.init = function(){ var lFunc = function(){ Util.loadOnLoad([ + initCmdButtons, initModules, baseInit ]); @@ -426,6 +427,24 @@ function initModules(pCallBack){ }); } +function initCmdButtons(pCallBack){ + var lFuncs =[ + null, + null, /* f1 */ + null, /* f2 */ + cloudcmd.view, /* f3 */ + cloudcmd.edit, /* f4 */ + null, /* f5 */ + null, /* f6 */ + null, /* f7 */ + null, /* f8 */ + ]; + for(var i = 1; i <= 8; i++) + getById('f' + i).onclick = lFuncs[i]; + + Util.exec(pCallBack); +} + function baseInit(pCallBack){ if(applicationCache){ var lFunc = applicationCache.onupdateready; diff --git a/config.json b/config.json index 0e41dd71..28e8881f 100644 --- a/config.json +++ b/config.json @@ -2,7 +2,7 @@ "cache" : {"allowed" : false}, "appcache" : false, "minification" : { - "js" : true, + "js" : false, "css" : false, "html" : false, "img" : false diff --git a/lib/server/minify.js b/lib/server/minify.js index d1da79a6..4481e415 100644 --- a/lib/server/minify.js +++ b/lib/server/minify.js @@ -42,58 +42,55 @@ * если установлены параметры минимизации */ doit :(function(){ - if(this._allowed.css || - this._allowed.js || - this._allowed.html){ - var lMinify; - try{ - lMinify = require('minify'); - }catch(pError){ - this._allowed = {js:false,css:false,html:false}; - - console.log('You coud install minify ' + - 'for better download spead:\n' + - 'npm i minify'); - - return this._allowed; - } - - /* - * temporary changed dir path, - * becouse directory lib is write - * protected by others by default - * so if node process is started - * from other user (root for example - * in nodester) we can not write - * minified versions - */ - this.MinFolder = '/' + lMinify.MinFolder; - - var lOptimizeParams = []; - if (this._allowed.js) { - lOptimizeParams.push('client.js'); - } - - if (this._allowed.html) - lOptimizeParams.push(this.INDEX); - - if (this._allowed.css) { - lOptimizeParams.push({ - './css/style.css' : this._allowed.img - }); - - lOptimizeParams.push({ - './css/reset.css': this._allowed.img - }); - } - - if (lOptimizeParams) - lMinify.optimize(lOptimizeParams); - - this.Cache = lMinify.Cache; - - return this._allowed; + var lMinify = main.require('minify'); + + if(!lMinify){ + this._allowed = {js:false,css:false,html:false}; + + console.log('You coud install minify ' + + 'for better download spead:\n' + + 'npm i minify'); + + return this._allowed; } + + console.log(this._allowed); + + /* + * temporary changed dir path, + * becouse directory lib is write + * protected by others by default + * so if node process is started + * from other user (root for example + * in nodester) we can not write + * minified versions + */ + this.MinFolder = '/' + lMinify.MinFolder; + + var lOptimizeParams = []; + if (this._allowed.js) { + lOptimizeParams.push('client.js'); + } + + if (this._allowed.html) + lOptimizeParams.push(this.INDEX); + + if (this._allowed.css) { + lOptimizeParams.push({ + './css/style.css' : this._allowed.img + }); + + lOptimizeParams.push({ + './css/reset.css': this._allowed.img + }); + } + + if (lOptimizeParams) + lMinify.optimize(lOptimizeParams); + + this.Cache = lMinify.Cache; + + return this._allowed; }), optimize: function(pName, pParams){