try{services.factory("LiveHelperChatViewsFactory",["$http","$q",function(e,t){return this.updateViewsList=function(i){var n=t.defer();return e.get(WWW_DIR_JAVASCRIPT+"views/updateviews").then((function(e){void 0!==e.error_url?document.location=e.data.error_url:n.resolve(e.data)}),(function(e){n.reject(void 0!==e.status?"["+e.status+"]":"[0]")})),n.promise},this.loadInitialData=function(i){var n=t.defer();return e.get(WWW_DIR_JAVASCRIPT+"views/loadinitialdata"+i).then((function(e){void 0!==e.error_url?document.location=e.data.error_url:n.resolve(e.data)}),(function(e){n.reject(void 0!==e.status?"["+e.status+"]":"[0]")})),n.promise},this.loadView=function(i,n){var r=t.defer(),s=void 0!==n?n:"";return e.get(WWW_DIR_JAVASCRIPT+"views/loadview/"+i+s).then((function(e){r.resolve(e.data)}),(function(e){r.reject(void 0!==e.status?"["+e.status+"]":"[0]")})),r.promise},this.deleteView=function(i){var n=t.defer();return e.post(WWW_DIR_JAVASCRIPT+"views/deleteview/"+i).then((function(e){n.resolve(e.data)}),(function(e){n.reject(void 0!==e.status?"["+e.status+"]":"[0]")})),n.promise},this.updatePassiveMode=function(i){var n=t.defer();return e.post(WWW_DIR_JAVASCRIPT+"views/updatepassivemode/"+i).then((function(e){n.resolve(e.data)}),(function(e){n.reject(void 0!==e.status?"["+e.status+"]":"[0]")})),n.promise},this.loadViewPage=function(i){var n=t.defer();return e.get(i+"/(mode)/list").then((function(e){n.resolve(e.data)}),(function(e){n.reject(void 0!==e.status?"["+e.status+"]":"[0]")})),n.promise},this.truncate=function(e,t,i){return isNaN(t)&&(t=10),void 0===i&&(i="..."),e.length<=t||e.length-i.length<=t?e:String(e).substring(0,t-i.length)+i},this}]),lhcAppControllers.controller("LiveHelperChatViewsCtrl",["$scope","$http","$location","$rootScope","$log","$interval","$window","LiveHelperChatViewsFactory",function(e,t,i,n,r,s,a,o){e.current_user_id=confLH.user_id,this.views=[],this.invites=0,this.default_view_id=0,this.currentView=null,this.updateTimeout=null,this.updateViewsTimeout=null;var u=this;ee.addListener("views.updateViews",(function(e){u.fetchViews()})),this.shareView=function(e){lhc.revealModal({url:WWW_DIR_JAVASCRIPT+"views/shareview/"+e.id})},this.initLHCData=function(){o.loadInitialData("").then((function(e){if(u.views=e.views,u.invites=e.invites,u.views.length>0){var t=u.views[0];a.vctrl_default_view_id&&angular.forEach(u.views,(function(e){e.id==a.vctrl_default_view_id&&(t=e)})),u.loadView(t)}u.setUpdateLive(),u.setUpdateLiveViews()})),$("#view-content").on("click",".page-link",(function(e){if(e.stopPropagation(),e.preventDefault(),"#"!=$(e.target).attr("href")){var t=$(e.target).attr("href"),i=t.match(/\(page\)\/(\d+)/),n=1;null!=i&&(n=i[1]),u.currentView.page=n,u.updateViewList(t)}}))},this.updateViewList=function(e){o.loadViewPage(e).then((function(e){document.getElementById("view-content-list").innerHTML=e.body,null!=u.currentView&&u.currentView.id==e.view_id&&(u.currentView.total_records=e.total_records),u.protectCSFR()}))},this.changePassiveMode=function(e){e.passive=!e.passive,o.updatePassiveMode(e.id).then((function(e){}))},this.setUpdateLiveViews=function(){clearTimeout(this.updateViewsTimeout),this.updateViewsTimeout=setTimeout((function(){o.updateViewsList().then((function(e){u.views=e.views,u.invites=e.invites})),u.setUpdateLiveViews()}),5e3)},this.setUpdateLive=function(){clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout((function(){null!=u.currentView&&u.updateViewList(WWW_DIR_JAVASCRIPT+"views/loadview/"+u.currentView.id+"/(page)/"+u.currentView.page),u.setUpdateLive()}),2e4)},this.fetchViews=function(){o.loadInitialData("").then((function(e){u.views=e.views,u.invites=e.invites}))},this.deleteView=function(e){confirm("Are you sure?")&&o.deleteView(e.id).then((function(){u.views.splice(u.views.indexOf(e),1),null!==u.currentView&&u.currentView.id==e.id&&(u.currentView=null),u.views.length>0&&u.loadView(u.views[0])}))},this.cleanupTabs=function(){var e=[];$.each(lhinst.chatsSynchronising,(function(t,i){e.push(i)})),$.each(e,(function(e,t){lhinst.removeSynchroChat(t)}))},this.loadView=function(e){this.cleanupTabs(),u.currentView=e,u.currentView.page=1,o.loadView(e.id).then((function(e){null!==u.currentView&&u.currentView.id==e.view_id&&(document.getElementById("view-content").innerHTML=e.body,u.currentView.total_records=e.total_records,u.protectCSFR())}))},this.exportView=function(e){lhc.revealModal({title:"Export",height:350,backdrop:!0,url:WWW_DIR_JAVASCRIPT+"/views/exportview/"+e.id})},this.protectCSFR=function(){$("#view-content a.csfr-required").click((function(){var e=$(this);e.attr("data-secured")||(e.attr("href",e.attr("href")+"/(csfr)/"+confLH.csrf_token),e.attr("data-secured",1))}))},this.initLHCData()}])}catch(e){if(!lhcError)throw Error("lhc : "+e.message);lhcError.log(e.message,"angular.lhc-views.js",e.lineNumber||e.line,e.stack)}
//# sourceMappingURL=3c8de6c14d5fa1e50a3e8a08c8fc53bf.js.map
