[extensions-web] js: Add button to launch extension preferences
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] js: Add button to launch extension preferences
- Date: Wed, 8 Feb 2012 15:43:13 +0000 (UTC)
commit dca9ecc09f36991940b35b3358aa8f0cc9ebb105
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Jan 18 21:36:12 2012 -0500
js: Add button to launch extension preferences
sweettooth/static/css/sweettooth.css | 14 ++++++++++
sweettooth/static/js/extensions.js | 34 ++++++++++++++++++++++++
sweettooth/static/js/main.js | 2 +-
sweettooth/static/js/versions/1/main.js | 3 +-
sweettooth/static/js/versions/2/main.js | 1 +
sweettooth/static/js/versions/3/main.js | 24 +++++++++++++++++
sweettooth/static/js/versions/common/common.js | 6 ++++
7 files changed, 82 insertions(+), 2 deletions(-)
---
diff --git a/sweettooth/static/css/sweettooth.css b/sweettooth/static/css/sweettooth.css
index 4902650..55d4855 100644
--- a/sweettooth/static/css/sweettooth.css
+++ b/sweettooth/static/css/sweettooth.css
@@ -790,3 +790,17 @@ input[type=submit], button {
-o-transform: rotate(90deg);
transform: rotate(90deg);
}
+
+.launch-prefs-button {
+ background-color: #4D90FE;
+ border: 1px solid #3079ED;
+ border-radius: 2px;
+ color: white;
+ margin-left: 25px;
+ padding: 2px 10px;
+ cursor: pointer;
+}
+
+.launch-prefs-button:hover {
+ background-color: #5EA1FF;
+}
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index bf578c4..3edf18f 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -64,6 +64,9 @@ function($, messages, dbusProxy, extensionUtils) {
$.fn.addOutOfDateIndicator = function() {
};
+ $.fn.addLaunchExtensionPrefsButton = function() {
+ };
+
$.fn.checkForUpdates = function() {
};
@@ -233,6 +236,11 @@ function($, messages, dbusProxy, extensionUtils) {
append($('<span>', {'class': 'author'})).
append($('<p>', {'class': 'description'}).text(extension.description));
+ $elem.data('uuid', extension.uuid);
+
+ if (extension.hasPrefs && extension.state !== ExtensionState.OUT_OF_DATE)
+ $elem.addLaunchExtensionPrefsButton(true);
+
$.ajax({
url: "/ajax/detail/",
dataType: "json",
@@ -348,6 +356,32 @@ function($, messages, dbusProxy, extensionUtils) {
});
};
+ $.fn.addLaunchExtensionPrefsButton = function(force) {
+ function launchExtensionPrefsButton($elem, uuid) {
+ $elem.
+ find('.description').
+ before($('<span>', {'class': 'launch-prefs-button'}).
+ text("Configure").
+ click(function() {
+ dbusProxy.LaunchExtensionPrefs(uuid);
+ }));
+ }
+
+ return this.each(function() {
+ var $elem = $(this);
+ var uuid = $elem.data('uuid');
+
+ if (force) {
+ launchExtensionPrefsButton($elem, uuid);
+ } else {
+ dbusProxy.GetExtensionInfo(uuid).done(function(data) {
+ if (data.hasPrefs && data.state !== ExtensionState.OUT_OF_DATE)
+ launchExtensionPrefsButton($elem, uuid);
+ });
+ }
+ });
+ };
+
$.fn.checkForUpdates = function() {
return this.each(function() {
var $elem = $(this);
diff --git a/sweettooth/static/js/main.js b/sweettooth/static/js/main.js
index 82cf4f4..ad60688 100644
--- a/sweettooth/static/js/main.js
+++ b/sweettooth/static/js/main.js
@@ -78,7 +78,7 @@ require(['jquery', 'messages', 'modal',
});
$('#local_extensions').addLocalExtensions();
- $('.extension.single-page').addExtensionSwitch();
+ $('.extension.single-page').addExtensionSwitch().addLaunchExtensionPrefsButton();
$.extend($.fn.raty.defaults, {
path: '/static/images/',
diff --git a/sweettooth/static/js/versions/1/main.js b/sweettooth/static/js/versions/1/main.js
index 3bfae28..23cb2ea 100644
--- a/sweettooth/static/js/versions/1/main.js
+++ b/sweettooth/static/js/versions/1/main.js
@@ -9,10 +9,11 @@ define(['jquery', 'dbus!API', 'versions/common/common'], function($, API, common
DisableExtension: common.DisableExtension,
InstallExtension: common.InstallExtension,
UninstallExtension: common.UninstallExtension,
+ LaunchExtensionPrefs: common.LaunchExtensionPrefsDummy,
ShellVersion: API.shellVersion,
- extensionStateChangedHandler: null,
+ extensionStateChangedHandler: null
};
API.onchange = common.API_onchange(proxy);
diff --git a/sweettooth/static/js/versions/2/main.js b/sweettooth/static/js/versions/2/main.js
index 6b95f3b..e90cae3 100644
--- a/sweettooth/static/js/versions/2/main.js
+++ b/sweettooth/static/js/versions/2/main.js
@@ -9,6 +9,7 @@ define(['jquery', 'dbus!API', 'versions/common/common'], function($, API, common
DisableExtension: common.DisableExtension,
InstallExtension: common.InstallExtension,
UninstallExtension: common.UninstallExtension,
+ LaunchExtensionPrefs: common.LaunchExtensionPrefsDummy,
ShellVersion: API.shellVersion,
diff --git a/sweettooth/static/js/versions/3/main.js b/sweettooth/static/js/versions/3/main.js
new file mode 100644
index 0000000..c64ca36
--- /dev/null
+++ b/sweettooth/static/js/versions/3/main.js
@@ -0,0 +1,24 @@
+"use strict";
+
+define(['jquery', 'dbus!API', 'versions/common/common'], function($, API, common) {
+ var proxy = {
+ ListExtensions: common.ListExtensions,
+ GetExtensionInfo: common.GetExtensionInfo,
+ GetErrors: common.GetErrors,
+ EnableExtension: common.EnableExtension,
+ DisableExtension: common.DisableExtension,
+ InstallExtension: common.InstallExtension,
+ UninstallExtension: common.UninstallExtension,
+ LaunchExtensionPrefs: common.LaunchExtensionPrefs,
+
+ ShellVersion: API.shellVersion,
+
+ extensionStateChangedHandler: null,
+ shellRestartHandler: null
+ };
+
+ API.onchange = common.API_onchange(proxy);
+ API.onshellrestart = common.API_onshellrestart(proxy);
+
+ return proxy;
+});
diff --git a/sweettooth/static/js/versions/common/common.js b/sweettooth/static/js/versions/common/common.js
index 6b69fdf..7e99dc0 100644
--- a/sweettooth/static/js/versions/common/common.js
+++ b/sweettooth/static/js/versions/common/common.js
@@ -22,6 +22,12 @@ define(['jquery', 'dbus!API'], function($, API) {
return _makePromise(API.getExtensionErrors(uuid));
},
+ LaunchExtensionPrefs: function(uuid) {
+ return API.launchExtensionPrefs(uuid);
+ },
+
+ LaunchExtensionPrefsDummy: function(uuid) { },
+
EnableExtension: function(uuid) {
API.setExtensionEnabled(uuid, true);
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]