Projet

Général

Profil

Révision cd5c298a

Ajouté par Geoffroy Desvernay il y a environ 5 ans

MAJ 7.60 -> 7.62

Voir les différences:

drupal7/misc/tabledrag.js
580 580
 * Get the mouse coordinates from the event (allowing for browser differences).
581 581
 */
582 582
Drupal.tableDrag.prototype.mouseCoords = function (event) {
583

  
584
  // Match both null and undefined, but not zero, by using != null.
585
  // See https://stackoverflow.com/questions/2647867/how-to-determine-if-variable-is-undefined-or-null
586
  if (event.pageX != null && event.pageY != null) {
587
    return {x: event.pageX, y: event.pageY};
588
  }
589

  
583 590
  // Complete support for pointer events was only introduced to jQuery in
584 591
  // version 1.11.1; between versions 1.7 and 1.11.0 pointer events have the
585
  // clientX and clientY properties undefined. In those cases, the properties
586
  // must be retrieved from the event.originalEvent object instead.
587
  var clientX = event.clientX || event.originalEvent.clientX;
588
  var clientY = event.clientY || event.originalEvent.clientY;
592
  // pageX and pageY properties undefined. In those cases, the properties must
593
  // be retrieved from the event.originalEvent object instead.
594
  if (event.originalEvent && event.originalEvent.pageX != null && event.originalEvent.pageY != null) {
595
    return {x: event.originalEvent.pageX, y: event.originalEvent.pageY};
596
  }
589 597

  
590
  if (event.pageX || event.pageY) {
591
    return { x: event.pageX, y: event.pageY };
598
  // Some old browsers do not support MouseEvent.pageX and *.pageY at all.
599
  // See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/pageY
600
  // For those, we look at event.clientX and event.clientY instead.
601
  if (event.clientX == null || event.clientY == null) {
602
    // In some jQuery versions, some events created by jQuery do not have
603
    // clientX and clientY. But the original event might have.
604
    if (!event.originalEvent) {
605
      throw new Error("The event has no coordinates, and no event.originalEvent.");
606
    }
607
    event = event.originalEvent;
608
    if (event.clientX == null || event.clientY == null) {
609
      throw new Error("The original event has no coordinates.");
610
    }
592 611
  }
593 612

  
594
  return {
595
    x: clientX + document.body.scrollLeft - document.body.clientLeft,
596
    y: clientY + document.body.scrollTop  - document.body.clientTop
597
  };
613
  // Copied from jQuery.event.fix() in jQuery 1.4.1.
614
  // In newer jQuery versions, this code is in jQuery.event.mouseHooks.filter().
615
  var doc = document.documentElement, body = document.body;
616
  var pageX = event.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
617
  var pageY = event.clientY + ( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) - ( doc && doc.clientTop  || body && body.clientTop  || 0 );
618

  
619
  return {x: pageX, y: pageY};
598 620
};
599 621

  
600 622
/**

Formats disponibles : Unified diff