[Rt-commit] rt branch, 4.2/remove-js-selectbox, created. rt-4.0.5-282-gbb07649

Alex Vandiver alexmv at bestpractical.com
Tue May 7 15:14:36 EDT 2013


The branch, 4.2/remove-js-selectbox has been created
        at  bb07649938f726308d0697ff6a3fb45c5fe08ab3 (commit)

- Log -----------------------------------------------------------------
commit bb07649938f726308d0697ff6a3fb45c5fe08ab3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Apr 2 21:06:09 2012 -0400

    Remove old js selectbox code that was disabled everywhere
    
    This code currently serves no purpose, and could be much simpler written
    using modern JS tools if we needed the functionality.

diff --git a/share/html/Admin/Global/DashboardsInMenu.html b/share/html/Admin/Global/DashboardsInMenu.html
index c57a41a..715fd0f 100644
--- a/share/html/Admin/Global/DashboardsInMenu.html
+++ b/share/html/Admin/Global/DashboardsInMenu.html
@@ -48,13 +48,11 @@
 <& /Admin/Elements/Header, Title => loc("Dashboards in menu") &>
 <& /Elements/Tabs &>
 
-<& /Widgets/SelectionBox:header, nojs => 1 &>
-
 <& /Elements/ListActions, actions => \@actions &>
 <br />
 % for my $pane (@panes) {
 <&|/Widgets/TitleBox, title => loc('Dashboards in menu'), bodyclass => "" &>
-<& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &></&>
+<& /Widgets/SelectionBox:show, self => $pane &></&>
 <br />
 % }
 <%init>
@@ -107,7 +105,7 @@ my @panes = $m->comp(
     }
 );
 
-$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
     for @panes;
 
 
diff --git a/share/html/Admin/Global/MyRT.html b/share/html/Admin/Global/MyRT.html
index fd69617..7ada784 100644
--- a/share/html/Admin/Global/MyRT.html
+++ b/share/html/Admin/Global/MyRT.html
@@ -48,13 +48,11 @@
 <& /Admin/Elements/Header, Title => loc("RT at a glance") &>
 <& /Elements/Tabs &>
 
-<& /Widgets/SelectionBox:header, nojs => 1 &>
-
 <& /Elements/ListActions, actions => \@actions &>
 <br />
 % for my $pane (@panes) {
 <&|/Widgets/TitleBox, title => loc('RT at a glance').': '.loc($pane->{Name}), bodyclass => "" &>
-<& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &></&>
+<& /Widgets/SelectionBox:show, self => $pane &></&>
 <br />
 % }
 <%init>
@@ -104,7 +102,7 @@ my @panes = $m->comp(
     }
 );
 
-$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
     for @panes;
 
 
diff --git a/share/html/Admin/Users/DashboardsInMenu.html b/share/html/Admin/Users/DashboardsInMenu.html
index 4959626..19db2ec 100644
--- a/share/html/Admin/Users/DashboardsInMenu.html
+++ b/share/html/Admin/Users/DashboardsInMenu.html
@@ -48,8 +48,6 @@
 <& /Admin/Elements/Header, Title => $title  &>
 <& /Elements/Tabs &>
 
-<& /Widgets/SelectionBox:header, nojs => 1 &>
-
 <& /Elements/ListActions, actions => \@actions &>
 
 <form method="post" action="DashboardsInMenu.html">
@@ -62,7 +60,7 @@
 
 % for my $pane (@panes) {
 <&|/Widgets/TitleBox, title => loc('Dashboards in menu'), bodyclass => "" &>
-<& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &></&>
+<& /Widgets/SelectionBox:show, self => $pane &></&>
 <br />
 % }
 
@@ -111,7 +109,7 @@ my @panes = $m->comp(
 );
 
 
-$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
     for @panes;
 
 </%init>
diff --git a/share/html/Admin/Users/MyRT.html b/share/html/Admin/Users/MyRT.html
index 2512a74..90ac68b 100644
--- a/share/html/Admin/Users/MyRT.html
+++ b/share/html/Admin/Users/MyRT.html
@@ -48,8 +48,6 @@
 <& /Admin/Elements/Header, Title => $title  &>
 <& /Elements/Tabs &>
 
