jqajax_core2 0.0.9
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.
- checksums.yaml +7 -0
- data/app/assets/javascripts/jqac2/core.js.coffee.erb +109 -0
- data/app/assets/javascripts/jqac2/helpers.js.coffee.erb +52 -0
- data/app/assets/javascripts/jqac2/initializer.js.coffee.erb +30 -0
- data/app/assets/javascripts/jqac2/loading.js.coffee.erb +58 -0
- data/app/assets/javascripts/jqac2/modal.js.coffee.erb +83 -0
- data/app/assets/javascripts/jqac2/validation.js.coffee.erb +244 -0
- data/app/assets/javascripts/jqac2/widget_classes/checkbox_slidedown.coffee +33 -0
- data/app/assets/javascripts/jqac2/widgets.js.coffee +27 -0
- data/app/assets/javascripts/jqajax-core2.js.erb +8 -0
- data/app/assets/stylesheets/jqajax-core2.scss.erb +54 -0
- data/app/assets/stylesheets/jqajax2-variables.scss +10 -0
- data/app/controllers/jqac2_controller.rb +9 -0
- data/app/helpers/jqajax_core_helper.rb +139 -0
- data/app/helpers/jqajax_validation_helper.rb +76 -0
- data/app/helpers/jqajax_view_helper.rb +29 -0
- data/app/views/jqajax/_flash.html.erb +9 -0
- data/app/views/jqajax/_loader.html.erb +4 -0
- data/app/views/jqajax/_modal.html.erb +14 -0
- data/app/views/jqajax/_overlay.html.erb +11 -0
- data/app/views/layouts/_ajax_overlay.html.erb +5 -0
- data/app/views/layouts/_info_overlay.html.erb +9 -0
- data/app/views/layouts/jqac2_modal.html.erb +9 -0
- data/config/locales/jqac2.validations.de.yml +12 -0
- data/config/routes.rb +10 -0
- data/lib/jqajax_core2/application_controller_ext.rb +17 -0
- data/lib/jqajax_core2/config.rb +31 -0
- data/lib/jqajax_core2/engine.rb +10 -0
- data/lib/jqajax_core2/validations.rb +147 -0
- data/lib/jqajax_core2.rb +107 -0
- metadata +159 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
@import "jqajax2-variables";
|
2
|
+
|
3
|
+
#<%= JqajaxCore2::Config.overlay[:div_id] %> {
|
4
|
+
position: fixed; z-index: 5000;
|
5
|
+
top: 0; left: 0;
|
6
|
+
background: $jqac2-overlay-bg-color;
|
7
|
+
|
8
|
+
|
9
|
+
.overlay-content-box {
|
10
|
+
background: #fff;
|
11
|
+
padding: 12px;
|
12
|
+
border: solid 1px #ddd;
|
13
|
+
text-align: center;
|
14
|
+
max-width: 200px;
|
15
|
+
cursor: pointer;
|
16
|
+
position: fixed;
|
17
|
+
z-index: 5001;
|
18
|
+
|
19
|
+
.overlay-loader {
|
20
|
+
margin-bottom: 5px;
|
21
|
+
}
|
22
|
+
|
23
|
+
.overlay-title {
|
24
|
+
margin-bottom: 12px;
|
25
|
+
}
|
26
|
+
|
27
|
+
.overlay-link {
|
28
|
+
font-size: 10px;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
#<%= JqajaxCore2::Config.loading[:flash_area_div] %> {
|
34
|
+
|
35
|
+
position: fixed; max-width: 400px; z-index: 10001;
|
36
|
+
|
37
|
+
<% if JqajaxCore2::Config.loading[:flash_area_position] == :bottom_left %>
|
38
|
+
left: $jqac2-flash-x-space; bottom: $jqac2-flash-y-space;
|
39
|
+
<% elsif JqajaxCore2::Config.loading[:flash_area_position] == :bottom_right %>
|
40
|
+
right: $jqac2-flash-x-space; bottom: $jqac2-flash-y-space;
|
41
|
+
<% elsif JqajaxCore2::Config.loading[:flash_area_position] == :top_left %>
|
42
|
+
left: $jqac2-flash-x-space; top: $jqac2-flash-y-space;
|
43
|
+
<% elsif JqajaxCore2::Config.loading[:flash_area_position] == :top_right %>
|
44
|
+
right: $jqac2-flash-x-space; top: $jqac2-flash-y-space;
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
.jqac2-notify { background: #fff; padding: .5em 1em; -moz-border-radius: 5px; border-radius: 5px; }
|
48
|
+
.jqac2-notify.ok { border: solid 2px $jqac2-flash-ok; }
|
49
|
+
.jqac2-notify.error { border: solid 2px $jqac2-flash-error; }
|
50
|
+
.jqac2-notify.neutral { border: solid 2px $jqac2-flash-neutral; }
|
51
|
+
|
52
|
+
}
|
53
|
+
|
54
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
// Defining style for the loading overlay
|
2
|
+
$jqac2-overlay-bg-color: rgba(255,255,255, 0.7);
|
3
|
+
|
4
|
+
// Position and style for flash overlay
|
5
|
+
$jqac2-flash-y-space: 20px ;
|
6
|
+
$jqac2-flash-x-space: 20px ;
|
7
|
+
|
8
|
+
$jqac2-flash-error: red;
|
9
|
+
$jqac2-flash-ok: green;
|
10
|
+
$jqac2-flash-neutral: orange;
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module JqajaxCoreHelper
|
3
|
+
|
4
|
+
|
5
|
+
#== New and shiny polished Rails 3.2 Ajax Helper Functions
|
6
|
+
|
7
|
+
# Default Ajax Link for Links
|
8
|
+
def default_ajax_link(options ={})
|
9
|
+
link_data = init_link_data(options)
|
10
|
+
|
11
|
+
link_data.merge!(:title => options[:title])
|
12
|
+
options[:class] ||= ""
|
13
|
+
options[:class] << " #{JqajaxCore2::Config.core[:ajax_link_class]} #{JqajaxCore2::Config.core[:no_ajax_link_class]}"
|
14
|
+
|
15
|
+
if options[:append] == true
|
16
|
+
link_data.merge!(JqajaxCore2::Config.html_data[:append] => true)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Load-Message setzen: Entweder default oder eigene Nachricht
|
20
|
+
if options[:load_message] && (options[:load_message] != false && !options[:load_message].blank?)
|
21
|
+
options[:class] << " #{AJAX_LOAD_MESSAGE_TRIGGER}"
|
22
|
+
if options[:load_message].is_a?(String)
|
23
|
+
link_data.merge!(JqajaxCore2::Config.loading[:load_message].to_s => options[:load_message])
|
24
|
+
end
|
25
|
+
elsif options[:load_message] == false
|
26
|
+
options[:class] << " #{AJAX_HIDE_LOAD_MESSAGE_SELECTOR}"
|
27
|
+
end
|
28
|
+
|
29
|
+
link_data.merge!(html_defaults_from_options(options))
|
30
|
+
|
31
|
+
return link_data
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
def select_onchange_data(options ={})
|
36
|
+
link_data = init_link_data(options)
|
37
|
+
|
38
|
+
link_data.merge!(:disabled => options[:disabled])
|
39
|
+
options[:class] ||= ""
|
40
|
+
options[:class] << " #{JqajaxCore2::Config.core[:select_onchange_selector]} #{JqajaxCore2::Config.core[:no_ajax_link_class]}"
|
41
|
+
|
42
|
+
options[:with] ||= :id
|
43
|
+
|
44
|
+
options[:url].merge!(options[:with] => JqajaxCore2::Config.core[:url_placeholder])
|
45
|
+
|
46
|
+
url_scope = options[:scope].nil? ? main_app : options[:scope]
|
47
|
+
|
48
|
+
link_data.merge!(JqajaxCore2::Config.html_data[:target_url].to_s => url_scope.url_for(options[:url]))
|
49
|
+
|
50
|
+
# Load-Message setzen: Entweder default oder eigene Nachricht
|
51
|
+
if options[:load_message] && (options[:load_message] != false && !options[:load_message].blank?)
|
52
|
+
options[:class] << " #{AJAX_LOAD_MESSAGE_TRIGGER}"
|
53
|
+
if options[:load_message].is_a?(String)
|
54
|
+
link_data.merge!(JqajaxCore2::Config.loading[:load_message].to_s => options[:load_message])
|
55
|
+
end
|
56
|
+
elsif options[:load_message] == false
|
57
|
+
options[:class] << " #{AJAX_HIDE_LOAD_MESSAGE_SELECTOR}"
|
58
|
+
end
|
59
|
+
|
60
|
+
link_data.merge!(html_defaults_from_options(options))
|
61
|
+
|
62
|
+
return link_data
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
# Creates a box that slides down and up to show/hide the content.
|
68
|
+
# * Use ':open => true' to set the box open by default
|
69
|
+
# * Use ':default_class => "className"' to set the class used for the header
|
70
|
+
def slide_down_box(title, options = {:open => false}, &block)
|
71
|
+
options[:default_class] ||= "icon-arrow-right"
|
72
|
+
options[:type] ||= :div
|
73
|
+
|
74
|
+
|
75
|
+
box_session_id = Digest::SHA1.hexdigest("#{params[:action]}-#{title}")
|
76
|
+
|
77
|
+
open = options[:open] #|| (session[:slidedown_boxes_open].include?(box_session_id) rescue false)
|
78
|
+
|
79
|
+
concat raw("<div class='js-slide-down-box plain #{'open' if open} #{options[:box_class]} #{options[:class]}' data-session-id='#{box_session_id}'>
|
80
|
+
<#{options[:type]} class='#{options[:default_class]} js-slidedown-button'>
|
81
|
+
#{title}
|
82
|
+
</#{options[:type]}>
|
83
|
+
<div class='js-slidedown-content'>")
|
84
|
+
yield
|
85
|
+
concat raw("</div></div>")
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
def init_slidedown
|
91
|
+
raw("<script type='text/javascript'>init_slidedown();</script>")
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def init_link_data(options = {})
|
98
|
+
link_data = {:remote => true }
|
99
|
+
link_data.merge!(:method => options[:method]) if options[:method]
|
100
|
+
link_data.merge!(update_div_from_options(options))
|
101
|
+
link_data.merge!(submit_from_options(options))
|
102
|
+
link_data.merge!(callback_from_options(options))
|
103
|
+
link_data.merge!(confirm_message_from_options(options))
|
104
|
+
return link_data
|
105
|
+
end
|
106
|
+
|
107
|
+
def confirm_message_from_options(options = {})
|
108
|
+
# Confirm-Message setzen: Entweder default, oder eigene Nachricht
|
109
|
+
if options[:confirm]
|
110
|
+
{ JqajaxCore2::Config.html_data[:confirm] => (options[:confirm] == true ? JqajaxCore2::Config.core[:confirm_default] : options[:confirm].to_s )}
|
111
|
+
else
|
112
|
+
return {}
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def callback_from_options(options = {})
|
117
|
+
options[:callback] ? {JqajaxCore2::Config.html_data[:callback] => options[:callback]} : {}
|
118
|
+
end
|
119
|
+
|
120
|
+
def submit_from_options(options = {})
|
121
|
+
options[:submit] ? {
|
122
|
+
JqajaxCore2::Config.html_data[:submit_data] => options[:submit],
|
123
|
+
:method => "POST"
|
124
|
+
} : {}
|
125
|
+
end
|
126
|
+
|
127
|
+
def update_div_from_options(options = {})
|
128
|
+
options[:update] ? { JqajaxCore2::Config.core[:update_div] => options[:update]} : {}
|
129
|
+
end
|
130
|
+
|
131
|
+
def html_defaults_from_options(options = {})
|
132
|
+
l = {}
|
133
|
+
l.merge!(:class => options[:class])
|
134
|
+
l.merge!(:id => options[:id])
|
135
|
+
l.merge!(:style => options[:style])
|
136
|
+
return l
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module JqajaxValidationHelper
|
2
|
+
|
3
|
+
def jqac2_validation_for(*vtypes)
|
4
|
+
if vtypes.last.is_a?(Hash)
|
5
|
+
options = vtypes.last
|
6
|
+
vtypes.pop
|
7
|
+
else
|
8
|
+
options = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
current_data_attributes = options.delete(:data) || {}
|
12
|
+
|
13
|
+
# if a custom class for the form field wrapper is required....
|
14
|
+
current_data_attributes.merge!(wrapper_class: options[:wrapper_class]) if options[:wrapper_class]
|
15
|
+
|
16
|
+
# validierungsoptionen
|
17
|
+
if options[:validator_options]
|
18
|
+
options[:validator_options].each do |opt, val|
|
19
|
+
options.merge!(jqac2_data_attribute_for(opt) => val)
|
20
|
+
end
|
21
|
+
options.delete(:validator_options)
|
22
|
+
end
|
23
|
+
|
24
|
+
data_messages = []
|
25
|
+
if options[:hint]
|
26
|
+
data_messages << options[:hint]
|
27
|
+
end
|
28
|
+
|
29
|
+
vtypes.each do |vtype|
|
30
|
+
if JqajaxCore2::Validations.settings[vtype.to_sym]
|
31
|
+
options.merge!(:class => [options[:class], JqajaxCore2::Validations.settings[vtype.to_sym][:class]].compact.join(" "))
|
32
|
+
if I18n.exists?("jqac2.validations.hints.#{vtype}") && options[:show_hint] == true
|
33
|
+
data_messages << I18n.t("jqac2.validations.hints.#{vtype}")
|
34
|
+
end
|
35
|
+
elsif vtype.nil?
|
36
|
+
options
|
37
|
+
else
|
38
|
+
raise ArgumentError, "Validation of type #{vtype} is not known"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
if data_messages.any?
|
43
|
+
current_data_attributes.merge!(validation_messages: data_messages.compact.join(";"))
|
44
|
+
end
|
45
|
+
|
46
|
+
return options.merge(data: current_data_attributes)
|
47
|
+
end
|
48
|
+
|
49
|
+
def jqac2_validation_class_for(*vtypes)
|
50
|
+
css = []
|
51
|
+
vtypes.each do |vtype|
|
52
|
+
if !vtype.nil?
|
53
|
+
if JqajaxCore2::Validations.settings[vtype.to_sym]
|
54
|
+
css << JqajaxCore2::Validations.settings[vtype.to_sym][:class]
|
55
|
+
else
|
56
|
+
raise ArgumentError, "Validation of type #{vtype} is not known"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
return css.join(" ")
|
62
|
+
end
|
63
|
+
|
64
|
+
def jqac2_validate_form
|
65
|
+
JqajaxCore2::Validations.form_validation_class
|
66
|
+
end
|
67
|
+
|
68
|
+
def jqac2_data_attribute_for(m="bla")
|
69
|
+
"data-#{JqajaxCore2::Validations.data_prefix}-#{m.to_s.dasherize}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def init_jqac2_validator
|
73
|
+
javascript_tag("JqAjaxCore2.Validation.initForms()")
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module JqajaxViewHelper
|
2
|
+
|
3
|
+
|
4
|
+
def include_jqajax_overlay
|
5
|
+
render :partial => "/jqajax/overlay"
|
6
|
+
end
|
7
|
+
|
8
|
+
def include_jqajax_flash
|
9
|
+
render :partial => "/jqajax/flash"
|
10
|
+
end
|
11
|
+
|
12
|
+
def include_jqajax_core(*elements)
|
13
|
+
elements = %w(overlay flash) if elements.empty?
|
14
|
+
|
15
|
+
elements.each do |e|
|
16
|
+
concat(self.send("include_jqajax_#{e}"))
|
17
|
+
end
|
18
|
+
return nil
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
def jqajax_modal(options = {}, &block)
|
24
|
+
options[:draggable] = JqajaxCore2::Config.modal[:draggable]
|
25
|
+
render "/jqajax/modal", :options => options, :content => capture(&block)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%# flash[:notice] & flash[:error] display %>
|
2
|
+
<div id="<%= JqajaxCore2::Config.loading[:flash_area_div] %>" class="">
|
3
|
+
<% if !flash[:notice].blank? %>
|
4
|
+
<%= javascript_tag("JqAjaxCore2.Loading.flashNoticeDisplay('#{flash[:notice]}', 'ok')") %>
|
5
|
+
<% end %>
|
6
|
+
<% if !flash[:error].blank? %>
|
7
|
+
<%= javascript_tag("JqAjaxCore2.Loading.flashNoticeDisplay('#{flash[:error]}', 'error')") %>
|
8
|
+
<% end %>
|
9
|
+
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% id = "I#{Digest::SHA1.hexdigest(params.inspect)}" %>
|
2
|
+
<div class="<%= JqajaxCore2::Config.modal[:css_class] %> rounded" id="<%= id %>">
|
3
|
+
<%= image_tag JqajaxCore2::Config.modal[:close_icon_img], :class => "close-link", :onclick => "JqAjaxCore2.Modal.hideModal('#{id}')" %>
|
4
|
+
<div class="info-overlay-content">
|
5
|
+
<%= content %>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
JqAjaxCore2.Modal.initModal('<%= id %>')
|
11
|
+
<% if options[:draggable] %>
|
12
|
+
JqAjaxCore2.Modal.setModalDraggable('<%= id %>')
|
13
|
+
<% end %>
|
14
|
+
</script>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%# Default content Container %>
|
2
|
+
<div id="<%= JqajaxCore2::Config.core[:ajax_content_container_id] %>"></div>
|
3
|
+
|
4
|
+
<%# Loading Overlayer %>
|
5
|
+
<div id="<%= JqajaxCore2::Config.overlay[:div_id] %>" style="display:none">
|
6
|
+
<div class="overlay-content-box" onmousedown="JqAjaxCore2.Loading.hideLoading();">
|
7
|
+
<div class="overlay-loader"><%= image_tag(JqajaxCore2::Config.loading[:loader_img]) %></div>
|
8
|
+
<div class="overlay-title"><%= JqajaxCore2::Config.overlay[:info_text] %></div>
|
9
|
+
<%= link_to JqajaxCore2::Config.overlay[:hide_label], "#", :class => "overlay-link" %>
|
10
|
+
</div>
|
11
|
+
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% id = "I#{Digest::SHA1.hexdigest(params.inspect)}" %>
|
2
|
+
<div class="<%= JqajaxCore2::Config.modal[:css_class] %> rounded" id="<%= id %>">
|
3
|
+
<%= image_tag "icons/icon-close.png", :class => "close-link", :onclick => "$('##{id}').slideUp(200);" %>
|
4
|
+
<div class="info-overlay-content">
|
5
|
+
<%= yield %>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<%= render :partial => '/layouts/overlay_js', :locals => {:mode => :info, :id => id} %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% id = "I#{Digest::SHA1.hexdigest(params.inspect)}" %>
|
2
|
+
<div class="<%= JqajaxCore2::Config.modal[:css_class] %> rounded" id="<%= id %>">
|
3
|
+
<%= image_tag "icons/icon-close.png", :class => "close-link", :onclick => "$('##{id}').slideUp(200);" %>
|
4
|
+
<div class="info-overlay-content">
|
5
|
+
<%= yield %>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
de:
|
2
|
+
jqac2:
|
3
|
+
validations:
|
4
|
+
hints:
|
5
|
+
phone_int: 'Telefonnummer im intl. Format: +xx xxx...'
|
6
|
+
letters_only: 'Nur Buchstaben (A-Z) und Leerzeichen'
|
7
|
+
alphanumeric: 'Nur Buchstaben (A-Z), Zahlen (0-9) und Leerzeichen'
|
8
|
+
zip: 'Postleitzahl, 4-5-stellige Nummer, führende "0" erlaubt'
|
9
|
+
date: 'Datum im Format TT.MM.JJJJ'
|
10
|
+
datemonth: 'Datum im Format MM.JJJJ'
|
11
|
+
datetime: 'Datum/Uhrzeit im Format DD.MM.YYYY HH:MM'
|
12
|
+
required: 'Pflichtfeld'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
JqAjaxCore2::Engine.routes.draw do
|
3
|
+
|
4
|
+
#=== AJAX Routing
|
5
|
+
# Ajax Routen immer in Klartext, da diese auch in JS manuell verwendet werden.
|
6
|
+
get "/jqca2/jqac2_flash", :controller => "jqac2", :action => "json_flash_data"
|
7
|
+
#get "/jqca2/auto_complete", :controller => "ajax", :action => "auto_complete"
|
8
|
+
#get "/jqca2/save_slidedown_box/:id", :controller => "ajax", :action => "save_slidedown_box"
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module JqajaxCore2
|
2
|
+
module ApplicationControllerExt
|
3
|
+
|
4
|
+
def render_blank_ajax
|
5
|
+
render :text => nil, :status => 200, :content_type => "text/html"
|
6
|
+
end
|
7
|
+
|
8
|
+
def ajax_layout(layout_name="info_overlay")
|
9
|
+
render :layout => layout_name if request.xhr?
|
10
|
+
end
|
11
|
+
|
12
|
+
def ajax_text(text)
|
13
|
+
render :text => text.html_safe, :status => 200, :content_type => "text/html"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module JqajaxCore2
|
2
|
+
class Config
|
3
|
+
|
4
|
+
#= Core Setting
|
5
|
+
cattr_accessor :core, :prefix
|
6
|
+
self.core = {}
|
7
|
+
|
8
|
+
#= HTML Data-Attributes
|
9
|
+
# Naming of the HTML data-attributes for the link element config
|
10
|
+
cattr_accessor :html_data
|
11
|
+
self.html_data = {}
|
12
|
+
|
13
|
+
#= Overlay and Loading Settings
|
14
|
+
# Config for loading overlay, flash notifiers etc.
|
15
|
+
cattr_accessor :overlay, :loading
|
16
|
+
self.overlay = {}
|
17
|
+
self.loading = {}
|
18
|
+
|
19
|
+
#= Modal Settings
|
20
|
+
# Config for appearance and behavior of modal dialog
|
21
|
+
cattr_accessor :modal
|
22
|
+
self.modal = {}
|
23
|
+
|
24
|
+
def self.initialize
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
module JqajaxCore2
|
2
|
+
class Validations
|
3
|
+
|
4
|
+
cattr_accessor :settings, :checkbox_validation_class, :skip_validation_class, :form_validation_class, :prefix, :data_prefix, :error_description_class, :validation_description_class
|
5
|
+
|
6
|
+
self.prefix = "#{JqajaxCore2::Config.prefix}-vld"
|
7
|
+
self.data_prefix = "data-#{JqajaxCore2::Config.prefix}"
|
8
|
+
|
9
|
+
# Defition der Verüfgbaren validierungen:
|
10
|
+
# - Ist :regexp gesetzt, wird automatisch eine Validierungsfunktion für die Regexp in JS angelegt
|
11
|
+
# bei fehler wird die :message zurückgegeben
|
12
|
+
# - Ist keine Regexp angegeben muss eine Funktion manuell erstellt werden
|
13
|
+
|
14
|
+
self.settings = {
|
15
|
+
|
16
|
+
:email => {
|
17
|
+
:class => "#{self.prefix}-email-validation",
|
18
|
+
:regexp => '/[a-zA-Z0-9\.\-_]{1,}@[a-zA-Z0-9\.\-_]{1,}\.[a-zA-Z0-9\.\-_]{2,4}/',
|
19
|
+
:message => "Keine gültige E-Mail-Adresse"
|
20
|
+
},
|
21
|
+
|
22
|
+
:phone => {
|
23
|
+
:class => "#{self.prefix}-phone-validation",
|
24
|
+
:regexp => '/[0-9+]{1,}[0-9\ \/]{1,}/',
|
25
|
+
:message => "Keine gültige Telefonnummer"
|
26
|
+
},
|
27
|
+
|
28
|
+
:phone_int => {
|
29
|
+
:class => "#{self.prefix}-phone-int-validation",
|
30
|
+
:regexp => '/\+[1-9]{1}[0-9]{1,3}\ ?[0-9\ ]{1,}/',
|
31
|
+
:message => "Keine gültige Telefonnummer (Format +xx xxx...)"
|
32
|
+
},
|
33
|
+
|
34
|
+
:letters_only => {
|
35
|
+
class: "#{self.prefix}-letters-validation",
|
36
|
+
regexp: '/^[A-z\ ]+$/',
|
37
|
+
message: "Nur Buchstaben und Leerzeichen"
|
38
|
+
},
|
39
|
+
|
40
|
+
:alphanumeric => {
|
41
|
+
class: "#{self.prefix}-alphanum-validation",
|
42
|
+
regexp: '/^[A-z0-9\ ]+$/',
|
43
|
+
message: "Nur Buchstaben, Zahlen und Leerzeichen"
|
44
|
+
},
|
45
|
+
|
46
|
+
:zip => {
|
47
|
+
:class => "#{self.prefix}-zip-validation",
|
48
|
+
:regexp => '/[0-9]{4,5}/',
|
49
|
+
:message => "Ungültige PLZ"
|
50
|
+
},
|
51
|
+
|
52
|
+
:number => {
|
53
|
+
:class => "#{self.prefix}-nr-validation",
|
54
|
+
:regexp => '/[0-9\ ]{1,}/',
|
55
|
+
:message => "Ungültige Zahl",
|
56
|
+
},
|
57
|
+
|
58
|
+
:currency => {
|
59
|
+
:class => "#{self.prefix}-currency-validation",
|
60
|
+
:regexp => '/[0-9\.\,0]{1,}/',
|
61
|
+
:message => "Ungültige Eingabe",
|
62
|
+
},
|
63
|
+
|
64
|
+
#== Validations for dates etc...
|
65
|
+
:date => {
|
66
|
+
:class => "#{self.prefix}-date-validation",
|
67
|
+
# TODO: Regexp does not catch fake dates like 99.99.9999
|
68
|
+
:regexp => "/([0-9]{2}\.[0-9]{2}\.[0-9]{4})|([0-9]{4}-[0-9]{2}-[0-9]{2})/",
|
69
|
+
:message => "Ungültiges Datum"
|
70
|
+
},
|
71
|
+
|
72
|
+
:datemonth => {
|
73
|
+
:class => "#{self.prefix}-date-month-validation",
|
74
|
+
:regexp => "/[0-9]{2}\.[0-9]{4}/",
|
75
|
+
:message => "Ungültiges Format (MM.JJJJ)",
|
76
|
+
},
|
77
|
+
|
78
|
+
:datetime => {
|
79
|
+
:class => "#{self.prefix}-datetime-validation",
|
80
|
+
:regexp => "/[0-9]{2}\.[0-9]{2}\.[0-9]{4}\ [0-9]{2}\:[0-9]{2}/",
|
81
|
+
:message => "Ungültiges Format (DD.MM.YYYY HH:MM)",
|
82
|
+
},
|
83
|
+
|
84
|
+
#:date_in_future => {
|
85
|
+
# :class => "#{self.prefix}-date-in-future-validation",
|
86
|
+
# :message => "Datum darf nicht in der Vergangenheit liegen",
|
87
|
+
#}
|
88
|
+
#
|
89
|
+
#:date_min_age => {
|
90
|
+
# :class => "#{self.prefix}-date-min-ag-validation",
|
91
|
+
# :data => {:min_age => 18}
|
92
|
+
# :message => "Ungültiges Geburtsdatum",
|
93
|
+
#}
|
94
|
+
|
95
|
+
|
96
|
+
#== Validations for Passwords, Confirmation etc...
|
97
|
+
|
98
|
+
:password_simple => {
|
99
|
+
:class => "#{self.prefix}-simple-pass-validation",
|
100
|
+
# Data-Attributes used by the method, and their default values
|
101
|
+
:data => {:length => 6},
|
102
|
+
:message => "Min. [Length] Zeichen, min. Buchstaben und Zahlen"
|
103
|
+
|
104
|
+
},
|
105
|
+
|
106
|
+
:confirmation => {
|
107
|
+
:class => "#{self.prefix}-confirmation",
|
108
|
+
:data => {:confirm_field => "", :confirm_name => ""},
|
109
|
+
:message => "Bestätigung von [ConfirmName] stimmt nicht überein"
|
110
|
+
},
|
111
|
+
|
112
|
+
:exact => {
|
113
|
+
:class => "#{self.prefix}-exact-validation",
|
114
|
+
:data => {:value => ""},
|
115
|
+
:message => "Eingabe ungültig"
|
116
|
+
},
|
117
|
+
|
118
|
+
:length => {
|
119
|
+
:class => "#{self.prefix}-length-validation",
|
120
|
+
:data => {:length => 0},
|
121
|
+
:message => "[Length] Zeichen"
|
122
|
+
},
|
123
|
+
|
124
|
+
:required => {
|
125
|
+
:class => "#{self.prefix}-required-validation",
|
126
|
+
:regexp => '/[a-zA-Z0-9]{1,}/',
|
127
|
+
:empty => false,
|
128
|
+
:message => "Pflichtfeld"
|
129
|
+
},
|
130
|
+
|
131
|
+
:from_service => {
|
132
|
+
:class => "#{self.prefix}-from-service",
|
133
|
+
:data => {:url => "#", :additional_values => {}.to_json }
|
134
|
+
},
|
135
|
+
|
136
|
+
:none => {
|
137
|
+
class: "#{self.prefix}-none"
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
self.checkbox_validation_class = "#{self.prefix}-validate-checkbox"
|
142
|
+
self.skip_validation_class = "#{self.prefix}-skip-validation"
|
143
|
+
self.form_validation_class = "#{self.prefix}-form-validation"
|
144
|
+
self.error_description_class = "error-description"
|
145
|
+
self.validation_description_class = "validation-description"
|
146
|
+
end
|
147
|
+
end
|