From 0a833258b30ef80571c4acc5a732ac4bd58660af Mon Sep 17 00:00:00 2001 From: Jerry Jalava Date: Fri, 18 Jan 2008 14:18:40 +0200 Subject: [PATCH] Enhanced Dialog element --- js/ajatus.elements.js | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/js/ajatus.elements.js b/js/ajatus.elements.js index cc7ded2..8253412 100644 --- a/js/ajatus.elements.js +++ b/js/ajatus.elements.js @@ -19,7 +19,7 @@ /** * Ajatus Dialog */ - $.ajatus.elements.dialog = function(title, msg, options) + $.ajatus.elements.dialog = function(title, msg, opts) { $.ajatus.layout.styles.load($.ajatus.preferences.client.theme_url + 'css/jquery/plugins/jqModal.css'); $.ajatus.layout.styles.load($.ajatus.preferences.client.theme_url + 'css/jquery/plugins/dialog/dialog.css'); @@ -27,18 +27,33 @@ this.holder = $('#dynamic-elements'); this.options = { modal: true, - overlay: 30 + overlay: 30, + closable: true, + dialog: { + width: 300, + height: 200, + nested: false + } }; - this.id = this.create(title, msg, options); + if ( typeof opts != 'undefined' + && typeof opts.dialog != 'undefined') + { + this.options.dialog = $.extend({}, this.options.dialog, opts.dialog); + } + + this.id = this.create(title, msg, opts); return this; }; $.extend($.ajatus.elements.dialog.prototype, { create: function(title, msg, options) { var closable = true; - if (this.options.closable != undefined) { - closable = this.options.closable; + if ( typeof this.options.closable != 'undefined' + && this.options.closable == false) + { + this.options.modal = false; + closable = false; } var id = this._generate_id(); @@ -51,7 +66,7 @@ $('.jqmdMSG',dialog).html(msg); } - this.holder.html(dialog); + this.holder.append(dialog); var content_target = $('.jqmdMSG',dialog); @@ -69,6 +84,14 @@ return id; }, + get_dialog: function() { + return $('#' + this.id); + }, + + get_content_holder: function() { + return $('#' + this.id + ' .jqmdMSG'); + }, + set_content: function(content) { $('#' + this.id + ' .jqmdMSG').html(content); }, @@ -105,12 +128,20 @@ .attr('id', id) .addClass('jqmDialog') .hide() - .css({width: 300, height: 450}); + .css({width: this.options.dialog.width+"px", height: this.options.dialog.height+"px"}); + + if (this.options.dialog.nested) { + body.addClass('jqmdAbove'); + } var frame = $('
'); + $('.jqmdBC', frame).css({ + height: this.options.dialog.height - 70 + "px" + }); + if ( typeof closable == 'undefined' - || closable != false) + && closable) { frame.append(''); } -- 2.11.4.GIT