jqajax_core2 0.0.9 → 0.0.81

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c33f2459d45b3e3b72d1733224c92a3b27029a1b
4
- data.tar.gz: 7f00bf6b9b0aa00d5507064ff1a68c2c00a5b2a4
3
+ metadata.gz: c85b0bac54c45a89c23afdf274c4a394f7166fa3
4
+ data.tar.gz: 06ad4ba0ebf8913372cde586075f302b98c54b92
5
5
  SHA512:
6
- metadata.gz: '09d2abfff9674248ed7e375df4a817e293f0301e0d2a00188faa7f6e942a2c4ba034575317cbbbd8d5eb771d8208c4e8a8c931b82a0de348c3036e91af64748a'
7
- data.tar.gz: d9dcb7f5e0777cb17da6715daf94018a25e46c660aaa6412cd19c9a8f3c7b28f6584d56ff2bf5db2370e12f13a9393989b91d76f45839faa7c822d1dc8850a59
6
+ metadata.gz: 578e43be907c9039b8f604f76156f5c915cc848fec44250d87a8b971074662bae1b1eb8f1752bbd5128f120ca5573a00b822880c24a2d955f2426b136ac619f6
7
+ data.tar.gz: 23b469eb66a26d5f1c1c279839c8015d0e508153ad9fc94c744ccf7db52282184b20b1d8bb8dd8842f640dececed91ffc4a6b768a3e022218ef2667e6953fa5d
@@ -1,31 +1,27 @@
1
- window.JqAjaxCore2= {} if typeof(window.JqAjaxCore2) is 'undefined'
2
1
  window.JqAjaxCore2.Helpers =
3
2
 
4
3
  linkOptionsFromElement: (item) =>
5
4
  # Item is passed as $() object
6
5
  item = $(item)
7
6
  link_options = {};
8
-
7
+
9
8
  link_options['target_div'] = item.attr('<%= JqajaxCore2::Config.core[:update_div] %>') || '<%= JqajaxCore2::Config.core[:ajax_content_container_id] %>'
10
9
  link_options['load_message'] = item.attr('<%= JqajaxCore2::Config.loading[:load_message] %>') || ''
11
10
  link_options['submit_data'] = item.attr('<%= JqajaxCore2::Config.html_data[:submit_data] %>') || ''
12
11
  link_options['callback'] = item.attr('<%= JqajaxCore2::Config.html_data[:callback] %>') || ''
13
12
  link_options['append'] = item.attr('<%= JqajaxCore2::Config.html_data[:append] %>') ? true : false
14
-
15
- # Checking for confirmation
13
+
14
+ # Checking for confirmation
16
15
  link_options['confirm_message'] = (item.attr('<%= JqajaxCore2::Config.html_data[:confirm] %>') || '')
17
16
  link_options['confirm'] = link_options['confirm_message'] != ''
18
-
17
+
19
18
  return link_options
20
-
19
+
21
20
 
22
21
  # Element ausblenden - verwendung als Callback nach löschen etc...
23
22
  hideItem: (id) ->
24
23
  $("#"+id).fadeOut(300);
25
24
 
26
- assignTooltipDimensions: (el) ->
27
- $(el).css({display: 'none', opacity: 0})
28
- $(el).css({ height: $(el).height()+'px' })
29
25
 
30
26
 
31
27
  # Element löschen - verwendung als Callback nach löschen etc...
@@ -1,4 +1,3 @@
1
- window.JqAjaxCore2= {} if typeof(window.JqAjaxCore2) is 'undefined'
2
1
  window.JqAjaxCore2.Loading =
3
2
  <% actionview = ActionView::Base.new %>
4
3
  <% actionview.view_paths += [File.expand_path("../../../../views", __FILE__)] %>
@@ -22,6 +21,7 @@ window.JqAjaxCore2.Loading =
22
21
  @overlay().fadeIn(200);
23
22
  <% end %>
24
23
 
24
+
25
25
  hideLoading: ->
26
26
  @overlay().fadeOut(200);
27
27
 
@@ -36,16 +36,21 @@ window.JqAjaxCore2.Loading =
36
36
  # Flash Notify Tools
37
37
  flashNoticeDisplay: (text, mode) ->
38
38
 
39
+
39
40
  mode = mode || 'ok'
