Clean-up javascript files

This commit is contained in:
Eike Foken
2011-08-15 23:25:24 +02:00
parent e1f3b8da54
commit cc134691ac
2 changed files with 46 additions and 45 deletions

View File

@@ -67,35 +67,35 @@ $.fn.nl2br = function() {
return $(this).html().replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2'); 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. * Do some stuff if document is ready.
*/ */
$(document).ready(function() { $(document).ready(function() {
/*
* Tabs
*/
$('.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;
});
/*
* Notification stuff
*/
$('#notifications').hide();
getNotifications();
setInterval('getNotifications()', '5000');
/* /*
* Tables * Tables
*/ */
@@ -103,14 +103,14 @@ $(document).ready(function() {
table_class : 'tableList' table_class : 'tableList'
}; };
// add or delete "hover" class on mouseOver event // add or delete 'hover' class on mouseOver event
$('.' + settings.table_class + ' tbody tr').hover(function() { $('.' + settings.table_class + ' tbody tr').hover(function() {
$(this).addClass("hover"); $(this).addClass('hover');
}, function() { }, function() {
$(this).removeClass("hover"); $(this).removeClass('hover');
}); });
// add or delete "selected" class if a row is selected via checkbox // add or delete 'selected' class if a row is selected via checkbox
$('.' + settings.table_class + ' tbody input:checkbox').click(function() { $('.' + settings.table_class + ' tbody input:checkbox').click(function() {
if ($(this).attr('checked') == true) { if ($(this).attr('checked') == true) {
$(this).parent().parent().addClass('selected'); $(this).parent().parent().addClass('selected');
@@ -198,6 +198,9 @@ $(document).ready(function() {
$(this).removeClass('editable'); $(this).removeClass('editable');
}); });
/*
* Active project selection
*/
$('select[name="activeProject"]').bind('change', function () { $('select[name="activeProject"]').bind('change', function () {
var url = $(this).val(); var url = $(this).val();
if (url) { if (url) {

View File

@@ -5,7 +5,7 @@
* Licensed like jQuery, see http://docs.jquery.com/License. * Licensed like jQuery, see http://docs.jquery.com/License.
* *
* Configuration options: * Configuration options:
* *
* onDragStyle * onDragStyle
* This is the style that is assigned to the row during drag. There are limitations to the styles that can be * This is the style that is assigned to the row during drag. There are limitations to the styles that can be
* associated with a row (such as you can't assign a border--well you can, but it won't be * associated with a row (such as you can't assign a border--well you can, but it won't be
@@ -28,7 +28,7 @@
* Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the * Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
* table and the row which the user has started to drag. * table and the row which the user has started to drag.
* onAllowDrop * onAllowDrop
* Pass a function that will be called as a row is over another row. If the function returns true, allow * Pass a function that will be called as a row is over another row. If the function returns true, allow
* dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under * dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
* the cursor. It returns a boolean: true allows the drop, false doesn't allow it. * the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
* scrollAmount * scrollAmount
@@ -40,7 +40,7 @@
* specify this class, then you are responsible for setting cursor: move in the CSS and only these cells * specify this class, then you are responsible for setting cursor: move in the CSS and only these cells
* will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where * will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where
* the whole row is draggable. * the whole row is draggable.
* *
* Other ways to control behaviour: * Other ways to control behaviour:
* *
* Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
@@ -52,7 +52,7 @@
* *
* Other methods: * Other methods:
* *
* $("...").tableDnDUpdate() * $("...").tableDnDUpdate()
* Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells). * Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells).
* This is useful if you have updated the table rows using Ajax and you want to make the table draggable again. * This is useful if you have updated the table rows using Ajax and you want to make the table draggable again.
* The table maintains the original configuration (so you don't have to specify it again). * The table maintains the original configuration (so you don't have to specify it again).
@@ -63,7 +63,7 @@
* *
* Known problems: * Known problems:
* - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0 * - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
* *
* Version 0.2: 2008-02-20 First public version * Version 0.2: 2008-02-20 First public version
* Version 0.3: 2008-02-07 Added onDragStart option * Version 0.3: 2008-02-07 Added onDragStart option
* Made the scroll amount configurable (default is 5 as before) * Made the scroll amount configurable (default is 5 as before)
@@ -136,7 +136,7 @@ jQuery.tableDnD = {
} }
return false; return false;
}); });
}) });
} else { } else {
// For backwards compatibility, we add the event to the whole row // For backwards compatibility, we add the event to the whole row
var rows = jQuery("tr", table); // get all the rows as a wrapped set var rows = jQuery("tr", table); // get all the rows as a wrapped set
@@ -167,7 +167,7 @@ jQuery.tableDnD = {
if (this.tableDnDConfig) { if (this.tableDnDConfig) {
jQuery.tableDnD.makeDraggable(this); jQuery.tableDnD.makeDraggable(this);
} }
}) });
}, },
/** Get the mouse coordinates from the event (allowing for browser differences) */ /** Get the mouse coordinates from the event (allowing for browser differences) */
@@ -241,7 +241,7 @@ jQuery.tableDnD = {
} }
} }
if (mousePos.y-yOffset < config.scrollAmount) { if (mousePos.y-yOffset < config.scrollAmount) {
window.scrollBy(0, -config.scrollAmount); window.scrollBy(0, -config.scrollAmount);
} else { } else {
@@ -371,12 +371,10 @@ jQuery.tableDnD = {
return result; return result;
} }
} };
jQuery.fn.extend( jQuery.fn.extend({
{ tableDnD : jQuery.tableDnD.build,
tableDnD : jQuery.tableDnD.build, tableDnDUpdate : jQuery.tableDnD.updateTables,
tableDnDUpdate : jQuery.tableDnD.updateTables, tableDnDSerialize: jQuery.tableDnD.serializeTables
tableDnDSerialize: jQuery.tableDnD.serializeTables });
}
);