active_scaffold_signaturepad 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ if(!this.JSON){this.JSON={};}
2
+ (function(){function f(n){return n<10?'0'+n:n;}
3
+ if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
4
+ f(this.getUTCMonth()+1)+'-'+
5
+ f(this.getUTCDate())+'T'+
6
+ f(this.getUTCHours())+':'+
7
+ f(this.getUTCMinutes())+':'+
8
+ f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
9
+ var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
10
+ function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
11
+ if(typeof rep==='function'){value=rep.call(holder,key,value);}
12
+ switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
13
+ gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
14
+ v=partial.length===0?'[]':gap?'[\n'+gap+
15
+ partial.join(',\n'+gap)+'\n'+
16
+ mind+']':'['+partial.join(',')+']';gap=mind;return v;}
17
+ if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
18
+ v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
19
+ mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
20
+ if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
21
+ rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
22
+ return str('',{'':value});};}
23
+ if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
24
+ return reviver.call(holder,key,value);}
25
+ cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
26
+ ('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
27
+ if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
28
+ throw new SyntaxError('JSON.parse');};}}());
@@ -0,0 +1,171 @@
1
+ .sigPad {
2
+ margin: 0;
3
+ padding: 0;
4
+ display: inline-block;
5
+ }
6
+
7
+ .sigPad label {
8
+ display: block;
9
+ margin: 0 0 0.515em;
10
+ padding: 0;
11
+
12
+ color: #000;
13
+ }
14
+
15
+ .sigPad label.error {
16
+ color: #f33;
17
+ }
18
+
19
+ .sigPad input {
20
+ margin: 0;
21
+ padding: 0.2em 0;
22
+
23
+ border: 1px solid #666;
24
+
25
+ font-size: 1em;
26
+ }
27
+
28
+ .sigPad input.error {
29
+ border-color: #f33;
30
+ }
31
+
32
+ .sig {
33
+ display: none;
34
+ }
35
+
36
+ .sigNav {
37
+ display: none;
38
+ height: 2.25em;
39
+ margin: 0;
40
+ padding: 0;
41
+ position: relative;
42
+
43
+ list-style-type: none;
44
+ }
45
+
46
+ .sigNav li {
47
+ display: inline;
48
+ float: left;
49
+ margin: 0;
50
+ padding: 0;
51
+ }
52
+
53
+ .sigNav a,
54
+ .sigNav a:link,
55
+ .sigNav a:visited {
56
+ display: block;
57
+ margin: 0;
58
+ padding: 0 0.6em;
59
+
60
+ border: 0;
61
+
62
+ color: #333;
63
+ font-weight: bold;
64
+ line-height: 2.25em;
65
+ text-decoration: underline;
66
+ }
67
+
68
+ .sigNav a.current,
69
+ .sigNav a.current:link,
70
+ .sigNav a.current:visited {
71
+ background-color: #666;
72
+ -moz-border-radius-topleft: 8px;
73
+ -moz-border-radius-topright: 8px;
74
+ -webkit-border-top-left-radius: 8px;
75
+ -webkit-border-top-right-radius: 8px;
76
+ border-radius: 8px 8px 0 0;
77
+
78
+ color: #fff;
79
+ text-decoration: none;
80
+ }
81
+
82
+ .sigNav .typeIt a.current,
83
+ .sigNav .typeIt a.current:link,
84
+ .sigNav .typeIt a.current:visited {
85
+ background-color: #ccc;
86
+
87
+ color: #555;
88
+ }
89
+
90
+ .sigNav .clearButton {
91
+ bottom: 0.2em;
92
+ display: none;
93
+ position: absolute;
94
+ right: 0;
95
+
96
+ font-size: 0.75em;
97
+ line-height: 1.375;
98
+ }
99
+
100
+ .sigWrapper {
101
+ clear: both;
102
+ border: 1px solid #ccc;
103
+ }
104
+
105
+ .sigWrapper.current {
106
+ border-color: #666;
107
+ }
108
+
109
+ .signed .sigWrapper {
110
+ border: 0;
111
+ }
112
+
113
+ .pad {
114
+ position: relative;
115
+
116
+ /**
117
+ * For cross browser compatibility, this should be an absolute URL
118
+ * In IE the cursor is relative to the HTML document
119
+ * In all other browsers the cursor is relative to the CSS file
120
+ *
121
+ * http://www.useragentman.com/blog/2011/12/21/cross-browser-css-cursor-images-in-depth/
122
+ */
123
+ cursor: image-url("active_scaffold_signaturepad/pen.cur"), crosshair;
124
+ /**
125
+ * IE will ignore this line because of the hotspot position
126
+ * Unfortunately we need this twice, because some browsers ignore the hotspot inside the .cur
127
+ */
128
+ cursor: image-url("active_scaffold_signaturepad/pen.cur") 16 16, crosshair;
129
+
130
+ -ms-touch-action: none;
131
+ -webkit-user-select: none;
132
+ -moz-user-select: none;
133
+ -ms-user-select: none;
134
+ -o-user-select: none;
135
+ user-select: none;
136
+ }
137
+
138
+ .typed {
139
+ height: 55px;
140
+ margin: 0;
141
+ padding: 0 5px;
142
+ position: absolute;
143
+ z-index: 90;
144
+
145
+ cursor: default;
146
+
147
+ color: #145394;
148
+ font: 1.875em/50px;
149
+ }
150
+
151
+ .typeItDesc,
152
+ .drawItDesc {
153
+ display: none;
154
+ margin: 0.75em 0 0.515em;
155
+ padding: 0.515em 0 0;
156
+
157
+ border-top: 3px solid #ccc;
158
+
159
+ color: #000;
160
+ }
161
+
162
+ p.error {
163
+ display: block;
164
+ margin: 0.5em 0;
165
+ padding: 0.4em;
166
+
167
+ background-color: #f33;
168
+
169
+ color: #fff;
170
+ font-weight: bold;
171
+ }
@@ -0,0 +1,3 @@
1
+ en:
2
+ active_scaffold:
3
+ sign_document: "Please sign the document"
@@ -0,0 +1,3 @@
1
+ es:
2
+ active_scaffold:
3
+ sign_document: "Por favor firma el documento"
@@ -0,0 +1,4 @@
1
+ module ActiveScaffoldSignaturepad
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module ActiveScaffoldSignaturepad
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 1
6
+
7
+ STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
@@ -0,0 +1,44 @@
1
+ module ActiveScaffoldSignaturepad
2
+ module ViewHelpers
3
+ ATTRIBUTES = [:line_colour, :line_width, :line_margin, :line_top, :bg_colour, :pen_colour, :pen_width, :pen_cap, :display_only, :error_message_draw]
4
+ def signaturepad_attributes(column)
5
+ attributes = ATTRIBUTES.map{ |attr| [attr, column.options[attr]] if column.options[attr] }
6
+ attributes = Hash[attributes].reverse_merge(:error_message_draw => :sign_document)
7
+ attributes[:type] = column.options[:type] if column.options[:type]
8
+ attributes[:error_message_draw] = as_(attributes[:error_message_draw]) if attributes[:error_message_draw].is_a? Symbol
9
+ attributes
10
+ end
11
+
12
+ def active_scaffold_input_signaturepad(column, html_options)
13
+ content_tag(:div, :class => "sigPad #{html_options[:class]}", :data => signaturepad_attributes(column)) do
14
+ content_tag(:ul, :class => 'sigNav') do
15
+ if column.options[:type]
16
+ content_tag(:li, link_to(as_(:type_it), '#type-it'), :class => 'typeIt') <<
17
+ content_tag(:li, link_to(as_(:draw_it), '#draw-it'), :class => 'drawIt')
18
+ else
19
+ ''.html_safe
20
+ end <<
21
+ content_tag(:li, link_to(as_(:clear), '#clear'), :class => 'clearButton')
22
+ end <<
23
+ content_tag(:div, :class => 'sig sigWrapper') do
24
+ (column.options[:type] ? content_tag(:div, '', :class => 'typed') : ''.html_safe) <<
25
+ content_tag(:canvas, '', :width => column.options[:width] || 250, :height => column.options[:height] || 100) <<
26
+ hidden_field(:record, column.name, html_options.merge(:class => 'output'))
27
+ end
28
+ end
29
+ end
30
+
31
+ def active_scaffold_column_signaturepad(record, column)
32
+ content_tag :div, :class => 'sigPad', :data => signaturepad_attributes(column).merge(:display_only => true, :signature => record.send(column.name)) do
33
+ content_tag :div, :class => 'sigWrapper' do
34
+ content_tag :canvas, '', :width => column.options[:width] || 250, :height => column.options[:height] || 100
35
+ end
36
+ end
37
+ end
38
+ alias_method :active_scaffold_show_signaturepad, :active_scaffold_column_signaturepad
39
+
40
+ def self.json_attributes
41
+ ATTRIBUTES.map { |attr| attr.to_s.camelize(:lower) }.to_json.html_safe
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,12 @@
1
+ require "active_scaffold_signaturepad/engine.rb"
2
+
3
+ module ActiveScaffoldSignaturepad
4
+ def self.root
5
+ File.dirname(__FILE__) + "/.."
6
+ end
7
+ autoload 'ViewHelpers', 'active_scaffold_signaturepad/view_helpers.rb'
8
+ end
9
+
10
+ ActionView::Base.send :include, ActiveScaffoldSignaturepad::ViewHelpers
11
+ ActiveScaffold.stylesheets << 'active_scaffold_signaturepad'
12
+ ActiveScaffold.javascripts << 'active_scaffold_signaturepad'
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_scaffold_signaturepad
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sergio Cambra
8
+ - Volker Hochstein
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-12-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '1.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '1.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: active_scaffold
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: 3.4.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: 3.4.0
56
+ description: Helper to display a signature zone on ActiveScaffold forms, using jquery.signaturepad
57
+ email: activescaffold@googlegroups.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files:
61
+ - LICENSE.txt
62
+ - README.textile
63
+ files:
64
+ - LICENSE.txt
65
+ - README.textile
66
+ - app/assets/images/active_scaffold_signaturepad/pen.cur
67
+ - app/assets/javascripts/active_scaffold_signaturepad.js.erb
68
+ - app/assets/javascripts/jquery.signaturepad/jquery.signaturepad.js
69
+ - app/assets/javascripts/jquery.signaturepad/json2.min.js
70
+ - app/assets/stylesheets/active_scaffold_signaturepad.scss
71
+ - config/locales/en.yml
72
+ - config/locales/es.yml
73
+ - lib/active_scaffold_signaturepad.rb
74
+ - lib/active_scaffold_signaturepad/engine.rb
75
+ - lib/active_scaffold_signaturepad/version.rb
76
+ - lib/active_scaffold_signaturepad/view_helpers.rb
77
+ homepage: http://github.com/activescaffold/active_scaffold_signaturepad
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.5
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Signaturepad form_ui using jquery.signaturepad
101
+ test_files: []