picker.date.js 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  1. /*!
  2. * Date picker for pickadate.js v3.6.4
  3. * http://amsul.github.io/pickadate.js/date.htm
  4. */
  5. (function ( factory ) {
  6. // AMD.
  7. if ( typeof define == 'function' && define.amd )
  8. define( ['./picker', 'jquery'], factory )
  9. // Node.js/browserify.
  10. else if ( typeof exports == 'object' )
  11. module.exports = factory( require('./picker.js'), require('jquery') )
  12. // Browser globals.
  13. else factory( Picker, jQuery )
  14. }(function( Picker, $ ) {
  15. /**
  16. * Globals and constants
  17. */
  18. var DAYS_IN_WEEK = 7,
  19. WEEKS_IN_CALENDAR = 6,
  20. _ = Picker._
  21. /**
  22. * The date picker constructor
  23. */
  24. function DatePicker( picker, settings ) {
  25. var calendar = this,
  26. element = picker.$node[ 0 ],
  27. elementValue = element.value,
  28. elementDataValue = picker.$node.data( 'value' ),
  29. valueString = elementDataValue || elementValue,
  30. formatString = elementDataValue ? settings.formatSubmit : settings.format,
  31. isRTL = function() {
  32. return element.currentStyle ?
  33. // For IE.
  34. element.currentStyle.direction == 'rtl' :
  35. // For normal browsers.
  36. getComputedStyle( picker.$root[0] ).direction == 'rtl'
  37. }
  38. calendar.settings = settings
  39. calendar.$node = picker.$node
  40. // The queue of methods that will be used to build item objects.
  41. calendar.queue = {
  42. min: 'measure create',
  43. max: 'measure create',
  44. now: 'now create',
  45. select: 'parse create validate',
  46. highlight: 'parse navigate create validate',
  47. view: 'parse create validate viewset',
  48. disable: 'deactivate',
  49. enable: 'activate'
  50. }
  51. // The component's item object.
  52. calendar.item = {}
  53. calendar.item.clear = null
  54. calendar.item.disable = ( settings.disable || [] ).slice( 0 )
  55. calendar.item.enable = -(function( collectionDisabled ) {
  56. return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1
  57. })( calendar.item.disable )
  58. calendar.
  59. set( 'min', settings.min ).
  60. set( 'max', settings.max ).
  61. set( 'now' )
  62. // When there’s a value, set the `select`, which in turn
  63. // also sets the `highlight` and `view`.
  64. if ( valueString ) {
  65. calendar.set( 'select', valueString, {
  66. format: formatString,
  67. defaultValue: true
  68. })
  69. }
  70. // If there’s no value, default to highlighting “today”.
  71. else {
  72. calendar.
  73. set( 'select', null ).
  74. set( 'highlight', calendar.item.now )
  75. }
  76. // The keycode to movement mapping.
  77. calendar.key = {
  78. 40: 7, // Down
  79. 38: -7, // Up
  80. 39: function() { return isRTL() ? -1 : 1 }, // Right
  81. 37: function() { return isRTL() ? 1 : -1 }, // Left
  82. go: function( timeChange ) {
  83. var highlightedObject = calendar.item.highlight,
  84. targetDate = new Date( highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange )
  85. calendar.set(
  86. 'highlight',
  87. targetDate,
  88. { interval: timeChange }
  89. )
  90. this.render()
  91. }
  92. }
  93. // Bind some picker events.
  94. picker.
  95. on( 'render', function() {
  96. picker.$root.find( '.' + settings.klass.selectMonth ).on( 'change', function() {
  97. var value = this.value
  98. if ( value ) {
  99. picker.set( 'highlight', [ picker.get( 'view' ).year, value, picker.get( 'highlight' ).date ] )
  100. picker.$root.find( '.' + settings.klass.selectMonth ).trigger( 'focus' )
  101. }
  102. })
  103. picker.$root.find( '.' + settings.klass.selectYear ).on( 'change', function() {
  104. var value = this.value
  105. if ( value ) {
  106. picker.set( 'highlight', [ value, picker.get( 'view' ).month, picker.get( 'highlight' ).date ] )
  107. picker.$root.find( '.' + settings.klass.selectYear ).trigger( 'focus' )
  108. }
  109. })
  110. }, 1 ).
  111. on( 'open', function() {
  112. var includeToday = ''
  113. if ( calendar.disabled( calendar.get('now') ) ) {
  114. includeToday = ':not(.' + settings.klass.buttonToday + ')'
  115. }
  116. picker.$root.find( 'button' + includeToday + ', select' ).attr( 'disabled', false )
  117. }, 1 ).
  118. on( 'close', function() {
  119. picker.$root.find( 'button, select' ).attr( 'disabled', true )
  120. }, 1 )
  121. } //DatePicker
  122. /**
  123. * Set a datepicker item object.
  124. */
  125. DatePicker.prototype.set = function( type, value, options ) {
  126. var calendar = this,
  127. calendarItem = calendar.item
  128. // If the value is `null` just set it immediately.
  129. if ( value === null ) {
  130. if ( type == 'clear' ) type = 'select'
  131. calendarItem[ type ] = value
  132. return calendar
  133. }
  134. // Otherwise go through the queue of methods, and invoke the functions.
  135. // Update this as the time unit, and set the final value as this item.
  136. // * In the case of `enable`, keep the queue but set `disable` instead.
  137. // And in the case of `flip`, keep the queue but set `enable` instead.
  138. calendarItem[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = calendar.queue[ type ].split( ' ' ).map( function( method ) {
  139. value = calendar[ method ]( type, value, options )
  140. return value
  141. }).pop()
  142. // Check if we need to cascade through more updates.
  143. if ( type == 'select' ) {
  144. calendar.set( 'highlight', calendarItem.select, options )
  145. }
  146. else if ( type == 'highlight' ) {
  147. calendar.set( 'view', calendarItem.highlight, options )
  148. }
  149. else if ( type.match( /^(flip|min|max|disable|enable)$/ ) ) {
  150. if ( calendarItem.select && calendar.disabled( calendarItem.select ) ) {
  151. calendar.set( 'select', calendarItem.select, options )
  152. }
  153. if ( calendarItem.highlight && calendar.disabled( calendarItem.highlight ) ) {
  154. calendar.set( 'highlight', calendarItem.highlight, options )
  155. }
  156. }
  157. return calendar
  158. } //DatePicker.prototype.set
  159. /**
  160. * Get a datepicker item object.
  161. */
  162. DatePicker.prototype.get = function( type ) {
  163. return this.item[ type ]
  164. } //DatePicker.prototype.get
  165. /**
  166. * Create a picker date object.
  167. */
  168. DatePicker.prototype.create = function( type, value, options ) {
  169. var isInfiniteValue,
  170. calendar = this
  171. // If there’s no value, use the type as the value.
  172. value = value === undefined ? type : value
  173. // If it’s infinity, update the value.
  174. if ( value == -Infinity || value == Infinity ) {
  175. isInfiniteValue = value
  176. }
  177. // If it’s an object, use the native date object.
  178. else if ( $.isPlainObject( value ) && _.isInteger( value.pick ) ) {
  179. value = value.obj
  180. }
  181. // If it’s an array, convert it into a date and make sure
  182. // that it’s a valid date – otherwise default to today.
  183. else if ( $.isArray( value ) ) {
  184. value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] )
  185. value = _.isDate( value ) ? value : calendar.create().obj
  186. }
  187. // If it’s a number or date object, make a normalized date.
  188. else if ( _.isInteger( value ) || _.isDate( value ) ) {
  189. value = calendar.normalize( new Date( value ), options )
  190. }
  191. // If it’s a literal true or any other case, set it to now.
  192. else /*if ( value === true )*/ {
  193. value = calendar.now( type, value, options )
  194. }
  195. // Return the compiled object.
  196. return {
  197. year: isInfiniteValue || value.getFullYear(),
  198. month: isInfiniteValue || value.getMonth(),
  199. date: isInfiniteValue || value.getDate(),
  200. day: isInfiniteValue || value.getDay(),
  201. obj: isInfiniteValue || value,
  202. pick: isInfiniteValue || value.getTime()
  203. }
  204. } //DatePicker.prototype.create
  205. /**
  206. * Create a range limit object using an array, date object,
  207. * literal “true”, or integer relative to another time.
  208. */
  209. DatePicker.prototype.createRange = function( from, to ) {
  210. var calendar = this,
  211. createDate = function( date ) {
  212. if ( date === true || $.isArray( date ) || _.isDate( date ) ) {
  213. return calendar.create( date )
  214. }
  215. return date
  216. }
  217. // Create objects if possible.
  218. if ( !_.isInteger( from ) ) {
  219. from = createDate( from )
  220. }
  221. if ( !_.isInteger( to ) ) {
  222. to = createDate( to )
  223. }
  224. // Create relative dates.
  225. if ( _.isInteger( from ) && $.isPlainObject( to ) ) {
  226. from = [ to.year, to.month, to.date + from ];
  227. }
  228. else if ( _.isInteger( to ) && $.isPlainObject( from ) ) {
  229. to = [ from.year, from.month, from.date + to ];
  230. }
  231. return {
  232. from: createDate( from ),
  233. to: createDate( to )
  234. }
  235. } //DatePicker.prototype.createRange
  236. /**
  237. * Check if a date unit falls within a date range object.
  238. */
  239. DatePicker.prototype.withinRange = function( range, dateUnit ) {
  240. range = this.createRange(range.from, range.to)
  241. return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick
  242. }
  243. /**
  244. * Check if two date range objects overlap.
  245. */
  246. DatePicker.prototype.overlapRanges = function( one, two ) {
  247. var calendar = this
  248. // Convert the ranges into comparable dates.
  249. one = calendar.createRange( one.from, one.to )
  250. two = calendar.createRange( two.from, two.to )
  251. return calendar.withinRange( one, two.from ) || calendar.withinRange( one, two.to ) ||
  252. calendar.withinRange( two, one.from ) || calendar.withinRange( two, one.to )
  253. }
  254. /**
  255. * Get the date today.
  256. */
  257. DatePicker.prototype.now = function( type, value, options ) {
  258. value = new Date()
  259. if ( options && options.rel ) {
  260. value.setDate( value.getDate() + options.rel )
  261. }
  262. return this.normalize( value, options )
  263. }
  264. /**
  265. * Navigate to next/prev month.
  266. */
  267. DatePicker.prototype.navigate = function( type, value, options ) {
  268. var targetDateObject,
  269. targetYear,
  270. targetMonth,
  271. targetDate,
  272. isTargetArray = $.isArray( value ),
  273. isTargetObject = $.isPlainObject( value ),
  274. viewsetObject = this.item.view/*,
  275. safety = 100*/
  276. if ( isTargetArray || isTargetObject ) {
  277. if ( isTargetObject ) {
  278. targetYear = value.year
  279. targetMonth = value.month
  280. targetDate = value.date
  281. }
  282. else {
  283. targetYear = +value[0]
  284. targetMonth = +value[1]
  285. targetDate = +value[2]
  286. }
  287. // If we’re navigating months but the view is in a different
  288. // month, navigate to the view’s year and month.
  289. if ( options && options.nav && viewsetObject && viewsetObject.month !== targetMonth ) {
  290. targetYear = viewsetObject.year
  291. targetMonth = viewsetObject.month
  292. }
  293. // Figure out the expected target year and month.
  294. targetDateObject = new Date( targetYear, targetMonth + ( options && options.nav ? options.nav : 0 ), 1 )
  295. targetYear = targetDateObject.getFullYear()
  296. targetMonth = targetDateObject.getMonth()
  297. // If the month we’re going to doesn’t have enough days,
  298. // keep decreasing the date until we reach the month’s last date.
  299. while ( /*safety &&*/ new Date( targetYear, targetMonth, targetDate ).getMonth() !== targetMonth ) {
  300. targetDate -= 1
  301. /*safety -= 1
  302. if ( !safety ) {
  303. throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.'
  304. }*/
  305. }
  306. value = [ targetYear, targetMonth, targetDate ]
  307. }
  308. return value
  309. } //DatePicker.prototype.navigate
  310. /**
  311. * Normalize a date by setting the hours to midnight.
  312. */
  313. DatePicker.prototype.normalize = function( value/*, options*/ ) {
  314. value.setHours( 0, 0, 0, 0 )
  315. return value
  316. }
  317. /**
  318. * Measure the range of dates.
  319. */
  320. DatePicker.prototype.measure = function( type, value/*, options*/ ) {
  321. var calendar = this
  322. // If it's an integer, get a date relative to today.
  323. if ( _.isInteger( value ) ) {
  324. value = calendar.now( type, value, { rel: value } )
  325. }
  326. // If it’s anything false-y, remove the limits.
  327. else if ( !value ) {
  328. value = type == 'min' ? -Infinity : Infinity
  329. }
  330. // If it’s a string, parse it.
  331. else if ( typeof value == 'string' ) {
  332. value = calendar.parse( type, value )
  333. }
  334. return value
  335. } ///DatePicker.prototype.measure
  336. /**
  337. * Create a viewset object based on navigation.
  338. */
  339. DatePicker.prototype.viewset = function( type, dateObject/*, options*/ ) {
  340. return this.create([ dateObject.year, dateObject.month, 1 ])
  341. }
  342. /**
  343. * Validate a date as enabled and shift if needed.
  344. */
  345. DatePicker.prototype.validate = function( type, dateObject, options ) {
  346. var calendar = this,
  347. // Keep a reference to the original date.
  348. originalDateObject = dateObject,
  349. // Make sure we have an interval.
  350. interval = options && options.interval ? options.interval : 1,
  351. // Check if the calendar enabled dates are inverted.
  352. isFlippedBase = calendar.item.enable === -1,
  353. // Check if we have any enabled dates after/before now.
  354. hasEnabledBeforeTarget, hasEnabledAfterTarget,
  355. // The min & max limits.
  356. minLimitObject = calendar.item.min,
  357. maxLimitObject = calendar.item.max,
  358. // Check if we’ve reached the limit during shifting.
  359. reachedMin, reachedMax,
  360. // Check if the calendar is inverted and at least one weekday is enabled.
  361. hasEnabledWeekdays = isFlippedBase && calendar.item.disable.filter( function( value ) {
  362. // If there’s a date, check where it is relative to the target.
  363. if ( $.isArray( value ) ) {
  364. var dateTime = calendar.create( value ).pick
  365. if ( dateTime < dateObject.pick ) hasEnabledBeforeTarget = true
  366. else if ( dateTime > dateObject.pick ) hasEnabledAfterTarget = true
  367. }
  368. // Return only integers for enabled weekdays.
  369. return _.isInteger( value )
  370. }).length/*,
  371. safety = 100*/
  372. // Cases to validate for:
  373. // [1] Not inverted and date disabled.
  374. // [2] Inverted and some dates enabled.
  375. // [3] Not inverted and out of range.
  376. //
  377. // Cases to **not** validate for:
  378. // • Navigating months.
  379. // • Not inverted and date enabled.
  380. // • Inverted and all dates disabled.
  381. // • ..and anything else.
  382. if ( !options || (!options.nav && !options.defaultValue) ) if (
  383. /* 1 */ ( !isFlippedBase && calendar.disabled( dateObject ) ) ||
  384. /* 2 */ ( isFlippedBase && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
  385. /* 3 */ ( !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick) )
  386. ) {
  387. // When inverted, flip the direction if there aren’t any enabled weekdays
  388. // and there are no enabled dates in the direction of the interval.
  389. if ( isFlippedBase && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
  390. interval *= -1
  391. }
  392. // Keep looping until we reach an enabled date.
  393. while ( /*safety &&*/ calendar.disabled( dateObject ) ) {
  394. /*safety -= 1
  395. if ( !safety ) {
  396. throw 'Fell into an infinite loop while validating ' + dateObject.obj + '.'
  397. }*/
  398. // If we’ve looped into the next/prev month with a large interval, return to the original date and flatten the interval.
  399. if ( Math.abs( interval ) > 1 && ( dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month ) ) {
  400. dateObject = originalDateObject
  401. interval = interval > 0 ? 1 : -1
  402. }
  403. // If we’ve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit.
  404. if ( dateObject.pick <= minLimitObject.pick ) {
  405. reachedMin = true
  406. interval = 1
  407. dateObject = calendar.create([
  408. minLimitObject.year,
  409. minLimitObject.month,
  410. minLimitObject.date + (dateObject.pick === minLimitObject.pick ? 0 : -1)
  411. ])
  412. }
  413. else if ( dateObject.pick >= maxLimitObject.pick ) {
  414. reachedMax = true
  415. interval = -1
  416. dateObject = calendar.create([
  417. maxLimitObject.year,
  418. maxLimitObject.month,
  419. maxLimitObject.date + (dateObject.pick === maxLimitObject.pick ? 0 : 1)
  420. ])
  421. }
  422. // If we’ve reached both limits, just break out of the loop.
  423. if ( reachedMin && reachedMax ) {
  424. break
  425. }
  426. // Finally, create the shifted date using the interval and keep looping.
  427. dateObject = calendar.create([ dateObject.year, dateObject.month, dateObject.date + interval ])
  428. }
  429. } //endif
  430. // Return the date object settled on.
  431. return dateObject
  432. } //DatePicker.prototype.validate
  433. /**
  434. * Check if a date is disabled.
  435. */
  436. DatePicker.prototype.disabled = function( dateToVerify ) {
  437. var
  438. calendar = this,
  439. // Filter through the disabled dates to check if this is one.
  440. isDisabledMatch = calendar.item.disable.filter( function( dateToDisable ) {
  441. // If the date is a number, match the weekday with 0index and `firstDay` check.
  442. if ( _.isInteger( dateToDisable ) ) {
  443. return dateToVerify.day === ( calendar.settings.firstDay ? dateToDisable : dateToDisable - 1 ) % 7
  444. }
  445. // If it’s an array or a native JS date, create and match the exact date.
  446. if ( $.isArray( dateToDisable ) || _.isDate( dateToDisable ) ) {
  447. return dateToVerify.pick === calendar.create( dateToDisable ).pick
  448. }
  449. // If it’s an object, match a date within the “from” and “to” range.
  450. if ( $.isPlainObject( dateToDisable ) ) {
  451. return calendar.withinRange( dateToDisable, dateToVerify )
  452. }
  453. })
  454. // If this date matches a disabled date, confirm it’s not inverted.
  455. isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function( dateToDisable ) {
  456. return $.isArray( dateToDisable ) && dateToDisable[3] == 'inverted' ||
  457. $.isPlainObject( dateToDisable ) && dateToDisable.inverted
  458. }).length
  459. // Check the calendar “enabled” flag and respectively flip the
  460. // disabled state. Then also check if it’s beyond the min/max limits.
  461. return calendar.item.enable === -1 ? !isDisabledMatch : isDisabledMatch ||
  462. dateToVerify.pick < calendar.item.min.pick ||
  463. dateToVerify.pick > calendar.item.max.pick
  464. } //DatePicker.prototype.disabled
  465. /**
  466. * Parse a string into a usable type.
  467. */
  468. DatePicker.prototype.parse = function( type, value, options ) {
  469. var calendar = this,
  470. parsingObject = {}
  471. // If it’s already parsed, we’re good.
  472. if ( !value || typeof value != 'string' ) {
  473. return value
  474. }
  475. // We need a `.format` to parse the value with.
  476. if ( !( options && options.format ) ) {
  477. options = options || {}
  478. options.format = calendar.settings.format
  479. }
  480. // Convert the format into an array and then map through it.
  481. calendar.formats.toArray( options.format ).map( function( label ) {
  482. var
  483. // Grab the formatting label.
  484. formattingLabel = calendar.formats[ label ],
  485. // The format length is from the formatting label function or the
  486. // label length without the escaping exclamation (!) mark.
  487. formatLength = formattingLabel ? _.trigger( formattingLabel, calendar, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length
  488. // If there's a format label, split the value up to the format length.
  489. // Then add it to the parsing object with appropriate label.
  490. if ( formattingLabel ) {
  491. parsingObject[ label ] = value.substr( 0, formatLength )
  492. }
  493. // Update the value as the substring from format length to end.
  494. value = value.substr( formatLength )
  495. })
  496. // Compensate for month 0index.
  497. return [
  498. parsingObject.yyyy || parsingObject.yy,
  499. +( parsingObject.mm || parsingObject.m ) - 1,
  500. parsingObject.dd || parsingObject.d
  501. ]
  502. } //DatePicker.prototype.parse
  503. /**
  504. * Various formats to display the object in.
  505. */
  506. DatePicker.prototype.formats = (function() {
  507. // Return the length of the first word in a collection.
  508. function getWordLengthFromCollection( string, collection, dateObject ) {
  509. // Grab the first word from the string.
  510. // Regex pattern from http://stackoverflow.com/q/150033
  511. var word = string.match( /[^\x00-\x7F]+|[a-zA-Z0-9_\u0080-\u00FF]+/ )[ 0 ]
  512. // If there's no month index, add it to the date object
  513. if ( !dateObject.mm && !dateObject.m ) {
  514. dateObject.m = collection.indexOf( word ) + 1
  515. }
  516. // Return the length of the word.
  517. return word.length
  518. }
  519. // Get the length of the first word in a string.
  520. function getFirstWordLength( string ) {
  521. return string.match( /[a-zA-Z0-9_\u0080-\u00FF]+/ )[ 0 ].length
  522. }
  523. return {
  524. d: function( string, dateObject ) {
  525. // If there's string, then get the digits length.
  526. // Otherwise return the selected date.
  527. return string ? _.digits( string ) : dateObject.date
  528. },
  529. dd: function( string, dateObject ) {
  530. // If there's a string, then the length is always 2.
  531. // Otherwise return the selected date with a leading zero.
  532. return string ? 2 : _.lead( dateObject.date )
  533. },
  534. ddd: function( string, dateObject ) {
  535. // If there's a string, then get the length of the first word.
  536. // Otherwise return the short selected weekday.
  537. return string ? getFirstWordLength( string ) : this.settings.weekdaysShort[ dateObject.day ]
  538. },
  539. dddd: function( string, dateObject ) {
  540. // If there's a string, then get the length of the first word.
  541. // Otherwise return the full selected weekday.
  542. return string ? getFirstWordLength( string ) : this.settings.weekdaysFull[ dateObject.day ]
  543. },
  544. m: function( string, dateObject ) {
  545. // If there's a string, then get the length of the digits
  546. // Otherwise return the selected month with 0index compensation.
  547. return string ? _.digits( string ) : dateObject.month + 1
  548. },
  549. mm: function( string, dateObject ) {
  550. // If there's a string, then the length is always 2.
  551. // Otherwise return the selected month with 0index and leading zero.
  552. return string ? 2 : _.lead( dateObject.month + 1 )
  553. },
  554. mmm: function( string, dateObject ) {
  555. var collection = this.settings.monthsShort
  556. // If there's a string, get length of the relevant month from the short
  557. // months collection. Otherwise return the selected month from that collection.
  558. return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
  559. },
  560. mmmm: function( string, dateObject ) {
  561. var collection = this.settings.monthsFull
  562. // If there's a string, get length of the relevant month from the full
  563. // months collection. Otherwise return the selected month from that collection.
  564. return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
  565. },
  566. yy: function( string, dateObject ) {
  567. // If there's a string, then the length is always 2.
  568. // Otherwise return the selected year by slicing out the first 2 digits.
  569. return string ? 2 : ( '' + dateObject.year ).slice( 2 )
  570. },
  571. yyyy: function( string, dateObject ) {
  572. // If there's a string, then the length is always 4.
  573. // Otherwise return the selected year.
  574. return string ? 4 : dateObject.year
  575. },
  576. // Create an array by splitting the formatting string passed.
  577. toArray: function( formatString ) { return formatString.split( /(d{1,4}|m{1,4}|y{4}|yy|!.)/g ) },
  578. // Format an object into a string using the formatting options.
  579. toString: function ( formatString, itemObject ) {
  580. var calendar = this
  581. return calendar.formats.toArray( formatString ).map( function( label ) {
  582. return _.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' )
  583. }).join( '' )
  584. }
  585. }
  586. })() //DatePicker.prototype.formats
  587. /**
  588. * Check if two date units are the exact.
  589. */
  590. DatePicker.prototype.isDateExact = function( one, two ) {
  591. var calendar = this
  592. // When we’re working with weekdays, do a direct comparison.
  593. if (
  594. ( _.isInteger( one ) && _.isInteger( two ) ) ||
  595. ( typeof one == 'boolean' && typeof two == 'boolean' )
  596. ) {
  597. return one === two
  598. }
  599. // When we’re working with date representations, compare the “pick” value.
  600. if (
  601. ( _.isDate( one ) || $.isArray( one ) ) &&
  602. ( _.isDate( two ) || $.isArray( two ) )
  603. ) {
  604. return calendar.create( one ).pick === calendar.create( two ).pick
  605. }
  606. // When we’re working with range objects, compare the “from” and “to”.
  607. if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
  608. return calendar.isDateExact( one.from, two.from ) && calendar.isDateExact( one.to, two.to )
  609. }
  610. return false
  611. }
  612. /**
  613. * Check if two date units overlap.
  614. */
  615. DatePicker.prototype.isDateOverlap = function( one, two ) {
  616. var calendar = this,
  617. firstDay = calendar.settings.firstDay ? 1 : 0
  618. // When we’re working with a weekday index, compare the days.
  619. if ( _.isInteger( one ) && ( _.isDate( two ) || $.isArray( two ) ) ) {
  620. one = one % 7 + firstDay
  621. return one === calendar.create( two ).day + 1
  622. }
  623. if ( _.isInteger( two ) && ( _.isDate( one ) || $.isArray( one ) ) ) {
  624. two = two % 7 + firstDay
  625. return two === calendar.create( one ).day + 1
  626. }
  627. // When we’re working with range objects, check if the ranges overlap.
  628. if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
  629. return calendar.overlapRanges( one, two )
  630. }
  631. return false
  632. }
  633. /**
  634. * Flip the “enabled” state.
  635. */
  636. DatePicker.prototype.flipEnable = function(val) {
  637. var itemObject = this.item
  638. itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1)
  639. }
  640. /**
  641. * Mark a collection of dates as “disabled”.
  642. */
  643. DatePicker.prototype.deactivate = function( type, datesToDisable ) {
  644. var calendar = this,
  645. disabledItems = calendar.item.disable.slice(0)
  646. // If we’re flipping, that’s all we need to do.
  647. if ( datesToDisable == 'flip' ) {
  648. calendar.flipEnable()
  649. }
  650. else if ( datesToDisable === false ) {
  651. calendar.flipEnable(1)
  652. disabledItems = []
  653. }
  654. else if ( datesToDisable === true ) {
  655. calendar.flipEnable(-1)
  656. disabledItems = []
  657. }
  658. // Otherwise go through the dates to disable.
  659. else {
  660. datesToDisable.map(function( unitToDisable ) {
  661. var matchFound
  662. // When we have disabled items, check for matches.
  663. // If something is matched, immediately break out.
  664. for ( var index = 0; index < disabledItems.length; index += 1 ) {
  665. if ( calendar.isDateExact( unitToDisable, disabledItems[index] ) ) {
  666. matchFound = true
  667. break
  668. }
  669. }
  670. // If nothing was found, add the validated unit to the collection.
  671. if ( !matchFound ) {
  672. if (
  673. _.isInteger( unitToDisable ) ||
  674. _.isDate( unitToDisable ) ||
  675. $.isArray( unitToDisable ) ||
  676. ( $.isPlainObject( unitToDisable ) && unitToDisable.from && unitToDisable.to )
  677. ) {
  678. disabledItems.push( unitToDisable )
  679. }
  680. }
  681. })
  682. }
  683. // Return the updated collection.
  684. return disabledItems
  685. } //DatePicker.prototype.deactivate
  686. /**
  687. * Mark a collection of dates as “enabled”.
  688. */
  689. DatePicker.prototype.activate = function( type, datesToEnable ) {
  690. var calendar = this,
  691. disabledItems = calendar.item.disable,
  692. disabledItemsCount = disabledItems.length
  693. // If we’re flipping, that’s all we need to do.
  694. if ( datesToEnable == 'flip' ) {
  695. calendar.flipEnable()
  696. }
  697. else if ( datesToEnable === true ) {
  698. calendar.flipEnable(1)
  699. disabledItems = []
  700. }
  701. else if ( datesToEnable === false ) {
  702. calendar.flipEnable(-1)
  703. disabledItems = []
  704. }
  705. // Otherwise go through the disabled dates.
  706. else {
  707. datesToEnable.map(function( unitToEnable ) {
  708. var matchFound,
  709. disabledUnit,
  710. index,
  711. isExactRange
  712. // Go through the disabled items and try to find a match.
  713. for ( index = 0; index < disabledItemsCount; index += 1 ) {
  714. disabledUnit = disabledItems[index]
  715. // When an exact match is found, remove it from the collection.
  716. if ( calendar.isDateExact( disabledUnit, unitToEnable ) ) {
  717. matchFound = disabledItems[index] = null
  718. isExactRange = true
  719. break
  720. }
  721. // When an overlapped match is found, add the “inverted” state to it.
  722. else if ( calendar.isDateOverlap( disabledUnit, unitToEnable ) ) {
  723. if ( $.isPlainObject( unitToEnable ) ) {
  724. unitToEnable.inverted = true
  725. matchFound = unitToEnable
  726. }
  727. else if ( $.isArray( unitToEnable ) ) {
  728. matchFound = unitToEnable
  729. if ( !matchFound[3] ) matchFound.push( 'inverted' )
  730. }
  731. else if ( _.isDate( unitToEnable ) ) {
  732. matchFound = [ unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted' ]
  733. }
  734. break
  735. }
  736. }
  737. // If a match was found, remove a previous duplicate entry.
  738. if ( matchFound ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
  739. if ( calendar.isDateExact( disabledItems[index], unitToEnable ) ) {
  740. disabledItems[index] = null
  741. break
  742. }
  743. }
  744. // In the event that we’re dealing with an exact range of dates,
  745. // make sure there are no “inverted” dates because of it.
  746. if ( isExactRange ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
  747. if ( calendar.isDateOverlap( disabledItems[index], unitToEnable ) ) {
  748. disabledItems[index] = null
  749. break
  750. }
  751. }
  752. // If something is still matched, add it into the collection.
  753. if ( matchFound ) {
  754. disabledItems.push( matchFound )
  755. }
  756. })
  757. }
  758. // Return the updated collection.
  759. return disabledItems.filter(function( val ) { return val != null })
  760. } //DatePicker.prototype.activate
  761. /**
  762. * Create a string for the nodes in the picker.
  763. */
  764. DatePicker.prototype.nodes = function( isOpen ) {
  765. var
  766. calendar = this,
  767. settings = calendar.settings,
  768. calendarItem = calendar.item,
  769. nowObject = calendarItem.now,
  770. selectedObject = calendarItem.select,
  771. highlightedObject = calendarItem.highlight,
  772. viewsetObject = calendarItem.view,
  773. disabledCollection = calendarItem.disable,
  774. minLimitObject = calendarItem.min,
  775. maxLimitObject = calendarItem.max,
  776. // Create the calendar table head using a copy of weekday labels collection.
  777. // * We do a copy so we don't mutate the original array.
  778. tableHead = (function( collection, fullCollection ) {
  779. // If the first day should be Monday, move Sunday to the end.
  780. if ( settings.firstDay ) {
  781. collection.push( collection.shift() )
  782. fullCollection.push( fullCollection.shift() )
  783. }
  784. // Create and return the table head group.
  785. return _.node(
  786. 'thead',
  787. _.node(
  788. 'tr',
  789. _.group({
  790. min: 0,
  791. max: DAYS_IN_WEEK - 1,
  792. i: 1,
  793. node: 'th',
  794. item: function( counter ) {
  795. return [
  796. collection[ counter ],
  797. settings.klass.weekdays,
  798. 'scope=col title="' + fullCollection[ counter ] + '"'
  799. ]
  800. }
  801. })
  802. )
  803. ) //endreturn
  804. })( ( settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysShort ).slice( 0 ), settings.weekdaysFull.slice( 0 ) ), //tableHead
  805. // Create the nav for next/prev month.
  806. createMonthNav = function( next ) {
  807. // Otherwise, return the created month tag.
  808. return _.node(
  809. 'div',
  810. ' ',
  811. settings.klass[ 'nav' + ( next ? 'Next' : 'Prev' ) ] + (
  812. // If the focused month is outside the range, disabled the button.
  813. ( next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month ) ||
  814. ( !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ) ?
  815. ' ' + settings.klass.navDisabled : ''
  816. ),
  817. 'data-nav=' + ( next || -1 ) + ' ' + 'tabindex="0" ' +
  818. _.ariaAttr({
  819. role: 'button',
  820. controls: calendar.$node[0].id + '_table'
  821. }) + ' ' +
  822. 'title="' + (next ? settings.labelMonthNext : settings.labelMonthPrev ) + '"'
  823. ) //endreturn
  824. }, //createMonthNav
  825. // Create the month label.
  826. createMonthLabel = function() {
  827. var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull
  828. // If there are months to select, add a dropdown menu.
  829. if ( settings.selectMonths ) {
  830. return _.node( 'select',
  831. _.group({
  832. min: 0,
  833. max: 11,
  834. i: 1,
  835. node: 'option',
  836. item: function( loopedMonth ) {
  837. return [
  838. // The looped month and no classes.
  839. monthsCollection[ loopedMonth ], 0,
  840. // Set the value and selected index.
  841. 'value=' + loopedMonth +
  842. ( viewsetObject.month == loopedMonth ? ' selected' : '' ) +
  843. (
  844. (
  845. ( viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month ) ||
  846. ( viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month )
  847. ) ?
  848. ' disabled' : ''
  849. )
  850. ]
  851. }
  852. }),
  853. settings.klass.selectMonth,
  854. ( isOpen ? '' : 'disabled' ) + ' ' +
  855. _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' +
  856. 'title="' + settings.labelMonthSelect + '"'
  857. )
  858. }
  859. // If there's a need for a month selector
  860. return _.node( 'div', monthsCollection[ viewsetObject.month ], settings.klass.month )
  861. }, //createMonthLabel
  862. // Create the year label.
  863. createYearLabel = function() {
  864. var focusedYear = viewsetObject.year,
  865. // If years selector is set to a literal "true", set it to 5. Otherwise
  866. // divide in half to get half before and half after focused year.
  867. numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 )
  868. // If there are years to select, add a dropdown menu.
  869. if ( numberYears ) {
  870. var
  871. minYear = minLimitObject.year,
  872. maxYear = maxLimitObject.year,
  873. lowestYear = focusedYear - numberYears,
  874. highestYear = focusedYear + numberYears
  875. // If the min year is greater than the lowest year, increase the highest year
  876. // by the difference and set the lowest year to the min year.
  877. if ( minYear > lowestYear ) {
  878. highestYear += minYear - lowestYear
  879. lowestYear = minYear
  880. }
  881. // If the max year is less than the highest year, decrease the lowest year
  882. // by the lower of the two: available and needed years. Then set the
  883. // highest year to the max year.
  884. if ( maxYear < highestYear ) {
  885. var availableYears = lowestYear - minYear,
  886. neededYears = highestYear - maxYear
  887. lowestYear -= availableYears > neededYears ? neededYears : availableYears
  888. highestYear = maxYear
  889. }
  890. return _.node( 'select',
  891. _.group({
  892. min: lowestYear,
  893. max: highestYear,
  894. i: 1,
  895. node: 'option',
  896. item: function( loopedYear ) {
  897. return [
  898. // The looped year and no classes.
  899. loopedYear, 0,
  900. // Set the value and selected index.
  901. 'value=' + loopedYear + ( focusedYear == loopedYear ? ' selected' : '' )
  902. ]
  903. }
  904. }),
  905. settings.klass.selectYear,
  906. ( isOpen ? '' : 'disabled' ) + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' +
  907. 'title="' + settings.labelYearSelect + '"'
  908. )
  909. }
  910. // Otherwise just return the year focused
  911. return _.node( 'div', focusedYear, settings.klass.year )
  912. } //createYearLabel
  913. // Create and return the entire calendar.
  914. return _.node(
  915. 'div',
  916. ( settings.selectYears ? createYearLabel() + createMonthLabel() : createMonthLabel() + createYearLabel() ) +
  917. createMonthNav() + createMonthNav( 1 ),
  918. settings.klass.header
  919. ) + _.node(
  920. 'table',
  921. tableHead +
  922. _.node(
  923. 'tbody',
  924. _.group({
  925. min: 0,
  926. max: WEEKS_IN_CALENDAR - 1,
  927. i: 1,
  928. node: 'tr',
  929. item: function( rowCounter ) {
  930. // If Monday is the first day and the month starts on Sunday, shift the date back a week.
  931. var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0
  932. return [
  933. _.group({
  934. min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
  935. max: function() {
  936. return this.min + DAYS_IN_WEEK - 1
  937. },
  938. i: 1,
  939. node: 'td',
  940. item: function( targetDate ) {
  941. // Convert the time date from a relative date to a target date.
  942. targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
  943. var isSelected = selectedObject && selectedObject.pick == targetDate.pick,
  944. isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick,
  945. isDisabled = disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick,
  946. formattedDate = _.trigger( calendar.formats.toString, calendar, [ settings.format, targetDate ] ),
  947. calendarNodeUniqueId = settings.id + '_' + targetDate.pick
  948. return [
  949. _.node(
  950. 'div',
  951. targetDate.date,
  952. (function( klasses ) {
  953. // Add the `infocus` or `outfocus` classes based on month in view.
  954. klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus )
  955. // Add the `today` class if needed.
  956. if ( nowObject.pick == targetDate.pick ) {
  957. klasses.push( settings.klass.now )
  958. }
  959. // Add the `selected` class if something's selected and the time matches.
  960. if ( isSelected ) {
  961. klasses.push( settings.klass.selected )
  962. }
  963. // Add the `highlighted` class if something's highlighted and the time matches.
  964. if ( isHighlighted ) {
  965. klasses.push( settings.klass.highlighted )
  966. }
  967. // Add the `disabled` class if something's disabled and the object matches.
  968. if ( isDisabled ) {
  969. klasses.push( settings.klass.disabled )
  970. }
  971. return klasses.join( ' ' )
  972. })([ settings.klass.day ]),
  973. 'data-pick=' + targetDate.pick + ' id=' + calendarNodeUniqueId + ' tabindex="0" ' + _.ariaAttr({
  974. role: 'gridcell',
  975. label: formattedDate,
  976. selected: isSelected && calendar.$node.val() === formattedDate ? true : null,
  977. activedescendant: isHighlighted ? targetDate.pick : null,
  978. disabled: isDisabled ? true : null
  979. })
  980. ),
  981. ''
  982. ] //endreturn
  983. }
  984. })
  985. ] //endreturn
  986. }
  987. })
  988. ),
  989. settings.klass.table,
  990. 'id="' + calendar.$node[0].id + '_table' + '" ' + _.ariaAttr({
  991. role: 'grid',
  992. controls: calendar.$node[0].id,
  993. readonly: true
  994. })
  995. ) +
  996. // * For Firefox forms to submit, make sure to set the buttons’ `type` attributes as “button”.
  997. _.node(
  998. 'div',
  999. _.node( 'button', settings.today, settings.klass.buttonToday,
  1000. 'type=button data-pick=' + nowObject.pick +
  1001. ( isOpen && !calendar.disabled(nowObject) ? '' : ' disabled' ) + ' ' +
  1002. _.ariaAttr({ controls: calendar.$node[0].id }) ) +
  1003. _.node( 'button', settings.clear, settings.klass.buttonClear,
  1004. 'type=button data-clear=1' +
  1005. ( isOpen ? '' : ' disabled' ) + ' ' +
  1006. _.ariaAttr({ controls: calendar.$node[0].id }) ) +
  1007. _.node('button', settings.close, settings.klass.buttonClose,
  1008. 'type=button data-close=true ' +
  1009. ( isOpen ? '' : ' disabled' ) + ' ' +
  1010. _.ariaAttr({ controls: calendar.$node[0].id }) ),
  1011. settings.klass.footer
  1012. ) //endreturn
  1013. } //DatePicker.prototype.nodes
  1014. /**
  1015. * The date picker defaults.
  1016. */
  1017. DatePicker.defaults = (function( prefix ) {
  1018. return {
  1019. // The title label to use for the month nav buttons
  1020. labelMonthNext: 'Next month',
  1021. labelMonthPrev: 'Previous month',
  1022. // The title label to use for the dropdown selectors
  1023. labelMonthSelect: 'Select a month',
  1024. labelYearSelect: 'Select a year',
  1025. // Months and weekdays
  1026. monthsFull: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
  1027. monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
  1028. weekdaysFull: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
  1029. weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
  1030. // Today and clear
  1031. today: 'Today',
  1032. clear: 'Clear',
  1033. close: 'Close',
  1034. // Picker close behavior
  1035. closeOnSelect: true,
  1036. closeOnClear: true,
  1037. // Update input value on select/clear
  1038. updateInput: true,
  1039. // The format to show on the `input` element
  1040. format: 'd mmmm, yyyy',
  1041. // Classes
  1042. klass: {
  1043. table: prefix + 'table',
  1044. header: prefix + 'header',
  1045. navPrev: prefix + 'nav--prev',
  1046. navNext: prefix + 'nav--next',
  1047. navDisabled: prefix + 'nav--disabled',
  1048. month: prefix + 'month',
  1049. year: prefix + 'year',
  1050. selectMonth: prefix + 'select--month',
  1051. selectYear: prefix + 'select--year',
  1052. weekdays: prefix + 'weekday',
  1053. day: prefix + 'day',
  1054. disabled: prefix + 'day--disabled',
  1055. selected: prefix + 'day--selected',
  1056. highlighted: prefix + 'day--highlighted',
  1057. now: prefix + 'day--today',
  1058. infocus: prefix + 'day--infocus',
  1059. outfocus: prefix + 'day--outfocus',
  1060. footer: prefix + 'footer',
  1061. buttonClear: prefix + 'button--clear',
  1062. buttonToday: prefix + 'button--today',
  1063. buttonClose: prefix + 'button--close'
  1064. }
  1065. }
  1066. })( Picker.klasses().picker + '__' )
  1067. /**
  1068. * Extend the picker to add the date picker.
  1069. */
  1070. Picker.extend( 'pickadate', DatePicker )
  1071. }));