Ticket #8232: 8232.patch
File 8232.patch, 57.0 KB (added by , 5 years ago) |
---|
-
src/bp-core/js/vendor/jquery.atwho.js
6 6 */ 7 7 (function (root, factory) { 8 8 if (typeof define === 'function' && define.amd) { 9 // AMD. Register as an anonymous module unless amdModuleId is set 9 // AMD. Register as an anonymous module unless amdModuleId is set. 10 10 define(["jquery"], function (a0) { 11 11 return (factory(a0)); 12 12 }); -
src/bp-core/js/vendor/jquery.caret.js
6 6 }); 7 7 } else if (typeof exports === 'object') { 8 8 // Node. Does not work with strict CommonJS, but 9 // only CommonJS-like enviro ments that support module.exports,9 // only CommonJS-like environments that support module.exports, 10 10 // like Node. 11 11 module.exports = factory(require("jquery")); 12 12 } else { -
src/bp-core/js/vendor/moment-js/moment.js
28 28 29 29 function isObject(input) { 30 30 // IE8 will treat undefined and null as object if it wasn't for 31 // input != null 31 // input != null. 32 32 return input != null && Object.prototype.toString.call(input) === '[object Object]'; 33 33 } 34 34 … … 35 35 function isObjectEmpty(obj) { 36 36 var k; 37 37 for (k in obj) { 38 // even if its not own property I'd still call it non-empty38 // Even if its not own property I'd still call it non-empty. 39 39 return false; 40 40 } 41 41 return true; … … 224 224 225 225 var updateInProgress = false; 226 226 227 // Moment prototype object 227 // Moment prototype object. 228 228 function Moment(config) { 229 229 copyConfig(this, config); 230 230 this._d = new Date(config._d != null ? config._d.getTime() : NaN); … … 261 261 return value; 262 262 } 263 263 264 // compare two arrays, return the number of differences264 // Compare two arrays, return the number of differences. 265 265 function compareArrays(array1, array2, dontConvert) { 266 266 var len = Math.min(array1.length, array2.length), 267 267 lengthDiff = Math.abs(array1.length - array2.length), … … 300 300 for (var key in arguments[0]) { 301 301 arg += key + ': ' + arguments[0][key] + ', '; 302 302 } 303 arg = arg.slice(0, -2); // Remove trailing comma and space 303 arg = arg.slice(0, -2); // Remove trailing comma and space. 304 304 } else { 305 305 arg = arguments[i]; 306 306 } … … 367 367 if (hasOwnProp(parentConfig, prop) && 368 368 !hasOwnProp(childConfig, prop) && 369 369 isObject(parentConfig[prop])) { 370 // make sure changes to properties don't modify parent config370 // Make sure changes to properties don't modify parent config. 371 371 res[prop] = extend({}, res[prop]); 372 372 } 373 373 } … … 543 543 } 544 544 } 545 545 546 // MOMENTS 546 // MOMENTS. 547 547 548 548 function stringGet (units) { 549 549 units = normalizeUnits(units); … … 639 639 }; 640 640 } 641 641 642 // format date using native date object 642 // format date using native date object. 643 643 function formatMoment(m, format) { 644 644 if (!m.isValid()) { 645 645 return m.localeData().invalidDate(); … … 688 688 689 689 var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123 690 690 691 // any word (or two) characters or numbers including two/three word month in arabic.692 // includes scottish gaelic two word and hyphenated months 691 // Any word (or two) characters or numbers including two/three word month in arabic. 692 // includes scottish gaelic two word and hyphenated months. 693 693 var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i; 694 694 695 695 … … 766 766 indexOf = Array.prototype.indexOf; 767 767 } else { 768 768 indexOf = function (o) { 769 // I know 769 // I know. 770 770 var i; 771 771 for (i = 0; i < this.length; ++i) { 772 772 if (this[i] === o) { … … 781 781 return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); 782 782 } 783 783 784 // FORMATTING 784 // FORMATTING. 785 785 786 786 addFormatToken('M', ['MM', 2], 'Mo', function () { 787 787 return this.month() + 1; … … 795 795 return this.localeData().months(this, format); 796 796 }); 797 797 798 // ALIASES 798 // ALIASES. 799 799 800 800 addUnitAlias('month', 'M'); 801 801 802 // PRIORITY 802 // PRIORITY. 803 803 804 804 addUnitPriority('month', 8); 805 805 806 // PARSING 806 // PARSING. 807 807 808 808 addRegexToken('M', match1to2); 809 809 addRegexToken('MM', match1to2, match2); … … 820 820 821 821 addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { 822 822 var month = config._locale.monthsParse(input, token, config._strict); 823 // if we didn't find a month name, mark the date as invalid.823 // If we didn't find a month name, mark the date as invalid. 824 824 if (month != null) { 825 825 array[MONTH] = month; 826 826 } else { … … 828 828 } 829 829 }); 830 830 831 // LOCALES 831 // LOCALES. 832 832 833 833 var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/; 834 834 var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'); … … 903 903 this._shortMonthsParse = []; 904 904 } 905 905 906 // TODO: add sorting 906 // TODO: add sorting. 907 907 // Sorting makes sure if one month (or abbr) is a prefix of another 908 // see sorting in computeMonthsParse 908 // see sorting in computeMonthsParse. 909 909 for (i = 0; i < 12; i++) { 910 // make the regex if we don't have it already910 // Make the regex if we don't have it already. 911 911 mom = create_utc__createUTC([2000, i]); 912 912 if (strict && !this._longMonthsParse[i]) { 913 913 this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i'); … … 917 917 regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); 918 918 this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); 919 919 } 920 // test the regex920 // Test the regex. 921 921 if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) { 922 922 return i; 923 923 } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) { … … 928 928 } 929 929 } 930 930 931 // MOMENTS 931 // MOMENTS. 932 932 933 933 function setMonth (mom, value) { 934 934 var dayOfMonth; 935 935 936 936 if (!mom.isValid()) { 937 // No op 937 // No op. 938 938 return mom; 939 939 } 940 940 … … 1017 1017 var shortPieces = [], longPieces = [], mixedPieces = [], 1018 1018 i, mom; 1019 1019 for (i = 0; i < 12; i++) { 1020 // make the regex if we don't have it already1020 // Make the regex if we don't have it already. 1021 1021 mom = create_utc__createUTC([2000, i]); 1022 1022 shortPieces.push(this.monthsShort(mom, '')); 1023 1023 longPieces.push(this.months(mom, '')); … … 1043 1043 this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); 1044 1044 } 1045 1045 1046 // FORMATTING 1046 // FORMATTING. 1047 1047 1048 1048 addFormatToken('Y', 0, 0, function () { 1049 1049 var y = this.year(); … … 1058 1058 addFormatToken(0, ['YYYYY', 5], 0, 'year'); 1059 1059 addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); 1060 1060 1061 // ALIASES 1061 // ALIASES. 1062 1062 1063 1063 addUnitAlias('year', 'y'); 1064 1064 1065 // PRIORITIES 1065 // PRIORITIES. 1066 1066 1067 1067 addUnitPriority('year', 1); 1068 1068 1069 // PARSING 1069 // PARSING. 1070 1070 1071 1071 addRegexToken('Y', matchSigned); 1072 1072 addRegexToken('YY', match1to2, match2); … … 1085 1085 array[YEAR] = parseInt(input, 10); 1086 1086 }); 1087 1087 1088 // HELPERS 1088 // HELPERS. 1089 1089 1090 1090 function daysInYear(year) { 1091 1091 return isLeapYear(year) ? 366 : 365; … … 1095 1095 return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; 1096 1096 } 1097 1097 1098 // HOOKS 1098 // HOOKS. 1099 1099 1100 1100 utils_hooks__hooks.parseTwoDigitYear = function (input) { 1101 1101 return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); 1102 1102 }; 1103 1103 1104 // MOMENTS 1104 // MOMENTS. 1105 1105 1106 1106 var getSetYear = makeGetSet('FullYear', true); 1107 1107 … … 1110 1110 } 1111 1111 1112 1112 function createDate (y, m, d, h, M, s, ms) { 1113 // can't just apply() to create a date:1114 // http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply1113 // can't just apply() to create a date: 1114 // http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply 1115 1115 var date = new Date(y, m, d, h, M, s, ms); 1116 1116 1117 // the date constructor remaps years 0-99 to 1900-19991117 // The date constructor remaps years 0-99 to 1900-1999. 1118 1118 if (y < 100 && y >= 0 && isFinite(date.getFullYear())) { 1119 1119 date.setFullYear(y); 1120 1120 } … … 1124 1124 function createUTCDate (y) { 1125 1125 var date = new Date(Date.UTC.apply(null, arguments)); 1126 1126 1127 // the Date.UTC function remaps years 0-99 to 1900-19991127 // The Date.UTC function remaps years 0-99 to 1900-1999. 1128 1128 if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) { 1129 1129 date.setUTCFullYear(y); 1130 1130 } … … 1131 1131 return date; 1132 1132 } 1133 1133 1134 // start-of-first-week - start-of-year1134 // Start-of-first-week - start-of-year. 1135 1135 function firstWeekOffset(year, dow, doy) { 1136 var // first-week day -- which january is always in the first week (4 for iso, 1 for other)1136 var // First-week day -- which January is always in the first week (4 for iso, 1 for other). 1137 1137 fwd = 7 + dow - doy, 1138 // first-week day local weekday -- which local weekday is fwd1138 // First-week day local weekday -- which local weekday is fwd. 1139 1139 fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7; 1140 1140 1141 1141 return -fwdlw + fwd - 1; 1142 1142 } 1143 1143 1144 // http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday1144 // http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday 1145 1145 function dayOfYearFromWeeks(year, week, weekday, dow, doy) { 1146 1146 var localWeekday = (7 + weekday - dow) % 7, 1147 1147 weekOffset = firstWeekOffset(year, dow, doy), … … 1193 1193 return (daysInYear(year) - weekOffset + weekOffsetNext) / 7; 1194 1194 } 1195 1195 1196 // FORMATTING 1196 // FORMATTING. 1197 1197 1198 1198 addFormatToken('w', ['ww', 2], 'wo', 'week'); 1199 1199 addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek'); 1200 1200 1201 // ALIASES 1201 // ALIASES. 1202 1202 1203 1203 addUnitAlias('week', 'w'); 1204 1204 addUnitAlias('isoWeek', 'W'); 1205 1205 1206 // PRIORITIES 1206 // PRIORITIES. 1207 1207 1208 1208 addUnitPriority('week', 5); 1209 1209 addUnitPriority('isoWeek', 5); 1210 1210 1211 // PARSING 1211 // PARSING. 1212 1212 1213 1213 addRegexToken('w', match1to2); 1214 1214 addRegexToken('ww', match1to2, match2); … … 1219 1219 week[token.substr(0, 1)] = toInt(input); 1220 1220 }); 1221 1221 1222 // HELPERS 1222 // HELPERS. 1223 1223 1224 // LOCALES 1224 // LOCALES. 1225 1225 1226 1226 function localeWeek (mom) { 1227 1227 return weekOfYear(mom, this._week.dow, this._week.doy).week; … … 1240 1240 return this._week.doy; 1241 1241 } 1242 1242 1243 // MOMENTS 1243 // MOMENTS. 1244 1244 1245 1245 function getSetWeek (input) { 1246 1246 var week = this.localeData().week(this); … … 1252 1252 return input == null ? week : this.add((input - week) * 7, 'd'); 1253 1253 } 1254 1254 1255 // FORMATTING 1255 // FORMATTING. 1256 1256 1257 1257 addFormatToken('d', 0, 'do', 'day'); 1258 1258 … … 1271 1271 addFormatToken('e', 0, 0, 'weekday'); 1272 1272 addFormatToken('E', 0, 0, 'isoWeekday'); 1273 1273 1274 // ALIASES 1274 // ALIASES. 1275 1275 1276 1276 addUnitAlias('day', 'd'); 1277 1277 addUnitAlias('weekday', 'e'); 1278 1278 addUnitAlias('isoWeekday', 'E'); 1279 1279 1280 // PRIORITY 1280 // PRIORITY. 1281 1281 addUnitPriority('day', 11); 1282 1282 addUnitPriority('weekday', 11); 1283 1283 addUnitPriority('isoWeekday', 11); 1284 1284 1285 // PARSING 1285 // PARSING. 1286 1286 1287 1287 addRegexToken('d', match1to2); 1288 1288 addRegexToken('e', match1to2); … … 1299 1299 1300 1300 addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { 1301 1301 var weekday = config._locale.weekdaysParse(input, token, config._strict); 1302 // if we didn't get a weekday name, mark the date as invalid1302 // If we didn't get a weekday name, mark the date as invalid. 1303 1303 if (weekday != null) { 1304 1304 week.d = weekday; 1305 1305 } else { … … 1311 1311 week[token] = toInt(input); 1312 1312 }); 1313 1313 1314 // HELPERS 1314 // HELPERS. 1315 1315 1316 1316 function parseWeekday(input, locale) { 1317 1317 if (typeof input !== 'string') { … … 1337 1337 return isNaN(input) ? null : input; 1338 1338 } 1339 1339 1340 // LOCALES 1340 // LOCALES. 1341 1341 1342 1342 var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'); 1343 1343 function localeWeekdays (m, format) { … … 1437 1437 } 1438 1438 1439 1439 for (i = 0; i < 7; i++) { 1440 // make the regex if we don't have it already1440 // Make the regex if we don't have it already. 1441 1441 1442 1442 mom = create_utc__createUTC([2000, 1]).day(i); 1443 1443 if (strict && !this._fullWeekdaysParse[i]) { … … 1449 1449 regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); 1450 1450 this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); 1451 1451 } 1452 // test the regex1452 // Test the regex. 1453 1453 if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) { 1454 1454 return i; 1455 1455 } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) { … … 1462 1462 } 1463 1463 } 1464 1464 1465 // MOMENTS 1465 // MOMENTS. 1466 1466 1467 1467 function getSetDayOfWeek (input) { 1468 1468 if (!this.isValid()) { … … 1490 1490 return input != null ? this : NaN; 1491 1491 } 1492 1492 1493 // behaves the same as moment#day except1493 // Behaves the same as moment#day except 1494 1494 // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) 1495 1495 // as a setter, sunday should belong to the previous week. 1496 1496 … … 1604 1604 this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i'); 1605 1605 } 1606 1606 1607 // FORMATTING 1607 // FORMATTING. 1608 1608 1609 1609 function hFormat() { 1610 1610 return this.hours() % 12 || 12; … … 1645 1645 meridiem('a', true); 1646 1646 meridiem('A', false); 1647 1647 1648 // ALIASES 1648 // ALIASES. 1649 1649 1650 1650 addUnitAlias('hour', 'h'); 1651 1651 1652 // PRIORITY 1652 // PRIORITY. 1653 1653 addUnitPriority('hour', 13); 1654 1654 1655 // PARSING 1655 // PARSING. 1656 1656 1657 1657 function matchMeridiem (isStrict, locale) { 1658 1658 return locale._meridiemParse; … … 1706 1706 array[SECOND] = toInt(input.substr(pos2)); 1707 1707 }); 1708 1708 1709 // LOCALES 1709 // LOCALES. 1710 1710 1711 1711 function localeIsPM (input) { 1712 1712 // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays … … 1724 1724 } 1725 1725 1726 1726 1727 // MOMENTS 1727 // MOMENTS. 1728 1728 1729 1729 // Setting the hour should keep the time, because the user explicitly 1730 1730 // specified which hour he wants. So trying to maintain the same hour (in … … 1752 1752 meridiemParse: defaultLocaleMeridiemParse 1753 1753 }; 1754 1754 1755 // internal storage for locale config files1755 // Internal storage for locale config files. 1756 1756 var locales = {}; 1757 1757 var globalLocale; 1758 1758 … … 1760 1760 return key ? key.toLowerCase().replace('_', '-') : key; 1761 1761 } 1762 1762 1763 // pick the locale from the array1763 // Pick the locale from the array 1764 1764 // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each 1765 1765 // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root 1766 1766 function chooseLocale(names) { … … 1777 1777 return locale; 1778 1778 } 1779 1779 if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { 1780 // the next array item is better than a shallower substring of this one1780 // The next array item is better than a shallower substring of this one. 1781 1781 break; 1782 1782 } 1783 1783 j--; … … 1789 1789 1790 1790 function loadLocale(name) { 1791 1791 var oldLocale = null; 1792 // TODO: Find a better way to register and load all the locales in Node 1792 // TODO: Find a better way to register and load all the locales in Node. 1793 1793 if (!locales[name] && (typeof module !== 'undefined') && 1794 1794 module && module.exports) { 1795 1795 try { 1796 1796 oldLocale = globalLocale._abbr; 1797 1797 require('./locale/' + name); 1798 // because defineLocale currently also sets the global locale, we1799 // want to undo that for lazy loaded locales 1798 // Because defineLocale currently also sets the global locale, we 1799 // want to undo that for lazy loaded locales. 1800 1800 locale_locales__getSetGlobalLocale(oldLocale); 1801 1801 } catch (e) { } 1802 1802 } … … 1840 1840 if (locales[config.parentLocale] != null) { 1841 1841 parentConfig = locales[config.parentLocale]._config; 1842 1842 } else { 1843 // treat as if there is no base config1843 // Treat as if there is no base config. 1844 1844 deprecateSimple('parentLocaleUndefined', 1845 1845 'specified parentLocale is not defined yet. See http://momentjs.com/guides/#/warnings/parent-locale/'); 1846 1846 } … … 1847 1847 } 1848 1848 locales[name] = new Locale(mergeConfigs(parentConfig, config)); 1849 1849 1850 // backwards compat for now: also set the locale 1850 // backwards compat for now: also set the locale. 1851 1851 locale_locales__getSetGlobalLocale(name); 1852 1852 1853 1853 return locales[name]; 1854 1854 } else { 1855 // useful for testing1855 // Useful for testing. 1856 1856 delete locales[name]; 1857 1857 return null; 1858 1858 } … … 1861 1861 function updateLocale(name, config) { 1862 1862 if (config != null) { 1863 1863 var locale, parentConfig = baseConfig; 1864 // MERGE 1864 // MERGE. 1865 1865 if (locales[name] != null) { 1866 1866 parentConfig = locales[name]._config; 1867 1867 } … … 1870 1870 locale.parentLocale = locales[name]; 1871 1871 locales[name] = locale; 1872 1872 1873 // backwards compat for now: also set the locale1873 // Backwards compat for now: also set the locale. 1874 1874 locale_locales__getSetGlobalLocale(name); 1875 1875 } else { 1876 // pass null for config to unupdate, useful for tests1876 // Pass null for config to unupdate, useful for tests. 1877 1877 if (locales[name] != null) { 1878 1878 if (locales[name].parentLocale != null) { 1879 1879 locales[name] = locales[name].parentLocale; … … 1885 1885 return locales[name]; 1886 1886 } 1887 1887 1888 // returns locale data1888 // Returns locale data. 1889 1889 function locale_locales__getLocale (key) { 1890 1890 var locale; 1891 1891 … … 1898 1898 } 1899 1899 1900 1900 if (!isArray(key)) { 1901 // short-circuit everything else1901 // Short-circuit everything else. 1902 1902 locale = loadLocale(key); 1903 1903 if (locale) { 1904 1904 return locale; … … 1959 1959 ['YYYY-MM', /\d{4}-\d\d/, false], 1960 1960 ['YYYYYYMMDD', /[+-]\d{10}/], 1961 1961 ['YYYYMMDD', /\d{8}/], 1962 // YYYYMM is NOT allowed by the standard 1962 // YYYYMM is NOT allowed by the standard. 1963 1963 ['GGGG[W]WWE', /\d{4}W\d{3}/], 1964 1964 ['GGGG[W]WW', /\d{4}W\d{2}/, false], 1965 1965 ['YYYYDDD', /\d{7}/] 1966 1966 ]; 1967 1967 1968 // iso time formats and regexes1968 // Iso time formats and regexes. 1969 1969 var isoTimes = [ 1970 1970 ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], 1971 1971 ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], … … 1980 1980 1981 1981 var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i; 1982 1982 1983 // date from iso format1983 // Date from iso format. 1984 1984 function configFromISO(config) { 1985 1985 var i, l, 1986 1986 string = config._i, … … 2033 2033 } 2034 2034 } 2035 2035 2036 // date from iso format or fallback2036 // Date from iso format or fallback. 2037 2037 function configFromString(config) { 2038 2038 var matched = aspNetJsonRegex.exec(config._i); 2039 2039 … … 2079 2079 return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()]; 2080 2080 } 2081 2081 2082 // convert an array to a date.2082 // Convert an array to a date. 2083 2083 // the array should mirror the parameters below 2084 2084 // note: all values past the year are optional and will default to the lowest possible value. 2085 // [year, month, day , hour, minute, second, millisecond] 2085 // [year, month, day , hour, minute, second, millisecond]. 2086 2086 function configFromArray (config) { 2087 2087 var i, date, input = [], currentDate, yearToUse; 2088 2088 … … 2092 2092 2093 2093 currentDate = currentDateArray(config); 2094 2094 2095 // compute day of the year from weeks and weekdays2095 // Compute day of the year from weeks and weekdays. 2096 2096 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { 2097 2097 dayOfYearFromWeekInfo(config); 2098 2098 } 2099 2099 2100 // if the day of the year is set, figure out what it is2100 // If the day of the year is set, figure out what it is. 2101 2101 if (config._dayOfYear) { 2102 2102 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]); 2103 2103 … … 2119 2119 config._a[i] = input[i] = currentDate[i]; 2120 2120 } 2121 2121 2122 // Zero out whatever was not defaulted, including time 2122 // Zero out whatever was not defaulted, including time. 2123 2123 for (; i < 7; i++) { 2124 2124 config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; 2125 2125 } … … 2171 2171 week = defaults(w.w, 1); 2172 2172 2173 2173 if (w.d != null) { 2174 // weekday -- low day numbers are considered next week2174 // Weekday -- low day numbers are considered next week. 2175 2175 weekday = w.d; 2176 2176 if (weekday < 0 || weekday > 6) { 2177 2177 weekdayOverflow = true; 2178 2178 } 2179 2179 } else if (w.e != null) { 2180 // local weekday -- counting starts from begining of week2180 // Local weekday -- counting starts from beginning of week. 2181 2181 weekday = w.e + dow; 2182 2182 if (w.e < 0 || w.e > 6) { 2183 2183 weekdayOverflow = true; 2184 2184 } 2185 2185 } else { 2186 // default to begining of week2186 // Default to beginning of week. 2187 2187 weekday = dow; 2188 2188 } 2189 2189 } … … 2198 2198 } 2199 2199 } 2200 2200 2201 // constant that refers to the ISO standard2201 // Constant that refers to the ISO standard. 2202 2202 utils_hooks__hooks.ISO_8601 = function () {}; 2203 2203 2204 // date from string and format string2204 // Date from string and format string. 2205 2205 function configFromStringAndFormat(config) { 2206 // TODO: Move this to another part of the creation flow to prevent circular deps 2206 // TODO: Move this to another part of the creation flow to prevent circular deps. 2207 2207 if (config._f === utils_hooks__hooks.ISO_8601) { 2208 2208 configFromISO(config); 2209 2209 return; … … 2212 2212 config._a = []; 2213 2213 getParsingFlags(config).empty = true; 2214 2214 2215 // This array is used to make a Date, either with `new Date` or `Date.UTC` 2215 // This array is used to make a Date, either with `new Date` or `Date.UTC`. 2216 2216 var string = '' + config._i, 2217 2217 i, parsedInput, tokens, token, skipped, 2218 2218 stringLength = string.length, … … 2223 2223 for (i = 0; i < tokens.length; i++) { 2224 2224 token = tokens[i]; 2225 2225 parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; 2226 // console.log('token', token, 'parsedInput', parsedInput,2226 // Console.log('token', token, 'parsedInput', parsedInput, 2227 2227 // 'regex', getParseRegexForToken(token, config)); 2228 2228 if (parsedInput) { 2229 2229 skipped = string.substr(0, string.indexOf(parsedInput)); … … 2233 2233 string = string.slice(string.indexOf(parsedInput) + parsedInput.length); 2234 2234 totalParsedInputLength += parsedInput.length; 2235 2235 } 2236 // don't parse if it's not a known token2236 // Don't parse if it's not a known token. 2237 2237 if (formatTokenFunctions[token]) { 2238 2238 if (parsedInput) { 2239 2239 getParsingFlags(config).empty = false; … … 2248 2248 } 2249 2249 } 2250 2250 2251 // add remaining unparsed input length to the string2251 // Add remaining unparsed input length to the string. 2252 2252 getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength; 2253 2253 if (string.length > 0) { 2254 2254 getParsingFlags(config).unusedInput.push(string); 2255 2255 } 2256 2256 2257 // clear _12h flag if hour is <= 122257 // Clear _12h flag if hour is <= 12. 2258 2258 if (config._a[HOUR] <= 12 && 2259 2259 getParsingFlags(config).bigHour === true && 2260 2260 config._a[HOUR] > 0) { … … 2275 2275 var isPm; 2276 2276 2277 2277 if (meridiem == null) { 2278 // nothing to do2278 // Nothing to do. 2279 2279 return hour; 2280 2280 } 2281 2281 if (locale.meridiemHour != null) { 2282 2282 return locale.meridiemHour(hour, meridiem); 2283 2283 } else if (locale.isPM != null) { 2284 // Fallback 2284 // Fallback. 2285 2285 isPm = locale.isPM(meridiem); 2286 2286 if (isPm && hour < 12) { 2287 2287 hour += 12; … … 2291 2291 } 2292 2292 return hour; 2293 2293 } else { 2294 // this is not supposed to happen2294 // This is not supposed to happen. 2295 2295 return hour; 2296 2296 } 2297 2297 } 2298 2298 2299 // date from string and array of format strings2299 // Date from string and array of format strings. 2300 2300 function configFromStringAndArray(config) { 2301 2301 var tempConfig, 2302 2302 bestMoment, … … 2324 2324 continue; 2325 2325 } 2326 2326 2327 // if there is any input that was not parsed add a penalty for that format2327 // If there is any input that was not parsed add a penalty for that format. 2328 2328 currentScore += getParsingFlags(tempConfig).charsLeftOver; 2329 2329 2330 // or tokens2330 // Or tokens. 2331 2331 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; 2332 2332 2333 2333 getParsingFlags(tempConfig).score = currentScore; … … 2357 2357 function createFromConfig (config) { 2358 2358 var res = new Moment(checkOverflow(prepareConfig(config))); 2359 2359 if (res._nextDay) { 2360 // Adding is smart enough around DST 2360 // Adding is smart enough around DST. 2361 2361 res.add(1, 'd'); 2362 2362 res._nextDay = undefined; 2363 2363 } … … 2433 2433 (isArray(input) && input.length === 0)) { 2434 2434 input = undefined; 2435 2435 } 2436 // object construction must be done this way.2436 // Object construction must be done this way. 2437 2437 // https://github.com/moment/moment/issues/1423 2438 2438 c._isAMomentObject = true; 2439 2439 c._useUTC = c._isUTC = isUTC; … … 2524 2524 seconds = normalizedInput.second || 0, 2525 2525 milliseconds = normalizedInput.millisecond || 0; 2526 2526 2527 // representation for dateAddRemove2527 // Representation for dateAddRemove. 2528 2528 this._milliseconds = +milliseconds + 2529 2529 seconds * 1e3 + // 1000 2530 2530 minutes * 6e4 + // 1000 * 60 2531 hours * 1000 * 60 * 60; // using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/29782531 hours * 1000 * 60 * 60; // Using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 2532 2532 // Because of dateAddRemove treats 24 hours as different from a 2533 // day when working around DST, we need to store them separately 2533 // day when working around DST, we need to store them separately. 2534 2534 this._days = +days + 2535 2535 weeks * 7; 2536 2536 // It is impossible translate months into days without knowing … … 2559 2559 } 2560 2560 } 2561 2561 2562 // FORMATTING 2562 // FORMATTING. 2563 2563 2564 2564 function offset (token, separator) { 2565 2565 addFormatToken(token, 0, 0, function () { … … 2576 2576 offset('Z', ':'); 2577 2577 offset('ZZ', ''); 2578 2578 2579 // PARSING 2579 // PARSING. 2580 2580 2581 2581 addRegexToken('Z', matchShortOffset); 2582 2582 addRegexToken('ZZ', matchShortOffset); … … 2585 2585 config._tzm = offsetFromString(matchShortOffset, input); 2586 2586 }); 2587 2587 2588 // HELPERS 2588 // HELPERS. 2589 2589 2590 // timezone chunker2590 // Timezone chunker 2591 2591 // '+10:00' > ['10', '00'] 2592 // '-1530' > ['-15', '30'] 2592 // '-1530' > ['-15', '30']. 2593 2593 var chunkOffset = /([\+\-]|\d\d)/gi; 2594 2594 2595 2595 function offsetFromString(matcher, string) { … … 2769 2769 return this.isValid() ? this._isUTC && this._offset === 0 : false; 2770 2770 } 2771 2771 2772 // ASP.NET json date format regex 2772 // ASP.NET json date format regex. 2773 2773 var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/; 2774 2774 2775 2775 // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html 2776 2776 // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere 2777 // and further modified to allow for strings containing both week and day 2777 // and further modified to allow for strings containing both week and day. 2778 2778 var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/; 2779 2779 2780 2780 function create__createDuration (input, key) { 2781 2781 var duration = input, 2782 // matching against regexp is expensive, do it on demand2782 // Matching against regexp is expensive, do it on demand. 2783 2783 match = null, 2784 2784 sign, 2785 2785 ret, … … 2806 2806 h : toInt(match[HOUR]) * sign, 2807 2807 m : toInt(match[MINUTE]) * sign, 2808 2808 s : toInt(match[SECOND]) * sign, 2809 ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match2809 ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // The millisecond decimal point is included in the match. 2810 2810 }; 2811 2811 } else if (!!(match = isoRegex.exec(input))) { 2812 2812 sign = (match[1] === '-') ? -1 : 1; … … 2819 2819 m : parseIso(match[7], sign), 2820 2820 s : parseIso(match[8], sign) 2821 2821 }; 2822 } else if (duration == null) { // checks for null or undefined2822 } else if (duration == null) { // Checks for null or undefined. 2823 2823 duration = {}; 2824 2824 } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) { 2825 2825 diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to)); … … 2845 2845 // converts floats to ints. 2846 2846 // inp may be undefined, so careful calling replace on it. 2847 2847 var res = inp && parseFloat(inp.replace(',', '.')); 2848 // apply sign while we're at it2848 // Apply sign while we're at it. 2849 2849 return (isNaN(res) ? 0 : res) * sign; 2850 2850 } 2851 2851 … … 2881 2881 return res; 2882 2882 } 2883 2883 2884 // TODO: remove 'name' arg after deprecation is removed 2884 // TODO: remove 'name' arg after deprecation is removed. 2885 2885 function createAdder(direction, name) { 2886 2886 return function (val, period) { 2887 2887 var dur, tmp; 2888 // invert the arguments, but complain about it2888 // Invert the arguments, but complain about it. 2889 2889 if (period !== null && !isNaN(+period)) { 2890 2890 deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 2891 2891 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'); … … 2905 2905 months = absRound(duration._months); 2906 2906 2907 2907 if (!mom.isValid()) { 2908 // No op 2908 // No op. 2909 2909 return; 2910 2910 } 2911 2911 … … 3048 3048 } 3049 3049 3050 3050 function monthDiff (a, b) { 3051 // difference in months3051 // Difference in months. 3052 3052 var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()), 3053 // b is in (anchor - 1 month, anchor + 1 month)3053 // B is in (anchor - 1 month, anchor + 1 month). 3054 3054 anchor = a.clone().add(wholeMonthDiff, 'months'), 3055 3055 anchor2, adjust; 3056 3056 3057 3057 if (b - anchor < 0) { 3058 3058 anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); 3059 // linear across the month 3059 // linear across the month. 3060 3060 adjust = (b - anchor) / (anchor - anchor2); 3061 3061 } else { 3062 3062 anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); 3063 // linear across the month 3063 // linear across the month. 3064 3064 adjust = (b - anchor) / (anchor2 - anchor); 3065 3065 } 3066 3066 3067 // check for negative zero, return zero if negative zero3067 // Check for negative zero, return zero if negative zero. 3068 3068 return -(wholeMonthDiff + adjust) || 0; 3069 3069 } 3070 3070 … … 3079 3079 var m = this.clone().utc(); 3080 3080 if (0 < m.year() && m.year() <= 9999) { 3081 3081 if (isFunction(Date.prototype.toISOString)) { 3082 // native implementation is ~50x faster, use it when we can3082 // Native implementation is ~50x faster, use it when we can. 3083 3083 return this.toDate().toISOString(); 3084 3084 } else { 3085 3085 return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); … … 3159 3159 3160 3160 function startOf (units) { 3161 3161 units = normalizeUnits(units); 3162 // the following switch intentionally omits break keywords3162 // The following switch intentionally omits break keywords 3163 3163 // to utilize falling through the cases. 3164 3164 switch (units) { 3165 3165 case 'year': … … 3185 3185 this.milliseconds(0); 3186 3186 } 3187 3187 3188 // weeks are a special case3188 // Weeks are a special case. 3189 3189 if (units === 'week') { 3190 3190 this.weekday(0); 3191 3191 } … … 3193 3193 this.isoWeekday(1); 3194 3194 } 3195 3195 3196 // quarters are also special3196 // Quarters are also special. 3197 3197 if (units === 'quarter') { 3198 3198 this.month(Math.floor(this.month() / 3) * 3); 3199 3199 } … … 3246 3246 } 3247 3247 3248 3248 function toJSON () { 3249 // new Date(NaN).toJSON() === null3249 // New Date(NaN).toJSON() === null. 3250 3250 return this.isValid() ? this.toISOString() : null; 3251 3251 } 3252 3252 … … 3272 3272 }; 3273 3273 } 3274 3274 3275 // FORMATTING 3275 // FORMATTING. 3276 3276 3277 3277 addFormatToken(0, ['gg', 2], 0, function () { 3278 3278 return this.weekYear() % 100; … … 3291 3291 addWeekYearFormatToken('GGGG', 'isoWeekYear'); 3292 3292 addWeekYearFormatToken('GGGGG', 'isoWeekYear'); 3293 3293 3294 // ALIASES 3294 // ALIASES. 3295 3295 3296 3296 addUnitAlias('weekYear', 'gg'); 3297 3297 addUnitAlias('isoWeekYear', 'GG'); 3298 3298 3299 // PRIORITY 3299 // PRIORITY. 3300 3300 3301 3301 addUnitPriority('weekYear', 1); 3302 3302 addUnitPriority('isoWeekYear', 1); 3303 3303 3304 3304 3305 // PARSING 3305 // PARSING. 3306 3306 3307 3307 addRegexToken('G', matchSigned); 3308 3308 addRegexToken('g', matchSigned); … … 3321 3321 week[token] = utils_hooks__hooks.parseTwoDigitYear(input); 3322 3322 }); 3323 3323 3324 // MOMENTS 3324 // MOMENTS. 3325 3325 3326 3326 function getSetWeekYear (input) { 3327 3327 return getSetWeekYearHelper.call(this, … … 3369 3369 return this; 3370 3370 } 3371 3371 3372 // FORMATTING 3372 // FORMATTING. 3373 3373 3374 3374 addFormatToken('Q', 0, 'Qo', 'quarter'); 3375 3375 3376 // ALIASES 3376 // ALIASES. 3377 3377 3378 3378 addUnitAlias('quarter', 'Q'); 3379 3379 3380 // PRIORITY 3380 // PRIORITY. 3381 3381 3382 3382 addUnitPriority('quarter', 7); 3383 3383 3384 // PARSING 3384 // PARSING. 3385 3385 3386 3386 addRegexToken('Q', match1); 3387 3387 addParseToken('Q', function (input, array) { … … 3388 3388 array[MONTH] = (toInt(input) - 1) * 3; 3389 3389 }); 3390 3390 3391 // MOMENTS 3391 // MOMENTS. 3392 3392 3393 3393 function getSetQuarter (input) { 3394 3394 return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3); 3395 3395 } 3396 3396 3397 // FORMATTING 3397 // FORMATTING. 3398 3398 3399 3399 addFormatToken('D', ['DD', 2], 'Do', 'date'); 3400 3400 3401 // ALIASES 3401 // ALIASES. 3402 3402 3403 3403 addUnitAlias('date', 'D'); 3404 3404 3405 // PRIOROITY 3405 // PRIOROITY. 3406 3406 addUnitPriority('date', 9); 3407 3407 3408 // PARSING 3408 // PARSING. 3409 3409 3410 3410 addRegexToken('D', match1to2); 3411 3411 addRegexToken('DD', match1to2, match2); … … 3418 3418 array[DATE] = toInt(input.match(match1to2)[0], 10); 3419 3419 }); 3420 3420 3421 // MOMENTS 3421 // MOMENTS. 3422 3422 3423 3423 var getSetDayOfMonth = makeGetSet('Date', true); 3424 3424 3425 // FORMATTING 3425 // FORMATTING. 3426 3426 3427 3427 addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear'); 3428 3428 3429 // ALIASES 3429 // ALIASES. 3430 3430 3431 3431 addUnitAlias('dayOfYear', 'DDD'); 3432 3432 3433 // PRIORITY 3433 // PRIORITY. 3434 3434 addUnitPriority('dayOfYear', 4); 3435 3435 3436 // PARSING 3436 // PARSING. 3437 3437 3438 3438 addRegexToken('DDD', match1to3); 3439 3439 addRegexToken('DDDD', match3); … … 3441 3441 config._dayOfYear = toInt(input); 3442 3442 }); 3443 3443 3444 // HELPERS 3444 // HELPERS. 3445 3445 3446 // MOMENTS 3446 // MOMENTS. 3447 3447 3448 3448 function getSetDayOfYear (input) { 3449 3449 var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1; … … 3450 3450 return input == null ? dayOfYear : this.add((input - dayOfYear), 'd'); 3451 3451 } 3452 3452 3453 // FORMATTING 3453 // FORMATTING. 3454 3454 3455 3455 addFormatToken('m', ['mm', 2], 0, 'minute'); 3456 3456 3457 // ALIASES 3457 // ALIASES. 3458 3458 3459 3459 addUnitAlias('minute', 'm'); 3460 3460 3461 // PRIORITY 3461 // PRIORITY. 3462 3462 3463 3463 addUnitPriority('minute', 14); 3464 3464 3465 // PARSING 3465 // PARSING. 3466 3466 3467 3467 addRegexToken('m', match1to2); 3468 3468 addRegexToken('mm', match1to2, match2); 3469 3469 addParseToken(['m', 'mm'], MINUTE); 3470 3470 3471 // MOMENTS 3471 // MOMENTS. 3472 3472 3473 3473 var getSetMinute = makeGetSet('Minutes', false); 3474 3474 3475 // FORMATTING 3475 // FORMATTING. 3476 3476 3477 3477 addFormatToken('s', ['ss', 2], 0, 'second'); 3478 3478 3479 // ALIASES 3479 // ALIASES. 3480 3480 3481 3481 addUnitAlias('second', 's'); 3482 3482 3483 // PRIORITY 3483 // PRIORITY. 3484 3484 3485 3485 addUnitPriority('second', 15); 3486 3486 3487 // PARSING 3487 // PARSING. 3488 3488 3489 3489 addRegexToken('s', match1to2); 3490 3490 addRegexToken('ss', match1to2, match2); 3491 3491 addParseToken(['s', 'ss'], SECOND); 3492 3492 3493 // MOMENTS 3493 // MOMENTS. 3494 3494 3495 3495 var getSetSecond = makeGetSet('Seconds', false); 3496 3496 3497 // FORMATTING 3497 // FORMATTING. 3498 3498 3499 3499 addFormatToken('S', 0, 0, function () { 3500 3500 return ~~(this.millisecond() / 100); … … 3525 3525 }); 3526 3526 3527 3527 3528 // ALIASES 3528 // ALIASES. 3529 3529 3530 3530 addUnitAlias('millisecond', 'ms'); 3531 3531 3532 // PRIORITY 3532 // PRIORITY. 3533 3533 3534 3534 addUnitPriority('millisecond', 16); 3535 3535 3536 // PARSING 3536 // PARSING. 3537 3537 3538 3538 addRegexToken('S', match1to3, match1); 3539 3539 addRegexToken('SS', match1to3, match2); … … 3551 3551 for (token = 'S'; token.length <= 9; token += 'S') { 3552 3552 addParseToken(token, parseMs); 3553 3553 } 3554 // MOMENTS 3554 // MOMENTS. 3555 3555 3556 3556 var getSetMillisecond = makeGetSet('Milliseconds', false); 3557 3557 3558 // FORMATTING 3558 // FORMATTING. 3559 3559 3560 3560 addFormatToken('z', 0, 0, 'zoneAbbr'); 3561 3561 addFormatToken('zz', 0, 0, 'zoneName'); 3562 3562 3563 // MOMENTS 3563 // MOMENTS. 3564 3564 3565 3565 function getZoneAbbr () { 3566 3566 return this._isUTC ? 'UTC' : ''; … … 3610 3610 momentPrototype__proto.valueOf = to_type__valueOf; 3611 3611 momentPrototype__proto.creationData = creationData; 3612 3612 3613 // Year 3613 // Year. 3614 3614 momentPrototype__proto.year = getSetYear; 3615 3615 momentPrototype__proto.isLeapYear = getIsLeapYear; 3616 3616 3617 // Week Year 3617 // Week Year. 3618 3618 momentPrototype__proto.weekYear = getSetWeekYear; 3619 3619 momentPrototype__proto.isoWeekYear = getSetISOWeekYear; 3620 3620 3621 // Quarter 3621 // Quarter. 3622 3622 momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter; 3623 3623 3624 // Month 3624 // Month. 3625 3625 momentPrototype__proto.month = getSetMonth; 3626 3626 momentPrototype__proto.daysInMonth = getDaysInMonth; 3627 3627 3628 // Week 3628 // Week. 3629 3629 momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek; 3630 3630 momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek; 3631 3631 momentPrototype__proto.weeksInYear = getWeeksInYear; 3632 3632 momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear; 3633 3633 3634 // Day 3634 // Day. 3635 3635 momentPrototype__proto.date = getSetDayOfMonth; 3636 3636 momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek; 3637 3637 momentPrototype__proto.weekday = getSetLocaleDayOfWeek; … … 3638 3638 momentPrototype__proto.isoWeekday = getSetISODayOfWeek; 3639 3639 momentPrototype__proto.dayOfYear = getSetDayOfYear; 3640 3640 3641 // Hour 3641 // Hour. 3642 3642 momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour; 3643 3643 3644 // Minute 3644 // Minute. 3645 3645 momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute; 3646 3646 3647 // Second 3647 // Second. 3648 3648 momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond; 3649 3649 3650 // Millisecond 3650 // Millisecond. 3651 3651 momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond; 3652 3652 3653 // Offset 3653 // Offset. 3654 3654 momentPrototype__proto.utcOffset = getSetOffset; 3655 3655 momentPrototype__proto.utc = setOffsetToUTC; 3656 3656 momentPrototype__proto.local = setOffsetToLocal; … … 3662 3662 momentPrototype__proto.isUtc = isUtc; 3663 3663 momentPrototype__proto.isUTC = isUtc; 3664 3664 3665 // Timezone 3665 // Timezone. 3666 3666 momentPrototype__proto.zoneAbbr = getZoneAbbr; 3667 3667 momentPrototype__proto.zoneName = getZoneName; 3668 3668 3669 // Deprecations 3669 // Deprecations. 3670 3670 momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth); 3671 3671 momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth); 3672 3672 momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear); … … 3699 3699 prototype__proto.pastFuture = pastFuture; 3700 3700 prototype__proto.set = locale_set__set; 3701 3701 3702 // Month 3702 // Month. 3703 3703 prototype__proto.months = localeMonths; 3704 3704 prototype__proto.monthsShort = localeMonthsShort; 3705 3705 prototype__proto.monthsParse = localeMonthsParse; … … 3706 3706 prototype__proto.monthsRegex = monthsRegex; 3707 3707 prototype__proto.monthsShortRegex = monthsShortRegex; 3708 3708 3709 // Week 3709 // Week. 3710 3710 prototype__proto.week = localeWeek; 3711 3711 prototype__proto.firstDayOfYear = localeFirstDayOfYear; 3712 3712 prototype__proto.firstDayOfWeek = localeFirstDayOfWeek; 3713 3713 3714 // Day of Week 3714 // Day of Week. 3715 3715 prototype__proto.weekdays = localeWeekdays; 3716 3716 prototype__proto.weekdaysMin = localeWeekdaysMin; 3717 3717 prototype__proto.weekdaysShort = localeWeekdaysShort; … … 3721 3721 prototype__proto.weekdaysShortRegex = weekdaysShortRegex; 3722 3722 prototype__proto.weekdaysMinRegex = weekdaysMinRegex; 3723 3723 3724 // Hours 3724 // Hours. 3725 3725 prototype__proto.isPM = localeIsPM; 3726 3726 prototype__proto.meridiem = localeMeridiem; 3727 3727 … … 3827 3827 } 3828 3828 }); 3829 3829 3830 // Side effect imports 3830 // Side effect imports. 3831 3831 utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale); 3832 3832 utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale); 3833 3833 … … 3860 3860 return duration._bubble(); 3861 3861 } 3862 3862 3863 // supports only 2.0-style add(1, 's') or add(duration)3863 // Supports only 2.0-style add(1, 's') or add(duration). 3864 3864 function duration_add_subtract__add (input, value) { 3865 3865 return duration_add_subtract__addSubtract(this, input, value, 1); 3866 3866 } 3867 3867 3868 // supports only 2.0-style subtract(1, 's') or subtract(duration)3868 // Supports only 2.0-style subtract(1, 's') or subtract(duration). 3869 3869 function duration_add_subtract__subtract (input, value) { 3870 3870 return duration_add_subtract__addSubtract(this, input, value, -1); 3871 3871 } … … 3885 3885 var data = this._data; 3886 3886 var seconds, minutes, hours, years, monthsFromDays; 3887 3887 3888 // if we have a mix of positive and negative values, bubble down first3889 // check: https://github.com/moment/moment/issues/2166 3888 // If we have a mix of positive and negative values, bubble down first 3889 // check: https://github.com/moment/moment/issues/2166. 3890 3890 if (!((milliseconds >= 0 && days >= 0 && months >= 0) || 3891 3891 (milliseconds <= 0 && days <= 0 && months <= 0))) { 3892 3892 milliseconds += absCeil(monthsToDays(months) + days) * 864e5; … … 3909 3909 3910 3910 days += absFloor(hours / 24); 3911 3911 3912 // convert days to months3912 // Convert days to months. 3913 3913 monthsFromDays = absFloor(daysToMonths(days)); 3914 3914 months += monthsFromDays; 3915 3915 days -= absCeil(monthsToDays(monthsFromDays)); 3916 3916 3917 // 12 months -> 1 year 3917 // 12 months -> 1 year. 3918 3918 years = absFloor(months / 12); 3919 3919 months %= 12; 3920 3920 … … 3927 3927 3928 3928 function daysToMonths (days) { 3929 3929 // 400 years have 146097 days (taking into account leap year rules) 3930 // 400 years have 12 months === 4800 3930 // 400 years have 12 months === 4800. 3931 3931 return days * 4800 / 146097; 3932 3932 } 3933 3933 3934 3934 function monthsToDays (months) { 3935 // the reverse of daysToMonths3935 // The reverse of daysToMonths. 3936 3936 return months * 146097 / 4800; 3937 3937 } 3938 3938 … … 3948 3948 months = this._months + daysToMonths(days); 3949 3949 return units === 'month' ? months : months / 12; 3950 3950 } else { 3951 // handle milliseconds separately because of floating point math errors (issue #1867)3951 // Handle milliseconds separately because of floating point math errors (issue #1867). 3952 3952 days = this._days + Math.round(monthsToDays(this._months)); 3953 3953 switch (units) { 3954 3954 case 'week' : return days / 7 + milliseconds / 6048e5; … … 3956 3956 case 'hour' : return days * 24 + milliseconds / 36e5; 3957 3957 case 'minute' : return days * 1440 + milliseconds / 6e4; 3958 3958 case 'second' : return days * 86400 + milliseconds / 1000; 3959 // Math.floor prevents floating point math errors here 3959 // Math.floor prevents floating point math errors here. 3960 3960 case 'millisecond': return Math.floor(days * 864e5) + milliseconds; 3961 3961 default: throw new Error('Unknown unit ' + units); 3962 3962 } … … 4013 4013 4014 4014 var round = Math.round; 4015 4015 var thresholds = { 4016 s: 45, // seconds to minute4017 m: 45, // minutes to hour4018 h: 22, // hours to day4019 d: 26, // days to month4020 M: 11 // months to year4016 s: 45, // Seconds to minute. 4017 m: 45, // Minutes to hour. 4018 h: 22, // Hours to day. 4019 d: 26, // Days to month. 4020 M: 11 // Months to year. 4021 4021 }; 4022 4022 4023 // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize4023 // Helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize. 4024 4024 function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { 4025 4025 return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); 4026 4026 } … … 4051 4051 return substituteTimeAgo.apply(null, a); 4052 4052 } 4053 4053 4054 // This function allows you to set the rounding function for relative time strings 4054 // This function allows you to set the rounding function for relative time strings. 4055 4055 function duration_humanize__getSetRelativeTimeRounding (roundingFunction) { 4056 4056 if (roundingFunction === undefined) { 4057 4057 return round; … … 4063 4063 return false; 4064 4064 } 4065 4065 4066 // This function allows you to set a threshold for relative time strings 4066 // This function allows you to set a threshold for relative time strings. 4067 4067 function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) { 4068 4068 if (thresholds[threshold] === undefined) { 4069 4069 return false; … … 4092 4092 // for ISO strings we do not use the normal bubbling rules: 4093 4093 // * milliseconds bubble up until they become hours 4094 4094 // * days do not bubble at all 4095 // * months bubble up until they become years 4095 // * months bubble up until they become years. 4096 4096 // This is because there is no context-free conversion between hours and days 4097 4097 // (think of clock changes) 4098 // and also not between days and months (28-31 days per month) 4098 // and also not between days and months (28-31 days per month). 4099 4099 var seconds = iso_string__abs(this._milliseconds) / 1000; 4100 4100 var days = iso_string__abs(this._days); 4101 4101 var months = iso_string__abs(this._months); 4102 4102 var minutes, hours, years; 4103 4103 4104 // 3600 seconds -> 60 minutes -> 1 hour 4104 // 3600 seconds -> 60 minutes -> 1 hour. 4105 4105 minutes = absFloor(seconds / 60); 4106 4106 hours = absFloor(minutes / 60); 4107 4107 seconds %= 60; 4108 4108 minutes %= 60; 4109 4109 4110 // 12 months -> 1 year 4110 // 12 months -> 1 year. 4111 4111 years = absFloor(months / 12); 4112 4112 months %= 12; 4113 4113 4114 4114 4115 // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js4115 // Inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js 4116 4116 var Y = years; 4117 4117 var M = months; 4118 4118 var D = days; … … 4122 4122 var total = this.asSeconds(); 4123 4123 4124 4124 if (!total) { 4125 // this is the same as C#'s (Noda) and python (isodate)...4126 // but not other JS (goog.date) 4125 // This is the same as C#'s (Noda) and python (isodate)... 4126 // but not other JS (goog.date). 4127 4127 return 'P0D'; 4128 4128 } 4129 4129 … … 4170 4170 duration_prototype__proto.locale = locale; 4171 4171 duration_prototype__proto.localeData = localeData; 4172 4172 4173 // Deprecations 4173 // Deprecations. 4174 4174 duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString); 4175 4175 duration_prototype__proto.lang = lang; 4176 4176 4177 // Side effect imports 4177 // Side effect imports. 4178 4178 4179 // FORMATTING 4179 // FORMATTING. 4180 4180 4181 4181 addFormatToken('X', 0, 0, 'unix'); 4182 4182 addFormatToken('x', 0, 0, 'valueOf'); 4183 4183 4184 // PARSING 4184 // PARSING. 4185 4185 4186 4186 addRegexToken('x', matchSigned); 4187 4187 addRegexToken('X', matchTimestamp); … … 4192 4192 config._d = new Date(toInt(input)); 4193 4193 }); 4194 4194 4195 // Side effect imports 4195 // Side effect imports. 4196 4196 4197 4197 4198 4198 utils_hooks__hooks.version = '2.15.1'; -
src/bp-core/js/webcam.js
4 4 5 5 ( function() { 6 6 7 // Bail if not set 7 // Bail if not set. 8 8 if ( typeof BP_Uploader === 'undefined' ) { 9 9 return; 10 10 } … … 30 30 31 31 setView: function( view ) { 32 32 if ( 'camera' !== view ) { 33 // Stop the camera if needed 33 // Stop the camera if needed. 34 34 if ( ! _.isNull( this.params.video ) ) { 35 35 this.stop(); 36 36 37 // Remove all warnings as we're changing the view 37 // Remove all warnings as we're changing the view. 38 38 this.removeWarning(); 39 39 } 40 40 41 // Stop as this is not Camera area 41 // Stop as this is not Camera area. 42 42 return; 43 43 } 44 44 45 // Create the WebCam view 45 // Create the WebCam view. 46 46 var cameraView = new bp.Views.WebCamAvatar( { model: new Backbone.Model( { user_media: false } ) } ); 47 47 48 // Make sure the flipped param is reset 48 // Make sure the flipped param is reset. 49 49 this.params.flipped = false; 50 50 51 // Add it to views 51 // Add it to views. 52 52 bp.Avatar.views.add( { id: 'camera', view: cameraView } ); 53 53 54 // Display it 54 // Display it. 55 55 cameraView.inject( '.bp-avatar' ); 56 56 }, 57 57 … … 69 69 var video = bp.WebCam.params.video; 70 70 bp.WebCam.params.videoStream = stream; 71 71 72 // User Feedback 72 // User Feedback. 73 73 bp.WebCam.displayWarning( 'loaded' ); 74 74 75 75 video.onerror = function () { 76 // User Feedback 76 // User Feedback. 77 77 bp.WebCam.displayWarning( 'videoerror' ); 78 78 79 79 if ( video ) { … … 83 83 84 84 stream.onended = bp.WebCam.noStream(); 85 85 86 // Older browsers may not have srcObject 86 // Older browsers may not have srcObject. 87 87 if ( 'srcObject' in video ) { 88 88 video.srcObject = stream; 89 89 } else { … … 121 121 122 122 noStream: function() { 123 123 if ( _.isNull( bp.WebCam.params.videoStream ) ) { 124 // User Feedback 124 // User Feedback. 125 125 bp.WebCam.displayWarning( 'noaccess' ); 126 126 127 127 bp.WebCam.removeView(); … … 133 133 bp.WebCam.displayWarning( 'nocapture' ); 134 134 } 135 135 136 // Remove the view 136 // Remove the view. 137 137 bp.WebCam.removeView(); 138 138 139 139 bp.Avatar.setAvatar( avatar ); … … 156 156 } 157 157 }; 158 158 159 // BuddyPress WebCam view 159 // BuddyPress WebCam view. 160 160 bp.Views.WebCamAvatar = bp.View.extend( { 161 161 tagName: 'div', 162 162 id: 'bp-webcam-avatar', … … 180 180 ); 181 181 182 182 if ( typeof navigator.getUserMedia !== 'undefined' ) { 183 // We need to add some cropping stuff to use bp.Avatar.setAvatar() 183 // We need to add some cropping stuff to use bp.Avatar.setAvatar(). 184 184 params = _.extend( _.pick( BP_Uploader.settings.defaults.multipart_params.bp_params, 185 185 'object', 186 186 'item_id', … … 216 216 bp.WebCam.params.video = this.options.video.el; 217 217 bp.WebCam.params.canvas = this.options.canvas.el; 218 218 219 // User Feedback 219 // User Feedback. 220 220 bp.WebCam.displayWarning( 'requesting' ); 221 221 222 222 // Use deprecated getUserMedia call for browsers that require it. … … 234 234 }).then(bp.WebCam.gotStream, bp.WebCam.noStream) 235 235 // ES3 compatibility. 236 236 ['catch'](function() { 237 // User Feedback 237 // User Feedback. 238 238 bp.WebCam.displayWarning( 'errormsg' ); 239 239 }); 240 240 } … … 245 245 event.preventDefault(); 246 246 247 247 if ( ! bp.WebCam.params.capture_enable ) { 248 // User Feedback 248 // User Feedback. 249 249 bp.WebCam.displayWarning( 'loading' ); 250 250 return; 251 251 } … … 255 255 return; 256 256 } 257 257 258 // Set the offset 258 // Set the offset. 259 259 sc = this.options.video.el.videoHeight; 260 260 sx = ( this.options.video.el.videoWidth - sc ) / 2; 261 261 … … 270 270 bp.WebCam.params.capture = this.options.canvas.el.toDataURL( 'image/png' ); 271 271 this.model.set( 'url', bp.WebCam.params.capture ); 272 272 273 // User Feedback 273 // User Feedback. 274 274 bp.WebCam.displayWarning( 'ready' ); 275 275 }, 276 276 … … 278 278 event.preventDefault(); 279 279 280 280 if ( ! bp.WebCam.params.capture ) { 281 // User Feedback 281 // User Feedback. 282 282 bp.WebCam.displayWarning( 'nocapture' ); 283 283 return; 284 284 } … … 288 288 } 289 289 } ); 290 290 291 // BuddyPress Video stream view 291 // BuddyPress Video stream view. 292 292 bp.Views.WebCamVideo = bp.View.extend( { 293 293 tagName: 'video', 294 294 id: 'bp-webcam-video', … … 297 297 } 298 298 } ); 299 299 300 // BuddyPress Canvas (capture) view 300 // BuddyPress Canvas (capture) view. 301 301 bp.Views.WebCamCanvas = bp.View.extend( { 302 302 tagName: 'canvas', 303 303 id: 'bp-webcam-canvas', … … 307 307 }, 308 308 309 309 initialize: function() { 310 // Make sure to take in account bp_core_avatar_full_height or bp_core_avatar_full_width php filters 310 // Make sure to take in account bp_core_avatar_full_height or bp_core_avatar_full_width php filters. 311 311 if ( ! _.isUndefined( BP_Uploader.settings.crop.full_h ) && ! _.isUndefined( BP_Uploader.settings.crop.full_w ) ) { 312 312 this.el.attributes.width.value = BP_Uploader.settings.crop.full_w; 313 313 this.el.attributes.height.value = BP_Uploader.settings.crop.full_h;