diff options
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.js | 417 |
1 files changed, 417 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..f514b81a --- /dev/null +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js | |||
@@ -0,0 +1,417 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No 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 | |||
7 | var 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 | |||
13 | var 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 | this.templateList.element = this.templateIcons; | ||
92 | this.templateList.needsDraw = true; | ||
93 | |||
94 | |||
95 | this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; | ||
96 | } | ||
97 | |||
98 | //update file Extension | ||
99 | if(!!this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension){ | ||
100 | var fileExtensionEl = this.element.querySelector(".fileExtension"); | ||
101 | if(!!fileExtensionEl){ | ||
102 | fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension; | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | |||
107 | }, | ||
108 | |||
109 | /** | ||
110 | * Event Listners | ||
111 | */ | ||
112 | |||
113 | addIdentifiers:{ | ||
114 | value: function(){ | ||
115 | this.element.identifier = "newFileNav"; | ||
116 | } | ||
117 | }, | ||
118 | |||
119 | handleNewFileNavDrawTree:{ | ||
120 | value: function(evt){ | ||
121 | //toggle open or close for directory | ||
122 | if((evt.uriType === "directory") && (!!evt.subTreeContainer)){ | ||
123 | var tree = treeModule.Tree.create(); | ||
124 | tree.showIcons = false; | ||
125 | tree.highlightedUri = this.newFileModel.defaultProjectType; | ||
126 | tree.treeViewDataObject = this.newFileModel.prepareContents(evt.uri); | ||
127 | tree.element = evt.subTreeContainer; | ||
128 | tree.needsDraw = true; | ||
129 | } | ||
130 | } | ||
131 | }, | ||
132 | |||
133 | handleNewFileNavSelectedItem:{ | ||
134 | value: function(evt){ | ||
135 | var selectionType = this.newFileModel.projectTypeData[evt.uri].type; | ||
136 | if(evt.target.classList.contains("atreeItemContent") && (selectionType === "file")){//populate templates for project type selection | ||
137 | this.highlightSelection(evt.target, "projectType", evt.uri); | ||
138 | |||
139 | //clear current template selection | ||
140 | if((!!this.selectedTemplate) && (this.selectedTemplate.element.classList.contains("selected"))){ | ||
141 | this.selectedTemplate.element.classList.remove("selected"); | ||
142 | } | ||
143 | |||
144 | //update file Extension | ||
145 | if(!!this.newFileModel.projectTypeData[evt.uri].fileExtension){ | ||
146 | var fileExtensionEl = this.element.querySelector(".fileExtension"); | ||
147 | if(!!fileExtensionEl){ | ||
148 | fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[evt.uri].fileExtension; | ||
149 | } | ||
150 | } | ||
151 | |||
152 | //disable ok | ||
153 | if(!this.okButton.hasAttribute("disabled")){ | ||
154 | this.okButton.setAttribute("disabled", "true"); | ||
155 | } | ||
156 | |||
157 | //save project type selection | ||
158 | this.selectedProjectType = {"uri":evt.uri, "element":evt.target}; | ||
159 | |||
160 | //render templates | ||
161 | var templates = this.newFileModel.prepareContents(evt.uri); | ||
162 | if(this.templatesContainer.querySelectorAll(".list").length > 0){ | ||
163 | this.templateList.iconsViewDataObject = templates; | ||
164 | }else{ | ||
165 | this.templateList = iconsListModule.IconsList.create(); | ||
166 | this.templateList.iconsViewDataObject = templates; | ||
167 | this.templateList.element = this.templateIcons; | ||
168 | this.templateList.needsDraw = true; | ||
169 | } | ||
170 | |||
171 | |||
172 | } | ||
173 | |||
174 | if(evt.target.classList.contains("icon")){ | ||
175 | this.highlightSelection(evt.target, "template", evt.uri); | ||
176 | |||
177 | //save template selection | ||
178 | this.selectedTemplate = {"uri":evt.uri, "element":evt.target}; | ||
179 | |||
180 | this.enableOk(); | ||
181 | |||
182 | } | ||
183 | } | ||
184 | }, | ||
185 | |||
186 | handleCancelButtonAction :{ | ||
187 | value:function(evt){ | ||
188 | //clean up memory | ||
189 | this.cleanup(); | ||