alertifyjs-rails 1.4.1 → 1.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7390fe74d453aee5532602c534b72c61256d9ece
4
- data.tar.gz: 71e6728bff442c35766ac2c4dda7d8b9dfd1e5e3
3
+ metadata.gz: abf9dd50f7fafadaf48d8122fa922179afa2daa7
4
+ data.tar.gz: 1862091b09d7bd845250ac12da1eeb32c11403cf
5
5
  SHA512:
6
- metadata.gz: a52a575467752bc54b70418249293829fc776997ce446f9e8175e99b4fb1685f6f717afc0aaa4e0e22c35ff05d8bdd4dadd134c2e869b48350642f4d67be42d2
7
- data.tar.gz: 82d22226d0d751b390c9f567ef6f40fa9d43a69b09aec696617c9539ed6bc5a743bd7eb201986dc0ab6816029f643515230ea0c4eb64f589324c39228564f20a
6
+ metadata.gz: e041d1c63691dfcd1017b32290437e9120d9dafa854f116ed099f16bc0db4ae29fff2456fd8dec7e11bd81baef2d620b3206107853a0b4864f1f04227869790e
7
+ data.tar.gz: ba4cc04a0651cf36d73a4be6fbfbd194a8554a8d6dd35f244173f2357607736cb9a68b9b9bc037cc91dade84573ac1763a5b7563181118620df89cc5bd51ac44
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alertifyjs 1.4.1 http://alertifyjs.com
2
+ * alertifyjs 1.5.0 http://alertifyjs.com
3
3
  * AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
4
4
  * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
5
5
  * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
@@ -127,7 +127,68 @@
127
127
  element.removeChild(element.lastChild);
128
128
  }
129
129
  }
130
+ /**
131
+ * Extends a given prototype by merging properties from base into sub.
132
+ *
133
+ * @sub {Object} sub The prototype being overwritten.
134
+ * @base {Object} base The prototype being written.
135
+ *
136
+ * @return {Object} The extended prototype.
137
+ */
138
+ function copy(src) {
139
+ if(null === src)
140
+ return src;
130
141
 
142
+ if(Array.isArray(src)){
143
+ var cpy = [];
144
+ for(var x=0;x<src.length;x+=1){
145
+ cpy.push(copy(src[x]));
146
+ }
147
+ return cpy;
148
+ }
149
+
150
+ if(src instanceof Date){
151
+ return new Date(src.getTime());
152
+ }
153
+
154
+ if(src instanceof RegExp){
155
+ var cpy = new RegExp(src.source);
156
+ cpy.global = src.global;
157
+ cpy.ignoreCase = src.ignoreCase;
158
+ cpy.multiline = src.multiline;
159
+ cpy.lastIndex = src.lastIndex;
160
+ return cpy;
161
+ }
162
+
163
+ if(typeof src === 'object'){
164
+ var cpy = {};
165
+ // copy dialog pototype over definition.
166
+ for (var prop in src) {
167
+ if (src.hasOwnProperty(prop)) {
168
+ cpy[prop] = copy(src[prop]);
169
+ }
170
+ }
171
+ return cpy;
172
+ }
173
+
174
+ return src;
175
+ }
176
+ /**
177
+ * Helper: destruct the dialog
178
+ *
179
+ */
180
+ function destruct(instance, initialize){
181
+ //delete the dom and it's references.
182
+ var root = instance.elements.root;
183
+ root.parentNode.removeChild(root);
184
+ delete instance.elements;
185
+ //copy back initial settings.
186
+ instance.settings = copy(instance.__settings);
187
+ //re-reference init function.
188
+ instance.__init = initialize;
189
+ //delete __internal variable to allow re-initialization.
190
+ delete instance.__internal;
191
+ }
131
192
 
