/*jsl:import ipa.js */ /* Authors: * Endi Sukma Dewata * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /* REQUIRES: widget.js */ /** * This is a base class for dialog boxes. */ IPA.dialog = function(spec) { spec = spec || {}; var that = {}; that.name = spec.name; that.title = spec.title; that.template = spec.template; that._entity_name = spec.entity_name; that.width = spec.width || '400px'; that.height = spec.height; that.buttons = {}; that.fields = $.ordered_map(); that.sections = $.ordered_map(); that.conditional_fields = []; that.enable_conditional_fields = function(){ for (var i =0; i < that.conditional_fields.length; i+=1) { $('label[id='+ that.conditional_fields[i] +'-label]', that.container).css('visibility','visible'); $('input[name='+ that.conditional_fields[i] + ']',that.container).css('visibility','visible'); } }; that.disable_conditional_fields = function(){ for (var i =0; i < that.conditional_fields.length; i+=1) { $('label[id='+ that.conditional_fields[i] +'-label]', that.container).css('visibility','hidden'); $('input[name='+ that.conditional_fields[i] + ']',that.container).css('visibility','hidden'); } }; that.__defineGetter__("entity_name", function(){ return that._entity_name; }); that.__defineSetter__("entity_name", function(entity_name){ that._entity_name = entity_name; var fields = that.fields.values; for (var i=0; i').appendTo(that.container); var fields = that.fields.values; for (var i=0; i').appendTo(table); var td = $('', { style: 'vertical-align: top;', title: field.label }).appendTo(tr); td.append($('