sketchily 1.2.0 → 1.3.0

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 CHANGED
@@ -59,6 +59,9 @@ Currently available options are:
59
59
  - `width` total width of editor
60
60
  - `height` total height of editor
61
61
 
62
+ - `bkgd_color` canvas background color (3 or 6 hex digit html color format; not saved with image)
63
+ - `bkgd_url` canvas background raster image url (not saved with image)
64
+
62
65
  - `canvas_width` initial canvas width
63
66
  - `canvas_height` initial canvas height
64
67
  - `canvas_expansion` 0 if you want to disable scrolling
File without changes
@@ -5,6 +5,8 @@
5
5
  # Additionally, they may override the following variables:
6
6
  width ||= "750px"
7
7
  height ||= "650px"
8
+ bkgd_color ||= "FFF"
9
+ bkgd_url ||= ""
8
10
  canvas_width ||= 640
9
11
  canvas_height ||= 480
10
12
  canvas_expansion ||= 3
@@ -19,14 +21,13 @@
19
21
  <% iframe_src = URI.parse("/assets/svg-editor.html")
20
22
 
21
23
  query_hash = {:dimensions => [canvas_width, canvas_height].join(','),
24
+ :bkgd_color => bkgd_color,
25
+ :bkgd_url => bkgd_url,
22
26
  :canvas_expansion => canvas_expansion,
23
27
  :showRulers => !hide_rulers,
24
28
  :showlayers => show_layers}
25
- if url
26
- query_hash[:url] = url
27
- else
28
- query_hash[:source] = nil
29
- end
29
+ query_hash[:url] = url if url
30
+ query_hash[:source] = nil unless url
30
31
 
31
32
  iframe_src.query = query_hash.map{|k,v| "#{k}=#{v}"}.join('&') %>
32
33
 
@@ -5,6 +5,8 @@
5
5
  # Additionally, they may override the following variables:
6
6
  width ||= "750px"
7
7
  height ||= "650px"
8
+ bkgd_color ||= "FFFFFF"
9
+ bkgd_url ||= ""
8
10
  canvas_width ||= 640
9
11
  canvas_height ||= 480
10
12
  canvas_expansion ||= 3
@@ -19,14 +21,13 @@
19
21
  <% iframe_src = URI.parse("/assets/svg-editor.html")
20
22
 
21
23
  query_hash = {:dimensions => [canvas_width, canvas_height].join(','),
24
+ :bkgd_color => bkgd_color,
25
+ :bkgd_url => bkgd_url,
22
26
  :canvas_expansion => canvas_expansion,
23
27
  :showRulers => !hide_rulers,
24
28
  :showlayers => show_layers}
25
- if url
26
- query_hash[:url] = url
27
- else
28
- query_hash[:source] = nil
29
- end
29
+ query_hash[:url] = url if url
30
+ query_hash[:source] = nil unless url
30
31
 
31
32
  iframe_src.query = query_hash.map{|k,v| "#{k}=#{v}"}.join('&') %>
32
33
 
@@ -49,3 +50,4 @@
49
50
  :hide_hyperlink_tool => hide_hyperlink_tool,
50
51
  :url => url} %>
51
52
  </script>
53
+
@@ -1,3 +1,3 @@
1
1
  module Sketchily
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Sketchily
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
data/lib/sketchily.rb CHANGED
@@ -5,7 +5,7 @@ require "sketchily/sketchily_tag"
5
5
  module Sketchily
6
6
  ASSET_FILES = %w(sketchily.css sketchily.js sketchily_embed.js canvg/canvg.js canvg/rgbcolor.js extensions/ext-*.js locale/lang.*.js)
7
7
 
8
- SKETCHILY_OPTIONS = [:width, :height, :canvas_width, :canvas_height, :canvas_expansion, :hide_rulers, :hide_menu, :hide_image_tool, :hide_hyperlink_tool, :show_layers, :url]
8
+ SKETCHILY_OPTIONS = [:width, :height, :bkgd_color, :bkgd_url, :canvas_width, :canvas_height, :canvas_expansion, :hide_rulers, :hide_menu, :hide_image_tool, :hide_hyperlink_tool, :show_layers, :url]
9
9
  TAG_OPTIONS = [:id, :value, :index]
10
10
  OPTIONS = SKETCHILY_OPTIONS + TAG_OPTIONS
11
11
 
data/lib/sketchily.rb~ CHANGED
@@ -5,7 +5,7 @@ require "sketchily/sketchily_tag"
5
5
  module Sketchily
6
6
  ASSET_FILES = %w(sketchily.css sketchily.js sketchily_embed.js canvg/canvg.js canvg/rgbcolor.js extensions/ext-*.js locale/lang.*.js)
7
7
 
