2 * This file is included in tophat_render.php
4 // Escape special characters in jQuery Selector
5 function escape_id( myid ) {
6 return "#" + myid.replace( /(:|\.|\[|\])/g, "\\$1" );
9 function getKeySplitId(id,separator){
10 // id of elements must respect this rule
11 // split_id[0] = plugin_uuid
12 // split_id[1] = element
13 // split_id[2] = field or key
15 var split_id = id.split(separator);
16 var key = split_id[2];
21 function arrays_equal(a,b) { return !(a<b || b<a); }
23 function arrayInArray(elt,tab){
25 jQuery.each(tab, function(i,x){
26 if(arrays_equal(x,elt)){flag=true;return;}
31 jQuery.fn.spin = function(opts) {
32 this.each(function() {
33 var $this = jQuery(this),
41 data.spinner = new Spinner(jQuery.extend({color: $this.css('color')}, opts)).spin(this);
47 // FROM Triptych : http://stackoverflow.com/users/43089/triptych
48 // http://stackoverflow.com/questions/979256/how-to-sort-an-array-of-javascript-objects
49 // data.sort(sort_by('city', false, function(a){return a.toUpperCase()}));
50 var sort_by = function(field, reverse, primer){
52 var key = function (x) {return primer ? primer(x[field]) : x[field]};
53 //var key = primer ? function (x) { return primer(x[field]); } : function (x) { return x[field]; }
55 return function (a,b) {
56 var A = key(a), B = key(b);
57 return (A < B ? -1 : (A > B ? 1 : 0)) * [1,-1][+!!reverse];
58 //return ((A < B) ? -1 :
59 // (A > B) ? +1 : 0)) * [-1,1][+!!reverse];