Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. // Create new object to cache iframe offsets
  2. $.ui.ddmanager.frameOffsets = {};
  3.  
  4. // Override the native `prepareOffsets` method. This is almost
  5. // identical to the un-edited method, except for the last part!
  6. $.ui.ddmanager.prepareOffsets = function (t, event) {
  7. var i, j,
  8. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  9. type = event ? event.type : null, // workaround for #2317
  10. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack(),
  11. doc, frameOffset;
  12.  
  13. droppablesLoop: for (i = 0; i < m.length; i++) {
  14.  
  15. //No disabled and non-accepted
  16. if (m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0], (t.currentItem || t.element)))) {
  17. continue;
  18. }
  19.  
  20. // Filter out elements in the current dragoged item
  21. for (j = 0; j < list.length; j++) {
  22. if (list[j] === m[i].element[0]) {
  23. m[i].proportions().height = 0;
  24. continue droppablesLoop;
  25. }
  26. }
  27.  
  28. m[i].visible = m[i].element.css("display") !== "none";
  29. if (!m[i].visible) {
  30. continue;
  31. }
  32.  
  33. //Activate the droppable if used directly from draggables
  34. if (type === "mousedown") {
  35. m[i]._activate.call(m[i], event);
  36. }
  37.  
  38. // Re-calculate offset
  39. m[i].offset = m[i].element.offset();
  40.  
  41. // Re-calculate proportions (jQuery UI ~1.10 introduced a `proportions` cache method, so support both here!)
  42. proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  43. typeof m[i].proportions === 'function' ? m[i].proportions(proportions) : (m[i].proportions = proportions);
  44.  
  45. /* ============ Here comes the fun bit! =============== */
  46.  
  47. // If the element is within an another document...
  48. if ((doc = m[i].document[0]) !== document) {
  49. // Determine in the frame offset using cached offset (if already calculated)
  50. frameOffset = $.ui.ddmanager.frameOffsets[doc];
  51. if (!frameOffset) {
  52. // Calculate and cache the offset in our new `$.ui.ddmanager.frameOffsets` object
  53. frameOffset = $.ui.ddmanager.frameOffsets[doc] = $(
  54. // Different browsers store it on different properties (IE...)
  55. (doc.defaultView || doc.parentWindow).frameElement
  56. ).offset();
  57. }
  58.  
  59. // Add the frame offset to the calculated offset
  60. m[i].offset.left += frameOffset.left;
  61. m[i].offset.top += frameOffset.top;
  62. }
  63. }
  64. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement