ips.templates.set('core.streams.teaser'," ");ips.templates.set('core.streams.unreadBar',"

  • ");ips.templates.set('core.streams.noMore',"
  • {{#lang}}noMoreActivity{{/lang}}
  • ");ips.templates.set('core.streams.loadMore'," {{#lang}}loadNewActivity{{/lang}}");; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.streams.results',{_streamID:0,_newUpdates:$('
    '),_waitingCount:0,_config:{},initialize:function(){this.on('updateResults.stream',this.updateResults);this.on('resultsTeaser.stream',this.resultsTeaser);this.on('click','[data-action="insertNewItems"]',this.insertNewItems);this.on('click','a[data-linkType]',this.clickResult);this.setup();},setup:function(){if(this.scope.attr('data-streamID')){this._streamID=this.scope.attr('data-streamID');} this._config=ips.getSetting('stream_config');},updateResults:function(e,data){if(data.append){this._appendNewResults(data);}else{this._replaceWithNewResults(data);}},_replaceWithNewResults:function(data){this._config=JSON.parse(data.response.config);if(data.response.results.indexOf('core.front.streams.results')!==-1){var content=$('
    '+data.response.results+'
    ');var root=content.find('[data-controller="core.front.streams.results"]');this.cleanContents();this.scope.html(root.html()).attr('data-streamReadType',root.attr('data-streamReadType')).attr('data-streamURL',root.attr('data-streamURL')).attr('data-streamID',root.attr('data-streamID'));}else{ips.controller.cleanContentsOf(this.scope.find('[data-role="streamContent"]'));this.scope.find('[data-role="streamContent"]').html(data.response.results);} this.trigger('resultsUpdated.stream',{response:data.response});$(document).trigger('contentChange',[this.scope]);},_appendNewResults:function(data){var content=$('
    '+data.response.results+'
    ');var latestBubble=this.scope.find('[data-timeType]').last().attr('data-timeType');content.find('[data-timeType="'+latestBubble+'"]').remove();content.find('[data-role="activityItem"]').attr('data-new',true).css({opacity:"0"});if(!_.isUndefined(data.url)){content.find('.ipsComment_content form[action="'+this._config['url']+'"]').attr('action',data.url);} var existingItems=this.scope.find('[data-role="activityItem"]');var count=existingItems.length;existingItems.last().after(content);this.scope.find('[data-role="activityItem"]').slice(count).each(function(){$(document).trigger('contentChange',[$(this)]);});this._animateNewItems();},clickResult:function(e,data){var item=$(e.target).closest('[data-indexID]');var star=item.find('a[data-linkType="star"]');this.scope.find('.ipsStreamItem_active').removeClass('ipsStreamItem_active');item.addClass('ipsStreamItem_active').find('.ipsStreamItem_unread').removeClass('ipsStreamItem_unread');if(star.attr('data-iPostedIn')){star.find('span.ipsItemStatus').addClass('ipsItemStatus_read').addClass('ipsItemStatus_posted').unwrap();}else{star.addClass('ipsHide');}},insertNewItems:function(e){e.preventDefault();var insertBefore=null;if(this.scope.find('[data-timeType="past_hour"]').length){insertBefore=this.scope.find('[data-timeType="past_hour"]').siblings('[data-role="activityItem"]').first();this._newUpdates.find('[data-timeType]').remove();}else{insertBefore=this.scope.find('[data-timeType], [data-role="activityItem"]').first();} this.scope.find('[data-role="unreadBar"]').remove();this._newUpdates.append(ips.templates.render('core.streams.unreadBar'));this._newUpdates.find('[data-role="activityItem"]').attr('data-new',true).css({opacity:"0"});insertBefore.before(this._newUpdates.html());$(document).trigger('contentChange',[this.scope]);this.scope.find('[data-action="insertNewItems"]').remove();this._animateNewItems();this._newUpdates=$('
    ');this._waitingCount=0;},_animateNewItems:function(){var newItems=this.scope.find('[data-new]');var delay=200;newItems.each(function(index){var d=(index*delay);$(this).delay((d>1200)?1200:d).animate({opacity:"1"}).removeAttr('data-new');});},resultsTeaser:function(e,data){var self=this;var response=data.response;var count=parseInt(response.count);var tmp=$('
    '+response.results+'
    ');self.trigger('latestTimestamp.stream',{timestamp:parseInt(tmp.find('[data-timestamp]').first().attr('data-timestamp'))});self._waitingCount+=count;if(tmp.find('[data-timeType]').length){var type=tmp.find('[data-timeType]').attr('data-timeType');self._newUpdates.find('[data-timeType="'+type+'"]').remove();} self._newUpdates.prepend(tmp.contents());var teaser=ips.templates.render('core.streams.teaser',{count:self._waitingCount,words:ips.pluralize(ips.getString('newActivityItems'),[self._waitingCount,self._waitingCount])});if(self.scope.find('[data-action="insertNewItems"]').length){self.scope.find('[data-action="insertNewItems"]').replaceWith(teaser);self.scope.find('[data-action="insertNewItems"]').show();}else{self.scope.find('[data-role="activityItem"]').first().before(teaser);self.scope.find('[data-action="insertNewItems"]').slideDown();}}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.streams.main',{_streamLoadingOverlay:null,_tooltip:null,_tooltipTimer:null,_baseURL:'',_streamID:0,_currentView:'',_shortInterval:15,_longInterval:45,_killUpdate:45,_timer:null,_killTimer:null,_activityUpdate:null,_loadMore:null,_timestamp:0,_autoUpdate:false,_windowFocus:false,initialize:function(){this.on('formSubmitted.stream',this.formSubmitted);this.on('initialFormData.stream',this.initialFormData);this.on('loadMoreResults.stream',this.loadMoreResults);this.on('latestTimestamp.stream',this.latestTimestamp);this.on('click','[data-action="switchView"]',this.switchView);this.on('menuOpened','#elStreamShare',this.menuOpened);this.on('click','[data-action="toggleStreamDefault"]',this.toggleDefault);this.on('click','[data-action="removeStream"]',this.removeStream);this.on('click','[data-action="loadMore"]',this.loadMoreResults);this.on('resultsUpdated.stream',this.resultsUpdated);this.on('stickyStatusChange.sticky','#elStreamFilterForm',this.stickyChange);this.on('click','[data-action="toggleFilters"]',this.toggleFilters);this.on(document,'breakpointChange',this.breakpointChange);this.on(document,'markAllRead',this.markAllRead);this.on(document,ips.utils.events.getVisibilityEvent(),this.windowVisibilityChange);History.Adapter.bind(window,'statechange',_.bind(this.stateChange,this));this.setup();},setup:function(){this._streamID=this.scope.attr('data-streamID');this._baseURL=ips.getSetting('stream_config')['url'];if(this._baseURL.match(/\?/)){this._baseURL+='&';}else{this._baseURL+='?';} if(this._baseURL.slice(-1)=='&'){this._baseURL=this._baseURL.slice(0,-1)} this._timestamp=parseInt(this.scope.find('[data-timestamp]').first().attr('data-timestamp'));this._currentView=this.scope.find('[data-action="switchView"].ipsButtonRow_active').attr('data-view');if(!_.isUndefined(this.scope.find('[data-role="streamResults"]').attr('data-autoPoll'))){this._autoUpdate=true;this.windowVisibilityChange();} if(ips.utils.responsive.currentIs('phone')){this.scope.find('[data-role="filterBar"]').addClass('ipsHide');this.scope.find('[data-action="toggleFilters"]').html(ips.getString('toggleFiltersHidden'));}},stateChange:function(){var state=History.getState();var self=this;if((!state.data.controller||state.data.controller!='core.front.streams.main')&&this._initialURL!==state.url){return;} if(state.data.action=='saveForm'||state.data.action=='updateForm'){this.triggerOn('core.front.streams.form','streamStateUpdate.streamForm',{filterData:state.data.filterData,hideSaveBar:(_.isEmpty(this._getUrlDiff(state.data.filterData))||state.data.action=='saveForm')});ips.utils.analytics.trackPageView(state.url);if(!_.isUndefined(state.data.filterData.stream_sort)){this._togglePolling(!(state.data.filterData.stream_sort=='oldest'));} var data=_.extend({view:this._currentView},state.data.filterData);switch(state.data.action){case'updateForm':data=_.extend(data,false,{'updateOnly':1});break;case'saveForm':data=_.extend(data,false,{'form':'save'});break;} this._loadResults(data).done(function(response){self.triggerOn('core.front.streams.results','updateResults.stream',{append:false,response:response});if(state.data.action=='saveForm'){ips.setSetting('stream_config',JSON.parse(response.config));History.replaceState({controller:'core.front.streams.main',url:ips.getSetting('stream_config')['url'],skipUpdate:true},document.title,ips.getSetting('stream_config')['url']);}})}else if(state.data.action=='loadMore'){var data=_.extend({before:state.data.before,view:this._currentView},state.data.filters);var before=this.scope.find('[data-role="activityItem"]').last().attr('data-timestamp');var _this=this;this._loadResults(data).done(function(response){var content=$('
    '+response.results+'
    ');var latest=parseInt(content.find('[data-role="activityItem"]').last().attr('data-timestamp'))-1;History.replaceState({controller:'core.front.streams.main',latest:latest},document.title,_this._buildRequestURL({before:before,latest:isNaN(latest)?0:latest}));self.triggerOn('core.front.streams.results','updateResults.stream',{append:true,response:response,url:_this._buildRequestURL({before:before,latest:isNaN(latest)?0:latest})});});}else if(state.data.action=='viewToggle'){this._setViewType(state.data.view);this._loadResults(_.extend({view:state.data.view},state.data.filters)).done(function(response){self.triggerOn('core.front.streams.results','updateResults.stream',{response:response});});}else{Debug.log('skip update');}},loadMoreResults:function(e,data){e.preventDefault();var timestamp=this.scope.find('[data-role="activityItem"]').last().attr('data-timestamp');var url=this._buildRequestURL({before:timestamp});this.scope.find('[data-role="loadMoreContainer"] [data-action="loadMore"]').addClass('ipsButton_disabled').text(ips.getString('loading'));History.pushState({controller:'core.front.streams.main',before:timestamp,filters:this._getUrlDiff(this._formData),action:'loadMore'},document.title,url);},toggleFilters:function(e){e.preventDefault();var filterBar=this.scope.find('[data-role="filterBar"]');var toggleButton=$(e.currentTarget);if(filterBar.is(':visible')){filterBar.slideUp();toggleButton.html(ips.getString('toggleFiltersHidden')).removeClass('cStreamFilter_toggleShown');this.scope.find('[data-role="saveButtonContainer"]').addClass('ipsHide');}else{filterBar.slideDown();toggleButton.html(ips.getString('toggleFiltersShown')).addClass('cStreamFilter_toggleShown');} $(document).trigger('closeMenu');},breakpointChange:function(e,data){if(data.curBreakName=='phone'){this.scope.find('[data-role="filterBar"]').addClass('ipsHide').hide();this.scope.find('[data-action="toggleFilters"]').html(ips.getString('toggleFiltersHidden')).removeClass('cStreamFilter_toggleShown')}else{this.scope.find('[data-role="filterBar"]').removeClass('ipsHide');if(!this.scope.find('[data-role="filterBar"]').is(':visible')){this.scope.find('[data-role="filterBar"]').slideDown();this.scope.find('[data-action="toggleFilters"]').html(ips.getString('toggleFiltersShown')).addClass('cStreamFilter_toggleShown');}}},_setViewType:function(type){this._currentView=type;this.scope.find('[data-action="switchView"]').removeClass('ipsButton_primary').addClass('ipsButton_veryLight').filter('[data-view="'+type+'"]').removeClass('ipsButton_veryLight').addClass('ipsButton_primary');ips.utils.cookie.set('stream_view_'+this._streamID,type,true);},stickyChange:function(e,data){this.scope.find('[data-ipsMenu]').trigger('closeMenu');},switchView:function(e){e.preventDefault();var type=$(e.currentTarget).attr('data-view');var url=this._buildRequestURL({view:type});History.pushState({controller:'core.front.streams.main',view:type,filters:this._getUrlDiff(this._formData),action:'viewToggle'},document.title,url);},formSubmitted:function(e,data){this._formData=this._getFormData(data.data);var url=this._buildRequestURL();History.pushState({controller:'core.front.streams.main',url:url,filterData:this._formData,action:data.action},document.title,url);},initialFormData:function(e,data){this._formData=this._getFormData(data.data);},latestTimestamp:function(e,data){this._timestamp=data.timestamp;},windowVisibilityChange:function(){var hiddenProp=ips.utils.events.getVisibilityProp();if(!_.isUndefined(hiddenProp)){if(document[hiddenProp]){this._windowFocus=false;this._startTimer(this._longInterval);this._killTimer=setTimeout(_.bind(this._stopPolling,this),this._killUpdate*60*1000);Debug.log("Set the kill timer");}else{this._windowFocus=true;this._startTimer(this._shortInterval);this._updateTitle(0);clearTimeout(this._killTimer);Debug.log("Cleared the kill timer");}}else{this._startTimer(this._longInterval);}},_loadResults:function(data,resetConfig,silent){var self=this;var promise=$.Deferred();if(!silent){this._setStreamLoading(true);} ips.getAjax()(ips.getSetting('stream_config')['url'],{type:'post',data:data||{}}).done(function(response){if(!silent){self._setStreamLoading(false);self._updateStreamUI(response);} promise.resolve(response);}).fail(function(response){if(!silent){ips.ui.alert.show({type:'alert',message:ips.getString('errorLoadingStream'),icon:'warn'});} promise.reject();});return promise;},resultsUpdated:function(e,data){if(this.scope.find('[data-role="activityItem"]').length==0){this.scope.find('[data-role="loadMoreContainer"]').hide();this.scope.find('[data-role="streamContent"]').removeClass('ipsStream_withTimeline');} else{this.scope.find('[data-role="streamContent"]').addClass('ipsStream_withTimeline');this.scope.find('[data-role="loadMoreContainer"]').show();}},_updateStreamUI:function(response){Debug.log("Updating stream UI...");this.scope.find('[data-role="streamBlurb"]').text(response.blurb.replace(/'/g,"'"));this.scope.find('[data-role="streamTitle"]').html(response.title);if(response.count==0){this.scope.find('[data-role="loadMoreContainer"]').show().html(ips.templates.render('core.streams.noMore'));}else{this.scope.find('[data-role="loadMoreContainer"]').show().html(ips.templates.render('core.streams.loadMore'));} if(response.id){var menuItem=$('body').find('[data-streamid="'+response.id+'"] > a');menuItem.text(response.title);}},_getFormData:function(data){var returnValues={};_.each(data,function(val,key){if(key.startsWith('stream_')){returnValues[key]=val;}});try{if(!_.isUndefined(returnValues['stream_classes']['__EMPTY'])){returnValues['stream_classes']=_.omit(returnValues['stream_classes'],'__EMPTY');}}catch(err){} return returnValues;},_getUrlDiff:function(data){var returnedValues={};var defaultValues=ips.getSetting('stream_config');if(!_.size(data)){return returnedValues;} if(!_.isUndefined(defaultValues['changed'])){_.each(defaultValues['changed'],function(val,key){defaultValues[key]=val;});} _.each(['stream_sort','stream_include_comments','stream_read','stream_default_view','stream_club_select','stream_club_filter'],function(val){if(defaultValues[val]!=data[val]&&!_.isUndefined(data[val])){returnedValues[val]=data[val];}});if(data['stream_ownership']=='custom'){var newNames=_.isObject(data['stream_custom_members'])?data['stream_custom_members']:data['stream_custom_members'].split(/\n/);var oldNames=defaultValues['stream_custom_members'];if(!_.isObject(oldNames)){oldNames=[];} var nameIntersection=_.intersection(newNames,oldNames);if(!newNames.length){returnedValues['stream_ownership']='all';} else if(newNames.length!==oldNames.length||nameIntersection.length!==newNames.length){returnedValues['stream_ownership']='custom';returnedValues['stream_custom_members']=data['stream_custom_members'];}}else if(defaultValues['stream_ownership']!==data['stream_ownership']){returnedValues['stream_ownership']=data['stream_ownership'];} if(!(defaultValues['stream_follow']=='all'&&data['stream_follow']=='all')){if(data['stream_follow']=='followed'){var newFollowTypes=_.keys(data['stream_followed_types']);var oldFollowTypes=_.keys(defaultValues['stream_followed_types']);var followIntersection=_.intersection(newFollowTypes,oldFollowTypes);if(newFollowTypes.length!==oldFollowTypes.length||followIntersection.length!==newFollowTypes.length){returnedValues['stream_follow']='followed';returnedValues['stream_followed_types']=data['stream_followed_types'];}}else{returnedValues['stream_follow']=data['stream_follow'];}} if(!_.isUndefined(data['stream_tags'])&&!_.isEmpty(data['stream_tags'].trim())){var newTags=_.compact((data['stream_tags']||'').split(/\n/));var oldTags=_.compact((defaultValues['stream_tags']||'').split(/\n/));var tagIntersection=_.intersection(newTags,defaultValues['stream_tags']);if(newTags.length!==oldTags.length||tagIntersection.length!==newTags.length){returnedValues['stream_tags']=_.map(newTags,function(str){return str.trim()}).join(',');}}else if(defaultValues['stream_tags']){returnedValues['stream_tags']='';} if(data['stream_date_type']=='custom'){var startTest=data['stream_date_range']['start'];if(startTest.toString().match(/^[0-9]{9,10}$/)){var start=data['stream_date_range']['start'];var end=data['stream_date_range']['end'];} else{var start=new Date(data['stream_date_range']['start']).getTime()/ 1000;var end=new Date(data['stream_date_range']['end']).getTime()/ 1000;} if(data['stream_date_range']['start']&&(_.isUndefined(defaultValues['stream_date_range'])||start!==defaultValues['stream_date_range']['start'])){returnedValues['stream_date_type']='custom';returnedValues['stream_date_start']=start;} if(data['stream_date_range']['end']&&(_.isUndefined(defaultValues['stream_date_range'])||end!==defaultValues['stream_date_range']['end'])){returnedValues['stream_date_type']='custom';returnedValues['stream_date_end']=end;}}else if(data['stream_date_type']=='relative'){if(defaultValues['stream_date_relative_days']!==data['stream_date_relative_days']){returnedValues['stream_date_type']='relative';returnedValues['stream_date_relative_days']=data['stream_date_relative_days'];}}else if(defaultValues['stream_date_type']!==data['stream_date_type']){returnedValues['stream_date_type']=data['stream_date_type'];} if(data['stream_classes_type']==0&&defaultValues['stream_classes_type']==1){returnedValues['stream_classes']={};}else{var newClasses=_.without(_.keys(data['stream_classes']),'__EMPTY');var classIntersection=_.intersection(newClasses,_.keys(defaultValues['stream_classes']));if(classIntersection.length!==newClasses.length){returnedValues['stream_classes']=_.omit(data['stream_classes'],'__EMPTY');}} var containers={};if(!_.isUndefined(data['stream_classes'])&&_.isObject(data['stream_classes'])){_.each(_.without(_.keys(data['stream_classes']),'__EMPTY'),function(val,key){var contentType=$('div[data-role="streamContainer"][data-className="'+val.replace(/\\/g,'\\\\')+'"]').attr('data-contentKey');if(!_.isUndefined(contentType)&&$('input[name="stream_containers_'+contentType+'"]').length){containers[val]=$('input[name="stream_containers_'+contentType+'"]').val();}});} if(!_.isEmpty(containers)){if(!_.isUndefined(defaultValues['containers'])&&!_.isEqual(containers,defaultValues['containers'])){returnedValues['stream_containers']=containers;}} return returnedValues;},_buildRequestURL:function(extraParams){var urlDiff=this._getUrlDiff(this._formData);var params=[];_.each(urlDiff,function(val,key){if(_.isObject(val)){if(!_.size(val)){params.push(key+'=');}else{var keys=_.keys(val);var values=_.values(val);for(var i=0;i').addClass('ipsLoading');ips.getContainer().append(this._streamLoadingOverlay);} var dims=ips.utils.position.getElemDims(stream);var position=ips.utils.position.getElemPosition(stream);this._streamLoadingOverlay.show().css({left:position.viewportOffset.left+'px',top:position.viewportOffset.top+$(document).scrollTop()+'px',width:dims.width+'px',height:dims.height+'px',position:'absolute',zIndex:ips.ui.zIndex()});stream.css({opacity:"0.5"});}},_startTimer:function(interval){if(!this._autoUpdate){return;} if(!interval){interval=this._shortInterval;} if(this._timer){clearInterval(this._timer);} this._timer=setInterval(_.bind(this._autoFetchNew,this),interval*1000);},_togglePolling:function(status){if(!this._autoUpdate){clearInterval(this._timer);return;} if(status){this._startTimer();this.scope.find('[data-role="updateMessage"]').show();}else{if(this._timer){clearInterval(this._timer);this.scope.find('[data-role="updateMessage"]').hide();}}},_autoFetchNew:function(){var self=this;if(!_.isNumber(this._timestamp)||_.isNaN(this._timestamp)){Debug.log("Timestamp not a number");clearInterval(this._timer);return;} this._loadResults({after:this._timestamp},false,true).done(function(response){var count=parseInt(response.count);if(response.error&&response.error=='auto_polling_disabled'){self.scope.find('[data-role="updateMessage"]').remove();clearInterval(self._timer);return;} if(_.isNaN(count)||count==0){return;} self.triggerOn('core.front.streams.results','resultsTeaser.stream',{response:response});});},_stopPolling:function(){clearInterval(this._timer);this._autoUpdate=false;this.scope.find('[data-role="updateMessage"]').html(ips.getString('autoUpdateStopped'));Debug.log("Stopped polling due to user inactivity");},_updateTitle:function(count){},markAllRead:function(){this.scope.find('.ipsStreamItem_unread').removeClass('ipsStreamItem_unread').find('.ipsItemStatus:not(.ipsItemStatus_read)').addClass('ipsItemStatus_read');}});}(jQuery,_));; ;(function($,_,undefined){"use strict";ips.controller.register('core.front.streams.form',{loaded:{},formSnapshot:false,reloaded:false,_loadedContainer:{},_loadedClubs:false,_formData:{},initialize:function(){this.on('streamStateUpdate.streamForm',this.streamStateUpdate);this.on('itemClicked.sideMenu','[data-filterType="type"]',this.selectedType);this.on('menuItemSelected','#elStreamReadStatus, #elStreamShowMe',this.checkFormUpdate);this.on('tokenAdded tokenDeleted',this.tokensChanged);this.on('menuItemSelected','#elStreamSortEdit',this.changeSort);this.on('click','[data-action="saveStream"], [data-action="newStream"]',this.submitForm);this.on('click','[data-role="streamContainer"]',this.openStreamContainer);this.on('click','[data-role="streamClubs"]',this.openStreamClubs);this.on('click','[data-action="dismissSave"]',this.dismissSave);this.on('keydown','input',this.inputKeydown);if(this.scope.attr('data-formType')=='createStream'){this.on('itemClicked.sideMenu','[data-filterType="date"]',this.selectedDate);this.on('itemClicked.sideMenu','[data-filterType="ownership"]',this.selectedOwnership);}else{this.on('menuItemSelected','#elStreamFollowStatus',this.selectedFollowStatus);this.on('menuItemSelected','#elStreamTimePeriod',this.selectedDate);this.on('menuItemSelected','#elStreamOwnership',this.selectedOwnership);} this.on('change','#elSelect_stream_club_filter',this.clubSelectionChanged);this.on('change','#stream_club_filter_unlimited',this.clubSelectionChanged);this.on('nodeItemSelected',this.toggleApplyFilterButton);this.on('nodeItemUnselected',this.toggleApplyFilterButton);this.on('click','[data-action="applyFilters"]',this.applyFilters);this.on('menuItemSelected','#elStreamSortEdit, #elStreamFollowStatus',this.selectedMenuItem);this.on('menuItemSelected','#elStreamTimePeriod, #elStreamOwnership, #elStreamShowMe',this.selectedMenuItem);this.on('menuItemSelected','#elStreamReadStatus',this.selectedReadStatus);this.on('menuClosed',this.menuClosed);this.setup();},setup:function(){this._serializeConfig={'stream_date_range[start]':this._serializeDate,'stream_date_range[end]':this._serializeDate};if(this.scope.attr('data-formType')!='createStream'){this._formData=ips.getSetting('stream_config');this._changeReadStatus(this._formData['stream_read']);this._updateFilterOverview();this.takeFormSnapshot();} this.trigger('initialFormData.stream',{data:this._formData});},inputKeydown:function(e){if(e.which==13){e.preventDefault();}},toggleApplyFilterButton:function(e){var button=$('.ipsMenu').filter(':visible').first().find('[data-action="applyFilters"]');if(this.hasFormChanged()){button.removeClass('ipsButton_disabled');}else{button.addClass('ipsButton_disabled');}},applyFilters:function(e){var button=$(e.currentTarget);button.closest('.ipsMenu').trigger('closeMenu');},streamStateUpdate:function(e,data){this._formData=data.filterData;this._updateFieldValues();if(!_.isUndefined(data.hideSaveBar)&&data.hideSaveBar){this.scope.find('[data-role="saveButtonContainer"]').slideUp();}else{this.scope.find('[data-role="saveButtonContainer"]').slideDown();}},_updateFilterOverview:function(){if(this.scope.attr('data-formType')=='createStream'){return;} var self=this;var values=this._formData;var _overview=function(type){return self.scope.find('[data-filter="'+type+'"] [data-role="filterOverview"]');};_.each(['stream_include_comments','stream_read','stream_sort'],function(val){var lang='streamFilter_'+val+'_'+values[val];_overview(val).html(ips.getString(lang));});if(!_.isUndefined(values['stream_tags'])&&values['stream_tags'].trim()!==''){var tags=_.compact(values['stream_tags'].split(/\n/));if(tags.length<=2){var tagLang=ips.getString('streamFilter_stream_tags_tags',{'tags':_.escape(tags.join(','))});}else{var tagLang=ips.pluralize(ips.getString('streamFilter_stream_tags_count'),tags.length);} _overview('stream_include_comments').append('; '+tagLang);}else{_overview('stream_include_comments').append('; '+ips.getString('streamFilter_stream_tags_noTags'));} if(values['stream_ownership']=='custom'&&(_.isUndefined(values['stream_custom_members'])||values['stream_custom_members']==null||values['stream_custom_members']=='')){values['stream_ownership']='all'} if(values['stream_ownership']!=='custom'){var ownershipLang='streamFilter_stream_ownership_'+values['stream_ownership'];_overview('stream_ownership').html(ips.getString(ownershipLang));}else if(!_.isUndefined(values['stream_custom_members'])&&values['stream_custom_members']!=null){var names=_.compact((_.isObject(values['stream_custom_members'])?values['stream_custom_members']:values['stream_custom_members'].split(/\n/)));var ownershipLang=ips.pluralize(ips.getString('streamFilter_stream_ownership_custom'),names.length);_overview('stream_ownership').text(ownershipLang);} if(values['stream_follow']=='all'){_overview('stream_follow').html(ips.getString('streamFilter_stream_follow_all'));}else{var value=_.keys(values['stream_followed_types']);var follows=[];for(var i=0;i span');if(elem.length){classes.push(elem.text().trim());}} _overview('stream_classes').text(classes.join(', '));}},_updateFieldValues:function(){var self=this;var data=this._formData;if(data['stream_read']=='unread'){data['stream_include_comments']=0;} _.each(['stream_include_comments','stream_read','stream_sort','stream_follow','stream_ownership','stream_date_type'],function(key){self.scope.find('[name="'+key+'"]').prop('checked',false).closest('.ipsMenu_item').removeClass('ipsMenu_itemChecked').end().filter('[value="'+data[key]+'"]').prop('checked',true).change().closest('.ipsMenu_item').addClass('ipsMenu_itemChecked');});var followSelector=_.map(data['stream_followed_types'],function(val,key){return'[name="stream_followed_types['+key+']"]';});this.scope.find('[name^="stream_followed_types"]').prop('checked',false).closest('.ipsMenu_item').removeClass('ipsMenu_itemChecked').end().filter(followSelector.join(',')).prop('checked',true).change().closest('.ipsMenu_item').addClass('ipsMenu_itemChecked');if(this.scope.find('#elInput_stream_custom_members').length){var ownerAC=ips.ui.autocomplete.getObj(this.scope.find('#elInput_stream_custom_members'));ownerAC.removeAll();if(data['stream_ownership']=='custom'){var names=_.compact(data['stream_custom_members'].split(/\n/));for(var i=0;i').attr('type','hidden').attr('name','do').attr('value','create'));}else{this._formData=ips.utils.form.serializeAsObject(this.scope.find('form'),this._serializeConfig);this.trigger('formSubmitted.stream',{data:this._formData,action:(button.attr('data-action')=='newStream')?'createForm':'saveForm'});}},updateResults:function(){this._formData=ips.utils.form.serializeAsObject(this.scope.find('form'),this._serializeConfig);this._updateFilterOverview();this.trigger('formSubmitted.stream',{data:this._formData,action:'updateForm'});},selectedDate:function(e,data){this.reloaded=false;if(data.selectedItemID=='custom'){this.scope.find('[data-role="dateRelativeForm"]').slideUp();this.scope.find('[data-role="dateForm"]').slideDown();}else if(data.selectedItemID=='relative'){this.scope.find('[data-role="dateForm"]').slideUp();this.scope.find('[data-role="dateRelativeForm"]').slideDown();this.scope.find('[name="stream_date_relative_days"]').focus();}else{if(!_.isUndefined(data.selectedItemID)){this.scope.find('[data-role="dateForm"]').slideUp();this.scope.find('[data-role="dateRelativeForm"]').slideUp();this.checkFormUpdate();}}},selectedFollowStatus:function(e,data){var selectedItems=data.selectedItems;if(!_.size(selectedItems)){this.scope.find('[name="stream_follow"]').val('all');}else{this.scope.find('[name="stream_follow"]').val('followed');} this.checkFormUpdate();},selectedOwnership:function(e,data){if(data.selectedItemID=='custom'){this.scope.find('[data-role="ownershipMemberForm"]').slideDown();}else{if(!_.isUndefined(data.selectedItemID)){this.scope.find('[data-role="ownershipMemberForm"]').slideUp();this.checkFormUpdate();}}},clubSelectionChanged:function(e,data){if(this.scope.find('[name="stream_club_filter_dummy_unlimited"]').is(':checked')){this.scope.find('[name="stream_club_select"]').val('all');}else{this.scope.find('[name="stream_club_select"]').val('select');this.scope.find('[name="stream_club_filter"]').val($('#elSelect_stream_club_filter').val());} this.toggleApplyFilterButton();},selectedType:function(e,data){var self=this;var typeMenu=this.scope.find('[data-filterType="type"]');var all=typeMenu.find('[data-ipsMenuValue="__all"]');var allButAll=typeMenu.find('[data-ipsMenuValue]:not( [data-ipsMenuValue="__all"] )');var allButAllChecks=allButAll.find('> input[type="checkbox"]');this.reloaded=false;this.toggleApplyFilterButton();if(data.selectedItemID=='__all'){allButAll.removeClass('ipsSideMenu_itemActive').find('> input[type="checkbox"]').prop('checked',false);all.addClass('ipsSideMenu_itemActive');this.scope.find('input[type="radio"][name="stream_classes_type"][value="0"]').prop('checked',true);this.scope.find('[data-contentType]').closest('.cStreamForm_nodes').slideUp();}else{if(allButAllChecks.filter(':checked').length){all.removeClass('ipsSideMenu_itemActive') this.scope.find('input[type="radio"][name="stream_classes_type"][value="1"]').prop('checked',true);allButAllChecks.filter(':checked').each(function(){var type=$(this).closest('[data-ipsMenuValue]').attr('data-ipsMenuValue');if(self.scope.find('[data-contentType="'+type+'"]').length){self.scope.find('[data-contentType="'+type+'"]').slideDown();}});allButAllChecks.filter(':not( :checked )').each(function(){var type=$(this).closest('[data-ipsMenuValue]').attr('data-ipsMenuValue');if(self.scope.find('[data-contentType="'+type+'"]').length){self.scope.find('[data-contentType="'+type+'"]').slideUp();}})}else{all.addClass('ipsSideMenu_itemActive').find('> input[type="checkbox"]').prop('checked',true);this.scope.find('[data-contentType]').slideUp();}}},_serializeDate:function(name,value){if(ips.utils.time.supportsHTMLDate()){return value;} var dateObj=ips.utils.time.getDateFromInput($('input[name='+ips.utils.css.escapeSelector(name)+']'));if(!ips.utils.time.isValidDateObj(dateObj)){return'';} var month=('0'+(dateObj.getUTCMonth()+1)).slice(-2);var day=('0'+(dateObj.getUTCDate())).slice(-2);return dateObj.getUTCFullYear()+'-'+month+'-'+day;}});}(jQuery,_));;