Exemple #1
0
 event.on("TinyHipposLoaded", function () {
     var doc = emulatorBridge.document(),
         evt = doc.createEvent("Events");
     evt.initEvent("webworksready", true, true);
     doc.dispatchEvent(evt);
     _console.log("fired webworksready event!");
 });
Exemple #2
0
TouchEvent = function (type, canBubble, cancelable, touches, targetTouches, changedTouches, altKey, metaKey, ctrlKey, shiftKey) {
    var touchEvent = emulatorBridge.document().createEvent("UIEvents");
    touchEvent.initUIEvent(type, canBubble, cancelable, emulatorBridge.window(), 1);

    touchEvent.__defineGetter__("touches", function () {
        return touches;
    });
    touchEvent.__defineGetter__("targetTouches", function () {
        return targetTouches;
    });
    touchEvent.__defineGetter__("changedTouches", function () {
        return changedTouches;
    });
    touchEvent.__defineGetter__("altKey", function () {
        return altKey;
    });
    touchEvent.__defineGetter__("metaKey", function () {
        return metaKey;
    });
    touchEvent.__defineGetter__("ctrlKey", function () {
        return ctrlKey;
    });
    touchEvent.__defineGetter__("shiftKey", function () {
        return shiftKey;
    });
    return touchEvent;
};
Exemple #3
0
    vibrate: function () {
        var pattern = arguments[0],
            i;

        // If vibrator is off, stop the vibration
        event.on("VibratingModeChanged", function (value) {
            if (value === false) {
                vibrator.stopVibrate();
            }
        });

        //1. If the hidden attribute [PAGE-VISIBILITY] is set to true, abort these steps.
        if (emulatorBridge.document().hidden) {
            return;
        }

        //2. Let pattern be the value of the first argument.
        if (!tizen1_utils.isValidArray(pattern)) {
            pattern |= 0;
        } else {
            for (i = 0; i < pattern.length; i++) {
                pattern[i] |= 0;
            }
        }

        //3. If pattern is 0, or an empty list, cancel the pre-existing instance of the processing vibration patterns algorithm, if any, and abort these steps.
        if (pattern === 0 || (tizen1_utils.isValidArray(pattern) && pattern.length === 0)) {
            vibrator.stopVibrate();
            return;
        }

        //4. If pattern is a list, proceed to the next step. Otherwise run the following substeps:
        //a. Let list be an initially empty list, and add pattern to list.
        //b. Let pattern be list.
        if (!tizen1_utils.isValidArray(pattern)) {
            pattern = [pattern];
        }

        //5. If any entry of pattern exceeds an implementation-dependent limit, then the user agent may throw a NotSupportedError exception and abort these steps.

        //6. If the length of pattern is even, then remove the last entry in pattern.
        if (pattern.length % 2 === 0) {
            pattern.pop();
        }

        //7. Cancel the pre-existing instance of the processing vibration patterns algorithm, if any.
        if (vibrator.isVibrating) {
            vibrator.stopVibrate();
        }

        curPost = 0;
        vibrator.startVibrate(pattern);
    }
Exemple #4
0
    function changePulse() {
        if (emulatorBridge.document().hidden) {
            return;
        }

        //run time
        runTime = runTime + MILLILSECONDS_OF_ONE_VIBRATION;
        if (curPost >= vibratorPattern.length) {
            setTimeout(stopVibrate, 1);
        }
        if (runTime > vibratorPattern[curPost]) {
            curPost = curPost + 1;
            runTime = 0;
        } else {
            if ((curPost % 2) === 0) {
                vibrate();
            }
        }
    }
// NOTE: missing view, detail, touches, targetTouches, scale and rotation
function _initTouchEvent(type, canBubble, cancelable, eventData) {
    var touchEvent = emulatorBridge.document().createEvent("Event");
    touchEvent.initEvent(type, canBubble, cancelable);
    utils.mixin(eventData, touchEvent);
    return touchEvent;
}