;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.tagEditor',{_minTags:null,_maxTags:null,_count:0,_tagEditID:'',initialize:function(){this.on('click','[data-action="removeTag"]',this.removeTag);this.on(document,'tagsUpdated',this.tagsUpdated);this.setup();},setup:function(){this._tagEditID=this.scope.attr('data-tagEditID');this._minTags=this.scope.attr('data-minTags')||null;this._maxTags=this.scope.attr('data-maxTags')||null;this._setCount();this._checkMinMax();},_destroy:function(){if($('#elTagEditor_'+this._tagEditID+'_menu').length){$('#elTagEditor_'+this._tagEditID+'_menu').remove();}},tagsUpdated:function(e,data){if(data.tagEditID!==this._tagEditID){return;} this.scope.find('.ipsTag').closest('li').remove();this.scope.prepend(data.tags);var editablePrefix=$('body').find('[data-editablePrefix]');if(editablePrefix.length){if(data.prefix){editablePrefix.html(data.prefix).removeClass('ipsHide');}else{editablePrefix.html('').addClass('ipsHide');}} this._setCount();this._checkMinMax();ips.ui.flashMsg.show(ips.getString('tagsUpdated'));},removeTag:function(e){e.preventDefault();var self=this;var remove=$(e.currentTarget);var url=remove.attr('href');var tagContainer=remove.closest('li');var tag=tagContainer.find('.ipsTag');tagContainer.fadeOut('fast');this._count--;this._checkMinMax();ips.getAjax()(url,{bypassRedirect:true}).done(function(){ips.ui.flashMsg.show(ips.getString('tagRemoved'));setTimeout(function(){tagContainer.remove();},200);}).fail(function(jqXHR,textStatus,errorThrown){tagContainer.stop().show().css({opacity:"1"});self._count++;if(jqXHR.responseJSON){ips.ui.alert.show({type:'alert',icon:'warn',message:jqXHR.responseJSON,callbacks:{}});}});},_checkMinMax:function(){var allowRemove=!(this._minTags&&this._count<=this._minTags);this.scope.find('[data-action="removeTag"]').toggle(allowRemove).end().find('.ipsTags_deletable').toggleClass('ipsTags_deletable',allowRemove);this.scope.find('.ipsTags_edit').toggle(!(this._maxTags&&this._count>=this._maxTags));},_setCount:function(){var prefix=this._getPrefix();var count=this.scope.find('.ipsTag').length;if(prefix.length&&prefix.is(':visible')){count++;} this._count=count;},_getPrefix:function(){return $('body').find('[data-editablePrefix]');}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.tagEditorForm',{_placeholder:null,_menuID:'',_tagEditID:'',initialize:function(){this.on(document,'menuOpened',this.menuOpened);this.on(document,'menuClosed',this.menuClosed);this.on('submit','form',this.submitForm);this.setup();},setup:function(){this._menuID=this.scope.closest('.ipsMenu').attr('id').replace('_menu','');this._tagEditID=this._menuID.replace('elTagEditor_','');},menuClosed:function(e,data){if(data.elemID!=this._menuID){return;} this.scope.html(ips.templates.render('core.edittags.default'));},menuOpened:function(e,data){if(data.elemID!=this._menuID){return;} var self=this;var url=$(data.originalEvent.currentTarget).attr('href');ips.getAjax()(url).done(function(response){self._setLoading(false);self.scope.html(response);$(document).trigger('contentChange',[self.scope]);}).fail(function(){window.location=url;});},submitForm:function(e){e.preventDefault();var self=this;var form=$(e.currentTarget);var autoComplete=this.scope.find('[data-ipsAutocomplete]');autoComplete.trigger('blur');setTimeout(function(){if(ips.ui.autocomplete.getObj(autoComplete).hasErrors()){e.preventDefault();return;} self._setLoading(true);ips.getAjax()(form.attr('action'),{type:'post',data:form.serialize(),dataType:'json'}).done(function(response){self.scope.trigger('tagsUpdated',{tagEditID:self._tagEditID,tags:response.tags,prefix:response.prefix});self.scope.trigger('closeMenu');setTimeout(function(){self._setLoading(false);},200);}).fail(function(jqXHR,textStatus,errorThrown){if(jqXHR.responseJSON){ips.ui.alert.show({type:'alert',icon:'warn',message:jqXHR.responseJSON,callbacks:{}});}});},500);},_setLoading:function(loading){if(loading){if(!this._placeholder){this._buildPlaceholder();} var width=this.scope.outerWidth();var height=this.scope.outerHeight();this.scope.hide();this._placeholder.show().css({width:width+'px',height:height+'px'});}else{if(this._placeholder){this._placeholder.hide();this.scope.show();}}},_buildPlaceholder:function(){this._placeholder=$('
').addClass('ipsLoading').hide();this.scope.after(this._placeholder);}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.articlePages',{_currentPage:1,_pages:null,_articleID:'',initialize:function(){this.on('paginationClicked',this.paginationClicked);History.Adapter.bind(window,'statechange',_.bind(this.stateChange,this));this.setup();},setup:function(){this._articleID=this._getArticleID();this._setupPages();},stateChange:function(){var state=History.getState();if(_.isUndefined(state.data.controller)||state.data.controller!='article-'+this._articleID){return;} var newPage=parseInt(state.data['page'+this._articleID]);if(_.isUndefined(this._pages[newPage-1])){return;} this._pages.hide();this._currentPage=newPage;ips.utils.anim.go('fadeIn',$(this._pages[newPage-1]));this._checkButtons();},paginationClicked:function(e,data){if(data.originalEvent){data.originalEvent.preventDefault();data.originalEvent.stopPropagation();} e.stopPropagation();var urlData={controller:'article-'+this._articleID};if(data.pageNo=='next'){urlData['page'+this._articleID]=this._currentPage+1;}else{urlData['page'+this._articleID]=this._currentPage-1;} var url=this._buildURL(urlData['page'+this._articleID]);History.pushState(urlData,document.title,url);},_getArticleID:function(){if(this.scope.attr('data-articleID')){return this.scope.attr('data-articleID');}else if(this.scope.closest('[data-commentID]')){return'comment'+this.scope.closest('[data-commentID]').attr('data-commentID');}else{return this.scope.identify().attr('id');}},_buildURL:function(pageNo){var urlObj=ips.utils.url.getURIObject();var url=urlObj.protocol+'://'+urlObj.host+(urlObj.port?(':'+urlObj.port):'')+urlObj.path+'?';urlObj.queryKey['page'+this._articleID]=pageNo;var params=_.clone(urlObj.queryKey);if(urlObj.file=='index.php'){_.each(params,function(val,key){if(key.startsWith('/')){url+=key;delete params[key];}});url+='&';} if(!_.isEmpty(params)){url+=$.param(params);} return url;},_checkButtons:function(){var indexedPage=this._currentPage-1;this.scope.find('.ipsPagination_prev').toggle(!(indexedPage<=0));this.scope.find('.ipsPagination_next').toggle(!(indexedPage>=(this._pages.length-1)));},_setupPages:function(){this._pages=this.scope.find('[data-role="contentPage"]');if(this._pages.length<2){return;} this.scope.prepend(ips.templates.render('core.pagination'));this.scope.append(ips.templates.render('core.pagination'));this._pages.hide();if(!_.isUndefined(ips.utils.url.getParam('page'+this._articleID))){this._currentPage=parseInt(ips.utils.url.getParam('page'+this._articleID));} $(this._pages[this._currentPage-1]).show();this._checkButtons();this.scope.find('[data-role="contentPageBreak"]').hide();$(document).trigger('contentChange',[this.scope]);}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.announcementBanner',{initialize:function(){this.setup();this.on('click','[data-role="dismissAnnouncement"]',this.dismissAnnouncement);},setup:function(){$('.cAnnouncements').addClass('cAnnouncementsFloat').css('zIndex',ips.ui.zIndex());this.scope.find('[data-announcementId]').each(function(){var announcement=$(this);if(!ips.utils.cookie.get('announcement_'+announcement.attr('data-announcementId'))){announcement.show();}});},dismissAnnouncement:function(e){if(e){e.preventDefault();} var element=$(e.target).closest('[data-announcementId]');var id=element.attr('data-announcementId');var date=new Date();date.setTime(date.getTime()+(7*86400000));ips.utils.cookie.set('announcement_'+id,true,date.toUTCString());element.slideUp({duration:400,complete:function(){$(this).remove();},progress:function(){}});},reflow:function(e){}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.statusFeedWidget',{initialize:function(){this.on('editorWidgetInitialized','[data-role="statusFormArea"]',this.editorReady);this.on('focus','[data-role="statusFormArea"] .ipsComposeArea_dummy',this.focusNewStatus);this.on('submit','[data-role="statusFormArea"] form',this.submitNewStatus);this.setup();},setup:function(){},focusNewStatus:function(e){e.preventDefault();var self=this;$(e.currentTarget).text(ips.getString('loading')+"...");ips.getAjax()(ips.getSetting('baseURL')+'index.php?app=core&module=status&controller=ajaxcreate').done(function(response){self.scope.find('[data-role="statusEditor"]').html(response);$(document).trigger('contentChange',[self.scope.find('[data-role="statusEditor"]')]);});},editorReady:function(e,data){this.scope.find('[data-role="statusEditor"]').show();this.scope.find('[data-role="statusDummy"]').hide().find('.ipsComposeArea_dummy').text(ips.getString('whatsOnYourMind'));try{CKEDITOR.instances[data.id].focus();}catch(err){Debug.log(err);}},submitNewStatus:function(e){e.preventDefault();var self=this;var form=$(e.currentTarget);form.find('button[type="submit"]').prop('disabled',true).text(ips.getString('updatingStatus'));ips.getAjax()(form.attr('action'),{data:form.serialize(),type:'post',bypassRedirect:true}).done(function(response){var newStatus=$(response.content);self.scope.find('[data-role="statusDummy"]').show();self.scope.find('[data-role="statusEditor"]').hide();self.scope.find('[data-role="statusFeedEmpty"]').hide();self.scope.find('[data-role="statusFeed"]').prepend(newStatus).find('[data-statusID="'+response.id+'"]').hide().slideDown();$(document).trigger('contentChange',[self.scope.find('[data-role="statusFeed"]')]);}).always(function(){form.find('button[type="submit"]').prop('disabled',false).text(ips.getString('submitStatus'));});}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.reviewForm',{initialize:function(){this.on('click','[data-action="writeReview"]',this.toggleReview);},toggleReview:function(e){e.preventDefault();this.scope.find('[data-role="reviewIntro"]').hide();this.scope.find('[data-role="reviewForm"]').show();}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.poll',{initialize:function(){this.on('submit','form',this.submitPoll);this.on('click','[data-action="viewResults"]',this.viewResults);},viewResults:function(e){e.preventDefault();var url=$(e.currentTarget).attr('href')+'&fetchPoll=1&viewResults=1';if($(e.currentTarget).attr('data-viewResults-confirm')){var self=this;ips.ui.alert.show({type:'confirm',icon:'warn',message:ips.getString('generic_confirm'),subText:ips.getString('warn_allow_result_view'),callbacks:{ok:function(){self._viewResults(url+'&nullVote=1');}}});}else{this._viewResults(url);}},_viewResults:function(url){var self=this;self._setContentsLoading();ips.getAjax()(url).done(function(response){self.cleanContents();self.scope.html(response);$(document).trigger('contentChange',[self.scope]);});},_setContentsLoading:function(){var container=this.scope.find('[data-role="pollContents"]');var height=container.outerHeight();container.css({height:height+'px'}).html('').addClass('ipsLoading');},submitPoll:function(e){var form=$(e.currentTarget);if(form.attr('data-bypassAjax')){return} e.preventDefault();var url=form.attr('action');var self=this;this.scope.find('button[type="submit"]').prop('disabled',true).text(ips.getString('votingNow'));if(url.match(/\?/)){url+='&';}else{url+='?';} ips.getAjax()(url+'fetchPoll=1',{data:form.serialize(),type:'POST'}).done(function(response){self.cleanContents();self.scope.html(response);$(document).trigger('contentChange',[self.scope]);ips.ui.flashMsg.show(ips.getString('thanksForVoting'));}).fail(function(){form.attr('data-bypassAjax',true).submit();});}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.pollEditor',{initialize:function(){this.on('click','[data-action="removeChoice"]',this.removeChoice);this.on('click','[data-action="addChoice"]',this.addChoice);this.on('click','[data-action="addQuestion"]',this.addQuestion);this.on('click','[data-action="removeQuestion"]',this.removeQuestion);this.setup();},setup:function(){this._maxQuestions=this.scope.attr('data-maxQuestions');this._maxChoices=this.scope.attr('data-maxChoices');this._name=this.scope.attr('data-pollName');this._showCounts=this.scope.attr('data-showCounts')==='false'?false:true;var pollData=ips.getSetting('pollData');if(_.isArray(pollData)&&pollData.length){for(var i=0;i