This code deals with the variety of parameters that may be passed to a call to
pagination.
Line 5 tests to see whether the first parameter to the call is a string that doesn't start with an underscore (_) and is the name of a function in the internal methods object. If so, that method is invoked and passed the rest of the arguments to the pagination call. Thus it would handle method calls like:
- $(selector).pagination('enable');
- $(selector).pagination('option', 'name', value);
Line 7 tests for the first parameter being an object or absent altogether. If so, the internal init function is invoked and the parameters are passed through. This handles the initialisation of the plugin for a selection:
- $(selector).pagination();
- $(selector).pagination({option1: value1, option2: value2});
Line 9 handles the conditions not covered by the above two tests and raises an error.
To enable the pagination calls to be chained, it should return a reference to this (the current jQuery collection), but perhaps that is what init and the other internal functions already do.