8
- SKETCHILY_OPTIONS = [:width, :height, :canvas_width, :canvas_height, :canvas_expansion, :hide_rulers, :hide_menu, :hide_image_tool, :hide_hyperlink_tool, :url, :show_layers]
8
+ SKETCHILY_OPTIONS = [:width, :height, :canvas_width, :canvas_height, :canvas_expansion, :hide_rulers, :hide_menu, :hide_image_tool, :hide_hyperlink_tool, :show_layers, :url]
9
9
  TAG_OPTIONS = [:id, :value, :index]
10
10
  OPTIONS = SKETCHILY_OPTIONS + TAG_OPTIONS
11
11
 
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.2.0
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -101,6 +101,7 @@ extra_rdoc_files: []
101
101
  files:
102
102
  - app/assets/stylesheets/sketchily.css~
103
103
  - app/assets/stylesheets/sketchily.css
104
+ - app/assets/javascripts/base64.js
104
105
  - app/assets/javascripts/sketchily.js
105
106
  - app/assets/javascripts/sketchily.js~
106
107
  - app/assets/javascripts/sketchily_embed.js
@@ -359,8 +360,6 @@ files:
359
360
  - vendor/assets/svg-edit-2.6/jquerybbq/jquery.bbq.min.js
360
361
  - vendor/assets/svg-edit-2.6/js-hotkeys/jquery.hotkeys.min.js
361
362
  - vendor/assets/svg-edit-2.6/js-hotkeys/README.md
362
- - vendor/assets/javascripts/base64.js
363
- - vendor/assets/javascripts/base64.js~
364
363
  - MIT-LICENSE
365
364
  - Rakefile
366
365
  - README.md
@@ -1,95 +0,0 @@
1
- // This code was written by Tyler Akins and has been placed in the
2
- // public domain. It would be nice if you left this header intact.
3
- // Base64 code from Tyler Akins -- http://rumkin.com
4
-
5
- // schiller: Removed string concatenation in favour of Array.join() optimization,
6
- // also precalculate the size of the array needed.
7
-
8
- // Function: sketchily_encode64
9
- // Converts a string to base64
10
- var sketchily_encode64 = function(input) {
11
- // base64 strings are 4/3 larger than the original string
12
- input = sketchily_convertToXMLReferences(input);
13
- if(window.btoa) return window.btoa(input); // Use native if available
14
- var output = new Array( Math.floor( (input.length + 2) / 3 ) * 4 );
15
- var chr1, chr2, chr3;
16
- var enc1, enc2, enc3, enc4;
17
- var i = 0, p = 0;
18
-
19
- do {
20
- chr1 = input.charCodeAt(i++);
21
- chr2 = input.charCodeAt(i++);
22
- chr3 = input.charCodeAt(i++);
23
-
24
- enc1 = chr1 >> 2;
25
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
26
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
27
- enc4 = chr3 & 63;
28
-
29
- if (isNaN(chr2)) {
30
- enc3 = enc4 = 64;
31
- } else if (isNaN(chr3)) {
32
- enc4 = 64;
33
- }
34
-
35
- output[p++] = KEYSTR.charAt(enc1);
36
- output[p++] = KEYSTR.charAt(enc2);
37
- output[p++] = KEYSTR.charAt(enc3);
38
- output[p++] = KEYSTR.charAt(enc4);
39
- } while (i < input.length);
40
-
41
- return output.join('');
42
- };
43
-
44
- // Function: sketchily_decode64
45
- // Converts a string from base64
46
- var sketchily_decode64 = function(input) {
47
- if(window.atob) return window.atob(input);
48
- var output = "";
49
- var chr1, chr2, chr3 = "";
50
- var enc1, enc2, enc3, enc4 = "";
51
- var i = 0;
52
-
53
- // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
54
- input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
55
-
56
- do {
57
- enc1 = KEYSTR.indexOf(input.charAt(i++));
58
- enc2 = KEYSTR.indexOf(input.charAt(i++));
59
- enc3 = KEYSTR.indexOf(input.charAt(i++));
60
- enc4 = KEYSTR.indexOf(input.charAt(i++));
61
-
62
- chr1 = (enc1 << 2) | (enc2 >> 4);
63
- chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
64
- chr3 = ((enc3 & 3) << 6) | enc4;
65
-
66
- output = output + String.fromCharCode(chr1);
67
-
68
- if (enc3 != 64) {
69
- output = output + String.fromCharCode(chr2);
70
- }
71
- if (enc4 != 64) {
72
- output = output + String.fromCharCode(chr3);
73
- }
74
-
75
- chr1 = chr2 = chr3 = "";
76
- enc1 = enc2 = enc3 = enc4 = "";
77
-
78
- } while (i < input.length);
79
- return unescape(output);
80
- };
81
-
82
- // Function: sketchily_convertToXMLReferences
83
- // Converts a string to use XML references
84
- sketchily_convertToXMLReferences = function(input) {
85
- var output = '';
86
- for (var n = 0; n < input.length; n++){
87
- var c = input.charCodeAt(n);
88
- if (c < 128) {
89
- output += input[n];
90
- } else if(c > 127) {
91
- output += ("&#" + c + ";");
92
- }
93
- }
94
- return output;
95
- };