mirror of
https://github.com/e107inc/e107.git
synced 2025-04-14 09:32:17 +02:00
New Feature: Adding data-modal-submit='true' to a link (with class='e-modal') that points to an admin-ui create/edit form will now cause the iframe's form buttons to be hidden, and the "Create" or "Update" button placed in the footer of the modal window. Basically, this avoids the need to scroll the iframe in order to submit the form. The iframe's form is submitted from the modal window's button.
The same can be achieved with $readParms = array('target'=>'modal', 'modalSubmit'=>true); on an 'options' field in admin-ui $fields.
This commit is contained in:
parent
7933ec651e
commit
7d40402760
@ -4324,6 +4324,11 @@ class e_form
|
||||
$eModalCap = "";
|
||||
}
|
||||
|
||||
if(!empty($parms['modalSubmit']))
|
||||
{
|
||||
$eModalCap .= " data-modal-submit='true'";
|
||||
}
|
||||
|
||||
$query = http_build_query($query, null, '&');
|
||||
$value .= "<a href='".e_SELF."?{$query}' class='btn btn-default btn-secondary".$eModal."' ".$eModalCap." title='".LAN_EDIT."' data-toggle='tooltip' data-placement='left'>
|
||||
".$editIconDefault."</a>";
|
||||
|
@ -174,6 +174,7 @@ $ADMIN_MODAL = '
|
||||
<p>'.LAN_LOADING.'</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="e-modal-submit" class="btn btn-success" style="display:none" data-loading-icon="fa-spinner"><!-- placeholder --></button>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">'.LAN_CLOSE.'</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -19,7 +19,7 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
{
|
||||
var $this = $(this);
|
||||
|
||||
if($this.attr('data-cache') == 'false')
|
||||
if($this.attr('data-cache') === 'false')
|
||||
{
|
||||
$('#uiModal').on('shown.bs.modal', function ()
|
||||
{
|
||||
@ -31,6 +31,7 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
var caption = $this.attr('data-modal-caption');
|
||||
var height = ($(window).height() * 0.7) - 120;
|
||||
|
||||
|
||||
if(caption === undefined)
|
||||
{
|
||||
caption = '';
|
||||
@ -43,8 +44,18 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
$("#e-modal-iframe").on("load", function ()
|
||||
{
|
||||
$('#e-modal-loading').hide();
|
||||
|
||||
if($this.attr('data-modal-submit'))
|
||||
{
|
||||
var buttonCaption = $('#e-modal-iframe').contents().find('#etrigger-submit').text(); // copy submit button caption from iframe form.
|
||||
$('#e-modal-submit').text(buttonCaption).fadeIn(); // display the button in the modal footer.
|
||||
$('#e-modal-iframe').contents().find('.buttons-bar').hide(); // hide buttons in the iframe's form.
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
@ -138,6 +149,45 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
|
||||
$('#e-modal-submit').click(function () {
|
||||
$('#e-modal-iframe').contents().find('#etrigger-submit').trigger('click');
|
||||
|
||||
var type = $(this).data('loading-icon');
|
||||
var orig = $(this).text();
|
||||
|
||||
var caption = "<i class='fa fa-spin " + type + " fa-fw'></i>";
|
||||
caption += "<span>" + orig + "</span>";
|
||||
|
||||
$(this).html(caption);
|
||||
|
||||
$('#e-modal-iframe').on('load', function(){
|
||||
|
||||
var buttonFound = $('#e-modal-iframe').contents().find('#etrigger-submit');
|
||||
|
||||
if(buttonFound.length === 0) // disable resubmitting if not button found after submit.
|
||||
{
|
||||
$('#e-modal-submit').fadeOut(1000);
|
||||
}
|
||||
|
||||
$('#e-modal-submit').text(orig); // remove spinner.
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('[data-dismiss="modal"]').click(function(){ // hide button for next modal popup usage.
|
||||
|
||||
$('#e-modal-submit').hide(1000);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('form').h5Validate(
|
||||
{ errorClass: 'has-error' }
|
||||
); // allow older browsers to use html5 validation.
|
||||
|
Loading…
x
Reference in New Issue
Block a user