Skip to content

Commit

Permalink
Fix Datatable settings
Browse files Browse the repository at this point in the history
created a common JS datatable settings for all standard datatables to use..

fixed dataTable to DataTable
  • Loading branch information
DawoudIO committed Jul 3, 2017
1 parent 8403c75 commit 291bf93
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 150 deletions.
6 changes: 1 addition & 5 deletions src/CartView.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,7 @@ function codename()

<script type="text/javascript">
$(document).ready(function() {
$("#cart-listing-table").DataTable({
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
}
});
$("#cart-listing-table").DataTable(window.CRM.plugin.dataTable);
});
</script>

Expand Down
10 changes: 1 addition & 9 deletions src/Checkin.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,7 @@ class="direct-chat-img initials-image">&nbsp
<script language="javascript" type="text/javascript">
var perArr;
$(document).ready(function () {
$('#checkedinTable').dataTable({
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
},
responsive: true,
"dom": "<'row'<'col-md-6'i><'col-md-6'f>>" +
'rt<"bottom"lp><"clear">'

});
$('#checkedinTable').DataTable(window.CRM.plugin.dataTable);
});

$(document).ready(function() {
Expand Down
11 changes: 1 addition & 10 deletions src/EventNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,7 @@
<script type="text/javascript">
$(document).ready(function () {
//Added by @saulowulhynek to translation of datatable nav terms
$('#eventNames').dataTable({
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
},
responsive: true,
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "//cdn.datatables.net/tabletools/2.2.3/swf/copy_csv_xls_pdf.swf"
}
});
$('#eventNames').DataTable(window.CRM.plugin.dataTable);
});
</script>

Expand Down
11 changes: 1 addition & 10 deletions src/FamilyList.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,7 @@

<script type="text/javascript">
$(document).ready(function () {
$('#families').dataTable({
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
},
responsive: true,
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "//cdn.datatables.net/tabletools/2.2.3/swf/copy_csv_xls_pdf.swf"
}
});
$('#families').DataTable(window.CRM.plugin.dataTable);
});
</script>

Expand Down
154 changes: 83 additions & 71 deletions src/Include/Header-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ function Header_system_notifications()
{
if (NotificationService::hasActiveNotifications()) {
?>
<div class="systemNotificationBar">
<?php
foreach (NotificationService::getNotifications() as $notification) {
echo "<a href=\"".$notification->link."\">".$notification->title."</a>";
} ?>
</div>
<?php
<div class="systemNotificationBar">
<?php
foreach (NotificationService::getNotifications() as $notification) {
echo "<a href=\"" . $notification->link . "\">" . $notification->title . "</a>";
} ?>
</div>
<?php
}
}

Expand Down Expand Up @@ -77,7 +77,7 @@ function Header_modals()
<div class="row">
<div class="col-xl-3">
<label
for="issueTitle"><?= gettext('Enter a Title for your bug / feature report') ?>
for="issueTitle"><?= gettext('Enter a Title for your bug / feature report') ?>
: </label>
</div>
<div class="col-xl-3">
Expand All @@ -87,7 +87,7 @@ function Header_modals()
<div class="row">
<div class="col-xl-3">
<label
for="issueDescription"><?= gettext('What were you doing when you noticed the bug / feature opportunity?') ?></label>
for="issueDescription"><?= gettext('What were you doing when you noticed the bug / feature opportunity?') ?></label>
</div>
<div class="col-xl-3">
<textarea rows="10" cols="50" name="issueDescription"></textarea>
Expand Down Expand Up @@ -120,15 +120,27 @@ function Header_body_scripts()
global $localeInfo;
$systemService = new SystemService(); ?>
<script>
window.CRM = {
root: "<?= SystemURLs::getRootPath() ?>",
lang: "<?= $localeInfo->getLanguageCode() ?>",
locale: "<?= $localeInfo->getLocale() ?>",
maxUploadSize: "<?= $systemService->getMaxUploadFileSize(true) ?>",
maxUploadSizeBytes: "<?= $systemService->getMaxUploadFileSize(false) ?>"
};
window.CRM = {
root: "<?= SystemURLs::getRootPath() ?>",
lang: "<?= $localeInfo->getLanguageCode() ?>",
locale: "<?= $localeInfo->getLocale() ?>",
maxUploadSize: "<?= $systemService->getMaxUploadFileSize(true) ?>",
maxUploadSizeBytes: "<?= $systemService->getMaxUploadFileSize(false) ?>",
plugin: {
dataTable : {
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
},
responsive: true,
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "//cdn.datatables.net/tabletools/2.2.3/swf/copy_csv_xls_pdf.swf"
}
}
}
};
</script>
<script src="<?= SystemURLs::getRootPath()?>/skin/js/CRMJSOM.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/js/CRMJSOM.js"></script>
<?php
}

