summaryrefslogtreecommitdiffstats
path: root/toolkit/jetpack/sdk/ui/button
diff options
context:
space:
mode:
authorNew Tobin Paradigm <email@mattatobin.com>2018-04-20 09:40:31 -0400
committerGitHub <noreply@github.com>2018-04-20 09:40:31 -0400
commit633cc96bcec268700dd244aa956811797d3f8208 (patch)
tree90f6d18499eec3ed93ebb6b6b6f59015aaf85f67 /toolkit/jetpack/sdk/ui/button
parentae4be7c9eb5d2ac6094296b83704c333105aa5d7 (diff)
parentc1a1f487afb26405b4dc2297ad681b0c07c24b84 (diff)
downloadUXP-633cc96bcec268700dd244aa956811797d3f8208.tar
UXP-633cc96bcec268700dd244aa956811797d3f8208.tar.gz
UXP-633cc96bcec268700dd244aa956811797d3f8208.tar.lz
UXP-633cc96bcec268700dd244aa956811797d3f8208.tar.xz
UXP-633cc96bcec268700dd244aa956811797d3f8208.zip
Merge pull request #211 from JustOff/PR_PMkit_part1
Make Add-on SDK (Jetpack) work on Pale Moon || Part 1
Diffstat (limited to 'toolkit/jetpack/sdk/ui/button')
-rw-r--r--toolkit/jetpack/sdk/ui/button/action.js1
-rw-r--r--toolkit/jetpack/sdk/ui/button/toggle.js1
-rw-r--r--toolkit/jetpack/sdk/ui/button/view.js47
-rw-r--r--toolkit/jetpack/sdk/ui/button/view/events.js1
4 files changed, 49 insertions, 1 deletions
diff --git a/toolkit/jetpack/sdk/ui/button/action.js b/toolkit/jetpack/sdk/ui/button/action.js
index dfb092d0c..5355705be 100644
--- a/toolkit/jetpack/sdk/ui/button/action.js
+++ b/toolkit/jetpack/sdk/ui/button/action.js
@@ -6,6 +6,7 @@
module.metadata = {
'stability': 'experimental',
'engines': {
+ 'Palemoon': '> 27',
'Firefox': '> 28'
}
};
diff --git a/toolkit/jetpack/sdk/ui/button/toggle.js b/toolkit/jetpack/sdk/ui/button/toggle.js
index a226b3212..d8a3d1758 100644
--- a/toolkit/jetpack/sdk/ui/button/toggle.js
+++ b/toolkit/jetpack/sdk/ui/button/toggle.js
@@ -6,6 +6,7 @@
module.metadata = {
'stability': 'experimental',
'engines': {
+ 'Palemoon': '> 27',
'Firefox': '> 28'
}
};
diff --git a/toolkit/jetpack/sdk/ui/button/view.js b/toolkit/jetpack/sdk/ui/button/view.js
index 63b7aea31..552aab2f7 100644
--- a/toolkit/jetpack/sdk/ui/button/view.js
+++ b/toolkit/jetpack/sdk/ui/button/view.js
@@ -6,6 +6,7 @@
module.metadata = {
'stability': 'experimental',
'engines': {
+ 'Palemoon': '> 27',
'Firefox': '> 28'
}
};
@@ -19,14 +20,19 @@ const { isObject, isNil } = require('../../lang/type');
const { getMostRecentBrowserWindow } = require('../../window/utils');
const { ignoreWindow } = require('../../private-browsing/utils');
+#ifdef MC_PALEMOON
+const { buttons } = require('../buttons');
+#else
const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
const { AREA_PANEL, AREA_NAVBAR } = CustomizableUI;
+#endif
const { events: viewEvents } = require('./view/events');
const XUL_NS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
const views = new Map();
+#ifndef MC_PALEMOON
const customizedWindows = new WeakMap();
const buttonListener = {
@@ -64,19 +70,25 @@ CustomizableUI.addListener(buttonListener);
require('../../system/unload').when( _ =>
CustomizableUI.removeListener(buttonListener)
);
+#endif
function getNode(id, window) {
return !views.has(id) || ignoreWindow(window)
? null
+#ifdef MC_PALEMOON
+ : buttons.getNode(id, window);
+#else
: CustomizableUI.getWidget(id).forWindow(window).node
+#endif
};
+#ifndef MC_PALEMOON
function isInToolbar(id) {
let placement = CustomizableUI.getPlacementOfWidget(id);
return placement && CustomizableUI.getAreaType(placement.area) === 'toolbar';
}
-
+#endif
function getImage(icon, isInToolbar, pixelRatio) {
let targetSize = (isInToolbar ? 18 : 32) * pixelRatio;
@@ -109,7 +121,11 @@ function getImage(icon, isInToolbar, pixelRatio) {
}
function nodeFor(id, window=getMostRecentBrowserWindow()) {
+#ifdef MC_PALEMOON
+ return getNode(id, window);
+#else
return customizedWindows.has(window) ? null : getNode(id, window);
+#endif
};
exports.nodeFor = nodeFor;
@@ -119,14 +135,23 @@ function create(options) {
if (views.has(id))
throw new Error('The ID "' + id + '" seems already used.');
+#ifdef MC_PALEMOON
+ buttons.createButton({
+#else
CustomizableUI.createWidget({
+#endif
id: id,
+#ifdef MC_PALEMOON
+
+ onBuild: function(document, _id) {
+#else
type: 'custom',
removable: true,
defaultArea: AREA_NAVBAR,
allowedAreas: [ AREA_PANEL, AREA_NAVBAR ],
onBuild: function(document) {
+#endif
let window = document.defaultView;
let node = document.createElementNS(XUL_NS, 'toolbarbutton');
@@ -136,16 +161,28 @@ function create(options) {
if (ignoreWindow(window))
node.style.display = 'none';
+#ifdef MC_PALEMOON
+ node.setAttribute('id', _id);
+#else
node.setAttribute('id', this.id);
+#endif
node.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional badged-button');
+#ifndef MC_PALEMOON
node.setAttribute('type', type);
+#endif
node.setAttribute('label', label);
node.setAttribute('tooltiptext', label);
node.setAttribute('image', image);
+#ifdef MC_PALEMOON
+ node.setAttribute('pmkit-button', 'true');
+#else
node.setAttribute('constrain-size', 'true');
+#endif
views.set(id, {
+#ifndef MC_PALEMOON
area: this.currentArea,
+#endif
icon: icon,
label: label
});
@@ -171,7 +208,11 @@ function dispose(id) {
if (!views.has(id)) return;
views.delete(id);
+#ifdef MC_PALEMOON
+ buttons.destroyButton(id);
+#else
CustomizableUI.destroyWidget(id);
+#endif
}
exports.dispose = dispose;
@@ -179,8 +220,12 @@ function setIcon(id, window, icon) {
let node = getNode(id, window);
if (node) {
+#ifdef MC_PALEMOON
+ let image = getImage(icon, true, window.devicePixelRatio);
+#else
icon = customizedWindows.has(window) ? views.get(id).icon : icon;
let image = getImage(icon, isInToolbar(id), window.devicePixelRatio);
+#endif
node.setAttribute('image', image);
}
diff --git a/toolkit/jetpack/sdk/ui/button/view/events.js b/toolkit/jetpack/sdk/ui/button/view/events.js
index 98909656a..34d14be3a 100644
--- a/toolkit/jetpack/sdk/ui/button/view/events.js
+++ b/toolkit/jetpack/sdk/ui/button/view/events.js
@@ -7,6 +7,7 @@
module.metadata = {
'stability': 'experimental',
'engines': {
+ 'Palemoon': '*',
'Firefox': '*',
'SeaMonkey': '*',
'Thunderbird': '*'