From 5643f67fac0f802d31d1e976035713354d80a17e Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 26 Mar 2012 22:50:42 +0000 Subject: [PATCH] no more need of lab.js all loading is tru requirejs git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1305651 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/index.html | 31 +- .../src/main/webapp/js/archiva/main.js | 20 +- .../src/main/webapp/js/lab.js | 514 ------------------ .../src/main/webapp/js/startup.js | 14 +- 4 files changed, 25 insertions(+), 554 deletions(-) delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/lab.js diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html index bc921130e..d2e6838bd 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html @@ -9,8 +9,6 @@ - - Apache Archiva @@ -75,7 +73,8 @@ "repository-groups": "archiva/repository-groups", "roles": "redback/roles", "user": "redback/user", - "users": "redback/users" + "users": "redback/users", + "archiva/main": "archiva/main" } // file upload dependencies //.script("jquery.iframe-transport-1.4.js").wait() @@ -86,29 +85,21 @@ require(['order!domReady','order!jquery','order!i18n','order!startup'], function (domReady) { domReady.withResources(function () { loadi18n(); - $.ajax( - { + $.ajax({ url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(), dataType: 'json', success:function(data){ window.archivaDevMode=data.devMode; window.archivaJavascriptLog=data.javascriptLog; window.archivaRuntimeInfo=data; - - // CacheBust is for dev purpose use false in prod env ! - var options = { - AlwaysPreserveOrder:true, - BasePath:"js/", - explicit_preloading:false, - CacheBust:window.archivaDevMode - }; - $LAB.setGlobalDefaults(options); - $LAB - .script(buildLoadJsUrl("archiva/main.js")); - } - }) - - }); + require(['order!domReady','archiva/main'],function (domReady) { + domReady.withResources(function () { + startArchivaApplication(); + }) + }) + }} + ) + }) }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 83a97777b..9dfc039ef 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -16,25 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -require( ["order!jquery","jquery_ui","jquery_cookie","bootstrap","order!archiva/search", +define("main",["order!jquery","jquery_ui","jquery_cookie","bootstrap","order!archiva/search", "jquery_validate","jquery_json","order!knockout","order!redback-templates","order!main-templates","order!roles", "order!redback","general-admin","repositories","network-proxies","proxy-connectors","repository-groups"], function() { - - - // define a container object with various datas - window.archivaModel = {}; - - $.log("devMode:"+window.archivaDevMode); - - // no cache for ajax queries as we get datas from servers so preventing caching !! - jQuery.ajaxSetup( { - cache: false//!window.archivaDevMode - } ); - - - /** * reccord a cookie for session with the logged user * @param user see user.js @@ -337,10 +323,10 @@ function() { .data( "item.autocomplete", item ) .append( "" + item.artifactId + "" ) .appendTo( ul ); - };; + }; updateAppearanceToolBar(); } - startArchivaApplication(); + }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/lab.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/lab.js deleted file mode 100644 index 927a00265..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/lab.js +++ /dev/null @@ -1,514 +0,0 @@ -/*! LAB.js (LABjs :: Loading And Blocking JavaScript) - v2.0.3 (c) Kyle Simpson - MIT License -*/ - -(function(global){ - var _$LAB = global.$LAB, - - // constants for the valid keys of the options object - _UseLocalXHR = "UseLocalXHR", - _AlwaysPreserveOrder = "AlwaysPreserveOrder", - _AllowDuplicates = "AllowDuplicates", - _CacheBust = "CacheBust", - /*!START_DEBUG*/_Debug = "Debug",/*!END_DEBUG*/ - _BasePath = "BasePath", - - // stateless variables used across all $LAB instances - root_page = /^[^?#]*\//.exec(location.href)[0], - root_domain = /^\w+\:\/\/\/?[^\/]+/.exec(root_page)[0], - append_to = document.head || document.getElementsByTagName("head"), - - // inferences... ick, but still necessary - opera_or_gecko = (global.opera && Object.prototype.toString.call(global.opera) == "[object Opera]") || ("MozAppearance" in document.documentElement.style), - -/*!START_DEBUG*/ - // console.log() and console.error() wrappers - log_msg = function(){}, - log_error = log_msg, -/*!END_DEBUG*/ - - // feature sniffs (yay!) - test_script_elem = document.createElement("script"), - explicit_preloading = typeof test_script_elem.preload == "boolean", // http://wiki.whatwg.org/wiki/Script_Execution_Control#Proposal_1_.28Nicholas_Zakas.29 - real_preloading = explicit_preloading || (test_script_elem.readyState && test_script_elem.readyState == "uninitialized"), // will a script preload with `src` set before DOM append? - script_ordered_async = !real_preloading && test_script_elem.async === true, // http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order - - // XHR preloading (same-domain) and cache-preloading (remote-domain) are the fallbacks (for some browsers) - xhr_or_cache_preloading = !real_preloading && !script_ordered_async && !opera_or_gecko - ; - -/*!START_DEBUG*/ - // define console wrapper functions if applicable - if (global.console && global.console.log) { - if (!global.console.error) global.console.error = global.console.log; - log_msg = function(msg) { global.console.log(msg); }; - log_error = function(msg,err) { global.console.error(msg,err); }; - } -/*!END_DEBUG*/ - - // test for function - function is_func(func) { return Object.prototype.toString.call(func) == "[object Function]"; } - - // test for array - function is_array(arr) { return Object.prototype.toString.call(arr) == "[object Array]"; } - - // make script URL absolute/canonical - function canonical_uri(src,base_path) { - var absolute_regex = /^\w+\:\/\//; - - // is `src` is protocol-relative (begins with // or ///), prepend protocol - if (/^\/\/\/?/.test(src)) { - src = location.protocol + src; - } - // is `src` page-relative? (not an absolute URL, and not a domain-relative path, beginning with /) - else if (!absolute_regex.test(src) && src.charAt(0) != "/") { - // prepend `base_path`, if any - src = (base_path || "") + src; - } - // make sure to return `src` as absolute - return absolute_regex.test(src) ? src : ((src.charAt(0) == "/" ? root_domain : root_page) + src); - } - - // merge `source` into `target` - function merge_objs(source,target) { - for (var k in source) { if (source.hasOwnProperty(k)) { - target[k] = source[k]; // TODO: does this need to be recursive for our purposes? - }} - return target; - } - - // does the chain group have any ready-to-execute scripts? - function check_chain_group_scripts_ready(chain_group) { - var any_scripts_ready = false; - for (var i=0; i 0) { - for (var i=0; i=0;) { - val = queue.shift(); - $L = $L[val.type].apply(null,val.args); - } - return $L; - }, - - // rollback `[global].$LAB` to what it was before this file was loaded, the return this current instance of $LAB - noConflict:function(){ - global.$LAB = _$LAB; - return instanceAPI; - }, - - // create another clean instance of $LAB - sandbox:function(){ - return create_sandbox(); - } - }; - - return instanceAPI; - } - - // create the main instance of $LAB - global.$LAB = create_sandbox(); - - - /* The following "hack" was suggested by Andrea Giammarchi and adapted from: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html - NOTE: this hack only operates in FF and then only in versions where document.readyState is not present (FF < 3.6?). - - The hack essentially "patches" the **page** that LABjs is loaded onto so that it has a proper conforming document.readyState, so that if a script which does - proper and safe dom-ready detection is loaded onto a page, after dom-ready has passed, it will still be able to detect this state, by inspecting the now hacked - document.readyState property. The loaded script in question can then immediately trigger any queued code executions that were waiting for the DOM to be ready. - For instance, jQuery 1.4+ has been patched to take advantage of document.readyState, which is enabled by this hack. But 1.3.2 and before are **not** safe or - fixed by this hack, and should therefore **not** be lazy-loaded by script loader tools such as LABjs. - */ - (function(addEvent,domLoaded,handler){ - if (document.readyState == null && document[addEvent]){ - document.readyState = "loading"; - document[addEvent](domLoaded,handler = function(){ - document.removeEventListener(domLoaded,handler,false); - document.readyState = "complete"; - },false); - } - })("addEventListener","DOMContentLoaded"); - -})(this); \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js index 40844f6cc..1ec5fc6e1 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js @@ -17,7 +17,7 @@ * under the License. */ -require(["jquery","utils"], +define("startup",["jquery","utils"], function() { @@ -29,8 +29,16 @@ function() { return srcScript+"?"+appendArchivaVersion()+"&_"+jQuery.now(); } - $.ajaxSetup({ + + // define a container object with various datas + window.archivaModel = {}; + + $.log("devMode:"+window.archivaDevMode); + + // no cache for ajax queries as we get datas from servers so preventing caching !! + jQuery.ajaxSetup( { + cache: false,//!window.archivaDevMode dataType: 'json' - }); + } ); }); \ No newline at end of file -- 2.39.5