Expand Down Expand Up @@ -201,59 +213,59 @@ function addMenu($menu)

function addMenuItem($aMenu, $mIdx)
{
global $security_matrix;
global $security_matrix;

$link = ($aMenu['uri'] == '') ? '' : SystemURLs::getRootPath() . '/' . $aMenu['uri'];
$text = $aMenu['statustext'];
if (!is_null($aMenu['session_var'])) {
if (($link > '') && ($aMenu['session_var_in_uri']) && isset($_SESSION[$aMenu['session_var']])) {
if (strstr($link, '?') && true) {
$cConnector = '&';
} else {
$cConnector = '?';
}
$link .= $cConnector . $aMenu['url_parm_name'] . '=' . $_SESSION[$aMenu['session_var']];
}
if (($text > '') && ($aMenu['session_var_in_text']) && isset($_SESSION[$aMenu['session_var']])) {
$text .= ' ' . $_SESSION[$aMenu['session_var']];
$link = ($aMenu['uri'] == '') ? '' : SystemURLs::getRootPath() . '/' . $aMenu['uri'];
$text = $aMenu['statustext'];
if (!is_null($aMenu['session_var'])) {
if (($link > '') && ($aMenu['session_var_in_uri']) && isset($_SESSION[$aMenu['session_var']])) {
if (strstr($link, '?') && true) {
$cConnector = '&';
} else {
$cConnector = '?';
}
$link .= $cConnector . $aMenu['url_parm_name'] . '=' . $_SESSION[$aMenu['session_var']];
}
if ($aMenu['ismenu']) {
$sSQL = "SELECT name
if (($text > '') && ($aMenu['session_var_in_text']) && isset($_SESSION[$aMenu['session_var']])) {
$text .= ' ' . $_SESSION[$aMenu['session_var']];
}
}
if ($aMenu['ismenu']) {
$sSQL = "SELECT name
FROM menuconfig_mcf
WHERE parent = '" . $aMenu['name'] . "' AND active=1 " . $security_matrix . '
ORDER BY sortorder';

$rsItemCnt = RunQuery($sSQL);
$numItems = mysqli_num_rows($rsItemCnt);
}
if (!($aMenu['ismenu']) || ($numItems > 0)) {
if ($link) {
if ($aMenu['name'] != 'sundayschool-dash') { // HACK to remove the sunday school 2nd dashboard
$rsItemCnt = RunQuery($sSQL);
$numItems = mysqli_num_rows($rsItemCnt);
}
if (!($aMenu['ismenu']) || ($numItems > 0)) {
if ($link) {
if ($aMenu['name'] != 'sundayschool-dash') { // HACK to remove the sunday school 2nd dashboard
echo "<li><a href='$link'>";
if ($aMenu['icon'] != '') {
echo '<i class="fa ' . $aMenu['icon'] . '"></i>';
}
if ($aMenu['parent'] != 'root') {
echo '<i class="fa fa-angle-double-right"></i> ';
}
if ($aMenu['parent'] == 'root') {
echo '<span>' . gettext($aMenu['content']) . '</span></a>';
} else {
echo gettext($aMenu['content']) . '</a>';
}
}
if ($aMenu['icon'] != '') {
echo '<i class="fa ' . $aMenu['icon'] . '"></i>';
}
if ($aMenu['parent'] != 'root') {
echo '<i class="fa fa-angle-double-right"></i> ';
}
if ($aMenu['parent'] == 'root') {
echo '<span>' . gettext($aMenu['content']) . '</span></a>';
} else {
echo "<li class=\"treeview\">\n";
echo " <a href=\"#\">\n";
if ($aMenu['icon'] != '') {
echo '<i class="fa ' . $aMenu['icon'] . "\"></i>\n";
}
echo '<span>' . gettext($aMenu['content']) . "</span>\n";
echo "<i class=\"fa fa-angle-left pull-right\"></i>\n";
if ($aMenu['name'] == 'deposit') {
echo '<small class="badge pull-right bg-green">' . $_SESSION['iCurrentDeposit'] . "</small>\n";
} ?> </a>
echo gettext($aMenu['content']) . '</a>';
}
}
} else {
echo "<li class=\"treeview\">\n";
echo " <a href=\"#\">\n";
if ($aMenu['icon'] != '') {
echo '<i class="fa ' . $aMenu['icon'] . "\"></i>\n";
}
echo '<span>' . gettext($aMenu['content']) . "</span>\n";
echo "<i class=\"fa fa-angle-left pull-right\"></i>\n";
if ($aMenu['name'] == 'deposit') {
echo '<small class="badge pull-right bg-green">' . $_SESSION['iCurrentDeposit'] . "</small>\n";
} ?> </a>
<ul class="treeview-menu">
<?php
if ($aMenu['name'] == 'sundayschool') {
Expand All @@ -264,20 +276,20 @@ function addMenuItem($aMenu, $mIdx)
echo "<li><a href='" . SystemURLs::getRootPath() . '/sundayschool/SundaySchoolClassView.php?groupId=' . $aRow[grp_ID] . "'><i class='fa fa-angle-double-right'></i> " . gettext($aRow[grp_Name]) . '</a></li>';
}
}
}
if (($aMenu['ismenu']) && ($numItems > 0)) {
echo "\n";
addMenu($aMenu['name']);
echo "</ul>\n</li>\n";
} else {
echo "</li>\n";
}
}
if (($aMenu['ismenu']) && ($numItems > 0)) {
echo "\n";
addMenu($aMenu['name']);
echo "</ul>\n</li>\n";
} else {
echo "</li>\n";
}

return true;
return true;
} else {
return false;
}
}
}

function create_side_nav($menu)
{
Expand Down
11 changes: 1 addition & 10 deletions src/ListEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,7 @@
<script type="text/javascript">
//Added by @saulowulhynek to translation of datatable nav terms
$(document).ready(function () {
$('#listEvents').dataTable({
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
},
responsive: true,
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "//cdn.datatables.net/tabletools/2.2.3/swf/copy_csv_xls_pdf.swf"
}
});
$('#listEvents').DataTable(window.CRM.plugin.dataTable});
});
</script>

