Skip to content

Instantly share code, notes, and snippets.

View imjoshdean's full-sized avatar

Josh Dean imjoshdean

View GitHub Profile
@imjoshdean
imjoshdean / form.js
Created May 2, 2017 21:04
Proof of concept of #76: Adds true extensibility to can-components
import Component from 'can-component';
import DefineMap from 'can-define/map/';
import './form.less';
import view from './form.stache';
export const FormViewModel = DefineMap.extend({
lastModified: {
type: 'date',
value: new Date()
},
steal('can/component',
/* ...*/,
function(Component) {
var timestampComparator = function(ascending) {
return function(modelA, modelB) {
var timeStampA = modelA.attr('call.state.timestamp-connect'),
timeStampB = modelB.attr('call.state.timestamp-connect'),
callModel;
st-example {
div {
background-color: red;
}
.dragenetered {
backround-color: orange !important;
}
}
@imjoshdean
imjoshdean / windowstate.js
Last active January 8, 2016 16:57
WindowState close function that works with arrays of windows.
var WindowState = Construct.extend({ }, {
/*
Example usage:
WindowState.close('preferences');
WindowState.close('debug', true);
WindowState.close('notification', true, function(win) {
@imjoshdean
imjoshdean / windowstate.js
Created January 8, 2016 16:54
WindowState close function that works with
var WindowState = Construct.extend({ }, {
close: function(win, force, predicate) {
if(this[win]) {
if(can.isArray(this[win])) {
// if no predicate is defined, _.filter will return the entire list
_.filter(this[win], predicate).forEach(this.proxy(function(item) {
var index = this[win].indexOf(item);
item.close(true);
this[win].splice(index, 1);
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="CanJS jQuery">
<meta charset="utf-8">
<!--
Created using JS Bin
http://jsbin.com
Copyright (c) 2015 by anonymous (http://jsbin.com/riqekazexa/1/edit)
/*!
* CanJS - 2.1.3
* http://canjs.us/
* Copyright (c) 2014 Bitovi
* Mon, 25 Aug 2014 21:51:38 GMT
* Licensed MIT
* Includes: can/map/define
* Download from: http://canjs.com
*/
(function(undefined) {
@imjoshdean
imjoshdean / gist:4574287ec19527a77549
Last active August 29, 2015 14:09
Nested can/map/define
var Example = Map.extend({ }, {
define: {
name: {
value: 'Nailed it'
}
}
});
var NestedMap = Map.extend({ }, {
define: {
@imjoshdean
imjoshdean / gist:18dad734f60ded6a6c1c
Created September 22, 2014 14:04
console overloading with AJAX
var logs = ['log', 'debug', 'info', 'warn', 'error'];
logs.forEach(function(log) {
var func = console[log];
console[log] = function() {
var str = JSON.stringify(arguments);
// Run default version of console function
func.apply(console, arguments);
* {
font: 13px/16px "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
color: #333;
}
table {
margin: 5px auto;
margin-bottom: 15px;
width: 95%;
}
td {