modalist 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1440 @@
1
+ /*
2
+ * iziModal | v1.5.1
3
+ * http://izimodal.marcelodolce.com
4
+ * by Marcelo Dolce.
5
+ */
6
+ (function (factory) {
7
+ if (typeof define === 'function' && define.amd) {
8
+ define(['jquery'], factory);
9
+ } else if (typeof module === 'object' && module.exports) {
10
+ module.exports = function( root, jQuery ) {
11
+ if ( jQuery === undefined ) {
12
+ if ( typeof window !== 'undefined' ) {
13
+ jQuery = require('jquery');
14
+ }
15
+ else {
16
+ jQuery = require('jquery')(root);
17
+ }
18
+ }
19
+ factory(jQuery);
20
+ return jQuery;
21
+ };
22
+ } else {
23
+ factory(jQuery);
24
+ }
25
+ }(function ($) {
26
+
27
+ var $window = $(window),
28
+ $document = $(document),
29
+ PLUGIN_NAME = 'iziModal',
30
+ STATES = {
31
+ CLOSING: 'closing',
32
+ CLOSED: 'closed',
33
+ OPENING: 'opening',
34
+ OPENED: 'opened',
35
+ DESTROYED: 'destroyed'
36
+ };
37
+
38
+ function whichAnimationEvent(){
39
+ var t,
40
+ el = document.createElement('fakeelement'),
41
+ animations = {
42
+ 'animation' : 'animationend',
43
+ 'OAnimation' : 'oAnimationEnd',
44
+ 'MozAnimation' : 'animationend',
45
+ 'WebkitAnimation': 'webkitAnimationEnd'
46
+ };
47
+ for (t in animations){
48
+ if (el.style[t] !== undefined){
49
+ return animations[t];
50
+ }
51
+ }
52
+ }
53
+
54
+ function isIE(version) {
55
+ if(version === 9){
56
+ return navigator.appVersion.indexOf('MSIE 9.') !== -1;
57
+ } else {
58
+ userAgent = navigator.userAgent;
59
+ return userAgent.indexOf('MSIE ') > -1 || userAgent.indexOf('Trident/') > -1;
60
+ }
61
+ }
62
+
63
+ function clearValue(value){
64
+ var separators = /%|px|em|cm|vh|vw/;
65
+ return parseInt(String(value).split(separators)[0]);
66
+ }
67
+
68
+ var animationEvent = whichAnimationEvent(),
69
+ isMobile = (/Mobi/.test(navigator.userAgent)) ? true : false;
70
+
71
+ window.$iziModal = {};
72
+ window.$iziModal.autoOpen = 0;
73
+ window.$iziModal.history = false;
74
+
75
+ var iziModal = function (element, options) {
76
+ this.init(element, options);
77
+ };
78
+
79
+ iziModal.prototype = {
80
+
81
+ constructor: iziModal,
82
+
83
+ init: function (element, options) {
84
+
85
+ var that = this;
86
+ this.$element = $(element);
87
+
88
+ if(this.$element[0].id !== undefined && this.$element[0].id !== ''){
89
+ this.id = this.$element[0].id;
90
+ } else {
91
+ this.id = PLUGIN_NAME+Math.floor((Math.random() * 10000000) + 1);
92
+ this.$element.attr('id', this.id);
93
+ }
94
+ this.classes = ( this.$element.attr('class') !== undefined ) ? this.$element.attr('class') : '';
95
+ this.content = this.$element.html();
96
+ this.state = STATES.CLOSED;
97
+ this.options = options;
98
+ this.width = 0;
99
+ this.timer = null;
100
+ this.timerTimeout = null;
101
+ this.progressBar = null;
102
+ this.isPaused = false;
103
+ this.isFullscreen = false;
104
+ this.headerHeight = 0;
105
+ this.modalHeight = 0;
106
+ this.$overlay = $('<div class="'+PLUGIN_NAME+'-overlay" style="background-color:'+options.overlayColor+'"></div>');
107
+ this.$navigate = $('<div class="'+PLUGIN_NAME+'-navigate"><div class="'+PLUGIN_NAME+'-navigate-caption">Use</div><button class="'+PLUGIN_NAME+'-navigate-prev"></button><button class="'+PLUGIN_NAME+'-navigate-next"></button></div>');
108
+ this.group = {
109
+ name: this.$element.attr('data-'+PLUGIN_NAME+'-group'),
110
+ index: null,
111
+ ids: []
112
+ };
113
+ this.$element.attr('aria-hidden', 'true');
114
+ this.$element.attr('aria-labelledby', this.id);
115
+ this.$element.attr('role', 'dialog');
116
+
117
+ if( !this.$element.hasClass('iziModal') ){
118
+ this.$element.addClass('iziModal');
119
+ }
120
+
121
+ if(this.group.name === undefined && options.group !== ''){
122
+ this.group.name = options.group;
123
+ this.$element.attr('data-'+PLUGIN_NAME+'-group', options.group);
124
+ }
125
+ if(this.options.loop === true){
126
+ this.$element.attr('data-'+PLUGIN_NAME+'-loop', true);
127
+ }
128
+
129
+ $.each( this.options , function(index, val) {
130
+ var attr = that.$element.attr('data-'+PLUGIN_NAME+'-'+index);
131
+ try {
132
+ if(typeof attr !== typeof undefined){
133
+
134
+ if(attr === ''|| attr == 'true'){
135
+ options[index] = true;
136
+ } else if (attr == 'false') {
137
+ options[index] = false;
138
+ } else if (typeof val == 'function') {
139
+ options[index] = new Function(attr);
140
+ } else {
141
+ options[index] = attr;
142
+ }
143
+ }
144
+ } catch(exc){}
145
+ });
146
+
147
+ if(options.appendTo !== false){
148
+ this.$element.appendTo(options.appendTo);
149
+ }
150
+
151
+ if (options.iframe === true) {
152
+ this.$element.html('<div class="'+PLUGIN_NAME+'-wrap"><div class="'+PLUGIN_NAME+'-content"><iframe class="'+PLUGIN_NAME+'-iframe"></iframe>' + this.content + "</div></div>");
153
+
154
+ if (options.iframeHeight !== null) {
155
+ this.$element.find('.'+PLUGIN_NAME+'-iframe').css('height', options.iframeHeight);
156
+ }
157
+ } else {
158
+ this.$element.html('<div class="'+PLUGIN_NAME+'-wrap"><div class="'+PLUGIN_NAME+'-content">' + this.content + '</div></div>');
159
+ }
160
+
161
+ if (this.options.background !== null) {
162
+ this.$element.css('background', this.options.background);
163
+ }
164
+
165
+ this.$wrap = this.$element.find('.'+PLUGIN_NAME+'-wrap');
166
+
167
+ if(options.zindex !== null && !isNaN(parseInt(options.zindex)) ){
168
+ this.$element.css('z-index', options.zindex);
169
+ this.$navigate.css('z-index', options.zindex-1);
170
+ this.$overlay.css('z-index', options.zindex-2);
171
+ }
172
+
173
+ if(options.radius !== ''){
174
+ this.$element.css('border-radius', options.radius);
175
+ }
176
+
177
+ if(options.padding !== ''){
178
+ this.$element.find('.'+PLUGIN_NAME+'-content').css('padding', options.padding);
179
+ }
180
+
181
+ if(options.theme !== ''){
182
+ if(options.theme === 'light'){
183
+ this.$element.addClass(PLUGIN_NAME+'-light');
184
+ } else {
185
+ this.$element.addClass(options.theme);
186
+ }
187
+ }
188
+
189
+ if(options.rtl === true) {
190
+ this.$element.addClass(PLUGIN_NAME+'-rtl');
191
+ }
192
+
193
+ if(options.openFullscreen === true){
194
+ this.isFullscreen = true;
195
+ this.$element.addClass('isFullscreen');
196
+ }
197
+
198
+ this.createHeader();
199
+ this.recalcWidth();
200
+ this.recalcVerticalPos();
201
+
202
+ if (that.options.afterRender && ( typeof(that.options.afterRender) === 'function' || typeof(that.options.afterRender) === 'object' ) ) {
203
+ that.options.afterRender(that);
204
+ }
205
+
206
+ },
207
+
208
+ createHeader: function(){
209
+
210
+ this.$header = $('<div class="'+PLUGIN_NAME+'-header"><h2 class="'+PLUGIN_NAME+'-header-title">' + this.options.title + '</h2><p class="'+PLUGIN_NAME+'-header-subtitle">' + this.options.subtitle + '</p><div class="'+PLUGIN_NAME+'-header-buttons"></div></div>');
211
+
212
+ if (this.options.closeButton === true) {
213
+ this.$header.find('.'+PLUGIN_NAME+'-header-buttons').append('<a href="javascript:void(0)" class="'+PLUGIN_NAME+'-button '+PLUGIN_NAME+'-button-close" data-'+PLUGIN_NAME+'-close></a>');
214
+ }
215
+
216
+ if (this.options.fullscreen === true) {
217
+ this.$header.find('.'+PLUGIN_NAME+'-header-buttons').append('<a href="javascript:void(0)" class="'+PLUGIN_NAME+'-button '+PLUGIN_NAME+'-button-fullscreen" data-'+PLUGIN_NAME+'-fullscreen></a>');
218
+ }
219
+
220
+ if (this.options.timeoutProgressbar === true && !isNaN(parseInt(this.options.timeout)) && this.options.timeout !== false && this.options.timeout !== 0) {
221
+ this.$header.prepend('<div class="'+PLUGIN_NAME+'-progressbar"><div style="background-color:'+this.options.timeoutProgressbarColor+'"></div></div>');
222
+ }
223
+
224
+ if (this.options.subtitle === '') {
225
+ this.$header.addClass(PLUGIN_NAME+'-noSubtitle');
226
+ }
227
+
228
+ if (this.options.title !== '') {
229
+
230
+ if (this.options.headerColor !== null) {
231
+ if(this.options.borderBottom === true){
232
+ this.$element.css('border-bottom', '3px solid ' + this.options.headerColor + '');
233
+ }
234
+ this.$header.css('background', this.options.headerColor);
235
+ }
236
+ if (this.options.icon !== null || this.options.iconText !== null){
237
+
238
+ this.$header.prepend('<i class="'+PLUGIN_NAME+'-header-icon"></i>');
239
+
240
+ if (this.options.icon !== null) {
241
+ this.$header.find('.'+PLUGIN_NAME+'-header-icon').addClass(this.options.icon).css('color', this.options.iconColor);
242
+ }
243
+ if (this.options.iconText !== null){
244
+ this.$header.find('.'+PLUGIN_NAME+'-header-icon').html(this.options.iconText);
245
+ }
246
+ }
247
+ this.$element.css('overflow', 'hidden').prepend(this.$header);
248
+ }
249
+ },
250
+
251
+ setGroup: function(groupName){
252
+
253
+ var that = this,
254
+ group = this.group.name || groupName;
255
+ this.group.ids = [];
256
+
257
+ if( groupName !== undefined && groupName !== this.group.name){
258
+ group = groupName;
259
+ this.group.name = group;
260
+ this.$element.attr('data-'+PLUGIN_NAME+'-group', group);
261
+ }
262
+ if(group !== undefined && group !== ''){
263
+
264
+ var count = 0;
265
+ $.each( $('.'+PLUGIN_NAME+'[data-'+PLUGIN_NAME+'-group='+group+']') , function(index, val) {
266
+
267
+ that.group.ids.push($(this)[0].id);
268
+
269
+ if(that.id == $(this)[0].id){
270
+ that.group.index = count;
271
+ }
272
+ count++;
273
+ });
274
+ }
275
+ },
276
+
277
+ toggle: function () {
278
+
279
+ if(this.state == STATES.OPENED){
280
+ this.close();
281
+ }
282
+ if(this.state == STATES.CLOSED){
283
+ this.open();
284
+ }
285
+ },
286
+
287
+ open: function (param) {
288
+
289
+ var that = this;
290
+
291
+ $.each( $('.'+PLUGIN_NAME) , function(index, modal) {
292
+ if( $(modal).data().iziModal !== undefined ){
293
+ var state = $(modal).iziModal('getState');
294
+ if(state == 'opened' || state == 'opening'){
295
+ $(modal).iziModal('close');
296
+ }
297
+ }
298
+ });
299
+
300
+ (function urlHash(){
301
+ if(that.options.history){
302
+ var oldTitle = document.title;
303
+ document.title = oldTitle + " - " + that.options.title;
304
+ document.location.hash = that.id;
305
+ document.title = oldTitle;
306
+ //history.pushState({}, that.options.title, "#"+that.id);
307
+ window.$iziModal.history = true;
308
+ } else {
309
+ window.$iziModal.history = false;
310
+ }
311
+ })();
312
+
313
+ function opened(){
314
+
315
+ // console.info('[ '+PLUGIN_NAME+' | '+that.id+' ] Opened.');
316
+
317
+ that.state = STATES.OPENED;
318
+ that.$element.trigger(STATES.OPENED);
319
+
320
+ if (that.options.onOpened && ( typeof(that.options.onOpened) === "function" || typeof(that.options.onOpened) === "object" ) ) {
321
+ that.options.onOpened(that);
322
+ }
323
+ }
324
+
325
+ function bindEvents(){
326
+
327
+ // Close when button pressed
328
+ that.$element.off('click', '[data-'+PLUGIN_NAME+'-close]').on('click', '[data-'+PLUGIN_NAME+'-close]', function (e) {
329
+ e.preventDefault();
330
+
331
+ var transition = $(e.currentTarget).attr('data-'+PLUGIN_NAME+'-transitionOut');
332
+
333
+ if(transition !== undefined){
334
+ that.close({transition:transition});
335
+ } else {
336
+ that.close();
337
+ }
338
+ });
339
+
340
+ // Expand when button pressed
341
+ that.$element.off('click', '[data-'+PLUGIN_NAME+'-fullscreen]').on('click', '[data-'+PLUGIN_NAME+'-fullscreen]', function (e) {
342
+ e.preventDefault();
343
+ if(that.isFullscreen === true){
344
+ that.isFullscreen = false;
345
+ that.$element.removeClass('isFullscreen');
346
+ } else {
347
+ that.isFullscreen = true;
348
+ that.$element.addClass('isFullscreen');
349
+ }
350
+ if (that.options.onFullscreen && typeof(that.options.onFullscreen) === "function") {
351
+ that.options.onFullscreen(that);
352
+ }
353
+ that.$element.trigger('fullscreen', that);
354
+ });
355
+
356
+ // Next modal
357
+ that.$navigate.off('click', '.'+PLUGIN_NAME+'-navigate-next').on('click', '.'+PLUGIN_NAME+'-navigate-next', function (e) {
358
+ that.next(e);
359
+ });
360
+ that.$element.off('click', '[data-'+PLUGIN_NAME+'-next]').on('click', '[data-'+PLUGIN_NAME+'-next]', function (e) {
361
+ that.next(e);
362
+ });
363
+
364
+ // Previous modal
365
+ that.$navigate.off('click', '.'+PLUGIN_NAME+'-navigate-prev').on('click', '.'+PLUGIN_NAME+'-navigate-prev', function (e) {
366
+ that.prev(e);
367
+ });
368
+ that.$element.off('click', '[data-'+PLUGIN_NAME+'-prev]').on('click', '[data-'+PLUGIN_NAME+'-prev]', function (e) {
369
+ that.prev(e);
370
+ });
371
+ }
372
+
373
+ if(this.state == STATES.CLOSED){
374
+
375
+ bindEvents();
376
+
377
+ this.setGroup();
378
+ this.state = STATES.OPENING;
379
+ this.$element.trigger(STATES.OPENING);
380
+ this.$element.attr('aria-hidden', 'false');
381
+
382
+ // console.info('[ '+PLUGIN_NAME+' | '+this.id+' ] Opening...');
383
+
384
+ if(this.options.iframe === true){
385
+
386
+ this.$element.find('.'+PLUGIN_NAME+'-content').addClass(PLUGIN_NAME+'-content-loader');
387
+
388
+ this.$element.find('.'+PLUGIN_NAME+'-iframe').on('load', function(){
389
+ $(this).parent().removeClass(PLUGIN_NAME+'-content-loader');
390
+ });
391
+
392
+ var href = null;
393
+ try {
394
+ href = $(param.currentTarget).attr('href') !== '' ? $(param.currentTarget).attr('href') : null;
395
+ } catch(e) {
396
+ // console.warn(e);
397
+ }
398
+ if( (this.options.iframeURL !== null) && (href === null || href === undefined)){
399
+ href = this.options.iframeURL;
400
+ }
401
+ if(href === null || href === undefined){
402
+ throw new Error('Failed to find iframe URL');
403
+ }
404
+ this.$element.find('.'+PLUGIN_NAME+'-iframe').attr('src', href);
405
+ }
406
+
407
+
408
+ if (this.options.bodyOverflow || isMobile){
409
+ $('html').addClass(PLUGIN_NAME+'-isOverflow');
410
+ if(isMobile){
411
+ $('body').css('overflow', 'hidden');
412
+ }
413
+ }
414
+
415
+ if (this.options.onOpening && typeof(this.options.onOpening) === 'function') {
416
+ this.options.onOpening(this);
417
+ }
418
+ (function open(){
419
+
420
+ if(that.group.ids.length > 1 ){
421
+
422
+ that.$navigate.appendTo('body');
423
+ that.$navigate.addClass('fadeIn');
424
+
425
+ if(that.options.navigateCaption === true){
426
+ that.$navigate.find('.'+PLUGIN_NAME+'-navigate-caption').show();
427
+ }
428
+
429
+ var modalWidth = that.$element.outerWidth();
430
+ if(that.options.navigateArrows !== false){
431
+ if (that.options.navigateArrows === 'closeScreenEdge'){
432
+ that.$navigate.find('.'+PLUGIN_NAME+'-navigate-prev').css('left', 0).show();
433
+ that.$navigate.find('.'+PLUGIN_NAME+'-navigate-next').css('right', 0).show();
434
+ } else {
435
+ that.$navigate.find('.'+PLUGIN_NAME+'-navigate-prev').css('margin-left', -((modalWidth/2)+84)).show();
436
+ that.$navigate.find('.'+PLUGIN_NAME+'-navigate-next').css('margin-right', -((modalWidth/2)+84)).show();
437
+ }
438
+ } else {
439
+ that.$navigate.find('.'+PLUGIN_NAME+'-navigate-prev').hide();
440
+ that.$navigate.find('.'+PLUGIN_NAME+'-navigate-next').hide();
441
+ }
442
+
443
+ var loop;
444
+ if(that.group.index === 0){
445
+
446
+ loop = $('.'+PLUGIN_NAME+'[data-'+PLUGIN_NAME+'-group="'+that.group.name+'"][data-'+PLUGIN_NAME+'-loop]').length;
447
+
448
+ if(loop === 0 && that.options.loop === false)
449
+ that.$navigate.find('.'+PLUGIN_NAME+'-navigate-prev').hide();
450
+ }
451
+ if(that.group.index+1 === that.group.ids.length){
452
+
453
+ loop = $('.'+PLUGIN_NAME+'[data-'+PLUGIN_NAME+'-group="'+that.group.name+'"][data-'+PLUGIN_NAME+'-loop]').length;
454
+
455
+ if(loop === 0 && that.options.loop === false)
456
+ that.$navigate.find('.'+PLUGIN_NAME+'-navigate-next').hide();
457
+ }
458
+ }
459
+
460
+ if(that.options.overlay === true) {
461
+
462
+ if(that.options.appendToOverlay === false){
463
+ that.$overlay.appendTo('body');
464
+ } else {
465
+ that.$overlay.appendTo( that.options.appendToOverlay );
466
+ }
467
+ }
468
+
469
+ if (that.options.transitionInOverlay) {
470
+ that.$overlay.addClass(that.options.transitionInOverlay);
471
+ }
472
+
473
+ var transitionIn = that.options.transitionIn;
474
+
475
+ if( typeof param == 'object' ){
476
+ if(param.transition !== undefined || param.transitionIn !== undefined){
477
+ transitionIn = param.transition || param.transitionIn;
478
+ }
479
+ }
480
+
481
+ if (transitionIn !== '' && animationEvent !== undefined) {
482
+
483
+ that.$element.addClass('transitionIn '+transitionIn).show();
484
+ that.$wrap.one(animationEvent, function () {
485
+
486
+ that.$element.removeClass(transitionIn + ' transitionIn');
487
+ that.$overlay.removeClass(that.options.transitionInOverlay);
488
+ that.$navigate.removeClass('fadeIn');
489
+
490
+ opened();
491
+ });
492
+
493
+ } else {
494
+
495
+ that.$element.show();
496
+ opened();
497
+ }
498
+
499
+ if(that.options.pauseOnHover === true && that.options.pauseOnHover === true && that.options.timeout !== false && !isNaN(parseInt(that.options.timeout)) && that.options.timeout !== false && that.options.timeout !== 0){
500
+
501
+ that.$element.off('mouseenter').on('mouseenter', function(event) {
502
+ event.preventDefault();
503
+ that.isPaused = true;
504
+ });
505
+ that.$element.off('mouseleave').on('mouseleave', function(event) {
506
+ event.preventDefault();
507
+ that.isPaused = false;
508
+ });
509
+ }
510
+
511
+ })();
512
+
513
+ if (this.options.timeout !== false && !isNaN(parseInt(this.options.timeout)) && this.options.timeout !== false && this.options.timeout !== 0) {
514
+
515
+ if (this.options.timeoutProgressbar === true) {
516
+
517
+ this.progressBar = {
518
+ hideEta: null,
519
+ maxHideTime: null,
520
+ currentTime: new Date().getTime(),
521
+ el: this.$element.find('.'+PLUGIN_NAME+'-progressbar > div'),
522
+ updateProgress: function()
523
+ {
524
+ if(!that.isPaused){
525
+
526
+ that.progressBar.currentTime = that.progressBar.currentTime+10;
527
+
528
+ var percentage = ((that.progressBar.hideEta - (that.progressBar.currentTime)) / that.progressBar.maxHideTime) * 100;
529
+ that.progressBar.el.width(percentage + '%');
530
+ if(percentage < 0){
531
+ that.close();
532
+ }
533
+ }
534
+ }
535
+ };
536
+ if (this.options.timeout > 0) {
537
+
538
+ this.progressBar.maxHideTime = parseFloat(this.options.timeout);
539
+ this.progressBar.hideEta = new Date().getTime() + this.progressBar.maxHideTime;
540
+ this.timerTimeout = setInterval(this.progressBar.updateProgress, 10);
541
+ }
542
+
543
+ } else {
544
+
545
+ this.timerTimeout = setTimeout(function(){
546
+ that.close();
547
+ }, that.options.timeout);
548
+ }
549
+ }
550
+
551
+ // Close on overlay click
552
+ if (this.options.overlayClose && !this.$element.hasClass(this.options.transitionOut)) {
553
+ this.$overlay.click(function () {
554
+ that.close();
555
+ });
556
+ }
557
+
558
+ if (this.options.focusInput){
559
+ this.$element.find(':input:not(button):enabled:visible:first').focus(); // Focus on the first field
560
+ }
561
+
562
+ (function updateTimer(){
563
+ that.recalcLayout();
564
+ that.timer = setTimeout(updateTimer, 300);
565
+ })();
566
+
567
+ // Close when the Escape key is pressed
568
+ $document.on('keydown.'+PLUGIN_NAME, function (e) {
569
+ if (that.options.closeOnEscape && e.keyCode === 27) {
570
+ that.close();
571
+ }
572
+ });
573
+
574
+ }
575
+
576
+ },
577
+
578
+ close: function (param) {
579
+
580
+ var that = this;
581
+
582
+ function closed(){
583
+
584
+ // console.info('[ '+PLUGIN_NAME+' | '+that.id+' ] Closed.');
585
+
586
+ that.state = STATES.CLOSED;
587
+ that.$element.trigger(STATES.CLOSED);
588
+
589
+ if (that.options.iframe === true) {
590
+ that.$element.find('.'+PLUGIN_NAME+'-iframe').attr('src', '');
591
+ }
592
+
593
+ if (that.options.bodyOverflow || isMobile){
594
+ $('html').removeClass(PLUGIN_NAME+'-isOverflow');
595
+ if(isMobile){
596
+ $('body').css('overflow','auto');
597
+ }
598
+ }
599
+
600
+ if (that.options.onClosed && typeof(that.options.onClosed) === 'function') {
601
+ that.options.onClosed(that);
602
+ }
603
+
604
+ if(that.options.restoreDefaultContent === true){
605
+ that.$element.find('.'+PLUGIN_NAME+'-content').html( that.content );
606
+ }
607
+
608
+ if( $('.'+PLUGIN_NAME+':visible').length === 0 ){
609
+ $('html').removeClass(PLUGIN_NAME+'-isAttached');
610
+ }
611
+ }
612
+
613
+ if(this.state == STATES.OPENED || this.state == STATES.OPENING){
614
+
615
+ $document.off('keydown.'+PLUGIN_NAME);
616
+
617
+ this.state = STATES.CLOSING;
618
+ this.$element.trigger(STATES.CLOSING);
619
+ this.$element.attr('aria-hidden', 'true');
620
+
621
+ // console.info('[ '+PLUGIN_NAME+' | '+this.id+' ] Closing...');
622
+
623
+ clearTimeout(this.timer);
624
+ clearTimeout(this.timerTimeout);
625
+
626
+ if (that.options.onClosing && typeof(that.options.onClosing) === "function") {
627
+ that.options.onClosing(this);
628
+ }
629
+
630
+ var transitionOut = this.options.transitionOut;
631
+
632
+ if( typeof param == 'object' ){
633
+ if(param.transition !== undefined || param.transitionOut !== undefined){
634
+ transitionOut = param.transition || param.transitionOut;
635
+ }
636
+ }
637
+
638
+ if( (transitionOut === false || transitionOut === '' ) || animationEvent === undefined){
639
+
640
+ this.$element.hide();
641
+ this.$overlay.remove();
642
+ this.$navigate.remove();
643
+ closed();
644
+
645
+ } else {
646
+
647
+ this.$element.attr('class', [
648
+ this.classes,
649
+ PLUGIN_NAME,
650
+ transitionOut,
651
+ this.options.theme == 'light' ? PLUGIN_NAME+'-light' : this.options.theme,
652
+ this.isFullscreen === true ? 'isFullscreen' : '',
653
+ this.options.rtl ? PLUGIN_NAME+'-rtl' : ''
654
+ ].join(' '));
655
+
656
+ this.$overlay.attr('class', PLUGIN_NAME + '-overlay ' + this.options.transitionOutOverlay);
657
+
658
+ if(that.options.navigateArrows !== false){
659
+ this.$navigate.attr('class', PLUGIN_NAME + '-navigate fadeOut');
660
+ }
661
+
662
+ this.$element.one(animationEvent, function () {
663
+
664
+ if( that.$element.hasClass(transitionOut) ){
665
+ that.$element.removeClass(transitionOut + ' transitionOut').hide();
666
+ }
667
+ that.$overlay.removeClass(that.options.transitionOutOverlay).remove();
668
+ that.$navigate.removeClass('fadeOut').remove();
669
+ closed();
670
+ });
671
+
672
+ }
673
+
674
+ }
675
+ },
676
+
677
+ next: function (e){
678
+
679
+ var that = this;
680
+ var transitionIn = 'fadeInRight';
681
+ var transitionOut = 'fadeOutLeft';
682
+ var modal = $('.'+PLUGIN_NAME+':visible');
683
+ var modals = {};
684
+ modals.out = this;
685
+
686
+ if(e !== undefined && typeof e !== 'object'){
687
+ e.preventDefault();
688
+ modal = $(e.currentTarget);
689
+ transitionIn = modal.attr('data-'+PLUGIN_NAME+'-transitionIn');
690
+ transitionOut = modal.attr('data-'+PLUGIN_NAME+'-transitionOut');
691
+ } else if(e !== undefined){
692
+ if(e.transitionIn !== undefined){
693
+ transitionIn = e.transitionIn;
694
+ }
695
+ if(e.transitionOut !== undefined){
696
+ transitionOut = e.transitionOut;
697
+ }
698
+ }
699
+
700
+ this.close({transition:transitionOut});
701
+
702
+ setTimeout(function(){
703
+
704
+ var loop = $('.'+PLUGIN_NAME+'[data-'+PLUGIN_NAME+'-group="'+that.group.name+'"][data-'+PLUGIN_NAME+'-loop]').length;
705
+ for (var i = that.group.index+1; i <= that.group.ids.length; i++) {
706
+
707
+ try {
708
+ modals.in = $("#"+that.group.ids[i]).data().iziModal;
709
+ } catch(log) {
710
+ // console.info('[ '+PLUGIN_NAME+' ] No next modal.');
711
+ }
712
+ if(typeof modals.in !== 'undefined'){
713
+
714
+ $('#'+that.group.ids[i]).iziModal('open', { transition: transitionIn });
715
+ break;
716
+
717
+ } else {
718
+
719
+ if(i == that.group.ids.length && loop > 0 || that.options.loop === true){
720
+
721
+ for (var index = 0; index <= that.group.ids.length; index++) {
722
+
723
+ modals.in = $('#'+that.group.ids[index]).data().iziModal;
724
+ if(typeof modals.in !== 'undefined'){
725
+
726
+ $('#'+that.group.ids[index]).iziModal('open', { transition: transitionIn });
727
+
728
+ break;
729
+ }
730
+ }
731
+ }
732
+ }
733
+ }
734
+
735
+ }, 200);
736
+
737
+ $(document).trigger( PLUGIN_NAME + '-group-change', modals );
738
+ },
739
+
740
+ prev: function (e){
741
+ var that = this;
742
+ var transitionIn = 'fadeInLeft';
743
+ var transitionOut = 'fadeOutRight';
744
+ var modal = $('.'+PLUGIN_NAME+':visible');
745
+ var modals = {};
746
+ modals.out = this;
747
+
748
+ if(e !== undefined && typeof e !== 'object'){
749
+ e.preventDefault();
750
+ modal = $(e.currentTarget);
751
+ transitionIn = modal.attr('data-'+PLUGIN_NAME+'-transitionIn');
752
+ transitionOut = modal.attr('data-'+PLUGIN_NAME+'-transitionOut');
753
+
754
+ } else if(e !== undefined){
755
+
756
+ if(e.transitionIn !== undefined){
757
+ transitionIn = e.transitionIn;
758
+ }
759
+ if(e.transitionOut !== undefined){
760
+ transitionOut = e.transitionOut;
761
+ }
762
+ }
763
+
764
+ this.close({transition:transitionOut});
765
+
766
+ setTimeout(function(){
767
+
768
+ var loop = $('.'+PLUGIN_NAME+'[data-'+PLUGIN_NAME+'-group="'+that.group.name+'"][data-'+PLUGIN_NAME+'-loop]').length;
769
+
770
+ for (var i = that.group.index; i >= 0; i--) {
771
+
772
+ try {
773
+ modals.in = $('#'+that.group.ids[i-1]).data().iziModal;
774
+ } catch(log) {
775
+ // console.info('[ '+PLUGIN_NAME+' ] No previous modal.');
776
+ }
777
+ if(typeof modals.in !== 'undefined'){
778
+
779
+ $('#'+that.group.ids[i-1]).iziModal('open', { transition: transitionIn });
780
+ break;
781
+
782
+ } else {
783
+
784
+ if(i === 0 && loop > 0 || that.options.loop === true){
785
+
786
+ for (var index = that.group.ids.length-1; index >= 0; index--) {
787
+
788
+ modals.in = $('#'+that.group.ids[index]).data().iziModal;
789
+ if(typeof modals.in !== 'undefined'){
790
+
791
+ $('#'+that.group.ids[index]).iziModal('open', { transition: transitionIn });
792
+
793
+ break;
794
+ }
795
+ }
796
+ }
797
+ }
798
+ }
799
+
800
+ }, 200);
801
+
802
+ $(document).trigger( PLUGIN_NAME + '-group-change', modals );
803
+ },
804
+
805
+ destroy: function () {
806
+ var e = $.Event('destroy');
807
+
808
+ this.$element.trigger(e);
809
+
810
+ $document.off('keydown.'+PLUGIN_NAME);
811
+
812
+ clearTimeout(this.timer);
813
+ clearTimeout(this.timerTimeout);
814
+
815
+ if (this.options.iframe === true) {
816
+ this.$element.find('.'+PLUGIN_NAME+'-iframe').remove();
817
+ }
818
+ this.$element.html(this.$element.find('.'+PLUGIN_NAME+'-content').html());
819
+
820
+ this.$element.off('click', '[data-'+PLUGIN_NAME+'-close]');
821
+ this.$element.off('click', '[data-'+PLUGIN_NAME+'-fullscreen]');
822
+
823
+ this.$element
824
+ .off('.'+PLUGIN_NAME)
825
+ .removeData(PLUGIN_NAME)
826
+ .attr('style', '');
827
+
828
+ this.$overlay.remove();
829
+ this.$navigate.remove();
830
+ this.$element.trigger(STATES.DESTROYED);
831
+ this.$element = null;
832
+ },
833
+
834
+ getState: function(){
835
+
836
+ return this.state;
837
+ },
838
+
839
+ getGroup: function(){
840
+
841
+ return this.group;
842
+ },
843
+
844
+ setWidth: function(width){
845
+
846
+ this.options.width = width;
847
+
848
+ this.recalcWidth();
849
+
850
+ var modalWidth = this.$element.outerWidth();
851
+ if(this.options.navigateArrows === true || this.options.navigateArrows == 'closeToModal'){
852
+ this.$navigate.find('.'+PLUGIN_NAME+'-navigate-prev').css('margin-left', -((modalWidth/2)+84)).show();
853
+ this.$navigate.find('.'+PLUGIN_NAME+'-navigate-next').css('margin-right', -((modalWidth/2)+84)).show();
854
+ }
855
+
856
+ },
857
+
858
+ setTop: function(top){
859
+
860
+ this.options.top = top;
861
+
862
+ this.recalcVerticalPos(false);
863
+ },
864
+
865
+ setBottom: function(bottom){
866
+
867
+ this.options.bottom = bottom;
868
+
869
+ this.recalcVerticalPos(false);
870
+
871
+ },
872
+
873
+ setHeader: function(status){
874
+
875
+ if(status){
876
+ this.$element.find('.'+PLUGIN_NAME+'-header').show();
877
+ } else {
878
+ this.headerHeight = 0;
879
+ this.$element.find('.'+PLUGIN_NAME+'-header').hide();
880
+ }
881
+ },
882
+
883
+ setTitle: function(title){
884
+
885
+ this.options.title = title;
886
+
887
+ if(this.headerHeight === 0){
888
+ this.createHeader();
889
+ }
890
+
891
+ if( this.$header.find('.'+PLUGIN_NAME+'-header-title').length === 0 ){
892
+ this.$header.append('<h2 class="'+PLUGIN_NAME+'-header-title"></h2>');
893
+ }
894
+
895
+ this.$header.find('.'+PLUGIN_NAME+'-header-title').html(title);
896
+ },
897
+
898
+ setSubtitle: function(subtitle){
899
+
900
+ if(subtitle === ''){
901
+
902
+ this.$header.find('.'+PLUGIN_NAME+'-header-subtitle').remove();
903
+ this.$header.addClass(PLUGIN_NAME+'-noSubtitle');
904
+
905
+ } else {
906
+
907
+ if( this.$header.find('.'+PLUGIN_NAME+'-header-subtitle').length === 0 ){
908
+ this.$header.append('<p class="'+PLUGIN_NAME+'-header-subtitle"></p>');
909
+ }
910
+ this.$header.removeClass(PLUGIN_NAME+'-noSubtitle');
911
+
912
+ }
913
+
914
+ this.$header.find('.'+PLUGIN_NAME+'-header-subtitle').html(subtitle);
915
+ this.options.subtitle = subtitle;
916
+ },
917
+
918
+ setIcon: function(icon){
919
+
920
+ if( this.$header.find('.'+PLUGIN_NAME+'-header-icon').length === 0 ){
921
+ this.$header.prepend('<i class="'+PLUGIN_NAME+'-header-icon"></i>');
922
+ }
923
+ this.$header.find('.'+PLUGIN_NAME+'-header-icon').attr('class', PLUGIN_NAME+'-header-icon ' + icon);
924
+ this.options.icon = icon;
925
+ },
926
+
927
+ setIconText: function(iconText){
928
+
929
+ this.$header.find('.'+PLUGIN_NAME+'-header-icon').html(iconText);
930
+ this.options.iconText = iconText;
931
+ },
932
+
933
+ setHeaderColor: function(headerColor){
934
+ if(this.options.borderBottom === true){
935
+ this.$element.css('border-bottom', '3px solid ' + headerColor + '');
936
+ }
937
+ this.$header.css('background', headerColor);
938
+ this.options.headerColor = headerColor;
939
+ },
940
+
941
+ setBackground: function(background){
942
+ if(background === false){
943
+ this.options.background = null;
944
+ this.$element.css('background', '');
945
+ } else{
946
+ this.$element.css('background', background);
947
+ this.options.background = background;
948
+ }
949
+ },
950
+
951
+ setZindex: function(zIndex){
952
+
953
+ if (!isNaN(parseInt(this.options.zindex))) {
954
+ this.options.zindex = zIndex;
955
+ this.$element.css('z-index', zIndex);
956
+ this.$navigate.css('z-index', zIndex-1);
957
+ this.$overlay.css('z-index', zIndex-2);
958
+ }
959
+ },
960
+
961
+ setFullscreen: function(value){
962
+
963
+ if(value){
964
+ this.isFullscreen = true;
965
+ this.$element.addClass('isFullscreen');
966
+ } else {
967
+ this.isFullscreen = false;
968
+ this.$element.removeClass('isFullscreen');
969
+ }
970
+
971
+ },
972
+
973
+ setContent: function(content){
974
+
975
+ if( typeof content == 'object' ){
976
+ var replace = content.default || false;
977
+ if(replace === true){
978
+ this.content = content.content;
979
+ }
980
+ content = content.content;
981
+ }
982
+ if (this.options.iframe === false) {
983
+ this.$element.find('.'+PLUGIN_NAME+'-content').html(content);
984
+ }
985
+
986
+ },
987
+
988
+ setTransitionIn: function(transition){
989
+
990
+ this.options.transitionIn = transition;
991
+ },
992
+
993
+ setTransitionOut: function(transition){
994
+
995
+ this.options.transitionOut = transition;
996
+ },
997
+
998
+ resetContent: function(){
999
+
1000
+ this.$element.find('.'+PLUGIN_NAME+'-content').html(this.content);
1001
+
1002
+ },
1003
+
1004
+ startLoading: function(){
1005
+
1006
+ if( !this.$element.find('.'+PLUGIN_NAME+'-loader').length ){
1007
+ this.$element.append('<div class="'+PLUGIN_NAME+'-loader fadeIn"></div>');
1008
+ }
1009
+ this.$element.find('.'+PLUGIN_NAME+'-loader').css({
1010
+ top: this.headerHeight,
1011
+ borderRadius: this.options.radius
1012
+ });
1013
+ },
1014
+
1015
+ stopLoading: function(){
1016
+
1017
+ var $loader = this.$element.find('.'+PLUGIN_NAME+'-loader');
1018
+
1019
+ if( !$loader.length ){
1020
+ this.$element.prepend('<div class="'+PLUGIN_NAME+'-loader fadeIn"></div>');
1021
+ $loader = this.$element.find('.'+PLUGIN_NAME+'-loader').css('border-radius', this.options.radius);
1022
+ }
1023
+ $loader.removeClass('fadeIn').addClass('fadeOut');
1024
+ setTimeout(function(){
1025
+ $loader.remove();
1026
+ },600);
1027
+ },
1028
+
1029
+ recalcWidth: function(){
1030
+
1031
+ var that = this;
1032
+
1033
+ this.$element.css('max-width', this.options.width);
1034
+
1035
+ if(isIE()){
1036
+ var modalWidth = that.options.width;
1037
+
1038
+ if(modalWidth.toString().split('%').length > 1){
1039
+ modalWidth = that.$element.outerWidth();
1040
+ }
1041
+ that.$element.css({
1042
+ left: '50%',
1043
+ marginLeft: -(modalWidth/2)
1044
+ });
1045
+ }
1046
+ },
1047
+
1048
+ recalcVerticalPos: function(first){
1049
+
1050
+ if(this.options.top !== null && this.options.top !== false){
1051
+ this.$element.css('margin-top', this.options.top);
1052
+ if(this.options.top === 0){
1053
+ this.$element.css({
1054
+ borderTopRightRadius: 0,
1055
+ borderTopLeftRadius: 0
1056
+ });
1057
+ }
1058
+ } else {
1059
+ if(first === false){
1060
+ this.$element.css({
1061
+ marginTop: '',
1062
+ borderRadius: this.options.radius
1063
+ });
1064
+ }
1065
+ }
1066
+ if (this.options.bottom !== null && this.options.bottom !== false){
1067
+ this.$element.css('margin-bottom', this.options.bottom);
1068
+ if(this.options.bottom === 0){
1069
+ this.$element.css({
1070
+ borderBottomRightRadius: 0,
1071
+ borderBottomLeftRadius: 0
1072
+ });
1073
+ }
1074
+ } else {
1075
+ if(first === false){
1076
+ this.$element.css({
1077
+ marginBottom: '',
1078
+ borderRadius: this.options.radius
1079
+ });
1080
+ }
1081
+ }
1082
+
1083
+ },
1084
+
1085
+ recalcLayout: function(){
1086
+
1087
+ var that = this,
1088
+ windowHeight = $window.height(),
1089
+ modalHeight = this.$element.outerHeight(),
1090
+ modalWidth = this.$element.outerWidth(),
1091
+ contentHeight = this.$element.find('.'+PLUGIN_NAME+'-content')[0].scrollHeight,
1092
+ outerHeight = contentHeight + this.headerHeight,
1093
+ wrapperHeight = this.$element.innerHeight() - this.headerHeight,
1094
+ modalMargin = parseInt(-((this.$element.innerHeight() + 1) / 2)) + 'px',
1095
+ scrollTop = this.$wrap.scrollTop(),
1096
+ borderSize = 0;
1097
+
1098
+ if(isIE()){
1099
+ if( modalWidth >= $window.width() || this.isFullscreen === true ){
1100
+ this.$element.css({
1101
+ left: '0',
1102
+ marginLeft: ''
1103
+ });
1104
+ } else {
1105
+ this.$element.css({
1106
+ left: '50%',
1107
+ marginLeft: -(modalWidth/2)
1108
+ });
1109
+ }
1110
+ }
1111
+
1112
+ if(this.options.borderBottom === true && this.options.title !== ''){
1113
+ borderSize = 3;
1114
+ }
1115
+
1116
+ if(this.$element.find('.'+PLUGIN_NAME+'-header').length && this.$element.find('.'+PLUGIN_NAME+'-header').is(':visible') ){
1117
+ this.headerHeight = parseInt(this.$element.find('.'+PLUGIN_NAME+'-header').innerHeight());
1118
+ this.$element.css('overflow', 'hidden');
1119
+ } else {
1120
+ this.headerHeight = 0;
1121
+ this.$element.css('overflow', '');
1122
+ }
1123
+
1124
+ if(this.$element.find('.'+PLUGIN_NAME+'-loader').length){
1125
+ this.$element.find('.'+PLUGIN_NAME+'-loader').css('top', this.headerHeight);
1126
+ }
1127
+
1128
+ if(modalHeight !== this.modalHeight){
1129
+ this.modalHeight = modalHeight;
1130
+
1131
+ if (this.options.onResize && typeof(this.options.onResize) === "function") {
1132
+ this.options.onResize(this);
1133
+ }
1134
+ }
1135
+
1136
+ if(this.state == STATES.OPENED || this.state == STATES.OPENING){
1137
+
1138
+ if (this.options.iframe === true) {
1139
+
1140
+ // If the height of the window is smaller than the modal with iframe
1141
+ if(windowHeight < (this.options.iframeHeight + this.headerHeight+borderSize) || this.isFullscreen === true){
1142
+ this.$element.find('.'+PLUGIN_NAME+'-iframe').css( 'height', windowHeight - (this.headerHeight+borderSize));
1143
+ } else {
1144
+ this.$element.find('.'+PLUGIN_NAME+'-iframe').css( 'height', this.options.iframeHeight);
1145
+ }
1146
+ }
1147
+
1148
+ if(modalHeight == windowHeight){
1149
+ this.$element.addClass('isAttached');
1150
+ } else {
1151
+ this.$element.removeClass('isAttached');
1152
+ }
1153
+
1154
+ if(this.isFullscreen === false && this.$element.width() >= $window.width() ){
1155
+ this.$element.find('.'+PLUGIN_NAME+'-button-fullscreen').hide();
1156
+ } else {
1157
+ this.$element.find('.'+PLUGIN_NAME+'-button-fullscreen').show();
1158
+ }
1159
+ this.recalcButtons();
1160
+
1161
+ if(this.isFullscreen === false){
1162
+ windowHeight = windowHeight - (clearValue(this.options.top) || 0) - (clearValue(this.options.bottom) || 0);
1163
+ }
1164
+ // If the modal is larger than the height of the window..
1165
+ if (outerHeight > windowHeight) {
1166
+ if(this.options.top > 0 && this.options.bottom === null && contentHeight < $window.height()){
1167
+ this.$element.addClass('isAttachedBottom');
1168
+ }
1169
+ if(this.options.bottom > 0 && this.options.top === null && contentHeight < $window.height()){
1170
+ this.$element.addClass('isAttachedTop');
1171
+ }
1172
+ $('html').addClass(PLUGIN_NAME+'-isAttached');
1173
+ this.$element.css( 'height', windowHeight );
1174
+
1175
+ } else {
1176
+ this.$element.css('height', contentHeight + (this.headerHeight+borderSize));
1177
+ this.$element.removeClass('isAttachedTop isAttachedBottom');
1178
+ $('html').removeClass(PLUGIN_NAME+'-isAttached');
1179
+ }
1180
+
1181
+ (function applyScroll(){
1182
+ if(contentHeight > wrapperHeight && outerHeight > windowHeight){
1183
+ that.$element.addClass('hasScroll');
1184
+ that.$wrap.css('height', modalHeight - (that.headerHeight+borderSize));
1185
+ } else {
1186
+ that.$element.removeClass('hasScroll');
1187
+ that.$wrap.css('height', 'auto');
1188
+ }
1189
+ })();
1190
+
1191
+ (function applyShadow(){
1192
+ if (wrapperHeight + scrollTop < (contentHeight - 30)) {
1193
+ that.$element.addClass('hasShadow');
1194
+ } else {
1195
+ that.$element.removeClass('hasShadow');
1196
+ }
1197
+ })();
1198
+
1199
+ }
1200
+ },
1201
+
1202
+ recalcButtons: function(){
1203
+ var widthButtons = this.$header.find('.'+PLUGIN_NAME+'-header-buttons').innerWidth()+10;
1204
+ if(this.options.rtl === true){
1205
+ this.$header.css('padding-left', widthButtons);
1206
+ } else {
1207
+ this.$header.css('padding-right', widthButtons);
1208
+ }
1209
+ }
1210
+
1211
+ };
1212
+
1213
+
1214
+ $window.off('load.'+PLUGIN_NAME).on('load.'+PLUGIN_NAME, function(e) {
1215
+
1216
+ var modalHash = document.location.hash;
1217
+
1218
+ if(window.$iziModal.autoOpen === 0 && !$('.'+PLUGIN_NAME).is(':visible')){
1219
+
1220
+ try {
1221
+ var data = $(modalHash).data();
1222
+ if(typeof data !== 'undefined'){
1223
+ if(data.iziModal.options.autoOpen !== false){
1224
+ $(modalHash).iziModal('open');
1225
+ }
1226
+ }
1227
+ } catch(exc) { /* console.warn(exc); */ }
1228
+ }
1229
+
1230
+ });
1231
+
1232
+ $window.off('hashchange.'+PLUGIN_NAME).on('hashchange.'+PLUGIN_NAME, function(e) {
1233
+
1234
+ var modalHash = document.location.hash;
1235
+
1236
+ if(modalHash !== ''){
1237
+ try {
1238
+ var data = $(modalHash).data();
1239
+ if(typeof data !== 'undefined' && $(modalHash).iziModal('getState') !== 'opening'){
1240
+
1241
+ setTimeout(function(){
1242
+ $(modalHash).iziModal('open');
1243
+ },200);
1244
+ }
1245
+ } catch(exc) { /* console.warn(exc); */ }
1246
+
1247
+ } else {
1248
+
1249
+ if(window.$iziModal.history){
1250
+ $.each( $('.'+PLUGIN_NAME) , function(index, modal) {
1251
+ if( $(modal).data().iziModal !== undefined ){
1252
+ var state = $(modal).iziModal('getState');
1253
+ if(state == 'opened' || state == 'opening'){
1254
+ $(modal).iziModal('close');
1255
+ }
1256
+ }
1257
+ });
1258
+ }
1259
+ }
1260
+
1261
+
1262
+ });
1263
+
1264
+ $document.off('click', '[data-'+PLUGIN_NAME+'-open]').on('click', '[data-'+PLUGIN_NAME+'-open]', function(e) {
1265
+ e.preventDefault();
1266
+
1267
+ var modal = $('.'+PLUGIN_NAME+':visible');
1268
+ var openModal = $(e.currentTarget).attr('data-'+PLUGIN_NAME+'-open');
1269
+ var transitionIn = $(e.currentTarget).attr('data-'+PLUGIN_NAME+'-transitionIn');
1270
+ var transitionOut = $(e.currentTarget).attr('data-'+PLUGIN_NAME+'-transitionOut');
1271
+
1272
+ if(transitionOut !== undefined){
1273
+ modal.iziModal('close', {
1274
+ transition: transitionOut
1275
+ });
1276
+ } else {
1277
+ modal.iziModal('close');
1278
+ }
1279
+
1280
+ setTimeout(function(){
1281
+ if(transitionIn !== undefined){
1282
+ $(openModal).iziModal('open', {
1283
+ transition: transitionIn
1284
+ });
1285
+ } else {
1286
+ $(openModal).iziModal('open');
1287
+ }
1288
+ }, 200);
1289
+ });
1290
+
1291
+ $document.off('keyup.'+PLUGIN_NAME).on('keyup.'+PLUGIN_NAME, function(event) {
1292
+
1293
+ if( $('.'+PLUGIN_NAME+':visible').length ){
1294
+ var modal = $('.'+PLUGIN_NAME+':visible')[0].id,
1295
+ group = $('#'+modal).iziModal('getGroup'),
1296
+ e = event || window.event,
1297
+ target = e.target || e.srcElement,
1298
+ modals = {};
1299
+
1300
+ if(modal !== undefined && group.name !== undefined && !e.ctrlKey && !e.metaKey && !e.altKey && target.tagName.toUpperCase() !== 'INPUT' && target.tagName.toUpperCase() != 'TEXTAREA'){ //&& $(e.target).is('body')
1301
+
1302
+ if(e.keyCode === 37) { // left
1303
+
1304
+ $('#'+modal).iziModal('prev', e);
1305
+ }
1306
+ else if(e.keyCode === 39 ) { // right
1307
+
1308
+ $('#'+modal).iziModal('next', e);
1309
+
1310
+ }
1311
+ }
1312
+ }
1313
+ });
1314
+
1315
+ $.fn[PLUGIN_NAME] = function(option, args) {
1316
+
1317
+
1318
+ if( !$(this).length && typeof option == 'object'){
1319
+
1320
+ var newEL = {
1321
+ $el: document.createElement('div'),
1322
+ id: this.selector.split('#'),
1323
+ class: this.selector.split('.')
1324
+ };
1325
+
1326
+ if(newEL.id.length > 1){
1327
+ try{
1328
+ newEL.$el = document.createElement(id[0]);
1329
+ } catch(exc){ }
1330
+
1331
+ newEL.$el.id = this.selector.split('#')[1].trim();
1332
+
1333
+ } else if(newEL.class.length > 1){
1334
+ try{
1335
+ newEL.$el = document.createElement(newEL.class[0]);
1336
+ } catch(exc){ }
1337
+
1338
+ for (var x=1; x<newEL.class.length; x++) {
1339
+ newEL.$el.classList.add(newEL.class[x].trim());
1340
+ }
1341
+ }
1342
+ document.body.appendChild(newEL.$el);
1343
+
1344
+ this.push($(this.selector));
1345
+ }
1346
+ var objs = this;
1347
+
1348
+ for (var i=0; i<objs.length; i++) {
1349
+
1350
+ var $this = $(objs[i]);
1351
+ var data = $this.data(PLUGIN_NAME);
1352
+ var options = $.extend({}, $.fn[PLUGIN_NAME].defaults, $this.data(), typeof option == 'object' && option);
1353
+
1354
+ if (!data && (!option || typeof option == 'object')){
1355
+
1356
+ $this.data(PLUGIN_NAME, (data = new iziModal($this, options)));
1357
+ }
1358
+ else if (typeof option == 'string' && typeof data != 'undefined'){
1359
+
1360
+ return data[option].apply(data, [].concat(args));
1361
+ }
1362
+ if (options.autoOpen){ // Automatically open the modal if autoOpen setted true or ms
1363
+
1364
+ if( !isNaN(parseInt(options.autoOpen)) ){
1365
+
1366
+ setTimeout(function(){
1367
+ data.open();
1368
+ }, options.autoOpen);
1369
+
1370
+ } else if(options.autoOpen === true ) {
1371
+
1372
+ data.open();
1373
+ }
1374
+ window.$iziModal.autoOpen++;
1375
+ }
1376
+ }
1377
+
1378
+ return this;
1379
+ };
1380
+
1381
+ $.fn[PLUGIN_NAME].defaults = {
1382
+ title: '',
1383
+ subtitle: '',
1384
+ headerColor: '#88A0B9',
1385
+ background: null,
1386
+ theme: '', // light
1387
+ icon: null,
1388
+ iconText: null,
1389
+ iconColor: '',
1390
+ rtl: false,
1391
+ width: 600,
1392
+ top: null,
1393
+ bottom: null,
1394
+ borderBottom: true,
1395
+ padding: 0,
1396
+ radius: 3,
1397
+ zindex: 999,
1398
+ iframe: false,
1399
+ iframeHeight: 400,
1400
+ iframeURL: null,
1401
+ focusInput: true,
1402
+ group: '',
1403
+ loop: false,
1404
+ navigateCaption: true,
1405
+ navigateArrows: true, // Boolean, 'closeToModal', 'closeScreenEdge'
1406
+ history: false,
1407
+ restoreDefaultContent: false,
1408
+ autoOpen: 0, // Boolean, Number
1409
+ bodyOverflow: false,
1410
+ fullscreen: false,
1411
+ openFullscreen: false,
1412
+ closeOnEscape: true,
1413
+ closeButton: true,
1414
+ appendTo: 'body', // or false
1415
+ appendToOverlay: 'body', // or false
1416
+ overlay: true,
1417
+ overlayClose: true,
1418
+ overlayColor: 'rgba(0, 0, 0, 0.4)',
1419
+ timeout: false,
1420
+ timeoutProgressbar: false,
1421
+ pauseOnHover: false,
1422
+ timeoutProgressbarColor: 'rgba(255,255,255,0.5)',
1423
+ transitionIn: 'comingIn', // comingIn, bounceInDown, bounceInUp, fadeInDown, fadeInUp, fadeInLeft, fadeInRight, flipInX
1424
+ transitionOut: 'comingOut', // comingOut, bounceOutDown, bounceOutUp, fadeOutDown, fadeOutUp, , fadeOutLeft, fadeOutRight, flipOutX
1425
+ transitionInOverlay: 'fadeIn',
1426
+ transitionOutOverlay: 'fadeOut',
1427
+ onFullscreen: function(){},
1428
+ onResize: function(){},
1429
+ onOpening: function(){},
1430
+ onOpened: function(){},
1431
+ onClosing: function(){},
1432
+ onClosed: function(){},
1433
+ afterRender: function(){}
1434
+ };
1435
+
1436
+ $.fn[PLUGIN_NAME].Constructor = iziModal;
1437
+
1438
+ return $.fn.iziModal;
1439
+
1440
+ }));