Expand Down
10 changes: 2 additions & 8 deletions src/PersonView.php
Original file line number Diff line number Diff line change
Expand Up @@ -971,14 +971,8 @@ function GroupAdd() {
$("#input-volunteer-opportunities").select2();
$("#input-person-properties").select2();

var options = {
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
},
"responsive": true
};
$("#assigned-volunteer-opps-table").DataTable(options);
$("#assigned-properties-table").DataTable(options);
$("#assigned-volunteer-opps-table").DataTable(window.CRM.plugin.dataTable);
$("#assigned-properties-table").DataTable(window.CRM.plugin.dataTable);


contentExists(window.CRM.root + "/api/persons/" + person_ID + "/photo", function(success) {
Expand Down
6 changes: 1 addition & 5 deletions src/UserList.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@

<script type="text/javascript">
$(document).ready(function () {
$("#user-listing-table").DataTable({
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
}
});
$("#user-listing-table").DataTable(window.CRM.plugin.dataTable);
});

function deleteUser(userId, userName) {
Expand Down
7 changes: 1 addition & 6 deletions src/skin/js/FamilyView.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
$(document).ready(function () {

var options = {
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
}
};
$("#pledge-payment-table").DataTable(options);
$("#pledge-payment-table").DataTable(window.CRM.plugin.dataTable);


$("#onlineVerify").click(function () {
Expand Down
11 changes: 1 addition & 10 deletions src/sundayschool/SundaySchoolClassView.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,7 @@ class="fa fa-envelope"></i><?= gettext('Send Message') ?></button>
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {

var dataTable = $('.data-table').dataTable({
"dom": 'T<"clear">lfrtip',
responsive: true,
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
},
"tableTools": {
"sSwfPath": "//cdn.datatables.net/tabletools/2.2.3/swf/copy_csv_xls_pdf.swf"
}
});
var dataTable = $('.data-table').DataTable(window.CRM.plugin.dataTable);

// turn the element to select2 select style
$('.email-recepients-kids').select2({
Expand Down
7 changes: 1 addition & 6 deletions src/sundayschool/SundaySchoolDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,7 @@ class="fa fa-file-excel-o"></i><?= gettext('Export to CSV') ?></a><br/>
</div>
<script type="application/javascript">
$(document).ready(function () {
$('.data-table').dataTable({
responsive: true,
"language": {
"url": window.CRM.root + "/skin/locale/datatables/" + window.CRM.locale + ".json"
}
});
$('.data-table').DataTable(window.CRM.plugin.dataTable);

$("#addNewClassBtn").click(function (e) {
var groupName = $("#new-class-name").val(); // get the name of the from the textbox
Expand Down

0 comments on commit 291bf93

Please sign in to comment.