-<& /Widgets/SelectionBox:header, nojs => 1 &>
-
 <& /Elements/ListActions, actions => \@actions &>
 
 <form method="post" action="MyRT.html">
@@ -62,7 +60,7 @@
 
 % for my $pane (@panes) {
 <&|/Widgets/TitleBox, title => loc('RT at a glance').': '.loc($pane->{Name}), bodyclass => "" &>
-<& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &></&>
+<& /Widgets/SelectionBox:show, self => $pane &></&>
 <br />
 % }
 
@@ -119,7 +117,7 @@ my @panes = $m->comp(
     }
 );
 
-$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
     for @panes;
 
 </%init>
diff --git a/share/html/Dashboards/Queries.html b/share/html/Dashboards/Queries.html
index c005031..c95733b 100644
--- a/share/html/Dashboards/Queries.html
+++ b/share/html/Dashboards/Queries.html
@@ -48,8 +48,6 @@
 <& /Elements/Header, Title => $title &>
 <& /Elements/Tabs &>
 
-<& /Widgets/SelectionBox:header, nojs => 1 &>
-
 <& /Elements/ListActions, actions => \@results &>
 
 <& Elements/Deleted, searches => \@deleted, Dashboard => $Dashboard &>
@@ -65,7 +63,7 @@
 
 <&| /Widgets/TitleBox, title => $pane->{DisplayName} &>
 % my ( $pane_name ) = $pane->{Name} =~ /Searches-(.+)/;
