diff --git a/gxg/web/gxg_applications.rb b/gxg/web/gxg_applications.rb index 06a1ada..4a69946 100644 --- a/gxg/web/gxg_applications.rb +++ b/gxg/web/gxg_applications.rb @@ -440,6 +440,7 @@ module GxG # def menu_item_select(data=nil) # override this in your object script. + # data will contain the entire menu object settings. end # def run(data={}) diff --git a/gxg/web/gxg_foundation.rb b/gxg/web/gxg_foundation.rb index c541e78..c7a9cd9 100644 --- a/gxg/web/gxg_foundation.rb +++ b/gxg/web/gxg_foundation.rb @@ -1416,6 +1416,80 @@ module GxG super() @domtype = :li end + # + def initialize(the_parent, options, other_data={}) + @label = nil + super(the_parent, options, other_data) + self + end + # + def cascade + # + label = new_component(:"org.gxg.gui.link.anchor") + label.title = "label #{@uuid.to_s}" + # label[:options] = {:href => "#0", :content => (@settings[:label] || "Untitled").to_s} + label[:options] = {:content => (@settings[:label] || "Untitled").to_s} + label[:script] = " + on(:mouseup) do |event| + if @parent.enabled? + @parent.selecct() + end + end + " + # + page.build_components(self, [(label)], {:application => @application}) + the_object = page.find_object_by("label #{@uuid.to_s}") + if the_object + @label = the_object + end + end + # + def label() + @label + end + # + def set_label_text(the_text=nil) + if @label + @label.set_text(the_text.to_s) + @settings[:label] = the_text.to_s + end + end + # + def enabled?() + if @label + if @label.state_active?(:"menu-item-disabled") + false + else + true + end + else + false + end + end + # + def enable() + if @label + @label.set_state(:"menu-item-disabled",false) + end + end + # + def disable() + if @label + @label.set_state(:"menu-item-disabled",true) + end + end + # + def set_data(data=nil) + @settings[:data] = data + end + # + def select(data=nil) + application = @parent.application() + if application + application.menu_item_select(@settings) + end + end + # end ::GxG::Gui::register_component_class(:"org.gxg.gui.dropdown.menu.item", ::GxG::Gui::DropdownMenuItem) # @@ -1507,6 +1581,7 @@ module GxG unless @options.keys.include?(:"data-dropdown-menu") @options[:"data-dropdown-menu"] = nil end + # end # def add_menu_item(label=nil, data=nil) @@ -1516,20 +1591,13 @@ module GxG the_item[:options] = {} the_item[:script] = "" the_item[:content] = [] - page.build_components(self, [(the_item)]) + page.build_components(self, [(the_item)], {:application => @application}) true end end ::GxG::Gui::register_component_class(:"org.gxg.gui.dropdown.menu", ::GxG::Gui::DropdownMenu) # class MenuBar < ::GxG::Gui::DropdownMenu - def set_application(the_application=nil) - @application = the_application - end - # - def application() - @application - end end ::GxG::Gui::register_component_class(:"org.gxg.gui.menu.bar", ::GxG::Gui::MenuBar) # @@ -1545,17 +1613,10 @@ module GxG def add_menu_item(label=nil, data=nil) the_item = new_component(:"org.gxg.gui.menu.item") the_item[:settings] = {:label => label, :data => data} - page.build_components(self, [(the_item)]) + page.build_components(self, [(the_item)], {:application => @application}) true end # - def set_application(the_application=nil) - @application = the_application - end - # - def application() - @application - end end ::GxG::Gui::register_component_class(:"org.gxg.gui.menu", ::GxG::Gui::Menu) # @@ -1565,9 +1626,9 @@ module GxG @domtype = :li end # - def initialize(the_parent, options) + def initialize(the_parent, options, other_data={}) @label = nil - super(the_parent, options) + super(the_parent, options, other_data) self end # @@ -1579,24 +1640,54 @@ module GxG label[:options] = {:content => (@settings[:label] || "Untitled").to_s} label[:script] = " on(:mouseup) do |event| - @parent.selecct() + if @parent.enabled? + @parent.selecct() + end end " # - page.build_components(self, [(label)]) + page.build_components(self, [(label)], {:application => @application}) the_object = page.find_object_by("label #{@uuid.to_s}") if the_object @label = the_object end end # - def set_label(the_text=nil) + def label() + @label + end + # + def set_label_text(the_text=nil) if @label @label.set_text(the_text.to_s) @settings[:label] = the_text.to_s end end # + def enabled?() + if @label + if @label.state_active?(:"menu-item-disabled") + false + else + true + end + else + false + end + end + # + def enable() + if @label + @label.set_state(:"menu-item-disabled",false) + end + end + # + def disable() + if @label + @label.set_state(:"menu-item-disabled",true) + end + end + # def set_data(data=nil) @settings[:data] = data end @@ -1604,7 +1695,7 @@ module GxG def select(data=nil) application = @parent.application() if application - application.menu_item_select(@settings[:data]) + application.menu_item_select(@settings) end end # diff --git a/gxg/web/gxg_vdom.rb b/gxg/web/gxg_vdom.rb index b3b31d7..1c203c2 100644 --- a/gxg/web/gxg_vdom.rb +++ b/gxg/web/gxg_vdom.rb @@ -519,6 +519,14 @@ module GxG def toggle_state(the_state) self.set_state(the_state,(! self.get_state(the_state))) end + # + def set_application(the_application=nil) + @application = the_application + end + # + def application() + @application + end # Determine if the state is active # # @param [String] state The state name diff --git a/gxg/web/gxg_windows.rb b/gxg/web/gxg_windows.rb index 9723db8..953f785 100644 --- a/gxg/web/gxg_windows.rb +++ b/gxg/web/gxg_windows.rb @@ -479,34 +479,34 @@ module GxG @menu_reference end # - def menu() - @menu_bar + def menubar() + @menu_area end # - def set_menu(the_menu_source=nil) - if the_menu_source.is_any?(::Hash, ::GxG::Database::DetachedHash) - if @menu_area - page.build_components(@menu_area, [(the_menu_source)]) - # - @menu_margin = (`#{@menu_area.element}.getBoundingClientRect().bottom - #{@menu_area.element}.getBoundingClientRect().top`.to_i) - # - @menu_bar = self.find_child(@menu_reference,true) - # - if @menu_bar - self.commit_settings - true - else - log_warn("Unable to properly initialize window menu #{@menu_reference.inspect} .") - false - end - else - false - end - else - false - end - end - alias :menu= :set_menu + # def set_menu(the_menu_source=nil) + # if the_menu_source.is_any?(::Hash, ::GxG::Database::DetachedHash) + # if @menu_area + # page.build_components(@menu_area, [(the_menu_source)]) + # # + # @menu_margin = (`#{@menu_area.element}.getBoundingClientRect().bottom - #{@menu_area.element}.getBoundingClientRect().top`.to_i) + # # + # @menu_bar = self.find_child(@menu_reference,true) + # # + # if @menu_bar + # self.commit_settings + # true + # else + # log_warn("Unable to properly initialize window menu #{@menu_reference.inspect} .") + # false + # end + # else + # false + # end + # else + # false + # end + # end + # alias :menu= :set_menu # alias :original_add_child :add_child def add_child(object_record=nil) @@ -1223,7 +1223,7 @@ module GxG build_list << resizing_areas # @content = nil - page.build_components(self,build_list) + page.build_components(self,build_list, {:application => @application}) # self.build_interior_components(build_list) # the_object = page.find_object_by(interior_component_uuid)