the-admin 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7604eb9ddc4a5f9034a7a3949fb743fede534aa0
4
+ data.tar.gz: b6c46ee7fab6b067eb0e0930417f2a9fe408c4dc
5
+ SHA512:
6
+ metadata.gz: be203b590ba70b476c0d3598322b529b8b48e9fb5412a3ed3be18503171f14c7b04093104e02772b621e9a311379858016fe367c43c5b151561fdda919e06d7c
7
+ data.tar.gz: 418790d96e636e33e4c4f3a80482d859116d3173a7a98c254eeb2fa7cc7b92fb3028f620d6648f4e3252795f646dca10e156b5032467634294d44634455a0255
Binary file
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+
24
+ .ruby-version
25
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in theadmin.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'yard'
8
+ end
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2018 timmushen
2
+
3
+ MIT License
4
+
5
+ Use by Permission only
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
8
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
10
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
11
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
12
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
13
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # The Admin
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'the-admin'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install the-admin
18
+
19
+ ## Usage
20
+
21
+ To use in Sinatra add
22
+
23
+ require 'the-admin'
24
+
25
+ ## Configuration
26
+
27
+ the-admin.configuration do |config|
28
+ config.bugsnag_api_key = "string"
29
+ end
30
+
31
+ ## Documentation
32
+
33
+ The gem is documented with YARD. You can run yard documentation using its inbuilt
34
+ server. Following git clone...
35
+
36
+ ~# cd the-admin-gem
37
+ ~# bundle install
38
+ ~# yard server --reload
39
+
40
+ and visit localhost:8808.
41
+
42
+ If you prefer to compile it to html (ex: to host)..
43
+
44
+ ~# yard
45
+
46
+ For more information visit [yardoc website](http://yardoc.org/) or use...
47
+
48
+ ~# yard --help
49
+
50
+ ## Contributing
@@ -0,0 +1,20 @@
1
+ require 'rspec/core/rake_task'
2
+ require "bundler/gem_tasks"
3
+
4
+ desc "Check into repo, build & install"
5
+ task :gbuild do
6
+ # Your code goes here
7
+ puts `git add -Av`
8
+ puts `git commit -m 'updated gem'`
9
+ puts `rake build`
10
+ puts `git push origin master`
11
+ puts `rake install`
12
+ end
13
+
14
+ # Default directory to look in is `/specs`
15
+ # Run with `rake spec`
16
+ RSpec::Core::RakeTask.new(:spec) do |task|
17
+ # task.rspec_opts = ['--color', '--format']
18
+ end
19
+
20
+ task :default => :spec
@@ -0,0 +1,139 @@
1
+ # TheAdmin - gems
2
+ require "the-admin/version"
3
+ require "the-admin/form"
4
+ require "the-admin/layout"
5
+
6
+ # 3rd party gems
7
+ require "sinatra/base"
8
+ require "sinatra/contrib/all"
9
+ require "digest"
10
+ require "base64"
11
+ require "json"
12
+
13
+
14
+ module TheAdmin
15
+
16
+ class << self
17
+ # Controls the app configuration
18
+ # @return [TheAdmin::Configuration] configuration object
19
+ attr_accessor :configuration
20
+ end
21
+
22
+ # Configure the TheAdmin gem
23
+ #
24
+ # @example
25
+ # TheAdmin.confgure do |config|
26
+ # config.bugsnag_api_key = "XYZ"
27
+ #
28
+ # config.mail_from = "John Doe"
29
+ # config.mail_address = "johndoe@example.com"
30
+ # config.mail_port = "578"
31
+ # config.mail_domain = "smtp.mailgun.org"
32
+ # config.mail_user_name = ""
33
+ # config.mail_password = ""
34
+ # config.mail_authentication = "plain"
35
+ #
36
+ # config.aws_bucket = ""
37
+ # config.aws_access_key_id = ""
38
+ # config.aws_secret_access_key = ""
39
+ # config.aws_region = ""
40
+ # end
41
+ def self.configure
42
+ self.configuration ||= Configuration.new
43
+ yield(configuration)
44
+ end
45
+
46
+ #
47
+ # TheAdmin configuration class.
48
+ #
49
+ # @author Tim Mushen
50
+ #
51
+ class Configuration
52
+
53
+ # Controls the bugsnag api key attribute
54
+ # @return [String] Bugsnag api key
55
+ # attr_accessor :bugsnag_api_key
56
+
57
+ # Controls the mail from
58
+ # @return [String] the mail from
59
+ attr_accessor :mail_from
60
+
61
+ # Controls the mail address
62
+ # @return [String] the mail address
63
+ attr_accessor :mail_address
64
+
65
+ # Controls the mail port number
66
+ # @return [String] the mail port number
67
+ attr_accessor :mail_port
68
+
69
+ # Controls the mail domain
70
+ # @return [String] the mail domain
71
+ attr_accessor :mail_domain
72
+
73
+ # Controls the mail user name
74
+ # @return [String] the mail user name
75
+ attr_accessor :mail_user_name
76
+
77
+ # Controls the mail password
78
+ # @return [String] the mail password
79
+ attr_accessor :mail_password
80
+
81
+ # Controls mail authentication
82
+ # @return [String] mail authentication
83
+ attr_accessor :mail_authentication
84
+
85
+ # Controls the aws bucket name
86
+ # @return [String] aws bucket name
87
+ attr_accessor :aws_bucket
88
+
89
+ # Controls the aws access key id
90
+ # @return [String] the aws access key id
91
+ attr_accessor :aws_access_key_id
92
+
93
+ # Controls the aws secret access key
94
+ # @return [String] the aws secret access key
95
+ attr_accessor :aws_secret_access_key
96
+
97
+ # Controls the aws region
98
+ # @return [String] aws region
99
+ attr_accessor :aws_region
100
+
101
+ # Initialize TheAdmin configuration object and set defaults
102
+ def initialize
103
+ # Bugsnag
104
+ # @bugsnag_api_key = ""
105
+
106
+ # X_mail
107
+ @mail_from = ""
108
+ @mail_address = "smtp.mailgun.org"
109
+ @mail_port = "587"
110
+ @mail_domain = "smtp.mailgun.org"
111
+ @mail_user_name = ""
112
+ @mail_password = ""
113
+ @mail_authentication = "plain"
114
+
115
+ # For AWS/Fog
116
+ @aws_bucket = ""
117
+ @aws_secret_access_key = ""
118
+ @aws_access_key_id = ""
119
+ @aws_region = ""
120
+ end
121
+
122
+ end
123
+
124
+
125
+ # TheAdmin - Sinatra module
126
+ module Sinatra
127
+
128
+ def self.registered(app)
129
+
130
+ app.helpers TheAdmin::FormHelpers
131
+ app.helpers TheAdmin::LayoutHelpers
132
+
133
+ end
134
+
135
+ end # End Sinatra
136
+ end
137
+
138
+ #Register Helpers
139
+ Sinatra.register TheAdmin::Sinatra
@@ -0,0 +1,1401 @@
1
+ module TheAdmin
2
+ module FormHelpers
3
+
4
+ # View helper to generate check box
5
+ # @param id [String] the checkbox id attribute
6
+ # @param name [String] the checkbox name attribute
7
+ # @param value [String] the checkbox value
8
+ # @param label [String] the checkbox label
9
+ # @param checked [Boolean] if the checkbox is checked
10
+ # @param switch [Boolean] if the checkbox is a switch
11
+ # @param align [String] if the alignment should be left or right
12
+ # @param inline [Boolean] if the element is inline
13
+ # @param form_group [Boolean] if a form group
14
+ # @param required [Boolean] if required or not
15
+ # @return [String] Compiled html checkbox
16
+ def x_checkbox(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false)
17
+
18
+ checked_output = ""
19
+ switchery_div = ""
20
+ switchery_input = ""
21
+ align_class = ""
22
+ inline_class = ""
23
+ form_group_start = ""
24
+ form_group_end = ""
25
+ required_output = ""
26
+
27
+ if checked == true then checked_output='checked="checked"' end
28
+ if switch == true then switchery_div='checkbox-switchery' end
29
+ if switch == true then switchery_input='switch' end
30
+ if align == "left" then align_class='pull-left' end
31
+ if align == "right" then align_class='pull-right' end
32
+ if inline == true then inline_class ='inline' end
33
+ if form_group == true then form_group_start = '<div class="form-group">' end
34
+ if form_group == true then form_group_end = '</div>' end
35
+ if required == true then required_output = "data-parsley-mincheck='1'" end
36
+
37
+ cb = <<EOS
38
+ #{form_group_start}
39
+ <div class="checkbox #{switchery_div}">
40
+ <label class="#{align_class} #{inline_class}">
41
+ <input type="hidden" id="#{id}" name="post[#{name}]" value="0">
42
+ <input type="checkbox" class="#{switchery_input}" id="#{id}" name="post[#{name}]" value="1" #{checked_output} data-toggle="checkbox" #{required_output}/>
43
+ #{label} </label>
44
+ </div>
45
+ #{form_group_end}
46
+ EOS
47
+ return cb
48
+ end
49
+
50
+ # Check box helper
51
+ # @param id [String] the checkbox id
52
+ # @param name [String] the name attribute of the checkbox
53
+ # @param value [String] the checkbox value
54
+ # @param label [String] the label text of the checkbox
55
+ # @param checked [Boolean] if the checkbox is checked
56
+ # @param switch [Boolean] if the checkbox is a switchery input
57
+ # @param align [String] if the check box aligned 'left' or 'right'
58
+ # @param inline [Boolean] if the checkbox is inline or not
59
+ # @param form_group [Boolean] if the checkbox is of form group
60
+ # @param required [Boolean] if checkbox is required
61
+ # @return [String] the compiled checkbox
62
+ def x_checkbox_string(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false)
63
+
64
+ checked_output = ""
65
+ switchery_div = ""
66
+ switchery_input = ""
67
+ align_class = ""
68
+ inline_class = ""
69
+ form_group_start = ""
70
+ form_group_end = ""
71
+ required_output = ""
72
+
73
+ if checked == true then checked_output='checked="checked"' end
74
+ if switch == true then switchery_div='checkbox-switchery' end
75
+ if switch == true then switchery_input='switch' end
76
+ if align == "left" then align_class='pull-left' end
77
+ if align == "right" then align_class='pull-right' end
78
+ if inline == true then inline_class ='inline' end
79
+ if form_group == true then form_group_start = '<div class="form-group">' end
80
+ if form_group == true then form_group_end = '</div>' end
81
+ if required == true then required_output = "data-parsley-mincheck='1'" end
82
+
83
+ cb = <<EOS
84
+ #{form_group_start}
85
+ <div class="checkbox #{switchery_div}">
86
+ <label class="#{align_class} #{inline_class}">
87
+ <input type="checkbox" class="#{switchery_input}" id="#{id}" name="#{name}" value="#{value}" #{checked_output} data-toggle="checkbox" #{required_output}/>
88
+ #{label} </label>
89
+ </div>
90
+ #{form_group_end}
91
+ EOS
92
+ return cb
93
+ end
94
+
95
+
96
+ # Radio button view helper
97
+ # @param id [String] the radio id
98
+ # @param name [String] the name attribute of the radio
99
+ # @param value [String] the radio value
100
+ # @param label [String] the label text of the radio
101
+ # @param checked [Boolean] if the radio is checked
102
+ # @param align [String] if the check box aligned 'left' or 'right'
103
+ # @param inline [Boolean] if the radio is inline or not
104
+ # @param form_group [Boolean] if the radio is of form group
105
+ # @return [String] the compiled radio
106
+ def x_radio(id: "", name: "", value: "1", label: "", checked: false, checked_if: "", align: false, inline: false, include_false_as_hidden: false ,form_group: true)
107
+
108
+ checked_output = ""
109
+ align_class = ""
110
+ inline_class = ""
111
+ form_group_start = ""
112
+ form_group_end = ""
113
+ include_false_as_hidden_element = ""
114
+
115
+ if checked == checked_if then checked_output='checked="checked"' end
116
+ if checked_if != "" then checked = false end
117
+ if checked == true then checked_output='checked="checked"' end
118
+ if align == "left" then align_class='pull-left' end
119
+ if align == "right" then align_class='pull-right' end
120
+ if inline == true then inline_class ='inline' end
121
+ if form_group == true then form_group_start = '<div class="form-group">' end
122
+ if form_group == true then form_group_end = '</div>' end
123
+ if include_false_as_hidden == true then include_false_as_hidden_element = '<input type="hidden" id="#{id}" name="post[#{name}]" value="0">' end
124
+ radio_btn = <<EOS
125
+ #{form_group_start}
126
+ <div class="radio">
127
+ <label class="#{align_class} #{inline_class}">
128
+ #{include_false_as_hidden_element}
129
+ <input type="radio" id="#{id}" name="post[#{name}]" value="#{value}" #{checked_output} data-toggle="radio"/>
130
+ #{label}</label>
131
+ </div>
132
+ #{form_group_end}
133
+ EOS
134
+ return radio_btn
135
+ end
136
+
137
+ # Hidden input helper
138
+ # @param id [String] hidden input id
139
+ # @param name [String] hidden input name
140
+ # @param value [String] hidden input value
141
+ # @return [String] compiled hidden input html
142
+ def x_hidden(id: "", name: "", value: "")
143
+
144
+ hi = <<EOS
145
+ <input type="hidden" id="#{id}" name="post[#{name}]" value="#{value}"/>
146
+ EOS
147
+ return hi
148
+ end
149
+
150
+
151
+ # Text input helper
152
+ # @param id [String] input element id
153
+ # @param name [String] input element name
154
+ # @param value [String] input element value
155
+ # @param label [String] input element label
156
+ # @param required [Boolean] if input element is required
157
+ # @param placeholder [String] input element placeholder
158
+ # @param mask [String] input element mask
159
+ # @param maxlength [String] input element max length
160
+ # @return [String] compiled input element
161
+ def x_input(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "", css:"")
162
+
163
+ id = name unless id != ""
164
+ if required
165
+ if label != ""
166
+ required_output = '<sup class="text-danger">*</sup>'
167
+ else
168
+ required_output = ''
169
+ end
170
+ required_tag = 'required="required"'
171
+ else
172
+ required_output = ""
173
+ required_tag = ""
174
+ end
175
+
176
+ if label != ""
177
+ label = "<label>#{label}</label>"
178
+ end
179
+
180
+ if maxlength != ""
181
+ maxlength = "maxlength='#{maxlength}'"
182
+ end
183
+
184
+ if mask != ""
185
+ mask = "data-masked-input='#{mask}'"
186
+ end
187
+
188
+ tb = <<EOS
189
+ <div class="form-group">
190
+ #{label}#{required_output}
191
+ <input type="text" class="form-control #{css}" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" #{required_tag} #{mask} #{maxlength} />
192
+ </div>
193
+ EOS
194
+ return tb
195
+ end
196
+
197
+
198
+ # Money input helper
199
+ # @param id [String] the money input id
200
+ # @param name [String] the money input name
201
+ # @param label [String] the money input label
202
+ # @param required [Boolean] if money input is required or not
203
+ # @param placeholder [String] the moeny input placeholder
204
+ # @param mask [String] the money input mask
205
+ # @param maxlength [String] max length of the input
206
+ # @return [String] compiled money input html
207
+ def x_money(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")
208
+
209
+ id = name unless id != ""
210
+ if required
211
+ if label != ""
212
+ required_output = '<sup class="text-danger">*</sup>'
213
+ else
214
+ required_output = ''
215
+ end
216
+ required_tag = 'required="required"'
217
+ else
218
+ required_output = ""
219
+ required_tag = ""
220
+ end
221
+
222
+ if label != ""
223
+ label = "<label>#{label}</label>"
224
+ end
225
+
226
+ if maxlength != ""
227
+ maxlength = "maxlength='#{maxlength}'"
228
+ end
229
+
230
+ if mask != ""
231
+ mask = "data-masked-input='#{mask}'"
232
+ end
233
+
234
+ if value == 0 || value.nil? || value == ""
235
+ value = "0.00"
236
+ else
237
+ value = "%.2f" % value rescue nil
238
+ end
239
+
240
+ tb = <<EOS
241
+ <div class="form-group">
242
+ #{label}#{required_output}
243
+ <div class="input-group">
244
+ <span class="input-group-addon">$</span>
245
+ <input type="text" class="form-control money" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" data-parsley-type="number" #{required_tag} #{mask} #{maxlength} />
246
+ </div>
247
+ </div>
248
+ EOS
249
+ return tb
250
+ end
251
+
252
+ # Percentage input helper
253
+ # @param id [String] percentage input id
254
+ # @param name [String] percentage input name
255
+ # @param value [String] percentage input value
256
+ # @param label [String] percentage input label
257
+ # @param required [Boolean] if percentage input is required
258
+ # @param placeholder [String] percentage input placeholder
259
+ # @param mask [String] percentage input mask
260
+ # @param maxlength [String] percentage input maxlength
261
+ def x_percentage(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")
262
+
263
+ id = name unless id != ""
264
+ if required
265
+ if label != ""
266
+ required_output = '<sup class="text-danger">*</sup>'
267
+ else
268
+ required_output = ''
269
+ end
270
+ required_tag = 'required="required"'
271
+ else
272
+ required_output = ""
273
+ required_tag = ""
274
+ end
275
+
276
+ if label != ""
277
+ label = "<label>#{label}</label>"
278
+ end
279
+
280
+ if maxlength != ""
281
+ maxlength = "maxlength='#{maxlength}'"
282
+ end
283
+
284
+ if mask != ""
285
+ mask = "data-masked-input='#{mask}'"
286
+ end
287
+
288
+ tb = <<EOS
289
+ <div class="form-group">
290
+ #{label}#{required_output}
291
+ <div class="input-group">
292
+ <span class="input-group-addon">%</span>
293
+ <input type="text" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" data-parsley-type="number" #{required_tag} #{mask} #{maxlength} />
294
+ </div>
295
+ </div>
296
+ EOS
297
+ return tb
298
+ end
299
+
300
+ # Sq Ft input helper
301
+ # @param id [String] percentage input id
302
+ # @param name [String] percentage input name
303
+ # @param value [String] percentage input value
304
+ # @param label [String] percentage input label
305
+ # @param required [Boolean] if percentage input is required
306
+ # @param placeholder [String] percentage input placeholder
307
+ # @param mask [String] percentage input mask
308
+ # @param maxlength [String] percentage input maxlength
309
+ def x_sqft(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")
310
+
311
+ id = name unless id != ""
312
+ if required
313
+ if label != ""
314
+ required_output = '<sup class="text-danger">*</sup>'
315
+ else
316
+ required_output = ''
317
+ end
318
+ required_tag = 'required="required"'
319
+ else
320
+ required_output = ""
321
+ required_tag = ""
322
+ end
323
+
324
+ if label != ""
325
+ label = "<label>#{label}</label>"
326
+ end
327
+
328
+ if maxlength != ""
329
+ maxlength = "maxlength='#{maxlength}'"
330
+ end
331
+
332
+ if mask != ""
333
+ mask = "data-masked-input='#{mask}'"
334
+ end
335
+
336
+ tb = <<EOS
337
+ <div class="form-group">
338
+ #{label}#{required_output}
339
+ <div class="input-group">
340
+ <input type="text" class="form-control sq_ft" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" data-parsley-type="number" #{required_tag} #{mask} #{maxlength} />
341
+ <span class="input-group-addon">sqft</span>
342
+ </div>
343
+ </div>
344
+ EOS
345
+
346
+ return tb
347
+ end
348
+
349
+
350
+ # Number input helper
351
+ # @param id [String] number input id
352
+ # @param name [String] number input name
353
+ # @param value [String] number input value
354
+ # @param label [String] number input label
355
+ # @param required [Boolean] if required or not
356
+ # @param placeholder [String] number input placeholder text
357
+ # @param mask [String] number input mask
358
+ # @param maxlength [String] nuber input max length
359
+ # @return [String] compiled html of number input
360
+ def x_number(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")
361
+
362
+ if required
363
+ if label != ""
364
+ required_output = '<sup class="text-danger">*</sup>'
365
+ else
366
+ required_output = ''
367
+ end
368
+ required_tag = 'required="required"'
369
+ else
370
+ required_output = ""
371
+ required_tag = ""
372
+ end
373
+
374
+ if label != ""
375
+ label = "<label>#{label}#{required_output}</label>"
376
+ end
377
+
378
+ if maxlength != ""
379
+ maxlength = "maxlength='#{maxlength}'"
380
+ end
381
+
382
+ if mask != ""
383
+ mask = "data-masked-input='#{mask}'"
384
+ end
385
+
386
+ tb = <<EOS
387
+ <div class="form-group">
388
+ #{label}
389
+ <input type="text" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} placeholder="#{placeholder}" data-parsley-type="number" #{mask} #{maxlength}/>
390
+ </div>
391
+ EOS
392
+ return tb
393
+ end
394
+
395
+
396
+
397
+ # Phone input helper
398
+ # @param id [String] phone input id
399
+ # @param name [String] phone input name
400
+ # @param value [String] phone input value
401
+ # @param label [String] phone input label
402
+ # @param required [Boolean] if required or not
403
+ # @param placeholder [String] phone input placeholder text
404
+ # @param mask [String] phone input mask
405
+ # @param maxlength [String] nuber input max length
406
+ # @return [String] compiled html of phone input
407
+ def x_phone(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "(999) 999-9999 x99999", maxlength: "22")
408
+
409
+ if required
410
+ if label != ""
411
+ required_output = '<sup class="text-danger">*</sup>'
412
+ else
413
+ required_output = ''
414
+ end
415
+ required_tag = 'required="required"'
416
+ else
417
+ required_output = ""
418
+ required_tag = ""
419
+ end
420
+
421
+ if label != ""
422
+ label = "<label>#{label}#{required_output}</label>"
423
+ end
424
+
425
+ if mask != ""
426
+ mask = "data-masked-input='#{mask}'"
427
+ end
428
+
429
+ if maxlength != ""
430
+ maxlength = "maxlength='#{maxlength}'"
431
+ end
432
+
433
+ tb = <<EOS
434
+ <div class="form-group">
435
+ #{label}
436
+ <input type="text" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} placeholder="#{placeholder}" #{mask} #{maxlength} />
437
+ </div>
438
+ EOS
439
+ return tb
440
+ end
441
+
442
+
443
+ # SSN input helper
444
+ # @param id [String] ssn input id
445
+ # @param name [String] ssn input name
446
+ # @param value [String] ssn input value
447
+ # @param label [String] ssn input label
448
+ # @param required [Boolean] if required or not
449
+ # @param placeholder [String] ssn input placeholder text
450
+ # @param mask [String] ssn input mask
451
+ # @param maxlength [String] nuber input max length
452
+ # @return [String] compiled html of ssn input
453
+ def x_ssn(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "999-99-9999")
454
+
455
+ if required
456
+ if label != ""
457
+ required_output = '<sup class="text-danger">*</sup>'
458
+ else
459
+ required_output = ''
460
+ end
461
+ required_tag = 'required="required"'
462
+ else
463
+ required_output = ""
464
+ required_tag = ""
465
+ end
466
+
467
+ if label != ""
468
+ label = "<label>#{label}#{required_output}</label>"
469
+ end
470
+
471
+ if mask != ""
472
+ mask = "data-masked-input='#{mask}'"
473
+ end
474
+
475
+
476
+ tb = <<EOS
477
+ <div class="form-group">
478
+ #{label}
479
+ <input type="text" class="form-control ssn" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-minlength="11" placeholder="#{placeholder}" #{mask} />
480
+ </div>
481
+ EOS
482
+ return tb
483
+ end
484
+
485
+ # EIN input helper
486
+ # @param id [String] ein input id
487
+ # @param name [String] ein input name
488
+ # @param value [String] ein input value
489
+ # @param label [String] ein input label
490
+ # @param required [Boolean] if required or not
491
+ # @param placeholder [String] ein input placeholder text
492
+ # @param mask [String] ein input mask
493
+ # @param maxlength [String] nuber input max length
494
+ # @return [String] compiled html of ein input
495
+ def x_ein(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "99-9999999", maxlength: "10")
496
+
497
+ if required
498
+ if label != ""
499
+ required_output = '<sup class="text-danger">*</sup>'
500
+ else
501
+ required_output = ''
502
+ end
503
+ required_tag = 'required="required"'
504
+ else
505
+ required_output = ""
506
+ required_tag = ""
507
+ end
508
+
509
+ if label != ""
510
+ label = "<label>#{label}#{required_output}</label>"
511
+ end
512
+
513
+ if mask != ""
514
+ mask = "data-masked-input='#{mask}'"
515
+ end
516
+
517
+ if maxlength != ""
518
+ maxlength = "maxlength='#{maxlength}'"
519
+ end
520
+
521
+ tb = <<EOS
522
+ <div class="form-group">
523
+ #{label}
524
+ <input type="text" class="form-control ein" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-minlength="10" placeholder="#{placeholder}" #{mask} #{maxlength} />
525
+ </div>
526
+ EOS
527
+ return tb
528
+ end
529
+
530
+ # Zip input helper
531
+ # @param id [String] zip input id
532
+ # @param name [String] zip input name
533
+ # @param value [String] zip input value
534
+ # @param label [String] zip input label
535
+ # @param required [Boolean] if required or not
536
+ # @param placeholder [String] zip input placeholder text
537
+ # @param mask [String] zip input mask
538
+ # @param maxlength [String] nuber input max length
539
+ # @return [String] compiled html of zip input
540
+ def x_zip(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "99999", maxlength: "5")
541
+
542
+ if required
543
+ if label != ""
544
+ required_output = '<sup class="text-danger">*</sup>'
545
+ else
546
+ required_output = ''
547
+ end
548
+ required_tag = 'required="required"'
549
+ else
550
+ required_output = ""
551
+ required_tag = ""
552
+ end
553
+
554
+ if label != ""
555
+ label = "<label>#{label}#{required_output}</label>"
556
+ end
557
+
558
+ if mask != ""
559
+ mask = "data-masked-input='#{mask}'"
560
+ end
561
+
562
+ if maxlength != ""
563
+ maxlength = "maxlength='#{maxlength}'"
564
+ end
565
+
566
+ tb = <<EOS
567
+ <div class="form-group">
568
+ #{label}
569
+ <input type="text" class="form-control zip" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} placeholder="#{placeholder}" #{mask} data-parsley-length="[5,5]" data-parsley-length-message="This value should be exactly 5 digits long" data-parsley-type="digits" />
570
+ </div>
571
+ EOS
572
+ return tb
573
+ end
574
+
575
+ # State input helper
576
+ # @param id [String] state input id
577
+ # @param name [String] state input name
578
+ # @param value [String] state input value
579
+ # @param label [String] state input label
580
+ # @param required [Boolean] if required or not
581
+ # @param placeholder [String] state input placeholder text
582
+ # @param mask [String] state input mask
583
+ # @param maxlength [String] nuber input max length
584
+ # @return [String] compiled html of state input
585
+ def x_state(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "aa", maxlength: "2")
586
+
587
+ if required
588
+ if label != ""
589
+ required_output = '<sup class="text-danger">*</sup>'
590
+ else
591
+ required_output = ''
592
+ end
593
+ required_tag = 'required="required"'
594
+ else
595
+ required_output = ""
596
+ required_tag = ""
597
+ end
598
+
599
+ if label != ""
600
+ label = "<label>#{label}#{required_output}</label>"
601
+ end
602
+
603
+ if mask != ""
604
+ mask = "data-masked-input='#{mask}'"
605
+ end
606
+
607
+ if maxlength != ""
608
+ maxlength = "maxlength='#{maxlength}'"
609
+ end
610
+
611
+ tb = <<EOS
612
+ <div class="form-group">
613
+ #{label}
614
+ <input type="text" class="form-control state" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-pattern="^[A-Za-z]*$" data-parsley-minlength="2" placeholder="#{placeholder}" #{maxlength} />
615
+ </div>
616
+ EOS
617
+ return tb
618
+ end
619
+
620
+
621
+ # Credit card input helper
622
+ # @param id [String] credit card input id
623
+ # @param name [String] credit card input name
624
+ # @param value [String] credit card input value
625
+ # @param label [String] credit card label
626
+ # @param required [Boolean] if required or not
627
+ # @param placeholder [String] credit card input placeholder text
628
+ # @param mask [String] credit card input mask
629
+ # @param maxlength [String] nuber input max length
630
+ # @return [String] compiled html of credit card input
631
+ def x_credit_card(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "16", mask:"")
632
+
633
+ if required
634
+ if label != ""
635
+ required_output = '<sup class="text-danger">*</sup>'
636
+ else
637
+ required_output = ''
638
+ end
639
+ required_tag = 'required="required"'
640
+ else
641
+ required_output = ""
642
+ required_tag = ""
643
+ end
644
+
645
+ if label != ""
646
+ label = "<label>#{label}#{required_output} <small>(Numbers Only)</small></label>"
647
+ end
648
+
649
+ if mask != ""
650
+ mask = "data-masked-input='#{mask}'"
651
+ end
652
+
653
+ if maxlength != ""
654
+ maxlength = "maxlength='#{maxlength}'"
655
+ end
656
+
657
+ tb = <<EOS
658
+ <div class="form-group">
659
+ #{label}
660
+ <input type="number" pattern="[0-9]{13,16}" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-type="integer" data-parsley-length="[13, 16]" placeholder="#{placeholder}" #{mask} #{maxlength} />
661
+ </div>
662
+ EOS
663
+ return tb
664
+ end
665
+
666
+ # CVC input helper
667
+ # @param id [String] cvc input id
668
+ # @param name [String] cvc input name
669
+ # @param value [String] cvc input value
670
+ # @param lable [String] cvc label
671
+ # @param required [Boolean] if required or not
672
+ # @param placeholder [String] cvc input placeholder text
673
+ # @param mask [String] cvc input mask
674
+ # @param maxlength [String] nuber input max length
675
+ # @return [String] compiled html of cvc input
676
+ def x_cvc(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "4", mask:"999999999999999999")
677
+
678
+ if required
679
+ if label != ""
680
+ required_output = '<sup class="text-danger">*</sup>'
681
+ else
682
+ required_output = ''
683
+ end
684
+ required_tag = 'required="required"'
685
+ else
686
+ required_output = ""
687
+ required_tag = ""
688
+ end
689
+ if label != ""
690
+ label = "<label>#{label}</label>"
691
+ end
692
+
693
+ if mask != ""
694
+ mask = "data-masked-input='#{mask}'"
695
+ end
696
+
697
+ if maxlength != ""
698
+ maxlength = "maxlength='#{maxlength}'"
699
+ end
700
+
701
+ tb = <<EOS
702
+ <div class="form-group">
703
+ #{label}#{required_output}
704
+ <input type="number" pattern="[0-9]{3,4}" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-type="integer" data-parsley-length="[3, 4]" placeholder="#{placeholder}" #{mask} #{maxlength} />
705
+ </div>
706
+ EOS
707
+ return tb
708
+ end
709
+
710
+ # Email input helper
711
+ # @param id [String] email input id
712
+ # @param name [String] email input name
713
+ # @param value [String] email input value
714
+ # @param label [String] email input label
715
+ # @param required [Boolean] if required or not
716
+ # @param placeholder [String] email input placeholder text
717
+ # @return [String] compiled html of email input
718
+ def x_email(id: "", name: "", value: "", label: "", required: false, placeholder: "")
719
+
720
+ if required
721
+ if label != ""
722
+ required_output = '<sup class="text-danger">*</sup>'
723
+ else
724
+ required_output = ''
725
+ end
726
+ required_tag = 'required="required"'
727
+ else
728
+ required_output = ""
729
+ required_tag = ""
730
+ end
731
+ if label != ""
732
+ label = "<label>#{label}</label>"
733
+ end
734
+
735
+ tb = <<EOS
736
+ <div class="form-group">
737
+ #{label}#{required_output}
738
+ <input type="email" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-type="email" placeholder="#{placeholder}" />
739
+ </div>
740
+ EOS
741
+ return tb
742
+ end
743
+
744
+
745
+ # URL input helper
746
+ # @param id [String] url input id
747
+ # @param name [String] url input name
748
+ # @param value [String] url input value
749
+ # @param label [String] url input label
750
+ # @param required [Boolean] if required or not
751
+ # @param placeholder [String] url input placeholder text
752
+ # @return [String] compiled html of url input
753
+ def x_url(id:"", name:"", value:"", label:"", required: false, placeholder: "")
754
+
755
+ if required
756
+ if label != ""
757
+ required_output = '<sup class="text-danger">*</sup>'
758
+ else
759
+ required_output = ''
760
+ end
761
+ required_tag = 'required="required"'
762
+ else
763
+ required_output = ""
764
+ required_tag = ""
765
+ end
766
+ if label != ""
767
+ label = "<label>#{label}</label>"
768
+ end
769
+
770
+ tb = <<EOS
771
+ <div class="form-group">
772
+ #{label}#{required_output}
773
+ <input type="url" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-type="url" placeholder="#{placeholder}" />
774
+ </div>
775
+ EOS
776
+ return tb
777
+ end
778
+
779
+ # File input helper
780
+ # @param id [String] file input id
781
+ # @param name [String] file input name
782
+ # @param value [String] file input value
783
+ # @param label [String] file input label
784
+ # @param required [Boolean] if required or not
785
+ # @param placeholder [String] file input placeholder text
786
+ # @param css [String] file input css
787
+ # @return [String] compiled html of file input
788
+ def x_file(id:"", name:"", value:"", label:"", required: false, placeholder: "", css: "")
789
+
790
+ if required
791
+ if label != ""
792
+ required_output = '<sup class="text-danger">*</sup>'
793
+ else
794
+ required_output = ''
795
+ end
796
+ required_tag = 'required="required"'
797
+ else
798
+ required_output = ""
799
+ required_tag = ""
800
+ end
801
+ if label != ""
802
+ label = "<label>#{label}</label>"
803
+ end
804
+ tb = <<EOS
805
+ <div class="form-group">
806
+ #{label}#{required_output}
807
+ <input type="file" class="form-control file #{css}" id="#{id}" name="filename" value="#{value}" #{required_tag} placeholder="#{placeholder}" />
808
+ </div>
809
+ EOS
810
+ return tb
811
+ end
812
+
813
+ # Image Upload
814
+ # @param id [String] file input id
815
+ # @param name [String] file input name
816
+ # @param value [String] file input value
817
+ # @param label [String] file input label
818
+ # @param required [Boolean] if required or not
819
+ # @param placeholder [String] file input placeholder text
820
+ # @param css [String] file input css
821
+ # @return [String] compiled html of file input
822
+ def x_image_upload(id: "input1",name: "input1",value: "",label: "Input1",required: false, size: "1M",height: "",default: "")
823
+
824
+ if required && label != ""
825
+ required_output = '<sup class="text-danger">*</sup>'
826
+ required_tag = 'required="required"'
827
+ else
828
+ required_output = ""
829
+ required_tag = ""
830
+ end
831
+
832
+ if height == ""
833
+ height = ""
834
+ else
835
+ height="data-height='#{height}'"
836
+ end
837
+
838
+
839
+ tb = <<EOS
840
+ <div class="form-group">
841
+ <label>#{label}</label>
842
+ <input type="file" class="form-control file dropify" data-default-file="#{value}" data-max-file-size="#{size}" id="#{id}" name="filename" value="#{value}" #{required_tag} #{height}/>
843
+ </div>
844
+ EOS
845
+ return tb
846
+ end
847
+
848
+ # Date input helper
849
+ # @param id [String] date input id
850
+ # @param name [String] date input name
851
+ # @param value [String] date input value
852
+ # @param label [String] date input label
853
+ # @param required [Boolean] if required or not
854
+ # @param placeholder [String] date input placeholder text
855
+ # @return [String] compiled html of date input
856
+ def x_date(id: "", name: "", value: "", label: "", required: false, placeholder: "")
857
+
858
+ if required
859
+ if label != ""
860
+ required_output = '<sup class="text-danger">*</sup>'
861
+ else
862
+ required_output = ''
863
+ end
864
+ required_tag = 'required="required"'
865
+ else
866
+ required_output = ""
867
+ required_tag = ""
868
+ end
869
+ if label != ""
870
+ label = "<label for='#{id}' class='control-label'>#{label}</label>"
871
+ end
872
+
873
+ tb = <<EOS
874
+ <div class="form-group">
875
+ #{label}#{required_output}
876
+ <div class="input-group">
877
+ <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
878
+ <input type="text" class="form-control datepicker" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} placeholder="#{placeholder}" />
879
+ </div>
880
+ </div>
881
+ EOS
882
+ return tb
883
+ end
884
+
885
+ # Date-time input helper
886
+ # @param id [String] date-time input id
887
+ # @param name [String] date-time input name
888
+ # @param value [String] date-time input value
889
+ # @param label [String] date-time input label
890
+ # @param required [Boolean] if required or not
891
+ # @param placeholder [String] date-time input placeholder text
892
+ # @return [String] compiled html of date-time input
893
+ def x_datetime(id: "", name: "", value: "", label: "", required: false, placeholder: "")
894
+
895
+ if required
896
+ if label != ""
897
+ required_output = '<sup class="text-danger">*</sup>'
898
+ else
899
+ required_output = ''
900
+ end
901
+ required_tag = 'required="required"'
902
+ else
903
+ required_output = ""
904
+ required_tag = ""
905
+ end
906
+ if label != ""
907
+ label = "<label for='#{id}' class='control-label'>#{label}</label>"
908
+ end
909
+
910
+ tb = <<EOS
911
+ <div class="form-group">
912
+ #{label}#{required_output}
913
+ <div class="input-group">
914
+ <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
915
+ <input type="text" class="form-control datetimepicker" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} placeholder="#{placeholder}" />
916
+ </div>
917
+ </div>
918
+ EOS
919
+ return tb
920
+ end
921
+
922
+ # Time input helper
923
+ # @param id [String] time input id
924
+ # @param name [String] time input name
925
+ # @param value [String] time input value
926
+ # @param label [String] time input label
927
+ # @param required [Boolean] if required or not
928
+ # @param placeholder [String] time input placeholder text
929
+ # @return [String] compiled html of time input
930
+ def x_time(id: "", name: "", value: "", label: "", required: false, placeholder: "")
931
+
932
+ if required
933
+ if label != ""
934
+ required_output = '<sup class="text-danger">*</sup>'
935
+ else
936
+ required_output = ''
937
+ end
938
+ required_tag = 'required="required"'
939
+ else
940
+ required_output = ""
941
+ required_tag = ""
942
+ end
943
+ if label != ""
944
+ label = "<label for='#{id}' class='control-label'>#{label}</label>"
945
+ end
946
+
947
+ tb = <<EOS
948
+ <div class="form-group">
949
+ #{label}#{required_output}
950
+ <div class="input-group">
951
+ <span class="input-group-addon"><i class="fa fa fa-clock-o"></i></span>
952
+ <input type="text" class="form-control timepicker" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} placeholder="#{placeholder}" />
953
+ </div>
954
+ </div>
955
+ EOS
956
+ return tb
957
+ end
958
+
959
+
960
+ # Password input helper
961
+ # @param id [String] password input id
962
+ # @param name [String] password input name
963
+ # @param value [String] password input value
964
+ # @param label [String] password input label
965
+ # @param required [Boolean] if required or not
966
+ # @param placeholder [String] password input placeholder text
967
+ # @return [String] compiled html of password input
968
+ def x_password(id: "",name: "", value: "", label: "", required: false, placeholder: "")
969
+
970
+ if required
971
+ if label != ""
972
+ required_output = '<sup class="text-danger">*</sup>'
973
+ else
974
+ required_output = ''
975
+ end
976
+ required_tag = 'required="required"'
977
+ else
978
+ required_output = ""
979
+ required_tag = ""
980
+ end
981
+ if label != ""
982
+ label = "<label>#{label}</label>"
983
+ end
984
+
985
+ tb = <<EOS
986
+ <div class="form-group">
987
+ #{label}#{required_output}
988
+ <input type="password" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-length="[6, 34]" placeholder="#{placeholder}" />
989
+ </div>
990
+ EOS
991
+ return tb
992
+ end
993
+
994
+ # Submit Helper
995
+ # @param label [String] submit button label
996
+ # @param css [String] submit button css
997
+ # @param icon [String] submit button icon
998
+ # @param size [String] submit button size
999
+ # @param wrapper_css [String] submit button wrapper css
1000
+ # @return [String] compiled html of submit button
1001
+ def x_submit(label: "Submit", css: "btn-primary", icon: "", size: "", wrapper_css: "pull-right")
1002
+
1003
+ if icon != ""
1004
+ icon = "<i class='fa #{icon}'></i> "
1005
+ end
1006
+
1007
+ submit = <<EOS
1008
+ <div class="form-group form-actions #{wrapper_css}">
1009
+ <button type="submit" class="btn #{css} #{size}">#{icon}#{label}</button>
1010
+ </div>
1011
+ <div class="clearfix"></div>
1012
+ EOS
1013
+
1014
+ return submit
1015
+ end
1016
+
1017
+
1018
+
1019
+ # Text Area Helper
1020
+ # @param id [String] textarea id
1021
+ # @param name [String] textarea name
1022
+ # @param value [String] textarea value
1023
+ # @param placeholder [String] textarea placeholder text
1024
+ # @param label [String] textarea label
1025
+ # @param required [Boolean] if required or not
1026
+ # @param maxlength [String] textarea max length
1027
+ # @return [String] compiled html of textarea
1028
+ def x_textarea(id: "", name: "", value: "",label: "",placeholder: "",required: false, maxlength:"")
1029
+
1030
+ if required
1031
+ if label != ""
1032
+ required_output = '<sup class="text-danger">*</sup>'
1033
+ else
1034
+ required_output = ''
1035
+ end
1036
+ required_tag = 'required="required"'
1037
+ else
1038
+ required_output = ""
1039
+ required_tag = ""
1040
+ end
1041
+
1042
+ if label != ""
1043
+ label = "<label for='#{id}'>#{label}</label>"
1044
+ end
1045
+
1046
+ if label != ""
1047
+ label = "<label for='#{id}'>#{label}</label>"
1048
+ end
1049
+
1050
+ if maxlength != ""
1051
+ maxlength = "maxlength='#{maxlength}'"
1052
+ end
1053
+
1054
+ ta = <<EOS
1055
+ <div class="form-group">
1056
+ #{label}#{required_output}
1057
+ <textarea name="post[#{name}]" id="#{id}" rows="4" class="form-control" placeholder="#{placeholder}" #{maxlength} #{required_tag}>#{value}</textarea>
1058
+ </div>
1059
+ EOS
1060
+ return ta
1061
+ end
1062
+
1063
+ # Summernote
1064
+ # @param id [String] summernote id
1065
+ # @param name [String] summernote name
1066
+ # @param value [String] summernote value
1067
+ # @param label [String] summernote label
1068
+ # @param required [Boolean] if required or not
1069
+ # @return [String] compiled html of summernote
1070
+ def x_html(id: "", name: "", value: "", label: "", help: "", required: false)
1071
+
1072
+ if required
1073
+ if label != ""
1074
+ required_output = '<sup class="text-danger">*</sup>'
1075
+ else
1076
+ required_output = ''
1077
+ end
1078
+ required_tag = 'required="required"'
1079
+ else
1080
+ required_output = ""
1081
+ required_tag = ""
1082
+ end
1083
+ if label != ""
1084
+ label = "<label for='#{id}'>#{label}</label>"
1085
+ end
1086
+ ta = <<EOS
1087
+ <div class="form-group">
1088
+ #{label}
1089
+ <textarea name="post[#{name}]" id="#{id}" rows="4" class="form-control summernote">#{value}</textarea>
1090
+ </div>
1091
+ EOS
1092
+ return ta
1093
+ end
1094
+
1095
+
1096
+
1097
+ # Year Drop down
1098
+ def x_year
1099
+ current_year = Time.now.year
1100
+
1101
+ year_dd = <<EOS
1102
+ <select id="selected_year" name="selected_year" class="selectpicker" data-style="btn-primary btn" data-width="auto">
1103
+ <option selected="selected" value="#{current_year}">#{current_year}</option>
1104
+ <option value="#{current_year - 1}">#{current_year - 1}</option>
1105
+ <option value="#{current_year - 2}">#{current_year - 2}</option>
1106
+ <option value="#{current_year - 3}">#{current_year - 3}</option>
1107
+ <option value="#{current_year - 4}">#{current_year - 4}</option>
1108
+ <option value="#{current_year - 5}">#{current_year - 5}</option>
1109
+ <option value="#{current_year - 6}">#{current_year - 6}</option>
1110
+ <option value="#{current_year - 7}">#{current_year - 7}</option>
1111
+ </select>
1112
+ EOS
1113
+ end
1114
+
1115
+
1116
+ # Year Drop down (expiry)
1117
+ def x_exp_year
1118
+ current_year = Time.now.year
1119
+ begining_year = Time.now.year + 6
1120
+
1121
+ year_dd = <<EOS
1122
+ <div class="col-md-6">
1123
+ <div class="form-group">
1124
+ <label>Expiration Year</label>
1125
+ <select id="exp_year" name="post[exp_year]" class="form-control" data-stripe="exp-year">
1126
+ <option value="#{(current_year)}">#{current_year}</option>
1127
+ <option value="#{(current_year + 1)}">#{current_year + 1}</option>
1128
+ <option value="#{(current_year + 2)}">#{current_year + 2}</option>
1129
+ <option value="#{(current_year + 3)}">#{current_year + 3}</option>
1130
+ <option value="#{(current_year + 4)}">#{current_year + 4}</option>
1131
+ <option value="#{(current_year + 5)}">#{current_year + 5}</option>
1132
+ <option value="#{(current_year + 6)}">#{current_year + 6}</option>
1133
+ <option value="#{(current_year + 7)}">#{current_year + 7}</option>
1134
+ </select>
1135
+ </div>
1136
+ </div>
1137
+ EOS
1138
+ end
1139
+
1140
+ # Month Drop down
1141
+ def x_exp_month
1142
+ current_year = Time.now.year
1143
+ begining_year = Time.now.year - 6
1144
+
1145
+ year_dd = <<EOS
1146
+ <div class="col-md-6">
1147
+ <div class="form-group">
1148
+ <label>Expiration Month</label>
1149
+ <select id="exp_mo" name="post[exp_mo]" class="form-control" data-stripe="exp-month">
1150
+ <option value="01">01</option>
1151
+ <option value="02">02</option>
1152
+ <option value="03">03</option>
1153
+ <option value="04">04</option>
1154
+ <option value="05">05</option>
1155
+ <option value="06">06</option>
1156
+ <option value="07">07</option>
1157
+ <option value="08">08</option>
1158
+ <option value="09">09</option>
1159
+ <option value="10">10</option>
1160
+ <option value="11">11</option>
1161
+ <option value="12">12</option>
1162
+ </select>
1163
+ </div>
1164
+ </div>
1165
+ EOS
1166
+ end
1167
+
1168
+ # Switch
1169
+ # @param id [String] summernote id
1170
+ # @param name [String] summernote name
1171
+ # @param value [String] summernote value
1172
+ # @param label [String] summernote label
1173
+ # @param checked [Boolen] if checked or not
1174
+ # @return [String] compiled html of summernote
1175
+ def x_switch(id: "", name: "", value: "", label: "", checked: false)
1176
+
1177
+ checked_output = ""
1178
+
1179
+ if checked == true then checked_output='checked="checked"' end
1180
+
1181
+ cb = <<EOS
1182
+ <div class="form-group">
1183
+ <label>#{label}</label><br>
1184
+ <div class="switch"
1185
+ data-on-label="<i class='fa fa-check'></i>"
1186
+ data-off-label="<i class='fa fa-times'></i>">
1187
+ <input type="hidden" id="#{id}" name="post[#{name}]" value="0">
1188
+ <input type="checkbox" id="#{id}" name="post[#{name}]" value="1" #{checked_output}/>
1189
+ </div>
1190
+ </div>
1191
+ EOS
1192
+ return cb
1193
+ end
1194
+
1195
+ # Tags
1196
+ # @param id [String] tags id
1197
+ # @param name [String] tags name
1198
+ # @param value [String] tags value
1199
+ # @param label [String] tags label
1200
+ # @param required [Boolean] if required or not
1201
+ # @param placeholder [String] tags placeholder text
1202
+ # @return [String] compiled html of tags
1203
+ def x_tags(id: "", name: "", value: "", label: "", required: false, placeholder: "")
1204
+
1205
+ id = name unless id != ""
1206
+ if required
1207
+ if label != ""
1208
+ required_output = '<sup class="text-danger">*</sup>'
1209
+ else
1210
+ required_output = ''
1211
+ end
1212
+ required_tag = 'required="required"'
1213
+ else
1214
+ required_output = ""
1215
+ required_tag = ""
1216
+ end
1217
+
1218
+ if label != ""
1219
+ label = "<label>#{label}</label>"
1220
+ end
1221
+ tb = <<EOS
1222
+ <div class="form-group">
1223
+ #{label}#{required_output}
1224
+ <input type="text" class="form-control tagsinput typeahead tag-azure tag-fill" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" #{required_tag}/>
1225
+ </div>
1226
+ EOS
1227
+ return tb
1228
+ end
1229
+
1230
+
1231
+ # Typeahead
1232
+ # @param id [String] typeahead id
1233
+ # @param name [String] typeahead name
1234
+ # @param value [String] typeahead value
1235
+ # @param label [String] typeahead label
1236
+ # @param required [Boolean] if required or not
1237
+ # @param placeholder [String] typeahead placeholder text
1238
+ # @param css [String] typeahead css
1239
+ # @return [String] compiled html of typeahead
1240
+ def x_typeahead(id: "", name: "", value: "", label: "", required: false, placeholder: "", css: "")
1241
+
1242
+ id = name unless id != ""
1243
+ if required
1244
+ if label != ""
1245
+ required_output = '<sup class="text-danger">*</sup>'
1246
+ else
1247
+ required_output = ''
1248
+ end
1249
+ required_tag = 'required="required"'
1250
+ else
1251
+ required_output = ""
1252
+ required_tag = ""
1253
+ end
1254
+
1255
+ if label != ""
1256
+ label = "<label>#{label}</label>"
1257
+ end
1258
+ tb = <<EOS
1259
+ <div class="form-group">
1260
+ #{label}#{required_output}
1261
+ <input type="text" class="form-control typeahead #{css}" autocomplete="off" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" #{required_tag}/>
1262
+ </div>
1263
+ EOS
1264
+ return tb
1265
+ end
1266
+
1267
+
1268
+ # Rating Radios
1269
+ # @param id [String] id of the survey radio
1270
+ # @param name [String] name of the survey radio
1271
+ # @return [String] compiled html of the survey radio
1272
+ def x_survey_radio(id: "", name: "")
1273
+ tb = <<EOS
1274
+ <label class="radio radio-inline">
1275
+ <input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="1">
1276
+ </label>
1277
+ <label class="radio radio-inline">
1278
+ <input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="2">
1279
+ </label>
1280
+ <label class="radio radio-inline">
1281
+ <input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="3">
1282
+ </label>
1283
+ <label class="radio radio-inline">
1284
+ <input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="4">
1285
+ </label>
1286
+ <label class="radio radio-inline">
1287
+ <input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="5">
1288
+ </label>
1289
+ <label class="radio radio-inline">
1290
+ <input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="6">
1291
+ </label>
1292
+ <label class="radio radio-inline">
1293
+ <input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="7">
1294
+ </label>
1295
+ EOS
1296
+ return tb
1297
+ end
1298
+
1299
+
1300
+ # Select Dropdown
1301
+ # @param id [String] id of the select
1302
+ # @param name [String] name of the select
1303
+ # @param value [String] value of the select
1304
+ # @param name_col [String] name col of the select
1305
+ # @param value_col [String] vale col of the select
1306
+ # @param label [String] label of the select
1307
+ # @param css [String] css of the select
1308
+ # @param menu_style [String] menu syle of the select
1309
+ # @param style [String] style classes of the select
1310
+ # @param option_data [String] option data
1311
+ # @param option_name [String] option name
1312
+ # @param option_value [String] option value
1313
+ # @param selected_value [String] selected value of the select
1314
+ # @param title [String] title of the select
1315
+ # @param multple [Boolean] if multiple selection is enabled
1316
+ # @return [String] compiled select drop down
1317
+ def x_select(id: "", name: "", value: "",name_col: "name", value_col: "id", label: "", css: "selectpicker", menu_style: "dropdown-blue", style: "btn-default btn-block", option_data: "", option_name: "name", option_value: "id", selected_value: "", title: "", multiple: false, add_none: false, required: false, menu_size: 0, live_search: false)
1318
+
1319
+ options_html = ""
1320
+ show_multiple = ""
1321
+ add_none_option = ""
1322
+ live_search_html = ""
1323
+
1324
+ if multiple == true
1325
+ show_multiple = "Multiple"
1326
+ end
1327
+
1328
+ if required
1329
+ if label != ""
1330
+ required_output = '<sup class="text-danger">*</sup>'
1331
+ else
1332
+ required_output = ''
1333
+ end
1334
+ required_tag = 'required="required"'
1335
+ else
1336
+ required_output = ""
1337
+ required_tag = ""
1338
+ end
1339
+
1340
+ multiple_name = ""
1341
+ if multiple == true
1342
+ multiple_name = "[]"
1343
+ end
1344
+
1345
+ option_data.each do |i|
1346
+ selected = ""
1347
+
1348
+ if selected_value == i[:id]
1349
+ selected = "selected='selected'"
1350
+ end
1351
+
1352
+ if selected_value.kind_of?(Array) && (selected_value.include? i[:id])
1353
+ selected = "selected='selected'"
1354
+ end
1355
+
1356
+ unless name_col.kind_of?(Array)
1357
+ options_html << "<option value='#{i[value_col.to_sym]}' #{selected}>#{i[name_col.to_sym]}</option>"
1358
+ else
1359
+
1360
+ options_html << "<option value='#{i[value_col.to_sym]}' #{selected}>"
1361
+ name_col.each do |n|
1362
+ options_html << "#{i[n.to_sym]} "
1363
+ end
1364
+ options_html << "</option>"
1365
+
1366
+ end
1367
+ end
1368
+
1369
+ if option_data.count == 0 || option_data.nil?
1370
+ options_html << "<option value=''>No available selections</option>"
1371
+ end
1372
+
1373
+ if add_none == true
1374
+ add_none_option = "<option value=''>Select One</option>"
1375
+ end
1376
+
1377
+ if menu_size == 0
1378
+ menu_size_html = ""
1379
+ else
1380
+ menu_size_html = "data-size='#{menu_size}'"
1381
+ end
1382
+
1383
+ if live_search == true
1384
+ live_search_html = "data-live-search='true'"
1385
+ end
1386
+
1387
+ select = <<EOS
1388
+ <div class="form-group">
1389
+ <label>#{label}#{required_output}</label>
1390
+ <select id="#{id}" name="post[#{name}]#{multiple_name}" class="#{css}" data-title="#{title}" title="#{title}" data-style="#{style}" data-menu-style="#{menu_style}" #{show_multiple} #{required_tag} #{menu_size_html} data-container=".content" #{live_search_html}>
1391
+ #{add_none_option}
1392
+ #{options_html}
1393
+ </select>
1394
+ </div>
1395
+ EOS
1396
+
1397
+ return select
1398
+
1399
+ end
1400
+ end
1401
+ end