From 3d3e37c55e96b74c6c0a2841574fb03814d52999 Mon Sep 17 00:00:00 2001 From: Armen Kesablyan Date: Tue, 3 Jul 2012 12:19:56 -0700 Subject: Text Tool 2 Signed-off-by: Armen Kesablyan --- .../text-properties.reel/text-properties.js | 128 +++++++++++++-------- 1 file changed, 83 insertions(+), 45 deletions(-) (limited to 'js/components/tools-properties/text-properties.reel/text-properties.js') diff --git a/js/components/tools-properties/text-properties.reel/text-properties.js b/js/components/tools-properties/text-properties.reel/text-properties.js index 4f944adf..126665e2 100755 --- a/js/components/tools-properties/text-properties.reel/text-properties.js +++ b/js/components/tools-properties/text-properties.reel/text-properties.js @@ -8,32 +8,70 @@ var Montage = require("montage/core/core").Montage; var Component = require("montage/ui/component").Component; var ArrayController = require("montage/ui/controller/array-controller").ArrayController; var ToolProperties = require("js/components/tools-properties/tool-properties").ToolProperties; -var Converter = require("montage/core/converter/converter").Converter; exports.TextProperties = Montage.create(ToolProperties, { fontName: {value: null, serializable: true}, fontSize: {value: null, serializable: true}, - - fontSettings: {value: null, serializable: true}, // Note: Isn't used currently will need fontSettings Popup - fontColor: {value: null, serializable: true}, + btnBold: {value: null, serializable: true}, btnItalic: {value: null, serializable: true}, btnUnderline: {value: null, serializable: true}, btnStrikethrough: {value: null, serializable: true}, - txtLink: {value: null, serializable: true}, - linkTarget: {value: null, serializable: true}, + alignLeft: {value: null, serializable: true}, alignCenter: {value: null, serializable: true}, alignRight: {value: null, serializable: true}, alignJustify: {value: null, serializable: true}, + indent: {value: null, serializable: true}, outdent: {value: null, serializable: true}, + numberedList: {value: null, serializable: true}, bulletedList: {value: null, serializable: true}, - fontTypes: {value: null, serializable: true}, - fontSizes: {value: null, serializable: true}, + + // Events + handleEditorSelect: { + value: function(e) { + this.alignLeft.pressed = false; + this.alignCenter.pressed = false; + this.alignRight.pressed = false; + this.alignJustify.pressed = false; + this.bulletedList.pressed = false; + this.numberedList.pressed = false; + + + switch(this.application.ninja.stage.textTool.justify) { + case "left": + this.alignLeft.pressed = true; + break; + case "center": + this.alignCenter.pressed = true; + break; + case "right": + this.alignRight.pressed = true; + break; + case "full": + this.alignJustify.pressed = true; + } + + switch(this.application.ninja.stage.textTool.listStyle) { + case "ordered": + this.numberedList.pressed = true; + break; + case "unordered": + this.bulletedList.pressed = true; + } + } + }, + + handleEditorBlur: { + value: function(e) { + + } + }, + // Draw Cycle prepareForDraw: { @@ -46,6 +84,7 @@ exports.TextProperties = Montage.create(ToolProperties, { this.application.ninja.stage.textTool.addEventListener("editorSelect", this.handleEditorSelect.bind(this), false); + //Bind to Rich Text editor that lives on the stage component Object.defineBinding(this.application.ninja.stage.textTool, "fontName", { boundObject: this.fontName, @@ -85,83 +124,82 @@ exports.TextProperties = Montage.create(ToolProperties, { } }, - // Events - handleEditorSelect: { - value: function(e) { - - } - }, - - handleAlignLeftAction: { + // Actions + handleJustifyLeftAction: { value: function(e) { - //this.alignLeft.value = false; - this.alignCenter.value = false; - this.alignRight.value = false; - this.alignJustify.value = false; - this.application.ninja.stage.textTool.doAction("justifyleft"); + this.alignCenter.pressed = false; + this.alignRight.pressed = false; + this.alignJustify.pressed = false; + this.application.ninja.stage.textTool.justify = "left"; } }, - handleAlignCenterAction: { + handleJustifyCenterAction: { value: function(e) { - this.alignLeft.value = false; - //this.alignCenter.value = false; - this.alignRight.value = false; - this.alignJustify.value = false; - this.application.ninja.stage.textTool.doAction("justifycenter"); + this.alignLeft.pressed = false; + this.alignRight.pressed = false; + this.alignJustify.pressed = false; + this.application.ninja.stage.textTool.justify = "center" } }, - handleAlignRightAction: { + handleJustifyRightAction: { value: function(e) { - this.alignLeft.value = false; - this.alignCenter.value = false; - //this.alignRight.value = false; - this.alignJustify.value = false; - this.application.ninja.stage.textTool.doAction("justifyright"); + this.alignLeft.pressed = false; + this.alignCenter.pressed = false; + this.alignJustify.pressed = false; + this.application.ninja.stage.textTool.justify = "right"; } }, - handleAlignJustifyAction: { + handleJustifyAction: { value: function(e) { - this.alignLeft.value = false; - this.alignCenter.value = false; - this.alignRight.value = false; - //this.alignJustify.value = false; - this.application.ninja.stage.textTool.doAction("justifyfull"); + this.alignLeft.pressed = false; + this.alignCenter.pressed = false; + this.alignRight.pressed = false; + this.application.ninja.stage.textTool.justify = "full"; } }, handleIndentAction: { value: function(e) { - this.application.ninja.stage.textTool.doAction("indent"); + this.application.ninja.stage.textTool.indent(); } }, handleOutdentAction: { value: function(e) { - this.application.ninja.stage.textTool.doAction("outdent"); + this.application.ninja.stage.textTool.outdent(); } }, handleBulletedListAction: { value: function(e) { - this.application.ninja.stage.textTool.doAction("insertunorderedlist"); + this.numberedList.pressed = false; + if(e._currentTarget.pressed) { + this.application.ninja.stage.textTool.listStyle = "unordered"; + } else { + this.application.ninja.stage.textTool.listStyle = "none"; + } } }, handleNumberedListAction: { value: function(e) { - this.application.ninja.stage.textTool.doAction("insertorderedlist"); + this.bulletedList.pressed = false; + if(e._currentTarget.pressed) { + this.application.ninja.stage.textTool.listStyle = "ordered"; + } else { + this.application.ninja.stage.textTool.listStyle = "none"; + } } }, handleFontColorChange: { value: function(e) { - this.application.ninja.stage.textTool.foreColor = e._event.color.css; + this.application.ninja.stage.textTool.element.style.color = e._event.color.css; } } }); - -- cgit v1.2.3