sketchily 1.0.2 → 1.0.3
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/README.md +19 -19
- data/app/views/sketchily/_embed.js.erb +11 -7
- data/app/views/sketchily/_embed.js.erb~ +13 -8
- data/lib/sketchily/version.rb +1 -1
- data/lib/sketchily/version.rb~ +1 -1
- metadata +2 -2
data/README.md
CHANGED
|
@@ -8,27 +8,27 @@ Currently supports and provides `svg-edit-2.6`.
|
|
|
8
8
|
|
|
9
9
|
Add this line to your application's Gemfile:
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
```rb
|
|
12
|
+
gem 'sketchily'
|
|
13
|
+
```
|
|
14
14
|
|
|
15
15
|
And then execute:
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
```sh
|
|
18
|
+
$ bundle
|
|
19
|
+
```
|
|
20
20
|
|
|
21
21
|
Or install it yourself as:
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
```sh
|
|
24
|
+
$ gem install sketchily
|
|
25
|
+
```
|
|
26
26
|
|
|
27
27
|
Also make sure your `application.js` requires jquery (it usually does by default):
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
```js
|
|
30
|
+
//= require jquery
|
|
31
|
+
```
|
|
32
32
|
|
|
33
33
|
**Note:** sketchily will **automatically** add the following files to your asset precompilation list:
|
|
34
34
|
|
|
@@ -73,10 +73,10 @@ The following examples assume that the database table for `@my_object` has a `sk
|
|
|
73
73
|
|
|
74
74
|
Example usage (haml):
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
```haml
|
|
77
|
+
= form_for @my_object do |f|
|
|
78
|
+
= f.sketchily :sketch, :hide_menu => true
|
|
79
|
+
```
|
|
80
80
|
|
|
81
81
|
### `sketchily_show` helper
|
|
82
82
|
|
|
@@ -92,9 +92,9 @@ Passing only one of those options should keep the aspect ratio of the SVG consta
|
|
|
92
92
|
|
|
93
93
|
Example usage (haml):
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
```haml
|
|
96
|
+
= sketchily_show @my_object.sketch, :width => "500"
|
|
97
|
+
```
|
|
98
98
|
|
|
99
99
|
## Browser Support
|
|
100
100
|
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
var svgCanvas_<%= id %> = null;
|
|
11
11
|
|
|
12
|
+
function submitHandler_<%= id %>(e) {
|
|
13
|
+
svgCanvas_<%= id %>.getSvgString()(handleSvgData_<%= id %>);
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
e.stopImmediatePropagation();
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
function attachSubmitHandler_<%= id %>() {
|
|
13
|
-
$("input#<%= id %>").closest("form").
|
|
14
|
-
svgCanvas_<%= id %>.getSvgString()(handleSvgData_<%= id %>);
|
|
15
|
-
return false;
|
|
16
|
-
});
|
|
19
|
+
$("input#<%= id %>").closest("form").on("submit", submitHandler_<%= id %>);
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
function handleSvgData_<%= id %>(data, error) {
|
|
@@ -22,8 +25,9 @@ function handleSvgData_<%= id %>(data, error) {
|
|
|
22
25
|
}
|
|
23
26
|
else {
|
|
24
27
|
$("input#<%= id %>").attr("value", svgedit.utilities.encode64("<?xml version=\"1.0\"?>\n" + data));
|
|
28
|
+
$("input#<%= id %>").closest("form").off("submit", submitHandler_<%= id %>);
|
|
29
|
+
$("input#<%= id %>").closest("form").one("submit", attachSubmitHandler_<%= id %>);
|
|
25
30
|
$("input#<%= id %>").closest("form").submit();
|
|
26
|
-
attachSubmitHandler_<%= id %>();
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -53,10 +57,10 @@ function initEmbed_<%= id %>() {
|
|
|
53
57
|
var hyperlinkTool = doc.getElementById('tool_make_link');
|
|
54
58
|
hyperlinkTool.parentNode.removeChild(hyperlinkTool);
|
|
55
59
|
<% end %>
|
|
56
|
-
|
|
57
|
-
attachSubmitHandler_<%= id %>();
|
|
58
60
|
|
|
59
61
|
svgCanvas_<%= id %>.setSvgString(svgedit.utilities.decode64("<%= value.try(:squish) %>"));
|
|
62
|
+
|
|
63
|
+
attachSubmitHandler_<%= id %>();
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
$("#svgedit_<%= id %>").load(initEmbed_<%= id %>);
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
var svgCanvas_<%= id %> = null;
|
|
11
11
|
|
|
12
|
+
function submitHandler_<%= id %>(e) {
|
|
13
|
+
svgCanvas_<%= id %>.getSvgString()(handleSvgData_<%= id %>);
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
e.stopImmediatePropagation();
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
function attachSubmitHandler_<%= id %>() {
|
|
13
|
-
$("input#<%= id %>").closest("form").
|
|
14
|
-
svgCanvas_<%= id %>.getSvgString()(handleSvgData_<%= id %>);
|
|
15
|
-
return false;
|
|
16
|
-
});
|
|
19
|
+
$("input#<%= id %>").closest("form").on("submit", submitHandler_<%= id %>);
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
function handleSvgData_<%= id %>(data, error) {
|
|
@@ -22,8 +25,10 @@ function handleSvgData_<%= id %>(data, error) {
|
|
|
22
25
|
}
|
|
23
26
|
else {
|
|
24
27
|
$("input#<%= id %>").attr("value", svgedit.utilities.encode64("<?xml version=\"1.0\"?>\n" + data));
|
|
28
|
+
$("input#<%= id %>").closest("form").off("submit", submitHandler_<%= id %>);
|
|
29
|
+
waitingForCallback_<%= id %> = false;
|
|
30
|
+
$("input#<%= id %>").closest("form").one("submit", attachSubmitHandler_<%= id %>);
|
|
25
31
|
$("input#<%= id %>").closest("form").submit();
|
|
26
|
-
attachSubmitHandler_<%= id %>();
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
|
|
@@ -53,10 +58,10 @@ function initEmbed_<%= id %>() {
|
|
|
53
58
|
var hyperlinkTool = doc.getElementById('tool_make_link');
|
|
54
59
|
hyperlinkTool.parentNode.removeChild(hyperlinkTool);
|
|
55
60
|
<% end %>
|
|
56
|
-
|
|
57
|
-
attachSubmitHandler_<%= id %>();
|
|
58
61
|
|
|
59
62
|
svgCanvas_<%= id %>.setSvgString(svgedit.utilities.decode64("<%= value.try(:squish) %>"));
|
|
63
|
+
|
|
64
|
+
attachSubmitHandler_<%= id %>();
|
|
60
65
|
}
|
|
61
66
|
|
|
62
|
-
$().load(initEmbed_<%= id %>);
|
|
67
|
+
$("#svgedit_<%= id %>").load(initEmbed_<%= id %>);
|
data/lib/sketchily/version.rb
CHANGED
data/lib/sketchily/version.rb~
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sketchily
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-02-
|
|
12
|
+
date: 2013-02-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|