define('devbridge.autocomplete',['jquery'],function($){'use strict';var utils=(function(){return{escapeRegExChars:function(value){return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");},createNode:function(containerClass){var div=document.createElement('div');div.className=containerClass;div.style.position='absolute';div.style.display='none';return div;}};}()),keys={ESC:27,TAB:9,RETURN:13,LEFT:37,UP:38,RIGHT:39,DOWN:40};function Autocomplete(el,options){var noop=function(){},that=this,defaults={ajaxSettings:{},autoSelectFirst:!1,appendTo:document.body,serviceUrl:null,lookup:null,onSelect:null,width:'auto',minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:Autocomplete.formatResult,delimiter:null,zIndex:9999,type:'GET',noCache:!1,onSearchStart:noop,onSearchComplete:noop,onSearchError:noop,preserveInput:!1,containerClass:'autocomplete-suggestions',tabDisabled:!1,dataType:'text',currentRequest:null,triggerSelectOnValidInput:!0,preventBadQueries:
!0,lookupFilter:function(suggestion,originalQuery,queryLowerCase){return suggestion.value.toLowerCase().indexOf(queryLowerCase)!==-1;},paramName:'query',transformResult:function(response){return typeof response==='string'?$.parseJSON(response):response;},showNoSuggestionNotice:!1,noSuggestionNotice:'No results',orientation:'bottom',forceFixPosition:!1};that.element=el;that.el=$(el);that.suggestions=[];that.badQueries=[];that.selectedIndex=-1;that.currentValue=that.element.value;that.intervalId=0;that.cachedResponse={};that.onChangeInterval=null;that.onChange=null;that.isLocal=!1;that.suggestionsContainer=null;that.noSuggestionsContainer=null;that.options=$.extend({},defaults,options);that.classes={selected:'autocomplete-selected',suggestion:'autocomplete-suggestion'};that.hint=null;that.hintValue='';that.selection=null;that.initialize();that.setOptions(options);}Autocomplete.utils=utils;$.Autocomplete=Autocomplete;Autocomplete.formatResult=function(suggestion,currentValue){
if(!currentValue){return suggestion.value;}var pattern='('+utils.escapeRegExChars(currentValue)+')';return suggestion.value.replace(new RegExp(pattern,'gi'),'<strong>$1<\/strong>').replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/&lt;(\/?strong)&gt;/g,'<$1>');};Autocomplete.prototype={killerFn:null,initialize:function(){var that=this,suggestionSelector='.'+that.classes.suggestion,selected=that.classes.selected,options=that.options,container;that.element.setAttribute('autocomplete','off');that.killerFn=function(e){if($(e.target).closest('.'+that.options.containerClass).length===0){that.killSuggestions();that.disableKillerFn();}};that.noSuggestionsContainer=$('<div class="autocomplete-no-suggestion"></div>').html(this.options.noSuggestionNotice).get(0);that.suggestionsContainer=Autocomplete.utils.createNode(options.containerClass);container=$(that.suggestionsContainer);container.appendTo(options.appendTo);if(options.width!=='auto'){container
.width(options.width);}container.on('mouseover.autocomplete',suggestionSelector,function(){that.activate($(this).data('index'));});container.on('mouseout.autocomplete',function(){that.selectedIndex=-1;container.children('.'+selected).removeClass(selected);});container.on('click.autocomplete',suggestionSelector,function(){that.select($(this).data('index'));});that.fixPositionCapture=function(){if(that.visible){that.fixPosition();}};$(window).on('resize.autocomplete',that.fixPositionCapture);that.el.on('keydown.autocomplete',function(e){that.onKeyPress(e);});that.el.on('keyup.autocomplete',function(e){that.onKeyUp(e);});that.el.on('blur.autocomplete',function(){that.onBlur();});that.el.on('focus.autocomplete',function(){that.onFocus();});that.el.on('change.autocomplete',function(e){that.onKeyUp(e);});that.el.on('input.autocomplete',function(e){that.onKeyUp(e);});},onFocus:function(){var that=this;that.fixPosition();if(that.el.val().length>=that.options.minChars){that.onValueChange();}},
onBlur:function(){this.enableKillerFn();},abortAjax:function(){var that=this;if(that.currentRequest){that.currentRequest.abort();that.currentRequest=null;}},setOptions:function(suppliedOptions){var that=this,options=that.options;$.extend(options,suppliedOptions);that.isLocal=$.isArray(options.lookup);if(that.isLocal){options.lookup=that.verifySuggestionsFormat(options.lookup);}options.orientation=that.validateOrientation(options.orientation,'bottom');$(that.suggestionsContainer).css({'max-height':options.maxHeight+'px','width':options.width+'px','z-index':options.zIndex});},clearCache:function(){this.cachedResponse={};this.badQueries=[];},clear:function(){this.clearCache();this.currentValue='';this.suggestions=[];},disable:function(){var that=this;that.disabled=!0;clearInterval(that.onChangeInterval);that.abortAjax();},enable:function(){this.disabled=!1;},fixPosition:function(){var that=this,$container=$(that.suggestionsContainer),containerParent=$container.parent().get(0);if(
containerParent!==document.body&&!that.options.forceFixPosition){return;}var orientation=that.options.orientation,containerHeight=$container.outerHeight(),height=that.el.outerHeight(),offset=that.el.offset(),styles={'top':offset.top,'left':offset.left};if(orientation==='auto'){var viewPortHeight=$(window).height(),scrollTop=$(window).scrollTop(),topOverflow=-scrollTop+offset.top-containerHeight,bottomOverflow=scrollTop+viewPortHeight-(offset.top+height+containerHeight);orientation=(Math.max(topOverflow,bottomOverflow)===topOverflow)?'top':'bottom';}if(orientation==='top'){styles.top+=-containerHeight;}else{styles.top+=height;}if(containerParent!==document.body){var opacity=$container.css('opacity'),parentOffsetDiff;if(!that.visible){$container.css('opacity',0).show();}parentOffsetDiff=$container.offsetParent().offset();styles.top-=parentOffsetDiff.top;styles.left-=parentOffsetDiff.left;if(!that.visible){$container.css('opacity',opacity).hide();}}if(that.options.width==='auto'){styles.
width=(that.el.outerWidth()-2)+'px';}$container.css(styles);},enableKillerFn:function(){var that=this;$(document).on('click.autocomplete',that.killerFn);},disableKillerFn:function(){var that=this;$(document).off('click.autocomplete',that.killerFn);},killSuggestions:function(){var that=this;that.stopKillSuggestions();that.intervalId=window.setInterval(function(){if(that.visible){that.el.val(that.currentValue);that.hide();}that.stopKillSuggestions();},50);},stopKillSuggestions:function(){window.clearInterval(this.intervalId);},isCursorAtEnd:function(){var that=this,valLength=that.el.val().length,selectionStart=that.element.selectionStart,range;if(typeof selectionStart==='number'){return selectionStart===valLength;}if(document.selection){range=document.selection.createRange();range.moveStart('character',-valLength);return valLength===range.text.length;}return true;},onKeyPress:function(e){var that=this;if(!that.disabled&&!that.visible&&e.which===keys.DOWN&&that.currentValue){that.suggest(
);return;}if(that.disabled||!that.visible){return;}switch(e.which){case keys.ESC:that.el.val(that.currentValue);that.hide();break;case keys.RIGHT:if(that.hint&&that.options.onHint&&that.isCursorAtEnd()){that.selectHint();break;}return;case keys.TAB:if(that.hint&&that.options.onHint){that.selectHint();return;}if(that.selectedIndex===-1){that.hide();return;}that.select(that.selectedIndex);if(that.options.tabDisabled===false){return;}break;case keys.RETURN:if(that.selectedIndex===-1){that.hide();return;}that.select(that.selectedIndex);break;case keys.UP:that.moveUp();break;case keys.DOWN:that.moveDown();break;default:return;}e.stopImmediatePropagation();e.preventDefault();},onKeyUp:function(e){var that=this;if(that.disabled){return;}switch(e.which){case keys.UP:case keys.DOWN:return;}clearInterval(that.onChangeInterval);if(that.currentValue!==that.el.val()){that.findBestHint();if(that.options.deferRequestBy>0){that.onChangeInterval=setInterval(function(){that.onValueChange();},that.
options.deferRequestBy);}else{that.onValueChange();}}},onValueChange:function(){var that=this,options=that.options,value=that.el.val(),query=that.getQuery(value);if(that.selection&&that.currentValue!==query){that.selection=null;(options.onInvalidateSelection||$.noop).call(that.element);}clearInterval(that.onChangeInterval);that.currentValue=value;that.selectedIndex=-1;if(options.triggerSelectOnValidInput&&that.isExactMatch(query)){that.select(0);return;}if(query.length<options.minChars){that.hide();}else{that.getSuggestions(query);}},isExactMatch:function(query){var suggestions=this.suggestions;return(suggestions.length===1&&suggestions[0].value.toLowerCase()===query.toLowerCase());},getQuery:function(value){var delimiter=this.options.delimiter,parts;if(!delimiter){return value;}parts=value.split(delimiter);return $.trim(parts[parts.length-1]);},getSuggestionsLocal:function(query){var that=this,options=that.options,queryLowerCase=query.toLowerCase(),filter=options.lookupFilter,limit=
parseInt(options.lookupLimit,10),data;data={suggestions:$.grep(options.lookup,function(suggestion){return filter(suggestion,query,queryLowerCase);})};if(limit&&data.suggestions.length>limit){data.suggestions=data.suggestions.slice(0,limit);}return data;},getSuggestions:function(q){var response,that=this,options=that.options,serviceUrl=options.serviceUrl,params,cacheKey,ajaxSettings;options.params[options.paramName]=q;params=options.ignoreParams?null:options.params;if(options.onSearchStart.call(that.element,options.params)===false){return;}if($.isFunction(options.lookup)){options.lookup(q,function(data){that.suggestions=data.suggestions;that.suggest();options.onSearchComplete.call(that.element,q,data.suggestions);});return;}if(that.isLocal){response=that.getSuggestionsLocal(q);}else{if($.isFunction(serviceUrl)){serviceUrl=serviceUrl.call(that.element,q);}cacheKey=serviceUrl+'?'+$.param(params||{});response=that.cachedResponse[cacheKey];}if(response&&$.isArray(response.suggestions)){that
.suggestions=response.suggestions;that.suggest();options.onSearchComplete.call(that.element,q,response.suggestions);}else if(!that.isBadQuery(q)){that.abortAjax();ajaxSettings={url:serviceUrl,data:params,type:options.type,dataType:options.dataType};$.extend(ajaxSettings,options.ajaxSettings);that.currentRequest=$.ajax(ajaxSettings).done(function(data){var result;that.currentRequest=null;result=options.transformResult(data,q);that.processResponse(result,q,cacheKey);options.onSearchComplete.call(that.element,q,result.suggestions);}).fail(function(jqXHR,textStatus,errorThrown){options.onSearchError.call(that.element,q,jqXHR,textStatus,errorThrown);});}else{options.onSearchComplete.call(that.element,q,[]);}},isBadQuery:function(q){if(!this.options.preventBadQueries){return false;}var badQueries=this.badQueries,i=badQueries.length;while(i--){if(q.indexOf(badQueries[i])===0){return true;}}return false;},hide:function(){var that=this,container=$(that.suggestionsContainer);if($.isFunction(that
.options.onHide)&&that.visible){that.options.onHide.call(that.element,container);}that.visible=!1;that.selectedIndex=-1;clearInterval(that.onChangeInterval);$(that.suggestionsContainer).hide();that.signalHint(null);},suggest:function(){if(this.suggestions.length===0){if(this.options.showNoSuggestionNotice){this.noSuggestions();}else{this.hide();}return;}var that=this,options=that.options,groupBy=options.groupBy,formatResult=options.formatResult,value=that.getQuery(that.currentValue),className=that.classes.suggestion,classSelected=that.classes.selected,container=$(that.suggestionsContainer),noSuggestionsContainer=$(that.noSuggestionsContainer),beforeRender=options.beforeRender,html='',category,formatGroup=function(suggestion,index){var currentCategory=suggestion.data[groupBy];if(category===currentCategory){return'';}category=currentCategory;return'<div class="autocomplete-group"><strong>'+category+'</strong></div>';};if(options.triggerSelectOnValidInput&&that.isExactMatch(value)){
that.select(0);return;}$.each(that.suggestions,function(i,suggestion){if(groupBy){html+=formatGroup(suggestion,value,i);}html+='<div class="'+className+'" data-index="'+i+'">'+formatResult(suggestion,value)+'</div>';});this.adjustContainerWidth();noSuggestionsContainer.detach();container.html(html);if($.isFunction(beforeRender)){beforeRender.call(that.element,container);}that.fixPosition();container.show();if(options.autoSelectFirst){that.selectedIndex=0;container.scrollTop(0);container.children('.'+className).first().addClass(classSelected);}that.visible=!0;that.findBestHint();},noSuggestions:function(){var that=this,container=$(that.suggestionsContainer),noSuggestionsContainer=$(that.noSuggestionsContainer);this.adjustContainerWidth();noSuggestionsContainer.detach();container.empty();container.append(noSuggestionsContainer);that.fixPosition();container.show();that.visible=!0;},adjustContainerWidth:function(){var that=this,options=that.options,width,container=$(that.
suggestionsContainer);if(options.width==='auto'){width=that.el.outerWidth()-2;container.width(width>0?width:300);}},findBestHint:function(){var that=this,value=that.el.val().toLowerCase(),bestMatch=null;if(!value){return;}$.each(that.suggestions,function(i,suggestion){var foundMatch=suggestion.value.toLowerCase().indexOf(value)===0;if(foundMatch){bestMatch=suggestion;}return!foundMatch;});that.signalHint(bestMatch);},signalHint:function(suggestion){var hintValue='',that=this;if(suggestion){hintValue=that.currentValue+suggestion.value.substr(that.currentValue.length);}if(that.hintValue!==hintValue){that.hintValue=hintValue;that.hint=suggestion;(this.options.onHint||$.noop)(hintValue);}},verifySuggestionsFormat:function(suggestions){if(suggestions.length&&typeof suggestions[0]==='string'){return $.map(suggestions,function(value){return{value:value,data:null};});}return suggestions;},validateOrientation:function(orientation,fallback){orientation=$.trim(orientation||'').toLowerCase();if($.
inArray(orientation,['auto','bottom','top'])===-1){orientation=fallback;}return orientation;},processResponse:function(result,originalQuery,cacheKey){var that=this,options=that.options;result.suggestions=that.verifySuggestionsFormat(result.suggestions);if(!options.noCache){that.cachedResponse[cacheKey]=result;if(options.preventBadQueries&&result.suggestions.length===0){that.badQueries.push(originalQuery);}}if(originalQuery!==that.getQuery(that.currentValue)){return;}that.suggestions=result.suggestions;that.suggest();},activate:function(index){var that=this,activeItem,selected=that.classes.selected,container=$(that.suggestionsContainer),children=container.find('.'+that.classes.suggestion);container.find('.'+selected).removeClass(selected);that.selectedIndex=index;if(that.selectedIndex!==-1&&children.length>that.selectedIndex){activeItem=children.get(that.selectedIndex);$(activeItem).addClass(selected);return activeItem;}return null;},selectHint:function(){var that=this,i=$.inArray(that.
hint,that.suggestions);that.select(i);},select:function(i){var that=this;that.hide();that.onSelect(i);},moveUp:function(){var that=this;if(that.selectedIndex===-1){return;}if(that.selectedIndex===0){$(that.suggestionsContainer).children().first().removeClass(that.classes.selected);that.selectedIndex=-1;that.el.val(that.currentValue);that.findBestHint();return;}that.adjustScroll(that.selectedIndex-1);},moveDown:function(){var that=this;if(that.selectedIndex===(that.suggestions.length-1)){return;}that.adjustScroll(that.selectedIndex+1);},adjustScroll:function(index){var that=this,activeItem=that.activate(index);if(!activeItem){return;}var offsetTop,upperBound,lowerBound,heightDelta=$(activeItem).outerHeight();offsetTop=activeItem.offsetTop;upperBound=$(that.suggestionsContainer).scrollTop();lowerBound=upperBound+that.options.maxHeight-heightDelta;if(offsetTop<upperBound){$(that.suggestionsContainer).scrollTop(offsetTop);}else if(offsetTop>lowerBound){$(that.suggestionsContainer).
scrollTop(offsetTop-that.options.maxHeight+heightDelta);}if(!that.options.preserveInput){that.el.val(that.getValue(that.suggestions[index].value));}that.signalHint(null);},onSelect:function(index){var that=this,onSelectCallback=that.options.onSelect,suggestion=that.suggestions[index];that.currentValue=that.getValue(suggestion.value);if(that.currentValue!==that.el.val()&&!that.options.preserveInput){that.el.val(that.currentValue);}that.signalHint(null);that.suggestions=[];that.selection=suggestion;if($.isFunction(onSelectCallback)){onSelectCallback.call(that.element,suggestion);}},getValue:function(value){var that=this,delimiter=that.options.delimiter,currentValue,parts;if(!delimiter){return value;}currentValue=that.currentValue;parts=currentValue.split(delimiter);if(parts.length===1){return value;}return currentValue.substr(0,currentValue.length-parts[parts.length-1].length)+value;},dispose:function(){var that=this;that.el.off('.autocomplete').removeData('autocomplete');that.
disableKillerFn();$(window).off('resize.autocomplete',that.fixPositionCapture);$(that.suggestionsContainer).remove();}};function autocomplete(options,args){var dataKey='autocomplete';if(arguments.length===0){return this.first().data(dataKey);}return this.each(function(){var inputElement=$(this),instance=inputElement.data(dataKey);if(typeof options==='string'){if(instance&&typeof instance[options]==='function'){instance[options](args);}}else{if(instance&&instance.dispose){instance.dispose();}instance=new Autocomplete(this,options);inputElement.data(dataKey,instance);}});}return{autocomplete:autocomplete}});;define('Mousetrap',['wikia.window','wikia.document'],function(window,document){var _MAP={8:'backspace',9:'tab',13:'enter',16:'shift',17:'ctrl',18:'alt',20:'capslock',27:'esc',32:'space',33:'pageup',34:'pagedown',35:'end',36:'home',37:'left',38:'up',39:'right',40:'down',45:'ins',46:'del',91:'meta',93:'meta',224:'meta'};var _KEYCODE_MAP={106:'*',107:'+',109:'-',110:'.',111:'/',186:';',
187:'=',188:',',189:'-',190:'.',191:'/',192:'`',219:'[',220:'\\',221:']',222:'\''};var _SHIFT_MAP={'~':'`','!':'1','@':'2','#':'3','$':'4','%':'5','^':'6','&':'7','*':'8','(':'9',')':'0','_':'-','+':'=',':':';','\"':'\'','<':',','>':'.','?':'/','|':'\\'};var _SPECIAL_ALIASES={'option':'alt','command':'meta','return':'enter','escape':'esc','plus':'+','mod':/Mac|iPod|iPhone|iPad/.test(navigator.platform)?'meta':'ctrl'};var _REVERSE_MAP;for(var i=1;i<20;++i){_MAP[111+i]='f'+i;}for(i=0;i<=9;++i){_MAP[i+96]=i;}function _addEvent(object,type,callback){if(object.addEventListener){object.addEventListener(type,callback,false);return;}object.attachEvent('on'+type,callback);}function _characterFromEvent(e){if(e.type=='keypress'){var character=String.fromCharCode(e.which);if(!e.shiftKey){character=character.toLowerCase();}return character;}if(_MAP[e.which]){return _MAP[e.which];}if(_KEYCODE_MAP[e.which]){return _KEYCODE_MAP[e.which];}return String.fromCharCode(e.which).toLowerCase();}function
_modifiersMatch(modifiers1,modifiers2){return modifiers1.sort().join(',')===modifiers2.sort().join(',');}function _eventModifiers(e){var modifiers=[];if(e.shiftKey){modifiers.push('shift');}if(e.altKey){modifiers.push('alt');}if(e.ctrlKey){modifiers.push('ctrl');}if(e.metaKey){modifiers.push('meta');}return modifiers;}function _preventDefault(e){if(e.preventDefault){e.preventDefault();return;}e.returnValue=!1;}function _stopPropagation(e){if(e.stopPropagation){e.stopPropagation();return;}e.cancelBubble=!0;}function _isModifier(key){return key=='shift'||key=='ctrl'||key=='alt'||key=='meta';}function _getReverseMap(){if(!_REVERSE_MAP){_REVERSE_MAP={};for(var key in _MAP){if(key>95&&key<112){continue;}if(_MAP.hasOwnProperty(key)){_REVERSE_MAP[_MAP[key]]=key;}}}return _REVERSE_MAP;}function _pickBestAction(key,modifiers,action){if(!action){action=_getReverseMap()[key]?'keydown':'keypress';}if(action=='keypress'&&modifiers.length){action='keydown';}return action;}function
_keysFromString(combination){if(combination==='+'){return['+'];}combination=combination.replace(/\+{2}/g,'+plus');return combination.split('+');}function _getKeyInfo(combination,action){var keys;var key;var i;var modifiers=[];keys=_keysFromString(combination);for(i=0;i<keys.length;++i){key=keys[i];if(_SPECIAL_ALIASES[key]){key=_SPECIAL_ALIASES[key];}if(action&&action!='keypress'&&_SHIFT_MAP[key]){key=_SHIFT_MAP[key];modifiers.push('shift');}if(_isModifier(key)){modifiers.push(key);}}action=_pickBestAction(key,modifiers,action);return{key:key,modifiers:modifiers,action:action};}function _belongsTo(element,ancestor){if(element===null||element===document){return false;}if(element===ancestor){return true;}return _belongsTo(element.parentNode,ancestor);}function Mousetrap(targetElement){var self=this;targetElement=targetElement||document;if(!(self instanceof Mousetrap)){return new Mousetrap(targetElement);}self.target=targetElement;self._callbacks={};self._directMap={};var _sequenceLevels={
};var _resetTimer;var _ignoreNextKeyup=!1;var _ignoreNextKeypress=!1;var _nextExpectedAction=!1;function _resetSequences(doNotReset){doNotReset=doNotReset||{};var activeSequences=!1,key;for(key in _sequenceLevels){if(doNotReset[key]){activeSequences=!0;continue;}_sequenceLevels[key]=0;}if(!activeSequences){_nextExpectedAction=!1;}}function _getMatches(character,modifiers,e,sequenceName,combination,level){var i;var callback;var matches=[];var action=e.type;if(!self._callbacks[character]){return[];}if(action=='keyup'&&_isModifier(character)){modifiers=[character];}for(i=0;i<self._callbacks[character].length;++i){callback=self._callbacks[character][i];if(!sequenceName&&callback.seq&&_sequenceLevels[callback.seq]!=callback.level){continue;}if(action!=callback.action){continue;}if((action=='keypress'&&!e.metaKey&&!e.ctrlKey)||_modifiersMatch(modifiers,callback.modifiers)){var deleteCombo=!sequenceName&&callback.combo==combination;var deleteSequence=sequenceName&&callback.
seq==sequenceName&&callback.level==level;if(deleteCombo||deleteSequence){self._callbacks[character].splice(i,1);}matches.push(callback);}}return matches;}function _fireCallback(callback,e,combo,sequence){if(self.stopCallback(e,e.target||e.srcElement,combo,sequence)){return;}if(callback(e,combo)===false){_preventDefault(e);_stopPropagation(e);}}self._handleKey=function(character,modifiers,e){var callbacks=_getMatches(character,modifiers,e);var i;var doNotReset={};var maxLevel=0;var processedSequenceCallback=!1;for(i=0;i<callbacks.length;++i){if(callbacks[i].seq){maxLevel=Math.max(maxLevel,callbacks[i].level);}}for(i=0;i<callbacks.length;++i){if(callbacks[i].seq){if(callbacks[i].level!=maxLevel){continue;}processedSequenceCallback=!0;doNotReset[callbacks[i].seq]=1;_fireCallback(callbacks[i].callback,e,callbacks[i].combo,callbacks[i].seq);continue;}if(!processedSequenceCallback){_fireCallback(callbacks[i].callback,e,callbacks[i].combo);}}var ignoreThisKeypress=e.type=='keypress'&&
_ignoreNextKeypress;if(e.type==_nextExpectedAction&&!_isModifier(character)&&!ignoreThisKeypress){_resetSequences(doNotReset);}_ignoreNextKeypress=processedSequenceCallback&&e.type=='keydown';};function _handleKeyEvent(e){if(typeof e.which!=='number'){e.which=e.keyCode;}var character=_characterFromEvent(e);if(!character){return;}if(e.type=='keyup'&&_ignoreNextKeyup===character){_ignoreNextKeyup=!1;return;}self.handleKey(character,_eventModifiers(e),e);}function _resetSequenceTimer(){clearTimeout(_resetTimer);_resetTimer=setTimeout(_resetSequences,1000);}function _bindSequence(combo,keys,callback,action){_sequenceLevels[combo]=0;function _increaseSequence(nextAction){return function(){_nextExpectedAction=nextAction;++_sequenceLevels[combo];_resetSequenceTimer();};}function _callbackAndReset(e){_fireCallback(callback,e,combo);if(action!=='keyup'){_ignoreNextKeyup=_characterFromEvent(e);}setTimeout(_resetSequences,10);}for(var i=0;i<keys.length;++i){var isFinal=i+1===keys.length;var
wrappedCallback=isFinal?_callbackAndReset:_increaseSequence(action||_getKeyInfo(keys[i+1]).action);_bindSingle(keys[i],wrappedCallback,action,combo,i);}}function _bindSingle(combination,callback,action,sequenceName,level){self._directMap[combination+':'+action]=callback;combination=combination.replace(/\s+/g,' ');var sequence=combination.split(' ');var info;if(sequence.length>1){_bindSequence(combination,sequence,callback,action);return;}info=_getKeyInfo(combination,action);self._callbacks[info.key]=self._callbacks[info.key]||[];_getMatches(info.key,info.modifiers,{type:info.action},sequenceName,combination,level);self._callbacks[info.key][sequenceName?'unshift':'push']({callback:callback,modifiers:info.modifiers,action:info.action,seq:sequenceName,level:level,combo:combination});}self._bindMultiple=function(combinations,callback,action){for(var i=0;i<combinations.length;++i){_bindSingle(combinations[i],callback,action);}};_addEvent(targetElement,'keypress',_handleKeyEvent);_addEvent(
targetElement,'keydown',_handleKeyEvent);_addEvent(targetElement,'keyup',_handleKeyEvent);}Mousetrap.prototype.bind=function(keys,callback,action){var self=this;keys=keys instanceof Array?keys:[keys];self._bindMultiple.call(self,keys,callback,action);return self;};Mousetrap.prototype.unbind=function(keys,action){var self=this;return self.bind.call(self,keys,function(){},action);};Mousetrap.prototype.trigger=function(keys,action){var self=this;if(self._directMap[keys+':'+action]){self._directMap[keys+':'+action]({},keys);}return self;};Mousetrap.prototype.reset=function(){var self=this;self._callbacks={};self._directMap={};return self;};Mousetrap.prototype.stopCallback=function(e,element){var self=this;if((' '+element.className+' ').indexOf(' mousetrap ')>-1){return false;}if(_belongsTo(element,self.target)){return false;}return element.tagName=='INPUT'||element.tagName=='SELECT'||element.tagName=='TEXTAREA'||element.isContentEditable;};Mousetrap.prototype.handleKey=function(){var self=
this;return self._handleKey.apply(self,arguments);};Mousetrap.init=function(){var documentMousetrap=Mousetrap(document);for(var method in documentMousetrap){if(method.charAt(0)!=='_'){Mousetrap[method]=(function(method){return function(){return documentMousetrap[method].apply(documentMousetrap,arguments);};}(method));}}};Mousetrap.init();return Mousetrap;});;define('PageActions',['mw','jquery','wikia.log','wikia.window'],function(mw,$,log,context){'use strict';var CATEGORY_WEIGHTS={},categoryOtherName=mw.message('global-shortcuts-category-other').escaped(),all=[],byId={};CATEGORY_WEIGHTS[mw.message('global-shortcuts-category-current-page').escaped()]=10;CATEGORY_WEIGHTS[mw.message('global-shortcuts-category-current-wikia').escaped()]=20;CATEGORY_WEIGHTS[categoryOtherName]=1000;function PageAction(id,caption,fn,category,weight){this.id=id;this.caption='';this.fn=$.noop;this.category=categoryOtherName;this.categoryWeight=this._calculateCategoryWeight();this.weight=500;this.update({
caption:caption,fn:fn,category:category||categoryOtherName,weight:weight||500});}PageAction.prototype.update=function(key,value){if(typeof key!=='string'){Object.keys(key).forEach(function(k){this.update(k,key[k]);}.bind(this));return;}if(!value){return;}if(key==='caption'){this.caption=value;}else if(key==='fn'){this.fn=value;}else if(key==='category'){this.category=value;this.categoryWeight=this._calculateCategoryWeight();}else if(key==='weight'){this.weight=value;}else{log('Invalid property for PageAction: '+key,log.levels.warn,'GlobalShortcuts');}};PageAction.prototype.execute=function(){this.fn.call(context);closeModals();};PageAction.prototype._calculateCategoryWeight=function(){if(this.category in CATEGORY_WEIGHTS){return CATEGORY_WEIGHTS[this.category]*1000;}return 100*1000;};function register(pageAction,canReplace){if(!canReplace&&(pageAction.id in byId)){log('Could not register more than one action with the same ID: '+pageAction.id,log.levels.debug,'GlobalShortcuts');return;}
all.push(pageAction);byId[pageAction.id]=pageAction;}function add(desc,canReplace){var id=desc.id.toLowerCase(),caption=desc.caption,category=desc.category,fn,pageAction;if(!id||!caption){log('Invalid action description - missing id and/or caption: '+desc,log.levels.error);}if(desc.href){fn=function(){context.location.href=desc.href;};}if(desc.fn){fn=desc.fn;}if(!fn){log('Invalid action description - missing action specifier: '+desc,log.levels.error);}pageAction=new PageAction(id,caption,fn,category,desc.weight);register(pageAction,canReplace);}function find(id){return byId[id.toLowerCase()];}function sortList(pageActions){var items=pageActions.map(function(pageAction){return[[pageAction.categoryWeight,pageAction.category,pageAction.weight,pageAction.caption],pageAction];});items.sort(function(a,b){for(var i=0;i<a[0].length;i++){if(a[0][i]<b[0][i]){return-1;}else if(a[0][i]>b[0][i]){return 1;}}return 0;});return items.map(function(item){return item[1];});}function closeModals(){var
modals=$('.modal-blackout');if(modals.length){modals.remove();}}(context.wgWikiaPageActions||[]).forEach(function(actionDesc){add(actionDesc);});return{all:all,add:add,find:find,sortList:sortList};});require(['jquery','GlobalShortcuts'],function($,gs){'use strict';$(gs);});;define('GlobalShortcuts',['Mousetrap','mw','PageActions','GlobalShortcutsTracking','wikia.log'],function(Mousetrap,mw,PageActions,tracker,log){'use strict';var all={},wgWikiaShortcutKeys=mw.config.get('wgWikiaShortcutKeys');function initShortcut(actionId,key){Mousetrap.bind(key,function(){tracker.trackKey(actionId);PageActions.find(actionId).execute();return false;});}function add(actionId,key){if(!PageActions.find(actionId)){log('Unknown action: '+actionId,log.levels.error,'GlobalShortcuts');return;}var current=(actionId in all)?all[actionId]:[];if(current.indexOf(key)===-1){current.push(key);all[actionId]=current;initShortcut(actionId,key);}}function find(actionId){return(actionId in all)?all[actionId]:[];}
function init(){Object.keys(wgWikiaShortcutKeys).forEach(function(id){wgWikiaShortcutKeys[id].forEach(function(key){add(id,key);});});}init();return{all:all,add:add,find:find};});;define('GlobalShortcutsHelp',['mw','wikia.nirvana','wikia.mustache','GlobalShortcuts','PageActions','GlobalShortcutsTracking'],function(mw,nirvana,mustache,GlobalShortcuts,PageActions,tracker){'use strict';var modalConfig,templates={};function open(){tracker.trackClick('help:Keyboard');$.when(loadTemplates()).done(handleRequestsForModal);}function loadTemplates(){return templates.keyCombination||$.Deferred(function(dfd){Wikia.getMultiTypePackage({mustache:'extensions/wikia/GlobalShortcuts/templates/KeyCombination.mustache,'+'extensions/wikia/GlobalShortcuts/templates/GlobalShortcutsController_help.mustache',messages:'GlobalShortcuts',callback:function(pkg){templates.keyCombination=pkg.mustache[0];templates.help=pkg.mustache[1];dfd.resolve(templates);}});return dfd.promise();});}function handleRequestsForModal
(){var data=prepareData();setupModal(mustache.render(templates.help,{actions:data}));require(['wikia.ui.factory'],function(uiFactory){$.when(uiFactory.init(['modal']),mw.loader.using(['mediawiki.jqueryMsg'])).then(createComponent);});}function prepareData(){var data=[],i=0;for(var id in GlobalShortcuts.all){data[i]={keyCombination:parseShortcut(GlobalShortcuts.all[id]),label:PageActions.find(id).caption};i++;}return data;}function parseShortcut(combos){var comboNum=0,combosCount,keyCombination=[],keyCombinationHtml,keysCount,templateParams;combosCount=combos.length;for(var id in combos){keyCombination[id]={combo:combos[id].split(' ')};keysCount=keyCombination[id].combo.length;for(var j=0;j<keysCount;j++){keyCombination[id].combo[j]={'key':keyCombination[id].combo[j],'space':j<keysCount-1?1:0};}keyCombination[id].combo[j-1].or=comboNum<combosCount-1?1:0;comboNum++;}templateParams={keyCombination:keyCombination,orMsg:mw.message('global-shortcuts-key-or').plain(),thenMsg:mw.message(
'global-shortcuts-key-then').plain()};keyCombinationHtml=mustache.render(templates.keyCombination,templateParams);return keyCombinationHtml;}function createComponent(uiModal){uiModal.createComponent(modalConfig,processInstance);}function processInstance(modalInstance){var dotKey='<span class="key">.</span>';modalInstance.show();modalInstance.$element.find('footer').html(mw.message('global-shortcuts-press-to-explore-shortcuts',dotKey).parse());}function setupModal(content){modalConfig={vars:{id:'GlobalShortcutsHelp',classes:['global-shortcuts-help'],size:'medium',content:content,title:mw.message('global-shortcuts-title-keyboard-shortcuts').escaped()}};}return{open:open};});;require(['GlobalShortcutsHelp'],function(gs){'use strict';function init(){$('.global-shortcuts-help-entry-point').on('click',gs.open);}$(init);});;define('GlobalShortcutsSuggestions',['mw','wikia.nirvana','PageActions','GlobalShortcuts','GlobalShortcuts.RenderKeys','GlobalShortcutsTracking'],function(mw,nirvana,
PageActions,GlobalShortcuts,RenderKeys,tracker){'use strict';function GlobalShortcutsSuggestions($el,closeCb){var deferred=jQuery.Deferred();this.$el=$el;this.closeCb=closeCb;require(['devbridge.autocomplete'],function(Autocomplete){$.fn.suggestionsAutocomplete=Autocomplete.autocomplete;this.init().done(function(){deferred.resolve();});}.bind(this));return deferred.promise();}GlobalShortcutsSuggestions.prototype.close=function(){this.closeCb&&this.closeCb();};GlobalShortcutsSuggestions.prototype.suggestionsAsync=function(){return RenderKeys.loadTemplates().then(function(){var ret=[];PageActions.sortList(PageActions.all).forEach(function(pageAction){var shortcuts=GlobalShortcuts.find(pageAction.id);ret.push({value:pageAction.caption,data:{actionId:pageAction.id,shortcuts:shortcuts,html:RenderKeys.getHtml(shortcuts),category:pageAction.category}});});return ret;});};GlobalShortcutsSuggestions.prototype.init=function(){var autocompleteReEscape=new RegExp('(\\'+['/','.','*','+','?','|','('
,')','[',']','{','}','\\'].join('|\\')+')','gi');return this.suggestionsAsync().done(function(suggestions){this.$el.suggestionsAutocomplete({lookup:suggestions,onSelect:function(suggestion){var actionId=suggestion.data.actionId;this.close();tracker.trackClick(actionId);PageActions.find(actionId).execute();}.bind(this),groupBy:'category',appendTo:this.$el.parent().next(),maxHeight:320,minChars:0,selectedClass:'selected',width:'100%',preserveInput:!0,formatResult:function(suggestion,currentValue){var out='',pattern='('+currentValue.replace(autocompleteReEscape,'\\$1')+')';out+='<span class="label-in-suggestions">'+suggestion.value.replace(new RegExp(pattern,'gi'),'<strong>$1<\/strong>')+'</span>';if(suggestion.data.shortcuts){out+=suggestion.data.html;}return out;}.bind(this),skipBadQueries:!0,autoSelectFirst:!0});}.bind(this));};return GlobalShortcutsSuggestions;});;define('GlobalShortcutsSearch',['mw','wikia.loader','wikia.nirvana','wikia.throbber','GlobalShortcutsSuggestions'],
function(mw,loader,nirvana,throbber,GlobalShortcutsSuggestions){'use strict';function Init(){var modalConfig,suggestions;function open(){throbber.cover();$.when(loader({type:loader.MULTI,resources:{messages:'GlobalShortcuts'}})).done(function(res){mw.messages.set(res.messages);processOpen();});}function processOpen(){var html=['<div class="full-width global-shortcuts-field-wrapper">','<input type="text" placeholder="'+mw.message('global-shortcuts-search-placeholder').escaped()+'" id="global_shortcuts_search_field" />','</div>','<div class="full-width global-shortcuts-autocomplete-wrapper">','</div>'].join('');setupModalConfig(html);require(['wikia.ui.factory'],function(uiFactory){uiFactory.init(['modal']).then(createComponent);});}function createComponent(uiModal){uiModal.createComponent(modalConfig,processInstance);}function processInstance(modalInstance){var $searchField=$('#global_shortcuts_search_field');suggestions=new GlobalShortcutsSuggestions($searchField,function(){
modalInstance.trigger('close');}).done(function(){modalInstance.show();throbber.uncover();$searchField.focus();});}function setupModalConfig(content){modalConfig={vars:{id:'GlobalShortcutsSearch',classes:['global-shortcuts-search'],size:'medium',content:content,title:'Action explorer'}};}return{open:open};}return Init;});;define('GlobalShortcuts.RenderKeys',['mw','wikia.nirvana','wikia.mustache'],function(mw,nirvana,mustache){'use strict';var templates={},orSeparator={or:1};function loadTemplates(){return $.Deferred(function(dfd){if(templates.keyCombination){dfd.resolve(templates);return dfd.promise();}Wikia.getMultiTypePackage({mustache:'extensions/wikia/GlobalShortcuts/templates/KeyCombination2.mustache',messages:'GlobalShortcuts',callback:function(pkg){templates.keyCombination=pkg.mustache[0];dfd.resolve(templates);}});return dfd.promise();});}function insertBetween(arr,elem){var len=arr.length,newArr=[];for(var i=0;i<len;i++){newArr.push(arr[i]);if(i<len-1){newArr.push(elem);}}
return newArr;}function getHtml(keyCombinations){if(!templates.keyCombination){throw new Error('Required template is not loaded yet. '+'Please call loadTemplates method before and wait for resolution.');}var data;keyCombinations=keyCombinations.map(wrapToArr);data=insertBetween(keyCombinations,orSeparator);data=splitCombosBySpace(data);data=splitCombosByPlus(data);data=wrapCombos(data);for(var key in data){if(data[key].combo[0]){data[key].combo=data[key].combo.map(function(key){switch(key){case' ':return{space:1};case'+':return{plus:1};default:return{key:key};}});}}return mustache.render(templates.keyCombination,{keyCombination:data,class:'key-combination-in-suggestions',orMsg:mw.message('global-shortcuts-key-or').plain(),thenMsg:mw.message('global-shortcuts-key-then').plain()});}function wrapToArr(item){return[].concat(item);}function splitCombosBySpace(keyCombinations){var comboBySpaceAndPlus=[];keyCombinations.forEach(function(keys,ind){if(!keys[0]){comboBySpaceAndPlus[ind]=keys;
return;}comboBySpaceAndPlus[ind]=keys.map(splitComboBySpaceMap);});comboBySpaceAndPlus=flattenOneLevNest(comboBySpaceAndPlus);return comboBySpaceAndPlus;}function splitComboBySpaceMap(singleCombo){return insertBetween(singleCombo.split(' '),' ');}function splitCombosByPlus(keyCombinations){var comboBySpaceAndPlus=[];keyCombinations.forEach(function(keys,ind){if(!keys[0]){comboBySpaceAndPlus[ind]=keys;return;}comboBySpaceAndPlus[ind]=keys.map(splitComboByPlusMap);});comboBySpaceAndPlus=flattenOneLevNest(comboBySpaceAndPlus);return comboBySpaceAndPlus;}function splitComboByPlusMap(singleCombo){return insertBetween(singleCombo.split('+'),'+');}function wrapCombos(combos){return combos.map(wrapCombo);}function wrapCombo(combo){return{combo:combo};}function flattenOneLevNest(arr){return arr.concat.apply([],arr);}return{getHtml:getHtml,loadTemplates:loadTemplates};});;require(['GlobalShortcuts','PageActions','mw','wikia.loader','wikia.window'],function(GlobalShortcuts,PageActions,mw,loader,
win){'use strict';function init(){$.when(loader({type:loader.MULTI,resources:{messages:'GlobalShortcuts'}})).done(function(res){mw.messages.set(res.messages);addShortcuts();win.wgGlobalShortcutsLoaded=!0;});}function addShortcuts(){var INITIAL_SHORTCUTS={'general:StartWikia':{shortcuts:[],actionParams:{id:'general:StartWikia',caption:mw.message('global-shortcuts-caption-start-a-new-wikia').plain(),fn:function(){$('[data-id=start-wikia]')[0].click();},category:mw.message('global-shortcuts-category-global').escaped()}},'help:Actions':{shortcuts:['.'],actionParams:{id:'help:Actions',caption:mw.message('global-shortcuts-caption-action-list').plain(),fn:function(){require(['GlobalShortcutsSearch'],function(GlobalShortcutsSearch){var searchModal=new GlobalShortcutsSearch();searchModal.open();});},category:mw.message('global-shortcuts-category-help').escaped()}},'help:Keyboard':{shortcuts:['?'],actionParams:{id:'help:Keyboard',caption:mw.message(
'global-shortcuts-caption-keyboard-shortcuts-help').plain(),fn:function(){require(['GlobalShortcutsHelp'],function(help){help.open();});},category:mw.message('global-shortcuts-category-help').escaped()}},'wikia:Search':{shortcuts:['g s','/'],actionParams:{id:'wikia:Search',caption:mw.message('global-shortcuts-caption-search-for-a-page').plain(),fn:function(){$('.wds-global-navigation__search-toggle')[0].click();},category:mw.message('global-shortcuts-category-current-wikia').escaped()}}};Object.keys(INITIAL_SHORTCUTS).forEach(function(actionId){PageActions.add(INITIAL_SHORTCUTS[actionId].actionParams);INITIAL_SHORTCUTS[actionId].shortcuts.forEach(function(key){GlobalShortcuts.add(actionId,key);});});}init();});;define('GlobalShortcutsTracking',['wikia.tracker'],function(tracker){'use strict';var track=Wikia.Tracker.buildTrackingFunction({category:'global-shortcuts',trackingMethod:'analytics',action:tracker.ACTIONS.KEYPRESS});function trackKey(label){track({label:label});}function
trackClick(label){track({action:tracker.ACTIONS.CLICK,label:label});}return{trackKey:trackKey,trackClick:trackClick}});;