A curated compilation of resources to master Backbone.js development.
This file contains hidden or 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
'use strict'; | |
module.exports = function( grunt ) { | |
var configs = { | |
replace: { | |
dist: { | |
options: { | |
patterns: [ | |
{ | |
match: 'hash', |
This file contains hidden or 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
var Model = { | |
inherited: function() {}, | |
created: function() {}, | |
prototype: { | |
init: function() {}, | |
}, | |
create: function() { | |
var object = Object.create(this); |
This file contains hidden or 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
/*-------------------------------------------------------------------------- | |
* Models | |
*--------------------------------------------------------------------------*/ | |
var QuestionModel = Backbone.Model.extend({ | |
defaults: { | |
question: '', | |
choices: [], | |
answer: 0, | |
userAnswer: null |
This file contains hidden or 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
var myCollection = Marionette.CollectionView.extend({ | |
initialize: function() { | |
this.listenTo( this.collection, 'request', function() { | |
// show loading here | |
}); | |
this.listenTo( this.collection, 'reset', function() { | |
// hide loading here | |
}); | |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Marionette.js</title> | |
</head> | |
<body> | |
<div id="region-main"> | |
<p>Static content</p> | |
</div> |
This file contains hidden or 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
'use strict'; | |
requirejs.config({ | |
paths: { | |
'jquery' : 'lib/jquery', | |
'jquery.ui.widget' : 'lib/jquery.ui.widget', | |
'jquery-iframe-transport' : 'lib/jquery.iframe-transport', | |
'jquery-fileupload' : 'lib/jquery.fileupload' | |
} | |
}); |
This file contains hidden or 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
// função | |
var teste = function(obj) { | |
obj.nome = obj.nome || 'João'; | |
obj.idade = obj.idade || 20; | |
console.log(obj); | |
}; | |
// utilizando | |
teste({nome:'carlos'}); | |
teste({nome:'Marcos', idade: 15}); |
This file contains hidden or 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
/* Centraliza vertical e horizontal */ | |
.center-absolute { | |
position: relative; | |
top: 50%; | |
left: 50%; | |
-webkit-transform: translate(-50%, -50%); | |
-ms-transform: translate(-50%, -50%); | |
transform: translate(-50%, -50%); | |
} |
This file contains hidden or 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
/** | |
* @return string Attributes as string. | |
*/ | |
function parseAttributes(attributes) { | |
var str = ''; | |
var attr; | |
for(attr in attributes) { | |
if(attributes.hasOwnProperty(attr)) { | |
str += ' ' + attr + '="' + attributes[attr] + '"'; |