better annotations dictionary
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 16 Nov 2010 15:38:35 +0000 (16:38 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 16 Nov 2010 15:38:35 +0000 (16:38 +0100)
apps/wiki/templates/wiki/tabs/annotations_view.html
redakcja/static/css/gallery.css
redakcja/static/js/wiki/view_annotations.js

index 56c41b7..c118d0f 100644 (file)
@@ -2,7 +2,10 @@
 <div id="side-annotations">
     <!-- annotations toolbar -->
     <div class="toolbar">
-        <button class="refresh">{% trans "Refresh" %}</button>
+        <button class="refresh" title="Przypisy autorskie">pa</button>
+        <button class="refresh active" title="Przypisy edytorskie">pe</button>
+        <button class="refresh" title="Przypisy redakcyjne">pr</button>
+        <button class="refresh" title="Przypisy tłumacza">pt</button>
         <div class="toolbar-end">
         </div>
     </div>
@@ -10,4 +13,7 @@
     </div>
     <div class="annotations-list">
     </div>
+    <div class="spinner">
+        <img src='/media/static/img/spinner.gif' />
+    </div>
 </div>
index 6a9165e..55c020e 100644 (file)
     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;
index 7294678..f62cd65 100644 (file)
             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();
                 },
                 error: function(text){
                     self.$error.html('<p>Wystąpił błąd:</p><pre>' + text + '</pre>');
+                    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');
 
         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<annos.length; i++)
             {
-                xml_text = serializer.serializeToString(annos[i]).replace(/^<pe[^>]*>|<\/pe>$/g, "");
+                ann_expr = new RegExp("^<"+atype+"[^>]*>|</"+atype+">$", "g")
+                xml_text = serializer.serializeToString(annos[i]).replace(ann_expr, "");
                 xml2html({
                     xml: "<akap>" + xml_text + "</akap>",
                     success: function(xml_text){
                             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();
                     }
                 });
 
         $('.vsplitbar').not('.active').trigger('click');
         $(".vsplitbar-title").html("&darr;&nbsp;PRZYPISY&nbsp;&darr;");
-
-        this.refresh(this);
+        this.$refresh.filter('.active').trigger('click');
 
     };