Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Add the following lines to the following files:
To the bottom of the sites/all/themes/dpk_mobile/templates/page.tpl.php file, add the following lines:
<?php if ($user->uid == 0) { ?>
<div data-role="page" id="login" data-theme="<?php print $page_data_theme ?>">
<header data-role="header" data-position-"inline">
<h1>User Login</h1>
</header>
<div data-role="content" data-theme="<?php print $page_data_theme ?>">
<?php $form = drupal_get_form("user_login"); $form['#attributes']['data-ajax'] = "false"; echo drupal_render($form); ?>
<div class="ui-body ui-body-e" style="display:none;" id="form-errors"></div>
</div>
</div>
<?php } ?>
Edit the sites/all/themes/dpk_mobile/js/global.js file by adding the following lines:
Drupal.behaviors.jQMPageInit = {
attach: function(context) {
$("#user-login").not(".jQMPageInit-processed").submit(function(evt){
if (evt) { evt.preventDefault(); }
toSubmit = {
"username": $(this).find("#edit-name").val(),
"password": $(this).find("#edit-pass").val()
}
$.ajax({
url: "/rest/user/login.json",
dataType: "json",
data: toSubmit,
type: "post",
error: function(jqXHR, textStatus, errorThrown) {
$("#form-errors").html("There was an error logging you in").show();
},
complete: function(jqXHR, textStatus){
document.location.href = "/";
}
});
}).addClass("jQMPageInit-processed");
$("#user-logout").not(".jQMPageInit-processed").click(function(evt) {
if (evt) { evt.preventDefault(); }
$.mobile.showPageLoadingMsg();
document.location.href = "/user/logout";
}).addClass("jQMPageInit-processed");
},
detach: function(context){
}
}
Navigate to http://m.dpk.local. The login/logout process should work as expected.