Class: Cyberweb::Objectified::HtmlTags::Input

Inherits:
Base
  • Object
show all
Defined in:
lib/cyberweb/objectified/html_tags/input.rb

Overview

Cyberweb::Objectified::HtmlTags::Input

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#+, #add_css_rules, #add_this_to_javascript, #add_to_pre_content, #append_css_manager, #append_onto_the_css_class, #append_onto_the_result, #append_the_content, #append_this_to_the_css_style, #attach, #batch_append_css_class_then_the_ID_and_then_the_css_style, #bblack1, #bblack2, #bblack3, #bblack4, #bblack5, #bblack6, #center, #consider_adding_the_pre_content, #consider_adding_the_script_entry_from_the_internal_hash, #content?, #content_as_string, #css_class?, #css_manager, #css_style?, #display, #do_not_load_lazily, #ee, #enable_lazy_loading, #evaluate_this_block, #font=, #id?, #is_an_objectified_html_tag?, #is_draggable?, #lazy_loading?, #make_bold, #modify_the_css_style_based_on_the_alignment, #name=, #name?, #on_click_select, #on_clicked, #on_hover_colour, #on_hover_pulse_increase, #on_mouse_hover, #pad, #pad10px, #pad1px, #pad2px, #pad3px, #pad4px, #pad5px, #pad6px, #pad7px, #pad8px, #pad9px, #path_to_internal_javascript_file, #pre_content?, #raw_result?, #report, report, #report?, #reset_the_content, #reset_the_result, #return_appendable_content, #return_css_class, #return_css_style, #return_javascript, #script?, #set_content, #set_css_class, #set_css_style, #set_id, #set_is_draggable, #set_title, #set_width, #title?, #to_str, #try_to_register_this_tag, #use_this_on_click_function=, #very_light_yellowish_background, #width_height, #yellow_background

Methods included from BaseModule

#attach_these_constants, #base_dir?, #beautiful_url, #cd, #create_the_internal_hash, #doctype?, #ee, #ensure_main_encoding, #esystem, #html_templates, #initialize_the_config_if_the_config_hash_is_empty, #internal_hash?, #log_dir?, #no_http, #random_alphabet_characters, #rarrow?, #rds, #remove_comments_from_this_string, #remove_numbers, #require_the_html_templates, #require_these, #return_file_size_in_kb_of, #return_html_comment, #ruby_sitelib_dir?, #sanitize_this_id, #server_base_directory?, #string_remote_image, #today?, #try_to_require_rack, #try_to_require_the_open_gem, #write_what_into

Methods included from BaseModule::ContentType

#content_type_is_html, #content_type_is_jpeg, #content_type_is_json, #content_type_is_plain_text

Methods included from BaseModule::CommandlineArguments

#append_to_the_commandline_arguments, #commandline_arguments?, #first_argument?, #parse_these_commandline_arguments, #second_argument?, #set_commandline_arguments

Methods included from BaseModule::Colours

#all_html_colours, #lightgreen, #rev, #sdir, #sfancy, #sfile, #simp, #steelblue, #tomato

Constructor Details

#initialize(use_this_text = '', optional_css_class = Input.css_class?, optional_id = nil, optional_css_style = nil) ⇒ Input

#

initialize

Usage example:

Cyberweb::Objectified::HtmlTags::Input.new(i)
#


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 58

def initialize(
    use_this_text      = '',
    optional_css_class = Input.css_class?,
    optional_id        = nil,
    optional_css_style = nil
  )
  try_to_register_this_tag(self)
  reset
  if use_this_text.is_a? Hash
    _ = use_this_text
    # ===================================================================== #
    # === :css_style
    #
    # This entry point should support Syntax such as:
    #
    #   oop_entry(css_style: 'padding: 8px')
    #
    # ===================================================================== #
    if _.has_key? :css_style
      optional_css_style = _.delete(:css_style)
    end
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if _.has_key? :id
      optional_id = _.delete(:id)
    end
    if _.empty?
      use_this_text = ''
    end
  end
  if optional_css_class.is_a? Hash
    _ = optional_css_class
    # ===================================================================== #
    # === :css_style
    #
    # This entry point should support Syntax such as:
    #
    #   oop_entry(css_style: 'padding: 8px')
    #
    # ===================================================================== #
    if _.has_key? :css_style
      optional_css_style = _.delete(:css_style)
    end
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if _.has_key? :id
      optional_id = _.delete(:id)
    end
    if _.empty?
      optional_css_class = ''
    end
  end
  use_this_text = use_this_text.join(' ').strip if use_this_text.is_a? Array
  set_content(use_this_text)
  set_CSS_class(optional_css_class) if optional_css_class
  set_id(optional_id)               if optional_id
  set_CSS_style(optional_css_style) if optional_css_style
