mirror of
https://github.com/e107inc/e107.git
synced 2025-07-29 02:40:25 +02:00
Use e107.behaviors handler to initialize click event on ".e-modal" elements.
This commit is contained in:
@@ -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()
|
$(document).ready(function()
|
||||||
{
|
{
|
||||||
$('form').h5Validate(
|
$('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;
|
var progresspump = null;
|
||||||
|
@@ -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);
|
})(jQuery);
|
||||||
|
|
||||||
|
|
||||||
@@ -397,60 +464,5 @@ $(document).ready(function()
|
|||||||
|
|
||||||
return true;
|
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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user