From: Alexandre Terrasa Date: Fri, 9 Jun 2017 18:28:41 +0000 (-0400) Subject: nitweb: index use ui-router and views for tabs X-Git-Url: http://nitlanguage.org nitweb: index use ui-router and views for tabs Signed-off-by: Alexandre Terrasa --- diff --git a/share/nitweb/javascripts/index.js b/share/nitweb/javascripts/index.js index 3c905b5..104d627 100644 --- a/share/nitweb/javascripts/index.js +++ b/share/nitweb/javascripts/index.js @@ -20,11 +20,30 @@ .config(function($stateProvider, $locationProvider) { $stateProvider - .state('index', { + .state('catalog', { url: '/', - templateUrl: 'views/index.html', - controller: 'IndexCtrl', - controllerAs: 'indexCtrl' + templateUrl: 'views/catalog/index.html', + controller: 'CatalogCtrl', + controllerAs: 'vm', + abstract: true + }) + .state('catalog.highlighted', { + url: '', + templateUrl: 'views/catalog/highlighted.html', + controller: 'CatalogHighlightedCtrl', + controllerAs: 'vm' + }) + .state('catalog.required', { + url: 'required', + templateUrl: 'views/catalog/most_required.html', + controller: 'CatalogRequiredCtrl', + controllerAs: 'vm' + }) + .state('catalog.tags', { + url: 'tags', + templateUrl: 'views/catalog/by_tags.html', + controller: 'CatalogTagsCtrl', + controllerAs: 'vm' }) }) @@ -62,60 +81,61 @@ } }]) - .controller('IndexCtrl', function(Catalog, $sce, $scope, $location, $anchorScroll) { - this.loadHighlighted = function() { - Catalog.loadHightlighted( - function(data) { - $scope.highlighted = data; - }, function(err) { - $scope.error = err; - }); - }; + .controller('CatalogCtrl', function(Catalog) { + var vm = this; + + Catalog.loadContributors( + function(data) { + vm.contributors = data; + }, function(err) { + vm.error = err; + }); + + Catalog.loadStats( + function(data) { + vm.stats = data; + }, function(err) { + vm.error = err; + }); + }) - this.loadMostRequired = function() { - Catalog.loadMostRequired( - function(data) { - $scope.required = data; - }, function(err) { - $scope.error = err; - }); - }; + .controller('CatalogHighlightedCtrl', function(Catalog) { + var vm = this; - this.loadByTags = function() { - Catalog.loadByTags( - function(data) { - $scope.bytags = data; - }, function(err) { - $scope.error = err; - }); - }; + Catalog.loadHightlighted( + function(data) { + vm.highlighted = data; + }, function(err) { + vm.error = err; + }); + }) - this.loadStats = function() { - Catalog.loadStats( - function(data) { - $scope.stats = data; - }, function(err) { - $scope.error = err; - }); - }; + .controller('CatalogRequiredCtrl', function(Catalog) { + var vm = this; - this.loadContributors = function() { - Catalog.loadContributors( - function(data) { - $scope.contributors = data; - }, function(err) { - $scope.error = err; - }); - }; + Catalog.loadMostRequired( + function(data) { + vm.required = data; + }, function(err) { + vm.error = err; + }); + }) + .controller('CatalogTagsCtrl', function(Catalog, $anchorScroll, $location) { + var vm = this; + + Catalog.loadByTags( + function(data) { + vm.bytags = data; + }, function(err) { + vm.error = err; + }); - this.scrollTo = function(hash) { - $anchorScroll(hash); - } - this.loadHighlighted(); - this.loadStats(); - this.loadContributors(); + vm.scrollTo = function(hash) { + $location.hash(hash); + $anchorScroll(); + } }) .directive('contributorList', function(Model) { diff --git a/share/nitweb/views/catalog/by_tags.html b/share/nitweb/views/catalog/by_tags.html new file mode 100644 index 0000000..31ca905 --- /dev/null +++ b/share/nitweb/views/catalog/by_tags.html @@ -0,0 +1,14 @@ +
+

Tags

+
+
+ {{packages.length}} + {{tag}} +
+
+
+ +
+
diff --git a/share/nitweb/views/catalog/highlighted.html b/share/nitweb/views/catalog/highlighted.html new file mode 100644 index 0000000..5607bd5 --- /dev/null +++ b/share/nitweb/views/catalog/highlighted.html @@ -0,0 +1,5 @@ +
+ +
diff --git a/share/nitweb/views/catalog/index.html b/share/nitweb/views/catalog/index.html new file mode 100644 index 0000000..877db4a --- /dev/null +++ b/share/nitweb/views/catalog/index.html @@ -0,0 +1,47 @@ +
+ + + + + + + +
+
{{value}} {{key}}
+
+ +
+
+
+
+ +
+
+
+
+ + +
+
+
diff --git a/share/nitweb/views/catalog/most_required.html b/share/nitweb/views/catalog/most_required.html new file mode 100644 index 0000000..93bf2e1 --- /dev/null +++ b/share/nitweb/views/catalog/most_required.html @@ -0,0 +1,5 @@ +
+ +
diff --git a/share/nitweb/views/index.html b/share/nitweb/views/index.html deleted file mode 100644 index b7bee8e..0000000 --- a/share/nitweb/views/index.html +++ /dev/null @@ -1,70 +0,0 @@ -
- - - - - - - -
-
{{value}} {{key}}
-
- -
-
-
-
- -
-
- -
-
-

Tags

-
-
- {{packages.length}} - {{tag}} -
-
-
- -
-
-
-
-
- - -
-
-