From: Jan Schneider Date: Tue, 16 Nov 2010 18:01:30 +0000 (+0100) Subject: Basic mailbox loading, no server data loading yet. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=39aa5405c3708459514b2bbb8db43e37deec31f9;p=horde.git Basic mailbox loading, no server data loading yet. --- diff --git a/imp/js/mobile.js b/imp/js/mobile.js new file mode 100644 index 000000000..12a31b56f --- /dev/null +++ b/imp/js/mobile.js @@ -0,0 +1,86 @@ +/** + * jQuery Mobile UI application logic. + * + * Copyright 2005-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + */ + +/* ImpMobile object. */ +var ImpMobile = { + + /** + * Perform an Ajax action + * + * @param string action The AJAX request + * @param object params The parameter hash + * @param function callback The callback function + */ + doAction: function(action, params, callback) + { + $.post(IMP.conf.URI_AJAX + action, params, callback, 'json'); + }, + + /** + * Switches to the mailbox view and loads a mailbox. + * + * @param string mailbox A mailbox name. + * @param string label A mailbox label. + */ + toMailbox: function(mailbox, label) + { + $('#imp-mailbox-header').text(label); + $.mobile.changePage('#mailbox', 'slide', false, true); + }, + + /** + * Catch-all event handler for the click event. + * + * @param object e An event object. + */ + clickHandler: function(e) + { + var elt = $(e.target), + orig = $(e.target), + id; + + while (elt) { + id = elt.attr('id'); + + switch (id) { + } + + if (elt.hasClass('imp-folder')) { + var link = elt.find('a[mailbox]'); + ImpMobile.toMailbox(link.attr('mailbox'), link.text()); + break; + } + + elt = elt.parent(); + } + }, + + /** + * Event handlder for the document-ready event, responsible for the inital + * setup. + */ + onDocumentReady: function() + { + // Global ajax options. + $.ajaxSetup({ + dataFilter: function(data, type) + { + // Remove json security token + filter = /^\/\*-secure-([\s\S]*)\*\/s*$/; + return data.replace(filter, "$1"); + } + }); + + $(document).click(ImpMobile.clickHandler); + } + +}; + +// JQuery Mobile setup +$(ImpMobile.onDocumentReady); diff --git a/imp/mobile.php b/imp/mobile.php index 2cad3be02..d07de7062 100644 --- a/imp/mobile.php +++ b/imp/mobile.php @@ -39,6 +39,7 @@ $view->logout = Horde::getServiceLink('logout')->setRaw(false); $title = _("Mobile Mail"); require $registry->get('templates', 'horde') . '/common-header-mobile.inc'; +include IMP_TEMPLATES . '/mobile/javascript_defs.php'; echo $view->render('head.html.php'); if (!empty($conf['user']['allow_folders'])) { echo $view->render('folders.html.php'); diff --git a/imp/templates/mobile/head.html.php b/imp/templates/mobile/head.html.php index 9ca38d24a..1d0cc9cae 100644 --- a/imp/templates/mobile/head.html.php +++ b/imp/templates/mobile/head.html.php @@ -1,3 +1,4 @@ + diff --git a/imp/templates/mobile/javascript_defs.php b/imp/templates/mobile/javascript_defs.php new file mode 100644 index 000000000..f98b17717 --- /dev/null +++ b/imp/templates/mobile/javascript_defs.php @@ -0,0 +1,55 @@ +getInstance('IMP_Imap_Flags')->getList(array('fgcolor' => true)) as $val) { + $flags[$val['flag']] = array_filter(array( + 'b' => isset($val['b']) ? $val['b'] : null, + 'c' => $val['c'], + 'f' => $val['f'], + 'l' => $val['l'], + 'n' => isset($val['n']) ? $val['n'] : null, + // Indicate if this is a user *P*ref flag + 'p' => intval($val['t'] == 'imapp'), + // Indicate if this is a flag that can be *S*earched for + 's' => intval(in_array($val['t'], array('imapp', 'imapu'))) + )); +} + +/* Variables used in core javascript files. */ +$code['conf'] = array_filter(array( + // URL variables + 'URI_AJAX' => Horde::getServiceLink('ajax', 'imp')->url, + 'URI_COMPOSE' => strval(Horde::url('compose-dimp.php')->setRaw(true)->add('ajaxui', 1)), + 'URI_DIMP' => strval(Horde::url('index-dimp.php')), + 'URI_MESSAGE' => strval(Horde::url('message-dimp.php')->setRaw(true)->add('ajaxui', 1)), + 'URI_PREFS_IMP' => strval(Horde::getServiceLink('prefs', 'imp')->setRaw(true)->add('ajaxui', 1)), + 'URI_SEARCH' => strval(Horde::url('search.php')), + 'URI_VIEW' => strval(Horde::url('view.php')), + + 'IDX_SEP' => IMP_Dimp::IDX_SEP, + 'SESSION_ID' => defined('SID') ? SID : '', + + // Other variables + 'flags' => $flags, + /* Needed to maintain flag ordering. */ + 'flags_o' => array_keys($flags), + 'refresh_time' => intval($GLOBALS['prefs']->getValue('refresh_time')), +)); + +/* Gettext strings used in core javascript files. */ +$code['text'] = array( +); + +Horde::addInlineJsVars(array( + 'var IMP' => $code +), array('top' => true)); diff --git a/imp/templates/mobile/mailbox.html.php b/imp/templates/mobile/mailbox.html.php index 2598c5151..797744d7a 100644 --- a/imp/templates/mobile/mailbox.html.php +++ b/imp/templates/mobile/mailbox.html.php @@ -3,7 +3,7 @@ allowFolders): ?> -

+

logout): ?>