removed createAttrs method and cleaned up init logic

This commit is contained in:
Eric Rowell 2013-07-22 22:05:21 -07:00
parent 37a15817b5
commit 1fc57bed4c
20 changed files with 15 additions and 48 deletions

View File

@ -2,7 +2,6 @@
Kinetic.Util.addMethods(Kinetic.Group, {
___init: function(config) {
this.nodeType = 'Group';
this.createAttrs();
// call super constructor
Kinetic.Container.call(this, config);
}

View File

@ -5,7 +5,6 @@
Kinetic.Util.addMethods(Kinetic.Layer, {
___init: function(config) {
this.nodeType = 'Layer';
this.createAttrs();
this.canvas = new Kinetic.SceneCanvas();
this.hitCanvas = new Kinetic.HitCanvas();
// call super constructor

View File

@ -37,6 +37,7 @@
_init: function(config) {
this._id = Kinetic.Global.idCounter++;
this.eventListeners = {};
this.attrs = {};
this.setAttrs(config);
},
/**
@ -238,13 +239,6 @@
getAttrs: function() {
return this.attrs || {};
},
createAttrs: function() {
if(this.attrs === undefined) {
this.attrs = {};
}
return this;
},
/**
* set multiple attrs at once using an object literal
* @method

View File

@ -37,7 +37,6 @@
this.colorKey = key;
shapes[key] = this;
this.createAttrs();
// call super constructor
Kinetic.Node.call(this, config);

View File

@ -38,7 +38,6 @@
Kinetic.Util.addMethods(Kinetic.Stage, {
___init: function(config) {
this.createAttrs();
// call super constructor
Kinetic.Container.call(this, config);
this.nodeType = STAGE;

View File

@ -58,7 +58,6 @@
____init: function(config) {
var that = this;
this.createAttrs();
this.className = LABEL;
Kinetic.Group.call(this, config);
@ -173,7 +172,6 @@
Kinetic.Tag.prototype = {
___init: function(config) {
this.createAttrs();
Kinetic.Shape.call(this, config);
this.className = 'Tag';
},

View File

@ -26,8 +26,6 @@
Kinetic.RegularPolygon.prototype = {
___init: function(config) {
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = 'RegularPolygon';

View File

@ -28,8 +28,6 @@
Kinetic.Star.prototype = {
___init: function(config) {
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = 'Star';

View File

@ -42,8 +42,6 @@
Kinetic.TextPath.prototype = {
___init: function(config) {
var that = this;
this.createAttrs();
this.dummyCanvas = document.createElement('canvas');
this.dataArray = [];

View File

@ -27,7 +27,6 @@
Kinetic.Blob.prototype = {
___init: function(config) {
var that = this;
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = 'Blob';

View File

@ -37,7 +37,6 @@
Kinetic.Circle.prototype = {
___init: function(config) {
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = CIRCLE;

View File

@ -18,8 +18,6 @@
Kinetic.Ellipse.prototype = {
___init: function(config) {
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = ELLIPSE;

View File

@ -37,8 +37,6 @@
Kinetic.Line.prototype = {
___init: function(config) {
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = 'Line';

View File

@ -23,8 +23,6 @@
Kinetic.Polygon.prototype = {
___init: function(config) {
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = 'Polygon';

View File

@ -23,7 +23,6 @@
Kinetic.Rect.prototype = {
___init: function(config) {
this.createAttrs();
Kinetic.Shape.call(this, config);
this.className = 'Rect';
},

View File

@ -27,7 +27,6 @@
Kinetic.Spline.prototype = {
___init: function(config) {
var that = this;
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = 'Spline';

View File

@ -72,8 +72,6 @@
Kinetic.Sprite.prototype = {
___init: function(config) {
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = 'Sprite';

View File

@ -68,12 +68,13 @@
Kinetic.Text.prototype = {
___init: function(config) {
var that = this;
this.createAttrs();
// since width and height work a bit different for Text,
// we need to default the values here
this.attrs.width = AUTO;
this.attrs.height = AUTO;
if (config.width === undefined) {
config.width = AUTO;
}
if (config.height === undefined) {
config.height = AUTO;
}
// call super constructor
Kinetic.Shape.call(this, config);

View File

@ -27,8 +27,6 @@
Kinetic.Wedge.prototype = {
___init: function(config) {
this.createAttrs();
// call super constructor
Kinetic.Shape.call(this, config);
this.className = 'Wedge';

View File

@ -54,7 +54,7 @@ Test.Modules.Text = {
group.add(text);
layer.add(group);
stage.add(layer);
test(text.getClassName() === 'Text', 'getClassName should be Text');
},
'text getters and setters': function(containerId) {
@ -98,7 +98,6 @@ Test.Modules.Text = {
test(text.getX() === stage.getWidth() / 2, 'text box x should be in center of stage');
test(text.getY() === stage.getHeight() / 2, 'text box y should be in center of stage');
test(text.getText() === 'Hello World!', 'text should be Hello World!');
test(text.getFontSize() == 50, 'font size should 50');
test(text.getFontFamily() == 'Calibri', 'font family should be Calibri');
@ -112,7 +111,6 @@ Test.Modules.Text = {
test(text.getPadding() === 10, 'padding should be 10');
test(text.getShadowColor() === 'black', 'text box shadow color should be black');
test(text.getDraggable() === true, 'text should be draggable');
test(text.getWidth() === 400, 'box width should be 400');
test(text.getHeight() === 100, 'box height should be 100');
test(text.getTextWidth() > 0, 'text width should be greater than 0');
@ -164,7 +162,7 @@ Test.Modules.Text = {
height: 200
});
var layer = new Kinetic.Layer();
var rect = new Kinetic.Rect({
x: 10,
y: 10,
@ -204,14 +202,14 @@ Test.Modules.Text = {
width: 50,
duration: 20
});
rect.transitionTo({
width: 50,
duration: 20
});
*/
},
'text multi line with shadows': function(containerId) {
var stage = new Kinetic.Stage({
@ -271,15 +269,15 @@ Test.Modules.Text = {
var width = text.getWidth();
var height = text.getHeight();
layer.add(text);
stage.add(layer);
text.setFontSize(30);
layer.draw();
//console.log(text.getHeight() + ',' + height);
test(text.getWidth() > width, 'text box width should have increased.');