nitweb: classdefs and propdefs link directly into class / property linerarization...
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 12 Jun 2017 17:51:45 +0000 (13:51 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 12 Jun 2017 17:51:45 +0000 (13:51 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitweb/directives/entity/defcard.html
share/nitweb/directives/entity/link.html
share/nitweb/javascripts/entities.js
share/nitweb/javascripts/nitweb.js
share/nitweb/views/classdef.html [deleted file]
share/nitweb/views/doc/entity.html
share/nitweb/views/doc/lin.html
share/nitweb/views/propdef.html [deleted file]
src/web/web_base.nit

index ddbef3b..2d14d83 100644 (file)
@@ -1,4 +1,4 @@
-<div class='card card-xl' ng-class='{active: isActive()}'>
+<div class='card card-xl' ng-class='{active: isActive()}' id='{{definition.full_name}}'>
        <div class='card-body'>
                <h5>
                        <span ng-if='definition.is_intro'>
index ae57696..740ea8b 100644 (file)
@@ -1,3 +1,3 @@
 <span>
-       <a ng-href='{{mentity.web_url | encodeURI}}'>{{mentity.name}}</a>
+       <a ng-href='{{mentity.web_url}}'>{{mentity.name}}</a>
 </span>
index 352c7e4..d5dd3ef 100644 (file)
                                                        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',
                                        $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() {
                                                }
                                        };
 
-                                       if($scope.isActive()) $scope.loadCardCode();
+                                       $scope.$watch('focus', function() {
+                                               if($scope.isActive()) $scope.loadCardCode();
+                                       });
                                }
                        };
                }])
index b4ac091..181da8e 100644 (file)
@@ -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 (file)
index 1e1365b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<ul class='nav nav-tabs' ng-init='entityCtrl.loadEntityLinearization()'>
-       <li role='presentation' class='warning'>
-               <a ng-href='{{mentity.mclass.web_url}}'>
-                       <span class='glyphicon glyphicon-chevron-left'/> Go to class
-               </a>
-       </li>
-       <li role='presentation' class='active'>
-               <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization'>
-                       <span class='glyphicon glyphicon-arrow-down'/> Linearization
-               </a>
-       </li>
-</ul>
-
-<div class='tab-content'>
-       <div role='tabpanel' class='tab-pane fade in active' id='linearization'>
-               <entity-linearization
-                       list-title='Class definitions'
-                       list-entities='linearization'
-                       list-focus='mentity' />
-       </div>
-</div>
index e0114dc..1a0dcf7 100644 (file)
                </li>
        </ul>
        <br>
-       <div ng-switch='vm.mentity.class_name'>
-               <div ng-switch-when='MClassDef'>
-                       <div ng-include src='"/views/classdef.html"' />
-               </div>
-               <div ng-switch-when='MMethodDef' ng-switch-when='MAttributeDef' ng-switch-when='MVirtualTypeDef'>
-                       <div ng-include src='"/views/propdef.html"' />
-               </div>
-
-               <ui-view />
-       </div>
+       <ui-view />
 </div>
index e36a852..96d9b82 100644 (file)
@@ -2,5 +2,5 @@
        <entity-linearization
                list-title='Class definitions'
                list-entities='vm.linearization'
-               list-focus='vm.mentity.intro' />
+               list-focus='vm.focus' />
 </div>
diff --git a/share/nitweb/views/propdef.html b/share/nitweb/views/propdef.html
deleted file mode 100644 (file)
index 975cfb5..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<ul class='nav nav-tabs' ng-init='entityCtrl.loadEntityLinearization()'>
-       <li role='presentation' class='warning'>
-               <a href='{{mentity.mproperty.web_url}}'>
-                       <span class='glyphicon glyphicon-chevron-left'/> Go to property
-               </a>
-       </li>
-       <li role='presentation' class='active'>
-               <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization'>
-                       <span class='glyphicon glyphicon-arrow-down'/> Linearization
-               </a>
-       </li>
-</ul>
-
-<div class='tab-content'>
-       <div role='tabpanel' class='tab-pane fade in active' id='linearization'>
-               <entity-linearization
-                       list-title='Class definitions'
-                       list-entities='linearization'
-                       list-focus='mentity' />
-       </div>
-</div>
index 265cadf..1daebdd 100644 (file)
@@ -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