Contient de nouveaux éléments :
<main>
<section>
<article>
<header>
<footer>
<aside>
<nav>
Et de nouveaux attributs pour des balises existantes.
Pour l'exhaustivité, voir Wikipédia HTML 5
Outil permettant de transformer un langage, en CSS valide.
#user {
display: block;
}
#user p{
text-align: center;
}
#user img{
max-width: 250px;
}
#user .friend-list{
border: solid black 1px;
}
#user {
display: block;
p{
text-align: center;
}
img{
max-width: 250px;
}
.friend-list{
border: solid black 1px;
}
}
#tweet {
border-bottom: solid #3b88c3 2px;
}
a {
color: #3b88c3;
}
button[type=submit] {
background-color: #3b88c3;
}
$color-blue: #3b88c3;
#tweet {
border-bottom: solid $color-blue 2px;
}
a {
color: $color-blue;
}
button[type=submit] {
background-color: $color-blue;
}
#post {
width: 70px; /* 100px - (15px*2) */
padding: 15px;
}
.list li {
color: white;
background-color: #000;
}
.list li:nth-child(even) {
background-color: #1a1a1a; /* noir "moins foncé" pour les LI pairs */
}
$color-black: #000;
$width: 100px;
$padding: 15px;
#post {
width: $width - ($padding * 2);
padding: $padding;
}
.list {
li {
color: white;
background-color: $color-black;
&:nth-child(even) {
background-color: lighten($color-black, 10);
}
}
}
$color-link: #00f;
$color-btn: #0f0;
a{
color: $color-link;
&:hover{
color:lighten($color-link, 10);
}
}
.btn{
color: $color-btn;
&:hover{
color:lighten($color-btn, 10);
}
}
$color-link: #00f;
$color-btn: #0f0;
@mixin hover-element($color){
&{
color: $color;
}
&:hover{
color:lighten($color, 10);
}
}
a{
@include hover-element($color-link);
}
.btn{
@include hover-element($color-btn);
}
ou
@import 'style/sass/_variable.scss';
@import 'style/sass/_form.scss';
@import 'style/sass/_header.scss';
…
…
…
.column-1{
width: 320px;
}
.column-2{
width: 640px;
}
#menu{ … }
#main{ … }
#ad { … }
…
…
…
.column-1, #menu, #ad{
width: 320px;
}
.column-2, #main{
width: 640px;
}
#menu{ … }
#main{ … }
#ad { … }
…
…
…
.column-1{
width: 320px;
}
.column-2{
width: 640px;
}
#menu{ @extend .column-1; }
#main{ @extend .column-2; }
#ad { @extend .column-1; }
-webkit-border-radius:15px;
-moz-border-radius:15px;
border-radius:15px;
-webkit-box-shadow:0 0 5px black;
-moz-box-shadow:0 0 5px black;
box-shadow:0 0 5px black;
@include border-radius(15px);
@include box-shadow(0 0 5px black);
Dépendance à Ruby
gem install compass
cd path/to/stylesheet
compass create myproject
compass watch
Applications écrites totalement en HTML 5, CSS 3 et JavaScript.
Pour offrir une expérience utilisateur optimale, sans la lenteur des changements de page.
Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
var User = Backbone.Model.extend({
initialize: function(){
console.log('user created');
},
login: function(){
//login code
}
});
var user = new User({name: "Ioan Roxin", email: "iroxin@ufc.fr"});
var name = user.get('name');
Attribut spécial du modèle permettant de l'identifier de manière unique
var Book = Backbone.Model.extend({
idAttribute: "isbn"
});
var akira = new Book({ isbn: "978-2723412162", name: "Akira Tome 1" });
alert("Akira id: " + akira.id);
Créer un modèle avec des attributs par défaut
var Meal = Backbone.Model.extend({
defaults: {
"appetizer": "caesar salad",
"entree": "ravioli",
"dessert": "cheesecake"
}
});
alert("Dessert will be " + (new Meal).get('dessert'));
Retourne un JSON des attributs du modèle
var artist = new Backbone.Model({
firstName: "Wassily",
lastName: "Kandinsky"
});
artist.set({birthday: "December 16, 1866"});
alert( artist.toJSON() );
//{
// firstName: "Wassily",
// lastName: "Kandinsky",
// birthday: "December 16, 1866"
//}
Base de l'url permettant de générer l'url finale
var Book = Backbone.Model.extend({urlRoot : '/books'});
var solaris = new Book({id: "1083-lem-solaris"});
alert(solaris.url()); // /books/1083-lem-solaris
change
est émit si des attributs on changés
var book = new Book();
book.on("change", function(){ alert('The book has changed'); });
book.fetch({
success(model, response, options){
// the success callback of jquery
}
});
var book = new Backbone.Model({
title: "The Rough Riders",
author: "Theodore Roosevelt"
});
book.save();
book.save({author: "Teddy"});
book.destroy({
success: function(model, response, options) {
...
}
});
{validate:true}
var Chapter = Backbone.Model.extend({
validate: function(attrs, options) {
if (attrs.end < attrs.start) {
return "can't end before it starts";
}
}
});
var one = new Chapter({
title : "Chapter One: The Beginning"
});
one.on("invalid", function(model, error) {
alert(model.get("title") + " " + error);
});
one.save({
start: 15,
end: 10
});
//{
// statut: 'OK',
// api_client: 'mobile',
// data: {
// title: "Javascript: The Good Parts",
// author: "D Crockford"
// }
//}
var Book = Backbone.Model.extend({
parse: function(response, options) {
return response.data;
}
});
var Book = Backbone.Model.extend();
var Library = Backbone.Collection.extend({
model: Book
});
var library = new Library([
{
title: "Javascript: The Good Parts",
author: "D Crockford"
},{
title: "High Performance JavaScript",
author: "Nicholas C Zakas"
},{
title: "JavaScript Web Applications",
author: "Alex Maccaw"
}
]);
var DocumentRow = Backbone.View.extend({
tagName: "li",
className: "document-row",
events: {
"click .icon": "open",
"click .button.edit": "openEditDialog",
"click .button.delete": "destroy"
},
initialize: function() {
this.listenTo(this.model, "change", this.render);
},
render: function() { ... }
});
var doc = documents.first();
var docRowView = new DocumentRow({
model: doc,
id: "document-row-" + doc.id
});
el
el
fait référence à l'objet Elementel
peut être inséré dans la page ou nonel
est créé à partir de tagName
, className
, id
et attributes
$el
Compile des templates JavaScript en fonction à évaluer avec les données pour le rendu.
Utilise la notation ERB <%= … %> <% … %>
var compiled = _.template("hello: <%= name %>");
compiled({name: 'moe'});
=> "hello: moe"
var list = "<% _.each(people, function(name) { %> <%= name %> <% }); %>";
_.template(list, {people: ['moe', 'curly', 'larry']});
=> "moe curly larry "
Fonction à surcharger pour rendre la vue
var Bookmark = Backbone.View.extend({
template: _.template(...),
render: function() {
this.$el.html( this.template( this.model.toJSON() ) );
return this;
}
});
var Workspace = Backbone.Router.extend({
routes: {
"help": "help", // #help
"search/:query": "search", // #search/kiwis
"search/:query/p:page": "search" // #search/kiwis/p7
},
help: function() {
...
},
search: function(query, page) {
...
}
});
package.json
Beaucoup de plugin existant
Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('default', ['uglify']);
};
bower install underscore
bower install jqueryui#1.10.4
bower search calendar
npm install generator-webapp
yo webapp
npm install generator-backbone
yo backbone [app-name]
yo backbone:model blog
yo backbone:collection blog
yo backbone:router blog
yo backbone:view blog
npm install -g yo