History

Refactor Mac/Windows detection

Thibaut committed 12 years ago

Commit 4ffc6051 parent a93b2d93 files · +9 −3Browse files

Unified · Split

3 files
  1. assets/javascripts/app/shortcuts.coffee +1 −1
  2. assets/javascripts/lib/util.coffee +6 −0
  3. assets/javascripts/templates/pages/help_tmpl.coffee +2 −2
assets/javascripts/app/shortcuts.coffee+1−1
@@ -2,7 +2,7 @@ class app.Shortcuts · 1 unmodified line
2 $.extend @prototype, Events2 $.extend @prototype, Events
3 3
4 constructor: ->4 constructor: ->
5 @isWindows = navigator.platform?.indexOf('Win') >= 05 @isWindows = $.isWindows()
6 @start()6 @start()
7 7
8 start: ->8 start: ->
assets/javascripts/lib/util.coffee+6−0
@@ -277,6 +277,12 @@ $.popup = (value) -> · 276 unmodified lines
277$.isTouchScreen = ->277$.isTouchScreen = ->
278 typeof ontouchstart isnt 'undefined'278 typeof ontouchstart isnt 'undefined'
279 279
280$.isWindows = ->
281 navigator.platform?.indexOf('Win') >= 0
282
283$.isMac = ->
284 navigator.userAgent?.indexOf('Mac') >= 0
285
280HIGHLIGHT_DEFAULTS =286HIGHLIGHT_DEFAULTS =
281 className: 'highlight'287 className: 'highlight'
282 delay: 1000288 delay: 1000
assets/javascripts/templates/pages/help_tmpl.coffee+2−2
@@ -1,5 +1,5 @@
1ctrlKey = if navigator.userAgent?.indexOf('Mac') >= 0 then 'cmd' else 'ctrl'1ctrlKey = if $.isMac() then 'cmd' else 'ctrl'
2navKey = if navigator.platform?.indexOf('Win') >= 0 then 'alt' else ctrlKey2navKey = if $.isWindows() then 'alt' else ctrlKey
3 3
4app.templates.helpPage = """4app.templates.helpPage = """
5 <div class="_toc">5 <div class="_toc">