Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit ba9d28cd1ffd2f5f58c5b69fea2b10d8751b2658 @nragaz committed Jun 29, 2011
3 .gitignore
@@ -0,0 +1,3 @@
+pkg/*
+tmp
+*.gem
9 Gemfile
@@ -0,0 +1,9 @@
+source :gemcutter
+
+# Specify your gem's dependencies in jquery-rails.gemspec
+gemspec
+# Rails is already being pulled in through gemspec
+# gem "rails", :git => "git://github.com/rails/rails.git"
+gem "rack", :git => "git://github.com/rack/rack.git"
+gem "sprockets", :git => "git://github.com/sstephenson/sprockets.git"
+gem "i18n", "0.6.0beta1"
120 Gemfile.lock
@@ -0,0 +1,120 @@
+GIT
+ remote: git://github.com/rack/rack.git
+ revision: a9beb476b27914794743d0677b327d5bafb5e8a3
+ specs:
+ rack (1.2.1)
+
+GIT
+ remote: git://github.com/rails/rails.git
+ revision: 2fbbd08616c25dc2931eca914349dd2161766f69
+ specs:
+ actionmailer (3.1.0.beta)
+ actionpack (= 3.1.0.beta)
+ mail (~> 2.3.0)
+ actionpack (3.1.0.beta)
+ activemodel (= 3.1.0.beta)
+ activesupport (= 3.1.0.beta)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6.0beta1)
+ rack (~> 1.2.1)
+ rack-cache (~> 1.0.0)
+ rack-mount (~> 0.7.2)
+ rack-test (~> 0.5.7)
+ sprockets (~> 2.0.0.beta.2)
+ tzinfo (~> 0.3.23)
+ activemodel (3.1.0.beta)
+ activesupport (= 3.1.0.beta)
+ bcrypt-ruby (~> 2.1.4)
+ builder (~> 3.0.0)
+ i18n (~> 0.6.0beta1)
+ activerecord (3.1.0.beta)
+ activemodel (= 3.1.0.beta)
+ activesupport (= 3.1.0.beta)
+ arel (~> 2.1.0)
+ tzinfo (~> 0.3.23)
+ activeresource (3.1.0.beta)
+ activemodel (= 3.1.0.beta)
+ activesupport (= 3.1.0.beta)
+ activesupport (3.1.0.beta)
+ multi_json (~> 1.0.0)
+ rails (3.1.0.beta)
+ actionmailer (= 3.1.0.beta)
+ actionpack (= 3.1.0.beta)
+ activerecord (= 3.1.0.beta)
+ activeresource (= 3.1.0.beta)
+ activesupport (= 3.1.0.beta)
+ bundler (~> 1.0)
+ railties (= 3.1.0.beta)
+ railties (3.1.0.beta)
+ actionpack (= 3.1.0.beta)
+ activesupport (= 3.1.0.beta)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
+
+GIT
+ remote: git://github.com/sstephenson/sprockets.git
+ revision: c4800417792744c11eb1fb888bbe9a3a82859952
+ specs:
+ sprockets (2.0.0.beta.2)
+ hike (~> 1.0)
+ rack (~> 1.0)
+ tilt (~> 1.0)
+
+PATH
+ remote: .
+ specs:
+ jquery-rails (0.3)
+ rails (~> 3.1)
+ thor (~> 0.14.4)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ addressable (2.2.4)
+ arel (2.1.0)
+ bcrypt-ruby (2.1.4)
+ builder (3.0.0)
+ crack (0.1.8)
+ erubis (2.7.0)
+ hike (1.0.0)
+ i18n (0.6.0beta1)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ multi_json (1.0.0)
+ polyglot (0.3.1)
+ rack-cache (1.0.1)
+ rack (>= 0.4)
+ rack-mount (0.7.2)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rake (0.8.7)
+ rspec (1.3.1)
+ thor (0.14.6)
+ tilt (1.3)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.27)
+ webmock (1.6.2)
+ addressable (>= 2.2.2)
+ crack (>= 0.1.7)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bundler (~> 1.0.0)
+ i18n (= 0.6.0beta1)
+ jquery-rails!
+ rack!
+ rails!
+ rspec (~> 1.3)
+ sprockets!
+ webmock (~> 1.6.2)
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Nick Ragaz
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
5 README.md
@@ -0,0 +1,5 @@
+# tipsy-rails
+
+This gem provides the jQuery Tipsy plugin for your Rails 3.1 app.
+
+For more information about Tipsy, visit http://onehackoranother.com/projects/jquery/tipsy/
2 Rakefile
@@ -0,0 +1,2 @@
+require 'bundler'
+Bundler::GemHelper.install_tasks
1 lib/tipsy-rails.rb
@@ -0,0 +1 @@
+require 'tipsy/rails'
6 lib/tipsy/rails.rb
@@ -0,0 +1,6 @@
+module Tipsy
+ module Rails
+ require 'tipsy/rails/engine'
+ require 'tipsy/rails/version'
+ end
+end
6 lib/tipsy/rails/engine.rb
@@ -0,0 +1,6 @@
+module Tipsy
+ module Rails
+ class Engine < ::Rails::Engine
+ end
+ end
+end
6 lib/tipsy/rails/version.rb
@@ -0,0 +1,6 @@
+module Tipsy
+ module Rails
+ VERSION = "1.0.0"
+ FANCYBOX_VERSION = "1.3.4"
+ end
+end
24 tipsy-rails.gemspec
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/tipsy/rails/version', __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "tipsy-rails"
+ s.version = Tipsy::Rails::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["Nick Ragaz"]
+ s.email = ["nick.ragaz@gmail.com"]
+ s.homepage = "http://rubygems.org/gems/tipsy-rails"
+ s.summary = "Use the Tipsy jQuery plugin with Rails 3.1"
+ s.description = "This gem provides the Tipsy jQuery plugin for your Rails 3.1 application."
+
+ s.required_rubygems_version = ">= 1.3.6"
+
+ s.add_dependency "railties", "~> 3.0"
+ s.add_dependency "thor", "~> 0.14"
+ s.add_development_dependency "bundler", "~> 1.0.0"
+ s.add_development_dependency "rails", "~> 3.0"
+
+ s.files = `git ls-files`.split("\n")
+ s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
+ s.require_path = 'lib'
+end
BIN vendor/assets/images/tipsy/tipsy.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
202 vendor/assets/javascripts/tipsy.js
@@ -0,0 +1,202 @@
+// tipsy, facebook style tooltips for jquery
+// version 1.0.0a
+// (c) 2008-2010 jason frame [jason@onehackoranother.com]
+// released under the MIT license
+
+(function($) {
+
+ function Tipsy(element, options) {
+ this.$element = $(element);
+ this.options = options;
+ this.enabled = true;
+ this.fixTitle();
+ }
+
+ Tipsy.prototype = {
+ show: function() {
+ var title = this.getTitle();
+ if (title && this.enabled) {
+ var $tip = this.tip();
+
+ $tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title);
+ $tip[0].className = 'tipsy'; // reset classname in case of dynamic gravity
+ $tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
+
+ var pos = $.extend({}, this.$element.offset(), {
+ width: this.$element[0].offsetWidth,
+ height: this.$element[0].offsetHeight
+ });
+
+ var actualWidth = $tip[0].offsetWidth, actualHeight = $tip[0].offsetHeight;
+ var gravity = (typeof this.options.gravity == 'function')
+ ? this.options.gravity.call(this.$element[0])
+ : this.options.gravity;
+
+ var tp;
+ switch (gravity.charAt(0)) {
+ case 'n':
+ tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2};
+ break;
+ case 's':
+ tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2};
+ break;
+ case 'e':
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset};
+ break;
+ case 'w':
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset};
+ break;
+ }
+
+ if (gravity.length == 2) {
+ if (gravity.charAt(1) == 'w') {
+ tp.left = pos.left + pos.width / 2 - 15;
+ } else {
+ tp.left = pos.left + pos.width / 2 - actualWidth + 15;
+ }
+ }
+
+ $tip.css(tp).addClass('tipsy-' + gravity);
+
+ if (this.options.fade) {
+ $tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity});
+ } else {
+ $tip.css({visibility: 'visible', opacity: this.options.opacity});
+ }
+ }
+ },
+
+ hide: function() {
+ if (this.options.fade) {
+ this.tip().stop().fadeOut(function() { $(this).remove(); });
+ } else {
+ this.tip().remove();
+ }
+ },
+
+ fixTitle: function() {
+ var $e = this.$element;
+ if ($e.attr('title') || typeof($e.attr('original-title')) != 'string') {
+ $e.attr('original-title', $e.attr('title') || '').removeAttr('title');
+ }
+ },
+
+ getTitle: function() {
+ var title, $e = this.$element, o = this.options;
+ this.fixTitle();
+ var title, o = this.options;
+ if (typeof o.title == 'string') {
+ title = $e.attr(o.title == 'title' ? 'original-title' : o.title);
+ } else if (typeof o.title == 'function') {
+ title = o.title.call($e[0]);
+ }
+ title = ('' + title).replace(/(^\s*|\s*$)/, "");
+ return title || o.fallback;
+ },
+
+ tip: function() {
+ if (!this.$tip) {
+ this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>');
+ }
+ return this.$tip;
+ },
+
+ validate: function() {
+ if (!this.$element[0].parentNode) {
+ this.hide();
+ this.$element = null;
+ this.options = null;
+ }
+ },
+
+ enable: function() { this.enabled = true; },
+ disable: function() { this.enabled = false; },
+ toggleEnabled: function() { this.enabled = !this.enabled; }
+ };
+
+ $.fn.tipsy = function(options) {
+
+ if (options === true) {
+ return this.data('tipsy');
+ } else if (typeof options == 'string') {
+ var tipsy = this.data('tipsy');
+ if (tipsy) tipsy[options]();
+ return this;
+ }
+
+ options = $.extend({}, $.fn.tipsy.defaults, options);
+
+ function get(ele) {
+ var tipsy = $.data(ele, 'tipsy');
+ if (!tipsy) {
+ tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options));
+ $.data(ele, 'tipsy', tipsy);
+ }
+ return tipsy;
+ }
+
+ function enter() {
+ var tipsy = get(this);
+ tipsy.hoverState = 'in';
+ if (options.delayIn == 0) {
+ tipsy.show();
+ } else {
+ tipsy.fixTitle();
+ setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn);
+ }
+ };
+
+ function leave() {
+ var tipsy = get(this);
+ tipsy.hoverState = 'out';
+ if (options.delayOut == 0) {
+ tipsy.hide();
+ } else {
+ setTimeout(function() { if (tipsy.hoverState == 'out') tipsy.hide(); }, options.delayOut);
+ }
+ };
+
+ if (!options.live) this.each(function() { get(this); });
+
+ if (options.trigger != 'manual') {
+ var binder = options.live ? 'live' : 'bind',
+ eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus',
+ eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur';
+ this[binder](eventIn, enter)[binder](eventOut, leave);
+ }
+
+ return this;
+
+ };
+
+ $.fn.tipsy.defaults = {
+ delayIn: 0,
+ delayOut: 0,
+ fade: false,
+ fallback: '',
+ gravity: 'n',
+ html: false,
+ live: false,
+ offset: 0,
+ opacity: 0.8,
+ title: 'title',
+ trigger: 'hover'
+ };
+
+ // Overwrite this method to provide options on a per-element basis.
+ // For example, you could store the gravity in a 'tipsy-gravity' attribute:
+ // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
+ // (remember - do not modify 'options' in place!)
+ $.fn.tipsy.elementOptions = function(ele, options) {
+ return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
+ };
+
+ $.fn.tipsy.autoNS = function() {
+ return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
+ };
+
+ $.fn.tipsy.autoWE = function() {
+ return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
+ };
+
+})(jQuery);
69 vendor/assets/stylesheets/tipsy.css
@@ -0,0 +1,69 @@
+.tipsy {
+ padding: 5px;
+ font-size: 12px;
+ line-height: 15px;
+ position: absolute;
+ z-index: 100000;
+}
+.tipsy-inner {
+ padding: 5px 8px 4px 8px;
+ background-color: black;
+ color: white;
+ max-width: 200px;
+ text-align: center;
+}
+.tipsy-inner {
+ border-radius: 3px;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+}
+.tipsy-arrow {
+ position: absolute;
+ background: image_url('tipsy/tipsy.gif') no-repeat top left;
+ width: 9px;
+ height: 5px;
+}
+.tipsy-n .tipsy-arrow {
+ top: 0;
+ left: 50%;
+ margin-left: -4px;
+}
+.tipsy-nw .tipsy-arrow {
+ top: 0;
+ left: 10px;
+}
+.tipsy-ne .tipsy-arrow {
+ top: 0;
+ right: 10px;
+}
+.tipsy-s .tipsy-arrow {
+ bottom: 0;
+ left: 50%;
+ margin-left: -4px;
+ background-position: bottom left;
+}
+.tipsy-sw .tipsy-arrow {
+ bottom: 0;
+ left: 10px;
+ background-position: bottom left;
+}
+.tipsy-se .tipsy-arrow {
+ bottom: 0;
+ right: 10px;
+ background-position: bottom left;
+}
+.tipsy-e .tipsy-arrow {
+ top: 50%;
+ margin-top: -4px;
+ right: 0;
+ width: 5px;
+ height: 9px;
+ background-position: top right;
+}
+.tipsy-w .tipsy-arrow {
+ top: 50%;
+ margin-top: -4px;
+ left: 0;
+ width: 5px;
+ height: 9px;
+}

0 comments on commit ba9d28c

Please sign in to comment.