Skip to content

Commit

Permalink
Merging MobileWeb master changes into 1_8_X
Browse files Browse the repository at this point in the history
[TIMOB-6398] [TIMOB-6388] [TIMOB-6587]
  • Loading branch information
cb1kenobi committed Dec 14, 2011
1 parent 5838415 commit 89e8e55
Show file tree
Hide file tree
Showing 129 changed files with 5,076 additions and 9,168 deletions.
25 changes: 6 additions & 19 deletions mobileweb/src/Ti.API/api.js
Expand Up @@ -3,23 +3,10 @@
Ti._5.EventDriven(api);

// Methods
api.debug = function(msg) {
console.debug("[DEBUG] " + msg);
};
require.each(["debug", "error", "info", "log", "warn"], function(fn) {
api[fn] = function(msg) {
console[fn]("[" + fn.toUpperCase() + "] " + msg);
};
});

api.error = function(msg) {
console.error("[ERROR] " + msg);
};

api.info = function(msg) {
console.info("[INFO] " + msg);
};

api.log = function(msg) {
console.log("[LOG] " + msg);
};

api.warn = function(msg) {
console.warn("[WARN] " + msg);
};
})(Ti._5.createClass('Titanium.API'));
})(Ti._5.createClass('Ti.API'));
53 changes: 23 additions & 30 deletions mobileweb/src/Ti.Accelerometer/accelerometer.js
@@ -1,40 +1,33 @@
(function(api){
// Interfaces
Ti._5.EventDriven(api);

var _tLastShake = new Date(), _lastAccel = null;
// need some delta for coordinates changed
var _delta = 0.2;

window.addEventListener("devicemotion", function (event) {
var e = event.acceleration || event.accelerationIncludingGravity,

var undef,
lastShake = (new Date()).getTime(),
lastAccel = {};

require.on(window, "devicemotion", function(evt) {
var e = evt.acceleration || evt.accelerationIncludingGravity,
currentTime,
accel = e && {
x: e.x,
y: e.y,
z: e.z
z: e.z,
source: evt.source
};
if (accel) {
_lastAccel = null == _lastAccel ? accel : _lastAccel;
if (
Math.abs(_lastAccel.x - accel.x) > _delta ||
Math.abs(_lastAccel.y - accel.y) > _delta ||
Math.abs(_lastAccel.z - accel.z) > _delta
) {
var currentTime = new Date();
var timeDifference = currentTime.getTime() - _tLastShake.getTime();
_tLastShake = currentTime;

api.fireEvent('update', {
source: event.source,
timestamp: timeDifference,
type: 'update',
x: accel.x,
y: accel.y,
z: accel.z
});
if (lastAccel.x !== undef && (
Math.abs(lastAccel.x - accel.x) > 0.2 ||
Math.abs(lastAccel.y - accel.y) > 0.2 ||
Math.abs(lastAccel.z - accel.z) > 0.2
)) {
currentTime = (new Date()).getTime();
accel.timestamp = currentTime - lastShake;
lastShake = currentTime;
api.fireEvent("update", accel);
}
_lastAccel = accel;
lastAccel = accel;
}
}, false);
})(Ti._5.createClass('Titanium.Accelerometer'));
});

})(Ti._5.createClass("Ti.Accelerometer"));
2 changes: 1 addition & 1 deletion mobileweb/src/Ti.Analytics/analytics.js
Expand Up @@ -28,4 +28,4 @@
api.userEvent = function(name, data){
Ti._5.addAnalyticsEvent('app.user', name, data);
};
})(Ti._5.createClass('Titanium.Analytics'));
})(Ti._5.createClass('Ti.Analytics'));
24 changes: 4 additions & 20 deletions mobileweb/src/Ti.Android/activity.js
Expand Up @@ -2,29 +2,13 @@
Ti._5.EventDriven(api);

// Properties
var _intent = null;
Object.defineProperty(api, 'intent', {
get: function(){return _intent;},
set: function(val){return _intent = val;}
});
Ti._5.prop(api, 'intent');

var _onCreateOptionsMenu = null;
Object.defineProperty(api, 'onCreateOptionsMenu', {
get: function(){return _onCreateOptionsMenu;},
set: function(val){return _onCreateOptionsMenu = val;}
});
Ti._5.prop(api, 'onCreateOptionsMenu');

var _onPrepareOptionsMenu = null;
Object.defineProperty(api, 'onPrepareOptionsMenu', {
get: function(){return _onPrepareOptionsMenu;},
set: function(val){return _onPrepareOptionsMenu = val;}
});
Ti._5.prop(api, 'onPrepareOptionsMenu');

var _requestedOrientation = null;
Object.defineProperty(api, 'requestedOrientation', {
get: function(){return _requestedOrientation;},
set: function(val){return _requestedOrientation = val;}
});
Ti._5.prop(api, 'requestedOrientation');

// Methods
api.finish = function(){
Expand Down

0 comments on commit 89e8e55

Please sign in to comment.