fixes #4475: Split thema into separate fields.
[redakcja.git] / src / redakcja / static / js / wiki / base.js
index 4d3a062..ad0ca83 100644 (file)
     $.wiki.exitTab = function(tab){
         var self = this;
         var $tab = $(tab);
-        if (!('.active', $tab)) return;
+        if (!('.active', $tab).length) return;
         $('.active', $tab).removeClass('active');
         self.perspectives[$tab.attr('id')].onExit();
         $('#' + $tab.attr('data-ui-related')).hide();
         $elem.removeClass('row-stub');
         params.container.append($elem);
 
-        $('*[data-stub-value]', $elem).each(function() {
-            var $this = $(this);
+        var populate = function($this) {
             var field = $this.attr('data-stub-value');
 
             var value = params.data[field];
                 $this.removeAttr('data-stub-target');
                 $this.removeAttr('data-stub-value');
             }
-        });
+        }
+        if ($elem.attr('data-stub-value')) populate($elem);
+        $('*[data-stub-value]', $elem).each(function() {populate($(this))});
 
         $elem.show();
         return $elem;
                 var span = $("*[data-ui-error-for='"+field_name+"']", this.$elem);
 
                 if(!span.length) {
-                    unassigned.push(field_name);
+                    unassigned.push(errors[field_name]);
                     continue;
                 }
 
             }
 
             if(unassigned.length > 0)
-                global.text( global.text() + 'W formularzu wystąpiły błędy');
+                global.text(
+                    global.text() + 'Wystąpił błąd: ' + unassigned.join(', '));
         }
     }
 
         $.ajax("/editor/editor-user-area/", {
             success: function(d) {
                 $("#user-area")[0].innerHTML = d;
+                $('#history-view-editor').toggleClass('can-approve', $('#user-area #pubmark_dialog').length > 0);
             }
         });
     }, false);