diff --git a/cocos2d/core/components/CCButton.js b/cocos2d/core/components/CCButton.js index 9319875045..7dfaa5c216 100644 --- a/cocos2d/core/components/CCButton.js +++ b/cocos2d/core/components/CCButton.js @@ -123,9 +123,9 @@ var EVENT_HOVER_OUT = 'hover-out'; var Button = cc.Class({ name: 'cc.Button', extends: require('./CCComponent'), + mixins: [EventTarget], ctor: function () { - EventTarget.call(this); this._touchListener = null; this._mouseListener = null; @@ -511,6 +511,4 @@ var Button = cc.Class({ }); -cc.js.addon(Button.prototype, EventTarget.prototype); - cc.Button = module.exports = Button; diff --git a/cocos2d/core/components/CCLabel.js b/cocos2d/core/components/CCLabel.js index f6c00774c5..059a3a8fc9 100644 --- a/cocos2d/core/components/CCLabel.js +++ b/cocos2d/core/components/CCLabel.js @@ -59,7 +59,7 @@ var Label = cc.Class({ /** * Horizontal Alignment of label - * @property {TextAlignment} horizontalAlign + * @property {Label.HorizontalAlign} horizontalAlign */ horizontalAlign: { default: HorizontalAlign.LEFT, @@ -75,7 +75,7 @@ var Label = cc.Class({ /** * Vertical Alignment of label - * @property {VerticalTextAlignment} verticalAlign + * @property {Label.VerticalAlign} verticalAlign */ verticalAlign: { default: VerticalAlign.TOP, @@ -135,7 +135,7 @@ var Label = cc.Class({ }, /** * Overflow of label - * @property {Overflow} overFlow + * @property {Label.Overflow} overFlow */ overflow: { default: Overflow.CLAMP, @@ -230,6 +230,26 @@ var Label = cc.Class({ }, + statics: { + /** + * The horizontal alignment of label. + * @property {cc.TextAlignment} HorizontalAlign + */ + HorizontalAlign: HorizontalAlign, + + /** + * The vertical alignment of label. + * @property {cc.VerticalTextAlignment} VerticalAlign + */ + VerticalAlign: VerticalAlign, + + /** + * Label overflow type, currently three types are supported: Clamp, Shrink and ResizeHeight. + * @property {Overflow} Overflow + */ + Overflow: Overflow, + }, + onLoad: function () { this._super(); this.node.on('size-changed', this._resized, this); diff --git a/cocos2d/core/components/CCLayout.js b/cocos2d/core/components/CCLayout.js index 8f6f96aaf0..96941cd8d7 100644 --- a/cocos2d/core/components/CCLayout.js +++ b/cocos2d/core/components/CCLayout.js @@ -25,9 +25,9 @@ /** * Enum for Layout type - * @enum Layout.LayoutType + * @enum Layout.Type */ -var LayoutType = cc.Enum({ +var Type = cc.Enum({ /** *@property {Number} BASIC */ @@ -98,12 +98,12 @@ var Layout = cc.Class({ /** * The layout type. - * @property {LayoutType} layoutType - * @default Layout.LayoutType.BASIC + * @property {Layout.Type} layoutType + * @default Layout.Type.BASIC */ layoutType: { - default: LayoutType.BASIC, - type: LayoutType, + default: Type.BASIC, + type: Type, notify: function() { this._doLayoutDirty(); } @@ -134,7 +134,7 @@ var Layout = cc.Class({ /** * Only take effect in Vertical layout mode. * This option changes the start element's positioning. - * @property {VerticalDirection} verticalDirection + * @property {Layout.VerticalDirection} verticalDirection */ verticalDirection: { default: VerticalDirection.TOP_TO_BOTTOM, @@ -147,7 +147,7 @@ var Layout = cc.Class({ /** * Only take effect in Horizontal layout mode. * This option changes the start element's positioning. - * @property {HorizontalDirection} horizontalDirection + * @property {Layout.HorizontalDirection} horizontalDirection */ horizontalDirection: { default: HorizontalDirection.LEFT_TO_RIGHT, @@ -158,6 +158,12 @@ var Layout = cc.Class({ }, }, + statics: { + Type: Type, + VerticalDirection: VerticalDirection, + HorizontalDirection: HorizontalDirection + }, + onLoad: function() { this.node.setContentSize(this._layoutSize); @@ -259,9 +265,9 @@ var Layout = cc.Class({ var layoutAnchor = this.node.getAnchorPoint(); var layoutSize = this.node.getContentSize(); - if (this.layoutType === LayoutType.HORIZONTAL) { + if (this.layoutType === Type.HORIZONTAL) { this._doLayoutHorizontally(layoutAnchor, layoutSize, children); - } else if (this.layoutType === LayoutType.VERTICAL) { + } else if (this.layoutType === Type.VERTICAL) { this._doLayoutVertically(layoutAnchor, layoutSize, children); } }, diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index e6bb064eb1..0dcbe300aa 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -52,7 +52,7 @@ var Mask = cc.Class({ this._clippingStencil.ignoreAnchorPointForPosition(false); this._clippingNode = new cc.ClippingNode(this._clippingStencil); }, - + onEnable: function () { var oldNode = this.node._sgNode; this._clippingStencil.setContentSize(this.node._contentSize); @@ -69,11 +69,11 @@ var Mask = cc.Class({ this.node.off('size-changed', this._onContentSizeChanged, this); this.node.off('anchor-changed',this._onAnchorChanged,this); }, - + onDestroy: function () { }, - + _onContentSizeChanged: function() { if(this._clippingStencil) { this._clippingStencil.setContentSize(this.node._contentSize); diff --git a/cocos2d/core/components/CCProgressBar.js b/cocos2d/core/components/CCProgressBar.js index 37a83f9654..91acb68329 100644 --- a/cocos2d/core/components/CCProgressBar.js +++ b/cocos2d/core/components/CCProgressBar.js @@ -141,7 +141,7 @@ var ProgressBar = cc.Class({ /** * The progress mode, there are two modes supported now: horizontal and vertical. - *@property {Mode} mode + *@property {ProgressBar.Mode} mode */ mode: { default: Mode.HORIZONTAL, @@ -198,6 +198,10 @@ var ProgressBar = cc.Class({ this._updateBarStatus(); } } + }, + + statics: { + Mode: Mode } }); diff --git a/cocos2d/core/components/CCScrollBar.js b/cocos2d/core/components/CCScrollBar.js index e2d7e6e6a2..f2709e0960 100644 --- a/cocos2d/core/components/CCScrollBar.js +++ b/cocos2d/core/components/CCScrollBar.js @@ -109,6 +109,10 @@ var Scrollbar = cc.Class({ } }, + statics: { + Direction: Direction + }, + setTargetScrollView: function(scrollView) { this._scrollView = scrollView; },