Skip to content

Commit

Permalink
releasing version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joseustra committed Jul 3, 2012
1 parent 8be714d commit b41e20d
Show file tree
Hide file tree
Showing 14 changed files with 360 additions and 39 deletions.
18 changes: 17 additions & 1 deletion .gitignore
@@ -1 +1,17 @@
*.gem
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
2 changes: 1 addition & 1 deletion Gemfile
@@ -1,4 +1,4 @@
source "http://rubygems.org"
source 'https://rubygems.org'

# Specify your gem's dependencies in jquery_notify_bar.gemspec
gemspec
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
Copyright (c) 2012 Jose Carlos Ustra Junior

MIT License

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.
106 changes: 106 additions & 0 deletions README.md
@@ -0,0 +1,106 @@
#JqueryNotifyBar

This is a simple ruby gem to include jquery.nofityBar from [Dmitri Smirnov](http://github.com/dknight/jQuery-Notify-bar) to your rails app.

jquery.notifyBar is a twitter like notification bar.

With this gem, all your flash messages will be showed in the nofity bar.

## Installation

In your gem file add:

```ruby
gem 'jquery_notify_bar'
```

## Usage

### Rails 3.0

Add this files to your javascripts and stylesheets folders
```
https://raw.github.com/ustrajunior/jquery_notify_bar/master/apps/assets/javascripts/jquery.notify_bar.js
https://raw.github.com/ustrajunior/jquery_notify_bar/master/apps/assets/stylesheets/jquery.notify_bar.css
```

in the head section of your application.html.erb add this helper

```rhtml
<%= jquery_notify_bar_assets %>
```

### Rails 3.1
On your application.js add

```
//= require jquery.notify_bar
```

On your application.css add

```
*= require jquery.notify_bar
```

### In your application.html

```rhtml
<%= jquery_notify_bar(flash) %>
```

Remember to add the helper after

```rhtml
<%= javascript_include_tag "application" %>
```

Because it depends of jQuery.

### Parameters

You can pass options too:

```
:cls => :success
:animation_speed => 'normal'
:delay => 2000
```

or all at the same time

```rhtml
<%= jquery_notify_bar(flash, :cls => :success, :animation_speed => 'normal', :delay => 2000) %>
```

## TODO ##

* write rspec and jasmine tests
* improve the css

## Maintainer ##

* José Carlos Ustra Júnior (http://ustrajunior.com)

## License ##

(The MIT License)

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.
3 changes: 2 additions & 1 deletion Rakefile
@@ -1 +1,2 @@
require 'bundler/gem_tasks'
#!/usr/bin/env rake
require "bundler/gem_tasks"
109 changes: 109 additions & 0 deletions app/assets/javascripts/jquery.notify_bar.js
@@ -0,0 +1,109 @@
/*
* Notify Bar - jQuery plugin
*
* Copyright (c) 2009-2010 Dmitri Smirnov
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Version: 1.2.2
*
* Project home:
* http://www.dmitri.me/blog/notify-bar
*/

/**
* param Object
*/
jQuery.notifyBar = function(settings) {

(function($) {

var bar = notifyBarNS = {};
notifyBarNS.shown = false;

if( !settings) {
settings = {};
}
// HTML inside bar
notifyBarNS.html = settings.html || "Your message here";

//How long bar will be delayed, doesn't count animation time.
notifyBarNS.delay = settings.delay || 2000;

//How long notifyBarNS bar will be slided up and down
notifyBarNS.animationSpeed = settings.animationSpeed || 200;

//Use own jquery object usually DIV, or use default
notifyBarNS.jqObject = settings.jqObject;

//Set up own class
notifyBarNS.cls = settings.cls || "";

//close button
notifyBarNS.close = settings.close || false;

if( notifyBarNS.jqObject) {
bar = notifyBarNS.jqObject;
notifyBarNS.html = bar.html();
} else {
bar = jQuery("<div></div>")
.addClass("jquery-notify-bar")
.addClass(notifyBarNS.cls)
.attr("id", "__notifyBar");
}

bar.html(notifyBarNS.html).hide();
var id = bar.attr("id");
switch (notifyBarNS.animationSpeed) {
case "slow":
asTime = 600;
break;
case "normal":
asTime = 400;
break;
case "fast":
asTime = 200;
break;
default:
asTime = notifyBarNS.animationSpeed;
}
if( bar != 'object'); {
jQuery("body").prepend(bar);
}

// Style close button in CSS file
if( notifyBarNS.close) {
bar.append(jQuery("<a href='#' class='notify-bar-close'>Close [X]</a>"));
jQuery(".notify-bar-close").click(function() {
if( bar.attr("id") == "__notifyBar") {
jQuery("#" + id).slideUp(asTime, function() { jQuery("#" + id).remove() });
} else {
jQuery("#" + id).slideUp(asTime);
}
return false;
});
}

// Check if we've got any visible bars and if we have, slide them up before showing the new one
if($('.jquery-notify-bar:visible').length > 0) {
$('.jquery-notify-bar:visible').stop().slideUp(asTime, function() {
bar.stop().slideDown(asTime);
});
} else {
bar.slideDown(asTime);
}

// Allow the user to click on the bar to close it
bar.click(function() {
$(this).slideUp(asTime);
})

// If taken from DOM dot not remove just hide
if( bar.attr("id") == "__notifyBar") {
setTimeout("jQuery('#" + id + "').stop().slideUp(" + asTime +", function() {jQuery('#" + id + "').remove()});", notifyBarNS.delay + asTime);
} else {
setTimeout("jQuery('#" + id + "').stop().slideUp(" + asTime +", function() {jQuery('#" + id + "')});", notifyBarNS.delay + asTime);
}

})(jQuery) };
42 changes: 42 additions & 0 deletions app/assets/stylesheets/jquery.notify_bar.css
@@ -0,0 +1,42 @@
/*
* Notify Bar - jQuery plugin
*
* Copyright (c) 2009-2010 Dmitri Smirnov
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Version: 1.2
*
* Project home:
* http://www.dmitri.me/blog/notify-bar
*/

.jquery-notify-bar {
width:100%;
position:fixed;
top:0;
left:0;
z-index:32768;
background-color:#efefef;
font-size:18px;
color:#000;
text-align:center;
font-family: Arial, Verdana, sans-serif;
padding:20px 0px;
border-bottom:1px solid #bbb;
cursor: pointer;
}
.jquery-notify-bar.error {
color:#f00;
background-color:#fdd;
}
.jquery-notify-bar.success {
color:#060;
background-color:#BBFFB6;
}
.notify-bar-close {
position:absolute;
left:95%;
font-size:11px;
}
33 changes: 17 additions & 16 deletions jquery_notify_bar.gemspec
@@ -1,20 +1,21 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "jquery_notify_bar/version"
require File.expand_path('../lib/jquery_notify_bar/version', __FILE__)

Gem::Specification.new do |s|
s.name = "jquery_notify_bar"
s.version = JqueryNotifyBar::VERSION
s.authors = ["Jose Carlos Ustra Junior"]
s.email = ["contato@ustrajunior.com"]
s.homepage = "http://ustrajunior.com/apps/jquery_notify_bar"
s.summary = %q{jquery.notifyBar in your app}
s.description = %q{A simple gem to include jquery.notifyBar to your rails app.}
Gem::Specification.new do |gem|
gem.authors = ["Jose Carlos Ustra Junior"]
gem.email = ["ustrajunior@gmail.com"]
gem.description = "A simple gem to include jquery.notifyBar to your rails app."
gem.summary = "jquery.notifyBar in your app"
gem.homepage = "http://ustrajunior.com/apps/jquery_notify_bar"

s.rubyforge_project = "jquery_notify_bar"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
gem.files = `git ls-files`.split($\)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.name = "jquery_notify_bar"
gem.require_paths = ["lib"]
gem.version = JqueryNotifyBar::VERSION

gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec', '~> 2.8.0'
gem.add_development_dependency 'jasmine', '>= 1.1.1'
end
2 changes: 1 addition & 1 deletion lib/jquery_notify_bar.rb
@@ -1,2 +1,2 @@
require "jquery_notify_bar/version"
require 'jquery_notify_bar/railtie' if defined?(Rails)
require "jquery_notify_bar/engine" if defined? Rails
10 changes: 10 additions & 0 deletions lib/jquery_notify_bar/engine.rb
@@ -0,0 +1,10 @@
require "jquery_notify_bar/view_helpers"

module JqueryNotifyBar
class Engine < Rails::Engine
# Adds the ViewHelpers into ActionView::Base
initializer "jquery_notify_bar.view_helpers" do
ActionView::Base.send :include, ViewHelpers
end
end
end
2 changes: 1 addition & 1 deletion lib/jquery_notify_bar/version.rb
@@ -1,3 +1,3 @@
module JqueryNotifyBar
VERSION = "0.0.4"
VERSION = "1.0.0"
end

0 comments on commit b41e20d

Please sign in to comment.