From 22cd938ecc3754f56ae25f683309ae74b0073294 Mon Sep 17 00:00:00 2001 From: David Norton Date: Wed, 31 May 2006 20:29:46 +0000 Subject: [PATCH] Some new CSS placeholders once the designers start making this look good. Scholar.TreeView is now Scholar.FolderTreeView (SourcesTreeView later? depends) Some changes to the way FolderTreeView works. New Scholar.ItemGroup -- used by FolderTreeView and ItemTreeView. the root folder is not currently displayed -- doesn't really matter because we are changing the way it all works. (note: the Scholar.Items.getAll() function does not seem to be working correctly -- try clicking on the library) --- .../content/scholar/folderTreeView.js | 132 ++++++++++-------- .../content/scholar/itemTreeView.js | 6 +- chrome/chromeFiles/content/scholar/overlay.js | 10 +- .../chromeFiles/content/scholar/overlay.xul | 11 +- chrome/chromeFiles/content/scholar/view.xul | 2 - .../skin/default/scholar/overlay.css | 45 ++++++ .../skin/default/scholar/scholar.css | 7 - .../chromeFiles/skin/default/scholar/view.css | 27 ++-- 8 files changed, 141 insertions(+), 99 deletions(-) create mode 100644 chrome/chromeFiles/skin/default/scholar/overlay.css diff --git a/chrome/chromeFiles/content/scholar/folderTreeView.js b/chrome/chromeFiles/content/scholar/folderTreeView.js index c9a732b39a..2d21928465 100644 --- a/chrome/chromeFiles/content/scholar/folderTreeView.js +++ b/chrome/chromeFiles/content/scholar/folderTreeView.js @@ -1,63 +1,48 @@ -Scholar.TreeView = function(root) +Scholar.FolderTreeView = function() { this._treebox = null; this._dataItems = new Array(); this.rowCount = 0; - this._treeType; - this._rootFolder = root; + this._showItem(new Scholar.ItemGroup('library',null),0,1); } -Scholar.TreeView.prototype.setTree = function(treebox) +Scholar.FolderTreeView.prototype.setTree = function(treebox) { if(this._treebox) return; this._treebox = treebox; - this._treeType = treebox.element.getAttribute("treeviewtype"); - var newRows = Scholar.Items.getTreeRows(this._rootFolder,this._treeType); + var newRows = Scholar.Items.getTreeRows(0,'folders'); for(var i = 0; i < newRows.length; i++) - this._showItem(newRows[i], 0, i+1); //item ref, isContainerOpen, level + this._showItem(new Scholar.ItemGroup('folder',newRows[i]), 0, this._dataItems.length); //item ref, level, beforeRow this._refreshHashMap(); } -Scholar.TreeView.prototype.getCellText = function(row, column) +Scholar.FolderTreeView.prototype.getCellText = function(row, column) { var obj = this._getItemAtRow(row); - if(obj.isFolder()) - { - if(column.id == "name_column") - return obj.getName(); - else - return ""; - } + if(column.id == "name_column") + return obj.getName(); else - { - if(column.id == "title_column") - return obj.getField("title"); - else if(column.id == "creator_column") - return obj.getField("firstCreator"); - else if(column.id == "source_column") - return obj.getField("source"); - else - return ""; - } + return ""; } -Scholar.TreeView.prototype.isContainer = function(row) { return this._getItemAtRow(row).isFolder(); } -Scholar.TreeView.prototype.isContainerOpen = function(row) { return this._dataItems[row][1]; } -Scholar.TreeView.prototype.isContainerEmpty = function(row) +Scholar.FolderTreeView.prototype.isContainer = function(row) { return this._getItemAtRow(row).isFolder(); } +Scholar.FolderTreeView.prototype.isContainerOpen = function(row) { return this._dataItems[row][1]; } +Scholar.FolderTreeView.prototype.isContainerEmpty = function(row) { - if(this._treeType == 'folders') - return !this._getItemAtRow(row).hasChildFolders(); + var itemGroup = this._getItemAtRow(row); + if(itemGroup.isFolder()) + return !itemGroup.ref.hasChildFolders(); else - return (this.isContainer(row) && this._getItemAtRow(row).isEmpty()); + return true; } -Scholar.TreeView.prototype.getLevel = function(row) { return this._dataItems[row][2]; } +Scholar.FolderTreeView.prototype.getLevel = function(row) { return this._dataItems[row][2]; } -Scholar.TreeView.prototype.getParentIndex = function(row) +Scholar.FolderTreeView.prototype.getParentIndex = function(row) { var thisLevel = this.getLevel(row); if(thisLevel == 0) return -1; @@ -67,7 +52,7 @@ Scholar.TreeView.prototype.getParentIndex = function(row) return -1; } -Scholar.TreeView.prototype.hasNextSibling = function(row, afterIndex) +Scholar.FolderTreeView.prototype.hasNextSibling = function(row, afterIndex) { var thisLevel = this.getLevel(row); for(var i = afterIndex + 1; i < this.rowCount; i++) @@ -78,7 +63,7 @@ Scholar.TreeView.prototype.hasNextSibling = function(row, afterIndex) } } -Scholar.TreeView.prototype.toggleOpenState = function(row) +Scholar.FolderTreeView.prototype.toggleOpenState = function(row) { var count = 0; //used to tell the tree how many rows were added/removed var thisLevel = this.getLevel(row); @@ -94,12 +79,12 @@ Scholar.TreeView.prototype.toggleOpenState = function(row) } else { - var newRows = Scholar.Items.getTreeRows(this._getItemAtRow(row).getID(),this._treeType); //Get children + var newRows = Scholar.Items.getTreeRows(this._getItemAtRow(row).ref.getID(),'folders'); //Get children for(var i = 0; i < newRows.length; i++) { count++; - this._showItem(newRows[i], thisLevel+1, row+i+1); //insert new row + this._showItem(new Scholar.ItemGroup('folder',newRows[i]), thisLevel+1, row+i+1); //insert new row } } this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value @@ -110,24 +95,25 @@ Scholar.TreeView.prototype.toggleOpenState = function(row) this._refreshHashMap(); } -Scholar.TreeView.prototype._showItem = function(item, level, beforeRow) { this._dataItems.splice(beforeRow, 0, [item, false, level]); this.rowCount++; } +Scholar.FolderTreeView.prototype._showItem = function(item, level, beforeRow) { this._dataItems.splice(beforeRow, 0, [item, false, level]); this.rowCount++; } -Scholar.TreeView.prototype._hideItem = function(row) { this._dataItems.splice(row,1); this.rowCount--; } +Scholar.FolderTreeView.prototype._hideItem = function(row) { this._dataItems.splice(row,1); this.rowCount--; } -Scholar.TreeView.prototype._getItemAtRow = function(row) { return this._dataItems[row][0]; } -Scholar.TreeView.prototype.isSorted = function() { return false; } -Scholar.TreeView.prototype.isSeparator = function(row) { return false; } -Scholar.TreeView.prototype.isEditable = function(row, idx) { return false; } -Scholar.TreeView.prototype.getRowProperties = function(row, prop) { } -Scholar.TreeView.prototype.getColumnProperties = function(col, prop) { } -Scholar.TreeView.prototype.getCellProperties = function(row, col, prop) { } -Scholar.TreeView.prototype.getImageSrc = function(row, col) { } -Scholar.TreeView.prototype.performAction = function(action) { } -Scholar.TreeView.prototype.performActionOnCell = function(action, row, col) { } -Scholar.TreeView.prototype.getProgressMode = function(row, col) { } +Scholar.FolderTreeView.prototype._getItemAtRow = function(row) { return this._dataItems[row][0]; } +Scholar.FolderTreeView.prototype.isSorted = function() { return false; } +Scholar.FolderTreeView.prototype.isSeparator = function(row) { return false; } +Scholar.FolderTreeView.prototype.isEditable = function(row, idx) { return false; } +Scholar.FolderTreeView.prototype.getRowProperties = function(row, prop) { } +Scholar.FolderTreeView.prototype.getColumnProperties = function(col, prop) { } +Scholar.FolderTreeView.prototype.getCellProperties = function(row, col, prop) { } +Scholar.FolderTreeView.prototype.getImageSrc = function(row, col) { } +Scholar.FolderTreeView.prototype.performAction = function(action) { } +Scholar.FolderTreeView.prototype.performActionOnCell = function(action, row, col) { } +Scholar.FolderTreeView.prototype.getProgressMode = function(row, col) { } -Scholar.TreeView.prototype.deleteSelection = function() +Scholar.FolderTreeView.prototype.deleteSelection = function() { + /* if(this.selection.count == 0) return; @@ -161,23 +147,55 @@ Scholar.TreeView.prototype.deleteSelection = function() this._treebox.endUpdateBatch(); this._refreshHashMap(); + */ } -Scholar.TreeView.prototype._refreshHashMap = function() +Scholar.FolderTreeView.prototype._refreshHashMap = function() { // Create hash map of folder and object ids to row indexes - this._itemRowMap = new Array(); this._folderRowMap = new Array(); for(var i=0; i < this.rowCount; i++){ if (this.isContainer(i)){ - this._folderRowMap[this._getItemAtRow(i).getID()] = i; - } - else { - this._itemRowMap[this._getItemAtRow(i).getID()] = i; + this._folderRowMap[this._getItemAtRow(i).ref.getID()] = i; } } //Scholar.debug(Scholar.varDump(this.folderRowMap)); //Scholar.debug(Scholar.varDump(this.objectRowMap)); +} +Scholar.ItemGroup = function(type, ref) +{ + this.type = type; + this.ref = ref; +} + +Scholar.ItemGroup.prototype.isLibrary = function() +{ + return this.type == 'library'; +} + +Scholar.ItemGroup.prototype.isFolder = function() +{ + return this.type == 'folder'; +} + +Scholar.ItemGroup.prototype.getName = function() +{ + if(this.isFolder()) + return this.ref.getName(); + else if(this.isLibrary()) + return "Library"; + else + return ""; +} + +Scholar.ItemGroup.prototype.getChildItems = function() +{ + if(this.isFolder()) + return Scholar.Items.getTreeRows(this.ref.getID(),'items'); + else if(this.isLibrary()) + return Scholar.Items.getAll(); + else + return null; } \ No newline at end of file diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js index e8eb833b4c..3a4e48df2e 100644 --- a/chrome/chromeFiles/content/scholar/itemTreeView.js +++ b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -1,9 +1,9 @@ -Scholar.ItemTreeView = function(root) +Scholar.ItemTreeView = function(itemGroup) { this._treebox = null; this._dataItems = new Array(); this.rowCount = 0; - this._rootFolder = root; + this._itemGroup = itemGroup; } Scholar.ItemTreeView.prototype.setTree = function(treebox) @@ -12,7 +12,7 @@ Scholar.ItemTreeView.prototype.setTree = function(treebox) return; this._treebox = treebox; - var newRows = Scholar.Items.getTreeRows(this._rootFolder,"items"); + var newRows = this._itemGroup.getChildItems(); for(var i = 0; i < newRows.length; i++) this._showItem(newRows[i], i+1); //item ref, before row diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index de9be3ec17..019ea1435e 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -15,10 +15,9 @@ var ScholarPane = new function() function init() { - foldersView = new Scholar.TreeView(0); //pass params here? + foldersView = new Scholar.FolderTreeView(); //pass params here? document.getElementById('folders-tree').view = foldersView; - itemsView = new Scholar.ItemTreeView(0); - document.getElementById('items-tree').view = itemsView; + document.getElementById('items-tree').view = null; var addMenu = document.getElementById('tb-add').firstChild; var itemTypes = Scholar.ItemTypes.getTypes(); @@ -45,13 +44,12 @@ var ScholarPane = new function() { if(foldersView.selection.count == 1 && foldersView.selection.currentIndex != -1) { - itemsView = new Scholar.ItemTreeView(foldersView._getItemAtRow(foldersView.selection.currentIndex).getID()); + itemsView = new Scholar.ItemTreeView(foldersView._getItemAtRow(foldersView.selection.currentIndex)); document.getElementById('items-tree').view = itemsView; } else if(foldersView.selection.count == 0) { - itemsView = new Scholar.ItemTreeView(0); - document.getElementById('items-tree').view = itemsView; + document.getElementById('items-tree').view = null; } else { diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul index cced40b6c6..a174412d5b 100644 --- a/chrome/chromeFiles/content/scholar/overlay.xul +++ b/chrome/chromeFiles/content/scholar/overlay.xul @@ -1,5 +1,6 @@ + @@ -32,7 +33,7 @@ - + - + @@ -81,10 +82,10 @@ - + diff --git a/chrome/chromeFiles/content/scholar/view.xul b/chrome/chromeFiles/content/scholar/view.xul index df4ee947aa..4ed716f6d8 100644 --- a/chrome/chromeFiles/content/scholar/view.xul +++ b/chrome/chromeFiles/content/scholar/view.xul @@ -16,7 +16,6 @@ - @@ -26,7 +25,6 @@ - diff --git a/chrome/chromeFiles/skin/default/scholar/overlay.css b/chrome/chromeFiles/skin/default/scholar/overlay.css new file mode 100644 index 0000000000..7b4ef5a082 --- /dev/null +++ b/chrome/chromeFiles/skin/default/scholar/overlay.css @@ -0,0 +1,45 @@ +vbox #scholar-pane +{ + background: #f5f5f5; + min-height: 150px; +} + +tree #folders-tree +{ + min-width: 100px; + max-width: 200px; +} + +#scholar-tree-splitter +{ + +} + +tree #items-tree +{ + +} + +#scholar-toolbar +{ + +} + +#scholar-toolbar toolbarbutton +{ + +} + +#tb-search +{ + width: 150px; +} + +#scholar-splitter +{ + border-top: none; + border-bottom: 1px solid #A3A3A3; + min-height: 4px; + max-height: 4px; + background: #f5f5f5 !important; +} \ No newline at end of file diff --git a/chrome/chromeFiles/skin/default/scholar/scholar.css b/chrome/chromeFiles/skin/default/scholar/scholar.css index 74dbdc3c42..e69de29bb2 100644 --- a/chrome/chromeFiles/skin/default/scholar/scholar.css +++ b/chrome/chromeFiles/skin/default/scholar/scholar.css @@ -1,7 +0,0 @@ -#scholar-sidebar-object-pane-dynamic-fields label { - font-weight: bold; -} - -#editpane { - background-color: rgb(239, 248, 206); -} \ No newline at end of file diff --git a/chrome/chromeFiles/skin/default/scholar/view.css b/chrome/chromeFiles/skin/default/scholar/view.css index 248bf1b7ba..e19ab35b95 100644 --- a/chrome/chromeFiles/skin/default/scholar/view.css +++ b/chrome/chromeFiles/skin/default/scholar/view.css @@ -5,18 +5,12 @@ #view-toolbar .toggler { - + margin: 4px; } -#metadata-background +#subs { - position: relative; - margin-top: 10px; - left: 10px; width: 400px; - height: 100px; - background-color: black; - opacity: 0.4; } #metadata-pane @@ -27,17 +21,9 @@ width: 400px; height: 100px; overflow: auto; -} - -#notes-background -{ - position: relative; - margin-top: 10px; - left: 10px; - width: 400px; - height: 100px; - background-color: black; - opacity: 0.4; + padding: 5px; + font-size: 11px; + background: #f5f5f5; } #notes-pane @@ -47,4 +33,7 @@ left: 10px; width: 400px; height: 100px; + padding: 5px; + font-size: 11px; + background: #f5f5f5; } \ No newline at end of file