mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-24 00:15:45 +01:00
Remove some unused functionality from messages.jsm.
This commit is contained in:
@@ -733,11 +733,9 @@ function Class() {
|
|||||||
if (callable(args[0]))
|
if (callable(args[0]))
|
||||||
superclass = args.shift();
|
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 Constructor = function Constructor() {
|
||||||
var self = Object.create(Constructor.prototype, {
|
var self = Object.create(Constructor.prototype);
|
||||||
constructor: { value: Constructor },
|
|
||||||
});
|
|
||||||
self.instance = self;
|
self.instance = self;
|
||||||
|
|
||||||
if ("_metaInit_" in self && self._metaInit_)
|
if ("_metaInit_" in self && self._metaInit_)
|
||||||
@@ -749,9 +747,7 @@ function Class() {
|
|||||||
else
|
else
|
||||||
var Constructor = eval(String.replace(<![CDATA[
|
var Constructor = eval(String.replace(<![CDATA[
|
||||||
(function constructor(PARAMS) {
|
(function constructor(PARAMS) {
|
||||||
var self = Object.create(Constructor.prototype, {
|
var self = Object.create(Constructor.prototype);
|
||||||
constructor: { value: Constructor },
|
|
||||||
});
|
|
||||||
self.instance = self;
|
self.instance = self;
|
||||||
|
|
||||||
if ("_metaInit_" in self && self._metaInit_)
|
if ("_metaInit_" in self && self._metaInit_)
|
||||||
@@ -779,9 +775,10 @@ function Class() {
|
|||||||
|
|
||||||
Class.extend(Constructor, superclass, args[0]);
|
Class.extend(Constructor, superclass, args[0]);
|
||||||
update(Constructor, args[1]);
|
update(Constructor, args[1]);
|
||||||
|
|
||||||
Constructor.__proto__ = superclass;
|
Constructor.__proto__ = superclass;
|
||||||
args = args.slice(2);
|
|
||||||
Array.forEach(args, function (obj) {
|
args.slice(2).forEach(function (obj) {
|
||||||
if (callable(obj))
|
if (callable(obj))
|
||||||
obj = obj.prototype;
|
obj = obj.prototype;
|
||||||
update(Constructor.prototype, obj);
|
update(Constructor.prototype, obj);
|
||||||
@@ -915,6 +912,9 @@ Class.prototype = {
|
|||||||
*/
|
*/
|
||||||
init: function c_init() {},
|
init: function c_init() {},
|
||||||
|
|
||||||
|
get instance() ({}),
|
||||||
|
set instance(val) Class.replaceProperty(this, "instance", val),
|
||||||
|
|
||||||
withSavedValues: function withSavedValues(names, callback, self) {
|
withSavedValues: function withSavedValues(names, callback, self) {
|
||||||
let vals = names.map(function (name) this[name], this);
|
let vals = names.map(function (name) this[name], this);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -253,10 +253,14 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
* Returns true if the current Gecko runtime is of the given version
|
* Returns true if the current Gecko runtime is of the given version
|
||||||
* or greater.
|
* 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}
|
* @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. */
|
/** Dactyl's notion of the current operating system platform. */
|
||||||
OS: memoize({
|
OS: memoize({
|
||||||
|
|||||||
@@ -17,19 +17,13 @@ var Messages = Module("messages", {
|
|||||||
|
|
||||||
init: function init(name) {
|
init: function init(name) {
|
||||||
let self = this;
|
let self = this;
|
||||||
name = name || "messages";
|
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._ = Class("_", String, {
|
this._ = Class("_", String, {
|
||||||
init: function _(message) {
|
init: function _(message) {
|
||||||
this.args = arguments;
|
this.args = arguments;
|
||||||
},
|
},
|
||||||
|
instance: {},
|
||||||
message: Class.Memoize(function () {
|
message: Class.Memoize(function () {
|
||||||
let message = this.args[0];
|
let message = this.args[0];
|
||||||
|
|
||||||
@@ -42,18 +36,23 @@ var Messages = Module("messages", {
|
|||||||
valueOf: function valueOf() this.message,
|
valueOf: function valueOf() this.message,
|
||||||
toString: function toString() 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])
|
bundles: Class.Memoize(function ()
|
||||||
iter(prop.QueryInterface(Ci.nsIPropertyElement) for (prop in iter(bundle.getSimpleEnumeration()))),
|
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() {
|
cleanup: function cleanup() {
|
||||||
services.stringBundle.flushBundles();
|
services.stringBundle.flushBundles();
|
||||||
|
|||||||
Reference in New Issue
Block a user