/* 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; version 2 only * * 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* REQUIRES: ipa.js */ function ipa_widget(spec) { spec = spec || {}; var that = {}; that.id = spec.id; that.name = spec.name; that.label = spec.label; that.read_only = spec.read_only; that._entity_name = spec.entity_name; that.create = spec.create || create; that.setup = spec.setup || setup; that.load = spec.load || load; that.save = spec.save || save; that.super = function(name) { var method = that[name]; return function () { return method.apply(that, arguments); }; }; that.__defineGetter__("entity_name", function(){ return that._entity_name; }); that.__defineSetter__("entity_name", function(entity_name){ that._entity_name = entity_name; }); function create(container) { } function setup(container) { } function load(container, result) { } function save(container) { return []; } return that; } function ipa_text_widget(spec) { spec = spec || {}; var that = ipa_widget(spec); that.load = function(container, result) { that.value = result[that.name] || ''; var input = $('input[name="'+that.name+'"]', container); var param_info = ipa_get_param_info(that.entity_name, that.name); if (param_info.primary_key) { input.replaceWith($('