summaryrefslogtreecommitdiffstats
path: root/js/build/app.min.js
blob: c07ee600caf24084d9c723ebe2cc8bac4c3864cb (plain)
1
!function(a,b,c,d,e,f,g){"use strict";var h=c.module("News",["ngRoute","ngSanitize","ngAnimate"]);h.config(["$routeProvider","$provide","$httpProvider",function(a,b,c){var d={FEED:0,FOLDER:1,STARRED:2,SUBSCRIPTIONS:3,SHARED:4,EXPLORE:5};b.constant("REFRESH_RATE",60),b.constant("ITEM_BATCH_SIZE",40),b.constant("ITEM_AUTO_PAGE_SIZE",20),b.constant("BASE_URL",e.generateUrl("/apps/news")),b.constant("FEED_TYPE",d),b.constant("MARK_READ_TIMEOUT",.5),b.constant("SCROLL_TIMEOUT",.1),b.factory("CSRFInterceptor",["$q","BASE_URL","$window",function(a,b,c){return{request:function(d){var e=c.location.href.split(c.location.pathname)[0];return(0===d.url.indexOf(b)||0===d.url.indexOf(e))&&(d.headers.requesttoken=f),d||a.when(d)}}}]),c.interceptors.push("CSRFInterceptor");var h=function(a){return{data:["$http","$route","$q","BASE_URL","ITEM_BATCH_SIZE","SettingsResource",function(b,c,d,e,f,h){var i=h.get("showAll"),j=h.get("oldestFirst"),k=d.defer();if(null===i||null===j)k.resolve({});else{var l={type:a,limit:f,showAll:i,oldestFirst:j};c.current.params.id!==g&&(l.id=c.current.params.id),b({url:e+"/items",method:"GET",params:l}).success(function(a){k.resolve(a)})}return k.promise}]}},i=function(){return{sites:["$http","$q","BASE_URL","Publisher","SettingsResource",function(a,b,c,d,e){var f=b.defer();return a.get(c+"/settings").then(function(b){d.publishAll(b);var c=e.get("exploreUrl"),f=e.get("language");return a({url:c,method:"GET",params:{lang:f}})}).then(function(a){f.resolve(a.data)}).catch(function(){f.reject()}),f.promise}]}};a.when("/items",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.SUBSCRIPTIONS),type:d.SUBSCRIPTIONS}).when("/items/starred",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.STARRED),type:d.STARRED}).when("/items/feeds/:id",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.FEED),type:d.FEED}).when("/items/folders/:id",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.FOLDER),type:d.FOLDER}).when("/explore",{controller:"ExploreController as Explore",templateUrl:"explore.html",resolve:i(),type:d.EXPLORE}).when("/shortcuts",{templateUrl:"shortcuts.html",type:-1})}]),h.run(["$rootScope","$location","$http","$q","$interval","$route","Loading","ItemResource","FeedResource","FolderResource","SettingsResource","Publisher","BASE_URL","FEED_TYPE","REFRESH_RATE",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){g.setLoading("global",!0),l.subscribe(h).toChannels(["items","newestItemId","starred"]),l.subscribe(j).toChannels(["folders"]),l.subscribe(i).toChannels(["feeds"]),l.subscribe(k).toChannels(["settings"]);var p=d.defer();c.get(m+"/settings").success(function(a){l.publishAll(a),p.resolve()});var q=d.defer(),r=b.path();c.get(m+"/feeds/active").success(function(a){var c;switch(a.activeFeed.type){case n.FEED:c="/items/feeds/"+a.activeFeed.id;break;case n.FOLDER:c="/items/folders/"+a.activeFeed.id;break;case n.STARRED:c="/items/starred";break;case n.EXPLORE:c="/explore";break;default:c="/items"}/^\/items(\/(starred|explore|feeds\/\d+|folders\/\d+))?\/?$/.test(r)||b.path(c),q.resolve()});var s,t=d.defer();c.get(m+"/feeds").success(function(a){s=a,t.resolve()});var u,v=d.defer();c.get(m+"/folders").success(function(a){u=a,v.resolve()}),d.all([t.promise,v.promise]).then(function(){l.publishAll(s),l.publishAll(u),0===s.feeds.length&&0===u.folders.length&&b.path("/explore")}),d.all([p.promise,q.promise,t.promise,v.promise]).then(function(){f.reload(),g.setLoading("global",!1)}),e(function(){c.get(m+"/feeds").success(function(a){l.publishAll(a)}),c.get(m+"/folders").success(function(a){l.publishAll(a)})},1e3*o),a.$on("$routeChangeStart",function(){g.setLoading("content",!0)}),a.$on("$routeChangeSuccess",function(){g.setLoading("content",!1)}),a.$on("$routeChangeError",function(){b.path("/items")})}]),h.controller("AppController",["Loading","FeedResource","FolderResource",function(a,b,c){this.loading=a,this.isFirstRun=function(){return 0===b.size()&&0===c.size()}}]),h.controller("ContentController",["Publisher","FeedResource","ItemResource","SettingsResource","data","$route","$routeParams","FEED_TYPE","ITEM_AUTO_PAGE_SIZE","Loading",function(a,b,c,d,e,f,h,i,j,k){c.clear(),a.publishAll(e),this.isAutoPagingEnabled=!0,this.isNothingMoreToAutoPage=c.size()>=j?!1:!0,this.getItems=function(){return c.getAll()},this.toggleStar=function(a){c.toggleStar(a)},this.toggleItem=function(a){this.isCompactView()&&(a.show=!a.show)},this.isShowAll=function(){return d.get("showAll")},this.markRead=function(a){var d=c.get(a);d.keepUnread||d.unread!==!0||(c.markItemRead(a),b.markItemOfFeedRead(d.feedId))},this.getFeed=function(a){return b.getById(a)},this.toggleKeepUnread=function(a){var d=c.get(a);d.unread||(b.markItemOfFeedUnread(d.feedId),c.markItemRead(a,!