;(function($,_,undefined){"use strict";ips.controller.register('pocketfives.front.localwall.locationSelector',{initialize:function(){var location=window.location.pathname.replace(/^\/|\/$/g,'').split('/');this.on('submit',this.changeLocation);this.on('change','[data-role="countrySelect"]',this.locationChanged);if(this.scope.find('[data-role="countrySelect"]').find('option[name="'+location[0]+'"]').length){this.scope.find('[data-role="countrySelect"]').val(location[0]).trigger('change');}else{this.scope.find('[data-role="countrySelect"]').val(location[0]+'/community').trigger('change');}
if(location[1]){if(this.scope.find('[data-role="regionSelect"]').find('option[name="'+location[1]+'"]').length){this.scope.find('[data-role="regionSelect"]').val(location[1]).trigger('change');}else{this.scope.find('[data-role="regionSelect"]').val(location[1]+'/community').trigger('change');}}},locationChanged:function(e){var countrySelect=$(e.target);var regionSelect=this.scope.find('[data-role="regionSelect"]');var regionOptions='<option value=""></option>';var countryID=countrySelect.find(':selected').data('countryid');var regions=this.scope.data('regions');if(regions[countryID]!==undefined){regionSelect.parent().parent().show();for(var i=0;i<regions[countryID].length;i++){regionOptions+='<option value="'+regions[countryID][i].name_seo+'">'+regions[countryID][i].name+'</option>';}
regionSelect.html(regionOptions);}else{regionSelect.val('');regionSelect.parent().parent().hide();}},changeLocation:function(e){e.preventDefault();var countrySelect=this.scope.find('[data-role="countrySelect"]');var regionSelect=this.scope.find('[data-role="regionSelect"]');var location=[];location.push(countrySelect.val());if(regionSelect.val()){if(countrySelect.val().indexOf('community')!==-1){location.pop();location.push(countrySelect.val().replace('/community',''));}
location.push(regionSelect.val());}
window.location='/'+location.join('/')+'/';}});}(jQuery,_));;
;(function($,_,undefined){"use strict";ips.controller.register('pocketfives.front.localwall.wallfeed',{_leaveAloneFirstTime:true,_leaveAloneFirstTimeTopic:true,initialize:function(){this.on('submit','.wall_post_form',this.postWall);this.on('click','.wall_post_form .cancel',this.closeForm);this.on('click','.wall_post_form .ipsComposeArea_dummy',this.openForm);this.on('click','.wall_filters',this.toggleFilters);$("#check_add_hand").trigger('change');},toggleFilters:function(e){e.preventDefault();$('#elWallFilterForm').toggle();},toggleCommentForm:function(e){e.preventDefault();if(this._leaveAloneFirstTime&&$(e.currentTarget).is('.ipsComposeArea_dummy')){this._leaveAloneFirstTime=false;return false;}
$(e.currentTarget).parents('.ipsForm').find('[data-role="mainEditorArea"], [data-ipseditor-toollist], .ipsComposeArea_dummy').toggle();},closeForm:function(e){e.preventDefault();$(".wall_post_form").find('.ipsComposeArea_dummy').show().end().find('.inputsContainer > div').slice(1).hide();},openForm:function(e){e.preventDefault();$(".wall_post_form").find('.ipsComposeArea_dummy').hide().end().find('.inputsContainer > div').slice(1).show();},postWall:function(e){e.preventDefault();if(ipsSettings.memberID===0){location.href='/register/';}
ips.getAjax()($(e.currentTarget).attr('action'),{data:$(e.currentTarget).serialize(),type:'post'}).done(function(data){ips.ui.flashMsg.show(data.msg);ips.ui.editor.getObj($(".wall_post_form [data-ipsEditor]")).reset();$(".wall_post_form").trigger('reset');$(".wall_post_form .cancel").trigger('click');$("div[data-tableid='topics'] [data-role='tableRows']").prepend(data.content);});}});}(jQuery,_));;