From 7508feb95a07a01b3f9d23a879f05f676b351f99 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Mon, 12 Jun 2017 13:51:45 -0400 Subject: [PATCH] nitweb: classdefs and propdefs link directly into class / property linerarization list Signed-off-by: Alexandre Terrasa --- share/nitweb/directives/entity/defcard.html | 2 +- share/nitweb/directives/entity/link.html | 2 +- share/nitweb/javascripts/entities.js | 27 +++++++++++++++++++++------ share/nitweb/javascripts/nitweb.js | 4 ---- share/nitweb/views/classdef.html | 21 --------------------- share/nitweb/views/doc/entity.html | 11 +---------- share/nitweb/views/doc/lin.html | 2 +- share/nitweb/views/propdef.html | 21 --------------------- src/web/web_base.nit | 4 ++++ 9 files changed, 29 insertions(+), 65 deletions(-) delete mode 100644 share/nitweb/views/classdef.html delete mode 100644 share/nitweb/views/propdef.html diff --git a/share/nitweb/directives/entity/defcard.html b/share/nitweb/directives/entity/defcard.html index ddbef3b..2d14d83 100644 --- a/share/nitweb/directives/entity/defcard.html +++ b/share/nitweb/directives/entity/defcard.html @@ -1,4 +1,4 @@ -
+
diff --git a/share/nitweb/directives/entity/link.html b/share/nitweb/directives/entity/link.html index ae57696..740ea8b 100644 --- a/share/nitweb/directives/entity/link.html +++ b/share/nitweb/directives/entity/link.html @@ -1,3 +1,3 @@ - {{mentity.name}} + {{mentity.name}} diff --git a/share/nitweb/javascripts/entities.js b/share/nitweb/javascripts/entities.js index 352c7e4..d5dd3ef 100644 --- a/share/nitweb/javascripts/entities.js +++ b/share/nitweb/javascripts/entities.js @@ -146,11 +146,24 @@ return d.promise; } }, - controller: function(mentity, lin) { - this.mentity = mentity; - this.lin = lin; + controller: function(mentity, lin, $scope, $location, $anchorScroll) { + var vm = this; + vm.focus = $location.hash() ? + $location.hash() : mentity.intro.full_name; + vm.mentity = mentity; + vm.linearization = lin; + setTimeout(function() { + $anchorScroll(); + }, 400); + $scope.$watch(function () { + return $location.hash(); + }, function (value) { + vm.focus = $location.hash() ? + $location.hash() : mentity.intro.full_name; + $anchorScroll(); + }); }, - controllerAs: 'vm', + controllerAs: 'vm' }) .state('doc.entity.all', { url: '/all', @@ -369,7 +382,7 @@ $scope.codeId = 'code_' + $scope.definition.full_name.replace(/[^a-zA-Z0-9]/g, '_'); $scope.isActive = function() { - return $scope.focus.full_name == $scope.definition.full_name; + return $scope.focus == $scope.definition.full_name; } $scope.loadCardCode = function() { @@ -392,7 +405,9 @@ } }; - if($scope.isActive()) $scope.loadCardCode(); + $scope.$watch('focus', function() { + if($scope.isActive()) $scope.loadCardCode(); + }); } }; }]) diff --git a/share/nitweb/javascripts/nitweb.js b/share/nitweb/javascripts/nitweb.js index b4ac091..181da8e 100644 --- a/share/nitweb/javascripts/nitweb.js +++ b/share/nitweb/javascripts/nitweb.js @@ -34,8 +34,4 @@ }) $locationProvider.html5Mode(true); }) - - .filter('encodeURI', function() { - return encodeURIComponent; - }); })(); diff --git a/share/nitweb/views/classdef.html b/share/nitweb/views/classdef.html deleted file mode 100644 index 1e1365b..0000000 --- a/share/nitweb/views/classdef.html +++ /dev/null @@ -1,21 +0,0 @@ - - -
-
- -
-
diff --git a/share/nitweb/views/doc/entity.html b/share/nitweb/views/doc/entity.html index e0114dc..1a0dcf7 100644 --- a/share/nitweb/views/doc/entity.html +++ b/share/nitweb/views/doc/entity.html @@ -77,14 +77,5 @@
-
-
-
-
-
-
-
- - -
+
diff --git a/share/nitweb/views/doc/lin.html b/share/nitweb/views/doc/lin.html index e36a852..96d9b82 100644 --- a/share/nitweb/views/doc/lin.html +++ b/share/nitweb/views/doc/lin.html @@ -2,5 +2,5 @@ + list-focus='vm.focus' />
diff --git a/share/nitweb/views/propdef.html b/share/nitweb/views/propdef.html deleted file mode 100644 index 975cfb5..0000000 --- a/share/nitweb/views/propdef.html +++ /dev/null @@ -1,21 +0,0 @@ - - -
-
- -
-
diff --git a/src/web/web_base.nit b/src/web/web_base.nit index 265cadf..1daebdd 100644 --- a/src/web/web_base.nit +++ b/src/web/web_base.nit @@ -278,6 +278,8 @@ redef class MClassDef end return new Namespace.from([mmodule.full_name, "$::", mclass.intro_mmodule.to_ns_ref: nullable NSEntity]) end + + redef fun web_url do return "{mclass.web_url}/lin#{full_name}" end redef class MProperty @@ -317,6 +319,8 @@ redef class MPropDef end return res end + + redef fun web_url do return "{mproperty.web_url}/lin#{full_name}" end redef class MClassType -- 1.7.9.5