Class: Lipsiadmin::Ext::Button

Inherits:
Component show all
Defined in:
lib/view/helpers/ext/button.rb

Overview

Generate a new Ext.Button

This component is usefull for ex in toolbars

# Generates:
#{
#  buttons: [{
#    disabled: false,
#    text: Backend.locale.buttons.add,
#    id: "add",
#    cls: "x-btn-text-icon add"
#  },{
#    disabled: true,
#    text: Backend.locale.buttons.edit,
#    id: "edit",
#    cls: "x-btn-text-icon edit"
#  },{
#    disabled: true,
#    text: Backend.locale.buttons.remove,
#    id: "remove",
#    cls: "x-btn-text-icon remove"
#  },{
#    disabled: false,
#    menu: [{
#    text: "Test Me"
#  },{
#    text: "IM a sub Menu"
#  }],
#    text: Backend.locale.buttons.print,
#    id: "print",
#    cls: "x-btn-text-icon print"
#  }]
#}
tbar.add_button :text => "Backend.locale.buttons.add".to_l,    :id => "add",    :disabled => false,  :cls => "x-btn-text-icon add",    :handler => "add".to_l
tbar.add_button :text => "Backend.locale.buttons.edit".to_l,   :id => "edit",   :disabled => true,   :cls => "x-btn-text-icon edit",   :handler => "edit".to_l
tbar.add_button :text => "Backend.locale.buttons.remove".to_l, :id => "remove", :disabled => true,   :cls => "x-btn-text-icon remove", :handler => "remove".to_l
tbar.add_button :text => "Backend.locale.buttons.print".to_l,  :id => "print",  :disabled => false,  :cls => "x-btn-text-icon print" do |menu|
  menu.add_button :text => "Test Me"
  menu.add_button :text => "IM a sub Menu"
end

Instance Method Summary collapse

Methods inherited from Component

#add, #after, #before, #config, #config=, #get_var, #id, #method_missing, #on, #prefix=, #raise_error, #title, #to_s, #un, #var, #with_output_buffer

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Button

:nodoc:

Yields:

  • (_self)

Yield Parameters:



46
47
48
49
# File 'lib/view/helpers/ext/button.rb', line 46

def initialize(options={}, &block)#:nodoc:
  super("Ext.Button", options)
  yield self if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Lipsiadmin::Ext::Component

Instance Method Details

#add_button(options, &block) ⇒ Object

Add new Button to the menu of this one

# Generates: { handler: show, text: "Add", other: "...", icon: "..." }
add_button :text => "Add",  :handler => "show".to_l, :icon => "...", :other => "..."


56
57
58
59
# File 'lib/view/helpers/ext/button.rb', line 56

def add_button(options, &block)
  config[:menu] ||= []
  config[:menu] << (options.is_a?(String) ? options : Button.new(options, &block).config)
end