;(function($,_,undefined){"use strict";ips.controller.register('core.front.statuses.status',{_commentStatusID:null,initialize:function(){this.on('click','[data-action="loadPreviousComments"], [data-action="loadNextComments"]',this.paginate);this.on('submit','[data-role="replyComment"]',this.quickReply);this.on(document,'addToStatusFeed',this.addToStatusFeed);this.setup();},setup:function(){this._commentStatusID=this.scope.attr('data-statusID');},paginate:function(e){e.preventDefault();var feed=$(e.currentTarget).closest('[data-role="statusComments"]');var paginateRow=$(e.currentTarget).closest('.cStatusUpdates_pagination');paginateRow.html(ips.templates.render('core.statuses.loadingComments'));ips.getAjax()($(e.currentTarget).attr('href')).done(function(response){paginateRow.replaceWith(response);feed.find('meta').remove().end();$(document).trigger('contentChange',[feed]);}).fail(function(response){paginateRow.replaceWith('');ips.ui.alert.show({type:'alert',icon:'warn',message:_.isUndefined(response.responseJSON)?ips.getString('errorLoadingContent'):response.responseJSON,});});},quickReply:function(e){var form=this.scope.find('[data-role="replyComment"] form');if(form.attr('data-noAjax')){return;} e.preventDefault();e.stopPropagation();var self=this;var feed=$(e.currentTarget).closest('[data-role="statusComments"]');var replyArea=this.scope.find('[data-role="replyComment"]');var submit=this.scope.find('[type="submit"]');var page=feed.attr('data-currentPage');if(!page){page=1;} var currentText=submit.text();submit.prop('disabled',true).text(ips.getString('saving'));ips.getAjax()(form.attr('action'),{data:form.serialize()+'&submitting=1¤tPage='+page,type:'post'}).done(function(response){self.trigger('addToStatusFeed',{content:response.content,statusID:self._commentStatusID});}).fail(function(){form.attr('data-noAjax','true');form.submit();}).always(function(){submit.prop('disabled',false).text(currentText);});},addToStatusFeed:function(e,data){if(!data.content||data.statusID!=this._commentStatusID){return;} var content=$('
').append(data.content);this.scope.find('[data-role="statusComments"]').append(content);ips.utils.anim.go('fadeInDown',content);ips.ui.editor.getObj(this.scope.find('[data-role="replyComment"] [data-ipsEditor]')).reset();$(document).trigger('contentChange',[this.scope]);}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.statuses.statusFeed',{initialize:function(){this.on('submit','[data-role="newStatus"] form',this.submitNewStatus);this.setup();},setup:function(){},submitNewStatus:function(e){e.preventDefault();e.stopPropagation();var self=this;var feed=this.scope.find('[data-role="activityStream"]');var replyArea=this.scope.find('[data-role="replyComment"]');var form=this.scope.find('[data-role="newStatus"] form');var submit=this.scope.find('[data-action="submitComment"]');var textarea=form.find('textarea');var currentText=submit.text();if(!textarea.val()){ips.ui.alert.show({type:'alert',message:ips.getString('validation_required'),icon:'warn'});return;} submit.prop('disabled',true).text(ips.getString('saving'));ips.getAjax()(form.attr('action'),{data:form.serialize(),type:'post',bypassRedirect:true}).done(function(response){var content=$('').append(response);var comment=content.find('.ipsComment,.ipsStreamItem').first();feed.prepend(comment);ips.utils.anim.go('fadeInDown',comment);$('textarea[name="'+textarea.attr('name')+'"]').closest('[data-ipsEditor]').data('_editor').reset();$(document).trigger('contentChange',[comment]);}).fail(function(xhr){self.scope.find('#elStatusSubmit').parent().html(xhr.responseText);$(document).trigger('contentChange',[self.scope.find('#elStatusSubmit').parent()]);}).always(function(){submit.prop('disabled',false).text(currentText);});}});}(jQuery,_));;