humane-rails 2.2.6.0.1.0 → 2.7.1.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.md CHANGED
@@ -8,14 +8,30 @@
8
8
 
9
9
  This is a gemified version of Marc Harter's humane-js library. See http://wavded.github.com/humane-js/ for more details.
10
10
 
11
+ [![Build Status](https://secure.travis-ci.org/harrigan/humane-rails.png)](http://travis-ci.org/harrigan/humane-rails)
12
+
11
13
  ## Instructions
12
14
 
13
15
  Add the following to your Gemfile:
16
+
14
17
  `gem "humane-rails"`
15
18
 
16
- Then add the following to your application.js manifest:
19
+ Then add the following to your application.js:
20
+
17
21
  `//= require humane`
18
22
 
23
+ and one of the following to your application.css:
24
+
25
+ `*= require original`
26
+
27
+ `*= require libnotify`
28
+
29
+ `*= require bigbox`
30
+
31
+ `*= require boldlight`
32
+
33
+ `*= require jackedup`
34
+
19
35
  Don't forget to run `bundle update` after upgrading to the latest gem version to ensure it's used by your Rails app.
20
36
 
21
37
  ## License
@@ -1,3 +1,3 @@
1
1
  module HumaneRails
2
- VERSION = "2.2.6.0.1.0"
2
+ VERSION = "2.7.1.0.1.0"
3
3
  end
@@ -1,206 +1,207 @@
1
1
  /**
2
- * HumaneJS
2
+ * humane.js
3
3
  * Humanized Messages for Notifications
4
4
  * @author Marc Harter (@wavded)
5
- * @contributers
6
- * Alexander (@bga_)
7
- * Jose (@joseanpg)
8
- * Will McKenzie (@OiNutter)
9
5
  * @example
10
6
  * humane('hello world');
11
7
  * See more usage examples at: http://wavded.github.com/humane-js/
12
8
  */
13
9
  ;(function (win,doc) {
14
- var on,
15
- off,
16
- isArray,
17
- eventing = false,
18
- animationInProgress = false,
19
- humaneEl = null,
20
- timeout = null,
21
- useFilter = /msie [678]/i.test(navigator.userAgent), // sniff, sniff,
22
- vendors = {Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS'},
23
- eventPrefix = "",
24
- isSetup = false,
25
- queue = [],
26
- after = null;
27
-
28
- if ('addEventListener' in win) {
29
- on = function (obj,type,fn) { obj.addEventListener(type,fn,false) };
30
- off = function (obj,type,fn) { obj.removeEventListener(type,fn,false) };
31
- }
32
- else {
33
- on = function (obj,type,fn) { obj.attachEvent('on'+type,fn) };
34
- off = function (obj,type,fn) { obj.detachEvent('on'+type,fn) };
35
- }
36
- isArray = Array.isArray || function (obj) { return Object.prototype.toString.call(obj) === '[object Array]' };
37
-
38
- function normalizeEvent(name) {
39
- return eventPrefix ? eventPrefix + name : name.toLowerCase();
40
- }
41
-
42
- on (win,'load',function () {
43
- var transitionSupported = ( function (style) {
44
- var prefixes = ['MozT','WebkitT','OT','msT','KhtmlT','t'];
45
- for(var i = 0, prefix; prefix = prefixes[i]; i++) {
46
- if (prefix+'ransition' in style) return true;
47
- }
48
- return false;
49
- }(doc.body.style));
50
- if (!transitionSupported) animate = jsAnimateOpacity; // use js animation when no transition support
51
-
52
- setup(); run();
53
- });
54
-
55
- function setup() {
56
- humaneEl = doc.createElement('div');
57
- humaneEl.id = 'humane';
58
- humaneEl.className = 'humane';
59
- doc.body.appendChild(humaneEl);
60
- for (vendor in vendors){
61
- if (humaneEl.style[vendor + 'TransitionProperty'] !== undefined)
62
- eventPrefix = vendors[vendor];
63
- }
64
- isSetup = true;
65
- }
66
-
67
- function remove() {
68
- off (doc.body,'mousemove',remove);
69
- off (doc.body,'click',remove);
70
- off (doc.body,'keypress',remove);
71
- off (doc.body,'touchstart',remove);
72
- eventing = false;
73
- if (humane.clickToClose) { off (humaneEl,'click',remove); off (humaneEl, 'touchstart', remove); }
74
- if (animationInProgress) animate(0);
75
- }
76
-
77
- function run() {
78
- if (animationInProgress && !win.humane.forceNew) return;
79
- if (!queue.length) { remove(); return; }
80
- after = null;
81
- animationInProgress = true;
82
- if (timeout) {
83
- clearTimeout(timeout);
84
- timeout = null;
85
- }
86
- timeout = setTimeout(function(){ // allow notification to stay alive for timeout
87
- if (!eventing) {
88
- on (doc.body,'mousemove',remove);
89
- on (doc.body,'click',remove);
90
- on (doc.body,'keypress',remove);
91
- on (doc.body,'touchstart',remove);
92
- eventing = true;
93
- if(!win.humane.waitForMove) remove();
10
+
11
+ var humane, on, off, isArray,
12
+ eventing = false,
13
+ useTransitions = false,
14
+ animationInProgress = false,
15
+ humaneEl = null,
16
+ timeout = null,
17
+ useFilter = /msie [678]/i.test(navigator.userAgent), // sniff, sniff
18
+ vendors = { Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS' },
19
+ eventPrefix = "",
20
+ isSetup = false,
21
+ currentMessage = {},
22
+ noop = function(){},
23
+ events = { 'add': noop, 'show': noop, 'hide': noop },
24
+ queue = [];
25
+
26
+ if ('addEventListener' in win) {
27
+ on = function (obj,type,fn) { obj.addEventListener(type,fn,false) };
28
+ off = function (obj,type,fn) { obj.removeEventListener(type,fn,false) };
29
+ }
30
+ else {
31
+ on = function (obj,type,fn) { obj.attachEvent('on'+type,fn) };
32
+ off = function (obj,type,fn) { obj.detachEvent('on'+type,fn) };
33
+ }
34
+
35
+ isArray = Array.isArray || function (obj) { return Object.prototype.toString.call(obj) === '[object Array]' };
36
+
37
+ function normalizeEvent(name) {
38
+ return eventPrefix ? eventPrefix + name : name.toLowerCase();
39
+ }
40
+
41
+ function getConfig(type, config) {
42
+ return win.humane[type][config] !== void 0 ? win.humane[type][config] : win.humane[config];
43
+ }
44
+
45
+ on (win,'load', setup);
46
+
47
+ function setup() {
48
+ humaneEl = doc.createElement('div');
49
+ humaneEl.id = 'humane';
50
+ humaneEl.className = 'humane';
51
+ doc.body.appendChild(humaneEl);
52
+ for (vendor in vendors) {
53
+ if (vendor + 'TransitionProperty' in humaneEl.style) {
54
+ eventPrefix = vendors[vendor];
55
+ useTransitions = true;
56
+ }
94
57
  }
95
- }, win.humane.timeout);
96
-
97
- if (humane.clickToClose) { on (humaneEl,'click',remove); on (humaneEl, 'touchstart', remove); }
98
-
99
- var next = queue.shift(),
100
- type = next[0],
101
- content = next[1],
102
- callback = next[2];
103
-
104
- after = callback;
105
- if ( isArray(content) ) content = '<ul><li>' + content.join('<li>') + '</ul>';
106
-
107
- humaneEl.innerHTML = content;
108
- animate(type,1);
109
- }
110
-
111
- function animate (type,level) {
112
- if(level === 1){
113
- humaneEl.className = "humane humane-" + type + " humane-animate";
114
- }
115
- else {
116
- humaneEl.className = humaneEl.className.replace(" humane-animate","");
117
- if(after!=null)
118
- on(humaneEl,normalizeEvent('TransitionEnd'),after);
119
- end();
120
- }
121
- }
122
-
123
- function end(){
124
- setTimeout(function(){
125
- animationInProgress = false;
58
+ if (!useTransitions) animate = jsAnimateOpacity; // use js animation when no transition support
59
+ isSetup = true;
126
60
  run();
127
- },500);
128
- }
61
+ }
62
+
63
+ function run() {
64
+ if (animationInProgress) return;
65
+ if (!queue.length) return;
66
+
67
+ after = null;
68
+ animationInProgress = true;
69
+ if (timeout) {
70
+ clearTimeout(timeout);
71
+ timeout = null;
72
+ }
73
+
74
+ var next = queue.shift();
75
+ currentMessage = { type: next[0], message: next[1], callback: next[2] };
76
+ var content = currentMessage.message,
77
+ type = currentMessage.type;
78
+
79
+ if ( getConfig(type, 'clickToClose') === true ) {
80
+ on (humaneEl, 'click', remove);
81
+ on (humaneEl, 'touchstart', remove);
82
+ }
129
83
 
130
- // if CSS Transitions not supported, fallback to JS Animation
131
- var setOpacity = (function(){
132
- if (useFilter) {
133
- return function(opacity){
134
- humaneEl.filters.item('DXImageTransform.Microsoft.Alpha').Opacity = opacity*100;
84
+ var timeoutInMillis = getConfig(type, 'timeout');
85
+
86
+ if (timeoutInMillis > 0) {
87
+ timeout = setTimeout(function(){ // allow notification to stay alive for timeout
88
+ if (!eventing) {
89
+ on (doc.body, 'mousemove', remove);
90
+ on (doc.body, 'click', remove);
91
+ on (doc.body, 'keypress', remove);
92
+ on (doc.body, 'touchstart', remove);
93
+ eventing = true;
94
+ if( getConfig(type, 'waitForMove') !== true ) remove();
95
+ }
96
+ }, timeoutInMillis);
97
+ }
98
+
99
+ events['show'](type,content,'show');
100
+ if ( isArray(content) ) content = '<ul><li>' + content.join('<li>') + '</ul>';
101
+
102
+ humaneEl.innerHTML = content;
103
+ humaneEl.style.display = 'block';
104
+ setTimeout(function(){ animate(1,type); },50) // prevent queueing display in animation
105
+ }
135
106
 
107
+ function animate (level,type) {
108
+ if (level === 1) {
109
+ humaneEl.className = "humane humane-" + type + " humane-animate";
136
110
  }
137
- }
138
- else {
139
- return function (opacity) { humaneEl.style.opacity = String(opacity); }
140
- }
141
- }());
142
-
143
- function jsAnimateOpacity(type,level){
144
- var interval;
145
- var opacity;
146
-
147
- if (level === 1) {
148
- opacity = 0;
149
- humaneEl.className = "humane humane-js-animate humane-" + type;
150
- if (humaneEl.filters) humaneEl.filters.item('DXImageTransform.Microsoft.Alpha').Opacity = 0; // reset value so hover states work
151
-
152
- if (win.humane.forceNew) {
153
- opacity = useFilter
154
- ? humaneEl.filters.item('DXImageTransform.Microsoft.Alpha').Opacity/100|0
155
- : humaneEl.style.opacity|0;
111
+ else {
112
+ humaneEl.className = humaneEl.className.replace(" humane-animate","");
113
+ on ( humaneEl, normalizeEvent('TransitionEnd'), end );
114
+ }
115
+ }
116
+
117
+ function remove() {
118
+ off (doc.body, 'mousemove', remove);
119
+ off (doc.body, 'click', remove);
120
+ off (doc.body, 'keypress', remove);
121
+ off (doc.body, 'touchstart', remove);
122
+ // remove click and touchstart in case clickToClose was added
123
+ off (humaneEl, 'click', remove);
124
+ off (humaneEl, 'touchstart', remove);
125
+ eventing = false;
126
+ if (animationInProgress) animate(0);
127
+ }
128
+
129
+
130
+ function end() {
131
+ // turn off animation event if supported, a little trigger happy
132
+ if (useTransitions) off ( humaneEl, normalizeEvent('TransitionEnd'), end );
133
+ animationInProgress = false;
134
+ if (currentMessage.callback) currentMessage.callback();
135
+ events['hide'](currentMessage.type, currentMessage.message,'hide');
136
+ humaneEl.style.display = 'none';
137
+ run();
138
+ }
139
+
140
+ var setOpacity = useFilter
141
+ ? function (opacity) { humaneEl.filters.item('DXImageTransform.Microsoft.Alpha').Opacity = opacity*100; }
142
+ : function (opacity) { humaneEl.style.opacity = String(opacity); }
143
+
144
+ function jsAnimateOpacity (level,type) {
145
+ var interval;
146
+ var opacity;
147
+
148
+ if (level === 1) {
149
+ opacity = 0;
150
+ humaneEl.className = "humane humane-js-animate humane-" + type;
151
+ if (useFilter) setOpacity(0); // reset value so hover states work
152
+ humaneEl.style.zIndex = 1000000;
153
+
154
+ interval = setInterval(function(){
155
+ if (opacity < 1) {
156
+ opacity += 0.1;
157
+ if (opacity > 1) opacity = 1;
158
+ setOpacity(opacity);
159
+ }
160
+ else {
161
+ clearInterval(interval);
162
+ }
163
+ }, 100 / 20);
164
+ }
165
+ else {
166
+ opacity = 1;
167
+ interval = setInterval(function(){
168
+ if(opacity > 0) {
169
+ opacity -= 0.1;
170
+ if (opacity < 0) opacity = 0;
171
+ setOpacity(opacity);
172
+ }
173
+ else {
174
+ humaneEl.className = humaneEl.className.replace(" humane-js-animate","");
175
+ humaneEl.style.zIndex = -1;
176
+ clearInterval(interval);
177
+ end();
178
+ }
179
+ }, 100 / 20);
180
+ }
181
+ }
182
+
183
+ function notifier (type) {
184
+ return function (message, cb) {
185
+ queue.push( [type, message, cb] );
186
+ events['add'](type,message,'add');
187
+ if (isSetup) run();
156
188
  }
157
- interval = setInterval(function(){
158
- if (opacity < 1) {
159
- opacity += 0.1;
160
- if (opacity > 1) opacity = 1;
161
- setOpacity(opacity);
162
- }
163
- else {
164
- clearInterval(interval);
165
- }
166
- }, 100 / 20);
167
- }
168
- else {
169
- opacity = 1;
170
- interval = setInterval(function(){
171
- if(opacity > 0) {
172
- opacity -= 0.1;
173
- if (opacity < 0) opacity = 0;
174
- setOpacity(opacity);
175
- }
176
- else {
177
- humaneEl.className = humaneEl.className.replace(" humane-js-animate","");
178
- clearInterval(interval);
179
- if(after!=null)
180
- after();
181
- end();
182
- }
183
- }, 100 / 20);
184
- }
185
- }
186
-
187
- function notifier (type) {
188
- return function (message,callback) {
189
- queue.push( [type, message,callback] );
190
- if(isSetup) run();
191
- }
192
- }
193
-
194
- win.humane = notifier('log');
195
-
196
- win.humane.log = notifier('log');
197
- win.humane.error = notifier('error');
198
- win.humane.info = notifier('info');
199
- win.humane.success = notifier('success');
200
-
201
- win.humane.timeout = 2500;
202
- win.humane.waitForMove = false;
203
- win.humane.forceNew = false;
204
- win.humane.clickToClose = false;
205
-
206
- }( window, document));
189
+ }
190
+
191
+ // types
192
+ humane = notifier('log');
193
+ humane.log = notifier('log');
194
+ humane.error = notifier('error');
195
+ humane.info = notifier('info');
196
+ humane.success = notifier('success');
197
+ humane.remove = remove;
198
+
199
+ // options
200
+ humane.timeout = 2500;
201
+ humane.waitForMove = false;
202
+ humane.clickToClose = false;
203
+
204
+ // events
205
+ humane.on = function(type, handler){ events[type] = handler; };
206
+ win.humane = humane;
207
+ })( window, document );
@@ -9,10 +9,6 @@ body {
9
9
  -ms-transition: all 0.3s ease-out;
10
10
  -o-transition: all 0.3s ease-out;
11
11
  transition: all 0.3s ease-out;
12
- z-index: -1;
13
- }
14
- .humane.humane-animate,
15
- .humane.humane-js-animate {
16
12
  z-index: 100000;
17
13
  }
18
14
  .humane {
@@ -121,4 +117,4 @@ body {
121
117
  .humane.humane-js-animate:hover {
122
118
  opacity: 0.6;
123
119
  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=60);
124
- }
120
+ }
@@ -9,10 +9,6 @@ body {
9
9
  -ms-transition: all 0.3s ease-out;
10
10
  -o-transition: all 0.3s ease-out;
11
11
  transition: all 0.3s ease-out;
12
- z-index: -1;
13
- }
14
- .humane.humane-animate,
15
- .humane.humane-js-animate {
16
12
  z-index: 100000;
17
13
  }
18
14
  .humane {
@@ -120,4 +116,4 @@ body {
120
116
  .humane.humane-js-animate:hover {
121
117
  opacity: 0.4;
122
118
  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40);
123
- }
119
+ }
@@ -9,10 +9,6 @@ body {
9
9
  -ms-transition: all 0.6s ease-in-out;
10
10
  -o-transition: all 0.6s ease-in-out;
11
11
  transition: all 0.6s ease-in-out;
12
- z-index: -1;
13
- }
14
- .humane.humane-animate,
15
- .humane.humane-js-animate {
16
12
  z-index: 100000;
17
13
  }
18
14
  .humane {
@@ -121,4 +117,4 @@ body {
121
117
  .humane.humane-js-animate:hover {
122
118
  opacity: 0.7;
123
119
  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=70);
124
- }
120
+ }
@@ -9,10 +9,6 @@ body {
9
9
  -ms-transition: all 0.3s ease-out;
10
10
  -o-transition: all 0.3s ease-out;
11
11
  transition: all 0.3s ease-out;
12
- z-index: -1;
13
- }
14
- .humane.humane-animate,
15
- .humane.humane-js-animate {
16
12
  z-index: 100000;
17
13
  }
18
14
  .humane {
@@ -113,4 +109,4 @@ body {
113
109
  .humane.humane-js-animate:hover {
114
110
  opacity: 0.2;
115
111
  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=20);
116
- }
112
+ }
@@ -9,10 +9,6 @@ body {
9
9
  -ms-transition: all 0.2s ease-out;
10
10
  -o-transition: all 0.2s ease-out;
11
11
  transition: all 0.2s ease-out;
12
- z-index: -1;
13
- }
14
- .humane.humane-animate,
15
- .humane.humane-js-animate {
16
12
  z-index: 100000;
17
13
  }
18
14
  .humane {
@@ -67,4 +63,4 @@ body {
67
63
  .humane.humane-js-animate:hover {
68
64
  opacity: 0.6;
69
65
  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=60);
70
- }
66
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humane-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6.0.1.0
4
+ version: 2.7.1.0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-08 00:00:00.000000000 Z
12
+ date: 2012-02-08 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A gemified version of Marc Harter's humane-js.
15
15
  email:
@@ -45,18 +45,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
45
45
  - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- segments:
49
- - 0
50
- hash: -190101333893275154
51
48
  required_rubygems_version: !ruby/object:Gem::Requirement
52
49
  none: false
53
50
  requirements:
54
51
  - - ! '>='
55
52
  - !ruby/object:Gem::Version
56
53
  version: '0'
57
- segments:
58
- - 0
59
- hash: -190101333893275154
60
54
  requirements: []
61
55
  rubyforge_project: humane-rails
62
56
  rubygems_version: 1.8.11
@@ -64,3 +58,4 @@ signing_key:
64
58
  specification_version: 3
65
59
  summary: A gemified version of Marc Harter's humane-js.
66
60
  test_files: []
61
+ has_rdoc: