$.wiki.newTab = function(doc, title, klass) {
var base_id = 'id' + Math.floor(Math.random()* 5000000000);
var id = (''+klass)+'_' + base_id;
var $tab = $('<li id="'+id+'" data-ui-related="'+base_id+'" data-ui-jsclass="'+klass+'" >'
+ title + '<img src="/static/icons/close.png" class="tabclose"></li>');
$.wiki.newTab = function(doc, title, klass) {
var base_id = 'id' + Math.floor(Math.random()* 5000000000);
var id = (''+klass)+'_' + base_id;
var $tab = $('<li id="'+id+'" data-ui-related="'+base_id+'" data-ui-jsclass="'+klass+'" >'
+ title + '<img src="/static/icons/close.png" class="tabclose"></li>');
return new $.wiki[klass]({
doc: options.doc,
id: $(options.tab).attr('id'),
callback: function() {
$.wiki.perspectives[this.perspective_id] = this;
if(options.callback)
return new $.wiki[klass]({
doc: options.doc,
id: $(options.tab).attr('id'),
callback: function() {
$.wiki.perspectives[this.perspective_id] = this;
if(options.callback)
$.wiki.perspectiveForTab = function(tab) { // element or id
return this.perspectives[ $(tab).attr('id')];
}
$.wiki.perspectiveForTab = function(tab) { // element or id
return this.perspectives[ $(tab).attr('id')];
}
$old.each(function(){
$(this).removeClass('active');
$('#' + $(this).attr('data-ui-related')).hide();
self.perspectives[$(this).attr('id')].onExit();
});
$old.each(function(){
$(this).removeClass('active');
$('#' + $(this).attr('data-ui-related')).hide();
self.perspectives[$(this).attr('id')].onExit();
});
$.wiki.Perspective.prototype.onEnter = function () {
// called when perspective in initialized
if (this.perspective_id) {
document.location.hash = '#' + this.perspective_id;
}
$.wiki.Perspective.prototype.onEnter = function () {
// called when perspective in initialized
if (this.perspective_id) {
document.location.hash = '#' + this.perspective_id;
}
$('*[data-stub-value]', $elem).each(function() {
var $this = $(this);
var field = $this.attr('data-stub-value');
$('*[data-stub-value]', $elem).each(function() {
var $this = $(this);
var field = $this.attr('data-stub-value');
else {
$this.attr($this.attr('data-stub-target'), value);
$this.removeAttr('data-stub-target');
else {
$this.attr($this.attr('data-stub-target'), value);
$this.removeAttr('data-stub-target');
if(!self.$elem.attr('data-ui-initialized')) {
console.log("Initializing dialog", this);
self.initialize();
if(!self.$elem.attr('data-ui-initialized')) {
console.log("Initializing dialog", this);
self.initialize();
var action = $(this).attr('data-ui-action');
console.log("Button pressed, action: ", action);
var action = $(this).attr('data-ui-action');
console.log("Button pressed, action: ", action);
try {
self[action + "Action"].call(self);
} catch(e) {
console.log("Action failed:", e);
// always hide on cancel
if(action == 'cancel')
try {
self[action + "Action"].call(self);
} catch(e) {
console.log("Action failed:", e);
// always hide on cancel
if(action == 'cancel')
reportErrors: function(errors) {
var global = $("*[data-ui-error-for='__all__']", this.$elem);
var unassigned = [];
reportErrors: function(errors) {
var global = $("*[data-ui-error-for='__all__']", this.$elem);
var unassigned = [];
- }
- };
-
- $.wiki.cls.GenericDialog = GenericDialog;
-
- $.wiki.showDialog = function(selector) {
+ }
+ };
+
+ $.wiki.cls.GenericDialog = GenericDialog;
+
+ $.wiki.showDialog = function(selector, options) {
-
- try {
- var klass = elem.attr('data-ui-jsclass')
- return new $.wiki.cls[klass](elem);
+
+ try {
+ var klass = elem.attr('data-ui-jsclass');
+ return new $.wiki.cls[klass](elem, options);
} catch(e) {
console.log("Failed to show dialog", selector, klass, e);
return false;
} catch(e) {
console.log("Failed to show dialog", selector, klass, e);
return false;