?? downloadactions.js
字號:
return ""; }, getImageSrc: function (aIndex, aColumn) { if (aColumn.id == "fileExtension") return this.getItemAtIndex(aIndex).smallIcon; return ""; }, _selection: null, get selection () { return this._selection; }, set selection (val) { this._selection = val; return val; }, getRowProperties: function (aIndex, aProperties) {}, getCellProperties: function (aIndex, aColumn, aProperties) {}, getColumnProperties: function (aColumn, aProperties) {}, isContainer: function (aIndex) { return false; }, isContainerOpen: function (aIndex) { return false; }, isContainerEmpty: function (aIndex) { return false; }, isSeparator: function (aIndex) { return false; }, isSorted: function (aIndex) { return false; }, canDrop: function (aIndex, aOrientation) { return false; }, drop: function (aIndex, aOrientation) {}, getParentIndex: function (aIndex) { return -1; }, hasNextSibling: function (aParentIndex, aIndex) { return false; }, getLevel: function (aIndex) { return 0; }, getProgressMode: function (aIndex, aColumn) {}, getCellValue: function (aIndex, aColumn) {}, setTree: function (aTree) {}, toggleOpenState: function (aIndex) { }, cycleHeader: function (aColumn) {}, selectionChanged: function () {}, cycleCell: function (aIndex, aColumn) {}, isEditable: function (aIndex, aColumn) { return false; }, setCellValue: function (aIndex, aColumn, aValue) {}, setCellText: function (aIndex, aColumn, aValue) {}, performAction: function (aAction) {}, performActionOnRow: function (aAction, aIndex) {}, performActionOnCell: function (aAction, aindex, aColumn) {} }, removeFileHandler: function () { var selection = this._tree.view.selection; if (selection.count < 1) return; var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0; flags += promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1; var title = this._bundle.getString("removeTitle" + (selection.count > 1 ? "Multiple" : "Single")); var message = this._bundle.getString("removeMessage" + (selection.count > 1 ? "Multiple" : "Single")); var button = this._bundle.getString("removeButton" + (selection.count > 1 ? "Multiple" : "Single")); rv = promptService.confirmEx(window, title, message, flags, button, null, null, null, { value: 0 }); if (rv != 0) return; var rangeCount = selection.getRangeCount(); var lastSelected = 0; var mimeDSDirty = false; for (var i = 0; i < rangeCount; ++i) { var min = { }; var max = { }; selection.getRangeAt(i, min, max); for (var j = min.value; j <= max.value; ++j) { var item = this._view.getItemAtIndex(j); if (!item.handledOnlyByPlugin) { // There is data for this type in the MIME registry, so make sure we // remove it from the MIME registry. We don't disable the plugin here because // if we do there's currently no way through the UI to re-enable it. We may // come up with some sort of solution for that at a later date. var typeRes = this._rdf.GetResource(MIME_URI(item.type)); var handlerRes = this._getChildResource(typeRes, "handlerProp"); var extAppRes = this._getChildResource(handlerRes, "externalApplication"); this._cleanResource(extAppRes); this._cleanResource(handlerRes); this._cleanResource(typeRes); mimeDSDirty = true; } lastSelected = (j + 1) >= this._view.rowCount ? j-1 : j; } } if (mimeDSDirty && this._mimeDS instanceof Components.interfaces.nsIRDFRemoteDataSource) this._mimeDS.Flush(); // Just reload the list to make sure deletions are respected this._loadView(); this._updateRowCount(this._updateExclusions()); selection.select(lastSelected); }, _cleanResource: function (aResource) { var labels = this._mimeDS.ArcLabelsOut(aResource); while (labels.hasMoreElements()) { var arc = labels.getNext(); if (!(arc instanceof Components.interfaces.nsIRDFResource)) break; var target = this._mimeDS.GetTarget(aResource, arc, true); this._mimeDS.Unassert(aResource, arc, target); } }, _disablePluginForItem: function (aItem) { }, _enablePluginForItem: function (aItem) { }, _ensureMIMERegistryEntry: function (aItem) { var root = this._rdf.GetResource("urn:mimetypes:root"); var container = Components.classes["@mozilla.org/rdf/container;1"] .createInstance(Components.interfaces.nsIRDFContainer); container.Init(this._mimeDS, root); var itemResource = this._rdf.GetResource(MIME_URI(aItem.type)); var handlerResource = null; if (container.IndexOf(itemResource) == -1) { container.AppendElement(itemResource); this._setLiteralValue(itemResource, "editable", "true"); this._setLiteralValue(itemResource, "value", aItem.type); handlerResource = this._rdf.GetResource(HANDLER_URI(aItem.type)); this._setLiteralValue(handlerResource, "alwaysAsk", "false"); var handlerProp = this._rdf.GetResource(NC_URI("handlerProp")); this._mimeDS.Assert(itemResource, handlerProp, handlerResource, true); var extAppResource = this._rdf.GetResource(APP_URI(aItem.type)); this._setLiteralValue(extAppResource, "path", ""); var extAppProp = this._rdf.GetResource(NC_URI("externalApplication")); this._mimeDS.Assert(handlerResource, extAppProp, extAppResource, true); } else handlerResource = this._getChildResource(itemResource, "handlerProp"); return handlerResource; }, _setLiteralValue: function (aResource, aProperty, aValue) { var property = this._rdf.GetResource(NC_URI(aProperty)); var newValue = this._rdf.GetLiteral(aValue); var oldValue = this._mimeDS.GetTarget(aResource, property, true); if (oldValue) this._mimeDS.Change(aResource, property, oldValue, newValue); else this._mimeDS.Assert(aResource, property, newValue, true); }, editFileHandler: function () { var selection = this._tree.view.selection; if (selection.count != 1) return; var item = this._view.getItemAtIndex(selection.currentIndex); openDialog("chrome://messenger/content/preferences/changeaction.xul", "_blank", "modal,centerscreen", item); // Update the database switch (item.handleMode) { case FILEACTION_OPEN_PLUGIN: this._enablePluginForItem(item); // We don't need to adjust the database because plugin settings always // supercede whatever is in the db, leaving it untouched allows the last // user setting(s) to be preserved if they ever revert. break; case FILEACTION_OPEN_DEFAULT: this._disablePluginForItem(item); var handlerRes = this._ensureMIMERegistryEntry(item); this._setLiteralValue(handlerRes, "useSystemDefault", "true"); this._setLiteralValue(handlerRes, "saveToDisk", "false"); break; case FILEACTION_OPEN_CUSTOM: this._disablePluginForItem(item); var handlerRes = this._ensureMIMERegistryEntry(item); this._setLiteralValue(handlerRes, "useSystemDefault", "false"); this._setLiteralValue(handlerRes, "saveToDisk", "false"); var extAppRes = this._getChildResource(handlerRes, "externalApplication"); this._setLiteralValue(extAppRes, "path", item.customHandler.path); break; case FILEACTION_SAVE_TO_DISK: this._disablePluginForItem(item); var handlerRes = this._ensureMIMERegistryEntry(item); this._setLiteralValue(handlerRes, "useSystemDefault", "false"); this._setLiteralValue(handlerRes, "saveToDisk", "true"); break; } if (this._mimeDS instanceof Components.interfaces.nsIRDFRemoteDataSource) this._mimeDS.Flush(); // Update the view this._tree.treeBoxObject.invalidateRow(selection.currentIndex); }, onSelectionChanged: function () { if (this._tree.view.rowCount == 0) return; var selection = this._tree.view.selection; var selected = selection.count; this._removeButton.disabled = selected == 0; this._editButton.disabled = selected != 1; var stringKey = selected > 1 ? "removeButtonMultiple" : "removeButtonSingle"; this._removeButton.label = this._bundle.getString(stringKey); var canRemove = true; var canEdit = true; var rangeCount = selection.getRangeCount(); var min = { }, max = { }; var setLastSelected = false; for (var i = 0; i < rangeCount; ++i) { selection.getRangeAt(i, min, max); for (var j = min.value; j <= max.value; ++j) { if (!setLastSelected) { // Set the last selected index to the first item in the selection this._tree.setAttribute("lastSelected", j); setLastSelected = true; } var item = this._view.getItemAtIndex(j); if (item && (!item.editable || item.handleMode == FILEACTION_OPEN_INTERNALLY)) canEdit = false; if (item && (!item.editable || item.handleMode == FILEACTION_OPEN_INTERNALLY || item.handledOnlyByPlugin)) canRemove = false; } } if (!canRemove) this._removeButton.disabled = true; if (!canEdit) this._editButton.disabled = true; }, _lastSortProperty : "", _lastSortAscending: false, sort: function (aProperty) { var ascending = (aProperty == this._lastSortProperty) ? !this._lastSortAscending : true; function sortByProperty(a, b) { return a[aProperty].toLowerCase().localeCompare(b[aProperty].toLowerCase()); } function sortByExtension(a, b) { if (!a.hasExtension && b.hasExtension) return 1; if (!b.hasExtension && a.hasExtension) return -1; return a.extension.toLowerCase().localeCompare(b.extension.toLowerCase()); } // Sort the Filtered List, if in Filtered mode if (!this._view._filtered) { this._view.activeCollection.sort(aProperty == "extension" ? sortByExtension : sortByProperty); if (!ascending) this._view.activeCollection.reverse(); } this._view.selection.clearSelection(); this._view.selection.select(0); this._tree.treeBoxObject.invalidate(); this._tree.treeBoxObject.ensureRowIsVisible(0); this._lastSortAscending = ascending; this._lastSortProperty = aProperty; }, clearFilter: function () { // Clear the Filter and the Tree Display document.getElementById("filter").value = ""; this._view._filtered = false; this._view._filterSet = []; // Just reload the list to make sure deletions are respected this._loadView(); this._updateRowCount(this._updateExclusions()); // Restore selection this._view.selection.clearSelection(); for (i = 0; i < this._lastSelectedRanges.length; ++i) { var range = this._lastSelectedRanges[i]; this._view.selection.rangedSelect(range.min, range.max, true); } this._lastSelectedRanges = []; document.getElementById("actionsIntro").value = this._bundle.getString("actionsAll"); document.getElementById("clearFilter").disabled = true; }, _actionMatchesFilter: function (aAction) { return aAction.extension.toLowerCase().indexOf(this._view._filterValue) != -1 || aAction.typeName.toLowerCase().indexOf(this._view._filterValue) != -1 || aAction.type.toLowerCase().indexOf(this._view._filterValue) != -1 || aAction.action.toLowerCase().indexOf(this._view._filterValue) != -1; }, _filterActions: function (aFilterValue) { this._view._filterValue = aFilterValue; var actions = []; var collection = this._view._usingExclusionSet ? this._view._exclusionSet : this._actions; for (var i = 0; i < collection.length; ++i) { var action = collection[i]; if (this._actionMatchesFilter(action)) actions.push(action); } return actions; }, _lastSelectedRanges: [], _saveState: function () { // Save selection var seln = this._view.selection; this._lastSelectedRanges = []; var rangeCount = seln.getRangeCount(); for (var i = 0; i < rangeCount; ++i) { var min = {}; var max = {}; seln.getRangeAt(i, min, max); this._lastSelectedRanges.push({ min: min.value, max: max.value }); } }, _filterTimeout: -1, onFilterInput: function () { if (this._filterTimeout != -1) clearTimeout(this._filterTimeout); function filterActions() { var filter = document.getElementById("filter").value; if (filter == "") { gDownloadActionsWindow.clearFilter(); return; } var view = gDownloadActionsWindow._view; view._filterSet = gDownloadActionsWindow._filterActions(filter); if (!view._filtered) { // Save Display Info for the Non-Filtered mode when we first // enter Filtered mode. gDownloadActionsWindow._saveState(); view._filtered = true; } // Clear the display gDownloadActionsWindow._updateRowCount(view._filterSet.length); view.selection.select(0); document.getElementById("actionsIntro").value = gDownloadActionsWindow._bundle.getString("actionsFiltered"); document.getElementById("clearFilter").disabled = false; } window.filterActions = filterActions; this._filterTimeout = setTimeout("filterActions();", 500); }, onFilterKeyPress: function (aEvent) { if (aEvent.keyCode == 27) // ESC key this.clearFilter(); }, focusFilterBox: function () { var filter = document.getElementById("filter"); filter.focus(); filter.select(); } };
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -