From 50a40c4e21b9a4d53d6d1fb739d838c0319ab09b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 13 Feb 2012 19:55:46 -0800 Subject: new file dialog - preselect default template Signed-off-by: Ananya Sen --- js/components/ui/icon-list-basic/icon.reel/icon.js | 14 ++++++++++++++ .../ui/icon-list-basic/iconsList.reel/iconsList.html | 5 +++++ .../ui/icon-list-basic/iconsList.reel/iconsList.js | 8 +++++++- .../new-file-options-navigator.js | 9 +++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) 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 d934e7f1..b0279207 100755 --- a/js/components/ui/icon-list-basic/icon.reel/icon.js +++ b/js/components/ui/icon-list-basic/icon.reel/icon.js @@ -22,6 +22,13 @@ var Icon = exports.Icon = Montage.create(Component, { this.needsDraw = true; } }, + + selectedUri:{ + writable:true, + enumerable:true, + value:null + }, + metadata:{ enumerable:true, writable:true, @@ -83,6 +90,13 @@ var Icon = exports.Icon = Montage.create(Component, { 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);} + //show default selection + if(this.icondata.uri === this.selectedUri){ + var selectedItemEvent = document.createEvent("Events"); + selectedItemEvent.initEvent("selectedItem", false, false); + selectedItemEvent.uri = this.icondata.uri; + this.element.dispatchEvent(selectedItemEvent); + } } }, diff --git a/js/components/ui/icon-list-basic/iconsList.reel/iconsList.html b/js/components/ui/icon-list-basic/iconsList.reel/iconsList.html index 50a1d61d..0bb79873 100755 --- a/js/components/ui/icon-list-basic/iconsList.reel/iconsList.html +++ b/js/components/ui/icon-list-basic/iconsList.reel/iconsList.html @@ -21,6 +21,11 @@ "boundObject": {"@": "repetition1"}, "boundObjectPropertyPath": "objectAtCurrentIteration", "oneway": true + }, + "selectedUri": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "selected", + "oneway": true } } }, diff --git a/js/components/ui/icon-list-basic/iconsList.reel/iconsList.js b/js/components/ui/icon-list-basic/iconsList.reel/iconsList.js index 56eb57c3..d36aa40f 100755 --- a/js/components/ui/icon-list-basic/iconsList.reel/iconsList.js +++ b/js/components/ui/icon-list-basic/iconsList.reel/iconsList.js @@ -15,11 +15,17 @@ var IconsList = exports.IconsList = Montage.create(Component, { }, iconsViewDataObject:{ - writable:true, + writable:true, enumerable:true, value:[] }, + selected:{ + writable:true, + enumerable:true, + value:null + }, + willDraw: { enumerable: false, value: function() { 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 848e0cb8..f5ab0027 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 @@ -88,6 +88,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); this.templateList = iconsListModule.IconsList.create(); this.templateList.iconsViewDataObject = templates; + if(templates.length >0){ + this.templateList.selected = templates[0].uri; + } this.templateList.element = this.templateIcons; this.templateList.needsDraw = true; @@ -161,9 +164,15 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C var templates = this.newFileModel.prepareContents(evt.uri); if(this.templatesContainer.querySelectorAll(".list").length > 0){ this.templateList.iconsViewDataObject = templates; + if(templates.length >0){ + this.templateList.selected = templates[0].uri; + } }else{ this.templateList = iconsListModule.IconsList.create(); this.templateList.iconsViewDataObject = templates; + if(templates.length >0){ + this.templateList.selected = templates[0].uri; + } this.templateList.element = this.templateIcons; this.templateList.needsDraw = true; } -- cgit v1.2.3