Merge "RCFilters: Add missing jQueryMsg dependency"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.HighlightColorPickerWidget.js
index 570647e..64a7fcf 100644 (file)
@@ -24,7 +24,7 @@
                this.controller = controller;
                this.model = model;
 
-               this.currentSelection = '';
+               this.currentSelection = 'none';
                this.buttonSelect = new OO.ui.ButtonSelectWidget( {
                        items: colors.map( function ( color ) {
                                return new OO.ui.ButtonOptionWidget( {
                        } ),
                        classes: 'mw-rcfilters-ui-highlightColorPickerWidget-buttonSelect'
                } );
-               this.selectColor( 'none' );
 
                // Event
-               this.model.connect( this, { update: 'onModelUpdate' } );
+               this.model.connect( this, { update: 'updateUiBasedOnModel' } );
                this.buttonSelect.connect( this, { choose: 'onChooseColor' } );
 
+               this.updateUiBasedOnModel();
+
                this.$element
                        .addClass( 'mw-rcfilters-ui-highlightColorPickerWidget' )
                        .append(
@@ -73,7 +74,7 @@
        /**
         * Respond to item model update event
         */
-       mw.rcfilters.ui.HighlightColorPickerWidget.prototype.onModelUpdate = function () {
+       mw.rcfilters.ui.HighlightColorPickerWidget.prototype.updateUiBasedOnModel = function () {
                this.selectColor( this.model.getHighlightColor() || 'none' );
        };
 
@@ -83,8 +84,8 @@
         * @param {string} color Selected color
         */
        mw.rcfilters.ui.HighlightColorPickerWidget.prototype.selectColor = function ( color ) {
-               var previousItem = this.buttonSelect.getItemFromData( this.currentSelection ),
-                       selectedItem = this.buttonSelect.getItemFromData( color );
+               var previousItem = this.buttonSelect.findItemFromData( this.currentSelection ),
+                       selectedItem = this.buttonSelect.findItemFromData( color );
 
                if ( this.currentSelection !== color ) {
                        this.currentSelection = color;