end

Class Method Details

.clearObject

#

Cyberweb::Objectified::HtmlTags::Input.clear

#


32
33
34
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 32

def self.clear
  Input.set_css_class('')
end

.css_class?Boolean

#

Cyberweb::Objectified::HtmlTags::Input.css_class?

#

Returns:

  • (Boolean)


46
47
48
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 46

def self.css_class?
  @css_class
end

.reset_css_classObject

#

Cyberweb::Objectified::HtmlTags::Input.reset_css_class

#


25
26
27
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 25

def self.reset_css_class
  @css_class = nil
end

.set_css_class(i = DEFAULT_CSS_CLASS) ⇒ Object

#

Cyberweb::Objectified::HtmlTags::Input.set_css_class

#


39
40
41
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 39

def self.set_css_class(i = DEFAULT_CSS_CLASS)
  @css_class = i
end

Instance Method Details

#is_a_checkboxObject

#

is_a_checkbox

#


153
154
155
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 153

def is_a_checkbox
  @internal_hash[:type] = :checkbox
end

#is_a_submit_buttonObject

#

is_a_submit_button

#


160
161
162
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 160

def is_a_submit_button
  @internal_hash[:type] = :submit
end

#is_requiredObject Also known as: is_mandatory

#

is_required

#


167
168
169
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 167

def is_required
  @internal_hash[:required] = true
end

#is_textObject

#

is_text

#


139
140
141
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 139

def is_text
  @internal_hash[:type] = :text
end

#placeholder=(i) ⇒ Object

#

placeholder=

#


174
175
176
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 174

def placeholder=(i)
  @internal_hash[:placeholder] = i
end

#rebuild_the_resultObject

#

rebuild_the_result

#


181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 181

def rebuild_the_result
  reset_the_result
  consider_adding_the_script_entry_from_the_internal_hash
  consider_adding_the_pre_content
  type = type?
  append_onto_the_result '<input'
  case type
  # ========================================================================= #
  # === :text
  # ========================================================================= #
  when :text
    append_onto_the_result ' type="text"'
  else # Generic handler.
    append_onto_the_result ' type="'+type.to_s+'"'
  end
  # ========================================================================= #
  # === :placeholder
  # ========================================================================= #
  if @internal_hash.has_key?(:placeholder) and @internal_hash[:placeholder]
    append_onto_the_result ' placeholder="'+@internal_hash[:placeholder].to_s+'"'
  end
  if @internal_hash.has_key?(:required) and @internal_hash[:required]
    append_onto_the_result ' required'
  end
  batch_append_css_class_then_the_ID_and_then_the_css_style
  content = content?
  if content and !content.to_s.empty?
    append_onto_the_result ' value="'+content.to_s+'"' unless content.to_s.empty?
  end
  append_onto_the_result ">\n"
  # ======================================================================= #
  # <input> does not have a closing tag in HTML.
  # ======================================================================= #
  return raw_result?
end

#resetObject

#

reset

#


122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 122

def reset
  super()
  # ======================================================================= #
  # === :placeholder
  # ======================================================================= #
  @internal_hash[:placeholder] = nil
  # ======================================================================= #
  # === @internal_hash[:type]
  #
  # Determine a default value for @internal_hash[:type] here.
  # ======================================================================= #
  @internal_hash[:type] = :text
end

#type?Boolean

#

type?

#

Returns:

  • (Boolean)


146
147
148
# File 'lib/cyberweb/objectified/html_tags/input.rb', line 146

def type?
  @internal_hash[:type]
end