Merge "Fix 'Tags' padding to keep it farther from the edge and document the source...
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / mw.rcfilters.Controller.js
index 16f58ee..52438ca 100644 (file)
@@ -15,6 +15,8 @@
         * @cfg {string} savedQueriesPreferenceName Where to save the saved queries
         * @cfg {string} daysPreferenceName Preference name for the days filter
         * @cfg {string} limitPreferenceName Preference name for the limit filter
+        * @cfg {string} collapsedPreferenceName Preference name for collapsing and showing
+        *  the active filters area
         * @cfg {boolean} [normalizeTarget] Dictates whether or not to go through the
         *  title normalization to separate title subpage/parts into the target= url
         *  parameter
                this.savedQueriesPreferenceName = config.savedQueriesPreferenceName;
                this.daysPreferenceName = config.daysPreferenceName;
                this.limitPreferenceName = config.limitPreferenceName;
+               this.collapsedPreferenceName = config.collapsedPreferenceName;
                this.normalizeTarget = !!config.normalizeTarget;
 
                this.requestCounter = {};
                this.baseFilterState = {};
                this.uriProcessor = null;
-               this.initializing = false;
+               this.initialized = false;
                this.wereSavedQueriesSaved = false;
 
                this.prevLoggedItems = [];
                        }
                }
 
-               // Check whether we need to load defaults.
-               // We do this by checking whether the current URI query
-               // contains any parameters recognized by the system.
-               // If it does, we load the given state.
-               // If it doesn't, we have no values at all, and we assume
-               // the user loads the base-page and we load defaults.
-               // Defaults should only be applied on load (if necessary)
-               // or on request
-               this.initializing = true;
-
                if ( defaultSavedQueryExists ) {
                        // This came from the server, meaning that we have a default
                        // saved query, but the server could not load it, probably because
                        );
                }
 
-               this.initializing = false;
+               this.initialized = true;
                this.switchView( 'default' );
 
                this.pollingRate = mw.config.get( 'StructuredChangeFiltersLiveUpdatePollingRate' );
                }
        };
 
+       /**
+        * Check if the controller has finished initializing.
+        * @return {boolean} Controller is initialized
+        */
+       mw.rcfilters.Controller.prototype.isInitialized = function () {
+               return this.initialized;
+       };
+
        /**
         * Extracts information from the changes list DOM
         *
        mw.rcfilters.Controller.prototype.updateStickyPreferences = function () {
                // Update default sticky values with selected, whether they came from
                // the initial defaults or from the URL value that is being normalized
-               this.updateDaysDefault( this.filtersModel.getGroup( 'days' ).getSelectedItems()[ 0 ].getParamName() );
-               this.updateLimitDefault( this.filtersModel.getGroup( 'limit' ).getSelectedItems()[ 0 ].getParamName() );
+               this.updateDaysDefault( this.filtersModel.getGroup( 'days' ).findSelectedItems()[ 0 ].getParamName() );
+               this.updateLimitDefault( this.filtersModel.getGroup( 'limit' ).findSelectedItems()[ 0 ].getParamName() );
 
                // TODO: Make these automatic by having the model go over sticky
                // items and update their default values automatically
                this.updateNumericPreference( 'usenewrc', Number( newValue ) );
        };
 
+       /**
+        * Update the collapsed state value
+        *
+        * @param {boolean} isCollapsed Filter area is collapsed
+        */
+       mw.rcfilters.Controller.prototype.updateCollapsedState = function ( isCollapsed ) {
+               this.updateNumericPreference( this.collapsedPreferenceName, Number( isCollapsed ) );
+       };
+
        /**
         * Update a numeric preference with a new value
         *
                        rightNow = new Date().getTime(),
                        randomIdentifier = String( mw.user.sessionId() ) + String( rightNow ) + String( Math.random() ),
                        // Get all current filters
-                       filters = this.filtersModel.getSelectedItems().map( function ( item ) {
+                       filters = this.filtersModel.findSelectedItems().map( function ( item ) {
                                return item.getName();
                        } );