notie-rails 1.1.1 → 2.0.1
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.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/notie/rails/version.rb +1 -1
- data/vendor/assets/javascripts/notie.js +288 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32960fe9571dd8fed7489b895f4308e143e48929
|
4
|
+
data.tar.gz: 2eb0b4bdb620873d35a56e0c8a491c50799b4f76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 062238bd98aa3e0c1e854393aa41622db5a37ab773b3d538546ae80c06ab77148d7b3e782fedc19c450b3c22a03187ac4a9814c7904fa25c14332b54536a2d0b
|
7
|
+
data.tar.gz: d4765157d3fc6e1113d37350176b2b7027ad582d4028a1e33d72f13d3c1dbf2d4e6ae90a2033fa631201c506c50a2fc1ce08cc6b7cd359ef028851ca000bd4d3
|
data/README.md
CHANGED
@@ -20,6 +20,11 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
See [notie.js](https://jaredreich.com/projects/notie.js/) for questions about the actual javascript library. Otherwise fill out an issue if there are rails issues and I will do my best to attend to them in a timely fashion.
|
22
22
|
|
23
|
+
After you have installed notie-rails, install it to the asset pipeline by adding the following line to your `app/assets/javascripts/application.js`
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
//= require notie.js
|
27
|
+
```
|
23
28
|
## Contributing
|
24
29
|
|
25
30
|
1. Fork it ( https://github.com/djds23/notie-rails/fork )
|
data/lib/notie/rails/version.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
* Project home:
|
10
10
|
* https://jaredreich.com/projects/notie.js
|
11
11
|
*
|
12
|
-
* Version:
|
12
|
+
* Version: 2.0.1
|
13
13
|
*
|
14
14
|
*/
|
15
15
|
|
@@ -33,12 +33,12 @@ var notie = function(){
|
|
33
33
|
var alert_color_text = '#FFF';
|
34
34
|
|
35
35
|
// notie.confirm colors
|
36
|
-
var
|
37
|
-
var
|
38
|
-
var
|
39
|
-
var
|
40
|
-
var
|
41
|
-
var
|
36
|
+
var confirm_and_input_color_background = '#4D82D6';
|
37
|
+
var confirm_and_input_color_yes_background = '#57BF57';
|
38
|
+
var confirm_and_input_color_no_background = '#E1715B';
|
39
|
+
var confirm_and_input_color_text = '#FFF';
|
40
|
+
var confirm_and_input_color_yes_text = '#FFF';
|
41
|
+
var confirm_and_input_color_no_text = '#FFF';
|
42
42
|
|
43
43
|
// ID's for use within your own .css file (OPTIONAL)
|
44
44
|
// (Be sure to use !important to override the javascript)
|
@@ -54,6 +54,16 @@ var notie = function(){
|
|
54
54
|
var confirm_text_id = 'notie-confirm-text';
|
55
55
|
var confirm_yes_text_id = 'notie-confirm-yes-text';
|
56
56
|
var confirm_no_text_id = 'notie-confirm-no-text';
|
57
|
+
var input_outer_id = 'notie-input-outer';
|
58
|
+
var input_inner_id = 'notie-input-inner';
|
59
|
+
var input_backdrop_id = 'notie-input-backdrop';
|
60
|
+
var input_div_id = 'notie-input-div';
|
61
|
+
var input_field_id = 'notie-input-field';
|
62
|
+
var input_yes_id = 'notie-input-yes';
|
63
|
+
var input_no_id = 'notie-input-no';
|
64
|
+
var input_text_id = 'notie-input-text';
|
65
|
+
var input_yes_text_id = 'notie-input-yes-text';
|
66
|
+
var input_no_text_id = 'notie-input-no-text';
|
57
67
|
|
58
68
|
// *********************************************
|
59
69
|
|
@@ -107,7 +117,7 @@ var notie = function(){
|
|
107
117
|
|
108
118
|
// Declare variables
|
109
119
|
var height = 0;
|
110
|
-
var
|
120
|
+
var alert_is_showing = false;
|
111
121
|
var alert_timeout_1;
|
112
122
|
var alert_timeout_2;
|
113
123
|
var was_clicked_counter = 0;
|
@@ -122,7 +132,7 @@ var notie = function(){
|
|
122
132
|
|
123
133
|
if (was_clicked_counter == 1) {
|
124
134
|
|
125
|
-
if (
|
135
|
+
if (alert_is_showing) {
|
126
136
|
|
127
137
|
clearTimeout(alert_timeout_1);
|
128
138
|
clearTimeout(alert_timeout_2);
|
@@ -142,7 +152,7 @@ var notie = function(){
|
|
142
152
|
|
143
153
|
function alert_show(type, message, seconds) {
|
144
154
|
|
145
|
-
|
155
|
+
alert_is_showing = true;
|
146
156
|
|
147
157
|
var duration = 0;
|
148
158
|
if (typeof seconds == 'undefined') {
|
@@ -213,9 +223,9 @@ var notie = function(){
|
|
213
223
|
|
214
224
|
alert_outer.style.top = '-10000px';
|
215
225
|
|
216
|
-
|
226
|
+
alert_is_showing = false;
|
217
227
|
|
218
|
-
callback();
|
228
|
+
if (callback) { callback(); }
|
219
229
|
|
220
230
|
}, (animation_delay * 1000 + 10));
|
221
231
|
|
@@ -264,7 +274,7 @@ var notie = function(){
|
|
264
274
|
confirm_inner.style.padding = '20px';
|
265
275
|
confirm_inner.style.display = 'block';
|
266
276
|
confirm_inner.style.cursor = 'default';
|
267
|
-
confirm_inner.style.backgroundColor =
|
277
|
+
confirm_inner.style.backgroundColor = confirm_and_input_color_background;
|
268
278
|
confirm_outer.appendChild(confirm_inner);
|
269
279
|
|
270
280
|
var confirm_yes = document.createElement('div');
|
@@ -274,7 +284,7 @@ var notie = function(){
|
|
274
284
|
confirm_yes.style.lineHeight = '50px';
|
275
285
|
confirm_yes.style.width = '50%';
|
276
286
|
confirm_yes.style.cursor = 'pointer';
|
277
|
-
confirm_yes.style.backgroundColor =
|
287
|
+
confirm_yes.style.backgroundColor = confirm_and_input_color_yes_background;
|
278
288
|
confirm_outer.appendChild(confirm_yes);
|
279
289
|
|
280
290
|
var confirm_no = document.createElement('div');
|
@@ -284,14 +294,14 @@ var notie = function(){
|
|
284
294
|
confirm_no.style.lineHeight = '50px';
|
285
295
|
confirm_no.style.width = '50%';
|
286
296
|
confirm_no.style.cursor = 'pointer';
|
287
|
-
confirm_no.style.backgroundColor =
|
297
|
+
confirm_no.style.backgroundColor = confirm_and_input_color_no_background;
|
288
298
|
confirm_no.onclick = function() { confirm_hide(); }
|
289
299
|
confirm_outer.appendChild(confirm_no);
|
290
300
|
|
291
301
|
// Initialize confirm text
|
292
302
|
var confirm_text = document.createElement('span');
|
293
303
|
confirm_text.id = confirm_text_id;
|
294
|
-
confirm_text.style.color =
|
304
|
+
confirm_text.style.color = confirm_and_input_color_text;
|
295
305
|
if (window.innerWidth <= font_change_screen_width) { confirm_text.style.fontSize = font_size_small; }
|
296
306
|
else { confirm_text.style.fontSize = font_size_big; }
|
297
307
|
window.addEventListener('resize', function(){
|
@@ -302,7 +312,7 @@ var notie = function(){
|
|
302
312
|
|
303
313
|
var confirm_yes_text = document.createElement('span');
|
304
314
|
confirm_yes_text.id = confirm_yes_text_id;
|
305
|
-
confirm_yes_text.style.color =
|
315
|
+
confirm_yes_text.style.color = confirm_and_input_color_yes_text;
|
306
316
|
if (window.innerWidth <= font_change_screen_width) { confirm_yes_text.style.fontSize = font_size_small; }
|
307
317
|
else { confirm_yes_text.style.fontSize = font_size_big; }
|
308
318
|
window.addEventListener('resize', function(){
|
@@ -313,7 +323,7 @@ var notie = function(){
|
|
313
323
|
|
314
324
|
var confirm_no_text = document.createElement('span');
|
315
325
|
confirm_no_text.id = confirm_no_text_id;
|
316
|
-
confirm_no_text.style.color =
|
326
|
+
confirm_no_text.style.color = confirm_and_input_color_no_text;
|
317
327
|
if (window.innerWidth <= font_change_screen_width) { confirm_no_text.style.fontSize = font_size_small; }
|
318
328
|
else { confirm_no_text.style.fontSize = font_size_big; }
|
319
329
|
window.addEventListener('resize', function(){
|
@@ -331,13 +341,19 @@ var notie = function(){
|
|
331
341
|
var confirm_is_showing = false;
|
332
342
|
|
333
343
|
function confirm(title, yes_text, no_text, yes_callback) {
|
334
|
-
|
335
|
-
confirm_show(title, yes_text, no_text, yes_callback);
|
336
344
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
345
|
+
if (alert_is_showing) {
|
346
|
+
// Hide notie.alert
|
347
|
+
clearTimeout(alert_timeout_1);
|
348
|
+
clearTimeout(alert_timeout_2);
|
349
|
+
alert_hide(function() {
|
350
|
+
confirm_show(title, yes_text, no_text, yes_callback);
|
351
|
+
});
|
352
|
+
}
|
353
|
+
else {
|
354
|
+
confirm_show(title, yes_text, no_text, yes_callback);
|
355
|
+
}
|
356
|
+
|
341
357
|
|
342
358
|
}
|
343
359
|
function confirm_show(title, yes_text, no_text, yes_callback) {
|
@@ -417,9 +433,253 @@ var notie = function(){
|
|
417
433
|
}, (animation_delay * 1000 + 10));
|
418
434
|
|
419
435
|
}
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
// NOTIE.INPUT
|
441
|
+
// *********************************************
|
442
|
+
|
443
|
+
// input elements and styling
|
444
|
+
var input_outer = document.createElement('div');
|
445
|
+
input_outer.id = input_outer_id;
|
446
|
+
input_outer.style.position = 'fixed';
|
447
|
+
input_outer.style.top = '0';
|
448
|
+
input_outer.style.left = '0';
|
449
|
+
input_outer.style.zIndex = '999999998';
|
450
|
+
input_outer.style.height = 'auto';
|
451
|
+
input_outer.style.width = '100%';
|
452
|
+
input_outer.style.display = 'none';
|
453
|
+
input_outer.style.textAlign = 'center';
|
454
|
+
input_outer.style.MozTransition = '';
|
455
|
+
input_outer.style.WebkitTransition = '';
|
456
|
+
input_outer.style.transition = '';
|
457
|
+
|
458
|
+
var input_backdrop = document.createElement('div');
|
459
|
+
input_backdrop.id = input_backdrop_id;
|
460
|
+
input_backdrop.style.position = 'fixed';
|
461
|
+
input_backdrop.style.top = '0';
|
462
|
+
input_backdrop.style.left = '0';
|
463
|
+
input_backdrop.style.zIndex = '999999997';
|
464
|
+
input_backdrop.style.height = '100%';
|
465
|
+
input_backdrop.style.width = '100%';
|
466
|
+
input_backdrop.style.display = 'none';
|
467
|
+
input_backdrop.style.backgroundColor = 'white';
|
468
|
+
input_backdrop.style.MozTransition = 'all ' + animation_delay + 's ease';
|
469
|
+
input_backdrop.style.WebkitTransition = 'all ' + animation_delay + 's ease';
|
470
|
+
input_backdrop.style.transition = 'all ' + animation_delay + 's ease';
|
471
|
+
input_backdrop.style.opacity = '0';
|
472
|
+
input_backdrop.onclick = function() { input_hide(); }
|
473
|
+
|
474
|
+
var input_inner = document.createElement('div');
|
475
|
+
input_inner.id = input_inner_id;
|
476
|
+
input_inner.style.boxSizing = 'border-box';
|
477
|
+
input_inner.style.width = '100%';
|
478
|
+
input_inner.style.padding = '20px';
|
479
|
+
input_inner.style.display = 'block';
|
480
|
+
input_inner.style.cursor = 'default';
|
481
|
+
input_inner.style.backgroundColor = confirm_and_input_color_background;
|
482
|
+
input_outer.appendChild(input_inner);
|
483
|
+
|
484
|
+
var input_div = document.createElement('div');
|
485
|
+
input_div.id = input_div_id;
|
486
|
+
input_div.style.boxSizing = 'border-box';
|
487
|
+
input_div.style.height = '55px';
|
488
|
+
input_div.style.width = '100%';
|
489
|
+
input_div.style.display = 'block';
|
490
|
+
input_div.style.cursor = 'default';
|
491
|
+
input_div.style.backgroundColor = '#FFF';
|
492
|
+
input_outer.appendChild(input_div);
|
493
|
+
|
494
|
+
var input_field = document.createElement('input');
|
495
|
+
input_field.id = input_field_id;
|
496
|
+
input_field.setAttribute('autocomplete', 'off');
|
497
|
+
input_field.setAttribute('autocorrect', 'off');
|
498
|
+
input_field.setAttribute('autocapitalize', 'off');
|
499
|
+
input_field.setAttribute('spellcheck', 'false');
|
500
|
+
input_field.style.boxSizing = 'border-box';
|
501
|
+
input_field.style.height = '55px';
|
502
|
+
input_field.style.width = '100%';
|
503
|
+
input_field.style.textAlign = 'center';
|
504
|
+
input_field.style.textIndent = '10px';
|
505
|
+
input_field.style.paddingRight = '10px';
|
506
|
+
input_field.style.outline = '0';
|
507
|
+
input_field.style.border = '0';
|
508
|
+
input_field.style.fontFamily = 'inherit';
|
509
|
+
input_field.style.fontSize = font_size_big;
|
510
|
+
if (window.innerWidth <= font_change_screen_width) { input_field.style.fontSize = font_size_small; }
|
511
|
+
else { input_field.style.fontSize = font_size_big; }
|
512
|
+
window.addEventListener('resize', function(){
|
513
|
+
if (window.innerWidth <= font_change_screen_width) { input_field.style.fontSize = font_size_small; }
|
514
|
+
else { input_field.style.fontSize = font_size_big; }
|
515
|
+
}, true);
|
516
|
+
input_div.appendChild(input_field);
|
517
|
+
|
518
|
+
var input_yes = document.createElement('div');
|
519
|
+
input_yes.id = input_yes_id;
|
520
|
+
input_yes.style.cssFloat = 'left';
|
521
|
+
input_yes.style.height = '50px';
|
522
|
+
input_yes.style.lineHeight = '50px';
|
523
|
+
input_yes.style.width = '50%';
|
524
|
+
input_yes.style.cursor = 'pointer';
|
525
|
+
input_yes.style.backgroundColor = confirm_and_input_color_yes_background;
|
526
|
+
input_outer.appendChild(input_yes);
|
527
|
+
|
528
|
+
var input_no = document.createElement('div');
|
529
|
+
input_no.id = input_no_id;
|
530
|
+
input_no.style.cssFloat = 'right';
|
531
|
+
input_no.style.height = '50px';
|
532
|
+
input_no.style.lineHeight = '50px';
|
533
|
+
input_no.style.width = '50%';
|
534
|
+
input_no.style.cursor = 'pointer';
|
535
|
+
input_no.style.backgroundColor = confirm_and_input_color_no_background;
|
536
|
+
input_no.onclick = function() { input_hide(); }
|
537
|
+
input_outer.appendChild(input_no);
|
538
|
+
|
539
|
+
// Initialize input text
|
540
|
+
var input_text = document.createElement('span');
|
541
|
+
input_text.id = input_text_id;
|
542
|
+
input_text.style.color = confirm_and_input_color_text;
|
543
|
+
if (window.innerWidth <= font_change_screen_width) { input_text.style.fontSize = font_size_small; }
|
544
|
+
else { input_text.style.fontSize = font_size_big; }
|
545
|
+
window.addEventListener('resize', function(){
|
546
|
+
if (window.innerWidth <= font_change_screen_width) { input_text.style.fontSize = font_size_small; }
|
547
|
+
else { input_text.style.fontSize = font_size_big; }
|
548
|
+
}, true);
|
549
|
+
input_inner.appendChild(input_text);
|
550
|
+
|
551
|
+
var input_yes_text = document.createElement('span');
|
552
|
+
input_yes_text.id = input_yes_text_id;
|
553
|
+
input_yes_text.style.color = confirm_and_input_color_yes_text;
|
554
|
+
if (window.innerWidth <= font_change_screen_width) { input_yes_text.style.fontSize = font_size_small; }
|
555
|
+
else { input_yes_text.style.fontSize = font_size_big; }
|
556
|
+
window.addEventListener('resize', function(){
|
557
|
+
if (window.innerWidth <= font_change_screen_width) { input_yes_text.style.fontSize = font_size_small; }
|
558
|
+
else { input_yes_text.style.fontSize = font_size_big; }
|
559
|
+
}, true);
|
560
|
+
input_yes.appendChild(input_yes_text);
|
561
|
+
|
562
|
+
var input_no_text = document.createElement('span');
|
563
|
+
input_no_text.id = input_no_text_id;
|
564
|
+
input_no_text.style.color = confirm_and_input_color_no_text;
|
565
|
+
if (window.innerWidth <= font_change_screen_width) { input_no_text.style.fontSize = font_size_small; }
|
566
|
+
else { input_no_text.style.fontSize = font_size_big; }
|
567
|
+
window.addEventListener('resize', function(){
|
568
|
+
if (window.innerWidth <= font_change_screen_width) { input_no_text.style.fontSize = font_size_small; }
|
569
|
+
else { input_no_text.style.fontSize = font_size_big; }
|
570
|
+
}, true);
|
571
|
+
input_no.appendChild(input_no_text);
|
572
|
+
|
573
|
+
// Attach input elements to the body element
|
574
|
+
document.body.appendChild(input_outer);
|
575
|
+
document.body.appendChild(input_backdrop);
|
576
|
+
|
577
|
+
// Declare variables
|
578
|
+
var input_height = 0;
|
579
|
+
var input_is_showing = false;
|
580
|
+
|
581
|
+
function input(title, submit_text, cancel_text, type, placeholder, submit_callback, prefilled_value_optional) {
|
582
|
+
|
583
|
+
input_field.setAttribute('type', type);
|
584
|
+
input_field.setAttribute('placeholder', placeholder);
|
585
|
+
input_field.value = '';
|
586
|
+
if (typeof prefilled_value_optional !== 'undefined' && prefilled_value_optional.length > 0) { input_field.value = prefilled_value_optional }
|
587
|
+
|
588
|
+
if (alert_is_showing) {
|
589
|
+
// Hide notie.alert
|
590
|
+
clearTimeout(alert_timeout_1);
|
591
|
+
clearTimeout(alert_timeout_2);
|
592
|
+
alert_hide(function() {
|
593
|
+
input_show(title, submit_text, cancel_text, submit_callback);
|
594
|
+
});
|
595
|
+
}
|
596
|
+
else {
|
597
|
+
input_show(title, submit_text, cancel_text, submit_callback);
|
598
|
+
}
|
599
|
+
|
600
|
+
}
|
601
|
+
function input_show(title, submit_text, cancel_text, submit_callback) {
|
602
|
+
|
603
|
+
scroll_disable();
|
604
|
+
|
605
|
+
// Yes callback function
|
606
|
+
input_yes.onclick = function() {
|
607
|
+
input_hide();
|
608
|
+
setTimeout(function() {
|
609
|
+
submit_callback(input_field.value);
|
610
|
+
}, (animation_delay * 1000 + 10));
|
611
|
+
}
|
612
|
+
|
613
|
+
function input_show_inner() {
|
614
|
+
|
615
|
+
// Set input text
|
616
|
+
input_text.innerHTML = title;
|
617
|
+
input_yes_text.innerHTML = submit_text;
|
618
|
+
input_no_text.innerHTML = cancel_text;
|
619
|
+
|
620
|
+
// Get input's height
|
621
|
+
input_outer.style.top = '-10000px';
|
622
|
+
input_outer.style.display = 'table';
|
623
|
+
input_outer.style.top = '-' + input_outer.offsetHeight - 5 + 'px';
|
624
|
+
input_backdrop.style.display = 'block';
|
625
|
+
|
626
|
+
setTimeout(function() {
|
627
|
+
|
628
|
+
if (shadow) { input_outer.style.boxShadow = '0px 0px 10px 0px rgba(0,0,0,0.5)'; }
|
629
|
+
input_outer.style.MozTransition = 'all ' + animation_delay + 's ease';
|
630
|
+
input_outer.style.WebkitTransition = 'all ' + animation_delay + 's ease';
|
631
|
+
input_outer.style.transition = 'all ' + animation_delay + 's ease';
|
632
|
+
|
633
|
+
input_outer.style.top = 0;
|
634
|
+
input_backdrop.style.opacity = '0.75';
|
635
|
+
|
636
|
+
setTimeout(function() {
|
637
|
+
input_is_showing = true;
|
638
|
+
}, (animation_delay * 1000 + 10));
|
639
|
+
|
640
|
+
}, 20);
|
641
|
+
|
642
|
+
}
|
643
|
+
|
644
|
+
if (input_is_showing) {
|
645
|
+
input_hide();
|
646
|
+
setTimeout(function() {
|
647
|
+
input_show_inner();
|
648
|
+
}, (animation_delay * 1000 + 10));
|
649
|
+
}
|
650
|
+
else {
|
651
|
+
input_show_inner();
|
652
|
+
}
|
653
|
+
|
654
|
+
}
|
655
|
+
|
656
|
+
function input_hide() {
|
657
|
+
|
658
|
+
input_outer.style.top = '-' + input_outer.offsetHeight - 5 + 'px';
|
659
|
+
input_backdrop.style.opacity = '0';
|
660
|
+
|
661
|
+
setTimeout(function() {
|
662
|
+
|
663
|
+
if (shadow) { input_outer.style.boxShadow = ''; }
|
664
|
+
input_outer.style.MozTransition = '';
|
665
|
+
input_outer.style.WebkitTransition = '';
|
666
|
+
input_outer.style.transition = '';
|
667
|
+
input_backdrop.style.display = 'none';
|
668
|
+
|
669
|
+
input_outer.style.top = '-10000px';
|
670
|
+
|
671
|
+
scroll_enable();
|
672
|
+
|
673
|
+
input_is_showing = false;
|
674
|
+
|
675
|
+
}, (animation_delay * 1000 + 10));
|
676
|
+
|
677
|
+
}
|
678
|
+
|
679
|
+
|
420
680
|
|
421
681
|
|
422
|
-
// SCROLL DISABLE AND ENABLE FOR NOTIE.CONFIRM
|
682
|
+
// SCROLL DISABLE AND ENABLE FOR NOTIE.CONFIRM and NOTIE.INPUT
|
423
683
|
// *********************************************
|
424
684
|
var original_body_height, original_body_overflow;
|
425
685
|
function scroll_disable() {
|
@@ -438,11 +698,12 @@ var notie = function(){
|
|
438
698
|
|
439
699
|
return {
|
440
700
|
alert: alert,
|
441
|
-
confirm: confirm
|
701
|
+
confirm: confirm,
|
702
|
+
input: input
|
442
703
|
};
|
443
704
|
|
444
705
|
}();
|
445
706
|
|
446
|
-
if (module) {
|
707
|
+
if (typeof module !== 'undefined' && module) {
|
447
708
|
module.exports = notie;
|
448
709
|
}
|