aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
diff options
context:
space:
mode:
authorAnanya Sen2012-02-02 12:37:29 -0800
committerAnanya Sen2012-02-02 12:37:29 -0800
commit0e595c4e11ce9b44eff157de8616ed15fcd5d6fc (patch)
treeaba0df7f15b631345b9c44b6b50884d06b7a803a /js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
parent87e247e74040b5e80ff40003d233d5317881102a (diff)
downloadninja-0e595c4e11ce9b44eff157de8616ed15fcd5d6fc.tar.gz
refactoring some file names and locations,
change made to maintain only one codemirror div. Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js')
-rw-r--r--js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js378
1 files changed, 378 insertions, 0 deletions
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
new file mode 100644
index 00000000..cee8d4b7
--- /dev/null
+++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
@@ -0,0 +1,378 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component,
9 iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"),
10 treeModule = require("js/components/ui/tree-basic/tree.reel"),
11 newFileLocationSelectionModule = require("js/io/ui/new-file-dialog/new-file-workflow-controller"),
12 nj= require("js/lib/NJUtils.js").NJUtils;
13
14var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, {
15
16 newFileModel: {
17 writable: true,
18 enumerable:false,
19 value:null
20 },
21 selectedProjectType:{
22 writable: true,
23 enumerable:false,
24 value:null
25 },
26 selectedTemplate:{
27 writable: true,
28 enumerable:false,
29 value:null
30 },
31 newFileName:{
32 writable:true,
33 enumerable:false,
34 value:""
35 },
36 newFileDirectory:{
37 writable:true,
38 enumerable:false,
39 value:""
40 },
41 templateWidth:{
42 writable:true,
43 enumerable:false,
44 value:"0 px"
45 },
46 templateHeight:{
47 writable:true,
48 enumerable:false,
49 value:"0 px"
50 },
51 willDraw: {
52 enumerable: false,
53 value: function() {}
54 },
55 draw: {
56 enumerable: false,
57 value: function() {}
58 },
59 didDraw: {
60 enumerable: false,
61 value: function() {
62 var that = this;
63
64 this.templateList = null;
65
66 //draw left nav project type tree
67 var tree = treeModule.Tree.create();
68 tree.showIcons = false;
69 tree.expandTreeAfterDraw = true;
70 tree.directoryBold = true;
71 tree.highlightedUri = this.newFileModel.defaultProjectType;
72 tree.treeViewDataObject = this.newFileModel.prepareContents("categories");
73 tree.element = this.projectTypeTree;
74 tree.needsDraw = true;
75
76 //highlight defaultProjectType
77
78 this.addIdentifiers();
79
80 this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false);
81 this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only
82 this.eventManager.addEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false);
83 this.eventManager.addEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false);
84
85 if(!!this.newFileModel.defaultProjectType){
86 var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType);
87 this.templateList = iconsListModule.IconsList.create();
88 this.templateList.iconsViewDataObject = templates;
89 this.templateList.element = this.templateIcons;
90 this.templateList.needsDraw = true;
91
92
93 this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null};
94 }
95 }
96
97 },
98
99 /**
100 * Event Listners
101 */
102
103 addIdentifiers:{
104 value: function(){
105 this.element.identifier = "newFileNav";
106 }
107 },
108
109 handleNewFileNavDrawTree:{
110 value: function(evt){
111 //toggle open or close for directory
112 if((evt.uriType === "directory") && (!!evt.subTreeContainer)){
113 var tree = treeModule.Tree.create();
114 tree.showIcons = false;
115 tree.highlightedUri = this.newFileModel.defaultProjectType;
116 tree.treeViewDataObject = this.newFileModel.prepareContents(evt.uri);
117 tree.element = evt.subTreeContainer;
118 tree.needsDraw = true;
119 }
120 }
121 },
122
123 handleNewFileNavSelectedItem:{
124 value: function(evt){
125 var selectionType = this.newFileModel.projectTypeData[evt.uri].type;
126 if(evt.target.classList.contains("atreeItemContent") && (selectionType === "file")){//populate templates for project type selection
127 this.highlightSelection(evt.target, "projectType", evt.uri);
128
129 //clear current template selection
130 if((!!this.selectedTemplate) && (this.selectedTemplate.element.classList.contains("selected"))){
131 this.selectedTemplate.element.classList.remove("selected");
132 }
133
134 //disable ok
135 if(!this.okButton.hasAttribute("disabled")){
136 this.okButton.setAttribute("disabled", "true");
137 }
138
139 //save project type selection
140 this.selectedProjectType = {"uri":evt.uri, "element":evt.target};
141
142 //render templates
143 var templates = this.newFileModel.prepareContents(evt.uri);
144 if(this.templatesContainer.querySelectorAll(".list").length > 0){
145 this.templateList.iconsViewDataObject = templates;
146 }else{
147 this.templateList = iconsListModule.IconsList.create();
148 this.templateList.iconsViewDataObject = templates;
149 this.templateList.element = this.templateIcons;
150 this.templateList.needsDraw = true;
151 }
152
153
154 }
155
156 if(evt.target.classList.contains("icon")){
157 this.highlightSelection(evt.target, "template", evt.uri);
158
159 //save template selection
160 this.selectedTemplate = {"uri":evt.uri, "element":evt.target};
161
162 this.enableOk();
163
164 }
165 }
166 },
167
168 handleCancelButtonAction :{
169 value:function(evt){
170 //clean up memory
171 this.cleanup();
172
173 if(this.popup){
174 this.popup.hide();
175 }
176
177 }
178 },
179
180 handleOkButtonAction:{
181 value: function(evt){
182 var selectedProjectTypeID = this.selectedProjectType.uri,
183 templateID = this.selectedTemplate.uri,
184 projectName = this.newFileLocation.newFileName.value,
185 projectDirectory = this.newFileLocation.fileInputField.newFileDirectory.value,