mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-28 22:52:28 +01:00
Remove some unused functionality from messages.jsm.
This commit is contained in:
@@ -733,11 +733,9 @@ function Class() {
|
||||
if (callable(args[0]))
|
||||
superclass = args.shift();
|
||||
|
||||
if (loaded.config && config.haveGecko("6.0a1")) // Bug 657418.
|
||||
if (loaded.config && (config.haveGecko("5.*", "6.0") || config.haveGecko("8.0"))) // Bug 657418.
|
||||
var Constructor = function Constructor() {
|
||||
var self = Object.create(Constructor.prototype, {
|
||||
constructor: { value: Constructor },
|
||||
});
|
||||
var self = Object.create(Constructor.prototype);
|
||||
self.instance = self;
|
||||
|
||||
if ("_metaInit_" in self && self._metaInit_)
|
||||
@@ -749,9 +747,7 @@ function Class() {
|
||||
else
|
||||
var Constructor = eval(String.replace(<![CDATA[
|
||||
(function constructor(PARAMS) {
|
||||
var self = Object.create(Constructor.prototype, {
|
||||
constructor: { value: Constructor },
|
||||
});
|
||||
var self = Object.create(Constructor.prototype);
|
||||
self.instance = self;
|
||||
|
||||
if ("_metaInit_" in self && self._metaInit_)
|
||||
@@ -779,9 +775,10 @@ function Class() {
|
||||
|
||||
Class.extend(Constructor, superclass, args[0]);
|
||||
update(Constructor, args[1]);
|
||||
|
||||
Constructor.__proto__ = superclass;
|
||||
args = args.slice(2);
|
||||
Array.forEach(args, function (obj) {
|
||||
|
||||
args.slice(2).forEach(function (obj) {
|
||||
if (callable(obj))
|
||||
obj = obj.prototype;
|
||||
update(Constructor.prototype, obj);
|
||||
@@ -915,6 +912,9 @@ Class.prototype = {
|
||||
*/
|
||||
init: function c_init() {},
|
||||
|
||||
get instance() ({}),
|
||||
set instance(val) Class.replaceProperty(this, "instance", val),
|
||||
|
||||
withSavedValues: function withSavedValues(names, callback, self) {
|
||||
let vals = names.map(function (name) this[name], this);
|
||||
try {
|
||||
|
||||
@@ -253,10 +253,14 @@ var ConfigBase = Class("ConfigBase", {
|
||||
* Returns true if the current Gecko runtime is of the given version
|
||||
* or greater.
|
||||
*
|
||||
* @param {string} ver The required version.
|
||||
* @param {string} min The minimum required version. @optional
|
||||
* @param {string} max The maximum required version. @optional
|
||||
* @returns {boolean}
|
||||
*/
|
||||
haveGecko: function (ver) services.versionCompare.compare(services.runtime.platformVersion, ver) >= 0,
|
||||
haveGecko: function (min, max) let ({ compare } = services.versionCompare,
|
||||
{ platformVersion } = services.runtime)
|
||||
(min == null || compare(platformVersion, min) >= 0) &&
|
||||
(max == null || compare(platformVersion, max) < 0),
|
||||
|
||||
/** Dactyl's notion of the current operating system platform. */
|
||||
OS: memoize({
|
||||
|
||||
@@ -17,19 +17,13 @@ var Messages = Module("messages", {
|
||||
|
||||
init: function init(name) {
|
||||
let self = this;
|
||||
name = name || "messages";
|
||||
|
||||
this.bundles = array.uniq([JSMLoader.getTarget("dactyl://locale/" + name + ".properties"),
|
||||
JSMLoader.getTarget("dactyl://locale-local/" + name + ".properties"),
|
||||
"resource://dactyl-locale/en-US/" + name + ".properties",
|
||||
"resource://dactyl-locale-local/en-US/" + name + ".properties"])
|
||||
.map(services.stringBundle.createBundle)
|
||||
.filter(function (bundle) { try { bundle.getSimpleEnumeration(); return true; } catch (e) { return false; } });
|
||||
this.name = name || "messages";
|
||||
|
||||
this._ = Class("_", String, {
|
||||
init: function _(message) {
|
||||
this.args = arguments;
|
||||
},
|
||||
instance: {},
|
||||
message: Class.Memoize(function () {
|
||||
let message = this.args[0];
|
||||
|
||||
@@ -42,18 +36,23 @@ var Messages = Module("messages", {
|
||||
valueOf: function valueOf() this.message,
|
||||
toString: function toString() this.message
|
||||
});
|
||||
|
||||
let seen = {};
|
||||
for (let { key } in this.iterate()) {
|
||||
if (!Set.add(seen, key))
|
||||
this._[key] = this[key] = {
|
||||
__noSuchMethod__: function __(prop, args) self._.apply(self, [prop].concat(args))
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
iterate: function () let (bundle = this.bundles[0])
|
||||
iter(prop.QueryInterface(Ci.nsIPropertyElement) for (prop in iter(bundle.getSimpleEnumeration()))),
|
||||
bundles: Class.Memoize(function ()
|
||||
array.uniq([JSMLoader.getTarget("dactyl://locale/" + this.name + ".properties"),
|
||||
JSMLoader.getTarget("dactyl://locale-local/" + this.name + ".properties"),
|
||||
"resource://dactyl-locale/en-US/" + this.name + ".properties",
|
||||
"resource://dactyl-locale-local/en-US/" + this.name + ".properties"])
|
||||
.map(services.stringBundle.createBundle)
|
||||
.filter(function (bundle) { try { bundle.getSimpleEnumeration(); return true; } catch (e) { return false; } })),
|
||||
|
||||
iterate: function () {
|
||||
let seen = {};
|
||||
for (let bundle in values(this.bundles))
|
||||
for (let { key, value } in iter(bundle.getSimpleEnumeration(), Ci.nsIPropertyElement))
|
||||
if (!Set.add(seen, key))
|
||||
yield [key, value];
|
||||
},
|
||||
|
||||
cleanup: function cleanup() {
|
||||
services.stringBundle.flushBundles();
|
||||
|
||||
Reference in New Issue
Block a user