resize-plugin.js revision 76ca635d61eb3f9fb7c9d788a44fa8b1690aa138
/**
* The Resize Plugin allows you to make a Node or a Widget resizable. It supports all the functionality of
* the standalone Resize utility. Additionally, resizing a widget updates the widget's height,width and x,y
* attributes, if they exist.
*
* @module resize-plugin
*/
var ResizePlugin = function(config) {
//if its a widget, get the bounding box
config.node = ((Y.Widget && config.host instanceof Y.Widget) ? config.host.get('boundingBox') : config.host);
}
else {
}
};
/**
* @property NAME
* @description resize-plugin
* @type {String}
*/
/**
* @property NS
* @description The Resize instance will be placed on the Node instance under the resize namespace. It can be accessed via Node.resize or Widget.resize;
* @type {String}
*/
/**
* Static property used to define the default attribute
* configuration for the Resize plugin.
*
* @property ATTRS
* @type Object
* @static
*/
ResizePlugin.ATTRS = {
/**
* Stores the node that is being resized
*
* @attribute node
* @default undefined
* @public
*/
node: {
},
/**
* Stores the widget that the node belongs to, if one exists
*
* @attribute widget
* @default undefined
* @public
*/
widget: {
}
};
/**
* Stores the values for node and widget, and sets up an event-listener
*
* @method initializer
* @protected
*/
initializer: function(config) {
this.on('resize:resize', function(e) {
this._correctDimensions(e);
});
},
/**
* Updates the node's (x,y) values if they are changed via resizing.
* If the node belongs to a widget, passes the widget down to _setWidgetProperties method
*
* @method _correctDimensions
* @param {EventFacade} e The Event object
* @private
*/
_correctDimensions: function(e) {
x = {
},
y = {
};
if (this.get('widget')) {
this._setWidgetProperties(e, x, y);
}
//now set properties on just the node or the widget's bounding box
}
}
},
/**
* If the host is a widget, then set the width, height. Then look for widgetPosition and set x,y
*
* @method _setWidgetProperties
* @param {EventFacade} e The Event object
* @param {Object} x Literal containing old x value and current x value
* @param {Object} y Literal containing old y value and current y value
* @private
*/
_setWidgetProperties: function(e,x,y) {
}
}
//If the widget uses Y.WidgetPosition, it will also have x,y position support.
//console.log('new values: ' + x.current + ', ' + x.old);
// console.log('old values: ' + x.old + ', ' + y.old);
}
}
}
},
/**
* a little utility method that returns a value if the old !== new, otherwise it returns false.
*
* @method _isDifferent
* @param {Number} oldVal
* @param {Number} newVal
* @private
*/
return newVal;
}
else {
return false;
}
}
});
Y.namespace('Plugin');
}, '@VERSION@' ,{optional:['resize-constrain'], skinnable:false, requires:['resize-base', 'plugin']});