diff --git a/ui/builder/component-builder.d.ts b/ui/builder/component-builder.d.ts index 69379f79a..7245a15ec 100644 --- a/ui/builder/component-builder.d.ts +++ b/ui/builder/component-builder.d.ts @@ -5,6 +5,9 @@ declare module "ui/builder/component-builder" { export function getComponentModule(elementName: string, namespace: string, attributes: Object, exports: Object): ComponentModule; export function setPropertyValue(instance: view.View, instanceModuleExports: Object, pageExports: Object, propertyName: string, propertyValue: string) : void; + export var specialProperties: Array; + export function setSpecialPropertyValue(instance: view.View, propertyName: string, propertyValue: string): boolean; + export interface ComponentModule { component: view.View; exports: any; diff --git a/ui/builder/component-builder.ts b/ui/builder/component-builder.ts index 5c7be9671..5730a6a2d 100644 --- a/ui/builder/component-builder.ts +++ b/ui/builder/component-builder.ts @@ -29,6 +29,16 @@ var DOCK = "dock"; var LEFT = "left"; var TOP = "top"; +export var specialProperties: Array = [ + ROW, + COL, + COL_SPAN, + ROW_SPAN, + DOCK, + LEFT, + TOP, +] + var eventHandlers = {}; export function getComponentModule(elementName: string, namespace: string, attributes: Object, exports: Object): definition.ComponentModule { @@ -112,6 +122,28 @@ export function getComponentModule(elementName: string, namespace: string, attri return componentModule; } +export function setSpecialPropertyValue(instance: view.View, propertyName: string, propertyValue: string) { + if (propertyName === ROW) { + gridLayoutModule.GridLayout.setRow(instance, !isNaN(+propertyValue) && +propertyValue); + } else if (propertyName === COL) { + gridLayoutModule.GridLayout.setColumn(instance, !isNaN(+propertyValue) && +propertyValue); + } else if (propertyName === COL_SPAN) { + gridLayoutModule.GridLayout.setColumnSpan(instance, !isNaN(+propertyValue) && +propertyValue); + } else if (propertyName === ROW_SPAN) { + gridLayoutModule.GridLayout.setRowSpan(instance, !isNaN(+propertyValue) && +propertyValue); + } else if (propertyName === LEFT) { + absoluteLayoutDef.AbsoluteLayout.setLeft(instance, !isNaN(+propertyValue) && +propertyValue); + } else if (propertyName === TOP) { + absoluteLayoutDef.AbsoluteLayout.setTop(instance, !isNaN(+propertyValue) && +propertyValue); + } else if (propertyName === DOCK) { + console.log('set dock: ' + propertyName + ' -> ' + propertyValue); + dockLayoutDef.DockLayout.setDock(instance, propertyValue); + } else { + return false; + } + return true; +} + export function setPropertyValue(instance: view.View, instanceModule: Object, exports: Object, propertyName: string, propertyValue: string) { // Note: instanceModule can be null if we are loading custom compnenet with no code-behind. var isEventOrGesture: boolean = isKnownEventOrGesture(propertyName, instance); @@ -136,20 +168,8 @@ export function setPropertyValue(instance: view.View, instanceModule: Object, ex if (types.isFunction(handler)) { instance.on(propertyName, handler); } - } else if (propertyName === ROW) { - gridLayoutModule.GridLayout.setRow(instance, !isNaN(+propertyValue) && +propertyValue); - } else if (propertyName === COL) { - gridLayoutModule.GridLayout.setColumn(instance, !isNaN(+propertyValue) && +propertyValue); - } else if (propertyName === COL_SPAN) { - gridLayoutModule.GridLayout.setColumnSpan(instance, !isNaN(+propertyValue) && +propertyValue); - } else if (propertyName === ROW_SPAN) { - gridLayoutModule.GridLayout.setRowSpan(instance, !isNaN(+propertyValue) && +propertyValue); - } else if (propertyName === LEFT) { - absoluteLayoutDef.AbsoluteLayout.setLeft(instance, !isNaN(+propertyValue) && +propertyValue); - } else if (propertyName === TOP) { - absoluteLayoutDef.AbsoluteLayout.setTop(instance, !isNaN(+propertyValue) && +propertyValue); - } else if (propertyName === DOCK) { - dockLayoutDef.DockLayout.setDock(instance, propertyValue); + } else if (setSpecialPropertyValue(instance, propertyName, propertyValue)) { + // Already set by setSpecialPropertyValue } else { var attrHandled = false; @@ -211,4 +231,4 @@ function isBinding(value: string): boolean { } return isBinding; -} \ No newline at end of file +}