Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update device.coffee #50

Merged
merged 5 commits into from

2 participants

André Tarnowsky Matthew Hudson
André Tarnowsky

The Portrait/Landscape Detection did not work, due to the different implementation of the device manufacturers of window.orientation

lotterfriends added some commits
André Tarnowsky lotterfriends Update device.coffee
The Portrait/Landscape Detection did not work, due to the different implementation of the device manufacturers of window.orientation
5ebb4df
André Tarnowsky lotterfriends Update device.coffee
RTrim unnecessary Whitespaces
cd0e2b4
André Tarnowsky lotterfriends Update package.json
Update Version Number to 0.1.59
63a0ee8
André Tarnowsky lotterfriends Update README.markdown
Added device.desktop()
81a2cd9
Matthew Hudson

@lotterfriends Looks like a decent enough workaround.

Let me see if I can figure out a way to write some tests before I merge. If you have any ideas in this regard - I'm all ears. See here: #17

André Tarnowsky lotterfriends Update device.coffee
create device.desktop()
168bf41
mwurzberger mwurzberger referenced this pull request from a commit
mwurzberger #50 b15bb64
Matthew Hudson matthewhudson merged commit 0744750 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 5, 2014
  1. André Tarnowsky

    Update device.coffee

    lotterfriends authored
    The Portrait/Landscape Detection did not work, due to the different implementation of the device manufacturers of window.orientation
  2. André Tarnowsky

    Update device.coffee

    lotterfriends authored
    RTrim unnecessary Whitespaces
  3. André Tarnowsky

    Update package.json

    lotterfriends authored
    Update Version Number to 0.1.59
  4. André Tarnowsky

    Update README.markdown

    lotterfriends authored
    Added device.desktop()
Commits on Feb 14, 2014
  1. André Tarnowsky

    Update device.coffee

    lotterfriends authored
    create device.desktop()
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 5 deletions.
  1. +4 −0 README.markdown
  2. +2 −2 package.json
  3. +7 −3 src/device.coffee
4 README.markdown
View
@@ -138,6 +138,10 @@ Device.js _also_ includes support for conditional JavaScript, allowing you to wr
<td>device.tablet()</td>
</tr>
<tr>
+ <td>Desktop</td>
+ <td>device.desktop()</td>
+ </tr>
+ <tr>
<td>iOS</td>
<td>device.ios()</td>
</tr>
4 package.json
View
@@ -1,6 +1,6 @@
{
"name": "device.js",
- "version": "0.1.58",
+ "version": "0.1.59",
"homepage": "https://github.com/matthewhudson/device.js",
"description": "Device.js makes it easy to write conditional CSS _and/or_ JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).",
"author": {
@@ -24,4 +24,4 @@
"grunt-contrib-uglify": "~0.2.2"
},
"license": "MIT"
-}
+}
10 src/device.coffee
View
@@ -80,11 +80,14 @@ device.mobile = ->
device.tablet = ->
device.ipad() or device.androidTablet() or device.blackberryTablet() or device.windowsTablet() or device.fxosTablet()
+device.desktop = ->
+ not device.tablet() and not device.mobile()
+
device.portrait = ->
- Math.abs(window.orientation) isnt 90
+ (window.innerHeight/window.innerWidth) > 1
device.landscape = ->
- Math.abs(window.orientation) is 90
+ (window.innerHeight/window.innerWidth) < 1
# Run device.js in noConflict mode, returning the device variable to its previous owner.
# Returns a reference to the device object.
@@ -107,7 +110,8 @@ _hasClass = (class_name) ->
# Add one or more CSS classes to the <html> element.
_addClass = (class_name) ->
if not _hasClass class_name
- _doc_element.className += " " + class_name
+ clazz = _doc_element.className.replace /\s+$/ "" + " " + class_name
+ _doc_element.className = clazz
# Remove single CSS class from the <html> element.
_removeClass = (class_name) ->
Something went wrong with that request. Please try again.