summaryrefslogtreecommitdiffstats
path: root/js/build/app.min.js
blob: cd0e6a4ae078f389e0769405999ad3ca33c06761 (plain)
1
2
!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)}}}]),b.factory("ConnectionErrorInterceptor",["$q","$timeout",function(a,b){var c;return{responseError:function(d){var f={0:t("news","Request failed, network connection unavailable!"),401:t("news","Request unauthorized. Are you logged in?"),403:t("news","Request forbidden. Are you an admin?"),412:t("news","Token expired or app not enabled! Try to reload the page!"),500:t("news","Internal server error! Please check your data/owncloud.log file for additional information!"),503:t("news","Request failed, ownCloud is in currently in maintenance mode!")};return d.status in f&&(c&&b.cancel(c),e.Notification.hide(),e.Notification.showHtml(f[d.status]),c=b(function(){e.Notification.hide()},5e3)),a.reject(d)}}}]),c.interceptors.push("CSRFInterceptor"),c.interceptors.push("ConnectionErrorInterceptor");var h=function(a){return{data:["$http","$route","$q","BASE_URL","ITEM_BATCH_SIZE","FEED_TYPE","SettingsResource","FeedResource",function(b,c,d,e,f,h,i,j){var k=i.get("showAll"),l=i.get("oldestFirst"),m=d.defer();if(null===k||null===l)m.resolve({});else{var n={type:a,limit:f,showAll:k,oldestFirst:l};if(c.current.params.id!==g&&(n.id=c.current.params.id),a===h.FEED){var o=j.getById(n.id);1===o.ordering?n.oldestFirst=!0:2===o.ordering&&(n.oldestFirst=!1)}b({url:e+"/items",method:"GET",params:n}).success(function(a){m.resolve(a)})}return m.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,