delay auto-select and call on_select
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Mar 2007 20:11:00 +0000 (20:11 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Mar 2007 20:11:00 +0000 (20:11 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0_3@7047 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/util/list.js

index f90a95f..dd9c2fe 100644 (file)
@@ -340,7 +340,14 @@ util.list.prototype = {
                if (typeof params.to_bottom != 'undefined') {
                        treechildren_node.appendChild( treeitem );
                        if (typeof params.no_auto_select == 'undefined') {
-                               try { obj.node.view.selection.select(Number(obj.node.view.rowCount)-1); } catch(E) { obj.error.sdump('D_ALERT','tree auto select: ' + E + '\n'); }
+                               if (!obj.auto_select_pending) {
+                                       obj.auto_select_pending = true;
+                                       setTimeout(function() {
+                                               try { obj.node.view.selection.select(Number(obj.node.view.rowCount)-1); } catch(E) { obj.error.sdump('D_ALERT','tree auto select: ' + E + '\n'); }
+                                               try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_ALERT','tree auto select, on_select: ' + E + '\n'); }
+                                               obj.auto_select_pending = false;
+                                       }, 1000);
+                               }
                        }
                } else {
                        if (treechildren_node.firstChild) {
@@ -349,7 +356,14 @@ util.list.prototype = {
                                treechildren_node.appendChild( treeitem );
                        }
                        if (typeof params.no_auto_select == 'undefined') {
-                               try { obj.node.view.selection.select(0); } catch(E) { obj.error.sdump('D_ALERT','tree auto select: ' + E + '\n'); }
+                               if (!obj.auto_select_pending) {
+                                       obj.auto_select_pending = true;
+                                       setTimeout(function() {
+                                               try { obj.node.view.selection.select(0); } catch(E) { obj.error.sdump('D_ALERT','tree auto select: ' + E + '\n'); }
+                                               try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_ALERT','tree auto select, on_select: ' + E + '\n'); }
+                                               obj.auto_select_pending = false;
+                                       }, 1000);
+                               }
                        }
                }
                var treerow = document.createElement('treerow');