html2img 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec147c60b7bc797af688e1392877ce1598026719
4
- data.tar.gz: 53b106fbb46e04380f75dac91fcaf1d038820ccc
3
+ metadata.gz: a17aecb720b42a620844666fdb6ee1b3135fbe1a
4
+ data.tar.gz: 7abb45e362ba1a9d4b10e4aca2411a9e670d22f0
5
5
  SHA512:
6
- metadata.gz: 0c85226c312cbea783eb4ec6edb9080bcf8a676c6f775518f4f01ee839db2d9e894e34171297040b7a542dc2a1cd48e4652b33743da825c690f6dae7677132c7
7
- data.tar.gz: 30793baa92d5a6a5f19a898e2dd4cdbfd988959fb23b24364fb7b3cd93e47fd1fc8f473051ee5b3ae86c3a55133ec13f6dcae96e2eba3aa9ae25b88fae1db334
6
+ metadata.gz: fb8fdbcaae18aa9c5c57ae57919b7baa0d89f2181b460afb13fcfd5ef8ef0c32d98c5ac1b9d60f7ee8565f1392e54ede174be5ce30b03378c409d3582152e8f2
7
+ data.tar.gz: cac25be1a7a44c782f19c61d57d76953bdd8e6b54e2de6865769bfa033e4dfe5064c2570a41eb0359e12d39e574a97ba3ebc1bfc587e6a4a46bfb6e78c6d2c4c
@@ -6,27 +6,47 @@ $(function() {
6
6
  // console.log( index + ": " + $( this ).text() );
7
7
  //$("[id^=html2img]").click(function() {
8
8
 
9
- $("[class^=html2img-#download-#]").click(function() {
9
+ $("[class^=html2img-#]").click(function() {
10
10
  console.log("start")
11
- var img_id = returnHtml2imgID($(this));
11
+ var h2i = returnHtml2imgID($(this));
12
12
  // console.log(cls);
13
13
  // var img_id = "#" + id.split("-#")[2];
14
14
 
15
+ var img_id = "#" + h2i.id;
15
16
  console.log(img_id);
17
+ console.log(h2i.method);
18
+ switch(h2i.method) {
19
+ case "download":
20
+ html2canvas($(img_id), {
21
+ onrendered: function(canvas) {
22
+ //theCanvas = canvas;
23
+ // document.body.appendChild(canvas);
24
+
25
+ // Convert and download as image and downloads
26
+ Canvas2Image.saveAsPNG(canvas);
27
+ //$(this).replaceWith(canvas);
28
+ // $("#img-out").append(canvas);
29
+ // Clean up
30
+ //document.body.removeChild(canvas);
31
+ }
32
+ });
33
+ break;
34
+ case "print":
35
+ html2canvas($(img_id), {
36
+ onrendered: function(canvas) {
37
+ theCanvas = canvas;
38
+ document.body.appendChild(canvas);
39
+
40
+ // Convert and download as image
41
+ //Canvas2Image.saveAsPNG(canvas);
42
+ $(".html2img-out-" + h2i.id).append(canvas);
43
+ }
44
+ });
45
+ break;
46
+
47
+
48
+ }
16
49
 
17
- html2canvas($(img_id), {
18
- onrendered: function(canvas) {
19
- //theCanvas = canvas;
20
- // document.body.appendChild(canvas);
21
-
22
- // Convert and download as image and downloads
23
- Canvas2Image.saveAsPNG(canvas);
24
- //$(this).replaceWith(canvas);
25
- // $("#img-out").append(canvas);
26
- // Clean up
27
- //document.body.removeChild(canvas);
28
- }
29
- });
30
50
  });
31
51
 
32
52
  function returnHtml2imgID(el) {
@@ -35,12 +55,16 @@ $(function() {
35
55
  for (i in classList) {
36
56
  item = classList[i];
37
57
  console.log(item);
38
- var id = item.split("html2img-#download-#")[1];
39
-
40
- if (id !== undefined) {
41
- console.log(id);
42
- //do something
43
- return "#" + id;
58
+ var index = item.search("html2img");
59
+ // var id = item.split("html2img-#download-#")[1];
60
+ console.log(index);
61
+ if (index > -1) {
62
+
63
+ return {
64
+ id: item.split("-#")[2],
65
+ method: item.split("-#")[1]
66
+ };
67
+
44
68
  }
45
69
  }
46
70
 
Binary file
@@ -1,3 +1,3 @@
1
1
  module Html2img
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html2img
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Mothershaw
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-08 00:00:00.000000000 Z
11
+ date: 2016-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,6 +57,7 @@ files:
57
57
  - bin/console
58
58
  - bin/setup
59
59
  - html2img-0.0.2.gem
60
+ - html2img-0.0.3.gem
60
61
  - html2img.gemspec
61
62
  - lib/html2img.rb
62
63
  - lib/html2img/engine.rb