Takeshi Takatsudo Takazudo

View htmlDprTweak.js
1 2 3 4 5 6 7 8 9 10
/**
* `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 */
View legacyIE.js
1 2 3 4 5 6 7 8 9 10
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];
View Modernizr.believablehover.js
1 2 3 4 5 6 7 8 9 10
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;
View transendeventname.coffee
1 2 3 4 5 6 7 8 9 10
# transitionEnd event name detection from Modernizr
# http://modernizr.com/docs/
 
transEndEventName = do ->
names =
WebkitTransition: "webkitTransitionEnd"
MozTransition: "transitionend"
OTransition: "oTransitionEnd"
msTransition: "MSTransitionEnd"
transition: "transitionend"
View eventmodule.coffee
1 2 3 4 5 6 7 8 9 10
/* 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) ->
View audiopreloader.coffee
1 2 3 4 5 6 7 8 9
class Module
_.extend Module::, Backbone.Events
 
class AudioPreloader extends Module
constructor: (options) ->
 
@options = options
@playableSrc = @_detectPlayableSrc()
View requestAnimationFramePolyfill.coffee
1 2 3 4 5 6 7 8
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
View lazyEventModuleWithBackbone.coffee
1 2 3 4 5 6 7 8 9
class Module
_.extend Module::, Backbone.Events
 
class App extends Module
 
app = new App
 
app.on 'hoge', ->
console.log 'hoge done!'
View safariversiondetection.js
1 2 3 4 5 6 7 8 9 10
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)) {
View jquerymobiletransition.html
1 2 3 4 5 6 7 8 9 10
<!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>
Something went wrong with that request. Please try again.