[29539] | 1 | jQuery.fn.fontCheckbox = function() { |
---|
| 2 | this.find('input[type=checkbox], input[type=radio]').each(function() { |
---|
| 3 | if (!jQuery(this).is(':checked')) { |
---|
| 4 | jQuery(this).prev().toggleClass('icon-check icon-check-empty'); |
---|
| 5 | } |
---|
| 6 | }); |
---|
| 7 | this.find('input[type=checkbox]').on('change', function() { |
---|
| 8 | jQuery(this).prev().toggleClass('icon-check icon-check-empty'); |
---|
| 9 | }); |
---|
| 10 | this.find('input[type=radio]').on('change', function() { |
---|
| 11 | jQuery(this).closest('.font-checkbox').find('input[type=radio][name='+ jQuery(this).attr('name') +']') |
---|
| 12 | .prev().toggleClass('icon-check icon-check-empty'); |
---|
| 13 | }); |
---|
| 14 | }; |
---|
| 15 | |
---|
| 16 | // init fontChecbox everywhere |
---|
| 17 | jQuery('.font-checkbox').fontCheckbox(); |
---|
| 18 | |
---|
[25194] | 19 | function array_delete(arr, item) { |
---|
| 20 | var i = arr.indexOf(item); |
---|
| 21 | if (i != -1) arr.splice(i, 1); |
---|
| 22 | } |
---|
| 23 | |
---|
[26179] | 24 | function str_repeat(i, m) { |
---|
| 25 | for (var o = []; m > 0; o[--m] = i); |
---|
| 26 | return o.join(''); |
---|
| 27 | } |
---|
| 28 | |
---|
[28039] | 29 | if (!Array.prototype.indexOf) |
---|
| 30 | { |
---|
| 31 | Array.prototype.indexOf = function(elt /*, from*/) |
---|
| 32 | { |
---|
| 33 | var len = this.length; |
---|
| 34 | |
---|
| 35 | var from = Number(arguments[1]) || 0; |
---|
| 36 | from = (from < 0) |
---|
| 37 | ? Math.ceil(from) |
---|
| 38 | : Math.floor(from); |
---|
| 39 | if (from < 0) |
---|
| 40 | from += len; |
---|
| 41 | |
---|
| 42 | for (; from < len; from++) |
---|
| 43 | { |
---|
| 44 | if (from in this && |
---|
| 45 | this[from] === elt) |
---|
| 46 | return from; |
---|
| 47 | } |
---|
| 48 | return -1; |
---|
| 49 | }; |
---|
| 50 | } |
---|
| 51 | |
---|
[25194] | 52 | function sprintf() { |
---|
| 53 | var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = ''; |
---|
| 54 | while (f) { |
---|
| 55 | if (m = /^[^\x25]+/.exec(f)) { |
---|
| 56 | o.push(m[0]); |
---|
| 57 | } |
---|
| 58 | else if (m = /^\x25{2}/.exec(f)) { |
---|
| 59 | o.push('%'); |
---|
| 60 | } |
---|
| 61 | else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) { |
---|
| 62 | if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) { |
---|
| 63 | throw('Too few arguments.'); |
---|
| 64 | } |
---|
| 65 | if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) { |
---|
| 66 | throw('Expecting number but found ' + typeof(a)); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | switch (m[7]) { |
---|
| 70 | case 'b': a = a.toString(2); break; |
---|
| 71 | case 'c': a = String.fromCharCode(a); break; |
---|
| 72 | case 'd': a = parseInt(a); break; |
---|
| 73 | case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break; |
---|
| 74 | case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break; |
---|
| 75 | case 'o': a = a.toString(8); break; |
---|
| 76 | case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break; |
---|
| 77 | case 'u': a = Math.abs(a); break; |
---|
| 78 | case 'x': a = a.toString(16); break; |
---|
| 79 | case 'X': a = a.toString(16).toUpperCase(); break; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a); |
---|
| 83 | c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' '; |
---|
| 84 | x = m[5] - String(a).length - s.length; |
---|
| 85 | p = m[5] ? str_repeat(c, x) : ''; |
---|
| 86 | o.push(s + (m[4] ? a + p : p + a)); |
---|
| 87 | } |
---|
| 88 | else { |
---|
| 89 | throw('Huh ?!'); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | f = f.substring(m[0].length); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | return o.join(''); |
---|
| 96 | } |
---|