Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Fix problems with window.orientation deprecation (FIXES HTML-199) #24

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Client/player/pocketCodePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ PocketCode.Web = {
function PlayerInterface() {
this._domLoaded = false;
this._addDomListener(window, 'load', this._initOnLoad);
this._isMobile = (typeof window.orientation !== 'undefined') || !!navigator.userAgent.match(/iPad|iPhone|Android|BlackBerry|Phone|ZuneWP7|WPDesktop|webOS/i);
this._isMobile = (typeof ((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined)) !== 'undefined') || !!navigator.userAgent.match(/iPad|iPhone|Android|BlackBerry|Phone|ZuneWP7|WPDesktop|webOS/i);
}

PlayerInterface.prototype = {
Expand Down
2 changes: 1 addition & 1 deletion Client/player/pocketCodePlayer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Client/pocketCode/libs/smartJs/sj.custom.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Client/pocketCode/scripts/components/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ PocketCode.Device = (function () {
this._initDeviceMotionListener = this._addDomListener(window, 'devicemotion', this._initDeviceMotionHandler);

this._orientationChangeListener = this._addDomListener(window, 'orientationchange', this._orientationChangeHandler);
this._windowOrientation = window.orientation;
this._windowOrientation = ((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined));
}
else { //initialized but no supported
var features = this._features;
Expand Down Expand Up @@ -557,7 +557,7 @@ PocketCode.Device = (function () {
//this._rotationRate = e.rotationRate;
},
_orientationChangeHandler: function () {
this._windowOrientation = window.orientation;
this._windowOrientation = ((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined));
},
//geo location
_setGeoLocationInitialized: function () {
Expand Down Expand Up @@ -814,7 +814,7 @@ PocketCode.MediaDevice = (function () {
},
_cameraChangeHandler: function (e) {
e = e || this._camStatus;
e.merge({ orientation: window.orientation || 0, transparency: this._cameraTransparency });
e.merge({ orientation: ((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined)) || 0, transparency: this._cameraTransparency });
this._camStatus = e;
/** if (e.on && e.width && e.height && e.src)
this._fd.start(e.src, e.width, e.height, e.orientation);
Expand Down Expand Up @@ -855,7 +855,7 @@ PocketCode.MediaDevice = (function () {
// video.width = width;
// video.height = height;
// if (this._cam.on)
// this._onCameraChange.dispatchEvent({ on: true, src: video, height: video.videoHeight, width: video.videoWidth, orientation: window.orientation || 0, transparency: this._cameraTransparency });
// this._onCameraChange.dispatchEvent({ on: true, src: video, height: video.videoHeight, width: video.videoWidth, orientation: ((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined)) || 0, transparency: this._cameraTransparency });
},
setCameraTransparency: function (value) {
if (value < 0.0)
Expand All @@ -873,7 +873,7 @@ PocketCode.MediaDevice = (function () {
src: video,
height: video.videoHeight,
width: video.videoWidth,
orientation: window.orientation || 0,
orientation: ((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined)) || 0,
transparency: value
});
return true;
Expand Down
2 changes: 1 addition & 1 deletion Client/pocketCode/scripts/components/deviceFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ PocketCode.merge({
video.play();
this._startCameraStreamOnInit = false;
this._on = true;
//var orientation = window.orientation || 0;
//var orientation = ((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined)) || 0;
this._onChange.dispatchEvent({ on: true, src: video, height: video.videoHeight, width: video.videoWidth });
}

Expand Down
2 changes: 1 addition & 1 deletion Client/smartJs/sj-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SmartJs.Ui._Window = (function () { //static class

//var onResizeHandler = function () { };
var resizeEventName = 'resize';
if (window.orientationchange)
if (((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined))change)
resizeEventName = 'orientationchange';

this._addDomListener(window, resizeEventName, function (e) { this._onResize.dispatchEvent({ height: this.height, width: this.width }); });
Expand Down
4 changes: 2 additions & 2 deletions Client/smartJs/sj.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ var SmartJs = {
* SmartJs.Device is a helper object to simply indicate if a device supports touch events and/or is a mobile device
*/
Device: {
isIOs: ((typeof window.orientation !== 'undefined') && navigator.userAgent.match(/iPad|iPhone|iPod/i) && !navigator.userAgent.match(/IEMobile|Windows Phone/i)),
isIOs: ((typeof ((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined)) !== 'undefined') && navigator.userAgent.match(/iPad|iPhone|iPod/i) && !navigator.userAgent.match(/IEMobile|Windows Phone/i)),
isFirefoxOS: (!!"mozApps" in navigator && navigator.userAgent.search("Mobile") != -1 && avigator.userAgent.search("Android") < 0),
isTouch: ('ontouchstart' in window) || ('msMaxTouchPoints' in navigator && navigator.msMaxTouchPoints > 0) || ('maxTouchPoints' in navigator && navigator.maxTouchPoints > 0),
isMobile: (typeof window.orientation !== 'undefined') || !!navigator.userAgent.match(/iPad|iPhone|Android|BlackBerry|Phone|ZuneWP7|WPDesktop|webOS/i),
isMobile: (typeof ((window.orientation!==undefined)?window.orientation:((window.screen!==undefined)?window.screen.orientation.angle:undefined)) !== 'undefined') || !!navigator.userAgent.match(/iPad|iPhone|Android|BlackBerry|Phone|ZuneWP7|WPDesktop|webOS/i),
},

/**
Expand Down