mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-28 01:29:05 +01:00
Enhance autocomplete fixer and fixes some bugs
This commit is contained in:
parent
7a0662b529
commit
59e922221c
@ -226,7 +226,7 @@ class etemplate_new extends etemplate_widget_template
|
||||
$load_array['response'] = egw_json_response::get()->returnResult();
|
||||
}
|
||||
// <iframe> and <form> tags added only to get browser autocomplete handling working again
|
||||
echo '<iframe name="egw_iframe_autocomplete_helper" src="about:blank" style="display:none;"></iframe><form id="egw_form_autocomplete_helper" target="egw_iframe_autocomplete_helper" action="about:blank" method="get"><div id="'.$dom_id.'" class="et2_container" data-etemplate="'.html::htmlspecialchars(egw_json_response::json_encode($load_array), true).'"></div></form>';
|
||||
echo '<div id="'.$dom_id.'" class="et2_container" data-etemplate="'.html::htmlspecialchars(egw_json_response::json_encode($load_array), true).'"></div>';
|
||||
|
||||
if ($output_mode == 2)
|
||||
{
|
||||
|
@ -571,6 +571,47 @@ etemplate2.prototype.isDirty = function()
|
||||
return dirty;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fixes browser autocomplete issue because of no form submission
|
||||
* it wraps the given DOMNode with form tag and add an iframe with
|
||||
* about:blank source to fake the submission
|
||||
*
|
||||
* @param {type} _node DOMNode which needs to be wrapped by autocomplete fixer form tag
|
||||
* @param {type} _id uniqu id to remove autocomplete extra tags after the operation
|
||||
*/
|
||||
etemplate2.prototype.autocomplete_fixer = function (_node,_id)
|
||||
{
|
||||
var node = _node||jQuery('.et2_contianer');
|
||||
var id = _id||this.uniqueId;
|
||||
|
||||
// Submit the template to an empty iframe (egw_iframe_autocomplete_helper)
|
||||
// in order to get default browser autocomplete working
|
||||
// maybe later we find better solution then we can remove this part
|
||||
var $et2_container = jQuery(node);
|
||||
if ($et2_container.length > 0)
|
||||
{
|
||||
//Creates form wrapper
|
||||
var $form = jQuery(document.createElement('form'))
|
||||
.attr({id:id + '_form_autocomplete_fixer',action:'about:blank', target:'egw_iframe_autocomplete helper'});
|
||||
//Creates iframe for fake submission
|
||||
$et2_container.before(jQuery(document.createElement('iframe'))
|
||||
.attr({id:id + '_iframe_autocomplete_fixer',src:'about:blank',name:'egw_iframe_autocomplete helper'}).hide());
|
||||
//Wraps the wrapper
|
||||
$et2_container.wrap($form);
|
||||
}
|
||||
//Activate autocomplete
|
||||
setTimeout(function(){
|
||||
var $a = jQuery(node).parent();
|
||||
if ($a.length>0 && typeof $a.parent() != 'undefined') $a.submit(); //Submit to iframe
|
||||
setTimeout(function(){
|
||||
//Clean up the mess from DOM
|
||||
if(jQuery(node).parent().is('form'))
|
||||
jQuery(node).unwrap();
|
||||
jQuery('iframe#'+id + '_iframe_autocomplete_fixer').remove();
|
||||
},1);
|
||||
},1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Submit form via ajax
|
||||
*
|
||||
@ -651,17 +692,15 @@ etemplate2.prototype.submit = function(button, async, no_validation)
|
||||
// Create the request object
|
||||
if (this.menuaction)
|
||||
{
|
||||
// Call autocomplete fixer
|
||||
this.autocomplete_fixer(this.DOMContainer,this.uniqueId);
|
||||
|
||||
// unbind our session-destroy handler, as we are submitting
|
||||
this.unbind_unload();
|
||||
|
||||
var api = this.widgetContainer.egw();
|
||||
var request = api.json(this.menuaction, [this.etemplate_exec_id, values, no_validation], null, this, async);
|
||||
request.sendRequest();
|
||||
|
||||
// Submit the template to an empty iframe (egw_iframe_autocomplete_helper)
|
||||
// in order to get default browser autocomplete working
|
||||
// maybe later we find better solution then we can remove this part
|
||||
jQuery("form#egw_form_autocomplete_helper").submit();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user