summaryrefslogtreecommitdiffstats
path: root/js/build/app.min.js
blob: 0fcdcafc86b42a6103d0b24e985b9b4dc3d20281 (plain)
1
!function(a,b,c,d,e,f,g){"use strict";var h=c.module("News",["ngRoute","ngSanitize"]);h.config(["$routeProvider","$provide","$httpProvider",function(a,b,c){var d={FEED:0,FOLDER:1,STARRED:2,SUBSCRIPTIONS:3,SHARED:4};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",function(a,b){return{request:function(c){return 0===c.url.indexOf(b)&&(c.headers.requesttoken=f),c||a.when(c)}}}]),c.interceptors.push("CSRFInterceptor");var h=function(a){return{data:["$http","$route","$q","BASE_URL","ITEM_BATCH_SIZE",function(b,c,d,e,f){var h={type:a,limit:f};c.current.params.id!==g&&(h.id=c.current.params.id);var i=d.defer();return b({url:e+"/items",method:"GET",params:h}).success(function(a){i.resolve(a)}),i.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})}]),h.run(["$rootScope","$location","$http","$q","$interval","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){f.setLoading("global",!0),k.subscribe(g).toChannels(["items","newestItemId","starred"]),k.subscribe(i).toChannels(["folders"]),k.subscribe(h).toChannels(["feeds"]),k.subscribe(j).toChannels(["settings"]);var o=d.defer();c.get(l+"/settings").success(function(a){k.publishAll(a),o.resolve()});var p=d.defer(),q=b.path();c.get(l+"/feeds/active").success(function(a){var c;switch(a.activeFeed.type){case m.FEED:c="/items/feeds/"+a.activeFeed.id;break;case m.FOLDER:c="/items/folders/"+a.activeFeed.id;break;case m.STARRED:c="/items/starred";break;default:c="/items"}/^\/items(\/(starred|feeds\/\d+|folders\/\d+))?\/?$/.test(q)||b.path(c),p.resolve()});var r=d.defer();c.get(l+"/folders").success(function(a){k.publishAll(a),r.resolve()});var s=d.defer();c.get(l+"/feeds").success(function(a){k.publishAll(a),s.resolve()}),d.all([o.promise,p.promise,s.promise,r.promise]).then(function(){f.setLoading("global",!1)}),e(function(){c.get(l+"/feeds").success(function(a){k.publishAll(a)}),c.get(l+"/folders").success(function(a){k.publishAll(a)})},1e3*n),a.$on("$routeChangeStart",function(){f.setLoading("content",!0)}),a.$on("$routeChangeSuccess",function(){f.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",function(a,b,c,d,e,f,h,i){c.clear(),a.publishAll(e),this.isAutoPagingEnabled=!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.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,!1)),d.keepUnread=!d.keepUnread},this.orderBy=function(){return d.get("oldestFirst")?"id":"-id"},this.isCompactView=function(){return d.get("compact")},this.autoPagingEnabled=function(){return this.isAutoPagingEnabled},this.markReadEnabled=function(){return!d.get("preventReadOnScroll")},this.scrollRead=function(a){var d=[],e=[];a.forEach(function(a){var b=c.get(a);b.keepUnread||(d.push(a),e.push(b.feedId))}),d.length>0&&(b.markItemsOfFeedsRead(e),c.markItemsRead(d))},this.isFeed=function(){return f.current.$$route.type===i.FEED},this.autoPage=function(){if(!this.isAutoPagingEnabled)return void(this.autoPageAgain=!0);this.isAutoPagingEnabled=!1,this.autoPageAgain=!1;var b=f.current.$$route.type,e=h.id,g=d.get("oldestFirst"),i=this;c.autoPage(b,e,g).success(function(b){a.publishAll(b),b.items.length>0&&(i.isAutoPagingEnabled=!0),i.isAutoPagingEnabled&&i.autoPageAgain&&i.autoPage()}).error(function(){i.isAutoPagingEnabled=!0})},this.getRelativeDate=function(a){if(a!==g&&""!==a){var b=d.get("language"),c=moment.unix(a).locale(b).fromNow()+"";return c}return""},this.refresh=function(){f.reload()}}]),h.controller("NavigationController",["$route"