
(function(){'use strict';var utils,DelayedHoverModule;utils={extend:function(dst,src){var p;for(p in src){if(src.hasOwnProperty(p)){dst[p]=src[p];}}
return dst;}};DelayedHoverModule=function(){var getSquaredMoveDistance,eventHandler,mouseEnterHandler,mouseLeaveHandler,mouseMoveHandler,lastLocation,lastCheckedLocation,options,possiblyActivate,timeoutId;options={checkInterval:100,maxActivationDistance:20,onActivate:Function.prototype,onDeactivate:Function.prototype,activateOnClick:true};getSquaredMoveDistance=function(){return(lastCheckedLocation.x-lastLocation.x)*(lastCheckedLocation.x-lastLocation.x)+
(lastCheckedLocation.y-lastLocation.y)*(lastCheckedLocation.y-lastLocation.y);};possiblyActivate=function(){var context=this;if(lastLocation&&getSquaredMoveDistance()<=options.maxSquaredActivationDistance){options.onActivate.apply(context,arguments);}else{if(timeoutId){clearTimeout(timeoutId);}
timeoutId=setTimeout(function(){possiblyActivate.apply(context,arguments);},options.checkInterval);}
if(lastLocation){lastCheckedLocation=lastLocation;}};eventHandler=function(target,event,handler){var i,targetsCount;targetsCount=target.length;if(targetsCount>1){for(i=0;i<targetsCount;i++){target[i].addEventListener(event,handler);}}else{target.addEventListener(event,handler);}};mouseMoveHandler=function(e){lastLocation={x:e.pageX,y:e.pageY};};mouseEnterHandler=function(e){lastCheckedLocation={x:e.pageX,y:e.pageY};lastLocation=null;possiblyActivate.apply(this,arguments);};mouseLeaveHandler=function(){if(timeoutId){clearTimeout(timeoutId);}
options.onDeactivate.apply(this,arguments);};this.init=function(elem,opts){options=utils.extend(options,opts);options.maxSquaredActivationDistance=options.maxActivationDistance*options.maxActivationDistance;if(options.activateOnClick){eventHandler(elem,'click',options.onActivate);}
eventHandler(elem,'mouseenter',mouseEnterHandler);eventHandler(elem,'mouseleave',mouseLeaveHandler);eventHandler(elem,'mousemove',mouseMoveHandler);return this;};};window.delayedHover=function(elem,options){var delayedHover=new DelayedHoverModule();return delayedHover.init(elem,options);};})();;define('wikia.delayedhover',['wikia.window'],function(win){'use strict';function attach(entryPoint,options){win.delayedHover(entryPoint,options);}
return{attach:attach};});;define('wikia.scrollToLink',['wikia.window','wikia.querystring','wikia.history','jquery'],function(win,qs,hist,$){'use strict';function getOffsetTop(element){var offsetTop=$(element).offset().top;return offsetTop|0;}
function scrollToElement(element,offsetToScroll){var targetOffset=getOffsetTop(element);win.setTimeout(function(){win.scrollTo(win.pageXOffset,targetOffset+offsetToScroll);},1);}
function handleScrollTo(href,offsetToScroll){offsetToScroll=offsetToScroll||0;var sanitizedHref=qs().sanitizeHref(href),doc=win.document,target;if(!!sanitizedHref){target=doc.getElementById(sanitizedHref);if(!!target){scrollToElement(target,offsetToScroll);return hist.pushState({},doc.title,win.location.pathname+'#'+sanitizedHref);}}
return false;}
return{handleScrollTo:handleScrollTo,scrollToElement:scrollToElement};});;(function($){'use strict';var TransparentOut=function(){var $domNode,initialize=function(){$domNode=$('<div class="transparent-out" />');$('body').append($domNode);};this.show=function(){if(!$domNode){initialize();}
$domNode.addClass('visible');};this.hide=function(){if($domNode){$domNode.removeClass('visible');}};this.bindClick=function(callback){if(!$domNode){initialize();}
$domNode.on('click touchstart',$.proxy(function(e){e.preventDefault();e.stopPropagation();callback(this);},this));};};window.transparentOut=new TransparentOut();})(jQuery);;define('wikia.globalNavigationDropdowns',['wikia.window','jquery'],function(win,$){'use strict';var registeredDropdowns={},activeDropdown;function openDropdown(event){var $this=$(this),dropdownOpts=registeredDropdowns[this.id];if(activeDropdown&&activeDropdown!==this.id){closeActiveDropdown();}
$this.addClass('active');dropdownOpts.onOpen.call(this,event);win.transparentOut.show();activeDropdown=this.id}
function closeDropdown(){var $this=$(this),dropdownOpts=registeredDropdowns[this.id];closeSelectedDropdown($this,dropdownOpts);}
function closeActiveDropdown(){var $dropdown,dropdownOpts;if(activeDropdown){$dropdown=$(document.getElementById(activeDropdown));dropdownOpts=registeredDropdowns[activeDropdown];closeSelectedDropdown($dropdown,dropdownOpts,true);}}
function closeSelectedDropdown($dropdown,dropdownOpts,forceClose){var onCloseReturnVal;if(dropdownOpts){onCloseReturnVal=dropdownOpts.onClose.call(this);}
if(forceClose||onCloseReturnVal!==false){$dropdown.removeClass('active');win.transparentOut.hide();activeDropdown=false;}}
function toggleDropdown(event){var $target=$(event.target);if($target.closest('.global-nav-dropdown').length>0){return;}
if(activeDropdown){closeActiveDropdown();if(this.id!==activeDropdown){openDropdown.call(this,event);}}else{openDropdown.call(this,event);}}
function attachDropdown($entryPoint,dropdownOpts){var id=$entryPoint.attr('id');registeredDropdowns[id]={onOpen:dropdownOpts.onOpen||Function.prototype,onClose:dropdownOpts.onClose||Function.prototype};if(dropdownOpts.onClick){$entryPoint.on('click',dropdownOpts.onClickTarget,dropdownOpts.onClick);}else{$entryPoint.on('click',toggleDropdown);}}
$(function(){win.transparentOut.bindClick(closeActiveDropdown);});return{openDropdown:openDropdown,closeDropdown:closeDropdown,attachDropdown:attachDropdown};});;define('GlobalNavigationiOSScrollFix',['jquery','wikia.window'],function($,win){'use strict';var cachedScrollY;function scrollToTop($element){cachedScrollY=win.scrollY;$element.addClass('static');setTimeout(function(){win.scrollTo(win.scrollX,0);},0);}
function restoreScrollY($element){$element.removeClass('static');if(cachedScrollY){win.scrollTo(win.scrollX,cachedScrollY);}}
return{scrollToTop:scrollToTop,restoreScrollY:restoreScrollY};});;require(['wikia.scrollToLink','wikia.window','jquery','wikia.browserDetect'],function(scrollToLink,win,$,browserDetect){'use strict';var offset=0;function hashChangeHandler(event){if(scrollToLink.handleScrollTo(win.location.hash,offset)||browserDetect.isIOS7orLower()){event.preventDefault();return false;}}
win.GlobalNavigationScrollToElement=function(element){scrollToLink.scrollToElement(element,offset);};$(function(){var $win=$(win),spacingBelowGlobalNav=10,$globalNavigation=$('#globalNavigation'),globalNavigationHeight=$globalNavigation.height();if(win.location.hash){$globalNavigation.css({top:-1*globalNavigationHeight});$win.on('load',function(){win.setTimeout(function(){win.scrollTo(0,win.scrollY+offset);$globalNavigation.animate({top:0},500);},0);});}
offset=-(globalNavigationHeight+spacingBelowGlobalNav);$win.on('hashchange',hashChangeHandler);});});;$(function($){'use strict';var searchSuggestionsShowed,track,$globalNavigation,$globalNavigationSearch;$globalNavigation=$('#globalNavigation');$globalNavigationSearch=$globalNavigation.find('#searchForm');searchSuggestionsShowed=false;track=Wikia.Tracker.buildTrackingFunction({category:'search',trackingMethod:'analytics',action:Wikia.Tracker.ACTIONS.CLICK});function globalNavigationClickTrackingHandler(event){var $element,label;if(event.type==='mousedown'&&event.which!==1){return;}
$element=$(event.target);label=getLabelByIdentifier($element)||getLabelByDOM($element)||getLabelByDataTrackingLabel($element);if(label!==false){track({category:'top-nav',label:label});}}
function getLabelByDataTrackingLabel($element){return $element.data('tracking-label')||false;}
function getLabelByIdentifier($element){var dataId=$element.data('id')||$element.closest('[data-id]').data('id'),map={'logout':'user-menu-logout','help':'user-menu-help','preferences':'user-menu-preferences','facebook':'facebook','register':'register','start-wikia':'start-a-wiki','wikia-logo':'wikia-logo','mytalk':(function(){return $element.hasClass('message-wall')?'user-menu-message-wall':'user-menu-talk';})()};return map[dataId]||false;}
function getLabelByDOM($element){var label=false,$parent;if($element.closest('.hub-links').length>0||$element.closest('.hub-list').length>0){label='hub-item';}else if($element.closest('.notifications-for-wiki').length>0){$parent=$element.closest('.notifications-for-wiki');if($parent.data('wiki-id')===parseInt(window.wgCityId)){label='notification-item-local';}else{label='notification-item-cross-wiki';}}else if($element.hasClass('login-button')){label='login';}else if($element.closest('.ajaxLogin').attr('accesskey')==='.'){label='user-menu-profile';}
return label;}
function searchSuggestionsClickTrackingHandler(event){if(event.type==='mousedown'&&event.which!==1){return;}
track({browserEvent:event,label:'search-suggest'});}
function searchSubmitButtonClickTrackingHandler(event){if(event.which===1&&event.clientX>0){track({label:!searchSuggestionsShowed?'search-button':'search-after-suggest-button'});}}
function searchSubmitEnterPressTrackingHandler(event){if(event.which===13&&$(event.target).is(':focus')){track({label:!searchSuggestionsShowed?'search-enter':'search-after-suggest-enter'});}}
function searchSuggestionsEnterPressOnSuggestionsTrackingHandler(){track({label:'search-suggest-enter'});}
function searchSuggestionsShowedTrackingHandler(){searchSuggestionsShowed=true;track({action:Wikia.Tracker.ACTIONS.VIEW,label:'search-suggest-show'});}
$globalNavigation.on('mousedown touchstart',globalNavigationClickTrackingHandler);$globalNavigationSearch.on('mousedown touchstart','.autocomplete',searchSuggestionsClickTrackingHandler).on('mousedown touchstart','.search-button',searchSubmitButtonClickTrackingHandler).on('keypress','[name=search]',searchSubmitEnterPressTrackingHandler).on('suggestEnter',searchSuggestionsEnterPressOnSuggestionsTrackingHandler).one('suggestShow',searchSuggestionsShowedTrackingHandler);});;define('wikia.globalnavigation.lazyload',['jquery','wikia.nirvana','wikia.window'],function lazyLoad($,nirvana,win){'use strict';var menuLoading=false,menuLoaded=false;function getMenuItemsDone(menuItems){var $sections=$($.parseHTML(menuItems)).removeClass('active'),$hubs=$('#hubs'),$verticals=$hubs.children('.hub-list'),$hubLinks=$hubs.children('.hub-links'),subMenuSelector='.'+$('.active',$verticals).data('vertical')+'-links';$('> .active',$hubLinks).removeClass('active');$hubLinks.append($sections);$hubLinks.find(subMenuSelector).addClass('active');menuLoading=false;menuLoaded=true;}
function errorHandler(){menuLoading=false;menuLoaded=false;}
function isMenuWorking(){return(menuLoading||menuLoaded);}
function getHubLinks(){var data={cb:win.wgStyleVersion,uselang:win.wgUserLanguage};if(isMenuWorking()){return;}
menuLoading=true;nirvana.sendRequest({controller:'GlobalNavigationController',method:'lazyLoadHubsMenu',format:'html',type:'GET',data:data}).then(getMenuItemsDone,errorHandler);}
return{getHubLinks:getHubLinks,isMenuWorking:isMenuWorking};});;require(['jquery','wikia.browserDetect','GlobalNavigationiOSScrollFix'],function($,browserDetect,scrollFix){'use strict';var $selectElement=$('#searchSelect'),$searchInput=$('#searchInput'),$autocompleteObj;function setFormOptions(){var $selectedOption=$selectElement.find('option:selected'),isLocalSearchDisabled=!$selectElement.length;$searchInput.attr('placeholder',$selectedOption.data('placeholder'));$('#searchForm').attr('action',$selectedOption.attr('data-search-url'));$autocompleteObj=$autocompleteObj||$searchInput.data('autocomplete');if($selectedOption.val()==='global'||isLocalSearchDisabled){setPropertiesOnInput(false);}else{setPropertiesOnInput(true);}}
function setPropertiesOnInput(enable){$('#searchInputResultLang').prop('disabled',enable);if($autocompleteObj){if(enable){$autocompleteObj.enable();}else{$autocompleteObj.disable();}}}
$(function(){var $globalNav=$('#globalNavigation'),$searchForm=$('#searchForm');$searchForm.submit(function(){if(!$searchInput.val()){return false;}})
if($selectElement){setFormOptions();$selectElement.on('change keyup keydown',function(){setFormOptions();});}
if(browserDetect.isIOS7orLower()){$searchInput.on('focus',function(){scrollFix.scrollToTop($globalNav);}).on('blur',function(){scrollFix.restoreScrollY($globalNav);});}});});;$(function(){'use strict';if(!window.wgGoogleSearchTest){return;}
var $wikiaSite=$('.WikiaSiteWrapper'),searchId=window.wgGoogleSearchParam;if($wikiaSite.length===0){return;}
$wikiaSite.before('<gcse:search></gcse:search>');$.loadGoogleSearchAPI(searchId);$('#searchForm').submit(function(evt){var contentLang=window.wgContentLanguage||'en',searchQuery=$('#searchInput').val(),$googleInput=$('.gsc-input'),$googleButton=$('.gsc-search-button'),$selectElement=$('#searchSelect'),$selectedOption=$selectElement.find('option:selected'),currentUrlPath=window.location.pathname,fakeSearchParam='&qInter='+encodeURIComponent(searchQuery);if($selectedOption.val()==='local'){return;}
evt.preventDefault();currentUrlPath+='?q='+encodeURIComponent(searchQuery)+fakeSearchParam;window.guaTrackPageview(currentUrlPath);$googleInput.val(searchQuery);$googleButton.trigger('click');});});;$(function(){'use strict';var SearchSuggestions=(function(){function WikiaSearchApp(id){this.id=id;this.searchForm=$(id);this.searchField=$('#searchInput');this.searchSelect=$('#searchSelect');if(!this.searchForm.hasClass('noautocomplete')){this.searchField.bind({'suggestShow':window.transparentOut.show,'suggestHide':window.transparentOut.hide});this.searchField.one('focus',$.proxy(this.initSuggest,this));if(this.searchField.is(':focus')){this.initSuggest();}}}
WikiaSearchApp.prototype.track=Wikia.Tracker.buildTrackingFunction({trackingMethod:'internal'});function getPositionRightValue(){var width=0;width=parseInt($('.search-container').css('padding-left'),10)+
$('.account-navigation-container').width()+
$('.notifications-container').width();return'-'+width+'px';}
WikiaSearchApp.prototype.initSuggest=function(){var autocompleteReEscape=new RegExp('(\\'+['/','.','*','+','?','|','(',')','[',']','{','}','\\'].join('|\\')+')','g');mw.loader.using('jquery.autocomplete').then($.proxy(function(){this.searchField.autocomplete({serviceUrl:window.wgServer+window.wgScript+'?action=ajax&rs=getLinkSuggest&format=json',onSelect:$.proxy(function(value,data,event){var valueEncoded=encodeURIComponent(value.replace(/ /g,'_')),location=window.wgArticlePath.replace(/\$1/,valueEncoded).replace(encodeURIComponent('/'),'/');this.track({eventName:'search_start_suggest',sterm:valueEncoded,rver:0});if(event.button===1||event.metaKey||event.ctrlKey){window.open(location);return false;}else{window.location.href=location;}},this),appendTo:'.global-nav-search-input-wrapper',deferRequestBy:200,disabled:(this.searchSelect.val()==='global')?true:false,minLength:3,maxHeight:1000,selectedClass:'selected',width:'100%',positionRight:getPositionRightValue(),fnFormatResult:function(value,data,currentValue){var pattern='('+currentValue.replace(autocompleteReEscape,'\\$1')+')';return'<span>'+
value.replace(new RegExp(pattern,'gi'),'<strong>$1<\/strong>')+'</span>';},skipBadQueries:true});},this));};return WikiaSearchApp;})();new SearchSuggestions('#searchForm');});;require(['jquery','wikia.window'],function($,win){'use strict';var $globalNav=$('#globalNavigation'),$topAds=$('#WikiaTopAds');function changeStateOnScroll(){var adSize=$topAds.height(),scrollTop=win.pageYOffset,inverseOffset=50,inversedStateClass='inverse';if(scrollTop<=adSize&&$globalNav.hasClass(inversedStateClass)){$globalNav.removeClass(inversedStateClass);}else if(scrollTop>inverseOffset+adSize){$globalNav.addClass(inversedStateClass);}}
$(win).on('scroll',$.throttle(250,changeStateOnScroll));});;require(['jquery','GlobalNavigationiOSScrollFix','wikia.window','wikia.browserDetect','wikia.delayedhover','wikia.globalNavigationDropdowns'],function($,scrollFix,win,browserDetect,delayedHover,dropdowns){'use strict';var $globalNavigation=$('#globalNavigation'),loginAjaxForm=false;function onEntryPointClick(event){var $this=$(event.currentTarget);event.preventDefault();event.stopImmediatePropagation();if(this.$entryPoint.hasClass('active')){win.location=$this.attr('href')||$this.children('a').attr('href');}else{dropdowns.openDropdown.call(this.$entryPoint.get(0));}}
function onDropdownOpen(event){$globalNavigation.trigger('user-login-menu-opened');if(event){event.preventDefault();event.stopPropagation();}
if(!win.wgUserName&&!loginAjaxForm){loginAjaxForm=new win.UserLoginAjaxForm(this.$entryPoint,{skipFocus:true});win.FacebookLogin.init(win.FacebookLogin.origins.DROPDOWN);}}
function onDropdownClose(){var activeElementId=document.activeElement.id;if(!win.wgUserName){if(activeElementId==='usernameInput'||activeElementId==='passwordInput'){return false;}}}
function authModalOpen(url){window.wikiaAuthModal.load({url:url,origin:'global-nav',onAuthSuccess:onAuthSuccess.bind({url:url})});}
function onAuthSuccess(){var redirect=this.url.replace(/.*?redirect=([^&]+).*/,'$1');window.location.href=decodeURIComponent(redirect);}
function globalNavAuthButtonsClick(event){if(event.which!==1||event.shiftKey||event.altKey||event.metaKey||event.ctrlKey){return;}
if(event){event.preventDefault();event.stopPropagation();}
authModalOpen(event.currentTarget.href);}
function oldAccountNav($entryPoint){var $userLoginDropdown=$('#UserLoginDropdown');dropdowns.attachDropdown($entryPoint,{onOpen:onDropdownOpen.bind({$entryPoint:$entryPoint}),onClose:onDropdownClose,onClick:!!win.wgUserName?onEntryPointClick.bind({$entryPoint:$entryPoint}):false,onClickTarget:'.links-container'});delayedHover.attach($entryPoint.get(0),{checkInterval:100,maxActivationDistance:20,onActivate:dropdowns.openDropdown,onDeactivate:dropdowns.closeDropdown,activateOnClick:false});if(browserDetect.isIOS7orLower()){$userLoginDropdown.on('focus','#usernameInput, #passwordInput',function(){scrollFix.scrollToTop($globalNavigation);}).on('blur','#usernameInput, #passwordInput',function(){scrollFix.restoreScrollY($globalNavigation);});}}
$(function(){var $entryPoint,$authEntryPoints;$entryPoint=$('#AccountNavigation');if(!win.wgUserName&&win.wgEnableNewAuthModal){$authEntryPoints=$entryPoint.find('.auth-link.register, .auth-link.sign-in, a.sign-in');$authEntryPoints.click(globalNavAuthButtonsClick);}
else{oldAccountNav($entryPoint);}});});;require(['jquery','wikia.window','wikia.delayedhover','wikia.globalNavigationDropdowns'],function($,w,delayedHover,dropdowns){'use strict';var $entryPoint,$exploreLink,track=Wikia.Tracker.buildTrackingFunction({category:'top-nav',trackingMethod:'analytics',action:Wikia.Tracker.ACTIONS.CLICK});function onEntryPointClick(event){var $this=$(event.target),$a=$this.closest('a'),href=$a.attr('href');if($a.parent().attr('id')===$entryPoint.attr('id')){event.preventDefault();event.stopImmediatePropagation();if($entryPoint.hasClass('active')&&href!=='#'){track({label:$a.data('tracking-label')});w.location=href;}else{dropdowns.openDropdown.call($entryPoint.get(0));}}}
$(function(){$entryPoint=$('#exploreWikiaEntryPoint');$exploreLink=$entryPoint.children('a.cell-link');dropdowns.attachDropdown($entryPoint,{onClick:onEntryPointClick.bind({$entryPoint:$entryPoint}),onClickTarget:$exploreLink.get(0)});delayedHover.attach($entryPoint.get(0),{checkInterval:100,maxActivationDistance:20,onActivate:dropdowns.openDropdown,onDeactivate:dropdowns.closeDropdown,activateOnClick:false});});});;(function(){'use strict';var UserBaseAjaxForm=function(el,options){if(!(el instanceof HTMLElement||el instanceof jQuery||typeof el==='string')){throw new Error('This module requires an element or selector as its first argument');}
this.el=$(el);this.options=options||{};this.init();};UserBaseAjaxForm.prototype.init=function(){this.wikiaForm=new WikiaForm(this.el.find('form'));this.inputs=this.wikiaForm.inputs;this.cacheDOM();this.bindEvents();if(!this.options.skipFocus){this.inputs.username.focus();}};UserBaseAjaxForm.prototype.cacheDOM=function(){this.form=this.wikiaForm.form;this.forgotPasswordLink=this.form.find('.forgot-password');this.submitButton=this.el.find('input[type=submit]');};UserBaseAjaxForm.prototype.bindEvents=function(){this.form.on('submit',this.submitLogin.bind(this));this.forgotPasswordLink.on('click',this.mailPassword.bind(this));};UserBaseAjaxForm.prototype.submitLogin=function(e){$(window).trigger('UserLoginSubmit');this.submitButton.attr('disabled','disabled');if(this.options.ajaxLogin){e.preventDefault();this.ajaxLogin();}};UserBaseAjaxForm.prototype.ajaxLogin=function(){$.nirvana.postJson('UserLoginSpecial','login',{loginToken:this.loginToken,username:this.inputs.username.val(),password:this.inputs.password.val(),keeploggedin:this.inputs.keeploggedin.is(':checked')},this.submitLoginHandler.bind(this));};UserBaseAjaxForm.prototype.submitLoginHandler=function(json){this.resetValidation();if(json.result==='ok'){this.onOkayResponse(json);}else if(json.result==='error'){this.onErrorResponse(json);}else if(json.result==='unconfirm'){this.onUnconfirmedEmailResponse();}};UserBaseAjaxForm.prototype.resetValidation=function(){this.form.find('.error-msg').remove();this.form.find('.input-group').removeClass('error');};UserBaseAjaxForm.prototype.onOkayResponse=function(json){var callback=this.options.callback||'';window.wgUserName=json.wgUserName;if(callback&&typeof callback==='function'){callback.bind(this,json)();}else{this.reloadPage();}};UserBaseAjaxForm.prototype.onErrorResponse=function(json){this.submitButton.removeAttr('disabled');this.errorValidation(json);};UserBaseAjaxForm.prototype.onUnconfirmedEmailResponse=function(){$.get(window.wgScriptPath+'/wikia.php',{controller:'UserLoginSpecial',method:'getUnconfirmedUserRedirectUrl',format:'json',username:this.inputs.username.val()},function(json){window.location=json.redirectUrl;});};UserBaseAjaxForm.prototype.errorValidation=function(json){if(json.errParam){this.wikiaForm.showInputError(json.errParam,json.msg);}else{this.wikiaForm.showGenericError(json.msg);}};UserBaseAjaxForm.prototype.mailPassword=function(e){e.preventDefault();this.form.find('.input-group').removeClass('error');this.form.find('.error-msg').remove();$.nirvana.postJson('UserLoginSpecial','mailPassword',{username:this.inputs.username.val(),token:this.inputs.loginToken.val()},this.errorValidation.bind(this));};UserBaseAjaxForm.prototype.reloadPage=function(){require(['wikia.querystring'],function(QuerySring){var qs=new QuerySring();qs.addCb().goTo();});};window.UserBaseAjaxForm=UserBaseAjaxForm;})();;(function(){'use strict';var UserLoginAjaxForm=function(el,options){UserBaseAjaxForm.call(this,el,options);};UserLoginAjaxForm.prototype=Object.create(UserBaseAjaxForm.prototype);UserLoginAjaxForm.prototype.init=function(){UserBaseAjaxForm.prototype.init.call(this);this.retrieveLoginToken();};UserLoginAjaxForm.prototype.submitLoginHandler=function(json){var result=json.result;UserBaseAjaxForm.prototype.submitLoginHandler.call(this,json);if(result==='resetpass'){this.onResetPasswordResponse(json);}else if(result==='closurerequested'){this.onAccountClosureRequestResponse();}else{this.onErrorResponse();}};UserLoginAjaxForm.prototype.onResetPasswordResponse=function(){$.nirvana.sendRequest({controller:'UserLoginSpecial',method:'changePassword',format:'html',data:{username:this.inputs.username.val(),password:this.inputs.password.val(),loginToken:this.inputs.loginToken.val(),returnto:this.inputs.returnto.val(),fakeGet:1},callback:this.setupChangePasswordForm.bind(this)});};UserLoginAjaxForm.prototype.setupChangePasswordForm=function(html){var content,form,heading,modal,contentBlock,duration;content=$('<div>').hide().append(html);duration=400;if(this.options.modal){heading=content.find('h1');modal=this.options.modal;contentBlock=modal.$element.find('.UserLoginModal');modal.setTitle(heading.text());heading.remove();contentBlock.slideUp(duration,function(){contentBlock.html('').html(content);content.show();contentBlock.slideDown(duration);});}else{form=this.form;form.slideUp(duration,(function(){var newForm=content.find('form');form.replaceWith(content);content.slideDown(duration);newForm.on('submit',this.submitLoginAfterResetPass.bind(this));this.wikiaForm=new WikiaForm(newForm);this.inputs=this.wikiaForm.inputs;}).bind(this));}};UserLoginAjaxForm.prototype.onAccountClosureRequestResponse=function(){$.post(wgScriptPath+'/wikia.php',{controller:'UserLoginSpecial',method:'getCloseAccountRedirectUrl',format:'json'},function(data){window.location=data.redirectUrl;});};UserLoginAjaxForm.prototype.retrieveLoginToken=function(params){params=params||{};if(!this.loginToken||params.clearCache){this.loginToken='retrieving';$.nirvana.postJson('UserLoginSpecial','retrieveLoginToken',function(res){this.loginToken=res.loginToken;this.inputs.loginToken.val(res.loginToken);}.bind(this));}};UserLoginAjaxForm.prototype.submitLoginAfterResetPass=function(e){this.submitButton.attr('disabled','disabled');if(this.options.ajaxLogin){e.preventDefault();this.ajaxLoginAfterResetPass();}};UserLoginAjaxForm.prototype.ajaxLoginAfterResetPass=function(){$.nirvana.postJson('UserLoginSpecial','loginForm',{loginToken:this.loginToken,username:this.inputs.username.val(),password:this.inputs.password.val(),newpassword:this.inputs.newpassword.val(),retype:this.inputs.retype.val(),action:this.inputs.action.val(),editToken:this.inputs.editToken.val()},this.submitLoginHandler.bind(this));};window.UserLoginAjaxForm=UserLoginAjaxForm;})();;!function($){"use strict";var Tooltip=function(element,options){this.init('tooltip',element,options)}
Tooltip.prototype={constructor:Tooltip,init:function(type,element,options){var eventIn,eventOut
this.type=type
this.$element=$(element)
this.options=this.getOptions(options)
this.enabled=true
if(this.options.trigger!='manual'){eventIn=this.options.trigger=='hover'?'mouseenter':'focus'
eventOut=this.options.trigger=='hover'?'mouseleave':'blur'
this.$element.on(eventIn,this.options.selector,$.proxy(this.enter,this))
this.$element.on(eventOut,this.options.selector,$.proxy(this.leave,this))}
this.options.selector?(this._options=$.extend({},this.options,{trigger:'manual',selector:''})):this.fixTitle()},getOptions:function(options){options=$.extend({},$.fn[this.type].defaults,options,this.$element.data())
if(options.delay&&typeof options.delay=='number'){options.delay={show:options.delay,hide:options.delay}}
return options},enter:function(e){var self=$(e.currentTarget)[this.type](this._options).data(this.type)
if(!self.options.delay||!self.options.delay.show)return self.show()
clearTimeout(this.timeout)
self.hoverState='in'
this.timeout=setTimeout(function(){if(self.hoverState=='in')self.show()},self.options.delay.show)},leave:function(e){var self=$(e.currentTarget)[this.type](this._options).data(this.type)
if(this.timeout)clearTimeout(this.timeout)
if(!self.options.delay||!self.options.delay.hide)return self.hide()
self.hoverState='out'
this.timeout=setTimeout(function(){if(self.hoverState=='out')self.hide()},self.options.delay.hide)},show:function(){var $tip,inside,pos,actualWidth,actualHeight,placement,tp
if(this.hasContent()&&this.enabled){$tip=this.tip()
this.setContent()
if(this.options.animation){$tip.addClass('fade')}
placement=typeof this.options.placement=='function'?this.options.placement.call(this,$tip[0],this.$element[0]):this.options.placement
inside=/in/.test(placement)
$tip.remove().css({top:0,left:0,display:'block'}).appendTo(inside?this.$element:document.body)
if(this.options&&this.options['z-index']){$tip.css('z-index',this.options['z-index']);}
pos=this.getPosition(inside)
actualWidth=$tip[0].offsetWidth
actualHeight=$tip[0].offsetHeight
switch(inside?placement.split(' ')[1]:placement){case'bottom':tp={top:pos.top+pos.height,left:pos.left+pos.width/2-actualWidth/2}
break
case'top':tp={top:pos.top-actualHeight,left:pos.left+pos.width/2-actualWidth/2}
break
case'left':tp={top:pos.top+pos.height/2-actualHeight/2,left:pos.left-actualWidth}
break
case'right':tp={top:pos.top+pos.height/2-actualHeight/2,left:pos.left+pos.width}
break
case'wikiaBar':tp={top:pos.top-actualHeight,right:0}
break
case'wikiaBarMessage':tp={top:pos.top-actualHeight,right:0}
break}
$tip.css(tp).addClass(placement).addClass('in')}},isHTML:function(text){return typeof text!='string'||(text.charAt(0)==="<"&&text.charAt(text.length-1)===">"&&text.length>=3)||/^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text)},setContent:function(){var $tip=this.tip(),title=this.getTitle()
$tip.find('.tooltip-inner')[this.isHTML(title)?'html':'text'](title)
$tip.removeClass('fade in top bottom left right')},hide:function(){var that=this,$tip=this.tip()
$tip.removeClass('in')
function removeWithAnimation(){var timeout=setTimeout(function(){$tip.off($.support.transition.end).remove()},500)
$tip.one($.support.transition.end,function(){clearTimeout(timeout)
$tip.remove()})}
$.support.transition&&this.$tip.hasClass('fade')?removeWithAnimation():$tip.remove()
return this;},fixTitle:function(){var $e=this.$element
if($e.attr('title')||typeof($e.attr('data-original-title'))!='string'){$e.attr('data-original-title',$e.attr('title')||'').removeAttr('title')}},hasContent:function(){return this.getTitle()},getPosition:function(inside){return $.extend({},(inside?{top:0,left:0}:this.$element.offset()),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var title,$e=this.$element,o=this.options
title=$e.attr('data-original-title')||(typeof o.title=='function'?o.title.call($e[0]):o.title)
return title},tip:function(){return this.$tip=this.$tip||$(this.options.template)},validate:function(){if(!this.$element[0].parentNode){this.hide()
this.$element=null
this.options=null}},enable:function(){this.enabled=true},disable:function(){this.enabled=false},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(){this[this.tip().hasClass('in')?'hide':'show']()}}
$.fn.tooltip=function(option){return this.each(function(){var $this=$(this),data=$this.data('tooltip'),options=typeof option=='object'&&option
if(!data)$this.data('tooltip',(data=new Tooltip(this,options)))
if(typeof option=='string')data[option]()})}
$.fn.tooltip.Constructor=Tooltip
$.fn.tooltip.defaults={animation:true,placement:'top',selector:false,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:'hover',title:'',delay:0}}(window.jQuery);;