/* * This object contains the various functions for the interface */ var ScholarPane = new function() { var collectionsView; var itemsView; var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); //Privileged methods this.onLoad = onLoad; this.onUnload = onUnload; this.toggleDisplay = toggleDisplay; this.newItem = newItem; this.newCollection = newCollection; this.onCollectionSelected = onCollectionSelected; this.itemSelected = itemSelected; this.deleteItemSelection = deleteItemSelection; this.deleteCollectionSelection = deleteCollectionSelection; this.renameSelectedCollection = renameSelectedCollection; this.search = search; /* * Called when the window is open */ function onLoad() { //Initialize collections view collectionsView = new Scholar.CollectionTreeView(); document.getElementById('collections-tree').view = collectionsView; //select Library collectionsView.selection.select(0); //Create the add menu with each item type var addMenu = document.getElementById('tb-add').firstChild; var itemTypes = Scholar.ItemTypes.getTypes(); for(var i = 0; i 0 && confirm(Scholar.getString('pane.items.delete'))) itemsView.deleteSelection(); } function deleteCollectionSelection() { if(collectionsView.selection.count > 0 && confirm(Scholar.getString('pane.collections.delete'))) collectionsView.deleteSelection(); } function renameSelectedCollection() { if(collectionsView.selection.count > 0) { collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex); var newName = prompt(Scholar.getString('pane.collections.rename'),collection.getName()); if(newName) collection.ref.rename(newName); } } function search() { if(itemsView) itemsView.searchText(document.getElementById('tb-search').value); } } var ScholarItemsDragObserver = { onDragStart: function (evt,transferData,action) { transferData.data=new TransferData(); transferData.data.addDataForFlavour("text/unicode","random data"); } }; var ScholarCollectionsDragObserver = { getSupportedFlavours : function () { var flavours = new FlavourSet(); flavours.appendFlavour("text/unicode"); return flavours; }, onDragOver: function (evt,dropdata,session){}, onDrop: function (evt,dropdata,session) { alert(dropdata.data); } } window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false); window.addEventListener("unload", function(e) { ScholarPane.onUnload(e); }, false);