From ab719d6f3e68ab2525bd0f68f54558a0adbeed85 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Thu, 17 Oct 2013 17:44:36 +0200 Subject: New Fluid form layout https://fedorahosted.org/freeipa/ticket/3904 --- install/ui/src/freeipa/widget.js | 179 ++++++++++++++++++++++++++++++--------- 1 file changed, 140 insertions(+), 39 deletions(-) (limited to 'install/ui/src/freeipa/widget.js') diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index b67ee72a..77846896 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -3738,34 +3738,49 @@ IPA.collapsible_section = function(spec) { var that = IPA.composite_widget(spec); + that.collabsible = !!spec.collabsible; + that.show_header = spec.show_header === undefined ? true : spec.show_header; + that.create = function(container) { that.widget_create(container); - that.header = $('

', { + if (that.show_header) { + that.create_header(container); + } + + that.content_container = $('
', { name: that.name, - title: that.label + 'class': 'details-section' }).appendTo(container); - that.icon = $('', { - name: 'icon', - 'class': 'icon section-expand '+IPA.expanded_icon - }).appendTo(that.header); - - that.header.append(' '); + that.create_content(); + }; - that.header.append(that.label); + that.create_header = function(container) { - that.content_container = $('
', { - name: that.name, - 'class': 'details-section' + that.header = $('

', { + name: that.name }).appendTo(container); - that.header.click(function() { - var visible = that.content_container.is(":visible"); - that.toggle(!visible); - }); + if (that.collabsible) { + that.icon = $('', { + name: 'icon', + 'class': 'icon section-expand '+IPA.expanded_icon + }).appendTo(that.header); + + that.header.click(function() { + var visible = that.content_container.is(":visible"); + that.toggle(!visible); + }); + } + that.header.append(' '); + + that.header.append(that.label); + }; + + that.create_content = function() { that.composite_widget_create(that.content_container); }; @@ -3782,19 +3797,25 @@ IPA.collapsible_section = function(spec) { return that; }; -/** - * Section which can be collapsed - * @class - * @extends IPA.collapsible_section - */ -IPA.details_section = IPA.collapsible_section; - /** * Base layout * @class */ + IPA.layout = function(spec) { - return {}; + + var that = {}; + + that.get_measurement_unit_text = function(widget) { + + if (widget.measurement_unit) { + var unit = text.get('@i18n:measurement_units.'+widget.measurement_unit); + return ' (' + unit + ')'; + } + return ''; + }; + + return that; }; /** @@ -3878,32 +3899,100 @@ IPA.table_layout = function(spec) { return that; }; +IPA.fluid_layout = function(spec) { + + var that = IPA.layout(spec); + + that.cont_cls = spec.cont_cls || 'form-horizontal'; + + that.create = function(widgets) { + + that.rows = $.ordered_map(); + + var container = $('
', { 'class': that.cont_cls }); + + for (var i=0; i', { 'class': 'control-group' }); + that.rows.put(widget.name, group); + + if (widget.hidden) { + group.css('display', 'none'); + } + + group.appendTo(container); + return group; + }; + + that.create_label = function(widget) { + var label_text = widget.label + that.get_measurement_unit_text(widget); + + var label_cont = $('
', { 'class': 'control-label' }); + + $('