OSDN Git Service

setup spinelz environment
[cloudmanganw/git_repo.git] / war / WEB-INF / classes / jp / sourceforge / manganetwork / page / javascripts / spinelz / selectableTable.js
index a470e42..6b67ad9 100644 (file)
-// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
-// 
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-var SelectableTable = Class.create();
-
-SelectableTable.classNames = {
-  table:        'selectableTable_table',
-  tr:           'selectableTable_tr',
-  trHover:      'selectableTable_trHover',
-  trSelected:   'selectableTable_trSelected'
-}
-
-SelectableTable.prototype = {
-  initialize: function(element) {
-    this.element = $(element);
-    Element.setStyle(this.element, {visibility: 'hidden'});
-    var defaultOptions  = {
-      arrayDefaultData:                 [],
-      flagAllowUnselect:                true,
-      flagInitialAllowMultiple:         false,
-      flagKeypressAvailable:            false,
-      flagKeypressDeleteAvailable:      false,
-      flagKeypressInsertAvailable:      false,
-      functionPostAdd:                  Prototype.emptyFunction,
-      functionPostDelete:               Prototype.emptyFunction,
-      functionPostPressLeft:            Prototype.emptyFunction,
-      functionPostPressRight:           Prototype.emptyFunction,
-      functionPostSelect:               Prototype.emptyFunction,
-      functionPostUnselect:             Prototype.emptyFunction,
-      functionPreAdd:                   function() {return true;},
-      functionPreDelete:                function() {return true;},
-      functionSubmit:                   Prototype.emptyFunction,
-      initialSelected:                  null,
-      prefixTrId:                       'selectable_table_',
-      prefixCSS:                        'custom_'
-    }
-    this.options                = Object.extend(defaultOptions, arguments[1] || {});
-    this.classNames             = new CssUtil([SelectableTable.classNames, CssUtil.appendPrefix(this.options.prefixCSS, SelectableTable.classNames)]);
-    this.documentListener       = this.eventKeypress.bindAsEventListener(this);
-    this.flagAllowMultiple      = this.options.flagInitialAllowMultiple;
-    this.flagAvailable          = true;
-    this.focused                = null;
-    this.lastSelected           = null;
-    this.newNumber              = 1;
-    this.selected               = new Object();
-    this.build();
-    if(arguments[2]) {
-      this.selectEffect(this.buildTrId(arguments[2]));
-    }
-    Element.setStyle(this.element, {visibility: 'visible'});
-  },
-
-  add: function() {
-    if(!this.flagAvailable) {return;}
-    if(!this.options.functionPreAdd(this)) {return;}
-    if(arguments[0] == null) {arguments[0] = this.options.arrayDefaultData;}
-    if(typeof(arguments[0]) != 'string') {
-      arguments = arguments[0];
-    }
-    if(arguments[0] == null) {return;}
-    var objTr, objTd;
-    objTr = document.createElement('tr');
-    objTr.id = 'new_' + this.newNumber;
-    this.buildTr(objTr);
-    for(var i = 0; i < arguments.length; i++) {
-      objTd = document.createElement('td');
-      objTd.innerHTML = arguments[i];
-      objTr.appendChild(objTd);
-    }
-    this.element.tBodies[0].appendChild(objTr);
-    this.newNumber++;
-    this.options.functionPostAdd(this);
-  },
-
-  build: function() {
-    var lines = this.element.tBodies[0].rows;
-    this.classNames.addClassNames(this.element, 'table');
-    Event.observe(document, 'keypress', this.documentListener);
-    for(var i = 0; i < lines.length; i++) {
-      this.buildTr(lines[i]);
-    }
-    var selected = this.options.initialSelected
-    if(selected) {
-      this.selectEffect(this.buildTrId(selected));
-    }
-  },
-
-  buildTr: function(objTr) {
-    objTr.id = this.buildTrId(objTr.id);
-    this.classNames.addClassNames(objTr, 'tr');
-    Event.observe(objTr, 'click',     this.eventClick.bindAsEventListener(this));
-    Event.observe(objTr, 'dblclick',  this.eventDoubleClick.bindAsEventListener(this));
-    Event.observe(objTr, 'mouseout',  this.eventFocusOut.bindAsEventListener(this));
-    Event.observe(objTr, 'mouseover', this.eventFocusOver.bindAsEventListener(this));
-  },
-
-  buildTrId: function(strId) {
-    return this.options.prefixTrId + strId
-  },
-
-  deleteAll: function() {
-    if(!this.flagAvailable) {return;}
-    if(!this.options.functionPreDelete(this)) {return;}
-    for(var trId in this.selected) {
-      this.element.tBodies[0].removeChild($(trId));
-      delete this.selected[trId];
-    }
-    this.focused = null;
-    this.options.functionPostDelete(this);
-  },
-
-  eventClick: function(event) {
-    if(!this.flagAvailable) {return;}
-    if(event.shiftKey) {
-      this.selectOrUnselectRange(Event.findElement(event, 'tr').id);
-    } else {
-      this.selectOrUnselect(Event.findElement(event, 'tr').id, event.ctrlKey);
-    }
-  },
-
-  eventDoubleClick: function(event) {
-    if(!this.flagAvailable) {return;}
-    if(this.flagAllowMultiple) {
-      this.select(Event.findElement(event, 'tr').id, false);
-      this.submit();
-    }
-  },
-
-  eventFocusOut: function(event) {
-    if(!this.flagAvailable) {return;}
-    this.focusOff();
-  },
-
-  eventFocusOver: function(event) {
-    if(!this.flagAvailable) {return;}
-    this.focusOn(Event.findElement(event, 'tr').id);
-    Event.findElement(event, 'tr').focus();
-  },
-
-  eventKeypress: function(event) {
-    if(!this.flagAvailable) {return;}
-    if(!this.options.flagKeypressAvailable) {return;}
-    switch(event.keyCode) {
-      case 13: //Enter
-        if(event.shiftKey) {
-          this.selectOrUnselectRange(this.focused);
-        } else {
-          this.selectOrUnselect(this.focused, event.ctrlKey);
-        }
-        break;
-      case 37: //Left
-        this.options.functionPostPressLeft(this);
-        break;
-      case 38: //Up
-        this.focusMove('up');
-        break;
-      case 39: //Right
-        this.options.functionPostPressRight(this);
-        break;
-      case 40: //Down
-        this.focusMove('down');
-        break;
-      case 45: //Insert
-        if(this.options.flagKeypressInsertAvailable) {this.add();}
-        break;
-      case 46: //Delete
-        if(this.options.flagKeypressDeleteAvailable) {this.deleteAll();}
-        break;
-    }
-  },
-
-  focusMove: function(direction) {
-    if(!this.flagAvailable) {return;}
-    if(this.focused == null) {
-      this.focusOn(this.element.tBodies[0].rows[0].id);
-    } else {
-      var rowIndex = $(this.focused).rowIndex;
-      var correctionValue, flagEdge;
-      switch(direction) {
-        case 'down':
-          correctionValue = 1;
-          flagEdge = this.isBottom(rowIndex);
-          break;
-        case 'up':
-          correctionValue = -1;
-          flagEdge = this.isTop(rowIndex);
-          break;
-      }
-      if(!flagEdge) {
-        this.focusOn(this.element.rows[rowIndex + correctionValue].id);
-      }
-    }
-  },
-
-  focusOff: function() {
-    if(!this.flagAvailable) {return;}
-    if(this.focused != null) {
-      var objTr = $(this.focused);
-      this.classNames.removeClassNames(objTr, 'trHover');
-      this.focused = null;
-    }
-  },
-
-  focusOn: function(trId) {
-    if(!this.flagAvailable) {return;}
-    if($(trId) != null) {
-      this.focusOff();
-      this.classNames.addClassNames($(trId), 'trHover');
-      this.focused = trId;
-    }
-  },
-
-  getSelected: function() {
-    var selectedIdList  = new Array();
-    for(var trId in this.selected) {
-      selectedIdList.push(trId.replace(this.options.prefixTrId, ''));
-    }
-    return selectedIdList;
-  },
-
-  getSelectedElement: function(id) {
-    var trId = this.options.prefixTrId + id;
-    return $(trId)
-  },
-
-  isBottom: function(rowIndex) {
-    return (rowIndex == this.element.rows.length - 1) ? true : false;
-  },
-
-  isTop: function(rowIndex) {
-    return (rowIndex == this.element.tBodies[0].rows[0].rowIndex) ? true : false;
-  },
-
-  makeAvailable: function() {
-    this.flagAvailable = true;
-  },
-
-  makeMultiple: function() {
-    this.flagAllowMultiple = true;
-  },
-
-  makeSingular: function() {
-    this.flagAllowMultiple = false;
-    this.unselectAll();
-  },
-
-  makeUnavailable: function() {
-    this.flagAvailable = false;
-  },
-
-  removeEventFromDocument: function() {
-    Event.stopObserving(document, 'keypress', this.documentListener);
-  },
-
-  select: function(trId, ctrl) {
-    if(!this.flagAvailable) {return;}
-    this.selectEffect(trId, ctrl);
-    this.lastSelected = trId;
-    this.options.functionPostSelect(this);
-    if(!this.flagAllowMultiple) {
-      this.submit();
-    }
-  },
-
-  selectAll: function() {
-    if(!this.flagAvailable) {return;}
-    if(!this.flagAllowMultiple) {return;}
-    this.selected = new Object();
-    var lines = this.element.tBodies[0].rows;
-    for(var i = 0; i < lines.length; i++) {
-      this.select(lines[i].id, true);
-    }
-  },
-
-  selectEffect: function(trId, ctrl) {
-    if($(trId)) {
-      if(!this.flagAllowMultiple || !ctrl) {
-        this.unselectAll();
-      }
-      this.classNames.addClassNames($(trId), 'trSelected');
-      this.selected[trId] = true;
-    }
-  },
-
-  selectOrUnselect: function(trId, ctrl) {
-    if(!this.flagAvailable) {return;}
-    if(trId == null) {return;}
-    if(ctrl && this.selected[trId]) {
-      if(!this.flagAllowMultiple && !this.options.flagAllowUnselect) {return;}
-      this.unselect(trId);
-    } else {
-      this.select(trId, ctrl);
-    }
-  },
-
-  selectOrUnselectRange: function(trId) {
-    if(!this.flagAvailable) {return;}
-    if(trId == null) {return;}
-    if(this.lastSelected == null || this.lastSelected == trId) {
-      this.selectOrUnselect(trId);
-      return;
-    }
-    var flagSelect = false;
-    var lines = this.element.tBodies[0].rows;
-    var lastSelected = this.lastSelected
-    for(var i = 0; i < lines.length; i++) {
-      if(lines[i].id == trId || lines[i].id == lastSelected) {
-        flagSelect = (flagSelect) ? false : true;
-      } else if(!flagSelect) {
-        continue;
-      }
-      if(this.selected[lastSelected]) {
-        this.select(lines[i].id, true);
-      } else {
-        this.unselect(lines[i].id);
-      }
-    }
-  },
-
-  submit: function(trId) {
-    if(!this.flagAvailable) {return;}
-    var selected = this.getSelected();
-    this.options.functionSubmit(selected[0]);
-  },
-
-  unselect: function(trId) {
-    if(!this.flagAvailable) {return;}
-    this.classNames.removeClassNames($(trId), 'trSelected');
-    delete this.selected[trId];
-    this.lastSelected = trId;
-    this.options.functionPostUnselect(this);
-  },
-
-  unselectAll: function() {
-    if(!this.flagAvailable) {return;}
-    var lines = this.element.tBodies[0].rows;
-    for(var i = 0; i < lines.length; i++) {
-      this.unselect(lines[i].id);
-    }
-  }
-}
-
-var SelectableTableManager = Class.create();
-SelectableTableManager.prototype = {
-  initialize: function() {
-    this.active = null,
-    this.list   = {}
-  },
-  activate: function(key) {
-    this.stop();
-    if(this.list[key]) {
-      this.list[key].makeAvailable();
-      this.active = this.list[key];
-    } else {
-      this.active = null;
-    }
-  },
-  push: function(key, element) {
-    this.list[key] = element;
-  },
-  start: function() {
-    if(this.active) {
-      this.active.makeAvailable();
-    }
-  },
-  stop: function() {
-    $H(this.list).each(
-      function(el) {
-        if(el[1]) {
-          el[1].makeUnavailable();
-        }
-      }
-    );
-  }
-}
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)\r
+// \r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+//\r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+\r
+var SelectableTable = Class.create();\r
+\r
+SelectableTable.classNames = {\r
+  table:        'selectableTable_table',\r
+  tr:           'selectableTable_tr',\r
+  trHover:      'selectableTable_trHover',\r
+  trSelected:   'selectableTable_trSelected'\r
+}\r
+\r
+SelectableTable.prototype = {\r
+  initialize: function(element) {\r
+    this.element = $(element);\r
+    Element.setStyle(this.element, {visibility: 'hidden'});\r
+    var defaultOptions  = {\r
+      arrayDefaultData:                 [],\r
+      flagAllowUnselect:                true,\r
+      flagInitialAllowMultiple:         false,\r
+      flagKeypressAvailable:            false,\r
+      flagKeypressDeleteAvailable:      false,\r
+      flagKeypressInsertAvailable:      false,\r
+      functionPostAdd:                  Prototype.emptyFunction,\r
+      functionPostDelete:               Prototype.emptyFunction,\r
+      functionPostPressLeft:            Prototype.emptyFunction,\r
+      functionPostPressRight:           Prototype.emptyFunction,\r
+      functionPostSelect:               Prototype.emptyFunction,\r
+      functionPostUnselect:             Prototype.emptyFunction,\r
+      functionPreAdd:                   function() {return true;},\r
+      functionPreDelete:                function() {return true;},\r
+      functionSubmit:                   Prototype.emptyFunction,\r
+      initialSelected:                  null,\r
+      prefixTrId:                       'selectable_table_',\r
+      prefixCSS:                        'custom_'\r
+    }\r
+    this.options                = Object.extend(defaultOptions, arguments[1] || {});\r
+    this.classNames             = new CssUtil([SelectableTable.classNames, CssUtil.appendPrefix(this.options.prefixCSS, SelectableTable.classNames)]);\r
+    this.documentListener       = this.eventKeypress.bindAsEventListener(this);\r
+    this.flagAllowMultiple      = this.options.flagInitialAllowMultiple;\r
+    this.flagAvailable          = true;\r
+    this.focused                = null;\r
+    this.lastSelected           = null;\r
+    this.newNumber              = 1;\r
+    this.selected               = new Object();\r
+    this.build();\r
+    if(arguments[2]) {\r
+      this.selectEffect(this.buildTrId(arguments[2]));\r
+    }\r
+    Element.setStyle(this.element, {visibility: 'visible'});\r
+  },\r
+\r
+  add: function() {\r
+    if(!this.flagAvailable) {return;}\r
+    if(!this.options.functionPreAdd(this)) {return;}\r
+    if(arguments[0] == null) {arguments[0] = this.options.arrayDefaultData;}\r
+    if(typeof(arguments[0]) != 'string') {\r
+      arguments = arguments[0];\r
+    }\r
+    if(arguments[0] == null) {return;}\r
+    var objTr, objTd;\r
+    objTr = document.createElement('tr');\r
+    objTr.id = 'new_' + this.newNumber;\r
+    this.buildTr(objTr);\r
+    for(var i = 0; i < arguments.length; i++) {\r
+      objTd = document.createElement('td');\r
+      objTd.innerHTML = arguments[i];\r
+      objTr.appendChild(objTd);\r
+    }\r
+    this.element.tBodies[0].appendChild(objTr);\r
+    this.newNumber++;\r
+    this.options.functionPostAdd(this);\r
+  },\r
+\r
+  build: function() {\r
+    var lines = this.element.tBodies[0].rows;\r
+    this.classNames.addClassNames(this.element, 'table');\r
+    Event.observe(document, 'keypress', this.documentListener);\r
+    for(var i = 0; i < lines.length; i++) {\r
+      this.buildTr(lines[i]);\r
+    }\r
+    var selected = this.options.initialSelected\r
+    if(selected) {\r
+      this.selectEffect(this.buildTrId(selected));\r
+    }\r
+  },\r
+\r
+  buildTr: function(objTr) {\r
+    objTr.id = this.buildTrId(objTr.id);\r
+    this.classNames.addClassNames(objTr, 'tr');\r
+    Event.observe(objTr, 'click',     this.eventClick.bindAsEventListener(this));\r
+    Event.observe(objTr, 'dblclick',  this.eventDoubleClick.bindAsEventListener(this));\r
+    Event.observe(objTr, 'mouseout',  this.eventFocusOut.bindAsEventListener(this));\r
+    Event.observe(objTr, 'mouseover', this.eventFocusOver.bindAsEventListener(this));\r
+  },\r
+\r
+  buildTrId: function(strId) {\r
+    return this.options.prefixTrId + strId\r
+  },\r
+\r
+  deleteAll: function() {\r
+    if(!this.flagAvailable) {return;}\r
+    if(!this.options.functionPreDelete(this)) {return;}\r
+    for(var trId in this.selected) {\r
+      this.element.tBodies[0].removeChild($(trId));\r
+      delete this.selected[trId];\r
+    }\r
+    this.focused = null;\r
+    this.options.functionPostDelete(this);\r
+  },\r
+\r
+  eventClick: function(event) {\r
+    if(!this.flagAvailable) {return;}\r
+    if(event.shiftKey) {\r
+      this.selectOrUnselectRange(Event.findElement(event, 'tr').id);\r
+    } else {\r
+      this.selectOrUnselect(Event.findElement(event, 'tr').id, event.ctrlKey);\r
+    }\r
+  },\r
+\r
+  eventDoubleClick: function(event) {\r
+    if(!this.flagAvailable) {return;}\r
+    if(this.flagAllowMultiple) {\r
+      this.select(Event.findElement(event, 'tr').id, false);\r
+      this.submit();\r
+    }\r
+  },\r
+\r
+  eventFocusOut: function(event) {\r
+    if(!this.flagAvailable) {return;}\r
+    this.focusOff();\r
+  },\r
+\r
+  eventFocusOver: function(event) {\r
+    if(!this.flagAvailable) {return;}\r
+    this.focusOn(Event.findElement(event, 'tr').id);\r
+    Event.findElement(event, 'tr').focus();\r
+  },\r
+\r
+  eventKeypress: function(event) {\r
+    if(!this.flagAvailable) {return;}\r
+    if(!this.options.flagKeypressAvailable) {return;}\r
+    switch(event.keyCode) {\r
+      case 13: //Enter\r
+        if(event.shiftKey) {\r
+          this.selectOrUnselectRange(this.focused);\r
+        } else {\r
+          this.selectOrUnselect(this.focused, event.ctrlKey);\r
+        }\r
+        break;\r
+      case 37: //Left\r
+        this.options.functionPostPressLeft(this);\r
+        break;\r
+      case 38: //Up\r
+        this.focusMove('up');\r
+        break;\r
+      case 39: //Right\r
+        this.options.functionPostPressRight(this);\r
+        break;\r
+      case 40: //Down\r
+        this.focusMove('down');\r
+        break;\r
+      case 45: //Insert\r
+        if(this.options.flagKeypressInsertAvailable) {this.add();}\r
+        break;\r
+      case 46: //Delete\r
+        if(this.options.flagKeypressDeleteAvailable) {this.deleteAll();}\r
+        break;\r
+    }\r
+  },\r
+\r
+  focusMove: function(direction) {\r
+    if(!this.flagAvailable) {return;}\r
+    if(this.focused == null) {\r
+      this.focusOn(this.element.tBodies[0].rows[0].id);\r
+    } else {\r
+      var rowIndex = $(this.focused).rowIndex;\r
+      var correctionValue, flagEdge;\r
+      switch(direction) {\r
+        case 'down':\r
+          correctionValue = 1;\r
+          flagEdge = this.isBottom(rowIndex);\r
+          break;\r
+        case 'up':\r
+          correctionValue = -1;\r
+          flagEdge = this.isTop(rowIndex);\r
+          break;\r
+      }\r
+      if(!flagEdge) {\r
+        this.focusOn(this.element.rows[rowIndex + correctionValue].id);\r
+      }\r
+    }\r
+  },\r
+\r
+  focusOff: function() {\r
+    if(!this.flagAvailable) {return;}\r
+    if(this.focused != null) {\r
+      var objTr = $(this.focused);\r
+      this.classNames.removeClassNames(objTr, 'trHover');\r
+      this.focused = null;\r
+    }\r
+  },\r
+\r
+  focusOn: function(trId) {\r
+    if(!this.flagAvailable) {return;}\r
+    if($(trId) != null) {\r
+      this.focusOff();\r
+      this.classNames.addClassNames($(trId), 'trHover');\r
+      this.focused = trId;\r
+    }\r
+  },\r
+\r
+  getSelected: function() {\r
+    var selectedIdList  = new Array();\r
+    for(var trId in this.selected) {\r
+      selectedIdList.push(trId.replace(this.options.prefixTrId, ''));\r
+    }\r
+    return selectedIdList;\r
+  },\r
+\r
+  getSelectedElement: function(id) {\r
+    var trId = this.options.prefixTrId + id;\r
+    return $(trId)\r
+  },\r
+\r
+  isBottom: function(rowIndex) {\r
+    return (rowIndex == this.element.rows.length - 1) ? true : false;\r
+  },\r
+\r
+  isTop: function(rowIndex) {\r
+    return (rowIndex == this.element.tBodies[0].rows[0].rowIndex) ? true : false;\r
+  },\r
+\r
+  makeAvailable: function() {\r
+    this.flagAvailable = true;\r
+  },\r
+\r
+  makeMultiple: function() {\r
+    this.flagAllowMultiple = true;\r
+  },\r
+\r
+  makeSingular: function() {\r
+    this.flagAllowMultiple = false;\r
+    this.unselectAll();\r
+  },\r
+\r
+  makeUnavailable: function() {\r
+    this.flagAvailable = false;\r
+  },\r
+\r
+  removeEventFromDocument: function() {\r
+    Event.stopObserving(document, 'keypress', this.documentListener);\r
+  },\r
+\r
+  select: function(trId, ctrl) {\r
+    if(!this.flagAvailable) {return;}\r
+    this.selectEffect(trId, ctrl);\r
+    this.lastSelected = trId;\r
+    this.options.functionPostSelect(this);\r
+    if(!this.flagAllowMultiple) {\r
+      this.submit();\r
+    }\r
+  },\r
+\r
+  selectAll: function() {\r
+    if(!this.flagAvailable) {return;}\r
+    if(!this.flagAllowMultiple) {return;}\r
+    this.selected = new Object();\r
+    var lines = this.element.tBodies[0].rows;\r
+    for(var i = 0; i < lines.length; i++) {\r
+      this.select(lines[i].id, true);\r
+    }\r
+  },\r
+\r
+  selectEffect: function(trId, ctrl) {\r
+    if($(trId)) {\r
+      if(!this.flagAllowMultiple || !ctrl) {\r
+        this.unselectAll();\r
+      }\r
+      this.classNames.addClassNames($(trId), 'trSelected');\r
+      this.selected[trId] = true;\r
+    }\r
+  },\r
+\r
+  selectOrUnselect: function(trId, ctrl) {\r
+    if(!this.flagAvailable) {return;}\r
+    if(trId == null) {return;}\r
+    if(ctrl && this.selected[trId]) {\r
+      if(!this.flagAllowMultiple && !this.options.flagAllowUnselect) {return;}\r
+      this.unselect(trId);\r
+    } else {\r
+      this.select(trId, ctrl);\r
+    }\r
+  },\r
+\r
+  selectOrUnselectRange: function(trId) {\r
+    if(!this.flagAvailable) {return;}\r
+    if(trId == null) {return;}\r
+    if(this.lastSelected == null || this.lastSelected == trId) {\r
+      this.selectOrUnselect(trId);\r
+      return;\r
+    }\r
+    var flagSelect = false;\r
+    var lines = this.element.tBodies[0].rows;\r
+    var lastSelected = this.lastSelected\r
+    for(var i = 0; i < lines.length; i++) {\r
+      if(lines[i].id == trId || lines[i].id == lastSelected) {\r
+        flagSelect = (flagSelect) ? false : true;\r
+      } else if(!flagSelect) {\r
+        continue;\r
+      }\r
+      if(this.selected[lastSelected]) {\r
+        this.select(lines[i].id, true);\r
+      } else {\r
+        this.unselect(lines[i].id);\r
+      }\r
+    }\r
+  },\r
+\r
+  submit: function(trId) {\r
+    if(!this.flagAvailable) {return;}\r
+    var selected = this.getSelected();\r
+    this.options.functionSubmit(selected[0]);\r
+  },\r
+\r
+  unselect: function(trId) {\r
+    if(!this.flagAvailable) {return;}\r
+    this.classNames.removeClassNames($(trId), 'trSelected');\r
+    delete this.selected[trId];\r
+    this.lastSelected = trId;\r
+    this.options.functionPostUnselect(this);\r
+  },\r
+\r
+  unselectAll: function() {\r
+    if(!this.flagAvailable) {return;}\r
+    var lines = this.element.tBodies[0].rows;\r
+    for(var i = 0; i < lines.length; i++) {\r
+      this.unselect(lines[i].id);\r
+    }\r
+  }\r
+}\r
+\r
+var SelectableTableManager = Class.create();\r
+SelectableTableManager.prototype = {\r
+  initialize: function() {\r
+    this.active = null,\r
+    this.list   = {}\r
+  },\r
+  activate: function(key) {\r
+    this.stop();\r
+    if(this.list[key]) {\r
+      this.list[key].makeAvailable();\r
+      this.active = this.list[key];\r
+    } else {\r
+      this.active = null;\r
+    }\r
+  },\r
+  push: function(key, element) {\r
+    this.list[key] = element;\r
+  },\r
+  start: function() {\r
+    if(this.active) {\r
+      this.active.makeAvailable();\r
+    }\r
+  },\r
+  stop: function() {\r
+    $H(this.list).each(\r
+      function(el) {\r
+        if(el[1]) {\r
+          el[1].makeUnavailable();\r
+        }\r
+      }\r
+    );\r
+  }\r
+}\r