Skip to content

Instantly share code, notes, and snippets.

View evocateur's full-sized avatar

Daniel Stockman evocateur

View GitHub Profile
"use strict";
var _ = SM.import('lodash');
var DOM = SM.import('sm-dom');
var Uri = SM.import('sm-uri');
// WebKit (as of version 538.35.8) fires a useless popstate event after every
// page load, even when the page wasn't popped off the HTML5 history stack. We
// only want to handle popstate events that result from a page actually being
// popped off the HTML5 history stack, so we need a way to differentiate between
$(function() {
// Clone HTML5's placeholder attribute functionality
$('input[placeholder]').each(function() {
// Store the placeholder text and then set the element's value
// TODO: Check to make sure value is empty before setting here
$(this).data('placeholder', $(this).attr('placeholder'));
$(this).val($(this).data('placeholder')).addClass('placeholder');
// Handle the removal/addition of the placeholder text on focus/blur
$(this).focus(function() {
<!DOCTYPE html>
<html>
<head>
<title>ModelResource Manual Tests</title>
</head>
<body>
<h1>ModelResource Manual Tests</h1>
@tivac
tivac / _README.md
Last active October 4, 2015 11:38
Parent/Child Y.View extension

Parent/Child Y.Views

As I worked with Y.App it became clear that while Y.View is a great abstraction it would be easy to overwhelm a single instance with way too much functionality. This is my attempt to solve that issue by allowing multiple child views to be attached to a single parent view via an extension.

Usage

The extension is mixed into the parent view like any other extension using Y.Base.create.

var Parent = Y.Base.create("view", Y.View, [
@tivac
tivac / home-carousel.handlebars.js
Created May 15, 2012 20:07
Combo-handler served Handlebars files
@rgrove
rgrove / node-scroll-info.js
Created June 6, 2012 21:35
node-scroll-info.js
/*!
Copyright (c) 2012 Ryan Grove. All rights reserved.
Redistribution and use of this software in source and binary forms, with or
without modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
@tivac
tivac / extension-model-reset.js
Created June 22, 2012 20:58
More powerful Model.reset()
ResetExtension = function(){};
ResetExtension.prototype = {
reset : function(name, options) {
var self = this,
attributes = {};
//allow old-style string name/string name + options/just options
if(Y.Lang.isString(name)) {
attributes[name] = self._state.get(name, "initValue");
} else if(Y.Lang.isObject(name)) {
@tivac
tivac / transform-buttondir.js
Created August 6, 2012 17:48
View transforms
/*global YUI:true */
YUI.add("transform-buttondir", function(Y) {
Y.namespace("GW2.Transforms").buttonDir = function(models, dir) {
return Y.Array.map(models, function(item) {
if(item.quantities) {
//if a dir was specified set every quantity to that
if(dir) {
item.quantities = Y.Array.map(item.quantities, function(quantity) {
quantity.dir = dir;
@derek
derek / README.md
Created August 17, 2012 02:06
Loading YUI from the CDN into a Web Worker

Scenario

I want to use YUI inside of a WebWorker thread. Flickr recently wrote a post on this very topic, Web workers and YUI.

Problem

But I want to use YUI's CDN, which WebWorkers prevent because it enforces a same-origin policy with importScripts()

Solution

@ericf
ericf / gist:4558180
Last active December 11, 2015 06:18
{
"align_indent": false,
"alignment_chars":
[
"=",
":"
],
"alignment_space_chars":
[
"="