popup.helper.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. $(function () {
  2. 'use strict';
  3. window.utils = window.utils || {};
  4. window.utils.popup = {
  5. createAnimation: function () {
  6. return {
  7. show: { type: "pop", duration: 200, from: { opacity: 1, scale: 0.4 }, to: { scale: 1 } },
  8. hide: { type: "fade", duration: 200, from: 1, to: 0 }
  9. }
  10. },
  11. getAttachFunc: function (selectString, timerObj, position) {
  12. return function (value) {
  13. if (value) {
  14. if (timerObj.timer !== null) {
  15. clearInterval(timerObj.timer);
  16. }
  17. var top, left;
  18. var element = $(selectString).offsetParent();
  19. position({ my: 'left top', at: 'right top', of: element });
  20. timerObj.timer = setInterval(function () {
  21. element = $(selectString).offsetParent();
  22. var offset = element.offset();
  23. if (top !== offset.top || left !== offset.left) {
  24. top = offset.top;
  25. left = offset.left;
  26. position({ my: 'left top', at: 'right top', of: element });
  27. }
  28. }, 0);
  29. }
  30. else {
  31. if (timerObj.timer !== null) {
  32. clearInterval(timerObj.timer);
  33. timerObj.timer = null;
  34. }
  35. }
  36. };
  37. }
  38. };
  39. });