woblink fixes
[redakcja.git] / src / redakcja / static / js / wiki / view_annotations.js
index e7f6239..8e3671a 100644 (file)
@@ -4,41 +4,35 @@
      * Perspective
      */
     class AnnotationsPerspective extends $.wiki.SidebarPerspective {
      * Perspective
      */
     class AnnotationsPerspective extends $.wiki.SidebarPerspective {
-        constructor(options) {
-            var old_callback = options.callback || function() { };
+        vsplitbar = 'PRZYPISY';
 
 
-            options.callback = function(){
-                var self = this;
+        constructor(options) {
+            super(options);
 
 
-                this.vsplitbar = 'PRZYPISY';
-                this.$element = $("#side-annotations");
-                this.$error = $('.error-message', this.$element);
-                this.$annos = $('.annotations-list', this.$element);
-                this.$spinner = $('.spinner', this.$element);
-                this.$refresh = $('.refresh', this.$element);
+            var self = this;
+            this.$element = $("#side-annotations");
+            this.$error = $('.error-message', this.$element);
+            this.$annos = $('.annotations-list', this.$element);
+            this.$spinner = $('.spinner', this.$element);
+            this.$refresh = $('.refresh', this.$element);
 
 
-                this.$refresh.click(function() {
-                    var $this = $(this);
+            this.$refresh.click(function() {
+                var $this = $(this);
 
 
-                    self.$refresh.removeClass('active');
-                    $this.addClass('active');
-                    var atype = $this.attr('data-tag');
+                self.$refresh.removeClass('active');
+                $this.addClass('active');
+                var atype = $this.attr('data-tag');
 
 
-                    self.$annos.hide();
-                    self.$error.hide();
-                    self.$spinner.fadeIn(100, function() {
-                        self.refresh(atype);
-                    });
+                self.$annos.hide();
+                self.$error.hide();
+                self.$spinner.fadeIn(100, function() {
+                    self.refresh(atype);
                 });
                 });
-
-                old_callback.call(this);
-            };
-
-            super(options);
+            });
         }
 
         updateAnnotationIds() {
         }
 
         updateAnnotationIds() {
-            let selt = this;
+            let self = this;
             self.annotationToAnchor = {};
             $('#html-view').find('.annotation-inline-box').each(
                 function(i, annoBox) {
             self.annotationToAnchor = {};
             $('#html-view').find('.annotation-inline-box').each(
                 function(i, annoBox) {
             var anchor = self.annotationToAnchor[content];
             if (anchor != undefined) {
                 var $htmlView = $("#html-view");
             var anchor = self.annotationToAnchor[content];
             if (anchor != undefined) {
                 var $htmlView = $("#html-view");
-                var top = $htmlView.offset().top +
-                    $("[name=" + anchor + "]", $htmlView).offset().top -
-                    $htmlView.children().eq(0).offset().top;
+                var top = $("[name=" + anchor + "]", $htmlView).offset().top -
+                    $htmlView.offset().top +
+                    $htmlView.scrollTop()
+                ;
 
                 $htmlView.animate({scrollTop: top}, 250);
             }
 
                 $htmlView.animate({scrollTop: top}, 250);
             }