Tip.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Ext.define('erp.view.core.picker.Tip', {
  2. extend : 'Ext.Component',
  3. floating : true,
  4. text : null,
  5. direction : 'bottom',
  6. clsFile : basePath + 'resource/css/tip.css',
  7. injectStyleSheet: function(cssFile) {
  8. Ext.util.CSS.swapStyleSheet('tipcss', cssFile);
  9. },
  10. initComponent : function() {
  11. var me = this;
  12. me.injectStyleSheet(me.clsFile);
  13. Ext.apply(me.renderData, {
  14. cls : 'custom-tip',
  15. text : me.text,
  16. direction : me.direction
  17. });
  18. me.callParent();
  19. me.showAt(me.getPosition());
  20. },
  21. getPosition : function() {
  22. var me = this;
  23. if (me.target) {
  24. var p = me.target.getXY(), x = p[0], y = p[1], d = me.direction;
  25. switch (d) {
  26. case 'top':
  27. y += 20;break;
  28. case 'bottom':
  29. y -= 20;break;
  30. case 'left':
  31. x += 20;break;
  32. case 'right':
  33. x -= 20;break;
  34. }
  35. return [x, y];
  36. }
  37. return null;
  38. },
  39. renderTpl: [
  40. '<div class="{cls}">',
  41. '<div class="{cls}-body">',
  42. '<div class="{cls}-body-text">{text}</div>',
  43. '</div>',
  44. '<div class="{cls}-arrow-{direction}"></div>',
  45. '<div class="{cls}-arrow-{direction}-i"></div>',
  46. '</div>'
  47. ]
  48. });