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
/* FOR REFERENCE PURPOSES ONLY. CODE IS AUTHORED BY KEVAN DAVIS, COPYRIGHT 2010-2014 GILT GROUPE. */ | |
/*jshint asi: false, bitwise: true, boss: false, curly: true, eqeqeq: true, eqnull: false, evil: false, forin: false, immed: true, laxbreak: false, newcap: true, noarg: true, noempty: true, nonew: false, nomen: false, onevar: true, plusplus: false, regexp: false, undef: true, sub: false, strict: false, white: false */ | |
/*jshint browser: true, maxerr: 50, passfail: false */ | |
/*global define: false */ | |
/** | |
* requirejs wrapper | |
* | |
* will use either requirejs or global variables based on several factors, |
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
/* less than 480px | |
_______ | |
/_ __(_)___ __ __ | |
/ / / / __ \/ / / / | |
/ / / / / / / /_/ / | |
/_/ /_/_/ /_/\__, / | |
/____/ | |
*/ | |
@media (max-width: @layout-tiny-max) { |
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
define('my_view', | |
[jquery, underscore, backbone], | |
function ($, _, Backbone) { | |
// These will all have "this" bound correctly | |
var | |
MyView, | |
helpers; |
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
Date.prototype.beginningOfWeek = function () { | |
return new Date(this - ((this.getDay() - (arguments[0] || 0)) * 86400000)); | |
} |
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
// Gets the location in a grid of objects by numbered row and lettered column | |
// Example: 5C is the 5th row, 3rd column | |
getGridLocation = function($el) { | |
var $items = $el.find('.item:visible'), | |
index = $items.index($el), | |
lefts = [], | |
tops = []; | |
$items.each(function() { | |
var $item = $(this), |
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
// Rendering markup with loops and string concatenation | |
for (var i = 0; i < foo.name.length; i++) { | |
content += '<li><a href="foo/' + foo.id[i] + '">' + foo.name[i] + '</a></li>'; | |
} | |
// Rendering with a JavaScript template | |
content = '{{#foo}}' + | |
'<li><a href="foo/${id}">${name}</a></li>' + | |
'{{/foo}}'; |
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
handlebars : { | |
cache: [], | |
render : function (name, template, content, context, callback) { | |
try { | |
if (!cache[name]) { | |
cache[name] = Handlebars.compile(template); | |
} | |
callback(cache[name](content, context)); | |
} catch (e) { | |
// console.log('Could not render. Handlebars might not be installed'); |
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
Gilt.Template.register('baz', '<div class="foo">' + | |
'<div class="foo-image">' + | |
'<img src="{{images/0}}" fullsrc="{{images/0}}" alt="{{{title}}}" />' + | |
'</div>' + | |
'<div class="foo-text">' + | |
'<h1>{{{brand_name}}}</h1>' + | |
'<h2>{{{title}}}</h2>' + | |
'</div>' + | |
'</div>', | |
{ version : 'bar' } |
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
Gilt.Template.render( | |
'baz', // The name of this feed or template type | |
data[0], // The data object to render | |
function(html) { // The callback function | |
Gilt.Notify.publish('feedTemplated', [html]); | |
}, | |
{ version : 'bar' } // Options, in this case an alternate version | |
); |
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
foo = 'abc'; | |
console.log(foo.length); | |
console.log(0.1+0.2); | |
////////// | |
var foo = {}; | |
console.log('------ foo'); |
OlderNewer