summaryrefslogtreecommitdiffstats
path: root/js/build/app.min.js
blob: fa31b57e112e70b9e58ff9dee0d073c9b7dca4c3 (plain)
1
var $__app__=function(){"use strict";return function(a,b,c,d,e,f,g){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};b.constant("REFRESH_RATE",60),b.constant("ITEM_BATCH_SIZE",50),b.constant("BASE_URL",e.generateUrl("/apps/news")),b.constant("FEED_TYPE",d),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"),c.get(l+"/folders")},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",function(a,b,c,d,e,f,h){var i=this;c.clear(),a.publishAll(e),this.isAutoPagingEnabled=!0,this.getItems=function(){return c.getAll()},this.toggleStar=function(a){c.toggleStar(a)},this.markRead=function(a){var d=c.get(a);d.keepUnread||(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 i.isAutoPagingEnabled},this.markReadEnabled=function(){return!d.get("preventReadOnScroll")},this.scrollRead=function(a){for(var d,e,f,g=[],h=[],i=a[$traceurRuntime.toProperty(Symbol.iterator)]();!(f=i.next()).done;)d=f.value,e=c.get(d),e.keepUnread||(g.push(d),h.push(e.feedId));b.markItemsOfFeedsRead(h),c.markItemsRead(g)},this.autoPage=function(){i.isAutoPagingEnabled=!1;var b=f.current.$$route.type,d=h.id;c.autoPage(b,d).success(function(b){a.publishAll(b),b.items.length>0&&(i.isAutoPagingEnabled=!0)}).error(function(){i.isAutoPagingEnabled=!0})},this.getRelativeDate=function(a){var b,c;return a!==g&&""!==a?(b=d.get("language"),c=moment.unix(a).locale(b).fromNow()+""):""}}]),h.controller("NavigationController",["$route","FEED_TYPE","FeedResource","FolderResource","ItemResource","SettingsResource",function(a,b,c,d,e,f){var h=this;this.feedError="",this.folderError="",this.getFeeds=function(){return c.getAll()},this.getFolders=function(){return d.getAll()},this.markFolderRead=function(a){var b;c.markFolderRead(a);for(var d,f=c.getByFolderId(a)[$traceurRuntime.toProperty(Symbol.iterator)]();!(d=f.next()).done;)b=d.value,e.markFeedRead(b.id)},this.markFeedRead=function(a){e.markFeedRead(a),c.markFeedRead(a)},this.markRead=function(){e.markRead(),c.markRead()},this.isShowAll=function(){return f.get("showAll")},this.getFeedsOfFolder=function(a){return c.getByFolderId(a)},this.getUnreadCount=function(){return c.getUnreadCount()},this.getFeedUnreadCount=function(a){return c.getById(a).unreadCount},this.getFolderUnreadCount=function(a){return c.getFolderUnreadCount(a)},this.getStarredCount=function(){return e.getStarredCount()},this.toggleFolder=function(a){d.toggleOpen(a)},this.hasFeeds=function(a){return c.getFolderUnreadCount(a)!==g},this.subFeedActive=function(d){var e,f=a.current.$$route.type;return f===b.FEED&&(e=c.getById(a.current.params.id),e.folderId===d)?!0:!1},this.isSubscriptionsActive=function(){return a.current&&a.current.$$route.type===b.SUBSCRIPTIONS},this.isStarredActive=function(){return a.current&&a.current.$$route.type===b.STARRED},this.isFolderActive=function(c){var d=parseInt(a.current.params.id,10);return a.current&&a.current.$$route.type===b.FOLDER&&d===c},this.isFeedActive=function(c){var d=parseInt(a.current.params.id,10);return a.current&&a.current.$$route.type===b.FEED&&d===c},this.folderNameExists=function(a){return d.get(a)!==g},this.isAddingFolder=function(){return!0},this.createFolder=function(a){console.log(a.name),a.name=""},this.createFeed=function(a){h.newFolder=!1,console.log(a.url+a.folder),a.url=""},this.cancelRenameFolder=function(a){console.log(a)},