Skip to content

Instantly share code, notes, and snippets.

<meta property="og:site_name" content=""/>
<meta property="og:title" content=""/>
<meta property="og:description" content=""/>
<meta property="og:url" content=""/>
<meta property="og:image" content=""/>
<meta property="og:type" content="website"/>
<meta property="og:locale" content="en_US" />
@justinhillsjohnson
justinhillsjohnson / 3DObjectView.js
Created March 28, 2012 03:11
Three.js + 3d model .obj
/*
* IndexView.js
*
*/
var THREEDObjectView = Backbone.View.extend({
'events': {},
'initialize': function(options) {
_.bindAll(this, 'render', 'createScene');
/*
* THREEDObjectView.js
*
*/
var THREEDObjectView = Backbone.View.extend({
'defaults': {
'sceneWidth': 600,
'sceneHeight': 600
},
//within the callback
$(window).trigger('jsonLoaded');
$(window).bind('jsonLoaded', function() {
//do something
});
/*
* CarouselView.js
*
*/
var CarouselView = Backbone.View.extend({
//define carousel template
//'template': _.template(),
//define default values for carousel
var isClicked = false,
$videoContent = $('#video-content'); //cache the selector
//utilize event delegation instead of direct event binding (note the 2nd param is the selector for event delegation)
$videoContent.on('click', '.ratings img', function() {
e.preventDefault(); //this is all it takes to shortcircuit the event, unless you want to also call e.stopPropagation(); return false does both of these.
});
$videoContent.on('click', '.ratings' function() {
//use === false instead of ! to prevent type coercion issues
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="10" y="10" height="130" width="500" style="fill: #000000"/>
<image x="20" y="20" width="100%" height="100%" xlink:href="http://jenkov.com/images/layout/top-bar-logo.png"/>
<line x1="25" y1="80" x2="350" y2="80" style="stroke: #ffffff; stroke-width: 3;"/>
</svg>
@justinhillsjohnson
justinhillsjohnson / gist:3663095
Created September 7, 2012 04:19
vml image scale
<HTML xmlns:v="urn:schemas-microsoft-com:vml">
<HEAD>
<STYLE>
v\:* { behavior: url(#default#VML); display:inline-block}
</STYLE>
<TITLE>VML Sample</TITLE>
</HEAD>
<BODY>
<DIV id="MyDiv"></DIV>
<SCRIPT LANGUAGE="VBScript">
<?php
//acquire all loaded resource ID's
$resources = unserialize(base64_decode($modx->runSnippet('get_resources_snippet')));
$output = '';
$workList = '';
$downloadSection = '';
//get client data
$clientDataArray = array(
'id' => $resources['client'],
$franchiseForm.find('textarea').on('keyup', function(e) {
var $textarea = $(this);
var maxlength = $textarea.attr('data-maxlength');
var $countdown = $(this).parent().find('.charRemain');
if ($textarea.val().length > maxlength) {
$textarea.val($textarea.val().substring(0, maxlength));
} else {
$countdown.text(500 - $textarea.val().length);
}
});