Skip to content

Instantly share code, notes, and snippets.

View cpjobling's full-sized avatar

Chris P. Jobling cpjobling

View GitHub Profile
@cpjobling
cpjobling / final-main.js
Last active December 16, 2015 07:39
Final Step: Small fix to allow "deep linking" from bookmarked project (e.g.http://localhost:3000/#/projects/3) to actual project. Also a small fix to correct bug in toggle styles
// Just a small addition to show method
AppRouter = Backbone.Router.extend({
// ...
show: function(id) {
// Seem to have to reconstruct HomeView to allow "deep-linking"
new HomeView();
this.toggleStyles(id);
project = projectList.get(id);
@cpjobling
cpjobling / index.html
Last active December 16, 2015 07:38
Step 3: Add template for showing project details, add view for rendering view of project, add projectView to HomeView when routed to a particular project, add route to projects/:id to router. Add function to toggle styles when routing to a new project.
<script id="project-show" type="text/template">
<h2><%= title %></h2>
<p><strong>For discipline</strong>: <%= discipline %></p>
<%= description %>
<p>
<strong>Supervisor</strong>:
<%= supervisor.name %>
(<%= supervisor.email %>),<br>
<%= supervisor.centre.name %>
( <%= supervisor.centre.code %> ).
@cpjobling
cpjobling / index.html
Created April 16, 2013 21:56
Step 2: Build template for project-list, remove dummy list from home view template, create view for list items, add list to home view.
<!-- simplified item-home termplate -->
<script id="item-home" type="text/template">
<!-- Example row of columns -->
<div class="row-fluid">
<div class="span4">
<form id="selection" action="" method="post">
<h2>List of Projects</h2>
<ul id="p-list">
<li>Loading projects...</li>
</ul>
@cpjobling
cpjobling / index.html
Last active December 16, 2015 07:38
Step 1: Move HTML for App-Data into home template, define home view to render the template, define home route to render home view and start URL history tracking.
<!DOCTYPE html>
<html class="no-js">
<body>
:
<!-- Note "Hero Unit" has been deleted -->
<div class="container">
<div id="app">
<!-- content of item-home template was here -->
</div>
@cpjobling
cpjobling / index.html
Created April 16, 2013 17:38
The main.js and index.html files at the start of the process. Pure HTML in the index page with an example list of projects. Dummy data data and Backbone model and collection in the script file.
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Project Selctr - EG-259 Web Applictions Technology (2012-2013)</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/bootstrap.min.css">
@cpjobling
cpjobling / projects_index.js.coffee
Created April 16, 2013 11:17
Backbone-on-rails generated view for the index action for a projects resource
class AppName.Views.ProjectsIndex extends Backbone.View
template: JST['projects/index']
@cpjobling
cpjobling / projects.js.coffee
Created April 16, 2013 11:09
Backbone-on-rails generated collections class for a project resource
class Pselectr.Collections.Projects extends Backbone.Collection
model: Pselectr.Models.Project
@cpjobling
cpjobling / project.js.coffee
Created April 16, 2013 11:08
Backbone-on-rails generated model for a projects resource
class Pselectr.Models.Project extends Backbone.Model
@cpjobling
cpjobling / projects_router.js.coffee
Created April 16, 2013 11:07
Backbone-on-rails generated router for a projects resource
class AppName.Routers.Projects extends Backbone.Router
routes:
'': 'index'
index: ->
alert "home page"
@cpjobling
cpjobling / app_name.js
Created April 16, 2013 11:02
App with projects router defined
(function() {
window.AppName = {
Models: {},
Collections: {},
Views: {},
Routers: {},
init: function() {
new AppName.Routers.Projects;
return Backbone.history.start();
}