Refactor Mac/Windows detection

This commit is contained in:
Thibaut 2014-08-10 08:30:37 -04:00
parent a93b2d922c
commit 4ffc605019
3 changed files with 9 additions and 3 deletions

View file

@ -2,7 +2,7 @@ class app.Shortcuts
$.extend @prototype, Events
constructor: ->
@isWindows = navigator.platform?.indexOf('Win') >= 0
@isWindows = $.isWindows()
@start()
start: ->

View file

@ -277,6 +277,12 @@ $.popup = (value) ->
$.isTouchScreen = ->
typeof ontouchstart isnt 'undefined'
$.isWindows = ->
navigator.platform?.indexOf('Win') >= 0
$.isMac = ->
navigator.userAgent?.indexOf('Mac') >= 0
HIGHLIGHT_DEFAULTS =
className: 'highlight'
delay: 1000

View file

@ -1,5 +1,5 @@
ctrlKey = if navigator.userAgent?.indexOf('Mac') >= 0 then 'cmd' else 'ctrl'
navKey = if navigator.platform?.indexOf('Win') >= 0 then 'alt' else ctrlKey
ctrlKey = if $.isMac() then 'cmd' else 'ctrl'
navKey = if $.isWindows() then 'alt' else ctrlKey
app.templates.helpPage = """
<div class="_toc">