aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-02-22 16:26:41 -0800
committerArmen Kesablyan2012-02-22 16:26:41 -0800
commit0bd1cefea2ab350fad1a891bdc926053b799aafc (patch)
tree962f559fcc02a3dfeb297d59907e40fa153453f3 /js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
parent695bc5082f48dddf66ce31480a4faefc067b38bd (diff)
parent2d2b1af8b5c0d506fe6a1cf65614101fec145970 (diff)
downloadninja-0bd1cefea2ab350fad1a891bdc926053b799aafc.tar.gz
Merge branch 'refs/heads/master' into new-tool-icons
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.js442
1 files changed, 442 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..11b322fe
--- /dev/null
+++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
@@ -0,0 +1,442 @@
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
13var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, {
14
15 newFileModel: {
16 writable: true,
17 enumerable:false,
18 value:null
19 },
20 selectedProjectType:{
21 writable: true,
22 enumerable:false,
23 value:null
24 },
25 selectedTemplate:{
26 writable: true,
27 enumerable:false,
28 value:null
29 },
30 newFileName:{
31 writable:true,
32 enumerable:false,
33 value:""
34 },
35 newFileDirectory:{
36 writable:true,
37 enumerable:false,
38 value:""
39 },
40 templateWidth:{
41 writable:true,
42 enumerable:false,
43 value:"0 px"
44 },
45 templateHeight:{
46 writable:true,
47 enumerable:false,
48 value:"0 px"
49 },
50 willDraw: {
51 enumerable: false,
52 value: function() {}
53 },
54 draw: {
55 enumerable: false,
56 value: function() {}
57 },
58 didDraw: {
59 enumerable: false,
60 value: function() {
61 var that = this;
62
63 this.templateList = null;
64
65 //draw left nav project type tree
66 var tree = treeModule.Tree.create();
67 tree.showIcons = false;
68 tree.expandTreeAfterDraw = true;
69 tree.directoryBold = true;
70 tree.highlightedUri = this.newFileModel.defaultProjectType;
71 tree.treeViewDataObject = this.newFileModel.prepareContents("categories");
72 tree.element = this.projectTypeTree;
73 tree.needsDraw = true;
74
75 //highlight defaultProjectType
76
77 this.addIdentifiers();
78
79 this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false);
80 this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only
81 this.eventManager.addEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false);
82 this.eventManager.addEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false);
83
84 this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false);
85 this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false);
86
87 if(!!this.newFileModel.defaultProjectType){
88 var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType);
89 this.templateList = iconsListModule.IconsList.create();
90 this.templateList.iconsViewDataObject = templates;
91 if(templates.length >0){
92 this.templateList.selected = templates[0].uri;
93 }
94 this.templateList.element = this.templateIcons;
95 this.templateList.needsDraw = true;
96
97
98 this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null};
99 }
100
101 //update file Extension
102 if(!!this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension){
103 var fileExtensionEl = this.element.querySelector(".fileExtension");
104 if(!!fileExtensionEl){
105 fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension;
106 }
107 }
108 }
109
110 },
111
112 /**
113 * Event Listners
114 */
115
116 addIdentifiers:{
117 value: function(){
118 this.element.identifier = "newFileNav";
119 }
120 },
121
122 handleNewFileNavDrawTree:{
123 value: function(evt){
124 //toggle open or close for directory
125 if((evt.uriType === "directory") && (!!evt.subTreeContainer)){
126 var tree = treeModule.Tree.create();
127 tree.showIcons = false;
128 tree.highlightedUri = this.newFileModel.defaultProjectType;
129 tree.treeViewDataObject = this.newFileModel.prepareContents(evt.uri);
130 tree.element = evt.subTreeContainer;
131 tree.needsDraw = true;
132 }
133 }
134 },
135
136 handleNewFileNavSelectedItem:{
137 value: function(evt){
138 var selectionType = this.newFileModel.projectTypeData[evt.uri].type;
139 if(evt.target.classList.contains("atreeItemContent") && (selectionType === "file")){//populate templates for project type selection
140 this.highlightSelection(evt.target, "projectType", evt.uri);
141
142 //clear current template selection
143 if((!!this.selectedTemplate) && (this.selectedTemplate.element.classList.contains("selected"))){
144 this.selectedTemplate.element.classList.remove("selected");
145 }
146
147 //update file Extension
148 if(!!this.newFileModel.projectTypeData[evt.uri].fileExtension){
149 var fileExtensionEl = this.element.querySelector(".fileExtension");
150 if(!!fileExtensionEl){
151 fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[evt.uri].fileExtension;
152 }
153 }
154
155 //disable ok
156 if(!this.okButton.hasAttribute("disabled")){
157 this.okButton.setAttribute("disabled", "true");
158 }
159
160 //save project type selection
161 this.selectedProjectType = {"uri":evt.uri, "element":evt.target};
162
163 //render templates
164 var templates = this.newFileModel.prepareContents(evt.uri);
165 if(this.templatesContainer.querySelectorAll(".list").length > 0){
166 this.templateList.iconsViewDataObject = templates;
167 if(templates.length >0){
168 this.templateList.selected = templates[0].uri;
169 }
170 }else{
171 this.templateList = iconsListModule.IconsList.create();
172 this.templateList.iconsViewDataObject = templates;
173 if(templates.length >0){
174 this.templateList.selected = templates[0].uri;
175 }
176 this.templateList.element = this.templateIcons;
177 this.templateList.needsDraw = true;
178 }
179
180
181 }
182