From 61a419422b1a05a779fd9a66c53de3fa8ab5f65a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:28:34 -0700 Subject: - enable/disable save, saveAs, saveAll, close, closeAll as per documents open - added close file and close all menu items Signed-off-by: Ananya Sen Conflicts: js/helper-classes/3D/draw-utils.js Signed-off-by: Ananya Sen --- js/components/menu/menu-item.reel/menu-item.js | 13 +- js/controllers/document-controller.js | 26 +- js/data/menu-data.js | 830 +++++++++++++------------ js/document/text-document.js | 8 +- 4 files changed, 481 insertions(+), 396 deletions(-) (limited to 'js') diff --git a/js/components/menu/menu-item.reel/menu-item.js b/js/components/menu/menu-item.reel/menu-item.js index 64a89a6a..8d975c4b 100755 --- a/js/components/menu/menu-item.reel/menu-item.js +++ b/js/components/menu/menu-item.reel/menu-item.js @@ -61,6 +61,8 @@ exports.MenuItem = Montage.create(Component, { prepareForDraw: { value: function() { + var boundObject = this.application.ninja, strArr = null, i=0; + if(!this.data) return; if(this.data.separator) { @@ -82,9 +84,16 @@ exports.MenuItem = Montage.create(Component, { } if(this.data.enabled.boundProperty) { + strArr = this.data.enabled.boundObj.split("."); + for(i=0;i 0){ + this.closeDocument(this._documents[this._documents.length -1].uuid); + } + } + } + }, + //////////////////////////////////////////////////////////////////// // fileSaveResult: { value: function (result) { diff --git a/js/data/menu-data.js b/js/data/menu-data.js index 40512f5d..093ecf14 100755 --- a/js/data/menu-data.js +++ b/js/data/menu-data.js @@ -4,414 +4,464 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Montage = require("montage/core/core").Montage; +var Montage = require("montage/core/core").Montage; exports.MenuData = Montage.create( Montage, { topLevelMenu: { value: [ - { - "header": "File", - "entries": [ - { - "displayText" : "New Project", - "hasSubMenu" : false, - "enabled": false, - "action": "executeNewProject" - }, - { - "displayText" : "New File", - "hasSubMenu" : false, - "enabled": true, - "action": "executeNewFile" - }, - { - "displayText" : "Open File", - "hasSubMenu" : false, - "enabled": true, - "action": "executeFileOpen" - }, - { - "displayText" : "Close File", - "hasSubMenu" : false, - "enabled": true, - "action": "executeFileClose" - }, - { - "displayText" : "", - "separator": true - }, - { - "displayText" : "Save", - "hasSubMenu" : false, - "enabled": true, - "action": "executeSave" - }, - { - "displayText" : "Save As", - "hasSubMenu" : false, - "enabled": true, - "action":"executeSaveAs" - }, - { - "displayText" : "Save All", - "hasSubMenu" : false, - "enabled": true, - "action": "executeSaveAll" - }, - { - "displayText" : "", - "separator": true - }, - { - "displayText" : "Open Project", - "hasSubMenu" : false, - "enabled": false - }, - { - "displayText" : "Open Recent", - "hasSubMenu" : false, - "enabled": false - }, - { - "displayText" : "Close Project", - "hasSubMenu" : false, - "enabled": false - } - ] - }, - { - "header": "Edit", - "entries": [ - { - "displayText" : "Undo", - "hasSubMenu" : false, - "enabled": { - "value": false, - "boundObj": "undocontroller", - "boundProperty": "canUndo" - }, - "action": "executeUndo" - }, - { - "displayText" : "Redo", - "hasSubMenu" : false, - "enabled": { - "value": false, - "boundObj": "undocontroller", - "boundProperty": "canRedo" - }, - "action": "executeRedo" - }, - { - "displayText" : "Cut", - "hasSubMenu" : false, - "enabled": true - }, - { - "displayText" : "Copy", - "hasSubMenu" : false, - "enabled": true - }, - { - "displayText" : "Paste", - "hasSubMenu" : false, - "enabled": true - } - ] - }, - { - "header": "View", - "entries": [ - { - "displayText" : "Zoom In", - "hasSubMenu" : false, - "enabled": true - }, - { - "displayText" : "Zoom Out", - "hasSubMenu" : false, - "enabled": true - }, - { - "displayText" : "", - "separator": true - }, - { - "displayText" : "Live Preview", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": false, - "boundProperty": "livePreview" - } - }, - { - "displayText" : "Chrome Preview", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": false, - "boundProperty": "chromePreview" - } - }, - { - "displayText" : "Layout View", - "hasSubMenu" : false, - "enabled": true, - "submenu": true, - "entries": [ - { - "displayText" : "View All", - "hasSubMenu" : false, - "radio": true, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "layoutAll" + { + "header": "File", + "entries": [ + { + "displayText" : "New Project", + "hasSubMenu" : false, + "enabled": false, + "action": "executeNewProject" + }, + { + "displayText" : "New File", + "hasSubMenu" : false, + "enabled": true, + "action": "executeNewFile" + }, + { + "displayText" : "Open File", + "hasSubMenu" : false, + "enabled": true, + "action": "executeFileOpen" + }, + { + "displayText" : "Close File", + "hasSubMenu" : false, + "enabled": { + "value": false, + "boundObj": "documentController", + "boundProperty": "activeDocument", + "oneway": true, + "boundValueMutator": function(activeDocument){ + if(activeDocument !== null){return true;} + else{return false;} } }, - { - "displayText" : "View Items Only", - "hasSubMenu" : false, - "radio": true, - "enabled": true, - "checked": { - "value": false, - "boundProperty": "layoutItems" + "action": "executeFileClose" + }, + { + "displayText" : "Close All", + "hasSubMenu" : false, + "enabled": { + "value": false, + "boundObj": "documentController", + "boundProperty": "activeDocument", + "oneway": true, + "boundValueMutator": function(activeDocument){ + if(activeDocument !== null){return true;} + else{return false;} } }, - { - "displayText" : "Off", - "hasSubMenu" : false, - "radio": true, - "enabled": true, - "checked": { - "value": false, - "boundProperty": "layoutOff" + "action": "executeFileCloseAll" + }, + { + "displayText" : "", + "separator": true + }, + { + "displayText" : "Save", + "hasSubMenu" : false, + "enabled": { + "value": false, + "boundObj": "documentController", + "boundProperty": "canSave", + "oneway": true + }, + "action": "executeSave" + }, + { + "displayText" : "Save As", + "hasSubMenu" : false, + "enabled": { + "value": false, + "boundObj": "documentController", + "boundProperty": "activeDocument", + "oneway": true, + "boundValueMutator": function(activeDocument){ + if(activeDocument !== null){return true;} + else{return false;} } - } - ] - }, - { - "displayText" : "Snap", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "snap" - } - - }, - { - "displayText" : "Snap To", - "hasSubMenu" : false, - "enabled": { - "value": true, - "boundObj": "appModel", - "boundProperty": "snap" - }, - "submenu": true, - "entries": [ - { - "displayText" : "Grid", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "snapGrid" + }, + "action":"executeSaveAs" + }, + { + "displayText" : "Save All", + "hasSubMenu" : false, + "enabled": { + "value": false, + "boundObj": "documentController", + "boundProperty": "canSaveAll", + "oneway": true, + "boundValueMutator": function(canSaveAll){ + if(canSaveAll === true){return true;} + else{return false;} } }, - { - "displayText" : "Objects", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "snapObjects" + "action": "executeSaveAll" + }, + { + "displayText" : "", + "separator": true + }, + { + "displayText" : "Open Project", + "hasSubMenu" : false, + "enabled": false + }, + { + "displayText" : "Open Recent", + "hasSubMenu" : false, + "enabled": false + }, + { + "displayText" : "Close Project", + "hasSubMenu" : false, + "enabled": false + } + ] + }, + { + "header": "Edit", + "entries": [ + { + "displayText" : "Undo", + "hasSubMenu" : false, + "enabled": { + "value": false, + "boundObj": "undocontroller", + "boundProperty": "canUndo", + "oneway": true + }, + "action": "executeUndo" + }, + { + "displayText" : "Redo", + "hasSubMenu" : false, + "enabled": { + "value": false, + "boundObj": "undocontroller", + "boundProperty": "canRedo", + "oneway": true + }, + "action": "executeRedo" + }, + { + "displayText" : "Cut", + "hasSubMenu" : false, + "enabled": true + }, + { + "displayText" : "Copy", + "hasSubMenu" : false, + "enabled": true + }, + { + "displayText" : "Paste", + "hasSubMenu" : false, + "enabled": true + } + ] + }, + { + "header": "View", + "entries": [ + { + "displayText" : "Zoom In", + "hasSubMenu" : false, + "enabled": true + }, + { + "displayText" : "Zoom Out", + "hasSubMenu" : false, + "enabled": true + }, + { + "displayText" : "", + "separator": true + }, + { + "displayText" : "Live Preview", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": false, + "boundProperty": "livePreview" + } + }, + { + "displayText" : "Chrome Preview", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": false, + "boundProperty": "chromePreview" + } + }, + { + "displayText" : "Layout View", + "hasSubMenu" : false, + "enabled": true, + "submenu": true, + "entries": [ + { + "displayText" : "View All", + "hasSubMenu" : false, + "radio": true, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "layoutAll" + } + }, + { + "displayText" : "View Items Only", + "hasSubMenu" : false, + "radio": true, + "enabled": true, + "checked": { + "value": false, + "boundProperty": "layoutItems" + } + }, + { + "displayText" : "Off", + "hasSubMenu" : false, + "radio": true, + "enabled": true, + "checked": { + "value": false, + "boundProperty": "layoutOff" + } } + ] + }, + { + "displayText" : "Snap", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "snap" + } + + }, + { + "displayText" : "Snap To", + "hasSubMenu" : false, + "enabled": { + "value": true, + "boundObj": "appModel", + "boundProperty": "snap", + "oneway": true }, - { - "displayText" : "Snap Align", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "snapAlign" + "submenu": true, + "entries": [ + { + "displayText" : "Grid", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "snapGrid" + } + }, + { + "displayText" : "Objects", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "snapObjects" + } + }, + { + "displayText" : "Snap Align", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "snapAlign" + } } + ] + }, + { + "displayText" : "Show 3D Grid", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": false, + "boundProperty": "show3dGrid" + } + }, + { + "displayText" : "", + "separator": true + }, + { + "displayText" : "Front View", + "hasSubMenu" : false, + "enabled": true, + "radio": true, + "checked": { + "value": true, + "boundProperty": "frontStageView" + } + }, + { + "displayText" : "Top View", + "hasSubMenu" : false, + "enabled": true, + "radio": true, + "checked": { + "value": true, + "boundProperty": "topStageView" + } + }, + { + "displayText" : "Side View", + "hasSubMenu" : false, + "enabled": true, + "radio": true, + "checked": { + "value": true, + "boundProperty": "sideStageView" + } + }, + { + "displayText" : "", + "separator": true + }, + { + "displayText" : "Debug", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "debug" } - ] - }, - { - "displayText" : "Show 3D Grid", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": false, - "boundProperty": "show3dGrid" - } - }, - { - "displayText" : "", - "separator": true - }, - { - "displayText" : "Front View", - "hasSubMenu" : false, - "enabled": true, - "radio": true, - "checked": { - "value": true, - "boundProperty": "frontStageView" - } - }, - { - "displayText" : "Top View", - "hasSubMenu" : false, - "enabled": true, - "radio": true, - "checked": { - "value": true, - "boundProperty": "topStageView" - } - }, - { - "displayText" : "Side View", - "hasSubMenu" : false, - "enabled": true, - "radio": true, - "checked": { - "value": true, - "boundProperty": "sideStageView" - } - }, - { - "displayText" : "", - "separator": true - }, - { - "displayText" : "Debug", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "debug" - } - } - ] - }, - { - "header": "Window", - "entries": [ - { - "displayText" : "Tools", - "hasSubMenu" : false, - "enabled": true - }, - { - "displayText" : "Timeline", - "hasSubMenu" : false, - "enabled": true - }, - { - "displayText" : "Properties", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "PropertiesPanel" - } - }, - { - "displayText" : "Project", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "ProjectPanel" - } - }, - { - "displayText" : "Color", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "ColorPanel" - } - }, - { - "displayText" : "Components", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "ComponentsPanel" - } - }, - { - "displayText" : "CSS", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "CSSPanel" } - }, - { - "displayText" : "Materials", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "MaterialsPanel" + ] + }, + { + "header": "Window", + "entries": [ + { + "displayText" : "Tools", + "hasSubMenu" : false, + "enabled": true + }, + { + "displayText" : "Timeline", + "hasSubMenu" : false, + "enabled": true + }, + { + "displayText" : "Properties", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "PropertiesPanel" + } + }, + { + "displayText" : "Project", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "ProjectPanel" + } + }, + { + "displayText" : "Color", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "ColorPanel" + } + }, + { + "displayText" : "Components", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "ComponentsPanel" + } + }, + { + "displayText" : "CSS", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "CSSPanel" + } + }, + { + "displayText" : "Materials", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "MaterialsPanel" + } + }, + { + "displayText" : "Presets", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": true, + "boundProperty": "PresetsPanel" + } + }, + { + "displayText" : "Code", + "hasSubMenu" : false, + "enabled": true } - }, - { - "displayText" : "Presets", - "hasSubMenu" : false, - "enabled": true, - "checked": { - "value": true, - "boundProperty": "PresetsPanel" + ] + }, + { + "header": "Help", + "entries": [ + { + "displayText" : "Ninja FAQ", + "hasSubMenu" : false, + "enabled": true, + "action": "executeHelpFAQ" + }, + { + "displayText" : "Ninja Forums", + "hasSubMenu" : false, + "enabled": true, + "action": "executeHelpForums" + }, + { + "displayText" : "Help Topics", + "hasSubMenu" : false, + "enabled": true, + "action": "executeHelpTopics" + }, + { + "displayText" : "About Ninja...", + "hasSubMenu" : false, + "enabled": true, + "action": "executeHelpAbout" } - }, - { - "displayText" : "Code", - "hasSubMenu" : false, - "enabled": true - } - ] - }, - { - "header": "Help", - "entries": [ - { - "displayText" : "Ninja FAQ", - "hasSubMenu" : false, - "enabled": true, - "action": "executeHelpFAQ" - }, - { - "displayText" : "Ninja Forums", - "hasSubMenu" : false, - "enabled": true, - "action": "executeHelpForums" - }, - { - "displayText" : "Help Topics", - "hasSubMenu" : false, - "enabled": true, - "action": "executeHelpTopics" - }, - { - "displayText" : "About Ninja...", - "hasSubMenu" : false, - "enabled": true, - "action": "executeHelpAbout" - } - ] - } - ] + ] + } + ] } }); diff --git a/js/document/text-document.js b/js/document/text-document.js index 88464d87..54a53999 100755 --- a/js/document/text-document.js +++ b/js/document/text-document.js @@ -163,7 +163,13 @@ var TextDocument = exports.TextDocument = Montage.create(Component, { needsSave: { get: function() { return this._needsSave; }, - set: function(value) { this._needsSave = value } + set: function(value) { + var i=0, canSaveAll=false; + this._needsSave = value; + + this.application.ninja.documentController.canSave = value;//for save menu state update + this.application.ninja.documentController.canSaveAll = value;//for save menu state update..currently save all is tried to the current document only + } }, callback: { -- cgit v1.2.3 From 2557f463c1cfe2d0dd8ea187c184755bd141dab4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:38:44 -0700 Subject: IKNINJA-1302 : For File>New and File>SaveAll dialogs, 'ESC' key now triggers Cancel button and 'Enter' key now triggers OK button. For File picker, the 'ESC' now triggers the Cancel button. Signed-off-by: Ananya Sen Conflicts: js/io/ui/new-file-dialog/new-file-workflow-controller.js Signed-off-by: Ananya Sen --- js/io/ui/file-picker/file-picker-controller.js | 7 +++++- .../picker-navigator.reel/picker-navigator.js | 2 +- .../new-file-location.reel/new-file-location.js | 6 +++++ .../new-file-options-navigator.js | 8 ++++++ .../new-file-workflow-controller.js | 14 +++++++++-- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 23 +++++++++++++++-- js/mediators/keyboard-mediator.js | 29 ++++++++++++++++++++++ 7 files changed, 83 insertions(+), 6 deletions(-) (limited to 'js') diff --git a/js/io/ui/file-picker/file-picker-controller.js b/js/io/ui/file-picker/file-picker-controller.js index 105dc223..e3276ee6 100755 --- a/js/io/ui/file-picker/file-picker-controller.js +++ b/js/io/ui/file-picker/file-picker-controller.js @@ -23,6 +23,11 @@ var FilePickerController = exports.FilePickerController = Montage.create(require } }, + pickerNavChoices:{ + enumerable: true, + value: null + }, + filePickerPopupType:{ enumerable: false, value: "filePicker" @@ -149,7 +154,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require writable:false, enumerable:true, value:function(callback, aModel){ - var pickerNavChoices = Montage.create(pickerNavigatorReel); + var pickerNavChoices = this.pickerNavChoices = Montage.create(pickerNavigatorReel); var initUri = aModel.currentRoot; //remove extra / at the end diff --git a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js index 7a9d90b4..e31fa29d 100644 --- a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js +++ b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js @@ -258,7 +258,6 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.element.addEventListener("refreshTreeSegment", function(evt){that.handlePickerNavRefreshTreeSegment(evt);}, false); this.resultsArea.addEventListener("click", function(evt){that.handleResultsAreaClick(evt);}, false); this.element.addEventListener("click", function(evt){that.handlePickerNavClick(evt);}, false); - this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); @@ -1071,6 +1070,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { //clear memory - TODO:check for more memory leaks this.pickerModel = null; this.application.ninja.filePickerController._directoryContentCache = {}; + this.application.ninja.filePickerController.pickerNavChoices = null; //remove listeners this.element.removeEventListener("openFolder", this, false);//add icon double click event listener to reload iconList with new set of data this.element.removeEventListener("selectedItem", this, false);//for single selection only diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js index 0e1e09a4..c4b7ea99 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js @@ -34,6 +34,12 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { newFileNameSetEvent.newFileName = this.newFileName.value; this.eventManager.dispatchEvent(newFileNameSetEvent); } + if(evt.keyCode === 13){ + var enterPressedEvent = document.createEvent("Events"); + enterPressedEvent.initEvent("enterPressed", false, false); + enterPressedEvent.newFileName = this.newFileName.value; + this.eventManager.dispatchEvent(enterPressedEvent); + } } } diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index aaf39005..5adcc250 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -106,6 +106,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + this.element.addEventListener("enterPressed", function(evt){ + if(!that.okButton.hasAttribute("disabled")){ + that.handleOkButtonAction(evt); + } + }, false); + if(!!this.newFileModel.defaultProjectType){ var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); this.templateList = iconsListModule.IconsList.create(); @@ -382,6 +388,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.element.removeEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only this.eventManager.removeEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); this.eventManager.removeEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); + + this.application.ninja.newFileController.newFileOptionsNav = null; } }, diff --git a/js/io/ui/new-file-dialog/new-file-workflow-controller.js b/js/io/ui/new-file-dialog/new-file-workflow-controller.js index d065ca35..279a74b4 100755 --- a/js/io/ui/new-file-dialog/new-file-workflow-controller.js +++ b/js/io/ui/new-file-dialog/new-file-workflow-controller.js @@ -27,6 +27,16 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre value: null }, + newFileOptionsNav:{ + enumerable:true, + value: null + }, + + saveAsDialog:{ + enumerable:true, + value: null + }, + showNewFileDialog:{ writable:false, enumerable:true, @@ -49,7 +59,7 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre this.model.defaultProjectType = lastSelectedProjectType; } - var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); + var newFileOptionsNav = this.newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); newFileOptionsNav.newFileModel = this.model; var popup = Popup.create(); @@ -70,7 +80,7 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre var fileName = data.fileName || "filename.txt"; var folderUri = data.folderUri || "/Documents"; - var saveAsDialog = saveAsModule.SaveAsDialog.create(); + var saveAsDialog = this.saveAsDialog = saveAsModule.SaveAsDialog.create(); saveAsDialog.fileName = fileName; saveAsDialog.folderUri = folderUri; saveAsDialog.callback = data.callback; diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.js b/js/io/ui/save-as-dialog.reel/save-as-dialog.js index c60a92f9..98749106 100644 --- a/js/io/ui/save-as-dialog.reel/save-as-dialog.js +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js @@ -83,6 +83,11 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.enableOk(); } } + if(evt.keyCode === 13){ + if(!this.okButton.hasAttribute("disabled")){ + this.handleOkButtonAction(evt); + } + } } }, @@ -99,7 +104,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { handleCancelButtonAction :{ value:function(evt){ //clean up memory - //this.cleanup(); + this.cleanup(); if(this.popup){ this.popup.hide(); @@ -134,7 +139,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { if(success){ //clean up memory - //this.cleanup(); + this.cleanup(); if(this.popup){ this.popup.hide(); @@ -227,6 +232,20 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { } return status; } + }, + + cleanup:{ + value:function(){ + var self = this; + + //remove event listener + this.newFileName.removeEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); + this.eventManager.removeEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); + this.okButton.removeEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); + this.cancelButton.removeEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); + + this.application.ninja.newFileController.saveAsDialog = null; } + } }); \ No newline at end of file diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 65dd34cd..63dcfa88 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -246,6 +246,35 @@ exports.KeyboardMediator = Montage.create(Component, { return; } + // check for ENTER key + if((evt.keyCode == Keyboard.ENTER) && !(evt.ctrlKey || evt.metaKey)) { + //new file + if((this.application.ninja.newFileController.newFileOptionsNav !== null) + && !this.application.ninja.newFileController.newFileOptionsNav.okButton.hasAttribute("disabled")){ + + this.application.ninja.newFileController.newFileOptionsNav.handleOkButtonAction(); + } + //save as + if((this.application.ninja.newFileController.saveAsDialog !== null) + && !this.application.ninja.newFileController.saveAsDialog.okButton.hasAttribute("disabled")){ + + this.application.ninja.newFileController.saveAsDialog.handleOkButtonAction(); + } + return; + } + //ESC key + if(evt.keyCode === Keyboard.ESCAPE){ + if(this.application.ninja.filePickerController.pickerNavChoices !== null){ + this.application.ninja.filePickerController.pickerNavChoices.handleCancelButtonAction(); + } + if(this.application.ninja.newFileController.newFileOptionsNav !== null){ + this.application.ninja.newFileController.newFileOptionsNav.handleCancelButtonAction(); + } + if(this.application.ninja.newFileController.saveAsDialog !== null){ + this.application.ninja.newFileController.saveAsDialog.handleCancelButtonAction(); + } + return; + } } }, -- cgit v1.2.3 From 15bd1a15459df5c831c97ee7bf225af47d812385 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:40:22 -0700 Subject: IKNINJA-1266 : restrict tab size for long file names and resize tabs on window resize Signed-off-by: Ananya Sen --- js/components/layout/document-entry.reel/document-entry.css | 13 ++++++++++--- js/components/layout/documents-tab.reel/documents-tab.css | 11 +++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/components/layout/document-entry.reel/document-entry.css b/js/components/layout/document-entry.reel/document-entry.css index 52d08d72..d723c45f 100755 --- a/js/components/layout/document-entry.reel/document-entry.css +++ b/js/components/layout/document-entry.reel/document-entry.css @@ -4,19 +4,26 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ +.documentEntry{ + white-space: nowrap; +} + .documentEntry span { - /*display: inline-block;*/ + display: inline-block; white-space: nowrap; overflow: hidden; - text-overflow: ellipsis; /* Causes ... to appear ?? */ + text-overflow: ellipsis; max-width:100px; + width:85%; + min-width:0px; } .documentEntry img { opacity: 0.5; /* 50% */ - padding-left: 5px; width: 12px; + max-width:12px; + min-width:5px; height: 12px; -webkit-transition: opacity 0.2s ease; transition: opacity 0.2s ease; diff --git a/js/components/layout/documents-tab.reel/documents-tab.css b/js/components/layout/documents-tab.reel/documents-tab.css index 689eb777..da00f727 100755 --- a/js/components/layout/documents-tab.reel/documents-tab.css +++ b/js/components/layout/documents-tab.reel/documents-tab.css @@ -12,7 +12,6 @@ } .openDocuments { - float: left; height: 25px; width: 100%; font-size: 12px; @@ -21,16 +20,20 @@ padding: 0; position: relative; text-decoration: none; + display: -webkit-box; + -webkit-box-orient: horizontal; + -webkit-box-pack:start; + -webkit-box-align:start; } .openDocuments li { border-right: 1px solid black; cursor: pointer; - display: inline; - float: left; padding: 0.5em 1em; - text-shadow: 1px 1px 1px #000000; vertical-align: middle; + text-shadow: 1px 1px 1px #000000; + -webkit-box-flex: 1; + max-width: 115px; } .openDocuments li:hover, -- cgit v1.2.3 From 85bf9f937fa2ec46e42f791fc6815f7c2f5446ea Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:42:05 -0700 Subject: file picker - added size unit new file - don't disable OK is file exists Signed-off-by: Ananya Sen --- js/components/ui/icon-list-basic/icon.reel/icon.js | 2 +- .../ui/tree-basic/treeItem.reel/treeItem.js | 2 +- .../picker-navigator.reel/picker-navigator.js | 2 +- .../new-file-options-navigator.js | 26 +++++++++++++++------- 4 files changed, 21 insertions(+), 11 deletions(-) (limited to 'js') diff --git a/js/components/ui/icon-list-basic/icon.reel/icon.js b/js/components/ui/icon-list-basic/icon.reel/icon.js index 1ef6e277..7d36bc59 100755 --- a/js/components/ui/icon-list-basic/icon.reel/icon.js +++ b/js/components/ui/icon-list-basic/icon.reel/icon.js @@ -86,7 +86,7 @@ var Icon = exports.Icon = Montage.create(Component, { this.metadata = "Name: "+this.icondata.name; } this.metadata = this.metadata + "
" + "Type: "+this.icondata.type; - if(this.icondata.size){this.metadata = this.metadata + "
" + "Size: "+this.icondata.size;} + if(this.icondata.size){this.metadata = this.metadata + "
" + "Size: "+this.icondata.size+ " bytes";} if(this.icondata.creationDate){this.metadata = this.metadata + "
" + "Creation date: "+ this.formatTimestamp(this.icondata.creationDate);} if(this.icondata.modifiedDate){this.metadata = this.metadata + "
" + "Modified date: "+ this.formatTimestamp(this.icondata.modifiedDate);} diff --git a/js/components/ui/tree-basic/treeItem.reel/treeItem.js b/js/components/ui/tree-basic/treeItem.reel/treeItem.js index 13e278e9..e9e5c1fb 100755 --- a/js/components/ui/tree-basic/treeItem.reel/treeItem.js +++ b/js/components/ui/tree-basic/treeItem.reel/treeItem.js @@ -118,7 +118,7 @@ exports.TreeItem = Montage.create(Component, { this.metadata = "Name: "+this.treeItemData.name; } this.metadata = this.metadata + "
" + "Type: "+this.treeItemData.type; - if(this.treeItemData.size){this.metadata = this.metadata + "
" + "Size: "+this.treeItemData.size;} + if(this.treeItemData.size){this.metadata = this.metadata + "
" + "Size: "+this.treeItemData.size+ " bytes";} if(this.treeItemData.creationDate){this.metadata = this.metadata + "
" + "Creation date: "+ this.formatTimestamp(this.treeItemData.creationDate);} if(this.treeItemData.modifiedDate){this.metadata = this.metadata + "
" + "Modified date: "+ this.formatTimestamp(this.treeItemData.modifiedDate);} diff --git a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js index e31fa29d..3cf6fc5a 100644 --- a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js +++ b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js @@ -500,7 +500,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { metadata = "Name: "+data.name; } metadata = metadata + "
" + "Type: "+data.type; - if(data.size){metadata = metadata + "
" + "Size: "+data.size;} + if(data.size){metadata = metadata + "
" + "Size: "+data.size+" bytes";} if(data.creationDate){metadata = metadata + "
" + "Creation date: "+ this.formatTimestamp(data.creationDate);} if(data.modifiedDate){metadata = metadata + "
" + "Modified date: "+ this.formatTimestamp(data.modifiedDate);} } diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index 5adcc250..f63067b1 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -297,10 +297,16 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C }else{ if(this.error.innerHTML === ""){ this.showError("! Project Template, Name and Directory should be valid."); - } - //disable ok - if(!this.okButton.hasAttribute("disabled")){ - this.okButton.setAttribute("disabled", "true"); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } + }else if(!this.selectedProjectType || !this.selectedTemplate){ + this.showError("! Project Template should be selected."); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } } } } @@ -399,6 +405,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(uri !== ""){ if(!status){ this.showError("! Invalid directory."); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } } } return status; @@ -410,6 +420,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(fileName !== ""){ if(!status){ this.showError("! Invalid file name."); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } } } return status; @@ -445,10 +459,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C value:function(errorString){ this.error.innerHTML = ""; this.error.innerHTML=errorString; - //disable ok - if(!this.okButton.hasAttribute("disabled")){ - this.okButton.setAttribute("disabled", "true"); - } } }, -- cgit v1.2.3 From 5b0ff2b7347d158876c366c51988a94570dda18b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:43:54 -0700 Subject: IKNINJA-1302 : more fix Signed-off-by: Ananya Sen --- .../file-input-field.reel/file-input-field.js | 1 + .../new-file-location.reel/new-file-location.js | 7 +--- .../new-file-options-navigator.js | 39 +++++++++++----------- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 5 ++- 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'js') diff --git a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js index 651fd7fa..ccb925b9 100755 --- a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js +++ b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js @@ -69,6 +69,7 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { var newFileDirectorySetEvent = document.createEvent("Events"); newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; + newFileDirectorySetEvent.keyCode = evt.keyCode; this.eventManager.dispatchEvent(newFileDirectorySetEvent); } } diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js index c4b7ea99..811231e4 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js @@ -32,14 +32,9 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { var newFileNameSetEvent = document.createEvent("Events"); newFileNameSetEvent.initEvent("newFileNameSet", false, false); newFileNameSetEvent.newFileName = this.newFileName.value; + newFileNameSetEvent.keyCode = evt.keyCode;