mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
apply new js formatter
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
var module = angular.module('commafeed.directives', []);
|
var module = angular.module('commafeed.directives', []);
|
||||||
|
|
||||||
module.directive('focus', [ '$timeout', function($timeout) {
|
module.directive('focus', ['$timeout', function($timeout) {
|
||||||
return {
|
return {
|
||||||
restrict : 'A',
|
restrict : 'A',
|
||||||
link : function(scope, element, attrs) {
|
link : function(scope, element, attrs) {
|
||||||
@@ -13,7 +13,7 @@ module.directive('focus', [ '$timeout', function($timeout) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} ]);
|
}]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a popup window pointing to the url in the href attribute
|
* Open a popup window pointing to the url in the href attribute
|
||||||
@@ -70,7 +70,7 @@ module.directive('onScrollMiddle', function() {
|
|||||||
var w = $(window);
|
var w = $(window);
|
||||||
var e = $(element);
|
var e = $(element);
|
||||||
var d = $(document);
|
var d = $(document);
|
||||||
|
|
||||||
var offset = parseInt(attrs.onScrollMiddleOffset, 10);
|
var offset = parseInt(attrs.onScrollMiddleOffset, 10);
|
||||||
|
|
||||||
var down = function() {
|
var down = function() {
|
||||||
@@ -90,12 +90,10 @@ module.directive('onScrollMiddle', function() {
|
|||||||
if (!w.data.scrollInit) {
|
if (!w.data.scrollInit) {
|
||||||
w.data.scrollPosition = d.scrollTop();
|
w.data.scrollPosition = d.scrollTop();
|
||||||
w.data.scrollDirection = 'down';
|
w.data.scrollDirection = 'down';
|
||||||
|
|
||||||
var onScroll = function(e) {
|
var onScroll = function(e) {
|
||||||
var scroll = d.scrollTop();
|
var scroll = d.scrollTop();
|
||||||
w.data.scrollDirection = (scroll
|
w.data.scrollDirection = (scroll - w.data.scrollPosition > 0) ? 'down' : 'up';
|
||||||
- w.data.scrollPosition > 0) ? 'down'
|
|
||||||
: 'up';
|
|
||||||
w.data.scrollPosition = scroll;
|
w.data.scrollPosition = scroll;
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
};
|
};
|
||||||
@@ -115,10 +113,10 @@ module.directive('onScrollMiddle', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrolls to the element if the value is true and the attribute is not fully visible,
|
* Scrolls to the element if the value is true and the attribute is not fully
|
||||||
* unless the attribute scroll-to-force is true
|
* visible, unless the attribute scroll-to-force is true
|
||||||
*/
|
*/
|
||||||
module.directive('scrollTo', [ '$timeout', function($timeout) {
|
module.directive('scrollTo', ['$timeout', function($timeout) {
|
||||||
return {
|
return {
|
||||||
restrict : 'A',
|
restrict : 'A',
|
||||||
link : function(scope, element, attrs) {
|
link : function(scope, element, attrs) {
|
||||||
@@ -126,7 +124,7 @@ module.directive('scrollTo', [ '$timeout', function($timeout) {
|
|||||||
if (!value)
|
if (!value)
|
||||||
return;
|
return;
|
||||||
var force = scope.$eval(attrs.scrollToForce);
|
var force = scope.$eval(attrs.scrollToForce);
|
||||||
|
|
||||||
// timeout here to execute after dom update
|
// timeout here to execute after dom update
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
var docTop = $(window).scrollTop();
|
var docTop = $(window).scrollTop();
|
||||||
@@ -149,7 +147,7 @@ module.directive('scrollTo', [ '$timeout', function($timeout) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} ]);
|
}]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent mousewheel scrolling from propagating to the parent when scrollbar
|
* Prevent mousewheel scrolling from propagating to the parent when scrollbar
|
||||||
@@ -164,9 +162,7 @@ module.directive('mousewheelScrolling', function() {
|
|||||||
if (d > 0 && t.scrollTop() === 0) {
|
if (d > 0 && t.scrollTop() === 0) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else {
|
} else {
|
||||||
if (d < 0
|
if (d < 0 && (t.scrollTop() == t.get(0).scrollHeight - t.innerHeight())) {
|
||||||
&& (t.scrollTop() == t.get(0).scrollHeight
|
|
||||||
- t.innerHeight())) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +175,7 @@ module.directive('mousewheelScrolling', function() {
|
|||||||
* Needed to use recursive directives. Wrap a recursive element with a
|
* Needed to use recursive directives. Wrap a recursive element with a
|
||||||
* <recursive> tag
|
* <recursive> tag
|
||||||
*/
|
*/
|
||||||
module.directive('recursive', [ '$compile', function($compile) {
|
module.directive('recursive', ['$compile', function($compile) {
|
||||||
return {
|
return {
|
||||||
restrict : 'E',
|
restrict : 'E',
|
||||||
priority : 100000,
|
priority : 100000,
|
||||||
@@ -196,12 +192,12 @@ module.directive('recursive', [ '$compile', function($compile) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} ]);
|
}]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reusable category component
|
* Reusable category component
|
||||||
*/
|
*/
|
||||||
module.directive('category', [ function() {
|
module.directive('category', [function() {
|
||||||
return {
|
return {
|
||||||
scope : {
|
scope : {
|
||||||
node : '=',
|
node : '=',
|
||||||
@@ -215,110 +211,98 @@ module.directive('category', [ function() {
|
|||||||
restrict : 'E',
|
restrict : 'E',
|
||||||
replace : true,
|
replace : true,
|
||||||
templateUrl : 'templates/_category.html',
|
templateUrl : 'templates/_category.html',
|
||||||
controller : [
|
controller : ['$scope', '$state', '$dialog', 'FeedService', 'CategoryService', 'SettingsService', 'MobileService',
|
||||||
'$scope',
|
function($scope, $state, $dialog, FeedService, CategoryService, SettingsService, MobileService) {
|
||||||
'$state',
|
$scope.settingsService = SettingsService;
|
||||||
'$dialog',
|
|
||||||
'FeedService',
|
|
||||||
'CategoryService',
|
|
||||||
'SettingsService',
|
|
||||||
'MobileService',
|
|
||||||
function($scope, $state, $dialog, FeedService, CategoryService,
|
|
||||||
SettingsService, MobileService) {
|
|
||||||
$scope.settingsService = SettingsService;
|
|
||||||
|
|
||||||
$scope.getClass = function(level) {
|
$scope.getClass = function(level) {
|
||||||
if ($scope.showLabel) {
|
if ($scope.showLabel) {
|
||||||
return 'indent' + level;
|
return 'indent' + level;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.categoryLabel = function(category) {
|
$scope.categoryLabel = function(category) {
|
||||||
return $scope.showLabel !== true ? $scope.showLabel
|
return $scope.showLabel !== true ? $scope.showLabel : category.name;
|
||||||
: category.name;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
$scope.categoryCountLabel = function(category) {
|
$scope.categoryCountLabel = function(category) {
|
||||||
var count = $scope.unreadCount({
|
var count = $scope.unreadCount({
|
||||||
category : category
|
category : category
|
||||||
});
|
});
|
||||||
var label = '';
|
var label = '';
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
label = '(' + count + ')';
|
label = '(' + count + ')';
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.feedCountLabel = function(feed) {
|
$scope.feedCountLabel = function(feed) {
|
||||||
var label = '';
|
var label = '';
|
||||||
if (feed.unread > 0) {
|
if (feed.unread > 0) {
|
||||||
label = '(' + feed.unread + ')';
|
label = '(' + feed.unread + ')';
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.feedClicked = function(id, event) {
|
$scope.feedClicked = function(id, event) {
|
||||||
// Could be called by a middle click
|
// Could be called by a middle click
|
||||||
if (!event || (!event.ctrlKey && event.which == 1)) {
|
if (!event || (!event.ctrlKey && event.which == 1)) {
|
||||||
|
MobileService.toggleLeftMenu();
|
||||||
|
if ($scope.selectedType == 'feed' && id == $scope.selectedId) {
|
||||||
|
$scope.$emit('emitReload');
|
||||||
|
} else {
|
||||||
|
$state.transitionTo('feeds.view', {
|
||||||
|
_type : 'feed',
|
||||||
|
_id : id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.categoryClicked = function(id) {
|
||||||
MobileService.toggleLeftMenu();
|
MobileService.toggleLeftMenu();
|
||||||
if ($scope.selectedType == 'feed'
|
if ($scope.selectedType == 'category' && id == $scope.selectedId) {
|
||||||
&& id == $scope.selectedId) {
|
|
||||||
$scope.$emit('emitReload');
|
$scope.$emit('emitReload');
|
||||||
} else {
|
} else {
|
||||||
$state.transitionTo('feeds.view', {
|
$state.transitionTo('feeds.view', {
|
||||||
_type : 'feed',
|
_type : 'category',
|
||||||
_id : id
|
_id : id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (event) {
|
$scope.showFeedDetails = function(feed) {
|
||||||
event.preventDefault();
|
$state.transitionTo('feeds.feed_details', {
|
||||||
event.stopPropagation();
|
_id : feed.id
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.categoryClicked = function(id) {
|
|
||||||
MobileService.toggleLeftMenu();
|
|
||||||
if ($scope.selectedType == 'category'
|
|
||||||
&& id == $scope.selectedId) {
|
|
||||||
$scope.$emit('emitReload');
|
|
||||||
} else {
|
|
||||||
$state.transitionTo('feeds.view', {
|
|
||||||
_type : 'category',
|
|
||||||
_id : id
|
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
$scope.showFeedDetails = function(feed) {
|
$scope.showCategoryDetails = function(category) {
|
||||||
$state.transitionTo('feeds.feed_details', {
|
$state.transitionTo('feeds.category_details', {
|
||||||
_id : feed.id
|
_id : category.id
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.showCategoryDetails = function(category) {
|
$scope.toggleCategory = function(category, event) {
|
||||||
$state.transitionTo('feeds.category_details', {
|
event.preventDefault();
|
||||||
_id : category.id
|
event.stopPropagation();
|
||||||
});
|
category.expanded = !category.expanded;
|
||||||
};
|
if (category.id == 'all') {
|
||||||
|
return;
|
||||||
$scope.toggleCategory = function(category, event) {
|
}
|
||||||
event.preventDefault();
|
CategoryService.collapse({
|
||||||
event.stopPropagation();
|
id : category.id,
|
||||||
category.expanded = !category.expanded;
|
collapse : !category.expanded
|
||||||
if (category.id == 'all') {
|
});
|
||||||
return;
|
};
|
||||||
}
|
}]
|
||||||
CategoryService.collapse({
|
|
||||||
id : category.id,
|
|
||||||
collapse : !category.expanded
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
} ]);
|
}]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reusable spinner component
|
* Reusable spinner component
|
||||||
@@ -365,83 +349,81 @@ module.directive('draggable', function() {
|
|||||||
restrict : 'A',
|
restrict : 'A',
|
||||||
link : function(scope, element, attrs) {
|
link : function(scope, element, attrs) {
|
||||||
element.draggable({
|
element.draggable({
|
||||||
revert: 'invalid',
|
revert : 'invalid',
|
||||||
helper: 'clone',
|
helper : 'clone',
|
||||||
distance: 10,
|
distance : 10,
|
||||||
axis: 'y'
|
axis : 'y'
|
||||||
}).data('source', scope.$eval(attrs.draggable));
|
}).data('source', scope.$eval(attrs.draggable));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
module.directive('droppable', [ 'CategoryService', 'FeedService',
|
module.directive('droppable', ['CategoryService', 'FeedService', function(CategoryService, FeedService) {
|
||||||
function(CategoryService, FeedService) {
|
return {
|
||||||
return {
|
restrict : 'A',
|
||||||
restrict : 'A',
|
link : function(scope, element, attrs) {
|
||||||
link : function(scope, element, attrs) {
|
element.droppable({
|
||||||
element.droppable({
|
tolerance : 'pointer',
|
||||||
tolerance : 'pointer',
|
over : function(event, ui) {
|
||||||
over : function(event, ui) {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
drop : function(event, ui) {
|
drop : function(event, ui) {
|
||||||
var draggable = angular.element(ui.draggable);
|
var draggable = angular.element(ui.draggable);
|
||||||
|
|
||||||
var source = draggable.data('source');
|
var source = draggable.data('source');
|
||||||
var target = scope.$eval(attrs.droppable);
|
var target = scope.$eval(attrs.droppable);
|
||||||
|
|
||||||
if (angular.equals(source, target)) {
|
if (angular.equals(source, target)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
id : source.id,
|
id : source.id,
|
||||||
name : source.name
|
name : source.name
|
||||||
};
|
};
|
||||||
|
|
||||||
if (source.children) {
|
if (source.children) {
|
||||||
// source is a category
|
// source is a category
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// source is a feed
|
// source is a feed
|
||||||
|
|
||||||
if (target.children) {
|
if (target.children) {
|
||||||
// target is a category
|
// target is a category
|
||||||
data.categoryId = target.id;
|
data.categoryId = target.id;
|
||||||
data.position = 0;
|
data.position = 0;
|
||||||
} else {
|
} else {
|
||||||
// target is a feed
|
// target is a feed
|
||||||
data.categoryId = target.categoryId;
|
data.categoryId = target.categoryId;
|
||||||
data.position = target.position;
|
data.position = target.position;
|
||||||
}
|
|
||||||
|
|
||||||
FeedService.modify(data, function() {
|
|
||||||
CategoryService.init();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
scope.$apply();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} ]);
|
|
||||||
|
|
||||||
|
FeedService.modify(data, function() {
|
||||||
|
CategoryService.init();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
scope.$apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}]);
|
||||||
|
|
||||||
module.filter('highlight', function() {
|
module.filter('highlight', function() {
|
||||||
return function(html, keywords) {
|
return function(html, keywords) {
|
||||||
if (keywords) {
|
if (keywords) {
|
||||||
var tokens = keywords.split(' ');
|
var tokens = keywords.split(' ');
|
||||||
for (var i = 0; i < tokens.length; i++) {
|
for ( var i = 0; i < tokens.length; i++) {
|
||||||
var expr = new RegExp(tokens[i], 'gi');
|
var expr = new RegExp(tokens[i], 'gi');
|
||||||
var container = $('<span>').html(html);
|
var container = $('<span>').html(html);
|
||||||
var elements = container.find('*').addBack();
|
var elements = container.find('*').addBack();
|
||||||
var textNodes = elements.not('iframe').contents().not(elements);
|
var textNodes = elements.not('iframe').contents().not(elements);
|
||||||
textNodes.each(function() {
|
textNodes.each(function() {
|
||||||
var replaced = this.nodeValue.replace(expr, '<span class="highlight-search">$&</span>');
|
var replaced = this.nodeValue.replace(expr, '<span class="highlight-search">$&</span>');
|
||||||
$('<span>').html(replaced).insertBefore(this);
|
$('<span>').html(replaced).insertBefore(this);
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
return container.html();
|
return container.html();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return html;
|
return html;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module.filter('entryDate', function() {
|
|||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var d = moment(timestamp);
|
var d = moment(timestamp);
|
||||||
var now = moment();
|
var now = moment();
|
||||||
var formatted;
|
var formatted;
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
var app = angular.module('commafeed', [ 'ui', 'ui.bootstrap', 'ui.state',
|
var app = angular.module('commafeed', ['ui', 'ui.bootstrap', 'ui.state', 'commafeed.directives', 'commafeed.controllers',
|
||||||
'commafeed.directives', 'commafeed.controllers', 'commafeed.services',
|
'commafeed.services', 'commafeed.filters', 'ngSanitize', 'infinite-scroll', 'ngGrid']);
|
||||||
'commafeed.filters', 'ngSanitize', 'infinite-scroll',
|
|
||||||
'ngGrid' ]);
|
|
||||||
|
|
||||||
app.config([ '$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpProvider',
|
app.config(['$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpProvider',
|
||||||
function($routeProvider, $stateProvider, $urlRouterProvider, $httpProvider) {
|
function($routeProvider, $stateProvider, $urlRouterProvider, $httpProvider) {
|
||||||
|
|
||||||
var interceptor = [ '$rootScope', '$q', function(scope, $q) {
|
var interceptor = ['$rootScope', '$q', function(scope, $q) {
|
||||||
|
|
||||||
var success = function (response) {
|
var success = function(response) {
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
var error = function (response) {
|
var error = function(response) {
|
||||||
var status = response.status;
|
var status = response.status;
|
||||||
if (status == 401) {
|
if (status == 401) {
|
||||||
window.location = 'logout';
|
window.location = 'logout';
|
||||||
@@ -20,16 +18,16 @@ app.config([ '$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpPro
|
|||||||
return $q.reject(response);
|
return $q.reject(response);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var promise = function(promise) {
|
var promise = function(promise) {
|
||||||
return promise.then(success, error);
|
return promise.then(success, error);
|
||||||
};
|
};
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
} ];
|
}];
|
||||||
|
|
||||||
$httpProvider.responseInterceptors.push(interceptor);
|
$httpProvider.responseInterceptors.push(interceptor);
|
||||||
|
|
||||||
$stateProvider.state('feeds', {
|
$stateProvider.state('feeds', {
|
||||||
'abstract' : true,
|
'abstract' : true,
|
||||||
url : '/feeds',
|
url : '/feeds',
|
||||||
@@ -106,4 +104,4 @@ app.config([ '$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpPro
|
|||||||
$urlRouterProvider.when('/admin', '/admin/settings');
|
$urlRouterProvider.when('/admin', '/admin/settings');
|
||||||
$urlRouterProvider.otherwise('/');
|
$urlRouterProvider.otherwise('/');
|
||||||
|
|
||||||
} ]);
|
}]);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
var module = angular.module('commafeed.services', [ 'ngResource' ]);
|
var module = angular.module('commafeed.services', ['ngResource']);
|
||||||
|
|
||||||
module.service('AnalyticsService', [ '$state', function($state) {
|
module.service('AnalyticsService', ['$state', function($state) {
|
||||||
this.track = function(path) {
|
this.track = function(path) {
|
||||||
if (typeof ga === 'undefined') {
|
if (typeof ga === 'undefined') {
|
||||||
return;
|
return;
|
||||||
@@ -10,9 +10,9 @@ module.service('AnalyticsService', [ '$state', function($state) {
|
|||||||
page : path
|
page : path
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
} ]);
|
}]);
|
||||||
|
|
||||||
module.service('MobileService', [ '$state', function($state) {
|
module.service('MobileService', ['$state', function($state) {
|
||||||
this.leftMenu = false;
|
this.leftMenu = false;
|
||||||
this.rightMenu = false;
|
this.rightMenu = false;
|
||||||
this.toggleLeftMenu = function() {
|
this.toggleLeftMenu = function() {
|
||||||
@@ -27,7 +27,6 @@ module.service('MobileService', [ '$state', function($state) {
|
|||||||
this.mobile = width < 979;
|
this.mobile = width < 979;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
module.factory('ProfileService', ['$resource', function($resource) {
|
module.factory('ProfileService', ['$resource', function($resource) {
|
||||||
var res = $resource('rest/user/profile/');
|
var res = $resource('rest/user/profile/');
|
||||||
res.deleteAccount = $resource('rest/user/profile/deleteAccount').save;
|
res.deleteAccount = $resource('rest/user/profile/deleteAccount').save;
|
||||||
@@ -65,8 +64,7 @@ module.factory('SettingsService', ['$resource', function($resource) {
|
|||||||
return s;
|
return s;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
module.factory('FeedService', ['$resource', '$http',
|
module.factory('FeedService', ['$resource', '$http', function($resource, $http) {
|
||||||
function($resource, $http) {
|
|
||||||
var actions = {
|
var actions = {
|
||||||
entries : {
|
entries : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
@@ -122,9 +120,8 @@ function($resource, $http) {
|
|||||||
return res;
|
return res;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
module.factory('CategoryService', ['$resource', '$http',
|
module.factory('CategoryService', ['$resource', '$http', function($resource, $http) {
|
||||||
function($resource, $http) {
|
|
||||||
|
|
||||||
var traverse = function(callback, category, parentName) {
|
var traverse = function(callback, category, parentName) {
|
||||||
callback(category, parentName);
|
callback(category, parentName);
|
||||||
var children = category.children;
|
var children = category.children;
|
||||||
@@ -134,7 +131,7 @@ function($resource, $http) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// flatten categories
|
// flatten categories
|
||||||
var flatten = function(category) {
|
var flatten = function(category) {
|
||||||
var array = [];
|
var array = [];
|
||||||
@@ -145,8 +142,8 @@ function($resource, $http) {
|
|||||||
}
|
}
|
||||||
array.push({
|
array.push({
|
||||||
id : category.id,
|
id : category.id,
|
||||||
name : name,
|
name : name,
|
||||||
orig: category
|
orig : category
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
traverse(callback, category);
|
traverse(callback, category);
|
||||||
@@ -162,18 +159,18 @@ function($resource, $http) {
|
|||||||
traverse(callback, category);
|
traverse(callback, category);
|
||||||
return subs;
|
return subs;
|
||||||
};
|
};
|
||||||
|
|
||||||
// flatten everything
|
// flatten everything
|
||||||
var flatAll = function(category, a) {
|
var flatAll = function(category, a) {
|
||||||
a.push([ category.id, 'category' ]);
|
a.push([category.id, 'category']);
|
||||||
_.each(category.children, function(child) {
|
_.each(category.children, function(child) {
|
||||||
flatAll(child, a);
|
flatAll(child, a);
|
||||||
});
|
});
|
||||||
_.each(category.feeds, function(feed) {
|
_.each(category.feeds, function(feed) {
|
||||||
a.push([ feed.id, 'feed' ]);
|
a.push([feed.id, 'feed']);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var actions = {
|
var actions = {
|
||||||
get : {
|
get : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
@@ -228,7 +225,7 @@ function($resource, $http) {
|
|||||||
res.subscriptions = data;
|
res.subscriptions = data;
|
||||||
res.flatCategories = flatten(data);
|
res.flatCategories = flatten(data);
|
||||||
res.feeds = flatFeeds(data);
|
res.feeds = flatFeeds(data);
|
||||||
|
|
||||||
res.flatAll = [];
|
res.flatAll = [];
|
||||||
flatAll(data, res.flatAll);
|
flatAll(data, res.flatAll);
|
||||||
res.flatAll.splice(1, 0, ['starred', 'category']);
|
res.flatAll.splice(1, 0, ['starred', 'category']);
|
||||||
@@ -249,8 +246,7 @@ function($resource, $http) {
|
|||||||
return res;
|
return res;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
module.factory('EntryService', ['$resource', '$http',
|
module.factory('EntryService', ['$resource', '$http', function($resource, $http) {
|
||||||
function($resource, $http) {
|
|
||||||
var actions = {
|
var actions = {
|
||||||
search : {
|
search : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
@@ -299,7 +295,7 @@ module.factory('AdminCleanupService', ['$resource', function($resource) {
|
|||||||
var actions = {
|
var actions = {
|
||||||
findDuplicateFeeds : {
|
findDuplicateFeeds : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
isArray: true,
|
isArray : true,
|
||||||
params : {
|
params : {
|
||||||
_method : 'findDuplicateFeeds'
|
_method : 'findDuplicateFeeds'
|
||||||
}
|
}
|
||||||
@@ -316,6 +312,6 @@ module.factory('AdminCleanupService', ['$resource', function($resource) {
|
|||||||
}]);
|
}]);
|
||||||
|
|
||||||
module.factory('ServerService', ['$resource', function($resource) {
|
module.factory('ServerService', ['$resource', function($resource) {
|
||||||
var res = $resource('rest/server/get');
|
var res = $resource('rest/server/get');
|
||||||
return res;
|
return res;
|
||||||
}]);
|
}]);
|
||||||
@@ -14,11 +14,10 @@ app.factory('$templateCache', ['$cacheFactory', '$http', '$injector', function($
|
|||||||
|
|
||||||
if (!allTplPromise) {
|
if (!allTplPromise) {
|
||||||
var lang = $('html').attr('lang');
|
var lang = $('html').attr('lang');
|
||||||
allTplPromise = $http.get('templates/all-templates.' + lang + '.html?${timestamp}').then(
|
allTplPromise = $http.get('templates/all-templates.' + lang + '.html?${timestamp}').then(function(response) {
|
||||||
function(response) {
|
$injector.get('$compile')(response.data);
|
||||||
$injector.get('$compile')(response.data);
|
return response;
|
||||||
return response;
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return allTplPromise.then(function(response) {
|
return allTplPromise.then(function(response) {
|
||||||
|
|||||||
Reference in New Issue
Block a user