sugar-rails 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/copy_release.sh +28 -0
- data/lib/sugar/rails/version.rb +2 -2
- data/vendor/assets/javascripts/precompiled/development/array.js +6 -4
- data/vendor/assets/javascripts/precompiled/development/date.js +45 -31
- data/vendor/assets/javascripts/precompiled/development/date_locales.js +274 -47
- data/vendor/assets/javascripts/precompiled/development/number.js +2 -2
- data/vendor/assets/javascripts/precompiled/development/object.js +2 -2
- data/vendor/assets/javascripts/precompiled/minified/array.js +15 -15
- data/vendor/assets/javascripts/precompiled/minified/core.js +9 -9
- data/vendor/assets/javascripts/precompiled/minified/date.js +40 -40
- data/vendor/assets/javascripts/precompiled/minified/date_locales.js +33 -22
- data/vendor/assets/javascripts/precompiled/minified/date_ranges.js +2 -2
- data/vendor/assets/javascripts/precompiled/minified/es5.js +8 -8
- data/vendor/assets/javascripts/precompiled/minified/function.js +4 -4
- data/vendor/assets/javascripts/precompiled/minified/inflections.js +5 -5
- data/vendor/assets/javascripts/precompiled/minified/language.js +5 -5
- data/vendor/assets/javascripts/precompiled/minified/number.js +5 -5
- data/vendor/assets/javascripts/precompiled/minified/object.js +5 -5
- data/vendor/assets/javascripts/precompiled/minified/regexp.js +2 -2
- data/vendor/assets/javascripts/precompiled/minified/string.js +11 -11
- data/vendor/assets/javascripts/sugar-development.js +330 -87
- data/vendor/assets/javascripts/sugar-full.js +145 -134
- data/vendor/assets/javascripts/sugar.js +102 -102
- metadata +5 -4
data/copy_release.sh
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
# assign the release version to copy
|
6
|
+
release=$1
|
7
|
+
|
8
|
+
if [ -z $release ]; then
|
9
|
+
echo "You must enter a release version." >&2
|
10
|
+
exit 1
|
11
|
+
fi
|
12
|
+
|
13
|
+
# working paths
|
14
|
+
copy_from="../Sugar/release"
|
15
|
+
copy_to="vendor/assets/javascripts"
|
16
|
+
|
17
|
+
# move the 'precompiled' directory
|
18
|
+
cp -R $copy_from/$release/precompiled $copy_to
|
19
|
+
|
20
|
+
# move the full scripts
|
21
|
+
cp $copy_from/$release/sugar-$release-full.development.js $copy_to/sugar-development.js
|
22
|
+
cp $copy_from/$release/sugar-$release-full.min.js $copy_to/sugar-full.js
|
23
|
+
cp $copy_from/$release/sugar-$release.min.js $copy_to/sugar.js
|
24
|
+
|
25
|
+
# update the version identifier
|
26
|
+
sed -i "" "s/SUGARJS_VERSION = \"[0-9\.]*\"/SUGARJS_VERSION = \"$release\"/" lib/sugar/rails/version.rb
|
27
|
+
|
28
|
+
echo "Successfully copied Sugar $release to the sugar-rails"
|
data/lib/sugar/rails/version.rb
CHANGED
@@ -314,13 +314,15 @@
|
|
314
314
|
*
|
315
315
|
***/
|
316
316
|
'create': function() {
|
317
|
-
var result = []
|
317
|
+
var result = [], tmp;
|
318
318
|
multiArgs(arguments, function(a) {
|
319
319
|
if(isObjectPrimitive(a)) {
|
320
|
-
|
321
|
-
|
322
|
-
|
320
|
+
tmp = array.prototype.slice.call(a);
|
321
|
+
if(tmp.length > 0) {
|
322
|
+
a = tmp;
|
323
|
+
}
|
323
324
|
}
|
325
|
+
result = result.concat(a);
|
324
326
|
});
|
325
327
|
return result;
|
326
328
|
}
|
@@ -90,6 +90,7 @@
|
|
90
90
|
{
|
91
91
|
token: '[Tt]{1,2}',
|
92
92
|
format: function(d, loc, n, format) {
|
93
|
+
if(loc['ampm'].length == 0) return '';
|
93
94
|
var hours = callDateGet(d, 'Hours');
|
94
95
|
var str = loc['ampm'][floor(hours / 12)];
|
95
96
|
if(format.length === 1) str = str.slice(0,1);
|
@@ -246,7 +247,7 @@
|
|
246
247
|
return English['units'][this['units'].indexOf(n) % 8];
|
247
248
|
},
|
248
249
|
|
249
|
-
|
250
|
+
getRelativeFormat: function(adu) {
|
250
251
|
return this.convertAdjustedToFormat(adu, adu[2] > 0 ? 'future' : 'past');
|
251
252
|
},
|
252
253
|
|
@@ -264,25 +265,23 @@
|
|
264
265
|
},
|
265
266
|
|
266
267
|
matchPM: function(str) {
|
267
|
-
return str === this['ampm'][1];
|
268
|
+
return str && str === this['ampm'][1];
|
268
269
|
},
|
269
270
|
|
270
|
-
convertAdjustedToFormat: function(adu,
|
271
|
-
var
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
}
|
279
|
-
} else {
|
280
|
-
mult = this['plural'] && num > 1 ? 1 : 0;
|
271
|
+
convertAdjustedToFormat: function(adu, mode) {
|
272
|
+
var sign, unit, mult,
|
273
|
+
num = adu[0],
|
274
|
+
u = adu[1],
|
275
|
+
ms = adu[2],
|
276
|
+
format = this[mode] || this['relative'];
|
277
|
+
if(isFunction(format)) {
|
278
|
+
return format.call(this, num, u, ms, mode);
|
281
279
|
}
|
280
|
+
mult = this['plural'] && num > 1 ? 1 : 0;
|
282
281
|
unit = this['units'][mult * 8 + u] || this['units'][u];
|
283
282
|
if(this['capitalizeUnit']) unit = simpleCapitalize(unit);
|
284
283
|
sign = this['modifiers'].filter(function(m) { return m.name == 'sign' && m.value == (ms > 0 ? 1 : -1); })[0];
|
285
|
-
return
|
284
|
+
return format.replace(/\{(.*?)\}/g, function(full, match) {
|
286
285
|
switch(match) {
|
287
286
|
case 'num': return num;
|
288
287
|
case 'unit': return unit;
|
@@ -300,9 +299,13 @@
|
|
300
299
|
|
301
300
|
src = src.replace(/\s+/g, '[-,. ]*');
|
302
301
|
src = src.replace(/\{([^,]+?)\}/g, function(all, k) {
|
303
|
-
var
|
302
|
+
var value, arr, result,
|
303
|
+
opt = k.match(/\?$/),
|
304
|
+
nc = k.match(/^(\d+)\??$/),
|
305
|
+
slice = k.match(/(\d)(?:-(\d))?/),
|
306
|
+
key = k.replace(/[^a-z]+$/, '');
|
304
307
|
if(nc) {
|
305
|
-
value = loc['
|
308
|
+
value = loc['tokens'][nc[1]];
|
306
309
|
} else if(loc[key]) {
|
307
310
|
value = loc[key];
|
308
311
|
} else if(loc[key + 's']) {
|
@@ -322,13 +325,17 @@
|
|
322
325
|
value = arrayToAlternates(value);
|
323
326
|
}
|
324
327
|
if(nc) {
|
325
|
-
|
328
|
+
result = '(?:' + value + ')';
|
326
329
|
} else {
|
327
330
|
if(!match) {
|
328
331
|
to.push(key);
|
329
332
|
}
|
330
|
-
|
333
|
+
result = '(' + value + ')';
|
331
334
|
}
|
335
|
+
if(opt) {
|
336
|
+
result += '?';
|
337
|
+
}
|
338
|
+
return result;
|
332
339
|
});
|
333
340
|
if(allowsTime) {
|
334
341
|
time = prepareTime(RequiredTime, loc, iso);
|
@@ -423,7 +430,7 @@
|
|
423
430
|
// Initialize the locale
|
424
431
|
loc = new Localization(set);
|
425
432
|
initializeField('modifiers');
|
426
|
-
'months,weekdays,units,numbers,articles,
|
433
|
+
'months,weekdays,units,numbers,articles,tokens,timeMarker,ampm,timeSuffixes,dateParse,timeParse'.split(',').forEach(initializeField);
|
427
434
|
|
428
435
|
canAbbreviate = !loc['monthSuffix'];
|
429
436
|
|
@@ -571,7 +578,7 @@
|
|
571
578
|
d.utc(forceUTC);
|
572
579
|
|
573
580
|
if(isDate(f)) {
|
574
|
-
d = f.
|
581
|
+
d = new date(f.getTime());
|
575
582
|
} else if(isNumber(f)) {
|
576
583
|
d = new date(f);
|
577
584
|
} else if(isObject(f)) {
|
@@ -824,7 +831,7 @@
|
|
824
831
|
adu[1] = 1;
|
825
832
|
adu[0] = 1;
|
826
833
|
}
|
827
|
-
return loc.
|
834
|
+
return loc.getRelativeFormat(adu);
|
828
835
|
}
|
829
836
|
|
830
837
|
format = format || 'long';
|
@@ -891,6 +898,10 @@
|
|
891
898
|
return isDefined(getParam(key));
|
892
899
|
}
|
893
900
|
|
901
|
+
function uniqueParamExists(key, isDay) {
|
902
|
+
return paramExists(key) || (isDay && paramExists('weekday'));
|
903
|
+
}
|
904
|
+
|
894
905
|
function canDisambiguate() {
|
895
906
|
var now = new date;
|
896
907
|
return (prefer === -1 && d > now) || (prefer === 1 && d < now);
|
@@ -915,7 +926,7 @@
|
|
915
926
|
// as setting hour: 3, minute: 345, etc.
|
916
927
|
iterateOverObject(DateUnitsReversed, function(i,u) {
|
917
928
|
var isDay = u.unit === 'day';
|
918
|
-
if(
|
929
|
+
if(uniqueParamExists(u.unit, isDay)) {
|
919
930
|
params.specificity = u.unit;
|
920
931
|
specificityIndex = +i;
|
921
932
|
return false;
|
@@ -925,6 +936,7 @@
|
|
925
936
|
}
|
926
937
|
});
|
927
938
|
|
939
|
+
|
928
940
|
// Now actually set or advance the date in order, higher units first.
|
929
941
|
DateUnits.forEach(function(u,i) {
|
930
942
|
var unit = u.unit, method = u.method, higherUnit = DateUnits[i - 1], value;
|
@@ -959,6 +971,7 @@
|
|
959
971
|
}
|
960
972
|
});
|
961
973
|
|
974
|
+
|
962
975
|
// If a weekday is included in the params, set it ahead of time and set the params
|
963
976
|
// to reflect the updated date so that resetting works properly.
|
964
977
|
if(!advance && !paramExists('day') && paramExists('weekday')) {
|
@@ -969,7 +982,7 @@
|
|
969
982
|
if(canDisambiguate()) {
|
970
983
|
iterateOverObject(DateUnitsReversed.slice(specificityIndex + 1), function(i,u) {
|
971
984
|
var ambiguous = u.ambiguous || (u.unit === 'week' && paramExists('weekday'));
|
972
|
-
if(ambiguous && !
|
985
|
+
if(ambiguous && !uniqueParamExists(u.unit, u.unit === 'day')) {
|
973
986
|
d[u.addMethod](prefer);
|
974
987
|
return false;
|
975
988
|
}
|
@@ -2139,7 +2152,7 @@
|
|
2139
2152
|
'units': 'millisecond:|s,second:|s,minute:|s,hour:|s,day:|s,week:|s,month:|s,year:|s',
|
2140
2153
|
'numbers': 'one,two,three,four,five,six,seven,eight,nine,ten',
|
2141
2154
|
'articles': 'a,an,the',
|
2142
|
-
'
|
2155
|
+
'tokens': 'the,st|nd|rd|th,of',
|
2143
2156
|
'short': '{Month} {d}, {yyyy}',
|
2144
2157
|
'long': '{Month} {d}, {yyyy} {h}:{mm}{tt}',
|
2145
2158
|
'full': '{Weekday} {Month} {d}, {yyyy} {h}:{mm}:{ss}{tt}',
|
@@ -2151,7 +2164,7 @@
|
|
2151
2164
|
{ 'name': 'day', 'src': 'today', 'value': 0 },
|
2152
2165
|
{ 'name': 'day', 'src': 'tomorrow', 'value': 1 },
|
2153
2166
|
{ 'name': 'sign', 'src': 'ago|before', 'value': -1 },
|
2154
|
-
{ 'name': 'sign', 'src': 'from now|after|from|in', 'value': 1 },
|
2167
|
+
{ 'name': 'sign', 'src': 'from now|after|from|in|later', 'value': 1 },
|
2155
2168
|
{ 'name': 'edge', 'src': 'last day', 'value': -2 },
|
2156
2169
|
{ 'name': 'edge', 'src': 'end', 'value': -1 },
|
2157
2170
|
{ 'name': 'edge', 'src': 'first day|beginning', 'value': 1 },
|
@@ -2162,20 +2175,21 @@
|
|
2162
2175
|
'dateParse': [
|
2163
2176
|
'{num} {unit} {sign}',
|
2164
2177
|
'{sign} {num} {unit}',
|
2165
|
-
'{num} {unit=4-5} {sign} {day}',
|
2166
2178
|
'{month} {year}',
|
2167
2179
|
'{shift} {unit=5-7}',
|
2168
|
-
'{0
|
2180
|
+
'{0?} {date}{1}',
|
2181
|
+
'{0?} {edge} of {shift?} {unit=4-7?}{month?}{year?}'
|
2169
2182
|
],
|
2170
2183
|
'timeParse': [
|
2171
2184
|
'{0} {num}{1} {day} of {month} {year?}',
|
2172
|
-
'{weekday?} {month} {date}{1} {year?}',
|
2185
|
+
'{weekday?} {month} {date}{1?} {year?}',
|
2173
2186
|
'{date} {month} {year}',
|
2174
2187
|
'{shift} {weekday}',
|
2175
2188
|
'{shift} week {weekday}',
|
2176
|
-
'{weekday} {2} {shift} week',
|
2177
|
-
'{
|
2178
|
-
'{0
|
2189
|
+
'{weekday} {2?} {shift} week',
|
2190
|
+
'{num} {unit=4-5} {sign} {day}',
|
2191
|
+
'{0?} {date}{1} of {month}',
|
2192
|
+
'{0?}{month?} {date?}{1?} of {shift} {unit=6-7}'
|
2179
2193
|
]
|
2180
2194
|
});
|
2181
2195
|
|