aboutsummaryrefslogtreecommitdiff
path: root/js/io/workflow/newFileDialog/new-file-workflow-controller.js
blob: 5cc68bf93b293bb641faa2928aa9e48709d6a5ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc.  All Rights Reserved.
</copyright> */

var Montage = require("montage/core/core").Montage,
    Popup = require("montage/ui/popup/popup.reel").Popup,
    newFileOptionsNavigatorModule = require("js/io/workflow/newFileDialog/new-file-options-navigator.reel"),
    newFileWorkflowModelModule = require("js/io/workflow/newFileDialog/new-file-workflow-model");

//singleton
exports.NewFileWorkflowController = Montage.create(require("montage/ui/component").Component, {
    /**
     * Register a listener for showPicker event
     */
    deserializedFromTemplate:{
        writable:false,
        enumerable:true,
        value:function(){
            var that = this;
            this.eventManager.addEventListener("executeNewFile", function(evt){
                that.showNewFileDialog();
            }, false);
        }
    },

    showNewFileDialog:{
        writable:false,
        enumerable:true,
        value:function(){
            var aModel = null;
            //render modal dialog
            var newFileNavContent = document.createElement("div");
            newFileNavContent.id = "newFileDialog";
            newFileNavContent.style.width = "650px";
            newFileNavContent.style.height = "350px";
            newFileNavContent.style.color = "#fff";

            //elements needs to be on DOM to be drawn
            document.getElementById('modalContainer').appendChild(newFileNavContent);

            var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create();
            newFileOptionsNav.newFileModel = newFileWorkflowModelModule.NewFileWorkflowModel;
            newFileOptionsNav.element = newFileNavContent;

            //hack - remove after rendering and add in modal dialog
            document.getElementById('modalContainer').removeChild(newFileNavContent);

            var popup = Popup.create();
            popup.content = newFileOptionsNav;
            popup.modal = true;
            popup.show();

            newFileOptionsNav.popup = popup;//handle to be used for hiding the popup

        }
    }
});