alertifyjs-rails 0.1.4 → 0.1.5

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7ca53d8a430d1a6482ff288e1b3c4bbe083c348b
4
+ data.tar.gz: cdf819e7fec0e42d62e3e892fcfc03842c8c263c
5
+ SHA512:
6
+ metadata.gz: 5dfc7777cc4d2b89478c5d9257e69409ddb0b0b07cbe6009e975ef42a0203fa7850b217a869a1014b1f3817f43c6142e093d31f9069318d3ca7894ad4e966f0d
7
+ data.tar.gz: f83c19d29a5bc9b0460fa754ee8d9f93fe68bf3655c13ba1824314d3cdeebf6866bcd75188ccd44864ca83d101aba2ab4a267c20c3cf7834485a8afac324957b
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # alertifyjs-rails
2
2
 
3
- This gem provides [alertify.js](http://alertifyjs.com/) (v0.7) for Rails.
3
+ This gem provides [alertify.js](http://alertifyjs.com/) (v0.9) for Rails.
4
4
 
5
5
 
6
6
  ## Installation
@@ -7,11 +7,11 @@ Gem::Specification.new do |gem|
7
7
  gem.name = "alertifyjs-rails"
8
8
  gem.version = Alertifyjs::Rails::VERSION
9
9
  gem.authors = ["mkhairi"]
10
-
10
+ gem.email = ["khairi@labs.my"]
11
11
  gem.description = %q{Use Alertify.js (alertifyjs.com) with Rails 3 and 4}
12
12
  gem.summary = %q{This gem provides the Alertify.js (alertifyjs.com) for Rails applications}
13
13
  gem.homepage = "https://github.com/mkhairi/alertifyjs-rails.git"
14
-
14
+ gem.license = "MIT"
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -1,6 +1,6 @@
1
1
  module Alertifyjs #:nodoc:
2
2
  module Rails #:nodoc:
3
- VERSION = "0.1.4"
4
- ALERTIFYJS_VERSION = "0.7.0"
3
+ VERSION = "0.1.5"
4
+ ALERTIFYJS_VERSION = "0.10.2"
5
5
  end
6
6
  end
@@ -7,7 +7,7 @@
7
7
  * @license MIT <http://opensource.org/licenses/mit-license.php>
8
8
  * @link http://alertifyjs.com
9
9
  * @module AlertifyJS
10
- * @version 0.7.0
10
+ * @version 0.10.2
11
11
  */
12
12
  ( function ( window ) {
13
13
  'use strict';
@@ -20,7 +20,9 @@
20
20
  ENTER: 13,
21
21
  ESC: 27,
22
22
  F1: 112,
23
- F12: 123
23
+ F12: 123,
24
+ LEFT: 37,
25
+ RIGHT: 39
24
26
  };
25
27
  /**
26
28
  * Default options
@@ -28,10 +30,13 @@
28
30
  */
29
31
  var defaults = {
30
32
  modal:true,
33
+ basic:false,
34
+ frameless:false,
31
35
  movable:true,
32
36
  resizable:true,
33
37
  closable:true,
34
38
  maximizable:true,
39
+ startMaximized:false,
35
40
  pinnable:true,
36
41
  pinned:true,
37
42
  padding: true,
@@ -254,7 +259,7 @@
254
259
  /*tab index required to fire click event before body focus*/
255
260
  modal: '<div class="ajs-modal" tabindex="0"></div>',
256
261
  dialog: '<div class="ajs-dialog" tabindex="0"></div>',
257
- reset: '<a class="ajs-reset" href="#"></a>',
262
+ reset: '<button class="ajs-reset"></button>',
258
263
  commands: '<div class="ajs-commands"><button class="ajs-pin"></button><button class="ajs-maximize"></button><button class="ajs-close"></button></div>',
259
264
  header: '<div class="ajs-header"></div>',
260
265
  body: '<div class="ajs-body"></div>',
@@ -286,7 +291,9 @@
286
291
  maximized: 'ajs-maximized',
287
292
  animationIn: 'ajs-in',
288
293
  animationOut: 'ajs-out',
289
- shake:'ajs-shake'
294
+ shake:'ajs-shake',
295
+ basic:'ajs-basic',
296
+ frameless:'ajs-frameless'
290
297
  };
291
298
 
292
299
  /**
@@ -344,16 +351,19 @@
344
351
  activeElement:document.body,
345
352
  timerIn:undefined,
346
353
  timerOut:undefined,
347
- buttons: setup.buttons,
354
+ buttons: setup.buttons || [],
348
355
  focus: setup.focus,
349
356
  options: {
350
357
  title: undefined,
351
358
  modal: undefined,
359
+ basic:undefined,
360
+ frameless:undefined,
352
361
  pinned: undefined,
353
362
  movable: undefined,
354
363
  resizable: undefined,
355
364
  closable: undefined,
356
365
  maximizable: undefined,
366
+ startMaximized: undefined,
357
367
  pinnable: undefined,
358
368
  transition: undefined,
359
369
  padding:undefined,
@@ -389,7 +399,7 @@
389
399
  elements.modal = elements.root.lastChild;
390
400
  elements.modal.innerHTML = templates.dialog;
391
401
  elements.dialog = elements.modal.firstChild;
392
- elements.dialog.innerHTML = templates.reset + templates.commands + templates.header + templates.body + templates.footer + templates.reset;
402
+ elements.dialog.innerHTML = templates.reset + templates.commands + templates.header + templates.body + templates.footer + templates.resizeHandle + templates.reset;
393
403
 
394
404
  //reset links
395
405
  elements.reset = [];
@@ -413,8 +423,10 @@
413
423
 
414
424
  //footer
415
425
  elements.footer = elements.body.nextSibling;
416
- elements.footer.innerHTML = templates.buttons.auxiliary + templates.buttons.primary + templates.resizeHandle;
417
- elements.resizeHandle = elements.footer.lastChild;
426
+ elements.footer.innerHTML = templates.buttons.auxiliary + templates.buttons.primary;
427
+
428
+ //resize handle
429
+ elements.resizeHandle = elements.footer.nextSibling;
418
430
 
419
431
  //buttons
420
432
  elements.buttons = {};
@@ -465,23 +477,26 @@
465
477
 
466
478
 
467
479
  //settings
468
- instance.setting('title', setup.options.title === undefined ? alertify.defaults.glossary.title : setup.options.title);
480
+ instance.set('title', setup.options.title === undefined ? alertify.defaults.glossary.title : setup.options.title);
469
481
 
470
- instance.setting('modal', setup.options.modal === undefined ? alertify.defaults.modal : setup.options.modal);
482
+ instance.set('modal', setup.options.modal === undefined ? alertify.defaults.modal : setup.options.modal);
483
+ instance.set('basic', setup.options.basic === undefined ? alertify.defaults.basic : setup.options.basic);
484
+ instance.set('frameless', setup.options.frameless === undefined ? alertify.defaults.frameless : setup.options.frameless);
471
485
 
472
- instance.setting('movable', setup.options.movable === undefined ? alertify.defaults.movable : setup.options.movable);
473
- instance.setting('resizable', setup.options.resizable === undefined ? alertify.defaults.resizable : setup.options.resizable);
486
+ instance.set('movable', setup.options.movable === undefined ? alertify.defaults.movable : setup.options.movable);
487
+ instance.set('resizable', setup.options.resizable === undefined ? alertify.defaults.resizable : setup.options.resizable);
474
488
 
475
- instance.setting('closable', setup.options.closable === undefined ? alertify.defaults.closable : setup.options.closable);
476
- instance.setting('maximizable', setup.options.maximizable === undefined ? alertify.defaults.maximizable : setup.options.maximizable);
489
+ instance.set('closable', setup.options.closable === undefined ? alertify.defaults.closable : setup.options.closable);
490
+ instance.set('maximizable', setup.options.maximizable === undefined ? alertify.defaults.maximizable : setup.options.maximizable);
491
+ instance.set('startMaximized', setup.options.startMaximized === undefined ? alertify.defaults.startMaximized : setup.options.startMaximized);
477
492
 
478
- instance.setting('pinnable', setup.options.pinnable === undefined ? alertify.defaults.pinnable : setup.options.pinnable);
479
- instance.setting('pinned', setup.options.pinned === undefined ? alertify.defaults.pinned : setup.options.pinned);
493
+ instance.set('pinnable', setup.options.pinnable === undefined ? alertify.defaults.pinnable : setup.options.pinnable);
494
+ instance.set('pinned', setup.options.pinned === undefined ? alertify.defaults.pinned : setup.options.pinned);
480
495
 
481
- instance.setting('transition', setup.options.transition === undefined ? alertify.defaults.transition : setup.options.transition);
496
+ instance.set('transition', setup.options.transition === undefined ? alertify.defaults.transition : setup.options.transition);
482
497
 
483
- instance.setting('padding', setup.options.padding === undefined ? alertify.defaults.padding : setup.options.padding);
484
- instance.setting('overflow', setup.options.overflow === undefined ? alertify.defaults.overflow : setup.options.overflow);
498
+ instance.set('padding', setup.options.padding === undefined ? alertify.defaults.padding : setup.options.padding);
499
+ instance.set('overflow', setup.options.overflow === undefined ? alertify.defaults.overflow : setup.options.overflow);
485
500
 
486
501
 
487
502
  // allow dom customization
@@ -533,12 +548,11 @@
533
548
  * Toggles the dialog display mode
534
549
  *
535
550
  * @param {Object} instance The dilog instance.
536
- * @param {Boolean} on True to make it modal, false otherwise.
537
551
  *
538
552
  * @return {undefined}
539
553
  */
540
554
  function updateDisplayMode(instance){
541
- if(instance.setting('modal')){
555
+ if(instance.get('modal')){
542
556
 
543
557
  //make modal
544
558
  removeClass(instance.elements.root, classes.modeless);
@@ -567,6 +581,40 @@
567
581
  }
568
582
  }
569
583
  }
584
+
585
+ /**
586
+ * Toggles the dialog basic view mode
587
+ *
588
+ * @param {Object} instance The dilog instance.
589
+ *
590
+ * @return {undefined}
591
+ */
592
+ function updateBasicMode(instance){
593
+ if (instance.get('basic')) {
594
+ // add class
595
+ addClass(instance.elements.root, classes.basic);
596
+ } else {
597
+ // remove class
598
+ removeClass(instance.elements.root, classes.basic);
599
+ }
600
+ }
601
+
602
+ /**
603
+ * Toggles the dialog frameless view mode
604
+ *
605
+ * @param {Object} instance The dilog instance.
606
+ *
607
+ * @return {undefined}
608
+ */
609
+ function updateFramelessMode(instance){
610
+ if (instance.get('frameless')) {
611
+ // add class
612
+ addClass(instance.elements.root, classes.frameless);
613
+ } else {
614
+ // remove class
615
+ removeClass(instance.elements.root, classes.frameless);
616
+ }
617
+ }
570
618
 
571
619
  /**
572
620
  * Helper: Brings the modeless dialog to front, attached to modeless dialogs.
@@ -614,6 +662,12 @@
614
662
  case 'modal':
615
663
  updateDisplayMode(instance);
616
664
  break;
665
+ case 'basic':
666
+ updateBasicMode(instance);
667
+ break;
668
+ case 'frameless':
669
+ updateFramelessMode(instance);
670
+ break;
617
671
  case 'pinned':
618
672
  updatePinned(instance);
619
673
  break;
@@ -792,7 +846,7 @@
792
846
  */
793
847
  function pin(instance) {
794
848
  //pin the dialog
795
- instance.setting('pinned', true);
849
+ instance.set('pinned', true);
796
850
  }
797
851
 
798
852
  /**
@@ -804,7 +858,7 @@
804
858
  */
805
859
  function unpin(instance) {
806
860
  //unpin the dialog
807
- instance.setting('pinned', false);
861
+ instance.set('pinned', false);
808
862
  }
809
863
 
810
864
 
@@ -847,7 +901,7 @@
847
901
  * @return {undefined}
848
902
  */
849
903
  function updatePinnable(instance) {
850
- if (instance.setting('pinnable')) {
904
+ if (instance.get('pinnable')) {
851
905
  // add class
852
906
  addClass(instance.elements.root, classes.pinnable);
853
907
  } else {
@@ -908,7 +962,7 @@
908
962
  */
909
963
  function updateAbsPositionFix(instance) {
910
964
  // if modeless and unpinned add fix
911
- if (!instance.setting('modal') && !instance.setting('pinned')) {
965
+ if (!instance.get('modal') && !instance.get('pinned')) {
912
966
  addAbsPositionFix(instance);
913
967
  } else {
914
968
  removeAbsPositionFix(instance);
@@ -923,7 +977,7 @@
923
977
  * @return {undefined}
924
978
  */
925
979
  function updatePinned(instance) {
926
- if (instance.setting('pinned')) {
980
+ if (instance.get('pinned')) {
927
981
  removeClass(instance.elements.root, classes.unpinned);
928
982
  if (instance.isOpen()) {
929
983
  removeAbsPositionFix(instance);
@@ -945,7 +999,7 @@
945
999
  * @return {undefined}
946
1000
  */
947
1001
  function updateMaximizable(instance) {
948
- if (instance.setting('maximizable')) {
1002
+ if (instance.get('maximizable')) {
949
1003
  // add class
950
1004
  addClass(instance.elements.root, classes.maximizable);
951
1005
  } else {
@@ -963,7 +1017,7 @@
963
1017
  * @return {undefined}
964
1018
  */
965
1019
  function updateClosable(instance) {
966
- if (instance.setting('closable')) {
1020
+ if (instance.get('closable')) {
967
1021
  // add class
968
1022
  addClass(instance.elements.root, classes.closable);
969
1023
  bindClosableEvents(instance);
@@ -1054,7 +1108,10 @@
1054
1108
  }
1055
1109
  var instance = openDialogs[openDialogs.length - 1];
1056
1110
  var keyCode = event.keyCode;
1057
- if (usedKeys.indexOf(keyCode) > -1) {
1111
+ if (instance.__internal.buttons.length === 0 && keyCode === keys.ESC && instance.get('closable') === true) {
1112
+ triggerClose(instance);
1113
+ return false;
1114
+ }else if (usedKeys.indexOf(keyCode) > -1) {
1058
1115
  triggerCallback(instance, function (button) {
1059
1116
  return button.key === keyCode;
1060
1117
  });
@@ -1072,7 +1129,21 @@
1072
1129
  function keydownHandler(event) {
1073
1130
  var instance = openDialogs[openDialogs.length - 1];
1074
1131
  var keyCode = event.keyCode;
1075
- if (keyCode < keys.F12 + 1 && keyCode > keys.F1 - 1 && usedKeys.indexOf(keyCode) > -1) {
1132
+ if (keyCode === keys.LEFT || keyCode === keys.RIGHT) {
1133
+ var buttons = instance.__internal.buttons;
1134
+ for (var x = 0; x < buttons.length; x += 1) {
1135
+ if (document.activeElement === buttons[x].element) {
1136
+ switch (keyCode) {
1137
+ case keys.LEFT:
1138
+ buttons[(x || buttons.length) - 1].element.focus();
1139
+ return;
1140
+ case keys.RIGHT:
1141
+ buttons[(x + 1) % buttons.length].element.focus();
1142
+ return;
1143
+ }
1144
+ }
1145
+ }
1146
+ }else if (keyCode < keys.F12 + 1 && keyCode > keys.F1 - 1 && usedKeys.indexOf(keyCode) > -1) {
1076
1147
  event.preventDefault();
1077
1148
  event.stopPropagation();
1078
1149
  triggerCallback(instance, function (button) {
@@ -1100,9 +1171,32 @@
1100
1171
  var focus = instance.__internal.focus;
1101
1172
  // the focus element.
1102
1173
  var element = focus.element;
1174
+
1175
+ switch (typeof focus.element) {
1103
1176
  // a number means a button index
1104
- if (typeof focus.element === 'number') {
1105
- element = instance.__internal.buttons[focus.element].element;
1177
+ case 'number':
1178
+ if (instance.__internal.buttons.length > focus.element) {
1179
+ //in basic view, skip focusing the buttons.
1180
+ if (instance.get('basic') === true) {
1181
+ element = instance.elements.reset[0];
1182
+ } else {
1183
+ element = instance.__internal.buttons[focus.element].element;
1184
+ }
1185
+ }
1186
+ break;
1187
+ // a string means querySelector to select from dialog body contents.
1188
+ case 'string':
1189
+ element = instance.elements.body.querySelector(focus.element);
1190
+ break;
1191
+ // a function should return the focus element.
1192
+ case 'function':
1193
+ element = focus.element.call(instance);
1194
+ break;
1195
+ }
1196
+
1197
+ // if no focus element, default to first reset element.
1198
+ if ((typeof element === 'undefined' || element === null) && instance.__internal.buttons.length === 0) {
1199
+ element = instance.elements.reset[0];
1106
1200
  }
1107
1201
  // focus
1108
1202
  if (element && element.focus) {
@@ -1139,13 +1233,13 @@
1139
1233
  if (instance && instance.isModal()) {
1140
1234
  // determine reset target to enable forward/backward tab cycle.
1141
1235
  var resetTarget, target = event.srcElement || event.target;
1142
- var lastResetLink = target === instance.elements.reset[1];
1236
+ var lastResetElement = target === instance.elements.reset[1] || (instance.__internal.buttons.length === 0 && target === document.body);
1143
1237
 
1144
1238
  // if last reset link, then go to maximize or close
1145
- if (lastResetLink) {
1146
- if (instance.setting('maximizable')) {
1239
+ if (lastResetElement) {
1240
+ if (instance.get('maximizable')) {
1147
1241
  resetTarget = instance.elements.commands.maximize;
1148
- } else if (instance.setting('closable')) {
1242
+ } else if (instance.get('closable')) {
1149
1243
  resetTarget = instance.elements.commands.close;
1150
1244
  }
1151
1245
  }
@@ -1155,7 +1249,7 @@
1155
1249
  // button focus element, go to first available button
1156
1250
  if (target === instance.elements.reset[0]) {
1157
1251
  resetTarget = instance.elements.buttons.auxiliary.firstChild || instance.elements.buttons.primary.firstChild;
1158
- } else if (lastResetLink) {
1252
+ } else if (lastResetElement) {
1159
1253
  //restart the cycle by going to first reset link
1160
1254
  resetTarget = instance.elements.reset[0];
1161
1255
  }
@@ -1190,8 +1284,8 @@
1190
1284
  cancelKeyup = false;
1191
1285
 
1192
1286
  // allow custom `onfocus` method
1193
- if (typeof instance.setting('onfocus') === 'function') {
1194
- instance.setting('onfocus')();
1287
+ if (typeof instance.get('onfocus') === 'function') {
1288
+ instance.get('onfocus')();
1195
1289
  }
1196
1290
 
1197
1291
  // unbind the event
@@ -1220,7 +1314,7 @@
1220
1314
  resetResize(instance);
1221
1315
 
1222
1316
  // restore if maximized
1223
- if (instance.isMaximized()) {
1317
+ if (instance.isMaximized() && !instance.get('startMaximized')) {
1224
1318
  restore(instance);
1225
1319
  }
1226
1320
 
@@ -1264,7 +1358,7 @@
1264
1358
  * @return {Boolean} false
1265
1359
  */
1266
1360
  function beginMove(event, instance) {
1267
- if (resizable === null && !instance.isMaximized() && instance.setting('movable')) {
1361
+ if (resizable === null && !instance.isMaximized() && instance.get('movable')) {
1268
1362
  var eventSrc;
1269
1363
  if (event.type === 'touchstart') {
1270
1364
  event.preventDefault();
@@ -1355,7 +1449,7 @@
1355
1449
  * @return {undefined}
1356
1450
  */
1357
1451
  function updateMovable(instance) {
1358
- if (instance.setting('movable')) {
1452
+ if (instance.get('movable')) {
1359
1453
  // add class
1360
1454
  addClass(instance.elements.root, classes.movable);
1361
1455
  if (instance.isOpen()) {
@@ -1504,7 +1598,7 @@
1504
1598
  eventSrc = event;
1505
1599
  }
1506
1600
  if (eventSrc) {
1507
- resizeElement(eventSrc, resizable.elements.dialog, !resizable.setting('modal') && !resizable.setting('pinned'));
1601
+ resizeElement(eventSrc, resizable.elements.dialog, !resizable.get('modal') && !resizable.get('pinned'));
1508
1602
  }
1509
1603
  }
1510
1604
  }
@@ -1552,7 +1646,7 @@
1552
1646
  * @return {undefined}
1553
1647
  */
1554
1648
  function updateResizable(instance) {
1555
- if (instance.setting('resizable')) {
1649
+ if (instance.get('resizable')) {
1556
1650
  // add class
1557
1651
  addClass(instance.elements.root, classes.resizable);
1558
1652
  if (instance.isOpen()) {
@@ -1591,7 +1685,7 @@
1591
1685
  * @return {undefined}
1592
1686
  */
1593
1687
  function bindEvents(instance) {
1594
- // if first dialog, hook body handlers
1688
+ // if first dialog, hook global handlers
1595
1689
  if (openDialogs.length === 1) {
1596
1690
  //global
1597
1691
  on(window, 'resize', windowResize);
@@ -1600,15 +1694,15 @@
1600
1694
  on(document.body, 'focus', onReset);
1601
1695
 
1602
1696
  //move
1603
- on(document.body, 'mousemove', move);
1604
- on(document.body, 'touchmove', move);
1605
- on(document.body, 'mouseup', endMove);
1606
- on(document.body, 'touchend', endMove);
1697
+ on(document.documentElement, 'mousemove', move);
1698
+ on(document.documentElement, 'touchmove', move);
1699
+ on(document.documentElement, 'mouseup', endMove);
1700
+ on(document.documentElement, 'touchend', endMove);
1607
1701
  //resize
1608
- on(document.body, 'mousemove', resize);
1609
- on(document.body, 'touchmove', resize);
1610
- on(document.body, 'mouseup', endResize);
1611
- on(document.body, 'touchend', endResize);
1702
+ on(document.documentElement, 'mousemove', resize);
1703
+ on(document.documentElement, 'touchmove', resize);
1704
+ on(document.documentElement, 'mouseup', endResize);
1705
+ on(document.documentElement, 'touchend', endResize);
1612
1706
  }
1613
1707
 
1614
1708
  // common events
@@ -1623,17 +1717,17 @@
1623
1717
  on(instance.elements.dialog, transition.type, instance.__internal.transitionInHandler);
1624
1718
 
1625
1719
  // modelss only events
1626
- if (!instance.setting('modal')) {
1720
+ if (!instance.get('modal')) {
1627
1721
  bindModelessEvents(instance);
1628
1722
  }
1629
1723
 
1630
1724
  // resizable
1631
- if (instance.setting('resizable')) {
1725
+ if (instance.get('resizable')) {
1632
1726
  bindResizableEvents(instance);
1633
1727
  }
1634
1728
 
1635
1729
  // movable
1636
- if (instance.setting('movable')) {
1730
+ if (instance.get('movable')) {
1637
1731
  bindMovableEvents(instance);
1638
1732
  }
1639
1733
  }
@@ -1646,7 +1740,7 @@
1646
1740
  * @return {undefined}
1647
1741
  */
1648
1742
  function unbindEvents(instance) {
1649
- // if last dialog, remove body handlers
1743
+ // if last dialog, remove global handlers
1650
1744
  if (openDialogs.length === 1) {
1651
1745
  //global
1652
1746
  off(window, 'resize', windowResize);
@@ -1654,11 +1748,11 @@
1654
1748
  off(document.body, 'keydown', keydownHandler);
1655
1749
  off(document.body, 'focus', onReset);
1656
1750
  //move
1657
- off(document.body, 'mousemove', move);
1658
- off(document.body, 'mouseup', endMove);
1751
+ off(document.documentElement, 'mousemove', move);
1752
+ off(document.documentElement, 'mouseup', endMove);
1659
1753
  //resize
1660
- off(document.body, 'mousemove', resize);
1661
- off(document.body, 'mouseup', endResize);
1754
+ off(document.documentElement, 'mousemove', resize);
1755
+ off(document.documentElement, 'mouseup', endResize);
1662
1756
  }
1663
1757
 
1664
1758
  // common events
@@ -1671,17 +1765,17 @@
1671
1765
  on(instance.elements.dialog, transition.type, instance.__internal.transitionOutHandler);
1672
1766
 
1673
1767
  // modelss only events
1674
- if (!instance.setting('modal')) {
1768
+ if (!instance.get('modal')) {
1675
1769
  unbindModelessEvents(instance);
1676
1770
  }
1677
1771
 
1678
1772
  // movable
1679
- if (instance.setting('movable')) {
1773
+ if (instance.get('movable')) {
1680
1774
  unbindMovableEvents(instance);
1681
1775
  }
1682
1776
 
1683
1777
  // resizable
1684
- if (instance.setting('resizable')) {
1778
+ if (instance.get('resizable')) {
1685
1779
  unbindResizableEvents(instance);
1686
1780
  }
1687
1781
 
@@ -1826,6 +1920,73 @@
1826
1920
  }
1827
1921
  return this;
1828
1922
  },
1923
+ /**
1924
+ * Move the dialog to a specific x/y coordinates
1925
+ *
1926
+ * @param {Number} x The new dialog x coordinate in pixels.
1927
+ * @param {Number} y The new dialog y coordinate in pixels.
1928
+ *
1929
+ * @return {Object} The dialog instance.
1930
+ */
1931
+ moveTo:function(x,y){
1932
+ if(!isNaN(x) && !isNaN(y)){
1933
+ var element = this.elements.dialog,
1934
+ current = element,
1935
+ offsetLeft = 0,
1936
+ offsetTop = 0;
1937
+
1938
+ //subtract existing left,top
1939
+ if (element.style.left) {
1940
+ offsetLeft -= parseInt(element.style.left, 10);
1941
+ }
1942
+ if (element.style.top) {
1943
+ offsetTop -= parseInt(element.style.top, 10);
1944
+ }
1945
+ //calc offset
1946
+ do {
1947
+ offsetLeft += current.offsetLeft;
1948
+ offsetTop += current.offsetTop;
1949
+ } while (current = current.offsetParent);
1950
+
1951
+ //calc left, top
1952
+ var left = (x - offsetLeft);
1953
+ var top = (y - offsetTop);
1954
+
1955
+ //// rtl handling
1956
+ if (isRightToLeft()) {
1957
+ left *= -1;
1958
+ }
1959
+
1960
+ element.style.left = left + 'px';
1961
+ element.style.top = top + 'px';
1962
+ }
1963
+ return this;
1964
+ },
1965
+ /**
1966
+ * Resize the dialog to a specific width/height (the dialog must be 'resizable').
1967
+ * The dialog can be resized to:
1968
+ * A minimum width equal to the initial display width
1969
+ * A minimum height equal to the sum of header/footer heights.
1970
+ *
1971
+ *
1972
+ * @param {Number} width The new dialog width in pixels.
1973
+ * @param {Number} height The new dialog height in pixels.
1974
+ *
1975
+ * @return {Object} The dialog instance.
1976
+ */
1977
+ resizeTo:function(width,height){
1978
+ if(!isNaN(width) && !isNaN(height) && this.get('resizable') === true){
1979
+ var element = this.elements.dialog;
1980
+ if (element.style.maxWidth !== 'none') {
1981
+ element.style.minWidth = (minWidth = element.offsetWidth) + 'px';
1982
+ }
1983
+ element.style.maxWidth = 'none';
1984
+ element.style.minHeight = this.elements.header.offsetHeight + this.elements.footer.offsetHeight + 'px';
1985
+ element.style.width = width + 'px';
1986
+ element.style.height = height + 'px';
1987
+ }
1988
+ return this;
1989
+ },
1829
1990
  /**
1830
1991
  * Gets or Sets dialog settings/options
1831
1992
  *
@@ -1938,7 +2099,7 @@
1938
2099
  bindEvents(this);
1939
2100
 
1940
2101
  if(modal !== undefined){
1941
- this.setting('modal', modal);
2102
+ this.set('modal', modal);
1942
2103
  }
1943
2104
 
1944
2105
  ensureNoOverflow();
@@ -1948,6 +2109,13 @@
1948
2109
  this.__internal.className = className;
1949
2110
  addClass(this.elements.root, className);
1950
2111
  }
2112
+
2113
+ // maximize if start maximized
2114
+ if ( this.get('startMaximized')) {
2115
+ this.maximize();
2116
+ }else if(this.isMaximized()){
2117
+ restore(this);
2118
+ }
1951
2119
 
1952
2120
  updateAbsPositionFix(this);
1953
2121
 
@@ -1972,9 +2140,10 @@
1972
2140
  removeClass(this.elements.root, classes.hidden);
1973
2141
 
1974
2142
  // allow custom `onshow` method
1975
- if ( typeof this.setting('onshow') === 'function' ) {
1976
- this.setting('onshow')();
2143
+ if ( typeof this.get('onshow') === 'function' ) {
2144
+ this.get('onshow')();
1977
2145
  }
2146
+
1978
2147
  }else{
1979
2148
  // reset move updates
1980
2149
  resetMove(this);
@@ -1992,7 +2161,7 @@
1992
2161
  /**
1993
2162
  * Close the dialog
1994
2163
  *
1995
- * @return {undefined}
2164
+ * @return {Object} The dialog instance
1996
2165
  */
1997
2166
  close: function () {
1998
2167
  if (this.__internal.isOpen ) {
@@ -2016,8 +2185,8 @@
2016
2185
  }
2017
2186
 
2018
2187
  // allow custom `onclose` method
2019
- if ( typeof this.setting('onclose') === 'function' ) {
2020
- this.setting('onclose')();
2188
+ if ( typeof this.get('onclose') === 'function' ) {
2189
+ this.get('onclose')();
2021
2190
  }
2022
2191
 
2023
2192
  //remove from open dialogs
@@ -2649,9 +2818,9 @@
2649
2818
  onok = _onok;
2650
2819
  break;
2651
2820
  }
2652
- this.setting('title', title);
2653
- this.setting('message', message);
2654
- this.setting('onok', onok);
2821
+ this.set('title', title);
2822
+ this.set('message', message);
2823
+ this.set('onok', onok);
2655
2824
  return this;
2656
2825
  },
2657
2826
  setup: function () {
@@ -2701,8 +2870,8 @@
2701
2870
  }
2702
2871
  },
2703
2872
  callback: function (closeEvent) {
2704
- if (typeof this.settings.onok === 'function') {
2705
- var returnValue = this.settings.onok.call(undefined, closeEvent);
2873
+ if (typeof this.get('onok') === 'function') {
2874
+ var returnValue = this.get('onok').call(undefined, closeEvent);
2706
2875
  if (typeof returnValue !== 'undefined') {
2707
2876
  closeEvent.cancel = !returnValue;
2708
2877
  }
@@ -2789,10 +2958,10 @@
2789
2958
  oncancel = _oncancel;
2790
2959
  break;
2791
2960
  }
2792
- this.setting('title', title);
2793
- this.setting('message', message);
2794
- this.setting('onok', onok);
2795
- this.setting('oncancel', oncancel);
2961
+ this.set('title', title);
2962
+ this.set('message', message);
2963
+ this.set('onok', onok);
2964
+ this.set('oncancel', oncancel);
2796
2965
  return this;
2797
2966
  },
2798
2967
  setup: function () {
@@ -2869,16 +3038,16 @@
2869
3038
  var returnValue;
2870
3039
  switch (closeEvent.index) {
2871
3040
  case 0:
2872
- if (typeof this.settings.onok === 'function') {
2873
- returnValue = this.settings.onok.call(undefined, closeEvent);
3041
+ if (typeof this.get('onok') === 'function') {
3042
+ returnValue = this.get('onok').call(undefined, closeEvent);
2874
3043
  if (typeof returnValue !== 'undefined') {
2875
3044
  closeEvent.cancel = !returnValue;
2876
3045
  }
2877
3046
  }
2878
3047
  break;
2879
3048
  case 1:
2880
- if (typeof this.settings.oncancel === 'function') {
2881
- returnValue = this.settings.oncancel.call(undefined, closeEvent);
3049
+ if (typeof this.get('oncancel') === 'function') {
3050
+ returnValue = this.get('oncancel').call(undefined, closeEvent);
2882
3051
  if (typeof returnValue !== 'undefined') {
2883
3052
  closeEvent.cancel = !returnValue;
2884
3053
  }
@@ -2931,7 +3100,7 @@
2931
3100
  onok = _value;
2932
3101
  oncancel = _onok;
2933
3102
  break;
2934
- case 4:
3103
+ case 5:
2935
3104
  title = _title;
2936
3105
  message = _message;
2937
3106
  value = _value;
@@ -2939,11 +3108,11 @@
2939
3108
  oncancel = _oncancel;
2940
3109
  break;
2941
3110
  }
2942
- this.setting('title', title);
2943
- this.setting('message', message);
2944
- this.setting('value', value);
2945
- this.setting('onok', onok);
2946
- this.setting('oncancel', oncancel);
3111
+ this.set('title', title);
3112
+ this.set('message', message);
3113
+ this.set('value', value);
3114
+ this.set('onok', onok);
3115
+ this.set('oncancel', oncancel);
2947
3116
  return this;
2948
3117
  },
2949
3118
  setup: function () {
@@ -2974,7 +3143,7 @@
2974
3143
  build: function () {
2975
3144
  input.className = alertify.defaults.theme.input;
2976
3145
  input.setAttribute('type', 'text');
2977
- input.value = this.settings.value;
3146
+ input.value = this.get('value');
2978
3147
  this.elements.content.appendChild(p);
2979
3148
  this.elements.content.appendChild(input);
2980
3149
  },
@@ -3027,16 +3196,16 @@
3027
3196
  switch (closeEvent.index) {
3028
3197
  case 0:
3029
3198
  this.value = input.value;
3030
- if (typeof this.settings.onok === 'function') {
3031
- returnValue = this.settings.onok.call(undefined, closeEvent, this.value);
3199
+ if (typeof this.get('onok') === 'function') {
3200
+ returnValue = this.get('onok').call(undefined, closeEvent, this.value);
3032
3201
  if (typeof returnValue !== 'undefined') {
3033
3202
  closeEvent.cancel = !returnValue;
3034
3203
  }
3035
3204
  }
3036
3205
  break;
3037
3206
  case 1:
3038
- if (typeof this.settings.oncancel === 'function') {
3039
- returnValue = this.settings.oncancel.call(undefined, closeEvent);
3207
+ if (typeof this.get('oncancel') === 'function') {
3208
+ returnValue = this.get('oncancel').call(undefined, closeEvent);
3040
3209
  if (typeof returnValue !== 'undefined') {
3041
3210
  closeEvent.cancel = !returnValue;
3042
3211
  }
@@ -3046,6 +3215,7 @@
3046
3215
  }
3047
3216
  };
3048
3217
  });
3218
+
3049
3219
  // AMD and window support
3050
3220
  if ( typeof define === 'function' ) {
3051
3221
  define( [], function () {
@@ -74,6 +74,7 @@
74
74
  padding: 4px;
75
75
  margin-left: -24px;
76
76
  margin-right: -24px;
77
+ min-height: 43px;
77
78
  }
78
79
  .alertify .ajs-footer .ajs-buttons.ajs-primary {
79
80
  text-align: right;
@@ -93,7 +94,7 @@
93
94
  min-width: 88px;
94
95
  min-height: 35px;
95
96
  }
96
- .alertify .ajs-footer .ajs-handle {
97
+ .alertify .ajs-handle {
97
98
  position: absolute;
98
99
  display: none;
99
100
  width: 10px;
@@ -219,6 +220,29 @@
219
220
  max-height: 500px;
220
221
  overflow: auto;
221
222
  }
223
+ .alertify.ajs-basic .ajs-header {
224
+ opacity: 0;
225
+ }
226
+ .alertify.ajs-basic .ajs-footer {
227
+ visibility: hidden;
228
+ }
229
+ .alertify.ajs-frameless .ajs-header,
230
+ .alertify.ajs-frameless .ajs-footer {
231
+ display: none;
232
+ }
233
+ .alertify.ajs-frameless .ajs-body .ajs-content {
234
+ position: absolute;
235
+ top: 0;
236
+ right: 0;
237
+ bottom: 0;
238
+ left: 0;
239
+ }
240
+ .alertify.ajs-frameless:not(.ajs-resizable) .ajs-dialog {
241
+ padding-top: 0;
242
+ }
243
+ .alertify.ajs-frameless:not(.ajs-resizable) .ajs-dialog .ajs-commands {
244
+ margin-top: 0;
245
+ }
222
246
  .ajs-no-overflow {
223
247
  overflow: hidden !important;
224
248
  outline: none;
@@ -239,6 +263,12 @@
239
263
  }
240
264
  .alertify:not(.ajs-maximized).ajs-resizable .ajs-dialog {
241
265
  min-width: initial;
266
+ min-width: auto /*IE fallback*/;
267
+ }
268
+ }
269
+ @-moz-document url-prefix() {
270
+ .alertify button:focus {
271
+ outline: 1px dotted #3593D2;
242
272
  }
243
273
  }
244
274
  .alertify .ajs-dimmer,
@@ -74,6 +74,7 @@
74
74
  padding: 4px;
75
75
  margin-right: -24px;
76
76
  margin-left: -24px;
77
+ min-height: 43px;
77
78
  }
78
79
  .alertify .ajs-footer .ajs-buttons.ajs-primary {
79
80
  text-align: left;
@@ -93,7 +94,7 @@
93
94
  min-width: 88px;
94
95
  min-height: 35px;
95
96
  }
96
- .alertify .ajs-footer .ajs-handle {
97
+ .alertify .ajs-handle {
97
98
  position: absolute;
98
99
  display: none;
99
100
  width: 10px;
@@ -219,6 +220,29 @@
219
220
  max-height: 500px;
220
221
  overflow: auto;
221
222
  }
223
+ .alertify.ajs-basic .ajs-header {
224
+ opacity: 0;
225
+ }
226
+ .alertify.ajs-basic .ajs-footer {
227
+ visibility: hidden;
228
+ }
229
+ .alertify.ajs-frameless .ajs-header,
230
+ .alertify.ajs-frameless .ajs-footer {
231
+ display: none;
232
+ }
233
+ .alertify.ajs-frameless .ajs-body .ajs-content {
234
+ position: absolute;
235
+ top: 0;
236
+ left: 0;
237
+ bottom: 0;
238
+ right: 0;
239
+ }
240
+ .alertify.ajs-frameless:not(.ajs-resizable) .ajs-dialog {
241
+ padding-top: 0;
242
+ }
243
+ .alertify.ajs-frameless:not(.ajs-resizable) .ajs-dialog .ajs-commands {
244
+ margin-top: 0;
245
+ }
222
246
  .ajs-no-overflow {
223
247
  overflow: hidden !important;
224
248
  outline: none;
@@ -239,6 +263,12 @@
239
263
  }
240
264
  .alertify:not(.ajs-maximized).ajs-resizable .ajs-dialog {
241
265
  min-width: initial;
266
+ min-width: auto /*IE fallback*/;
267
+ }
268
+ }
269
+ @-moz-document url-prefix() {
270
+ .alertify button:focus {
271
+ outline: 1px dotted #3593D2;
242
272
  }
243
273
  }
244
274
  .alertify .ajs-dimmer,
@@ -32,3 +32,24 @@
32
32
  border-top: 1px solid #e5e5e5;
33
33
  border-radius: 0 0 6px 6px;
34
34
  }
35
+ .alertify-notifier .ajs-message {
36
+ background: rgba(255, 255, 255, 0.95);
37
+ color: #000;
38
+ text-align: center;
39
+ border: solid 1px #ddd;
40
+ border-radius: 2px;
41
+ }
42
+ .alertify-notifier .ajs-message.ajs-success {
43
+ color: #fff;
44
+ background: rgba(91, 189, 114, 0.95);
45
+ text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.5);
46
+ }
47
+ .alertify-notifier .ajs-message.ajs-error {
48
+ color: #fff;
49
+ background: rgba(217, 92, 92, 0.95);
50
+ text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.5);
51
+ }
52
+ .alertify-notifier .ajs-message.ajs-warning {
53
+ background: rgba(252, 248, 215, 0.95);
54
+ border-color: #999;
55
+ }
@@ -32,3 +32,24 @@
32
32
  border-top: 1px solid #e5e5e5;
33
33
  border-radius: 0 0 6px 6px;
34
34
  }
35
+ .alertify-notifier .ajs-message {
36
+ background: rgba(255, 255, 255, 0.95);
37
+ color: #000;
38
+ text-align: center;
39
+ border: solid 1px #ddd;
40
+ border-radius: 2px;
41
+ }
42
+ .alertify-notifier .ajs-message.ajs-success {
43
+ color: #fff;
44
+ background: rgba(91, 189, 114, 0.95);
45
+ text-shadow: 1px -1px 0 rgba(0, 0, 0, 0.5);
46
+ }
47
+ .alertify-notifier .ajs-message.ajs-error {
48
+ color: #fff;
49
+ background: rgba(217, 92, 92, 0.95);
50
+ text-shadow: 1px -1px 0 rgba(0, 0, 0, 0.5);
51
+ }
52
+ .alertify-notifier .ajs-message.ajs-warning {
53
+ background: rgba(252, 248, 215, 0.95);
54
+ border-color: #999;
55
+ }
@@ -57,3 +57,24 @@
57
57
  border-top: none;
58
58
  border-radius: 0 0 5px 5px;
59
59
  }
60
+ .alertify-notifier .ajs-message {
61
+ background: rgba(255, 255, 255, 0.95);
62
+ color: #000;
63
+ text-align: center;
64
+ border: solid 1px #ddd;
65
+ border-radius: 2px;
66
+ }
67
+ .alertify-notifier .ajs-message.ajs-success {
68
+ color: #fff;
69
+ background: rgba(91, 189, 114, 0.95);
70
+ text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.5);
71
+ }
72
+ .alertify-notifier .ajs-message.ajs-error {
73
+ color: #fff;
74
+ background: rgba(217, 92, 92, 0.95);
75
+ text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.5);
76
+ }
77
+ .alertify-notifier .ajs-message.ajs-warning {
78
+ background: rgba(252, 248, 215, 0.95);
79
+ border-color: #999;
80
+ }
@@ -57,3 +57,24 @@
57
57
  border-top: none;
58
58
  border-radius: 0 0 5px 5px;
59
59
  }
60
+ .alertify-notifier .ajs-message {
61
+ background: rgba(255, 255, 255, 0.95);
62
+ color: #000;
63
+ text-align: center;
64
+ border: solid 1px #ddd;
65
+ border-radius: 2px;
66
+ }
67
+ .alertify-notifier .ajs-message.ajs-success {
68
+ color: #fff;
69
+ background: rgba(91, 189, 114, 0.95);
70
+ text-shadow: 1px -1px 0 rgba(0, 0, 0, 0.5);
71
+ }
72
+ .alertify-notifier .ajs-message.ajs-error {
73
+ color: #fff;
74
+ background: rgba(217, 92, 92, 0.95);
75
+ text-shadow: 1px -1px 0 rgba(0, 0, 0, 0.5);
76
+ }
77
+ .alertify-notifier .ajs-message.ajs-warning {
78
+ background: rgba(252, 248, 215, 0.95);
79
+ border-color: #999;
80
+ }
metadata CHANGED
@@ -1,23 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alertifyjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
4
+ version: 0.1.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - mkhairi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-10-09 00:00:00.000000000 Z
11
+ date: 2014-12-02 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Use Alertify.js (alertifyjs.com) with Rails 3 and 4
15
- email:
14
+ email:
15
+ - khairi@labs.my
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - .gitignore
20
+ - ".gitignore"
21
21
  - Gemfile
22
22
  - LICENSE.txt
23
23
  - README.md
@@ -40,27 +40,27 @@ files:
40
40
  - vendor/assets/stylesheets/alertify/semantic.css
41
41
  - vendor/assets/stylesheets/alertify/semantic.rtl.css
42
42
  homepage: https://github.com/mkhairi/alertifyjs-rails.git
43
- licenses: []
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
44
46
  post_install_message:
45
47
  rdoc_options: []
46
48
  require_paths:
47
49
  - lib
48
50
  required_ruby_version: !ruby/object:Gem::Requirement
49
- none: false
50
51
  requirements:
51
- - - ! '>='
52
+ - - ">="
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
55
  required_rubygems_version: !ruby/object:Gem::Requirement
55
- none: false
56
56
  requirements:
57
- - - ! '>='
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubyforge_project:
62
- rubygems_version: 1.8.23
62
+ rubygems_version: 2.4.4
63
63
  signing_key:
64
- specification_version: 3
64
+ specification_version: 4
65
65
  summary: This gem provides the Alertify.js (alertifyjs.com) for Rails applications
66
66
  test_files: []