factor out canvas support check function
This commit is contained in:
parent
9caeeb0910
commit
ddaf8f5410
3 changed files with 21 additions and 15 deletions
|
@ -24,6 +24,7 @@
|
|||
//= require ./src/views/videoView
|
||||
//= require ./src/views/room
|
||||
//= require ./src/JIT
|
||||
//= require ./src/check-canvas-support
|
||||
//= require ./src/Metamaps
|
||||
//= require ./src/Metamaps.Create
|
||||
//= require ./src/Metamaps.TopicCard
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
// TODO document this user agent function
|
||||
var labelType, useGradients, nativeTextSupport, animate
|
||||
;(function () {
|
||||
var ua = navigator.userAgent,
|
||||
iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i),
|
||||
typeOfCanvas = typeof HTMLCanvasElement,
|
||||
nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'),
|
||||
textSupport = nativeCanvasSupport && (typeof document.createElement('canvas').getContext('2d').fillText == 'function')
|
||||
// I'm setting this based on the fact that ExCanvas provides text support for IE
|
||||
// and that as of today iPhone/iPad current text support is lame
|
||||
labelType = (!nativeCanvasSupport || (textSupport && !iStuff)) ? 'Native' : 'HTML'
|
||||
nativeTextSupport = labelType == 'Native'
|
||||
useGradients = nativeCanvasSupport
|
||||
animate = !(iStuff || !nativeCanvasSupport)
|
||||
})()
|
||||
/* global Metamaps */
|
||||
|
||||
/*
|
||||
* Metamaps.js.erb
|
||||
*/
|
||||
|
||||
// TODO eliminate these 5 top-level variables
|
||||
Metamaps.panningInt = null
|
||||
|
|
15
app/assets/javascripts/src/check-canvas-support.js
Normal file
15
app/assets/javascripts/src/check-canvas-support.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
// TODO document this user agent function
|
||||
var labelType, useGradients, nativeTextSupport, animate
|
||||
;(function () {
|
||||
var ua = navigator.userAgent,
|
||||
iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i),
|
||||
typeOfCanvas = typeof HTMLCanvasElement,
|
||||
nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'),
|
||||
textSupport = nativeCanvasSupport && (typeof document.createElement('canvas').getContext('2d').fillText == 'function')
|
||||
// I'm setting this based on the fact that ExCanvas provides text support for IE
|
||||
// and that as of today iPhone/iPad current text support is lame
|
||||
labelType = (!nativeCanvasSupport || (textSupport && !iStuff)) ? 'Native' : 'HTML'
|
||||
nativeTextSupport = labelType == 'Native'
|
||||
useGradients = nativeCanvasSupport
|
||||
animate = !(iStuff || !nativeCanvasSupport)
|
||||
})()
|
Loading…
Add table
Reference in a new issue