Ejemplo n.º 1
0
function _initializeLayout(prev, baton) {
    var layout = db.retrieve("layout"),
        layoutLandscape = document.getElementById(constants.COMMON.ORIENTATION_SELECT_LANDSCAPE_ID),
        layoutPortrait = document.getElementById(constants.COMMON.ORIENTATION_SELECT_PORTRAIT_ID),
        currentDevice = devices.getCurrentDevice(),
        defaultOrientation =  currentDevice ? currentDevice.defaultOrientation : null,
        layoutTypeChanged = false;

    jQuery("#" + constants.COMMON.ORIENTATION_SELECT_LANDSCAPE_ID).bind("click", function () {
        resizer.changeLayoutType("landscape");
        event.trigger("LayoutChanged", ["landscape"], true);
        layoutLandscape.setAttribute("class", "layout-selected");
        layoutPortrait.setAttribute("class", "layout-not-selected");
    });

    jQuery("#" + constants.COMMON.ORIENTATION_SELECT_PORTRAIT_ID).bind("click", function () {
        resizer.changeLayoutType("portrait");
        event.trigger("LayoutChanged", ["portrait"], true);
        layoutLandscape.setAttribute("class", "layout-not-selected");
        layoutPortrait.setAttribute("class", "layout-selected");
    });

    jQuery("#" + constants.COMMON.MENU_BUTTON).bind("click", function () {
        event.trigger("HardwareKey", [1]);
    });

    jQuery("#" + constants.COMMON.BACK_BUTTON).bind("click", function () {
        event.trigger("HardwareKey", [0]);
    });

    if (!layout) {
        layout = defaultOrientation || "portrait";
        layoutTypeChanged = true;
        resizer.changeLayoutType(layout);
    }

    //Hide the orientation buttons that we don't need for this device
    if (!currentDevice.viewPort.landscape) {
        layoutLandscape.setAttribute("style", "display:none");
    }

    if (!currentDevice.viewPort.portrait) {
        layoutPortrait.setAttribute("style", "display:none");
    }

    if (layout && layout === "portrait") {
        layoutLandscape.setAttribute("class", "layout-not-selected");
        layoutPortrait.setAttribute("class", "layout-selected");
    }
    else if (layout && layout === "landscape") {
        layoutLandscape.setAttribute("class", "layout-selected");
        layoutPortrait.setAttribute("class", "layout-not-selected");
    }

    if (!layoutTypeChanged) {
        resizer.resize(currentDevice);
    }
}
Ejemplo n.º 2
0
 expect(function () {
     resizer.changeLayoutType("blargggg");
 }).toThrow();
Ejemplo n.º 3
0
 expect(function () {
     resizer.changeLayoutType(true);
 }).toThrow();
Ejemplo n.º 4
0
 expect(function () {
     resizer.changeLayoutType("1", "2", "3", 3, true);
 }).toThrow();
Ejemplo n.º 5
0
 jQuery("#" + constants.COMMON.ORIENTATION_SELECT_PORTRAIT_ID).bind("click", function () {
     resizer.changeLayoutType("portrait");
     event.trigger("LayoutChanged", ["portrait"], true);
     layoutLandscape.setAttribute("class", "layout-not-selected");
     layoutPortrait.setAttribute("class", "layout-selected");
 });
Ejemplo n.º 6
0
            it("triggers the orientationchange event off of window", function () {
                resizer.changeLayoutType("landscape");

                expect(evt.initEvent).toHaveBeenCalledWith("orientationchange", true, true);
                expect(win.dispatchEvent).toHaveBeenCalledWith(evt);
            });
Ejemplo n.º 7
0
 it("triggers the window.onorientationchange function when changed", function () {
     win.onorientationchange = jasmine.createSpy("onorientationchange");
     resizer.changeLayoutType("portrait");
     expect(win.onorientationchange).toHaveBeenCalled();
 });
Ejemplo n.º 8
0
 it("sets window.orientation to 90 when landscape", function () {
     resizer.changeLayoutType("landscape");
     expect(window.orientation).toBe(90);
     expect(win.orientation).toBe(90);
 });
Ejemplo n.º 9
0
 it("sets window.orientation to 0 when portrait", function () {
     resizer.changeLayoutType("portrait");
     expect(window.orientation).toBe(0);
     expect(win.orientation).toBe(0);
 });