Merge "RCFilters: Have the model accept multiple views"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / dm / mw.rcfilters.dm.FiltersViewModel.js
index ad0794e..46f0fd8 100644 (file)
@@ -20,7 +20,7 @@
                this.parameterMap = {};
 
                this.views = {};
-               this.currentView = null;
+               this.currentView = 'default';
 
                // Events
                this.aggregate( { update: 'filterItemUpdate' } );
         * @return {string} View trigger, if exists
         */
        mw.rcfilters.dm.FiltersViewModel.prototype.getViewTrigger = function ( view ) {
-               return this.views[ view ] && this.views[ view ].trigger;
+               return ( this.views[ view ] && this.views[ view ].trigger ) || '';
        };
        /**
         * Get the value of a specific parameter
                        filterItem.clearHighlightColor();
                } );
        };
+
+       /**
+        * Return a version of the given string that is without any
+        * view triggers.
+        *
+        * @param {string} str Given string
+        * @return {string} Result
+        */
+       mw.rcfilters.dm.FiltersViewModel.prototype.removeViewTriggers = function ( str ) {
+               if ( this.getViewByTrigger( str.substr( 0, 1 ) ) !== 'default' ) {
+                       str = str.substr( 1 );
+               }
+
+               return str;
+       };
 }( mediaWiki, jQuery ) );