Guest User

Untitled

a guest
Jan 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. var MessageBall = Class.create();
  2. MessageBall.prototype = function () {
  3.  
  4. // private attributes
  5.  
  6. var _divTag = null;
  7. var _imgTag = null;
  8. var _size = null;
  9.  
  10. var createDiv = function(parent,id){
  11. _divTag = document.createElement("div");
  12. _divTag.id = id;
  13. _divTag.className = id;
  14. document.getElementById(parent).appendChild(_divTag);
  15. return jQuery(_divTag);
  16. }
  17.  
  18. var createBackground = function(){
  19. _imgTag = document.createElement("img");
  20. _imgTag.setAttribute("src", "img/ball.png");
  21. _imgTag.setAttribute("width","100%");
  22. _imgTag.setAttribute("height","100%");
  23. _divTag.appendChild(_imgTag);
  24. }
  25.  
  26. // public attributes
  27.  
  28. return {
  29. setSize: function(size){
  30. console.log("setSize");
  31. this.element.width(size);
  32. this.element.height(size);
  33. _size = size;
  34. },
  35.  
  36. getSize: function(){
  37. return _size;
  38. },
  39.  
  40. setPosition: function(x,y){
  41. this.element.offset({
  42. top: y-this.getSize()/2,
  43. left: x-this.getSize()/2
  44. })
  45. },
  46.  
  47. getPosition: function(){
  48. return {
  49. x:this.element.position().left+this.getSize()/2,
  50. y:this.element.position().top+this.getSize()/2
  51. }
  52. },
  53.  
  54. initialize: function(id, parent, text1, text2){
  55. console.log("MessageBall");
  56. this.element = createDiv(parent,id);
  57. createBackground();
  58. }
  59. }
  60. }();
  61.  
  62.  
  63.  
  64.  
  65. /*
  66. function setupDivs() {
  67. console.log("setupDivs");
  68. var i;
  69. for( i=0; i<circles.length; i++) {
  70. var _divTag = document.createElement("div");
  71. var id = "div"+i;
  72. _divTag.id = id;
  73. _divTag.className ="dynamicDiv";
  74. var _imgTag = document.createElement("img");
  75. _imgTag.id = "img"+i;
  76. _imgTag.className ="dynamicImg";
  77. _imgTag.setAttribute("src","img/ball.png");
  78. _imgTag.setAttribute("width","100%");
  79. _imgTag.setAttribute("height","100%");
  80. _divTag.appendChild(_imgTag);
  81. document.getElementById('balls').appendChild(_divTag);
  82. divs.push(_divTag);
  83.  
  84. jQuery("div.dynamicDiv").height(circleWidth);
  85. jQuery("div.dynamicDiv").width(circleWidth);
  86. }
  87.  
  88. jQuery("div.dynamicDiv").bind({
  89. mouseover: function() {
  90. circleWidth = 100;
  91. jQuery(this).height(circleWidth);
  92. jQuery(this).width(circleWidth);
  93. var thisIndex = divs.indexOf(jQuery(this)[0]);
  94. var circle = circles[thisIndex];
  95. circle.m_shapeList.m_radius = 100;
  96. circle.QuickSyncShapes();
  97. },
  98. mouseout: function() {
  99. circleWidth = 60;
  100. jQuery(this).height(circleWidth);
  101. jQuery(this).width(circleWidth);
  102. var thisIndex = divs.indexOf(jQuery(this)[0]);
  103. circles[thisIndex].m_shapeList.m_radius = 60;
  104. circles[thisIndex].QuickSyncShapes();
  105. }
  106. });
  107. }
  108. */
Add Comment
Please, Sign In to add comment