From e3ab5797a024248c1dda409c2af8d53a80cd6220 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 4 Feb 2013 22:57:39 +0000 Subject: [PATCH] require 2.1.4 and text.js 2.0.5 git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1442418 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-webapp/src/main/webapp/index.html | 2 +- .../src/main/webapp/js/require.2.1.4.js | 35 +++++++ .../archiva-webapp/src/main/webapp/js/text.js | 91 ++++++++++++------- 3 files changed, 95 insertions(+), 33 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/require.2.1.4.js diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/index.html b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/index.html index 6897a243a..a234253e5 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/index.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/index.html @@ -34,7 +34,7 @@ - + Apache Archiva diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/require.2.1.4.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/require.2.1.4.js new file mode 100644 index 000000000..d58ca2086 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/require.2.1.4.js @@ -0,0 +1,35 @@ +/* + RequireJS 2.1.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + Available via the MIT or new BSD license. + see: http://github.com/jrburke/requirejs for details +*/ +var requirejs,require,define; +(function(Y){function I(b){return"[object Function]"===L.call(b)}function J(b){return"[object Array]"===L.call(b)}function x(b,c){if(b){var d;for(d=0;dthis.depCount&&!this.defined){if(I(n)){if(this.events.error)try{e=k.execCb(c,n,b,e)}catch(d){a=d}else e=k.execCb(c,n,b,e);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!==this.exports?e=b.exports:void 0===e&&this.usingExports&&(e=this.exports));if(a)return a.requireMap=this.map,a.requireModules=[this.map.id],a.requireType="define",A(this.error=a)}else e=n;this.exports=e;if(this.map.isDefine&& +!this.ignore&&(p[c]=e,l.onResourceLoad))l.onResourceLoad(k,this.map,this.depMaps);delete j[c];this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=h(a.prefix);this.depMaps.push(d);s(d,"defined",t(this,function(e){var n,d;d=this.map.name;var v=this.map.parentMap?this.map.parentMap.name:null,g=k.makeRequire(a.parentMap,{enableBuildCallback:!0}); +if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,v,!0)})||""),e=h(a.prefix+"!"+d,this.map.parentMap),s(e,"defined",t(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=i(j,e.id)){this.depMaps.push(e);if(this.events.error)d.on("error",t(this,function(a){this.emit("error",a)}));d.enable()}}else n=t(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),n.error=t(this,function(a){this.inited=!0;this.error=a;a.requireModules= +[b];E(j,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&delete j[a.map.id]});A(a)}),n.fromText=t(this,function(e,c){var d=a.name,u=h(d),v=O;c&&(e=c);v&&(O=!1);q(u);r(m.config,b)&&(m.config[d]=m.config[b]);try{l.exec(e)}catch(j){return A(F("fromtexteval","fromText eval for "+b+" failed: "+j,j,[b]))}v&&(O=!0);this.depMaps.push(u);k.completeLoad(d);g([d],n)}),e.load(a.name,g,n,m)}));k.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){this.enabling=this.enabled=!0;x(this.depMaps,t(this,function(a, +b){var c,e;if("string"===typeof a){a=h(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=i(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;s(a,"defined",t(this,function(a){this.defineDep(b,a);this.check()}));this.errback&&s(a,"error",this.errback)}c=a.id;e=j[c];!r(N,c)&&(e&&!e.enabled)&&k.enable(a,this)}));E(this.pluginMaps,t(this,function(a){var b=i(j,a.id);b&&!b.enabled&&k.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c= +this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){x(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};k={config:m,contextName:b,registry:j,defined:p,urlFetched:S,defQueue:G,Module:W,makeModuleMap:h,nextTick:l.nextTick,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=m.pkgs,c=m.shim,e={paths:!0,config:!0,map:!0};E(a,function(a,b){e[b]?"map"===b?Q(m[b],a,!0,!0):Q(m[b],a,!0):m[b]=a});a.shim&&(E(a.shim,function(a, +b){J(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=k.makeShimExports(a);c[b]=a}),m.shim=c);a.packages&&(x(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ga,"").replace(aa,"")}}),m.pkgs=b);E(j,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=h(b))});if(a.deps||a.callback)k.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(Y,arguments)); +return b||a.exports&&Z(a.exports)}},makeRequire:function(a,d){function g(e,c,u){var i,m;d.enableBuildCallback&&(c&&I(c))&&(c.__requireJsBuild=!0);if("string"===typeof e){if(I(c))return A(F("requireargs","Invalid require call"),u);if(a&&r(N,e))return N[e](j[a.id]);if(l.get)return l.get(k,e,a);i=h(e,a,!1,!0);i=i.id;return!r(p,i)?A(F("notloaded",'Module name "'+i+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):p[i]}K();k.nextTick(function(){K();m=q(h(null,a));m.skipMap=d.skipMap; +m.init(e,c,u,{enabled:!0});C()});return g}d=d||{};Q(g,{isBrowser:z,toUrl:function(b){var d,f=b.lastIndexOf("."),h=b.split("/")[0];if(-1!==f&&(!("."===h||".."===h)||1g.attachEvent.toString().indexOf("[native code"))&& +!V?(O=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=d,K=g,D?B.insertBefore(g,D):B.appendChild(g),K=null,g;$&&(importScripts(d),b.completeLoad(c))};z&&M(document.getElementsByTagName("script"),function(b){B||(B=b.parentNode);if(s=b.getAttribute("data-main"))return q.baseUrl||(H=s.split("/"),ba=H.pop(),ca=H.length?H.join("/")+"/":"./",q.baseUrl=ca,s=ba),s=s.replace(aa,""),q.deps=q.deps?q.deps.concat(s): +[s],!0});define=function(b,c,d){var i,g;"string"!==typeof b&&(d=c,c=b,b=null);J(c)||(d=c,c=[]);!c.length&&I(d)&&d.length&&(d.toString().replace(ia,"").replace(ja,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c));if(O){if(!(i=K))P&&"interactive"===P.readyState||M(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),i=P;i&&(b||(b=i.getAttribute("data-requiremodule")),g=C[i.getAttribute("data-requirecontext")])}(g? +g.defQueue:R).push([b,c,d])};define.amd={jQuery:!0};l.exec=function(b){return eval(b)};l(q)}})(this); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/text.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/text.js index 39016dc03..9223e65c8 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/text.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/text.js @@ -1,5 +1,5 @@ /** - * @license RequireJS text 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + * @license RequireJS text 2.0.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/requirejs/text for details */ @@ -11,7 +11,8 @@ define(['module'], function (module) { 'use strict'; - var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'], + var text, fs, + progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'], xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, bodyRegExp = /]*>\s*([\s\S]+)\s*<\/body>/im, hasLocation = typeof location !== 'undefined' && location.href, @@ -19,11 +20,10 @@ define(['module'], function (module) { defaultHostName = hasLocation && location.hostname, defaultPort = hasLocation && (location.port || undefined), buildMap = [], - masterConfig = (module.config && module.config()) || {}, - text, fs; + masterConfig = (module.config && module.config()) || {}; text = { - version: '2.0.1', + version: '2.0.5', strip: function (content) { //Strips declarations so that external SVG and XML @@ -83,16 +83,30 @@ define(['module'], function (module) { * where strip is a boolean. */ parseName: function (name) { - var strip = false, index = name.indexOf("."), - modName = name.substring(0, index), - ext = name.substring(index + 1, name.length); + var modName, ext, temp, + strip = false, + index = name.indexOf("."), + isRelative = name.indexOf('./') === 0 || + name.indexOf('../') === 0; - index = ext.indexOf("!"); + if (index !== -1 && (!isRelative || index > 1)) { + modName = name.substring(0, index); + ext = name.substring(index + 1, name.length); + } else { + modName = name; + } + + temp = ext || modName; + index = temp.indexOf("!"); if (index !== -1) { //Pull off the strip arg. - strip = ext.substring(index + 1, ext.length); - strip = strip === "strip"; - ext = ext.substring(0, index); + strip = temp.substring(index + 1) === "strip"; + temp = temp.substring(0, index); + if (ext) { + ext = temp; + } else { + modName = temp; + } } return { @@ -113,8 +127,8 @@ define(['module'], function (module) { * @returns Boolean */ useXhr: function (url, protocol, hostname, port) { - var match = text.xdRegExp.exec(url), - uProtocol, uHostName, uPort; + var uProtocol, uHostName, uPort, + match = text.xdRegExp.exec(url); if (!match) { return true; } @@ -156,7 +170,8 @@ define(['module'], function (module) { masterConfig.isBuild = config.isBuild; var parsed = text.parseName(name), - nonStripName = parsed.moduleName + '.' + parsed.ext, + nonStripName = parsed.moduleName + + (parsed.ext ? '.' + parsed.ext : ''), url = req.toUrl(nonStripName), useXhr = (masterConfig.useXhr) || text.useXhr; @@ -194,11 +209,11 @@ define(['module'], function (module) { writeFile: function (pluginName, moduleName, req, write, config) { var parsed = text.parseName(moduleName), - nonStripName = parsed.moduleName + '.' + parsed.ext, + extPart = parsed.ext ? '.' + parsed.ext : '', + nonStripName = parsed.moduleName + extPart, //Use a '.js' file name so that it indicates it is a //script that can be loaded across domains. - fileName = req.toUrl(parsed.moduleName + '.' + - parsed.ext) + '.js'; + fileName = req.toUrl(parsed.moduleName + extPart) + '.js'; //Leverage own load() method to load plugin value, but only //write out values that do not have the strip argument, @@ -219,9 +234,10 @@ define(['module'], function (module) { } }; - if (typeof process !== "undefined" && - process.versions && - !!process.versions.node) { + if (masterConfig.env === 'node' || (!masterConfig.env && + typeof process !== "undefined" && + process.versions && + !!process.versions.node)) { //Using special require.nodeRequire, something added by r.js. fs = require.nodeRequire('fs'); @@ -233,11 +249,21 @@ define(['module'], function (module) { } callback(file); }; - } else if (text.createXhr()) { - text.get = function (url, callback, errback) { - var xhr = text.createXhr(); + } else if (masterConfig.env === 'xhr' || (!masterConfig.env && + text.createXhr())) { + text.get = function (url, callback, errback, headers) { + var xhr = text.createXhr(), header; xhr.open('GET', url, true); + //Allow plugins direct access to xhr headers + if (headers) { + for (header in headers) { + if (headers.hasOwnProperty(header)) { + xhr.setRequestHeader(header.toLowerCase(), headers[header]); + } + } + } + //Allow overrides specified in config if (masterConfig.onXhr) { masterConfig.onXhr(xhr, url); @@ -261,17 +287,18 @@ define(['module'], function (module) { }; xhr.send(null); }; - } else if (typeof Packages !== 'undefined') { + } else if (masterConfig.env === 'rhino' || (!masterConfig.env && + typeof Packages !== 'undefined' && typeof java !== 'undefined')) { //Why Java, why is this so awkward? text.get = function (url, callback) { - var encoding = "utf-8", + var stringBuffer, line, + encoding = "utf-8", file = new java.io.File(url), lineSeparator = java.lang.System.getProperty("line.separator"), input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)), - StringBuilder, line, content = ''; try { - StringBuilder = new java.lang.StringBuilder(); + stringBuffer = new java.lang.StringBuffer(); line = input.readLine(); // Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324 @@ -286,14 +313,14 @@ define(['module'], function (module) { line = line.substring(1); } - StringBuilder.append(line); + stringBuffer.append(line); while ((line = input.readLine()) !== null) { - StringBuilder.append(lineSeparator); - StringBuilder.append(line); + stringBuffer.append(lineSeparator); + stringBuffer.append(line); } //Make sure we return a JavaScript string and not a Java string. - content = String(StringBuilder.toString()); //String + content = String(stringBuffer.toString()); //String } finally { input.close(); }