From ecfff1393f1937bc04da83984fba6ef6745b5f92 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Mon, 11 Sep 2006 01:05:26 +0000 Subject: [PATCH] - closes #225, ability to cite a specific page/paragraph/etc in Word integration. the output isn't quite right at the moment, but the interface works. - removes net icons that haven't been used in months - fixes another date bug (the last one, i hope) - renames CSL class to Scholar.CSL --- .../content/scholar/addCitationDialog.js | 143 +++++++++++++ .../content/scholar/addCitationDialog.xul | 124 +++++++++++ .../content/scholar/selectItemsDialog.js | 20 +- .../chromeFiles/content/scholar/xpcom/cite.js | 197 ++++++++++-------- .../content/scholar/xpcom/integration.js | 92 +++++--- .../content/scholar/xpcom/scholar.js | 21 +- .../locale/en-US/scholar/locales.xml | 8 + .../locale/en-US/scholar/scholar.dtd | 6 +- .../locale/en-US/scholar/scholar.properties | 5 +- .../default/scholar/addCitationDialog.css | 17 ++ .../skin/default/scholar/capture_colored.png | Bin 668 -> 0 bytes .../skin/default/scholar/capture_gray.png | Bin 669 -> 0 bytes .../default/scholar/citation-add-gray.png | Bin 0 -> 437 bytes .../skin/default/scholar/citation-add.png | Bin 0 -> 349 bytes .../default/scholar/citation-delete-gray.png | Bin 0 -> 429 bytes .../skin/default/scholar/citation-delete.png | Bin 0 -> 345 bytes 16 files changed, 508 insertions(+), 125 deletions(-) create mode 100644 chrome/chromeFiles/content/scholar/addCitationDialog.js create mode 100644 chrome/chromeFiles/content/scholar/addCitationDialog.xul create mode 100644 chrome/chromeFiles/skin/default/scholar/addCitationDialog.css delete mode 100644 chrome/chromeFiles/skin/default/scholar/capture_colored.png delete mode 100644 chrome/chromeFiles/skin/default/scholar/capture_gray.png create mode 100644 chrome/chromeFiles/skin/default/scholar/citation-add-gray.png create mode 100644 chrome/chromeFiles/skin/default/scholar/citation-add.png create mode 100644 chrome/chromeFiles/skin/default/scholar/citation-delete-gray.png create mode 100644 chrome/chromeFiles/skin/default/scholar/citation-delete.png diff --git a/chrome/chromeFiles/content/scholar/addCitationDialog.js b/chrome/chromeFiles/content/scholar/addCitationDialog.js new file mode 100644 index 000000000..48f26204e --- /dev/null +++ b/chrome/chromeFiles/content/scholar/addCitationDialog.js @@ -0,0 +1,143 @@ +/* + Zotero + Copyright (C) 2006 Center for History and New Media, George Mason University, Fairfax, VA + http://chnm.gmu.edu/ +*/ + +var Scholar_Citation_Dialog = new function () { + var _itemLocators = new Object(); + var _itemLocatorTypes = new Object(); + var _multipleSourcesOn = false; + var _lastSelected = null; + + this.load = load; + this.toggleMultipleSources = toggleMultipleSources; + this.treeItemSelected = treeItemSelected; + this.listItemSelected = listItemSelected; + this.addCitation = addCitation; + this.deleteCitation = deleteCitation; + this.accept = accept; + + function load() { + document.getElementById("multiple-sources-button").label = Scholar.getString("citation.multipleSources"); + + // load (from selectItemsDialog.js) + doLoad(); + } + + function toggleMultipleSources() { + if(_multipleSourcesOn) { + document.getElementById("multiple-sources").hidden = true; + document.getElementById("add-citation-dialog").width = "600"; + document.getElementById("multiple-sources-button").label = Scholar.getString("citation.multipleSources"); + window.sizeToContent(); + window.moveTo((window.screenX+75), window.screenY); + } else { + document.getElementById("multiple-sources").hidden = undefined; + document.getElementById("add-citation-dialog").width = "750"; + document.getElementById("multiple-sources-button").label = Scholar.getString("citation.singleSource"); + window.sizeToContent(); + window.moveTo((window.screenX-75), window.screenY); + } + + _multipleSourcesOn = !_multipleSourcesOn; + } + + function treeItemSelected() { + if(_multipleSourcesOn) { + // get selected item (from selectItemsDialog.js) + var item = getSelectedItems(true); + + // if item has already been added, disable add button + document.getElementById("citation-add").disabled = (!item.length || _itemLocators[item[0]] != undefined ? true : false); + } + } + + function listItemSelected() { + var pagesBox = document.getElementById("item-locator"); + var locatorTypeBox = document.getElementById("item-locator-type"); + if(_lastSelected) { + _itemLocators[_lastSelected.value] = pagesBox.value; + _itemLocatorTypes[_lastSelected.value] = locatorTypeBox.selectedIndex; + } + + var selectedListItem = document.getElementById("citation-list").getSelectedItem(0); + + if(selectedListItem) { + document.getElementById("citation-delete").disabled = pagesBox.disabled = locatorTypeBox.disabled = false; + pagesBox.value = _itemLocators[selectedListItem.value]; + locatorTypeBox.selectedIndex = _itemLocatorTypes[selectedListItem.value]; + } else { + document.getElementById("citation-delete").disabled = pagesBox.disabled = locatorTypeBox.disabled = true; + pagesBox.value = ""; + locatorTypeBox.selectedIndex = -1; + } + + _lastSelected = selectedListItem; + } + + function addCitation() { + // get selected item (from selectItemsDialog.js) + var item = getSelectedItems(); + item = item[0]; + var itemID = item.getID(); + + // add to list + var itemNode = document.createElement("listitem"); + itemNode.setAttribute("value", itemID); + itemNode.setAttribute("label", item.getField("title")); + itemNode.setAttribute("class", "listitem-iconic"); + itemNode.setAttribute("image", "chrome://scholar/skin/treeitem-"+Scholar.ItemTypes.getName(item.getType())+".png"); + document.getElementById("citation-list").appendChild(itemNode); + + // don't let someone select it again + document.getElementById("citation-add").disabled = true; + + // flag + _itemLocators[itemID] = document.getElementById("tree-locator").value; + _itemLocatorTypes[itemID] = document.getElementById("tree-locator-type").selectedIndex; + document.getElementById("tree-locator").value = ""; + } + + function deleteCitation() { + var citationList = document.getElementById("citation-list"); + var selectedListItem = citationList.getSelectedItem(0); + + // remove from _itemLocators + _itemLocators[selectedListItem.value] = _itemLocatorType[selectedListItem.value] = undefined; + + // remove from list + citationList.removeChild(selectedListItem); + } + + function accept() { + var io = window.arguments[0]; + if(_multipleSourcesOn) { + treeItemSelected(); // store locator info + + var citationList = document.getElementById("citation-list"); + var listLength = citationList.childNodes.length; + + if(listLength) { + io.items = new Array(); + io.locatorTypes = new Array(); + io.locators = new Array(); + + for(var i=0; i + + + + + + + + + +