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
// Simple Data Component to handle authorization calls | |
var Auth = flight.component(function() { | |
this.defaultAttrs({ | |
user: 'default' | |
}); | |
this.authenticate = function(ev, data) { | |
console.log("[debug] calling authenticate"); | |
$.ajax({ | |
method: 'POST', |
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.serializeFormJSON = function(f) { | |
var json = {}, | |
$f = f.jquery ? f : $(f); | |
$('input.serialize, select.serialize, textarea.serialize', $f).each(function(index, node) { | |
var keypath = $(this).attr('name').split('.'), | |
key = keypath.pop(), | |
item = json; | |
for (var i=0, l=keypath.length; i < l; i++) { |
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 has_bind_native = Function.prototype.bind ? true : false; | |
/** | |
* An ES5 compaitible polyfill for Function.prototype.bind(thisArg, arg1, arg2, ...). Allows you to | |
* rebind a function to a different this context. This is already available in browsers implementing | |
* the ES5 standards. | |
* | |
* @param {Object} _context - the new object to bind this to in the function | |
* @returns {Function} - the newly bound function | |
*/ |
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
function _debug() { | |
var tm = "%c[" + (new Date()).toTimeString().split(/\s+/)[0] + "]", | |
pre = "%c debug ", | |
args = [].slice.call(arguments, 0), | |
// styles for: timestamp, prefix, message | |
styles = ["color: #4682b4", "color: #fff; background-color: #cd5c5c;", "color: #2f4f4f"], | |
msg = tm + pre + "%c " + args.shift(); | |
console.log.apply(console, [msg].concat(styles, args)); | |
} |
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 Promise = function() { | |
this.resolve_callbacks = []; | |
this.reject_callbacks = []; | |
this.state = null; | |
}; | |
Promise.prototype = { | |
then: function(resolvefn, rejectfn) { | |
if (this.state == 'resolved') { | |
resolvefn(); |
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
function xhr(){ | |
try { | |
return new XMLHttpRequest(); | |
}catch(e){} | |
try { | |
return new ActiveXObject("Msxml3.XMLHTTP"); | |
}catch(e){} | |
try { | |
return new ActiveXObject("Msxml2.XMLHTTP.6.0"); | |
}catch(e){} |
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
function parseUrl(url) { | |
var _url = (url || window.location.href).match(/^(?:(https?:)\/\/)?([^\?\#\/\:]+)(?::(\d+))?([^\?\#]+)?(\?[^#]+)?(#[^\s]+)?$/), | |
params = _url[5] || false; | |
if (!_url.length) { | |
// couldn't parse url string | |
return false; | |
} | |
if (params && !/^$/.test(params)) { |
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
{ | |
// JSHint Default Configuration File | |
// See http://jshint.com/docs/ for more details | |
"maxerr" : 50, // {int} Maximum error before stopping | |
// Enforcing | |
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) | |
"camelcase" : false, // true: Identifiers must be in camelCase | |
"curly" : true, // true: Require {} for every new block or scope |
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
!function (factory) { | |
if (typeof exports == 'object') { | |
factory(require('jquery')); | |
} else if (typeof define == 'function' && define.amd) { | |
define(['jquery'], factory); | |
} else { | |
factory(jQuery); | |
} | |
}(function($) { | |
'use strict'; |
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> | |
<head> | |
<style type="text/css"> | |
.moveable { | |
border: 1px solid red; | |
display: inline-block; | |
padding: 2px; | |
font-family: sans-serif; | |
} |
OlderNewer