/*jsl:import ipa.js */ /* Authors: * Pavel Zuna * Adam Young * Endi S. 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 . */ /* IPA Object Details - populating definiton lists from entry data */ /* REQUIRES: ipa.js */ IPA.expanded_icon = 'expanded-icon'; IPA.collapsed_icon = 'collapsed-icon'; IPA.details_section = function(spec) { spec = spec || {}; var that = {}; that.name = spec.name || ''; that.label = spec.label || ''; that.template = spec.template; that._entity_name = spec.entity_name; that.fields = $.ordered_map(); 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', { name: field.name, 'class': 'details-field' }).appendTo(container); field.create(field_container); } }; that.setup = function(container) { that.container = container; if (that.template) return; var fields = that.fields.values; for (var i=0; i tag. * The attribute name is defined inside a
tag. The attribute * value is specified within a inside a
tag. If the * attribute has multiple values the will contain be * duplicated to display each value. * * Example: *
* *
First Name:
*
* * John Smith * *
* *
Telephone Number:
*
* *
111-1111
*
222-2222
*
*
* *
*/ IPA.details_list_section = function(spec) { spec = spec || {}; var that = IPA.details_section(spec); that.create = function(container) { // do not call section_create() here if (that.template) return; var dl = $('
', { 'id': that.name, 'class': 'entryattrs' }).appendTo(container); var fields = that.fields.values; for (var i=0; i', { html: label+':', title: label }).appendTo(dl); var dd = $('
').appendTo(dl); var field_container = $('
', { name: field.name, 'class': 'details-field' }).appendTo(dd); field.create(field_container); } }; return that; }; IPA.details_facet = function(spec) { spec = spec || {}; spec.name = spec.name || 'details'; var that = IPA.facet(spec); that.pre_execute_hook = spec.pre_execute_hook; that.label = spec.label || IPA.messages && IPA.messages.facets && IPA.messages.facets.details; that.facet_group = spec.facet_group || 'settings'; that.sections = $.ordered_map(); that.__defineGetter__("entity_name", function(){ return that._entity_name; }); that.__defineSetter__("entity_name", function(entity_name){ that._entity_name = entity_name; var sections = that.sections.values; for (var i=0; i', { 'class': 'details-content' }).appendTo(container); var sections = that.sections.values; for (var i=0; i', { name: section.name, title: section.label }).appendTo(that.content); var icon = $('', { name: 'icon', 'class': 'icon section-expand '+IPA.expanded_icon }).appendTo(header); header.append(' '); header.append(section.label); var div = $('
', { name: section.name, 'class': 'details-section' }).appendTo(that.content); header.click(function(section, div) { return function() { var visible = div.is(":visible"); that.toggle(section, !visible); }; }(section, div)); section.create(div); if (i < sections.length-1) { that.content.append('
'); } } $('', { name: 'summary', 'class': 'details-summary' }).appendTo(container); }; that.setup = function(container) { that.facet_setup(container); var sections = that.sections.values; for (var i=0; i', { id: spec.id, name: spec.name, href: spec.href || '#' + (spec.name || 'button'), title: spec.title || spec.label, 'class': 'ui-state-default ui-corner-all input_link', style: spec.style, click: spec.click, blur: spec.blur }); if (spec['class']) button.addClass(spec['class']); if (spec.icon) { $('', { 'class': 'icon '+spec.icon }).appendTo(button); } if (spec.label) { $('', { 'class': 'button-label', html: spec.label }).appendTo(button); } return button; };