40
41
  text = text.replace(/\'/g, "\"")
41
42
  html_notice = "<div class='jqac2-notify " + mode + "' style='display:none'>" + text + "</div>"
42
43
 
44
+
45
+
43
46
  @flashArea().html(html_notice)
44
47
  @flashArea().children().slideDown(500)
45
- window.setTimeout('JqAjaxCore2.Loading.flashFadeOut()', <%= JqajaxCore2::Config.loading[:notify_display_duration] %>)
48
+ window.setTimeout('JqAjaxCore2.Loading.flashFadeOut()', 5000)
49
+
46
50
 
47
51
  flashFadeOut: ->
48
52
  @flashArea().children().fadeOut(500)
53
+
49
54
 
50
55
  loadAjaxFlashNotice: ->
51
56
  $.getJSON '/jqca2/jqac2_flash', (data) ->
@@ -55,4 +60,6 @@ window.JqAjaxCore2.Loading =
55
60
  addLoader: (div, text) ->
56
61
  $('#'+div).html(JqAjaxCore2.Loading.loaderHtml.replace('{TXT}', text))
57
62
 
58
- loaderHtml: '<%= actionview.render "/jqajax/loader" %>'
63
+ loaderHtml: '<%= actionview.render "/jqajax/loader" %>'
64
+
65
+
@@ -1,4 +1,3 @@
1
- window.JqAjaxCore2= {} if typeof(window.JqAjaxCore2) is 'undefined'
2
1
  window.JqAjaxCore2.Modal =
3
2
 
4
3
  # Init position of overlay Modal
@@ -1,4 +1,3 @@
1
- window.JqAjaxCore2= {} if typeof(window.JqAjaxCore2) is 'undefined'
2
1
  window.JqAjaxCore2.Validation =
3
2
 
4
3
  <% JqajaxCore2::Validations.settings.each do |name, settings| %>
@@ -9,8 +8,8 @@ window.JqAjaxCore2.Validation =
9
8
  result.status = JqAjaxCore2.Validation.validateFormat(attr, <%= settings[:regexp] %>, <%= settings[:empty] == false ? 'false' : 'true' %>)
10
9
  result.message = JqAjaxCore2.ValidationErrorMessages.<%= name.to_s.camelize %>
11
10
  return result
12
- <% end %>
13
- # Provide getter for data attributes defined in th
11
+ <% end %>
12
+ # Provide getter for data attributes defined in th
14
13
  <% if settings[:data] %>
15
14
  get<%= name.to_s.camelize %>Data: (el) ->
16
15
  data = {}
@@ -18,91 +17,86 @@ window.JqAjaxCore2.Validation =
18
17
  data.<%= m.to_s.camelize %> = $(el).attr("<%= "data-#{JqajaxCore2::Validations.data_prefix}-#{m.to_s.dasherize}" %>") || "<%= d %>"
19
18
  <% end %>
20
19
  return data
21
- <% end %>
20
+ <% end %>
22
21
  <% end %>
23
-
24
-
22
+
23
+
25
24
  # Define Custom methods for complex validation
26
25
  validatePasswordSimple: (el) ->
27
26
  value = $(el).val()
28
-
27
+
29
28
  settings = JqAjaxCore2.Validation.getPasswordSimpleData(el)
30
29
  result = {}
31
-
32
- if value == ""
33
- result.status = true
34
- return result
35
- else
36
- result.status = false
37
- result.message = JqAjaxCore2.Validation.renderErrorMessage(JqAjaxCore2.ValidationErrorMessages.PasswordSimple, settings)
38
-
39
- if JqAjaxCore2.Validation.validateRequired(el) && value.length >= parseInt(settings.Length)
40
- result.status = true
41
- result.status = false if value.match(/[A-Za-z]/) == null
42
- result.status = false if value.match(/[0-9]/) == null
43
- return result
44
-
30
+ result.status = false
31
+ result.message = JqAjaxCore2.Validation.renderErrorMessage(JqAjaxCore2.ValidationErrorMessages.PasswordSimple, settings)
32
+
33
+ if JqAjaxCore2.Validation.validateRequired(el) && value.length >= parseInt(settings.Length)
34
+ result.status = true
35
+ result.status = false if value.match(/[A-Za-z]/) == null
36
+ result.status = false if value.match(/[0-9]/) == null
37
+ return result
38
+
45
39
  validateConfirmation: (el) ->
46
40
  value = $(el).val()
47
-
41
+
48
42
  settings = JqAjaxCore2.Validation.getConfirmationData(el)
49
43
  result = {}
50
44
  result.status = false
51
45
  result.message = JqAjaxCore2.Validation.renderErrorMessage(JqAjaxCore2.ValidationErrorMessages.Confirmation, settings)
52
-
46
+
53
47
  ref_value = $("#"+settings.ConfirmField).val()
54
-
55
- if JqAjaxCore2.Validation.validateRequired(el) && value == ref_value
48
+
49
+ if JqAjaxCore2.Validation.validateRequired(el) && value == ref_value
56
50
  result.status = true
57
51
  return result
58
-
52
+
59
53
  validateExact: (el) ->
60
54
  value = $(el).val()
61
-
55
+
62
56
  settings = JqAjaxCore2.Validation.getExactData(el)
63
57
  result = {}
64
58
  result.status = false
65
59
  result.message = JqAjaxCore2.Validation.renderErrorMessage(JqAjaxCore2.ValidationErrorMessages.Exact, settings)
66
-
60
+
67
61
  if value == settings.Value
68
62
  result.status = true
69
-
70
- return result
71
-
63
+
64
+ return result
65
+
72
66
  validateLength: (el) ->
73
67
  value = $(el).val()
74
68
 
75
69
  settings = JqAjaxCore2.Validation.getLengthData(el)
76
70
  result = {}
77
71
  result.status = false
78
-
72
+
79
73
  result.message = JqAjaxCore2.Validation.renderErrorMessage(JqAjaxCore2.ValidationErrorMessages.Length, settings)
80
- length_settings = JqAjaxCore2.Validation.getLengthData(el).Length
81
-
82
- length_range = length_settings.split("-")
83
-
84
- if length_range.length == 1
85
- if value.length == parseInt(length_range[0])
86
- result.status = true
87
- else
88
- if value.length >= parseInt(length_range[0]) && value.length <= parseInt(length_range[1])
89
- result.status = true
90
74
 
75
+ if value.length == parseInt(JqAjaxCore2.Validation.getLengthData(el).Length)
76
+ result.status = true
77
+
91
78
  return result
92
-
93
- validateFromService: (el) ->
79
+
80
+ validateFromService: (el) ->
94
81
  value = $(el).val()
95
82
 
96
83
  json_url = JqAjaxCore2.Validation.getFromServiceData(el).Url
97
84
  result = {}
98
85
  values_hash = {value: value}
99
-
86
+
100
87
  # loading additional fields
101
88
  additional_fields = JSON.parse(JqAjaxCore2.Validation.getFromServiceData(el).AdditionalValues)
102
-
89
+
103
90
  for id, name of additional_fields
104
91
  values_hash[name] = $("#"+id).val()
105
-
92
+
93
+
94
+
95
+ console.log(el)
96
+ console.log(values_hash)
97
+ console.log(json_url)
98
+
99
+
106
100
  request = $.ajax
107
101
  dataType: "json",
108
102
  method: 'POST',
@@ -111,17 +105,17 @@ window.JqAjaxCore2.Validation =
111
105
  async: false
112
106
  success: (data) ->
113
107
  result = data
114
-
108
+
115
109
  console.log(request)
116
-
110
+
117
111
  return result
118
-
112
+
119
113
  renderErrorMessage: (text, vars) ->
120
114
  t = text
121
115
  for attr, value of vars
122
116
  t = t.replace('['+attr+']', value)
123
- return t
124
-
117
+ return t
118
+
125
119
  # Helper method for string validation with given regular expression
126
120
  validateFormat: (string, regexp, empty) ->
127
121
  if (!string || 0 == string.length) && empty == true
@@ -130,115 +124,77 @@ window.JqAjaxCore2.Validation =
130
124
  return false
131
125
  else
132
126
  return true
133
-
127
+
134
128
  # run the complete validation for the given form
135
129
  validateForm: (form) ->
136
130
  form = $(form)
137
-
138
- # check if there are any fields with errors
131
+
132
+ # check if there are any fields with errors
139
133
  formStatus = true
140
- submitButton = $(form.find("input[type=submit]"))
141
-
134
+ submitButton = $(form.find("input[type=submit]"))
135
+
142
136
  $(".error-description").remove()
143
- console.log
144
- JqAjaxCore2.Validation.removeErrorFromInput(form.find(":input.error"))
145
-
137
+
146
138
  $(form.find("input")).bind 'change keydown click', ->
147
139
  submitButton.removeAttr("disabled")
148
140
  submitButton.removeClass("disabled")
149
-
141
+
150
142
  <% JqajaxCore2::Validations.settings.keys.each do |mode| %>
151
- inputsForValidation = form.find(":input.<%= JqajaxCore2::Validations.settings[mode][:class] %>").not("[type='hidden']")
143
+ inputsForValidation = form.find(":input.<%= JqajaxCore2::Validations.settings[mode][:class] %>")
152
144
  inputsForValidation.each ->
153
- if !$(this).is(":disabled")
154
- validationResult = JqAjaxCore2.Validation.validate<%= mode.to_s.camelize %>($(this))
155
- if validationResult.status == false && !$(this).hasClass("<%= JqajaxCore2::Validations.skip_validation_class %>") && $(this).parents(".<%= JqajaxCore2::Validations.skip_validation_class %>").length == 0
156
- formStatus = false;
157
- JqAjaxCore2.Validation.addErrorToInput($(this), validationResult.message)
158
- #else
159
- # JqAjaxCore2.Validation.removeErrorFromInput($(this))
145
+ validationResult = JqAjaxCore2.Validation.validate<%= mode.to_s.camelize %>($(this))
146
+ if validationResult.status == false && !$(this).hasClass("<%= JqajaxCore2::Validations.skip_validation_class %>") && $(this).parents(".<%= JqajaxCore2::Validations.skip_validation_class %>").length == 0
147
+ formStatus = false;
148
+ JqAjaxCore2.Validation.addErrorToInput($(this), validationResult.message)
149
+ else
150
+ JqAjaxCore2.Validation.removeErrorFromInput($(this))
160
151
  <% end %>
161
-
152
+
162
153
  checkboxesForValidation = form.find("input.<%= JqajaxCore2::Validations.checkbox_validation_class %>")
163
154
  checkboxesForValidation.each ->
164
155
  # Find the label for the checkbox
165
- checkbox_id = $(this).attr("id")
166
- label = $("label[for="+checkbox_id+"]")
167
-
156
+ checkbox_id = $(this).attr("id")
157
+ label = $("label[for="+checkbox_id+"]")
158
+
168
159
  if !$(this).is(":checked") && !$(this).hasClass("<%= JqajaxCore2::Validations.skip_validation_class %>") && $(this).parents(".<%= JqajaxCore2::Validations.skip_validation_class %>").length == 0
169
160
  formStatus = false
170
161
  label.addClass("error")
171
- alert("Bitte bestätigen Sie: " + label.text())
172
162
  else
173
163
  label.removeClass("error")
174
-
164
+
175
165
  if formStatus == false || $(form).attr("data-has-error") == "true"
176
166
  submitButton.attr("disabled", true)
177
167
  submitButton.addClass("disabled")
178
168
  ##alert("Bei der Eingabe sind Fehler aufgetreten. Bitte prüfen Sie die markierten Felder.")
179
- if $(".error-description")[0]
180
- $('html, body').animate
181
- scrollTop: $($(".error-description")[0]).offset().top-100, 250
182
-
169
+
183
170
  return formStatus
184
-
185
-
171
+
172
+
186
173
  # Bind validation to all forms that can be found
187
174
  initForms: ->
188
-
189
- main_selector = "[class*=<%= JqajaxCore2::Validations.prefix %>]"
190
-
191
- for field in $("input"+main_selector+":first, :input"+main_selector+":first")
192
- $("form").addClass("<%= JqajaxCore2::Validations.form_validation_class %>")
193
-
194
- for field in $("input"+main_selector+", :input"+main_selector)
195
- wrapper_class = "<%= JqajaxCore2::Validations.prefix %>-wrapper"
196
- wrapper_class = wrapper_class + " " + $(field).attr("type") + "-wrapper"
197
- if $(field).attr('data-wrapper-class')
198
- wrapper_class = wrapper_class + ' ' + $(field).attr('data-wrapper-class')
199
-
200
- wrapper = '<span class="'+ wrapper_class + '"></span>'
201
- if field.type == 'checkbox' && $(field).siblings('label[for="' + field.id + '"]').length != 0
202
- $('#' + field.id + ', label[for="' + field.id + '"]').wrapAll(wrapper)
203
- else
204
- $(field).wrap(wrapper)
205
- <% if JqajaxCore2::Config.core[:show_validation_hints] == true %>
206
- if $(field).attr('data-validation-messages')
207
- messages_converted = $(field).attr('data-validation-messages').split(";").join("<br />")
208
- $(field).before("<div data-<%= JqajaxCore2::Config.prefix %>-validation-hint class='<%= JqajaxCore2::Validations.validation_description_class %>'><span class='validation_tooltip'>"+ messages_converted + "</span></div>");
209
- if $(field).is(':visible') == false
210
- $(field).prev().hide()
211
- JqAjaxCore2.Helpers.assignTooltipDimensions($(field).prev().find(".validation_tooltip"))
212
- <% end %>
213
-
175
+ $("input[class*=<%= JqajaxCore2::Validations.prefix %>]:first, :input[class^=<%= JqajaxCore2::Validations.prefix %>]:first").each ->
176
+ $(this).closest("form").addClass("<%= JqajaxCore2::Validations.form_validation_class %>")
177
+
214
178
  $("form.<%= JqajaxCore2::Validations.form_validation_class %>").submit ->
215
-
179
+
216
180
  return JqAjaxCore2.Validation.validateForm(this)
217
-
181
+
218
182
  # Helper methods
219
183
  addErrorToInput: (el, message) ->
220
184
  # remove old error msg if present
221
185
  if $(el).prev().hasClass("<%= JqajaxCore2::Validations.error_description_class %>")
222
186
  $(el).prev().remove()
223
-
187
+
224
188
  $(el).addClass("error")
225
- $(el).parent().addClass("error")
226
-
227
- console.log $(el).parent()
228
-
189
+
229
190
  # label form as error
230
191
  $($(el).parents("form")[0]).attr("data-has-error", "true")
231
- $(el).before("<div data-<%= JqajaxCore2::Config.prefix %>-error-indicator class='<%= JqajaxCore2::Validations.error_description_class %>'><span class='error_tooltip'>"+ message + "</span></div>");
232
- JqAjaxCore2.Helpers.assignTooltipDimensions($(el).prev().find(".error_tooltip"))
233
-
192
+ $(el).before("<div class='<%= JqajaxCore2::Validations.error_description_class %>'>"+ message + "</div>");
193
+
234
194
  removeErrorFromInput: (el) ->
235
195
  $(el).removeClass("error")
236
- $(el).parent().removeClass("error")
237
-
238
-
239
-
240
-
241
- JqAjaxCore2.ValidationErrorMessages =
196
+
197
+ JqAjaxCore2.ValidationErrorMessages =
242
198
  <% JqajaxCore2::Validations.settings.each do |name, settings| %>
243
199
  <%= name.to_s.camelize %>: '<%= settings[:message] %>'
244
- <% end %>
200
+ <% end %>
@@ -1,4 +1,3 @@
1
- window.JqAjaxCore2= {} if typeof(window.JqAjaxCore2) is 'undefined'
2
1
  window.JqAjaxCore2.Widgets =
3
2
  initSlidedownBoxes: ->
4
3
  boxes = $(".js-slide-down-box.plain")
@@ -5,4 +5,3 @@
5
5
  //= require "jqac2/widgets"
6
6
  //= require "jqac2/validation"
7
7
  //= require "jqac2/initializer"
8
- //= require_tree "./jqac2/widget_classes"
@@ -1,139 +1,133 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module JqajaxCoreHelper
3
-
4
-
3
+
4
+
5
5
  #== New and shiny polished Rails 3.2 Ajax Helper Functions
6
-
6
+
7
7
  # Default Ajax Link for Links
8
8
  def default_ajax_link(options ={})
9
9
  link_data = init_link_data(options)
10
-
10
+
11
11
  link_data.merge!(:title => options[:title])
12
12
  options[:class] ||= ""
13
13
  options[:class] << " #{JqajaxCore2::Config.core[:ajax_link_class]} #{JqajaxCore2::Config.core[:no_ajax_link_class]}"
14
-
14
+
15
15
  if options[:append] == true
16
16
  link_data.merge!(JqajaxCore2::Config.html_data[:append] => true)
17
- end
18
-
17
+ end
18
+
19
19
  # Load-Message setzen: Entweder default oder eigene Nachricht
20
20
  if options[:load_message] && (options[:load_message] != false && !options[:load_message].blank?)
21
21
  options[:class] << " #{AJAX_LOAD_MESSAGE_TRIGGER}"
22
22
  if options[:load_message].is_a?(String)
23
23
  link_data.merge!(JqajaxCore2::Config.loading[:load_message].to_s => options[:load_message])
24
- end
24
+ end
25
25
  elsif options[:load_message] == false
26
26
  options[:class] << " #{AJAX_HIDE_LOAD_MESSAGE_SELECTOR}"
27
- end
28
-
27
+ end
28
+
29
29
  link_data.merge!(html_defaults_from_options(options))
30
-
30
+
31
31
  return link_data
32
- end
33
-
34
- #
32
+ end
33
+
34
+ #
35
35
  def select_onchange_data(options ={})
36
36
  link_data = init_link_data(options)
37
-
38
- link_data.merge!(:disabled => options[:disabled])
37
+
38
+ link_data.merge!(:disabled => options[:disabled])
39
39
  options[:class] ||= ""
40
40
  options[:class] << " #{JqajaxCore2::Config.core[:select_onchange_selector]} #{JqajaxCore2::Config.core[:no_ajax_link_class]}"
41
41
 
42
- options[:with] ||= :id
42
+ options[:with] ||= :id
43
43
 
44
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
-
45
+ link_data.merge!(JqajaxCore2::Config.html_data[:target_url].to_s => (options[:scope] || main_app).url_for(options[:url]))
46
+
50
47
  # Load-Message setzen: Entweder default oder eigene Nachricht
51
48
  if options[:load_message] && (options[:load_message] != false && !options[:load_message].blank?)
52
49
  options[:class] << " #{AJAX_LOAD_MESSAGE_TRIGGER}"
53
50
  if options[:load_message].is_a?(String)
54
51
  link_data.merge!(JqajaxCore2::Config.loading[:load_message].to_s => options[:load_message])
55
- end
52
+ end
56
53
  elsif options[:load_message] == false
57
54
  options[:class] << " #{AJAX_HIDE_LOAD_MESSAGE_SELECTOR}"
58
55
  end
59
-
56
+
60
57
  link_data.merge!(html_defaults_from_options(options))
61
-
58
+
62
59
  return link_data
63
60
  end
64
-
65
-
66
-
67
- # Creates a box that slides down and up to show/hide the content.
61
+
62
+
63
+
64
+ # Creates a box that slides down and up to show/hide the content.
68
65
  # * Use ':open => true' to set the box open by default
69
66
  # * Use ':default_class => "className"' to set the class used for the header
70
67
  def slide_down_box(title, options = {:open => false}, &block)
71
68
  options[:default_class] ||= "icon-arrow-right"
72
69
  options[:type] ||= :div
73
-
74
-
70
+
71
+
75
72
  box_session_id = Digest::SHA1.hexdigest("#{params[:action]}-#{title}")
76
-
73
+
77
74
  open = options[:open] #|| (session[:slidedown_boxes_open].include?(box_session_id) rescue false)
78
-
75
+
79
76
  concat raw("<div class='js-slide-down-box plain #{'open' if open} #{options[:box_class]} #{options[:class]}' data-session-id='#{box_session_id}'>
80
77
  <#{options[:type]} class='#{options[:default_class]} js-slidedown-button'>
81
78
  #{title}
82
79
  </#{options[:type]}>
83
- <div class='js-slidedown-content'>")
80
+ <div class='js-slidedown-content'>")
84
81
  yield
85
- concat raw("</div></div>")
82
+ concat raw("</div></div>")
86
83
  end
87
-
88
-
89
-
84
+
85
+
86
+
90
87
  def init_slidedown
91
88
  raw("<script type='text/javascript'>init_slidedown();</script>")
92
89
  end
93
-
94
-
90
+
91
+
95
92
  private
96
-
93
+
97
94
  def init_link_data(options = {})
98
95
  link_data = {:remote => true }
99
96
  link_data.merge!(:method => options[:method]) if options[:method]
100
97
  link_data.merge!(update_div_from_options(options))
101
98
  link_data.merge!(submit_from_options(options))
102
99
  link_data.merge!(callback_from_options(options))
103
- link_data.merge!(confirm_message_from_options(options))
100
+ link_data.merge!(confirm_message_from_options(options))
104
101
  return link_data
105
- end
106
-
102
+ end
103
+
107
104
  def confirm_message_from_options(options = {})
108
105
  # Confirm-Message setzen: Entweder default, oder eigene Nachricht
109
106
  if options[:confirm]
110
- { JqajaxCore2::Config.html_data[:confirm] => (options[:confirm] == true ? JqajaxCore2::Config.core[:confirm_default] : options[:confirm].to_s )}
107
+ { JqajaxCore2::Config.html_data[:confirm] => (options[:confirm] == true ? JqajaxCore2::Config.core[:confirm_default] : options[:confirm].to_s )}
111
108
  else
112
109
  return {}
113
- end
110
+ end
114
111
  end
115
-
112
+
116
113
  def callback_from_options(options = {})
117
114
  options[:callback] ? {JqajaxCore2::Config.html_data[:callback] => options[:callback]} : {}
118
115
  end
119
-
120
- def submit_from_options(options = {})
121
- options[:submit] ? {
122
- JqajaxCore2::Config.html_data[:submit_data] => options[:submit],
123
- :method => "POST"
124
- } : {}
116
+
117
+ def submit_from_options(options = {})
118
+ options[:submit] ? {JqajaxCore2::Config.html_data[:submit_data] => options[:submit]} : {}
125
119
  end
126
-
120
+
127
121
  def update_div_from_options(options = {})
128
122
  options[:update] ? { JqajaxCore2::Config.core[:update_div] => options[:update]} : {}
129
123
  end
130
-
131
- def html_defaults_from_options(options = {})
132
- l = {}
124
+
125
+ def html_defaults_from_options(options = {})
126
+ l = {}
133
127
  l.merge!(:class => options[:class])
134
128
  l.merge!(:id => options[:id])
135
129
  l.merge!(:style => options[:style])
136
130
  return l
137
- end
138
-
131
+ end
132
+
139
133
  end
@@ -1,76 +1,47 @@
1
1
  module JqajaxValidationHelper
2
-
2
+
3
3
  def jqac2_validation_for(*vtypes)
4
4
  if vtypes.last.is_a?(Hash)
5
5
  options = vtypes.last
6
6
  vtypes.pop
7
7
  else
8
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]
9
+ end
10
+
15
11
 
12
+
16
13
  # validierungsoptionen
17
14
  if options[:validator_options]
18
15
  options[:validator_options].each do |opt, val|
19
16
  options.merge!(jqac2_data_attribute_for(opt) => val)
20
- end
17
+ end
21
18
  options.delete(:validator_options)
22
- end
23
-
24
- data_messages = []
25
- if options[:hint]
26
- data_messages << options[:hint]
27
- end
28
-
19
+ end
20
+
29
21
  vtypes.each do |vtype|
30
22
  if JqajaxCore2::Validations.settings[vtype.to_sym]
31
23
  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
24
+
35
25
  elsif vtype.nil?
36
26
  options
37
- else
27
+ else
38
28
  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(" ")
29
+ end
30
+ end
31
+
32
+ return options
62
33
  end
63
-
34
+
64
35
  def jqac2_validate_form
65
36
  JqajaxCore2::Validations.form_validation_class
66
- end
67
-
37
+ end
38
+
68
39
  def jqac2_data_attribute_for(m="bla")
69
40
  "data-#{JqajaxCore2::Validations.data_prefix}-#{m.to_s.dasherize}"
70
- end
71
-
72
- def init_jqac2_validator
41
+ end
42
+
43
+ def init_jqac2_validator
73
44
  javascript_tag("JqAjaxCore2.Validation.initForms()")
74
- end
75
-
76
- end
45
+ end
46
+
47
+ end
@@ -1,4 +1,4 @@
1
1
  <div class="jqac-inline-loader cf">
2
- <div class="overlay-loader"><img src="<%= JqajaxCore2::Config.loading[:loader_img] %>"></div>
2
+ <div class="overlay-loader"><%= image_tag(JqajaxCore2::Config.loading[:loader_img]) %></div>
3
3
  <div class="overlay-title">{TXT}</div>
4
4
  <%= link_to JqajaxCore2::Config.overlay[:hide_label], "#", :class => "overlay-link" %>
@@ -1,86 +1,56 @@
1
1
  module JqajaxCore2
2
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
-
3
+
4
+ cattr_accessor :settings, :checkbox_validation_class, :skip_validation_class, :form_validation_class, :prefix, :data_prefix, :error_description_class
5
+
6
6
  self.prefix = "#{JqajaxCore2::Config.prefix}-vld"
7
7
  self.data_prefix = "data-#{JqajaxCore2::Config.prefix}"
8
-
8
+
9
9
  # Defition der Verüfgbaren validierungen:
10
10
  # - Ist :regexp gesetzt, wird automatisch eine Validierungsfunktion für die Regexp in JS angelegt
11
11
  # bei fehler wird die :message zurückgegeben
12
12
  # - Ist keine Regexp angegeben muss eine Funktion manuell erstellt werden
13
-
13
+
14
14
  self.settings = {
15
-
15
+
16
16
  :email => {
17
17
  :class => "#{self.prefix}-email-validation",
18
18
  :regexp => '/[a-zA-Z0-9\.\-_]{1,}@[a-zA-Z0-9\.\-_]{1,}\.[a-zA-Z0-9\.\-_]{2,4}/',
19
19
  :message => "Keine gültige E-Mail-Adresse"
20
20
  },
21
-
21
+
22
22
  :phone => {
23
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
24
  :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"
25
+ :message => "Keine gültige Telefonnummer"
44
26
  },
45
-
27
+
46
28
  :zip => {
47
29
  :class => "#{self.prefix}-zip-validation",
48
30
  :regexp => '/[0-9]{4,5}/',
49
- :message => "Ungültige PLZ"
31
+ :message => "Ungültige PLZ",
50
32
  },
51
-
33
+
52
34
  :number => {
53
35
  :class => "#{self.prefix}-nr-validation",
54
36
  :regexp => '/[0-9\ ]{1,}/',
55
37
  :message => "Ungültige Zahl",
56
38
  },
57
39
 
58
- :currency => {
59
- :class => "#{self.prefix}-currency-validation",
60
- :regexp => '/[0-9\.\,0]{1,}/',
61
- :message => "Ungültige Eingabe",
62
- },
63
-
64
40
  #== Validations for dates etc...
65
41
  :date => {
66
42
  :class => "#{self.prefix}-date-validation",
67
43
  # TODO: Regexp does not catch fake dates like 99.99.9999
68
44
  :regexp => "/([0-9]{2}\.[0-9]{2}\.[0-9]{4})|([0-9]{4}-[0-9]{2}-[0-9]{2})/",
69
- :message => "Ungültiges Datum"
45
+ :message => "Ungültiges Datum",
70
46
  },
71
-
47
+
72
48
  :datemonth => {
73
49
  :class => "#{self.prefix}-date-month-validation",
74
50
  :regexp => "/[0-9]{2}\.[0-9]{4}/",
75
51
  :message => "Ungültiges Format (MM.JJJJ)",
76
52
  },
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
-
53
+
84
54
  #:date_in_future => {
85
55
  # :class => "#{self.prefix}-date-in-future-validation",
86
56
  # :message => "Datum darf nicht in der Vergangenheit liegen",
@@ -91,57 +61,54 @@ module JqajaxCore2
91
61
  # :data => {:min_age => 18}
92
62
  # :message => "Ungültiges Geburtsdatum",
93
63
  #}
94
-
95
-
64
+
65
+
96
66
  #== Validations for Passwords, Confirmation etc...
97
-
67
+
98
68
  :password_simple => {
99
69
  :class => "#{self.prefix}-simple-pass-validation",
100
70
  # Data-Attributes used by the method, and their default values
101
71
  :data => {:length => 6},
102
72
  :message => "Min. [Length] Zeichen, min. Buchstaben und Zahlen"
103
-
73
+
104
74
  },
105
-
75
+
106
76
  :confirmation => {
107
77
  :class => "#{self.prefix}-confirmation",
108
78
  :data => {:confirm_field => "", :confirm_name => ""},
109
79
  :message => "Bestätigung von [ConfirmName] stimmt nicht überein"
110
80
  },
111
-
81
+
112
82
  :exact => {
113
83
  :class => "#{self.prefix}-exact-validation",
114
84
  :data => {:value => ""},
115
85
  :message => "Eingabe ungültig"
116
86
  },
117
-
87
+
118
88
  :length => {
119
89
  :class => "#{self.prefix}-length-validation",
120
90
  :data => {:length => 0},
121
91
  :message => "[Length] Zeichen"
122
92
  },
123
-
93
+
124
94
  :required => {
125
95
  :class => "#{self.prefix}-required-validation",
126
96
  :regexp => '/[a-zA-Z0-9]{1,}/',
127
97
  :empty => false,
128
98
  :message => "Pflichtfeld"
129
99
  },
130
-
100
+
131
101
  :from_service => {
132
102
  :class => "#{self.prefix}-from-service",
133
103
  :data => {:url => "#", :additional_values => {}.to_json }
134
- },
135
-
136
- :none => {
137
- class: "#{self.prefix}-none"
138
104
  }
139
105
  }
140
-
106
+
107
+
141
108
  self.checkbox_validation_class = "#{self.prefix}-validate-checkbox"
142
109
  self.skip_validation_class = "#{self.prefix}-skip-validation"
143
110
  self.form_validation_class = "#{self.prefix}-form-validation"
144
111
  self.error_description_class = "error-description"
145
- self.validation_description_class = "validation-description"
146
112
  end
147
- end
113
+ end
114
+
data/lib/jqajax_core2.rb CHANGED
@@ -13,10 +13,10 @@ JqajaxCore2::Config.core[:no_ajax_link_class] ||= "#{p}-not-loaded"
13
13
  JqajaxCore2::Config.core[:select_onchange_selector] ||= "#{p}-select-onchange"
14
14
 
15
15
  # HTML data-Attribute for specifing the div to be updated
16
- JqajaxCore2::Config.core[:update_div] ||= "data-jqac2-update-element"
16
+ JqajaxCore2::Config.core[:update_div] ||= "data-jqac2-update-element"
17
17
 
18
18
  # id name of the main Ajax Overlay Container
19
- JqajaxCore2::Config.core[:ajax_content_container_id] ||= "jqac2-ajax-content"
19
+ JqajaxCore2::Config.core[:ajax_content_container_id] ||= "jqac2-ajax-content"
20
20
 
21
21
  # Placeholder string in URLS
22
22
  JqajaxCore2::Config.core[:url_placeholder] ||= ".-."
@@ -24,9 +24,6 @@ JqajaxCore2::Config.core[:url_placeholder] ||= ".-."
24
24
  # Confirmation
25
25
  JqajaxCore2::Config.core[:confirm_default] ||= "Sind Sie sicher das Sie fortfahren möchten?"
26
26
 
27
- # Hinweise für Validierte Felder zeigen?
28
- JqajaxCore2::Config.core[:show_validation_hints] ||= false
29
-
30
27
  #== Overlay and Loader Settings
31
28
  JqajaxCore2::Config.overlay[:div_id] ||= "#{p}-overlay"
32
29
  JqajaxCore2::Config.overlay[:hide_label] ||= "ausblenden"
@@ -40,11 +37,9 @@ JqajaxCore2::Config.overlay[:enable_on_page_unload] ||= true
40
37
 
41
38
  # div area for showing flash notice/errors
42
39
  JqajaxCore2::Config.loading[:flash_area_div] ||= "#{p}-flash-area"
43
- JqajaxCore2::Config.loading[:loader_img] ||= "/ajax-loader.gif"
40
+ JqajaxCore2::Config.loading[:loader_img] ||= "ajax-loader.gif"
44
41
  JqajaxCore2::Config.loading[:flash_area_position] ||= :bottom_right
45
42
  JqajaxCore2::Config.loading[:load_message] ||= "data-jqac2-loading"
46
- JqajaxCore2::Config.loading[:notify_display_duration] ||= 5000
47
-
48
43
 
49
44
  #== Modal Settings
50
45
  JqajaxCore2::Config.modal[:max_width_factor] ||= 0.9
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jqajax_core2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.81
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Eck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-11 00:00:00.000000000 Z
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: sass-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '4.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '4.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,6 @@ files:
109
109
  - app/assets/javascripts/jqac2/loading.js.coffee.erb
110
110
  - app/assets/javascripts/jqac2/modal.js.coffee.erb
111
111
  - app/assets/javascripts/jqac2/validation.js.coffee.erb
112
- - app/assets/javascripts/jqac2/widget_classes/checkbox_slidedown.coffee
113
112
  - app/assets/javascripts/jqac2/widgets.js.coffee
114
113
  - app/assets/javascripts/jqajax-core2.js.erb
115
114
  - app/assets/stylesheets/jqajax-core2.scss.erb
@@ -125,7 +124,6 @@ files:
125
124
  - app/views/layouts/_ajax_overlay.html.erb
126
125
  - app/views/layouts/_info_overlay.html.erb
127
126
  - app/views/layouts/jqac2_modal.html.erb
128
- - config/locales/jqac2.validations.de.yml
129
127
  - config/routes.rb
130
128
  - lib/jqajax_core2.rb
131
129
  - lib/jqajax_core2/application_controller_ext.rb
@@ -152,8 +150,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
150
  version: '0'
153
151
  requirements: []
154
152
  rubyforge_project:
155
- rubygems_version: 2.6.14
153
+ rubygems_version: 2.2.1
156
154
  signing_key:
157
155
  specification_version: 4
158
156
  summary: Makes Rails Ajax easy
159
157
  test_files: []
158
+ has_rdoc:
@@ -1,33 +0,0 @@
1
- class JqAjaxCore2.CheckboxSlidedown
2
- constructor: (el) ->
3
- @$el = $(el)
4
-
5
- @settings =
6
- content_selector: @$el.data("jqac2-checkbox-slidedown-content")
7
- trigger_selector: @$el.data("jqac2-checkbox-slidedown-trigger")
8
- open: @$el.data("jqac2-checkbox-slidedown-open") || 'false'
9
-
10
- @$content = @$el.find(@settings.content_selector)
11
- @$trigger = @$el.find(@settings.trigger_selector)
12
-
13
- @element_id = "s" + Math.random()+Math.random()
14
-
15
- @$checkbox = $('<input id=" ' + @element_id + ' " class="jqac2-checkbox-slidedown-trigger" type="checkbox"></input>')
16
-
17
- init: ->
18
- # content should be hidden until checkbox was checked
19
- @$content.hide()
20
-
21
- # Add checkbox before the trigger element
22
- @$trigger.before(@$checkbox)
23
- @$checkbox.on 'change', @setContentVisibility
24
-
25
- @setContentVisibility
26
-
27
-
28
- setContentVisibility: =>
29
- if @$checkbox.is(":checked")
30
- @$content.show()
31
- else
32
- @$content.hide()
33
-
@@ -1,12 +0,0 @@
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'