View | Details | Raw Unified | Return to bug 15481
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js (-88 lines)
Lines 135-168 jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay Link Here
135
    });
135
    });
136
}
136
}
137
137
138
// Useful if you want to filter on dates with 2 inputs (start date and end date)
139
// You have to include calendar.inc to use it
140
function dt_add_rangedate_filter(begindate_id, enddate_id, dateCol) {
141
    $.fn.dataTableExt.afnFiltering.push(
142
        function( oSettings, aData, iDataIndex ) {
143
144
            var beginDate = Date_from_syspref($("#"+begindate_id).val()).getTime();
145
            var endDate   = Date_from_syspref($("#"+enddate_id).val()).getTime();
146
147
            var data = Date_from_syspref(aData[dateCol]).getTime();
148
149
            if ( !parseInt(beginDate) && ! parseInt(endDate) ) {
150
                return true;
151
            }
152
            else if ( beginDate <= data && !parseInt(endDate) ) {
153
                return true;
154
            }
155
            else if ( data <= endDate && !parseInt(beginDate) ) {
156
                return true;
157
            }
158
            else if ( beginDate <= data && data <= endDate) {
159
                return true;
160
            }
161
            return false;
162
        }
163
    );
164
}
165
166
// Sorting on html contains
138
// Sorting on html contains
167
// <a href="foo.pl">bar</a> sort on 'bar'
139
// <a href="foo.pl">bar</a> sort on 'bar'
168
function dt_overwrite_html_sorting_localeCompare() {
140
function dt_overwrite_html_sorting_localeCompare() {
Lines 203-267 function dt_overwrite_html_sorting_localeCompare() { Link Here
203
    };
175
    };
204
}
176
}
205
177
206
// Sorting on string without accentued characters
207
function dt_overwrite_string_sorting_localeCompare() {
208
    jQuery.fn.dataTableExt.oSort['string-asc']  = function(a,b) {
209
        a = a.replace(/<.*?>/g, "").replace(/\s+/g, " ");
210
        b = b.replace(/<.*?>/g, "").replace(/\s+/g, " ");
211
        if (typeof(a.localeCompare == "function")) {
212
           return a.localeCompare(b);
213
        } else {
214
           return (a > b) ? 1 : ((a < b) ? -1 : 0);
215
        }
216
    };
217
218
    jQuery.fn.dataTableExt.oSort['string-desc'] = function(a,b) {
219
        a = a.replace(/<.*?>/g, "").replace(/\s+/g, " ");
220
        b = b.replace(/<.*?>/g, "").replace(/\s+/g, " ");
221
        if(typeof(b.localeCompare == "function")) {
222
            return b.localeCompare(a);
223
        } else {
224
            return (b > a) ? 1 : ((b < a) ? -1 : 0);
225
        }
226
    };
227
}
228
229
// Replace a node with a html and js contain.
230
function replace_html( original_node, type ) {
231
    switch ( $(original_node).attr('data-type') ) {
232
        case "range_dates":
233
            var id = $(original_node).attr("data-id");
234
            var format = $(original_node).attr("data-format");
235
            replace_html_date( original_node, id, format );
236
            break;
237
        default:
238
            alert(_("This node can't be replaced"));
239
    }
240
}
241
242
// Replace a node with a "From [date] To [date]" element
243
// Used on tfoot > td
244
function replace_html_date( original_node, id, format ) {
245
    var node = $('<span style="white-space:nowrap">' + _("From") + '<input type="text" id="' + id + 'from" readonly="readonly" placeholder=\'' + _("Pick date") + '\' size="7" /><a title="' + _("Delete this filter") + '" style="cursor:pointer" onclick=\'$("#' + id + 'from").val("").change();\' >&times;</a></span><br/><span style="white-space:nowrap">' + _("To") + '<input type="text" id="' + id + 'to" readonly="readonly" placeholder=\'' + _("Pick date") + '\' size="7" /><a title="' + _("Delete this filter") + '" style="cursor:pointer" onclick=\'$("#' + id + 'to").val("").change();\' >&times;</a></span>');
246
    $(original_node).replaceWith(node);
247
    var script = document.createElement( 'script' );
248
    script.type = 'text/javascript';
249
    var script_content = "Calendar.setup({";
250
    script_content += "    inputField: \"" + id + "from\",";
251
    script_content += "    ifFormat: \"" + format + "\",";
252
    script_content += "    button: \"" + id + "from\",";
253
    script_content += "    onClose: function(){ $(\"#" + id + "from\").change(); this.hide();}";
254
    script_content += "  });";
255
    script_content += "  Calendar.setup({";
256
    script_content += "    inputField: \"" + id + "to\",";
257
    script_content += "    ifFormat: \"" + format + "\",";
258
    script_content += "    button: \"" + id + "to\",";
259
    script_content += "    onClose: function(){ $(\"#" + id + "to\").change(); this.hide();}";
260
    script_content += "  });";
261
    script.text = script_content;
262
    $(original_node).append( script );
263
}
264
265
$.fn.dataTableExt.oPagination.four_button = {
178
$.fn.dataTableExt.oPagination.four_button = {
266
    /*
179
    /*
267
     * Function: oPagination.four_button.fnInit
180
     * Function: oPagination.four_button.fnInit
268
- 

Return to bug 15481