[Code Style] Use prototypes in Layout bundle

WTD-1482
This commit is contained in:
Victor Woeltjen
2015-08-12 13:45:48 -07:00
parent a9e2d48036
commit ed53808556
15 changed files with 615 additions and 596 deletions

View File

@@ -37,33 +37,41 @@ define(
* when adding a new element will require user input
*/
function FixedProxy(addElementCallback, $q, dialogService) {
var factory = new ElementFactory(dialogService);
return {
/**
* Add a new visual element to this view.
* @memberof platform/features/layout.FixedProxy#
*/
add: function (type) {
// Place a configured element into the view configuration
function addElement(element) {
// Configure common properties of the element
element.x = element.x || 0;
element.y = element.y || 0;
element.width = element.width || 1;
element.height = element.height || 1;
element.type = type;
// Finally, add it to the view's configuration
addElementCallback(element);
}
// Defer creation to the factory
$q.when(factory.createElement(type)).then(addElement);
}
};
this.factory = new ElementFactory(dialogService);
this.$q = $q;
this.addElementCallback = addElementCallback;
}
/**
* Add a new visual element to this view. Supported types are:
*
* * `fixed.image`
* * `fixed.box`
* * `fixed.text`
* * `fixed.line`
*
* @param {string} type the type of element to add
*/
FixedProxy.prototype.add = function (type) {
var addElementCallback = this.addElementCallback;
// Place a configured element into the view configuration
function addElement(element) {
// Configure common properties of the element
element.x = element.x || 0;
element.y = element.y || 0;
element.width = element.width || 1;
element.height = element.height || 1;
element.type = type;
// Finally, add it to the view's configuration
addElementCallback(element);
}
// Defer creation to the factory
this.$q.when(this.factory.createElement(type)).then(addElement);
};
return FixedProxy;
}
);