You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/03/26 22:46:29 UTC

svn commit: r1305567 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp: index.html js/archiva/startup.js js/archiva/utils.js js/domReady.js js/require.1.0.1.js js/startup.js

Author: olamy
Date: Mon Mar 26 20:46:28 2012
New Revision: 1305567

URL: http://svn.apache.org/viewvc?rev=1305567&view=rev
Log:
start refactoring to use only require js to ensure correct js loading order

Added:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/domReady.js   (with props)
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js   (contents, props changed)
      - copied, changed from r1305566, archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/startup.js
Removed:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/startup.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/require.1.0.1.js
Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html?rev=1305567&r1=1305566&r2=1305567&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html Mon Mar 26 20:46:28 2012
@@ -10,9 +10,17 @@
   <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
 
   <script type="text/javascript" src="js/lab.js"></script>
+    <script type="text/javascript">
+        var require = {
+            config:{
+                urlArgs: "timeStampCache="+new Date().getTime()
+            },
+            deps: ["js/jquery-1.7.2.js","js/jquery.tmpl.js","js/archiva/utils.js","js/startup.js"]
+        };
+    </script>
   <script type="text/javascript" src="js/require.1.0.7.js"></script>
   <script type="text/javascript" src="js/jquery.i18n.properties-1.0.9.js"></script>
-  <script type="text/javascript" src="js/archiva/startup.js"></script>
+
   <title>Apache Archiva</title>
 
 </head>
@@ -48,18 +56,22 @@
 
 <script type="text/javascript">
 
-    $(function() {
+
 
         require.config({
             baseUrl: "js/",
+            urlArgs: "timeStampCache="+new Date().getTime(),
             "paths": {
                 "i18n":"jquery.i18n.properties-1.0.9",
                 "jquery": "jquery-1.7.2"
             }
         });
+        require(['domReady'], function (domReady) {
+          domReady.withResources(function () {
+              loadJs();
+          });
+        });
 
-        loadJs();
-    });
 
 
 </script>

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js?rev=1305567&r1=1305566&r2=1305567&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js Mon Mar 26 20:46:28 2012
@@ -17,343 +17,368 @@
  * under the License.
  */
 
