2006-08-02 16:49:19 +00:00
|
|
|
/*
|
2006-10-04 17:16:56 +00:00
|
|
|
***** BEGIN LICENSE BLOCK *****
|
|
|
|
|
|
|
|
Copyright (c) 2006 Center for History and New Media
|
|
|
|
George Mason University, Fairfax, Virginia, USA
|
|
|
|
http://chnm.gmu.edu
|
|
|
|
|
|
|
|
Licensed under the Educational Community License, Version 1.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.opensource.org/licenses/ecl1.php
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
***** END LICENSE BLOCK *****
|
2006-08-02 16:49:19 +00:00
|
|
|
*/
|
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
/*
|
|
|
|
* This object contains the various functions for the interface
|
|
|
|
*/
|
2006-10-02 23:15:27 +00:00
|
|
|
var ZoteroPane = new function()
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
this.collectionsView = false;
|
|
|
|
this.itemsView = false;
|
2006-05-30 22:06:33 +00:00
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
//Privileged methods
|
|
|
|
this.onLoad = onLoad;
|
|
|
|
this.onUnload = onUnload;
|
|
|
|
this.toggleDisplay = toggleDisplay;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.isShowing = isShowing;
|
2006-07-05 16:19:26 +00:00
|
|
|
this.fullScreen = fullScreen;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.isFullScreen = isFullScreen;
|
|
|
|
this.handleKeyDown = handleKeyDown;
|
|
|
|
this.handleKeyUp = handleKeyUp;
|
|
|
|
this.setHighlightedRowsCallback = setHighlightedRowsCallback;
|
|
|
|
this.handleKeyPress = handleKeyPress;
|
2006-05-30 22:06:33 +00:00
|
|
|
this.newItem = newItem;
|
2006-06-01 03:50:34 +00:00
|
|
|
this.newCollection = newCollection;
|
2006-08-09 11:43:33 +00:00
|
|
|
this.newSearch = newSearch;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.openAdvancedSearchWindow = openAdvancedSearchWindow;
|
|
|
|
this.toggleTagSelector = toggleTagSelector;
|
|
|
|
this.updateTagSelectorSize = updateTagSelectorSize;
|
|
|
|
this.getTagSelection = getTagSelection;
|
|
|
|
this.clearTagSelection = clearTagSelection;
|
|
|
|
this.updateTagFilter = updateTagFilter;
|
2006-06-05 18:01:53 +00:00
|
|
|
this.onCollectionSelected = onCollectionSelected;
|
2006-05-30 22:06:33 +00:00
|
|
|
this.itemSelected = itemSelected;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.reindexItem = reindexItem;
|
|
|
|
this.duplicateSelectedItem = duplicateSelectedItem;
|
2006-06-19 15:00:13 +00:00
|
|
|
this.deleteSelectedCollection = deleteSelectedCollection;
|
2006-08-30 04:09:34 +00:00
|
|
|
this.editSelectedCollection = editSelectedCollection;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.copySelectedItemsToClipboard = copySelectedItemsToClipboard;
|
|
|
|
this.clearQuicksearch = clearQuicksearch;
|
|
|
|
this.handleSearchKeypress = handleSearchKeypress;
|
|
|
|
this.handleSearchInput = handleSearchInput;
|
2006-05-30 22:06:33 +00:00
|
|
|
this.search = search;
|
2006-07-31 19:14:06 +00:00
|
|
|
this.selectItem = selectItem;
|
2006-07-24 22:12:25 +00:00
|
|
|
this.getSelectedCollection = getSelectedCollection;
|
2006-08-30 04:09:34 +00:00
|
|
|
this.getSelectedSavedSearch = getSelectedSavedSearch;
|
2006-07-26 15:09:06 +00:00
|
|
|
this.getSelectedItems = getSelectedItems;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.getSortedItems = getSortedItems;
|
|
|
|
this.getSortField = getSortField;
|
|
|
|
this.getSortDirection = getSortDirection;
|
2006-06-19 15:00:13 +00:00
|
|
|
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
|
|
|
this.buildItemContextMenu = buildItemContextMenu;
|
2006-08-02 16:08:19 +00:00
|
|
|
this.onDoubleClick = onDoubleClick;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.loadURI = loadURI;
|
|
|
|
this.setItemsPaneMessage = setItemsPaneMessage;
|
|
|
|
this.clearItemsPaneMessage = clearItemsPaneMessage;
|
|
|
|
this.contextPopupShowing = contextPopupShowing;
|
2006-06-27 22:47:17 +00:00
|
|
|
this.openNoteWindow = openNoteWindow;
|
2006-07-26 14:30:38 +00:00
|
|
|
this.newNote = newNote;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.addTextToNote = addTextToNote;
|
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
2006-09-27 08:12:09 +00:00
|
|
|
this.addItemFromPage = addItemFromPage;
|
2006-08-12 00:18:20 +00:00
|
|
|
this.addAttachmentFromDialog = addAttachmentFromDialog;
|
|
|
|
this.addAttachmentFromPage = addAttachmentFromPage;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.viewAttachment = viewAttachment;
|
2006-08-12 00:18:20 +00:00
|
|
|
this.viewSelectedAttachment = viewSelectedAttachment;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.showAttachmentNotFoundDialog = showAttachmentNotFoundDialog;
|
|
|
|
this.relinkAttachment = relinkAttachment;
|
|
|
|
this.reportErrors = reportErrors;
|
|
|
|
this.displayErrorMessage = displayErrorMessage;
|
|
|
|
|
|
|
|
const DEFAULT_ZPANE_HEIGHT = 300;
|
|
|
|
const COLLECTIONS_HEIGHT = 125; // minimum height of the collections pane and toolbar
|
|
|
|
|
|
|
|
var self = this;
|
2006-05-30 22:06:33 +00:00
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
/*
|
|
|
|
* Called when the window is open
|
|
|
|
*/
|
|
|
|
function onLoad()
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!Zotero || !Zotero.initialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
if(Zotero.Prefs.get("zoteroPaneOnTop"))
|
2006-06-28 15:15:38 +00:00
|
|
|
{
|
2006-10-02 23:15:27 +00:00
|
|
|
var oldPane = document.getElementById('zotero-pane');
|
|
|
|
var oldSplitter = document.getElementById('zotero-splitter');
|
2006-07-19 16:14:27 +00:00
|
|
|
var appContent = document.getElementById('appcontent');
|
|
|
|
|
|
|
|
var newPane = document.createElement('hbox');
|
2006-10-02 23:15:27 +00:00
|
|
|
newPane.setAttribute('id','zotero-pane');
|
2007-10-23 07:11:59 +00:00
|
|
|
newPane.setAttribute('persist','savedHeight');
|
|
|
|
newPane.setAttribute('hidden', true);
|
|
|
|
newPane.setAttribute('onkeydown', 'ZoteroPane.handleKeyDown(event, this.id)');
|
|
|
|
newPane.setAttribute('onkeyup', 'ZoteroPane.handleKeyUp(event, this.id)');
|
|
|
|
newPane.setAttribute('chromedir', '&locale.dir;');
|
|
|
|
|
2006-07-27 18:08:09 +00:00
|
|
|
newPane.height = oldPane.height;
|
2006-07-19 16:14:27 +00:00
|
|
|
while(oldPane.hasChildNodes())
|
|
|
|
newPane.appendChild(oldPane.firstChild);
|
|
|
|
appContent.removeChild(oldPane);
|
|
|
|
appContent.insertBefore(newPane, document.getElementById('content'));
|
|
|
|
|
|
|
|
var newSplitter = document.createElement('splitter');
|
2006-10-02 23:15:27 +00:00
|
|
|
newSplitter.setAttribute('id','zotero-splitter');
|
2007-10-23 07:11:59 +00:00
|
|
|
newSplitter.setAttribute('hidden', true);
|
2006-07-19 16:14:27 +00:00
|
|
|
newSplitter.setAttribute('resizebefore','closest');
|
|
|
|
newSplitter.setAttribute('resizeafter','closest');
|
2007-10-23 07:11:59 +00:00
|
|
|
newSplitter.setAttribute('onmouseup', 'ZoteroPane.updateTagSelectorSize()');
|
2006-07-19 16:14:27 +00:00
|
|
|
appContent.removeChild(oldSplitter);
|
|
|
|
appContent.insertBefore(newSplitter, document.getElementById('content'));
|
2006-07-28 16:49:19 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
document.getElementById('zotero-tb-fullscreen').setAttribute('zoterotop','true');
|
2006-06-28 15:15:38 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
Zotero.setFontSize(document.getElementById('zotero-pane'))
|
|
|
|
|
2008-07-07 19:44:51 +00:00
|
|
|
if (Zotero.isMac) {
|
|
|
|
document.getElementById('zotero-tb-actions-zeroconf-update').setAttribute('hidden', false);
|
|
|
|
}
|
|
|
|
|
2006-07-26 14:03:54 +00:00
|
|
|
//Initialize collections view
|
2007-10-23 07:11:59 +00:00
|
|
|
this.collectionsView = new Zotero.CollectionTreeView();
|
|
|
|
var collectionsTree = document.getElementById('zotero-collections-tree');
|
|
|
|
collectionsTree.view = this.collectionsView;
|
2006-10-02 23:15:27 +00:00
|
|
|
collectionsTree.controllers.appendController(new Zotero.CollectionTreeCommandController(collectionsTree));
|
2006-07-28 13:28:50 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
var itemsTree = document.getElementById('zotero-items-tree');
|
2006-10-02 23:15:27 +00:00
|
|
|
itemsTree.controllers.appendController(new Zotero.ItemTreeCommandController(itemsTree));
|
2006-07-26 14:03:54 +00:00
|
|
|
|
2006-10-02 06:44:16 +00:00
|
|
|
// Create the New Item (+) menu with each item type
|
2007-10-23 07:11:59 +00:00
|
|
|
var addMenu = document.getElementById('zotero-tb-add').firstChild;
|
|
|
|
var separator = document.getElementById('zotero-tb-add').firstChild.firstChild;
|
|
|
|
var moreMenu = document.getElementById('zotero-tb-add-more');
|
2006-10-02 23:15:27 +00:00
|
|
|
var itemTypes = Zotero.ItemTypes.getPrimaryTypes();
|
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
2006-09-27 08:12:09 +00:00
|
|
|
for(var i = 0; i<itemTypes.length; i++)
|
|
|
|
{
|
|
|
|
var menuitem = document.createElement("menuitem");
|
2006-10-02 23:15:27 +00:00
|
|
|
menuitem.setAttribute("label", Zotero.getString("itemTypes."+itemTypes[i]['name']));
|
|
|
|
menuitem.setAttribute("oncommand","ZoteroPane.newItem("+itemTypes[i]['id']+")");
|
2007-10-23 07:11:59 +00:00
|
|
|
menuitem.setAttribute("tooltiptext", "");
|
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
2006-09-27 08:12:09 +00:00
|
|
|
addMenu.insertBefore(menuitem, separator);
|
|
|
|
}
|
|
|
|
// Create submenu for secondary item types
|
2006-10-02 23:15:27 +00:00
|
|
|
var itemTypes = Zotero.ItemTypes.getSecondaryTypes();
|
2006-06-20 13:59:59 +00:00
|
|
|
for(var i = 0; i<itemTypes.length; i++)
|
|
|
|
{
|
|
|
|
var menuitem = document.createElement("menuitem");
|
2006-10-02 23:15:27 +00:00
|
|
|
menuitem.setAttribute("label", Zotero.getString("itemTypes."+itemTypes[i]['name']));
|
|
|
|
menuitem.setAttribute("oncommand","ZoteroPane.newItem("+itemTypes[i]['id']+")");
|
2007-10-23 07:11:59 +00:00
|
|
|
menuitem.setAttribute("tooltiptext", "");
|
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
2006-09-27 08:12:09 +00:00
|
|
|
moreMenu.appendChild(menuitem);
|
2006-06-20 13:59:59 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
var menu = document.getElementById("contentAreaContextMenu");
|
|
|
|
menu.addEventListener("popupshowing", ZoteroPane.contextPopupShowing, false);
|
|
|
|
|
|
|
|
Zotero.Keys.windowInit(document);
|
|
|
|
|
|
|
|
// If the database was initialized and Zotero hasn't been run before
|
|
|
|
// in this profile, display the Quick Start Guide -- this way the guide
|
2009-01-02 00:35:09 +00:00
|
|
|
// won't be displayed when they sync their DB to another profile or if
|
2007-10-23 07:11:59 +00:00
|
|
|
// they the DB is initialized erroneously (e.g. while switching data
|
|
|
|
// directory locations)
|
2009-01-02 00:35:09 +00:00
|
|
|
if (Zotero.restoreFromServer) {
|
|
|
|
Zotero.restoreFromServer = false;
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
var pr = Components.classes["@mozilla.org/network/default-prompt;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrompt);
|
|
|
|
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING)
|
|
|
|
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL);
|
|
|
|
var index = pr.confirmEx(
|
|
|
|
"Zotero Restore",
|
|
|
|
"The local Zotero database has been cleared."
|
|
|
|
+ " "
|
|
|
|
+ "Would you like to restore from the Zotero server now?",
|
|
|
|
buttonFlags,
|
|
|
|
"Sync Now",
|
|
|
|
null, null, null, {}
|
|
|
|
);
|
|
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
Zotero.Sync.Server.sync(function () {
|
|
|
|
pr.alert(
|
|
|
|
"Restore Completed",
|
|
|
|
"The local Zotero database has been successfully restored."
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
else if (Zotero.Schema.dbInitialized && Zotero.Prefs.get('firstRun')) {
|
2007-10-23 07:11:59 +00:00
|
|
|
setTimeout(function () {
|
2009-01-02 00:35:09 +00:00
|
|
|
gBrowser.selectedTab = gBrowser.addTab(ZOTERO_CONFIG.FIRST_RUN_URL);
|
2007-10-23 07:11:59 +00:00
|
|
|
}, 400);
|
|
|
|
Zotero.Prefs.set('firstRun', false);
|
|
|
|
}
|
2009-01-02 16:51:13 +00:00
|
|
|
|
|
|
|
// Hide sync debugging menu by default
|
|
|
|
if (Zotero.Prefs.get('sync.debugMenu')) {
|
|
|
|
var sep = document.getElementById('zotero-tb-actions-sync-separator');
|
|
|
|
var menuitems = [];
|
|
|
|
sep.nextSibling.hidden = false;
|
|
|
|
sep.nextSibling.nextSibling.hidden = false;
|
|
|
|
sep.nextSibling.nextSibling.nextSibling.hidden = false;
|
|
|
|
sep.nextSibling.nextSibling.nextSibling.nextSibling.hidden = false;
|
|
|
|
}
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
/*
|
|
|
|
* Called when the window closes
|
|
|
|
*/
|
|
|
|
function onUnload()
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!Zotero || !Zotero.initialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var tagSelector = document.getElementById('zotero-tag-selector');
|
|
|
|
tagSelector.unregister();
|
|
|
|
|
|
|
|
this.collectionsView.unregister();
|
|
|
|
if (this.itemsView)
|
|
|
|
this.itemsView.unregister();
|
2006-06-02 15:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-10-02 23:15:27 +00:00
|
|
|
* Hides/displays the Zotero interface
|
2006-06-02 15:27:52 +00:00
|
|
|
*/
|
|
|
|
function toggleDisplay()
|
2006-05-31 22:01:31 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var zoteroPane = document.getElementById('zotero-pane');
|
|
|
|
var zoteroSplitter = document.getElementById('zotero-splitter')
|
|
|
|
|
|
|
|
if (zoteroPane.getAttribute('hidden') == 'true') {
|
|
|
|
var isHidden = true;
|
|
|
|
}
|
|
|
|
else if (zoteroPane.getAttribute('collapsed') == 'true') {
|
|
|
|
var isCollapsed = true;
|
|
|
|
}
|
2006-05-31 22:01:31 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
if (isHidden || isCollapsed) {
|
|
|
|
var makeVisible = true;
|
|
|
|
}
|
2006-07-05 16:19:26 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
// If Zotero not initialized, try to get the error handler
|
|
|
|
// or load the default error page
|
|
|
|
if (makeVisible && (!Zotero || !Zotero.initialized)) {
|
|
|
|
if (Zotero) {
|
|
|
|
var errMsg = Zotero.startupError;
|
|
|
|
var errFunc = Zotero.startupErrorHandler;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!errMsg) {
|
|
|
|
// Get the stringbundle manually
|
|
|
|
var src = 'chrome://zotero/locale/zotero.properties';
|
|
|
|
var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'].
|
|
|
|
getService(Components.interfaces.nsILocaleService);
|
|
|
|
var appLocale = localeService.getApplicationLocale();
|
|
|
|
var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
|
|
|
.getService(Components.interfaces.nsIStringBundleService);
|
|
|
|
var stringBundle = stringBundleService.createBundle(src, appLocale);
|
|
|
|
|
|
|
|
var errMsg = stringBundle.GetStringFromName('startupError');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errFunc) {
|
|
|
|
errFunc();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// TODO: Add a better error page/window here with reporting
|
|
|
|
// instructions
|
|
|
|
// window.loadURI('chrome://zotero/content/error.xul');
|
|
|
|
alert(errMsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
zoteroSplitter.setAttribute('hidden', !makeVisible);
|
|
|
|
|
|
|
|
// Restore fullscreen mode if necessary
|
|
|
|
var fullScreenMode = document.getElementById('zotero-tb-fullscreen').getAttribute('fullscreenmode') == 'true';
|
|
|
|
if (makeVisible && fullScreenMode) {
|
|
|
|
this.fullScreen(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (zoteroPane.hasAttribute('savedHeight')) {
|
|
|
|
var savedHeight = zoteroPane.getAttribute('savedHeight');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var savedHeight = DEFAULT_ZPANE_HEIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Zotero.debug("zoteroPane.boxObject.height: " + zoteroPane.boxObject.height);
|
|
|
|
Zotero.debug("zoteroPane.getAttribute('height'): " + zoteroPane.getAttribute('height'));
|
|
|
|
Zotero.debug("zoteroPane.getAttribute('minheight'): " + zoteroPane.getAttribute('minheight'));
|
|
|
|
Zotero.debug("savedHeight: " + savedHeight);
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (makeVisible) {
|
|
|
|
this.updateTagSelectorSize();
|
|
|
|
|
|
|
|
var max = document.getElementById('appcontent').boxObject.height
|
|
|
|
- zoteroSplitter.boxObject.height;
|
|
|
|
|
|
|
|
if (isHidden) {
|
|
|
|
zoteroPane.setAttribute('height', Math.min(savedHeight, max));
|
|
|
|
zoteroPane.setAttribute('hidden', false);
|
|
|
|
}
|
|
|
|
else if (isCollapsed) {
|
|
|
|
zoteroPane.setAttribute('height', Math.min(savedHeight, max));
|
|
|
|
zoteroPane.setAttribute('collapsed', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Focus the quicksearch on pane open
|
|
|
|
setTimeout("document.getElementById('zotero-tb-search').inputField.select();", 1);
|
2008-07-01 20:39:20 +00:00
|
|
|
|
2008-08-31 23:39:14 +00:00
|
|
|
if (Zotero.Prefs.get('sync.autoSync') && Zotero.Sync.Server.enabled) {
|
2008-07-01 20:39:20 +00:00
|
|
|
setTimeout(function () {
|
2008-08-31 23:39:14 +00:00
|
|
|
Zotero.Sync.Runner.sync();
|
2008-07-01 20:39:20 +00:00
|
|
|
}, 1000);
|
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
zoteroPane.setAttribute('collapsed', true);
|
|
|
|
zoteroPane.height = 0;
|
|
|
|
|
2006-07-05 16:19:26 +00:00
|
|
|
document.getElementById('content').setAttribute('collapsed', false);
|
2006-10-03 19:09:21 +00:00
|
|
|
|
|
|
|
// Return focus to the browser content pane
|
|
|
|
window.content.window.focus();
|
2006-07-28 16:49:19 +00:00
|
|
|
}
|
2006-07-05 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
function isShowing() {
|
|
|
|
var zoteroPane = document.getElementById('zotero-pane');
|
|
|
|
return zoteroPane.getAttribute('hidden') != 'true' &&
|
|
|
|
zoteroPane.getAttribute('collapsed') != 'true';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fullScreen(set)
|
2006-07-05 16:19:26 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var fs = document.getElementById('zotero-tb-fullscreen');
|
|
|
|
|
|
|
|
if (set != undefined) {
|
|
|
|
var makeFullScreen = set;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var makeFullScreen = fs.getAttribute('fullscreenmode') != 'true';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Turn Z-pane flex on to stretch to window in full-screen, but off otherwise so persist works
|
|
|
|
document.getElementById('zotero-pane').setAttribute('flex', makeFullScreen ? "1" : "0");
|
|
|
|
document.getElementById('content').setAttribute('collapsed', makeFullScreen);
|
|
|
|
document.getElementById('zotero-splitter').setAttribute('hidden', makeFullScreen);
|
|
|
|
fs.setAttribute('fullscreenmode', makeFullScreen);
|
2006-05-31 22:01:31 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
function isFullScreen() {
|
|
|
|
var fs = document.getElementById('zotero-tb-fullscreen');
|
|
|
|
return fs.getAttribute('fullscreenmode') == 'true'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Trigger actions based on keyboard shortcuts
|
|
|
|
*/
|
|
|
|
function handleKeyDown(event, from) {
|
Merged revisions 2640-2647,2651,2653-2654,2656-2658,2660-2667,2670-2672,2674-2677,2680,2683-2684,2687-2704,2707 to trunk via svnmerge from 1.0 branch
2008-05-16 09:14:11 +00:00
|
|
|
try {
|
|
|
|
// Ignore keystrokes outside of Zotero pane
|
|
|
|
if (!(event.originalTarget.ownerDocument instanceof XULDocument)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
Zotero.debug(e);
|
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
if (from == 'zotero-pane') {
|
|
|
|
// Highlight collections containing selected items
|
|
|
|
//
|
|
|
|
// We use Control (17) on Windows because Alt triggers the menubar;
|
|
|
|
// otherwise we use Alt/Option (18)
|
|
|
|
if ((Zotero.isWin && event.keyCode == 17 && !event.altKey) ||
|
|
|
|
(!Zotero.isWin && event.keyCode == 18 && !event.ctrlKey)
|
|
|
|
&& !event.shiftKey && !event.metaKey) {
|
|
|
|
|
|
|
|
this.highlightTimer = Components.classes["@mozilla.org/timer;1"].
|
|
|
|
createInstance(Components.interfaces.nsITimer);
|
|
|
|
// {} implements nsITimerCallback
|
|
|
|
this.highlightTimer.initWithCallback({
|
|
|
|
notify: ZoteroPane.setHighlightedRowsCallback
|
|
|
|
}, 225, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
}
|
|
|
|
else if ((Zotero.isWin && event.ctrlKey) ||
|
|
|
|
(!Zotero.isWin && event.altKey)) {
|
|
|
|
if (this.highlightTimer) {
|
|
|
|
this.highlightTimer.cancel();
|
|
|
|
this.highlightTimer = null;
|
|
|
|
}
|
|
|
|
ZoteroPane.collectionsView.setHighlightedRows();
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ignore keystrokes if Zotero pane is closed
|
|
|
|
var zoteroPane = document.getElementById('zotero-pane');
|
|
|
|
if (zoteroPane.getAttribute('hidden') == 'true' ||
|
|
|
|
zoteroPane.getAttribute('collapsed') == 'true') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var useShift = Zotero.isMac;
|
|
|
|
|
|
|
|
var key = String.fromCharCode(event.which);
|
|
|
|
if (!key) {
|
|
|
|
Zotero.debug('No key');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Merged revisions 2989,2994,2996-2999,3001,3003-3004,3007,3010,3012,3015-3016,3026-3029,3036-3038,3040-3041,3046,3048,3050,3052,3054-3055,3057-3058,3066,3069-3073 from 1.0 branch via svnmerge
2008-07-22 05:45:32 +00:00
|
|
|
// Ignore modifiers other than Ctrl-Alt or Cmd-Shift
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!((Zotero.isMac ? event.metaKey : event.ctrlKey) &&
|
Merged revisions 2989,2994,2996-2999,3001,3003-3004,3007,3010,3012,3015-3016,3026-3029,3036-3038,3040-3041,3046,3048,3050,3052,3054-3055,3057-3058,3066,3069-3073 from 1.0 branch via svnmerge
2008-07-22 05:45:32 +00:00
|
|
|
(useShift ? event.shiftKey : event.altKey))) {
|
2007-10-23 07:11:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-06-02 15:27:52 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
var command = Zotero.Keys.getCommand(key);
|
|
|
|
if (!command) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Zotero.debug(command);
|
|
|
|
|
|
|
|
switch (command) {
|
Merged revisions 2640-2647,2651,2653-2654,2656-2658,2660-2667,2670-2672,2674-2677,2680,2683-2684,2687-2704,2707 to trunk via svnmerge from 1.0 branch
2008-05-16 09:14:11 +00:00
|
|
|
case 'openZotero':
|
|
|
|
try {
|
|
|
|
// Ignore Cmd-Shift-Z keystroke in text areas
|
|
|
|
if (Zotero.isMac && key == 'Z' &&
|
|
|
|
event.originalTarget.localName == 'textarea') {
|
|
|
|
Zotero.debug('Ignoring keystroke in text area');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
Zotero.debug(e);
|
|
|
|
}
|
|
|
|
ZoteroPane.toggleDisplay()
|
|
|
|
break;
|
2007-10-23 07:11:59 +00:00
|
|
|
case 'library':
|
|
|
|
document.getElementById('zotero-collections-tree').focus();
|
|
|
|
ZoteroPane.collectionsView.selection.select(0);
|
|
|
|
break;
|
|
|
|
case 'quicksearch':
|
|
|
|
document.getElementById('zotero-tb-search').select();
|
|
|
|
break;
|
|
|
|
case 'newItem':
|
|
|
|
ZoteroPane.newItem(2); // book
|
|
|
|
document.getElementById('zotero-editpane-type-menu').focus();
|
|
|
|
break;
|
|
|
|
case 'newNote':
|
|
|
|
// Use key that's not the modifier as the popup toggle
|
|
|
|
ZoteroPane.newNote(useShift ? event.altKey : event.shiftKey);
|
|
|
|
break;
|
|
|
|
case 'toggleTagSelector':
|
|
|
|
ZoteroPane.toggleTagSelector();
|
|
|
|
break;
|
|
|
|
case 'toggleFullscreen':
|
|
|
|
ZoteroPane.fullScreen();
|
|
|
|
break;
|
|
|
|
case 'copySelectedItemCitationsToClipboard':
|
|
|
|
ZoteroPane.copySelectedItemsToClipboard(true)
|
|
|
|
break;
|
|
|
|
case 'copySelectedItemsToClipboard':
|
|
|
|
ZoteroPane.copySelectedItemsToClipboard();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw ('Command "' + command + '" not found in ZoteroPane.handleKeyDown()');
|
|
|
|
}
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function handleKeyUp(event, from) {
|
|
|
|
if (from == 'zotero-pane') {
|
|
|
|
if ((Zotero.isWin && event.keyCode == 17) ||
|
|
|
|
(!Zotero.isWin && event.keyCode == 18)) {
|
|
|
|
if (this.highlightTimer) {
|
|
|
|
this.highlightTimer.cancel();
|
|
|
|
this.highlightTimer = null;
|
|
|
|
}
|
|
|
|
ZoteroPane.collectionsView.setHighlightedRows();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Highlights collections containing selected items on Ctrl (Win) or
|
|
|
|
* Option/Alt (Mac/Linux) press
|
|
|
|
*/
|
|
|
|
function setHighlightedRowsCallback() {
|
|
|
|
var itemIDs = ZoteroPane.getSelectedItems(true);
|
|
|
|
if (itemIDs && itemIDs.length) {
|
|
|
|
var collectionIDs = Zotero.Collections.getCollectionsContainingItems(itemIDs, true);
|
|
|
|
if (collectionIDs) {
|
|
|
|
ZoteroPane.collectionsView.setHighlightedRows(collectionIDs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function handleKeyPress(event, from) {
|
|
|
|
if (from == 'zotero-collections-tree') {
|
|
|
|
if (event.keyCode == event.DOM_VK_BACK_SPACE ||
|
|
|
|
event.keyCode == event.DOM_VK_DELETE) {
|
|
|
|
ZoteroPane.deleteSelectedCollection();
|
|
|
|
event.preventDefault();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (from == 'zotero-items-tree') {
|
|
|
|
if (event.keyCode == event.DOM_VK_BACK_SPACE ||
|
|
|
|
event.keyCode == event.DOM_VK_DELETE) {
|
|
|
|
// If Cmd or Ctrl delete, delete from Library (with prompt)
|
|
|
|
var fromDB = event.metaKey || (!Zotero.isMac && event.ctrlKey);
|
2009-01-28 21:25:06 +00:00
|
|
|
ZoteroPane.deleteSelectedItems(fromDB);
|
2007-10-23 07:11:59 +00:00
|
|
|
event.preventDefault();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
/*
|
2006-06-17 00:57:50 +00:00
|
|
|
* Create a new item
|
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
2006-09-27 08:12:09 +00:00
|
|
|
*
|
|
|
|
* _data_ is an optional object with field:value for itemData
|
2006-06-02 15:27:52 +00:00
|
|
|
*/
|
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
2006-09-27 08:12:09 +00:00
|
|
|
function newItem(typeID, data)
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!Zotero.stateCheck()) {
|
|
|
|
this.displayErrorMessage(true);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var item = new Zotero.Item(false, typeID);
|
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
2006-09-27 08:12:09 +00:00
|
|
|
|
|
|
|
for (var i in data)
|
|
|
|
{
|
|
|
|
item.setField(i, data[i]);
|
|
|
|
}
|
|
|
|
|
2006-06-17 00:57:50 +00:00
|
|
|
item.save();
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
if (this.itemsView && this.itemsView._itemGroup.isCollection()) {
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
this.itemsView._itemGroup.ref.addItem(item.id);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
2006-06-25 04:57:52 +00:00
|
|
|
//set to Info tab
|
2006-10-02 23:15:27 +00:00
|
|
|
document.getElementById('zotero-view-item').selectedIndex = 0;
|
2006-08-04 14:23:44 +00:00
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
this.selectItem(item.id);
|
2007-10-23 07:11:59 +00:00
|
|
|
|
2006-08-04 14:23:44 +00:00
|
|
|
return item;
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
function newCollection(parent)
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2006-08-30 19:07:51 +00:00
|
|
|
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPromptService);
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
var untitled = Zotero.DB.getNextName('collections', 'collectionName',
|
2006-10-02 23:15:27 +00:00
|
|
|
Zotero.getString('pane.collections.untitled'));
|
2006-09-22 23:53:16 +00:00
|
|
|
|
|
|
|
var newName = { value: untitled };
|
2007-10-23 07:11:59 +00:00
|
|
|
var result = promptService.prompt(window,
|
|
|
|
Zotero.getString('pane.collections.newCollection'),
|
2006-10-02 23:15:27 +00:00
|
|
|
Zotero.getString('pane.collections.name'), newName, "", {});
|
2006-08-30 19:07:51 +00:00
|
|
|
|
|
|
|
if (!result)
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
return;
|
2006-08-30 19:07:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!newName.value)
|
|
|
|
{
|
2006-09-22 23:53:16 +00:00
|
|
|
newName.value = untitled;
|
2006-08-30 19:07:51 +00:00
|
|
|
}
|
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var collection = new Zotero.Collection;
|
|
|
|
collection.name = newName.value;
|
|
|
|
collection.parent = parent;
|
|
|
|
collection.save();
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
2006-08-09 11:43:33 +00:00
|
|
|
function newSearch()
|
|
|
|
{
|
2006-10-02 23:15:27 +00:00
|
|
|
var s = new Zotero.Search();
|
2007-10-23 07:11:59 +00:00
|
|
|
s.addCondition('title', 'contains', '');
|
2006-08-09 11:43:33 +00:00
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
var untitled = Zotero.getString('pane.collections.untitled');
|
|
|
|
untitled = Zotero.DB.getNextName('savedSearches', 'savedSearchName',
|
|
|
|
Zotero.getString('pane.collections.untitled'));
|
2006-09-22 23:53:16 +00:00
|
|
|
var io = {dataIn: {search: s, name: untitled}, dataOut: null};
|
2006-10-02 23:15:27 +00:00
|
|
|
window.openDialog('chrome://zotero/content/searchDialog.xul','','chrome,modal',io);
|
2006-08-09 11:43:33 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
function openAdvancedSearchWindow() {
|
|
|
|
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
|
|
|
.getService(Components.interfaces.nsIWindowMediator);
|
|
|
|
var enumerator = wm.getEnumerator('zotero:search');
|
|
|
|
while (enumerator.hasMoreElements()) {
|
|
|
|
var win = enumerator.getNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (win) {
|
|
|
|
win.focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var s = new Zotero.Search();
|
|
|
|
s.addCondition('title', 'contains', '');
|
|
|
|
var io = {dataIn: {search: s}, dataOut: null};
|
|
|
|
window.openDialog('chrome://zotero/content/advancedSearch.xul', '', 'chrome,dialog=no,centerscreen', io);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function toggleTagSelector(){
|
|
|
|
var zoteroPane = document.getElementById('zotero-pane');
|
|
|
|
var splitter = document.getElementById('zotero-tags-splitter');
|
|
|
|
var tagSelector = document.getElementById('zotero-tag-selector');
|
|
|
|
|
|
|
|
var showing = tagSelector.getAttribute('collapsed') == 'true';
|
|
|
|
tagSelector.setAttribute('collapsed', !showing);
|
|
|
|
splitter.setAttribute('collapsed', !showing);
|
|
|
|
this.updateTagSelectorSize();
|
|
|
|
|
|
|
|
// If showing, set scope to items in current view
|
|
|
|
// and focus filter textbox
|
|
|
|
if (showing) {
|
|
|
|
_setTagScope();
|
|
|
|
tagSelector.focusTextbox();
|
|
|
|
}
|
|
|
|
// If hiding, clear selection
|
|
|
|
else {
|
|
|
|
tagSelector.uninit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateTagSelectorSize() {
|
|
|
|
//Zotero.debug('Updating tag selector size');
|
|
|
|
var zoteroPane = document.getElementById('zotero-pane');
|
|
|
|
var splitter = document.getElementById('zotero-tags-splitter');
|
|
|
|
var tagSelector = document.getElementById('zotero-tag-selector');
|
|
|
|
|
|
|
|
// Nothing should be bigger than appcontent's height
|
|
|
|
var max = document.getElementById('appcontent').boxObject.height
|
|
|
|
- splitter.boxObject.height;
|
|
|
|
|
|
|
|
// Shrink tag selector to appcontent's height
|
|
|
|
var maxTS = max - COLLECTIONS_HEIGHT;
|
|
|
|
if (parseInt(tagSelector.getAttribute("height")) > maxTS) {
|
|
|
|
//Zotero.debug("Limiting tag selector height to appcontent");
|
|
|
|
tagSelector.setAttribute('height', maxTS);
|
|
|
|
}
|
|
|
|
|
Merged revisions 2640-2647,2651,2653-2654,2656-2658,2660-2667,2670-2672,2674-2677,2680,2683-2684,2687-2704,2707 to trunk via svnmerge from 1.0 branch
2008-05-16 09:14:11 +00:00
|
|
|
var height = tagSelector.boxObject.height;
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Zotero.debug("tagSelector.boxObject.height: " + tagSelector.boxObject.height);
|
|
|
|
Zotero.debug("tagSelector.getAttribute('height'): " + tagSelector.getAttribute('height'));
|
|
|
|
Zotero.debug("zoteroPane.boxObject.height: " + zoteroPane.boxObject.height);
|
|
|
|
Zotero.debug("zoteroPane.getAttribute('height'): " + zoteroPane.getAttribute('height'));
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Don't let the Z-pane jump back down to its previous height
|
|
|
|
// (if shrinking or hiding the tag selector let it clear the min-height)
|
|
|
|
if (zoteroPane.getAttribute('height') < zoteroPane.boxObject.height) {
|
|
|
|
//Zotero.debug("Setting Zotero pane height attribute to " + zoteroPane.boxObject.height);
|
|
|
|
zoteroPane.setAttribute('height', zoteroPane.boxObject.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tagSelector.getAttribute('collapsed') == 'true') {
|
|
|
|
// 32px is the default Z pane min-height in overlay.css
|
|
|
|
height = 32;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// tS.boxObject.height doesn't exist at startup, so get from attribute
|
|
|
|
if (!height) {
|
|
|
|
height = parseInt(tagSelector.getAttribute('height'));
|
|
|
|
}
|
|
|
|
// 121px seems to be enough room for the toolbar and collections
|
|
|
|
// tree at minimum height
|
|
|
|
height = height + 125;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Zotero.debug('Setting Zotero pane minheight to ' + height);
|
|
|
|
zoteroPane.setAttribute('minheight', height);
|
|
|
|
|
|
|
|
if (this.isShowing() && !this.isFullScreen()) {
|
|
|
|
zoteroPane.setAttribute('savedHeight', zoteroPane.boxObject.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fix bug whereby resizing the Z pane downward after resizing
|
|
|
|
// the tag selector up and then down sometimes caused the Z pane to
|
|
|
|
// stay at a fixed size and get pushed below the bottom
|
|
|
|
tagSelector.height++;
|
|
|
|
tagSelector.height--;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getTagSelection(){
|
|
|
|
var tagSelector = document.getElementById('zotero-tag-selector');
|
|
|
|
return tagSelector.selection ? tagSelector.selection : {};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function clearTagSelection() {
|
|
|
|
if (Zotero.hasValues(this.getTagSelection())) {
|
|
|
|
var tagSelector = document.getElementById('zotero-tag-selector');
|
|
|
|
tagSelector.clearAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sets the tag filter on the items view
|
|
|
|
*/
|
|
|
|
function updateTagFilter(){
|
|
|
|
this.itemsView.setFilter('tags', getTagSelection());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the tags scope to the items in the current view
|
|
|
|
*
|
|
|
|
* Passed to the items tree to trigger on changes
|
|
|
|
*/
|
|
|
|
function _setTagScope() {
|
|
|
|
var itemgroup = self.collectionsView.
|
|
|
|
_getItemAtRow(self.collectionsView.selection.currentIndex);
|
|
|
|
var tagSelector = document.getElementById('zotero-tag-selector');
|
|
|
|
if (!tagSelector.getAttribute('collapsed') ||
|
|
|
|
tagSelector.getAttribute('collapsed') == 'false') {
|
|
|
|
Zotero.debug('Updating tag selector with current tags');
|
|
|
|
tagSelector.scope = itemgroup.getChildTags();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-05 18:01:53 +00:00
|
|
|
function onCollectionSelected()
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.itemsView)
|
|
|
|
{
|
|
|
|
this.itemsView.unregister();
|
|
|
|
}
|
2006-06-06 22:43:58 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
document.getElementById('zotero-tb-search').value = "";
|
2006-07-24 22:12:25 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.collectionsView.selection.count == 1 && this.collectionsView.selection.currentIndex != -1) {
|
|
|
|
var itemgroup = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
|
2006-08-09 11:43:33 +00:00
|
|
|
itemgroup.setSearch('');
|
2007-10-23 07:11:59 +00:00
|
|
|
itemgroup.setTags(getTagSelection());
|
|
|
|
|
|
|
|
try {
|
|
|
|
Zotero.UnresponsiveScriptIndicator.disable();
|
|
|
|
this.itemsView = new Zotero.ItemTreeView(itemgroup);
|
|
|
|
this.itemsView.addCallback(_setTagScope);
|
|
|
|
document.getElementById('zotero-items-tree').view = this.itemsView;
|
|
|
|
this.itemsView.selection.clearSelection();
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
Zotero.UnresponsiveScriptIndicator.enable();
|
|
|
|
}
|
2006-06-05 13:08:16 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
if (itemgroup.isLibrary()) {
|
|
|
|
Zotero.Prefs.set('lastViewedFolder', 'L');
|
|
|
|
}
|
|
|
|
if (itemgroup.isCollection()) {
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
Zotero.Prefs.set('lastViewedFolder', 'C' + itemgroup.ref.id);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
else if (itemgroup.isSearch()) {
|
|
|
|
Zotero.Prefs.set('lastViewedFolder', 'S' + itemgroup.ref.id);
|
|
|
|
}
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
document.getElementById('zotero-items-tree').view = this.itemsView = null;
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-29 01:14:46 +00:00
|
|
|
|
2006-05-30 22:06:33 +00:00
|
|
|
function itemSelected()
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!Zotero.stateCheck()) {
|
|
|
|
this.displayErrorMessage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-01-28 21:25:06 +00:00
|
|
|
// Display restore button if items selected in Trash
|
|
|
|
if (this.itemsView && this.itemsView.selection.count) {
|
|
|
|
document.getElementById('zotero-item-restore-button').hidden
|
2009-01-29 01:14:46 +00:00
|
|
|
= !this.itemsView._itemGroup.isTrash()
|
|
|
|
|| _nonDeletedItemsSelected(this.itemsView);
|
2009-01-28 21:25:06 +00:00
|
|
|
}
|
2009-01-29 23:03:13 +00:00
|
|
|
else {
|
|
|
|
document.getElementById('zotero-item-restore-button').hidden = true;
|
|
|
|
}
|
2009-01-28 21:25:06 +00:00
|
|
|
|
|
|
|
var tabs = document.getElementById('zotero-view-tabs');
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.itemsView && this.itemsView.selection.count == 1 && this.itemsView.selection.currentIndex != -1)
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var item = this.itemsView._getItemAtRow(this.itemsView.selection.currentIndex);
|
2006-05-30 22:06:33 +00:00
|
|
|
|
2008-06-16 05:46:10 +00:00
|
|
|
if(item.ref.isNote()) {
|
2009-01-28 21:25:06 +00:00
|
|
|
tabs.hidden = true;
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
var noteEditor = document.getElementById('zotero-note-editor');
|
2008-12-29 06:18:41 +00:00
|
|
|
noteEditor.mode = this.itemsView.readOnly ? 'view' : 'edit';
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
|
|
|
|
// If loading new or different note, disable undo while we repopulate the text field
|
|
|
|
// so Undo doesn't end up clearing the field. This also ensures that Undo doesn't
|
|
|
|
// undo content from another note into the current one.
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
if (!noteEditor.item || noteEditor.item.id != item.ref.id) {
|
|
|
|
noteEditor.disableUndo();
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
}
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
noteEditor.parent = null;
|
|
|
|
noteEditor.item = item.ref;
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
noteEditor.enableUndo();
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
|
2009-01-28 21:25:06 +00:00
|
|
|
var viewButton = document.getElementById('zotero-view-note-button');
|
|
|
|
if (this.itemsView.readOnly) {
|
|
|
|
viewButton.hidden = true;
|
2006-10-04 06:57:49 +00:00
|
|
|
}
|
2009-01-28 21:25:06 +00:00
|
|
|
else {
|
|
|
|
viewButton.hidden = false;
|
|
|
|
viewButton.setAttribute('noteID', item.ref.id);
|
|
|
|
if (item.ref.getSource()) {
|
|
|
|
viewButton.setAttribute('sourceID', item.ref.getSource());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
viewButton.removeAttribute('sourceID');
|
|
|
|
}
|
2006-10-04 06:57:49 +00:00
|
|
|
}
|
2009-01-28 21:25:06 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
document.getElementById('zotero-item-pane-content').selectedIndex = 2;
|
2006-07-27 18:08:09 +00:00
|
|
|
}
|
2008-06-16 05:46:10 +00:00
|
|
|
|
|
|
|
else if(item.ref.isAttachment()) {
|
2009-01-28 21:25:06 +00:00
|
|
|
tabs.hidden = true;
|
|
|
|
|
2008-12-29 06:18:41 +00:00
|
|
|
var attachmentBox = document.getElementById('zotero-attachment-box');
|
|
|
|
attachmentBox.mode = this.itemsView.readOnly ? 'view' : 'edit';
|
|
|
|
attachmentBox.item = item.ref;
|
2006-10-02 00:00:50 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
document.getElementById('zotero-item-pane-content').selectedIndex = 3;
|
2006-06-27 20:37:02 +00:00
|
|
|
}
|
2008-06-16 05:46:10 +00:00
|
|
|
|
|
|
|
// Regular item
|
2006-06-27 20:37:02 +00:00
|
|
|
else
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
document.getElementById('zotero-item-pane-content').selectedIndex = 1;
|
2009-01-28 21:25:06 +00:00
|
|
|
if (this.itemsView.readOnly) {
|
|
|
|
document.getElementById('zotero-view-item').selectedIndex = 0;
|
|
|
|
ZoteroItemPane.viewItem(item.ref, 'view');
|
|
|
|
tabs.hidden = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ZoteroItemPane.viewItem(item.ref);
|
|
|
|
tabs.selectedIndex = document.getElementById('zotero-view-item').selectedIndex;
|
|
|
|
tabs.hidden = false;
|
|
|
|
}
|
2006-06-27 20:37:02 +00:00
|
|
|
}
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-28 21:25:06 +00:00
|
|
|
tabs.hidden = true;
|
2007-10-23 07:11:59 +00:00
|
|
|
document.getElementById('zotero-item-pane-content').selectedIndex = 0;
|
2006-06-20 13:59:59 +00:00
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
var label = document.getElementById('zotero-view-selected-label');
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
if (this.itemsView && this.itemsView.selection.count) {
|
|
|
|
label.value = Zotero.getString('pane.item.selected.multiple', this.itemsView.selection.count);
|
|
|
|
}
|
|
|
|
else {
|
2006-10-02 23:15:27 +00:00
|
|
|
label.value = Zotero.getString('pane.item.selected.zero');
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
2009-01-29 01:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if any selected items in the passed (trash) treeview are not deleted
|
|
|
|
*
|
|
|
|
* @param {nsITreeView}
|
|
|
|
* @return {Boolean}
|
|
|
|
*/
|
|
|
|
function _nonDeletedItemsSelected(itemsView) {
|
|
|
|
var start = {};
|
|
|
|
var end = {};
|
|
|
|
for (var i=0, len=itemsView.selection.getRangeCount(); i<len; i++) {
|
|
|
|
itemsView.selection.getRangeAt(i, start, end);
|
|
|
|
for (var j=start.value; j<=end.value; j++) {
|
|
|
|
if (!itemsView._getItemAtRow(j).ref.deleted) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
2006-10-04 06:57:49 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
function reindexItem() {
|
|
|
|
var items = this.getSelectedItems();
|
|
|
|
if (!items) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i=0; i<items.length; i++) {
|
|
|
|
if (!items[i].isAttachment()) {
|
|
|
|
continue;
|
|
|
|
}
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var itemID = items[i].id;
|
2007-10-23 07:11:59 +00:00
|
|
|
Zotero.Fulltext.indexItems(itemID, true);
|
|
|
|
}
|
2008-12-29 06:18:41 +00:00
|
|
|
document.getElementById('zotero-attachment-box').updateItemIndexedState();
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function duplicateSelectedItem() {
|
2008-12-02 09:36:41 +00:00
|
|
|
var item = this.getSelectedItems()[0];
|
|
|
|
if (item.getTags()) {
|
|
|
|
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPromptService);
|
|
|
|
ps.alert(null, "Error", "Duplication of tagged items is not available in this Zotero release.");
|
|
|
|
return;
|
|
|
|
}
|
2008-11-18 00:06:36 +00:00
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var newItem = this.getSelectedItems()[0].clone();
|
|
|
|
var newItemID = newItem.save()
|
2007-10-23 07:11:59 +00:00
|
|
|
var newItem = Zotero.Items.get(newItemID);
|
|
|
|
|
|
|
|
if (this.itemsView._itemGroup.isCollection()) {
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
this.itemsView._itemGroup.ref.addItem(newItem.id);
|
2007-10-23 07:11:59 +00:00
|
|
|
this.selectItem(newItemID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-28 21:25:06 +00:00
|
|
|
this.deleteSelectedItem = function () {
|
|
|
|
Zotero.debug("ZoteroPane.deleteSelectedItem() is deprecated -- use ZoteroPane.deleteSelectedItems()");
|
|
|
|
this.deleteSelectedItems();
|
|
|
|
}
|
|
|
|
|
2006-09-22 09:01:25 +00:00
|
|
|
/*
|
|
|
|
* _force_ deletes item from DB even if removing from a collection or search
|
|
|
|
*/
|
2009-01-28 21:25:06 +00:00
|
|
|
this.deleteSelectedItems = function (force) {
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.itemsView && this.itemsView.selection.count > 0) {
|
2006-09-22 09:01:25 +00:00
|
|
|
if (!force){
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.itemsView._itemGroup.isCollection()) {
|
2006-09-22 09:01:25 +00:00
|
|
|
var noPrompt = true;
|
|
|
|
}
|
|
|
|
// Do nothing in search view
|
2008-06-03 05:26:30 +00:00
|
|
|
else if (this.itemsView._itemGroup.isSearch() ||
|
|
|
|
this.itemsView._itemGroup.isShare()) {
|
2006-09-22 09:01:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-01-29 01:14:46 +00:00
|
|
|
// Do nothing in trash view if any non-deleted items are selected
|
|
|
|
else if (this.itemsView._itemGroup.isTrash()) {
|
|
|
|
var start = {};
|
|
|
|
var end = {};
|
|
|
|
for (var i=0, len=this.itemsView.selection.getRangeCount(); i<len; i++) {
|
|
|
|
this.itemsView.selection.getRangeAt(i, start, end);
|
|
|
|
for (var j=start.value; j<=end.value; j++) {
|
|
|
|
if (!this.itemsView._getItemAtRow(j).ref.deleted) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-22 08:26:54 +00:00
|
|
|
}
|
|
|
|
|
2006-08-04 14:36:04 +00:00
|
|
|
var eraseChildren = {value: true};
|
2006-07-31 19:14:06 +00:00
|
|
|
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPromptService);
|
2006-08-04 14:36:04 +00:00
|
|
|
var hasChildren;
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!this.getSelectedCollection()) {
|
2009-01-29 01:14:46 +00:00
|
|
|
var start = {};
|
|
|
|
var end = {};
|
2007-10-23 07:11:59 +00:00
|
|
|
for (var i=0, len=this.itemsView.selection.getRangeCount(); i<len; i++) {
|
2009-01-29 01:14:46 +00:00
|
|
|
this.itemsView.selection.getRangeAt(i, start, end);
|
|
|
|
for (var j=start.value; j<=end.value; j++) {
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.itemsView._getItemAtRow(j).numChildren()) {
|
2006-08-07 15:25:29 +00:00
|
|
|
hasChildren = true;
|
2006-08-30 21:34:51 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-01-29 01:14:46 +00:00
|
|
|
}
|
2006-08-07 15:25:29 +00:00
|
|
|
}
|
2006-08-04 14:36:04 +00:00
|
|
|
}
|
2006-09-22 08:26:54 +00:00
|
|
|
|
|
|
|
if (noPrompt || promptService.confirmCheck(
|
2006-08-30 21:34:51 +00:00
|
|
|
window,
|
2006-10-02 23:15:27 +00:00
|
|
|
Zotero.getString('pane.items.delete.title'),
|
2007-10-23 07:11:59 +00:00
|
|
|
Zotero.getString('pane.items.delete' + (this.itemsView.selection.count>1 ? '.multiple' : '')),
|
2006-10-02 23:15:27 +00:00
|
|
|
hasChildren ? Zotero.getString('pane.items.delete.attached') : '',
|
2006-08-30 21:34:51 +00:00
|
|
|
eraseChildren))
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
this.itemsView.deleteSelection(eraseChildren.value, force);
|
2006-08-30 21:34:51 +00:00
|
|
|
}
|
2006-07-31 19:14:06 +00:00
|
|
|
}
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 15:00:13 +00:00
|
|
|
function deleteSelectedCollection()
|
2006-06-02 14:11:23 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.collectionsView.selection.count == 1) {
|
2006-08-31 06:27:02 +00:00
|
|
|
var row =
|
2007-10-23 07:11:59 +00:00
|
|
|
this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
|
2006-08-31 06:27:02 +00:00
|
|
|
|
|
|
|
if (row.isCollection())
|
|
|
|
{
|
2006-10-02 23:15:27 +00:00
|
|
|
if (confirm(Zotero.getString('pane.collections.delete')))
|
2006-08-31 06:27:02 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
this.collectionsView.deleteSelection();
|
2006-08-31 06:27:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (row.isSearch())
|
|
|
|
{
|
2006-10-02 23:15:27 +00:00
|
|
|
if (confirm(Zotero.getString('pane.collections.deleteSearch')))
|
2006-08-31 06:27:02 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
this.collectionsView.deleteSelection();
|
2006-08-31 06:27:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-02 14:11:23 +00:00
|
|
|
}
|
|
|
|
|
2009-01-28 21:25:06 +00:00
|
|
|
|
|
|
|
this.restoreSelectedItems = function () {
|
|
|
|
var items = this.getSelectedItems();
|
|
|
|
if (!items) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Zotero.DB.beginTransaction();
|
|
|
|
for (var i=0; i<items.length; i++) {
|
|
|
|
items[i].deleted = false;
|
|
|
|
items[i].save();
|
|
|
|
}
|
|
|
|
Zotero.DB.commitTransaction();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.emptyTrash = function () {
|
|
|
|
var prompt = Components.classes["@mozilla.org/network/default-prompt;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrompt);
|
|
|
|
|
|
|
|
var result = prompt.confirm("",
|
|
|
|
Zotero.getString('pane.collections.emptyTrash') + "\n\n" +
|
|
|
|
Zotero.getString('general.actionCannotBeUndone'));
|
|
|
|
if (result) {
|
|
|
|
Zotero.Items.emptyTrash();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-30 04:09:34 +00:00
|
|
|
function editSelectedCollection()
|
2006-06-05 13:08:16 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.collectionsView.selection.count > 0) {
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var row = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
|
2006-06-05 13:08:16 +00:00
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
if (row.isCollection()) {
|
2006-08-30 19:07:51 +00:00
|
|
|
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPromptService);
|
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var newName = { value: row.getName() };
|
2006-08-30 19:07:51 +00:00
|
|
|
var result = promptService.prompt(window, "",
|
2006-10-02 23:15:27 +00:00
|
|
|
Zotero.getString('pane.collections.rename'), newName, "", {});
|
2006-08-30 19:07:51 +00:00
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
if (result && newName.value) {
|
|
|
|
row.ref.name = newName.value;
|
|
|
|
row.ref.save();
|
2006-08-30 19:07:51 +00:00
|
|
|
}
|
2006-08-09 11:43:33 +00:00
|
|
|
}
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
else {
|
2008-06-02 09:15:43 +00:00
|
|
|
var s = new Zotero.Search(row.ref.id);
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var io = {dataIn: {search: s, name: row.getName()}, dataOut: null};
|
2006-10-02 23:15:27 +00:00
|
|
|
window.openDialog('chrome://zotero/content/searchDialog.xul','','chrome,modal',io);
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
if (io.dataOut) {
|
2007-10-23 07:11:59 +00:00
|
|
|
this.onCollectionSelected(); //reload itemsView
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
}
|
2006-08-09 11:43:33 +00:00
|
|
|
}
|
2006-06-05 13:08:16 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-06 19:53:27 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
function copySelectedItemsToClipboard(asCitations) {
|
|
|
|
var items = this.getSelectedItems();
|
|
|
|
if (!items.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure at least one item is not a standalone note or attachment
|
|
|
|
var haveRegularItem = false;
|
|
|
|
for each(var item in items) {
|
|
|
|
if (item.isRegularItem()) {
|
|
|
|
haveRegularItem = true;
|
|
|
|
break;
|
|
|
|
}
|
2006-06-21 22:23:42 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!haveRegularItem) {
|
|
|
|
window.alert(Zotero.getString("fileInterface.noReferencesError"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var url = window.content.location.href;
|
|
|
|
var [mode, format] = Zotero.QuickCopy.getFormatFromURL(url).split('=');
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
var [mode, contentType] = mode.split('/');
|
2006-06-21 22:23:42 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
if (mode == 'bibliography') {
|
|
|
|
if (asCitations) {
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
Zotero_File_Interface.copyCitationToClipboard(items, format, contentType == 'html');
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
else {
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
Zotero_File_Interface.copyItemsToClipboard(items, format, contentType == 'html');
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mode == 'export') {
|
|
|
|
// Copy citations doesn't work in export mode
|
|
|
|
if (asCitations) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Zotero_File_Interface.exportItemsToClipboard(items, format);
|
|
|
|
}
|
|
|
|
}
|
2006-06-01 16:40:43 +00:00
|
|
|
}
|
2006-06-08 18:42:55 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
function clearQuicksearch() {
|
|
|
|
var search = document.getElementById('zotero-tb-search');
|
|
|
|
if (search.value != '') {
|
|
|
|
search.value = '';
|
|
|
|
search.doCommand('cmd_zotero_search');
|
|
|
|
}
|
2006-06-08 18:42:55 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
function handleSearchKeypress(textbox, event) {
|
|
|
|
// Events that turn find-as-you-type on
|
|
|
|
if (event.keyCode == event.DOM_VK_ESCAPE) {
|
|
|
|
textbox.value = '';
|
|
|
|
ZoteroPane.setItemsPaneMessage(Zotero.getString('searchInProgress'));
|
|
|
|
setTimeout("document.getElementById('zotero-tb-search').doCommand('cmd_zotero_search'); ZoteroPane.clearItemsPaneMessage();", 1);
|
|
|
|
}
|
|
|
|
else if (event.keyCode == event.DOM_VK_RETURN ||
|
|
|
|
event.keyCode == event.DOM_VK_ENTER) {
|
|
|
|
textbox.skipTimeout = true;
|
|
|
|
ZoteroPane.setItemsPaneMessage(Zotero.getString('searchInProgress'));
|
|
|
|
setTimeout("document.getElementById('zotero-tb-search').doCommand('cmd_zotero_search'); ZoteroPane.clearItemsPaneMessage();", 1);
|
|
|
|
}
|
2006-06-02 12:59:58 +00:00
|
|
|
}
|
2006-06-19 15:00:13 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
function handleSearchInput(textbox, event) {
|
|
|
|
// This is the new length, except, it seems, when the change is a
|
|
|
|
// result of Undo or Redo
|
|
|
|
if (!textbox.value.length) {
|
|
|
|
textbox.skipTimeout = true;
|
|
|
|
ZoteroPane.setItemsPaneMessage(Zotero.getString('searchInProgress'));
|
|
|
|
setTimeout("document.getElementById('zotero-tb-search').doCommand('cmd_zotero_search'); ZoteroPane.clearItemsPaneMessage();", 1);
|
|
|
|
}
|
|
|
|
else if (textbox.value.indexOf('"') != -1) {
|
|
|
|
ZoteroPane.setItemsPaneMessage(Zotero.getString('advancedSearchMode'));
|
2006-07-31 19:14:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
function search()
|
2006-07-24 22:12:25 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.itemsView) {
|
|
|
|
var searchVal = document.getElementById('zotero-tb-search').value;
|
|
|
|
this.itemsView.setFilter('search', searchVal);
|
|
|
|
|
|
|
|
document.getElementById('zotero-tb-search-cancel').hidden = searchVal == "";
|
2006-07-24 22:12:25 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
2006-07-24 22:12:25 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Select item in current collection or, if not there, in Library
|
|
|
|
*
|
|
|
|
* If _inLibrary_, force switch to Library
|
|
|
|
* If _expand_, open item if it's a container
|
|
|
|
*/
|
|
|
|
function selectItem(itemID, inLibrary, expand)
|
2006-08-30 04:09:34 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!itemID) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.itemsView) {
|
|
|
|
if (!this.itemsView._itemGroup.isLibrary() && inLibrary) {
|
|
|
|
this.collectionsView.selection.select(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
var selected = this.itemsView.selectItem(itemID, expand);
|
|
|
|
if (!selected) {
|
|
|
|
this.collectionsView.selection.select(0);
|
|
|
|
this.itemsView.selectItem(itemID, expand);
|
2006-08-30 04:09:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
function getSelectedCollection(asID) {
|
|
|
|
if (this.collectionsView.selection
|
|
|
|
&& this.collectionsView.selection.count > 0
|
|
|
|
&& this.collectionsView.selection.currentIndex != -1) {
|
|
|
|
var collection = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
|
|
|
|
if (collection && collection.isCollection()) {
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
return asID ? collection.ref.id : collection.ref;
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// If the Zotero pane hasn't yet been opened, use the lastViewedFolder pref
|
|
|
|
else {
|
|
|
|
var lastViewedFolder = Zotero.Prefs.get('lastViewedFolder');
|
|
|
|
var matches = lastViewedFolder.match(/^(?:(C|S)([0-9]+)|L)$/);
|
|
|
|
if (matches && matches[1] == 'C') {
|
|
|
|
var col = Zotero.Collections.get(matches[2]);
|
|
|
|
if (col) {
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
return asID ? col.id : col;
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSelectedSavedSearch(asID)
|
2006-07-24 22:12:25 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.collectionsView.selection.count > 0 && this.collectionsView.selection.currentIndex != -1) {
|
|
|
|
var collection = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
|
|
|
|
if (collection && collection.isSearch()) {
|
|
|
|
return asID ? collection.ref.id : collection.ref;
|
2006-07-26 15:09:06 +00:00
|
|
|
}
|
2006-07-24 22:12:25 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
// If the Zotero pane hasn't yet been opened, use the lastViewedFolder pref
|
|
|
|
else {
|
|
|
|
var lastViewedFolder = Zotero.Prefs.get('lastViewedFolder');
|
|
|
|
var matches = lastViewedFolder.match(/^(?:(C|S)([0-9]+)|L)$/);
|
|
|
|
if (matches && matches[1] == 'S') {
|
|
|
|
var search = Zotero.Search.get(matches[2]);
|
|
|
|
if (search) {
|
|
|
|
return asID ? search.id : search;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2006-07-24 22:12:25 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
/*
|
|
|
|
* Return an array of Item objects for selected items
|
|
|
|
*
|
|
|
|
* If asIDs is true, return an array of itemIDs instead
|
|
|
|
*/
|
|
|
|
function getSelectedItems(asIDs)
|
|
|
|
{
|
2008-06-17 20:39:26 +00:00
|
|
|
if (!this.itemsView) {
|
|
|
|
return [];
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
2008-06-17 20:39:26 +00:00
|
|
|
|
|
|
|
return this.itemsView.getSelectedItems(asIDs);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2008-06-17 20:39:26 +00:00
|
|
|
* Returns an array of Zotero.Item objects of visible items in current sort order
|
|
|
|
*
|
|
|
|
* If asIDs is true, return an array of itemIDs instead
|
2007-10-23 07:11:59 +00:00
|
|
|
*/
|
2008-06-17 20:39:26 +00:00
|
|
|
function getSortedItems(asIDs) {
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!this.itemsView) {
|
2008-06-17 20:39:26 +00:00
|
|
|
return [];
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
2008-06-17 20:39:26 +00:00
|
|
|
return this.itemsView.getSortedItems(asIDs);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getSortField() {
|
|
|
|
if (!this.itemsView) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.itemsView.getSortField();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getSortDirection() {
|
|
|
|
if (!this.itemsView) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.itemsView.getSortDirection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-19 15:00:13 +00:00
|
|
|
function buildCollectionContextMenu()
|
|
|
|
{
|
2006-10-02 23:15:27 +00:00
|
|
|
var menu = document.getElementById('zotero-collectionmenu');
|
2006-06-19 15:00:13 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
var m = {
|
|
|
|
newCollection: 0,
|
|
|
|
newSavedSearch: 1,
|
|
|
|
newSubcollection: 2,
|
|
|
|
sep1: 3,
|
|
|
|
editSelectedCollection: 4,
|
|
|
|
removeCollection: 5,
|
|
|
|
sep2: 6,
|
|
|
|
exportCollection: 7,
|
|
|
|
createBibCollection: 8,
|
|
|
|
exportFile: 9,
|
2009-01-28 21:25:06 +00:00
|
|
|
loadReport: 10,
|
|
|
|
emptyTrash: 11
|
2007-10-23 07:11:59 +00:00
|
|
|
};
|
|
|
|
|
2006-08-30 04:09:34 +00:00
|
|
|
// Collection
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.collectionsView.selection.count == 1 &&
|
|
|
|
this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex).isCollection())
|
2006-08-30 04:09:34 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var show = [m.newSubcollection, m.sep1, m.editSelectedCollection, m.removeCollection,
|
|
|
|
m.sep2, m.exportCollection, m.createBibCollection, m.loadReport];
|
|
|
|
if (this.itemsView.rowCount>0) {
|
|
|
|
var enable = [m.exportCollection, m.createBibCollection, m.loadReport];
|
2006-08-30 17:16:33 +00:00
|
|
|
}
|
Merged revisions 2989,2994,2996-2999,3001,3003-3004,3007,3010,3012,3015-3016,3026-3029,3036-3038,3040-3041,3046,3048,3050,3052,3054-3055,3057-3058,3066,3069-3073 from 1.0 branch via svnmerge
2008-07-22 05:45:32 +00:00
|
|
|
else if (!this.collectionsView.isContainerEmpty(this.collectionsView.selection.currentIndex)) {
|
|
|
|
var enable = [m.exportCollection];
|
|
|
|
var disable = [m.createBibCollection, m.loadReport];
|
|
|
|
}
|
2006-08-30 17:16:33 +00:00
|
|
|
else
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var disable = [m.exportCollection, m.createBibCollection, m.loadReport];
|
2006-08-30 17:16:33 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
2009-01-28 21:25:06 +00:00
|
|
|
// Adjust labels
|
2007-10-23 07:11:59 +00:00
|
|
|
menu.childNodes[m.editSelectedCollection].setAttribute('label', Zotero.getString('pane.collections.menu.rename.collection'));
|
|
|
|
menu.childNodes[m.removeCollection].setAttribute('label', Zotero.getString('pane.collections.menu.remove.collection'));
|
|
|
|
menu.childNodes[m.exportCollection].setAttribute('label', Zotero.getString('pane.collections.menu.export.collection'));
|
|
|
|
menu.childNodes[m.createBibCollection].setAttribute('label', Zotero.getString('pane.collections.menu.createBib.collection'));
|
|
|
|
menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.collections.menu.generateReport.collection'));
|
2006-08-30 04:09:34 +00:00
|
|
|
}
|
|
|
|
// Saved Search
|
2007-10-23 07:11:59 +00:00
|
|
|
else if (this.collectionsView.selection.count == 1 &&
|
|
|
|
this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex).isSearch()) {
|
|
|
|
var show = [m.editSelectedCollection, m.removeCollection, m.sep2, m.exportCollection,
|
|
|
|
m.createBibCollection, m.loadReport];
|
|
|
|
|
|
|
|
if (this.itemsView.rowCount>0) {
|
|
|
|
var enable = [m.exportCollection, m.createBibCollection, m.loadReport];
|
2006-08-30 17:16:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var disable = [m.exportCollection, m.createBibCollection, m.loadReport];
|
2006-08-30 17:16:33 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
2009-01-28 21:25:06 +00:00
|
|
|
// Adjust labels
|
2007-10-23 07:11:59 +00:00
|
|
|
menu.childNodes[m.editSelectedCollection].setAttribute('label', Zotero.getString('pane.collections.menu.edit.savedSearch'));
|
|
|
|
menu.childNodes[m.removeCollection].setAttribute('label', Zotero.getString('pane.collections.menu.remove.savedSearch'));
|
|
|
|
menu.childNodes[m.exportCollection].setAttribute('label', Zotero.getString('pane.collections.menu.export.savedSearch'));
|
|
|
|
menu.childNodes[m.createBibCollection].setAttribute('label', Zotero.getString('pane.collections.menu.createBib.savedSearch'));
|
|
|
|
menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.collections.menu.generateReport.savedSearch'));
|
2006-06-19 15:00:13 +00:00
|
|
|
}
|
2009-01-28 21:25:06 +00:00
|
|
|
// Trash
|
|
|
|
else if (this.collectionsView.selection.count == 1 &&
|
|
|
|
this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex).isTrash()) {
|
|
|
|
var show = [m.emptyTrash];
|
|
|
|
}
|
2006-08-30 04:09:34 +00:00
|
|
|
// Library
|
2006-06-19 15:00:13 +00:00
|
|
|
else
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var show = [m.newCollection, m.newSavedSearch, m.sep1, m.exportFile];
|
2006-08-30 04:09:34 +00:00
|
|
|
}
|
|
|
|
|
2006-08-30 17:16:33 +00:00
|
|
|
for (var i in disable)
|
|
|
|
{
|
|
|
|
menu.childNodes[disable[i]].setAttribute('disabled', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i in enable)
|
|
|
|
{
|
|
|
|
menu.childNodes[enable[i]].setAttribute('disabled', false);
|
|
|
|
}
|
|
|
|
|
2009-01-28 21:25:06 +00:00
|
|
|
// Hide all items by default
|
|
|
|
for each(var pos in m) {
|
|
|
|
menu.childNodes[pos].setAttribute('hidden', true);
|
2006-08-30 04:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (var i in show)
|
|
|
|
{
|
|
|
|
menu.childNodes[show[i]].setAttribute('hidden', false);
|
2006-06-19 15:00:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function buildItemContextMenu()
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var m = {
|
|
|
|
showInLibrary: 0,
|
|
|
|
sep1: 1,
|
|
|
|
addNote: 2,
|
|
|
|
attachSnapshot: 3,
|
|
|
|
attachLink: 4,
|
|
|
|
sep2: 5,
|
|
|
|
duplicateItem: 6,
|
|
|
|
deleteItem: 7,
|
|
|
|
deleteFromLibrary: 8,
|
|
|
|
sep3: 9,
|
|
|
|
exportItems: 10,
|
|
|
|
createBib: 11,
|
|
|
|
loadReport: 12,
|
|
|
|
sep4: 13,
|
2008-08-22 05:35:44 +00:00
|
|
|
reindexItem: 14,
|
|
|
|
recognizePDF: 15
|
2007-10-23 07:11:59 +00:00
|
|
|
};
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
var menu = document.getElementById('zotero-itemmenu');
|
2006-06-19 15:00:13 +00:00
|
|
|
|
2006-10-05 05:56:56 +00:00
|
|
|
var enable = [], disable = [], show = [], hide = [], multiple = '';
|
|
|
|
|
2008-06-03 05:26:30 +00:00
|
|
|
// TODO: implement menu for remote items
|
|
|
|
if (this.itemsView.readOnly) {
|
|
|
|
for each(var pos in m) {
|
|
|
|
disable.push(pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (this.itemsView && this.itemsView.selection.count > 0) {
|
2007-10-23 07:11:59 +00:00
|
|
|
enable.push(m.showInLibrary, m.addNote, m.attachSnapshot, m.attachLink,
|
|
|
|
m.sep2, m.duplicateItem, m.deleteItem, m.deleteFromLibrary,
|
|
|
|
m.exportItems, m.createBib, m.loadReport);
|
2006-10-05 05:56:56 +00:00
|
|
|
|
|
|
|
// Multiple items selected
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.itemsView.selection.count > 1) {
|
2006-10-05 05:56:56 +00:00
|
|
|
var multiple = '.multiple';
|
2007-10-23 07:11:59 +00:00
|
|
|
hide.push(m.showInLibrary, m.sep1, m.addNote, m.attachSnapshot,
|
|
|
|
m.attachLink, m.sep2, m.duplicateItem);
|
|
|
|
|
2008-08-22 05:35:44 +00:00
|
|
|
// If all items can be reindexed, or all items can be recognized, show option
|
2008-09-23 02:11:56 +00:00
|
|
|
if (Zotero.Fulltext.pdfConverterIsRegistered()) {
|
|
|
|
var items = this.getSelectedItems();
|
|
|
|
var canIndex = true;
|
|
|
|
var canRecognize = true;
|
|
|
|
for (var i=0; i<items.length; i++) {
|
|
|
|
if (!Zotero.Fulltext.canReindex(items[i].id)) {
|
|
|
|
canIndex = false;
|
|
|
|
}
|
|
|
|
if(!Zotero_RecognizePDF.canRecognize(items[i])) {
|
|
|
|
canRecognize = false;
|
|
|
|
}
|
|
|
|
if(!canIndex && !canRecognize) {
|
|
|
|
break;
|
|
|
|
}
|
2008-08-22 05:35:44 +00:00
|
|
|
}
|
2008-09-23 02:11:56 +00:00
|
|
|
if (canIndex) {
|
|
|
|
show.push(m.reindexItem);
|
2008-08-22 05:35:44 +00:00
|
|
|
}
|
2008-09-23 02:11:56 +00:00
|
|
|
else {
|
|
|
|
hide.push(m.reindexItem);
|
|
|
|
}
|
|
|
|
if (canRecognize) {
|
|
|
|
show.push(m.recognizePDF);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hide.push(m.recognizePDF);
|
|
|
|
}
|
|
|
|
if (canIndex || canRecognize) {
|
|
|
|
show.push(m.sep4);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hide.push(m.sep4);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-05 05:56:56 +00:00
|
|
|
}
|
|
|
|
// Single item selected
|
|
|
|
else
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var item = this.itemsView._getItemAtRow(this.itemsView.selection.currentIndex).ref;
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var itemID = item.id;
|
2007-10-23 07:11:59 +00:00
|
|
|
menu.setAttribute('itemID', itemID);
|
|
|
|
|
|
|
|
// Show in Library
|
|
|
|
if (!this.itemsView._itemGroup.isLibrary()) {
|
|
|
|
show.push(m.showInLibrary, m.sep1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hide.push(m.showInLibrary, m.sep1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.isRegularItem())
|
2006-10-05 05:56:56 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
show.push(m.addNote, m.attachSnapshot, m.attachLink, m.sep2);
|
2006-10-05 05:56:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
hide.push(m.addNote, m.attachSnapshot, m.attachLink, m.sep2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.isAttachment()) {
|
2008-08-22 05:38:36 +00:00
|
|
|
var showSep4 = false;
|
2007-10-23 07:11:59 +00:00
|
|
|
hide.push(m.duplicateItem);
|
2008-09-23 02:11:56 +00:00
|
|
|
if (Zotero.Fulltext.pdfConverterIsRegistered()) {
|
|
|
|
// If not linked URL, show reindex line
|
|
|
|
if (Zotero.Fulltext.canReindex(item.id)) {
|
|
|
|
show.push(m.reindexItem);
|
|
|
|
showSep4 = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hide.push(m.reindexItem);
|
|
|
|
}
|
2008-08-22 05:35:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Zotero_RecognizePDF.canRecognize(item)) {
|
|
|
|
show.push(m.recognizePDF);
|
|
|
|
showSep4 = true;
|
2008-09-23 02:11:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-08-22 05:35:44 +00:00
|
|
|
hide.push(m.recognizePDF);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
2008-08-22 05:35:44 +00:00
|
|
|
|
2008-09-23 02:11:56 +00:00
|
|
|
if (showSep4) {
|
2008-08-22 05:35:44 +00:00
|
|
|
show.push(m.sep4);
|
2008-09-23 02:11:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-08-22 05:35:44 +00:00
|
|
|
hide.push(m.sep4);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
show.push(m.duplicateItem);
|
2008-08-22 05:35:44 +00:00
|
|
|
hide.push(m.sep4, m.reindexItem, m.recognizePDF);
|
2006-10-05 05:56:56 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-26 15:28:31 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
// No items selected
|
2006-06-19 15:00:13 +00:00
|
|
|
else
|
2006-07-26 15:28:31 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
// Show in Library
|
|
|
|
if (!this.itemsView._itemGroup.isLibrary()) {
|
|
|
|
show.push(m.showInLibrary, m.sep1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hide.push(m.showInLibrary, m.sep1);
|
|
|
|
}
|
|
|
|
|
|
|
|
disable.push(m.showInLibrary, m.duplicateItem, m.deleteItem,
|
|
|
|
m.deleteFromLibrary, m.exportItems, m.createBib, m.loadReport);
|
2008-08-22 05:35:44 +00:00
|
|
|
hide.push(m.addNote, m.attachSnapshot, m.attachLink, m.sep2, m.sep4, m.reindexItem,
|
|
|
|
m.recognizePDF);
|
2006-07-26 15:28:31 +00:00
|
|
|
}
|
2006-09-22 09:01:25 +00:00
|
|
|
|
2006-10-05 05:56:56 +00:00
|
|
|
// Remove from collection
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.itemsView._itemGroup.isCollection() && !(item && item.getSource()))
|
2006-07-26 15:28:31 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
menu.childNodes[m.deleteItem].setAttribute('label', Zotero.getString('pane.items.menu.remove' + multiple));
|
|
|
|
show.push(m.deleteItem);
|
2006-07-26 15:28:31 +00:00
|
|
|
}
|
2006-06-19 15:00:13 +00:00
|
|
|
else
|
2006-07-26 15:28:31 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
hide.push(m.deleteItem);
|
2006-10-05 05:56:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Plural if necessary
|
2007-10-23 07:11:59 +00:00
|
|
|
menu.childNodes[m.deleteFromLibrary].setAttribute('label', Zotero.getString('pane.items.menu.erase' + multiple));
|
|
|
|
menu.childNodes[m.exportItems].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple));
|
|
|
|
menu.childNodes[m.createBib].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple));
|
|
|
|
menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.items.menu.generateReport' + multiple));
|
|
|
|
menu.childNodes[m.reindexItem].setAttribute('label', Zotero.getString('pane.items.menu.reindexItem' + multiple));
|
2008-08-22 05:35:44 +00:00
|
|
|
menu.childNodes[m.recognizePDF].setAttribute('label', Zotero.getString('pane.items.menu.recognizePDF' + multiple));
|
2006-10-05 05:56:56 +00:00
|
|
|
|
|
|
|
for (var i in disable)
|
|
|
|
{
|
|
|
|
menu.childNodes[disable[i]].setAttribute('disabled', true);
|
2006-07-26 15:28:31 +00:00
|
|
|
}
|
2006-09-22 09:01:25 +00:00
|
|
|
|
2006-10-05 05:56:56 +00:00
|
|
|
for (var i in enable)
|
|
|
|
{
|
|
|
|
menu.childNodes[enable[i]].setAttribute('disabled', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i in hide)
|
|
|
|
{
|
|
|
|
menu.childNodes[hide[i]].setAttribute('hidden', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i in show)
|
|
|
|
{
|
|
|
|
menu.childNodes[show[i]].setAttribute('hidden', false);
|
|
|
|
}
|
2006-06-19 15:00:13 +00:00
|
|
|
}
|
2006-06-27 22:47:17 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
2006-08-02 16:08:19 +00:00
|
|
|
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
|
|
|
|
function onDoubleClick(event, tree)
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (event && tree && event.type == "dblclick") {
|
2006-08-02 16:08:19 +00:00
|
|
|
var row = {}, col = {}, obj = {};
|
|
|
|
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
// obj.value == 'cell'/'text'/'image'
|
|
|
|
if (!obj.value) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tree.id == 'zotero-collections-tree') {
|
|
|
|
var s = this.getSelectedSavedSearch();
|
|
|
|
if (s) {
|
|
|
|
this.editSelectedCollection();
|
2006-08-02 16:08:19 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
else if (tree.id == 'zotero-items-tree') {
|
2008-06-03 05:26:30 +00:00
|
|
|
if (this.itemsView.readOnly) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
if (this.itemsView && this.itemsView.selection.currentIndex > -1) {
|
|
|
|
var item = this.getSelectedItems()[0];
|
|
|
|
if (item && item.isNote()) {
|
|
|
|
document.getElementById('zotero-view-note-button').doCommand();
|
|
|
|
}
|
|
|
|
else if (item && item.isAttachment()) {
|
|
|
|
this.viewSelectedAttachment(event);
|
|
|
|
}
|
2006-08-11 15:48:26 +00:00
|
|
|
}
|
2006-08-02 16:08:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
2008-11-30 20:18:48 +00:00
|
|
|
this.startDrag = function (event, element) {
|
|
|
|
if (Zotero.isFx2 || Zotero.isFx30) {
|
|
|
|
nsDragAndDrop.startDrag(event, element);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
element.onDragStart(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.dragEnter = function (event, element) {
|
|
|
|
if (Zotero.isFx2 || Zotero.isFx30) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return element.onDragEnter(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.dragOver = function (event, element) {
|
|
|
|
if (Zotero.isFx2 || Zotero.isFx30) {
|
|
|
|
return nsDragAndDrop.dragOver(event, element);
|
|
|
|
}
|
|
|
|
return element.onDragOver(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.dragDrop = function (event, element) {
|
|
|
|
if (Zotero.isFx2 || Zotero.isFx30) {
|
|
|
|
return nsDragAndDrop.drop(event, element);
|
|
|
|
}
|
|
|
|
return element.onDrop(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
/*
|
|
|
|
* Loads a URL following the standard modifier key behavior
|
|
|
|
* (e.g. meta-click == new background tab, meta-shift-click == new front tab,
|
|
|
|
* shift-click == new window, no modifier == frontmost tab
|
|
|
|
*/
|
|
|
|
function loadURI(uri, event, data) {
|
|
|
|
// Open in new tab
|
|
|
|
if (event.metaKey || (!Zotero.isMac && event.ctrlKey)) {
|
|
|
|
var tab = gBrowser.addTab(uri);
|
|
|
|
var browser = gBrowser.getBrowserForTab(tab);
|
|
|
|
|
|
|
|
if (event.shiftKey) {
|
|
|
|
gBrowser.selectedTab = tab;
|
|
|
|
}
|
Merged revisions 3080-3081,3084,3087-3088,3090,3092,3099-3103,3113-3114,3132,3134-3143,3145,3148-3151,3154-3159,3165,3174,3194,3234-3235,3239-3240,3244,3246-3254,3258-3262,3268,3270,3274,3279,3286-3288,3294-3295 from 1.0 branch via svnmerge
2008-09-01 01:54:00 +00:00
|
|
|
} else if (event.shiftKey) {
|
2007-10-23 07:11:59 +00:00
|
|
|
window.open(uri, "zotero-loaded-page",
|
|
|
|
"menubar=yes,location=yes,toolbar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes");
|
Merged revisions 3080-3081,3084,3087-3088,3090,3092,3099-3103,3113-3114,3132,3134-3143,3145,3148-3151,3154-3159,3165,3174,3194,3234-3235,3239-3240,3244,3246-3254,3258-3262,3268,3270,3274,3279,3286-3288,3294-3295 from 1.0 branch via svnmerge
2008-09-01 01:54:00 +00:00
|
|
|
} else {
|
2007-10-23 07:11:59 +00:00
|
|
|
window.loadURI(uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function setItemsPaneMessage(msg, lock) {
|
|
|
|
var elem = document.getElementById('zotero-items-pane-message-box');
|
|
|
|
|
|
|
|
if (elem.getAttribute('locked') == 'true') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (elem.hasChildNodes()) {
|
|
|
|
elem.removeChild(elem.firstChild);
|
|
|
|
}
|
|
|
|
var msgParts = msg.split("\n\n");
|
|
|
|
for (var i=0; i<msgParts.length; i++) {
|
|
|
|
var desc = document.createElement('description');
|
|
|
|
desc.appendChild(document.createTextNode(msgParts[i]));
|
|
|
|
elem.appendChild(desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make message permanent
|
|
|
|
if (lock) {
|
|
|
|
elem.setAttribute('locked', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById('zotero-items-pane-content').selectedIndex = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function clearItemsPaneMessage() {
|
|
|
|
// If message box is locked, don't clear
|
|
|
|
var box = document.getElementById('zotero-items-pane-message-box');
|
|
|
|
if (box.getAttribute('locked') == 'true') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById('zotero-items-pane-content').selectedIndex = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Updates browser context menu options
|
|
|
|
function contextPopupShowing()
|
2006-06-27 22:47:17 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!Zotero.Prefs.get('browserContentContextMenu')) {
|
|
|
|
return;
|
2006-10-02 06:44:16 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
var menuitem = document.getElementById("zotero-context-add-to-current-note");
|
|
|
|
var showing = false;
|
|
|
|
if (menuitem){
|
|
|
|
var items = ZoteroPane.getSelectedItems();
|
|
|
|
if (ZoteroPane.itemsView.selection && ZoteroPane.itemsView.selection.count==1
|
|
|
|
&& items[0] && items[0].isNote()
|
|
|
|
&& window.gContextMenu.isTextSelected)
|
|
|
|
{
|
|
|
|
menuitem.hidden = false;
|
|
|
|
showing = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menuitem.hidden = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var menuitem = document.getElementById("zotero-context-add-to-new-note");
|
|
|
|
if (menuitem){
|
|
|
|
if (window.gContextMenu.isTextSelected)
|
2006-10-02 06:44:16 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
menuitem.hidden = false;
|
|
|
|
showing = true;
|
2006-10-02 06:44:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
menuitem.hidden = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var menuitem = document.getElementById("zotero-context-save-link-as-snapshot");
|
|
|
|
if (menuitem) {
|
|
|
|
if (window.gContextMenu.onLink) {
|
|
|
|
menuitem.hidden = false;
|
|
|
|
showing = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
menuitem.hidden = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var menuitem = document.getElementById("zotero-context-save-image-as-snapshot");
|
|
|
|
if (menuitem) {
|
|
|
|
// Not using window.gContextMenu.hasBGImage -- if the user wants it,
|
|
|
|
// they can use the Firefox option to view and then import from there
|
|
|
|
if (window.gContextMenu.onImage) {
|
|
|
|
menuitem.hidden = false;
|
|
|
|
showing = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
menuitem.hidden = true;
|
2006-10-02 06:44:16 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
var separator = document.getElementById("zotero-context-separator");
|
|
|
|
separator.hidden = !showing;
|
2006-07-26 14:30:38 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
function newNote(popup, parent, text) {
|
|
|
|
if (!Zotero.stateCheck()) {
|
|
|
|
this.displayErrorMessage(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!popup) {
|
2008-10-24 11:10:05 +00:00
|
|
|
if (!text) {
|
|
|
|
text = '';
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
2008-10-24 11:10:05 +00:00
|
|
|
text = Zotero.Utilities.prototype.trim(text);
|
2007-10-23 07:11:59 +00:00
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var item = new Zotero.Item(false, 'note');
|
|
|
|
item.setNote(text);
|
|
|
|
if (parent) {
|
|
|
|
item.setSource(parent);
|
|
|
|
}
|
|
|
|
var itemID = item.save();
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
if (this.itemsView && this.itemsView._itemGroup.isCollection()) {
|
|
|
|
this.itemsView._itemGroup.ref.addItem(itemID);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.selectItem(itemID);
|
|
|
|
|
|
|
|
document.getElementById('zotero-note-editor').focus();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// TODO: _text_
|
|
|
|
var c = this.getSelectedCollection();
|
|
|
|
if (c) {
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
this.openNoteWindow(null, c.id);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.openNoteWindow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function addTextToNote(text)
|
2006-07-26 14:30:38 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
try {
|
|
|
|
// trim
|
|
|
|
text = text.replace(/^[\xA0\r\n\s]*(.*)[\xA0\r\n\s]*$/m, "$1");
|
|
|
|
}
|
|
|
|
catch (e){}
|
|
|
|
|
|
|
|
if (!text || !text.length)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var items = this.getSelectedItems();
|
|
|
|
if (this.itemsView.selection.count == 1 && items[0] && items[0].isNote()) {
|
|
|
|
var note = items[0].getNote()
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
|
|
|
|
items[0].setNote(note == '' ? text : note + "\n\n" + text);
|
|
|
|
items[0].save();
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
var noteElem = document.getElementById('zotero-note-editor')
|
|
|
|
noteElem.focus();
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
noteElem.noteField.inputField.editor.
|
2007-10-23 07:11:59 +00:00
|
|
|
selectionController.scrollSelectionIntoView(1,
|
|
|
|
1,
|
|
|
|
true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2006-06-27 22:47:17 +00:00
|
|
|
}
|
2006-07-31 16:58:14 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
function openNoteWindow(itemID, col, parentItemID)
|
|
|
|
{
|
|
|
|
var name = null;
|
|
|
|
|
|
|
|
if (itemID) {
|
|
|
|
// Create a name for this window so we can focus it later
|
|
|
|
//
|
|
|
|
// Collection is only used on new notes, so we don't need to
|
|
|
|
// include it in the name
|
|
|
|
name = 'zotero-note-' + itemID;
|
|
|
|
|
|
|
|
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
|
|
|
.getService(Components.interfaces.nsIWindowMediator);
|
|
|
|
var e = wm.getEnumerator('');
|
|
|
|
while (e.hasMoreElements()) {
|
|
|
|
var w = e.getNext();
|
|
|
|
if (w.name == name) {
|
|
|
|
w.focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.open('chrome://zotero/content/note.xul?v=1'
|
|
|
|
+ (itemID ? '&id=' + itemID : '') + (col ? '&coll=' + col : '')
|
|
|
|
+ (parentItemID ? '&p=' + parentItemID : ''),
|
|
|
|
name, 'chrome,resizable,centerscreen');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-12 00:18:20 +00:00
|
|
|
function addAttachmentFromDialog(link, id)
|
2006-07-31 16:58:14 +00:00
|
|
|
{
|
|
|
|
var nsIFilePicker = Components.interfaces.nsIFilePicker;
|
|
|
|
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
|
|
|
.createInstance(nsIFilePicker);
|
2007-10-23 07:11:59 +00:00
|
|
|
fp.init(window, Zotero.getString('pane.item.attachments.select'), nsIFilePicker.modeOpenMultiple);
|
|
|
|
fp.appendFilters(Components.interfaces.nsIFilePicker.filterAll);
|
2006-07-31 16:58:14 +00:00
|
|
|
|
|
|
|
if(fp.show() == nsIFilePicker.returnOK)
|
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var files = fp.files;
|
|
|
|
while (files.hasMoreElements()){
|
|
|
|
var file = files.getNext();
|
|
|
|
file.QueryInterface(Components.interfaces.nsILocalFile);
|
|
|
|
var attachmentID;
|
|
|
|
if(link)
|
|
|
|
attachmentID = Zotero.Attachments.linkFromFile(file, id);
|
|
|
|
else
|
|
|
|
attachmentID = Zotero.Attachments.importFromFile(file, id);
|
|
|
|
|
|
|
|
if(attachmentID && !id)
|
|
|
|
{
|
|
|
|
var c = this.getSelectedCollection();
|
|
|
|
if(c)
|
|
|
|
c.addItem(attachmentID);
|
|
|
|
}
|
2006-07-31 19:14:06 +00:00
|
|
|
}
|
2006-07-31 16:58:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
2006-09-27 08:12:09 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
function addItemFromPage() {
|
|
|
|
if (!Zotero.stateCheck()) {
|
|
|
|
this.displayErrorMessage(true);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var progressWin = new Zotero.ProgressWindow();
|
|
|
|
progressWin.changeHeadline(Zotero.getString('ingester.scraping'));
|
|
|
|
var icon = 'chrome://zotero/skin/treeitem-webpage.png';
|
|
|
|
progressWin.addLines(window.content.document.title, icon)
|
|
|
|
progressWin.show();
|
|
|
|
progressWin.startCloseTimer();
|
|
|
|
|
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
2006-09-27 08:12:09 +00:00
|
|
|
var data = {
|
|
|
|
title: window.content.document.title,
|
|
|
|
url: window.content.document.location.href,
|
|
|
|
accessDate: "CURRENT_TIMESTAMP"
|
2006-08-04 14:23:44 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
var item = this.newItem(Zotero.ItemTypes.getID('webpage'), data);
|
2006-10-04 22:59:07 +00:00
|
|
|
|
|
|
|
// Automatically save snapshot if pref set
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
if (item.id && Zotero.Prefs.get('automaticSnapshots'))
|
2006-10-04 22:59:07 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
var f = function() {
|
|
|
|
// We set |noParent|, since child items don't belong to collections
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
ZoteroPane.addAttachmentFromPage(false, item.id, true);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
// Give progress window time to appear
|
|
|
|
setTimeout(f, 300);
|
2006-10-04 22:59:07 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
return item.id;
|
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
2006-09-27 08:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
/*
|
|
|
|
* Create an attachment from the current page
|
|
|
|
*
|
|
|
|
* |link| -- create web link instead of snapshot
|
|
|
|
* |itemID| -- itemID of parent item
|
|
|
|
* |noParent| -- don't add to current collection
|
|
|
|
*/
|
|
|
|
function addAttachmentFromPage(link, itemID, noParent)
|
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
2006-09-27 08:12:09 +00:00
|
|
|
{
|
2007-10-23 07:11:59 +00:00
|
|
|
if (!Zotero.stateCheck()) {
|
|
|
|
this.displayErrorMessage(true);
|
|
|
|
return;
|
2006-10-01 19:59:34 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
if (!noParent) {
|
|
|
|
var progressWin = new Zotero.ProgressWindow();
|
|
|
|
progressWin.changeHeadline(Zotero.getString('save.' + (link ? 'link' : 'attachment')));
|
|
|
|
var type = link ? 'web-link' : 'snapshot';
|
|
|
|
var icon = 'chrome://zotero/skin/treeitem-attachment-' + type + '.png';
|
|
|
|
progressWin.addLines(window.content.document.title, icon)
|
|
|
|
progressWin.show();
|
|
|
|
progressWin.startCloseTimer();
|
|
|
|
|
|
|
|
if (this.itemsView && this.itemsView._itemGroup.isCollection()) {
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
var parentCollectionID = this.itemsView._itemGroup.ref.id;
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
2006-10-01 19:59:34 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
var f = function() {
|
|
|
|
if (link) {
|
|
|
|
Zotero.Attachments.linkFromDocument(window.content.document, itemID, parentCollectionID);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Zotero.Attachments.importFromDocument(window.content.document, itemID, false, parentCollectionID);
|
|
|
|
}
|
2006-10-01 19:59:34 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
// Give progress window time to appear
|
|
|
|
setTimeout(f, 100);
|
2006-07-31 16:58:14 +00:00
|
|
|
}
|
2006-08-11 15:48:26 +00:00
|
|
|
|
2006-10-02 00:00:50 +00:00
|
|
|
|
2008-12-29 06:18:41 +00:00
|
|
|
function viewAttachment(itemID, event, noLocateOnMissing) {
|
2007-10-23 07:11:59 +00:00
|
|
|
var attachment = Zotero.Items.get(itemID);
|
|
|
|
if (!attachment.isAttachment()) {
|
|
|
|
throw ("Item " + itemID + " is not an attachment in ZoteroPane.viewAttachment()");
|
|
|
|
}
|
|
|
|
|
2008-12-29 06:18:41 +00:00
|
|
|
if (attachment.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
2007-10-23 07:11:59 +00:00
|
|
|
this.loadURI(attachment.getField('url'), event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var file = attachment.getFile();
|
|
|
|
if (file) {
|
|
|
|
var mimeType = attachment.getAttachmentMIMEType();
|
|
|
|
// If no MIME type specified, try to detect again (I guess in case
|
|
|
|
// we've gotten smarter since the file was imported?)
|
|
|
|
if (!mimeType) {
|
|
|
|
var mimeType = Zotero.MIME.getMIMETypeFromFile(file);
|
|
|
|
var ext = Zotero.File.getExtension(file);
|
|
|
|
|
|
|
|
// TODO: update DB with new info
|
|
|
|
}
|
|
|
|
var ext = Zotero.File.getExtension(file);
|
|
|
|
var isNative = Zotero.MIME.hasNativeHandler(mimeType, ext);
|
|
|
|
var internal = Zotero.MIME.hasInternalHandler(mimeType, ext);
|
2006-08-11 15:48:26 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
if (isNative ||
|
|
|
|
(internal && !Zotero.Prefs.get('launchNonNativeFiles'))) {
|
Merged revisions 2989,2994,2996-2999,3001,3003-3004,3007,3010,3012,3015-3016,3026-3029,3036-3038,3040-3041,3046,3048,3050,3052,3054-3055,3057-3058,3066,3069-3073 from 1.0 branch via svnmerge
2008-07-22 05:45:32 +00:00
|
|
|
|
|
|
|
var url = 'zotero://attachment/' + itemID + '/';
|
|
|
|
this.loadURI(url, event, { attachmentID: itemID});
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
else {
|
Merged revisions 2989,2994,2996-2999,3001,3003-3004,3007,3010,3012,3015-3016,3026-3029,3036-3038,3040-3041,3046,3048,3050,3052,3054-3055,3057-3058,3066,3069-3073 from 1.0 branch via svnmerge
2008-07-22 05:45:32 +00:00
|
|
|
var fileURL = attachment.getLocalFileURL();
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
// Some platforms don't have nsILocalFile.launch, so we just load it and
|
|
|
|
// let the Firefox external helper app window handle it
|
|
|
|
try {
|
- Added file.js to chnmIScholarService.js
- Fixed bug in File.hasInternalHandler() (no access to navigator from XPCOM)
- Changed "View Attachment" action to check File.hasInternalHandler() and use window.loadURI() for internally handled files and nsIFile.launch() for external -- this prevents the user from getting a helper app dialog when they try to view external files. I basically had to duplicate most of Mozilla's content detection logic and "guess" whether or not it will be able to handle the file internally, which seems a little silly, but, while I feel there are probably better ways to do various parts of this, what's here seems to do the trick. Let me know if you notice it guessing incorrectly (i.e. you get a helper app dialog rather than having a file just open or it launches a file that should've just been loaded into the window). Also look for text files that should be launched rather than opened, especially XML-based data files, as this is a chance for Scholar to be smarter than Firefox itself--for example, OmniGraffle files, which are actually just XML files, normally open up in Firefox as an XML tree, but Scholar will launch them instead. (I imagine the same will need to be done for OmniOutliner, among other things...)
2006-08-12 03:45:57 +00:00
|
|
|
file.launch();
|
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
catch (e) {
|
|
|
|
window.loadURI(fileURL);
|
|
|
|
}
|
2006-10-02 00:00:50 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
else {
|
2008-12-29 06:18:41 +00:00
|
|
|
this.showAttachmentNotFoundDialog(itemID, noLocateOnMissing);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-29 06:18:41 +00:00
|
|
|
function viewSelectedAttachment(event, noLocateOnMissing)
|
2007-10-23 07:11:59 +00:00
|
|
|
{
|
|
|
|
if (this.itemsView && this.itemsView.selection.count == 1) {
|
2008-12-29 06:18:41 +00:00
|
|
|
this.viewAttachment(this.getSelectedItems(true)[0], event, noLocateOnMissing);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
2006-10-02 00:00:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-29 06:18:41 +00:00
|
|
|
this.showAttachmentInFilesystem = function (itemID, noLocateOnMissing) {
|
|
|
|
var attachment = Zotero.Items.get(itemID)
|
|
|
|
if (attachment.attachmentLinkMode != Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
|
|
|
var file = attachment.getFile();
|
|
|
|
if (file){
|
|
|
|
try {
|
|
|
|
file.reveal();
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
// On platforms that don't support nsILocalFile.reveal() (e.g. Linux),
|
|
|
|
// "double-click" the parent directory
|
2007-10-23 07:11:59 +00:00
|
|
|
try {
|
2008-12-29 06:18:41 +00:00
|
|
|
var parent = file.parent.QueryInterface(Components.interfaces.nsILocalFile);
|
|
|
|
parent.launch();
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
2008-12-29 06:18:41 +00:00
|
|
|
// If launch also fails, try the OS handler
|
2007-10-23 07:11:59 +00:00
|
|
|
catch (e) {
|
2008-12-29 06:18:41 +00:00
|
|
|
var uri = Components.classes["@mozilla.org/network/io-service;1"].
|
|
|
|
getService(Components.interfaces.nsIIOService).
|
|
|
|
newFileURI(parent);
|
|
|
|
var protocolService =
|
|
|
|
Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].
|
|
|
|
getService(Components.interfaces.nsIExternalProtocolService);
|
|
|
|
protocolService.loadUrl(uri);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-29 06:18:41 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.showAttachmentNotFoundDialog(attachment.id, noLocateOnMissing)
|
2006-08-11 15:48:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
|
|
|
|
2008-12-29 06:18:41 +00:00
|
|
|
function showAttachmentNotFoundDialog(itemID, noLocate) {
|
2007-10-23 07:11:59 +00:00
|
|
|
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
|
|
|
|
createInstance(Components.interfaces.nsIPromptService);
|
2008-12-29 06:18:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Don't show Locate button
|
|
|
|
if (noLocate) {
|
|
|
|
var index = ps.alert(null,
|
|
|
|
Zotero.getString('pane.item.attachments.fileNotFound.title'),
|
|
|
|
Zotero.getString('pane.item.attachments.fileNotFound.text')
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-25 07:37:47 +00:00
|
|
|
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
|
|
|
|
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
|
2007-10-23 07:11:59 +00:00
|
|
|
var index = ps.confirmEx(null,
|
|
|
|
Zotero.getString('pane.item.attachments.fileNotFound.title'),
|
|
|
|
Zotero.getString('pane.item.attachments.fileNotFound.text'),
|
2008-10-25 07:37:47 +00:00
|
|
|
buttonFlags, Zotero.getString('general.locate'), null,
|
2007-10-23 07:11:59 +00:00
|
|
|
null, null, {});
|
|
|
|
|
2008-10-25 07:37:47 +00:00
|
|
|
if (index == 0) {
|
2007-10-23 07:11:59 +00:00
|
|
|
this.relinkAttachment(itemID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function relinkAttachment(itemID) {
|
|
|
|
var item = Zotero.Items.get(itemID);
|
|
|
|
if (!item) {
|
|
|
|
throw('Item ' + itemID + ' not found in ZoteroPane.relinkAttachment()');
|
|
|
|
}
|
|
|
|
|
|
|
|
var nsIFilePicker = Components.interfaces.nsIFilePicker;
|
|
|
|
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
|
|
|
.createInstance(nsIFilePicker);
|
|
|
|
fp.init(window, Zotero.getString('pane.item.attachments.select'), nsIFilePicker.modeOpen);
|
|
|
|
|
|
|
|
|
|
|
|
var file = item.getFile(false, true);
|
|
|
|
var dir = Zotero.File.getClosestDirectory(file);
|
|
|
|
if (dir) {
|
|
|
|
dir.QueryInterface(Components.interfaces.nsILocalFile);
|
|
|
|
fp.displayDirectory = dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
fp.appendFilters(Components.interfaces.nsIFilePicker.filterAll);
|
|
|
|
|
|
|
|
if (fp.show() == nsIFilePicker.returnOK) {
|
|
|
|
var file = fp.file;
|
|
|
|
file.QueryInterface(Components.interfaces.nsILocalFile);
|
|
|
|
item.relinkAttachmentFile(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-29 14:13:29 +00:00
|
|
|
this.setLastSyncStatus = function (tooltip) {
|
|
|
|
var label = tooltip.firstChild.nextSibling;
|
|
|
|
|
|
|
|
var msg = Zotero.Sync.Runner.lastSyncError;
|
|
|
|
if (msg) {
|
|
|
|
label.value = 'Last error: ' + msg; // TODO: localize
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var lastSyncTime = Zotero.Sync.Server.lastLocalSyncTime;
|
|
|
|
msg = 'Last sync: ' // TODO: localize
|
|
|
|
+ (lastSyncTime
|
|
|
|
? new Date(lastSyncTime * 1000).toLocaleString()
|
|
|
|
: 'Not yet synced'
|
|
|
|
);
|
|
|
|
label.value = msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
function reportErrors() {
|
|
|
|
var errors = Zotero.getErrors(true);
|
|
|
|
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
|
|
|
.getService(Components.interfaces.nsIWindowWatcher);
|
|
|
|
var data = {
|
|
|
|
msg: Zotero.getString('errorReport.followingErrors'),
|
|
|
|
e: errors.join('\n\n'),
|
|
|
|
askForSteps: true
|
|
|
|
};
|
|
|
|
var io = { wrappedJSObject: { Zotero: Zotero, data: data } };
|
|
|
|
var win = ww.openWindow(null, "chrome://zotero/content/errorReport.xul",
|
|
|
|
"zotero-error-report", "chrome,centerscreen,modal", io);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Display an error message saying that an error has occurred and Firefox
|
|
|
|
* needs to be restarted.
|
|
|
|
*
|
|
|
|
* If |popup| is TRUE, display in popup progress window; otherwise, display
|
|
|
|
* as items pane message
|
|
|
|
*/
|
|
|
|
function displayErrorMessage(popup) {
|
|
|
|
var reportErrorsStr = Zotero.getString('errorReport.reportErrors');
|
|
|
|
var reportInstructions =
|
|
|
|
Zotero.getString('errorReport.reportInstructions', reportErrorsStr)
|
|
|
|
|
|
|
|
// Display as popup progress window
|
|
|
|
if (popup) {
|
|
|
|
var pw = new Zotero.ProgressWindow();
|
|
|
|
pw.changeHeadline(Zotero.getString('general.errorHasOccurred'));
|
|
|
|
var desc = Zotero.getString('general.restartFirefox') + ' '
|
|
|
|
+ reportInstructions;
|
|
|
|
pw.addDescription(desc);
|
|
|
|
pw.show();
|
|
|
|
pw.startCloseTimer(8000);
|
|
|
|
}
|
|
|
|
// Display as items pane message
|
|
|
|
else {
|
|
|
|
var msg = Zotero.getString('general.errorHasOccurred') + ' '
|
|
|
|
+ Zotero.getString('general.restartFirefox') + '\n\n'
|
|
|
|
+ reportInstructions;
|
|
|
|
self.setItemsPaneMessage(msg, true);
|
|
|
|
}
|
|
|
|
}
|
2006-06-02 12:59:58 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
window.addEventListener("load", function(e) { ZoteroPane.onLoad(e); }, false);
|
2007-10-23 07:11:59 +00:00
|
|
|
window.addEventListener("unload", function(e) { ZoteroPane.onUnload(e); }, false);
|