Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 29 additions & 25 deletions postmaster/static/js/admins.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,13 @@ function deleteAdmin (id) {
});
}


// Sets the event listeners in the dynamic table
function adminEventListeners () {
// Sets the event listeners for x-editable
function editableAdminEventListeners() {

var adminUsername = $('a.adminUsername');
var adminPassword = $('a.adminPassword');
var adminName = $('a.adminName');
var deleteModal = $('#deleteModal');
var deleteModalBtn = $('#modalDeleteBtn');
var newItemAnchor = $('#newItemAnchor');

adminUsername.unbind();
adminPassword.unbind();
adminName.unbind();
Expand Down Expand Up @@ -142,20 +139,39 @@ function adminEventListeners () {
addStatusMessage('success', 'The administrator\'s name was changed successfully');
}
});
}

// Sets the event listeners in the dynamic table
function adminEventListeners () {

var deleteModal = $('#deleteModal');
var deleteModalBtn = $('#modalDeleteBtn');
var newItemAnchor = $('#newItemAnchor');

// When hitting the back/forward buttons, reload the table
$(window).bind("popstate", function () {
fillInTable();
});

// Set the filter event listener
var typeWatchOptions = {
callback: function () { fillInTable() },
wait: 750,
captureLength: 2
};

$('#filterRow input').typeWatch(typeWatchOptions);

deleteModal.unbind('show.bs.modal');
deleteModal.on('show.bs.modal', function (e) {
deleteModalBtn.attr('data-pk', $(e.relatedTarget).data('pk'));
});

deleteModalBtn.unbind('click');
deleteModalBtn.on('click', function (e) {
deleteModal.modal('hide');
deleteAdmin($(this).attr('data-pk'));
});

// When the Add button is clicked, it will POST to the API
newItemAnchor.unbind();
newItemAnchor.on('click', function (e) {

// Close any status messages
Expand Down Expand Up @@ -197,7 +213,6 @@ function adminEventListeners () {
});

var newAdminInputs = $('#newAdminInput, #newAdminPasswordInput, #newAdminNameInput');
newAdminInputs.unbind();
// When the user clicks out of the errored input field, the red border disappears
newAdminInputs.blur(function () {
$('#newAdminInput').parent().removeClass('has-error');
Expand Down Expand Up @@ -249,7 +264,7 @@ function fillInTable () {
result['meta']['pages'] == 0 ? pages = 1 : pages = result['meta']['pages'];
setPagination(result['meta']['page'], pages, 'admins');
//Activate x-editable on new elements and other events
adminEventListeners();
editableAdminEventListeners();
// Remove the loading spinner
manageSpinner(false);
})
Expand All @@ -268,20 +283,9 @@ $(document).ready(function () {
// This stops the browser from caching AJAX (fixes IE)
$.ajaxSetup({ cache: false });

// Sets the default event listeners
adminEventListeners();

// Populate the table
fillInTable();

// When hitting the back/forward buttons, reload the table
$(window).bind("popstate", function () {
fillInTable();
});

// Set the filter event listener
var typeWatchOptions = {
callback: function () { fillInTable() },
wait: 750,
captureLength: 2
};

$('#filterRow input').typeWatch(typeWatchOptions);
});
52 changes: 29 additions & 23 deletions postmaster/static/js/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ function deleteAlias (id) {
}


// Sets the event listeners in the dynamic table
function aliasEventListeners() {
// Sets the event listeners for x-editable
function editableAliasEventListeners() {

var sourceAlias = $('a.sourceAlias');
var destinationAlias = $('a.destinationAlias');
var deleteAnchor = $('a.deleteAnchor');
var newItemAnchor = $('#newItemAnchor');

sourceAlias.unbind();
sourceAlias.tooltip();
Expand All @@ -76,16 +74,35 @@ function aliasEventListeners() {
addStatusMessage('success', 'The destination alias was changed successfully');
}
});
}

// Sets the event listeners in the dynamic table
function aliasEventListeners() {

deleteAnchor.unbind();
deleteAnchor.on('click', function (e) {
var sourceAlias = $('a.sourceAlias');
var destinationAlias = $('a.destinationAlias');
var newItemAnchor = $('#newItemAnchor');

// When hitting the back/forward buttons, reload the table
$(window).bind("popstate", function () {
fillInTable();
});

// Set the filter event listener
var typeWatchOptions = {
callback: function () { fillInTable() },
wait: 750,
captureLength: 2
};

$('#filterRow input').typeWatch(typeWatchOptions);

$('#dynamicTable').on('click', 'a.deleteAnchor', function (e) {
deleteAlias($(this).attr('data-pk'));
e.preventDefault();
});

// When the Add button is clicked, it will POST to the API
newItemAnchor.unbind();
newItemAnchor.on('click', function (e) {

// Close any status messages
Expand Down Expand Up @@ -169,7 +186,7 @@ function fillInTable () {
result['meta']['pages'] == 0 ? pages = 1 : pages = result['meta']['pages'];
setPagination(result['meta']['page'], pages, 'aliases');
//Activate x-editable on new elements and other events
aliasEventListeners();
editableAliasEventListeners();
// Remove the loading spinner
manageSpinner(false);
})
Expand All @@ -188,8 +205,8 @@ $(document).ready(function () {
// This stops the browser from caching AJAX (fixes IE)
$.ajaxSetup({ cache: false });

// Populate the table
fillInTable();
// Sets the default event listeners
aliasEventListeners();

// Set the defaults for x-editable
$.fn.editable.defaults.mode = 'inline';
Expand All @@ -210,17 +227,6 @@ $(document).ready(function () {
$(this).html(filterText(value.toLowerCase()));
};

// When hitting the back/forward buttons, reload the table
$(window).bind("popstate", function () {
fillInTable();
});

// Set the filter event listener
var typeWatchOptions = {
callback: function () { fillInTable() },
wait: 750,
captureLength: 2
};

$('#filterRow input').typeWatch(typeWatchOptions);
// Populate the table
fillInTable();
});
37 changes: 17 additions & 20 deletions postmaster/static/js/domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,31 @@ function domainEventListeners() {
var deleteModal = $('#deleteModal');
var deleteModalBtn = $('#modalDeleteBtn');
var newDomainInput = $('#newDomainInput');

// When hitting the back/forward buttons, reload the table
$(window).bind("popstate", function () {
fillInTable();
});

// Set the filter event listener
var typeWatchOptions = {
callback: function () { fillInTable() },
wait: 750,
captureLength: 2
};

$('#filterRow input').typeWatch(typeWatchOptions);

deleteModal.unbind('show.bs.modal');
deleteModal.on('show.bs.modal', function (e) {
deleteModalBtn.attr('data-pk', $(e.relatedTarget).data('pk'));
});

deleteModalBtn.unbind('click');
deleteModalBtn.on('click', function (e) {
deleteModal.modal('hide');
deleteDomain($(this).attr('data-pk'));
});

// When the Add button is clicked, it will POST to the API
newItemAnchor.unbind();
newItemAnchor.on('click', function (e) {

// Close any status messages
Expand All @@ -94,7 +105,6 @@ function domainEventListeners() {
});

// When the user clicks out of the errored input field, the red border disappears
newDomainInput.unbind();
newDomainInput.blur(function () {
newDomainInput.parent().removeClass('has-error');
});
Expand Down Expand Up @@ -141,8 +151,6 @@ function fillInTable(filter) {
// Set the pagination
result['meta']['pages'] == 0 ? pages = 1 : pages = result['meta']['pages'];
setPagination(result['meta']['page'], pages, 'domains');
// Reactive all event listeners
domainEventListeners();
// Remove the loading spinner
manageSpinner(false);
})
Expand All @@ -161,20 +169,9 @@ $(document).ready(function () {
// This stops the browser from caching AJAX (fixes IE)
$.ajaxSetup({ cache: false });

// Sets the default event listeners
domainEventListeners();

// Populate the table
fillInTable();

// When hitting the back/forward buttons, reload the table
$(window).bind("popstate", function () {
fillInTable();
});

// Set the filter event listener
var typeWatchOptions = {
callback: function () { fillInTable() },
wait: 750,
captureLength: 2
};

$('#filterRow input').typeWatch(typeWatchOptions);
});
Loading