AppfiXarna
AppfiXarna

Reputation: 11

Titanium Alloy - Closeing window

Im working in Titanium Alloy and creating a popup window as a widget. I want to have the close - image up over the right top corner, so it stick abit out of the popup window. So I created 2 separate window in the widget xml-file. One to just hold the close - image and one who is the popup - window.
Everythings look as I want, but I cant get the popup - window to close?!

I have tried: $.myWindow.close();

Amd I have tried: var win = Widget.createController('myWindow', 'myWindowID').getView(); win.close();

But nothing happens

Here is my xml - code:

<Alloy>
    <Window id="popup">
        <View id="myImagesViewIn" class="myImagesViewIn" onClick="closeWin">
            <ImageView id="myImageIn" class="myImageIN" />
        </View>
    </Window>
    <Window id="winImageOut" onClick="closeWindow">
        <View id="myImagesViewOut" class="myImagesViewOut" >
            <ImageView id="myImageOut" class="myImageOut" />
        </View>
    </Window>
</Alloy>

And here is my JS-code:

var args = arguments[0] || {};

$.popup.transform = args.transform || '';

/*
 exports.setDataModalWindow = function(data) {
 $.lblModalWinHead.text = data.title;
 $.lblModalWinBody.text = data.text;
 };
 */
function fnCloseClick() {
    $.viewModal.close();
}

/*
 $.myImagesViewOut.addEventListener('click', function(e) {
 $.popup.close();
 });
 */

function closeWin(e) {
    $.myImagesViewOut.setVisible(false);
    $.popup.close();

}

function closeWindow(e) {

    //$.popup.close();
    var wins = Widget.createController('widget', 'popup').getView();
    wins.setVisible(false);
    alert('hejsan');
    //Ti.API.info('close');
}

exports.openModalWindow = function(arg) {

    //$.lblModalTitle.text = arg.title || 'foo';
    //$.lblModalText.text = arg.text || 'ff';

    var t = Titanium.UI.create2DMatrix().scale(0);

    var args = {

        transform : t
    };

    var controller = Widget.createController('widget', args).getView();

    controller.open();

    // controller.animate(a2);

    var t1 = Titanium.UI.create2DMatrix();
    t1 = t1.scale(1.2);
    var a1 = Titanium.UI.createAnimation();
    a1.transform = t1;
    a1.duration = 400;

    controller.animate(a1);

    var b1 = Titanium.UI.create2DMatrix();
    var a2;
    a1.addEventListener('complete', function() {
        b1 = b1.scale(1.5);
        a2 = Titanium.UI.createAnimation();
        a2.transform = b1;
        a2.duration = 400;

        controller.animate(a2);

    });
    // create the controller a keep the reference

    /*
    controller.setDetails({
    label: 'Are you sure you wish to log out?\n\nIf you do so you will no longer be able to take part in any challenges until you login again.',
    ok: 'Log me out',
    cancel: 'Cancel'
    });
    */
    // now get a reference to the UI inside the controller
    //var win = controller.getView();

    a1.addEventListener('complete', function() {
        // simple reset animation
        var t2 = Ti.UI.create2DMatrix();
        var a3 = Titanium.UI.createAnimation();
        a3.transform = t2;
        a3.duration = 400;
        controller.animate(a3);

        $.winImageOut.open();

    });

};

Upvotes: 0

Views: 2116

Answers (1)

Mitul Bhalia
Mitul Bhalia

Reputation: 1217

first thing is you are opening popup window so you should open that window...

then you should close bot the window in closeWindow function.

function closeWindow(e) {

    $.popup.close();
    $.winImageOut.close();
    alert('hejsan');
    //Ti.API.info('close');
}

I do not know your requirement but you should use only one window to show popup then its easy for you to handle open,close event of window.

Upvotes: 1

Related Questions