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 - - - + + - - + + + + + +