132
193
  /**
133
194
  * Use a closure to return proper event listener method. Try to use
@@ -315,6 +376,10 @@
315
376
 
316
377
  //no need to expose init after this.
317
378
  delete instance.__init;
379
+
380
+ //keep a copy of initial dialog settings
381
+ if(!this.__settings)
382
+ this.__settings = copy(this.settings);
318
383
 
319
384
  //in case the script was included before body.
320
385
  //after first dialog gets initialized, it won't be null anymore!
@@ -352,13 +417,13 @@
352
417
  if(Array.isArray(setup.buttons)){
353
418
  for(var b=0;b<setup.buttons.length;b+=1){
354
419
  var ref = setup.buttons[b],
355
- copy = {};
420
+ cpy = {};
356
421
  for (var i in ref) {
357
422
  if (ref.hasOwnProperty(i)) {
358
- copy[i] = ref[i];
423
+ cpy[i] = ref[i];
359
424
  }
360
425
  }
361
- buttonsDefinition.push(copy);
426
+ buttonsDefinition.push(cpy);
362
427
  }
363
428
  }
364
429
 
@@ -410,7 +475,8 @@
410
475
  buttonsClickHandler:undefined,
411
476
  commandsClickHandler:undefined,
412
477
  transitionInHandler:undefined,
413
- transitionOutHandler:undefined
478
+ transitionOutHandler:undefined,
479
+ destroy:undefined
414
480
  };
415
481
 
416
482
 
@@ -547,8 +613,8 @@
547
613
  */
548
614
  var scrollX, scrollY;
549
615
  function saveScrollPosition(){
550
- scrollX = window.scrollX;
551
- scrollY = window.scrollY;
616
+ scrollX = getScrollLeft();
617
+ scrollY = getScrollTop();
552
618
  }
553
619
  function restoreScrollPosition(){
554
620
  window.scrollTo(scrollX, scrollY);
@@ -1376,6 +1442,11 @@
1376
1442
  instance.__internal.activeElement.focus();
1377
1443
  instance.__internal.activeElement = null;
1378
1444
  }
1445
+
1446
+ //destory the instance
1447
+ if (typeof instance.__internal.destroy === 'function') {
1448
+ instance.__internal.destroy.apply(instance);
1449
+ }
1379
1450
  }
1380
1451
  /* Controls moving a dialog around */
1381
1452
  //holde the current moving instance
@@ -2296,7 +2367,25 @@
2296
2367
  closeOthers:function(){
2297
2368
  alertify.closeAll(this);
2298
2369
  return this;
2299
- }
2370
+ },
2371
+ /**
2372
+ * Destroys this dialog instance
2373
+ *
2374
+ * @return {undefined}
2375
+ */
2376
+ destroy:function(){
2377
+ if (this.__internal.isOpen ) {
2378
+ //mark dialog for destruction, this will be called on tranistionOut event.
2379
+ this.__internal.destroy = function(){
2380
+ destruct(this, initialize);
2381
+ }
2382
+ //close the dialog to unbind all events.
2383
+ this.close();
2384
+ }else{
2385
+ destruct(this, initialize);
2386
+ }
2387
+ return this;
2388
+ },
2300
2389
  };
2301
2390
  } () );
2302
2391
  var notifier = (function () {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alertifyjs 1.4.1 http://alertifyjs.com
2
+ * alertifyjs 1.5.0 http://alertifyjs.com
3
3
  * AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
4
4
  * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
5
5
  * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alertifyjs 1.4.1 http://alertifyjs.com
2
+ * alertifyjs 1.5.0 http://alertifyjs.com
3
3
  * AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
4
4
  * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
5
5
  * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alertifyjs 1.4.1 http://alertifyjs.com
2
+ * alertifyjs 1.5.0 http://alertifyjs.com
3
3
  * AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
4
4
  * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
5
5
  * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alertifyjs 1.4.1 http://alertifyjs.com
2
+ * alertifyjs 1.5.0 http://alertifyjs.com
3
3
  * AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
4
4
  * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
5
5
  * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alertifyjs 1.4.1 http://alertifyjs.com
2
+ * alertifyjs 1.5.0 http://alertifyjs.com
3
3
  * AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
4
4
  * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
5
5
  * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alertifyjs 1.4.1 http://alertifyjs.com
2
+ * alertifyjs 1.5.0 http://alertifyjs.com
3
3
  * AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
4
4
  * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
5
5
  * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alertifyjs 1.4.1 http://alertifyjs.com
2
+ * alertifyjs 1.5.0 http://alertifyjs.com
3
3
  * AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
4
4
  * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
5
5
  * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alertifyjs 1.4.1 http://alertifyjs.com
2
+ * alertifyjs 1.5.0 http://alertifyjs.com
3
3
  * AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
4
4
  * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
5
5
  * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
@@ -1,5 +1,5 @@
1
1
  module Alertifyjs #:nodoc:
2
2
  module Rails #:nodoc:
3
- VERSION = "1.4.1"
3
+ VERSION = "1.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alertifyjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mkhairi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-10-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use Alertify.js (alertifyjs.com) with Rails 3 and 4
14
14
  email: