1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-28 10:20:45 +02:00

Use e107.behaviors handler to initialize click event on ".e-modal" elements.

This commit is contained in:
Lóna Lore
2017-01-20 18:32:23 +01:00
parent b5b06536df
commit da16d2d52e
2 changed files with 123 additions and 93 deletions

View File

@@ -1,3 +1,59 @@
var e107 = e107 || {'settings': {}, 'behaviors': {}};
(function ($)
{
/**
* Initializes click event on '.e-modal' elements.
*
* @type {{attach: e107.behaviors.eModalAdmin.attach}}
*/
e107.behaviors.eModalAdmin = {
attach: function (context, settings)
{
$(context).find('.e-modal').once('e-modal-admin').each(function ()
{
var $that = $(this);
$that.on('click', function ()
{
var $this = $(this);
if($this.attr('data-cache') == 'false')
{
$('#uiModal').on('shown.bs.modal', function ()
{
$(this).removeData('bs.modal');
});
}
var url = $this.attr('href');
var caption = $this.attr('data-modal-caption');
var height = ($(window).height() * 0.7) - 120;
if(caption === undefined)
{
caption = '';
}
$('.modal-body').html('<div class="well"><iframe id="e-modal-iframe" width="100%" height="' + height + 'px" frameborder="0" scrolling="auto" style="display:block;background-color:transparent" allowtransparency="true" src="' + url + '"></iframe></div>');
$('.modal-caption').html(caption + ' <i id="e-modal-loading" class="fa fa-spin fa-spinner"></i>');
$('.modal').modal('show');
$("#e-modal-iframe").on("load", function ()
{
$('#e-modal-loading').hide();
});
return false;
});
});
}
};
})(jQuery);
$(document).ready(function()
{
$('form').h5Validate(
@@ -208,44 +264,6 @@ $(document).ready(function()
});
/* Bootstrap Modal window within an iFrame */
$('.e-modal').on('click', function(e)
{
e.preventDefault();
if($(this).attr('data-cache') == 'false')
{
$('#uiModal').on('shown.bs.modal', function () {
$(this).removeData('bs.modal');
});
}
var url = $(this).attr('href');
var caption = $(this).attr('data-modal-caption');
var height = ($(window).height() * 0.7) - 120;
if(caption === undefined)
{
caption = '';
}
$('.modal-body').html('<div class="well"><iframe id="e-modal-iframe" width="100%" height="'+height+'px" frameborder="0" scrolling="auto" style="display:block;background-color:transparent" allowtransparency="true" src="' + url + '"></iframe></div>');
$('.modal-caption').html(caption + ' <i id="e-modal-loading" class="fa fa-spin fa-spinner"></i>');
$('.modal').modal('show');
$("#e-modal-iframe").on("load", function () {
$('#e-modal-loading').hide();
});
});
var progresspump = null;

View File

@@ -40,6 +40,73 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
}
};
/**
* Initializes click event on '.e-modal' elements.
*
* @type {{attach: e107.behaviors.eModalFront.attach}}
*/
e107.behaviors.eModalFront = {
attach: function (context, settings)
{
$(context).find('.e-modal').once('e-modal-front').each(function ()
{
var $that = $(this);
$that.on('click', function ()
{
var $this = $(this);
if($this.attr('data-cache') == 'false')
{
$('#uiModal').on('shown.bs.modal', function ()
{
$(this).removeData('bs.modal');
});
}
var url = $this.attr('href');
var caption = $this.attr('data-modal-caption');
var backdrop = $this.attr('data-modal-backdrop');
var keyboard = $this.attr('data-modal-keyboard');
var height = ($(window).height() * 0.7) - 120;
var modalOptions = {show: true};
if(backdrop !== undefined)
{
modalOptions['backdrop'] = backdrop;
}
if(keyboard !== undefined)
{
modalOptions['keyboard'] = keyboard;
}
if(caption === undefined)
{
caption = '';
}
if($this.attr('data-modal-height') !== undefined)
{
height = $(this).attr('data-modal-height');
}
$('.modal-body').html('<div><iframe id="e-modal-iframe" width="100%" height="' + height + 'px" frameborder="0" scrolling="auto" style="display:block;" allowtransparency="true" allowfullscreen src="' + url + '"></iframe></div>');
$('.modal-caption').html(caption + ' <i id="e-modal-loading" class="fa fa-spin fa-spinner"></i>');
$('.modal').modal(modalOptions);
$("#e-modal-iframe").on("load", function ()
{
$('#e-modal-loading').hide();
});
return false;
});
});
}
};
})(jQuery);
@@ -397,60 +464,5 @@ $(document).ready(function()
return true;
});
/* Bootstrap Modal window within an iFrame for frontend */
$('.e-modal').on('click', function(e)
{
e.preventDefault();
if($(this).attr('data-cache') == 'false')
{
$('#uiModal').on('shown.bs.modal', function () {
$(this).removeData('bs.modal');
});
}
var url = $(this).attr('href');
var caption = $(this).attr('data-modal-caption');
var backdrop = $(this).attr('data-modal-backdrop');
var keyboard = $(this).attr('data-modal-keyboard');
var height = ($(window).height() * 0.7) - 120;
var modalOptions = {show: true};
if(backdrop !== undefined)
{
modalOptions['backdrop'] = backdrop;
}
if(keyboard !== undefined)
{
modalOptions['keyboard'] = keyboard;
}
if(caption === undefined)
{
caption = '';
}
if($(this).attr('data-modal-height') !== undefined)
{
height = $(this).attr('data-modal-height');
}
$('.modal-body').html('<div><iframe id="e-modal-iframe" width="100%" height="'+height+'px" frameborder="0" scrolling="auto" style="display:block;" allowtransparency="true" allowfullscreen src="' + url + '"></iframe></div>');
$('.modal-caption').html(caption + ' <i id="e-modal-loading" class="fa fa-spin fa-spinner"></i>');
$('.modal').modal(modalOptions);
$("#e-modal-iframe").on("load", function () {
$('#e-modal-loading').hide();
});
});
});