www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f37ab47b39f5c15d6b01eef0728b47bd7c07f267
parent 2a117168a99dca738f75bd35d8725e580a60a759
Author: David Norton <david@nortoncrew.com>
Date:   Fri,  2 Jun 2006 15:27:52 +0000

Revised the way the ItemTreeView handles multiple-selection deletes.
Revised the way the dateAdded and dateModified columns are displayed.
Views are now unregistered on window close.

A few functions in overlay.js were renamed.
Began better commenting of the interface code.

Diffstat:
Mchrome/chromeFiles/content/scholar/folderTreeView.js | 7++++++-
Mchrome/chromeFiles/content/scholar/itemTreeView.js | 23++++++++---------------
Mchrome/chromeFiles/content/scholar/overlay.js | 50+++++++++++++++++++++++++++++++++++++++-----------
Mchrome/chromeFiles/content/scholar/overlay.xul | 6+++---
4 files changed, 56 insertions(+), 30 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/folderTreeView.js b/chrome/chromeFiles/content/scholar/folderTreeView.js @@ -7,12 +7,17 @@ Scholar.FolderTreeView = function() this._unregisterID = Scholar.Notifier.registerColumnTree(this); } +/* + * Unregisters itself from Scholar.Notifier (called on window close) + */ Scholar.FolderTreeView.prototype.unregister = function() { Scholar.Notifier.unregisterColumnTree(this._unregisterID); } -//CALLED BY DATA LAYER ON CHANGE: +/* + * Is called by Scholar.Notifier on any changes to the data layer + */ Scholar.FolderTreeView.prototype.notify = function(action, type, ids) { ids = Scholar.flattenArguments(ids); diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -40,19 +40,14 @@ Scholar.ItemTreeView.prototype.getCellText = function(row, column) if(column.id == 'dateAdded' || column.id == 'dateModified') //this is not so much that we will use this format for date, but a simple template for later revisions. { - // - var d = val.split(' '); - var date = d[0].split('-'); - var time = d[1].split('-'); - var myDate = new Date(); - myDate.setFullYear(date[0],date[1]-1,date[2]); - val = myDate.getMonth()+1 + '/' + myDate.getDate() + '/' + myDate.getFullYear(); + myDate.setTime(Date.parse(val.replace("-","/").replace("-","/"))); + + val = myDate.getMonth()+1 + '/' + myDate.getDate() + '/' + myDate.getFullYear() + " " + myDate.getHours() + ":" + myDate.getMinutes(); } return val; - } @@ -100,24 +95,24 @@ Scholar.ItemTreeView.prototype.deleteSelection = function() return; //create an array of selected items - var rows = new Array(); + var items = new Array(); var start = new Object(); var end = new Object(); for (var i=0, len=this.selection.getRangeCount(); i<len; i++) { this.selection.getRangeAt(i,start,end); for (var j=start.value; j<=end.value; j++) - rows.push(j); + items.push(this._getItemAtRow(j)); } //iterate and erase... this._treebox.beginUpdateBatch(); - for (var i=0; i<rows.length; i++) + for (var i=0; i<items.length; i++) { if(this._itemGroup.isLibrary()) //erase item from DB - this._getItemAtRow(rows[i]-i).erase(); + items[i].erase(); else if(this._itemGroup.isCollection()) - this._itemGroup.ref.removeItem(this._getItemAtRow(rows[i]-i).getID()); + this._itemGroup.ref.removeItem(items[i].getID()); /* Disabled for now (notifier) //remove row from tree: @@ -125,8 +120,6 @@ Scholar.ItemTreeView.prototype.deleteSelection = function() this._treebox.rowCountChanged(rows[i]-i, -1); */ } this._treebox.endUpdateBatch(); - - this._refreshHashMap(); } Scholar.ItemTreeView.prototype.searchText = function(search) diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js @@ -1,12 +1,16 @@ +/* + * This object contains the various functions for the interface + */ var ScholarPane = new function() { - var foldersView; var itemsView; var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); - this.init = init; - this.toggleScholar = toggleScholar; + //Privileged methods + this.onLoad = onLoad; + this.onUnload = onUnload; + this.toggleDisplay = toggleDisplay; this.newItem = newItem; this.newCollection = newCollection; this.folderSelected = folderSelected; @@ -16,12 +20,19 @@ var ScholarPane = new function() this.search = search; this.toggleView = toggleView; - function init() + /* + * Called when the window is open + */ + function onLoad() { - foldersView = new Scholar.FolderTreeView(); //pass params here? + //Initialize folders view + foldersView = new Scholar.FolderTreeView(); document.getElementById('folders-tree').view = foldersView; + + //select Library foldersView.selection.select(0); + //Create the add menu with each item type var addMenu = document.getElementById('tb-add').firstChild; var itemTypes = Scholar.ItemTypes.getTypes(); for(var i = 0; i<itemTypes.length; i++) @@ -32,10 +43,23 @@ var ScholarPane = new function() addMenu.appendChild(menuitem); } -// Drag.init(document.getElementById('scholar-floater-handle'),document.getElementById('scholar-floater'), 0, 400, 0, 500, true, true); + //Drag.init(document.getElementById('scholar-floater-handle'),document.getElementById('scholar-floater'), 0, 400, 0, 500, true, true); } - function toggleScholar() + /* + * Called when the window closes + */ + function onUnload() + { + foldersView.unregister(); + if(itemsView) + itemsView.unregister(); + } + + /* + * Hides/displays the Scholar interface + */ + function toggleDisplay() { var visible = document.getElementById('scholar-pane').getAttribute('collapsed') == 'true'; @@ -43,7 +67,10 @@ var ScholarPane = new function() document.getElementById('scholar-splitter').setAttribute('collapsed',!visible); document.getElementById('scholar-floater').hidden = (!visible || itemsView.selection.count != 1); } - + + /* + * Called when the window closes + */ function newItem(typeID) { MetadataPane.viewItem(new Scholar.Item(typeID)); @@ -82,7 +109,7 @@ var ScholarPane = new function() { var editButton = document.getElementById('metadata-pane-edit-button'); - if(itemsView && itemsView.selection.count == 1) + if(itemsView && itemsView.selection.count == 1 && itemsView.selection.currentIndex != -1) { var item = itemsView._getItemAtRow(itemsView.selection.currentIndex); @@ -164,4 +191,5 @@ var ScholarCollectionsDragObserver = } } -window.addEventListener("load", function(e) { ScholarPane.init(e); }, false); -\ No newline at end of file +window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false); +window.addEventListener("unload", function(e) { ScholarPane.onUnload(e); }, false); +\ No newline at end of file diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul @@ -100,14 +100,14 @@ <spacer flex="1"/> <label value="Search:" control="tb-search"/> <textbox id="tb-search" type="timed" timeout="500" command="cmd_scholar_search"/> - <toolbarbutton class="tabs-closebutton" oncommand="ScholarPane.toggleScholar()"/> + <toolbarbutton class="tabs-closebutton" oncommand="ScholarPane.toggleDisplay()"/> </toolbar> </vbox> <splitter id="scholar-splitter" resizebefore="closest" resizeafter="closest" position="2" persist="collapsed"/> </vbox> <statusbar id="status-bar"> - <statusbarpanel id="scholar-load-status" label="Scholar is NOT loaded" onclick="ScholarPane.toggleScholar();"/> + <statusbarpanel id="scholar-load-status" label="Scholar is NOT loaded" onclick="ScholarPane.toggleDisplay();"/> </statusbar> <script> @@ -121,7 +121,7 @@ <menupopup id="menu_ToolsPopup"> <menuseparator id="scholarSeparator" insertbefore="devToolsSeparator"/> <menuitem id="tools-scholar" insertbefore="devToolsSeparator" - oncommand="ScholarPane.toggleScholar();" label="Scholar" + oncommand="ScholarPane.toggleDisplay();" label="Scholar" key="key_openScholar"/> </menupopup>