Dashboard sipadu mbip
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

aui-datepicker-base-debug.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. AUI.add('aui-datepicker-base', function(A) {
  2. var Lang = A.Lang,
  3. isBoolean = Lang.isBoolean,
  4. isFunction = Lang.isFunction,
  5. CALENDAR = 'calendar',
  6. CONTENT_BOX = 'contentBox',
  7. CURRENT_NODE = 'currentNode',
  8. FORMATTER = 'formatter',
  9. SELECT_MULTIPLE_DATES = 'selectMultipleDates',
  10. SET_VALUE = 'setValue',
  11. DATEPICKER = 'date-picker';
  12. var DatePicker = A.Component.create({
  13. NAME: DATEPICKER,
  14. ATTRS: {
  15. /**
  16. * <a href="Calendar.html">Calendar</a> configuration Object.</a>
  17. *
  18. * @attribute calendar
  19. * @default {}
  20. * @type Object
  21. */
  22. calendar: {
  23. setter: '_setCalendar',
  24. value: {}
  25. },
  26. /**
  27. * Function to format the array of the selected dates before set the
  28. * value of the input.
  29. *
  30. * @attribute formatter
  31. * @default function(dates) { return dates.formatted.join(','); }
  32. * @type function
  33. */
  34. formatter: {
  35. value: function(dates) {
  36. return dates.formatted.join(',');
  37. },
  38. validator: isFunction
  39. },
  40. /**
  41. * If true set the selected date with the correct
  42. * <a href="Calendar.html#config_dateFormat">dateFormat</a> to the
  43. * value of the input field which is hosting the Calendar.
  44. *
  45. * @attribute setValue
  46. * @default true
  47. * @type boolean
  48. */
  49. setValue: {
  50. value: true,
  51. validator: isBoolean
  52. },
  53. /**
  54. * If true is able To Do stacking with another overlays.
  55. *
  56. * @attribute stack
  57. * @default true
  58. * @type boolean
  59. */
  60. stack: {
  61. lazyAdd: false,
  62. value: true,
  63. setter: '_setStack',
  64. validator: isBoolean
  65. },
  66. showOn: {
  67. value: 'mousedown'
  68. },
  69. hideOn: {
  70. value: 'mousedown'
  71. }
  72. },
  73. EXTENDS: A.OverlayContext,
  74. prototype: {
  75. /**
  76. * Construction logic executed during Datepicker instantiation. Lifecycle.
  77. *
  78. * @method initializer
  79. * @protected
  80. */
  81. initializer: function() {
  82. var instance = this;
  83. instance.calendar = new A.Calendar(
  84. instance.get(CALENDAR)
  85. );
  86. },
  87. /**
  88. * Bind the events on the Datepicker UI. Lifecycle.
  89. *
  90. * @method bindUI
  91. * @protected
  92. */
  93. bindUI: function() {
  94. var instance = this;
  95. DatePicker.superclass.bindUI.apply(this, arguments);
  96. instance.on('show', instance._onShowOverlay);
  97. instance.after('calendar:select', instance._afterSelectDate);
  98. // Set the value of the trigger with the Calendar current date
  99. if (instance.get(SET_VALUE)) {
  100. instance._setTriggerValue(
  101. instance.calendar._getSelectEventData().date
  102. );
  103. }
  104. },
  105. /**
  106. * Descructor lifecycle implementation for the Datepicker class.
  107. * Purges events attached to the node (and all child nodes).
  108. *
  109. * @method destructor
  110. * @protected
  111. */
  112. destructor: function() {
  113. var instance = this;
  114. instance.calendar.destroy();
  115. },
  116. /**
  117. * Fires when a date is selected on the Calendar.
  118. *
  119. * @method _afterSelectDate
  120. * @param {Event} event
  121. * @protected
  122. */
  123. _afterSelectDate: function(event) {
  124. var instance = this;
  125. if (!instance.calendar.get(SELECT_MULTIPLE_DATES)) {
  126. instance.hide();
  127. }
  128. if (instance.get(SET_VALUE)) {
  129. instance._setTriggerValue(event.date);
  130. }
  131. },
  132. /**
  133. * Fires before the DatePicker overlay show. Responsible to invoke the
  134. * render phase of the Calendar.
  135. *
  136. * @method _onShowOverlay
  137. * @param {Event} event
  138. * @protected
  139. */
  140. _onShowOverlay: function(event) {
  141. var instance = this;
  142. instance._renderCalendar();
  143. },
  144. /**
  145. * Render the Calendar used inside the DatePicker.
  146. *
  147. * @method _renderCalendar
  148. * @protected
  149. */
  150. _renderCalendar: function() {
  151. var instance = this;
  152. instance.calendar.render(
  153. instance.get(CONTENT_BOX)
  154. );
  155. },
  156. /**
  157. * Setter for the <a href="DatePicker.html#calendar">calendar</a>
  158. * attribute.
  159. *
  160. * @method _setCalendar
  161. * @param {String} eventType Event type
  162. * @protected
  163. * @return {}
  164. */
  165. _setCalendar: function(val) {
  166. var instance = this;
  167. A.mix(val, {
  168. bubbleTargets: instance
  169. });
  170. return val;
  171. },
  172. /**
  173. * Setter for the <a href="Calendar.html#config_stack">stack</a> attribute.
  174. *
  175. * @method _setStack
  176. * @param {boolean} value
  177. * @protected
  178. * @return {boolean}
  179. */
  180. _setStack: function(value) {
  181. var instance = this;
  182. if (value) {
  183. A.DatepickerManager.register(instance);
  184. }
  185. else {
  186. A.DatepickerManager.remove(instance);
  187. }
  188. return value;
  189. },
  190. /**
  191. * Set the value of the trigger input with the date information.
  192. *
  193. * @method _setTriggerValue
  194. * @param {Object} dateObj Object containing date information
  195. * @protected
  196. */
  197. _setTriggerValue: function(dateObj) {
  198. var instance = this;
  199. var value = instance.get(FORMATTER).apply(instance, [dateObj]);
  200. instance.get(CURRENT_NODE).val(value);
  201. }
  202. }
  203. });
  204. A.DatePicker = DatePicker;
  205. /**
  206. * A base class for DatepickerManager:
  207. *
  208. * @param config {Object} Object literal specifying widget configuration properties.
  209. *
  210. * @class DatepickerManager
  211. * @constructor
  212. * @extends OverlayManager
  213. * @static
  214. */
  215. A.DatepickerManager = new A.OverlayManager({
  216. /**
  217. * ZIndex default value passed to the
  218. * <a href="OverlayManager.html#config_zIndexBase">zIndexBase</a> of
  219. * <a href="OverlayManager.html">OverlayManager</a>.
  220. *
  221. * @attribute zIndexBase
  222. * @default 1000
  223. * @type Number
  224. */
  225. zIndexBase: 1000
  226. });
  227. }, '@VERSION@' ,{requires:['aui-calendar','aui-overlay-context'], skinnable:true});