Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MessageBall = Class.create();
- MessageBall.prototype = function () {
- // private attributes
- var _divTag = null;
- var _imgTag = null;
- var _size = null;
- var createDiv = function(parent,id){
- _divTag = document.createElement("div");
- _divTag.id = id;
- _divTag.className = id;
- document.getElementById(parent).appendChild(_divTag);
- return jQuery(_divTag);
- }
- var createBackground = function(){
- _imgTag = document.createElement("img");
- _imgTag.setAttribute("src", "img/ball.png");
- _imgTag.setAttribute("width","100%");
- _imgTag.setAttribute("height","100%");
- _divTag.appendChild(_imgTag);
- }
- // public attributes
- return {
- setSize: function(size){
- console.log("setSize");
- this.element.width(size);
- this.element.height(size);
- _size = size;
- },
- getSize: function(){
- return _size;
- },
- setPosition: function(x,y){
- this.element.offset({
- top: y-this.getSize()/2,
- left: x-this.getSize()/2
- })
- },
- getPosition: function(){
- return {
- x:this.element.position().left+this.getSize()/2,
- y:this.element.position().top+this.getSize()/2
- }
- },
- initialize: function(id, parent, text1, text2){
- console.log("MessageBall");
- this.element = createDiv(parent,id);
- createBackground();
- }
- }
- }();
- /*
- function setupDivs() {
- console.log("setupDivs");
- var i;
- for( i=0; i<circles.length; i++) {
- var _divTag = document.createElement("div");
- var id = "div"+i;
- _divTag.id = id;
- _divTag.className ="dynamicDiv";
- var _imgTag = document.createElement("img");
- _imgTag.id = "img"+i;
- _imgTag.className ="dynamicImg";
- _imgTag.setAttribute("src","img/ball.png");
- _imgTag.setAttribute("width","100%");
- _imgTag.setAttribute("height","100%");
- _divTag.appendChild(_imgTag);
- document.getElementById('balls').appendChild(_divTag);
- divs.push(_divTag);
- jQuery("div.dynamicDiv").height(circleWidth);
- jQuery("div.dynamicDiv").width(circleWidth);
- }
- jQuery("div.dynamicDiv").bind({
- mouseover: function() {
- circleWidth = 100;
- jQuery(this).height(circleWidth);
- jQuery(this).width(circleWidth);
- var thisIndex = divs.indexOf(jQuery(this)[0]);
- var circle = circles[thisIndex];
- circle.m_shapeList.m_radius = 100;
- circle.QuickSyncShapes();
- },
- mouseout: function() {
- circleWidth = 60;
- jQuery(this).height(circleWidth);
- jQuery(this).width(circleWidth);
- var thisIndex = divs.indexOf(jQuery(this)[0]);
- circles[thisIndex].m_shapeList.m_radius = 60;
- circles[thisIndex].QuickSyncShapes();
- }
- });
- }
- */
Add Comment
Please, Sign In to add comment