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
22 $.extend @prototype, Events
33
44 constructor: ->
5− @isWindows = navigator.platform?.indexOf('Win') >= 0
5+ @isWindows = $.isWindows()
66 @start()
77
88 start: ->
assets/javascripts/lib/util.coffee+6−0
@@ -277,6 +277,12 @@ $.popup = (value) -> · 276 unmodified lines
277277 $.isTouchScreen = ->
278278 typeof ontouchstart isnt 'undefined'
279279
280+$.isWindows = ->
281+ navigator.platform?.indexOf('Win') >= 0
282+
283+$.isMac = ->
284+ navigator.userAgent?.indexOf('Mac') >= 0
285+
280286 HIGHLIGHT_DEFAULTS =
281287 className: 'highlight'
282288 delay: 1000
assets/javascripts/templates/pages/help_tmpl.coffee+2−2
@@ -1,5 +1,5 @@
1−ctrlKey = if navigator.userAgent?.indexOf('Mac') >= 0 then 'cmd' else 'ctrl'
2−navKey = if navigator.platform?.indexOf('Win') >= 0 then 'alt' else ctrlKey
1+ctrlKey = if $.isMac() then 'cmd' else 'ctrl'
2+navKey = if $.isWindows() then 'alt' else ctrlKey
33
44 app.templates.helpPage = """
55 <div class="_toc">