[Rt-commit] rt branch, 4.2/remove-js-selectbox, created. rt-4.1.8-477-gb4b1ec4

Ruslan Zakirov ruz at bestpractical.com
Fri May 24 15:37:37 EDT 2013


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

- Log -----------------------------------------------------------------
commit b4b1ec48c0bdf8e2d7c57dfcb222134cb16c65f5
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 22635f8..60e19d6 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 baa85b1..8f581b2 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 59ace2f..47063e0 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 d3befe9..7825a69 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 2b0a73e..16fbbcf 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>
@@ -268,7 +266,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/Prefs/DashboardsInMenu.html b/share/html/Prefs/DashboardsInMenu.html
index e471f72..d6d2e35 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 64de2af..368e11d 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 &>
 </&>
 % }
 
@@ -161,7 +158,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 1545d7e..6ee8ca7 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')%>/static/js/class.js"></script>
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/static/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};
diff --git a/share/static/js/class.js b/share/static/js/class.js
deleted file mode 100644
index b823c69..0000000
--- a/share/static/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/static/js/list.js b/share/static/js/list.js
deleted file mode 100644
index feb5527..0000000
--- a/share/static/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;
- }
-});

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


More information about the Rt-commit mailing list