[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/calendar/yui/build/moodle-calendar-eventmanager/ -> moodle-calendar-eventmanager-debug.js (source)

   1  YUI.add('moodle-calendar-eventmanager', function (Y, NAME) {
   2  
   3  var ENAME = 'Calendar event',
   4      EVENTID = 'eventId',
   5      EVENTNODE = 'node',
   6      EVENTTITLE = 'title',
   7      EVENTCONTENT = 'content',
   8      EVENTDELAY = 'delay',
   9      SHOWTIMEOUT = 'showTimeout',
  10      HIDETIMEOUT = 'hideTimeout',
  11  
  12      EVENT = function() {
  13          EVENT.superclass.constructor.apply(this, arguments);
  14      },
  15      EVENTMANAGER;
  16  
  17  Y.extend(EVENT, Y.Base, {
  18      initpanelcalled : false,
  19      initializer : function(){
  20          this.get(EVENTID);
  21          var node = this.get(EVENTNODE),
  22              td;
  23          if (!node) {
  24              return false;
  25          }
  26          td = node.ancestor('td');
  27          this.publish('showevent');
  28          this.publish('hideevent');
  29          td.on('mouseenter', this.startShow, this);
  30          td.on('mouseleave', this.startHide, this);
  31          td.on('focus', this.startShow, this);
  32          td.on('blur', this.startHide, this);
  33          return true;
  34      },
  35      initPanel : function() {
  36          if (!this.initpanelcalled) {
  37              this.initpanelcalled = true;
  38              var node = this.get(EVENTNODE),
  39                  td = node.ancestor('td'),
  40                  constraint = td.ancestor('div'),
  41                  panel;
  42              panel = new Y.Overlay({
  43                  constrain : constraint,
  44                  align : {
  45                      node : td,
  46                      points:[Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.BC]
  47                  },
  48                  headerContent : Y.Node.create('<h2 class="eventtitle">'+this.get(EVENTTITLE)+'</h2>'),
  49                  bodyContent : Y.Node.create('<div class="eventcontent">'+this.get(EVENTCONTENT)+'</div>'),
  50                  visible : false,
  51                  id : this.get(EVENTID)+'_panel',
  52                  width : Math.floor(constraint.get('offsetWidth')*0.9)+"px"
  53              });
  54              panel.render(td);
  55              node.setAttribute('aria-controls', panel.get('id'));
  56              panel.get('boundingBox').addClass('calendar-event-panel');
  57              panel.get('boundingBox').setAttribute('aria-live', 'off');
  58              this.on('showevent', panel.show, panel);
  59              this.on('showevent', this.setAriashow, panel);
  60              this.on('hideevent', this.setAriahide, panel);
  61              this.on('hideevent', panel.hide, panel);
  62          }
  63      },
  64      startShow : function() {
  65          this.cancelHide();
  66          if (this.get(SHOWTIMEOUT) !== null) {
  67              this.cancelShow();
  68          }
  69          var self = this;
  70          this.set(SHOWTIMEOUT, setTimeout(function(){self.show();}, this.get(EVENTDELAY)));
  71      },
  72      cancelShow : function() {
  73          clearTimeout(this.get(SHOWTIMEOUT));
  74      },
  75      setAriashow : function() {
  76          this.get('boundingBox').setAttribute('aria-live', 'assertive');
  77      },
  78      setAriahide : function() {
  79            this.get('boundingBox').setAttribute('aria-live', 'off');
  80      },
  81      show : function() {
  82          this.initPanel();
  83          this.fire('showevent');
  84      },
  85      startHide : function() {
  86          this.cancelShow();
  87          if (this.get(HIDETIMEOUT) !== null) {
  88              this.cancelHide();
  89          }
  90          var self = this;
  91          this.set(HIDETIMEOUT, setTimeout(function(){self.hide();}, this.get(EVENTDELAY)));
  92      },
  93      hide : function() {
  94          this.fire('hideevent');
  95      },
  96      cancelHide : function() {
  97          clearTimeout(this.get(HIDETIMEOUT));
  98      }
  99  }, {
 100      NAME : ENAME,
 101      ATTRS : {
 102          eventId : {
 103              setter : function(nodeid) {
 104                  this.set(EVENTNODE, Y.one('#'+nodeid));
 105                  return nodeid;
 106              },
 107              validator : Y.Lang.isString
 108          },
 109          node : {
 110              setter : function(node) {
 111                  if (typeof(node) === 'string') {
 112                      node = Y.one('#'+node);
 113                  }
 114                  return node;
 115              }
 116          },
 117          title : {
 118              validator : Y.Lang.isString
 119          },
 120          content : {
 121              validator : Y.Lang.isString
 122          },
 123          delay : {
 124              value : 300,
 125              validator : Y.Lang.isNumber
 126          },
 127          showTimeout : {
 128              value : null
 129          },
 130          hideTimeout : {
 131              value : null
 132          }
 133      }
 134  });
 135  Y.augment(EVENT, Y.EventTarget);
 136  
 137  EVENTMANAGER = {
 138      add_event : function(config) {
 139          new EVENT(config);
 140      }
 141  };
 142  
 143  M.core_calendar = M.core_calendar || {};
 144  Y.mix(M.core_calendar, EVENTMANAGER);
 145  
 146  
 147  }, '@VERSION@', {"requires": ["base", "node", "event-mouseenter", "overlay", "moodle-calendar-eventmanager-skin"]});


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1