Skip to content

Commit

Permalink
Update library
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 2, 2014
1 parent 30bd254 commit 1b98b3f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 28 deletions.
33 changes: 27 additions & 6 deletions components/loader.js
@@ -1,14 +1,34 @@
/**
* @fileOverview Loader module for restartless addons
* @author YUKI "Piro" Hiroshi
* @version 10
* @version 11
*
* @license
* The MIT License, Copyright (c) 2010-2014 YUKI "Piro" Hiroshi.
* https://github.com/piroor/restartless/blob/master/license.txt
* @url http://github.com/piroor/restartless
*/

function toPropertyDescriptors(aProperties) {
var descriptors = {};
Object.keys(aProperties).forEach(function(aProperty) {
var description = Object.getOwnPropertyDescriptor(aProperties, aProperty);
descriptors[aProperty] = description;
});
return descriptors;
}

function inherit(aParent, aExtraProperties) {
if (!Object.create) {
aExtraProperties.__proto__ = aParent;
return aExtraProperties;
}
if (aExtraProperties)
return Object.create(aParent, toPropertyDescriptors(aExtraProperties));
else
return Object.create(aParent);
}

/** You can customize shared properties for loaded scripts. */
var Application = (function() {
if ('@mozilla.org/fuel/application;1' in Components.classes)
Expand Down Expand Up @@ -42,7 +62,10 @@ var _namespacePrototype = {
},
atob : function(aInput) {
return atob(aInput);
}
},
inherit : function(aParent, aExtraProperties) {
return inherit(aParent, aExtraProperties);
},
};
var _namespaces;

Expand All @@ -55,7 +78,6 @@ var _namespaces;
*
* @param {String} aScriptURL
* URL of a script. Wrapped version of load() can handle related path.
* Related path will be resolved based on the location of the caller script.
* @param {Object=} aExportTargetForImport
* EXPORTED_SYMBOLS in the loaded script will be exported to the object.
Expand Down Expand Up @@ -159,7 +181,7 @@ function exists(aPath, aBaseURI)
var reader = Components.classes['@mozilla.org/libjar/zip-reader;1']
.createInstance(Components.interfaces.nsIZipReader);
reader.open(baseURI.JARFile.QueryInterface(Components.interfaces.nsIFileURL).file);
try {
try {
let baseEntry = baseURI.JAREntry.replace(/[^\/]+$/, '');
let entries = reader.findEntries(baseEntry + aPath + '$');
let found = entries.hasMore();
Expand Down Expand Up @@ -251,8 +273,7 @@ function _createNamespace(aURISpec, aRoot)
IOService.newURI(aRoot, null, null)
) :
aRoot ;
var ns = {
__proto__ : _namespacePrototype,
var ns = inherit(_namespacePrototype, {
location : _createFakeLocation(baseURI),
exists : function(aPath, aBase) {
return exists(aPath, aBase || baseURI.spec);
Expand Down
50 changes: 28 additions & 22 deletions modules/lib/confirmWithPopup.js
Expand Up @@ -13,7 +13,7 @@ var namespace = {
/**
* @fileOverview Popup Notification (Door Hanger) Based Confirmation Library for Firefox 4.0 or later
* @author YUKI "Piro" Hiroshi
* @version 5
* @version 6
* Basic usage:
*
* @example
Expand Down Expand Up @@ -62,9 +62,7 @@ var namespace = {
*
* @license
* The MIT License, Copyright (c) 2011-2012 YUKI "Piro" Hiroshi
* http://github.com/piroor/fxaddonlibs/blob/master/license.txt
* @url http://github.com/piroor/fxaddonlibs/blob/master/confirmWithPopup.js
* @url http://github.com/piroor/fxaddonlibs
* @url http://github.com/piroor/fxaddonlib-confirm-popup
*/

if (typeof window == 'undefined')
Expand Down Expand Up @@ -103,7 +101,7 @@ catch(e) {

var confirmWithPopup;
(function(global) {
const currentRevision = 5;
const currentRevision = 6;

var loadedRevision = 'confirmWithPopup' in namespace ?
namespace.confirmWithPopup.revision :
Expand Down Expand Up @@ -308,10 +306,14 @@ var confirmWithPopup;
options.anchor,
primaryAction,
secondaryActions,
{
__proto__ : nativeOptions,
dismissed : true
}
Object.create(nativeOptions, {
dismissed : {
writable : true,
configurable : true,
enumerable : true,
value : true
}
})
);
if (!options.dismissed) {
/**
Expand All @@ -325,21 +327,25 @@ var confirmWithPopup;
options.anchor,
primaryAction,
secondaryActions,
{
__proto__ : nativeOptions,
eventCallback : function(aEventType) {
try {
if (!done && (aEventType == 'removed' || aEventType == 'dismissed'))
deferred.fail(aEventType);
if (options.eventCallback)
options.eventCallback.call(aOptions.options || aOptions, aEventType);
}
finally {
if (aEventType == 'removed')
postProcess();
Object.create(nativeOptions, {
eventCallback : {
writable : true,
configurable : true,
enumerable : true,
value : function(aEventType) {
try {
if (!done && (aEventType == 'removed' || aEventType == 'dismissed'))
deferred.fail(aEventType);
if (options.eventCallback)
options.eventCallback.call(aOptions.options || aOptions, aEventType);
}
finally {
if (aEventType == 'removed')
postProcess();
}
}
}
}
})
);
};
if (namespace.Deferred)
Expand Down

0 comments on commit 1b98b3f

Please sign in to comment.