Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

aui-scheduler-calendar.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. AUI.add('aui-scheduler-calendar', function(A) {
  2. var Lang = A.Lang,
  3. isArray = Lang.isArray,
  4. isBoolean = Lang.isBoolean,
  5. isString = Lang.isString,
  6. isSchedulerEvent = function(val) {
  7. return (val instanceof A.SchedulerEvent);
  8. },
  9. COLOR = 'color',
  10. DISABLED = 'disabled',
  11. EVENTS = 'events',
  12. PALLETE = 'pallete',
  13. SCHEDULER = 'scheduler',
  14. SCHEDULER_CALENDAR = 'scheduler-calendar',
  15. VISIBLE = 'visible';
  16. var SchedulerCalendar = A.Component.create({
  17. NAME: SCHEDULER_CALENDAR,
  18. ATTRS: {
  19. color: {
  20. valueFn: function() {
  21. var instance = this;
  22. var pallete = instance.get(PALLETE);
  23. var randomIndex = Math.ceil(Math.random() * pallete.length) - 1;
  24. return pallete[randomIndex];
  25. },
  26. validator: isString
  27. },
  28. disabled: {
  29. value: false,
  30. validator: isBoolean
  31. },
  32. name: {
  33. value: '(no name)',
  34. validator: isString
  35. },
  36. pallete: {
  37. value: ['#d96666', '#e67399', '#b373b3', '#8c66d9', '#668cb3', '#668cd9', '#59bfb3', '#65ad89', '#4cb052', '#8cbf40', '#bfbf4d', '#e0c240', '#f2a640', '#e6804d', '#be9494', '#a992a9', '#8997a5', '#94a2be', '#85aaa5', '#a7a77d', '#c4a883', '#c7561e', '#b5515d', '#c244ab', '#603f99', '#536ca6', '#3640ad', '#3c995b', '#5ca632', '#7ec225', '#a7b828', '#cf9911', '#d47f1e', '#b56414', '#914d14', '#ab2671', '#9643a5', '#4585a3', '#737373', '#41a587', '#d1bc36', '#ad2d2d'],
  38. validator: isArray
  39. },
  40. scheduler: {
  41. lazyAdd: false,
  42. setter: '_setScheduler'
  43. },
  44. visible: {
  45. value: true,
  46. validator: isBoolean
  47. }
  48. },
  49. EXTENDS: A.Base,
  50. AUGMENTS: A.SchedulerEventSupport,
  51. prototype: {
  52. initializer: function() {
  53. var instance = this;
  54. instance.after('colorChange', instance._afterColorChange);
  55. instance.after('disabledChange', instance._afterDisabledChange);
  56. instance.after('eventsChange', instance._afterEventsChange);
  57. instance.after('visibleChange', instance._afterVisibleChange);
  58. instance._uiSetColor(
  59. instance.get(COLOR)
  60. );
  61. instance._uiSetDisabled(
  62. instance.get(DISABLED)
  63. );
  64. instance._uiSetEvents(
  65. instance.get(EVENTS)
  66. );
  67. instance._uiSetVisible(
  68. instance.get(VISIBLE)
  69. );
  70. },
  71. _afterColorChange: function(event) {
  72. var instance = this;
  73. instance._uiSetColor(event.newVal);
  74. },
  75. _afterDisabledChange: function(event) {
  76. var instance = this;
  77. instance._uiSetDisabled(event.newVal);
  78. },
  79. _afterEventsChange: function(event) {
  80. var instance = this;
  81. instance._uiSetEvents(event.newVal);
  82. },
  83. _afterVisibleChange: function(event) {
  84. var instance = this;
  85. instance._uiSetVisible(event.newVal);
  86. },
  87. _propagateAttr: function(attrName, attrValue) {
  88. var instance = this;
  89. instance.eachEvent(function(evt) {
  90. evt.set(attrName, attrValue);
  91. });
  92. },
  93. _setScheduler: function(val) {
  94. var instance = this;
  95. var scheduler = instance.get(SCHEDULER);
  96. if (scheduler) {
  97. instance.removeTarget(scheduler);
  98. }
  99. instance.addTarget(val);
  100. return val;
  101. },
  102. _uiSetColor: function(val) {
  103. var instance = this;
  104. instance._propagateAttr(COLOR, instance.get(COLOR));
  105. },
  106. _uiSetDisabled: function(val) {
  107. var instance = this;
  108. instance._propagateAttr(DISABLED, val);
  109. },
  110. _uiSetEvents: function(val) {
  111. var instance = this;
  112. var scheduler = instance.get(SCHEDULER);
  113. instance._propagateAttr(COLOR, instance.get(COLOR));
  114. instance._propagateAttr(DISABLED, instance.get(DISABLED));
  115. instance._propagateAttr(VISIBLE, instance.get(VISIBLE));
  116. if (scheduler) {
  117. scheduler.removeEvents(instance);
  118. scheduler.addEvents(val);
  119. scheduler.syncEventsUI();
  120. }
  121. },
  122. _uiSetVisible: function(val) {
  123. var instance = this;
  124. instance._propagateAttr(VISIBLE, val);
  125. }
  126. }
  127. });
  128. A.SchedulerCalendar = SchedulerCalendar;
  129. }, '@VERSION@' ,{requires:['aui-scheduler-event'], skinnable:false});