MaketRandevu/doc/code/js/backend_users.js.html

232 lines
9.9 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: backend_users.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: backend_users.js</h1>
<section>
<article>
<pre class="prettyprint source"><code>/**
* This namespace handles the js functionality of the users backend page. It uses three other
* classes (defined below) in order to handle the admin, provider and secretary record types.
*
* @namespace BackendUsers
*/
var BackendUsers = {
MIN_PASSWORD_LENGTH: 7,
/**
* Contains the current tab record methods for the page.
*
* @type AdminsHelper|ProvidersHelper|SecretariesHelper
*/
helper: {},
/**
* Use this class instance for performing actions on the working plan.
*
* @type {object}
*/
wp: {},
/**
* Initialize the backend users page.
*
* @param {bool} defaultEventHandlers (OPTIONAL) Whether to bind the default event handlers
* (default: true).
*/
initialize: function(defaultEventHandlers) {
if (defaultEventHandlers == undefined) defaultEventHandlers = true;
// Initialize jScrollPane Scrollbars
$('#filter-admins .results').jScrollPane();
$('#filter-providers .results').jScrollPane();
$('#filter-secretaries .results').jScrollPane();
// Instanciate default helper object (admin).
BackendUsers.helper = new AdminsHelper();
BackendUsers.helper.resetForm();
BackendUsers.helper.filter('');
BackendUsers.wp = new WorkingPlan();
BackendUsers.wp.bindEventHandlers();
// Fill the services and providers list boxes.
$.each(GlobalVariables.services, function(index, service) {
var html = '&lt;label class="checkbox">&lt;input type="checkbox" data-id="' + service.id + '" />'
+ service.name + '&lt;/label>';
$('#provider-services').append(html);
});
$('#provider-services').jScrollPane({ mouseWheelSpeed: 70 });
$.each(GlobalVariables.providers, function(index, provider) {
var html = '&lt;label class="checkbox">&lt;input type="checkbox" data-id="' + provider.id + '" />'
+ provider.first_name + ' ' + provider.last_name + '&lt;/label>';
$('#secretary-providers').append(html);
});
$('#secretary-providers').jScrollPane({ mouseWheelSpeed: 70 });
$('#reset-working-plan').qtip({
position: {
my: 'top center',
at: 'bottom center'
},
style: {
classes: 'qtip-green qtip-shadow custom-qtip'
}
});
// Bind event handlers.
if (defaultEventHandlers) BackendUsers.bindEventHandlers();
},
/**
* Binds the defauly backend users event handlers. Do not use this method on a different
* page because it needs the backend users page DOM.
*/
bindEventHandlers: function() {
/**
* Event: Page Tab Button "Click"
*
* Changes the displayed tab.
*/
$('.tab').click(function() {
$(this).parent().find('.active').removeClass('active');
$(this).addClass('active');
$('.tab-content').hide();
if ($(this).hasClass('admins-tab')) { // display admins tab
$('#admins').show();
BackendUsers.helper = new AdminsHelper();
} else if ($(this).hasClass('providers-tab')) { // display providers tab
$('#providers').show();
$('#provider-services').data('jsp').destroy();
$('#provider-services').jScrollPane({ mouseWheelSpeed: 70 });
BackendUsers.helper = new ProvidersHelper();
} else if ($(this).hasClass('secretaries-tab')) { // display secretaries tab
$('#secretaries').show();
BackendUsers.helper = new SecretariesHelper();
// Update the list with the all the available providers.
var postUrl = GlobalVariables.baseUrl + 'backend_api/ajax_filter_providers';
var postData = { 'key': '' };
$.post(postUrl, postData, function(response) {
//////////////////////////////////////////////////////////
//console.log('Get all db providers response:', response);
//////////////////////////////////////////////////////////
if (!GeneralFunctions.handleAjaxExceptions(response)) return;
GlobalVariables.providers = response;
$('#secretary-providers').data('jsp').destroy();
$('#secretary-providers').html('');
$.each(GlobalVariables.providers, function(index, provider) {
var html = '&lt;label class="checkbox">&lt;input type="checkbox" data-id="' + provider.id + '" />'
+ provider.first_name + ' ' + provider.last_name + '&lt;/label>';
$('#secretary-providers').append(html);
});
$('#secretary-providers input[type="checkbox"]').prop('disabled', true);
$('#secretary-providers').jScrollPane({ mouseWheelSpeed: 70 });
}, 'json');
}
BackendUsers.helper.resetForm();
BackendUsers.helper.filter('');
$('.filter-key').val('');
});
/**
* Event: Admin, Provider, Secretary Username "Focusout"
*
* When the user leaves the username input field we will need to check if the username
* is not taken by another record in the system. Usernames must be unique.
*/
$('#admin-username, #provider-username, #secretary-username').focusout(function() {
var $input = $(this);
if ($input.prop('readonly') == true || $input.val() == '') {
return;
}
var postUrl = GlobalVariables.baseUrl + 'backend_api/ajax_validate_username';
var postData = {
'username': $input.val(),
'record_exists': ($input.parents().eq(2).find('.record-id').val() != '') ? true : false
};
$.post(postUrl, postData, function(response) {
///////////////////////////////////////////////////////
//console.log('Validate Username Response:', response);
///////////////////////////////////////////////////////
if (!GeneralFunctions.handleAjaxExceptions(response)) return;
if (response == false) {
$input.css('border', '2px solid red');
$input.parents().eq(3).find('.form-message').text('Username already exists.');
$input.parents().eq(3).find('.form-message').show();
} else {
$input.css('border', '');
if ($input.parents().eq(3).find('.form-message').text() == 'Username already exists.') {
$input.parents().eq(3).find('.form-message').hide();
}
}
}, 'json');
});
// ------------------------------------------------------------------------
AdminsHelper.prototype.bindEventHandlers();
// ------------------------------------------------------------------------
ProvidersHelper.prototype.bindEventHandlers();
// ------------------------------------------------------------------------
SecretariesHelper.prototype.bindEventHandlers();
// ------------------------------------------------------------------------
}
};</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="AdminsHelper.html">AdminsHelper</a></li><li><a href="CategoriesHelper.html">CategoriesHelper</a></li><li><a href="CustomersHelper.html">CustomersHelper</a></li><li><a href="ProvidersHelper.html">ProvidersHelper</a></li><li><a href="SecretariesHelper.html">SecretariesHelper</a></li><li><a href="ServicesHelper.html">ServicesHelper</a></li><li><a href="SystemSettings.html">SystemSettings</a></li><li><a href="UserSettings.html">UserSettings</a></li><li><a href="WorkingPlan.html">WorkingPlan</a></li></ul><h3>Namespaces</h3><ul><li><a href="Backend.html">Backend</a></li><li><a href="BackendCalendar.html">BackendCalendar</a></li><li><a href="BackendCustomers.html">BackendCustomers</a></li><li><a href="BackendServices.html">BackendServices</a></li><li><a href="BackendSettings.html">BackendSettings</a></li><li><a href="BackendUsers.html">BackendUsers</a></li><li><a href="FrontendBook.html">FrontendBook</a></li><li><a href="GeneralFunctions.html">GeneralFunctions</a></li></ul><h3>Global</h3><ul><li><a href="global.html#enableCancel">enableCancel</a></li><li><a href="global.html#enableSubmit">enableSubmit</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a> on Sat Oct 19 2013 11:58:41 GMT+0300 (EEST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>