sugar-rails 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. data/lib/sugar/rails/version.rb +2 -2
  2. data/vendor/assets/javascripts/precompiled/development/array.js +19 -16
  3. data/vendor/assets/javascripts/precompiled/development/core.js +7 -1
  4. data/vendor/assets/javascripts/precompiled/development/date.js +44 -15
  5. data/vendor/assets/javascripts/precompiled/development/es5.js +0 -6
  6. data/vendor/assets/javascripts/precompiled/development/number.js +20 -14
  7. data/vendor/assets/javascripts/precompiled/development/object.js +4 -3
  8. data/vendor/assets/javascripts/precompiled/development/string.js +22 -11
  9. data/vendor/assets/javascripts/precompiled/minified/array.js +15 -14
  10. data/vendor/assets/javascripts/precompiled/minified/core.js +9 -9
  11. data/vendor/assets/javascripts/precompiled/minified/date.js +34 -33
  12. data/vendor/assets/javascripts/precompiled/minified/date_locales.js +1 -1
  13. data/vendor/assets/javascripts/precompiled/minified/date_ranges.js +2 -2
  14. data/vendor/assets/javascripts/precompiled/minified/es5.js +6 -6
  15. data/vendor/assets/javascripts/precompiled/minified/function.js +3 -3
  16. data/vendor/assets/javascripts/precompiled/minified/inflections.js +7 -7
  17. data/vendor/assets/javascripts/precompiled/minified/language.js +9 -9
  18. data/vendor/assets/javascripts/precompiled/minified/number.js +5 -5
  19. data/vendor/assets/javascripts/precompiled/minified/object.js +6 -6
  20. data/vendor/assets/javascripts/precompiled/minified/regexp.js +1 -1
  21. data/vendor/assets/javascripts/precompiled/minified/string.js +12 -12
  22. data/vendor/assets/javascripts/sugar-development.js +117 -67
  23. data/vendor/assets/javascripts/sugar-full.js +111 -109
  24. data/vendor/assets/javascripts/sugar.js +94 -92
  25. metadata +4 -4
@@ -1,6 +1,6 @@
1
1
  module Sugar
2
2
  module Rails
3
- VERSION = "1.3.5"
4
- SUGARJS_VERSION = "1.3.5"
3
+ VERSION = "1.3.6"
4
+ SUGARJS_VERSION = "1.3.6"
5
5
  end
6
6
  end
