return (!!CurrentDocument && CurrentDocument.has_local_changes) || ap.dirty();
};
- $.wiki.newTab = function(doc, title, klass) {
- var base_id = 'id' + Math.floor(Math.random()* 5000000000);
+ $.wiki.newTab = function(doc, title, klass, base_id) {
var id = (''+klass)+'_' + base_id;
var $tab = $('<li class="nav-item" id="'+id+'" data-ui-related="'+base_id+'" data-ui-jsclass="'+klass+'" ><a href="#" class="nav-link">'
+ title + ' <span class="badge badge-danger tabclose">x</span></a></li>');
$.wiki.initTab = function(options) {
var klass = $(options.tab).attr('data-ui-jsclass');
- return new $.wiki[klass]({
+ let perspective = new $.wiki[klass]({
doc: options.doc,
id: $(options.tab).attr('id'),
- callback: function() {
- $.wiki.perspectives[this.perspective_id] = this;
- if(options.callback)
- options.callback.call(this);
- }
});
+ $.wiki.perspectives[perspective.perspective_id] = perspective;
+ return perspective;
};
$.wiki.perspectiveForTab = function(tab) { // element or id
$.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();
var self = this;
var $tab = $(tab);
+ // Create dynamic tabs (for diffs).
+ if ($tab.length != 1) {
+ let parts = tab.split('_');
+ if (parts.length > 1) {
+ // TODO: register perspectives for it.
+ if (parts[0] == '#DiffPerspective') {
+ $tab = $($.wiki.DiffPerspective.openId(parts[1]));
+ }
+ }
+ }
+
if($tab.length != 1)
$tab = $(DEFAULT_PERSPECTIVE);
*/
$.wiki.Perspective = class Perspective {
constructor(options) {
- if(!options) return;
-
this.doc = options.doc;
- if (options.id) {
- this.perspective_id = options.id;
- }
- else {
- this.perspective_id = '';
- }
-
- if(options.callback)
- options.callback.call(this);
+ this.perspective_id = options.id || ''
};
config() {
destroy() {
// pass
}
-
- freezeState() {
- // free UI state (don't store data here)
- }
-
- unfreezeState(frozenState) {
- // restore UI state
- }
}
/*
$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);