Skip to content

Commit

Permalink
mobileInitCallback() should no longer be needed.
Browse files Browse the repository at this point in the history
All of these actions can be done in the base mobile.php page.
  • Loading branch information
slusarz committed Apr 2, 2012
1 parent eace04a commit ea074f8
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 115 deletions.
26 changes: 0 additions & 26 deletions ansel/lib/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,30 +196,4 @@ public function prefsSpecialUpdate($ui, $item)
return false;
}

/**
* Callback, called from common-template-mobile.inc that sets up the jquery
* mobile init hanler.
*/
public function mobileInitCallback()
{
require ANSEL_TEMPLATES . '/mobile/javascript_defs.php';

$page_output = $GLOBALS['injector']->getInstance('Horde_PageOutput');

$page_output->addScriptFile('mobile.js');
$page_output->addInlineScript(
'$(window.document).bind("mobileinit", function() {
$.mobile.page.prototype.options.backBtnText = "' . _("Back") .'";
$.mobile.loadingMessage = "' . _("loading") . '";
// TODO: Figure out how to force load the gallerylist page..
// this does not work
//$("#imageview").live("pagebeforeshow", function() {
// if (!AnselMobile.currentImage) {
// $.mobile.changePage("gallerylist", "slide", false, true);
// }
//});
});'
);
}

}
11 changes: 10 additions & 1 deletion ansel/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@
$view->portal = Horde::getServiceLink('portal', 'horde')->setRaw(false);
$view->logout = Horde::getServiceLink('logout')->setRaw(false);

require $registry->get('templates', 'horde') . '/common-header-mobile.inc';
require ANSEL_TEMPLATES . '/mobile/javascript_defs.php';

$page_output->addScriptFile('mobile.js');
// TODO: Figure out how to force load the gallerylist page.
$page_output->addInlineScript(
'$(window.document).bind("mobileinit", function() {
$.mobile.page.prototype.options.backBtnText = "' . _("Back") .'";
$.mobile.loadingMessage = "' . _("loading") . '";
});'
);

echo $view->render('head');
echo $view->render('galleries');
Expand Down
3 changes: 0 additions & 3 deletions framework/Core/lib/Horde/PageOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,6 @@ public function header(array $opts = array())
$this->addScriptFile('jquery.mobile/jquery.min.js', 'horde');
$this->addScriptFile('horde-jquery.js', 'horde');
$this->addScriptFile('mobile.js', 'horde');

$registry->callAppMethod($registry->getApp(), 'mobileInitCallback');

$this->addScriptFile('jquery.mobile/jquery.mobile.min.js', 'horde');

$this->addMetaTag('viewport', 'width=device-width, minimum-scale=1, maximum-scale=1');
Expand Down
26 changes: 0 additions & 26 deletions imp/lib/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,30 +586,4 @@ public function changeLanguage()
$GLOBALS['injector']->getInstance('IMP_Imap_Tree')->init();
}

/* Helper methods. */

/**
* Callback, called from common-template-mobile.inc that sets up the jquery
* mobile init handler.
*/
public function mobileInitCallback()
{
$page_output = $GLOBALS['injector']->getInstance('Horde_PageOutput');
$page_output->addScriptFile('mobile.js');

require IMP_TEMPLATES . '/mobile/javascript_defs.php';

$GLOBALS['notification']->notify(array('listeners' => 'status'));

/* Inline script. */
$page_output->addInlineScript(
'$(window.document).bind("mobileinit", function() {
$.mobile.page.prototype.options.addBackBtn = true;
$.mobile.page.prototype.options.backBtnText = "' . _("Back") .'";
$.mobile.dialog.prototype.options.closeBtnText = "' . _("Close") .'";
$.mobile.loadingMessage = "' . _("loading") . '";
});'
);
}

}
14 changes: 14 additions & 0 deletions imp/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@
$view->composeLink->pathInfo = 'addAttachment';
}

$page_output->addScriptFile('mobile.js');
require IMP_TEMPLATES . '/mobile/javascript_defs.php';
$notification->notify(array('listeners' => 'status'));

/* Inline script. */
$page_output->addInlineScript(
'$(window.document).bind("mobileinit", function() {
$.mobile.page.prototype.options.addBackBtn = true;
$.mobile.page.prototype.options.backBtnText = "' . _("Back") .'";
$.mobile.dialog.prototype.options.closeBtnText = "' . _("Close") .'";
$.mobile.loadingMessage = "' . _("loading") . '";
});'
);

$page_output->header(array(
'title' => _("Mobile Mail"),
'view' => $registry::VIEW_SMARTMOBILE
Expand Down
58 changes: 0 additions & 58 deletions kronolith/lib/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,64 +599,6 @@ public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
}
}

