PageSourceSearch

https://www.ilincs.org/ilincs/js/directives/buttons.js

js ilincs.org collected 2026-09-28 05:51:24 UTC 5,390 bytes, 180 lines download raw bytes

1var buttons = angular.module('iLincsButtons', []);
2
3buttons.directive('goBack', [function() {
4  return {
5    restrict: 'E',
6    transclude: true,
7    replace: true,
8    // template: '<div id="goback" class="{{theme}} {{show}}"><button><div ng-transclude></div></button></div>',
9    template: '<div id="goback" class="{{show}}"><button><div ng-transclude></div></button></div>',
10    scope: {
11      text: "@buttonText",
12      speed: "@scrollSpeed",
13      theme: "@buttonTheme"
14    },
15    link: function(scope, element) {
16
17      scope.historyLength = function() {
18        if (window.history.length>1){
19          return "show";
20        } else {
21          return "";
22        }
23      };
24
25      scope.text = scope.text || 'Scroll top';
26      scope.speed = parseInt(scope.speed, 10) || 300;
27      scope.theme = scope.theme || 'light';
28      // scope.theme = scope.theme + ' show';
29      // element.addClass('show');
30      scope.show = scope.historyLength();
31      var self = this;
32
33
34      // scope.currentYPosition = function() {
35      //   if (self.pageYOffset)
36      //     return self.pageYOffset;
37      //   if (document.documentElement && document.documentElement.scrollTop)
38      //     return document.documentElement.scrollTop;
39      //   if (document.body.scrollTop)
40      //     return document.body.scrollTop;
41      //   return 0;
42      // };
43
44      // scope.smoothScroll = function() {
45      //   var startY = scope.currentYPosition();
46      //   var stopY = 0;
47      //   var distance = stopY > startY ? stopY - startY : startY - stopY;
48      //   if (distance < 100) {
49      //     scrollTo(0, stopY);
50      //     return;
51      //   }
52      //   var speed = Math.round(scope.speed / 100);
53      //   var step = Math.round(distance / 25);
54      //   var leapY = stopY > startY ? startY + step : startY - step;
55      //   var timer = 0;
56      //   if (stopY > startY) {
57      //     for (var i = startY; i < stopY; i += step) {
58      //       setTimeout("window.scrollTo(0, " + leapY + ")", timer * speed);
59      //       leapY += step;
60      //       if (leapY > stopY) leapY = stopY;
61      //       timer++;
62      //     }
63      //     return;
64      //   }
65      //   for (var j = startY; j > stopY; j -= step) {
66      //     setTimeout("window.scrollTo(0, " + leapY + ")", timer * speed);
67      //     leapY -= step;
68      //     if (leapY < stopY) leapY = stopY;
69      //     timer++;
70      //   }
71      // };
72
73      scope.button = element.find('button');
74
75      scope.button.on('click', function() {
76        // scope.smoothScroll();
77        // element.removeClass('show');
78        console.log(window.history);
79        window.history.back();
80      });
81
82      // window.addEventListener('scroll', function() {
83      //   if (window.pageYOffset > 0) {
84      //     element.addClass('show');
85      //   } else {
86      //     element.removeClass('show');
87      //   }
88      // });
89    }
90  };
91
92}]);
93
94buttons.directive('goForward', [function() {
95  return {
96    restrict: 'E',
97    transclude: true,
98    replace: true,
99    template: '<div id="goforward" class="{{show}}"><button><div ng-transclude></div></button></div>',
100    scope: {
101      text: "@buttonText",
102      speed: "@scrollSpeed",
103      theme: "@buttonTheme"
104    },
105    link: function(scope, element) {
106
107      scope.historyLength = function() {
108        console.log(window.history.next);
109        // if (window.history.forward.length>0){
110        if (window.history.length>1){
111          return "show";
112        } else {
113          return "";
114        }
115      };
116
117      scope.text = scope.text || 'Scroll top';
118      scope.speed = parseInt(scope.speed, 10) || 300;
119      scope.theme = scope.theme || 'light';
120      // scope.theme = scope.theme + ' show';
121      // element.addClass('show');
122      scope.show = scope.historyLength();
123      var self = this;
124
125
126      scope.button = element.find('button');
127
128      scope.button.on('click', function() {
129        // scope.smoothScroll();
130        // element.removeClass('show');
131        console.log(window.history);
132        window.history.forward();
133      });
134    }
135  };
136}]);
137
138  buttons.directive('toolsIconButton', [function() {
139    return {
140      restrict: 'E',
141      // transclude: true,
142      // replace: true,
143      templateUrl: 'views/templates/directives/toolsIconButton.html',
144      // template: '<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6 text-center col-no-padding">'+
145      //           '<a  ui-sref="{{sref}}" ng-href="{{href}}" title="{{title}}">'+
146      //           '<div class="link-btn-icon"><h5 class="link-btn-title">{{title}}</h5>'+
147      //           '<img class="link-btn-img" ng-src="{{src}}" />'+
148      //           '</div></a></div>',
149      scope: {
150        sref: "@sref",
151        href: "@href",
152        src:  "@src",
153        title: "@title"//,
154        // experiment: "@experiment"
155      },
156      link: function(scope, element) {
157
158      }
159    };
160
161
162
163}]);
164
165// scroll-to-item scroll-to="#SPIA"
166// buttons.directive('scrollToItem', function() {
167// return {
168//     restrict: 'A',
169//     scope: {
170//         scrollTo: "@"
171//     },
172//     link: function(scope, $elm,$window,attr) {
173//
174//         $elm.on('click', function() {
175//             $('html,body').animate({scrollTop: $(scope.scrollTo).offset().top }, "slow");
176//
177//             // $window.getElementById('html,body').animate({scrollTop: $(scope.scrollTo).offset().top }, "slow");
178//         });
179//     }
180// }});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.