From c8eb76766afc8755e709cdba62586a8ab1ad65c9 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 21 Jun 2011 15:05:44 -0500 Subject: Converted entity header into facet header. The content and the size of entity header changes depending on the facet being displayed, so the entity header has been converted into a facet header to allow better control via CSS. The DNS record facet has been updated to use the same styling and support scrolling. To help styling and testing, all buttons have been assigned a name. --- install/ui/entity.js | 370 ++++++++++++++++++++++++--------------------------- 1 file changed, 177 insertions(+), 193 deletions(-) (limited to 'install/ui/entity.js') diff --git a/install/ui/entity.js b/install/ui/entity.js index 7e600e4e7..6a01652e5 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -31,10 +31,16 @@ IPA.facet = function (spec) { var that = {}; - that.display_class = spec.display_class || 'entity-facet'; that.name = spec.name; that.label = spec.label; that.title = spec.title || that.label; + that.display_class = spec.display_class; + + that.disable_back_link = spec.disable_back_link; + that.disable_facet_tabs = spec.disable_facet_tabs; + + that.header = spec.header || IPA.facet_header({ facet: that }); + that._entity_name = spec.entity_name; that.dialogs = $.ordered_map(); @@ -73,10 +79,13 @@ IPA.facet = function (spec) { that.container = container; - that.header = $('
', { + if (that.disable_facet_tabs) that.container.addClass('no-facet-tabs'); + that.container.addClass(that.display_class); + + that.header_container = $('
', { 'class': 'facet-header' }).appendTo(container); - that.create_header(that.header); + that.create_header(that.header_container); that.content = $('
', { 'class': 'facet-content' @@ -86,13 +95,7 @@ IPA.facet = function (spec) { that.create_header = function(container) { - that.title_container = $('
', { - 'class': 'facet-title' - }).appendTo(container); - - $('

').append(IPA.create_network_spinner()).appendTo(that.title_container); - - that.set_title(container, that.title); + that.header.create(container); that.controls = $('
', { 'class': 'facet-controls' @@ -168,6 +171,7 @@ IPA.facet = function (spec) { // methods that should be invoked by subclasses that.facet_init = that.init; + that.facet_create = that.create; that.facet_create_header = that.create_header; that.facet_create_content = that.create_content; that.facet_setup = that.setup; @@ -177,6 +181,165 @@ IPA.facet = function (spec) { return that; }; +IPA.facet_header = function(spec) { + + spec = spec || {}; + + var that = {}; + that.facet = spec.facet; + + that.select_tab = function() { + if (that.facet.disable_facet_tabs) return; + + $(that.facet_tabs).find('a').removeClass('selected'); + var facet_name = $.bbq.getState(that.facet.entity.name+'-facet'); + + if (!facet_name || facet_name === 'default') { + that.facet_tabs.find('a:first').addClass('selected'); + } else { + that.facet_tabs.find('a#' + facet_name ).addClass('selected'); + } + }; + + that.set_pkey = function(value) { + + if (value) { + var breadcrumb = []; + var current_entity = that.facet.entity.containing_entity; + + while(current_entity){ + breadcrumb.unshift($('',{ + text:$.bbq.getState(current_entity.name+'-pkey'), + title: current_entity.name, + click: function() { + var entity = IPA.get_entity((this.title)); + IPA.nav.show_page(that.facet.entity.name, 'default'); + $('a', that.facet_tabs).removeClass('selected'); + return false; + } + })); + + current_entity = current_entity.containing_entity; + } + + that.title_container.empty(); + var h3 = $('

').appendTo(that.title_container); + + h3.empty(); + h3.append(that.facet.entity.title); + h3.append(': '); + + for (var i = 0; i < breadcrumb.length; i+=1){ + h3.append(breadcrumb[i]); + h3.append(' > '); + + } + h3.append( + $('', { + 'class': 'facet-pkey', + text:value + })); + } else { + that.title_container.empty(); + var span = $('

',{ + text: that.facet.entity.metadata.label + }).appendTo(that.title_container); + } + }; + + that.create_facet_link = function(container, other_facet) { + + var li = $('
  • ', { + title: other_facet.name, + click: function() { + if (li.hasClass('entity-facet-disabled')) { + return false; + } + + var pkey = $.bbq.getState(that.facet.entity.name+'-pkey'); + IPA.nav.show_page(that.facet.entity.name, other_facet.name, pkey); + + return false; + } + }).appendTo(container); + + $('', { + text: other_facet.label, + id: other_facet.name + }).appendTo(li); + }; + + that.create_facet_group = function(container, facet_group) { + + var section = $('', { + 'class': 'facet-group' + }).appendTo(container); + + $('
    ', { + 'class': 'facet-group-name', + text: facet_group.label + }).appendTo(section); + + var ul = $('