This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* `html` class tweaking | |
* if `devicePixelRatio` was 2, switch html's class | |
* from `dpr-1` to `dpr-2` | |
*/ | |
(function() { | |
var html = document.getElementsByTagName("html")[0]; | |
/* helpers */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var legacyIE = (function() { | |
var ua = navigator.userAgent; | |
var matchRes = ua.match(/msie\s?(\d+)/i); | |
// '.... MSIE 7.0; Windows....' | |
// => ["MSIE 7", "7"] | |
if(!matchRes) { return false; } | |
var version = matchRes[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win8orhigher = (function() { | |
// windows browsers has str like "Windows NT 6.2" in its UA | |
// Win8 UAs' version is "6.2" | |
// browsers above this version may has touch events. | |
var ua = navigator.userAgent; | |
var matched = ua.match(/Windows NT ([\d\.]+)/); | |
if(!matched) { return false; } | |
var version = matched[1] * 1; | |
if(version < 6.2) { return false; } | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# transitionEnd event name detection from Modernizr | |
# http://modernizr.com/docs/ | |
transEndEventName = do -> | |
names = | |
WebkitTransition: "webkitTransitionEnd" | |
MozTransition: "transitionend" | |
OTransition: "oTransitionEnd" | |
msTransition: "MSTransitionEnd" | |
transition: "transitionend" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* lazy eventy implementation with jQuery */ | |
class Module | |
on: (evName, callback) -> | |
@_observer = $({}) unless @_observer? | |
@_observer.on evName, (args...) => | |
args.shift() # we don't want event object | |
callback.apply @_observer, args | |
@ | |
one: (evName, callback) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
_.extend Module::, Backbone.Events | |
class AudioPreloader extends Module | |
constructor: (options) -> | |
@options = options | |
@playableSrc = @_detectPlayableSrc() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.requestAnimFrame = do -> | |
window.requestAnimationFrame or | |
window.webkitRequestAnimationFrame or | |
window.mozRequestAnimationFrame or | |
window.oRequestAnimationFrame or | |
window.msRequestAnimationFrame or | |
(callback, element) -> | |
window.setTimeout callback, 1000 / 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
_.extend Module::, Backbone.Events | |
class App extends Module | |
app = new App | |
app.on 'hoge', -> | |
console.log 'hoge done!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var oldSafari = (function() { | |
var ua = window.navigator.userAgent; | |
if(!/safari/i.test(ua)) { | |
return false; | |
} | |
if(/chrome/i.test(ua)) { | |
// chrome has 'Safari' in its ua. | |
return false; | |
} | |
if(/mobile/i.test(ua)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title>test</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" /> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script> | |
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script> | |
</head> |