Skip to content

Instantly share code, notes, and snippets.

/*global define:true */
define(
[
'module/bootstrap',
'module/timestamp',
'module/imageenhancer',
'module/transclude',
'module/hyperpuff/hyperpuff'
], function(
// -- changed lines
return {
init: function() {
// store DOM references
var hyperpuff = news.$('.hyperpuff'),
hyperTitleText = news.$('.hyper-title', hyperpuff).text(),
firstGroupArticles = news.$('.group:first-child .article-wrapper article', hyperpuff),
insertBeforeTarget = news.$('.story-body .introduction'),
// -- changed lines
define(['module/bootstrap', 'module/hyperpuff/minihyper'], function(news, MiniHyper) {
module('MiniHyper');
test('has an init method', function() {
ok('init' in MiniHyper);
});
@danscotton
danscotton / gist:3039157
Created July 3, 2012 11:20
refactoring our js templating using curl
======
BEFORE
======
This is how we currently do 'JS templating' when we want to insert
snippets of markup into the DOM: Strings of markup in an array,
using [].join(''); We then do String.replace() to replace the
{{placeholders}} with content.
// minihyper.js
define([
@danscotton
danscotton / gist:3046645
Created July 4, 2012 10:33
emitted events from locator, local and weather
// LOCATOR
locator:error [response, actionType]
locator:renderChangePrompt
locator:renderForm
locator:open [selectorString]
locator:close
locator:locationChanged [location] <---- maybe we should listen to this?
locator:renderWait
locator:searchResults [data]
locator:newsLocalRegions [data]
======
BEFORE
======
// base.spv
86: 'locator': '../../../locator/news/responsive/<?= $config['locatorVersion'] ?>/js/'
// localweather.js
3: 'locator/module/main',
// locator_news_responsive/webapp/static/js/module/main.js
define([
'vendor/ender/reqwest',
'locator/bootstrap', <---- 'locator' here...where does this path come from?
'locator/locatorView' <---- is this the curl path that _we_ define in _our_ base.spv?
], function(
reqwest,
bootstrap,
LocatorView
){
@danscotton
danscotton / gist:3164353
Created July 23, 2012 15:52
mocking with amd
// ----------------------------------------
// /path/to/dependency.js
define(function() {
return {
doSomethingWithIt: function() {
// blah
}
};
});
@danscotton
danscotton / gist:3164620
Created July 23, 2012 16:41 — forked from froots/gist:3164377
mocking with amd
// ----------------------------------------
// /path/to/dependency.js
define(function() {
return {
doSomethingWithIt: function() {
// blah
}
};
});
@danscotton
danscotton / gist:3176063
Created July 25, 2012 13:02
major vs minor breakpoints
-----
MAJOR
-----
These are what I refer to as 'major' breakpoints. They're defined on our link tags, and are on the 'outside'.
All of our stylesheets are conditionally inserted (based off window innerWidth/innerHeight) into the page dynamically using javascript.
<head>
...
<link rel="stylesheet" type="text/css" href="compact.css" media="(max-width: 640px)" />
<link rel="stylesheet" type="text/css" href="tablet.css" media="(min-width: 641px)" />