[geeklog-cvs] geeklog: Fixed indexing issues related to bug 0001074

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Fri Apr 16 12:07:01 EDT 2010


changeset 7882:922bafd5b86e
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/922bafd5b86e
user: stan <stan at spalatnik.com>
date: Fri Apr 16 12:06:49 2010 -0400
description:
Fixed indexing issues related to bug 0001074

diffstat:

 public_html/javascript/configmanager.js                           |  21 +++++++++-
 public_html/layout/professional/admin/config/config_element.thtml |   2 +-
 system/classes/config.class.php                                   |   5 ++
 3 files changed, 25 insertions(+), 3 deletions(-)

diffs (58 lines):

diff -r 2d1bc9ff9534 -r 922bafd5b86e public_html/javascript/configmanager.js
--- a/public_html/javascript/configmanager.js	Thu Apr 08 20:35:11 2010 +0200
+++ b/public_html/javascript/configmanager.js	Fri Apr 16 12:06:49 2010 -0400
@@ -93,8 +93,25 @@
 }
 
 function gl_cfg_remove(self){
- cell = self.parentNode.parentNode;
- cell.parentNode.removeChild(cell);
+ var tableRow = self.parentNode.parentNode;
+ var tableBody = tableRow.parentNode;
+ var table = tableBody.parentNode;
+ var index = 0;
+ tableBody.removeChild(tableRow);
+ // reindex numerical lists
+ if (table.className.match(new RegExp('(\\s|^)numerical_config_list(\\s|$)'))) {
+  for (var i = 0; i < tableBody.childNodes.length; i += 1) {
+   if (tableBody.childNodes[i].tagName == "TR"
+       && tableBody.childNodes[i].childNodes[0].childNodes[0].nodeName == "#text") {
+     var textNode = tableBody.childNodes[i].childNodes[0].childNodes[0];
+     if (!isNaN(parseInt(textNode.nodeValue))) {
+       textNode.nodeValue = '' + index;
+       index += 1;
+     }
+   }
+  }
+ }
+ 
 }
 
 function add_array(tbl, arr_name, arr_index, key_names, arr_type, deletable){
diff -r 2d1bc9ff9534 -r 922bafd5b86e public_html/layout/professional/admin/config/config_element.thtml
--- a/public_html/layout/professional/admin/config/config_element.thtml	Thu Apr 08 20:35:11 2010 +0200
+++ b/public_html/layout/professional/admin/config/config_element.thtml	Fri Apr 16 12:06:49 2010 -0400
@@ -49,7 +49,7 @@
 <input type="button" value="+" onclick="hide_show_tbl(selectChildByID(this.parentNode, 'arr_table'), this);"{xhtml}>
 {delete}
 <input type="hidden" value="true" name="{name}[placeholder]"{xhtml}>
-<table style="display:none" id="arr_table">
+<table style="display:none" id="arr_table" class="{arr_table_class_list}">
 <col width="100">
 <col width="100%">
 {my_elements}
diff -r 2d1bc9ff9534 -r 922bafd5b86e system/classes/config.class.php
--- a/system/classes/config.class.php	Thu Apr 08 20:35:11 2010 +0200
+++ b/system/classes/config.class.php	Fri Apr 16 12:06:49 2010 -0400
@@ -756,6 +756,11 @@
                                 true);
             }
             $t->set_var('my_elements', $result);
+            // if the values are indexed numerically, add a class to the table
+            // for identification. The UI code can take advantage of it
+            if ($val === array_values($val)) {
+                $t->set_var('arr_table_class_list', 'numerical_config_list');
+            }
             return $t->parse('output', 'list-element');
         }
     }



More information about the geeklog-cvs mailing list