2011-01-30 09:44:01 +00:00
/ *
* * * * * BEGIN LICENSE BLOCK * * * * *
Copyright © 2009 Center for History and New Media
George Mason University , Fairfax , Virginia , USA
http : //zotero.org
This file is part of Zotero .
Zotero is free software : you can redistribute it and / or modify
2011-05-18 18:34:22 +00:00
it under the terms of the GNU Affero General Public License as published by
2011-01-30 09:44:01 +00:00
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Zotero is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
2011-05-18 18:34:22 +00:00
GNU Affero General Public License for more details .
2011-01-30 09:44:01 +00:00
2011-05-18 18:34:22 +00:00
You should have received a copy of the GNU Affero General Public License
2011-01-30 09:44:01 +00:00
along with Zotero . If not , see < http : //www.gnu.org/licenses/>.
* * * * * END LICENSE BLOCK * * * * *
* /
2011-02-03 20:22:56 +00:00
const ZOTERO _TAB _URL = "chrome://zotero/content/tab.xul" ;
2011-01-30 09:44:01 +00:00
/ *
* This object contains the various functions for the interface
* /
var ZoteroPane = new function ( )
{
2011-09-06 01:26:13 +00:00
var _unserialized = false ;
2011-01-30 09:44:01 +00:00
this . collectionsView = false ;
this . itemsView = false ;
this . _ _defineGetter _ _ ( 'loaded' , function ( ) _loaded ) ;
//Privileged methods
this . init = init ;
this . destroy = destroy ;
this . makeVisible = makeVisible ;
this . isShowing = isShowing ;
this . isFullScreen = isFullScreen ;
this . handleKeyDown = handleKeyDown ;
this . handleKeyUp = handleKeyUp ;
this . setHighlightedRowsCallback = setHighlightedRowsCallback ;
this . handleKeyPress = handleKeyPress ;
this . newItem = newItem ;
this . newCollection = newCollection ;
this . newSearch = newSearch ;
this . openAdvancedSearchWindow = openAdvancedSearchWindow ;
this . toggleTagSelector = toggleTagSelector ;
this . updateTagSelectorSize = updateTagSelectorSize ;
this . getTagSelection = getTagSelection ;
this . clearTagSelection = clearTagSelection ;
this . updateTagFilter = updateTagFilter ;
this . onCollectionSelected = onCollectionSelected ;
this . reindexItem = reindexItem ;
this . duplicateSelectedItem = duplicateSelectedItem ;
this . editSelectedCollection = editSelectedCollection ;
this . copySelectedItemsToClipboard = copySelectedItemsToClipboard ;
this . clearQuicksearch = clearQuicksearch ;
this . handleSearchKeypress = handleSearchKeypress ;
this . handleSearchInput = handleSearchInput ;
this . search = search ;
this . selectItem = selectItem ;
this . getSelectedCollection = getSelectedCollection ;
this . getSelectedSavedSearch = getSelectedSavedSearch ;
this . getSelectedItems = getSelectedItems ;
this . getSortedItems = getSortedItems ;
this . getSortField = getSortField ;
this . getSortDirection = getSortDirection ;
this . buildItemContextMenu = buildItemContextMenu ;
this . loadURI = loadURI ;
this . setItemsPaneMessage = setItemsPaneMessage ;
this . clearItemsPaneMessage = clearItemsPaneMessage ;
this . contextPopupShowing = contextPopupShowing ;
this . openNoteWindow = openNoteWindow ;
this . addTextToNote = addTextToNote ;
this . addAttachmentFromDialog = addAttachmentFromDialog ;
this . viewAttachment = viewAttachment ;
this . viewSelectedAttachment = viewSelectedAttachment ;
this . showAttachmentNotFoundDialog = showAttachmentNotFoundDialog ;
this . relinkAttachment = relinkAttachment ;
this . reportErrors = reportErrors ;
this . displayErrorMessage = displayErrorMessage ;
2011-05-19 23:00:01 +00:00
this . document = document ;
2011-01-30 09:44:01 +00:00
const COLLECTIONS _HEIGHT = 32 ; // minimum height of the collections pane and toolbar
2011-08-25 21:24:51 +00:00
var self = this ,
_loaded = false , _madeVisible = false ,
titlebarcolorState , titleState , observerService ,
2013-11-05 20:52:40 +00:00
_reloadFunctions = [ ] , _beforeReloadFunctions = [ ] ;
2011-01-30 09:44:01 +00:00
2011-06-14 00:36:21 +00:00
/ * *
2011-01-30 09:44:01 +00:00
* Called when the window containing Zotero pane is open
* /
2011-06-14 00:36:21 +00:00
function init ( ) {
2011-01-30 09:44:01 +00:00
// Set "Report Errors..." label via property rather than DTD entity,
// since we need to reference it in script elsewhere
document . getElementById ( 'zotero-tb-actions-reportErrors' ) . setAttribute ( 'label' ,
Zotero . getString ( 'errorReport.reportErrors' ) ) ;
// Set key down handler
2011-03-08 23:46:01 +00:00
document . getElementById ( 'appcontent' ) . addEventListener ( 'keydown' , ZoteroPane _Local . handleKeyDown , true ) ;
2011-01-30 09:44:01 +00:00
if ( Zotero . locked ) {
return ;
}
_loaded = true ;
2011-02-12 19:56:13 +00:00
var zp = document . getElementById ( 'zotero-pane' ) ;
2011-02-13 03:51:24 +00:00
Zotero . setFontSize ( zp ) ;
2011-06-14 00:36:21 +00:00
ZoteroPane _Local . updateToolbarPosition ( ) ;
window . addEventListener ( "resize" , ZoteroPane _Local . updateToolbarPosition , false ) ;
window . setTimeout ( ZoteroPane _Local . updateToolbarPosition , 0 ) ;
2011-01-30 09:44:01 +00:00
2011-04-26 17:43:00 +00:00
Zotero . updateQuickSearchBox ( document ) ;
2011-04-25 15:27:49 +00:00
2011-01-30 09:44:01 +00:00
if ( Zotero . isMac ) {
//document.getElementById('zotero-tb-actions-zeroconf-update').setAttribute('hidden', false);
document . getElementById ( 'zotero-pane-stack' ) . setAttribute ( 'platform' , 'mac' ) ;
} else if ( Zotero . isWin ) {
document . getElementById ( 'zotero-pane-stack' ) . setAttribute ( 'platform' , 'win' ) ;
}
2014-10-14 06:22:44 +00:00
// Use pre-Yosemite search fields before Fx34
// See note in chrome/content/zotero-platform/mac/overlay.css
if ( Zotero . isMac && Zotero . platformMajorVersion < 34 && Zotero . oscpu . contains ( ' 10.10' ) ) {
document . getElementById ( 'zotero-pane-stack' ) . setAttribute ( 'oldsearchfield' , 'true' )
}
2011-06-14 00:36:21 +00:00
// register an observer for Zotero reload
observerService = Components . classes [ "@mozilla.org/observer-service;1" ]
. getService ( Components . interfaces . nsIObserverService ) ;
2011-07-03 04:33:37 +00:00
observerService . addObserver ( _reloadObserver , "zotero-reloaded" , false ) ;
2013-11-05 20:52:40 +00:00
observerService . addObserver ( _reloadObserver , "zotero-before-reload" , false ) ;
this . addBeforeReloadListener ( function ( newMode ) {
if ( newMode == "connector" ) {
ZoteroPane _Local . setItemsPaneMessage ( Zotero . getString ( 'connector.standaloneOpen' ) ) ;
}
return ;
} ) ;
2011-06-14 00:36:21 +00:00
this . addReloadListener ( _loadPane ) ;
// continue loading pane
_loadPane ( ) ;
}
/ * *
* Called on window load or when has been reloaded after switching into or out of connector
* mode
* /
function _loadPane ( ) {
2013-12-14 07:07:36 +00:00
if ( ! Zotero || ! Zotero . initialized || Zotero . isConnector ) return ;
2011-06-14 00:36:21 +00:00
2013-12-14 07:07:36 +00:00
ZoteroPane _Local . clearItemsPaneMessage ( ) ;
2011-06-14 00:36:21 +00:00
2011-01-30 09:44:01 +00:00
//Initialize collections view
2011-06-14 00:36:21 +00:00
ZoteroPane _Local . collectionsView = new Zotero . CollectionTreeView ( ) ;
2011-01-30 09:44:01 +00:00
var collectionsTree = document . getElementById ( 'zotero-collections-tree' ) ;
2011-06-14 00:36:21 +00:00
collectionsTree . view = ZoteroPane _Local . collectionsView ;
2011-01-30 09:44:01 +00:00
collectionsTree . controllers . appendController ( new Zotero . CollectionTreeCommandController ( collectionsTree ) ) ;
2012-12-11 20:16:40 +00:00
collectionsTree . addEventListener ( "mousedown" , ZoteroPane _Local . onTreeMouseDown , true ) ;
2011-03-08 23:46:01 +00:00
collectionsTree . addEventListener ( "click" , ZoteroPane _Local . onTreeClick , true ) ;
2011-01-30 09:44:01 +00:00
var itemsTree = document . getElementById ( 'zotero-items-tree' ) ;
itemsTree . controllers . appendController ( new Zotero . ItemTreeCommandController ( itemsTree ) ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
itemsTree . addEventListener ( "mousedown" , ZoteroPane _Local . onTreeMouseDown , true ) ;
2011-03-08 23:46:01 +00:00
itemsTree . addEventListener ( "click" , ZoteroPane _Local . onTreeClick , true ) ;
2011-01-30 09:44:01 +00:00
var menu = document . getElementById ( "contentAreaContextMenu" ) ;
2011-03-08 23:46:01 +00:00
menu . addEventListener ( "popupshowing" , ZoteroPane _Local . contextPopupShowing , false ) ;
2011-01-30 09:44:01 +00:00
Zotero . Keys . windowInit ( document ) ;
if ( Zotero . restoreFromServer ) {
Zotero . restoreFromServer = false ;
setTimeout ( function ( ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var buttonFlags = ( ps . BUTTON _POS _0 ) * ( ps . BUTTON _TITLE _IS _STRING )
+ ( ps . BUTTON _POS _1 ) * ( ps . BUTTON _TITLE _CANCEL ) ;
var index = ps . confirmEx (
null ,
"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 ( {
onSuccess : function ( ) {
Zotero . Sync . Runner . setSyncIcon ( ) ;
ps . alert (
null ,
"Restore Completed" ,
"The local Zotero database has been successfully restored."
) ;
} ,
onError : function ( msg ) {
ps . alert (
null ,
"Restore Failed" ,
"An error occurred while restoring from the server:\n\n"
+ msg
) ;
Zotero . Sync . Runner . error ( msg ) ;
}
} ) ;
}
} , 1000 ) ;
}
// If the database was initialized or there are no sync credentials and
// Zotero hasn't been run before in this profile, display the start page
// -- this way the page won't be displayed when they sync their DB to
// another profile or if the DB is initialized erroneously (e.g. while
// switching data directory locations)
2011-07-02 16:52:34 +00:00
else if ( Zotero . Prefs . get ( 'firstRun2' ) ) {
2011-01-30 09:44:01 +00:00
if ( Zotero . Schema . dbInitialized || ! Zotero . Sync . Server . enabled ) {
setTimeout ( function ( ) {
2011-07-02 16:52:34 +00:00
if ( Zotero . isStandalone ) {
2011-07-03 04:33:37 +00:00
ZoteroPane _Local . loadURI ( "https://www.zotero.org/start_standalone" ) ;
2011-07-02 16:52:34 +00:00
} else {
2011-07-03 04:33:37 +00:00
gBrowser . selectedTab = gBrowser . addTab ( "https://www.zotero.org/start" ) ;
2011-07-02 16:52:34 +00:00
}
2011-01-30 09:44:01 +00:00
} , 400 ) ;
}
Zotero . Prefs . set ( 'firstRun2' , false ) ;
try {
Zotero . Prefs . clear ( 'firstRun' ) ;
}
catch ( e ) { }
}
// Hide sync debugging menu by default
if ( Zotero . Prefs . get ( 'sync.debugMenu' ) ) {
var sep = document . getElementById ( 'zotero-tb-actions-sync-separator' ) ;
sep . hidden = false ;
sep . nextSibling . hidden = false ;
sep . nextSibling . nextSibling . hidden = false ;
sep . nextSibling . nextSibling . nextSibling . hidden = false ;
}
2012-11-11 00:38:22 +00:00
if ( Zotero . openPane ) {
Zotero . openPane = false ;
setTimeout ( function ( ) {
ZoteroPane _Local . show ( ) ;
} , 0 ) ;
}
2011-01-30 09:44:01 +00:00
}
2011-06-01 04:22:45 +00:00
/ *
* Create the New Item ( + ) submenu with each item type
* /
this . buildItemTypeSubMenu = function ( ) {
2011-01-30 09:44:01 +00:00
var moreMenu = document . getElementById ( 'zotero-tb-add-more' ) ;
2012-08-02 20:59:28 +00:00
while ( moreMenu . hasChildNodes ( ) ) {
moreMenu . removeChild ( moreMenu . firstChild ) ;
}
2011-01-30 09:44:01 +00:00
// Sort by localized name
2011-06-01 04:22:45 +00:00
var t = Zotero . ItemTypes . getSecondaryTypes ( ) ;
2011-01-30 09:44:01 +00:00
var itemTypes = [ ] ;
for ( var i = 0 ; i < t . length ; i ++ ) {
itemTypes . push ( {
id : t [ i ] . id ,
name : t [ i ] . name ,
localized : Zotero . ItemTypes . getLocalizedString ( t [ i ] . id )
} ) ;
}
var collation = Zotero . getLocaleCollation ( ) ;
itemTypes . sort ( function ( a , b ) {
return collation . compareString ( 1 , a . localized , b . localized ) ;
} ) ;
for ( var i = 0 ; i < itemTypes . length ; i ++ ) {
var menuitem = document . createElement ( "menuitem" ) ;
menuitem . setAttribute ( "label" , itemTypes [ i ] . localized ) ;
menuitem . setAttribute ( "tooltiptext" , "" ) ;
2012-02-06 07:38:53 +00:00
let type = itemTypes [ i ] . id ;
2012-02-20 08:31:22 +00:00
menuitem . addEventListener ( "command" , function ( ) { ZoteroPane _Local . newItem ( type , { } , null , true ) ; } , false ) ;
2011-06-01 04:22:45 +00:00
moreMenu . appendChild ( menuitem ) ;
2011-01-30 09:44:01 +00:00
}
2011-06-01 04:22:45 +00:00
}
this . updateNewItemTypes = function ( ) {
var addMenu = document . getElementById ( 'zotero-tb-add' ) . firstChild ;
2011-01-30 09:44:01 +00:00
2011-06-01 04:22:45 +00:00
// Remove all nodes so we can regenerate
var options = addMenu . getElementsByAttribute ( "class" , "zotero-tb-add" ) ;
while ( options . length ) {
var p = options [ 0 ] . parentNode ;
p . removeChild ( options [ 0 ] ) ;
}
2011-01-30 09:44:01 +00:00
2011-06-01 04:22:45 +00:00
var separator = addMenu . firstChild ;
2011-01-30 09:44:01 +00:00
// Sort by localized name
2011-06-01 04:22:45 +00:00
var t = Zotero . ItemTypes . getPrimaryTypes ( ) ;
2011-01-30 09:44:01 +00:00
var itemTypes = [ ] ;
for ( var i = 0 ; i < t . length ; i ++ ) {
itemTypes . push ( {
id : t [ i ] . id ,
name : t [ i ] . name ,
localized : Zotero . ItemTypes . getLocalizedString ( t [ i ] . id )
} ) ;
}
var collation = Zotero . getLocaleCollation ( ) ;
itemTypes . sort ( function ( a , b ) {
return collation . compareString ( 1 , a . localized , b . localized ) ;
} ) ;
for ( var i = 0 ; i < itemTypes . length ; i ++ ) {
var menuitem = document . createElement ( "menuitem" ) ;
menuitem . setAttribute ( "label" , itemTypes [ i ] . localized ) ;
menuitem . setAttribute ( "tooltiptext" , "" ) ;
2012-02-06 07:38:53 +00:00
let type = itemTypes [ i ] . id ;
2012-02-20 08:31:22 +00:00
menuitem . addEventListener ( "command" , function ( ) { ZoteroPane _Local . newItem ( type , { } , null , true ) ; } , false ) ;
2011-01-30 09:44:01 +00:00
menuitem . className = "zotero-tb-add" ;
2011-06-01 04:22:45 +00:00
addMenu . insertBefore ( menuitem , separator ) ;
2011-01-30 09:44:01 +00:00
}
}
2011-06-01 04:22:45 +00:00
2011-01-30 09:44:01 +00:00
/ *
* Called when the window closes
* /
function destroy ( )
{
if ( ! Zotero || ! Zotero . initialized || ! _loaded ) {
return ;
}
2011-03-08 23:14:19 +00:00
if ( this . isShowing ( ) ) {
this . serializePersist ( ) ;
}
2011-02-11 22:39:13 +00:00
2011-01-30 09:44:01 +00:00
var tagSelector = document . getElementById ( 'zotero-tag-selector' ) ;
tagSelector . unregister ( ) ;
2011-08-24 22:08:27 +00:00
if ( this . collectionsView ) this . collectionsView . unregister ( ) ;
if ( this . itemsView ) this . itemsView . unregister ( ) ;
2011-06-14 00:36:21 +00:00
2011-08-24 22:08:27 +00:00
observerService . removeObserver ( _reloadObserver , "zotero-reloaded" ) ;
2011-01-30 09:44:01 +00:00
}
/ * *
* Called before Zotero pane is to be made visible
* @ return { Boolean } True if Zotero pane should be loaded , false otherwise ( if an error
* occurred )
* /
function makeVisible ( )
{
// If pane not loaded, load it or display an error message
2011-03-08 23:46:01 +00:00
if ( ! ZoteroPane _Local . loaded ) {
2011-01-30 09:44:01 +00:00
if ( Zotero . locked ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var msg = Zotero . getString ( 'general.operationInProgress' ) + '\n\n' + Zotero . getString ( 'general.operationInProgress.waitUntilFinished' ) ;
ps . alert ( null , "" , msg ) ;
return false ;
}
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . init ( ) ;
2011-01-30 09:44:01 +00:00
}
// If Zotero could not be initialized, display an error message and return
if ( ! Zotero || ! Zotero . initialized ) {
2011-02-10 01:53:15 +00:00
this . displayStartupError ( ) ;
2011-01-30 09:44:01 +00:00
return false ;
}
2011-08-25 21:24:51 +00:00
if ( ! _madeVisible ) {
this . buildItemTypeSubMenu ( ) ;
}
_madeVisible = true ;
2011-03-26 04:37:12 +00:00
this . unserializePersist ( ) ;
2011-06-01 09:10:33 +00:00
this . updateToolbarPosition ( ) ;
2011-03-25 03:38:42 +00:00
this . updateTagSelectorSize ( ) ;
2011-02-11 22:16:32 +00:00
2011-03-25 03:38:42 +00:00
// restore saved row selection (for tab switching)
2011-02-11 22:39:13 +00:00
var containerWindow = ( window . ZoteroTab ? window . ZoteroTab . containerWindow : window ) ;
2011-03-25 03:38:42 +00:00
if ( containerWindow . zoteroSavedCollectionSelection ) {
this . collectionsView . rememberSelection ( containerWindow . zoteroSavedCollectionSelection ) ;
delete containerWindow . zoteroSavedCollectionSelection ;
}
// restore saved item selection (for tab switching)
if ( containerWindow . zoteroSavedItemSelection ) {
2011-03-08 23:14:19 +00:00
var me = this ;
// hack to restore saved selection after itemTreeView finishes loading
window . setTimeout ( function ( ) {
2011-03-25 03:38:42 +00:00
if ( containerWindow . zoteroSavedItemSelection ) {
me . itemsView . rememberSelection ( containerWindow . zoteroSavedItemSelection ) ;
delete containerWindow . zoteroSavedItemSelection ;
2011-03-08 23:14:19 +00:00
}
} , 51 ) ;
2011-02-11 22:39:13 +00:00
}
2011-01-30 09:44:01 +00:00
// Focus the quicksearch on pane open
2011-06-20 20:02:14 +00:00
var searchBar = document . getElementById ( 'zotero-tb-search' ) ;
setTimeout ( function ( ) {
searchBar . inputField . select ( ) ;
} , 1 ) ;
2011-01-30 09:44:01 +00:00
var d = new Date ( ) ;
Zotero . purgeDataObjects ( ) ;
var d2 = new Date ( ) ;
Zotero . debug ( "Purged data tables in " + ( d2 - d ) + " ms" ) ;
// Auto-sync on pane open
2011-03-28 00:05:29 +00:00
if ( Zotero . Prefs . get ( 'sync.autoSync' ) ) {
2013-05-01 10:29:31 +00:00
Zotero . proxyAuthComplete
. delay ( 1000 )
. then ( function ( ) {
2012-03-12 20:25:35 +00:00
if ( ! Zotero . Sync . Server . enabled ) {
Zotero . debug ( 'Sync not enabled -- skipping auto-sync' , 4 ) ;
return ;
}
if ( Zotero . Sync . Server . syncInProgress || Zotero . Sync . Storage . syncInProgress ) {
2011-03-28 00:05:29 +00:00
Zotero . debug ( 'Sync already running -- skipping auto-sync' , 4 ) ;
return ;
}
if ( Zotero . Sync . Server . manualSyncRequired ) {
Zotero . debug ( 'Manual sync required -- skipping auto-sync' , 4 ) ;
return ;
}
2013-08-02 04:45:26 +00:00
Zotero . Sync . Runner . sync ( {
background : true
} ) ;
2013-05-01 10:29:31 +00:00
} )
. done ( ) ;
2011-01-30 09:44:01 +00:00
}
2011-03-30 12:17:30 +00:00
// Set sync icon to spinning or not
//
// We don't bother setting an error state at open
if ( Zotero . Sync . Server . syncInProgress || Zotero . Sync . Storage . syncInProgress ) {
Zotero . Sync . Runner . setSyncIcon ( 'animate' ) ;
}
2011-01-30 09:44:01 +00:00
return true ;
}
2011-02-11 22:16:32 +00:00
/ * *
2011-03-08 23:46:01 +00:00
* Function to be called before ZoteroPane _Local is hidden . Does not actually hide the Zotero pane .
2011-02-11 22:16:32 +00:00
* /
this . makeHidden = function ( ) {
2011-02-22 18:43:05 +00:00
this . serializePersist ( ) ;
2011-02-11 22:16:32 +00:00
}
2011-01-30 09:44:01 +00:00
function isShowing ( ) {
var zoteroPane = document . getElementById ( 'zotero-pane-stack' ) ;
return zoteroPane . getAttribute ( 'hidden' ) != 'true' &&
zoteroPane . getAttribute ( 'collapsed' ) != 'true' ;
}
function isFullScreen ( ) {
return document . getElementById ( 'zotero-pane-stack' ) . getAttribute ( 'fullscreenmode' ) == 'true' ;
}
/ *
* Trigger actions based on keyboard shortcuts
* /
function handleKeyDown ( event , from ) {
try {
// Ignore keystrokes outside of Zotero pane
if ( ! ( event . originalTarget . ownerDocument instanceof XULDocument ) ) {
return ;
}
}
catch ( e ) {
Zotero . debug ( e ) ;
}
if ( Zotero . locked ) {
event . preventDefault ( ) ;
return ;
}
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 ( {
2011-03-08 23:46:01 +00:00
notify : ZoteroPane _Local . setHighlightedRowsCallback
2011-01-30 09:44:01 +00:00
} , 225 , Components . interfaces . nsITimer . TYPE _ONE _SHOT ) ;
}
2011-10-12 18:41:23 +00:00
// Unhighlight on key up
2011-01-30 09:44:01 +00:00
else if ( ( Zotero . isWin && event . ctrlKey ) ||
( ! Zotero . isWin && event . altKey ) ) {
if ( this . highlightTimer ) {
this . highlightTimer . cancel ( ) ;
this . highlightTimer = null ;
}
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . collectionsView . setHighlightedRows ( ) ;
2011-01-30 09:44:01 +00:00
}
}
}
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 ;
}
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . collectionsView . setHighlightedRows ( ) ;
2011-01-30 09:44:01 +00:00
}
}
}
/ *
* Highlights collections containing selected items on Ctrl ( Win ) or
* Option / Alt ( Mac / Linux ) press
* /
function setHighlightedRowsCallback ( ) {
2011-03-08 23:46:01 +00:00
var itemIDs = ZoteroPane _Local . getSelectedItems ( true ) ;
2011-01-30 09:44:01 +00:00
if ( itemIDs && itemIDs . length ) {
var collectionIDs = Zotero . Collections . getCollectionsContainingItems ( itemIDs , true ) ;
if ( collectionIDs ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . collectionsView . setHighlightedRows ( collectionIDs ) ;
2011-01-30 09:44:01 +00:00
}
}
}
2013-07-02 06:43:53 +00:00
function handleKeyPress ( event ) {
var from = event . originalTarget . id ;
// Ignore keystrokes if Zotero pane is closed
var zoteroPane = document . getElementById ( 'zotero-pane-stack' ) ;
if ( zoteroPane . getAttribute ( 'hidden' ) == 'true' ||
zoteroPane . getAttribute ( 'collapsed' ) == 'true' ) {
return ;
}
if ( Zotero . locked ) {
event . preventDefault ( ) ;
return ;
}
2011-01-30 09:44:01 +00:00
if ( from == 'zotero-collections-tree' ) {
if ( ( event . keyCode == event . DOM _VK _BACK _SPACE && Zotero . isMac ) ||
event . keyCode == event . DOM _VK _DELETE ) {
2013-03-17 02:55:50 +00:00
var deleteItems = event . metaKey || ( ! Zotero . isMac && event . shiftKey ) ;
ZoteroPane _Local . deleteSelectedCollection ( deleteItems ) ;
2011-01-30 09:44:01 +00:00
event . preventDefault ( ) ;
return ;
}
}
else if ( from == 'zotero-items-tree' ) {
2013-07-02 06:43:53 +00:00
// Focus TinyMCE explicitly on tab key, since the normal focusing
// doesn't work right
if ( ! event . shiftKey && event . keyCode == event . DOM _VK _TAB ) {
var deck = document . getElementById ( 'zotero-item-pane-content' ) ;
if ( deck . selectedPanel . id == 'zotero-view-note' ) {
setTimeout ( function ( ) {
document . getElementById ( 'zotero-note-editor' ) . focus ( ) ;
} , 0 ) ;
}
}
else if ( ( event . keyCode == event . DOM _VK _BACK _SPACE && Zotero . isMac ) ||
2011-01-30 09:44:01 +00:00
event . keyCode == event . DOM _VK _DELETE ) {
2014-10-28 17:45:55 +00:00
// If Cmd/Shift delete, use forced mode, which does different
2011-01-30 09:44:01 +00:00
// things depending on the context
2013-03-17 02:55:50 +00:00
var force = event . metaKey || ( ! Zotero . isMac && event . shiftKey ) ;
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . deleteSelectedItems ( force ) ;
2011-01-30 09:44:01 +00:00
event . preventDefault ( ) ;
return ;
}
2012-11-01 05:53:31 +00:00
else if ( event . keyCode == event . DOM _VK _RETURN ) {
var items = this . itemsView . getSelectedItems ( ) ;
// Don't do anything if more than 20 items selected
if ( ! items . length || items . length > 20 ) {
return ;
}
ZoteroPane _Local . viewItems ( items , event ) ;
// These don't seem to do anything. Instead we override
// the tree binding's _handleEnter method in itemTreeView.js.
//event.preventDefault();
//event.stopPropagation();
return ;
}
2011-01-30 09:44:01 +00:00
}
2013-07-02 06:43:53 +00:00
var key = String . fromCharCode ( event . which ) ;
if ( ! key ) {
Zotero . debug ( 'No key' ) ;
return ;
}
2013-07-29 00:18:24 +00:00
// Ignore modifiers other than Ctrl-Shift/Cmd-Shift
if ( ! ( ( Zotero . isMac ? event . metaKey : event . ctrlKey ) && event . shiftKey ) ) {
2013-07-02 06:43:53 +00:00
return ;
}
var command = Zotero . Keys . getCommand ( key ) ;
if ( ! command ) {
return ;
}
Zotero . debug ( command ) ;
// Errors don't seem to make it out otherwise
try {
switch ( command ) {
case 'openZotero' :
try {
// Ignore Cmd-Shift-Z keystroke in text areas
if ( Zotero . isMac && key == 'Z' &&
2014-04-30 18:29:59 +00:00
( event . originalTarget . localName == 'input'
|| event . originalTarget . localName == 'textarea' ) ) {
try {
var isSearchBar = event . originalTarget . parentNode . parentNode . id == 'zotero-tb-search' ;
}
catch ( e ) {
Zotero . debug ( e , 1 ) ;
Components . utils . reportError ( e ) ;
}
if ( ! isSearchBar ) {
Zotero . debug ( 'Ignoring keystroke in text field' ) ;
return ;
}
2013-07-02 06:43:53 +00:00
}
}
catch ( e ) {
Zotero . debug ( e ) ;
}
if ( window . ZoteroOverlay ) window . ZoteroOverlay . toggleDisplay ( )
break ;
case 'library' :
document . getElementById ( 'zotero-collections-tree' ) . focus ( ) ;
break ;
case 'quicksearch' :
document . getElementById ( 'zotero-tb-search' ) . select ( ) ;
break ;
case 'newItem' :
2013-07-02 20:48:53 +00:00
// Default to most recent item type from here or the
// New Type menu
var mru = Zotero . Prefs . get ( 'newItemTypeMRU' ) ;
// Or fall back to 'book'
var typeID = mru ? mru . split ( ',' ) [ 0 ] : 2 ;
ZoteroPane _Local . newItem ( typeID ) ;
let itemBox = document . getElementById ( 'zotero-editpane-item-box' ) ;
var menu = itemBox . itemTypeMenu ;
var self = this ;
var handleTypeChange = function ( ) {
self . addItemTypeToNewItemTypeMRU ( this . itemTypeMenu . value ) ;
itemBox . removeHandler ( 'itemtypechange' , handleTypeChange ) ;
} ;
// Only update the MRU when the menu is opened for the
// keyboard shortcut, not on subsequent opens
var removeTypeChangeHandler = function ( ) {
itemBox . removeHandler ( 'itemtypechange' , handleTypeChange ) ;
itemBox . itemTypeMenu . firstChild . removeEventListener ( 'popuphiding' , removeTypeChangeHandler ) ;
2013-08-08 00:24:20 +00:00
// Focus the title field after menu closes
itemBox . focusFirstField ( ) ;
2013-07-02 20:48:53 +00:00
} ;
itemBox . addHandler ( 'itemtypechange' , handleTypeChange ) ;
itemBox . itemTypeMenu . firstChild . addEventListener ( 'popuphiding' , removeTypeChangeHandler ) ;
2013-07-02 06:43:53 +00:00
menu . focus ( ) ;
document . getElementById ( 'zotero-editpane-item-box' ) . itemTypeMenu . menupopup . openPopup ( menu , "before_start" , 0 , 0 ) ;
break ;
case 'newNote' :
// If a regular item is selected, use that as the parent.
// If a child item is selected, use its parent as the parent.
// Otherwise create a standalone note.
var parent = false ;
var items = ZoteroPane _Local . getSelectedItems ( ) ;
if ( items . length == 1 ) {
if ( items [ 0 ] . isRegularItem ( ) ) {
parent = items [ 0 ] . id ;
}
else {
parent = items [ 0 ] . getSource ( ) ;
}
}
// Use key that's not the modifier as the popup toggle
2013-07-29 00:18:24 +00:00
ZoteroPane _Local . newNote ( event . altKey , parent ) ;
2013-07-02 06:43:53 +00:00
break ;
case 'toggleTagSelector' :
ZoteroPane _Local . toggleTagSelector ( ) ;
break ;
case 'toggleFullscreen' :
ZoteroPane _Local . toggleTab ( ) ;
break ;
case 'copySelectedItemCitationsToClipboard' :
ZoteroPane _Local . copySelectedItemsToClipboard ( true )
break ;
case 'copySelectedItemsToClipboard' :
ZoteroPane _Local . copySelectedItemsToClipboard ( ) ;
break ;
case 'importFromClipboard' :
Zotero _File _Interface . importFromClipboard ( ) ;
break ;
default :
throw ( 'Command "' + command + '" not found in ZoteroPane_Local.handleKeyDown()' ) ;
}
}
catch ( e ) {
Zotero . debug ( e , 1 ) ;
Components . utils . reportError ( e ) ;
}
event . preventDefault ( ) ;
2011-01-30 09:44:01 +00:00
}
/ *
* Create a new item
*
* _data _ is an optional object with field : value for itemData
* /
2012-02-20 08:31:22 +00:00
function newItem ( typeID , data , row , manual )
2011-01-30 09:44:01 +00:00
{
if ( ! Zotero . stateCheck ( ) ) {
this . displayErrorMessage ( true ) ;
return false ;
}
2012-03-17 07:12:49 +00:00
if ( ( row === undefined || row === null ) && this . collectionsView . selection ) {
2011-01-30 09:44:01 +00:00
row = this . collectionsView . selection . currentIndex ;
2011-08-28 22:15:39 +00:00
2012-03-17 07:12:49 +00:00
// Make sure currently selected view is editable
2011-08-28 22:15:39 +00:00
if ( ! this . canEdit ( row ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2011-01-30 09:44:01 +00:00
}
2012-02-20 08:31:22 +00:00
if ( row !== undefined && row !== null ) {
2011-01-30 09:44:01 +00:00
var itemGroup = this . collectionsView . _getItemAtRow ( row ) ;
var libraryID = itemGroup . ref . libraryID ;
}
else {
var libraryID = null ;
var itemGroup = null ;
}
2011-06-01 14:28:59 +00:00
Zotero . DB . beginTransaction ( ) ;
2011-01-30 09:44:01 +00:00
var item = new Zotero . Item ( typeID ) ;
item . libraryID = libraryID ;
for ( var i in data ) {
item . setField ( i , data [ i ] ) ;
}
var itemID = item . save ( ) ;
if ( itemGroup && itemGroup . isCollection ( ) ) {
itemGroup . ref . addItem ( itemID ) ;
}
2011-06-01 14:28:59 +00:00
Zotero . DB . commitTransaction ( ) ;
2011-01-30 09:44:01 +00:00
//set to Info tab
document . getElementById ( 'zotero-view-item' ) . selectedIndex = 0 ;
2012-02-20 08:31:22 +00:00
if ( manual ) {
2013-08-07 17:17:25 +00:00
// Focus the title field
2013-11-22 00:52:13 +00:00
if ( this . selectItem ( itemID ) ) {
setTimeout ( function ( ) {
document . getElementById ( 'zotero-editpane-item-box' ) . focusFirstField ( ) ;
} , 0 ) ;
}
2013-08-07 17:17:25 +00:00
// Update most-recently-used list for New Item menu
2013-07-02 20:48:53 +00:00
this . addItemTypeToNewItemTypeMRU ( typeID ) ;
2011-06-01 04:22:45 +00:00
}
2011-01-30 09:44:01 +00:00
return Zotero . Items . get ( itemID ) ;
}
2013-07-02 20:48:53 +00:00
this . addItemTypeToNewItemTypeMRU = function ( itemTypeID ) {
var mru = Zotero . Prefs . get ( 'newItemTypeMRU' ) ;
if ( mru ) {
var mru = mru . split ( ',' ) ;
var pos = mru . indexOf ( itemTypeID + '' ) ;
if ( pos != - 1 ) {
mru . splice ( pos , 1 ) ;
}
mru . unshift ( itemTypeID ) ;
}
else {
var mru = [ itemTypeID + '' ] ;
}
Zotero . Prefs . set ( 'newItemTypeMRU' , mru . slice ( 0 , 5 ) . join ( ',' ) ) ;
}
2011-01-30 09:44:01 +00:00
function newCollection ( parent )
{
if ( ! Zotero . stateCheck ( ) ) {
this . displayErrorMessage ( true ) ;
return false ;
}
2012-10-31 09:22:58 +00:00
if ( ! this . canEditLibrary ( ) ) {
2011-01-30 09:44:01 +00:00
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var promptService = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var untitled = Zotero . DB . getNextName ( 'collections' , 'collectionName' ,
Zotero . getString ( 'pane.collections.untitled' ) ) ;
var newName = { value : untitled } ;
var result = promptService . prompt ( window ,
Zotero . getString ( 'pane.collections.newCollection' ) ,
Zotero . getString ( 'pane.collections.name' ) , newName , "" , { } ) ;
if ( ! result )
{
return ;
}
if ( ! newName . value )
{
newName . value = untitled ;
}
var collection = new Zotero . Collection ;
collection . libraryID = this . getSelectedLibraryID ( ) ;
collection . name = newName . value ;
collection . parent = parent ;
collection . save ( ) ;
}
this . newGroup = function ( ) {
this . loadURI ( Zotero . Groups . addGroupURL ) ;
}
function newSearch ( )
{
if ( ! Zotero . stateCheck ( ) ) {
this . displayErrorMessage ( true ) ;
return false ;
}
var s = new Zotero . Search ( ) ;
s . libraryID = this . getSelectedLibraryID ( ) ;
s . addCondition ( 'title' , 'contains' , '' ) ;
var untitled = Zotero . getString ( 'pane.collections.untitled' ) ;
untitled = Zotero . DB . getNextName ( 'savedSearches' , 'savedSearchName' ,
Zotero . getString ( 'pane.collections.untitled' ) ) ;
var io = { dataIn : { search : s , name : untitled } , dataOut : null } ;
window . openDialog ( 'chrome://zotero/content/searchDialog.xul' , '' , 'chrome,modal' , io ) ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
this . setVirtual = function ( libraryID , mode , show ) {
switch ( mode ) {
case 'duplicates' :
var prefKey = 'duplicateLibraries' ;
var lastViewedFolderID = 'D' + ( libraryID ? libraryID : 0 ) ;
break ;
case 'unfiled' :
var prefKey = 'unfiledLibraries' ;
var lastViewedFolderID = 'U' + ( libraryID ? libraryID : 0 ) ;
break ;
default :
throw ( "Invalid virtual mode '" + mode + "' in ZoteroPane.setVirtual()" ) ;
}
2011-02-14 03:59:32 +00:00
try {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var ids = Zotero . Prefs . get ( prefKey ) . split ( ',' ) ;
2011-02-14 03:59:32 +00:00
}
catch ( e ) {
var ids = [ ] ;
}
if ( ! libraryID ) {
libraryID = 0 ;
}
var newids = [ ] ;
for each ( var id in ids ) {
id = parseInt ( id ) ;
if ( isNaN ( id ) ) {
continue ;
}
// Remove current library if hiding
if ( id == libraryID && ! show ) {
continue ;
}
// Remove libraryIDs that no longer exist
if ( id != 0 && ! Zotero . Libraries . exists ( id ) ) {
continue ;
}
newids . push ( id ) ;
}
// Add the current library if it's not already set
if ( show && newids . indexOf ( libraryID ) == - 1 ) {
newids . push ( libraryID ) ;
}
newids . sort ( ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
Zotero . Prefs . set ( prefKey , newids . join ( ) ) ;
2011-02-14 03:59:32 +00:00
this . collectionsView . refresh ( ) ;
2011-07-25 21:27:32 +00:00
// If group is closed, open it
this . collectionsView . selectLibrary ( libraryID ) ;
row = this . collectionsView . selection . currentIndex ;
if ( ! this . collectionsView . isContainerOpen ( row ) ) {
this . collectionsView . toggleOpenState ( row ) ;
}
2011-02-14 03:59:32 +00:00
// Select new row
2011-07-25 21:27:32 +00:00
if ( show ) {
Zotero . Prefs . set ( 'lastViewedFolder' , lastViewedFolderID ) ;
var row = this . collectionsView . getLastViewedRow ( ) ;
this . collectionsView . selection . select ( row ) ;
}
2011-02-14 03:59:32 +00:00
}
2011-01-30 09:44:01 +00:00
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
2011-01-30 09:44:01 +00:00
this . openLookupWindow = function ( ) {
if ( ! Zotero . stateCheck ( ) ) {
this . displayErrorMessage ( true ) ;
return false ;
}
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
window . openDialog ( 'chrome://zotero/content/lookup.xul' , 'zotero-lookup' , 'chrome,modal' ) ;
}
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 ( ) ;
2014-05-15 07:19:49 +00:00
s . libraryID = this . getSelectedLibraryID ( ) ;
2011-01-30 09:44:01 +00:00
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 tagSelector = document . getElementById ( 'zotero-tag-selector' ) ;
var showing = tagSelector . getAttribute ( 'collapsed' ) == 'true' ;
tagSelector . 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-stack' ) ;
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 ) ;
}
var height = tagSelector . boxObject . height ;
/ * Z o t e r o . d e b u g ( " t a g S e l e c t o r . b o x O b j e c t . h e i g h t : " + t a g S e l e c t o r . b o x O b j e c t . h e i g h t ) ;
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 + COLLECTIONS _HEIGHT ;
}
//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 . Utilities . isEmpty ( this . getTagSelection ( ) ) ) {
var tagSelector = document . getElementById ( 'zotero-tag-selector' ) ;
tagSelector . clearAll ( ) ;
}
}
/ *
* Sets the tag filter on the items view
* /
function updateTagFilter ( ) {
2011-08-05 22:04:48 +00:00
if ( this . itemsView ) {
2013-01-22 22:25:50 +00:00
this . itemsView . setFilter ( 'tags' , getTagSelection ( ) ) ;
2011-08-05 22:04:48 +00:00
}
2011-01-30 09:44:01 +00:00
}
/ *
* 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' ) ;
if ( itemGroup . editable ) {
tagSelector . mode = 'edit' ;
}
else {
tagSelector . mode = 'view' ;
}
tagSelector . libraryID = itemGroup . ref . libraryID ;
tagSelector . scope = itemGroup . getChildTags ( ) ;
}
}
function onCollectionSelected ( )
{
if ( this . itemsView )
{
this . itemsView . unregister ( ) ;
document . getElementById ( 'zotero-items-tree' ) . view = this . itemsView = null ;
}
2011-08-05 22:04:48 +00:00
// Clear quick search and tag selector when switching views
document . getElementById ( 'zotero-tb-search' ) . value = "" ;
document . getElementById ( 'zotero-tag-selector' ) . clearAll ( ) ;
2011-01-30 09:44:01 +00:00
if ( this . collectionsView . selection . count != 1 ) {
document . getElementById ( 'zotero-items-tree' ) . view = this . itemsView = null ;
return ;
}
// this.collectionsView.selection.currentIndex != -1
var itemgroup = this . collectionsView . _getItemAtRow ( this . collectionsView . selection . currentIndex ) ;
2013-03-21 02:35:44 +00:00
// Not necessary with seltype="cell", which calls nsITreeView::isSelectable()
/ * i f ( i t e m g r o u p . i s S e p a r a t o r ( ) ) {
2011-01-30 09:44:01 +00:00
document . getElementById ( 'zotero-items-tree' ) . view = this . itemsView = null ;
return ;
2013-03-21 02:35:44 +00:00
} * /
2011-01-30 09:44:01 +00:00
itemgroup . setSearch ( '' ) ;
itemgroup . setTags ( getTagSelection ( ) ) ;
2012-01-11 23:23:36 +00:00
// Enable or disable toolbar icons and menu options as necessary
const disableIfNoEdit = [
"cmd_zotero_newCollection" ,
"cmd_zotero_newSavedSearch" ,
"zotero-tb-add" ,
"cmd_zotero_newItemFromCurrentPage" ,
"zotero-tb-lookup" ,
"cmd_zotero_newStandaloneNote" ,
"zotero-tb-note-add" ,
"zotero-tb-attachment-add"
] ;
2011-10-02 23:28:38 +00:00
for ( var i = 0 ; i < disableIfNoEdit . length ; i ++ ) {
var el = document . getElementById ( disableIfNoEdit [ i ] ) ;
2012-10-31 09:22:58 +00:00
// If a trash is selected, new collection depends on the
// editability of the library
if ( itemgroup . isTrash ( ) &&
disableIfNoEdit [ i ] == 'cmd_zotero_newCollection' ) {
if ( itemgroup . ref . libraryID ) {
var overrideEditable =
Zotero . Libraries . isEditable ( itemgroup . ref . libraryID ) ;
}
else {
var overrideEditable = true ;
}
}
else {
var overrideEditable = false ;
}
if ( itemgroup . editable || overrideEditable ) {
2011-10-02 23:28:38 +00:00
if ( el . hasAttribute ( "disabled" ) ) el . removeAttribute ( "disabled" ) ;
} else {
el . setAttribute ( "disabled" , "true" ) ;
}
}
2011-01-30 09:44:01 +00:00
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 ( ) ;
Configurable secondary sorting and other improvements
- Each column in the middle pane can now have its own persistent
secondary sort column, configurable from a new submenu in the column
picker menu (top right of items list). The settings are stored in
extensions.zotero.secondarySort.[primaryField]. The submenu title
includes the current primary field (e.g., "Secondary Sort (Creator)"),
which is pretty weird, and I'm not sure I want to keep it, but it does
convey that the setting is specific to the selected column.
- The fallback sort fields (firstCreator, date, title, dateAdded) are
now configurable via the extensions.zotero.fallbackSort. Setting that
pref to an empty string avoids all fallback sorts, which
allows reverse-order clicking to set the order, as requested by
@aurimasv in #275.
- The previous behavior of sorting based on the exact Creator string
(rather than the actual creators) can now be restored with the
extensions.zotero.sortCreatorAsString pref. (It simply circumvents all
the newer code, so it's pretty safe.) This setting should result in
faster sorting in large libraries that have many items with the same
Creator string.
- Some of the lesser fields in the column picker menu are now in the
More Columns submenu (which is now alphabetical)
- The "Type" column is now the less-ambiguous "Item Type".
- This uses a different method to modify the column picker menu that is
simultaneously less and more hacky. (It no longer has to duplicate
Mozilla code in a custom XBL binding that wouldn't reflect future
upstream changes, and instead it bushwhacks its way through various
boxObject properties to get to the underlying menupopup.)
2014-05-07 08:22:49 +00:00
// Add events to treecolpicker to update menu before showing/hiding
try {
let treecols = document . getElementById ( 'zotero-items-columns-header' ) ;
let treecolpicker = treecols . boxObject . firstChild . nextSibling ;
let menupopup = treecolpicker . boxObject . firstChild . nextSibling ;
let attr = menupopup . getAttribute ( 'onpopupshowing' ) ;
if ( attr . indexOf ( 'Zotero' ) == - 1 ) {
menupopup . setAttribute ( 'onpopupshowing' , 'ZoteroPane.itemsView.onColumnPickerShowing(event);' )
// Keep whatever else is there
+ ' ' + attr ;
menupopup . setAttribute ( 'onpopuphidden' , 'ZoteroPane.itemsView.onColumnPickerHidden(event);' )
// Keep whatever else is there
+ ' ' + menupopup . getAttribute ( 'onpopuphidden' ) ;
}
}
catch ( e ) {
Zotero . debug ( e ) ;
}
2011-01-30 09:44:01 +00:00
}
finally {
Zotero . UnresponsiveScriptIndicator . enable ( ) ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
Zotero . Prefs . set ( 'lastViewedFolder' , itemgroup . id ) ;
2011-01-30 09:44:01 +00:00
}
this . getItemGroup = function ( ) {
2011-12-30 17:44:19 +00:00
if ( ! this . collectionsView . selection ) {
return false ;
}
2011-01-30 09:44:01 +00:00
return this . collectionsView . _getItemAtRow ( this . collectionsView . selection . currentIndex ) ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
this . itemSelected = function ( event ) {
2011-01-30 09:44:01 +00:00
if ( ! Zotero . stateCheck ( ) ) {
this . displayErrorMessage ( ) ;
return ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// DEBUG: Is this actually possible?
if ( ! this . itemsView ) {
Components . utils . reportError ( "this.itemsView is not defined in ZoteroPane.itemSelected()" ) ;
}
2011-01-30 09:44:01 +00:00
// Display restore button if items selected in Trash
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( this . itemsView . selection . count ) {
2011-01-30 09:44:01 +00:00
document . getElementById ( 'zotero-item-restore-button' ) . hidden
= ! this . itemsView . _itemGroup . isTrash ( )
|| _nonDeletedItemsSelected ( this . itemsView ) ;
}
else {
document . getElementById ( 'zotero-item-restore-button' ) . hidden = true ;
}
var tabs = document . getElementById ( 'zotero-view-tabbox' ) ;
2011-03-26 22:39:24 +00:00
// save note when switching from a note
if ( document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex == 2 ) {
document . getElementById ( 'zotero-note-editor' ) . save ( ) ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var itemGroup = this . getItemGroup ( ) ;
2011-01-30 09:44:01 +00:00
// Single item selected
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( this . itemsView . selection . count == 1 && this . itemsView . selection . currentIndex != - 1 )
2011-01-30 09:44:01 +00:00
{
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var item = this . itemsView . getSelectedItems ( ) [ 0 ] ;
2011-01-30 09:44:01 +00:00
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( item . isNote ( ) ) {
2011-01-30 09:44:01 +00:00
var noteEditor = document . getElementById ( 'zotero-note-editor' ) ;
noteEditor . mode = this . collectionsView . editable ? 'edit' : 'view' ;
2012-04-17 19:42:15 +00:00
var clearUndo = noteEditor . item ? noteEditor . item . id != item . id : false ;
noteEditor . parent = null ;
noteEditor . item = item ;
2011-01-30 09:44:01 +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.
2012-04-17 19:42:15 +00:00
if ( clearUndo ) {
noteEditor . clearUndo ( ) ;
2011-01-30 09:44:01 +00:00
}
var viewButton = document . getElementById ( 'zotero-view-note-button' ) ;
if ( this . collectionsView . editable ) {
viewButton . hidden = false ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
viewButton . setAttribute ( 'noteID' , item . id ) ;
if ( item . getSource ( ) ) {
viewButton . setAttribute ( 'sourceID' , item . getSource ( ) ) ;
2011-01-30 09:44:01 +00:00
}
else {
viewButton . removeAttribute ( 'sourceID' ) ;
}
}
else {
viewButton . hidden = true ;
}
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 2 ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
else if ( item . isAttachment ( ) ) {
2011-01-30 09:44:01 +00:00
var attachmentBox = document . getElementById ( 'zotero-attachment-box' ) ;
attachmentBox . mode = this . collectionsView . editable ? 'edit' : 'view' ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
attachmentBox . item = item ;
2011-01-30 09:44:01 +00:00
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 3 ;
}
// Regular item
else {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var isCommons = itemGroup . isBucket ( ) ;
2011-01-30 09:44:01 +00:00
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 1 ;
var tabBox = document . getElementById ( 'zotero-view-tabbox' ) ;
var pane = tabBox . selectedIndex ;
tabBox . firstChild . hidden = isCommons ;
var button = document . getElementById ( 'zotero-item-show-original' ) ;
if ( isCommons ) {
button . hidden = false ;
button . disabled = ! this . getOriginalItem ( ) ;
}
else {
button . hidden = true ;
}
if ( this . collectionsView . editable ) {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
ZoteroItemPane . viewItem ( item , null , pane ) ;
2011-01-30 09:44:01 +00:00
tabs . selectedIndex = document . getElementById ( 'zotero-view-item' ) . selectedIndex ;
}
else {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
ZoteroItemPane . viewItem ( item , 'view' , pane ) ;
2011-01-30 09:44:01 +00:00
tabs . selectedIndex = document . getElementById ( 'zotero-view-item' ) . selectedIndex ;
}
}
}
// Zero or multiple items selected
else {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var count = this . itemsView . selection . count ;
2011-01-30 09:44:01 +00:00
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// Display duplicates merge interface in item pane
if ( itemGroup . isDuplicates ( ) ) {
if ( ! itemGroup . editable ) {
if ( count ) {
2013-03-04 02:44:14 +00:00
var msg = Zotero . getString ( 'pane.item.duplicates.writeAccessRequired' ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
}
else {
var msg = Zotero . getString ( 'pane.item.selected.zero' ) ;
}
this . setItemPaneMessage ( msg ) ;
}
else if ( count ) {
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 4 ;
// Load duplicates UI code
if ( typeof Zotero _Duplicates _Pane == 'undefined' ) {
Zotero . debug ( "Loading duplicatesMerge.js" ) ;
Components . classes [ "@mozilla.org/moz/jssubscript-loader;1" ]
. getService ( Components . interfaces . mozIJSSubScriptLoader )
. loadSubScript ( "chrome://zotero/content/duplicatesMerge.js" ) ;
}
// On a Select All of more than a few items, display a row
// count instead of the usual item type mismatch error
var displayNumItemsOnTypeError = count > 5 && count == this . itemsView . rowCount ;
// Initialize the merge pane with the selected items
Zotero _Duplicates _Pane . setItems ( this . getSelectedItems ( ) , displayNumItemsOnTypeError ) ;
}
else {
2013-03-04 02:44:14 +00:00
var msg = Zotero . getString ( 'pane.item.duplicates.selectToMerge' ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
this . setItemPaneMessage ( msg ) ;
}
2011-01-30 09:44:01 +00:00
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// Display label in the middle of the item pane
2011-01-30 09:44:01 +00:00
else {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( count ) {
var msg = Zotero . getString ( 'pane.item.selected.multiple' , count ) ;
}
else {
2012-03-13 19:21:07 +00:00
var rowCount = this . itemsView . rowCount ;
var str = 'pane.item.unselected.' ;
switch ( rowCount ) {
case 0 :
str += 'zero' ;
break ;
case 1 :
str += 'singular' ;
break ;
default :
str += 'plural' ;
break ;
}
var msg = Zotero . getString ( str , [ rowCount ] ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
}
this . setItemPaneMessage ( msg ) ;
2011-01-30 09:44:01 +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 ;
}
this . updateNoteButtonMenu = function ( ) {
2011-03-08 23:46:01 +00:00
var items = ZoteroPane _Local . getSelectedItems ( ) ;
2011-01-30 09:44:01 +00:00
var button = document . getElementById ( 'zotero-tb-add-child-note' ) ;
button . disabled = ! this . canEdit ( ) ||
! ( items . length == 1 && ( items [ 0 ] . isRegularItem ( ) || ! items [ 0 ] . isTopLevelItem ( ) ) ) ;
}
this . updateAttachmentButtonMenu = function ( popup ) {
2011-03-08 23:46:01 +00:00
var items = ZoteroPane _Local . getSelectedItems ( ) ;
2011-01-30 09:44:01 +00:00
var disabled = ! this . canEdit ( ) || ! ( items . length == 1 && items [ 0 ] . isRegularItem ( ) ) ;
if ( disabled ) {
for each ( var node in popup . childNodes ) {
node . disabled = true ;
}
return ;
}
var itemgroup = this . collectionsView . _getItemAtRow ( this . collectionsView . selection . currentIndex ) ;
var canEditFiles = this . canEditFiles ( ) ;
var prefix = "menuitem-iconic zotero-menuitem-attachments-" ;
for ( var i = 0 ; i < popup . childNodes . length ; i ++ ) {
var node = popup . childNodes [ i ] ;
2013-05-19 04:14:13 +00:00
var className = node . className . replace ( 'standalone-no-display' , '' ) . trim ( ) ;
2011-01-30 09:44:01 +00:00
2013-05-19 04:14:13 +00:00
switch ( className ) {
2011-01-30 09:44:01 +00:00
case prefix + 'link' :
node . disabled = itemgroup . isWithinGroup ( ) ;
break ;
case prefix + 'snapshot' :
case prefix + 'file' :
node . disabled = ! canEditFiles ;
break ;
case prefix + 'web-link' :
node . disabled = false ;
break ;
default :
2013-05-19 04:14:13 +00:00
throw ( "Invalid class name '" + className + "' in ZoteroPane_Local.updateAttachmentButtonMenu()" ) ;
2011-01-30 09:44:01 +00:00
}
}
}
this . checkPDFConverter = function ( ) {
if ( Zotero . Fulltext . pdfConverterIsRegistered ( ) ) {
return true ;
}
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var buttonFlags = ( ps . BUTTON _POS _0 ) * ( ps . BUTTON _TITLE _IS _STRING )
+ ( ps . BUTTON _POS _1 ) * ( ps . BUTTON _TITLE _CANCEL ) ;
var index = ps . confirmEx (
null ,
2013-03-04 02:44:14 +00:00
Zotero . getString ( 'pane.item.attachments.PDF.installTools.title' ) ,
Zotero . getString ( 'pane.item.attachments.PDF.installTools.text' ) ,
2011-01-30 09:44:01 +00:00
buttonFlags ,
2013-03-04 02:44:14 +00:00
Zotero . getString ( 'general.openPreferences' ) ,
2011-01-30 09:44:01 +00:00
null , null , null , { }
) ;
if ( index == 0 ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . openPreferences ( 'zotero-prefpane-search' , 'pdftools-install' ) ;
2011-01-30 09:44:01 +00:00
}
return false ;
}
function reindexItem ( ) {
var items = this . getSelectedItems ( ) ;
if ( ! items ) {
return ;
}
var itemIDs = [ ] ;
var checkPDF = false ;
for ( var i = 0 ; i < items . length ; i ++ ) {
// If any PDFs, we need to make sure the converter is installed and
// prompt for installation if not
if ( ! checkPDF && items [ i ] . attachmentMIMEType && items [ i ] . attachmentMIMEType == "application/pdf" ) {
checkPDF = true ;
}
itemIDs . push ( items [ i ] . id ) ;
}
if ( checkPDF ) {
var installed = this . checkPDFConverter ( ) ;
if ( ! installed ) {
document . getElementById ( 'zotero-attachment-box' ) . updateItemIndexedState ( ) ;
return ;
}
}
Zotero . Fulltext . indexItems ( itemIDs , true ) ;
document . getElementById ( 'zotero-attachment-box' ) . updateItemIndexedState ( ) ;
}
function duplicateSelectedItem ( ) {
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var item = this . getSelectedItems ( ) [ 0 ] ;
Zotero . DB . beginTransaction ( ) ;
// Create new unsaved clone item in target library
var newItem = new Zotero . Item ( item . itemTypeID ) ;
newItem . libraryID = item . libraryID ;
// DEBUG: save here because clone() doesn't currently work on unsaved tagged items
var id = newItem . save ( ) ;
var newItem = Zotero . Items . get ( id ) ;
2012-11-02 09:45:26 +00:00
item . clone ( false , newItem , false , ! Zotero . Prefs . get ( 'groups.copyTags' ) ) ;
2011-01-30 09:44:01 +00:00
newItem . save ( ) ;
if ( this . itemsView . _itemGroup . isCollection ( ) && ! newItem . getSource ( ) ) {
this . itemsView . _itemGroup . ref . addItem ( newItem . id ) ;
}
Zotero . DB . commitTransaction ( ) ;
this . selectItem ( newItem . id ) ;
}
this . deleteSelectedItem = function ( ) {
2011-03-08 23:46:01 +00:00
Zotero . debug ( "ZoteroPane_Local.deleteSelectedItem() is deprecated -- use ZoteroPane_Local.deleteSelectedItems()" ) ;
2011-01-30 09:44:01 +00:00
this . deleteSelectedItems ( ) ;
}
/ *
* Remove , trash , or delete item ( s ) , depending on context
*
2013-01-05 21:35:33 +00:00
* @ param { Boolean } [ force = false ] Trash or delete even if in a collection or search ,
* or trash without prompt in library
* @ param { Boolean } [ fromMenu = false ] If triggered from context menu , which always prompts for deletes
2011-01-30 09:44:01 +00:00
* /
2013-01-05 21:35:33 +00:00
this . deleteSelectedItems = function ( force , fromMenu ) {
2011-01-30 09:44:01 +00:00
if ( ! this . itemsView || ! this . itemsView . selection . count ) {
return ;
}
var itemGroup = this . itemsView . _itemGroup ;
if ( ! itemGroup . isTrash ( ) && ! itemGroup . isBucket ( ) && ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var toTrash = {
title : Zotero . getString ( 'pane.items.trash.title' ) ,
text : Zotero . getString (
'pane.items.trash' + ( this . itemsView . selection . count > 1 ? '.multiple' : '' )
)
} ;
var toDelete = {
title : Zotero . getString ( 'pane.items.delete.title' ) ,
text : Zotero . getString (
'pane.items.delete' + ( this . itemsView . selection . count > 1 ? '.multiple' : '' )
)
} ;
2011-08-30 23:35:12 +00:00
if ( itemGroup . isLibrary ( true ) ) {
2011-01-30 09:44:01 +00:00
// In library, don't prompt if meta key was pressed
2013-01-05 21:35:33 +00:00
var prompt = ( force && ! fromMenu ) ? false : toTrash ;
2011-01-30 09:44:01 +00:00
}
else if ( itemGroup . isCollection ( ) ) {
// In collection, only prompt if trashing
2011-08-30 23:35:12 +00:00
var prompt = force ? toTrash : false ;
2011-01-30 09:44:01 +00:00
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
else if ( itemGroup . isSearch ( ) || itemGroup . isUnfiled ( ) || itemGroup . isDuplicates ( ) ) {
2011-01-30 09:44:01 +00:00
if ( ! force ) {
return ;
}
var prompt = toTrash ;
}
// Do nothing in trash view if any non-deleted items are selected
else if ( 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 ;
}
}
}
var prompt = toDelete ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
else if ( itemGroup . isBucket ( ) ) {
var prompt = toDelete ;
}
// Do nothing in share views
else if ( itemGroup . isShare ( ) ) {
return ;
}
2011-01-30 09:44:01 +00:00
var promptService = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
if ( ! prompt || promptService . confirm ( window , prompt . title , prompt . text ) ) {
this . itemsView . deleteSelection ( force ) ;
}
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
this . mergeSelectedItems = function ( ) {
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 4 ;
if ( typeof Zotero _Duplicates _Pane == 'undefined' ) {
Zotero . debug ( "Loading duplicatesMerge.js" ) ;
Components . classes [ "@mozilla.org/moz/jssubscript-loader;1" ]
. getService ( Components . interfaces . mozIJSSubScriptLoader )
. loadSubScript ( "chrome://zotero/content/duplicatesMerge.js" ) ;
}
// Initialize the merge pane with the selected items
Zotero _Duplicates _Pane . setItems ( this . getSelectedItems ( ) ) ;
}
2013-03-17 02:55:50 +00:00
this . deleteSelectedCollection = function ( deleteItems ) {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var itemGroup = this . getItemGroup ( ) ;
// Remove virtual duplicates collection
if ( itemGroup . isDuplicates ( ) ) {
this . setVirtual ( itemGroup . ref . libraryID , 'duplicates' , false ) ;
2012-01-11 23:08:11 +00:00
return ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
}
// Remove virtual unfiled collection
else if ( itemGroup . isUnfiled ( ) ) {
this . setVirtual ( itemGroup . ref . libraryID , 'unfiled' , false ) ;
2011-02-14 03:59:32 +00:00
return ;
}
2011-01-30 09:44:01 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2013-03-17 02:55:50 +00:00
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
buttonFlags = ps . BUTTON _POS _0 * ps . BUTTON _TITLE _IS _STRING
+ ps . BUTTON _POS _1 * ps . BUTTON _TITLE _CANCEL ;
2011-01-30 09:44:01 +00:00
if ( this . collectionsView . selection . count == 1 ) {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( itemGroup . isCollection ( ) )
2011-01-30 09:44:01 +00:00
{
2013-03-17 02:55:50 +00:00
if ( deleteItems ) {
var index = ps . confirmEx (
null ,
Zotero . getString ( 'pane.collections.deleteWithItems.title' ) ,
Zotero . getString ( 'pane.collections.deleteWithItems' ) ,
buttonFlags ,
Zotero . getString ( 'pane.collections.deleteWithItems.title' ) ,
"" , "" , "" , { }
) ;
}
else {
var index = ps . confirmEx (
null ,
Zotero . getString ( 'pane.collections.delete.title' ) ,
Zotero . getString ( 'pane.collections.delete' )
+ "\n\n"
+ Zotero . getString ( 'pane.collections.delete.keepItems' ) ,
buttonFlags ,
Zotero . getString ( 'pane.collections.delete.title' ) ,
"" , "" , "" , { }
) ;
}
if ( index == 0 ) {
this . collectionsView . deleteSelection ( deleteItems ) ;
2011-01-30 09:44:01 +00:00
}
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
else if ( itemGroup . isSearch ( ) )
2011-01-30 09:44:01 +00:00
{
2013-03-17 02:55:50 +00:00
var index = ps . confirmEx (
null ,
Zotero . getString ( 'pane.collections.deleteSearch.title' ) ,
Zotero . getString ( 'pane.collections.deleteSearch' ) ,
buttonFlags ,
Zotero . getString ( 'pane.collections.deleteSearch.title' ) ,
"" , "" , "" , { }
) ;
if ( index == 0 ) {
2011-01-30 09:44:01 +00:00
this . collectionsView . deleteSelection ( ) ;
}
}
}
}
// Currently used only for Commons to find original linked item
this . getOriginalItem = function ( ) {
var item = this . getSelectedItems ( ) [ 0 ] ;
var itemGroup = this . getItemGroup ( ) ;
// TEMP: Commons buckets only
return itemGroup . ref . getLocalItem ( item ) ;
}
this . showOriginalItem = function ( ) {
var item = this . getOriginalItem ( ) ;
if ( ! item ) {
Zotero . debug ( "Original item not found" ) ;
return ;
}
this . selectItem ( item . id ) ;
}
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 ( ) {
2011-08-30 23:35:12 +00:00
var libraryID = this . getSelectedLibraryID ( ) ;
2011-01-30 09:44:01 +00:00
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var result = ps . confirm (
null ,
"" ,
Zotero . getString ( 'pane.collections.emptyTrash' ) + "\n\n"
+ Zotero . getString ( 'general.actionCannotBeUndone' )
) ;
if ( result ) {
2011-08-30 23:35:12 +00:00
Zotero . Items . emptyTrash ( libraryID ) ;
2011-01-30 09:44:01 +00:00
Zotero . purgeDataObjects ( true ) ;
}
}
function editSelectedCollection ( )
{
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
if ( this . collectionsView . selection . count > 0 ) {
var row = this . collectionsView . _getItemAtRow ( this . collectionsView . selection . currentIndex ) ;
if ( row . isCollection ( ) ) {
var promptService = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var newName = { value : row . getName ( ) } ;
var result = promptService . prompt ( window , "" ,
Zotero . getString ( 'pane.collections.rename' ) , newName , "" , { } ) ;
if ( result && newName . value ) {
row . ref . name = newName . value ;
row . ref . save ( ) ;
}
}
else {
var s = new Zotero . Search ( ) ;
s . id = row . ref . id ;
var io = { dataIn : { search : s , name : row . getName ( ) } , dataOut : null } ;
window . openDialog ( 'chrome://zotero/content/searchDialog.xul' , '' , 'chrome,modal' , io ) ;
if ( io . dataOut ) {
this . onCollectionSelected ( ) ; //reload itemsView
}
}
}
}
function copySelectedItemsToClipboard ( asCitations ) {
var items = this . getSelectedItems ( ) ;
if ( ! items . length ) {
return ;
}
// Make sure at least one item is a regular item
//
// DEBUG: We could copy notes via keyboard shortcut if we altered
// Z_F_I.copyItemsToClipboard() to use Z.QuickCopy.getContentFromItems(),
// but 1) we'd need to override that function's drag limit and 2) when I
// tried it the OS X clipboard seemed to be getting text vs. HTML wrong,
// automatically converting text/html to plaintext rather than using
// text/unicode. (That may be fixable, however.)
var canCopy = false ;
for each ( var item in items ) {
if ( item . isRegularItem ( ) ) {
canCopy = true ;
break ;
}
}
if ( ! canCopy ) {
2011-05-31 04:13:46 +00:00
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
2011-01-30 09:44:01 +00:00
. getService ( Components . interfaces . nsIPromptService ) ;
ps . alert ( null , "" , Zotero . getString ( "fileInterface.noReferencesError" ) ) ;
return ;
}
2011-07-02 04:00:12 +00:00
var url = ( window . content && window . content . location ? window . content . location . href : null ) ;
2011-01-30 09:44:01 +00:00
var [ mode , format ] = Zotero . QuickCopy . getFormatFromURL ( url ) . split ( '=' ) ;
var [ mode , contentType ] = mode . split ( '/' ) ;
if ( mode == 'bibliography' ) {
if ( asCitations ) {
Zotero _File _Interface . copyCitationToClipboard ( items , format , contentType == 'html' ) ;
}
else {
Zotero _File _Interface . copyItemsToClipboard ( items , format , contentType == 'html' ) ;
}
}
else if ( mode == 'export' ) {
// Copy citations doesn't work in export mode
if ( asCitations ) {
return ;
}
else {
Zotero _File _Interface . exportItemsToClipboard ( items , format ) ;
}
}
}
function clearQuicksearch ( ) {
var search = document . getElementById ( 'zotero-tb-search' ) ;
if ( search . value != '' ) {
search . value = '' ;
2011-04-25 15:27:49 +00:00
ZoteroPane _Local . search ( ) ;
2011-01-30 09:44:01 +00:00
}
}
function handleSearchKeypress ( textbox , event ) {
// Events that turn find-as-you-type on
if ( event . keyCode == event . DOM _VK _ESCAPE ) {
textbox . value = '' ;
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . setItemsPaneMessage ( Zotero . getString ( 'searchInProgress' ) ) ;
2011-06-20 20:02:14 +00:00
setTimeout ( function ( ) {
ZoteroPane _Local . search ( ) ;
ZoteroPane _Local . clearItemsPaneMessage ( ) ;
} , 1 ) ;
2011-01-30 09:44:01 +00:00
}
else if ( event . keyCode == event . DOM _VK _RETURN || event . keyCode == event . DOM _VK _ENTER ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . setItemsPaneMessage ( Zotero . getString ( 'searchInProgress' ) ) ;
2011-06-20 20:02:14 +00:00
setTimeout ( function ( ) {
ZoteroPane _Local . search ( true ) ;
ZoteroPane _Local . clearItemsPaneMessage ( ) ;
} , 1 ) ;
2011-01-30 09:44:01 +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 ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . setItemsPaneMessage ( Zotero . getString ( 'searchInProgress' ) ) ;
2011-06-20 20:02:14 +00:00
setTimeout ( function ( ) {
ZoteroPane _Local . search ( ) ;
ZoteroPane _Local . clearItemsPaneMessage ( ) ;
} , 1 ) ;
2011-01-30 09:44:01 +00:00
}
else if ( textbox . value . indexOf ( '"' ) != - 1 ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . setItemsPaneMessage ( Zotero . getString ( 'advancedSearchMode' ) ) ;
2011-01-30 09:44:01 +00:00
}
}
function search ( runAdvanced )
{
if ( this . itemsView ) {
var search = document . getElementById ( 'zotero-tb-search' ) ;
if ( ! runAdvanced && search . value . indexOf ( '"' ) != - 1 ) {
return ;
}
var searchVal = search . value ;
this . itemsView . setFilter ( 'search' , searchVal ) ;
}
}
/ *
* 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 )
{
if ( ! itemID ) {
return false ;
}
var item = Zotero . Items . get ( itemID ) ;
if ( ! item ) {
return false ;
}
if ( ! this . itemsView ) {
2011-03-08 23:46:01 +00:00
Components . utils . reportError ( "Items view not set in ZoteroPane_Local.selectItem()" ) ;
2011-01-30 09:44:01 +00:00
return false ;
}
var currentLibraryID = this . getSelectedLibraryID ( ) ;
// If in a different library
if ( item . libraryID != currentLibraryID ) {
2011-03-22 02:24:58 +00:00
Zotero . debug ( "Library ID differs; switching library" ) ;
2011-01-30 09:44:01 +00:00
this . collectionsView . selectLibrary ( item . libraryID ) ;
}
// Force switch to library view
else if ( ! this . itemsView . _itemGroup . isLibrary ( ) && inLibrary ) {
2011-03-22 02:24:58 +00:00
Zotero . debug ( "Told to select in library; switching to library" ) ;
2011-01-30 09:44:01 +00:00
this . collectionsView . selectLibrary ( item . libraryID ) ;
}
var selected = this . itemsView . selectItem ( itemID , expand ) ;
if ( ! selected ) {
2011-03-22 02:24:58 +00:00
Zotero . debug ( "Item was not selected; switching to library" ) ;
2011-01-30 09:44:01 +00:00
this . collectionsView . selectLibrary ( item . libraryID ) ;
this . itemsView . selectItem ( itemID , expand ) ;
}
return true ;
}
this . getSelectedLibraryID = function ( ) {
2011-10-05 17:46:23 +00:00
return this . collectionsView . getSelectedLibraryID ( ) ;
2011-01-30 09:44:01 +00:00
}
function getSelectedCollection ( asID ) {
2011-10-05 17:46:23 +00:00
return this . collectionsView ? this . collectionsView . getSelectedCollection ( asID ) : false ;
2011-01-30 09:44:01 +00:00
}
function getSelectedSavedSearch ( asID )
{
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 ;
}
}
return false ;
}
/ *
* Return an array of Item objects for selected items
*
* If asIDs is true , return an array of itemIDs instead
* /
function getSelectedItems ( asIDs )
{
if ( ! this . itemsView ) {
return [ ] ;
}
return this . itemsView . getSelectedItems ( asIDs ) ;
}
this . getSelectedGroup = function ( asID ) {
if ( this . collectionsView . selection
&& this . collectionsView . selection . count > 0
&& this . collectionsView . selection . currentIndex != - 1 ) {
2011-08-30 23:35:12 +00:00
var itemGroup = this . getItemGroup ( ) ;
2011-01-30 09:44:01 +00:00
if ( itemGroup && itemGroup . isGroup ( ) ) {
return asID ? itemGroup . ref . id : itemGroup . ref ;
}
}
return false ;
}
/ *
* Returns an array of Zotero . Item objects of visible items in current sort order
*
* If asIDs is true , return an array of itemIDs instead
* /
function getSortedItems ( asIDs ) {
if ( ! this . itemsView ) {
return [ ] ;
}
return this . itemsView . getSortedItems ( asIDs ) ;
}
function getSortField ( ) {
if ( ! this . itemsView ) {
return false ;
}
return this . itemsView . getSortField ( ) ;
}
function getSortDirection ( ) {
if ( ! this . itemsView ) {
return false ;
}
return this . itemsView . getSortDirection ( ) ;
}
this . buildCollectionContextMenu = function buildCollectionContextMenu ( )
{
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var options = [
"newCollection" ,
"newSavedSearch" ,
"newSubcollection" ,
"sep1" ,
"showDuplicates" ,
"showUnfiled" ,
"editSelectedCollection" ,
2013-03-17 02:55:50 +00:00
"deleteCollection" ,
"deleteCollectionAndItems" ,
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
"sep2" ,
"exportCollection" ,
"createBibCollection" ,
"exportFile" ,
"loadReport" ,
"emptyTrash" ,
"createCommonsBucket" ,
"refreshCommonsBucket"
] ;
var m = { } ;
var i = 0 ;
for each ( var option in options ) {
m [ option ] = i ++ ;
}
2011-01-30 09:44:01 +00:00
var menu = document . getElementById ( 'zotero-collectionmenu' ) ;
var itemGroup = this . collectionsView . _getItemAtRow ( this . collectionsView . selection . currentIndex ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// By default things are hidden and visible, so we only need to record
// when things are visible and when they're visible but disabled
var show = [ ] , disable = [ ] ;
2011-01-30 09:44:01 +00:00
if ( itemGroup . isCollection ( ) ) {
show = [
m . newSubcollection ,
m . sep1 ,
m . editSelectedCollection ,
2013-03-17 02:55:50 +00:00
m . deleteCollection ,
m . deleteCollectionAndItems ,
2011-01-30 09:44:01 +00:00
m . sep2 ,
m . exportCollection ,
m . createBibCollection ,
m . loadReport
] ;
var s = [ m . exportCollection , m . createBibCollection , m . loadReport ] ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( ! this . itemsView . rowCount ) {
if ( ! this . collectionsView . isContainerEmpty ( this . collectionsView . selection . currentIndex ) ) {
disable = [ m . createBibCollection , m . loadReport ] ;
}
else {
disable = s ;
}
2011-01-30 09:44:01 +00:00
}
// Adjust labels
menu . childNodes [ m . editSelectedCollection ] . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.rename.collection' ) ) ;
2013-03-17 02:55:50 +00:00
menu . childNodes [ m . deleteCollection ] . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.delete.collection' ) ) ;
menu . childNodes [ m . deleteCollectionAndItems ] . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.delete.collectionAndItems' ) ) ;
2011-01-30 09:44:01 +00:00
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' ) ) ;
}
else if ( itemGroup . isSearch ( ) ) {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
show = [
m . editSelectedCollection ,
2013-03-17 02:55:50 +00:00
m . deleteCollection ,
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
m . sep2 ,
m . exportCollection ,
m . createBibCollection ,
m . loadReport
] ;
2013-03-17 02:55:50 +00:00
menu . childNodes [ m . deleteCollection ] . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.delete.savedSearch' ) ) ;
2011-01-30 09:44:01 +00:00
var s = [ m . exportCollection , m . createBibCollection , m . loadReport ] ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( ! this . itemsView . rowCount ) {
2011-01-30 09:44:01 +00:00
disable = s ;
}
// Adjust labels
menu . childNodes [ m . editSelectedCollection ] . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.edit.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' ) ) ;
}
else if ( itemGroup . isTrash ( ) ) {
show = [ m . emptyTrash ] ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
else if ( itemGroup . isGroup ( ) ) {
show = [ m . newCollection , m . newSavedSearch , m . sep1 , m . showDuplicates , m . showUnfiled ] ;
}
else if ( itemGroup . isDuplicates ( ) || itemGroup . isUnfiled ( ) ) {
show = [
2013-03-17 02:55:50 +00:00
m . deleteCollection
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
] ;
2013-03-17 05:18:19 +00:00
menu . childNodes [ m . deleteCollection ] . setAttribute ( 'label' , Zotero . getString ( 'general.hide' ) ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
}
2011-01-30 09:44:01 +00:00
else if ( itemGroup . isHeader ( ) ) {
if ( itemGroup . ref . id == 'commons-header' ) {
show = [ m . createCommonsBucket ] ;
}
}
else if ( itemGroup . isBucket ( ) ) {
show = [ m . refreshCommonsBucket ] ;
}
// Library
else
{
2011-07-25 21:27:32 +00:00
show = [ m . newCollection , m . newSavedSearch , m . sep1 , m . showDuplicates , m . showUnfiled , m . sep2 , m . exportFile ] ;
2011-01-30 09:44:01 +00:00
}
// Disable some actions if user doesn't have write access
2012-01-11 23:23:36 +00:00
//
// Some actions are disabled via their commands in onCollectionSelected()
2013-03-17 02:55:50 +00:00
var s = [ m . newSubcollection , m . editSelectedCollection , m . deleteCollection , m . deleteCollectionAndItems ] ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( itemGroup . isWithinGroup ( ) && ! itemGroup . editable && ! itemGroup . isDuplicates ( ) && ! itemGroup . isUnfiled ( ) ) {
2011-01-30 09:44:01 +00:00
disable = disable . concat ( s ) ;
}
2012-01-19 07:40:46 +00:00
// If within non-editable group or trash it empty, disable Empty Trash
if ( itemGroup . isTrash ( ) ) {
if ( ( itemGroup . isWithinGroup ( ) && ! itemGroup . isWithinEditableGroup ( ) ) || ! this . itemsView . rowCount ) {
disable . push ( m . emptyTrash ) ;
}
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// Hide and enable all actions by default (so if they're shown they're enabled)
2011-01-30 09:44:01 +00:00
for each ( var pos in m ) {
menu . childNodes [ pos ] . setAttribute ( 'hidden' , true ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
menu . childNodes [ pos ] . setAttribute ( 'disabled' , false ) ;
2011-01-30 09:44:01 +00:00
}
for ( var i in show )
{
menu . childNodes [ show [ i ] ] . setAttribute ( 'hidden' , false ) ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
for ( var i in disable )
{
menu . childNodes [ disable [ i ] ] . setAttribute ( 'disabled' , true ) ;
}
2011-01-30 09:44:01 +00:00
}
function buildItemContextMenu ( )
{
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var options = [
'showInLibrary' ,
'sep1' ,
'addNote' ,
'addAttachments' ,
'sep2' ,
'duplicateItem' ,
'deleteItem' ,
'deleteFromLibrary' ,
2011-10-02 15:50:54 +00:00
'restoreToLibrary' ,
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
'mergeItems' ,
'sep3' ,
'exportItems' ,
'createBib' ,
'loadReport' ,
'sep4' ,
'recognizePDF' ,
2011-08-04 06:00:57 +00:00
'createParent' ,
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
'renameAttachments' ,
'reindexItem'
] ;
var m = { } ;
var i = 0 ;
for each ( var option in options ) {
m [ option ] = i ++ ;
}
2011-01-30 09:44:01 +00:00
var menu = document . getElementById ( 'zotero-itemmenu' ) ;
2011-03-01 22:40:56 +00:00
// remove old locate menu items
while ( menu . firstChild && menu . firstChild . getAttribute ( "zotero-locate" ) ) {
menu . removeChild ( menu . firstChild ) ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var disable = [ ] , show = [ ] , multiple = '' ;
2011-01-30 09:44:01 +00:00
if ( ! this . itemsView ) {
return ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var itemGroup = this . getItemGroup ( ) ;
2011-10-02 15:50:54 +00:00
if ( itemGroup . isTrash ( ) ) {
show . push ( m . restoreToLibrary ) ;
} else {
show . push ( m . deleteFromLibrary ) ;
}
show . push ( m . sep3 , m . exportItems , m . createBib , m . loadReport ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
2011-01-30 09:44:01 +00:00
if ( this . itemsView . selection . count > 0 ) {
// Multiple items selected
if ( this . itemsView . selection . count > 1 ) {
var multiple = '.multiple' ;
var items = this . getSelectedItems ( ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var canMerge = true , canIndex = true , canRecognize = true , canRename = true ;
2011-01-30 09:44:01 +00:00
if ( ! Zotero . Fulltext . pdfConverterIsRegistered ( ) ) {
canIndex = false ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
for each ( var item in items ) {
if ( canMerge && ! item . isRegularItem ( ) || itemGroup . isDuplicates ( ) ) {
canMerge = false ;
}
if ( canIndex && ! Zotero . Fulltext . canReindex ( item . id ) ) {
2011-01-30 09:44:01 +00:00
canIndex = false ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( canRecognize && ! Zotero _RecognizePDF . canRecognize ( item ) ) {
2011-01-30 09:44:01 +00:00
canRecognize = false ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// Show rename option only if all items are child attachments
if ( canRename && ( ! item . isAttachment ( ) || ! item . getSource ( ) || item . attachmentLinkMode == Zotero . Attachments . LINK _MODE _LINKED _URL ) ) {
canRename = false ;
2011-01-30 09:44:01 +00:00
}
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( canMerge ) {
show . push ( m . mergeItems ) ;
}
2011-01-30 09:44:01 +00:00
if ( canIndex ) {
show . push ( m . reindexItem ) ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
2011-01-30 09:44:01 +00:00
if ( canRecognize ) {
show . push ( m . recognizePDF ) ;
}
2011-08-04 06:31:14 +00:00
var canCreateParent = true ;
for each ( var item in items ) {
if ( ! item . isTopLevelItem ( ) || ! item . isAttachment ( ) ) {
canCreateParent = false ;
break ;
2011-01-30 09:44:01 +00:00
}
}
2011-08-04 06:31:14 +00:00
if ( canCreateParent ) {
show . push ( m . createParent ) ;
}
2011-01-30 09:44:01 +00:00
if ( canRename ) {
show . push ( m . renameAttachments ) ;
}
// Add in attachment separator
if ( canCreateParent || canRecognize || canRename || canIndex ) {
show . push ( m . sep4 ) ;
}
// Block certain actions on files if no access and at least one item
// is an imported attachment
if ( ! itemGroup . filesEditable ) {
var hasImportedAttachment = false ;
for ( var i = 0 ; i < items . length ; i ++ ) {
var item = items [ i ] ;
if ( item . isImportedAttachment ( ) ) {
hasImportedAttachment = true ;
break ;
}
}
if ( hasImportedAttachment ) {
2011-10-02 15:50:54 +00:00
disable . push ( m . deleteFromLibrary , m . createParent , m . renameAttachments ) ;
2011-01-30 09:44:01 +00:00
}
}
}
// Single item selected
else
{
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var item = this . getSelectedItems ( ) [ 0 ] ;
2011-01-30 09:44:01 +00:00
var itemID = item . id ;
menu . setAttribute ( 'itemID' , itemID ) ;
// Show in Library
if ( ! itemGroup . isLibrary ( ) && ! itemGroup . isWithinGroup ( ) ) {
show . push ( m . showInLibrary , m . sep1 ) ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// Disable actions in the trash
if ( itemGroup . isTrash ( ) ) {
2011-10-02 15:50:54 +00:00
disable . push ( m . deleteItem ) ;
2011-01-30 09:44:01 +00:00
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( item . isRegularItem ( ) ) {
2011-01-30 09:44:01 +00:00
show . push ( m . addNote , m . addAttachments , m . sep2 ) ;
}
if ( item . isAttachment ( ) ) {
var showSep4 = false ;
if ( Zotero _RecognizePDF . canRecognize ( item ) ) {
show . push ( m . recognizePDF ) ;
showSep4 = true ;
}
2011-08-04 06:00:57 +00:00
// Allow parent item creation for standalone attachments
if ( item . isTopLevelItem ( ) ) {
show . push ( m . createParent ) ;
showSep4 = true ;
2011-01-30 09:44:01 +00:00
}
// Attachment rename option
if ( item . getSource ( ) && item . attachmentLinkMode != Zotero . Attachments . LINK _MODE _LINKED _URL ) {
show . push ( m . renameAttachments ) ;
showSep4 = true ;
}
// If not linked URL, show reindex line
if ( Zotero . Fulltext . pdfConverterIsRegistered ( )
&& Zotero . Fulltext . canReindex ( item . id ) ) {
show . push ( m . reindexItem ) ;
showSep4 = true ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( showSep4 ) {
show . push ( m . sep4 ) ;
2011-01-30 09:44:01 +00:00
}
}
else {
show . push ( m . duplicateItem ) ;
}
// Update attachment submenu
var popup = document . getElementById ( 'zotero-add-attachment-popup' )
this . updateAttachmentButtonMenu ( popup ) ;
// Block certain actions on files if no access
if ( item . isImportedAttachment ( ) && ! itemGroup . filesEditable ) {
var d = [ m . deleteFromLibrary , m . createParent , m . renameAttachments ] ;
for each ( var val in d ) {
disable . push ( val ) ;
}
}
}
}
// No items selected
else
{
// Show in Library
if ( ! itemGroup . isLibrary ( ) ) {
show . push ( m . showInLibrary , m . sep1 ) ;
}
disable . push ( m . showInLibrary , m . duplicateItem , m . deleteItem ,
m . deleteFromLibrary , m . exportItems , m . createBib , m . loadReport ) ;
}
// TODO: implement menu for remote items
if ( ! itemGroup . editable ) {
for ( var i in m ) {
// Still show export/bib/report for non-editable views
// (other than Commons buckets, which aren't real items)
if ( ! itemGroup . isBucket ( ) ) {
switch ( i ) {
case 'exportItems' :
case 'createBib' :
case 'loadReport' :
2011-10-02 15:50:54 +00:00
case 'restoreToLibrary' :
2011-01-30 09:44:01 +00:00
continue ;
}
}
disable . push ( m [ i ] ) ;
}
}
// Remove from collection
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( itemGroup . isCollection ( ) && ! ( item && item . getSource ( ) ) )
2011-01-30 09:44:01 +00:00
{
menu . childNodes [ m . deleteItem ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.remove' + multiple ) ) ;
show . push ( m . deleteItem ) ;
}
// Plural if necessary
2013-03-17 05:18:19 +00:00
menu . childNodes [ m . deleteFromLibrary ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.moveToTrash' + multiple ) ) ;
2011-01-30 09:44:01 +00:00
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 . createParent ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.createParent' + multiple ) ) ;
menu . childNodes [ m . recognizePDF ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.recognizePDF' + multiple ) ) ;
menu . childNodes [ m . renameAttachments ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.renameAttachments' + multiple ) ) ;
menu . childNodes [ m . reindexItem ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.reindexItem' + multiple ) ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// Hide and enable all actions by default (so if they're shown they're enabled)
for each ( var pos in m ) {
menu . childNodes [ pos ] . setAttribute ( 'hidden' , true ) ;
menu . childNodes [ pos ] . setAttribute ( 'disabled' , false ) ;
2011-01-30 09:44:01 +00:00
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
for ( var i in disable )
2011-01-30 09:44:01 +00:00
{
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
menu . childNodes [ disable [ i ] ] . setAttribute ( 'disabled' , true ) ;
2011-01-30 09:44:01 +00:00
}
for ( var i in show )
{
menu . childNodes [ show [ i ] ] . setAttribute ( 'hidden' , false ) ;
}
2011-02-22 00:02:05 +00:00
// add locate menu options
2013-04-13 06:53:02 +00:00
Zotero _LocateMenu . buildContextMenu ( menu , true ) ;
2011-01-30 09:44:01 +00:00
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
this . onTreeMouseDown = function ( event ) {
2011-10-12 18:41:23 +00:00
var t = event . originalTarget ;
var tree = t . parentNode ;
2013-03-04 23:25:44 +00:00
// Ignore click on column headers
if ( ! tree . treeBoxObject ) {
return ;
}
2012-12-11 20:16:40 +00:00
var row = { } , col = { } , obj = { } ;
tree . treeBoxObject . getCellAt ( event . clientX , event . clientY , row , col , obj ) ;
if ( row . value == - 1 ) {
return ;
}
if ( tree . id == 'zotero-collections-tree' ) {
2013-02-22 23:41:49 +00:00
let itemGroup = ZoteroPane _Local . collectionsView . _getItemAtRow ( row . value ) ;
// Prevent the tree's select event from being called for a click
// on a library sync error icon
2012-12-11 20:16:40 +00:00
if ( itemGroup . isLibrary ( true ) ) {
if ( col . value . id == 'zotero-collections-sync-status-column' ) {
var libraryID = itemGroup . isLibrary ( ) ? 0 : itemGroup . ref . libraryID ;
var errors = Zotero . Sync . Runner . getErrors ( libraryID ) ;
if ( errors ) {
event . stopPropagation ( ) ;
return ;
}
}
}
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// Automatically select all equivalent items when clicking on an item
// in duplicates view
2013-02-22 23:41:49 +00:00
else if ( tree . id == 'zotero-items-tree' ) {
let itemGroup = ZoteroPane _Local . getItemGroup ( ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
2013-02-22 23:41:49 +00:00
if ( itemGroup . isDuplicates ( ) ) {
2013-05-20 02:01:50 +00:00
// Trigger only on primary-button single clicks without modifiers
2013-02-22 23:41:49 +00:00
// (so that items can still be selected and deselected manually)
2013-05-20 02:01:50 +00:00
if ( ! event || event . detail != 1 || event . button != 0 || event . metaKey
|| event . shiftKey || event . altKey || event . ctrlKey ) {
2013-02-22 23:41:49 +00:00
return ;
}
var t = event . originalTarget ;
if ( t . localName != 'treechildren' ) {
return ;
}
var tree = t . parentNode ;
var row = { } , col = { } , obj = { } ;
tree . treeBoxObject . getCellAt ( event . clientX , event . clientY , row , col , obj ) ;
// obj.value == 'cell'/'text'/'image'/'twisty'
if ( ! obj . value ) {
return ;
}
// Duplicated in itemTreeView.js::notify()
var itemID = ZoteroPane _Local . itemsView . _getItemAtRow ( row . value ) . ref . id ;
var setItemIDs = itemGroup . ref . getSetItemsByItemID ( itemID ) ;
ZoteroPane _Local . itemsView . selectItems ( setItemIDs ) ;
// Prevent the tree's select event from being called here,
// since it's triggered by the multi-select
event . stopPropagation ( ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
}
}
}
2011-01-30 09:44:01 +00:00
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
this . onTreeClick = function ( event ) {
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var t = event . originalTarget ;
if ( t . localName != 'treechildren' ) {
return ;
}
2011-10-12 18:41:23 +00:00
var tree = t . parentNode ;
2012-12-11 20:16:40 +00:00
var row = { } , col = { } , obj = { } ;
tree . treeBoxObject . getCellAt ( event . clientX , event . clientY , row , col , obj ) ;
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// We care only about primary-button double and triple clicks
2011-01-30 09:44:01 +00:00
if ( ! event || ( event . detail != 2 && event . detail != 3 ) || event . button != 0 ) {
2012-12-11 20:16:40 +00:00
if ( row . value == - 1 ) {
return ;
}
2013-02-22 23:41:49 +00:00
if ( tree . id == 'zotero-collections-tree' ) {
let itemGroup = ZoteroPane _Local . collectionsView . _getItemAtRow ( row . value ) ;
// Show the error panel when clicking a library-specific
// sync error icon
if ( itemGroup . isLibrary ( true ) ) {
if ( col . value . id == 'zotero-collections-sync-status-column' ) {
var libraryID = itemGroup . isLibrary ( ) ? 0 : itemGroup . ref . libraryID ;
var errors = Zotero . Sync . Runner . getErrors ( libraryID ) ;
if ( ! errors ) {
return ;
}
var panel = Zotero . Sync . Runner . updateErrorPanel ( window . document , errors ) ;
var anchor = document . getElementById ( 'zotero-collections-tree-shim' ) ;
var x = { } , y = { } , width = { } , height = { } ;
tree . treeBoxObject . getCoordsForCellItem ( row . value , col . value , 'image' , x , y , width , height ) ;
x = x . value + Math . round ( width . value / 2 ) ;
y = y . value + height . value + 3 ;
panel . openPopup ( anchor , "after_start" , x , y , false , false ) ;
2012-12-11 20:16:40 +00:00
}
2013-02-22 23:41:49 +00:00
return ;
2012-12-11 20:16:40 +00:00
}
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// The Mozilla tree binding fires select() in mousedown(),
// but if when it gets to click() the selection differs from
// what it expects (say, because multiple items had been
2012-12-11 20:16:40 +00:00
// selected during mousedown(), as is the case in duplicates mode),
// it fires select() again. We prevent that here.
2013-02-22 23:41:49 +00:00
else if ( tree . id == 'zotero-items-tree' ) {
let itemGroup = ZoteroPane _Local . getItemGroup ( ) ;
if ( itemGroup . isDuplicates ( ) ) {
2013-05-20 09:39:19 +00:00
if ( event . button != 0 || event . metaKey || event . shiftKey
|| event . altKey || event . ctrlKey ) {
2013-02-22 23:41:49 +00:00
return ;
}
if ( obj . value == 'twisty' ) {
return ;
}
event . stopPropagation ( ) ;
event . preventDefault ( ) ;
2011-10-12 18:41:23 +00:00
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
}
2011-01-30 09:44:01 +00:00
return ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
var itemGroup = ZoteroPane _Local . getItemGroup ( ) ;
2011-01-30 09:44:01 +00:00
2011-10-12 18:41:23 +00:00
// Ignore double-clicks in duplicates view on everything except attachments
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
if ( itemGroup . isDuplicates ( ) ) {
2011-10-12 18:41:23 +00:00
var items = ZoteroPane _Local . getSelectedItems ( ) ;
if ( items . length != 1 || ! items [ 0 ] . isAttachment ( ) ) {
event . stopPropagation ( ) ;
event . preventDefault ( ) ;
return ;
}
2011-01-30 09:44:01 +00:00
}
// obj.value == 'cell'/'text'/'image'
if ( ! obj . value ) {
return ;
}
if ( tree . id == 'zotero-collections-tree' ) {
// Ignore triple clicks for collections
if ( event . detail != 2 ) {
return ;
}
if ( itemGroup . isLibrary ( ) ) {
var uri = Zotero . URI . getCurrentUserLibraryURI ( ) ;
if ( uri ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . loadURI ( uri ) ;
2011-01-30 09:44:01 +00:00
event . stopPropagation ( ) ;
}
return ;
}
if ( itemGroup . isSearch ( ) ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . editSelectedCollection ( ) ;
2011-01-30 09:44:01 +00:00
return ;
}
if ( itemGroup . isGroup ( ) ) {
var uri = Zotero . URI . getGroupURI ( itemGroup . ref , true ) ;
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . loadURI ( uri ) ;
2011-01-30 09:44:01 +00:00
event . stopPropagation ( ) ;
return ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
// Ignore double-clicks on Unfiled Items source row
if ( itemGroup . isUnfiled ( ) ) {
return ;
}
2011-01-30 09:44:01 +00:00
if ( itemGroup . isHeader ( ) ) {
if ( itemGroup . ref . id == 'group-libraries-header' ) {
var uri = Zotero . URI . getGroupsURL ( ) ;
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . loadURI ( uri ) ;
2011-01-30 09:44:01 +00:00
event . stopPropagation ( ) ;
}
return ;
}
if ( itemGroup . isBucket ( ) ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . loadURI ( itemGroup . ref . uri ) ;
2011-01-30 09:44:01 +00:00
event . stopPropagation ( ) ;
}
}
else if ( tree . id == 'zotero-items-tree' ) {
2012-11-20 10:34:38 +00:00
var viewOnDoubleClick = Zotero . Prefs . get ( 'viewOnDoubleClick' ) ;
if ( viewOnDoubleClick ) {
// Expand/collapse on triple-click, though the double-click
// will still trigger
if ( event . detail == 3 ) {
tree . view . toggleOpenState ( tree . view . selection . currentIndex ) ;
return ;
}
// Don't expand/collapse on double-click
event . stopPropagation ( ) ;
2011-01-30 09:44:01 +00:00
}
if ( tree . view && tree . view . selection . currentIndex > - 1 ) {
2011-03-08 23:46:01 +00:00
var item = ZoteroPane _Local . getSelectedItems ( ) [ 0 ] ;
2011-01-30 09:44:01 +00:00
if ( item ) {
2012-11-20 10:34:38 +00:00
if ( ! viewOnDoubleClick && item . isRegularItem ( ) ) {
return ;
}
2012-11-01 05:53:31 +00:00
ZoteroPane _Local . viewItems ( [ item ] , event ) ;
2011-01-30 09:44:01 +00:00
}
}
}
}
this . openPreferences = function ( paneID , action ) {
var io = {
pane : paneID ,
action : action
} ;
2013-02-19 21:27:16 +00:00
var win = null ;
// If window is already open, just focus it
if ( ! action ) {
var wm = Components . classes [ "@mozilla.org/appshell/window-mediator;1" ]
. getService ( Components . interfaces . nsIWindowMediator ) ;
var enumerator = wm . getEnumerator ( "zotero:pref" ) ;
if ( enumerator . hasMoreElements ( ) ) {
var win = enumerator . getNext ( ) ;
win . focus ( ) ;
if ( paneID ) {
var pane = win . document . getElementsByAttribute ( 'id' , paneID ) [ 0 ] ;
pane . parentElement . showPane ( pane ) ;
}
}
}
if ( ! win ) {
window . openDialog ( 'chrome://zotero/content/preferences/preferences.xul' ,
'zotero-prefs' ,
'chrome,titlebar,toolbar,centerscreen,'
+ Zotero . Prefs . get ( 'browser.preferences.instantApply' , true ) ? 'dialog=no' : 'modal' ,
io
) ;
}
2011-01-30 09:44:01 +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
* /
2011-12-14 22:49:14 +00:00
function loadURI ( uris , event ) {
2011-02-09 03:22:06 +00:00
if ( typeof uris === "string" ) {
uris = [ uris ] ;
2011-01-30 09:44:01 +00:00
}
2011-02-09 03:22:06 +00:00
for each ( var uri in uris ) {
// Ignore javascript: and data: URIs
if ( uri . match ( /^(javascript|data):/ ) ) {
return ;
2011-01-30 09:44:01 +00:00
}
2011-08-16 02:37:16 +00:00
if ( Zotero . isStandalone ) {
if ( uri . match ( /^https?/ ) ) {
2012-01-20 20:23:06 +00:00
this . launchURL ( uri ) ;
2011-08-16 02:37:16 +00:00
} else {
ZoteroStandalone . openInViewer ( uri ) ;
}
2011-02-09 03:22:06 +00:00
return ;
}
2011-01-30 09:44:01 +00:00
2011-02-09 03:22:06 +00:00
// Open in new tab
var openInNewTab = event && ( event . metaKey || ( ! Zotero . isMac && event . ctrlKey ) ) ;
if ( event && event . shiftKey && ! openInNewTab ) {
window . open ( uri , "zotero-loaded-page" ,
"menubar=yes,location=yes,toolbar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes" ) ;
}
else if ( openInNewTab || ! window . loadURI || uris . length > 1 ) {
// if no gBrowser, find it
if ( ! gBrowser ) {
var wm = Components . classes [ "@mozilla.org/appshell/window-mediator;1" ]
. getService ( Components . interfaces . nsIWindowMediator ) ;
var browserWindow = wm . getMostRecentWindow ( "navigator:browser" ) ;
var gBrowser = browserWindow . gBrowser ;
}
// load in a new tab
var tab = gBrowser . addTab ( uri ) ;
var browser = gBrowser . getBrowserForTab ( tab ) ;
if ( event && event . shiftKey || ! openInNewTab ) {
// if shift key is down, or we are opening in a new tab because there is no loadURI,
// select new tab
gBrowser . selectedTab = tab ;
}
}
else {
window . loadURI ( uri ) ;
2011-01-30 09:44:01 +00:00
}
}
}
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 ;
}
Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys
Possible future improvements:
- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates
Other changes in this commit:
- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things
Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00
this . setItemPaneMessage = function ( msg ) {
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 0 ;
var label = document . getElementById ( 'zotero-item-pane-message' ) ;
label . value = msg ;
}
2011-01-30 09:44:01 +00:00
// Updates browser context menu options
function contextPopupShowing ( )
{
if ( ! Zotero . Prefs . get ( 'browserContentContextMenu' ) ) {
return ;
}
var menuitem = document . getElementById ( "zotero-context-add-to-current-note" ) ;
if ( menuitem ) {
2011-03-08 23:46:01 +00:00
var items = ZoteroPane _Local . getSelectedItems ( ) ;
if ( ZoteroPane _Local . itemsView . selection && ZoteroPane _Local . itemsView . selection . count == 1
2011-01-30 09:44:01 +00:00
&& items [ 0 ] && items [ 0 ] . isNote ( )
&& window . gContextMenu . isTextSelected )
{
menuitem . hidden = false ;
}
else
{
menuitem . hidden = true ;
}
}
var menuitem = document . getElementById ( "zotero-context-add-to-new-note" ) ;
if ( menuitem ) {
if ( window . gContextMenu . isTextSelected )
{
menuitem . hidden = false ;
}
else
{
menuitem . hidden = true ;
}
}
var menuitem = document . getElementById ( "zotero-context-save-link-as-item" ) ;
if ( menuitem ) {
if ( window . gContextMenu . onLink ) {
menuitem . hidden = false ;
}
else {
menuitem . hidden = true ;
}
}
var menuitem = document . getElementById ( "zotero-context-save-image-as-item" ) ;
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 ;
}
else {
menuitem . hidden = true ;
}
}
// If Zotero is locked or library is read-only, disable menu items
var menu = document . getElementById ( 'zotero-content-area-context-menu' ) ;
var disabled = Zotero . locked ;
if ( ! disabled && self . collectionsView . selection && self . collectionsView . selection . count ) {
var itemGroup = self . collectionsView . _getItemAtRow ( self . collectionsView . selection . currentIndex ) ;
disabled = ! itemGroup . editable ;
}
for each ( var menuitem in menu . firstChild . childNodes ) {
menuitem . disabled = disabled ;
}
}
this . newNote = function ( popup , parent , text , citeURI ) {
if ( ! Zotero . stateCheck ( ) ) {
this . displayErrorMessage ( true ) ;
return ;
}
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
if ( ! popup ) {
if ( ! text ) {
text = '' ;
}
text = Zotero . Utilities . trim ( text ) ;
if ( text ) {
text = '<blockquote'
+ ( citeURI ? ' cite="' + citeURI + '"' : '' )
+ '>' + Zotero . Utilities . text2html ( text ) + "</blockquote>" ;
}
var item = new Zotero . Item ( 'note' ) ;
item . libraryID = this . getSelectedLibraryID ( ) ;
item . setNote ( text ) ;
if ( parent ) {
item . setSource ( parent ) ;
}
var itemID = item . save ( ) ;
if ( ! parent && 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 ) {
this . openNoteWindow ( null , c . id , parent ) ;
}
else {
this . openNoteWindow ( null , null , parent ) ;
}
}
}
function addTextToNote ( text , citeURI )
{
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
if ( ! text ) {
return false ;
}
text = Zotero . Utilities . trim ( text ) ;
if ( ! text . length ) {
return false ;
}
text = '<blockquote'
+ ( citeURI ? ' cite="' + citeURI + '"' : '' )
+ '>' + Zotero . Utilities . text2html ( text ) + "</blockquote>" ;
var items = this . getSelectedItems ( ) ;
if ( this . itemsView . selection . count == 1 && items [ 0 ] && items [ 0 ] . isNote ( ) ) {
var note = items [ 0 ] . getNote ( )
items [ 0 ] . setNote ( note + text ) ;
items [ 0 ] . save ( ) ;
var noteElem = document . getElementById ( 'zotero-note-editor' )
noteElem . focus ( ) ;
return true ;
}
return false ;
}
function openNoteWindow ( itemID , col , parentItemID )
{
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
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 ) ;
2014-05-28 18:31:58 +00:00
var e = wm . getEnumerator ( 'zotero:note' ) ;
2011-01-30 09:44:01 +00:00
while ( e . hasMoreElements ( ) ) {
var w = e . getNext ( ) ;
if ( w . name == name ) {
w . focus ( ) ;
return ;
}
}
}
2014-05-28 18:31:58 +00:00
var io = { itemID : itemID , collectionID : col , parentItemID : parentItemID } ;
2014-06-05 04:53:44 +00:00
window . openDialog ( 'chrome://zotero/content/note.xul' , name , 'chrome,resizable,centerscreen,dialog=false' , io ) ;
2011-01-30 09:44:01 +00:00
}
2011-06-16 18:17:06 +00:00
this . addAttachmentFromURI = function ( link , itemID ) {
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2014-12-16 16:20:55 +00:00
var io = { } ;
window . openDialog ( 'chrome://zotero/content/attachLink.xul' ,
'zotero-attach-uri-dialog' , 'centerscreen, modal' , io ) ;
if ( io . out ) {
Zotero . Attachments . linkFromURL ( io . out . link , itemID , null , io . out . title ) ;
}
2011-06-16 18:17:06 +00:00
}
2011-01-30 09:44:01 +00:00
function addAttachmentFromDialog ( link , id )
{
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2011-03-08 23:46:01 +00:00
var itemGroup = ZoteroPane _Local . collectionsView . _getItemAtRow ( this . collectionsView . selection . currentIndex ) ;
2011-01-30 09:44:01 +00:00
if ( link && itemGroup . isWithinGroup ( ) ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
ps . alert ( null , "" , "Linked files cannot be added to group libraries." ) ;
return ;
}
// TODO: disable in menu
if ( ! this . canEditFiles ( ) ) {
this . displayCannotEditLibraryFilesMessage ( ) ;
return ;
}
var libraryID = itemGroup . ref . libraryID ;
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 . modeOpenMultiple ) ;
fp . appendFilters ( Components . interfaces . nsIFilePicker . filterAll ) ;
if ( fp . show ( ) == nsIFilePicker . returnOK )
{
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 , libraryID ) ;
if ( attachmentID && ! id )
{
var c = this . getSelectedCollection ( ) ;
if ( c )
c . addItem ( attachmentID ) ;
}
}
}
}
this . addItemFromPage = function ( itemType , saveSnapshot , row ) {
2011-08-13 04:51:40 +00:00
if ( Zotero . isConnector ) {
// In connector, save page via Zotero Standalone
var doc = window . content . document ;
Zotero . Connector . callMethod ( "saveSnapshot" , { "url" : doc . location . toString ( ) ,
"cookie" : doc . cookie , "html" : doc . documentElement . innerHTML } ,
function ( returnValue , status ) {
_showPageSaveStatus ( doc . title ) ;
} ) ;
return ;
}
if ( ( row || ( this . collectionsView && this . collectionsView . selection ) ) && ! this . canEdit ( row ) ) {
2011-01-30 09:44:01 +00:00
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
return this . addItemFromDocument ( window . content . document , itemType , saveSnapshot , row ) ;
}
2011-08-13 04:51:40 +00:00
/ * *
* Shows progress dialog for a webpage / snapshot save request
* /
function _showPageSaveStatus ( title ) {
var progressWin = new Zotero . ProgressWindow ( ) ;
progressWin . changeHeadline ( Zotero . getString ( 'ingester.scraping' ) ) ;
var icon = 'chrome://zotero/skin/treeitem-webpage.png' ;
progressWin . addLines ( title , icon )
progressWin . show ( ) ;
progressWin . startCloseTimer ( ) ;
}
2011-01-30 09:44:01 +00:00
/ * *
* @ param { Document } doc
* @ param { String | Integer } [ itemType = 'webpage' ] Item type id or name
* @ param { Boolean } [ saveSnapshot ] Force saving or non - saving of a snapshot ,
* regardless of automaticSnapshots pref
* /
this . addItemFromDocument = function ( doc , itemType , saveSnapshot , row ) {
2011-08-13 04:51:40 +00:00
_showPageSaveStatus ( doc . title ) ;
2011-01-30 09:44:01 +00:00
// Save snapshot if explicitly enabled or automatically pref is set and not explicitly disabled
saveSnapshot = saveSnapshot || ( saveSnapshot !== false && Zotero . Prefs . get ( 'automaticSnapshots' ) ) ;
// TODO: this, needless to say, is a temporary hack
if ( itemType == 'temporaryPDFHack' ) {
itemType = null ;
var isPDF = false ;
2013-04-21 01:48:28 +00:00
if ( doc . title . indexOf ( 'application/pdf' ) != - 1 || Zotero . Attachments . isPDFJS ( doc )
|| doc . contentType == 'application/pdf' ) {
2011-01-30 09:44:01 +00:00
isPDF = true ;
}
else {
var ios = Components . classes [ "@mozilla.org/network/io-service;1" ] .
getService ( Components . interfaces . nsIIOService ) ;
try {
var uri = ios . newURI ( doc . location , null , null ) ;
if ( uri . fileName && uri . fileName . match ( /pdf$/ ) ) {
isPDF = true ;
}
}
catch ( e ) {
Zotero . debug ( e ) ;
Components . utils . reportError ( e ) ;
}
}
if ( isPDF && saveSnapshot ) {
//
// Duplicate newItem() checks here
//
if ( ! Zotero . stateCheck ( ) ) {
this . displayErrorMessage ( true ) ;
return false ;
}
// Currently selected row
2011-08-13 04:51:40 +00:00
if ( row === undefined && this . collectionsView && this . collectionsView . selection ) {
2011-01-30 09:44:01 +00:00
row = this . collectionsView . selection . currentIndex ;
}
2011-08-13 04:51:40 +00:00
if ( row && ! this . canEdit ( row ) ) {
2011-01-30 09:44:01 +00:00
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
if ( row !== undefined ) {
var itemGroup = this . collectionsView . _getItemAtRow ( row ) ;
var libraryID = itemGroup . ref . libraryID ;
}
else {
var libraryID = null ;
var itemGroup = null ;
}
//
//
//
if ( ! this . canEditFiles ( row ) ) {
this . displayCannotEditLibraryFilesMessage ( ) ;
return ;
}
if ( itemGroup && itemGroup . isCollection ( ) ) {
var collectionID = itemGroup . ref . id ;
}
else {
var collectionID = false ;
}
var itemID = Zotero . Attachments . importFromDocument ( doc , false , false , collectionID , null , libraryID ) ;
// importFromDocument() doesn't trigger the notifier for a second
//
// The one-second delay is weird but better than nothing
var self = this ;
setTimeout ( function ( ) {
self . selectItem ( itemID ) ;
} , 1001 ) ;
return ;
}
}
// Save web page item by default
if ( ! itemType ) {
itemType = 'webpage' ;
}
var data = {
title : doc . title ,
url : doc . location . href ,
accessDate : "CURRENT_TIMESTAMP"
}
itemType = Zotero . ItemTypes . getID ( itemType ) ;
var item = this . newItem ( itemType , data , row ) ;
if ( item . libraryID ) {
var group = Zotero . Groups . getByLibraryID ( item . libraryID ) ;
2012-02-04 03:10:58 +00:00
var filesEditable = group . filesEditable ;
2011-01-30 09:44:01 +00:00
}
else {
2012-02-04 03:10:58 +00:00
var filesEditable = true ;
2011-01-30 09:44:01 +00:00
}
if ( saveSnapshot ) {
var link = false ;
if ( link ) {
Zotero . Attachments . linkFromDocument ( doc , item . id ) ;
}
else if ( filesEditable ) {
Zotero . Attachments . importFromDocument ( doc , item . id ) ;
}
}
return item . id ;
}
this . addItemFromURL = function ( url , itemType , saveSnapshot , row ) {
2011-09-27 14:51:15 +00:00
if ( window . content && url == window . content . document . location . href ) {
2011-01-30 09:44:01 +00:00
return this . addItemFromPage ( itemType , saveSnapshot , row ) ;
}
var self = this ;
2012-01-17 04:07:56 +00:00
url = Zotero . Utilities . resolveIntermediateURL ( url ) ;
2011-01-30 09:44:01 +00:00
Zotero . MIME . getMIMETypeFromURL ( url , function ( mimeType , hasNativeHandler ) {
// If native type, save using a hidden browser
if ( hasNativeHandler ) {
var processor = function ( doc ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . addItemFromDocument ( doc , itemType , saveSnapshot , row ) ;
2011-01-30 09:44:01 +00:00
} ;
var done = function ( ) { }
var exception = function ( e ) {
Zotero . debug ( e ) ;
}
Zotero . HTTP . processDocuments ( [ url ] , processor , done , exception ) ;
}
// Otherwise create placeholder item, attach attachment, and update from that
else {
// TODO: this, needless to say, is a temporary hack
if ( itemType == 'temporaryPDFHack' ) {
itemType = null ;
if ( mimeType == 'application/pdf' ) {
//
// Duplicate newItem() checks here
//
if ( ! Zotero . stateCheck ( ) ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . displayErrorMessage ( true ) ;
2011-01-30 09:44:01 +00:00
return false ;
}
// Currently selected row
if ( row === undefined ) {
2011-03-08 23:46:01 +00:00
row = ZoteroPane _Local . collectionsView . selection . currentIndex ;
2011-01-30 09:44:01 +00:00
}
2011-03-08 23:46:01 +00:00
if ( ! ZoteroPane _Local . canEdit ( row ) ) {
ZoteroPane _Local . displayCannotEditLibraryMessage ( ) ;
2011-01-30 09:44:01 +00:00
return ;
}
if ( row !== undefined ) {
2011-03-08 23:46:01 +00:00
var itemGroup = ZoteroPane _Local . collectionsView . _getItemAtRow ( row ) ;
2011-01-30 09:44:01 +00:00
var libraryID = itemGroup . ref . libraryID ;
}
else {
var libraryID = null ;
var itemGroup = null ;
}
//
//
//
2011-03-08 23:46:01 +00:00
if ( ! ZoteroPane _Local . canEditFiles ( row ) ) {
ZoteroPane _Local . displayCannotEditLibraryFilesMessage ( ) ;
2011-01-30 09:44:01 +00:00
return ;
}
if ( itemGroup && itemGroup . isCollection ( ) ) {
var collectionID = itemGroup . ref . id ;
}
else {
var collectionID = false ;
}
2013-05-22 02:55:49 +00:00
var attachmentItem = Zotero . Attachments . importFromURL ( url , false ,
false , false , collectionID , mimeType , libraryID ,
function ( attachmentItem ) {
self . selectItem ( attachmentItem . id ) ;
} ) ;
2011-01-30 09:44:01 +00:00
return ;
}
}
if ( ! itemType ) {
itemType = 'webpage' ;
}
2011-03-08 23:46:01 +00:00
var item = ZoteroPane _Local . newItem ( itemType , { } , row ) ;
2011-01-30 09:44:01 +00:00
if ( item . libraryID ) {
var group = Zotero . Groups . getByLibraryID ( item . libraryID ) ;
filesEditable = group . filesEditable ;
}
else {
filesEditable = true ;
}
// Save snapshot if explicitly enabled or automatically pref is set and not explicitly disabled
if ( saveSnapshot || ( saveSnapshot !== false && Zotero . Prefs . get ( 'automaticSnapshots' ) ) ) {
var link = false ;
if ( link ) {
//Zotero.Attachments.linkFromURL(doc, item.id);
}
else if ( filesEditable ) {
var attachmentItem = Zotero . Attachments . importFromURL ( url , item . id , false , false , false , mimeType ) ;
if ( attachmentItem ) {
item . setField ( 'title' , attachmentItem . getField ( 'title' ) ) ;
item . setField ( 'url' , attachmentItem . getField ( 'url' ) ) ;
item . setField ( 'accessDate' , attachmentItem . getField ( 'accessDate' ) ) ;
item . save ( ) ;
}
}
}
return item . id ;
}
} ) ;
}
/ *
* Create an attachment from the current page
*
* | itemID | -- itemID of parent item
* | link | -- create web link instead of snapshot
* /
this . addAttachmentFromPage = function ( link , itemID )
{
if ( ! Zotero . stateCheck ( ) ) {
this . displayErrorMessage ( true ) ;
return ;
}
if ( typeof itemID != 'number' ) {
2011-03-08 23:46:01 +00:00
throw ( "itemID must be an integer in ZoteroPane_Local.addAttachmentFromPage()" ) ;
2011-01-30 09:44:01 +00:00
}
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 ( link ) {
Zotero . Attachments . linkFromDocument ( window . content . document , itemID ) ;
}
else {
Zotero . Attachments . importFromDocument ( window . content . document , itemID ) ;
}
}
2012-11-01 05:53:31 +00:00
this . viewItems = function ( items , event ) {
if ( items . length > 1 ) {
if ( ! event || ( ! event . metaKey && ! event . shiftKey ) ) {
event = { metaKey : true , shiftKey : true } ;
}
}
for each ( var item in items ) {
if ( item . isRegularItem ( ) ) {
2013-01-31 22:44:51 +00:00
// Prefer local file attachments
2012-11-01 05:53:31 +00:00
var uri = Components . classes [ "@mozilla.org/network/standard-url;1" ]
. createInstance ( Components . interfaces . nsIURI ) ;
var snapID = item . getBestAttachment ( ) ;
if ( snapID ) {
2012-11-02 02:14:08 +00:00
ZoteroPane _Local . viewAttachment ( snapID , event ) ;
continue ;
2012-11-01 05:53:31 +00:00
}
2013-01-31 22:44:51 +00:00
// Fall back to URI field, then DOI
2012-11-01 05:53:31 +00:00
var uri = item . getField ( 'url' ) ;
if ( ! uri ) {
var doi = item . getField ( 'DOI' ) ;
if ( doi ) {
// Pull out DOI, in case there's a prefix
doi = Zotero . Utilities . cleanDOI ( doi ) ;
if ( doi ) {
uri = "http://dx.doi.org/" + encodeURIComponent ( doi ) ;
}
}
}
2013-01-31 22:17:53 +00:00
2013-01-31 22:44:51 +00:00
// Fall back to first attachment link
if ( ! uri ) {
2013-01-31 22:17:53 +00:00
var link = item . getAttachments ( ) [ 0 ] ;
2013-01-31 22:44:51 +00:00
if ( link ) {
2013-01-31 22:17:53 +00:00
link = Zotero . Items . get ( link ) ;
2013-01-31 22:44:51 +00:00
if ( link ) uri = link . getField ( 'url' ) ;
2013-01-31 22:17:53 +00:00
}
}
2012-11-01 05:53:31 +00:00
if ( uri ) {
ZoteroPane _Local . loadURI ( uri , event ) ;
}
}
else if ( item . isNote ( ) ) {
if ( ! ZoteroPane _Local . collectionsView . editable ) {
continue ;
}
document . getElementById ( 'zotero-view-note-button' ) . doCommand ( ) ;
}
else if ( item . isAttachment ( ) ) {
ZoteroPane _Local . viewAttachment ( item . id , event ) ;
}
}
}
2011-07-11 22:19:10 +00:00
function viewAttachment ( itemIDs , event , noLocateOnMissing , forceExternalViewer ) {
2012-12-11 20:16:40 +00:00
Components . utils . import ( "resource://zotero/q.js" ) ;
2011-10-15 05:50:30 +00:00
// If view isn't editable, don't show Locate button, since the updated
// path couldn't be sent back up
2011-11-16 22:55:18 +00:00
if ( ! this . collectionsView . editable ) {
2011-10-15 05:50:30 +00:00
noLocateOnMissing = true ;
}
2011-07-11 22:19:10 +00:00
if ( typeof itemIDs != "object" ) itemIDs = [ itemIDs ] ;
2011-01-30 09:44:01 +00:00
2011-07-11 22:19:10 +00:00
// If multiple items, set up event so we open in new tab
if ( itemIDs . length > 1 ) {
if ( ! event || ( ! event . metaKey && ! event . shiftKey ) ) {
event = { "metaKey" : true , "shiftKey" : true } ;
}
2011-01-30 09:44:01 +00:00
}
2011-07-11 22:19:10 +00:00
for each ( var itemID in itemIDs ) {
2011-11-14 08:42:06 +00:00
var item = Zotero . Items . get ( itemID ) ;
if ( ! item . isAttachment ( ) ) {
2011-07-11 22:19:10 +00:00
throw ( "Item " + itemID + " is not an attachment in ZoteroPane_Local.viewAttachment()" ) ;
}
2011-11-14 08:42:06 +00:00
if ( item . attachmentLinkMode == Zotero . Attachments . LINK _MODE _LINKED _URL ) {
this . loadURI ( item . getField ( 'url' ) , event ) ;
2011-07-11 22:19:10 +00:00
continue ;
}
2011-11-14 08:42:06 +00:00
var file = item . getFile ( ) ;
2011-07-11 22:19:10 +00:00
if ( file ) {
2013-04-19 05:18:59 +00:00
Zotero . debug ( "Opening " + file . path ) ;
2011-07-11 22:19:10 +00:00
if ( forceExternalViewer !== undefined ) {
var externalViewer = forceExternalViewer ;
} else {
2013-01-29 03:44:02 +00:00
var mimeType = Zotero . MIME . getMIMETypeFromFile ( file ) ;
//var mimeType = attachment.attachmentMIMEType;
// TODO: update DB with new info if changed?
2011-02-11 08:07:20 +00:00
2011-07-11 22:19:10 +00:00
var ext = Zotero . File . getExtension ( file ) ;
var externalViewer = Zotero . isStandalone || ( ! Zotero . MIME . hasNativeHandler ( mimeType , ext ) &&
( ! Zotero . MIME . hasInternalHandler ( mimeType , ext ) || Zotero . Prefs . get ( 'launchNonNativeFiles' ) ) ) ;
2011-02-11 08:07:20 +00:00
}
2011-01-30 09:44:01 +00:00
2011-07-11 22:19:10 +00:00
if ( ! externalViewer ) {
var url = 'zotero://attachment/' + itemID + '/' ;
2011-12-14 22:49:14 +00:00
this . loadURI ( url , event ) ;
2011-01-30 09:44:01 +00:00
}
2011-07-11 22:19:10 +00:00
else {
2013-08-02 04:45:26 +00:00
Zotero . Notifier . trigger ( 'open' , 'file' , itemID ) ;
2013-04-11 08:28:38 +00:00
Zotero . launchFile ( file ) ;
2011-01-30 09:44:01 +00:00
}
}
2011-07-11 22:19:10 +00:00
else {
2012-12-11 20:16:40 +00:00
if ( ! item . isImportedAttachment ( ) || ! Zotero . Sync . Storage . downloadAsNeeded ( item . libraryID ) ) {
this . showAttachmentNotFoundDialog ( itemID , noLocateOnMissing ) ;
return ;
2011-11-14 08:42:06 +00:00
}
2012-12-11 20:16:40 +00:00
let downloadedItem = item ;
Q . fcall ( function ( ) {
return Zotero . Sync . Storage . downloadFile (
downloadedItem ,
{
onProgress : function ( progress , progressMax ) { }
} ) ;
} )
. then ( function ( ) {
if ( ! downloadedItem . getFile ( ) ) {
ZoteroPane _Local . showAttachmentNotFoundDialog ( downloadedItem . id , noLocateOnMissing ) ;
return ;
}
// check if unchanged?
// maybe not necessary, since we'll get an error if there's an error
Zotero . Notifier . trigger ( 'redraw' , 'item' , [ ] ) ;
ZoteroPane _Local . viewAttachment ( downloadedItem . id , event , false , forceExternalViewer ) ;
} )
. fail ( function ( e ) {
// TODO: show error somewhere else
Zotero . debug ( e , 1 ) ;
ZoteroPane _Local . syncAlert ( e ) ;
} )
2013-02-18 21:05:58 +00:00
. done ( ) ;
2011-07-11 22:19:10 +00:00
}
2011-01-30 09:44:01 +00:00
}
}
2012-01-20 20:23:06 +00:00
/ * *
2013-04-11 08:28:38 +00:00
* @ deprecated
2012-01-20 20:23:06 +00:00
* /
this . launchFile = function ( file ) {
2013-04-11 08:28:38 +00:00
Zotero . debug ( "ZoteroPane.launchFile() is deprecated -- use Zotero.launchFile()" , 2 ) ;
Zotero . launchFile ( file ) ;
2012-01-20 20:23:06 +00:00
}
/ * *
* Launch an HTTP URL externally , the best way we can
*
* Used only by Standalone
* /
this . launchURL = function ( url ) {
if ( ! url . match ( /^https?/ ) ) {
throw new Error ( "launchURL() requires an HTTP(S) URL" ) ;
}
try {
var io = Components . classes [ '@mozilla.org/network/io-service;1' ]
. getService ( Components . interfaces . nsIIOService ) ;
var uri = io . newURI ( url , null , null ) ;
var handler = Components . classes [ '@mozilla.org/uriloader/external-protocol-service;1' ]
. getService ( Components . interfaces . nsIExternalProtocolService )
. getProtocolHandlerInfo ( 'http' ) ;
handler . preferredAction = Components . interfaces . nsIHandlerInfo . useSystemDefault ;
handler . launchWithURI ( uri , null ) ;
}
catch ( e ) {
Zotero . debug ( "launchWithURI() not supported -- trying fallback executable" ) ;
if ( Zotero . isWin ) {
var pref = "fallbackLauncher.windows" ;
}
else {
var pref = "fallbackLauncher.unix" ;
}
var path = Zotero . Prefs . get ( pref ) ;
var exec = Components . classes [ "@mozilla.org/file/local;1" ]
. createInstance ( Components . interfaces . nsILocalFile ) ;
exec . initWithPath ( path ) ;
if ( ! exec . exists ( ) ) {
throw ( "Fallback executable not found -- check extensions.zotero." + pref + " in about:config" ) ;
}
var proc = Components . classes [ "@mozilla.org/process/util;1" ]
. createInstance ( Components . interfaces . nsIProcess ) ;
proc . init ( exec ) ;
var args = [ url ] ;
2012-03-20 06:16:43 +00:00
proc . runw ( false , args , args . length ) ;
2012-03-21 18:22:21 +00:00
}
2012-01-20 20:23:06 +00:00
}
2011-01-30 09:44:01 +00:00
function viewSelectedAttachment ( event , noLocateOnMissing )
{
if ( this . itemsView && this . itemsView . selection . count == 1 ) {
this . viewAttachment ( this . getSelectedItems ( true ) [ 0 ] , event , noLocateOnMissing ) ;
}
}
this . showAttachmentInFilesystem = function ( itemID , noLocateOnMissing ) {
var attachment = Zotero . Items . get ( itemID )
if ( attachment . attachmentLinkMode != Zotero . Attachments . LINK _MODE _LINKED _URL ) {
var file = attachment . getFile ( ) ;
2012-01-20 20:23:06 +00:00
if ( file ) {
2011-01-30 09:44:01 +00:00
try {
file . reveal ( ) ;
}
catch ( e ) {
// On platforms that don't support nsILocalFile.reveal() (e.g. Linux),
2012-01-20 20:23:06 +00:00
// launch the parent directory
var parent = file . parent . QueryInterface ( Components . interfaces . nsILocalFile ) ;
2013-04-11 08:28:38 +00:00
Zotero . launchFile ( parent ) ;
2011-01-30 09:44:01 +00:00
}
2013-08-02 04:45:26 +00:00
Zotero . Notifier . trigger ( 'open' , 'file' , attachment . id ) ;
2011-01-30 09:44:01 +00:00
}
else {
this . showAttachmentNotFoundDialog ( attachment . id , noLocateOnMissing )
}
}
}
/ * *
2012-10-31 09:22:58 +00:00
* Test if the user can edit the currently selected view
2011-01-30 09:44:01 +00:00
*
* @ param { Integer } [ row ]
*
* @ return { Boolean } TRUE if user can edit , FALSE if not
* /
this . canEdit = function ( row ) {
// Currently selected row
if ( row === undefined ) {
row = this . collectionsView . selection . currentIndex ;
}
var itemGroup = this . collectionsView . _getItemAtRow ( row ) ;
return itemGroup . editable ;
}
/ * *
2012-10-31 09:22:58 +00:00
* Test if the user can edit the parent library of the selected view
*
* @ param { Integer } [ row ]
* @ return { Boolean } TRUE if user can edit , FALSE if not
* /
this . canEditLibrary = function ( row ) {
// Currently selected row
if ( row === undefined ) {
row = this . collectionsView . selection . currentIndex ;
}
var itemGroup = this . collectionsView . _getItemAtRow ( row ) ;
// TODO: isEditable for user library should just return true
if ( itemGroup . ref . libraryID ) {
return Zotero . Libraries . isEditable ( itemGroup . ref . libraryID ) ;
}
return true ;
}
/ * *
* Test if the user can edit the currently selected library / collection
2011-01-30 09:44:01 +00:00
*
* @ param { Integer } [ row ]
*
* @ return { Boolean } TRUE if user can edit , FALSE if not
* /
this . canEditFiles = function ( row ) {
// Currently selected row
if ( row === undefined ) {
row = this . collectionsView . selection . currentIndex ;
}
var itemGroup = this . collectionsView . _getItemAtRow ( row ) ;
return itemGroup . filesEditable ;
}
this . displayCannotEditLibraryMessage = function ( ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
2012-01-20 22:51:00 +00:00
ps . alert ( null , "" , Zotero . getString ( 'save.error.cannotMakeChangesToCollection' ) ) ;
2011-01-30 09:44:01 +00:00
}
this . displayCannotEditLibraryFilesMessage = function ( ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
2012-01-20 22:51:00 +00:00
ps . alert ( null , "" , Zotero . getString ( 'save.error.cannotAddFilesToCollection' ) ) ;
2011-01-30 09:44:01 +00:00
}
function showAttachmentNotFoundDialog ( itemID , noLocate ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ] .
createInstance ( Components . interfaces . nsIPromptService ) ;
// 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 ;
}
var buttonFlags = ( ps . BUTTON _POS _0 ) * ( ps . BUTTON _TITLE _IS _STRING )
+ ( ps . BUTTON _POS _1 ) * ( ps . BUTTON _TITLE _CANCEL ) ;
var index = ps . confirmEx ( null ,
Zotero . getString ( 'pane.item.attachments.fileNotFound.title' ) ,
Zotero . getString ( 'pane.item.attachments.fileNotFound.text' ) ,
buttonFlags , Zotero . getString ( 'general.locate' ) , null ,
null , null , { } ) ;
if ( index == 0 ) {
this . relinkAttachment ( itemID ) ;
}
}
2012-12-11 20:16:40 +00:00
this . syncAlert = function ( e ) {
e = Zotero . Sync . Runner . parseSyncError ( e ) ;
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var buttonFlags = ps . BUTTON _POS _0 * ps . BUTTON _TITLE _OK
+ ps . BUTTON _POS _1 * ps . BUTTON _TITLE _IS _STRING ;
// Warning
2013-03-13 01:10:11 +00:00
if ( e . errorMode == 'warning' ) {
2012-12-11 20:16:40 +00:00
var title = Zotero . getString ( 'general.warning' ) ;
// If secondary button not specified, just use an alert
if ( e . buttonText ) {
var buttonText = e . buttonText ;
}
else {
ps . alert ( null , title , e . message ) ;
return ;
}
var index = ps . confirmEx (
null ,
title ,
e . message ,
buttonFlags ,
"" ,
buttonText ,
"" , null , { }
) ;
if ( index == 1 ) {
setTimeout ( function ( ) { buttonCallback ( ) ; } , 1 ) ;
}
}
// Error
2013-03-13 01:10:11 +00:00
else if ( e . errorMode == 'error' ) {
2012-12-11 20:16:40 +00:00
var title = Zotero . getString ( 'general.error' ) ;
// If secondary button is explicitly null, just use an alert
if ( buttonText === null ) {
ps . alert ( null , title , e . message ) ;
return ;
}
if ( typeof buttonText == 'undefined' ) {
var buttonText = Zotero . getString ( 'errorReport.reportError' ) ;
var buttonCallback = function ( ) {
ZoteroPane . reportErrors ( ) ;
} ;
}
else {
var buttonText = e . buttonText ;
var buttonCallback = e . buttonCallback ;
}
var index = ps . confirmEx (
null ,
title ,
e . message ,
buttonFlags ,
"" ,
buttonText ,
"" , null , { }
) ;
if ( index == 1 ) {
setTimeout ( function ( ) { buttonCallback ( ) ; } , 1 ) ;
}
}
// Upgrade
2013-03-13 01:10:11 +00:00
else if ( e . errorMode == 'upgrade' ) {
2012-12-11 20:16:40 +00:00
ps . alert ( null , "" , e . message ) ;
}
} ;
2011-01-30 09:44:01 +00:00
this . createParentItemsFromSelected = function ( ) {
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var items = this . getSelectedItems ( ) ;
for ( var i = 0 ; i < items . length ; i ++ ) {
var item = items [ i ] ;
if ( ! item . isTopLevelItem ( ) || item . isRegularItem ( ) ) {
2011-03-08 23:46:01 +00:00
throw ( 'Item ' + itemID + ' is not a top-level attachment or note in ZoteroPane_Local.createParentItemsFromSelected()' ) ;
2011-01-30 09:44:01 +00:00
}
Zotero . DB . beginTransaction ( ) ;
// TODO: remove once there are no top-level web attachments
if ( item . isWebAttachment ( ) ) {
var parent = new Zotero . Item ( 'webpage' ) ;
}
else {
var parent = new Zotero . Item ( 'document' ) ;
}
parent . libraryID = item . libraryID ;
parent . setField ( 'title' , item . getField ( 'title' ) ) ;
if ( item . isWebAttachment ( ) ) {
parent . setField ( 'accessDate' , item . getField ( 'accessDate' ) ) ;
parent . setField ( 'url' , item . getField ( 'url' ) ) ;
}
var itemID = parent . save ( ) ;
item . setSource ( itemID ) ;
item . save ( ) ;
Zotero . DB . commitTransaction ( ) ;
}
}
this . renameSelectedAttachmentsFromParents = function ( ) {
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var items = this . getSelectedItems ( ) ;
for ( var i = 0 ; i < items . length ; i ++ ) {
var item = items [ i ] ;
if ( ! item . isAttachment ( ) || ! item . getSource ( ) || item . attachmentLinkMode == Zotero . Attachments . LINK _MODE _LINKED _URL ) {
2011-03-08 23:46:01 +00:00
throw ( 'Item ' + itemID + ' is not a child file attachment in ZoteroPane_Local.renameAttachmentFromParent()' ) ;
2011-01-30 09:44:01 +00:00
}
var file = item . getFile ( ) ;
if ( ! file ) {
continue ;
}
var parentItemID = item . getSource ( ) ;
var newName = Zotero . Attachments . getFileBaseNameFromItem ( parentItemID ) ;
2012-04-04 08:44:04 +00:00
var ext = file . leafName . match ( /\.[^\.]+$/ ) ;
2011-01-30 09:44:01 +00:00
if ( ext ) {
2012-04-04 08:44:04 +00:00
newName = newName + ext ;
2011-01-30 09:44:01 +00:00
}
var renamed = item . renameAttachmentFile ( newName ) ;
if ( renamed !== true ) {
Zotero . debug ( "Could not rename file (" + renamed + ")" ) ;
continue ;
}
item . setField ( 'title' , newName ) ;
item . save ( ) ;
}
return true ;
}
function relinkAttachment ( itemID ) {
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var item = Zotero . Items . get ( itemID ) ;
if ( ! item ) {
2011-03-08 23:46:01 +00:00
throw ( 'Item ' + itemID + ' not found in ZoteroPane_Local.relinkAttachment()' ) ;
2011-01-30 09:44:01 +00:00
}
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 ) ;
}
}
function reportErrors ( ) {
var ww = Components . classes [ "@mozilla.org/embedcomp/window-watcher;1" ]
. getService ( Components . interfaces . nsIWindowWatcher ) ;
var data = {
2014-05-27 00:07:41 +00:00
msg : Zotero . getString ( 'errorReport.followingReportWillBeSubmitted' ) ,
errorData : Zotero . getErrors ( true ) ,
2011-01-30 09:44:01 +00:00
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' ) ) ;
2011-08-10 07:07:26 +00:00
var msg = Zotero . getString ( 'general.restartFirefox' , Zotero . appName ) + ' '
2011-01-30 09:44:01 +00:00
+ reportInstructions ;
pw . addDescription ( msg ) ;
pw . show ( ) ;
pw . startCloseTimer ( 8000 ) ;
}
// Display as items pane message
else {
var msg = Zotero . getString ( 'general.errorHasOccurred' ) + ' '
2011-08-10 07:07:26 +00:00
+ Zotero . getString ( 'general.restartFirefox' , Zotero . appName ) + '\n\n'
2011-01-30 09:44:01 +00:00
+ reportInstructions ;
self . setItemsPaneMessage ( msg , true ) ;
}
Zotero . debug ( msg , 1 ) ;
}
2011-02-10 01:53:15 +00:00
this . displayStartupError = function ( asPaneMessage ) {
if ( ! 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');
//if(asPaneMessage) {
2011-03-08 23:46:01 +00:00
// ZoteroPane_Local.setItemsPaneMessage(errMsg, true);
2011-02-10 01:53:15 +00:00
//} else {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
ps . alert ( null , "" , errMsg ) ;
//}
}
}
}
2011-01-30 09:44:01 +00:00
/ * *
* Toggles Zotero - as - a - tab by passing off the request to the ZoteroOverlay object associated
* with the present window
* /
this . toggleTab = function ( ) {
var wm = Components . classes [ "@mozilla.org/appshell/window-mediator;1" ]
. getService ( Components . interfaces . nsIWindowMediator ) ;
var browserWindow = wm . getMostRecentWindow ( "navigator:browser" ) ;
if ( browserWindow . ZoteroOverlay ) browserWindow . ZoteroOverlay . toggleTab ( ) ;
}
/ * *
* Shows the Zotero pane , making it visible if it is not and switching to the appropriate tab
* if necessary .
* /
this . show = function ( ) {
2011-02-03 07:04:14 +00:00
if ( window . ZoteroOverlay ) {
2011-01-30 09:44:01 +00:00
if ( ZoteroOverlay . isTab ) {
ZoteroOverlay . loadZoteroTab ( ) ;
} else if ( ! this . isShowing ( ) ) {
ZoteroOverlay . toggleDisplay ( ) ;
}
}
}
2011-02-11 22:16:32 +00:00
/ * *
* Unserializes zotero - persist elements from preferences
* /
2011-02-22 18:43:05 +00:00
this . unserializePersist = function ( ) {
2011-09-06 01:26:13 +00:00
_unserialized = true ;
2011-02-11 22:16:32 +00:00
var serializedValues = Zotero . Prefs . get ( "pane.persist" ) ;
if ( ! serializedValues ) return ;
serializedValues = JSON . parse ( serializedValues ) ;
for ( var id in serializedValues ) {
var el = document . getElementById ( id ) ;
if ( ! el ) return ;
var elValues = serializedValues [ id ] ;
for ( var attr in elValues ) {
el . setAttribute ( attr , elValues [ attr ] ) ;
}
}
2011-02-11 22:39:13 +00:00
if ( this . itemsView ) {
// may not yet be initialized
try {
this . itemsView . sort ( ) ;
} catch ( e ) { } ;
}
2011-02-11 22:16:32 +00:00
}
/ * *
* Serializes zotero - persist elements to preferences
* /
2011-02-22 18:43:05 +00:00
this . serializePersist = function ( ) {
2011-09-06 01:26:13 +00:00
if ( ! _unserialized ) return ;
2011-02-11 22:16:32 +00:00
var serializedValues = { } ;
for each ( var el in document . getElementsByAttribute ( "zotero-persist" , "*" ) ) {
if ( ! el . getAttribute ) continue ;
var id = el . getAttribute ( "id" ) ;
if ( ! id ) continue ;
var elValues = { } ;
for each ( var attr in el . getAttribute ( "zotero-persist" ) . split ( /[\s,]+/ ) ) {
var attrValue = el . getAttribute ( attr ) ;
elValues [ attr ] = attrValue ;
}
serializedValues [ id ] = elValues ;
}
Zotero . Prefs . set ( "pane.persist" , JSON . stringify ( serializedValues ) ) ;
}
2011-02-13 03:51:24 +00:00
/ * *
* Moves around the toolbar when the user moves around the pane
* /
this . updateToolbarPosition = function ( ) {
2011-06-01 09:10:33 +00:00
if ( document . getElementById ( "zotero-pane-stack" ) . hidden ) return ;
2015-01-04 11:47:41 +00:00
var collectionsPane = document . getElementById ( "zotero-collections-pane" ) ;
var collectionsToolbar = document . getElementById ( "zotero-collections-toolbar" ) ;
var collectionsSplitter = document . getElementById ( "zotero-collections-splitter" ) ;
var itemsPane = document . getElementById ( "zotero-items-pane" ) ;
var itemsToolbar = document . getElementById ( "zotero-items-toolbar" ) ;
var itemsSplitter = document . getElementById ( "zotero-items-splitter" ) ;
var itemPane = document . getElementById ( "zotero-item-pane" ) ;
var itemToolbar = document . getElementById ( "zotero-item-toolbar" ) ;
var collectionsPaneComputedStyle = window . getComputedStyle ( collectionsPane , null ) ;
var collectionsSplitterComputedStyle = window . getComputedStyle ( collectionsSplitter , null ) ;
var itemsPaneComputedStyle = window . getComputedStyle ( itemsPane , null ) ;
var itemsSplitterComputedStyle = window . getComputedStyle ( itemsSplitter , null ) ;
var itemPaneComputedStyle = window . getComputedStyle ( itemPane , null ) ;
var collectionsPaneWidth = collectionsPaneComputedStyle . getPropertyValue ( "width" ) ;
var collectionsSplitterWidth = collectionsSplitterComputedStyle . getPropertyValue ( "width" ) ;
var itemsPaneWidth = itemsPaneComputedStyle . getPropertyValue ( "width" ) ;
var itemsSplitterWidth = itemsSplitterComputedStyle . getPropertyValue ( "width" ) ;
var itemPaneWidth = itemPaneComputedStyle . getPropertyValue ( "width" ) ;
collectionsToolbar . style . width = collectionsPaneWidth ;
collectionsToolbar . style . marginRight = collectionsSplitterWidth ;
itemsToolbar . style . marginRight = itemsSplitterWidth ;
var itemsToolbarWidthNumber = parseInt ( itemsPaneWidth , 10 ) ;
if ( collectionsPane . collapsed ) {
var collectionsToolbarComputedStyle = window . getComputedStyle ( collectionsToolbar , null ) ;
var collectionsToolbarWidth = collectionsToolbarComputedStyle . getPropertyValue ( "width" ) ; // real width (nonzero) after the new definition
itemsToolbarWidthNumber = itemsToolbarWidthNumber - parseInt ( collectionsToolbarWidth , 10 ) ;
2011-02-13 03:51:24 +00:00
}
2015-01-04 11:47:41 +00:00
if ( itemPane . collapsed ) {
// Then the itemsToolbar and itemToolbar share the same space, and it seems best to use some flex attribute from right (because there might be other icons appearing or vanishing).
itemsToolbar . style . removeProperty ( 'width' ) ;
itemsToolbar . setAttribute ( "flex" , "1" ) ;
itemToolbar . setAttribute ( "flex" , "0" ) ;
} else {
itemsToolbar . style . width = itemsToolbarWidthNumber + "px" ;
itemsToolbar . setAttribute ( "flex" , "0" ) ;
itemToolbar . setAttribute ( "flex" , "1" ) ;
}
2011-02-13 03:51:24 +00:00
}
2011-05-31 06:34:21 +00:00
/ * *
* Opens the about dialog
* /
this . openAboutDialog = function ( ) {
window . openDialog ( 'chrome://zotero/content/about.xul' , 'about' , 'chrome' ) ;
}
2011-06-14 00:36:21 +00:00
/ * *
* Adds or removes a function to be called when Zotero is reloaded by switching into or out of
* the connector
* /
this . addReloadListener = function ( /** @param {Function} **/ func ) {
if ( _reloadFunctions . indexOf ( func ) === - 1 ) _reloadFunctions . push ( func ) ;
}
2013-11-05 20:52:40 +00:00
/ * *
* Adds or removes a function to be called just before Zotero is reloaded by switching into or
* out of the connector
* /
this . addBeforeReloadListener = function ( /** @param {Function} **/ func ) {
if ( _beforeReloadFunctions . indexOf ( func ) === - 1 ) _beforeReloadFunctions . push ( func ) ;
}
2011-06-14 00:36:21 +00:00
/ * *
2011-07-03 04:33:37 +00:00
* Implements nsIObserver for Zotero reload
2011-06-14 00:36:21 +00:00
* /
2011-07-03 04:33:37 +00:00
var _reloadObserver = {
/ * *
* Called when Zotero is reloaded ( i . e . , if it is switched into or out of connector mode )
* /
2013-11-05 20:52:40 +00:00
"observe" : function ( aSubject , aTopic , aData ) {
if ( aTopic == "zotero-reloaded" ) {
Zotero . debug ( "Reloading Zotero pane" ) ;
for each ( var func in _reloadFunctions ) func ( aData ) ;
} else if ( aTopic == "zotero-before-reload" ) {
Zotero . debug ( "Zotero pane caught before-reload event" ) ;
for each ( var func in _beforeReloadFunctions ) func ( aData ) ;
}
2011-07-03 04:33:37 +00:00
}
} ;
2011-03-08 23:46:01 +00:00
}
/ * *
* Keep track of which ZoteroPane was local ( since ZoteroPane object might get swapped out for a
* tab ' s ZoteroPane )
* /
2011-06-16 18:17:06 +00:00
var ZoteroPane _Local = ZoteroPane ;