* All apps: Activate cross-browser autocomplete

This commit is contained in:
Hadi Nategh 2015-02-06 13:23:40 +00:00
parent 540ed1e96e
commit 4249dca91d
9 changed files with 54 additions and 25 deletions

View File

@ -189,11 +189,15 @@ class etemplate_new extends etemplate_widget_template
{
egw_framework::validate_file('.','app',$app,false);
}
// set action attribute for autocomplete form tag
// as firefox complains on about:balnk action, thus we have to literaly submit the form to a blank html
$form_action = "about:blank";
if (html::$user_agent == 'firefox') $form_action = $GLOBALS['egw_info']['server']['webserver_url'].'/etemplate/empty.html';
// check if we are in an ajax-exec call from jdots template (or future other tabbed templates)
if (isset($GLOBALS['egw']->framework->response))
{
$content = '<div id="'.$dom_id.'" class="et2_container"></div>';
$content = '<form target="egw_iframe_autocomplete_helper" action="'.$form_action.'" id="'.$dom_id.'" class="et2_container"></form><iframe name="egw_iframe_autocomplete_helper" style="width:0;height:0;position: absolute;"/>';
// add server-side page-generation times
if($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
{
@ -225,7 +229,7 @@ class etemplate_new extends etemplate_widget_template
{
$load_array['response'] = egw_json_response::get()->returnResult();
}
echo '<div id="'.$dom_id.'" class="et2_container" data-etemplate="'.html::htmlspecialchars(egw_json_response::json_encode($load_array), true).'"></div>';
echo '<form target="egw_iframe_autocomplete_helper" action="'.$form_action.'" id="'.$dom_id.'" class="et2_container" data-etemplate="'.html::htmlspecialchars(egw_json_response::json_encode($load_array), true).'"></form><iframe name="egw_iframe_autocomplete_helper" style="width:0;height:0;position: absolute;"/>';
if ($output_mode == 2)
{

View File

@ -1957,6 +1957,8 @@ var et2_nextmatch_header_bar = et2_DOMWidget.extend(et2_INextmatchHeader,
.on("keypress", function(event) {
if(event.which == 13)
{
event.preventDefault();
self.getInstanceManager().autocomplete_fixer();
self.nextmatch.applyFilters({search: self.search.getValue()});
}
});

View File

@ -99,7 +99,8 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM],
if (!this.options.readonly)
{
this.btn = $j(document.createElement("button"))
.addClass("et2_button et2_button_text");
.addClass("et2_button et2_button_text")
.attr({type:"button"});
this.setDOMNode(this.btn[0]);
}
},

View File

@ -581,6 +581,24 @@ etemplate2.prototype.isDirty = function()
return dirty;
};
/**
* Submit the et2_container form to a blank iframe in order to activate browser autocomplete
*/
etemplate2.prototype.autocomplete_fixer = function ()
{
var self = this;
var form = self.DOMContainer;
if (form)
{
form.onsubmit = function(){return false;};
// Firefox give a security warning when transmitting to "about:blank" from a https site
// we work around that by giving existing etemplate/empty.html url
if (navigator.userAgent.match(/firefox/i)) jQuery(form).attr({action: egw.webserverUrl+'/etemplate/empty.html',method:'post'});
form.submit();
}
};
/**
* Submit form via ajax
*
@ -661,6 +679,10 @@ etemplate2.prototype.submit = function(button, async, no_validation)
// Create the request object
if (this.menuaction)
{
//Autocomplete
this.autocomplete_fixer();
// unbind our session-destroy handler, as we are submitting
this.unbind_unload();

View File

@ -652,13 +652,13 @@ div.mailPreviewHeaders div.mail_extraEmails {
overflow: hidden;
text-overflow: ellipsis;
}
div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject {
#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject {
width: 58%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject > span {
#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject > span {
white-space: nowrap;
}
div.mailPreviewHeaders div.mail_extraEmails.visible,

View File

@ -652,13 +652,13 @@ div.mailPreviewHeaders div.mail_extraEmails {
overflow: hidden;
text-overflow: ellipsis;
}
div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject {
#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject {
width: 58%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject > span {
#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject > span {
white-space: nowrap;
}
div.mailPreviewHeaders div.mail_extraEmails.visible,
@ -893,23 +893,23 @@ iframe#mail-display_mailDisplayBodySrc {
body {
background-color: white;
}
div#mail-index {
#mail-index {
margin: 0 1% 0 0 !important;
}
div#mail-index div#mail-index_nm div.nextmatch_header div.filters select {
#mail-index div#mail-index_nm div.nextmatch_header div.filters select {
margin-top: 9px;
}
div#mail-index div#mail-index_nm div.nextmatch_header div.filters input#mail-index_search {
#mail-index div#mail-index_nm div.nextmatch_header div.filters input#mail-index_search {
/*height: 20px !important;*/
}
div#mail-index div#mail-index_nm tr.mail td img {
#mail-index div#mail-index_nm tr.mail td img {
height: 12px;
-webkit-box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
-moz-box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
border: 0px solid rgba(0, 0, 0, 0.9);
}
div#mail-index div#mail-index_nm tr.mail td img[src*="svg"] {
#mail-index div#mail-index_nm tr.mail td img[src*="svg"] {
background-color: #505050;
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxsaW5lYXJHcmFkaWVudCBpZD0iZzc0MyIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHgxPSIwJSIgeTE9IjAlIiB4Mj0iMCUiIHkyPSIxMDAlIj48c3RvcCBzdG9wLWNvbG9yPSIjNTA1MDUwIiBvZmZzZXQ9IjAiLz48c3RvcCBzdG9wLWNvbG9yPSIjNTA1MDUwIiBvZmZzZXQ9IjEiLz48L2xpbmVhckdyYWRpZW50PjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjZzc0MykiLz48L3N2Zz4=);
background-image: -moz-linear-gradient(top, #505050, #505050);
@ -920,38 +920,38 @@ div#mail-index div#mail-index_nm tr.mail td img[src*="svg"] {
background-image: linear-gradient(top, #505050, #505050);
background-repeat: repeat-x;
}
div#mail-index div#mail-index_nm tr.mail div span {
#mail-index div#mail-index_nm tr.mail div span {
height: 12px;
-webkit-box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
-moz-box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
}
div#mail-index div.splitter-bar,
div#mail-index div.splitter-bar-horizontal {
#mail-index div.splitter-bar,
#mail-index div.splitter-bar-horizontal {
background-color: #ffc200;
}
div#mail-index div#mail-index_mailPreview {
#mail-index div#mail-index_mailPreview {
margin: 0;
background-color: #fafafa;
}
div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersFrom {
#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersFrom {
width: 50%;
}
div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersTo {
#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersTo {
width: 50%;
}
div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersDate {
#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersDate {
position: absolute;
right: 0px;
margin: 3px 5px 0 0;
}
div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject {
#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject {
width: 58%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject > span {
#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubject > span {
white-space: nowrap;
}
/*##############################################

View File

@ -63,7 +63,7 @@ body {
div#mail-index{
#mail-index{
table.egwGridView_grid{
@ -353,7 +353,7 @@ div#mail-index{
background-color: @color_positive_action;
}

View File

@ -384,7 +384,7 @@ try{c.moveToPoint(a.clientX,a.clientY)}catch(e){}d.setEndPoint(f.compareEndPoint
if(CKEDITOR.env.version>7&&CKEDITOR.env.version<11)n.on("mousedown",function(a){if(a.data.getTarget().is("html")){g.on("mouseup",c);n.on("mouseup",c)}})}}k.attachListener(k,"selectionchange",a,d);k.attachListener(k,"keyup",e,d);k.attachListener(k,CKEDITOR.env.webkit?"DOMFocusIn":"focus",function(){d.forceNextSelectionCheck();d.selectionChange(1)});if(w&&(CKEDITOR.env.webkit||CKEDITOR.env.gecko)){var x;k.attachListener(k,"mousedown",function(){x=1});k.attachListener(f.getDocumentElement(),"mouseup",
function(){x&&e.call(d);x=0})}else k.attachListener(CKEDITOR.env.ie?k:f.getDocumentElement(),"mouseup",e,d);CKEDITOR.env.webkit&&k.attachListener(f,"keydown",function(a){switch(a.data.getKey()){case 13:case 33:case 34:case 35:case 36:case 37:case 39:case 8:case 45:case 46:h(k)}},null,null,-1);k.attachListener(k,"keydown",t(d),null,null,-1)});d.on("setData",function(){d.unlockSelection();CKEDITOR.env.webkit&&c()});d.on("contentDomUnload",function(){d.unlockSelection()});if(CKEDITOR.env.ie9Compat)d.on("beforeDestroy",
c,null,null,9);d.on("dataReady",function(){delete d._.fakeSelection;delete d._.hiddenSelectionContainer;d.selectionChange(1)});d.on("loadSnapshot",function(){var a=CKEDITOR.dom.walker.nodeType(CKEDITOR.NODE_ELEMENT),b=d.editable().getLast(a);if(b&&b.hasAttribute("data-cke-hidden-sel")){b.remove();if(CKEDITOR.env.gecko)(a=d.editable().getFirst(a))&&(a.is("br")&&a.getAttribute("_moz_editor_bogus_node"))&&a.remove()}},null,null,100);d.on("key",function(a){if(d.mode=="wysiwyg"){var b=d.getSelection();
if(b.isFake){var c=j[a.data.keyCode];if(c)return c({editor:d,selected:b.getSelectedElement(),selection:b,keyEvent:a})}}})});CKEDITOR.on("instanceReady",function(a){function b(){var a=e.editable();if(a)if(a=d(a)){var c=e.document.$.getSelection();if(c.type!="None"&&(c.anchorNode==a.$||c.focusNode==a.$))j=i(c);f=a.getText();a.setText(l(f))}}function c(){var a=e.editable();if(a)if(a=d(a)){a.setText(f);if(j){g(e.document.$,j);j=null}}}var e=a.editor,f,j;if(CKEDITOR.env.webkit){e.on("selectionChange",
if(b.isFake){var c=j[a.data.keyCode];if(c)return c({editor:d,selected:b.getSelectedElement(),selection:b,keyEvent:a})}}})});CKEDITOR.on("instanceReady",function(a){function b(){var a=e.editable();if(a)if(a=d(a)){var c=e.document.$.getSelection();if(c && c.type!="None"&&(c.anchorNode==a.$||c.focusNode==a.$))j=i(c);f=a.getText();a.setText(l(f))}}function c(){var a=e.editable();if(a)if(a=d(a)){a.setText(f);if(j){g(e.document.$,j);j=null}}}var e=a.editor,f,j;if(CKEDITOR.env.webkit){e.on("selectionChange",
function(){var a=e.editable(),b=d(a);b&&(b.getCustomData("ready")?h(a):b.setCustomData("ready",1))},null,null,-1);e.on("beforeSetMode",function(){h(e.editable())},null,null,-1);e.on("beforeUndoImage",b);e.on("afterUndoImage",c);e.on("beforeGetData",b,null,null,0);e.on("getData",c)}});CKEDITOR.editor.prototype.selectionChange=function(b){(b?a:e).call(this)};CKEDITOR.editor.prototype.getSelection=function(a){if((this._.savedSelection||this._.fakeSelection)&&!a)return this._.savedSelection||this._.fakeSelection;
return(a=this.editable())&&this.mode=="wysiwyg"?new CKEDITOR.dom.selection(a):null};CKEDITOR.editor.prototype.lockSelection=function(a){a=a||this.getSelection(1);if(a.getType()!=CKEDITOR.SELECTION_NONE){!a.isLocked&&a.lock();this._.savedSelection=a;return true}return false};CKEDITOR.editor.prototype.unlockSelection=function(a){var b=this._.savedSelection;if(b){b.unlock(a);delete this._.savedSelection;return true}return false};CKEDITOR.editor.prototype.forceNextSelectionCheck=function(){delete this._.selectionPreviousPath};
CKEDITOR.dom.document.prototype.getSelection=function(){return new CKEDITOR.dom.selection(this)};CKEDITOR.dom.range.prototype.select=function(){var a=this.root instanceof CKEDITOR.editable?this.root.editor.getSelection():new CKEDITOR.dom.selection(this.root);a.selectRanges([this]);return a};CKEDITOR.SELECTION_NONE=1;CKEDITOR.SELECTION_TEXT=2;CKEDITOR.SELECTION_ELEMENT=3;var u=typeof window.getSelection!="function",v=1;CKEDITOR.dom.selection=function(a){if(a instanceof CKEDITOR.dom.selection)var b=

View File

@ -272,7 +272,7 @@
// rest needs DOM to be ready
$j(function() {
// load etemplate2 template(s)
$j('div.et2_container[data-etemplate]').each(function(index, node){
$j('form.et2_container[data-etemplate]').each(function(index, node){
var data = JSON.parse(node.getAttribute('data-etemplate')) || {};
var currentapp = data.data.currentapp || window.egw_appName;
if(popup || window.opener)