-    <& /Widgets/SelectionBox:show, self => $pane, nojs => 1, grep( {
+    <& /Widgets/SelectionBox:show, self => $pane, grep( {
             $_->{pane} eq $pane_name} @deleted ) ? ( ShowUpdate => 1 ) : () &>
 </&>
 </form>
@@ -265,7 +263,7 @@ for my $pane (keys %pane_name) {
     push @panes, $sel;
 }
 
-$m->comp('/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1)
+$m->comp('/Widgets/SelectionBox:process', %ARGS, self => $_ )
     for @panes;
 
 my @hidden_searches = $Dashboard->PossibleHiddenSearches;
diff --git a/share/html/NoAuth/js/class.js b/share/html/NoAuth/js/class.js
deleted file mode 100644
index b823c69..0000000
--- a/share/html/NoAuth/js/class.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/* by TKirby, released under GPL */
-
- function _ClassSetup(Object) {
-  this.prototype	= Object;
-  return this;
- }
- 
- function Class(name) {
-  var _newclass_;
-  eval("window."+name+"	= new Function('this."+name+".apply(this,arguments);');");
-  eval("window."+name+".define = _ClassSetup;");
-  eval("_newclass_ = window."+name+";");
-  return _newclass_;
- }
-
diff --git a/share/html/NoAuth/js/list.js b/share/html/NoAuth/js/list.js
deleted file mode 100644
index feb5527..0000000
--- a/share/html/NoAuth/js/list.js
+++ /dev/null
@@ -1,112 +0,0 @@
-/* by TKirby, released under GPL */
-/* Define the "list" Class */
-Class("list").define({
- name : null,
- xml  : null,
- sels : null,
- list : function (src, esrc, name) { this.init(src, esrc, name); },
- read : function () {
-     var i		= 0;
-     if(this.xml.readyState!=4) { setTimeout(this.name+".read()", 100); }
-     else if(this.xml.status!=200) alert("Document not available.");
-     else {
-	 var doc	= this.xml.responseXML;
-	 var nNode	= null;
-	 if(doc.childNodes[0].nodeName=="parseerror") alert("Parse Error.");
-	 doc		= doc.getElementsByTagName("list")[0];
-	 for(i=0;i<doc.childNodes.length;i++) {
-	     if(doc.childNodes[i].childNodes.length>0) {
-		 nNode	= document.createElement("option");
-		 nNode.appendChild(document.createTextNode(doc.childNodes[i].childNodes[0].nodeValue));
-		 this.sels[0].appendChild(nNode);
-	     }
-	 }
-     }
- },
-     
- init : function (src,esrc,name) {
-     if(!src) return;
-     this.name		= name;
-     this.sels		= new Array();
-     var i			= 0;
-     for(i=0;i<src.childNodes.length;i++) {
-	 if(src.childNodes[i].nodeName=="select" || src.childNodes[i].nodeName=="SELECT") {
-	     this.sels.push(src.childNodes[i]);
-	 } 
-
-	 if((src.childNodes[i].nodeName=="input" || src.childNodes[i].nodeName=="INPUT")
-	    && (src.childNodes[i].name=="fromjs")) {
-	     src.childNodes[i].value = 1;
-	 }
-
-	 if((src.childNodes[i].nodeName=="input" || src.childNodes[i].nodeName=="INPUT")
-	    && (src.childNodes[i].type=="submit" || src.childNodes[i].type=="SUBMIT")) {
-
-	     if (src.childNodes[i].name.indexOf("Save") < 0) {
-		 var tmp	= document.createElement("input");
-		 tmp.type	= "button";
-		 tmp.name	= src.childNodes[i].name;
-		 tmp.value	= src.childNodes[i].value;
-		 src.replaceChild(tmp,src.childNodes[i]);
-	     }
-
-	     if(src.childNodes[i].name=="add")
-		 src.childNodes[i].onclick = new Function(this.name+".add();");
-	     if(src.childNodes[i].name=="remove") 
-		 src.childNodes[i].onclick = new Function(this.name+".remove();");
-	     if(src.childNodes[i].name=="moveup") 
-		 src.childNodes[i].onclick = new Function(this.name+".moveup();");
-	     if(src.childNodes[i].name=="movedown") 
-		 src.childNodes[i].onclick = new Function(this.name+".movedown();");
-	 } 
-     }
-     if (esrc) {
-	 this.xml	= (window.navigator.appName!="Microsoft Internet Explorer"
-			   ?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP"));
-	 this.xml.open("GET", esrc);
-	 this.xml.send("");
-	 setTimeout(this.name+".read()", 100);
-     }
- },
-     
- add : function() {
-     var i, j 	= 0;
-     var dNode	= null;
-     for(i=0;i<this.sels[0].length;i++) if(this.sels[0][i].selected) {
-	 for(j=0;j<this.sels[1].length;j++) if(this.sels[1][j].value==this.sels[0][i].value) break;
-	 if(j==this.sels[1].length) dNode	= this.sels[0][i].cloneNode(true), 
-					this.sels[1].appendChild(dNode);
-     }
- },
-
- moveup : function() { this.move(-1); },
- movedown : function() { this.move(1); },
- move : function(v) {
-  var i		= 0;
-  if(v<0) for(i=0;i<this.sels[1].length;i++) this.moveOne(v, i);
-  else if(v>0) for(i=this.sels[1].length-1;i>=0;i--)this.moveOne(v, i);
- },
-
- moveOne : function(v, i) {
-  var ins	= v + i;
-  if(ins<0 || ins>=this.sels[1].length) return;
-  if(this.sels[1][ins].selected) return;
-  if(this.sels[1][i].selected) {
-   Node		= this.sels[1][i];
-   this.sels[1].removeChild(Node);
-   this.sels[1].insertBefore(Node, this.sels[1][ins]);
-  }
- },
-
- remove : function() {
-  var i		= 0;
-  for(i=this.sels[1].length-1;i>=0;i--) if(this.sels[1][i].selected) 
-   this.sels[1].removeChild(this.sels[1][i]);
- },
-
- selectAll: function() {
-  var i		= 0;
-  for(i=0;i<this.sels[0].length;i++) this.sels[0][i].selected = false;
-  for(i=0;i<this.sels[1].length;i++) this.sels[1][i].selected = true;
- }
-});
diff --git a/share/html/Prefs/DashboardsInMenu.html b/share/html/Prefs/DashboardsInMenu.html
index 66dbc99..e78defe 100644
--- a/share/html/Prefs/DashboardsInMenu.html
+++ b/share/html/Prefs/DashboardsInMenu.html
@@ -50,9 +50,6 @@
 &>
 <& /Elements/ListActions, actions => \@results &>
 
-<& /Widgets/SelectionBox:header, nojs => 1 &>
-
-
 <br />
 
 % for my $pane ( @panes ) {
@@ -60,7 +57,7 @@
     title => loc('Dashboards in menu'),
     bodyclass => ""
 &>
-<& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &>
+<& /Widgets/SelectionBox:show, self => $pane &>
 </&>
 % }
 
@@ -109,7 +106,7 @@ my @panes = $m->comp(
     }
 );
 
-$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
     for @panes;
 
 </%INIT>
diff --git a/share/html/Prefs/MyRT.html b/share/html/Prefs/MyRT.html
index 648737f..9a4d650 100644
--- a/share/html/Prefs/MyRT.html
+++ b/share/html/Prefs/MyRT.html
@@ -50,9 +50,6 @@
 &>
 <& /Elements/ListActions, actions => \@results &>
 
-<& /Widgets/SelectionBox:header, nojs => 1 &>
-
-
 <br />
 
 % for my $pane ( @panes ) {
@@ -60,7 +57,7 @@
     title => loc('RT at a glance') .': '. loc( $pane->{Name} ),
     bodyclass => ""
 &>
-<& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &>
+<& /Widgets/SelectionBox:show, self => $pane &>
 </&>
 % }
 
@@ -160,7 +157,7 @@ my @panes = $m->comp(
     }
 );
 
-$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
     for @panes;
 
 </%INIT>
diff --git a/share/html/Widgets/SelectionBox b/share/html/Widgets/SelectionBox
index 979adc9..f94ead2 100644
--- a/share/html/Widgets/SelectionBox
+++ b/share/html/Widgets/SelectionBox
@@ -49,9 +49,6 @@
 %# 
 %# SYNOPSIS
 %#
-%# include javascript:
-%# <& /Widgets/SelectionBox:header &>
-%#
 %# <%init>:
 %# my $sel = $m->comp ('/Widgets/SelectionBox:new',
 %#		  Action => me.html',
@@ -71,17 +68,7 @@
 %# <& /Widgets/SelectionBox:show, self => $sel &>
 %#
 %# if the SelectionBox is created with AutoSave option, OnSubmit will be called
-%# on every button clicked in non-js mode.
-<%method header>
-% unless ($nojs) {
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/class.js"></script>
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/list.js"></script>
-% }
-<%ARGS>
-$nojs => 0
-</%ARGS>
-</%method>
-
+%# on every button clicked
 <%method new>
 <%init>
 $ARGS{_item_map} = {map {$_->[0] => $_->[1]} @{$ARGS{Available}}};
@@ -103,56 +90,51 @@ if ($self->{Selected} && !ref($self->{Selected})) {
     $self->{Selected} = [$self->{Selected}];
 }
 
-if ($ARGS{fromjs}) {
-    $self->{Current} = $self->{Selected};
+my $current = $self->{Current} = $ARGS{$self->{Name}.'-Current'};
+if ($current && !ref ($current)) {
+    $current = [$current];
 }
-else {
-    my $current = $self->{Current} = $ARGS{$self->{Name}.'-Current'};
-    if ($current && !ref ($current)) {
-        $current = [$current];
-    }
 
-    unless ($self->{ReadOnly}) {
-        ++$self->{Modified};
-        if ($ARGS{add}) {
-            my $choosed = $ARGS{$self->{Name}.'-Available'};
-            for my $add (ref($choosed) ? @$choosed : $choosed) {
-                next if grep { $_ eq $add } @$current;
-                push @$current, $add;
-            }
+unless ($self->{ReadOnly}) {
+    ++$self->{Modified};
+    if ($ARGS{add}) {
+        my $choosed = $ARGS{$self->{Name}.'-Available'};
+        for my $add (ref($choosed) ? @$choosed : $choosed) {
+            next if grep { $_ eq $add } @$current;
+            push @$current, $add;
         }
+    }
 
-        if ($ARGS{remove}) {
-            my $choosed = $ARGS{$self->{Name}.'-Selected'};
-            for my $del (ref($choosed) ? @$choosed : $choosed) {
-                @$current = map { $_ eq $del ? () : $_ } @$current;
-            }
+    if ($ARGS{remove}) {
+        my $choosed = $ARGS{$self->{Name}.'-Selected'};
+        for my $del (ref($choosed) ? @$choosed : $choosed) {
+            @$current = map { $_ eq $del ? () : $_ } @$current;
         }
+    }
 
-        if ($ARGS{moveup} or $ARGS{movedown}) {
-            my $offset = $ARGS{moveup} ? 1 : 0;
-            my $choosed = $ARGS{$self->{Name}.'-Selected'};
-            $choosed = [$choosed] unless ref ($choosed);
-            my $canmove = 0; # not in the cornor
-            for my $i ($ARGS{moveup} ? 0..$#{$current} : reverse 0..$#{$current}) {
-                if (grep {$_ eq $current->[$i]} @$choosed) {
-                if ($canmove) {
-                    splice (@$current, $i-$offset, 2,
-                        @{$current}[$i+1-$offset,$i-$offset]);
-                }
-                }
-                else {
-                ++$canmove;
-                }
+    if ($ARGS{moveup} or $ARGS{movedown}) {
+        my $offset = $ARGS{moveup} ? 1 : 0;
+        my $choosed = $ARGS{$self->{Name}.'-Selected'};
+        $choosed = [$choosed] unless ref ($choosed);
+        my $canmove = 0; # not in the cornor
+        for my $i ($ARGS{moveup} ? 0..$#{$current} : reverse 0..$#{$current}) {
+            if (grep {$_ eq $current->[$i]} @$choosed) {
+            if ($canmove) {
+                splice (@$current, $i-$offset, 2,
+                    @{$current}[$i+1-$offset,$i-$offset]);
+            }
+            }
+            else {
+            ++$canmove;
             }
         }
+    }
 
-        if ($ARGS{clear}) {
-            $current = [];
-        }
-
-        $self->{Current} = $current;
+    if ($ARGS{clear}) {
+        $current = [];
     }
+
+    $self->{Current} = $current;
 }
 
 @{$self->{Current}} = grep { exists $self->{_item_map}{$_} } @{$self->{Current}};
@@ -182,14 +164,9 @@ $self => undef
 </%method>
 
 <%method show>
-<form method="post" action="<%$self->{Action}%>" name="SelectionBox-<% $name %>" id="SelectionBox-<% $name %>"
-% unless ($nojs) {
-onsubmit="list_<% $name %>.selectAll();"
-% }
->
+<form method="post" action="<%$self->{Action}%>" name="SelectionBox-<% $name %>" id="SelectionBox-<% $name %>">
 <input type="hidden" class="hidden" name="<% $self->{Name} %>-Submit" value="1" />
 <& SelectionBox:current, self => $self &>
-<input type="hidden" class="hidden" name="fromjs" value="0" />
 <&|/l&>Available</&>:
 <br />
 <select name="<%$name%>-Available" id="<%$name%>-Available" size="<%$size%>" multiple="multiple">
@@ -234,17 +211,9 @@ selected="selected"
 % }
 </form>
 
-% unless ($nojs) {
-<script type="text/javascript">
-//<![CDATA[
-var list_<%$name%> = new list(document.getElementById("SelectionBox-<% $name %>"), 0, "list_<%$name%>");
-//]]>
-</script>
-% }
 <%ARGS>
 $self => undef
 $size => 10
-$nojs => 0
 </%ARGS>
 <%INIT>
 my $name = $self->{Name};

-----------------------------------------------------------------------


More information about the Rt-commit mailing list