rails-alertify 0.2.12
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/.gitignore +9 -0
- data/Gemfile +6 -0
- data/MIT-LICENSE +20 -0
- data/README.md +49 -0
- data/Rakefile +38 -0
- data/lib/alertify-rails.rb +11 -0
- data/lib/alertify-rails/version.rb +3 -0
- data/rails-alertify.gemspec +19 -0
- data/vendor/assets/javascripts/alertify.js +467 -0
- data/vendor/assets/stylesheets/alertify/core.css +95 -0
- data/vendor/assets/stylesheets/alertify/default.css +74 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Daniel Schmidt
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Alertify.js for Rails
|
2
|
+
|
3
|
+
Rails asset-pipeline gem to provide alertify.js out of the box.
|
4
|
+
|
5
|
+
### Install
|
6
|
+
|
7
|
+
Add to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "rails-alertify"
|
11
|
+
```
|
12
|
+
|
13
|
+
### Usage
|
14
|
+
|
15
|
+
In your application.js manifest include the javascript files:
|
16
|
+
|
17
|
+
```js
|
18
|
+
//= require alertify
|
19
|
+
```
|
20
|
+
|
21
|
+
If your manifest is written in CoffeeScript:
|
22
|
+
|
23
|
+
```coffeescript
|
24
|
+
#= require alertify
|
25
|
+
```
|
26
|
+
|
27
|
+
Last step is to add the <code>core</code> and <code>default</code> stylesheets tou your application if you want to use the default ones.
|
28
|
+
|
29
|
+
```css
|
30
|
+
/*
|
31
|
+
*= require alertify/core
|
32
|
+
*= require alertify/default
|
33
|
+
*
|
34
|
+
*/
|
35
|
+
```
|
36
|
+
|
37
|
+
### About me
|
38
|
+
|
39
|
+
Senior Developer @ Datenspiel GmbH (Leipzig/Germany)
|
40
|
+
|
41
|
+
### Thanks
|
42
|
+
|
43
|
+
Thanks to Fabien Doiron for [Alertify.js](https://github.com/fabien-d/alertify.js)
|
44
|
+
|
45
|
+
### License
|
46
|
+
|
47
|
+
Copyright (c) 2012 Daniel Schmidt
|
48
|
+
|
49
|
+
Licensed under MIT-License.
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'AlertifyRails'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.libs << 'test'
|
33
|
+
t.pattern = 'test/**/*_test.rb'
|
34
|
+
t.verbose = false
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
task :default => :test
|
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "alertify-rails/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "rails-alertify"
|
9
|
+
s.version = AlertifyRails::VERSION
|
10
|
+
s.authors = ["Daniel Schmidt"]
|
11
|
+
s.email = ["dsci@code79.net"]
|
12
|
+
s.homepage = "https://github.com/dsci/rails-alertify"
|
13
|
+
s.summary = %q{alertify.js asset pipeline integration}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,467 @@
|
|
1
|
+
/**
|
2
|
+
* alertify
|
3
|
+
* An unobtrusive customizable JavaScript notification system
|
4
|
+
*
|
5
|
+
* @author Fabien Doiron <fabien.doiron@gmail.com>
|
6
|
+
* @copyright Fabien Doiron 2012
|
7
|
+
* @license MIT <http://opensource.org/licenses/mit-license.php>
|
8
|
+
* @link http://www.github.com/fabien-d
|
9
|
+
* @module alertify
|
10
|
+
* @version 0.2.12
|
11
|
+
*/
|
12
|
+
|
13
|
+
/*global define*/
|
14
|
+
(function (global, undefined) {
|
15
|
+
"use strict";
|
16
|
+
|
17
|
+
var document = global.document,
|
18
|
+
Alertify;
|
19
|
+
|
20
|
+
Alertify = function () {
|
21
|
+
|
22
|
+
var _alertify = {},
|
23
|
+
dialogs = {},
|
24
|
+
isopen = false,
|
25
|
+
keys = { ENTER: 13, ESC: 27, SPACE: 32 },
|
26
|
+
queue = [],
|
27
|
+
$, elCallee, elCover, elDialog, elLog;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Markup pieces
|
31
|
+
* @type {Object}
|
32
|
+
*/
|
33
|
+
dialogs = {
|
34
|
+
buttons : {
|
35
|
+
holder : "<nav class=\"alertify-buttons\">{{buttons}}</nav>",
|
36
|
+
submit : "<button type=\"submit\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\" />{{ok}}</button>",
|
37
|
+
ok : "<a href=\"#\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\">{{ok}}</a>",
|
38
|
+
cancel : "<a href=\"#\" class=\"alertify-button alertify-button-cancel\" id=\"alertify-cancel\">{{cancel}}</a>"
|
39
|
+
},
|
40
|
+
input : "<input type=\"text\" class=\"alertify-text\" id=\"alertify-text\">",
|
41
|
+
message : "<p class=\"alertify-message\">{{message}}</p>",
|
42
|
+
log : "<article class=\"alertify-log{{class}}\">{{message}}</article>"
|
43
|
+
};
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Shorthand for document.getElementById()
|
47
|
+
*
|
48
|
+
* @param {String} id A specific element ID
|
49
|
+
* @return {Object} HTML element
|
50
|
+
*/
|
51
|
+
$ = function (id) {
|
52
|
+
return document.getElementById(id);
|
53
|
+
};
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Alertify private object
|
57
|
+
* @type {Object}
|
58
|
+
*/
|
59
|
+
_alertify = {
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Labels object
|
63
|
+
* @type {Object}
|
64
|
+
*/
|
65
|
+
labels : {
|
66
|
+
ok : "OK",
|
67
|
+
cancel : "Cancel"
|
68
|
+
},
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Delay number
|
72
|
+
* @type {Number}
|
73
|
+
*/
|
74
|
+
delay : 5000,
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Set the proper button click events
|
78
|
+
*
|
79
|
+
* @param {Function} fn [Optional] Callback function
|
80
|
+
*
|
81
|
+
* @return {undefined}
|
82
|
+
*/
|
83
|
+
addListeners : function (fn) {
|
84
|
+
var btnReset = $("alertify-resetFocus"),
|
85
|
+
btnOK = $("alertify-ok") || undefined,
|
86
|
+
btnCancel = $("alertify-cancel") || undefined,
|
87
|
+
input = $("alertify-text") || undefined,
|
88
|
+
form = $("alertify-form") || undefined,
|
89
|
+
hasOK = (typeof btnOK !== "undefined"),
|
90
|
+
hasCancel = (typeof btnCancel !== "undefined"),
|
91
|
+
hasInput = (typeof input !== "undefined"),
|
92
|
+
val = "",
|
93
|
+
self = this,
|
94
|
+
ok, cancel, common, key, reset;
|
95
|
+
|
96
|
+
// ok event handler
|
97
|
+
ok = function (event) {
|
98
|
+
if (typeof event.preventDefault !== "undefined") event.preventDefault();
|
99
|
+
common(event);
|
100
|
+
if (typeof input !== "undefined") val = input.value;
|
101
|
+
if (typeof fn === "function") fn(true, val);
|
102
|
+
};
|
103
|
+
|
104
|
+
// cancel event handler
|
105
|
+
cancel = function (event) {
|
106
|
+
if (typeof event.preventDefault !== "undefined") event.preventDefault();
|
107
|
+
common(event);
|
108
|
+
if (typeof fn === "function") fn(false);
|
109
|
+
};
|
110
|
+
|
111
|
+
// common event handler (keyup, ok and cancel)
|
112
|
+
common = function (event) {
|
113
|
+
self.hide();
|
114
|
+
self.unbind(document.body, "keyup", key);
|
115
|
+
self.unbind(btnReset, "focus", reset);
|
116
|
+
if (hasInput) self.unbind(form, "submit", ok);
|
117
|
+
if (hasOK) self.unbind(btnOK, "click", ok);
|
118
|
+
if (hasCancel) self.unbind(btnCancel, "click", cancel);
|
119
|
+
};
|
120
|
+
|
121
|
+
// keyup handler
|
122
|
+
key = function (event) {
|
123
|
+
var keyCode = event.keyCode;
|
124
|
+
if (keyCode === keys.SPACE && !hasInput) ok(event);
|
125
|
+
if (keyCode === keys.ESC && hasCancel) cancel(event);
|
126
|
+
};
|
127
|
+
|
128
|
+
// reset focus to first item in the dialog
|
129
|
+
reset = function (event) {
|
130
|
+
if (hasInput) input.focus();
|
131
|
+
else if (hasCancel) btnCancel.focus();
|
132
|
+
else btnOK.focus();
|
133
|
+
};
|
134
|
+
|
135
|
+
// handle reset focus link
|
136
|
+
// this ensures that the keyboard focus does not
|
137
|
+
// ever leave the dialog box until an action has
|
138
|
+
// been taken
|
139
|
+
this.bind(btnReset, "focus", reset);
|
140
|
+
// handle OK click
|
141
|
+
if (hasOK) this.bind(btnOK, "click", ok);
|
142
|
+
// handle Cancel click
|
143
|
+
if (hasCancel) this.bind(btnCancel, "click", cancel);
|
144
|
+
// listen for keys, Cancel => ESC
|
145
|
+
this.bind(document.body, "keyup", key);
|
146
|
+
// bind form submit
|
147
|
+
if (hasInput) this.bind(form, "submit", ok);
|
148
|
+
// set focus on OK button or the input text
|
149
|
+
global.setTimeout(function () {
|
150
|
+
if (input) {
|
151
|
+
input.focus();
|
152
|
+
input.select();
|
153
|
+
}
|
154
|
+
else btnOK.focus();
|
155
|
+
}, 50);
|
156
|
+
},
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Bind events to elements
|
160
|
+
*
|
161
|
+
* @param {Object} el HTML Object
|
162
|
+
* @param {Event} event Event to attach to element
|
163
|
+
* @param {Function} fn Callback function
|
164
|
+
*
|
165
|
+
* @return {undefined}
|
166
|
+
*/
|
167
|
+
bind : function (el, event, fn) {
|
168
|
+
if (typeof el.addEventListener === "function") {
|
169
|
+
el.addEventListener(event, fn, false);
|
170
|
+
} else if (el.attachEvent) {
|
171
|
+
el.attachEvent("on" + event, fn);
|
172
|
+
}
|
173
|
+
},
|
174
|
+
|
175
|
+
/**
|
176
|
+
* Build the proper message box
|
177
|
+
*
|
178
|
+
* @param {Object} item Current object in the queue
|
179
|
+
*
|
180
|
+
* @return {String} An HTML string of the message box
|
181
|
+
*/
|
182
|
+
build : function (item) {
|
183
|
+
var html = "",
|
184
|
+
type = item.type,
|
185
|
+
message = item.message;
|
186
|
+
|
187
|
+
html += "<div class=\"alertify-dialog\">";
|
188
|
+
|
189
|
+
if (type === "prompt") html += "<form id=\"alertify-form\">";
|
190
|
+
|
191
|
+
html += "<article class=\"alertify-inner\">";
|
192
|
+
html += dialogs.message.replace("{{message}}", message);
|
193
|
+
|
194
|
+
if (type === "prompt") html += dialogs.input;
|
195
|
+
|
196
|
+
html += dialogs.buttons.holder;
|
197
|
+
html += "</article>";
|
198
|
+
|
199
|
+
if (type === "prompt") html += "</form>";
|
200
|
+
|
201
|
+
html += "<a id=\"alertify-resetFocus\" class=\"alertify-resetFocus\" href=\"#\">Reset Focus</a>";
|
202
|
+
html += "</div>";
|
203
|
+
|
204
|
+
switch (type) {
|
205
|
+
case "confirm":
|
206
|
+
html = html.replace("{{buttons}}", dialogs.buttons.cancel + dialogs.buttons.ok);
|
207
|
+
html = html.replace("{{ok}}", this.labels.ok).replace("{{cancel}}", this.labels.cancel);
|
208
|
+
break;
|
209
|
+
case "prompt":
|
210
|
+
html = html.replace("{{buttons}}", dialogs.buttons.cancel + dialogs.buttons.submit);
|
211
|
+
html = html.replace("{{ok}}", this.labels.ok).replace("{{cancel}}", this.labels.cancel);
|
212
|
+
break;
|
213
|
+
case "alert":
|
214
|
+
html = html.replace("{{buttons}}", dialogs.buttons.ok);
|
215
|
+
html = html.replace("{{ok}}", this.labels.ok);
|
216
|
+
break;
|
217
|
+
default:
|
218
|
+
break;
|
219
|
+
}
|
220
|
+
|
221
|
+
elDialog.className = "alertify alertify-show alertify-" + type;
|
222
|
+
elCover.className = "alertify-cover";
|
223
|
+
return html;
|
224
|
+
},
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Close the log messages
|
228
|
+
*
|
229
|
+
* @param {Object} elem HTML Element of log message to close
|
230
|
+
* @param {Number} wait [optional] Time (in ms) to wait before automatically hiding the message
|
231
|
+
*
|
232
|
+
* @return {undefined}
|
233
|
+
*/
|
234
|
+
close : function (elem, wait) {
|
235
|
+
var timer = (wait && !isNaN(wait)) ? +wait : this.delay; // Unary Plus: +"2" === 2
|
236
|
+
this.bind(elem, "click", function () {
|
237
|
+
elLog.removeChild(elem);
|
238
|
+
});
|
239
|
+
setTimeout(function () {
|
240
|
+
if (typeof elem !== "undefined" && elem.parentNode === elLog) elLog.removeChild(elem);
|
241
|
+
}, timer);
|
242
|
+
},
|
243
|
+
|
244
|
+
/**
|
245
|
+
* Create a dialog box
|
246
|
+
*
|
247
|
+
* @param {String} message The message passed from the callee
|
248
|
+
* @param {String} type Type of dialog to create
|
249
|
+
* @param {Function} fn [Optional] Callback function
|
250
|
+
* @param {String} placeholder [Optional] Default value for prompt input field
|
251
|
+
*
|
252
|
+
* @return {Object}
|
253
|
+
*/
|
254
|
+
dialog : function (message, type, fn, placeholder) {
|
255
|
+
// set the current active element
|
256
|
+
// this allows the keyboard focus to be resetted
|
257
|
+
// after the dialog box is closed
|
258
|
+
elCallee = document.activeElement;
|
259
|
+
// check to ensure the alertify dialog element
|
260
|
+
// has been successfully created
|
261
|
+
var check = function () {
|
262
|
+
if (elDialog && elDialog.scrollTop !== null) return;
|
263
|
+
else check();
|
264
|
+
};
|
265
|
+
// error catching
|
266
|
+
if (typeof message !== "string") throw new Error("message must be a string");
|
267
|
+
if (typeof type !== "string") throw new Error("type must be a string");
|
268
|
+
if (typeof fn !== "undefined" && typeof fn !== "function") throw new Error("fn must be a function");
|
269
|
+
// initialize alertify if it hasn't already been done
|
270
|
+
if (typeof this.init === "function") {
|
271
|
+
this.init();
|
272
|
+
check();
|
273
|
+
}
|
274
|
+
|
275
|
+
queue.push({ type: type, message: message, callback: fn, placeholder: placeholder });
|
276
|
+
if (!isopen) this.setup();
|
277
|
+
|
278
|
+
return this;
|
279
|
+
},
|
280
|
+
|
281
|
+
/**
|
282
|
+
* Extend the log method to create custom methods
|
283
|
+
*
|
284
|
+
* @param {String} type Custom method name
|
285
|
+
*
|
286
|
+
* @return {Function}
|
287
|
+
*/
|
288
|
+
extend : function (type) {
|
289
|
+
return function (message, wait) { this.log(message, type, wait); };
|
290
|
+
},
|
291
|
+
|
292
|
+
/**
|
293
|
+
* Hide the dialog and rest to defaults
|
294
|
+
*
|
295
|
+
* @return {undefined}
|
296
|
+
*/
|
297
|
+
hide : function () {
|
298
|
+
// remove reference from queue
|
299
|
+
queue.splice(0,1);
|
300
|
+
// if items remaining in the queue
|
301
|
+
if (queue.length > 0) this.setup();
|
302
|
+
else {
|
303
|
+
isopen = false;
|
304
|
+
elDialog.className = "alertify alertify-hide alertify-hidden";
|
305
|
+
elCover.className = "alertify-cover alertify-hidden";
|
306
|
+
// set focus to the last element or body
|
307
|
+
// after the dialog is closed
|
308
|
+
elCallee.focus();
|
309
|
+
}
|
310
|
+
},
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Initialize Alertify
|
314
|
+
* Create the 2 main elements
|
315
|
+
*
|
316
|
+
* @return {undefined}
|
317
|
+
*/
|
318
|
+
init : function () {
|
319
|
+
// ensure legacy browsers support html5 tags
|
320
|
+
document.createElement("nav");
|
321
|
+
document.createElement("article");
|
322
|
+
document.createElement("section");
|
323
|
+
// cover
|
324
|
+
elCover = document.createElement("div");
|
325
|
+
elCover.setAttribute("id", "alertify-cover");
|
326
|
+
elCover.className = "alertify-cover alertify-hidden";
|
327
|
+
document.body.appendChild(elCover);
|
328
|
+
// main element
|
329
|
+
elDialog = document.createElement("section");
|
330
|
+
elDialog.setAttribute("id", "alertify");
|
331
|
+
elDialog.className = "alertify alertify-hidden";
|
332
|
+
document.body.appendChild(elDialog);
|
333
|
+
// log element
|
334
|
+
elLog = document.createElement("section");
|
335
|
+
elLog.setAttribute("id", "alertify-logs");
|
336
|
+
elLog.className = "alertify-logs";
|
337
|
+
document.body.appendChild(elLog);
|
338
|
+
// set tabindex attribute on body element
|
339
|
+
// this allows script to give it focus
|
340
|
+
// after the dialog is closed
|
341
|
+
document.body.setAttribute("tabindex", "0");
|
342
|
+
// clean up init method
|
343
|
+
delete this.init;
|
344
|
+
},
|
345
|
+
|
346
|
+
/**
|
347
|
+
* Show a new log message box
|
348
|
+
*
|
349
|
+
* @param {String} message The message passed from the callee
|
350
|
+
* @param {String} type [Optional] Optional type of log message
|
351
|
+
* @param {Number} wait [Optional] Time (in ms) to wait before auto-hiding the log
|
352
|
+
*
|
353
|
+
* @return {Object}
|
354
|
+
*/
|
355
|
+
log : function (message, type, wait) {
|
356
|
+
// check to ensure the alertify dialog element
|
357
|
+
// has been successfully created
|
358
|
+
var check = function () {
|
359
|
+
if (elLog && elLog.scrollTop !== null) return;
|
360
|
+
else check();
|
361
|
+
};
|
362
|
+
// initialize alertify if it hasn't already been done
|
363
|
+
if (typeof this.init === "function") {
|
364
|
+
this.init();
|
365
|
+
check();
|
366
|
+
}
|
367
|
+
this.notify(message, type, wait);
|
368
|
+
return this;
|
369
|
+
},
|
370
|
+
|
371
|
+
/**
|
372
|
+
* Add new log message
|
373
|
+
* If a type is passed, a class name "alertify-log-{type}" will get added.
|
374
|
+
* This allows for custom look and feel for various types of notifications.
|
375
|
+
*
|
376
|
+
* @param {String} message The message passed from the callee
|
377
|
+
* @param {String} type [Optional] Type of log message
|
378
|
+
* @param {Number} wait [Optional] Time (in ms) to wait before auto-hiding
|
379
|
+
*
|
380
|
+
* @return {undefined}
|
381
|
+
*/
|
382
|
+
notify : function (message, type, wait) {
|
383
|
+
var log = document.createElement("article");
|
384
|
+
log.className = "alertify-log" + ((typeof type === "string" && type !== "") ? " alertify-log-" + type : "");
|
385
|
+
log.innerHTML = message;
|
386
|
+
// prepend child
|
387
|
+
elLog.insertBefore(log, elLog.firstChild);
|
388
|
+
// triggers the CSS animation
|
389
|
+
setTimeout(function() { log.className = log.className + " alertify-log-show"; }, 50);
|
390
|
+
this.close(log, wait);
|
391
|
+
},
|
392
|
+
|
393
|
+
/**
|
394
|
+
* Set properties
|
395
|
+
*
|
396
|
+
* @param {Object} args Passing parameters
|
397
|
+
*
|
398
|
+
* @return {undefined}
|
399
|
+
*/
|
400
|
+
set : function (args) {
|
401
|
+
var k;
|
402
|
+
// error catching
|
403
|
+
if (typeof args !== "object" && args instanceof Array) throw new Error("args must be an object");
|
404
|
+
// set parameters
|
405
|
+
for (k in args) {
|
406
|
+
if (args.hasOwnProperty(k)) {
|
407
|
+
this[k] = args[k];
|
408
|
+
}
|
409
|
+
}
|
410
|
+
},
|
411
|
+
|
412
|
+
/**
|
413
|
+
* Initiate all the required pieces for the dialog box
|
414
|
+
*
|
415
|
+
* @return {undefined}
|
416
|
+
*/
|
417
|
+
setup : function () {
|
418
|
+
var item = queue[0];
|
419
|
+
|
420
|
+
isopen = true;
|
421
|
+
elDialog.innerHTML = this.build(item);
|
422
|
+
if (typeof item.placeholder === "string") $("alertify-text").value = item.placeholder;
|
423
|
+
this.addListeners(item.callback);
|
424
|
+
},
|
425
|
+
|
426
|
+
/**
|
427
|
+
* Unbind events to elements
|
428
|
+
*
|
429
|
+
* @param {Object} el HTML Object
|
430
|
+
* @param {Event} event Event to detach to element
|
431
|
+
* @param {Function} fn Callback function
|
432
|
+
*
|
433
|
+
* @return {undefined}
|
434
|
+
*/
|
435
|
+
unbind : function (el, event, fn) {
|
436
|
+
if (typeof el.removeEventListener === "function") {
|
437
|
+
el.removeEventListener(event, fn, false);
|
438
|
+
} else if (el.detachEvent) {
|
439
|
+
el.detachEvent("on" + event, fn);
|
440
|
+
}
|
441
|
+
}
|
442
|
+
};
|
443
|
+
|
444
|
+
return {
|
445
|
+
alert : function (message, fn) { _alertify.dialog(message, "alert", fn); return this; },
|
446
|
+
confirm : function (message, fn) { _alertify.dialog(message, "confirm", fn); return this; },
|
447
|
+
extend : _alertify.extend,
|
448
|
+
init : _alertify.init,
|
449
|
+
log : function (message, type, wait) { _alertify.log(message, type, wait); return this; },
|
450
|
+
prompt : function (message, fn, placeholder) { _alertify.dialog(message, "prompt", fn, placeholder); return this; },
|
451
|
+
success : function (message, wait) { _alertify.log(message, "success", wait); return this; },
|
452
|
+
error : function (message, wait) { _alertify.log(message, "error", wait); return this; },
|
453
|
+
set : function (args) { _alertify.set(args); },
|
454
|
+
labels : _alertify.labels
|
455
|
+
};
|
456
|
+
};
|
457
|
+
|
458
|
+
// AMD and window support
|
459
|
+
if (typeof define === "function") {
|
460
|
+
define([], function () { return new Alertify(); });
|
461
|
+
} else {
|
462
|
+
if (typeof global.alertify === "undefined") {
|
463
|
+
global.alertify = new Alertify();
|
464
|
+
}
|
465
|
+
}
|
466
|
+
|
467
|
+
}(this));
|
@@ -0,0 +1,95 @@
|
|
1
|
+
.alertify-show,
|
2
|
+
.alertify-log {
|
3
|
+
-webkit-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1); /* older webkit */
|
4
|
+
-webkit-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275);
|
5
|
+
-moz-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275);
|
6
|
+
-ms-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275);
|
7
|
+
-o-transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275);
|
8
|
+
transition: all 500ms cubic-bezier(0.175, 0.885, 0.320, 1.275); /* easeOutBack */
|
9
|
+
}
|
10
|
+
.alertify-hide {
|
11
|
+
-webkit-transition: all 250ms cubic-bezier(0.600, 0, 0.735, 0.045); /* older webkit */
|
12
|
+
-webkit-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045);
|
13
|
+
-moz-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045);
|
14
|
+
-ms-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045);
|
15
|
+
-o-transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045);
|
16
|
+
transition: all 250ms cubic-bezier(0.600, -0.280, 0.735, 0.045); /* easeInBack */
|
17
|
+
}
|
18
|
+
.alertify-cover {
|
19
|
+
position: fixed; z-index: 99999;
|
20
|
+
top: 0; right: 0; bottom: 0; left: 0;
|
21
|
+
}
|
22
|
+
.alertify {
|
23
|
+
position: fixed; z-index: 99999;
|
24
|
+
top: 50px; left: 50%;
|
25
|
+
width: 550px;
|
26
|
+
margin-left: -275px;
|
27
|
+
}
|
28
|
+
.alertify-hidden {
|
29
|
+
top: -50px;
|
30
|
+
visibility: hidden;
|
31
|
+
}
|
32
|
+
.alertify-logs {
|
33
|
+
position: fixed;
|
34
|
+
z-index: 5000;
|
35
|
+
bottom: 10px;
|
36
|
+
right: 10px;
|
37
|
+
width: 300px;
|
38
|
+
}
|
39
|
+
.alertify-log {
|
40
|
+
display: block;
|
41
|
+
margin-top: 10px;
|
42
|
+
position: relative;
|
43
|
+
right: -300px;
|
44
|
+
}
|
45
|
+
.alertify-log-show {
|
46
|
+
right: 0;
|
47
|
+
}
|
48
|
+
.alertify-dialog {
|
49
|
+
padding: 25px;
|
50
|
+
}
|
51
|
+
.alertify-resetFocus {
|
52
|
+
border: 0;
|
53
|
+
clip: rect(0 0 0 0);
|
54
|
+
height: 1px;
|
55
|
+
margin: -1px;
|
56
|
+
overflow: hidden;
|
57
|
+
padding: 0;
|
58
|
+
position: absolute;
|
59
|
+
width: 1px;
|
60
|
+
}
|
61
|
+
.alertify-inner {
|
62
|
+
text-align: center;
|
63
|
+
}
|
64
|
+
.alertify-text {
|
65
|
+
margin-bottom: 15px;
|
66
|
+
width: 100%;
|
67
|
+
-webkit-box-sizing: border-box;
|
68
|
+
-moz-box-sizing: border-box;
|
69
|
+
box-sizing: border-box;
|
70
|
+
font-size: 100%;
|
71
|
+
}
|
72
|
+
.alertify-buttons {
|
73
|
+
}
|
74
|
+
.alertify-button {
|
75
|
+
/* line-height and font-size for input button */
|
76
|
+
line-height: 1.5;
|
77
|
+
font-size: 100%;
|
78
|
+
display: inline-block;
|
79
|
+
cursor: pointer;
|
80
|
+
margin-left: 5px;
|
81
|
+
}
|
82
|
+
|
83
|
+
@media only screen and (max-width: 680px) {
|
84
|
+
.alertify,
|
85
|
+
.alertify-logs {
|
86
|
+
width: 90%;
|
87
|
+
-webkit-box-sizing: border-box;
|
88
|
+
-moz-box-sizing: border-box;
|
89
|
+
box-sizing: border-box;
|
90
|
+
}
|
91
|
+
.alertify {
|
92
|
+
left: 5%;
|
93
|
+
margin: 0;
|
94
|
+
}
|
95
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
/**
|
2
|
+
* Default Look and Feel
|
3
|
+
*/
|
4
|
+
.alertify,
|
5
|
+
.alertify-log {
|
6
|
+
font-family: sans-serif;
|
7
|
+
}
|
8
|
+
.alertify {
|
9
|
+
background: #FFF;
|
10
|
+
border: 10px solid #333; /* browsers that don't support rgba */
|
11
|
+
border: 10px solid rgba(0,0,0,.7);
|
12
|
+
border-radius: 8px;
|
13
|
+
box-shadow: 0 3px 3px rgba(0,0,0,.3);
|
14
|
+
-webkit-background-clip: padding; /* Safari 4? Chrome 6? */
|
15
|
+
-moz-background-clip: padding; /* Firefox 3.6 */
|
16
|
+
background-clip: padding-box; /* Firefox 4, Safari 5, Opera 10, IE 9 */
|
17
|
+
}
|
18
|
+
.alertify-text {
|
19
|
+
border: 1px solid #CCC;
|
20
|
+
padding: 10px;
|
21
|
+
border-radius: 4px;
|
22
|
+
}
|
23
|
+
.alertify-button {
|
24
|
+
border-radius: 4px;
|
25
|
+
color: #FFF;
|
26
|
+
font-weight: bold;
|
27
|
+
padding: 6px 15px;
|
28
|
+
text-decoration: none;
|
29
|
+
text-shadow: 1px 1px 0 rgba(0,0,0,.5);
|
30
|
+
box-shadow: inset 0 1px 0 0 rgba(255,255,255,.5);
|
31
|
+
background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0));
|
32
|
+
background-image: -moz-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0));
|
33
|
+
background-image: -ms-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0));
|
34
|
+
background-image: -o-linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0));
|
35
|
+
background-image: linear-gradient(top, rgba(255,255,255,.3), rgba(255,255,255,0));
|
36
|
+
}
|
37
|
+
.alertify-button:hover,
|
38
|
+
.alertify-button:focus {
|
39
|
+
outline: none;
|
40
|
+
box-shadow: 0 0 15px #2B72D5;
|
41
|
+
background-image: -webkit-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0));
|
42
|
+
background-image: -moz-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0));
|
43
|
+
background-image: -ms-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0));
|
44
|
+
background-image: -o-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0));
|
45
|
+
background-image: linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,0));
|
46
|
+
}
|
47
|
+
.alertify-button:active {
|
48
|
+
position: relative;
|
49
|
+
top: 1px;
|
50
|
+
}
|
51
|
+
.alertify-button-cancel {
|
52
|
+
background-color: #FE1A00;
|
53
|
+
border: 1px solid #D83526;
|
54
|
+
}
|
55
|
+
.alertify-button-ok {
|
56
|
+
background-color: #5CB811;
|
57
|
+
border: 1px solid #3B7808;
|
58
|
+
}
|
59
|
+
.alertify-log {
|
60
|
+
background: #1F1F1F;
|
61
|
+
background: rgba(0,0,0,.9);
|
62
|
+
padding: 15px;
|
63
|
+
border-radius: 4px;
|
64
|
+
color: #FFF;
|
65
|
+
text-shadow: -1px -1px 0 rgba(0,0,0,.5);
|
66
|
+
}
|
67
|
+
.alertify-log-error {
|
68
|
+
background: #FE1A00;
|
69
|
+
background: rgba(254,26,0,.9);
|
70
|
+
}
|
71
|
+
.alertify-log-success {
|
72
|
+
background: #5CB811;
|
73
|
+
background: rgba(92,184,17,.9);
|
74
|
+
}
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-alertify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.12
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daniel Schmidt
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-12 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- dsci@code79.net
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- MIT-LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/alertify-rails.rb
|
27
|
+
- lib/alertify-rails/version.rb
|
28
|
+
- rails-alertify.gemspec
|
29
|
+
- vendor/assets/javascripts/alertify.js
|
30
|
+
- vendor/assets/stylesheets/alertify/core.css
|
31
|
+
- vendor/assets/stylesheets/alertify/default.css
|
32
|
+
homepage: https://github.com/dsci/rails-alertify
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.24
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: alertify.js asset pipeline integration
|
56
|
+
test_files: []
|