All Downloads are FREE. Search and download functionalities are using the official Maven repository.

inspector.ide.js Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2012-2013 eBay Software Foundation and ios-driver committers
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

$(document).ready(function () {

    inspector = new Inspector("#tree");
});

var realOffsetX = 0;
var realOffsetY = 0;

var scale = 1;

var frame_h = 0;
var frame_w = 0;

var screen_h = 0;
var screen_w = 0;

var to_top = 0;
var to_left = 0;

var margin = 0;

findFrameSizeInPixels = function () {
    var w = $("#device").width();
    return w;
};

var device;
var orientation;
var variation;

configure = function (d, v, o) {
    device = d;
    orientation = o;
    variation = v;
    var FRAME_IPAD_H = 1108;
    var FRAME_IPAD_W = 852;
    var SCREEN_IPAD_H = 1024;
    var SCREEN_IPAD_W = 768;
    var SCREEN_TO_TOP_IPAD = 42;
    var SCREEN_TO_LEFT_IPAD = 42;

    var FRAME_IPHONE_H = 716;
    var FRAME_IPHONE_W = 368;
    var SCREEN_IPHONE_H = 480;
    var SCREEN_IPHONE_W = 320;
    var SCREEN_TO_TOP_IPHONE = 118;
    var SCREEN_TO_LEFT_IPHONE = 24;

    if (variation === 'Retina4') {
        SCREEN_IPHONE_H = 568;
        SCREEN_IPHONE_W = 320;
        FRAME_IPHONE_W = 386;
        FRAME_IPHONE_H = 806;
        SCREEN_TO_LEFT_IPHONE = 33;
        SCREEN_TO_TOP_IPHONE = 119;
    }

    if (device === 'ipad') {
        frame_h = FRAME_IPAD_H;
        frame_w = FRAME_IPAD_W;
        screen_h = SCREEN_IPAD_H;
        screen_w = SCREEN_IPAD_W;
        to_top = SCREEN_TO_TOP_IPAD;
        to_left = SCREEN_TO_LEFT_IPAD;
    } else if (device === 'iphone') {
        frame_h = FRAME_IPHONE_H;
        frame_w = FRAME_IPHONE_W;
        screen_h = SCREEN_IPHONE_H;
        screen_w = SCREEN_IPHONE_W;
        to_top = SCREEN_TO_TOP_IPHONE;
        to_left = SCREEN_TO_LEFT_IPHONE;
    } else {
        // console.log("error, wrong device :" + device);
    }

    console.log('TODO , freynaud : orientation norm.');
    // if the orientation is landscape, w and h are  inverted.
    if (orientation === 'UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT'
        || orientation === 'UIA_DEVICE_ORIENTATION_LANDSCAPELEFT'
        || orientation === 'LANDSCAPE') {
        var tmp = frame_h;
        frame_h = frame_w;
        frame_w = tmp;

        var tmp = screen_h;
        screen_h = screen_w;
        screen_w = tmp;

        tmp = to_top;
        to_top = to_left;
        to_left = tmp;

    }

};

/**
 * returns the html source of the webview, if any.
 */
getHTMLSource = function () {
    return source;
}
var source = null;
setHTMLSource = function (newSource) {
    source = newSource;
}
resize = function () {

    var neededSpace = frame_w;
    console.log('frame_w '+frame_w);

    var leftInPixel = findFrameSizeInPixels();
    scale = leftInPixel / neededSpace;
    if (scale > 1) {
        scale = 1;
    }

    //$('#simulator').css('-moz-transform', 'scale(' + scale + ')');
    $('#screenshot').css('width', screen_w + 'px');
    $('#screen').css('top', to_top + 'px');
    $('#screen').css('left', to_left + 'px');

    var mouseOver_w = screen_w;
    var mouseOver_h = screen_h;
    var width = frame_w;
    realOffsetX = margin + to_left;
    realOffsetY = margin + to_top;

    $('#rotationCenter').css('left', margin + 'px');
    $('#rotationCenter').css('top', margin + 'px');


    $('#mouseOver').css('top', realOffsetY + 'px');
    $('#mouseOver').css('left', realOffsetX + 'px');
    $('#mouseOver').css('left', realOffsetX + 'px');

    $('#mouseOver').css('height', mouseOver_h + 'px');
    $('#mouseOver').css('width', mouseOver_w + 'px');


    $('#rotationCenter').css('-moz-transform', 'scale(' + scale + ')');
    $('#rotationCenter').css('-webkit-transform', 'scale(' + scale + ')');

};

$(window).resize(function () {
    resize();
});





© 2015 - 2024 Weber Informatics LLC | Privacy Policy