Skip to content

Commit

Permalink
add isPhoneSized to AMD context when in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
hgoebl committed Jul 15, 2014
1 parent f6d3e2f commit 36eb136
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
28 changes: 16 additions & 12 deletions generate/mobile-detect.template.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*global module:false*/
/*global define:false*/
/*global module:false, define:false*/

(function (exports, undefined) {
'use strict';
Expand Down Expand Up @@ -544,17 +543,8 @@
exports(MobileDetect);

})(function (data, undefined) {
if (typeof module !== 'undefined' && module.exports) {

data.isPhoneSized = function () {};
module.exports = data;

} else if (typeof define === 'function' && define.amd) {

define(function () { return data; });

} else if (typeof window !== 'undefined') {

if (typeof window !== 'undefined' && window.screen && window.screen.width) {
data.isPhoneSized = function (maxPhoneWidth) {
if (maxPhoneWidth < 0) {
return undefined;
Expand All @@ -565,8 +555,22 @@

return cssPixelWidth <= maxPhoneWidth;
};
} else {
data.isPhoneSized = function () {};
}

if (typeof module !== 'undefined' && module.exports) {

module.exports = data;

} else if (typeof define === 'function' && define.amd) {

define(function () { return data; });

} else if (typeof window !== 'undefined') {

window.MobileDetect = data;

} else {
throw new Error('unknown environment'); // please file a bug if you get this error!
}
Expand Down
23 changes: 16 additions & 7 deletions mobile-detect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// THIS FILE IS GENERATED - DO NOT EDIT!
/*global module:false*/
/*global module:false, define:false*/

(function (exports, undefined) {
'use strict';
Expand Down Expand Up @@ -793,13 +793,8 @@
exports(MobileDetect);

})(function (data, undefined) {
if (typeof module !== 'undefined' && module.exports) {

data.isPhoneSized = function () {};
module.exports = data;

} else if (typeof window !== 'undefined') {

if (typeof window !== 'undefined' && window.screen && window.screen.width) {
data.isPhoneSized = function (maxPhoneWidth) {
if (maxPhoneWidth < 0) {
return undefined;
Expand All @@ -810,8 +805,22 @@

return cssPixelWidth <= maxPhoneWidth;
};
} else {
data.isPhoneSized = function () {};
}

if (typeof module !== 'undefined' && module.exports) {

module.exports = data;

} else if (typeof define === 'function' && define.amd) {

define(function () { return data; });

} else if (typeof window !== 'undefined') {

window.MobileDetect = data;

} else {
throw new Error('unknown environment'); // please file a bug if you get this error!
}
Expand Down
Loading

0 comments on commit 36eb136

Please sign in to comment.