
(function($){MiniEditor.Wall={};GlobalTriggers.on('MiniEditorReady',function(){if(MiniEditor.ckeditorEnabled){RTE.config.contentsCss.push($.getSassLocalURL('/extensions/wikia/MiniEditor/css/Wall/Wall.content.scss'));}});GlobalTriggers.on('WikiaEditorReady',function(wikiaEditor){if(wikiaEditor.getEditorElement().parentsUntil('.new-message').length){wikiaEditor.getEditbox().addClass('new-message');}});})(jQuery);;(function(){'use strict';MiniEditor.Wall=MiniEditor.Wall||{};MiniEditor.Wall.Animations={editorActivated:function(event,wikiaEditor){var element,wrapper,animation,hasContent,textarea;element=wikiaEditor.getEditorElement();wrapper=wikiaEditor.getEditboxWrapper();animation={height:wikiaEditor.config.minHeight};if(wikiaEditor.ck){hasContent=wikiaEditor.getContent();if(this.isReady&&!hasContent){wrapper.height(element.height()).show();}
if(hasContent){wikiaEditor.fire('editorAfterActivated');}else{wrapper.animate(animation,function(){wikiaEditor.getEditbox().focusNoScroll();wikiaEditor.fire('editorAfterActivated');});}
element.hide();}else{if(!element.is('textarea')){textarea=wikiaEditor.getEditbox();element.hide();if(!this.isReady){textarea.css('overflow','auto').animate(animation,function(){wikiaEditor.fire('editorAfterActivated');});}else{textarea.show();wikiaEditor.fire('editorAfterActivated');}}else{element.animate(animation,function(){wikiaEditor.fire('editorAfterActivated');});}}},editorDeactivated:function(wikiaEditor){var element,animation;if(wikiaEditor.getContent()){return;}
element=wikiaEditor.getEditorElement();animation={height:this.originalHeight};this.hideButtons(function(){if(wikiaEditor.ck){var wrapper=wikiaEditor.getEditboxWrapper();wrapper.animate(animation,function(){wrapper.hide();element.show();});}else{if(!element.is('textarea')){wikiaEditor.getEditbox().hide();element.show();}else{element.animate(animation);}}
wikiaEditor.fire('editorAfterDeactivated');});}};})();;(function($){'use strict';MiniEditor.Wall=MiniEditor.Wall||{};MiniEditor.Wall.EditMessageForm=$.createClass(Wall.settings.classBindings.editMessageForm,{oldTitle:{},oldBody:{},bucky:window.Bucky('MiniEditor.Wall.EditMessageForm'),editMessage:function(e){var self,msg,body,wikiaEditor,id,bubble,animation;this.bucky.timer.start('editMessage');self=this;msg=$(e.target).closest('li.message');body=msg.find('.msg-body').first();wikiaEditor=body.data('wikiaEditor');id=msg.attr('data-id');bubble=msg.find('.speech-bubble-message').first();animation={};e.preventDefault();this.setOldHTML(id,bubble);msg.find('.timestamp').hide();$('.follow',bubble).hide();msg.find('.wikia-menu-button').removeClass('active');body.closest('.speech-bubble-message').animate(animation,function(){if(!MiniEditor.assetsLoaded){MiniEditor.loadAssets(initEditor);}else{initEditor();}});$('.msg-title textarea.title',msg).autoResize({min:30,limit:256,extraSpace:15});function initEditor(){var mode,format;self.bucky.timer.start('editMessage.initEditor');mode=MiniEditor.getStartupMode(body);format=WikiaEditor.modeToFormat(mode);msg.find('.msg-title').first().html('<textarea class="title">'+msg.find('.msg-title a').html()+'</textarea>');self.model.loadEditData(self.page,id,'edit',format,function(data){var hasEdgeCases=typeof data.edgeCases!=='undefined';if(wikiaEditor){wikiaEditor.fire('editorActivated');if(hasEdgeCases){wikiaEditor.ck.setMode('source');}
wikiaEditor.setContent(data.htmlorwikitext);}else{if(typeof RTE==='object'){body.html(data.htmlorwikitext);}else{body.text(data.htmlorwikitext);}
body.miniEditor({config:{animations:MiniEditor.Wall.Animations,mode:hasEdgeCases?'source':MiniEditor.config.mode}});}
self.bucky.timer.stop('editMessage.initEditor');});}
this.bucky.timer.stop('editMessage');},getNewBody:function(msg){return $('.msg-body',msg).first().data('wikiaEditor').getContent();},getEditFormat:function(msg){var wikiaEditor=$('.msg-body',msg).first().data('wikiaEditor');return(MiniEditor.ckeditorEnabled&&(!wikiaEditor||(wikiaEditor&&wikiaEditor.mode!=='source')))?'richtext':'';},getSaveFormat:function(msg){return $('.msg-body',msg).first().data('wikiaEditor').mode==='wysiwyg'?'wikitext':'';},insertOldHTML:function(id,bubble){$('.msg-title',bubble).html(this.oldTitle[id]);$('.msg-body',bubble).html(this.oldBody[id]);},setOldHTML:function(id,bubble){this.oldTitle[id]=bubble.find('.msg-title').html();this.oldBody[id]=bubble.find('.msg-body').html();},afterCancel:function(body,isSource,target,bubble){if(isSource){target.parent().hide();bubble.find('.timestamp').show();}else{this.afterClose(bubble);body.data('wikiaEditor').fire('editorReset');}},resetHTMLAfterEdit:function(id,bubble){$('.msg-body',bubble).first().data('wikiaEditor').fire('editorReset');this.afterClose(bubble);},afterClose:function(bubble){$('.follow',bubble).show();bubble.find('.timestamp').show();if(!bubble.parent().data('is-reply')){bubble.animate({});}}});Wall.settings.classBindings.editMessageForm=MiniEditor.Wall.EditMessageForm;})(jQuery);;(function($){'use strict';MiniEditor.Wall=MiniEditor.Wall||{};MiniEditor.Wall.NewMessageForm=$.createClass(Wall.settings.classBindings.newMessageForm,{bucky:window.Bucky('MiniEditor.Wall.NewMessageForm'),initEvents:function(){var self=this;this.bucky.timer.start('initEvents');if(this.messageBody.is(':focus')){self.initEditor();}
this.messageBody.add(this.messageTitle).focus(function(event){self.initEditor(event);}).one('editorAfterActivated',function(){if(!MiniEditor.ckeditorEnabled){self.messageBody.autoResize({min:200});}});this.messageTitle.autoResize({min:30,limit:256,extraSpace:15});this.messageTitle.blur(this.proxy(this.postNewMessageBlur));this.bucky.timer.stop('initEvents');},initEditor:function(event){var self=this;this.bucky.timer.start('initEditor');if(!this.messageBody.data('wikiaEditor')){this.messageBody.unbind('.placeholder');}
this.messageBody.miniEditor({config:{animations:MiniEditor.Wall.Animations},events:{editorReady:function(event,wikiaEditor){if(!MiniEditor.ckeditorEnabled){wikiaEditor.getEditbox().placeholder().triggerHandler('focus.placeholder');}
if($.browser.msie){self.messageTitle.keydown(function(e){if(e.keyCode===9){e.preventDefault();wikiaEditor.editorFocus();}});}
self.bucky.timer.stop('initEditor');}}},event);},getMessageBody:function(){return $.trim(this.messageBody.data('wikiaEditor').getContent());},getFormat:function(){return this.messageBody.data('wikiaEditor').mode==='wysiwyg'?'wikitext':'';},clearNewMessageBody:function(){},clearNewMessageTitle:function(){this.messageTitle.val('').trigger('blur');this.messageNoTitle.fadeOut('fast');},disableNewMessage:function(){this.messageTitle.trigger('blur');this.messageBody.data('wikiaEditor').fire('editorReset');},enableNewMessage:function(){this.messageSubmit.html($.msg('wall-button-to-submit-comment'));this.messageTitle.removeClass('no-title');this.messageNoTitle.fadeOut('fast');},handleNewMessageTextChangeContent:function(){},postNewMessageBlur:function(){var title=this.messageTitle.val();if(title.length>0){this.messageTitle.val($.trim(title));}}});Wall.settings.classBindings.newMessageForm=MiniEditor.Wall.NewMessageForm;})(jQuery);;(function($){MiniEditor.Wall=MiniEditor.Wall||{};MiniEditor.Wall.ReplyMessageForm=$.createClass(Wall.ReplyMessageForm,{constructor:function(page,model){MiniEditor.Wall.ReplyMessageForm.superclass.constructor.apply(this,arguments);},deferred:'',initEvents:function(){var self=this;$(this.mainContent).on('click.MiniEditor',this.replyButton,this.proxy(this.replyToMessage)).on('click',this.replyPreviewButton,this.proxy(this.showPreview)).on('click.MiniEditor',this.replyBody,this.proxy(this.initEditor)).on('focus.MiniEditor',this.replyBody,this.proxy(this.focus));$(this.replyBody).each(function(){if($(this).is(':focus')){self.initEditor({target:this});}});},focus:function(e){this.initEditor({target:e.target});},setContent:function(replyWrapper,content){if(content){var wikiaEditor=this.editor.data('wikiaEditor');wikiaEditor.setContent(content);wikiaEditor.getEditbox().putCursorAtEndCE();}},activatedCallback:function(event,wikiaEditor){this.deferred.resolve(wikiaEditor);},initEditor:function(e){var target=$(e.target);this.deferred=$.Deferred();if(!target.data('wikiaEditor')){target.unbind('.placeholder').val('');}
this.editor=target.miniEditor({config:{animations:MiniEditor.Wall.Animations},events:{editorReady:function(event,wikiaEditor){if(!MiniEditor.ckeditorEnabled){wikiaEditor.getEditbox().placeholder();}},editorActivated:$.proxy(this.activatedCallback,this)}});return this.deferred.promise();},getMessageBody:function(reply){var wikiaEditor=$('.wikiaEditor',reply).data('wikiaEditor');return wikiaEditor.getContent();},getFormat:function(reply){var wikiaEditor=$('.wikiaEditor',reply).data('wikiaEditor');var format=wikiaEditor.mode=='wysiwyg'?'wikitext':'';return format;},resetEditor:function(){var wikiaEditor=$('.wikiaEditor',reply).data('wikiaEditor');reply.find(this.replyBody).val('').trigger('blur');wikiaEditor.fire('editorReset');}});Wall.settings.classBindings.replyMessageForm=MiniEditor.Wall.ReplyMessageForm;})(jQuery);;