active_scaffold_signaturepad 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f4e79f674fe254f1706e6aa02c2e850b0752a9d6
4
+ data.tar.gz: 157ad8d3523717241b774d62df6eed74cc21902b
5
+ SHA512:
6
+ metadata.gz: 5f27772edad9aa856f3733d27f94bae470d5c0369abbbedcad05e69db6ca05e54066543f3a7fd65c646eddcd34f88d888a25e3f9ef9599f63fb75555f9f44147
7
+ data.tar.gz: 0cdd63478ce959a0d8c982eba153cff2d59228d1937df4adcd8543a39547177ec2782cd9b0f1fbe750b7e1bcf62a2abd2fefe7efc689fea944f196a4ecd892c6
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011-2012 Sergio Cambra
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,61 @@
1
+ h1. Signaturepad for ActiveScaffold
2
+
3
+ Currently, this plugin is compatible with ActiveScaffold >= 3.4 gem.
4
+
5
+ h2. Overview
6
+
7
+ This plugin adds a signaturepad form_ui to display a signature area. It uses "jquery.signaturepad":https://github.com/thomasjbradley/signature-pad
8
+
9
+ h2. Installation
10
+
11
+ You'll need at least ActiveScaffold 3.4 to use this
12
+
13
+
14
+ <pre>
15
+ gem install active_scaffold_signaturepad
16
+ </pre>
17
+
18
+ h2. Usage
19
+
20
+ h4. Step 1
21
+
22
+ Set column to use :signaturepad form_ui
23
+
24
+ h4. Step 2
25
+
26
+ Setup signaturepad using options method on column
27
+
28
+ <pre>
29
+ # app/controllers/visitors_controller.rb
30
+
31
+ class VisitorsController < ApplicationController
32
+ active_scaffold :visitor do |config|
33
+ config.columns[:signature].form_ui = :signaturepad
34
+ config.columns[:signature].options = {
35
+ :width => 150, # canvas width, default 250
36
+ :height => 55, # canvas height, default 100
37
+ :lineColour => 'transparent' # colour for signature line on canvas, transparent for none
38
+ }
39
+ end
40
+ end
41
+ </pre>
42
+
43
+ h4. Save image
44
+
45
+ Signaturepad sends a JSON representation to signature. It can be converted to image on server, adding some code to model:
46
+
47
+ https://gist.github.com/branch14/4258871
48
+
49
+ h2. Support
50
+
51
+ If you have issues installing the plugin, search / post to the "Active Scaffold":http://groups.google.com/group/activescaffold forum or "Create an issue":http://github.com/activescaffold/active_scaffold_signaturepad/issues
52
+
53
+ h2. Contributing
54
+
55
+ Fork, hack, push, and request a pull:
56
+
57
+ http://github.com/activescaffold/active_scaffold_signaturepad/
58
+
59
+ h2. License
60
+
61
+ Released under the MIT license (included).
@@ -0,0 +1,34 @@
1
+ //= require_tree ./jquery.signaturepad
2
+ //= require_self
3
+
4
+ ActiveScaffold.signaturepad = function(selector_or_elements, parent) {
5
+ var elements;
6
+ if (!jQuery.fn.signaturePad) return;
7
+ if (typeof(selector_or_elements) == 'string') elements = jQuery(selector_or_elements, parent);
8
+ else elements = jQuery(selector_or_elements);
9
+
10
+ var attributes = <%= ActiveScaffoldSignaturepad::ViewHelpers.json_attributes %>;
11
+ elements.each(function() {
12
+ var options = {}, $pad = $(this);
13
+ $.each(attributes, function(i, opt) {
14
+ var val = $pad.data(opt);
15
+ if (val != null) options[opt] = val;
16
+ });
17
+ if (!options.displayOnly) options.drawOnly = !$pad.data('type');
18
+ var api = $pad.signaturePad(options);
19
+ if (options.displayOnly) api.regenerate($pad.data('signature'));
20
+ });
21
+ };
22
+
23
+ jQuery(document).ready(function($) {
24
+ $(document).on('as:action_success', 'a.as_action', function(e, action_link) {
25
+ var pads = $('.sigPad', action_link.adapter);
26
+ if (pads.length) ActiveScaffold.signaturepad(pads);
27
+ });
28
+ $(document).on('as:element_updated', function(e) {
29
+ var pads = $('.sigPad', e.target);
30
+ if (pads.length) ActiveScaffold.signaturepad(pads);
31
+ });
32
+ var pads = $('.sigPad');
33
+ if (pads.length) ActiveScaffold.signaturepad(pads);
34
+ });