Repository: ambari
Updated Branches:
  refs/heads/trunk 9c1c7f935 -> 6adee814f


AMBARI-12294. Overrides for sliders doesn't drawn correctly after filtering 
out/in (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b0af95f5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b0af95f5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b0af95f5

Branch: refs/heads/trunk
Commit: b0af95f5d64d32510ea42eea00db340b4fd15423
Parents: 9c1c7f9
Author: Oleg Nechiporenko <onechipore...@apache.org>
Authored: Mon Jul 6 18:02:35 2015 +0300
Committer: Oleg Nechiporenko <onechipore...@apache.org>
Committed: Mon Jul 6 20:15:52 2015 +0300

----------------------------------------------------------------------
 .../widgets/slider_config_widget_view.js        | 31 ++++++++++++++++----
 1 file changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b0af95f5/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js 
b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
index 877d2b5..0905a09 100644
--- a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
@@ -526,10 +526,12 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
   },
 
   /**
-   * recreate widget in case max or min values were changed
+   * Recreate widget in case max or min values were changed
+   *
    * @method changeBoundariesOnce
    */
   changeBoundariesOnce: function () {
+    var self = this;
     if ($.mocho) {
       //temp fix as it can broke test that doesn't have any connection with 
this method
       return;
@@ -548,6 +550,10 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
         if (arguments.length) {
           this.refreshSliderObserver();
         }
+        else {
+          // hack for slider-overrides
+          this._changeBoundariesOnceLater("don't call me more!");
+        }
       } catch (e) {
         console.error('error while rebuilding slider for config: ' + 
this.get('config.name'));
       }
@@ -555,16 +561,31 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
   },
 
   /**
+   * Method used for initializing sliders in the next Ember run-loop
+   * It's useful for overrides, because they are redrawn a little bit later 
than origin config
+   *
+   * If this method is called without arguments, it will call itself 
recursively using <code>changeBoundariesOnce</code>
+   * and <code>refreshSliderObserver</code>
+   * If not - it will just call <code>changeBoundariesOnce</code> in the next 
run-loop
+   * @method changeBoundariesOnceLater
+   */
+  _changeBoundariesOnceLater: function() {
+    console.debug('_changeBoundariesOnceLater', arguments);
+    var args = arguments;
+    var self = this;
+    Em.run.later('sync', function() {
+      self.changeBoundariesOnce(args);
+    }, 10);
+  },
+
+  /**
    * Workaround for bootstrap-slider widget that was initiated inside hidden 
container.
    * @method refreshSliderObserver
    */
   refreshSliderObserver: function() {
     var sliderTickLabel = this.$('.ui-slider-wrapper:eq(0) 
.slider-tick-label:first');
-    var self = this;
     if (sliderTickLabel.width() == 0 && this.isValueCompatibleWithWidget()) {
-      Em.run.later('sync', function() {
-        self.changeBoundariesOnce();
-      }, 10);
+      this._changeBoundariesOnceLater();
     }
   }.observes('parentView.content.isActive', 
'parentView.parentView.tab.isActive'),
 

Reply via email to