From 6cdf09812dd13531acb29f1413de87ce7cd5218f Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Tue, 22 Nov 2011 16:00:48 +0100 Subject: Builders and collections for fields and widgets Introduced IPA.field_container and IPA.widget_container. IPA.field_container: collection for fields. Can set logical container (facet, dialog...) to fields. IPA.widget_container: collection for widgets. Has basic searching capability withing widget tree. Introduced field_builder, widget_builder, section_builder, details_builder. All are used for building fields and widgets. Field_builder and widget_builder have the main building logic. Section_builder can create content based on current section spec. Details builder defines a strategy for building content. https://fedorahosted.org/freeipa/ticket/2040 --- install/ui/widget.js | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index 710b6c25..1a5696b9 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -1830,6 +1830,149 @@ IPA.html_util = function() { return that; }(); +IPA.widget_container = function(spec) { + + spec = spec || {}; + + var that = {}; + + that.new_container_for_child = spec.new_container_for_child !== undefined ? + spec.new_container_for_child : true; + + that.widgets = $.ordered_map(); + that.widget_builder = spec.widget_builder || IPA.widget_builder(); + + that.add_widget = function(widget) { + that.widgets.put(widget.name, widget); + }; + + that.get_widget = function(path) { + + var path_len = path.length; + var i = path.indexOf('.'); + var name, child_path, widget, child; + + if (i >= 0) { + name = path.substring(0, i); + child_path = path.substring(i + 1); + + child = that.widgets.get(name); + widget = child.widgets.get_widget(child_path); + } else { + widget = that.widgets.get(path); + } + + return widget; + }; + + that.get_widgets = function() { + return that.widgets.values; + }; + + that.create = function(container) { + + var widgets = that.widgets.values; + for (var i=0; i', { + name: widget.name, + title: widget.label, + 'class': widget['class'] + }).appendTo(container); + } + widget.create(child_container); + + if(i < widgets.length - 1) { + that.create_widget_delimiter(container); + } + } + }; + + that.clear = function() { + + var widgets = that.widgets.values; + for (var i=0; i