-/**
- * log message in the console
- */
-$.log = (function(message) {
-  if ( !window.archivaJavascriptLog ){
-    return;
-  }
-  if (typeof window.console != 'undefined' && typeof window.console.log != 'undefined') {
-    console.log(message);
-  } else {
-    // do nothing no console
-  }
-});
-
-/**
- * display a success message
- * @param text the success text
- * @param idToAppend the id to append the success box
- */
-displaySuccessMessage=function(text,idToAppend){
-  var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
-  $.tmpl($("#alert-message-success").html(), { "message" : text }).appendTo( textId );
-  $(textId).focus();
-}
-
-/**
- * display an error message
- * @param text the success text
- * @param idToAppend the id to append the success box
- */
-displayErrorMessage=function(text,idToAppend){
-  var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
-  $.tmpl($("#alert-message-error").html(), { "message" : text }).appendTo( textId );
-  $(textId).focus();
-}
-
-/**
- * display a warning message
- * @param text the success text
- * @param idToAppend the id to append the success box
- */
-displayWarningMessage=function(text,idToAppend){
-  var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
-  $.tmpl($("#alert-message-warning").html(), { "message" : text }).appendTo( textId );
-  $(textId).focus();
-}
-
-displayInfoMessage=function(text,idToAppend){
-  var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
-  $.tmpl($("#alert-message-info").html(), { "message" : text }).appendTo( textId );
-  $(textId).focus();
-}
-
-/**
- * clear #main-content and call clearUserMessages
-  */
-screenChange=function(){
-  $("#main-content").html("");
-  $("#main-content").removeAttr("data-bind");
-  clearUserMessages();
-}
-
-/**
- * clear content of id if none clear content of #user-messages
-  * @param idToAppend
- */
-clearUserMessages=function(idToAppend){
-  var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
-  $(textId).html('');
-}
-
-/**
- * clear all input text and password found in the the selector
- * @param selectorStr
- */
-clearForm=function(selectorStr){
-  $(selectorStr).find("input[type='text']").each(function(ele){
-    $(this).val("");
-  });
-  $(selectorStr).find("input[type='password']").each(function(ele){
-    $(this).val("");
+define("utils",["jquery","i18n","js/jquery.tmpl.js"], function() {
+
+  /**
+   * log message in the console
+   */
+  $.log = (function(message) {
+    if ( !window.archivaJavascriptLog ){
+      return;
+    }
+    if (typeof window.console != 'undefined' && typeof window.console.log != 'undefined') {
+      console.log(message);
+    } else {
+      // do nothing no console
+    }
   });
 
-}
+  /**
+   * return value of a param in the url
+   * @param name
+   */
+  $.urlParam = function(name){
+      var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
+      if (results) {
+        return results[1] || 0;
+      }
+      return null;
+  }
 
-/**
- * open a confirm dialog based on bootstrap modal
- * @param okFn callback function to call on ok confirm
- * @param okMessage
- * @param cancelMessage
- * @param title
- */
-openDialogConfirm=function(okFn, okMessage, cancelMessage, title,bodyText){
-  if (window.modalConfirmDialog==null) {
-    window.modalConfirmDialog = $("#dialog-confirm-modal").modal();//{backdrop:'static',show:false}
-    window.modalConfirmDialog.bind('hidden', function () {
-      $("#dialog-confirm-modal-header-title").html("");
-      $("#dialog-confirm-modal-body-text").html("");
-    })
-    $("#dialog-confirm-modal-cancel").on("click", function(){
-      window.modalConfirmDialog.modal('hide');
+  usedLang=function(){
+    var browserLang = $.i18n.browserLang();
+    var requestLang = $.urlParam('request_lang');
+    if (requestLang) {
+      browserLang=requestLang;
+    }
+    return browserLang;
+  }
+
+  /**
+   * display a success message
+   * @param text the success text
+   * @param idToAppend the id to append the success box
+   */
+  displaySuccessMessage=function(text,idToAppend){
+    var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
+    $.tmpl($("#alert-message-success").html(), { "message" : text }).appendTo( textId );
+    $(textId).focus();
+  }
+
+  /**
+   * display an error message
+   * @param text the success text
+   * @param idToAppend the id to append the success box
+   */
+  displayErrorMessage=function(text,idToAppend){
+    var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
+    $.tmpl($("#alert-message-error").html(), { "message" : text }).appendTo( textId );
+    $(textId).focus();
+  }
+
+  /**
+   * display a warning message
+   * @param text the success text
+   * @param idToAppend the id to append the success box
+   */
+  displayWarningMessage=function(text,idToAppend){
+    var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
+    $.tmpl($("#alert-message-warning").html(), { "message" : text }).appendTo( textId );
+    $(textId).focus();
+  }
+
+  displayInfoMessage=function(text,idToAppend){
+    var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
+    $.tmpl($("#alert-message-info").html(), { "message" : text }).appendTo( textId );
+    $(textId).focus();
+  }
+
+  /**
+   * clear #main-content and call clearUserMessages
+    */
+  screenChange=function(){
+    $("#main-content").html("");
+    $("#main-content").removeAttr("data-bind");
+    clearUserMessages();
+  }
+
+  /**
+   * clear content of id if none clear content of #user-messages
+    * @param idToAppend
+   */
+  clearUserMessages=function(idToAppend){
+    var textId = idToAppend ? $("#"+idToAppend) : $("#user-messages");
+    $(textId).html('');
+  }
+
+  /**
+   * clear all input text and password found in the the selector
+   * @param selectorStr
+   */
+  clearForm=function(selectorStr){
+    $(selectorStr).find("input[type='text']").each(function(ele){
+      $(this).val("");
+    });
+    $(selectorStr).find("input[type='password']").each(function(ele){
+      $(this).val("");
     });
+
   }
-  $("#dialog-confirm-modal-header-title").html(title);
-  $("#dialog-confirm-modal-body-text").html(bodyText);
-  if (okMessage){
-    $("#dialog-confirm-modal-ok").html(okMessage);
+
+  /**
+   * open a confirm dialog based on bootstrap modal
+   * @param okFn callback function to call on ok confirm
+   * @param okMessage
+   * @param cancelMessage
+   * @param title
+   */
+  openDialogConfirm=function(okFn, okMessage, cancelMessage, title,bodyText){
+    if (window.modalConfirmDialog==null) {
+      window.modalConfirmDialog = $("#dialog-confirm-modal").modal();//{backdrop:'static',show:false}
+      window.modalConfirmDialog.bind('hidden', function () {
+        $("#dialog-confirm-modal-header-title").html("");
+        $("#dialog-confirm-modal-body-text").html("");
+      })
+      $("#dialog-confirm-modal-cancel").on("click", function(){
+        window.modalConfirmDialog.modal('hide');
+      });
+    }
+    $("#dialog-confirm-modal-header-title").html(title);
+    $("#dialog-confirm-modal-body-text").html(bodyText);
+    if (okMessage){
+      $("#dialog-confirm-modal-ok").html(okMessage);
+    }
+    if (cancelMessage){
+      $("#dialog-confirm-modal-cancel").html(cancelMessage);
+    }
+    window.modalConfirmDialog.modal('show');
+
+    // unbind previous events !!
+    $("#dialog-confirm-modal-ok").off( );
+    $("#dialog-confirm-modal-ok").on("click", okFn);
+
   }
-  if (cancelMessage){
-    $("#dialog-confirm-modal-cancel").html(cancelMessage);
+
+  /**
+   * return a small spinner html img element
+   */
+  smallSpinnerImg=function(){
+    return "<img id=\"small-spinner\" src=\"images/small-spinner.gif\"/>";
+  };
+
+  removeSmallSpinnerImg=function(){
+    $("#small-spinner").remove();
   }
-  window.modalConfirmDialog.modal('show');
 
-  // unbind previous events !!
-  $("#dialog-confirm-modal-ok").off( );
-  $("#dialog-confirm-modal-ok").on("click", okFn);
+  mediumSpinnerImg=function(){
+    return "<img id=\"medium-spinner\" src=\"images/medium-spinner.gif\"/>";
+  };
 
-}
+  removeMediumSpinnerImg=function(){
+    $("#medium-spinner").remove();
+  }
 
-/**
- * return a small spinner html img element
- */
-smallSpinnerImg=function(){
-  return "<img id=\"small-spinner\" src=\"images/small-spinner.gif\"/>";
-};
-
-removeSmallSpinnerImg=function(){
-  $("#small-spinner").remove();
-}
-
-mediumSpinnerImg=function(){
-  return "<img id=\"medium-spinner\" src=\"images/medium-spinner.gif\"/>";
-};
-
-removeMediumSpinnerImg=function(){
-  $("#medium-spinner").remove();
-}
-
-removeMediumSpinnerImg=function(selector){
-  $(selector+" #medium-spinner").remove();
-}
-
-closeDialogConfirm=function(){
-  window.modalConfirmDialog.modal('hide');
-}
-
-closeDialogConfirmui=function(){
-  $("#dialog-confirm" ).dialog("close");
-}
-
-/**
- * open a confirm dialog with jqueryui
- * @param okFn callback function to call on ok confirm
- * @param okMessage
- * @param cancelMessage
- * @param title
- */
-openDialogConfirmui=function(okFn, okMessage, cancelMessage, title){
-  $("#dialog-confirm" ).dialog({
-    resizable: false,
-    title: title,
-    modal: true,
-    show: 'slide',
-    buttons: [{
-      text: okMessage,
-      click: okFn},
-      {
-      text: cancelMessage,
-      click:function() {
-        $(this).dialog( "close" );
+  removeMediumSpinnerImg=function(selector){
+    $(selector+" #medium-spinner").remove();
+  }
+
+  closeDialogConfirm=function(){
+    window.modalConfirmDialog.modal('hide');
+  }
+
+  closeDialogConfirmui=function(){
+    $("#dialog-confirm" ).dialog("close");
+  }
+
+  /**
+   * open a confirm dialog with jqueryui
+   * @param okFn callback function to call on ok confirm
+   * @param okMessage
+   * @param cancelMessage
+   * @param title
+   */
+  openDialogConfirmui=function(okFn, okMessage, cancelMessage, title){
+    $("#dialog-confirm" ).dialog({
+      resizable: false,
+      title: title,
+      modal: true,
+      show: 'slide',
+      buttons: [{
+        text: okMessage,
+        click: okFn},
+        {
+        text: cancelMessage,
+        click:function() {
+          $(this).dialog( "close" );
+        }
+      }]
+    });
+  }
+
+  mapStringArray=function(data){
+    if (data) {
+      if ($.isArray(data)){
+        return $.map(data,function(item){
+          return item;
+        });
+      } else {
+        return new Array(data);
       }
-    }]
-  });
-}
+    }
+    return null;
+  }
 
-mapStringArray=function(data){
-  if (data) {
-    if ($.isArray(data)){
-      return $.map(data,function(item){
-        return item;
-      });
+  /**
+   * display redback error from redback json error response
+   * {"redbackRestError":{"errorMessages":{"args":1,"errorKey":"user.password.violation.numeric"}}}
+   * @param obj
+   * @param idToAppend
+   */
+  displayRedbackError=function(obj,idToAppend) {
+    if ($.isArray(obj.errorMessages)) {
+      $.log("displayRedbackError with array");
+      for(var i=0; i<obj.errorMessages.length; i++ ) {
+        if(obj.errorMessages[i].errorKey) {
+          $.log("displayRedbackError with array loop");
+          displayErrorMessage($.i18n.prop( obj.errorMessages[i].errorKey, obj.errorMessages[i].args ),idToAppend);
+        }
+      }
     } else {
-      return new Array(data);
+      $.log("displayRedbackError no array");
+      displayErrorMessage($.i18n.prop( obj.errorMessages.errorKey, obj.errorMessages.args ),idToAppend);
     }
   }
-  return null;
-}
 
-/**
- * display redback error from redback json error response
- * {"redbackRestError":{"errorMessages":{"args":1,"errorKey":"user.password.violation.numeric"}}}
- * @param obj
- * @param idToAppend
- */
-displayRedbackError=function(obj,idToAppend) {
-  if ($.isArray(obj.errorMessages)) {
-    $.log("displayRedbackError with array");
-    for(var i=0; i<obj.errorMessages.length; i++ ) {
-      if(obj.errorMessages[i].errorKey) {
-        $.log("displayRedbackError with array loop");
-        displayErrorMessage($.i18n.prop( obj.errorMessages[i].errorKey, obj.errorMessages[i].args ),idToAppend);
+  /*
+   * generic function to display error return by rest service
+   * if fieldName is here the function will try to find a field with this name and add a span on it
+   * if not error is displayed in #user-messages div
+   */
+  displayRestError=function(data,idToAppend){
+
+    if (data.redbackRestError){
+      displayRedbackError(archivaRestError,idToAppend)
+    }
+    // if we have the fieldName display error on it
+    if (data && data.fieldName){
+      var mainContent=$("#main-content");
+
+      if (mainContent.find("#"+data.fieldName)){
+        var message=null;
+        if (data.errorKey) {
+          message=$.i18n.prop('data.errorKey');
+        } else {
+          message=data.errorMessage;
+        }
+        mainContent.find("div.clearfix" ).removeClass( "error" );
+        mainContent.find("span.help-inline" ).remove();
+        mainContent.find("#"+data.fieldName).parents( "div.clearfix" ).addClass( "error" );
+        mainContent.find("#"+data.fieldName).parent().append( "<span class=\"help-inline\">" + message + "</span>" );
+        return;
       }
+      // we don't have any id with this fieldName so continue
     }
-  } else {
-    $.log("displayRedbackError no array");
-    displayErrorMessage($.i18n.prop( obj.errorMessages.errorKey, obj.errorMessages.args ),idToAppend);
-  }
-}
-
-/*
- * generic function to display error return by rest service
- * if fieldName is here the function will try to find a field with this name and add a span on it
- * if not error is displayed in #user-messages div
- */
-displayRestError=function(data,idToAppend){
 
-  if (data.redbackRestError){
-    displayRedbackError(archivaRestError,idToAppend)
-  }
-  // if we have the fieldName display error on it
-  if (data && data.fieldName){
-    var mainContent=$("#main-content");
-
-    if (mainContent.find("#"+data.fieldName)){
-      var message=null;
-      if (data.errorKey) {
-        message=$.i18n.prop('data.errorKey');
+    if (data.errorKey && data.errorKey.length>0){
+        displayErrorMessage($.i18n.prop( data.errorKey ),idToAppend);
       } else {
-        message=data.errorMessage;
-      }
-      mainContent.find("div.clearfix" ).removeClass( "error" );
-      mainContent.find("span.help-inline" ).remove();
-      mainContent.find("#"+data.fieldName).parents( "div.clearfix" ).addClass( "error" );
-      mainContent.find("#"+data.fieldName).parent().append( "<span class=\"help-inline\">" + message + "</span>" );
-      return;
+        $.log("data.errorMessage:"+data.errorMessage);
+        displayErrorMessage(data.errorMessage,idToAppend);
     }
-    // we don't have any id with this fieldName so continue
+
   }
 
-  if (data.errorKey && data.errorKey.length>0){
-      displayErrorMessage($.i18n.prop( data.errorKey ),idToAppend);
-    } else {
-      $.log("data.errorMessage:"+data.errorMessage);
-      displayErrorMessage(data.errorMessage,idToAppend);
+  /**
+   * used by validation error to customize error display in the ui
+   * @param selector
+   * @param validator
+   * @param errorMap
+   * @param errorList
+   */
+  customShowError=function(selector, validator, errorMap, errorList) {
+    $(selector).find("div.control-group" ).removeClass( "error" );
+    $(selector).find("span.help-inline").remove();
+    for ( var i = 0; errorList[i]; i++ ) {
+      var error = errorList[i];
+      var field = $(selector).find("#"+error.element.id);
+      field.parents( "div.control-group" ).addClass( "error" );
+      field.parent().append( "<span class=\"help-inline\">" + error.message + "</span>" );
+    }
   }
 
-}
+  timestampNoCache=function(){
+    if (!window.archivaDevMode){
+      return "";
+    }
+    return "&_="+jQuery.now();
+  }
 
-/**
- * used by validation error to customize error display in the ui
- * @param selector
- * @param validator
- * @param errorMap
- * @param errorList
- */
-customShowError=function(selector, validator, errorMap, errorList) {
-  $(selector).find("div.control-group" ).removeClass( "error" );
-  $(selector).find("span.help-inline").remove();
-  for ( var i = 0; errorList[i]; i++ ) {
-    var error = errorList[i];
-    var field = $(selector).find("#"+error.element.id);
-    field.parents( "div.control-group" ).addClass( "error" );
-    field.parent().append( "<span class=\"help-inline\">" + error.message + "</span>" );
-  }
-}
-
-timestampNoCache=function(){
-  if (!window.archivaDevMode){
-    return "";
-  }
-  return "&_="+jQuery.now();
-}
-
-appendTemplateUrl=function(){
-  return "?"+appendArchivaVersion()+timestampNoCache();
-}
-
-/**
- * mapping for a java Map entry
- * @param key
- * @param value
- */
-Entry=function(key,value){
-  var self=this;
-  this.key=ko.observable(key);
-  this.value=ko.observable(value);
-}
-
-/**
- * map {"strings":["snapshots","internal"]} to an array
- * @param data
- */
-mapStringList=function(data){
-  if (data && data.strings){
-  return $.isArray(data.strings) ?
-      $.map(data.strings,function(item){return item}): [data.strings];
-  }
-  return [];
-}
-
-/**
- * return an array with removing duplicate strings
- * @param strArray an array of string
- * @param sorted to sort or not
- */
-unifyArray=function(strArray,sorted){
-  var res = [];
-  $(strArray).each(function(idx,str){
-    if ( $.inArray(str,res)<0){
-      res.push(str);
+  appendTemplateUrl=function(){
+    return "?"+appendArchivaVersion()+timestampNoCache();
+  }
+
+  /**
+   * mapping for a java Map entry
+   * @param key
+   * @param value
+   */
+  Entry=function(key,value){
+    var self=this;
+    this.key=ko.observable(key);
+    this.value=ko.observable(value);
+  }
+
+  /**
+   * map {"strings":["snapshots","internal"]} to an array
+   * @param data
+   */
+  mapStringList=function(data){
+    if (data && data.strings){
+    return $.isArray(data.strings) ?
+        $.map(data.strings,function(item){return item}): [data.strings];
     }
+    return [];
+  }
+
+  /**
+   * return an array with removing duplicate strings
+   * @param strArray an array of string
+   * @param sorted to sort or not
+   */
+  unifyArray=function(strArray,sorted){
+    var res = [];
+    $(strArray).each(function(idx,str){
+      if ( $.inArray(str,res)<0){
+        res.push(str);
+      }
+    });
+    return sorted?res.sort():res;
+  }
+
+  //------------------------------------
+  // utils javascript string extensions
+  //------------------------------------
+
+  String.prototype.endsWith = function(str) {
+    return (this.match(str+"$")==str)
+  }
+
+  String.prototype.startsWith = function(str) {
+    return (this.match("^"+str)==str)
+  }
+
+  String.prototype.substringBeforeLast = function(str) {
+    return this.substring(0,this.lastIndexOf(str));
+  }
+
+  //-----------------------------------------
+  // extends jquery tmpl to support var def
+  //-----------------------------------------
+
+  $.extend($.tmpl.tag, {
+      "var": {
+          open: "var $1;"
+      }
   });
-  return sorted?res.sort():res;
-}
 
-//------------------------------------
-// utils javascript string extensions
-//------------------------------------
-
-String.prototype.endsWith = function(str) {
-  return (this.match(str+"$")==str)
-}
-
-String.prototype.startsWith = function(str) {
-  return (this.match("^"+str)==str)
-}
-
-String.prototype.substringBeforeLast = function(str) {
-  return this.substring(0,this.lastIndexOf(str));
-}
-
-//-----------------------------------------
-// extends jquery tmpl to support var def
-//-----------------------------------------
-
-$.extend($.tmpl.tag, {
-    "var": {
-        open: "var $1;"
-    }
 });
\ No newline at end of file

Added: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/domReady.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/domReady.js?rev=1305567&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/domReady.js (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/domReady.js Mon Mar 26 20:46:28 2012
@@ -0,0 +1,170 @@
+/**
+ * @license RequireJS domReady 1.0.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
+ * Available via the MIT or new BSD license.
+ * see: http://github.com/jrburke/requirejs for details
+ */
+/*jslint strict: false, plusplus: false */
+/*global require: false, define: false, requirejs: false,
+  window: false, clearInterval: false, document: false,
+  self: false, setInterval: false */
+
+
+define(function () {
+    var isBrowser = typeof window !== "undefined" && window.document,
+        isPageLoaded = !isBrowser,
+        doc = isBrowser ? document : null,
+        readyCalls = [],
+        readyLoaderCalls = [],
+        //Bind to a specific implementation, but if not there, try a
+        //a generic one under the "require" name.
+        req = requirejs || require || {},
+        oldResourcesReady = req.resourcesReady,
+        scrollIntervalId;
+
+    function runCallbacks(callbacks) {
+        for (var i = 0, callback; (callback = callbacks[i]); i++) {
+            callback(doc);
+        }
+    }
+
+    function callReady() {
+        var callbacks = readyCalls,
+            loaderCallbacks = readyLoaderCalls;
+
+        if (isPageLoaded) {
+            //Call the DOM ready callbacks
+            if (callbacks.length) {
+                readyCalls = [];
+                runCallbacks(callbacks);
+            }
+
+            //Now handle DOM ready + loader ready callbacks.
+            if (req.resourcesDone && loaderCallbacks.length) {
+                readyLoaderCalls = [];
+                runCallbacks(loaderCallbacks);
+            }
+        }
+    }
+
+    /**
+     * Add a method to require to get callbacks if there are loader resources still
+     * being loaded. If so, then hold off calling "withResources" callbacks.
+     *
+     * @param {Boolean} isReady: pass true if all resources have been loaded.
+     */
+    if ('resourcesReady' in req) {
+        req.resourcesReady = function (isReady) {
+            //Call the old function if it is around.
+            if (oldResourcesReady) {
+                oldResourcesReady(isReady);
+            }
+
+            if (isReady) {
+                callReady();
+            }
+        };
+    }
+
+    /**
+     * Sets the page as loaded.
+     */
+    function pageLoaded() {
+        if (!isPageLoaded) {
+            isPageLoaded = true;
+            if (scrollIntervalId) {
+                clearInterval(scrollIntervalId);
+            }
+
+            callReady();
+        }
+    }
+
+    if (isBrowser) {
+        if (document.addEventListener) {
+            //Standards. Hooray! Assumption here that if standards based,
+            //it knows about DOMContentLoaded.
+            document.addEventListener("DOMContentLoaded", pageLoaded, false);
+            window.addEventListener("load", pageLoaded, false);
+        } else if (window.attachEvent) {
+            window.attachEvent("onload", pageLoaded);
+
+            //DOMContentLoaded approximation, as found by Diego Perini:
+            //http://javascript.nwbox.com/IEContentLoaded/
+            if (self === self.top) {
+                scrollIntervalId = setInterval(function () {
+                    try {
+                        //From this ticket:
+                        //http://bugs.dojotoolkit.org/ticket/11106,
+                        //In IE HTML Application (HTA), such as in a selenium test,
+                        //javascript in the iframe can't see anything outside
+                        //of it, so self===self.top is true, but the iframe is
+                        //not the top window and doScroll will be available
+                        //before document.body is set. Test document.body
+                        //before trying the doScroll trick.
+                        if (document.body) {
+                            document.documentElement.doScroll("left");
+                            pageLoaded();
+                        }
+                    } catch (e) {}
+                }, 30);
+            }
+        }
+
+        //Check if document already complete, and if so, just trigger page load
+        //listeners.
+        if (document.readyState === "complete") {
+            pageLoaded();
+        }
+    }
+
+    /** START OF PUBLIC API **/
+
+    /**
+     * Registers a callback for DOM ready. If DOM is already ready, the
+     * callback is called immediately.
+     * @param {Function} callback
+     */
+    function domReady(callback) {
+        if (isPageLoaded) {
+            callback(doc);
+        } else {
+            readyCalls.push(callback);
+        }
+        return domReady;
+    }
+
+    /**
+     * Callback that waits for DOM ready as well as any outstanding
+     * loader resources. Useful when there are implicit dependencies.
+     * This method should be avoided, and always use explicit
+     * dependency resolution, with just regular DOM ready callbacks.
+     * The callback passed to this method will be called immediately
+     * if the DOM and loader are already ready.
+     * @param {Function} callback
+     */
+    domReady.withResources = function (callback) {
+        if (isPageLoaded && req.resourcesDone) {
+            callback(doc);
+        } else {
+            readyLoaderCalls.push(callback);
+        }
+        return domReady;
+    };
+
+    domReady.version = '1.0.0';
+
+    /**
+     * Loader Plugin API method
+     */
+    domReady.load = function (name, req, onLoad, config) {
+        if (config.isBuild) {
+            onLoad(null);
+        } else {
+            domReady(onLoad);
+        }
+    };
+
+    /** END OF PUBLIC API **/
+
+    return domReady;
+});

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/domReady.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/domReady.js
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js (from r1305566, archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/startup.js)
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js?p2=archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js&p1=archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/startup.js&r1=1305566&r2=1305567&rev=1305567&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/startup.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js Mon Mar 26 20:46:28 2012
@@ -17,41 +17,25 @@
  * under the License.
  */
 
-$(function() {
+require(["jquery","i18n","js/archiva/utils.js"],
+function() {
 
-  /**
-   * return value of a param in the url
-   * @param name
-   */
-  $.urlParam = function(name){
-      var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
-      if (results) {
-        return results[1] || 0;
-      }
-      return null;
-  }
-
-  usedLang=function(){
-    var browserLang = $.i18n.browserLang();
-    var requestLang = $.urlParam('request_lang');
-    if (requestLang) {
-      browserLang=requestLang;
-    }
-    return browserLang;
-  }
 
   appendArchivaVersion=function(){
     return "_archivaVersion="+window.archivaRuntimeInfo.version;
   }
 
   buildLoadJsUrl=function(srcScript){
-    return srcScript+"?"+appendArchivaVersion();
+    return srcScript+"?"+appendArchivaVersion()+"&_"+jQuery.now();
   }
 
   $.ajaxSetup({
     dataType: 'json'
   });
 
+
+
+
   loadJs=function(){
 
     $.ajax(
@@ -62,9 +46,20 @@ $(function() {
             window.archivaDevMode=data.devMode;
             window.archivaJavascriptLog=data.javascriptLog;
             window.archivaRuntimeInfo=data;
+
             require.config({
-                baseUrl: "js/"
-              });
+                baseUrl: "js/",
+                "paths": {
+                    "i18n":"jquery.i18n.properties-1.0.9",
+                    "jquery": "jquery-1.7.2",
+                    "redback": buildLoadJsUrl("redback/redback.js"),
+                    "utils":  buildLoadJsUrl("archiva/utils.js"),
+                    "i18nLoad":  buildLoadJsUrl("archiva/i18nload.js"),
+                    "jquerytmpl":  buildLoadJsUrl("jquery.tmpl.js"),
+                    "jquery_ui": "jquery-ui-1.8.16.custom.min"
+                }
+            });
+
             // CacheBust is for dev purpose use false in prod env !
             var options = {
                 AlwaysPreserveOrder:true,
@@ -79,7 +74,7 @@ $(function() {
                .script(buildLoadJsUrl("archiva/i18nload.js")).wait()
                .script("jquery.cookie.1.0.0.js").wait()
                .script("knockout-2.0.0.debug.js").wait()
-               .script("jquery-ui-1.8.16.custom.min.js").wait()
+               //.script("jquery-ui-1.8.16.custom.min.js").wait()
                .script("jquery.validate-1.9.0.js").wait()
                .script("jquery.json-2.3.min.js").wait()
                .script(buildLoadJsUrl("archiva/main-tmpl.js")).wait()
@@ -95,9 +90,13 @@ $(function() {
                .script("bootstrap.2.0.2.js" )
                .script(buildLoadJsUrl("knockout.simpleGrid.js"))
                .script(buildLoadJsUrl("knockout-sortable.js"))
+               //.script("jquery.iframe-transport-1.4.js").wait()
+               //.script("jquery.fileupload-5.10.0.js").wait()
+               //.script("jquery.fileupload-ip-1.0.6.js").wait()
+               //.script("jquery.fileupload-ui-6.6.3.js" ).wait()
                .script(buildLoadJsUrl("redback/user.js")).wait()
                .script(buildLoadJsUrl("redback/users.js")).wait()
-               .script(buildLoadJsUrl("redback/redback.js")).wait()
+               //.script(buildLoadJsUrl("redback/redback.js")).wait()
                .script(buildLoadJsUrl("redback/register.js")).wait()
                .script(buildLoadJsUrl("redback/permission.js")).wait()
                .script(buildLoadJsUrl("redback/resource.js")).wait()
@@ -107,4 +106,7 @@ $(function() {
       })
   }
 
+
+
+
 });
\ No newline at end of file

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/startup.js
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision