widget_list 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +8 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/widget_list.iml +10 -0
- data/.idea/workspace.xml +579 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +2 -7
- data/Rakefile +0 -0
- data/lib/extensions/action_controller_base.rb +33 -0
- data/lib/widget_list.rb +0 -0
- data/lib/widget_list/engine.rb +8 -0
- data/lib/widget_list/hash.rb +78 -0
- data/lib/widget_list/md5.rb +0 -0
- data/lib/widget_list/railtie.rb +32 -0
- data/lib/widget_list/sequel.rb +151 -0
- data/lib/widget_list/string.rb +42 -0
- data/lib/widget_list/tpl.rb +186 -0
- data/lib/widget_list/utils.rb +85 -0
- data/lib/widget_list/version.rb +1 -1
- data/lib/widget_list/widgets.rb +732 -0
- data/vendor/assets/images/buttons/regular/green/leftside-regular-btn.png +0 -0
- data/vendor/assets/images/buttons/regular/green/rightside-regular-btn.png +0 -0
- data/vendor/assets/images/buttons/small/green/leftside-small-btn.png +0 -0
- data/vendor/assets/images/buttons/small/green/rightside-small-btn.png +0 -0
- data/vendor/assets/images/catbar-bg.png +0 -0
- data/vendor/assets/images/gobblecons/README.rtf +128 -0
- data/vendor/assets/images/gobblecons/black/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/black/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/black/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/add-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/add-24(2).png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-square-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-triangle-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-small-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/lime/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/lime/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-square-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-triangle-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/add-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-solid-16-alt.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/orange/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/orange/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/purple/add-16.png +0 -0
- data/vendor/assets/images/gobblecons/purple/add-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/teal/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/trash-24.png +0 -0
- data/vendor/assets/images/grad.png +0 -0
- data/vendor/assets/images/input_text_left.png +0 -0
- data/vendor/assets/images/input_text_right.png +0 -0
- data/vendor/assets/images/list-loader.gif +0 -0
- data/vendor/assets/images/long-text.jpg +0 -0
- data/vendor/assets/images/page-back.gif +0 -0
- data/vendor/assets/images/page-next.gif +0 -0
- data/vendor/assets/images/select-multiple-left.png +0 -0
- data/vendor/assets/images/select-multiple-right.png +0 -0
- data/vendor/assets/images/select-multiple.gif +0 -0
- data/vendor/assets/images/text-field-long.gif +0 -0
- data/vendor/assets/images/text-field-medium-notes.gif +0 -0
- data/vendor/assets/images/text-field-medium-tiny.gif +0 -0
- data/vendor/assets/images/text-field-shipping.gif +0 -0
- data/vendor/assets/images/text-field-small.gif +0 -0
- data/vendor/assets/images/text-field-tiny.gif +0 -0
- data/vendor/assets/images/text-field.gif +0 -0
- data/vendor/assets/images/th_header.gif +0 -0
- data/vendor/assets/javascripts/widget_list.js +696 -0
- data/vendor/assets/stylesheets/widget_list.css +775 -0
- data/vendor/assets/stylesheets/widgets.css +117 -0
- metadata +241 -1
@@ -0,0 +1,85 @@
|
|
1
|
+
module WidgetList
|
2
|
+
|
3
|
+
class Utils
|
4
|
+
|
5
|
+
def self.numeric?(object)
|
6
|
+
true if Float(object) rescue false
|
7
|
+
end
|
8
|
+
|
9
|
+
#JsonEncode
|
10
|
+
def self.json_encode(arr,return_string = false)
|
11
|
+
if return_string
|
12
|
+
p JSON.generate(arr)
|
13
|
+
else
|
14
|
+
JSON.generate(arr)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#BuildQueryString
|
19
|
+
def self.build_query_string(args)
|
20
|
+
q = []
|
21
|
+
args.each { |k,v|
|
22
|
+
q << k.to_s + '=' + URI.encode(URI.decode(v.to_s))
|
23
|
+
}
|
24
|
+
q.join('&')
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
#BuildUrl
|
29
|
+
def self.build_url(page='',args = {}, append_get=false)
|
30
|
+
qs = build_query_string(args)
|
31
|
+
getvars = ''
|
32
|
+
if append_get && $_REQUEST
|
33
|
+
getvars = build_query_string($_REQUEST)
|
34
|
+
end
|
35
|
+
|
36
|
+
unless page =~ /\?/
|
37
|
+
"#{page}?" + qs + '&' + getvars
|
38
|
+
else
|
39
|
+
"#{page}" + qs + '&' + getvars
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
#Fill
|
44
|
+
def self.fill(tags = {}, template = '')
|
45
|
+
tpl = template.dup
|
46
|
+
tags.each { |k,v|
|
47
|
+
tpl = tpl.gsub(k.to_s,v.to_s)
|
48
|
+
}
|
49
|
+
tpl
|
50
|
+
end
|
51
|
+
|
52
|
+
#test_all
|
53
|
+
def self.test_all
|
54
|
+
output_final = ''
|
55
|
+
output_final += "JsonEncode\n<br/>\n<br/>"
|
56
|
+
|
57
|
+
a = { }
|
58
|
+
a['asdfasdf'] = 'asfd'
|
59
|
+
a[:test] = 1234
|
60
|
+
a[2153125] = nil
|
61
|
+
output_final += Utils.json_encode(a)
|
62
|
+
|
63
|
+
|
64
|
+
output_final += "\n<br/>\n<br/>BuildQueryString\n<br/>\n<br/>"
|
65
|
+
|
66
|
+
a = { }
|
67
|
+
a['asdfasdf'] = 'asdf asdfj ajskdfhasdf'
|
68
|
+
a['dave'] = 'a)(J#(*J@T2p2kfasdfa fas %20fj ajskdfhasdf'
|
69
|
+
output_final += Utils.build_query_string(a)
|
70
|
+
|
71
|
+
|
72
|
+
output_final += "\n<br/>\n<br/>BuildUrl\n<br/>\n<br/>"
|
73
|
+
|
74
|
+
|
75
|
+
output_final += Utils.build_url('page.php?',a)
|
76
|
+
|
77
|
+
|
78
|
+
output_final += "\n<br/>\n<br/>Fill\n<br/>\n<br/>"
|
79
|
+
|
80
|
+
output_final += Utils.fill({'<!--CONTENT-->'=>'dave','<!--TITLE-->'=>'the title'},'<!--TITLE--> --------- <!--CONTENT-->')
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
data/lib/widget_list/version.rb
CHANGED
@@ -0,0 +1,732 @@
|
|
1
|
+
module WidgetList
|
2
|
+
class Widgets
|
3
|
+
|
4
|
+
#todo - WidgetRadio, WidgetData?
|
5
|
+
|
6
|
+
# WidgetCheck
|
7
|
+
def self.widget_check(list={})
|
8
|
+
|
9
|
+
items = { 'name' => '',
|
10
|
+
'id' => '',
|
11
|
+
'value' => '',
|
12
|
+
'width' => '',
|
13
|
+
'disabled' => false,
|
14
|
+
'hidden' => false,
|
15
|
+
'required' => false,
|
16
|
+
'checked' => false,
|
17
|
+
'max_length' => '',
|
18
|
+
'title' => '',
|
19
|
+
'class' => '',
|
20
|
+
'style' => '',
|
21
|
+
'onclick' => '',
|
22
|
+
'input_style' => '',
|
23
|
+
'input_class' => '',
|
24
|
+
'template' => '',
|
25
|
+
}
|
26
|
+
|
27
|
+
items['template_required'] = $G_TEMPLATE['widget']['required']
|
28
|
+
|
29
|
+
items['template'] = $G_TEMPLATE['widget']['checkbox']['default']
|
30
|
+
|
31
|
+
items = populate_items(list,items)
|
32
|
+
|
33
|
+
if !items['required']
|
34
|
+
items['template_required'] = ''
|
35
|
+
end
|
36
|
+
|
37
|
+
if items['checked'] == true
|
38
|
+
items['checked'] = 'checked'
|
39
|
+
end
|
40
|
+
|
41
|
+
if !items['class'].empty?
|
42
|
+
items['input_class'] = items['class']
|
43
|
+
end
|
44
|
+
|
45
|
+
if !items['disabled']
|
46
|
+
items['input_class'] += ' disabled'
|
47
|
+
end
|
48
|
+
|
49
|
+
if items['hidden'] == true
|
50
|
+
items['style'] += ' display:none'
|
51
|
+
end
|
52
|
+
|
53
|
+
pieces = {
|
54
|
+
'<!--INPUT_CLASS-->' => items['input_class'],
|
55
|
+
'<!--INPUT_STYLE-->' => items['input_style'],
|
56
|
+
'<!--ID-->' => items['id'],
|
57
|
+
'<!--NAME-->' => items['name'],
|
58
|
+
'<!--TITLE-->' => items['title'],
|
59
|
+
'<!--ONCLICK-->' => items['onclick'],
|
60
|
+
'<!--VALUE-->' => items['value'],
|
61
|
+
'<!--REQUIRED-->' => items['template_required'],
|
62
|
+
'<!--CHECKED-->' => items['checked'],
|
63
|
+
'<!--VALUE-->' => items['value']
|
64
|
+
}
|
65
|
+
|
66
|
+
return WidgetList::Utils::fill(pieces, items['template'])
|
67
|
+
end
|
68
|
+
|
69
|
+
# WidgetSelect - todo - never tested one line of code in here!!!
|
70
|
+
def self.widget_select(sql = '', list={})
|
71
|
+
valid = true
|
72
|
+
selectOutput = []
|
73
|
+
|
74
|
+
#Parameter evaluation identification
|
75
|
+
#
|
76
|
+
if list.empty? && sql.class.name == 'Hash'
|
77
|
+
list = sql
|
78
|
+
end
|
79
|
+
|
80
|
+
if ! sql.empty? && ! list.key?('sql') && ! list.key?('view')
|
81
|
+
list['sql'] = sql
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Default configurations
|
86
|
+
#
|
87
|
+
items = {}
|
88
|
+
|
89
|
+
items['name'] = ''
|
90
|
+
items['id'] = ''
|
91
|
+
items['multiple'] = false
|
92
|
+
items['insertUnknown'] = false
|
93
|
+
items['required'] = ''
|
94
|
+
items['strLenBrk'] = 50
|
95
|
+
items['optGroupIndicator'] = ''
|
96
|
+
items['label'] = ''
|
97
|
+
items['selectTxt'] = 'Select One'
|
98
|
+
items['showId'] = false
|
99
|
+
items['showIdLeft'] = false
|
100
|
+
items['passive'] = false
|
101
|
+
items['freeflow'] = false
|
102
|
+
items['no_style'] = false
|
103
|
+
|
104
|
+
#
|
105
|
+
# Select box attributes
|
106
|
+
#
|
107
|
+
items['attribs'] = {}
|
108
|
+
items['size'] = 1
|
109
|
+
items['disabled'] = false
|
110
|
+
items['noDataMsg'] = 'No Data'
|
111
|
+
items['selectOne'] = 0
|
112
|
+
items['selected'] = {}
|
113
|
+
|
114
|
+
#
|
115
|
+
# SQL
|
116
|
+
#
|
117
|
+
items['bindVars'] = {}
|
118
|
+
items['view'] = ''
|
119
|
+
items['sql'] = ''
|
120
|
+
items['orderBy'] = ''
|
121
|
+
items['filter'] = ''
|
122
|
+
|
123
|
+
#
|
124
|
+
# Actions
|
125
|
+
#
|
126
|
+
items['onchange'] = ''
|
127
|
+
items['onclick'] = ''
|
128
|
+
|
129
|
+
#
|
130
|
+
# Style
|
131
|
+
#
|
132
|
+
items['style'] = '' #meant for internal use as nothing is appended only replaced.
|
133
|
+
items['inner_class'] = 'select-inner' #Left long piece of image
|
134
|
+
items['outer_class'] = 'select-outer' #Right corner of image
|
135
|
+
items['outer_style'] = '' #Basically the width of the select box ends up here
|
136
|
+
items['extra_class'] = '' #Not used currently
|
137
|
+
items['width'] = 184 #width of the select-outer element
|
138
|
+
|
139
|
+
#
|
140
|
+
# @deprecated
|
141
|
+
#
|
142
|
+
items['class'] = ''
|
143
|
+
|
144
|
+
|
145
|
+
#
|
146
|
+
# Setup templates
|
147
|
+
#
|
148
|
+
if items['freeflow']
|
149
|
+
#
|
150
|
+
# Freeflow
|
151
|
+
#
|
152
|
+
items['template']['wrapper'] = $G_TEMPLATE['widget']['selectfree']['wrapper']
|
153
|
+
items['template']['option'] = $G_TEMPLATE['widget']['selectfree']['option']
|
154
|
+
items['template']['initial'] = ''
|
155
|
+
items['template']['passive'] = ''
|
156
|
+
else
|
157
|
+
#
|
158
|
+
# Standard
|
159
|
+
#
|
160
|
+
items['template']['wrapper'] = $G_TEMPLATE['widget']['selectbox']['wrapper']
|
161
|
+
items['template']['option'] = $G_TEMPLATE['widget']['selectbox']['option']
|
162
|
+
items['template']['initial'] = $G_TEMPLATE['widget']['selectbox']['initial']
|
163
|
+
items['template']['passive'] = $G_TEMPLATE['widget']['selectbox']['passive']
|
164
|
+
end
|
165
|
+
|
166
|
+
# if numeric or string passed, convert to array
|
167
|
+
if list.key?('selected') && list['selected'].class.name != 'Array'
|
168
|
+
list['selected'] = [ list['selected'] ]
|
169
|
+
end
|
170
|
+
|
171
|
+
#
|
172
|
+
# Merge settings
|
173
|
+
#
|
174
|
+
items = populate_items(list,items)
|
175
|
+
|
176
|
+
if items['no_style']
|
177
|
+
items['template']['wrapper'] = $G_TEMPLATE['widget']['selectbox_nostyle']['wrapper']
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
#
|
182
|
+
# If multiple then override above settings and classes
|
183
|
+
#
|
184
|
+
if items['multiple']
|
185
|
+
items['outer_style'] = ';width:280px;'
|
186
|
+
items['width'] = 280
|
187
|
+
|
188
|
+
items['inner_class'] = 'select-inner-multiple'
|
189
|
+
items['outer_class'] = 'select-outer-multiple'
|
190
|
+
end
|
191
|
+
|
192
|
+
if items['showId']
|
193
|
+
items['template']['option'] = $G_TEMPLATE['widget']['selectbox']['option_showid']
|
194
|
+
end
|
195
|
+
|
196
|
+
if items['showIdLeft']
|
197
|
+
items['template']['option'] = $G_TEMPLATE['widget']['selectbox']['option_showid_left']
|
198
|
+
end
|
199
|
+
|
200
|
+
if items['disabled']
|
201
|
+
items['disabled'] = 'disabled="disabled"'
|
202
|
+
items['class'] += ' disabled'
|
203
|
+
end
|
204
|
+
|
205
|
+
if items['multiple']
|
206
|
+
items['multiple'] = 'multiple="multiple"'
|
207
|
+
end
|
208
|
+
|
209
|
+
if items['required']
|
210
|
+
items['required'] = $G_TEMPLATE['widget']['required']
|
211
|
+
end
|
212
|
+
|
213
|
+
if ! items['sql'].empty?
|
214
|
+
sql = items['sql']
|
215
|
+
elsif !items['view'].empty?
|
216
|
+
sql = "SELECT id, value FROM " + items['view']
|
217
|
+
else
|
218
|
+
valid = false
|
219
|
+
end
|
220
|
+
|
221
|
+
if ! items['filter'].empty?
|
222
|
+
sql += ' WHERE ' + items['filter'].join(' AND ')
|
223
|
+
end
|
224
|
+
|
225
|
+
if ! items['orderBy'].empty?
|
226
|
+
sql += ' ORDER BY ' + items['orderBy']
|
227
|
+
end
|
228
|
+
|
229
|
+
rows = WidgetList::List.get_database._select(sql, [], items['bindVars'])
|
230
|
+
selectRows = WidgetList::List.get_database.final_results
|
231
|
+
|
232
|
+
|
233
|
+
if rows > 0 && valid
|
234
|
+
if ! items['passive']
|
235
|
+
addedGroup = false
|
236
|
+
groupByRow = false
|
237
|
+
groupByValue = -1
|
238
|
+
if selectRows.key?('GROUPING_VAL')
|
239
|
+
groupByRow = true
|
240
|
+
end
|
241
|
+
|
242
|
+
max = rows-1
|
243
|
+
|
244
|
+
selected = ''
|
245
|
+
|
246
|
+
if (items['selectOne'] > 0 || (items['selectOne'].class.name == 'Array' && ! items['selectOne'].empty?) && ! items['freeflow'])
|
247
|
+
theVal = ''
|
248
|
+
theClk = ''
|
249
|
+
theSel = ''
|
250
|
+
theTxt = items['selectTxt']
|
251
|
+
|
252
|
+
if items['selectOne'].class.name == 'Array'
|
253
|
+
if(items['selectOne'].key?('text'))
|
254
|
+
theTxt = items['selectOne']['text']
|
255
|
+
end
|
256
|
+
|
257
|
+
if(items['selectOne'].key?('value'))
|
258
|
+
theVal = items['selectOne']['value']
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
pieces = { '<!--VALUE-->' => theVal,
|
263
|
+
'<!--ONCLICK-->' => theClk,
|
264
|
+
'<!--SELECTED-->' => theSel,
|
265
|
+
'<!--CONTENT-->' => theTxt
|
266
|
+
}
|
267
|
+
|
268
|
+
|
269
|
+
selectOutput << WidgetList::Utils::fill(pieces, items['template']['initial'])
|
270
|
+
end
|
271
|
+
|
272
|
+
hasASelectedMatch = false
|
273
|
+
startedGrouping = false
|
274
|
+
i = 0
|
275
|
+
for i in j..max
|
276
|
+
if items['selected'].class.name == 'Array' && items['selected'].count > 0
|
277
|
+
if items['selected'].include?(selectRows['ID'][i]) || items['selected'].include?(selectRows['VALUE'][i])
|
278
|
+
hasASelectedMatch = true
|
279
|
+
selected = ' selected'
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
if selectRows['VALUE'][i].length > items['strLenBrk']
|
284
|
+
first = CGI.escapeHTML(selectRows['VALUE'][i].to_s[0,10])
|
285
|
+
last = CGI.escapeHTML(selectRows['VALUE'][i].to_s[-40])
|
286
|
+
content = first + '...' + last
|
287
|
+
else
|
288
|
+
content = CGI.escapeHTML(selectRows['VALUE'][i])
|
289
|
+
end
|
290
|
+
|
291
|
+
pieces = {
|
292
|
+
'<!--VALUE-->' => selectRows['ID'][i],
|
293
|
+
'<!--ONCLICK-->' => items['onclick'],
|
294
|
+
'<!--SELECTED-->' => selected,
|
295
|
+
'<!--CONTENT-->' => content,
|
296
|
+
'<!--COUNTER-->' => i,
|
297
|
+
'<!--NAME-->' => items['name'],
|
298
|
+
}
|
299
|
+
|
300
|
+
|
301
|
+
if groupByRow
|
302
|
+
if selectRows['GROUPING_VAL'][i] != groupByValue
|
303
|
+
if (addedGroup)
|
304
|
+
selectOutput << '</optgroup>'
|
305
|
+
end
|
306
|
+
|
307
|
+
addedGroup = true
|
308
|
+
# Start new optgroup
|
309
|
+
groupByValue = selectRows['GROUPING_VAL'][i]
|
310
|
+
|
311
|
+
selectOutput << '<optgroup label="' + groupByValue + '">'
|
312
|
+
selectOutput << WidgetList::Utils::fill(pieces, items['template']['option'])
|
313
|
+
else
|
314
|
+
selectOutput << WidgetList::Utils::fill(pieces, items['template']['option'])
|
315
|
+
end
|
316
|
+
else
|
317
|
+
if selectRows['ID'][i] === 'GROUPING'
|
318
|
+
# Output OPTGROUP tags and labels no one can select this
|
319
|
+
if startedGrouping
|
320
|
+
selectOutput << '</optgroup>'
|
321
|
+
end
|
322
|
+
selectOutput << '<optgroup label="' + selectRows['VALUE'][i] + '">'
|
323
|
+
startedGrouping = true
|
324
|
+
else
|
325
|
+
# Output regular option tag
|
326
|
+
selectOutput << WidgetList::Utils::fill(pieces, items['template']['option'])
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
selected = ''
|
331
|
+
end
|
332
|
+
|
333
|
+
if (groupByRow && addedGroup)
|
334
|
+
selectOutput << '</optgroup>'
|
335
|
+
end
|
336
|
+
|
337
|
+
if hasASelectedMatch === false && items['insertUnknown'] === true
|
338
|
+
# in this mode, you wish to inject an option into the select box even though the results didnt find the match
|
339
|
+
|
340
|
+
|
341
|
+
items['selected'].each{ |vals|
|
342
|
+
pieces = {
|
343
|
+
'<!--VALUE-->' => vals,
|
344
|
+
'<!--ONCLICK-->' => items['onclick'],
|
345
|
+
'<!--SELECTED-->' => ' selected ',
|
346
|
+
'<!--CONTENT-->' => vals
|
347
|
+
}
|
348
|
+
selectOutput << WidgetList::Utils::fill(pieces, items['template']['option'])
|
349
|
+
}
|
350
|
+
end
|
351
|
+
end
|
352
|
+
else
|
353
|
+
pieces = {
|
354
|
+
'<!--VALUE-->' => '',
|
355
|
+
'<!--ONCLICK-->' => items['onclick'],
|
356
|
+
'<!--SELECTED-->' => '',
|
357
|
+
'<!--CONTENT-->' => items['noDataMsg']
|
358
|
+
}
|
359
|
+
|
360
|
+
selectOutput << WidgetList::Utils::fill(pieces, items['template']['initial'])
|
361
|
+
end
|
362
|
+
|
363
|
+
if items['id'].empty? && ! items['name'].empty?
|
364
|
+
items['id'] = items['name']
|
365
|
+
end
|
366
|
+
|
367
|
+
|
368
|
+
pieces = { '<!--SIZE-->' => items['size'],
|
369
|
+
'<!--ID-->' => items['id'],
|
370
|
+
'<!--NAME-->' => items['name'],
|
371
|
+
'<!--MULTIPLE-->' => items['multiple'],
|
372
|
+
'<!--OPTIONS-->' => selectOutput.join(''),
|
373
|
+
'<!--ONCHANGE-->' => items['onchange'],
|
374
|
+
'<!--REQUIRED-->' => items['required'],
|
375
|
+
'<!--CLASS-->' => items['class'],
|
376
|
+
'<!--DISABLED_FLG-->' => items['disabled'],
|
377
|
+
'<!--STYLE-->' => items['style'],
|
378
|
+
'<!--ATTRIBUTES-->' => items['attribs'].join(' '),
|
379
|
+
'<!--INNER_CLASS-->' => items['inner_class'],
|
380
|
+
'<!--OUTER_CLASS-->' => items['outer_class'],
|
381
|
+
'<!--OUTER_STYLE-->' => items['outer_style'],
|
382
|
+
'<!--INNER_STYLE-->' => '',
|
383
|
+
'<!--OUTER_ACTION-->' => ''
|
384
|
+
}
|
385
|
+
|
386
|
+
finalTemplate = items['template']['wrapper']
|
387
|
+
|
388
|
+
if items['passive'] && items['selected'].class.name == 'Array' && items['selected'].count > 0
|
389
|
+
#passKeys = array_keys(selectRows['ID'], items['selected'][0])
|
390
|
+
#pieces['<!--OPTIONS-->'] = selectRows['VALUE'][passKeys[0]]
|
391
|
+
finalTemplate = items['template']['passive']
|
392
|
+
end
|
393
|
+
|
394
|
+
WidgetList::Utils::fill(pieces, finalTemplate)
|
395
|
+
end
|
396
|
+
|
397
|
+
# WidgetInput
|
398
|
+
def self.widget_input(list={})
|
399
|
+
items = {
|
400
|
+
'name' => '',
|
401
|
+
'id' => '',
|
402
|
+
'outer_id' => '',
|
403
|
+
'value' => '',
|
404
|
+
'input_type' => 'text', #hidden
|
405
|
+
'width' => '150',
|
406
|
+
'readonly' => false,
|
407
|
+
'disabled' => false,
|
408
|
+
'hidden' => false,
|
409
|
+
'required' => false,
|
410
|
+
'list-search' => false,
|
411
|
+
'max_length' => '',
|
412
|
+
'events' => {},
|
413
|
+
'title' => '',
|
414
|
+
'add_class' => '',
|
415
|
+
'class' => 'inputOuter',
|
416
|
+
'inner_class' => 'inputInner',
|
417
|
+
'outer_onclick'=> '',
|
418
|
+
'style' => '',
|
419
|
+
'inner_style' => '',
|
420
|
+
'input_style' => '',
|
421
|
+
'input_class' => '',
|
422
|
+
'template' => '',
|
423
|
+
'search_ahead' => {},
|
424
|
+
'search_form' => '',
|
425
|
+
'search_handle'=> '',
|
426
|
+
'arrow_extra_class'=> '',
|
427
|
+
'icon_extra_class'=> '',
|
428
|
+
'arrow_action' => ''
|
429
|
+
}
|
430
|
+
|
431
|
+
items['template_required'] = $G_TEMPLATE['widget']['required']
|
432
|
+
|
433
|
+
items['template'] = $G_TEMPLATE['widget']['input']['default']
|
434
|
+
|
435
|
+
items = populate_items(list,items)
|
436
|
+
|
437
|
+
iconAction = ''
|
438
|
+
outerAction = ''
|
439
|
+
onkeyup = ''
|
440
|
+
|
441
|
+
if ! items['outer_onclick'].empty?
|
442
|
+
outerAction = items['outer_onclick']
|
443
|
+
end
|
444
|
+
|
445
|
+
if ! items['search_ahead'].empty?
|
446
|
+
# Search Ahead Input
|
447
|
+
#
|
448
|
+
items['template'] = $G_TEMPLATE['widget']['input']['search']
|
449
|
+
|
450
|
+
fill = {}
|
451
|
+
if items['list-search']
|
452
|
+
fill['<!--MAGNIFIER-->'] = '<div class="widget-search-magnifier <!--ICON_EXTRA_CLASS-->" style="" onclick="<!--ICON_ACTION-->"></div>'
|
453
|
+
end
|
454
|
+
|
455
|
+
items['template'] = WidgetList::Utils::fill(fill,items['template'])
|
456
|
+
|
457
|
+
if ! items['search_ahead']['search_form'].empty?
|
458
|
+
if(items['arrow_action'].empty?)
|
459
|
+
items['arrow_action'] = "ToggleAdvancedSearch(this)"
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
#####
|
464
|
+
|
465
|
+
if items['search_ahead'].key?('icon_action')
|
466
|
+
iconAction = items['search_ahead']['icon_action']
|
467
|
+
end
|
468
|
+
|
469
|
+
if items.key?('events') && items['events'].key?('onkeyup')
|
470
|
+
keyUp = items['events']['onkeyup'] + ';'
|
471
|
+
else
|
472
|
+
keyUp = ''
|
473
|
+
end
|
474
|
+
|
475
|
+
if items['search_ahead'].key?('onkeyup') && !items['search_ahead']['onkeyup'].empty?
|
476
|
+
items['events']['onkeyup'] = keyUp + items['search_ahead']['onkeyup']
|
477
|
+
else
|
478
|
+
if items['list-search']
|
479
|
+
items['events']['onkeyup'] = keyUp + "SearchWidgetList('#{items['search_ahead']['url']}', '#{items['search_ahead']['target']}', this);"
|
480
|
+
elsif items['search_ahead'].key?('skip_queue') && items['search_ahead']['skip_queue']
|
481
|
+
items['events']['onkeyup'] = keyUp + "WidgetInputSearchAhead('#{items['search_ahead']['url']}', '#{items['search_ahead']['target']}', this);"
|
482
|
+
else
|
483
|
+
items['events']['onkeyup'] = keyUp + "WidgetInputSearchAheadQueue('#{items['search_ahead']['url']}', '#{items['search_ahead']['target']}', this);"
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
if !items['events']['onkeyup'].empty?
|
488
|
+
iconAction = items['events']['onkeyup']
|
489
|
+
end
|
490
|
+
|
491
|
+
if items['search_ahead'].key?('onclick')
|
492
|
+
items['events']['onclick'] = items['search_ahead']['onclick']
|
493
|
+
end
|
494
|
+
|
495
|
+
items['input_class'] += ' search-ahead'
|
496
|
+
|
497
|
+
# Modify the width a bit to compensate for the search icon
|
498
|
+
#
|
499
|
+
items['width'] = items['width'].to_i - 30
|
500
|
+
|
501
|
+
# Build advanced searching
|
502
|
+
#
|
503
|
+
if ! items['search_ahead']['search_form'].empty?
|
504
|
+
if items['list-search']
|
505
|
+
items['arrow_extra_class'] += ' widget-search-arrow-advanced'
|
506
|
+
else
|
507
|
+
items['arrow_extra_class'] += ' widget-search-arrow-advanced-no-search'
|
508
|
+
end
|
509
|
+
|
510
|
+
items['icon_extra_class'] += ' widget-search-magnifier-advanced'
|
511
|
+
items['input_class'] += ' search-ahead-advanced'
|
512
|
+
end
|
513
|
+
|
514
|
+
end
|
515
|
+
|
516
|
+
#
|
517
|
+
# Mandatory For outer boundary and IE7
|
518
|
+
#
|
519
|
+
# @todo should be css MW 5/2012
|
520
|
+
#
|
521
|
+
items['style'] += "width:#{items['width']}px"
|
522
|
+
|
523
|
+
if !items['required']
|
524
|
+
items['template_required'] = ''
|
525
|
+
end
|
526
|
+
|
527
|
+
if items['disabled']
|
528
|
+
items['input_class'] += ' disabled'
|
529
|
+
end
|
530
|
+
|
531
|
+
if !items['add_class'].empty?
|
532
|
+
items['class'] += ' ' + items['add_class']
|
533
|
+
end
|
534
|
+
|
535
|
+
if items['hidden']
|
536
|
+
items['style'] += ' display:none'
|
537
|
+
end
|
538
|
+
|
539
|
+
if !items['events'].empty? && items['events'].is_a?(Hash)
|
540
|
+
items['event_attributes'] = ''
|
541
|
+
items['events'].each { |event,action|
|
542
|
+
items['event_attributes'] += ' ' + event + '="' + action + '"' + ' '
|
543
|
+
}
|
544
|
+
end
|
545
|
+
|
546
|
+
if ! items['search_ahead'].key?('search_form')
|
547
|
+
items['search_ahead']['search_form'] = ''
|
548
|
+
end
|
549
|
+
|
550
|
+
WidgetList::Utils::fill({
|
551
|
+
'<!--READONLY-->' => (items['readonly']) ? 'readonly' : '',
|
552
|
+
'<!--OUTER_ID-->' => items['outer_id'],
|
553
|
+
'<!--OUTER_CLASS-->' => items['class'],
|
554
|
+
'<!--OUTER_STYLE-->' => items['style'],
|
555
|
+
'<!--INNER_CLASS-->' => items['inner_class'],
|
556
|
+
'<!--INNER_STYLE-->' => items['inner_style'],
|
557
|
+
'<!--INPUT_CLASS-->' => items['input_class'],
|
558
|
+
'<!--INPUT_STYLE-->' => items['input_style'],
|
559
|
+
'<!--ID-->' => items['id'],
|
560
|
+
'<!--NAME-->' => items['name'],
|
561
|
+
'<!--TITLE-->' => items['title'],
|
562
|
+
'<!--MAX_LENGTH-->' => items['max_length'],
|
563
|
+
'<!--ONKEYUP-->' => onkeyup,
|
564
|
+
'<!--SEARCH_FORM-->' => items['search_ahead']['search_form'],
|
565
|
+
'<!--VALUE-->' => items['value'],
|
566
|
+
'<!--REQUIRED-->' => items['template_required'],
|
567
|
+
'<!--ICON_ACTION-->' => iconAction,
|
568
|
+
'<!--OUTER_ACTION-->' => outerAction,
|
569
|
+
'<!--EVENT_ATTRIBUTES-->' => items['event_attributes'],
|
570
|
+
'<!--INPUT_TYPE-->' => items['input_type'],
|
571
|
+
'<!--ARROW_EXTRA_CLASS-->' => items['arrow_extra_class'],
|
572
|
+
'<!--ARROW_ACTION-->' => items['arrow_action'],
|
573
|
+
'<!--ICON_EXTRA_CLASS-->' => items['icon_extra_class']
|
574
|
+
} ,
|
575
|
+
items['template']
|
576
|
+
)
|
577
|
+
|
578
|
+
end
|
579
|
+
|
580
|
+
def self.populate_items(list,items)
|
581
|
+
unless list.nil?
|
582
|
+
list.each { |k,v|
|
583
|
+
if list.key?(k)
|
584
|
+
items[k] = v
|
585
|
+
end
|
586
|
+
}
|
587
|
+
end
|
588
|
+
items
|
589
|
+
end
|
590
|
+
|
591
|
+
# WidgetButton
|
592
|
+
def self.widget_button(text='', list={}, small=false)
|
593
|
+
items = {
|
594
|
+
'label' => text,
|
595
|
+
'name' => '',
|
596
|
+
'id' => '',
|
597
|
+
'url' => '',
|
598
|
+
'link' => '', #alias of url
|
599
|
+
'href' => '', #alias of url
|
600
|
+
'page' => '',
|
601
|
+
'parameters' => false,
|
602
|
+
'style' => 'display:inline-block',
|
603
|
+
'frmSubmit' => '', #this option adds hidden frmbutton
|
604
|
+
'submit' => '',
|
605
|
+
'args' => {},
|
606
|
+
'class' => 'btn', #Always stays the same
|
607
|
+
'innerClass' => 'success', #.primary(blue) .info(light-blue) .success(green) .danger(red) .disabled(light grey) .default(grey)
|
608
|
+
'passive' => false,
|
609
|
+
'function' => 'ButtonLinkPost',
|
610
|
+
'onclick' => '',
|
611
|
+
'template' => ''
|
612
|
+
}
|
613
|
+
|
614
|
+
items = populate_items(list,items)
|
615
|
+
|
616
|
+
if items.key?('submit') && !items['submit'].empty?
|
617
|
+
items['onclick'] = "ButtonFormPost('#{list['submit']}');"
|
618
|
+
end
|
619
|
+
|
620
|
+
if items['template'].empty?
|
621
|
+
theClass = ''
|
622
|
+
if small
|
623
|
+
theClass = items['class'] + " small " + items['innerClass']
|
624
|
+
elsif ! items['class'].empty?
|
625
|
+
theClass = items['class'] + " " + items['innerClass']
|
626
|
+
end
|
627
|
+
items['template'] = $G_TEMPLATE['widget']['button']['default']
|
628
|
+
else
|
629
|
+
theClass = items['class']
|
630
|
+
end
|
631
|
+
|
632
|
+
if items['url'].empty? && !items['page'].empty?
|
633
|
+
items['url'] = WidgetList::Utils::build_url(items['page'], items['args'])
|
634
|
+
end
|
635
|
+
|
636
|
+
if !items['href'].empty? && items['onclick'].empty?
|
637
|
+
items['onclick'] = items['function'] + "('#{items['href']}')"
|
638
|
+
end
|
639
|
+
|
640
|
+
if !items['url'].empty? && items['onclick'].empty?
|
641
|
+
items['onclick'] = items['function'] + "('#{items['url']}')"
|
642
|
+
end
|
643
|
+
|
644
|
+
if !items['link'].empty? && items['onclick'].empty?
|
645
|
+
items['onclick'] = items['function'] + "('#{items['link']}')"
|
646
|
+
end
|
647
|
+
|
648
|
+
if items['parameters'] && !items['args'].empty? && items['args'].is_a?(Hash)
|
649
|
+
parameters = []
|
650
|
+
items['args'].each {|k,parameter|
|
651
|
+
if (parameter == 'this' || (parameter =~ /function/) && parameter =~ /\{/ && parameter =~ /\}/)
|
652
|
+
parameters << parameter.to_s
|
653
|
+
else
|
654
|
+
tmp = "'" + parameter.to_s + "'"
|
655
|
+
parameters << tmp
|
656
|
+
end
|
657
|
+
}
|
658
|
+
items['onclick'] = items['function'] + "(" + parameters.join(',') + ")"
|
659
|
+
end
|
660
|
+
|
661
|
+
if !items['frmSubmit'].empty?
|
662
|
+
items['frmSubmit'] = "<input type=\"submit\" value=\"\" style=\"position: absolute; float: left; z-index: -1;\"/> "
|
663
|
+
end
|
664
|
+
|
665
|
+
WidgetList::Utils::fill({
|
666
|
+
'<!--BUTTON_CLASS-->' => theClass,
|
667
|
+
'<!--BUTTON_ONCLICK-->' => items['onclick'].gsub(/\"/,"'"),
|
668
|
+
'<!--BUTTON_LABEL-->' => items['label'],
|
669
|
+
'<!--NAME-->' => items['name'],
|
670
|
+
'<!--ID-->' => items['id'],
|
671
|
+
'<!--BUTTON_STYLE-->' => items['style'],
|
672
|
+
'<!--BUTTON_CLASS_INNER-->' => items['innerClass'],
|
673
|
+
'<!--FRM_SUBMIT-->' => items['frmSubmit'],
|
674
|
+
},
|
675
|
+
items['template']
|
676
|
+
)
|
677
|
+
end
|
678
|
+
|
679
|
+
def self.test_all
|
680
|
+
output_final = ''
|
681
|
+
output_final += "error1" if $G_TEMPLATE['widget']['input']['search'].nil?
|
682
|
+
output_final += "error2" if $G_TEMPLATE['widget']['input']['default'].nil?
|
683
|
+
output_final += "error3" if $G_TEMPLATE['widget']['radio']['default'].nil?
|
684
|
+
output_final += "error4" if $G_TEMPLATE['widget']['checkbox']['default'].nil?
|
685
|
+
output_final += "error5" if $G_TEMPLATE['widget']['selectbox_nostyle']['wrapper'].nil?
|
686
|
+
output_final += "error6" if $G_TEMPLATE['widget']['selectbox']['wrapper'].nil?
|
687
|
+
output_final += "error7" if $G_TEMPLATE['widget']['selectbox']['option'].nil?
|
688
|
+
output_final += "error8" if $G_TEMPLATE['widget']['selectbox']['option'].nil?
|
689
|
+
output_final += "error9" if $G_TEMPLATE['widget']['selectbox']['option_showid'].nil?
|
690
|
+
output_final += "error10" if $G_TEMPLATE['widget']['selectbox']['option_showid_left'].nil?
|
691
|
+
output_final += "error11" if $G_TEMPLATE['widget']['selectbox']['initial'].nil?
|
692
|
+
output_final += "error12" if $G_TEMPLATE['widget']['selectbox']['passive'].nil?
|
693
|
+
output_final += "error13" if $G_TEMPLATE['widget']['selectfreeflow']['wrapper'].nil?
|
694
|
+
output_final += "error14" if $G_TEMPLATE['widget']['button']['default'].nil?
|
695
|
+
output_final += "error15" if $G_TEMPLATE['widget']['container']['row'].nil?
|
696
|
+
output_final += "error16" if $G_TEMPLATE['widget']['container']['col']['pre_text'].nil?
|
697
|
+
output_final += "error17" if $G_TEMPLATE['widget']['container']['col']['standard'].nil?
|
698
|
+
output_final += "error18" if $G_TEMPLATE['widget']['container']['wrapper'].nil?
|
699
|
+
|
700
|
+
#test submit
|
701
|
+
output_final += WidgetList::Widgets::widget_button('asfdsaf', {'id'=>'asdfasdf','submit'=>'213131'}) + "<br/><br/>"
|
702
|
+
|
703
|
+
#test arguments
|
704
|
+
output_final += WidgetList::Widgets::widget_button('asfdsaf', {'parameters'=>true,'args'=>{'dave'=>'123','dan'=>'1234'}}) + "<br/><br/>"
|
705
|
+
|
706
|
+
#test arguments with JS func
|
707
|
+
output_final += WidgetList::Widgets::widget_button('asfdsaf', {'parameters'=>true,'args'=> {'dave'=>'function() { alert(0); } '} } ) + "<br/><br/>"
|
708
|
+
|
709
|
+
output_final += WidgetList::Widgets::widget_button('asfdsaf', {'name'=>'asdfasf', 'id'=>'asfdasdf', 'parameters'=>true,'args'=> {'dave'=>'function() { alert(0); } '} }, true) + "<br/><br/>"
|
710
|
+
|
711
|
+
input = {}
|
712
|
+
input['list-search'] = true
|
713
|
+
input['width'] = '300'
|
714
|
+
input['input_class'] = 'info-input'
|
715
|
+
input['title'] = 'test search'
|
716
|
+
input['id'] = 'list_search_id_'
|
717
|
+
input['name'] = 'list_search_name_'
|
718
|
+
input['value'] = 'asfdasd'
|
719
|
+
input['class'] = 'inputOuter widget-search-outer -search'
|
720
|
+
input['search_ahead'] = {
|
721
|
+
'url' => 'http://google.com',
|
722
|
+
'skip_queue' => false,
|
723
|
+
'target' => 'test',
|
724
|
+
'search_form' => '',
|
725
|
+
'onclick' => ''
|
726
|
+
}
|
727
|
+
output_final += WidgetList::Widgets::widget_input(input) + "<br/><br/>"
|
728
|
+
|
729
|
+
output_final
|
730
|
+
end
|
731
|
+
end
|
732
|
+
end
|