mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-15 21:55:48 +01:00
Content pref code cleanup.
This commit is contained in:
@@ -68,6 +68,45 @@ var Buffer = Module("Buffer", {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a content preference for the given buffer.
|
||||||
|
*
|
||||||
|
* @param {string} pref The preference to get.
|
||||||
|
* @param {function(string|number|boolean)} callback The callback to
|
||||||
|
* call with the preference value. @optional
|
||||||
|
* @returns {string|number|boolean} The value of the preference, if
|
||||||
|
* callback is not provided.
|
||||||
|
*/
|
||||||
|
getPref: function getPref(pref, callback) {
|
||||||
|
// God damn it.
|
||||||
|
if (config.haveGecko("19.0a1"))
|
||||||
|
services.contentPrefs.getPref(this.uri, pref,
|
||||||
|
sanitizer.getContext(this.win), callback);
|
||||||
|
else
|
||||||
|
services.contentPrefs.getPref(uri, pref, callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a content preference for the given buffer.
|
||||||
|
*
|
||||||
|
* @param {string} pref The preference to set.
|
||||||
|
* @param {string} value The value to store.
|
||||||
|
*/
|
||||||
|
setPref: function setPref(pref, value) {
|
||||||
|
services.contentPrefs.setPref(
|
||||||
|
this.uri, pref, value, sanitizer.getContext(this.win));
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear a content preference for the given buffer.
|
||||||
|
*
|
||||||
|
* @param {string} pref The preference to clear.
|
||||||
|
*/
|
||||||
|
clearPref: function clearPref(pref) {
|
||||||
|
services.contentPrefs.removePref(
|
||||||
|
this.uri, pref, sanitizer.getContext(this.win));
|
||||||
|
},
|
||||||
|
|
||||||
climbUrlPath: function climbUrlPath(count) {
|
climbUrlPath: function climbUrlPath(count) {
|
||||||
let { dactyl } = this.modules;
|
let { dactyl } = this.modules;
|
||||||
|
|
||||||
@@ -1192,20 +1231,15 @@ var Buffer = Module("Buffer", {
|
|||||||
return dactyl.echoerr(_("zoom.illegal"));
|
return dactyl.echoerr(_("zoom.illegal"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (services.has("contentPrefs") && !storage.privateMode
|
if (prefs.get("browser.zoom.siteSpecific")) {
|
||||||
&& prefs.get("browser.zoom.siteSpecific")) {
|
|
||||||
var privacy = sanitizer.getContext(this.win);
|
var privacy = sanitizer.getContext(this.win);
|
||||||
if (value == 1) {
|
if (value == 1) {
|
||||||
services.contentPrefs.removePref(
|
this.clearPref("browser.content.full-zoom");
|
||||||
this.uri, "browser.content.full-zoom", privacy);
|
this.clearPref("dactyl.content.full-zoom");
|
||||||
services.contentPrefs.removePref(
|
|
||||||
this.uri, "dactyl.content.full-zoom", privacy);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
services.contentPrefs.setPref(
|
this.setPref("browser.content.full-zoom", value);
|
||||||
this.uri, "browser.content.full-zoom", value, privacy);
|
this.setPref("dactyl.content.full-zoom", fullZoom);
|
||||||
services.contentPrefs.setPref(
|
|
||||||
this.uri, "dactyl.content.full-zoom", fullZoom, privacy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1219,19 +1253,12 @@ var Buffer = Module("Buffer", {
|
|||||||
let self = this;
|
let self = this;
|
||||||
let uri = this.uri;
|
let uri = this.uri;
|
||||||
|
|
||||||
if (services.has("contentPrefs") && prefs.get("browser.zoom.siteSpecific")) {
|
if (prefs.get("browser.zoom.siteSpecific")) {
|
||||||
let callback = function (val) {
|
this.getPref("dactyl.content.full-zoom", function (val) {
|
||||||
if (val != null && uri.equals(self.uri) && val != prefs.get("browser.zoom.full"))
|
if (val != null && uri.equals(self.uri) && val != prefs.get("browser.zoom.full"))
|
||||||
[self.contentViewer.textZoom, self.contentViewer.fullZoom] =
|
[self.contentViewer.textZoom, self.contentViewer.fullZoom] =
|
||||||
[self.contentViewer.fullZoom, self.contentViewer.textZoom];
|
[self.contentViewer.fullZoom, self.contentViewer.textZoom];
|
||||||
}
|
});
|
||||||
// God damn it.
|
|
||||||
if (config.haveGecko("19.0a1"))
|
|
||||||
services.contentPrefs.getPref(uri, "dactyl.content.full-zoom",
|
|
||||||
sanitizer.getContext(this.win), callback);
|
|
||||||
else
|
|
||||||
services.contentPrefs.getPref(uri, "dactyl.content.full-zoom",
|
|
||||||
callback);
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user