inline_forms 1.1.19 → 1.1.20
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.
- data/Gemfile.lock +1 -1
- data/lib/app/assets/javascripts/inline_forms_application.js +10 -0
- data/lib/app/assets/javascripts/jquery.tools/jquery.tools.min.js +13 -0
- data/lib/app/assets/javascripts/validation_tooltips.js +11 -0
- data/lib/app/assets/stylesheets/{application.css → inline_forms_application.css} +2 -2
- data/lib/app/assets/stylesheets/validation_tooltips.css +9 -0
- data/lib/app/controllers/inline_forms_controller.rb +1 -0
- data/lib/app/helpers/inline_forms_helper.rb +18 -4
- data/lib/app/validators/is_curacao_phone_validator.rb +38 -0
- data/lib/app/validators/is_email_address_validator.rb +9 -1
- data/lib/app/validators/must_be_unique_validator.rb +11 -0
- data/lib/app/views/inline_forms/_show.html.erb +6 -3
- data/lib/app/views/layouts/inline_forms.html.erb +2 -2
- data/lib/inline_forms/version.rb +1 -1
- metadata +11 -5
data/Gemfile.lock
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
5
|
+
// the compiled file.
|
|
6
|
+
//
|
|
7
|
+
//= require_directory ./jquery.tools
|
|
8
|
+
//= require validation_tooltips
|
|
9
|
+
|
|
10
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* jQuery Tools v1.2.6 - The missing UI library for the Web
|
|
3
|
+
*
|
|
4
|
+
* tooltip/tooltip.js
|
|
5
|
+
* tooltip/tooltip.slide.js
|
|
6
|
+
*
|
|
7
|
+
* NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
|
|
8
|
+
*
|
|
9
|
+
* http://flowplayer.org/tools/
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
(function(a){a.tools=a.tools||{version:"v1.2.6"},a.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,fadeIE:!1,position:["top","center"],offset:[0,0],relative:!1,cancelDefault:!0,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,c,d){b[a]=[c,d]}};var b={toggle:[function(a){var b=this.getConf(),c=this.getTip(),d=b.opacity;d<1&&c.css({opacity:d}),c.show(),a.call()},function(a){this.getTip().hide(),a.call()}],fade:[function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeTo(c.fadeInSpeed,c.opacity,b):(this.getTip().show(),b())},function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeOut(c.fadeOutSpeed,b):(this.getTip().hide(),b())}]};function c(b,c,d){var e=d.relative?b.position().top:b.offset().top,f=d.relative?b.position().left:b.offset().left,g=d.position[0];e-=c.outerHeight()-d.offset[0],f+=b.outerWidth()+d.offset[1],/iPad/i.test(navigator.userAgent)&&(e-=a(window).scrollTop());var h=c.outerHeight()+b.outerHeight();g=="center"&&(e+=h/2),g=="bottom"&&(e+=h),g=d.position[1];var i=c.outerWidth()+b.outerWidth();g=="center"&&(f-=i/2),g=="left"&&(f-=i);return{top:e,left:f}}function d(d,e){var f=this,g=d.add(f),h,i=0,j=0,k=d.attr("title"),l=d.attr("data-tooltip"),m=b[e.effect],n,o=d.is(":input"),p=o&&d.is(":checkbox, :radio, select, :button, :submit"),q=d.attr("type"),r=e.events[q]||e.events[o?p?"widget":"input":"def"];if(!m)throw"Nonexistent effect \""+e.effect+"\"";r=r.split(/,\s*/);if(r.length!=2)throw"Tooltip: bad events configuration for "+q;d.bind(r[0],function(a){clearTimeout(i),e.predelay?j=setTimeout(function(){f.show(a)},e.predelay):f.show(a)}).bind(r[1],function(a){clearTimeout(j),e.delay?i=setTimeout(function(){f.hide(a)},e.delay):f.hide(a)}),k&&e.cancelDefault&&(d.removeAttr("title"),d.data("title",k)),a.extend(f,{show:function(b){if(!h){l?h=a(l):e.tip?h=a(e.tip).eq(0):k?h=a(e.layout).addClass(e.tipClass).appendTo(document.body).hide().append(k):(h=d.next(),h.length||(h=d.parent().next()));if(!h.length)throw"Cannot find tooltip for "+d}if(f.isShown())return f;h.stop(!0,!0);var o=c(d,h,e);e.tip&&h.html(d.data("title")),b=a.Event(),b.type="onBeforeShow",g.trigger(b,[o]);if(b.isDefaultPrevented())return f;o=c(d,h,e),h.css({position:"absolute",top:o.top,left:o.left}),n=!0,m[0].call(f,function(){b.type="onShow",n="full",g.trigger(b)});var p=e.events.tooltip.split(/,\s*/);h.data("__set")||(h.unbind(p[0]).bind(p[0],function(){clearTimeout(i),clearTimeout(j)}),p[1]&&!d.is("input:not(:checkbox, :radio), textarea")&&h.unbind(p[1]).bind(p[1],function(a){a.relatedTarget!=d[0]&&d.trigger(r[1].split(" ")[0])}),e.tip||h.data("__set",!0));return f},hide:function(c){if(!h||!f.isShown())return f;c=a.Event(),c.type="onBeforeHide",g.trigger(c);if(!c.isDefaultPrevented()){n=!1,b[e.effect][1].call(f,function(){c.type="onHide",g.trigger(c)});return f}},isShown:function(a){return a?n=="full":n},getConf:function(){return e},getTip:function(){return h},getTrigger:function(){return d}}),a.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(b,c){a.isFunction(e[c])&&a(f).bind(c,e[c]),f[c]=function(b){b&&a(f).bind(c,b);return f}})}a.fn.tooltip=function(b){var c=this.data("tooltip");if(c)return c;b=a.extend(!0,{},a.tools.tooltip.conf,b),typeof b.position=="string"&&(b.position=b.position.split(/,?\s/)),this.each(function(){c=new d(a(this),b),a(this).data("tooltip",c)});return b.api?c:this}})(jQuery);
|
|
13
|
+
(function(a){var b=a.tools.tooltip;a.extend(b.conf,{direction:"up",bounce:!1,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!a.browser.msie});var c={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};b.addEffect("slide",function(a){var b=this.getConf(),d=this.getTip(),e=b.slideFade?{opacity:b.opacity}:{},f=c[b.direction]||c.up;e[f[1]]=f[0]+"="+b.slideOffset,b.slideFade&&d.css({opacity:0}),d.show().animate(e,b.slideInSpeed,a)},function(b){var d=this.getConf(),e=d.slideOffset,f=d.slideFade?{opacity:0}:{},g=c[d.direction]||c.up,h=""+g[0];d.bounce&&(h=h=="+"?"-":"+"),f[g[1]]=h+"="+e,this.getTip().animate(f,d.slideOutSpeed,function(){a(this).hide(),b.call()})})})(jQuery);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
|
3
3
|
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
|
4
4
|
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
|
5
|
-
*=
|
|
6
|
-
*=
|
|
5
|
+
*= require 'inline_forms'
|
|
6
|
+
*= require 'validation_tooltips'
|
|
7
7
|
*/
|
|
@@ -213,6 +213,7 @@
|
|
|
213
213
|
private
|
|
214
214
|
# Get the class from the controller name.
|
|
215
215
|
# CountryController < InlineFormsController, so what class are we?
|
|
216
|
+
# TODO think about this a bit more.
|
|
216
217
|
def getKlass #:doc:
|
|
217
218
|
@Klass = self.controller_name.classify.constantize
|
|
218
219
|
end
|
|
@@ -13,6 +13,20 @@ module InlineFormsHelper
|
|
|
13
13
|
InlineForms::VERSION
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def validation_help_as_list_for(object, attribute)
|
|
17
|
+
"" and return if object.class.validators_on(attribute).empty?
|
|
18
|
+
content_tag(:ul, validation_help_for(object, attribute).map { |help_message| content_tag(:li, help_message ) }.to_s.html_safe )
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# validation_help_for(object, attribute) extracts the help messages for
|
|
22
|
+
# attribute of object.class (in an Array)
|
|
23
|
+
def validation_help_for(object, attribute)
|
|
24
|
+
"" and return if object.class.validators_on(attribute).empty?
|
|
25
|
+
object.class.validators_on(attribute).map do |v|
|
|
26
|
+
v.help_message if v.respond_to?(:help_message)
|
|
27
|
+
end.compact
|
|
28
|
+
end
|
|
29
|
+
|
|
16
30
|
# close link
|
|
17
31
|
def close_link( object, update_span )
|
|
18
32
|
link_to image_tag( 'close.png',
|
|
@@ -70,10 +84,10 @@ module InlineFormsHelper
|
|
|
70
84
|
out = ""
|
|
71
85
|
out << "<li class='new_record_link'>"
|
|
72
86
|
out << (link_to image_tag( 'add.png',
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
87
|
+
:class => "new_record_icon",
|
|
88
|
+
:title => text ),
|
|
89
|
+
send(path_to_new, :update => update_span, :parent_class => parent_class, :parent_id => parent_id ),
|
|
90
|
+
:remote => true)
|
|
77
91
|
out << "<div style='clear: both;'></div>"
|
|
78
92
|
out << "</li>"
|
|
79
93
|
""
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# == usage:
|
|
2
|
+
# in your model, add:
|
|
3
|
+
# validates :email, :presence => true, :is_email_address => true;
|
|
4
|
+
# taken from http://lindsaar.net/2010/1/31/validates_rails_3_awesome_is_true
|
|
5
|
+
# (It's probably a fake regex but hey, it looks legit.)
|
|
6
|
+
class IsCuracaoPhoneValidator < ActiveModel::EachValidator
|
|
7
|
+
EmailAddress = begin
|
|
8
|
+
qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'
|
|
9
|
+
dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'
|
|
10
|
+
atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' +
|
|
11
|
+
'\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'
|
|
12
|
+
quoted_pair = '\\x5c[\\x00-\\x7f]'
|
|
13
|
+
domain_literal = "\\x5b(?:#{dtext}|#{quoted_pair})*\\x5d"
|
|
14
|
+
quoted_string = "\\x22(?:#{qtext}|#{quoted_pair})*\\x22"
|
|
15
|
+
domain_ref = atom
|
|
16
|
+
sub_domain = "(?:#{domain_ref}|#{domain_literal})"
|
|
17
|
+
word = "(?:#{atom}|#{quoted_string})"
|
|
18
|
+
domain = "#{sub_domain}(?:\\x2e#{sub_domain})*"
|
|
19
|
+
local_part = "#{word}(?:\\x2e#{word})*"
|
|
20
|
+
addr_spec = "#{local_part}\\x40#{domain}"
|
|
21
|
+
pattern = /\A#{addr_spec}\z/
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def error_message
|
|
25
|
+
"is not a valid Curacao phone number."
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def help_message
|
|
29
|
+
"Needs to be a valid Curacao phone number."
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def validate_each(record, attribute, value)
|
|
33
|
+
unless value =~ EmailAddress
|
|
34
|
+
record.errors[attribute] << (options[:message] || error_message )
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -21,9 +21,17 @@ class IsEmailAddressValidator < ActiveModel::EachValidator
|
|
|
21
21
|
pattern = /\A#{addr_spec}\z/
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def error_message
|
|
25
|
+
"is not a valid email address."
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def help_message
|
|
29
|
+
"Needs to be a valid email address."
|
|
30
|
+
end
|
|
31
|
+
|
|
24
32
|
def validate_each(record, attribute, value)
|
|
25
33
|
unless value =~ EmailAddress
|
|
26
|
-
record.errors[attribute] << (options[:message] ||
|
|
34
|
+
record.errors[attribute] << (options[:message] || error_message )
|
|
27
35
|
end
|
|
28
36
|
end
|
|
29
37
|
|
|
@@ -19,15 +19,18 @@
|
|
|
19
19
|
<div class='<%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
|
|
20
20
|
<%= h(name) -%>
|
|
21
21
|
</div>
|
|
22
|
+
<div class='validation_help_tooltip'>
|
|
23
|
+
<%= validation_help_as_list_for(@object, attribute) -%>
|
|
24
|
+
</div>
|
|
22
25
|
</td>
|
|
23
26
|
<td valign="top">
|
|
24
27
|
<div class='<%= "attribute_value attribute_#{attribute} form_element_#{form_element}" -%>' >
|
|
25
28
|
<span id="<%= css_class_id -%>" >
|
|
26
29
|
<% if form_element == :associated -%>
|
|
27
30
|
<%= render :partial => "inline_forms/list",
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
:locals => { :parent_class => @object.class,
|
|
32
|
+
:parent_id => @object.id,
|
|
33
|
+
:attribute => attribute } %>
|
|
31
34
|
<% else -%>
|
|
32
35
|
<%= send("#{form_element}_show", @object, attribute) -%>
|
|
33
36
|
<% end -%>
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
<html>
|
|
4
4
|
<head>
|
|
5
5
|
<title><%= h( yield(:title) || "Unconfigured Titile") %></title>
|
|
6
|
-
<%= stylesheet_link_tag '
|
|
7
|
-
<%= javascript_include_tag 'application' %>
|
|
6
|
+
<%= stylesheet_link_tag 'inline_forms_application', 'application' %>
|
|
7
|
+
<%= javascript_include_tag 'application', 'inline_forms_application' %>
|
|
8
8
|
<%= csrf_meta_tag %>
|
|
9
9
|
<%= yield(:head) %>
|
|
10
10
|
<script>
|
data/lib/inline_forms/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inline_forms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 59
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 1
|
|
9
|
-
-
|
|
10
|
-
version: 1.1.
|
|
9
|
+
- 20
|
|
10
|
+
version: 1.1.20
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Ace Suares
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2012-01-
|
|
18
|
+
date: 2012-01-07 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: rspec-rails
|
|
@@ -131,10 +131,14 @@ files:
|
|
|
131
131
|
- lib/app/assets/images/ui-icons_fadc7a_256x240.png
|
|
132
132
|
- lib/app/assets/images/ui-icons_ffe180_256x240.png
|
|
133
133
|
- lib/app/assets/javascripts/ckeditor/config.js
|
|
134
|
-
- lib/app/assets/
|
|
134
|
+
- lib/app/assets/javascripts/inline_forms_application.js
|
|
135
|
+
- lib/app/assets/javascripts/jquery.tools/jquery.tools.min.js
|
|
136
|
+
- lib/app/assets/javascripts/validation_tooltips.js
|
|
135
137
|
- lib/app/assets/stylesheets/devise.css
|
|
136
138
|
- lib/app/assets/stylesheets/inline_forms.css
|
|
139
|
+
- lib/app/assets/stylesheets/inline_forms_application.css
|
|
137
140
|
- lib/app/assets/stylesheets/jquery-ui-sunny.css
|
|
141
|
+
- lib/app/assets/stylesheets/validation_tooltips.css
|
|
138
142
|
- lib/app/controllers/inline_forms_controller.rb
|
|
139
143
|
- lib/app/helpers/form_elements/check_box.rb
|
|
140
144
|
- lib/app/helpers/form_elements/check_list.rb
|
|
@@ -156,7 +160,9 @@ files:
|
|
|
156
160
|
- lib/app/helpers/form_elements/text_field.rb
|
|
157
161
|
- lib/app/helpers/inline_forms_helper.rb
|
|
158
162
|
- lib/app/models/geo_code_curacao.rb
|
|
163
|
+
- lib/app/validators/is_curacao_phone_validator.rb
|
|
159
164
|
- lib/app/validators/is_email_address_validator.rb
|
|
165
|
+
- lib/app/validators/must_be_unique_validator.rb
|
|
160
166
|
- lib/app/views/devise/confirmations/new.html.erb
|
|
161
167
|
- lib/app/views/devise/mailer/confirmation_instructions.html.erb
|
|
162
168
|
- lib/app/views/devise/mailer/reset_password_instructions.html.erb
|