From: Radek Czajka Date: Tue, 16 Nov 2010 15:38:35 +0000 (+0100) Subject: better annotations dictionary X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/8f0bfbd922b46c4d9e484343694aaa141de5b4fc?hp=613c90833cd963f769500b79b59e9986bc8970ad better annotations dictionary --- diff --git a/apps/wiki/templates/wiki/tabs/annotations_view.html b/apps/wiki/templates/wiki/tabs/annotations_view.html index 56c41b72..c118d0fa 100644 --- a/apps/wiki/templates/wiki/tabs/annotations_view.html +++ b/apps/wiki/templates/wiki/tabs/annotations_view.html @@ -2,7 +2,10 @@
- + + + +
@@ -10,4 +13,7 @@
+
+ +
diff --git a/redakcja/static/css/gallery.css b/redakcja/static/css/gallery.css index 6a9165e8..55c020ee 100644 --- a/redakcja/static/css/gallery.css +++ b/redakcja/static/css/gallery.css @@ -32,6 +32,25 @@ padding: 1em 1em 0 1em; } +#side-annotations .active { + font-weight: bold; +} + +#side-annotations .spinner { + position: absolute; + left: 0; + top: 28px; + right: 0; + bottom: 0; + text-align:center; + padding-top: 50%; + background: white; +} + +#side-annotations .spinner img { + margin-top: -15px; +} + #side-annotations .akap { font-size: 16px; font-family: "Georgia", "Times New Roman", serif; diff --git a/redakcja/static/js/wiki/view_annotations.js b/redakcja/static/js/wiki/view_annotations.js index 72946789..f62cd65c 100644 --- a/redakcja/static/js/wiki/view_annotations.js +++ b/redakcja/static/js/wiki/view_annotations.js @@ -15,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.text(); + + self.$annos.hide(); + self.$error.hide(); + self.$spinner.show(100, function(){ + self.refresh(self, atype); + }); }); old_callback.call(this); @@ -27,7 +40,7 @@ AnnotationsPerspective.prototype = new $.wiki.Perspective(); - AnnotationsPerspective.prototype.refresh = function(self) { + AnnotationsPerspective.prototype.refresh = function(self, atype) { var xml; persp = $.wiki.activePerspective(); @@ -42,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'); @@ -56,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 = doc.getElementsByTagName(atype); var counter = annos.length; + if (annos.length == 0) + { + self.$annos.html('Nie ma żadnych przypisów'); + self.$spinner.hide(); + self.$annos.show(); + } for (var i=0; i]*>|<\/pe>$/g, ""); + ann_expr = new RegExp("^<"+atype+"[^>]*>|$", "g") + xml_text = serializer.serializeToString(annos[i]).replace(ann_expr, ""); xml2html({ xml: "" + xml_text + "", success: function(xml_text){ @@ -82,13 +102,16 @@ if (!counter) { anno_list.sort(function(a, b){return a.sortby.localeCompare(b.sortby);}); self.$annos.append(anno_list); + self.$spinner.hide(); self.$annos.show(); } + } }(xml_text), error: function(text) { $.unblockUI(); self.$error.html(text); + self.$spinner.hide(); self.$error.show(); } }); @@ -104,8 +127,7 @@ $('.vsplitbar').not('.active').trigger('click'); $(".vsplitbar-title").html("↓ PRZYPISY ↓"); - - this.refresh(this); + this.$refresh.filter('.active').trigger('click'); };