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 ) );