summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorGabriel Luong2013-05-15 15:33:19 (EDT)
committer libing wang2013-05-16 11:48:57 (EDT)
commitcaa9b44bd3e22ad3f29ddb75f631f00d31af3fe8 (patch)
treefe4ff3be8a74cd8ebf0258d58744cc5c9f21163c
parent9777f2ef08245558c866713fc6dde9b4af4800c7 (diff)
downloadorg.eclipse.orion.client-caa9b44bd3e22ad3f29ddb75f631f00d31af3fe8.zip
org.eclipse.orion.client-caa9b44bd3e22ad3f29ddb75f631f00d31af3fe8.tar.gz
org.eclipse.orion.client-caa9b44bd3e22ad3f29ddb75f631f00d31af3fe8.tar.bz2
Bug 408154 - Add option to the command constructor to allow imageClass to be appended elements
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/commands.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/commands.js b/bundles/org.eclipse.orion.client.ui/web/orion/commands.js
index 1c78fbd..6c94ead 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/commands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/commands.js
@@ -225,10 +225,14 @@ define(['require', 'orion/util', 'orion/webui/littlelib', 'orion/webui/dropdown'
element.classList.add("commandImage"); //$NON-NLS-0$
var node;
if (command.imageClass) {
- node = document.createElement("span"); //$NON-NLS-0$
- element.appendChild(node);
- node.classList.add(command.spriteClass);
- node.classList.add(command.imageClass);
+ if (command.addImageClassToElement) {
+ element.classList.add(command.imageClass);
+ } else {
+ node = document.createElement("span"); //$NON-NLS-0$
+ element.appendChild(node);
+ node.classList.add(command.spriteClass);
+ node.classList.add(command.imageClass);
+ }
} else {
node = new Image();
node.alt = command.name;
@@ -414,10 +418,10 @@ define(['require', 'orion/util', 'orion/webui/littlelib', 'orion/webui/dropdown'
/**
* Constructs a new command with the given options.
- * @param {Object} options The command options object.
- * @param {String} options.id the unique id to be used when referring to the command in the command service.
- * @param {String} options.name the name to be used when showing the command as text.
- * @param {String} options.tooltip the tooltip description to use when explaining the purpose of the command.
+ * @param {Object} [options] The command options object.
+ * @param {String} [options.id] the unique id to be used when referring to the command in the command service.
+ * @param {String} [options.name] the name to be used when showing the command as text.
+ * @param {String} [options.tooltip] the tooltip description to use when explaining the purpose of the command.
* @param {Function} [options.callback] the callback to call when the command is activated. The callback should either
* perform the command or return a deferred that represents the asynchronous performance of the command. Optional.
* @param {Function} [options.hrefCallback] if specified, this callback is used to retrieve
@@ -429,6 +433,8 @@ define(['require', 'orion/util', 'orion/webui/littlelib', 'orion/webui/dropdown'
* menu from the command itself. Returns a list of choices that supply the name and image to show, and the callback
* to call when the choice is made. Optional.
* @param {String} [options.imageClass] a CSS class name suitable for showing a background image. Optional.
+ * @param {Boolean} [options.addImageClassToElement] If true, the image class will be added to the element's
+ * class list. Otherwise, a span element with the image class is created and appended to the element.
* @param {String} [options.spriteClass] an additional CSS class name that can be used to specify a sprite background image. This
* useful with some sprite generation tools, where imageClass specifies the location in a sprite, and spriteClass describes the
* sprite itself. Optional.
@@ -457,6 +463,8 @@ define(['require', 'orion/util', 'orion/webui/littlelib', 'orion/webui/dropdown'
// A choice is an object with a name, callback, and optional image
this.image = options.image || require.toUrl("images/none.png"); //$NON-NLS-0$
this.imageClass = options.imageClass; // points to the location in a sprite
+ this.addImageClassToElement = options.addImageClassToElement; // optional boolean if true will add the image class to the
+ // element's class list
this.spriteClass = options.spriteClass || "commandSprite"; // defines the background image containing sprites //$NON-NLS-0$
this.visibleWhen = options.visibleWhen;
this.parameters = options.parameters; // only used when a command is used in the command registry.