X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/3ca842cccb9ecaef81eb1123f3c5cc87943508c4..210e62452e0e9f26f3e006c874b66ac44005d492:/redakcja/static/js/wiki/view_annotations.js?ds=sidebyside diff --git a/redakcja/static/js/wiki/view_annotations.js b/redakcja/static/js/wiki/view_annotations.js index 3ea3aa1e..5bac593c 100644 --- a/redakcja/static/js/wiki/view_annotations.js +++ b/redakcja/static/js/wiki/view_annotations.js @@ -7,6 +7,7 @@ var old_callback = options.callback || function() { }; this.noupdate_hash_onenter = true; + this.vsplitbar = 'PRZYPISY'; options.callback = function(){ var self = this; @@ -14,8 +15,21 @@ this.$element = $("#side-annotations"); this.$error = $('.error-message', this.$element); this.$annos = $('.annotations-list', this.$element); - $('.refresh', this.$element).click(function() { - self.refresh(self); + this.$spinner = $('.spinner', this.$element); + this.$refresh = $('.refresh', this.$element); + + this.$refresh.click(function() { + $this = $(this); + + self.$refresh.removeClass('active'); + $this.addClass('active'); + atype = $this.attr('data-tag'); + + self.$annos.hide(); + self.$error.hide(); + self.$spinner.show(100, function(){ + self.refresh(self, atype); + }); }); old_callback.call(this); @@ -26,7 +40,7 @@ AnnotationsPerspective.prototype = new $.wiki.Perspective(); - AnnotationsPerspective.prototype.refresh = function(self) { + AnnotationsPerspective.prototype.refresh = function(self, atype) { var xml; persp = $.wiki.activePerspective(); @@ -41,13 +55,15 @@ }, error: function(text){ self.$error.html('
WystÄ piÅ bÅÄ d:
' + text + ''); + self.$spinner.hide(); + self.$error.show(); } }); } else { xml = this.doc.text; } - + var parser = new DOMParser(); var serializer = new XMLSerializer(); var doc = parser.parseFromString(xml, 'text/xml'); @@ -55,20 +71,25 @@ if (error.length > 0) { self.$error.html('BÅÄ d parsowania XML.'); + self.$spinner.hide(); self.$error.show(); - self.$annos.hide(); } else { - self.$error.hide(); - self.$annos.hide(); self.$annos.html(''); var anno_list = new Array(); - var annos = doc.getElementsByTagName('pe'); + var annos = $(atype, doc); var counter = annos.length; + var atype_rx = atype.replace(/,/g, '|'); + var ann_expr = new RegExp("^<("+atype_rx+")[^>]*>|("+atype_rx+")>$", "g") - for (var i=0; i