/** * Gets the queued notifications. */ function getNotifications() { $.get(SITE_URL + 'ajax/get_notifications', function(data) { if (data.length > 0) { $('#notifications').append(data).slideDown(); } }); } /** * Asks the user if he is sure to delete an item. * * @param url */ function deleteConfirm(url) { var answer = confirm('Are you sure?'); if (answer) { window.location = url; } } /** * Saves the changes done by in-place edit. * * @param obj * @param cancel */ function saveChanges(obj, cancel) { var a; if (!cancel) { a = $(obj).parent().siblings(0).val(); $.post(SITE_URL + 'ajax/save_project', { content: a }, function(response) { alert("Die Änderungen wurden gespeichert."); }); } else { a = cancel; } $(obj).parent().parent().after('
)|(<\/p>)/g, "");
};
/**
* Similar to PHP's nl2br function.
*/
$.fn.nl2br = function() {
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
' : '
';
return $(this).html().replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
};
/*
* Tabs
*/
$(document).ready(function() {
$(".tab_content").hide(); // hide all content
$("ul.tabs li:first").addClass("active").show(); // activate first tab
$(".tab_content:first").show(); // show first tab content
// onClick event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); // remove any "active" class
$(this).addClass("active"); // add "active" class to selected tab
$(".tab_content").hide(); // hide all tab content
var activeTab = $(this).find("a").attr("href");
$(activeTab).fadeIn(); // fade in the active tab content
return false;
});
$('#notifications').hide();
getNotifications();
setInterval('getNotifications()', '5000');
});
/**
* Do some stuff if document is ready.
*/
$(document).ready(function() {
/*
* Tables
*/
var settings = {
table_class : 'tableList'
};
// add or delete "hover" class on mouseOver event
$('.' + settings.table_class + ' tbody tr').hover(function() {
$(this).addClass("hover");
}, function() {
$(this).removeClass("hover");
});
// add or delete "selected" class if a row is selected via checkbox
$('.' + settings.table_class + ' tbody input:checkbox').click(function() {
if ($(this).attr('checked') == true) {
$(this).parent().parent().addClass('selected');
} else {
$(this).parent().parent().removeClass('selected');
}
});
// alternate table rows
$('.' + settings.table_class).each(function() {
var table = $(this);
table.alternateRowColors(table);
});
/*
* Pagination
*/
$('.paginated').each(function() {
var currentPage = 0;
var numPerPage = 10;
var table = $(this);
table.bind('repaginate', function() {
var start = currentPage * numPerPage;
var end = (currentPage + 1) * numPerPage;
table.find('tbody tr').slice(start, end).show().end().slice(0, start).hide().end().slice(end).hide().end();
});
var numRows = table.find('tbody tr').length;
var numPages = Math.ceil(numRows / numPerPage);
var $pager = $('