You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/01/12 19:50:59 UTC

[07/12] git commit: [flex-asjs] [refs/heads/develop] - fix ImageAndTextButton on JS

fix ImageAndTextButton on JS


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/9901c45f
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/9901c45f
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/9901c45f

Branch: refs/heads/develop
Commit: 9901c45f24d5d78dac2a17964aa771b8c0d8b365
Parents: f314c4f
Author: Alex Harui <ah...@apache.org>
Authored: Mon Jan 12 10:46:54 2015 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Jan 12 10:46:54 2015 -0800

----------------------------------------------------------------------
 .../org/apache/flex/html/ImageAndTextButton.js  | 27 +++++++++++++++-----
 1 file changed, 20 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9901c45f/frameworks/js/FlexJS/src/org/apache/flex/html/ImageAndTextButton.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/ImageAndTextButton.js b/frameworks/js/FlexJS/src/org/apache/flex/html/ImageAndTextButton.js
index 0f03214..2e8d4c3 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/ImageAndTextButton.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/ImageAndTextButton.js
@@ -25,7 +25,8 @@ goog.require('org.apache.flex.html.Button');
 org.apache.flex.html.ImageAndTextButton = function() {
   org.apache.flex.html.ImageAndTextButton.base(this, 'constructor');
 
-
+  this._text = '';
+  this._src = '';
 };
 goog.inherits(org.apache.flex.html.ImageAndTextButton,
     org.apache.flex.html.Button);
@@ -48,8 +49,6 @@ org.apache.flex.html.ImageAndTextButton.prototype.createElement =
     function() {
   this.element = document.createElement('button');
   this.element.setAttribute('type', 'button');
-  this.img = document.createElement('img');
-  this.element.appendChild(this.img);
 
   this.positioner = this.element;
   this.element.flexjs_wrapper = this;
@@ -68,7 +67,7 @@ org.apache.flex.html.ImageAndTextButton.prototype.createElement =
  * @return {string} The text getter.
  */
 org.apache.flex.html.ImageAndTextButton.prototype.get_text = function() {
-  return this.element.innerHTML;
+  return this._text;
 };
 
 
@@ -78,7 +77,8 @@ org.apache.flex.html.ImageAndTextButton.prototype.get_text = function() {
  */
 org.apache.flex.html.ImageAndTextButton.prototype.set_text =
     function(value) {
-  this.element.innerHTML = value;
+  this._text = value;
+  this.setInnerHTML();
 };
 
 
@@ -87,7 +87,7 @@ org.apache.flex.html.ImageAndTextButton.prototype.set_text =
  * @return {string} The image url.
  */
 org.apache.flex.html.ImageAndTextButton.prototype.get_image = function() {
-  return this.img.src;
+  return this._src;
 };
 
 
@@ -97,5 +97,18 @@ org.apache.flex.html.ImageAndTextButton.prototype.get_image = function() {
  */
 org.apache.flex.html.ImageAndTextButton.prototype.set_image =
     function(value) {
-  this.img.src = value;
+  this._src = value;
+  this.setInnerHTML();
+};
+
+
+/**
+ */
+org.apache.flex.html.ImageAndTextButton.prototype.setInnerHTML = function() {
+  var inner = '';
+  if (this._src != null)
+    inner += '<img src=\'' + this._src + '\'/>';
+  inner += '&nbsp;';
+  inner += this._text;
+  this.element.innerHTML = inner;
 };