Skip to content

Commit

Permalink
update backbone
Browse files Browse the repository at this point in the history
  • Loading branch information
Quicksaver committed Mar 12, 2016
1 parent e652082 commit f7105f5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 38 deletions.
6 changes: 3 additions & 3 deletions resource/modules/utils/PrefPanes.jsm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// VERSION 1.0.13
// VERSION 1.0.14
Modules.UTILS = true;

// PrefPanes - handles the preferences tab and all its contents for the add-on
Expand Down Expand Up @@ -78,8 +78,8 @@ this.PrefPanes = {
classID: Components.ID(addonUUID),
contractID: '@mozilla.org/network/protocol/about;1?what='+objPathString,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
newChannel: function(aURI) {
let chan = Services.io.newChannelFromURI(this.uri);
newChannel: function(aURI, aLoadInfo) {
let chan = Services.io.newChannelFromURIWithLoadInfo(this.uri, aLoadInfo);
chan.originalURI = aURI;
return chan;
},
Expand Down
14 changes: 2 additions & 12 deletions resource/modules/utils/about.jsm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// VERSION 1.2.1
// VERSION 1.2.2

this.about = {
kNS: 'http://www.w3.org/1999/xhtml',
Expand Down Expand Up @@ -373,17 +373,7 @@ this.about = {
},

openAddonsMgr: function() {
this._getChrome().BrowserOpenAddonsMgr();
},

_getChrome: function() {
return window
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
gWindow.BrowserOpenAddonsMgr();
}
};

Expand Down
58 changes: 35 additions & 23 deletions resource/modules/utils/preferencesUtils.jsm
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
// VERSION 2.4.14
// VERSION 2.4.16
Modules.UTILS = true;

XPCOMUtils.defineLazyGetter(this, "gWindow", function() {
// TODO: investigate when exactly I can use windowRoot
return window.windowRoot
? window.windowRoot.ownerGlobal
: window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
});

XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "TextEncoder", () => { return Cu.import("resource://gre/modules/osfile.jsm").TextEncoder; });
XPCOMUtils.defineLazyGetter(this, "TextDecoder", () => { return Cu.import("resource://gre/modules/osfile.jsm").TextDecoder; });

// dependsOn - object that adds a dependson attribute functionality to xul preference elements.
// Just add the attribute to the desired xul element and let the script do its thing. dependson accepts comma-separated or semicolon-separated strings in the following format:
// [!]element[:value] where:
Expand Down Expand Up @@ -580,7 +597,6 @@ this.helptext = {
kPanelWidth: 311, // roughly the maximum size of the panel node
kContentsWidth: 275, // the actual maximum size of the helptext contents

root: null,
panel: null,
contents: null,
main: null,
Expand Down Expand Up @@ -724,8 +740,8 @@ this.helptext = {
},

onLoad: function() {
this.panel = this.root.document.getElementById(objName+'-helptext');
this.contents = this.root.document.getElementById(objName+'-helptext-contents');
this.panel = gWindow.document.getElementById(objName+'-helptext');
this.contents = gWindow.document.getElementById(objName+'-helptext-contents');
this.main = $$('.main-content')[0];
this.prefPane = this.main.firstChild;

Expand Down Expand Up @@ -995,8 +1011,6 @@ this.controllers = {

export: function() {
this.showFilePicker(Ci.nsIFilePicker.modeSave, objPathString+'-prefs', function(aFile) {
let { TextEncoder, OS } = Cu.import("resource://gre/modules/osfile.jsm", {});

let list = { [objName]: AddonData.version };
for(let pref in prefList) {
list[pref] = Prefs[pref];
Expand All @@ -1013,8 +1027,6 @@ this.controllers = {

import: function() {
this.showFilePicker(Ci.nsIFilePicker.modeOpen, null, function(aFile) {
let { TextDecoder, OS } = Cu.import("resource://gre/modules/osfile.jsm", {});

OS.File.open(aFile.path, { read: true }).then(function(ref) {
ref.read().then(function(saved) {
ref.close();
Expand All @@ -1038,15 +1050,25 @@ this.controllers = {
});
},

showFilePicker: function(mode, prefix, aCallback) {
showFilePicker: function(mode, prefix, aCallback, path) {
let fileExt = '.json';
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.defaultExtension = 'json';
fp.appendFilter('JSON data', '*.json');

if(path) {
fp.displayDirectory = new FileUtils.File(path);
}

if(mode == Ci.nsIFilePicker.modeSave) {
let date = new Date();
let dateStr = date.getFullYear()+'-'+(date.getMonth() +1)+'-'+date.getDate()+'-'+date.getHours()+'-'+date.getMinutes()+'-'+date.getSeconds();
let y = date.getFullYear();
let m = (date.getMonth() +1); if(m < 10) { m = "0"+m; }
let d = date.getDate(); if(d < 10) { d = "0"+d; }
let h = date.getHours(); if(h < 10) { h = "0"+h; }
let mm = date.getMinutes(); if(mm < 10) { mm = "0"+mm; }
let s = date.getSeconds(); if(s < 10) { s = "0"+s; }
let dateStr = ""+y+m+d+"-"+h+mm+s;
fp.defaultString = prefix+'-'+dateStr+fileExt;
}

Expand Down Expand Up @@ -1199,7 +1221,7 @@ this.DnDproxy = {

Modules.LOADMODULE = function() {
alwaysRunOnClose.push(function() {
Overlays.removeOverlayWindow(helptext.root, 'utils/helptext');
Overlays.removeOverlayWindow(gWindow, 'utils/helptext');
});

callOnLoad(window, function() {
Expand All @@ -1210,17 +1232,7 @@ Modules.LOADMODULE = function() {
categories.init();
controllers.init();

// investigate when exactly I can use windowRoot
helptext.root = window.windowRoot
? window.windowRoot.ownerGlobal
: window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);

Overlays.overlayWindow(helptext.root, 'utils/helptext', helptext);
Overlays.overlayWindow(gWindow, 'utils/helptext', helptext);
});
};

Expand All @@ -1233,7 +1245,7 @@ Modules.UNLOADMODULE = function() {
controllers.uninit();
helptext.uninit();

Overlays.removeOverlayWindow(helptext.root, 'utils/helptext');
Overlays.removeOverlayWindow(gWindow, 'utils/helptext');

if(UNLOADED) {
window.close();
Expand Down

0 comments on commit f7105f5

Please sign in to comment.