print_preview-rails 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 03c8fe6c851752d6905307b7d662975a423fbe62
4
+ data.tar.gz: 7a8f884ce14c87c9356553efdb836d790268d3ca
5
+ SHA512:
6
+ metadata.gz: 4d840c83058c45efe6d72e8068e5c9ae8d627cb1c47c762fdef8c735751e71bd4a6984823cdc328a90dc6ad407b2973b84452e59fb7023bac45f171482f7d5a9
7
+ data.tar.gz: dba81213037ecefc86743673c0e5c77498b73359b1ec3083227d8c4b56cc9c3962520dab3b5133e35c05e1f6cdb445942ac67b674ff7dca0a7b1ed296c57ec44
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 YOURNAME
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.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = PrintPreviewRails
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'PrintPreviewRails'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
@@ -0,0 +1 @@
1
+ //= require_tree .
@@ -0,0 +1,54 @@
1
+ # depends of Browser object of lib do_rails
2
+
3
+ HTMLElement.prototype.printPreview = ->
4
+
5
+ if navigator.vendor == "Google Inc."
6
+ window.print()
7
+
8
+ else
9
+
10
+ # tentar migrar para jQuery
11
+ styleLinks = document.getElementsByTagName("link")
12
+ print = this.cloneNode(true)
13
+ head = document.getElementsByTagName("head").item(0).cloneNode(true)
14
+ preview = window.open()
15
+
16
+ printHTML = preview.document.getElementsByTagName("html").item(0)
17
+ printHead = preview.document.getElementsByTagName("head").item(0)
18
+ printHTML.replaceChild head, printHead
19
+
20
+ printHead = preview.document.getElementsByTagName("head").item(0)
21
+ htmlCollection = document.createElement("script")
22
+ nodeList = document.createElement("script")
23
+ printHead.appendChild htmlCollection
24
+ printHead.appendChild nodeList
25
+
26
+ # bug no FF. um document.createElement("script") no firefox retorna function() enquanto no Chrome e em outros navegadores, retorna HTMLScriptElement.
27
+ # uma solução seria colocar o código direto aqui para printar nas tags script. Mas iria ficar com uma cara ridícua de gambiarra por causa do bug do FF
28
+ htmlCollection.printFunction
29
+ prototype: "HTMLCollection"
30
+ name: "each"
31
+ body: HTMLCollection.prototype.each
32
+
33
+ nodeList.printFunction
34
+ prototype: "NodeList"
35
+ name: "each"
36
+ body: NodeList.prototype.each
37
+
38
+ # ele nem chegou aqui. Será que resolvendo o problema do script, ele reconhecerá o each para iterar sobre Nodes e HTMLCollections? Pois eu duvido muitíssimo. Moro, porra?
39
+ previewStyleLinks = preview.document.getElementsByTagName("link")
40
+ previewStyleLinks.each (printLink, i)->
41
+ printLink.href = styleLinks.item(i).href
42
+
43
+ printBody = preview.document.getElementsByTagName("body").item(0)
44
+ printBody.appendChild print
45
+ printBody.className = "print-preview"
46
+
47
+ imgs = document.querySelectorAll(".#{this.className} img") || document.querySelectorAll("##{this.id} img")
48
+ printImgs = preview.document.getElementsByTagName("img")
49
+ printImgs.each (printImg, i) ->
50
+ printImg.src = imgs.item(i).src
51
+
52
+ printAnchors = preview.document.querySelectorAll("a")
53
+ printAnchors.each (printAnchor, i) ->
54
+ printAnchor.href = "#"
@@ -0,0 +1,4 @@
1
+ require "print_preview/rails"
2
+
3
+ module PrintPreview
4
+ end
@@ -0,0 +1,4 @@
1
+ require "print_preview/rails/engine"
2
+
3
+ module PrintPreview
4
+ end
@@ -0,0 +1,7 @@
1
+ module PrintPreview
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace PrintPreview
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module PrintPreview
2
+ module Rails
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: print_preview-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - home-labs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 4.2.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 4.2.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.2.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: do_rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.0.3
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.0.3
47
+ description: Description of PrintPreview.
48
+ email:
49
+ - home-labs@outlook.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - README.rdoc
56
+ - Rakefile
57
+ - lib/assets/javascripts/print_preview/all.js
58
+ - lib/assets/javascripts/print_preview/print_preview.coffee
59
+ - lib/print_preview-rails.rb
60
+ - lib/print_preview/rails.rb
61
+ - lib/print_preview/rails/engine.rb
62
+ - lib/print_preview/rails/version.rb
63
+ homepage: https://rubygems.org/gems/print_preview-rails
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.8
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Summary of PrintPreview.
87
+ test_files: []