1 // Escape special characters in jQuery Selector
2 function escape_id( myid ) {
3 return "#" + myid.replace( /(:|\.|\[|\])/g, "\\$1" );
6 function getKeySplitId(id,separator){
7 // id of elements must respect this rule
8 // split_id[0] = plugin_uuid
9 // split_id[1] = element
10 // split_id[2] = field or key
12 var split_id = id.split(separator);
13 var key = split_id[2];
18 function arrays_equal(a,b) { return !(a<b || b<a); }
20 function arrayInArray(elt,tab){
22 jQuery.each(tab, function(i,x){
23 if(arrays_equal(x,elt)){flag=true;return;}
28 jQuery.fn.spin = function(opts) {
29 this.each(function() {
30 var $this = jQuery(this),
38 data.spinner = new Spinner(jQuery.extend({color: $this.css('color')}, opts)).spin(this);
44 // FROM Triptych : http://stackoverflow.com/users/43089/triptych
45 // http://stackoverflow.com/questions/979256/how-to-sort-an-array-of-javascript-objects
46 // data.sort(sort_by('city', false, function(a){return a.toUpperCase()}));
47 var sort_by = function(field, reverse, primer){
49 var key = function (x) {return primer ? primer(x[field]) : x[field]};
50 //var key = primer ? function (x) { return primer(x[field]); } : function (x) { return x[field]; }
52 return function (a,b) {
53 var A = key(a), B = key(b);
54 return (A < B ? -1 : (A > B ? 1 : 0)) * [1,-1][+!!reverse];
55 //return ((A < B) ? -1 :
56 // (A > B) ? +1 : 0)) * [-1,1][+!!reverse];