Class: Cyberweb::Objectified::HtmlTags::Base
- Inherits:
-
Object
- Object
- Cyberweb::Objectified::HtmlTags::Base
show all
- Includes:
- BaseModule
- Defined in:
- lib/cyberweb/objectified/html_tags/base.rb
Overview
Direct Known Subclasses
Audio, Blockquote, Body, Button, Canvas, Cite, Embed, Fieldset, Figure, Form, Head, Input, Label, Legend, Meta, Object, Progress, Section, Select, Span, Style, Table, Textarea, Thead, Title, Objectified::HtmlTags::A, Objectified::HtmlTags::Abbr, Objectified::HtmlTags::Div, Objectified::HtmlTags::H1, Objectified::HtmlTags::H2, Objectified::HtmlTags::H3, Objectified::HtmlTags::H4, Objectified::HtmlTags::H5, Objectified::HtmlTags::H6, Objectified::HtmlTags::I, Objectified::HtmlTags::Img, Objectified::HtmlTags::Li, Objectified::HtmlTags::Map, Objectified::HtmlTags::Nav, Objectified::HtmlTags::Ol, Objectified::HtmlTags::P, Objectified::HtmlTags::Pre, Objectified::HtmlTags::Td, Objectified::HtmlTags::Th, Objectified::HtmlTags::Tr, Objectified::HtmlTags::Ul
Class Method Summary
collapse
Instance Method Summary
collapse
-
#+(i = '') ⇒ Object
# === + ========================================================================= #.
-
#add_css_rules(i) ⇒ Object
# === add_css_rules.
-
#add_this_to_javascript(i, script = script? ) ⇒ Object
# === add_this_to_javascript.
-
#add_to_pre_content(i, append_a_newline = true) ⇒ Object
(also: #add_to_the_pre_content)
# === add_to_pre_content.
-
#append_css_manager(i, use_this_name = nil) ⇒ Object
# === append_css_manager.
-
#append_onto_the_css_class(i) ⇒ Object
(also: #append_onto_the_CSS_class, #acss, #append_to_css_class, #append_css_class, #add_to_CSS_classes, #add_this_CSS_class, #append_this_onto_the_CSS_class)
# === append_onto_the_css_class (append tag).
-
#append_onto_the_result(i) ⇒ Object
# === append_onto_the_result ========================================================================= #.
-
#append_the_content(content = content?, , append_to = raw_result? # This is: @internal_hash[:result] ) ⇒ Object
# === append_the_content.
-
#append_this_to_the_css_style(i) ⇒ Object
(also: #add_to_CSS_style, #append_css_style, #append_to_the_CSS_style)
# === append_this_to_the_css_style.
-
#attach(i) ⇒ Object
(also: #onto_result, #add, #append_to_content, #append_onto_content)
# === attach (attach tag, add tag).
-
#batch_append_css_class_then_the_ID_and_then_the_css_style ⇒ Object
# === batch_append_css_class_then_the_ID_and_then_the_css_style.
-
#bblack1 ⇒ Object
# === bblack1.
-
#bblack2 ⇒ Object
# === bblack2 ========================================================================= #.
-
#bblack3 ⇒ Object
# === bblack3 ========================================================================= #.
-
#bblack4 ⇒ Object
# === bblack4 ========================================================================= #.
-
#bblack5 ⇒ Object
# === bblack5 ========================================================================= #.
-
#bblack6 ⇒ Object
# === bblack6 ========================================================================= #.
-
#center ⇒ Object
# === center ========================================================================= #.
-
#consider_adding_the_pre_content(i = pre_content? ) ⇒ Object
# === consider_adding_the_pre_content ========================================================================= #.
-
#consider_adding_the_script_entry_from_the_internal_hash(script = script? ) ⇒ Object
# === consider_adding_the_script_entry_from_the_internal_hash.
-
#content? ⇒ Boolean
# === content? ========================================================================= #.
-
#content_as_string ⇒ Object
# === content_as_string.
-
#css_class? ⇒ Boolean
# === css_class? ========================================================================= #.
-
#css_manager(i = '', optional_argument1 = nil) ⇒ Object
# === css_manager.
-
#css_style? ⇒ Boolean
# === css_style? ========================================================================= #.
-
#display ⇒ Object
# === report (report tag) ========================================================================= # === display.
-
#do_not_load_lazily ⇒ Object
# === do_not_load_lazily ========================================================================= #.
-
#ee ⇒ Object
# === report (report tag) ========================================================================= # === ee.
-
#enable_lazy_loading ⇒ Object
(also: #lazy_loading, #lazy)
# === enable_lazy_loading ========================================================================= #.
-
#evaluate_this_block(&block) ⇒ Object
# === evaluate_this_block ========================================================================= #.
-
#font=(i) ⇒ Object
# === font= ========================================================================= #.
-
#id? ⇒ Boolean
# === id?.
-
#is_an_objectified_html_tag? ⇒ Boolean
# === is_an_objectified_html_tag?.
-
#is_draggable? ⇒ Boolean
# === is_draggable? ========================================================================= #.
-
#lazy_loading? ⇒ Boolean
# === lazy_loading? ========================================================================= #.
-
#make_bold ⇒ Object
# === make_bold ========================================================================= #.
-
#modify_the_css_style_based_on_the_alignment(i = ) ⇒ Object
# === modify_the_css_style_based_on_the_alignment.
-
#name=(i) ⇒ Object
(also: #set_name)
# === name=.
-
#name? ⇒ Boolean
# === name?.
-
#on_click_select ⇒ Object
(also: #on_clicked_select)
# === on_click_select.
-
#on_clicked(&block) ⇒ Object
# === on_clicked.
-
#on_hover_colour(use_this_colour = :steelblue) ⇒ Object
(also: #on_hover)
# === on_hover_colour.
-
#on_hover_pulse_increase(n_times = 8) ⇒ Object
# === on_hover_pulse_increase ========================================================================= #.
-
#on_mouse_hover(&block) ⇒ Object
(also: #on_mouse_over)
# === on_mouse_hover.
-
#pad ⇒ Object
# === pad ========================================================================= #.
-
#pad10px ⇒ Object
# === pad10px ========================================================================= #.
-
#pad1px ⇒ Object
# === pad1px ========================================================================= #.
-
#pad2px ⇒ Object
# === pad2px ========================================================================= #.
-
#pad3px ⇒ Object
# === pad3px ========================================================================= #.
-
#pad4px ⇒ Object
# === pad4px ========================================================================= #.
-
#pad5px ⇒ Object
# === pad5px ========================================================================= #.
-
#pad6px ⇒ Object
# === pad6px ========================================================================= #.
-
#pad7px ⇒ Object
# === pad7px ========================================================================= #.
-
#pad8px ⇒ Object
# === pad8px ========================================================================= #.
-
#pad9px ⇒ Object
# === pad9px ========================================================================= #.
-
#path_to_internal_javascript_file(i) ⇒ Object
# === path_to_internal_javascript_file.
-
#pre_content? ⇒ Boolean
# === pre_content? ========================================================================= #.
-
#raw_result? ⇒ Boolean
# === raw_result? ========================================================================= #.
-
#report(&block) ⇒ Object
# === report (report tag) ========================================================================= #.
-
#report? ⇒ Object
# === report (report tag) ========================================================================= # === report?.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#reset_the_content ⇒ Object
# === reset_the_content ========================================================================= #.
-
#reset_the_result ⇒ Object
# === reset_the_result ========================================================================= #.
-
#return_appendable_content ⇒ Object
(also: #appendable_content)
# === return_appendable_content.
-
#return_css_class(i = css_class? ) ⇒ Object
# === return_css_class ========================================================================= #.
-
#return_css_style(i = css_style? ) ⇒ Object
# === return_css_style.
-
#return_javascript(i) ⇒ Object
# === return_javascript ========================================================================= #.
-
#script? ⇒ Boolean
# === script? ========================================================================= #.
-
#set_content(i) ⇒ Object
(also: #content=, #inject, #value=, #<<, #set_text, #text=, #text)
# === set_content.
-
#set_css_class(i) ⇒ Object
(also: #class=, #css_class=, #css_class, #set_CSS_class)
# === set_css_class.
-
#set_css_style(i) ⇒ Object
(also: #style=, #css_style=, #style, #css_style, #set_CSS_style)
# === set_css_style ========================================================================= #.
-
#set_id(i = nil) ⇒ Object
(also: #id, #id=)
# === set_id.
-
#set_is_draggable ⇒ Object
(also: #is_draggable)
# === is_draggable.
-
#set_title(i) ⇒ Object
# === set_title ========================================================================= #.
-
#set_width(i = '500px') ⇒ Object
(also: #width=)
# === set_width ========================================================================= #.
-
#title? ⇒ Boolean
# === title?.
-
#to_str ⇒ Object
(also: #to_s, #string?, #result?)
# === to_str ========================================================================= #.
-
#try_to_register_this_tag(i) ⇒ Object
# === try_to_register_this_tag ========================================================================= #.
-
#use_this_on_click_function=(i, optional_arguments = '') ⇒ Object
(also: #set_use_this_on_click_function, #set_on_clicked)
# === use_this_on_click_function= ========================================================================= #.
-
#very_light_yellowish_background ⇒ Object
# === very_light_yellowish_background ========================================================================= #.
-
#width_height(width = 80, height = 40) ⇒ Object
# === width_height ========================================================================= #.
-
#yellow_background ⇒ Object
# === yellow_background ========================================================================= #.
Methods included from BaseModule
#attach_these_constants, #base_dir?, #beautiful_url, #cd, #create_the_internal_hash, #doctype?, #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
#content_type_is_html, #content_type_is_jpeg, #content_type_is_json, #content_type_is_plain_text
#append_to_the_commandline_arguments, #commandline_arguments?, #first_argument?, #parse_these_commandline_arguments, #second_argument?, #set_commandline_arguments
#all_html_colours, #lightgreen, #rev, #sdir, #sfancy, #sfile, #simp, #steelblue, #tomato
Class Method Details
.clear(operate_on_this_namespace = Cyberweb::Div) ⇒ Object
102
103
104
105
106
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 102
def self.clear(
operate_on_this_namespace = Cyberweb::Div
)
operate_on_this_namespace.clear end
|
.report(i, optional_arguments = nil) ⇒ Object
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1263
def self.report(
i, optional_arguments = nil
)
use_this_class = Cyberweb::Objectified::HtmlTags.const_get(inspect)
n_arguments = use_this_class.instance_method(:initialize).parameters.size
case n_arguments
when 1
print use_this_class.new(i).to_str
when 2
print use_this_class.new(i, optional_arguments).to_str
else
raise StandardError.new('Unhandled number of parameters.')
end
end
|
Instance Method Details
#+(i = '') ⇒ Object
531
532
533
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 531
def +(i = '')
self.to_s+i.to_s
end
|
#add_css_rules(i) ⇒ Object
#
add_css_rules
This method is primarily used by the HTML <div> tag (or the helper class called Window).
#
1110
1111
1112
1113
1114
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1110
def add_css_rules(i)
add(
"<style>#{i}</style>\n"
)
end
|
#add_this_to_javascript(i, script = script?
) ⇒ Object
#
add_this_to_javascript
Use this method to add to the javascript <script> tag.
#
934
935
936
937
938
939
940
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 934
def add_this_to_javascript(
i,
script = script?
)
script = ''.dup if script.nil? script << i
end
|
#add_to_pre_content(i, append_a_newline = true) ⇒ Object
Also known as:
add_to_the_pre_content
#
add_to_pre_content
This method will, by default, always append a newline.
#
569
570
571
572
573
574
575
576
577
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 569
def add_to_pre_content(
i,
append_a_newline = true
)
if append_a_newline
i << "\n"
end
@internal_hash[:pre_content] << i
end
|
#append_css_manager(i, use_this_name = nil) ⇒ Object
#
append_css_manager
This is a bit of a misnomer, as it will not be “append” - instead we will simply add onto the pre-content.
#
1173
1174
1175
1176
1177
1178
1179
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1173
def append_css_manager(
i, use_this_name = nil
)
add_to_the_pre_content(
css_manager(i, use_this_name).result_as_CSS_style?
)
end
|
#append_onto_the_css_class(i) ⇒ Object
Also known as:
append_onto_the_CSS_class, acss, append_to_css_class, append_css_class, add_to_CSS_classes, add_this_CSS_class, append_this_onto_the_CSS_class
#
append_onto_the_css_class (append tag)
This method will append onto the CSS classes in use.
#
871
872
873
874
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 871
def append_onto_the_css_class(i)
@internal_hash[:css_class] << " #{i}"
@internal_hash[:css_class].rstrip!
end
|
#append_onto_the_result(i) ⇒ Object
#
append_onto_the_result
#
369
370
371
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 369
def append_onto_the_result(i)
@internal_hash[:result] << i
end
|
#append_the_content(content = content?,
, append_to = raw_result? # This is: @internal_hash[:result]
) ⇒ Object
#
append_the_content
This method will append the current content of :content onto the variable :result.
#
353
354
355
356
357
358
359
360
361
362
363
364
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 353
def append_the_content(
content = content?,
append_to = raw_result? )
if content.is_a? Array content.each {|entry|
append_to << "#{entry}\n"
}
else
append_to << content
end
end
|
#append_this_to_the_css_style(i) ⇒ Object
Also known as:
add_to_CSS_style, append_css_style, append_to_the_CSS_style
#
append_this_to_the_css_style
This method can be used to append onto the CSS style of the webpage.
#
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1007
def append_this_to_the_css_style(i)
@internal_hash[:css_style] = @internal_hash[:css_style].dup if @internal_hash[:css_style].frozen?
i = " #{i.strip}" unless i.empty?
unless i.empty?
if (!i.end_with?('; ')) and (!i.end_with?(';'))
@internal_hash[:css_style] << ';' end
end
@internal_hash[:css_style] << i
@internal_hash[:css_style].rstrip!
end
|
#attach(i) ⇒ Object
Also known as:
onto_result, add, append_to_content, append_onto_content
#
attach (attach tag, add tag)
This method will simply append to @internal_hash.
#
773
774
775
776
777
778
779
780
781
782
783
784
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 773
def attach(i)
i = i.join(' ').strip if i.is_a? Array
if i.is_a? Symbol
i = send(i)
end
i = i.to_s
@internal_hash[:content] = @internal_hash[:content].dup if @internal_hash[:content].frozen?
@internal_hash[:content] << i
end
|
#batch_append_css_class_then_the_ID_and_then_the_css_style ⇒ Object
#
batch_append_css_class_then_the_ID_and_then_the_css_style
This method is a convenience method. It will tie together three separate method calls into one method invocation.
#
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 585
def batch_append_css_class_then_the_ID_and_then_the_css_style
if css_class? and !css_class?.empty?
append_onto_the_result " #{return_css_class}"
end
if id? and !id?.empty?
append_onto_the_result ' id="'+id?.to_s+'"'
end
unless css_style?.empty?
append_onto_the_result " #{return_css_style(css_style?)}"
end
end
|
#
bblack1
This is a shortcut towards “border: 1px solid black”, which is captured in the CSS rule called .bblack1.
#
717
718
719
720
721
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 717
def bblack1
unless @internal_hash[:css_class].include? 'bblack1'
@internal_hash[:css_class] << ' bblack1'
end
end
|
726
727
728
729
730
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 726
def bblack2
unless @internal_hash[:css_class].include? 'bblack2'
@internal_hash[:css_class] << ' bblack2'
end
end
|
735
736
737
738
739
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 735
def bblack3
unless @internal_hash[:css_class].include? 'bblack3'
@internal_hash[:css_class] << ' bblack3'
end
end
|
744
745
746
747
748
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 744
def bblack4
unless @internal_hash[:css_class].include? 'bblack4'
@internal_hash[:css_class] << ' bblack4'
end
end
|
753
754
755
756
757
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 753
def bblack5
unless @internal_hash[:css_class].include? 'bblack5'
@internal_hash[:css_class] << ' bblack5'
end
end
|
762
763
764
765
766
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 762
def bblack6
unless @internal_hash[:css_class].include? 'bblack6'
@internal_hash[:css_class] << ' bblack6'
end
end
|
1184
1185
1186
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1184
def center
add_this_CSS_class 'TAC'
end
|
#consider_adding_the_pre_content(i = pre_content?
) ⇒ Object
#
consider_adding_the_pre_content
#
294
295
296
297
298
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 294
def consider_adding_the_pre_content(
i = pre_content?
)
@internal_hash[:result] << i
end
|
#consider_adding_the_script_entry_from_the_internal_hash(script = script?
) ⇒ Object
#
consider_adding_the_script_entry_from_the_internal_hash
This will append the javascript-entry onto the main result, if it has been set (aka is non-empty).
#
1131
1132
1133
1134
1135
1136
1137
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1131
def consider_adding_the_script_entry_from_the_internal_hash(
script = script?
)
if script and !script.empty?
append_onto_the_result script
end
end
|
#content? ⇒ Boolean
339
340
341
342
343
344
345
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 339
def content?
if @internal_hash[:content].is_a? Array @internal_hash[:content]
else
@internal_hash[:content].to_s end
end
|
#content_as_string ⇒ Object
#
content_as_string
This method makes sure that a String will be returned.
#
558
559
560
561
562
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 558
def content_as_string
_ = content?
_ = _.first if _.is_a? Array
return _.to_s end
|
#css_class? ⇒ Boolean
885
886
887
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 885
def css_class?
@internal_hash[:css_class]
end
|
#css_manager(i = '', optional_argument1 = nil) ⇒ Object
#
css_manager
Invocation example:
_.css_manager.css_rule_for_hover_pulse_grow(5)
_.css_manager('css_rule_for_hover_pulse_grow(8)')
#
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1148
def css_manager(
i = '',
optional_argument1 = nil
)
css_manager = Cyberweb::CssManager.new
arguments = nil
if i.include?('(')
splitted = i.delete(')').
split('(')
i = splitted.first
arguments = splitted[1 .. -1]
end
if optional_argument1
arguments << optional_argument1
end
css_manager.send(i, *arguments)
return css_manager
end
|
#css_style? ⇒ Boolean
332
333
334
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 332
def css_style?
@internal_hash[:css_style]
end
|
#
report (report tag)
#
display
1197
1198
1199
1200
1201
1202
1203
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1197
def report(&block)
_ = to_str
if _.is_a? Array
_ = _.join(' ').strip
end
print _
end
|
#do_not_load_lazily ⇒ Object
317
318
319
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 317
def do_not_load_lazily
@internal_hash[:lazy_loading] = false
end
|
#
report (report tag)
#
ee
1199
1200
1201
1202
1203
1204
1205
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1199
def report(&block)
_ = to_str
if _.is_a? Array
_ = _.join(' ').strip
end
print _
end
|
#enable_lazy_loading ⇒ Object
Also known as:
lazy_loading, lazy
324
325
326
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 324
def enable_lazy_loading
@internal_hash[:lazy_loading] = true
end
|
#evaluate_this_block(&block) ⇒ Object
409
410
411
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 409
def evaluate_this_block(&block)
instance_eval(&block)
end
|
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 383
def font=(i)
if i.is_a? Symbol
i = i.to_s
if i.include? '_'
i = i.tr('_',' ') if i =~ / \d{1,2}$/ font_size_to_use = i.scan(/ \d{1,2}$/).flatten.last.strip
if i.include? ' '
i = i.split(' ')[0 .. -2].join(' ').strip
i = i.dup if i.frozen?
i << '; font-size: '+font_size_to_use.to_s+' px;'
end
end
end
end
i = i.dup if i.frozen?
i << ';' unless i.end_with?(';')
append_this_to_the_css_style " font-family: #{i}"
end
|
#id? ⇒ Boolean
#
id?
This method will return the value for the ID of the given HTML tag at hand.
#
1042
1043
1044
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1042
def id?
@internal_hash[:id]
end
|
#is_an_objectified_html_tag? ⇒ Boolean
#
is_an_objectified_html_tag?
Getter-method to confirm that this is an objectified HTML tag.
#
916
917
918
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 916
def is_an_objectified_html_tag?
true
end
|
#is_draggable? ⇒ Boolean
1063
1064
1065
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1063
def is_draggable?
@internal_hash[:is_draggable]
end
|
#lazy_loading? ⇒ Boolean
310
311
312
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 310
def lazy_loading?
@internal_hash[:lazy_loading]
end
|
#make_bold ⇒ Object
665
666
667
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 665
def make_bold
append_onto_the_CSS_class('BOLD')
end
|
#modify_the_css_style_based_on_the_alignment(i = ) ⇒ Object
#
modify_the_css_style_based_on_the_alignment
This method is specifically used for the HTML <span> tag. It could be put into the file span.rb
#
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 979
def modify_the_css_style_based_on_the_alignment(
i = @internal_hash[:alignment]
)
case i
when :center
append_this_to_the_css_style(' text-align: center;')
when :right
append_this_to_the_css_style(' text-align: right;')
when :left
append_this_to_the_css_style(' text-align: left;')
end
end
|
#name=(i) ⇒ Object
Also known as:
set_name
#
name=
Note that this setter-method will not work for every tag.
Usage example:
object.name = 'ask_a_question'
h1.name = 'ask_a_question'
#
1032
1033
1034
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1032
def name=(i)
@internal_hash[:name] = i
end
|
#name? ⇒ Boolean
#
name?
This is primarily for the HTML <map> tag, which requires a name attribute. I decided to put it into the base.rb file, though, in the event other HTML tags may need it.
#
896
897
898
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 896
def name?
@internal_hash[:name].to_s
end
|
#on_click_select ⇒ Object
Also known as:
on_clicked_select
#
on_click_select
This is a “shortcut” for selecting everything on an on-click event action.
#
524
525
526
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 524
def on_click_select
on_clicked { :select_everything }
end
|
#on_clicked(&block) ⇒ Object
#
on_clicked
This should ultimately yield a String such as:
<button onclick = "fun()">Click me</button>
#
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 441
def on_clicked(&block)
if block_given?
yielded = yield
if yielded.is_a? Symbol
case yielded
when :select_everything
set_on_clicked('selectText(this.id)')
_ = path_to_internal_javascript_file('select_everything_on_mouse_click_event.js')
if File.exist? _
add_this_to_javascript(
return_javascript(File.read(_))
)
else
puts "No file exists at #{_}"
end
else
@internal_hash[:on_clicked] = yielded
end
elsif yielded.is_a? Hash
if yielded.has_key? :javascript_pop_up
text_to_use = yielded.delete(:javascript_pop_up).to_s
@internal_hash[:onclick] = 'pop_up_this_text()'
@internal_hash[:script] << return_javascript(
'function pop_up_this_text() {
window.alert("'+text_to_use+'!");
}'
)
elsif yielded.has_key? :javascript_call
set_use_this_on_click_function('some_foobar()')
end
else
_ = yielded
if _.is_a? String
_ = _.dup
if _.include?('(')
if _.include? '"'
_.gsub!(/"/,'\"')
end
splitted = _.delete(')').split('(') set_use_this_on_click_function(
splitted[0], splitted[1..-1]
)
else
set_use_this_on_click_function(_)
end
else
set_use_this_on_click_function(_)
end
end
end
end
|
#on_hover_colour(use_this_colour = :steelblue) ⇒ Object
Also known as:
on_hover
#
on_hover_colour
Note that this depends on corresponding CSS classes - if you do not define them then this is basically useless.
The cyberweb project comes with these CSS classes bundled; or, if they are missing then they can be added still.
Usage example:
button.on_hover_colour(:steelblue)
#
427
428
429
430
431
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 427
def on_hover_colour(
use_this_colour = :steelblue
)
append_css_class("on_hover_colour_#{use_this_colour}")
end
|
#on_hover_pulse_increase(n_times = 8) ⇒ Object
#
on_hover_pulse_increase
#
903
904
905
906
907
908
909
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 903
def on_hover_pulse_increase(
n_times = 8
)
append_css_manager(
'css_rule_for_hover_pulse_grow('+n_times.to_s+')'
)
end
|
#on_mouse_hover(&block) ⇒ Object
Also known as:
on_mouse_over
#
on_mouse_hover
This method will be triggered on a mouse-hover event.
#
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 615
def on_mouse_hover(&block)
if block_given?
yielded = yield
if yielded.is_a? Hash
if yielded.has_key? :bg
use_this_as_the_background_colour = 'white'
if yielded.has_key? :fg
use_this_as_the_background_colour = yielded[:fg].to_s
end
if css_class? and css_class?.include?('BG_')
regex_to_use = /BG_(\w+)/ css_class? =~ regex_to_use use_this_as_the_background_colour = $1.to_s.dup
end
@internal_hash[:in_tag_script] <<
'onmouseover="this.style.background=\''+yielded[:bg].to_s+'\';" '\
'onmouseout="this.style.background=\''+use_this_as_the_background_colour+'\';"'
end
end
end
end
|
792
793
794
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 792
def pad
append_this_onto_the_CSS_class('pad0_5em')
end
|
862
863
864
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 862
def pad10px
append_this_onto_the_CSS_class('pad10px')
end
|
799
800
801
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 799
def pad1px
append_this_onto_the_CSS_class('pad1px')
end
|
806
807
808
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 806
def pad2px
append_this_onto_the_CSS_class('pad2px')
end
|
813
814
815
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 813
def pad3px
append_this_onto_the_CSS_class('pad3px')
end
|
820
821
822
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 820
def pad4px
append_this_onto_the_CSS_class('pad4px')
end
|
827
828
829
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 827
def pad5px
append_this_onto_the_CSS_class('pad5px')
end
|
834
835
836
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 834
def pad6px
append_this_onto_the_CSS_class('pad6px')
end
|
841
842
843
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 841
def pad7px
append_this_onto_the_CSS_class('pad7px')
end
|
848
849
850
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 848
def pad8px
append_this_onto_the_CSS_class('pad8px')
end
|
855
856
857
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 855
def pad9px
append_this_onto_the_CSS_class('pad9px')
end
|
#path_to_internal_javascript_file(i) ⇒ Object
#
path_to_internal_javascript_file
This method will return the path to a .js file that is distributed via the cyberweb gem.
This method can be used like this:
path_to_internal_javascript_file 'disable_right_click.js'
#
680
681
682
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 680
def path_to_internal_javascript_file(i)
return "#{project_base_dir?}javascript_code/#{i}"
end
|
#pre_content? ⇒ Boolean
303
304
305
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 303
def pre_content?
@internal_hash[:pre_content]
end
|
#raw_result? ⇒ Boolean
376
377
378
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 376
def raw_result?
@internal_hash[:result]
end
|
#report(&block) ⇒ Object
1191
1192
1193
1194
1195
1196
1197
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1191
def report(&block)
_ = to_str
if _.is_a? Array
_ = _.join(' ').strip
end
print _
end
|
#
report (report tag)
#
report?
1198
1199
1200
1201
1202
1203
1204
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1198
def report(&block)
_ = to_str
if _.is_a? Array
_ = _.join(' ').strip
end
print _
end
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 111
def reset
create_the_internal_hash
@internal_hash[:result] = ''.dup
@internal_hash[:pre_content] = ''.dup
@internal_hash[:is_draggable] = false
@internal_hash[:css_class] = ''.dup
@internal_hash[:id] = nil
@internal_hash[:css_style] = ''.dup
@internal_hash[:script] = ''.dup
reset_the_content
@internal_hash[:title] = nil
@internal_hash[:in_tag_script] = ''.dup
@internal_hash[:on_clicked] = nil
@internal_hash[:arguments_to_the_on_clicked_function] = []
@internal_hash[:hint] = nil
do_not_load_lazily
reset_the_result
end
|
#reset_the_content ⇒ Object
1097
1098
1099
1100
1101
1102
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1097
def reset_the_content
@internal_hash[:content] = ''.dup
end
|
#reset_the_result ⇒ Object
250
251
252
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 250
def reset_the_result
@internal_hash[:result] = ''.dup
end
|
#return_appendable_content ⇒ Object
Also known as:
appendable_content
#
return_appendable_content
This will return the @internal_hash, as a String.
#
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1081
def return_appendable_content
result = ''.dup
content = @internal_hash[:content]
if content.is_a? Array content.each {|entry|
result << "#{entry}\n"
}
else
result << content
end
return result
end
|
#return_css_class(i = css_class?
) ⇒ Object
1119
1120
1121
1122
1123
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1119
def return_css_class(
i = css_class?
)
return 'class="'+i.to_s.strip+'"'
end
|
#return_css_style(i = css_style?
) ⇒ Object
#
return_css_style
This method will add the style=“” entry.
#
689
690
691
692
693
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 689
def return_css_style(
i = css_style?
)
return 'style="'+i.to_s.strip+'"'
end
|
#return_javascript(i) ⇒ Object
287
288
289
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 287
def return_javascript(i)
return "\n<script>\n#{i}\n</script>\n"
end
|
#script? ⇒ Boolean
1056
1057
1058
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1056
def script?
@internal_hash[:script]
end
|
#set_content(i) ⇒ Object
Also known as:
content=, inject, value=, <<, set_text, text=, text
#
set_content
Store the content of the HTML tag at hand via the following method.
Note that Arrays that are passed into this method will NOT become Strings. The reason why that is the case is that some HTML elements, such as the html-dropbox, need an Array as input, not a String. Thus we would lose information if we were to ignore Arrays as input.
This method currently has three aliases, but it is not certain whether these will be retained (comment here made in October 2021) - the future will show how useful these are.
Note that the alias .text= was added in November 2021. I am not entirely certain whether it will be retained, but for now it is available.
#
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 214
def set_content(i)
if i.is_a? Hash
if i.has_key? :id
set_id(i.delete(:id))
end
if i.has_key? :class
set_CSS_class(i.delete(:class))
end
end
if i.is_a?(Hash) and i.empty?
i = ''
end
i = i.to_s.dup unless i.is_a? Array
@internal_hash[:content] = i
end
|
#set_css_class(i) ⇒ Object
Also known as:
class=, css_class=, css_class, set_CSS_class
#
set_css_class
Usage example:
textarea.class = 'rounded_border_6px bblack1 FS2em pad8px'
#
703
704
705
706
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 703
def set_css_class(i)
i = i.to_s.dup
@internal_hash[:css_class] = i
end
|
#set_css_style(i) ⇒ Object
Also known as:
style=, css_style=, style, css_style, set_CSS_style
276
277
278
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 276
def set_css_style(i)
@internal_hash[:css_style] = i
end
|
#set_id(i = nil) ⇒ Object
Also known as:
id, id=
#
set_id
This method allows the user to set a specific id for the HTML object at hand, such as a <div> tag.
Note that there is an alias to this setter-method, called id(). This alias exists mostly as a convenience shortcut and it is not absolutely 100% certain that this method name will be retained as-is - after all it could be synonymous to .id?, and some users may expect it to be like this (e. g. .id()). Thus, if you want to be absolutely certain, it is recommended to use either set_id() or id=(), since the behaviour may change one day. This notice here was written in January of 2022.
#
268
269
270
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 268
def set_id(i = nil)
@internal_hash[:id] = i
end
|
#set_is_draggable ⇒ Object
Also known as:
is_draggable
#
is_draggable
Setter-method.
#
1072
1073
1074
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1072
def set_is_draggable
@internal_hash[:is_draggable] = true
end
|
#set_title(i) ⇒ Object
538
539
540
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 538
def set_title(i)
@internal_hash[:title] = i
end
|
#set_width(i = '500px') ⇒ Object
Also known as:
width=
952
953
954
955
956
957
958
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 952
def set_width(i = '500px')
i = i.dup if i.frozen?
unless i.end_with? 'px'
i << 'px'
end
add_to_CSS_style("width: #{i}")
end
|
#title? ⇒ Boolean
#
title?
This method must be guaranteed to return a String. Keep in mind that the title may be empty, though, so it is best to check in the downstream code base whether a title-tag was set or not.
#
549
550
551
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 549
def title?
@internal_hash[:title].to_s
end
|
#to_str ⇒ Object
Also known as:
to_s, string?, result?
1204
1205
1206
1207
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1204
def to_str
rebuild_the_result
return raw_result?
end
|
#try_to_register_this_tag(i) ⇒ Object
#
try_to_register_this_tag
#
#use_this_on_click_function=(i, optional_arguments = '') ⇒ Object
Also known as:
set_use_this_on_click_function, set_on_clicked
#
use_this_on_click_function=
#
923
924
925
926
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 923
def use_this_on_click_function=(i, optional_arguments = '')
@internal_hash[:arguments_to_the_on_clicked_function] = optional_arguments
@internal_hash[:on_clicked] = i
end
|
#very_light_yellowish_background ⇒ Object
#
very_light_yellowish_background
#
1049
1050
1051
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 1049
def very_light_yellowish_background
@internal_hash[:css_class] << ' BG_very_light_yellowish'
end
|
#width_height(width = 80, height = 40) ⇒ Object
963
964
965
966
967
968
969
970
971
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 963
def width_height(
width = 80,
height = 40
)
set_width(width)
append_this_to_the_css_style(
'height: '+height.to_s+'px;'
)
end
|
#yellow_background ⇒ Object
945
946
947
|
# File 'lib/cyberweb/objectified/html_tags/base.rb', line 945
def yellow_background
add_to_CSS_classes('BG_Yellow')
end
|