Subversion-Projekte lars-tiefland.zeldi.de_alt

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
/**
2
 * This modification of DataTables' standard two button pagination controls
3
 * adds a little animation effect to the paging action by redrawing the table
4
 * multiple times for each event, each draw progressing by one row until the
5
 * required point in the table is reached.
6
 *
7
 *  @name Scrolling navigation
8
 *  @summary Show page changes as a redraw of the table, scrolling records.
9
 *  @author [Allan Jardine](http://sprymedia.co.uk)
10
 *
11
 *  @example
12
 *    $(document).ready(function() {
13
 *        $('#example').dataTable( {
14
 *            "sPaginationType": "scrolling"
15
 *        } );
16
 *    } );
17
 */
18
 
19
 
20
/* Time between each scrolling frame */
21
$.fn.dataTableExt.oPagination.iTweenTime = 100;
22
 
23
$.fn.dataTableExt.oPagination.scrolling = {
24
	"fnInit": function ( oSettings, nPaging, fnCallbackDraw )
25
	{
26
		var oLang = oSettings.oLanguage.oPaginate;
27
		var oClasses = oSettings.oClasses;
28
		var fnClickHandler = function ( e ) {
29
			if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
30
			{
31
				fnCallbackDraw( oSettings );
32
			}
33
		};
34
 
35
		var sAppend = (!oSettings.bJUI) ?
36
			'<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sPrevious+'</a>'+
37
			'<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sNext+'</a>'
38
			:
39
			'<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUIPrev+'"></span></a>'+
40
			'<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUINext+'"></span></a>';
41
		$(nPaging).append( sAppend );
42
 
43
		var els = $('a', nPaging);
44
		var nPrevious = els[0],
45
			nNext = els[1];
46
 
47
		oSettings.oApi._fnBindAction( nPrevious, {action: "previous"}, function() {
48
			/* Disallow paging event during a current paging event */
49
			if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 )
50
			{
51
				return;
52
			}
53
 
54
			oSettings.iPagingLoopStart = oSettings._iDisplayStart;
55
			oSettings.iPagingEnd = oSettings._iDisplayStart - oSettings._iDisplayLength;
56
 
57
			/* Correct for underrun */
58
			if ( oSettings.iPagingEnd < 0 )
59
			{
60
				oSettings.iPagingEnd = 0;
61
			}
62
 
63
			var iTween = $.fn.dataTableExt.oPagination.iTweenTime;
64
			var innerLoop = function () {
65
				if ( oSettings.iPagingLoopStart > oSettings.iPagingEnd ) {
66
					oSettings.iPagingLoopStart--;
67
					oSettings._iDisplayStart = oSettings.iPagingLoopStart;
68
					fnCallbackDraw( oSettings );
69
					setTimeout( function() { innerLoop(); }, iTween );
70
				} else {
71
					oSettings.iPagingLoopStart = -1;
72
				}
73
			};
74
			innerLoop();
75
		} );
76
 
77
		oSettings.oApi._fnBindAction( nNext, {action: "next"}, function() {
78
			/* Disallow paging event during a current paging event */
79
			if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 )
80
			{
81
				return;
82
			}
83
 
84
			oSettings.iPagingLoopStart = oSettings._iDisplayStart;
85
 
86
			/* Make sure we are not over running the display array */
87
			if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
88
			{
89
				oSettings.iPagingEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
90
			}
91
 
92
			var iTween = $.fn.dataTableExt.oPagination.iTweenTime;
93
			var innerLoop = function () {
94
				if ( oSettings.iPagingLoopStart < oSettings.iPagingEnd ) {
95
					oSettings.iPagingLoopStart++;
96
					oSettings._iDisplayStart = oSettings.iPagingLoopStart;
97
					fnCallbackDraw( oSettings );
98
					setTimeout( function() { innerLoop(); }, iTween );
99
				} else {
100
					oSettings.iPagingLoopStart = -1;
101
				}
102
			};
103
			innerLoop();
104
		} );
105
	},
106
 
107
	"fnUpdate": function ( oSettings, fnCallbackDraw )
108
	{
109
		if ( !oSettings.aanFeatures.p )
110
		{
111
			return;
112
		}
113
 
114
		/* Loop over each instance of the pager */
115
		var an = oSettings.aanFeatures.p;
116
		for ( var i=0, iLen=an.length ; i<iLen ; i++ )
117
		{
118
			if ( an[i].childNodes.length !== 0 )
119
			{
120
				an[i].childNodes[0].className =
121
					( oSettings._iDisplayStart === 0 ) ?
122
					oSettings.oClasses.sPagePrevDisabled : oSettings.oClasses.sPagePrevEnabled;
123
 
124
				an[i].childNodes[1].className =
125
					( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
126
					oSettings.oClasses.sPageNextDisabled : oSettings.oClasses.sPageNextEnabled;
127
			}
128
		}
129
	}
130
};