This file contains hidden or 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
(function(d, l, c) { | |
while(c=l.pop()){ | |
if(navigator.userAgent.match(new RegExp(c, 'i'))){ | |
d[c]=!0; | |
d.documentElement.className+=' '+c; | |
} | |
} | |
}(document, ['iphone', 'mobile', 'android'])); |
This file contains hidden or 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
angular.module('ui.inputFocus', []).directive "input", [-> | |
restrict: "E" | |
require: '?^ngModel' | |
link: (scope, elm, attrs, ctrl) -> | |
return unless ctrl | |
ctrl.$focus = no | |
elm.focus -> | |
scope.$apply(-> ctrl.$focus = yes) | |
elm.blur -> | |
scope.$apply(-> ctrl.$focus = no) |
This file contains hidden or 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
# If you have an API that returns JSON but want the reponse as raw text you | |
# can override Angulars built in JSON response parser by using an identity | |
# function as response transformer function | |
$http.get("/myapi", | |
{ transformResponse: (d, h) -> return d } # return raw response | |
) | |
.success((data, status, headers) -> | |
# data is now pure text | |
alert("Response is text: #{angular.isString(data)}") |
This file contains hidden or 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
angular.module('myApp').config([ | |
'$httpProvider' | |
($httpProvider) -> | |
# For all request types | |
$httpProvider.defaults.headers.common['Content-Type'] = 'application/json' | |
# For GET only | |
$httpProvider.defaults.headers.get['My-Header']='value'. | |
]) |
This file contains hidden or 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
$.ajaxTransport((options, originalOptions, jqXHR) -> | |
if window.XDomainRequest | |
xdr = null | |
return { | |
send: (headers, completeCallback) -> | |
# Match protocol since XDR doesn't allow differences | |
if 'http:' is document.location.protocol | |
options.url = options.url.replace('https:', 'http:') | |
xdr = new XDomainRequest() |
This file contains hidden or 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
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
[alias] | |
b = branch | |
ba = branch -a | |
ci = commit | |
co = checkout | |
d = diff |
This file contains hidden or 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> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Drag n' drop touch demo - sewa.se</title> | |
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;" /> | |
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<style type="text/css"> | |
.draggable { | |
position: absolute; | |
left: 30px; |
This file contains hidden or 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
<!-- 1. --> | |
<script type="text/javascript" charset="utf-8"> | |
function log(string){ | |
document.getElementById('log').innerHTML += (string + '<br/>'); | |
} | |
document.getElementById('the_div').addEventListener( | |
'click', function(){ log('the_div!') }, true); | |
document.getElementById('the_list').addEventListener( |
This file contains hidden or 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 Person = function (name) { | |
this.name = name; | |
} | |
Person.prototype.getName = function () { | |
return this.name; | |
} | |
// 1. Write a class to support the following code: |
This file contains hidden or 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
/////// Homework 1 /////// | |
var logCar = function (car) { | |
car = car || {}; | |
car.make = car.make || 'anonymous car'; | |
car.color = car.color || 'uncolored'; | |
var a = /^[aeiouy]/.test(this.color) ? 'an' : 'a'; | |
console.log('I\'m ' + a + ' ' + car.color + ' ' + car.make); | |
}; |
NewerOlder