"sSearch" : window.MSG_DT_SEARCH || "Search:",
"sZeroRecords" : window.MSG_DT_ZERO_RECORDS || "No matching records found"
},
- "sDom": '<"top pager"ilpf>t<"bottom pager"ip>'
+ "sDom": '<"top pager"ilpf>t<"bottom pager"ip>',
+ "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, window.MSG_DT_ALL || "All"]]
};
var table = this;
this.fnSetFilteringDelay(iDelay);
var filterTimerId = null;
- $("input."+sClass).keyup(function(event) {
+ $(table).find("input."+sClass).keyup(function(event) {
if (blacklist_keys.indexOf(event.keyCode) != -1) {
return this;
}else if ( event.keyCode == '13' ) {
}
} );
-}());
\ No newline at end of file
+}());
+
+/* Plugin to allow sorting on data stored in a span's title attribute
+ *
+ * Ex: <td><span title="[% ISO_date %]">[% formatted_date %]</span></td>
+ *
+ * In DataTables config:
+ * "aoColumns": [
+ * { "sType": "title-string" },
+ * ]
+ * http://datatables.net/plug-ins/sorting#hidden_title_string
+ */
+jQuery.extend( jQuery.fn.dataTableExt.oSort, {
+ "title-string-pre": function ( a ) {
+ return a.match(/title="(.*?)"/)[1].toLowerCase();
+ },
+
+ "title-string-asc": function ( a, b ) {
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
+ },
+
+ "title-string-desc": function ( a, b ) {
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
+ }
+} );
+
+/* Plugin to allow sorting on numeric data stored in a span's title attribute
+ *
+ * Ex: <td><span title="[% decimal_number_that_JS_parseFloat_accepts %]">
+ * [% formatted currency %]
+ * </span></td>
+ *
+ * In DataTables config:
+ * "aoColumns": [
+ * { "sType": "title-numeric" },
+ * ]
+ * http://datatables.net/plug-ins/sorting#hidden_title
+ */
+jQuery.extend( jQuery.fn.dataTableExt.oSort, {
+ "title-numeric-pre": function ( a ) {
+ var x = a.match(/title="*(-?[0-9\.]+)/)[1];
+ return parseFloat( x );
+ },
+
+ "title-numeric-asc": function ( a, b ) {
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
+ },
+
+ "title-numeric-desc": function ( a, b ) {
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
+ }
+} );
+
+(function() {
+
+ /* Plugin to allow text sorting to ignore articles
+ *
+ * In DataTables config:
+ * "aoColumns": [
+ * { "sType": "anti-the" },
+ * ]
+ * Based on the plugin found here:
+ * http://datatables.net/plug-ins/sorting#anti_the
+ * Modified to exclude HTML tags from sorting
+ * Extended to accept a string of space-separated articles
+ * from a configuration file (in English, "a," "an," and "the")
+ */
+
+ if(CONFIG_EXCLUDE_ARTICLES_FROM_SORT){
+ var articles = CONFIG_EXCLUDE_ARTICLES_FROM_SORT.split(" ");
+ var rpattern = "";
+ for(i=0;i<articles.length;i++){
+ rpattern += "^" + articles[i] + " ";
+ if(i < articles.length - 1){ rpattern += "|"; }
+ }
+ var re = new RegExp(rpattern, "i");
+ }
+
+ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
+ "anti-the-pre": function ( a ) {
+ var x = String(a).replace( /<[\s\S]*?>/g, "" );
+ var y = x.trim();
+ var z = y.replace(re, "").toLowerCase();
+ return z;
+ },
+
+ "anti-the-asc": function ( a, b ) {
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
+ },
+
+ "anti-the-desc": function ( a, b ) {
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
+ }
+ });
+
+}());
+
+// Remove string between NSB NSB characters
+$.fn.dataTableExt.oSort['nsb-nse-asc'] = function(a,b) {
+ var pattern = new RegExp("\x88.*\x89");
+ a = a.replace(pattern, "");
+ b = b.replace(pattern, "");
+ return (a > b) ? 1 : ((a < b) ? -1 : 0);
+}
+$.fn.dataTableExt.oSort['nsb-nse-desc'] = function(a,b) {
+ var pattern = new RegExp("\x88.*\x89");
+ a = a.replace(pattern, "");
+ b = b.replace(pattern, "");
+ return (b > a) ? 1 : ((b < a) ? -1 : 0);
+}
+
+/* Define two custom functions (asc and desc) for basket callnumber sorting */
+jQuery.fn.dataTableExt.oSort['callnumbers-asc'] = function(x,y) {
+ var x_array = x.split("<div>");
+ var y_array = y.split("<div>");
+
+ /* Pop the first elements, they are empty strings */
+ x_array.shift();
+ y_array.shift();
+
+ x_array = jQuery.map( x_array, function( a ) {
+ return parse_callnumber( a );
+ });
+ y_array = jQuery.map( y_array, function( a ) {
+ return parse_callnumber( a );
+ });
+
+ x_array.sort();
+ y_array.sort();
+
+ x = x_array.shift();
+ y = y_array.shift();
+
+ if ( !x ) { x = ""; }
+ if ( !y ) { y = ""; }
+
+ return ((x < y) ? -1 : ((x > y) ? 1 : 0));
+};
+
+jQuery.fn.dataTableExt.oSort['callnumbers-desc'] = function(x,y) {
+ var x_array = x.split("<div>");
+ var y_array = y.split("<div>");
+
+ /* Pop the first elements, they are empty strings */
+ x_array.shift();
+ y_array.shift();
+
+ x_array = jQuery.map( x_array, function( a ) {
+ return parse_callnumber( a );
+ });
+ y_array = jQuery.map( y_array, function( a ) {
+ return parse_callnumber( a );
+ });
+
+ x_array.sort();
+ y_array.sort();
+
+ x = x_array.pop();
+ y = y_array.pop();
+
+ if ( !x ) { x = ""; }
+ if ( !y ) { y = ""; }
+
+ return ((x < y) ? 1 : ((x > y) ? -1 : 0));
+};
+
+function parse_callnumber ( html ) {
+ var array = html.split('<span class="callnumber">');
+ if ( array[1] ) {
+ array = array[1].split('</span>');
+ return array[0];
+ } else {
+ return "";
+ }
+}