X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/9f979033640e55e9eaf62d1f1ae8dca634bdd6e2..b125e0db22458fa98fe6e3a06cdc33c189e89401:/redakcja/static/js/wiki/view_annotations.js
diff --git a/redakcja/static/js/wiki/view_annotations.js b/redakcja/static/js/wiki/view_annotations.js
index 72946789..b55effd0 100644
--- a/redakcja/static/js/wiki/view_annotations.js
+++ b/redakcja/static/js/wiki/view_annotations.js
@@ -15,40 +15,95 @@
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() {
+ var $this = $(this);
+
+ self.$refresh.removeClass('active');
+ $this.addClass('active');
+ var atype = $this.attr('data-tag');
+
+ self.$annos.hide();
+ self.$error.hide();
+ self.$spinner.show(100, function(){
+ self.refresh(self, atype);
+ });
});
- old_callback.call(this);
+ old_callback.call(this);
};
$.wiki.Perspective.call(this, options);
- };
+ }
AnnotationsPerspective.prototype = new $.wiki.Perspective();
- AnnotationsPerspective.prototype.refresh = function(self) {
+ AnnotationsPerspective.prototype.updateAnnotationIds = function(self){
+ self.annotationToAnchor = {};
+ $('#html-view').find('.annotation-inline-box').each(
+ function(i, annoBox) {
+ var $annoBox = $(annoBox);
+ var $anchor = $("a[name|=anchor]", $annoBox);
+ var htmlContent = $('span', $annoBox).html();
+ // TBD: perhaps use a hash of htmlContent as key
+ self.annotationToAnchor[htmlContent] = $anchor.attr('name');
+ });
+ };
+
+ AnnotationsPerspective.prototype.goToAnnotation = function(self, srcNode){
+ var content = $(srcNode).html();
+ content = content.replace(/>/g, '>').replace(/</g, '<').replace(/&/g, '&');
+ xml2html({
+ xml: '
WystÄ piÅ bÅÄ d:
' + text + ''); + self.$spinner.hide(); + self.$error.show(); } }); + self.updateAnnotationIds(self); } else { xml = this.doc.text; } - + var parser = new DOMParser(); var serializer = new XMLSerializer(); var doc = parser.parseFromString(xml, 'text/xml'); @@ -56,62 +111,69 @@ 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 anno_list = []; + 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