/**
* Callback, called from common-template-mobile.inc that sets up the jquery
* mobile init hanler.
*/
public function mobileInitCallback()
{
$datejs = str_replace('_', '-', $GLOBALS['language']) . '.js';
if (!file_exists($GLOBALS['registry']->get('jsfs', 'horde') . '/date/' . $datejs)) {
$datejs = 'en-US.js';
}

$page_output = $GLOBALS['injector']->getInstance('Horde_PageOutput');
$page_output->addScriptFile('date/' . $datejs, 'horde');
$page_output->addScriptFile('date/date.js', 'horde');
$page_output->addScriptFile('mobile.js');
require KRONOLITH_TEMPLATES . '/mobile/javascript_defs.php';

/* Inline script. */
$page_output->addInlineScript(
'$(window.document).bind("mobileinit", function() {
$.mobile.page.prototype.options.addBackBtn = true;
$.mobile.page.prototype.options.backBtnText = "' . _("Back") .'";
$.mobile.loadingMessage = "' . _("loading") . '";
// Setup event bindings to populate views on pagebeforeshow
KronolithMobile.date = new Date();
$("#dayview").live("pagebeforeshow", function() {
KronolithMobile.view = "day";
$(".kronolithDayDate").html(KronolithMobile.date.toString("ddd") + " " + KronolithMobile.date.toString("d"));
KronolithMobile.loadEvents(KronolithMobile.date, KronolithMobile.date, "day");
});
$("#monthview").live("pagebeforeshow", function(event, ui) {
KronolithMobile.view = "month";
// (re)build the minical only if we need to
if (!$(".kronolithMinicalDate").data("date") ||
($(".kronolithMinicalDate").data("date").toString("M") != KronolithMobile.date.toString("M"))) {
KronolithMobile.moveToMonth(KronolithMobile.date);
}
});
$("#eventview").live("pageshow", function(event, ui) {
KronolithMobile.view = "event";
});
// Set up overview
$("#overview").live("pageshow", function(event, ui) {
KronolithMobile.view = "overview";
if (!KronolithMobile.haveOverview) {
KronolithMobile.loadEvents(KronolithMobile.date, KronolithMobile.date.clone().addDays(7), "overview");
KronolithMobile.haveOverview = true;
}
});
});'
);
}

/* Alarm method. */

/**
Expand Down
50 changes: 49 additions & 1 deletion kronolith/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,55 @@
$view->portal = Horde::getServiceLink('portal', 'horde')->setRaw(false);
$view->logout = Horde::getServiceLink('logout')->setRaw(false);

require $registry->get('templates', 'horde') . '/common-header-mobile.inc';
$datejs = str_replace('_', '-', $GLOBALS['language']) . '.js';
if (!file_exists($GLOBALS['registry']->get('jsfs', 'horde') . '/date/' . $datejs)) {
$datejs = 'en-US.js';
}

$page_output->addScriptFile('date/' . $datejs, 'horde');
$page_output->addScriptFile('date/date.js', 'horde');
$page_output->addScriptFile('mobile.js');
require KRONOLITH_TEMPLATES . '/mobile/javascript_defs.php';

/* Inline script. */
$page_output->addInlineScript(
'$(window.document).bind("mobileinit", function() {
$.mobile.page.prototype.options.addBackBtn = true;
$.mobile.page.prototype.options.backBtnText = "' . _("Back") .'";
$.mobile.loadingMessage = "' . _("loading") . '";
// Setup event bindings to populate views on pagebeforeshow
KronolithMobile.date = new Date();
$("#dayview").live("pagebeforeshow", function() {
KronolithMobile.view = "day";
$(".kronolithDayDate").html(KronolithMobile.date.toString("ddd") + " " + KronolithMobile.date.toString("d"));
KronolithMobile.loadEvents(KronolithMobile.date, KronolithMobile.date, "day");
});
$("#monthview").live("pagebeforeshow", function(event, ui) {
KronolithMobile.view = "month";
// (re)build the minical only if we need to
if (!$(".kronolithMinicalDate").data("date") ||
($(".kronolithMinicalDate").data("date").toString("M") != KronolithMobile.date.toString("M"))) {
KronolithMobile.moveToMonth(KronolithMobile.date);
}
});
$("#eventview").live("pageshow", function(event, ui) {
KronolithMobile.view = "event";
});
// Set up overview
$("#overview").live("pageshow", function(event, ui) {
KronolithMobile.view = "overview";
if (!KronolithMobile.haveOverview) {
KronolithMobile.loadEvents(KronolithMobile.date, KronolithMobile.date.clone().addDays(7), "overview");
KronolithMobile.haveOverview = true;
}
});
});'
);

$page_outpt->header(array(
'title' => $title,
'view' => $registry::VIEW_SMARTMOBILE
));

echo $view->render('head');
echo $view->render('day');
Expand Down

0 comments on commit ea074f8

Please sign in to comment.