archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1398751 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp: ./ js/ js/archiva/ js/redback/
Date Tue, 16 Oct 2012 11:54:22 GMT
Author: olamy
Date: Tue Oct 16 11:54:21 2012
New Revision: 1398751

URL: http://svn.apache.org/viewvc?rev=1398751&view=rev
Log:
use knockout-2.2.0rc

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/archiva.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
    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/archiva/utils.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-sortable.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.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=1398751&r1=1398750&r2=1398751&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
Tue Oct 16 11:54:21 2012
@@ -29,7 +29,7 @@
   <link rel="stylesheet" href="css/bootstrap.2.1.1.css">
   <link rel="stylesheet" href="css/archiva.css">
   <link rel="shortcut icon" href="favicon.ico"/>
-    <link rel="stylesheet" href="css/prettify.css"/>
+  <link rel="stylesheet" href="css/prettify.css"/>
 
   <script type="text/javascript" src="js/jquery-1.8.1.min.js"></script>
   <script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/archiva.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/archiva.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/archiva.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/archiva.js
Tue Oct 16 11:54:21 2012
@@ -69,7 +69,7 @@ $.ajax({
                     "choosen": "chosen.jquery-0.9.8",
                     "jquery.validate": "jquery.validate-1.9.0",
                     "jquery.json": "jquery.json-2.3.min",
-                    "knockout": "knockout-2.0.0.debug",
+                    "knockout": "knockout-2.2.0rc.debug",
                     "knockout.simpleGrid": "knockout.simpleGrid",
                     "knockout.sortable": "knockout-sortable",
                     "jquery.iframe.transport": "jquery.iframe-transport-1.4",

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js
Tue Oct 16 11:54:21 2012
@@ -18,7 +18,7 @@
  */
 define("archiva.artifacts-management",["jquery","i18n","utils","jquery.tmpl","knockout",
   "knockout.simpleGrid","jquery.validate","bootstrap","jquery.fileupload","jquery.fileupload.ui"]
-    , function() {
+    , function(jquery,i18n,utils,jqueryTmpl,ko) {
 
   ArtifactUpload=function(classifier,pomFile){
     this.classifier=classifier;

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
Tue Oct 16 11:54:21 2012
@@ -18,7 +18,7 @@
  */
 define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout","knockout.simpleGrid",
   "knockout.sortable","jquery.validate","bootstrap"]
-    , function() {
+    , function(jquery,i18n,utils,jqueryTmpl,ko) {
 
   //-------------------------
   // legacy path part

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
Tue Oct 16 11:54:21 2012
@@ -21,7 +21,7 @@ define("archiva.main",["jquery","jquery.
           "redback.roles","redback","archiva.general-admin","archiva.repositories",
           "archiva.network-proxies","archiva.proxy-connectors","archiva.repository-groups","archiva.artifacts-management",
           "archiva.proxy-connectors-rules","archiva.docs"],
-function(jquery,ui,sammy,tmpl) {
+function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryValidate,jqueryJson,ko)
{
 
   /**
    * reccord a cookie for session with the logged user

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js
Tue Oct 16 11:54:21 2012
@@ -17,7 +17,7 @@
  * under the License.
  */
 define("archiva.network-proxies",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout"
-  ,"knockout.simpleGrid"], function() {
+  ,"knockout.simpleGrid"], function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
 
 
   NetworkProxy=function(id,protocol,host,port,username,password,useNtlm){

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
Tue Oct 16 11:54:21 2012
@@ -17,12 +17,14 @@
  * under the License.
  */
 define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstrap","jquery.ui","knockout"
-  ,"knockout.simpleGrid","knockout.sortable","archiva.proxy-connectors"], function() {
+  ,"knockout.simpleGrid","knockout.sortable","archiva.proxy-connectors"],
+  function(jquery,i18n,jqueryTmpl,bootstrap,jqueryUi,ko) {
 
   ProxyConnectorRulesViewModel=function(proxyConnectorRules,proxyConnectors){
     var self=this;
-    this.proxyConnectorRules=ko.observableArray(proxyConnectorRules?proxyConnectorRules:[]);
-    this.proxyConnectors=proxyConnectors;
+    self.proxyConnectorRules=ko.observableArray(proxyConnectorRules?proxyConnectorRules:[]);
+    self.proxyConnectors=ko.observableArray(proxyConnectors);
+    self.proxyConnectors.id="select";
 
     // FIXME get that from a REST service
     // FIXME i18n
@@ -163,17 +165,25 @@ define("archiva.proxy-connectors-rules",
 
     }
 
+    remove=function(){
+      $.log("remove");
+    }
+
   }
 
   ProxyConnectorRuleViewModel=function(proxyConnectorRule,proxyConnectorRulesViewModel,update){
     var self=this;
     this.proxyConnectorRule=proxyConnectorRule;
     this.proxyConnectorRulesViewModel=proxyConnectorRulesViewModel;
-    this.availableProxyConnectors=ko.observableArray(proxyConnectorRulesViewModel.proxyConnectors);
+    this.availableProxyConnectors=proxyConnectorRulesViewModel.proxyConnectors;
+    this.availableProxyConnectors.id="availableProxyConnectors";
     this.update=update;
 
     proxyConnectorMoved=function(arg){
       $.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
+      self.proxyConnectorRule.modified(true);
+      ///arg.sourceParent.remove(arg.item);
+      //arg.targetParent.push(arg.item);
     }
 
     saveProxyConnectorRule=function(){

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
Tue Oct 16 11:54:21 2012
@@ -17,7 +17,8 @@
  * under the License.
  */
 define("archiva.proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout"
-  ,"knockout.simpleGrid","knockout.sortable"], function() {
+  ,"knockout.simpleGrid","knockout.sortable"],
+  function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
 
   ProxyConnector=function(sourceRepoId,targetRepoId,proxyId,blackListPatterns,whiteListPatterns,policiesEntries,propertiesEntries,
                           disabled,order){

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
Tue Oct 16 11:54:21 2012
@@ -17,7 +17,7 @@
  * under the License.
  */
 define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout","knockout.simpleGrid"],
-       function() {
+function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
 
   // FIXME this must be dynamic if we do a plugin mechanism with dynamic repositories types
   // FIXME i18n

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js
Tue Oct 16 11:54:21 2012
@@ -18,7 +18,7 @@
  */
 define("archiva.repository-groups",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","jquery.ui","knockout"
   ,"knockout.simpleGrid","knockout.sortable"],
-function() {
+function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
 
   RepositoryGroup=function(id,repositories){
 

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
Tue Oct 16 11:54:21 2012
@@ -17,7 +17,7 @@
  * under the License.
  */
 define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","knockout.simpleGrid","jqueryFileTree","prettify"]
-, function() {
+, function(jquery,i18n,jqueryTmpl,choosen,ko,koSimpleGrid) {
 
   //-----------------------------------------
   // browse part

Modified: 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/archiva/startup.js?rev=1398751&r1=1398750&r2=1398751&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/archiva/startup.js
Tue Oct 16 11:54:21 2012
@@ -18,12 +18,12 @@
  */
 
 define("startup",["jquery","sammy","utils"],
-function() {
+function(jquery,sammy,utils) {
 
   // define a container object with various datas
   window.archivaModel = {};
 
-  $.log("devMode:"+window.archivaDevMode);
+  //$.log("devMode:"+window.archivaDevMode);
 
   // no cache for ajax queries as we get datas from servers so preventing caching !!
   jQuery.ajaxSetup( {

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=1398751&r1=1398750&r2=1398751&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
Tue Oct 16 11:54:21 2012
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-require(["jquery","jquery.tmpl","i18n"], function(jquery,jqueryTmpl,i18n) {
+require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i18n,ko) {
 
   loadi18n=function(loadCallback){
     $.log("loadi18n");

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-sortable.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-sortable.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-sortable.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-sortable.js
Tue Oct 16 11:54:21 2012
@@ -1,140 +1,285 @@
-//knockout-sortable | (c) 2012 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
-define("knockout.sortable",["jquery","utils","knockout"], function() {
+//knockout-sortable 0.6.6 | (c) 2012 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
+(function(factory) {
+    if (typeof define === "function" && define.amd) {
+        // AMD anonymous module
+        define(["knockout", "jquery", "jquery.ui"], factory);
+    } else {
+        // No module loader (plain <script> tag) - put directly in global namespace
+        factory(window.ko, jQuery);
+    }
+})(function(ko, $, undefined) {
+    var ITEMKEY = "ko_sortItem",
+        LISTKEY = "ko_sortList",
+        PARENTKEY = "ko_parentList",
+        DRAGKEY = "ko_dragItem";
+
+    //internal afterRender that adds meta-data to children
+    var addMetaDataAfterRender = function(elements, data) {
+        ko.utils.arrayForEach(elements, function(element) {
+            if (element.nodeType === 1) {
+                ko.utils.domData.set(element, ITEMKEY, data);
+                ko.utils.domData.set(element, PARENTKEY, ko.utils.domData.get(element.parentNode,
LISTKEY));
+            }
+        });
+    };
+
+    //prepare the proper options for the template binding
+    var prepareTemplateOptions = function(valueAccessor, dataName) {
+        var result = {},
+            options = ko.utils.unwrapObservable(valueAccessor()),
+            actualAfterRender;
+
+        //build our options to pass to the template engine
+        if (options.data) {
+            result[dataName] = options.data;
+            result.name = options.template;
+        } else {
+            result[dataName] = valueAccessor();
+        }
+
+        ko.utils.arrayForEach(["afterAdd", "afterRender", "beforeRemove", "includeDestroyed",
"templateEngine", "templateOptions"], function (option) {
+            result[option] = options[option] || ko.bindingHandlers.sortable[option];
+        });
+
+        //use an afterRender function to add meta-data
+        if (dataName === "foreach") {
+            if (result.afterRender) {
+                //wrap the existing function, if it was passed
+                actualAfterRender = result.afterRender;
+                result.afterRender = function(element, data) {
+                    addMetaDataAfterRender.call(data, element, data);
+                    actualAfterRender.call(data, element, data);
+                };
+            } else {
+                result.afterRender = addMetaDataAfterRender;
+            }
+        }
+
+        //return options to pass to the template binding
+        return result;
+    };
+
+    //connect items with observableArrays
+    ko.bindingHandlers.sortable = {
+        init: function(element, valueAccessor, allBindingsAccessor, data, context) {
+            var $element = $(element),
+                value = ko.utils.unwrapObservable(valueAccessor()) || {},
+                templateOptions = prepareTemplateOptions(valueAccessor, "foreach"),
+                sortable = {},
+                startActual, updateActual;
+
+            //remove leading/trailing text nodes from anonymous templates
+            ko.utils.arrayForEach(element.childNodes, function(node) {
+                if (node && node.nodeType === 3) {
+                    node.parentNode.removeChild(node);
+                }
+            });
+
+            //build a new object that has the global options with overrides from the binding
+            $.extend(true, sortable, ko.bindingHandlers.sortable);
+            if (value.options && sortable.options) {
+                ko.utils.extend(sortable.options, value.options);
+                delete value.options;
+            }
+            ko.utils.extend(sortable, value);
+
+            //if allowDrop is an observable or a function, then execute it in a computed
observable
+            if (sortable.connectClass && (ko.isObservable(sortable.allowDrop) ||
typeof sortable.allowDrop == "function")) {
+                ko.computed({
+                    read: function() {
+                        var value = ko.utils.unwrapObservable(sortable.allowDrop),
+                            shouldAdd = typeof value == "function" ? value.call(this, templateOptions.foreach)
: value;
+                        ko.utils.toggleDomNodeCssClass(element, sortable.connectClass, shouldAdd);
+                    },
+                    disposeWhenNodeIsRemoved: element
+                }, this);
+            } else {
+                ko.utils.toggleDomNodeCssClass(element, sortable.connectClass, sortable.allowDrop);
+            }
+
+            //wrap the template binding
+            ko.bindingHandlers.template.init(element, function() { return templateOptions;
}, allBindingsAccessor, data, context);
+
+            //keep a reference to start/update functions that might have been passed in
+            startActual = sortable.options.start;
+            updateActual = sortable.options.update;
+
+            //initialize sortable binding after template binding has rendered in update function
+            setTimeout(function() {
+                var dragItem;
+                $element.sortable(ko.utils.extend(sortable.options, {
+                    start: function(event, ui) {
+                        //make sure that fields have a chance to update model
+                        ui.item.find("input:focus").change();
+                        if (startActual) {
+                            startActual.apply(this, arguments);
+                        }
+                    },
+                    receive: function(event, ui) {
+                        dragItem = ko.utils.domData.get(ui.item[0], DRAGKEY);
+                        if (dragItem && dragItem.clone) {
+                            dragItem = dragItem.clone();
+                        }
+                    },
+                    update: function(event, ui) {
+                        var sourceParent, targetParent, targetIndex, i, targetUnwrapped,
arg,
+                            el = ui.item[0],
+                            item = ko.utils.domData.get(el, ITEMKEY) || dragItem;
+
+                        dragItem = null;
+
+                        if (this === ui.item.parent()[0] && item) {
+                            //identify parents
+                            sourceParent = ko.utils.domData.get(el, PARENTKEY);
+                            targetParent = ko.utils.domData.get(el.parentNode, LISTKEY);
+                            targetIndex = ko.utils.arrayIndexOf(ui.item.parent().children(),
el);
+
+                            //take destroyed items into consideration
+                            if (!templateOptions.includeDestroyed) {
+                                if(targetParent){
+                                  targetUnwrapped = $.isFunction(targetParent)?targetParent():targetParent;
+                                  for (i = 0; i < targetIndex; i++) {
+                                      //add one for every destroyed item we find before the
targetIndex in the target array
+                                      if (targetUnwrapped[i] && targetUnwrapped[i]._destroy)
{
+                                          targetIndex++;
+                                      }
+                                  }
+                                }
+                            }
+
+                            if (sortable.beforeMove || sortable.afterMove) {
+                                arg = {
+                                    item: item,
+                                    sourceParent: sourceParent,
+                                    sourceParentNode: sourceParent && el.parentNode,
+                                    sourceIndex: sourceParent && sourceParent.indexOf(item),
+                                    targetParent: targetParent,
+                                    targetIndex: targetIndex,
+                                    cancelDrop: false
+                                };
+                            }
+
+                            if (sortable.beforeMove) {
+                                sortable.beforeMove.call(this, arg, event, ui);
+                                if (arg.cancelDrop) {
+                                    //call cancel on the correct list
+                                    if (arg.sourceParent) {
+                                        $(arg.sourceParent === arg.targetParent ? this :
ui.sender).sortable('cancel');
+                                    }
+                                    //for a draggable item just remove the element
+                                    else {
+                                        $(el).remove();
+                                    }
+
+                                    return;
+                                }
+                            }
+
+                            if (targetIndex >= 0) {
+                                if (sourceParent) {
+                                    if( $.isFunction(sourceParent.remove)) sourceParent.remove(item);
+                                }
+
+                                targetParent.splice(targetIndex, 0, item);
+                            }
+
+                            //rendering is handled by manipulating the observableArray; ignore
dropped element
+                            ko.utils.domData.set(el, ITEMKEY, null);
+                            ui.item.remove();
+
+                            //allow binding to accept a function to execute after moving
the item
+                            if (sortable.afterMove) {
+                                sortable.afterMove.call(this, arg, event, ui);
+                            }
+                        }
+
+                        if (updateActual) {
+                            updateActual.apply(this, arguments);
+                        }
+                    },
+                    connectWith: sortable.connectClass ? "." + sortable.connectClass : false
+                }));
+
+                //handle enabling/disabling sorting
+                if (sortable.isEnabled !== undefined) {
+                    ko.computed({
+                        read: function() {
+                            $element.sortable(ko.utils.unwrapObservable(sortable.isEnabled)
? "enable" : "disable");
+                        },
+                        disposeWhenNodeIsRemoved: element
+                    });
+                }
+            }, 0);
+
+            //handle disposal
+            ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
+                $element.sortable("destroy");
+            });
+
+            return { 'controlsDescendantBindings': true };
+        },
+        update: function(element, valueAccessor, allBindingsAccessor, data, context) {
+            var templateOptions = prepareTemplateOptions(valueAccessor, "foreach");
+
+            //attach meta-data
+            ko.utils.domData.set(element, LISTKEY, templateOptions.foreach);
+
+            //call template binding's update with correct options
+            ko.bindingHandlers.template.update(element, function() { return templateOptions;
}, allBindingsAccessor, data, context);
+        },
+        connectClass: 'ko_container',
+        allowDrop: true,
+        afterMove: null,
+        beforeMove: null,
+        options: {}
+    };
+
+    //create a draggable that is appropriate for dropping into a sortable
+    ko.bindingHandlers.draggable = {
+        init: function(element, valueAccessor, allBindingsAccessor, data, context) {
+            var value = ko.utils.unwrapObservable(valueAccessor()) || {},
+                options = value.options || {},
+                draggableOptions = ko.utils.extend({}, ko.bindingHandlers.draggable.options),
+                templateOptions = prepareTemplateOptions(valueAccessor, "data"),
+                connectClass = value.connectClass || ko.bindingHandlers.draggable.connectClass,
+                isEnabled = value.isEnabled !== undefined ? value.isEnabled : ko.bindingHandlers.draggable.isEnabled;
+
+            value = value.data || value;
+
+            //set meta-data
+            ko.utils.domData.set(element, DRAGKEY, value);
+
+            //override global options with override options passed in
+            ko.utils.extend(draggableOptions, options);
+
+            //setup connection to a sortable
+
+            draggableOptions.connectToSortable = connectClass ? "." + connectClass : false;
+
+            //initialize draggable
+            $(element).draggable(draggableOptions);
+
+            //handle enabling/disabling sorting
+            if (isEnabled !== undefined) {
+                ko.computed({
+                    read: function() {
+                        $(element).draggable(ko.utils.unwrapObservable(isEnabled) ? "enable"
: "disable");
+                    },
+                    disposeWhenNodeIsRemoved: element
+                });
+            }
+
+            return ko.bindingHandlers.template.init(element, function() { return templateOptions;
}, allBindingsAccessor, data, context);
+        },
+        update: function(element, valueAccessor, allBindingsAccessor, data, context) {
+            var templateOptions = prepareTemplateOptions(valueAccessor, "data");
+
+            return ko.bindingHandlers.template.update(element, function() { return templateOptions;
}, allBindingsAccessor, data, context);
+        },
+        connectClass: ko.bindingHandlers.sortable.connectClass,
+        options: {
+            helper: "clone"
+        }
+    };
 
-(function(ko, $, undefined) {
-  var prepareTemplateOptions = function(valueAccessor) {
-      var result = {},
-          options = ko.utils.unwrapObservable(valueAccessor());
-
-      //build our options to pass to the template engine
-      if (options.data) {
-          result.foreach = options.data;
-          result.name = options.template;
-          result.afterAdd = options.afterAdd;
-          result.beforeRemove = options.beforeRemove;
-          result.afterRender = options.afterRender;
-          result.includeDestroyed = options.includeDestroyed;
-          result.templateEngine = options.templateEngine;
-      } else {
-          result.foreach = valueAccessor();
-      }
-
-      //use an afterRender function to add meta-data
-      if (options.afterRender) {
-          //wrap the existing function, if it was passed
-          result.afterRender = function(element, data) {
-              ko.bindingHandlers.sortable.afterRender.call(data, element, data);
-              options.afterRender.call(data, element, data);
-          };
-      } else {
-          result.afterRender = ko.bindingHandlers.sortable.afterRender;
-      }
-
-      //return options to pass to the template binding
-      return result;
-  };
-
-  //connect items with observableArrays
-  ko.bindingHandlers.sortable = {
-      init: function(element, valueAccessor, allBindingsAccessor, data, context) {
-          var value = ko.utils.unwrapObservable(valueAccessor()),
-              templateOptions = prepareTemplateOptions(valueAccessor),
-              sortable = ko.bindingHandlers.sortable,
-              connectClass = value.connectClass || sortable.connectClass,
-              allowDrop = value.allowDrop === undefined ? sortable.allowDrop : value.allowDrop,
-              beforeMove = value.beforeMove || sortable.beforeMove,
-              afterMove = value.afterMove || sortable.afterMove,
-              options = value.options || sortable.options;
-
-          //if allowDrop is an observable or a function, then execute it in a computed observable
-          if (ko.isObservable(allowDrop) || typeof allowDrop == "function") {
-              ko.computed({
-                 read: function() {
-                     var value = ko.utils.unwrapObservable(allowDrop),
-                         shouldAdd = typeof value == "function" ? value.call(this, templateOptions.foreach)
: value;
-                     ko.utils.toggleDomNodeCssClass(element, connectClass, shouldAdd);
-                 },
-                 disposeWhenNodeIsRemoved: element
-              }, this);
-          } else {
-              ko.utils.toggleDomNodeCssClass(element, connectClass, allowDrop);
-          }
-
-          //attach meta-data
-          $(element).data("ko_sortList", templateOptions.foreach);
-          $(element).sortable(ko.utils.extend(options, {
-              update: function(event, ui) {
-                  var sourceParent, targetParent, targetIndex, arg,
-                      item = ui.item.data("ko_sortItem");
-
-                  if (item) {
-                      //identify parents
-                      sourceParent = ui.item.data("ko_parentList");
-                      targetParent = ui.item.parent().data("ko_sortList");
-                      targetIndex = ko.utils.arrayIndexOf(ui.item.parent().children(), ui.item[0]);
-
-                      if (beforeMove || afterMove) {
-                          arg = {
-                              item: item,
-                              sourceParent: sourceParent,
-                              sourceIndex: sourceParent.indexOf(item),
-                              targetParent: targetParent,
-                              targetIndex: targetIndex,
-                              cancelDrop: false
-                          };
-                      }
-
-                      if (beforeMove) {
-                          beforeMove.call(this, arg, event, ui);
-                          if (arg.cancelDrop) {
-                              $(ui.sender).sortable('cancel');
-                              return;
-                          }
-                      }
-
-                      if (targetIndex >= 0) {
-                          sourceParent.remove(item);
-                          targetParent.splice(targetIndex, 0, item);
-                      }
-                      //rendering is handled by manipulating the observableArray; ignore
dropped element
-                      ui.item.remove();
-
-                      //allow binding to accept a function to execute after moving the item
-                      if (afterMove) {
-                         afterMove.call(this, arg, event, ui);
-                      }
-                  }
-              },
-              connectWith: "." + connectClass
-          }));
-
-          //handle disposal
-          ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
-              $(element).sortable("destroy");
-          });
-          //we are wrapping the template binding
-          return ko.bindingHandlers.template.init(element, function() { return templateOptions;
}, allBindingsAccessor, data, context);
-      },
-      update: function(element, valueAccessor, allBindingsAccessor, data, context) {
-          var templateOptions = prepareTemplateOptions(valueAccessor);
-
-          //call the actual template binding
-          ko.bindingHandlers.template.update(element, function() { return templateOptions;
}, allBindingsAccessor, data, context);
-      },
-      afterRender: function(elements, data) {
-          ko.utils.arrayForEach(elements, function(element) {
-              if (element.nodeType === 1) {
-                  $(element).data("ko_sortItem", data);
-                  $(element).data("ko_parentList", $(element).parent().data("ko_sortList"));
-              }
-          });
-      },
-      connectClass: 'ko_container',
-      allowDrop: true,
-      afterMove: null,
-      beforeMove: null,
-      options: {}
-  };
-})(ko, jQuery);
-
-})
\ No newline at end of file
+});

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
Tue Oct 16 11:54:21 2012
@@ -10,8 +10,16 @@
 //  ... etc
 
 
-define("knockout.simpleGrid",["jquery","utils","i18n","knockout"], function() {
-(function (ko, $) {
+
+  (function(factory) {
+      if (typeof define === "function" && define.amd) {
+          // AMD anonymous module
+          define("knockout.simpleGrid",["jquery","knockout","utils","i18n"], factory);
+      } else {
+          // No module loader (plain <script> tag) - put directly in global namespace
+          factory(window.ko, jQuery);
+      }
+  })(function ($,ko,utils,i18n) {
 
 
       ko.simpleGrid = {
@@ -73,6 +81,5 @@ define("knockout.simpleGrid",["jquery","
             if (viewModel.pageLinksUpdateCallBack) viewModel.pageLinksUpdateCallBack();
           }
       };
-})(ko, jQuery);
+})
 
-})
\ No newline at end of file

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js
Tue Oct 16 11:54:21 2012
@@ -17,7 +17,7 @@
  * under the License.
  */
 define("redback",["jquery","utils","jquery.validate","jquery.json","knockout",
-  "knockout.simpleGrid","redback.roles","redback.user","redback.users"], function() {
+  "knockout.simpleGrid","redback.roles","redback.user","redback.users"], function(jquery,utils,jqueryValidate,jqueryJson,ko)
{
 
   // define a container object with various datas
   window.redbackModel = {userOperationNames:null,key:null,i18n:$.i18n.map};

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
Tue Oct 16 11:54:21 2012
@@ -16,7 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-define("redback.roles",["jquery","utils","i18n","jquery.validate","knockout","knockout.simpleGrid"],
function() {
+define("redback.roles",["jquery","utils","i18n","jquery.validate","knockout","knockout.simpleGrid"],
+function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
 
   Role = function(name,description,assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers){
 

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
Tue Oct 16 11:54:21 2012
@@ -16,7 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","knockout.simpleGrid"],
function() {
+define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","knockout.simpleGrid"],
+function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
 
   /**
    * object model for user with some function to create/update/delete users

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js?rev=1398751&r1=1398750&r2=1398751&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js
Tue Oct 16 11:54:21 2012
@@ -16,7 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-define("redback.users",["jquery","utils","i18n","jquery.validate","knockout","knockout.simpleGrid"],
function() {
+define("redback.users",["jquery","utils","i18n","jquery.validate","knockout","knockout.simpleGrid"],
+function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
 
   /**
    * view model used for users grid



Mime
View raw message