css_tt 0.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.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 [name of plugin creator]
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.
@@ -0,0 +1,60 @@
1
+ = CssTt
2
+
3
+ CssTt provides a simple way for creating pure css based tooltips. It was inspired by Alexander Dawson post http://sixrevisions.com/css/css-only-tooltips/ and some Alex Hall improvements http://www.devseo.co.uk/examples/pure-css-tooltips/, so I just wraped that up to a simple Rails plugin.
4
+
5
+ == Instalation
6
+
7
+ (sudo) gem install css_tt
8
+
9
+ Then
10
+ script/generate css_tt
11
+ which will generate css files and copy icon images to your public dir.
12
+
13
+ You will also need to add css to any layout header you will use css_tt in.
14
+ <%= stylesheet_link_tag 'css_tt' %>
15
+ or
16
+ <%= stylesheet_link_tag 'application', 'your_css_files', 'css_tt', :cache => 'cached_css' %>
17
+ and add
18
+ config.gem "css_tt"
19
+ in your environment.rb file
20
+
21
+ == Example
22
+
23
+ css_tt() helper method returns a html markup which with help of css makes tooltips for given string
24
+
25
+ Use helper in your views e.g.:
26
+ <%= css_tt("I am text to be explained on hover", "I am the text in tooltip") %>
27
+ This will generate a classic popup
28
+
29
+ Some options are available for tooltips, like :type, :transition and :title
30
+ - :type => possible options are :classic, :critical, :help, :warning an :info. Type defines the look of the tooltip and if other than classic adds an icon. Types are quite self explainable
31
+ - :transition => works only for webkit based browsers (i.e. Chrome, Safari), but is unobtrusive and does nothing on other browsers, because it's css based
32
+ - :title => tootip title, optional
33
+
34
+ You can use tooltips for whatever inline html element you want and add any
35
+ inline elements inside the tooltip.
36
+ <%= css_tt(link_to(smth, path),
37
+ "<b>find</b> more #{link_to('here', path)}",
38
+ :type => :info,
39
+ :title => "Outside link",
40
+ :transition => :left) %>
41
+
42
+ How do these look like http://www.devseo.co.uk/examples/pure-css-tooltips/
43
+
44
+ == Future
45
+
46
+ In the future I expect to add more optional tooltip styles to css_tt
47
+
48
+ == TODO
49
+
50
+ * Tutorial-like demo page
51
+ * Option to add css file link tag to layout file while generating
52
+ * Add more fancy stuff
53
+
54
+ == Collaboration
55
+
56
+ If you are a good designer, have some css styles for tooltips and want them in this gem, pm me http://github.com/medwezys.
57
+ Keep in mind that the structure of tooltip styles should be simmilar i.e. types - classic, info, warning, critical, help and so on. These are defined using css classes. More info in Alexander Dawson post http://sixrevisions.com/css/css-only-tooltips/
58
+
59
+ Copyright (c) 2010 Tadas Tamosauskas, Alexander Dawson, Alex Hall.
60
+ Released under the MIT license
@@ -0,0 +1,33 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
5
+
6
+ # PKG_FILES = FileList[
7
+ # '[a-zA-Z]*',
8
+ # 'generators/**/*',
9
+ # 'lib/**/*',
10
+ # 'rails/**/*',
11
+ # 'tasks/**/*',
12
+ # 'test/**/*'
13
+ # ]
14
+
15
+ desc 'Default: run unit tests.'
16
+ task :default => :test
17
+
18
+ desc 'Test the css_tt plugin.'
19
+ Rake::TestTask.new(:test) do |t|
20
+ t.libs << 'lib'
21
+ t.libs << 'test'
22
+ t.pattern = 'test/**/*_test.rb'
23
+ t.verbose = true
24
+ end
25
+
26
+ desc 'Generate documentation for the css_tt plugin.'
27
+ Rake::RDocTask.new(:rdoc) do |rdoc|
28
+ rdoc.rdoc_dir = 'rdoc'
29
+ rdoc.title = 'CssTt'
30
+ rdoc.options << '--line-numbers' << '--inline-source'
31
+ rdoc.rdoc_files.include('README.rdoc')
32
+ rdoc.rdoc_files.include('lib/**/*.rb')
33
+ end
@@ -0,0 +1,60 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ PKG_FILES = %w[
4
+ css_tt.gemspec
5
+ generators
6
+ install.rb
7
+ lib
8
+ MIT-LICENSE
9
+ pkg
10
+ rails
11
+ Rakefile
12
+ rdoc
13
+ README.rdoc
14
+ tasks
15
+ test
16
+ uninstall.rb
17
+ generators/css_tt
18
+ generators/css_tt/css_tt_generator.rb
19
+ generators/css_tt/templates
20
+ generators/css_tt/templates/critical.png
21
+ generators/css_tt/templates/css_tt.css
22
+ generators/css_tt/templates/help.png
23
+ generators/css_tt/templates/info.png
24
+ generators/css_tt/templates/warning.png
25
+ generators/css_tt/USAGE
26
+ lib/css_tt.rb
27
+ rails/init.rb
28
+ tasks/css_tt_tasks.rake
29
+ test/css_tt_test.rb
30
+ test/test_helper.rb
31
+ ]
32
+
33
+ s.name = %q{css_tt}
34
+ s.version = "0.0.3"
35
+
36
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
37
+ s.authors = ["Tadas Tamosauskas", "Alexander Dawson", "Alex Hall"]
38
+ s.date = %q{2010-06-20}
39
+ s.description = %q{Dead simple pure CSS based tooltips for Rails}
40
+ s.email = %q{tadastoo@yahoo.com}
41
+ s.extra_rdoc_files = ["README.rdoc"]
42
+ s.files = PKG_FILES.to_a
43
+ s.has_rdoc = true
44
+ s.homepage = %q{http://github.com/medwezys/css_tt}
45
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "CssTt", "--main", "README.rdoc"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = %q{1.3.7}
48
+ s.summary = %q{Dead simple pure CSS based tooltips for Rails.}
49
+ s.platform = Gem::Platform::RUBY
50
+
51
+ if s.respond_to? :specification_version then
52
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
+ s.specification_version = 2
54
+
55
+ if current_version >= 3 then
56
+ else
57
+ end
58
+ else
59
+ end
60
+ end
@@ -0,0 +1,11 @@
1
+ Usage:
2
+ script/generate css_tt
3
+
4
+ This will create:
5
+
6
+ # static files
7
+ public/stylesheets/css_tt.css
8
+ public/images/css_tt/info.png
9
+ public/images/css_tt/help.png
10
+ public/images/css_tt/warning.png
11
+ public/images/css_tt/critical.png
@@ -0,0 +1,23 @@
1
+ class CssTtGenerator < Rails::Generator::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+ # css file
6
+ m.file "css_tt.css", "public/stylesheets/css_tt.css"
7
+
8
+ # images
9
+ img_dir = "public/images/css_tt"
10
+ m.directory img_dir
11
+
12
+ # %(info warning critical help).each do |img|
13
+ # m.file "#{img}.txt", File.join(img_dir, "#{img}.txt")
14
+ # end
15
+ m.file "info.png", File.join(img_dir, "info.png")
16
+ m.file "warning.png", File.join(img_dir, "warning.png")
17
+ m.file "critical.png", File.join(img_dir, "critical.png")
18
+ m.file "help.png", File.join(img_dir, "help.png")
19
+
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,79 @@
1
+ .css_tt_hoverable {
2
+ border-bottom: 1px dotted #000;
3
+ color: #000;
4
+ outline: none;
5
+ cursor: help;
6
+ text-decoration: none;
7
+ position: relative;
8
+ }
9
+ .css_tt_hoverable span {
10
+ position: absolute;
11
+ top: 2em;
12
+ left: 1em;
13
+ width: 250px;
14
+ margin-left: -99em;
15
+ opacity: 0;
16
+
17
+ border-radius: 5px;
18
+ -moz-border-radius: 5px;
19
+ -webkit-border-radius: 5px;
20
+
21
+ box-shadow: 2px 2px 10px rgba(0,0,0,0.4);
22
+ -webkit-box-shadow: 2px 2px 10px rgba(0,0,0,0.4);
23
+ -moz-box-shadow: 2px 2px 10px rgba(0,0,0,0.4);
24
+
25
+ -moz-transition-property: opacity;
26
+ -moz-transition-duration: 1s;
27
+ -webkit-transition-property: opacity;
28
+ -webkit-transition-duration: 1s;
29
+ -o-transition-property: opacity;
30
+ -o-transition-duration: 1s;
31
+ }
32
+ .css_tt_hoverable.css_tt_left span {
33
+ -moz-transition-property: opacity, margin-left, left;
34
+ -moz-transition-duration: 1s;
35
+ -webkit-transition-property: opacity, margin-left, left;
36
+ -webkit-transition-duration: 1s;
37
+ -o-transition-property: opacity, margin-left, left;
38
+ -o-transition-duration: 1s;
39
+ }
40
+ .css_tt_hoverable.css_tt_top span {
41
+ top: -99em;
42
+ margin-left: auto;
43
+
44
+ -moz-transition-property: opacity, top;
45
+ -moz-transition-duration: 1s;
46
+ -webkit-transition-property: opacity, top;
47
+ -webkit-transition-duration: 1s;
48
+ -o-transition-property: opacity, top;
49
+ -o-transition-duration: 1s;
50
+ }
51
+ .css_tt_hoverable:hover span {
52
+ font-family: Calibri, Tahoma, Geneva, sans-serif;
53
+ z-index: 99;
54
+ margin-left: 0;
55
+ opacity: 1;
56
+ }
57
+ .css_tt_hoverable.css_tt_top:hover span {
58
+ top: 2em;
59
+ margin-left: auto;
60
+ }
61
+ .css_tt_hoverable img {
62
+ position: absolute;
63
+ border: 0;
64
+ margin: -10px 0 0 -55px;
65
+ float: left;
66
+ }
67
+ .css_tt_hoverable em {
68
+ font: 700 1.2em Candara, Tahoma, Geneva, sans-serif;
69
+ display: block;
70
+ padding: 0.2em 0 0.6em 0;
71
+ }
72
+ .classic { padding: 0.8em 1em; }
73
+ .custom { padding: 0.5em 0.8em 0.8em 2em; }
74
+ * html a:hover { background: transparent; }
75
+ .classic {background: #FFA; border: 1px solid #FFAD33; }
76
+ .critical { background: #FCA; border: 1px solid #FF3334; }
77
+ .help { background: #9FDAEE; border: 1px solid #2BB0D7; }
78
+ .info { background: #9FDAEE; border: 1px solid #2BB0D7; }
79
+ .warning { background: #FFA; border: 1px solid #FFAD33; }
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,47 @@
1
+ # provides helper method available in views to generate css based tooltips
2
+ module CssTt
3
+ module CssTtHelper
4
+ # Returns a html markup which with help of css makes tooltips for given string
5
+ #
6
+ # Use helper in your views e.g.:
7
+ # <%= css_tt("I am text to be explained on hover", "I am the text in tooltip") %>
8
+ # This will generate a classic popup
9
+ #
10
+ # Some options are available for tooltips, like :type, :transition and :title
11
+ # * :type => possible options are :classic, :critical, :help, :warning, :info
12
+ # type defines the look of the tooltip and if other than classic adds an icon.
13
+ # types are quote self explainable
14
+ # * :transition => works only for webkit based browsers (i.e. Chrome, Safari), but
15
+ # is unobtrusive and does nothing on other browsers, because it's css based
16
+ # * :title => tootip title, optional
17
+ #
18
+ # You can use tooltips for whatever inline html element you want and add any
19
+ # inline elements inside the tooltip.
20
+ # <%= css_tt(link_to(smth, path),
21
+ # "<b>find</b> more #{link_to('here', path)}",
22
+ # :type => :info,
23
+ # :title => "Outside link",
24
+ # :transition => :left) %>
25
+
26
+ def css_tt(smth_with_tooltip, tooltip_contents, opts = {})
27
+ defaults = {
28
+ :type => :classic, # [:classic, :critical, :help, :warning, :info]
29
+ :transition => nil, # [:left, :top]
30
+ :title => nil #Information, Warning, Achtung, Atsargiai...
31
+ }
32
+ opts = defaults.merge opts
33
+ opts[:transition] = "css_tt_#{opts[:transition]}" if opts[:transition]
34
+ #css classes
35
+ hoverable_class = ('css_tt_hoverable ' + "#{opts[:transition]}").strip
36
+ tooltip_class = (opts[:type] && opts[:type] != :classic) ? "custom #{opts[:type]}" : 'classic'
37
+
38
+ #tooltip itself
39
+ tooltip_contents = content_tag(:em, opts[:title])+tooltip_contents if opts[:title]
40
+ tooltip_contents = image_tag("/images/css_tt/#{opts[:type].to_s}.png", :alt => opts[:type].to_s, :width => "48", :height => "48")+tooltip_contents if opts[:type] && opts[:type] != :classic
41
+ tooltip = content_tag(:span, tooltip_contents, :class => tooltip_class)
42
+
43
+ #result
44
+ return content_tag(:span, smth_with_tooltip + tooltip, :class => hoverable_class)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1 @@
1
+ ActionView::Base.send :include, CssTt::CssTtHelper
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :css_tt do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class CssTtTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: css_tt
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
11
+ platform: ruby
12
+ authors:
13
+ - Tadas Tamosauskas
14
+ - Alexander Dawson
15
+ - Alex Hall
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2010-06-20 00:00:00 +03:00
21
+ default_executable:
22
+ dependencies: []
23
+
24
+ description: Dead simple pure CSS based tooltips for Rails
25
+ email: tadastoo@yahoo.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - README.rdoc
32
+ files:
33
+ - css_tt.gemspec
34
+ - install.rb
35
+ - MIT-LICENSE
36
+ - Rakefile
37
+ - README.rdoc
38
+ - uninstall.rb
39
+ - generators/css_tt/css_tt_generator.rb
40
+ - generators/css_tt/templates/critical.png
41
+ - generators/css_tt/templates/css_tt.css
42
+ - generators/css_tt/templates/help.png
43
+ - generators/css_tt/templates/info.png
44
+ - generators/css_tt/templates/warning.png
45
+ - generators/css_tt/USAGE
46
+ - lib/css_tt.rb
47
+ - rails/init.rb
48
+ - tasks/css_tt_tasks.rake
49
+ - test/css_tt_test.rb
50
+ - test/test_helper.rb
51
+ has_rdoc: true
52
+ homepage: http://github.com/medwezys/css_tt
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options:
57
+ - --line-numbers
58
+ - --inline-source
59
+ - --title
60
+ - CssTt
61
+ - --main
62
+ - README.rdoc
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ hash: 11
80
+ segments:
81
+ - 1
82
+ - 2
83
+ version: "1.2"
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.3.7
88
+ signing_key:
89
+ specification_version: 2
90
+ summary: Dead simple pure CSS based tooltips for Rails.
91
+ test_files: []
92
+