@@ -16,7 +16,7 @@
16
16
  } else if(isRegExp(match) && isString(el)) {
17
17
  // Match against a regexp
18
18
  return regexp(match).test(el);
19
- } else if(isFunction(match) && !isFunction(el)) {
19
+ } else if(isFunction(match)) {
20
20
  // Match against a filtering function
21
21
  return match.apply(scope, params);
22
22
  } else if(isObject(match) && isObjectPrimitive(el)) {
@@ -317,10 +317,12 @@
317
317
  var result = [], tmp;
318
318
  multiArgs(arguments, function(a) {
319
319
  if(isObjectPrimitive(a)) {
320
- tmp = array.prototype.slice.call(a);
321
- if(tmp.length > 0) {
322
- a = tmp;
323
- }
320
+ try {
321
+ tmp = array.prototype.slice.call(a, 0);
322
+ if(tmp.length > 0) {
323
+ a = tmp;
324
+ }
325
+ } catch(e) {}
324
326
  }
325
327
  result = result.concat(a);
326
328
  });
@@ -905,15 +907,8 @@
905
907
  *
906
908
  ***/
907
909
  'sample': function(num) {
908
- var result = [], arr = this.clone(), index;
909
- if(isUndefined(num)) num = 1;
910
- while(result.length < num) {
911
- index = floor(math.random() * (arr.length - 1));
912
- result.push(arr[index]);
913
- arr.removeAt(index);
914
- if(arr.length == 0) break;
915
- }
916
- return arguments.length > 0 ? result : result[0];
910
+ var arr = this.randomize();
911
+ return arguments.length > 0 ? arr.slice(0, num) : arr[0];
917
912
  },
918
913
 
919
914
  /***
@@ -1102,6 +1097,7 @@
1102
1097
  * @extra In cases where a callback is used, instead of %element, index%, the callback will instead be passed %key, value%. Enumerable methods are also available to extended objects as instance methods.
1103
1098
  *
1104
1099
  * @set
1100
+ * each
1105
1101
  * map
1106
1102
  * any
1107
1103
  * all
@@ -1131,7 +1127,8 @@
1131
1127
  extendSimilar(object, false, false, names, function(methods, name) {
1132
1128
  methods[name] = function(obj, arg1, arg2) {
1133
1129
  var result;
1134
- result = array.prototype[name].call(keysWithCoercion(obj), function(key) {
1130
+ var x = keysWithCoercion(obj);
1131
+ result = array.prototype[name].call(x, function(key) {
1135
1132
  if(mapping) {
1136
1133
  return transformArgument(obj[key], arg1, obj, [key, obj[key], obj]);
1137
1134
  } else {
@@ -1168,6 +1165,12 @@
1168
1165
  return values.reduce.apply(values, multiArgs(arguments).slice(1));
1169
1166
  },
1170
1167
 
1168
+ 'each': function(obj, fn) {
1169
+ checkCallback(fn);
1170
+ iterateOverObject(obj, fn);
1171
+ return obj;
1172
+ },
1173
+
1171
1174
  /***
1172
1175
  * @method size(<obj>)
1173
1176
  * @returns Number
@@ -1186,7 +1189,7 @@
1186
1189
 
1187
1190
  buildEnhancements();
1188
1191
  buildAlphanumericSort();
1189
- buildEnumerableMethods('each,any,all,none,count,find,findAll,isEmpty');
1192
+ buildEnumerableMethods('any,all,none,count,find,findAll,isEmpty');
1190
1193
  buildEnumerableMethods('sum,average,min,max,least,most', true);
1191
1194
  buildObjectInstanceMethods('map,reduce,size', Hash);
1192
1195
 
@@ -120,6 +120,12 @@
120
120
  return result;
121
121
  }
122
122
 
123
+ function checkCallback(fn) {
124
+ if(!fn || !fn.call) {
125
+ throw new TypeError('Callback is not callable');
126
+ }
127
+ }
128
+
123
129
 
124
130
  // General helpers
125
131
 
@@ -154,7 +160,7 @@
154
160
  var key;
155
161
  for(key in obj) {
156
162
  if(!hasOwnProperty(obj, key)) continue;
157
- if(fn.call(obj, key, obj[key]) === false) break;
163
+ if(fn.call(obj, key, obj[key], obj) === false) break;
158
164
  }
159
165
  }
160
166
 
@@ -10,8 +10,10 @@
10
10
  var CurrentLocalization;
11
11
 
12
12
  var TimeFormat = ['ampm','hour','minute','second','ampm','utc','offset_sign','offset_hours','offset_minutes','ampm']
13
- var FloatReg = '\\d{1,2}(?:[,.]\\d+)?';
14
- var RequiredTime = '({t})?\\s*('+FloatReg+')(?:{h}('+FloatReg+')?{m}(?::?('+FloatReg+'){s})?\\s*(?:({t})|(Z)|(?:([+-])(\\d{2,2})(?::?(\\d{2,2}))?)?)?|\\s*({t}))';
13
+ var DecimalReg = '(?:[,.]\\d+)?';
14
+ var HoursReg = '\\d{1,2}' + DecimalReg;
15
+ var SixtyReg = '[0-5]\\d' + DecimalReg;
16
+ var RequiredTime = '({t})?\\s*('+HoursReg+')(?:{h}('+SixtyReg+')?{m}(?::?('+SixtyReg+'){s})?\\s*(?:({t})|(Z)|(?:([+-])(\\d{2,2})(?::?(\\d{2,2}))?)?)?|\\s*({t}))';
15
17
 
16
18
  var KanjiDigits = '〇一二三四五六七八九十百千万';
17
19
  var FullWidthDigits = '0123456789';
@@ -411,6 +413,10 @@
411
413
  return arrayToAlternates(arr);
412
414
  }
413
415
 
416
+ function setDefault(name, value) {
417
+ loc[name] = loc[name] || value;
418
+ }
419
+
414
420
  function setModifiers() {
415
421
  var arr = [];
416
422
  loc.modifiersByName = {};
@@ -439,10 +445,10 @@
439
445
  setArray('units', false, 8);
440
446
  setArray('numbers', false, 10);
441
447
 
442
- loc['code'] = localeCode;
443
- loc['date'] = getDigit(1,2, loc['digitDate']);
444
- loc['year'] = getDigit(4,4);
445
- loc['num'] = getNum();
448
+ setDefault('code', localeCode);
449
+ setDefault('date', getDigit(1,2, loc['digitDate']));
450
+ setDefault('year', "'\\d{2}|" + getDigit(4,4));
451
+ setDefault('num', getNum());
446
452
 
447
453
  setModifiers();
448
454
 
@@ -537,8 +543,10 @@
537
543
  arr.forEach(function(key, i) {
538
544
  value = match[i + 1];
539
545
  if(isUndefined(value) || value === '') return;
540
- if(key === 'year') obj.yearAsString = value;
541
- num = parseFloat(value.replace(/,/, '.'));
546
+ if(key === 'year') {
547
+ obj.yearAsString = value.replace(/'/, '');
548
+ }
549
+ num = parseFloat(value.replace(/'/, '').replace(/,/, '.'));
542
550
  obj[key] = !isNaN(num) ? num : value.toLowerCase();
543
551
  });
544
552
  return obj;
@@ -855,7 +863,8 @@
855
863
  // Date comparison helpers
856
864
 
857
865
  function compareDate(d, find, buffer, forceUTC) {
858
- var p = getExtendedDate(find, null, null, forceUTC), accuracy = 0, loBuffer = 0, hiBuffer = 0, override, capitalized;
866
+ var p, t, min, max, minOffset, maxOffset, override, capitalized, accuracy = 0, loBuffer = 0, hiBuffer = 0;
867
+ p = getExtendedDate(find, null, null, forceUTC);
859
868
  if(buffer > 0) {
860
869
  loBuffer = hiBuffer = buffer;
861
870
  override = true;
@@ -881,12 +890,27 @@
881
890
  hiBuffer = -50;
882
891
  }
883
892
  }
884
- var t = d.getTime();
885
- var min = p.date.getTime();
886
- var max = max || (min + accuracy);
893
+ t = d.getTime();
894
+ min = p.date.getTime();
895
+ max = max || (min + accuracy);
896
+ max = compensateForTimezoneTraversal(d, min, max);
887
897
  return t >= (min - loBuffer) && t <= (max + hiBuffer);
888
898
  }
889
899
 
900
+ function compensateForTimezoneTraversal(d, min, max) {
901
+ var dMin, dMax, minOffset, maxOffset;
902
+ dMin = new Date(min);
903
+ dMax = new Date(max).utc(d.isUTC());
904
+ if(callDateGet(dMax, 'Hours') !== 23) {
905
+ minOffset = dMin.getTimezoneOffset();
906
+ maxOffset = dMax.getTimezoneOffset();
907
+ if(minOffset !== maxOffset) {
908
+ max += (maxOffset - minOffset).minutes();
909
+ }
910
+ }
911
+ return max;
912
+ }
913
+
890
914
  function updateDate(d, params, reset, advance, prefer) {
891
915
  var weekday, specificityIndex;
892
916
 
@@ -917,7 +941,9 @@
917
941
  }
918
942
 
919
943
  // "date" can also be passed for the day
920
- if(params['date']) params['day'] = params['date'];
944
+ if(isDefined(params['date'])) {
945
+ params['day'] = params['date'];
946
+ }
921
947
 
922
948
  // Reset any unit lower than the least specific unit set. Do not do this for weeks
923
949
  // or for years. This needs to be performed before the acutal setting of the date
@@ -1030,7 +1056,9 @@
1030
1056
  // (or 29th in the case of a leap year).
1031
1057
 
1032
1058
  function checkMonthTraversal(date, targetMonth) {
1033
- if(targetMonth < 0) targetMonth += 12;
1059
+ if(targetMonth < 0) {
1060
+ targetMonth = targetMonth % 12 + 12;
1061
+ }
1034
1062
  if(targetMonth % 12 != callDateGet(date, 'Month')) {
1035
1063
  callDateSet(date, 'Date', 0);
1036
1064
  }
@@ -2152,7 +2180,7 @@
2152
2180
  'units': 'millisecond:|s,second:|s,minute:|s,hour:|s,day:|s,week:|s,month:|s,year:|s',
2153
2181
  'numbers': 'one,two,three,four,five,six,seven,eight,nine,ten',
2154
2182
  'articles': 'a,an,the',
2155
- 'tokens': 'the,st|nd|rd|th,of',
2183
+ 'tokens': 'the,st|nd|rd|th,of',
2156
2184
  'short': '{Month} {d}, {yyyy}',
2157
2185
  'long': '{Month} {d}, {yyyy} {h}:{mm}{tt}',
2158
2186
  'full': '{Weekday} {Month} {d}, {yyyy} {h}:{mm}:{ss}{tt}',
@@ -2184,6 +2212,7 @@
2184
2212
  '{0} {num}{1} {day} of {month} {year?}',
2185
2213
  '{weekday?} {month} {date}{1?} {year?}',
2186
2214
  '{date} {month} {year}',
2215
+ '{date} {month}',
2187
2216
  '{shift} {weekday}',
2188
2217
  '{shift} week {weekday}',
2189
2218
  '{weekday} {2?} {shift} week',
@@ -84,12 +84,6 @@
84
84
  }
85
85
  }
86
86
 
87
- function checkCallback(fn) {
88
- if(!fn || !fn.call) {
89
- throw new TypeError('Callback is not callable');
90
- }
91
- }
92
-
93
87
  function checkFirstArgumentExists(args) {
94
88
  if(args.length === 0) {
95
89
  throw new TypeError('First argument must be defined');
@@ -146,7 +146,7 @@
146
146
  *
147
147
  ***/
148
148
  'isOdd': function() {
149
- return !this.isMultipleOf(2);
149
+ return !isNaN(this) && !this.isMultipleOf(2);
150
150
  },
151
151
 
152
152
  /***
@@ -194,21 +194,27 @@
194
194
  *
195
195
  ***/
196
196
  'format': function(place, thousands, decimal) {
197
- var str, split, method, after, r = /(\d+)(\d{3})/;
198
- if(string(thousands).match(/\d/)) throw new TypeError('Thousands separator cannot contain numbers.');
199
- str = isNumber(place) ? round(this, place || 0).toFixed(math.max(place, 0)) : this.toString();
200
- thousands = thousands || ',';
201
- decimal = decimal || '.';
202
- split = str.split('.');
203
- str = split[0];
204
- after = split[1] || '';
205
- while (str.match(r)) {
206
- str = str.replace(r, '$1' + thousands + '$2');
197
+ var i, str, split, integer, fraction, result = '';
198
+ if(isUndefined(thousands)) {
199
+ thousands = ',';
207
200
  }
208
- if(after.length > 0) {
209
- str += decimal + repeatString((place || 0) - after.length, '0') + after;
201
+ if(isUndefined(decimal)) {
202
+ decimal = '.';
210
203
  }
211
- return str;
204
+ str = (isNumber(place) ? round(this, place || 0).toFixed(math.max(place, 0)) : this.toString()).replace(/^-/, '');
205
+ split = str.split('.');
206
+ integer = split[0];
207
+ fraction = split[1];
208
+ for(i = integer.length; i > 0; i -= 3) {
209
+ if(i < integer.length) {
210
+ result = thousands + result;
211
+ }
212
+ result = integer.slice(math.max(0, i - 3), i) + result;
213
+ }
214
+ if(fraction) {
215
+ result += decimal + repeatString((place || 0) - fraction.length, '0') + fraction;
216
+ }
217
+ return (this < 0 ? '-' : '') + result;
212
218
  },
213
219
 
214
220
  /***
@@ -1,4 +1,3 @@
1
-
2
1
  /***
3
2
  * @package Object
4
3
  * @dependency core
@@ -28,7 +27,7 @@
28
27
  });
29
28
  if(!key && paramIsArray) key = obj.length.toString();
30
29
  setParamsObject(obj, key, value);
31
- } else if(value.match(/^[\d.]+$/)) {
30
+ } else if(value.match(/^[+-]?\d+(\.\d+)?$/)) {
32
31
  obj[param] = parseFloat(value);
33
32
  } else if(value === 'true') {
34
33
  obj[param] = true;
@@ -308,7 +307,9 @@
308
307
  * @example
309
308
  *
310
309
  * Object.extend();
311
- * [2,4,6].map(Math.exp).tap(function(){ arr.pop(); }).map(Math.round); -> [7,55]
310
+ * [2,4,6].map(Math.exp).tap(function(arr) {
311
+ * arr.pop()
312
+ * });
312
313
  * [2,4,6].map(Math.exp).tap('pop').map(Math.round); -> [7,55]
313
314
  *
314
315
  ***/
@@ -92,8 +92,6 @@
92
92
  }
93
93
  }
94
94
 
95
-
96
-
97
95
  extend(string, true, false, {
98
96
 
99
97
  /***
@@ -152,7 +150,12 @@
152
150
  *
153
151
  ***/
154
152
  'escapeHTML': function() {
155
- return this.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
153
+ return this.replace(/&/g, '&amp;' )
154
+ .replace(/</g, '&lt;' )
155
+ .replace(/>/g, '&gt;' )
156
+ .replace(/"/g, '&quot;')
157
+ .replace(/'/g, '&apos;')
158
+ .replace(/\//g, '&#x2f;');
156
159
  },
157
160
 
158
161
  /***
@@ -166,7 +169,12 @@
166
169
  *
167
170
  ***/
168
171
  'unescapeHTML': function() {
169
- return this.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&');
172
+ return this.replace(/&amp;/g, '&')
173
+ .replace(/&lt;/g, '<')
174
+ .replace(/&gt;/g, '>')
175
+ .replace(/&quot;/g, '"')
176
+ .replace(/&apos;/g, "'")
177
+ .replace(/&#x2f;/g, '/');
170
178
  },
171
179
 
172
180
  /***
@@ -753,17 +761,21 @@
753
761
  *
754
762
  * 'jumpy'.repeat(2) -> 'jumpyjumpy'
755
763
  * 'a'.repeat(5) -> 'aaaaa'
764
+ * 'a'.repeat(0) -> ''
756
765
  *
757
766
  ***/
758
767
  'repeat': function(num) {
759
- var str = '', i = 0;
760
- if(isNumber(num) && num > 0) {
761
- while(i < num) {
762
- str += this;
763
- i++;
768
+ var result = '', str = this;
769
+ if(!isNumber(num) || num < 1) return '';
770
+ while (num) {
771
+ if (num & 1) {
772
+ result += str;
773
+ }
774
+ if (num >>= 1) {
775
+ str += str;
764
776
  }
765
777
  }
766
- return str;
778
+ return result;
767
779
  },
768
780
 
769
781
  /***
@@ -851,7 +863,6 @@
851
863
  });
852
864
  return context;
853
865
  }
854
-
855
866
  });
856
867
 
857
868
 
@@ -1,16 +1,17 @@
1
- function Ba(a,b,c,d){var e=k;if(a===b)return k;else if(D(b)&&C(a))return r(b).test(a);else if(z(b)&&!z(a))return b.apply(c,d);else if(L(b)&&ka(a)){G(b,function(g){Ba(a[g],b[g],c,[a[g],a])||(e=n)});return e}else return ua(a)&&ua(b)?ta(a)===ta(b):a===b}function R(a,b,c,d){return K(b)?a:z(b)?b.apply(c,d||[]):z(a[b])?a[b].call(a):a[b]}
2
- function T(a,b,c,d){var e,g;if(c<0)c=a.length+c;g=isNaN(c)?0:c;for(c=d===k?a.length+g:a.length;g<c;){e=g%a.length;if(e in a){if(b.call(a,a[e],e,a)===n)break}else return Ca(a,b,g,d);g++}}function Ca(a,b,c){var d=[],e;for(e in a)e in a&&e>>>0==e&&e!=4294967295&&e>=c&&d.push(parseInt(e));d.sort().each(function(g){return b.call(a,a[g],g,a)});return a}function Ea(a,b,c,d,e){var g,f;T(a,function(i,j,h){if(Ba(i,b,h,[i,j,h])){g=i;f=j;return n}},c,d);return e?f:g}
3
- function Fa(a,b){var c=[],d={},e;T(a,function(g,f){e=b?R(g,b,a,[g,f,a]):g;Ga(d,e)||c.push(g)});return c}function Ha(a,b,c){var d=[],e={};b.each(function(g){Ga(e,g)});a.each(function(g){var f=ta(g),i=!ua(g);if(Ia(e,f,g,i)!=c){var j=0;if(i)for(f=e[f];j<f.length;)if(f[j]===g)f.splice(j,1);else j+=1;else delete e[f];d.push(g)}});return d}function Ja(a,b,c){b=b||Infinity;c=c||0;var d=[];T(a,function(e){if(da(e)&&c<b)d=d.concat(Ja(e,b,c+1));else d.push(e)});return d}
4
- function Ka(a){var b=[];F(a,function(c){b=b.concat(c)});return b}function Ia(a,b,c,d){var e=b in a;if(d){a[b]||(a[b]=[]);e=a[b].indexOf(c)!==-1}return e}function Ga(a,b){var c=ta(b),d=!ua(b),e=Ia(a,c,b,d);if(d)a[c].push(b);else a[c]=b;return e}function La(a,b,c,d){var e,g=[],f=c==="max",i=c==="min",j=Array.isArray(a);G(a,function(h){var m=a[h];h=R(m,b,a,j?[m,parseInt(h),a]:[]);if(h===e)g.push(m);else if(K(e)||f&&h>e||i&&h<e){g=[m];e=h}});j||(g=Ja(g,1));return d?g:g[0]}
5
- function Ma(a){if(q[Na])a=a.toLowerCase();return a.replace(q[Oa],"")}function Pa(a,b){var c=a.charAt(b);return(q[Qa]||{})[c]||c}function Ra(a){var b=q[Sa];return a?b.indexOf(a):l}var Sa="AlphanumericSortOrder",Oa="AlphanumericSortIgnore",Na="AlphanumericSortIgnoreCase",Qa="AlphanumericSortEquivalents";E(q,n,n,{create:function(){var a=[],b;F(arguments,function(c){if(ka(c)){b=q.prototype.slice.call(c);if(b.length>0)c=b}a=a.concat(c)});return a}});
6
- E(q,k,n,{find:function(a,b,c){return Ea(this,a,b,c)},findAll:function(a,b,c){var d=[];T(this,function(e,g,f){Ba(e,a,f,[e,g,f])&&d.push(e)},b,c);return d},findIndex:function(a,b,c){a=Ea(this,a,b,c,k);return K(a)?-1:a},count:function(a){if(K(a))return this.length;return this.findAll(a).length},removeAt:function(a,b){if(K(a))return this;if(K(b))b=a;for(var c=0;c<=b-a;c++)this.splice(a,1);return this},include:function(a,b){return this.clone().add(a,b)},exclude:function(){return q.prototype.remove.apply(this.clone(),
7
- arguments)},clone:function(){return ma([],this)},unique:function(a){return Fa(this,a)},flatten:function(a){return Ja(this,a)},union:function(){return Fa(this.concat(Ka(arguments)))},intersect:function(){return Ha(this,Ka(arguments),n)},subtract:function(){return Ha(this,Ka(arguments),k)},at:function(){return va(this,arguments)},first:function(a){if(K(a))return this[0];if(a<0)a=0;return this.slice(0,a)},last:function(a){if(K(a))return this[this.length-1];return this.slice(this.length-a<0?0:this.length-
1
+ function Ba(a,b,c,d){var e=k;if(a===b)return k;else if(D(b)&&C(a))return r(b).test(a);else if(A(b))return b.apply(c,d);else if(M(b)&&ka(a)){G(b,function(f){Ba(a[f],b[f],c,[a[f],a])||(e=n)});return e}else return va(a)&&va(b)?ua(a)===ua(b):a===b}function R(a,b,c,d){return K(b)?a:A(b)?b.apply(c,d||[]):A(a[b])?a[b].call(a):a[b]}
2
+ function T(a,b,c,d){var e,f;if(c<0)c=a.length+c;f=isNaN(c)?0:c;for(c=d===k?a.length+f:a.length;f<c;){e=f%a.length;if(e in a){if(b.call(a,a[e],e,a)===n)break}else return Ca(a,b,f,d);f++}}function Ca(a,b,c){var d=[],e;for(e in a)e in a&&e>>>0==e&&e!=4294967295&&e>=c&&d.push(parseInt(e));d.sort().each(function(f){return b.call(a,a[f],f,a)});return a}function Ea(a,b,c,d,e){var f,h;T(a,function(i,j,g){if(Ba(i,b,g,[i,j,g])){f=i;h=j;return n}},c,d);return e?h:f}
3
+ function Fa(a,b){var c=[],d={},e;T(a,function(f,h){e=b?R(f,b,a,[f,h,a]):f;Ga(d,e)||c.push(f)});return c}function Ha(a,b,c){var d=[],e={};b.each(function(f){Ga(e,f)});a.each(function(f){var h=ua(f),i=!va(f);if(Ia(e,h,f,i)!=c){var j=0;if(i)for(h=e[h];j<h.length;)if(h[j]===f)h.splice(j,1);else j+=1;else delete e[h];d.push(f)}});return d}function Ja(a,b,c){b=b||Infinity;c=c||0;var d=[];T(a,function(e){if(da(e)&&c<b)d=d.concat(Ja(e,b,c+1));else d.push(e)});return d}
4
+ function Ka(a){var b=[];F(a,function(c){b=b.concat(c)});return b}function Ia(a,b,c,d){var e=b in a;if(d){a[b]||(a[b]=[]);e=a[b].indexOf(c)!==-1}return e}function Ga(a,b){var c=ua(b),d=!va(b),e=Ia(a,c,b,d);if(d)a[c].push(b);else a[c]=b;return e}function La(a,b,c,d){var e,f=[],h=c==="max",i=c==="min",j=Array.isArray(a);G(a,function(g){var m=a[g];g=R(m,b,a,j?[m,parseInt(g),a]:[]);if(g===e)f.push(m);else if(K(e)||h&&g>e||i&&g<e){f=[m];e=g}});j||(f=Ja(f,1));return d?f:f[0]}
5
+ function Ma(a){if(q[Na])a=a.toLowerCase();return a.replace(q[Oa],"")}function Pa(a,b){var c=a.charAt(b);return(q[Qa]||{})[c]||c}function Ra(a){var b=q[Sa];return a?b.indexOf(a):l}var Sa="AlphanumericSortOrder",Oa="AlphanumericSortIgnore",Na="AlphanumericSortIgnoreCase",Qa="AlphanumericSortEquivalents";E(q,n,n,{create:function(){var a=[],b;F(arguments,function(c){if(ka(c))try{b=q.prototype.slice.call(c,0);if(b.length>0)c=b}catch(d){}a=a.concat(c)});return a}});
6
+ E(q,k,n,{find:function(a,b,c){return Ea(this,a,b,c)},findAll:function(a,b,c){var d=[];T(this,function(e,f,h){Ba(e,a,h,[e,f,h])&&d.push(e)},b,c);return d},findIndex:function(a,b,c){a=Ea(this,a,b,c,k);return K(a)?-1:a},count:function(a){if(K(a))return this.length;return this.findAll(a).length},removeAt:function(a,b){if(K(a))return this;if(K(b))b=a;for(var c=0;c<=b-a;c++)this.splice(a,1);return this},include:function(a,b){return this.clone().add(a,b)},exclude:function(){return q.prototype.remove.apply(this.clone(),
7
+ arguments)},clone:function(){return ma([],this)},unique:function(a){return Fa(this,a)},flatten:function(a){return Ja(this,a)},union:function(){return Fa(this.concat(Ka(arguments)))},intersect:function(){return Ha(this,Ka(arguments),n)},subtract:function(){return Ha(this,Ka(arguments),k)},at:function(){return wa(this,arguments)},first:function(a){if(K(a))return this[0];if(a<0)a=0;return this.slice(0,a)},last:function(a){if(K(a))return this[this.length-1];return this.slice(this.length-a<0?0:this.length-
8
8
  a)},from:function(a){return this.slice(a)},to:function(a){if(K(a))a=this.length;return this.slice(0,a)},min:function(a,b){return La(this,a,"min",b)},max:function(a,b){return La(this,a,"max",b)},least:function(a,b){return La(this.groupBy.apply(this,[a]),"length","min",b)},most:function(a,b){return La(this.groupBy.apply(this,[a]),"length","max",b)},sum:function(a){a=a?this.map(a):this;return a.length>0?a.reduce(function(b,c){return b+c}):0},average:function(a){a=a?this.map(a):this;return a.length>0?
9
- a.sum()/a.length:0},inGroups:function(a,b){var c=arguments.length>1,d=this,e=[],g=M(this.length/a,void 0,"ceil");oa(0,a-1,function(f){f=f*g;var i=d.slice(f,f+g);c&&i.length<g&&oa(1,g-i.length,function(){i=i.add(b)});e.push(i)});return e},inGroupsOf:function(a,b){var c=[],d=this.length,e=this,g;if(d===0||a===0)return e;if(K(a))a=1;if(K(b))b=l;oa(0,M(d/a,void 0,"ceil")-1,function(f){for(g=e.slice(a*f,a*f+a);g.length<a;)g.push(b);c.push(g)});return c},isEmpty:function(){return this.compact().length==
10
- 0},sortBy:function(a,b){var c=this.clone();c.sort(function(d,e){var g,f;g=R(d,a,c,[d]);f=R(e,a,c,[e]);if(C(g)&&C(f)){g=g;f=f;var i,j,h,m,o=0,w=0;g=Ma(g);f=Ma(f);do{h=Pa(g,o);m=Pa(f,o);i=Ra(h);j=Ra(m);if(i===-1||j===-1){i=g.charCodeAt(o)||l;j=f.charCodeAt(o)||l}h=h!==g.charAt(o);m=m!==f.charAt(o);if(h!==m&&w===0)w=h-m;o+=1}while(i!=l&&j!=l&&i===j);g=i===j?w:i<j?-1:1}else g=g<f?-1:g>f?1:0;return g*(b?-1:1)});return c},randomize:function(){for(var a=this.concat(),b,c,d=a.length;d;b=parseInt(v.random()*
11
- d),c=a[--d],a[d]=a[b],a[b]=c);return a},zip:function(){var a=F(arguments);return this.map(function(b,c){return[b].concat(a.map(function(d){return c in d?d[c]:l}))})},sample:function(a){var b=[],c=this.clone(),d;if(K(a))a=1;for(;b.length<a;){d=N(v.random()*(c.length-1));b.push(c[d]);c.removeAt(d);if(c.length==0)break}return arguments.length>0?b:b[0]},each:function(a,b,c){T(this,a,b,c);return this},add:function(a,b){if(!A(u(b))||isNaN(b))b=this.length;q.prototype.splice.apply(this,[b,0].concat(a));
12
- return this},remove:function(){var a,b=this;F(arguments,function(c){for(a=0;a<b.length;)if(Ba(b[a],c,b,[b[a],a,b]))b.splice(a,1);else a++});return b},compact:function(a){var b=[];T(this,function(c){if(da(c))b.push(c.compact());else if(a&&c)b.push(c);else!a&&c!=l&&c.valueOf()===c.valueOf()&&b.push(c)});return b},groupBy:function(a,b){var c=this,d={},e;T(c,function(g,f){e=R(g,a,c,[g,f,c]);d[e]||(d[e]=[]);d[e].push(g)});b&&G(d,b);return d},none:function(){return!this.any.apply(this,arguments)}});
13
- E(q,k,n,{all:q.prototype.every,any:q.prototype.some,insert:q.prototype.add});function Ta(a){if(a&&a.valueOf)a=a.valueOf();return p.keys(a)}function Ua(a,b){H(p,n,n,a,function(c,d){c[d]=function(e,g,f){f=q.prototype[d].call(Ta(e),function(i){return b?R(e[i],g,e,[i,e[i],e]):Ba(e[i],g,e,[i,e[i],e])},f);if(da(f))f=f.reduce(function(i,j){i[j]=e[j];return i},{});return f}});wa(a,na)}
14
- E(p,n,n,{map:function(a,b){return Ta(a).reduce(function(c,d){c[d]=R(a[d],b,a,[d,a[d],a]);return c},{})},reduce:function(a){var b=Ta(a).map(function(c){return a[c]});return b.reduce.apply(b,F(arguments).slice(1))},size:function(a){return Ta(a).length}});(function(){H(q,k,function(){var a=arguments;return a.length>0&&!z(a[0])},"map,every,all,some,any,none,filter",function(a,b){a[b]=function(c){return this[b](function(d,e){return b==="map"?R(d,c,this,[d,e,this]):Ba(d,c,this,[d,e,this])})}})})();
9
+ a.sum()/a.length:0},inGroups:function(a,b){var c=arguments.length>1,d=this,e=[],f=N(this.length/a,void 0,"ceil");oa(0,a-1,function(h){h=h*f;var i=d.slice(h,h+f);c&&i.length<f&&oa(1,f-i.length,function(){i=i.add(b)});e.push(i)});return e},inGroupsOf:function(a,b){var c=[],d=this.length,e=this,f;if(d===0||a===0)return e;if(K(a))a=1;if(K(b))b=l;oa(0,N(d/a,void 0,"ceil")-1,function(h){for(f=e.slice(a*h,a*h+a);f.length<a;)f.push(b);c.push(f)});return c},isEmpty:function(){return this.compact().length==
10
+ 0},sortBy:function(a,b){var c=this.clone();c.sort(function(d,e){var f,h;f=R(d,a,c,[d]);h=R(e,a,c,[e]);if(C(f)&&C(h)){f=f;h=h;var i,j,g,m,o=0,v=0;f=Ma(f);h=Ma(h);do{g=Pa(f,o);m=Pa(h,o);i=Ra(g);j=Ra(m);if(i===-1||j===-1){i=f.charCodeAt(o)||l;j=h.charCodeAt(o)||l}g=g!==f.charAt(o);m=m!==h.charAt(o);if(g!==m&&v===0)v=g-m;o+=1}while(i!=l&&j!=l&&i===j);f=i===j?v:i<j?-1:1}else f=f<h?-1:f>h?1:0;return f*(b?-1:1)});return c},randomize:function(){for(var a=this.concat(),b,c,d=a.length;d;b=parseInt(w.random()*
11
+ d),c=a[--d],a[d]=a[b],a[b]=c);return a},zip:function(){var a=F(arguments);return this.map(function(b,c){return[b].concat(a.map(function(d){return c in d?d[c]:l}))})},sample:function(a){var b=this.randomize();return arguments.length>0?b.slice(0,a):b[0]},each:function(a,b,c){T(this,a,b,c);return this},add:function(a,b){if(!B(u(b))||isNaN(b))b=this.length;q.prototype.splice.apply(this,[b,0].concat(a));return this},remove:function(){var a,b=this;F(arguments,function(c){for(a=0;a<b.length;)if(Ba(b[a],
12
+ c,b,[b[a],a,b]))b.splice(a,1);else a++});return b},compact:function(a){var b=[];T(this,function(c){if(da(c))b.push(c.compact());else if(a&&c)b.push(c);else!a&&c!=l&&c.valueOf()===c.valueOf()&&b.push(c)});return b},groupBy:function(a,b){var c=this,d={},e;T(c,function(f,h){e=R(f,a,c,[f,h,c]);d[e]||(d[e]=[]);d[e].push(f)});b&&G(d,b);return d},none:function(){return!this.any.apply(this,arguments)}});E(q,k,n,{all:q.prototype.every,any:q.prototype.some,insert:q.prototype.add});
13
+ function Ta(a){if(a&&a.valueOf)a=a.valueOf();return p.keys(a)}function Ua(a,b){H(p,n,n,a,function(c,d){c[d]=function(e,f,h){var i=Ta(e);h=q.prototype[d].call(i,function(j){return b?R(e[j],f,e,[j,e[j],e]):Ba(e[j],f,e,[j,e[j],e])},h);if(da(h))h=h.reduce(function(j,g){j[g]=e[g];return j},{});return h}});xa(a,na)}
14
+ E(p,n,n,{map:function(a,b){return Ta(a).reduce(function(c,d){c[d]=R(a[d],b,a,[d,a[d],a]);return c},{})},reduce:function(a){var b=Ta(a).map(function(c){return a[c]});return b.reduce.apply(b,F(arguments).slice(1))},each:function(a,b){ja(b);G(a,b);return a},size:function(a){return Ta(a).length}});
15
+ (function(){H(q,k,function(){var a=arguments;return a.length>0&&!A(a[0])},"map,every,all,some,any,none,filter",function(a,b){a[b]=function(c){return this[b](function(d,e){return b==="map"?R(d,c,this,[d,e,this]):Ba(d,c,this,[d,e,this])})}})})();
15
16
  (function(){q[Sa]="A\u00c1\u00c0\u00c2\u00c3\u0104BC\u0106\u010c\u00c7D\u010e\u00d0E\u00c9\u00c8\u011a\u00ca\u00cb\u0118FG\u011eH\u0131I\u00cd\u00cc\u0130\u00ce\u00cfJKL\u0141MN\u0143\u0147\u00d1O\u00d3\u00d2\u00d4PQR\u0158S\u015a\u0160\u015eT\u0164U\u00da\u00d9\u016e\u00db\u00dcVWXY\u00ddZ\u0179\u017b\u017d\u00de\u00c6\u0152\u00d8\u00d5\u00c5\u00c4\u00d6".split("").map(function(b){return b+b.toLowerCase()}).join("");var a={};T("A\u00c1\u00c0\u00c2\u00c3\u00c4,C\u00c7,E\u00c9\u00c8\u00ca\u00cb,I\u00cd\u00cc\u0130\u00ce\u00cf,O\u00d3\u00d2\u00d4\u00d5\u00d6,S\u00df,U\u00da\u00d9\u00db\u00dc".split(","),
16
- function(b){var c=b.charAt(0);T(b.slice(1).split(""),function(d){a[d]=c;a[d.toLowerCase()]=c.toLowerCase()})});q[Na]=k;q[Qa]=a})();Ua("each,any,all,none,count,find,findAll,isEmpty");Ua("sum,average,min,max,least,most",k);wa("map,reduce,size",na);
17
+ function(b){var c=b.charAt(0);T(b.slice(1).split(""),function(d){a[d]=c;a[d.toLowerCase()]=c.toLowerCase()})});q[Na]=k;q[Qa]=a})();Ua("any,all,none,count,find,findAll,isEmpty");Ua("sum,average,min,max,least,most",k);xa("map,reduce,size",na);
@@ -1,9 +1,9 @@
1
- var k=true,l=null,n=false;function aa(a){return function(){return a}}var p=Object,q=Array,r=RegExp,s=Date,t=String,u=Number,v=Math,ba=typeof global!=="undefined"?global:this,ca=p.defineProperty&&p.defineProperties,x="Array,Boolean,Date,Function,Number,String,RegExp".split(","),da=y(x[0]),fa=y(x[1]),ga=y(x[2]),z=y(x[3]),A=y(x[4]),C=y(x[5]),D=y(x[6]);function y(a){return function(b){return p.prototype.toString.call(b)==="[object "+a+"]"}}
2
- function ha(a){if(!a.SugarMethods){ia(a,"SugarMethods",{});E(a,n,n,{restore:function(){var b=arguments.length===0,c=F(arguments);G(a.SugarMethods,function(d,e){if(b||c.indexOf(d)>-1)ia(e.wa?a.prototype:a,d,e.method)})},extend:function(b,c,d){E(a,d!==n,c,b)}})}}function E(a,b,c,d){var e=b?a.prototype:a,g;ha(a);G(d,function(f,i){g=e[f];if(typeof c==="function")i=ja(e[f],i,c);if(c!==n||!e[f])ia(e,f,i);a.SugarMethods[f]={wa:b,method:i,Da:g}})}
3
- function H(a,b,c,d,e){var g={};d=C(d)?d.split(","):d;d.forEach(function(f,i){e(g,f,i)});E(a,b,c,g)}function ja(a,b,c){return function(){return a&&(c===k||!c.apply(this,arguments))?a.apply(this,arguments):b.apply(this,arguments)}}function ia(a,b,c){if(ca)p.defineProperty(a,b,{value:c,configurable:k,enumerable:n,writable:k});else a[b]=c}function F(a,b){var c=[],d;for(d=0;d<a.length;d++){c.push(a[d]);b&&b.call(a,a[d],d)}return c}function I(a){return a!==void 0}function K(a){return a===void 0}
4
- function ka(a){return a&&typeof a==="object"}function L(a){return!!a&&p.prototype.toString.call(a)==="[object Object]"&&"hasOwnProperty"in a}function la(a,b){return p.hasOwnProperty.call(a,b)}function G(a,b){for(var c in a)if(la(a,c))if(b.call(a,c,a[c])===n)break}function ma(a,b){G(b,function(c){a[c]=b[c]});return a}function na(a){ma(this,a)}na.prototype.constructor=p;function oa(a,b,c,d){var e=[];a=parseInt(a);for(var g=d<0;!g&&a<=b||g&&a>=b;){e.push(a);c&&c.call(this,a);a+=d||1}return e}
5
- function M(a,b,c){c=v[c||"round"];var d=v.pow(10,v.abs(b||0));if(b<0)d=1/d;return c(a*d)/d}function N(a,b){return M(a,b,"floor")}function P(a,b,c,d){d=v.abs(a).toString(d||10);d=pa(b-d.replace(/\.\d+/,"").length,"0")+d;if(c||a<0)d=(a<0?"-":"+")+d;return d}function qa(a){if(a>=11&&a<=13)return"th";else switch(a%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}
6
- function ra(){return"\t\n\u000b\u000c\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u2028\u2029\u3000\ufeff"}function pa(a,b){return q(v.max(0,I(a)?a:1)+1).join(b||"")}function sa(a,b){var c=a.toString().match(/[^/]*$/)[0];if(b)c=(c+b).split("").sort().join("").replace(/([gimy])\1+/g,"$1");return c}function Q(a){C(a)||(a=t(a));return a.replace(/([\\/'*+?|()\[\]{}.^$])/g,"\\$1")}
7
- function ta(a,b){var c=typeof a,d,e,g,f,i,j;if(c==="string")return a;g=p.prototype.toString.call(a);d=L(a);e=g==="[object Array]";if(a!=l&&d||e){b||(b=[]);if(b.length>1)for(j=b.length;j--;)if(b[j]===a)return"CYC";b.push(a);d=t(a.constructor);f=e?a:p.keys(a).sort();for(j=0;j<f.length;j++){i=e?j:f[j];d+=i+ta(a[i],b)}b.pop()}else d=1/a===-Infinity?"-0":t(a&&a.valueOf?a.valueOf():a);return c+g+d}
8
- function ua(a){var b=p.prototype.toString.call(a);return b==="[object Date]"||b==="[object Array]"||b==="[object String]"||b==="[object Number]"||b==="[object RegExp]"||b==="[object Boolean]"||b==="[object Arguments]"||L(a)}function va(a,b,c){var d=[],e=a.length,g=b[b.length-1]!==n,f;F(b,function(i){if(fa(i))return n;if(g){i%=e;if(i<0)i=e+i}f=c?a.charAt(i)||"":a[i];d.push(f)});return d.length<2?d[0]:d}
9
- function wa(a,b){H(b,k,n,a,function(c,d){c[d+(d==="equal"?"s":"")]=function(){return p[d].apply(l,[this].concat(F(arguments)))}})}ha(p);G(x,function(a,b){ha(ba[b])});
1
+ var k=true,l=null,n=false;function aa(a){return function(){return a}}var p=Object,q=Array,r=RegExp,s=Date,t=String,u=Number,w=Math,ba=typeof global!=="undefined"?global:this,ca=p.defineProperty&&p.defineProperties,x="Array,Boolean,Date,Function,Number,String,RegExp".split(","),da=z(x[0]),ea=z(x[1]),fa=z(x[2]),A=z(x[3]),B=z(x[4]),C=z(x[5]),D=z(x[6]);function z(a){return function(b){return p.prototype.toString.call(b)==="[object "+a+"]"}}
2
+ function ga(a){if(!a.SugarMethods){ha(a,"SugarMethods",{});E(a,n,n,{restore:function(){var b=arguments.length===0,c=F(arguments);G(a.SugarMethods,function(d,e){if(b||c.indexOf(d)>-1)ha(e.wa?a.prototype:a,d,e.method)})},extend:function(b,c,d){E(a,d!==n,c,b)}})}}function E(a,b,c,d){var e=b?a.prototype:a,f;ga(a);G(d,function(h,i){f=e[h];if(typeof c==="function")i=ia(e[h],i,c);if(c!==n||!e[h])ha(e,h,i);a.SugarMethods[h]={wa:b,method:i,Da:f}})}
3
+ function H(a,b,c,d,e){var f={};d=C(d)?d.split(","):d;d.forEach(function(h,i){e(f,h,i)});E(a,b,c,f)}function ia(a,b,c){return function(){return a&&(c===k||!c.apply(this,arguments))?a.apply(this,arguments):b.apply(this,arguments)}}function ha(a,b,c){if(ca)p.defineProperty(a,b,{value:c,configurable:k,enumerable:n,writable:k});else a[b]=c}function F(a,b){var c=[],d;for(d=0;d<a.length;d++){c.push(a[d]);b&&b.call(a,a[d],d)}return c}
4
+ function ja(a){if(!a||!a.call)throw new TypeError("Callback is not callable");}function I(a){return a!==void 0}function K(a){return a===void 0}function ka(a){return a&&typeof a==="object"}function M(a){return!!a&&p.prototype.toString.call(a)==="[object Object]"&&"hasOwnProperty"in a}function la(a,b){return p.hasOwnProperty.call(a,b)}function G(a,b){for(var c in a)if(la(a,c))if(b.call(a,c,a[c],a)===n)break}function ma(a,b){G(b,function(c){a[c]=b[c]});return a}function na(a){ma(this,a)}
5
+ na.prototype.constructor=p;function oa(a,b,c,d){var e=[];a=parseInt(a);for(var f=d<0;!f&&a<=b||f&&a>=b;){e.push(a);c&&c.call(this,a);a+=d||1}return e}function N(a,b,c){c=w[c||"round"];var d=w.pow(10,w.abs(b||0));if(b<0)d=1/d;return c(a*d)/d}function pa(a,b){return N(a,b,"floor")}function O(a,b,c,d){d=w.abs(a).toString(d||10);d=qa(b-d.replace(/\.\d+/,"").length,"0")+d;if(c||a<0)d=(a<0?"-":"+")+d;return d}
6
+ function ra(a){if(a>=11&&a<=13)return"th";else switch(a%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}function sa(){return"\t\n\u000b\u000c\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u2028\u2029\u3000\ufeff"}function qa(a,b){return q(w.max(0,I(a)?a:1)+1).join(b||"")}function ta(a,b){var c=a.toString().match(/[^/]*$/)[0];if(b)c=(c+b).split("").sort().join("").replace(/([gimy])\1+/g,"$1");return c}
7
+ function Q(a){C(a)||(a=t(a));return a.replace(/([\\/'*+?|()\[\]{}.^$])/g,"\\$1")}function ua(a,b){var c=typeof a,d,e,f,h,i,j;if(c==="string")return a;f=p.prototype.toString.call(a);d=M(a);e=f==="[object Array]";if(a!=l&&d||e){b||(b=[]);if(b.length>1)for(j=b.length;j--;)if(b[j]===a)return"CYC";b.push(a);d=t(a.constructor);h=e?a:p.keys(a).sort();for(j=0;j<h.length;j++){i=e?j:h[j];d+=i+ua(a[i],b)}b.pop()}else d=1/a===-Infinity?"-0":t(a&&a.valueOf?a.valueOf():a);return c+f+d}
8
+ function va(a){var b=p.prototype.toString.call(a);return b==="[object Date]"||b==="[object Array]"||b==="[object String]"||b==="[object Number]"||b==="[object RegExp]"||b==="[object Boolean]"||b==="[object Arguments]"||M(a)}function wa(a,b,c){var d=[],e=a.length,f=b[b.length-1]!==n,h;F(b,function(i){if(ea(i))return n;if(f){i%=e;if(i<0)i=e+i}h=c?a.charAt(i)||"":a[i];d.push(h)});return d.length<2?d[0]:d}
9
+ function xa(a,b){H(b,k,n,a,function(c,d){c[d+(d==="equal"?"s":"")]=function(){return p[d].apply(l,[this].concat(F(arguments)))}})}ga(p);G(x,function(a,b){ga(ba[b])});