From 8613267cabf7146a81489a6aa8f7688d60ed8321 Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 23 Feb 2005 00:00:54 +0000 Subject: [PATCH] added incremental searches without page refreshes git-svn-id: http://svn.opengroupware.org/SOGo/trunk@607 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/MailerUI/ChangeLog | 4 + SOGo/UI/MailerUI/GNUmakefile | 2 + SOGo/UI/MailerUI/UIxMailFilterPanel.m | 13 +- SOGo/UI/MailerUI/UIxMailListView.m | 6 + SOGo/UI/MailerUI/Version | 2 +- SOGo/UI/MailerUI/generic.js | 112 +++++++++++ SOGo/UI/MailerUI/mailer.js | 181 +----------------- SOGo/UI/MailerUI/product.plist | 2 + SOGo/UI/MailerUI/searchfield.js | 105 ++++++++++ .../Templates/MailerUI/UIxMailFilterPanel.wox | 10 +- .../UI/Templates/MailerUI/UIxMailListView.wox | 14 +- .../Templates/MailerUI/UIxMailMainFrame.wox | 4 +- 12 files changed, 267 insertions(+), 188 deletions(-) create mode 100644 SOGo/UI/MailerUI/generic.js create mode 100644 SOGo/UI/MailerUI/searchfield.js diff --git a/SOGo/UI/MailerUI/ChangeLog b/SOGo/UI/MailerUI/ChangeLog index 2228fc61..b49c02e6 100644 --- a/SOGo/UI/MailerUI/ChangeLog +++ b/SOGo/UI/MailerUI/ChangeLog @@ -1,3 +1,7 @@ +2005-02-23 Helge Hess + + * mailer.js: split into multiple files (v0.9.121) + 2005-02-22 Helge Hess * UIxMailMainFrame.m: added ability not to generate the HTML frame diff --git a/SOGo/UI/MailerUI/GNUmakefile b/SOGo/UI/MailerUI/GNUmakefile index 655daefd..fc5bfd7c 100644 --- a/SOGo/UI/MailerUI/GNUmakefile +++ b/SOGo/UI/MailerUI/GNUmakefile @@ -49,6 +49,8 @@ MailerUI_RESOURCE_FILES += \ uix.css \ mailer.css \ mailer.js \ + generic.js \ + searchfield.js \ MailerUI_RESOURCE_FILES += \ Images/tbtv_*.gif \ diff --git a/SOGo/UI/MailerUI/UIxMailFilterPanel.m b/SOGo/UI/MailerUI/UIxMailFilterPanel.m index 6004bb0d..f0a76e64 100644 --- a/SOGo/UI/MailerUI/UIxMailFilterPanel.m +++ b/SOGo/UI/MailerUI/UIxMailFilterPanel.m @@ -24,6 +24,10 @@ @interface UIxMailFilterPanel : WOComponent { NSString *searchText; + struct { + int hideFrame:1; + int reserved:31; + } mfFlags; } @end @@ -75,6 +79,13 @@ static NSDictionary *filterToQualifier = nil; /* accessors */ +- (void)setHideFrame:(BOOL)_flag { + self->mfFlags.hideFrame = _flag ? 1 : 0; +} +- (BOOL)hideFrame { + return self->mfFlags.hideFrame ? YES : NO; +} + - (void)setSearchText:(NSString *)_txt { ASSIGNCOPY(self->searchText, _txt); } @@ -82,7 +93,7 @@ static NSDictionary *filterToQualifier = nil; if (self->searchText == nil) { // TODO: kinda hack self->searchText = - [[[[self context] request] formValueForKey:@"searchtext"] copy]; + [[[[self context] request] formValueForKey:@"search"] copy]; } return self->searchText; } diff --git a/SOGo/UI/MailerUI/UIxMailListView.m b/SOGo/UI/MailerUI/UIxMailListView.m index 85683e80..f8a2f102 100644 --- a/SOGo/UI/MailerUI/UIxMailListView.m +++ b/SOGo/UI/MailerUI/UIxMailListView.m @@ -63,6 +63,12 @@ static int attachmentFlagSize = 8096; [super dealloc]; } +/* frame */ + +- (BOOL)hideFrame { + return [[[[self context] request] formValueForKey:@"noframe"] boolValue]; +} + /* notifications */ - (void)sleep { diff --git a/SOGo/UI/MailerUI/Version b/SOGo/UI/MailerUI/Version index e5c391c6..327f9cad 100644 --- a/SOGo/UI/MailerUI/Version +++ b/SOGo/UI/MailerUI/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=120 +SUBMINOR_VERSION:=121 # v0.9.100 requires libNGMime v4.5.213 # v0.9.99 requires libNGMime v4.5.212 diff --git a/SOGo/UI/MailerUI/generic.js b/SOGo/UI/MailerUI/generic.js new file mode 100644 index 00000000..8cb97c5b --- /dev/null +++ b/SOGo/UI/MailerUI/generic.js @@ -0,0 +1,112 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ +/* some generic JavaScript code for SOGo */ + +/* generic stuff */ + +function ml_stripActionInURL(url) { + if (url[url.length - 1] != '/') { + var i; + + i = url.lastIndexOf("/"); + if (i != -1) url = url.substring(0, i); + } + if (url[url.length - 1] != '/') // ensure trailing slash + url = url + "/"; + return url; +} + +function escapeHTML(s) { + s = s.replace(/&/g, "&"); + s = s.replace(//g, ">"); + s = s.replace(/"/g, """); + return s; +} +function unescapeHTML(s) { + s = s.replace(/</g, "<"); + s = s.replace(/>/g, ">"); + s = s.replace(/"/g, '"'); + s = s.replace(/&/g, "&"); + return s; +} + +function createHTTPClient() { + // http://developer.apple.com/internet/webcontent/xmlhttpreq.html + if (typeof XMLHttpRequest != "undefined") + return new XMLHttpRequest(); + + try { return new ActiveXObject("Msxml2.XMLHTTP"); } + catch (e) { } + try { return new ActiveXObject("Microsoft.XMLHTTP"); } + catch (e) { } + return null; +} + +function resetSelection(win) { + var t = ""; + if (win && win.getSelection) { + t = win.getSelection().toString(); + win.getSelection().removeAllRanges(); + } + return t; +} + +function refreshOpener() { + if (window.opener && !window.opener.closed) { + window.opener.location.reload(); + } +} + +function getQueryParaArray(s) { + if (s.charAt(0) == "?") s = s.substr(1, s.length - 1); + return s.split("&"); +} +function getQueryParaValue(s, name) { + var t; + + t = getQueryParaArray(s); + for (var i = 0; i < t.length; i++) { + var s = t[i]; + + if (s.indexOf(name) != 0) + continue; + + s = s.substr(name.length, s.length - name.length); + return decodeURIComponent(s); + } + return null; +} + +function triggerOpenerCallback() { + /* this code has some issue if the folder has no proper trailing slash! */ + if (window.opener && !window.opener.closed) { + var t, cburl; + + t = getQueryParaValue(window.location.search, "openerurl="); + cburl = window.opener.location.href; + if (cburl[cburl.length - 1] != "/") { + cburl = cburl.substr(0, cburl.lastIndexOf("/") + 1); + } + cburl = cburl + t; + window.opener.location.href = cburl; + } +} diff --git a/SOGo/UI/MailerUI/mailer.js b/SOGo/UI/MailerUI/mailer.js index b97829f4..7c6e9ad2 100644 --- a/SOGo/UI/MailerUI/mailer.js +++ b/SOGo/UI/MailerUI/mailer.js @@ -74,7 +74,7 @@ function collectSelectedRows() { } function clearSearch(sender) { - var searchField = window.document.getElementById("searchtext"); + var searchField = window.document.getElementById("search"); if (searchField) searchField.value=""; return true; } @@ -191,97 +191,6 @@ function clickedNewFilter(sender) { return false; /* stop following the link */ } -/* generic stuff */ - -function ml_stripActionInURL(url) { - if (url[url.length - 1] != '/') { - var i; - - i = url.lastIndexOf("/"); - if (i != -1) url = url.substring(0, i); - } - if (url[url.length - 1] != '/') // ensure trailing slash - url = url + "/"; - return url; -} - -function escapeHTML(s) { - s = s.replace(/&/g, "&"); - s = s.replace(//g, ">"); - s = s.replace(/"/g, """); - return s; -} -function unescapeHTML(s) { - s = s.replace(/</g, "<"); - s = s.replace(/>/g, ">"); - s = s.replace(/"/g, '"'); - s = s.replace(/&/g, "&"); - return s; -} - -function createHTTPClient() { - // http://developer.apple.com/internet/webcontent/xmlhttpreq.html - if (typeof XMLHttpRequest != "undefined") - return new XMLHttpRequest(); - - try { return new ActiveXObject("Msxml2.XMLHTTP"); } - catch (e) { } - try { return new ActiveXObject("Microsoft.XMLHTTP"); } - catch (e) { } - return null; -} - -function resetSelection(win) { - var t = ""; - if (win && win.getSelection) { - t = win.getSelection().toString(); - win.getSelection().removeAllRanges(); - } - return t; -} - -function refreshOpener() { - if (window.opener && !window.opener.closed) { - window.opener.location.reload(); - } -} - -function getQueryParaArray(s) { - if (s.charAt(0) == "?") s = s.substr(1, s.length - 1); - return s.split("&"); -} -function getQueryParaValue(s, name) { - var t; - - t = getQueryParaArray(s); - for (var i = 0; i < t.length; i++) { - var s = t[i]; - - if (s.indexOf(name) != 0) - continue; - - s = s.substr(name.length, s.length - name.length); - return decodeURIComponent(s); - } - return null; -} - -function triggerOpenerCallback() { - /* this code has some issue if the folder has no proper trailing slash! */ - if (window.opener && !window.opener.closed) { - var t, cburl; - - t = getQueryParaValue(window.location.search, "openerurl="); - cburl = window.opener.location.href; - if (cburl[cburl.length - 1] != "/") { - cburl = cburl.substr(0, cburl.lastIndexOf("/") + 1); - } - cburl = cburl + t; - window.opener.location.href = cburl; - } -} - /* mail list DOM changes */ function markMailInWindow(win, msguid, markread) { @@ -385,91 +294,3 @@ function ml_lowlight(sender) { else sender.className = "tableview"; } - - -/* search field */ - -var didStop = false; -var field = null; -var firstValue = ""; -var isRegistered = false; -var lastKeyPress = null; -var submitAfterMS = 500; - -function ml_reloadTableView(searchtext, elementid) { - var http = createHTTPClient(); - - if (http) { - var viewURL, url; - var hasQueryPara; - - viewURL = this.location.href; - hasQueryPara = viewURL.indexOf("?") == -1 ? false : true; - url = viewURL.replace(/\/tb\.view/, "/tb.view?noframe=1"); - url = url + (hasQueryPara ? "&search=" : "?search=") + searchtext; - - http.open("GET", url, false); - http.send(null); - if (http.status != 200) { - alert("Could not reload view."); - } - else { - var tv; - - tv = document.getElementById(elementid) - tv.innerHTML = http.responseText; - } - } -} - -function ml_reloadSearchIfFieldChanged() { - if (field) { - if (field.value != firstValue) { - // TODO: we should just reload the tableview, not the whole page - //document.pageform.submit(); - ml_reloadTableView(field.value, "cl_tableview_reloadroot"); - } - } -} - -function ml_timeoutCallback() { - if (didStop) { - didStop = false; - return; - } - - var now = new Date().getTime(); - if ((now - lastKeyPress) < submitAfterMS) { - setTimeout("ml_timeoutCallback()", 10); - isRegistered = true; - return; - } - - ml_reloadSearchIfFieldChanged(); - isRegistered = false; -} - -function ml_activateSearchField(sender, _submitTimeout) { - didStop = false; - field = sender; - firstValue = field.value; - submitAfterMS = _submitTimeout; - return true; -} -function ml_deactivateSearchField(sender) { - didStop = true; - field = null; - firstValue = ""; - return true; -} - -function ml_searchFieldKeyPressed(sender) { - lastKeyPress = new Date().getTime(); - - if (isRegistered) - return; - - setTimeout("ml_timeoutCallback()", 10); - isRegistered = true; - return true; -} diff --git a/SOGo/UI/MailerUI/product.plist b/SOGo/UI/MailerUI/product.plist index df20f0bd..3d334677 100644 --- a/SOGo/UI/MailerUI/product.plist +++ b/SOGo/UI/MailerUI/product.plist @@ -5,6 +5,8 @@ "uix.css", "mailer.css", "mailer.js", + "generic.js", + "searchfield.js", "lori_32x32.png", diff --git a/SOGo/UI/MailerUI/searchfield.js b/SOGo/UI/MailerUI/searchfield.js new file mode 100644 index 00000000..22f9dc6f --- /dev/null +++ b/SOGo/UI/MailerUI/searchfield.js @@ -0,0 +1,105 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ +/* JavaScript for SOGo Mailer */ + +var didStop = false; +var field = null; +var firstValue = ""; +var isRegistered = false; +var lastKeyPress = null; +var submitAfterMS = 500; + +function ml_reloadTableView(searchtext, elementid) { + var http = createHTTPClient(); + + if (http) { + var viewURL, url; + var hasQueryPara; + + // TODO: properly parse query parameters + viewURL = this.location.href; + hasQueryPara = viewURL.indexOf("?") == -1 ? false : true; + url = viewURL + "?noframe=1&search=" + searchtext; + + http.open("GET", url, false); + http.send(null); + if (http.status != 200) { + alert("Could not reload view."); + } + else { + var tv; + + tv = document.getElementById(elementid) + tv.innerHTML = http.responseText; + } + } +} + +function ml_reloadSearchIfFieldChanged() { + if (field) { + if (field.value != firstValue) { + ml_reloadTableView(field.value, "cl_tableview_reloadroot"); + firstValue = field.value; + } + } +} + +function ml_timeoutCallback() { + if (didStop) { + didStop = false; + return; + } + + var now = new Date().getTime(); + if ((now - lastKeyPress) < submitAfterMS) { + setTimeout("ml_timeoutCallback()", 10); + isRegistered = true; + return; + } + + ml_reloadSearchIfFieldChanged(); + isRegistered = false; +} + +function ml_activateSearchField(sender, _submitTimeout) { + didStop = false; + field = sender; + firstValue = field.value; + submitAfterMS = _submitTimeout; + return true; +} +function ml_deactivateSearchField(sender) { + didStop = true; + field = null; + firstValue = ""; + return true; +} + +function ml_searchFieldKeyPressed(sender) { + lastKeyPress = new Date().getTime(); + + if (isRegistered) + return; + + setTimeout("ml_timeoutCallback()", 10); + isRegistered = true; + return true; +} diff --git a/SOGo/UI/Templates/MailerUI/UIxMailFilterPanel.wox b/SOGo/UI/Templates/MailerUI/UIxMailFilterPanel.wox index 709c418e..7adf6a5d 100644 --- a/SOGo/UI/Templates/MailerUI/UIxMailFilterPanel.wox +++ b/SOGo/UI/Templates/MailerUI/UIxMailFilterPanel.wox @@ -1,4 +1,10 @@ + + :
-
+
+
diff --git a/SOGo/UI/Templates/MailerUI/UIxMailListView.wox b/SOGo/UI/Templates/MailerUI/UIxMailListView.wox index 567a6cca..af5a2d81 100644 --- a/SOGo/UI/Templates/MailerUI/UIxMailListView.wox +++ b/SOGo/UI/Templates/MailerUI/UIxMailListView.wox @@ -8,9 +8,12 @@ xmlns:label="OGo:label" className="UIxMailMainFrame" title="panelTitle" + hideFrame="hideFrame" > - + +
+ + + diff --git a/SOGo/UI/Templates/MailerUI/UIxMailMainFrame.wox b/SOGo/UI/Templates/MailerUI/UIxMailMainFrame.wox index 7ecb19af..6e80dcf9 100644 --- a/SOGo/UI/Templates/MailerUI/UIxMailMainFrame.wox +++ b/SOGo/UI/Templates/MailerUI/UIxMailMainFrame.wox @@ -21,7 +21,9 @@ - + + + -- 2.39.5