notificater-rails 0.1.0

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.
data/README ADDED
@@ -0,0 +1,3 @@
1
+ notificater - A jQuery plugin for displaying small notification messages
2
+
3
+ See http://kla.github.com/notificater/ for usage
@@ -0,0 +1,6 @@
1
+ require "rails"
2
+
3
+ module NotificaterRails
4
+ class Engine < Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,66 @@
1
+
2
+ (function($) {
3
+ var $container, add, createContainer, defaultOptions, messages, render, renderNotification, width;
4
+ $container = null;
5
+ messages = [];
6
+ defaultOptions = {
7
+ duration: 5000,
8
+ sticky: false,
9
+ closeable: true,
10
+ offset: [6, 0]
11
+ };
12
+ add = function(message, options) {
13
+ if (options == null) options = {};
14
+ messages.push($.extend({}, {
15
+ message: message
16
+ }, defaultOptions, options));
17
+ if (!$container) createContainer();
18
+ return render();
19
+ };
20
+ createContainer = function() {
21
+ $(document.body).append("<div id=\"notifications\" style=\"display:none;position:fixed;top:0;left:50%\">\n <div class=\"message-container\" style=\"position:relative\">\n <span class=\"message\"></span>\n <a href=\"#\" class=\"notification-close\" style=\"display:none\">x</a>\n </div>\n</div>");
22
+ $container = $("#notifications");
23
+ return $container.find(".notification-close").click(function() {
24
+ $container.fadeOut(render);
25
+ return false;
26
+ });
27
+ };
28
+ width = function() {
29
+ var w;
30
+ $container.css({
31
+ visibility: "hidden",
32
+ display: ""
33
+ });
34
+ w = $container.find(".message-container").width();
35
+ $container.css({
36
+ visibility: "",
37
+ display: "none"
38
+ });
39
+ return w;
40
+ };
41
+ render = function() {
42
+ var msg;
43
+ if ($container.is(":visible") || messages.length <= 0) return;
44
+ renderNotification(msg = messages.shift());
45
+ $container.fadeIn();
46
+ if (!msg.sticky) return $container.delay(msg.duration).fadeOut(render);
47
+ };
48
+ renderNotification = function(msg) {
49
+ var $close;
50
+ $container.find(".message").html(msg.message);
51
+ $container.find(".message-container").css({
52
+ left: -(width() / 2.0) + msg.offset[1],
53
+ top: msg.offset[0]
54
+ });
55
+ $close = $container.find(".notification-close");
56
+ if (msg.sticky && msg.closeable) {
57
+ return $close.show();
58
+ } else {
59
+ return $close.hide();
60
+ }
61
+ };
62
+ return $.notificate = function(message, options) {
63
+ if (options == null) options = {};
64
+ return add(message, options);
65
+ };
66
+ })(jQuery);
@@ -0,0 +1,8 @@
1
+ #notifications .message-container {
2
+ color: #444;
3
+ padding: 3px 8px;
4
+ background-color: #fee9cc;
5
+ }
6
+ .notification-close {
7
+ padding-left:0.5em
8
+ }
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: notificater-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kien La
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: &73862810 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *73862810
25
+ description:
26
+ email:
27
+ - la.kien@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - lib/notificater-rails.rb
33
+ - vendor/assets/stylesheets/jquery.notificater.css
34
+ - vendor/assets/javascripts/jquery.notificater.js
35
+ - README
36
+ homepage: http://kla.github.com/notificater
37
+ licenses: []
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 1.8.10
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: Use notificater.js with rails 3.1
60
+ test_files: []