From 27f89fac5e0c2dfcba283d3079c679b1aa3724d5 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 27 Sep 2006 08:12:09 +0000 Subject: [PATCH] Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality --- .../content/scholar/admin/itemTypeManager.js | 3 +- .../chromeFiles/content/scholar/itemPane.js | 52 +++++++++++- .../chromeFiles/content/scholar/itemPane.xul | 6 +- chrome/chromeFiles/content/scholar/overlay.js | 74 +++++++++--------- .../chromeFiles/content/scholar/overlay.xul | 13 +-- .../content/scholar/xpcom/data_access.js | 48 ++++++++++-- .../content/scholar/xpcom/scholar.js | 5 ++ .../locale/en-US/scholar/scholar.dtd | 15 ++-- .../skin/default/scholar/overlay.css | 32 +++++--- .../scholar/toolbar-go-arrow-disabled.png | Bin 0 -> 467 bytes ...olbar-openurl.png => toolbar-go-arrow.png} | Bin .../scholar/toolbar-item-from-page.png | Bin 0 -> 942 bytes .../default/scholar/toolbar-snapshot-add.png | Bin 0 -> 800 bytes .../scholar/treeitem-attachment-snapshot.png | Bin 635 -> 985 bytes system.sql | 33 ++++---- user.sql | 9 ++- 16 files changed, 201 insertions(+), 89 deletions(-) create mode 100644 chrome/chromeFiles/skin/default/scholar/toolbar-go-arrow-disabled.png rename chrome/chromeFiles/skin/default/scholar/{toolbar-openurl.png => toolbar-go-arrow.png} (100%) create mode 100644 chrome/chromeFiles/skin/default/scholar/toolbar-item-from-page.png create mode 100644 chrome/chromeFiles/skin/default/scholar/toolbar-snapshot-add.png diff --git a/chrome/chromeFiles/content/scholar/admin/itemTypeManager.js b/chrome/chromeFiles/content/scholar/admin/itemTypeManager.js index 8f27ccad3..23129bb36 100644 --- a/chrome/chromeFiles/content/scholar/admin/itemTypeManager.js +++ b/chrome/chromeFiles/content/scholar/admin/itemTypeManager.js @@ -372,7 +372,8 @@ var Scholar_ItemTypeManager = new function(){ sql += prefix + "INSERT INTO itemTypes VALUES (" + types[i]['itemTypeID'] + ", '" + types[i]['typeName'] + "', " + (types[i]['templateItemTypeID'] - ? types[i]['templateItemTypeID'] : 'NULL') + ? types[i]['templateItemTypeID'] : 'NULL') + ", ", + + types[i]['display'] + ");\n" } diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js index 51429c176..1018a34c2 100644 --- a/chrome/chromeFiles/content/scholar/itemPane.js +++ b/chrome/chromeFiles/content/scholar/itemPane.js @@ -39,6 +39,7 @@ var ScholarItemPane = new function() this.viewItem = viewItem; this.loadPane = loadPane; this.changeTypeTo = changeTypeTo; + this.onGoToURLClick = onGoToURLClick; this.onOpenURLClick = onOpenURLClick; this.addCreatorRow = addCreatorRow; this.switchCreatorMode = switchCreatorMode; @@ -127,7 +128,6 @@ var ScholarItemPane = new function() } _itemBeingEdited = thisItem; - _loaded = {}; loadPane(_tabs.selectedIndex); @@ -154,6 +154,39 @@ var ScholarItemPane = new function() // Info pane if(index == 0) { + // Enable/disable "View =>" button + testView: try + { + var validURI = false; + var spec = _itemBeingEdited.getField('url'); + if (!spec) + { + break testView; + } + var uri = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService) + .newURI(spec, null, null); + validURI = uri.scheme && uri.host; + } + catch (e){} + document.getElementById('tb-go-to-url').setAttribute('disabled', !validURI); + + // Enable/disable "Locate =>" (OpenURL) button + switch (_itemBeingEdited.getType()) + { + // DEBUG: handle descendents of these types as well? + case Scholar.ItemTypes.getID('book'): + case Scholar.ItemTypes.getID('bookSection'): + case Scholar.ItemTypes.getID('journalArticle'): + case Scholar.ItemTypes.getID('thesis'): + var openURL = true; + break; + + default: + var openURL = false; + } + document.getElementById('tb-openurl').setAttribute('disabled', !openURL); + while(_dynamicFields.hasChildNodes()) _dynamicFields.removeChild(_dynamicFields.firstChild); @@ -174,8 +207,10 @@ var ScholarItemPane = new function() var val = _itemBeingEdited.getField(fieldNames[i]); // Convert dates from UTC - if (fieldNames[i]=='dateAdded' || fieldNames[i]=='dateModified'){ - val = Scholar.Date.sqlToDate(val, true).toLocaleString(); + if (fieldNames[i]=='dateAdded' || fieldNames[i]=='dateModified' + || fieldNames[i]=='accessDate'){ + var date = Scholar.Date.sqlToDate(val, true); + val = date ? date.toLocaleString() : ''; } // Start tabindex at 1000 after creators @@ -347,9 +382,18 @@ var ScholarItemPane = new function() } } + function onGoToURLClick() + { + window.loadURI(_itemBeingEdited.getField('url')); + } + function onOpenURLClick() { - window.open(Scholar.OpenURL.resolve(_itemBeingEdited)); + var url = Scholar.OpenURL.resolve(_itemBeingEdited); + if (url) + { + window.loadURI(Scholar.OpenURL.resolve(_itemBeingEdited)); + } } function addDynamicRow(label, value, beforeElement) diff --git a/chrome/chromeFiles/content/scholar/itemPane.xul b/chrome/chromeFiles/content/scholar/itemPane.xul index 9e6e834d0..12a0fce53 100644 --- a/chrome/chromeFiles/content/scholar/itemPane.xul +++ b/chrome/chromeFiles/content/scholar/itemPane.xul @@ -21,11 +21,14 @@ ScholarItemPane.modifyCreator(document.popupNode.getAttribute('fieldname').split('-')[1], 'typeID', typeID, otherFields)"/> + + diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index 0da4a218f..1bcca9c83 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -37,6 +37,7 @@ var ScholarPane = new function() this.onDoubleClick = onDoubleClick; this.openNoteWindow = openNoteWindow; this.newNote = newNote; + this.addItemFromPage = addItemFromPage; this.addAttachmentFromDialog = addAttachmentFromDialog; this.addAttachmentFromPage = addAttachmentFromPage; this.viewSelectedAttachment = viewSelectedAttachment; @@ -82,20 +83,26 @@ var ScholarPane = new function() var itemsTree = document.getElementById('items-tree'); itemsTree.controllers.appendController(new Scholar.ItemTreeCommandController(itemsTree)); - //Create the add menu with each item type + // Create the add menu with each item type var addMenu = document.getElementById('tb-add').firstChild; - var itemTypes = Scholar.ItemTypes.getTypes(); + var separator = document.getElementById('tb-add').firstChild.firstChild; + var moreMenu = document.getElementById('tb-add-more'); + var itemTypes = Scholar.ItemTypes.getPrimaryTypes(); for(var i = 0; i - - - + + - - + + + + + +