Permalink
Browse files

For #377 - merging new mobile section with fixes, linkifying URLs, co…

…rrecting image paths
  • Loading branch information...
1 parent e9261fa commit 87011c3a2544edf21694fe2d326aec6560f3ecca @addyosmani committed Mar 31, 2013
Showing with 43,027 additions and 251 deletions.
  1. BIN backbone-fundamentals.epub
  2. +769 −59 backbone-fundamentals.md
  3. +512 −69 backbone-fundamentals.rtf
  4. +769 −59 chapters/10-mobile-applications.md
  5. BIN img/chapter10-1-1-1.png
  6. BIN img/chapter10-1-1.png
  7. BIN img/chapter10-1-2.png
  8. BIN img/chapter10-2-1.png
  9. BIN img/chapter10-2-2.png
  10. BIN img/chapter10-3-1.png
  11. BIN img/chapter10-3-2.png
  12. BIN img/chapter10-3-3.png
  13. BIN img/chapter10-3-4.png
  14. +519 −64 index.html
  15. +5 −0 practicals/todo-jqm-app/.gitignore
  16. +17 −0 practicals/todo-jqm-app/.project
  17. +170 −0 practicals/todo-jqm-app/Gruntfile.js
  18. +6 −0 practicals/todo-jqm-app/app/common.js
  19. +45 −0 practicals/todo-jqm-app/app/config.js
  20. +28 −0 practicals/todo-jqm-app/app/handlebars_helpers.js
  21. +30 −0 practicals/todo-jqm-app/app/initialize.config.js
  22. +28 −0 practicals/todo-jqm-app/app/jquerymobile.config.js
  23. +45 −0 practicals/todo-jqm-app/app/main.js
  24. +19 −0 practicals/todo-jqm-app/app/modules/TodoModel.js
  25. +39 −0 practicals/todo-jqm-app/app/modules/TodosCollection.js
  26. +32 −0 practicals/todo-jqm-app/app/modules/view/EditTodoPage.js
  27. +86 −0 practicals/todo-jqm-app/app/modules/view/SingleTodoView.js
  28. +110 −0 practicals/todo-jqm-app/app/modules/view/TodosView.js
  29. +75 −0 practicals/todo-jqm-app/app/modules/view/abstract/BasicView.js
  30. +14 −0 practicals/todo-jqm-app/app/templates/abstract/basic_page_simple.template
  31. +1 −0 practicals/todo-jqm-app/app/templates/abstract/basic_popup.template
  32. +5 −0 practicals/todo-jqm-app/app/templates/todos/editTodoView.template_partial
  33. +13 −0 practicals/todo-jqm-app/app/templates/todos/singleTodo.template
  34. +31 −0 practicals/todo-jqm-app/app/templates/todos/todosPage.template_partial
  35. +17 −0 practicals/todo-jqm-app/app/templates/todos/todosStatisticsAndBulkFooter.template_partial
  36. +1 −0 practicals/todo-jqm-app/app/templates/welcome.template_partial
  37. +410 −0 practicals/todo-jqm-app/assets/css/base.css
  38. BIN practicals/todo-jqm-app/assets/css/bg.png
  39. +268 −0 practicals/todo-jqm-app/assets/css/h5bp.css
  40. BIN practicals/todo-jqm-app/assets/css/images/ajax-loader.gif
  41. BIN practicals/todo-jqm-app/assets/css/images/icons-18-black.png
  42. BIN practicals/todo-jqm-app/assets/css/images/icons-18-white.png
  43. BIN practicals/todo-jqm-app/assets/css/images/icons-36-black.png
  44. BIN practicals/todo-jqm-app/assets/css/images/icons-36-white.png
  45. +70 −0 practicals/todo-jqm-app/assets/css/index.css
  46. +3,357 −0 practicals/todo-jqm-app/assets/css/jquerymobile.css
  47. +314 −0 practicals/todo-jqm-app/assets/js/libs/almond.js
  48. +1,431 −0 practicals/todo-jqm-app/assets/js/libs/backbone.js
  49. +58 −0 practicals/todo-jqm-app/assets/js/libs/backbone_super.js
  50. +1,558 −0 practicals/todo-jqm-app/assets/js/libs/handlebars.js
  51. +9,472 −0 practicals/todo-jqm-app/assets/js/libs/jquery.js
  52. +11,090 −0 practicals/todo-jqm-app/assets/js/libs/jquerymobile.js
  53. +3 −0 practicals/todo-jqm-app/assets/js/libs/localstorage.js
  54. +3,286 −0 practicals/todo-jqm-app/assets/js/libs/lodash.js
  55. +1,988 −0 practicals/todo-jqm-app/assets/js/libs/require.js
  56. +1,059 −0 practicals/todo-jqm-app/assets/js/libs/underscore.js
  57. +2 −0 practicals/todo-jqm-app/compile
  58. BIN practicals/todo-jqm-app/favicon.ico
  59. +18 −0 practicals/todo-jqm-app/index.html
  60. +31 −0 practicals/todo-jqm-app/package.js
  61. +339 −0 practicals/todo-jqm-app/readme.md
  62. +44 −0 practicals/todo-jqm-app/test/jasmine/index.html
  63. +73 −0 practicals/todo-jqm-app/test/jasmine/spec/example.js
  64. +20 −0 practicals/todo-jqm-app/test/jasmine/vendor/MIT.LICENSE
  65. +190 −0 practicals/todo-jqm-app/test/jasmine/vendor/jasmine-html.js
  66. +166 −0 practicals/todo-jqm-app/test/jasmine/vendor/jasmine.css
  67. +2,476 −0 practicals/todo-jqm-app/test/jasmine/vendor/jasmine.js
  68. BIN practicals/todo-jqm-app/test/jasmine/vendor/jasmine_favicon.png
  69. +47 −0 practicals/todo-jqm-app/test/qunit/index.html
  70. +54 −0 practicals/todo-jqm-app/test/qunit/tests/example.js
  71. +228 −0 practicals/todo-jqm-app/test/qunit/vendor/qunit.css
  72. +1,589 −0 practicals/todo-jqm-app/test/qunit/vendor/qunit.js
View
Binary file not shown.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,5 @@
+dist/
+.idea/
+npm-debug.log
+.lock-wscript
+
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>backbone.js-jquerymobile-boilerplate-template</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.aptana.ide.core.unifiedBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.aptana.ruby.core.rubynature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,170 @@
+module.exports = function (grunt) {
+
+ grunt.loadNpmTasks('grunt-contrib');
+// grunt.loadNpmTasks('grunt-release');
+ grunt.loadNpmTasks('grunt-contrib-handlebars');
+
+ grunt.loadNpmTasks('grunt-contrib-connect');
+ grunt.loadNpmTasks('grunt-contrib-clean');
+
+ grunt.loadNpmTasks('grunt-contrib-requirejs');
+ grunt.loadNpmTasks('grunt-contrib-concat');
+
+ grunt.loadNpmTasks('grunt-contrib-csslint');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-copy');
+
+ grunt.registerTask("default", ["server"]);
+ grunt.registerTask("server", ["handlebars", "connect"]);
+ grunt.registerTask("liveload", ["watch"]);
+ grunt.registerTask("release", ["clean", "handlebars", "requirejs", "concat", "copy"]);
+ /* if release-task supports grunt 0.4.0, use instead
+ / grunt.registerTask("default", "clean lint jst requirejs concat");
+ / grunt.registerTask("release", ["default", "min", "mincss"]);
+ */
+
+ grunt.initConfig({
+ clean : ["dist/"],
+ lint : {
+ files : [
+ "build/config.js", "app/**/*.js"
+ ]
+ },
+ copy: {
+ main: {
+ files: [
+ {cwd: 'dist/debug/', src: ['**'], dest: 'dist/release/', expand: true},
+ {cwd: 'assets/', src: ['**'], dest: 'dist/release/', expand: true},
+ {src: ['index.html'], dest: 'dist/release/'}
+ ]
+ }
+ },
+ // The jshint option for scripturl is set to lax, because the anchor
+ // override inside main.js needs to test for them so as to not accidentally
+ // route.
+ jshint : {
+ options : {
+ scripturl : true
+ }
+ },
+ handlebars : {
+ compile : {
+ options : {
+ namespace : "JST",
+ processName : function (filePath) {
+ return getSimpleFileName(filePath);
+ },
+ processPartialName : function (filePath) { // input: templates/_header.handlebar
+ return getSimpleFileName(filePath);
+ },
+ partialRegex : /\.template_partial$/
+ },
+ files : {
+ "dist/debug/handlebars_packaged.js" : 'app/templates/**/*.template*'
+ }
+ }
+ },
+
+ watch : {
+ files : ['app/templates/**/*.template*'], // 'app/**/*.less',
+ tasks : 'handlebars'
+ },
+ mincss : {
+ "dist/release/index.css" : [
+ "assets/css/h5bp.css"
+ ]
+ },
+ min : {
+ "dist/release/require.js" : [
+ "dist/debug/require.js"
+ ]
+ },
+ connect: {
+ server: {
+ options: {
+ port: 9001,
+ base: '.',
+ keepalive : true
+ }
+ }
+ },
+ requirejs : {
+ compile : {
+ options : {
+ baseUrl : "app/",
+ mainConfigFile : "app/config.js",
+ out : "dist/debug/require.js",
+ name : "config",
+ // Do not wrap everything in an IIFE
+ wrap : false
+ }
+ }
+ },
+ qunit : {
+ all : ["test/qunit/*.html"]
+ }
+ // The concatenate task is used here to merge the almond require/define
+ // shim and the templates into the application code. It's named
+ // dist/debug/require.js, because we want to only load one script file in
+ // index.html.
+ ,concat : {
+ "dist/debug/require.js" : [
+ "assets/js/libs/almond.js",
+ "dist/debug/templates.js",
+ "dist/debug/require.js"
+ ],
+ "dist/debug/handlebars_packaged.js" : [
+ "app/handlebars_helpers.js",
+ "app/alltemplates.js"
+ ]
+ }
+
+ /*
+ With the upgrade to grunt 0.4.0, the grunt-release task is not supported, yet.
+ With 0.4.0, the release-task was replaced by the copy- and connect-task,
+ which slows down the development process of server reloading.
+
+ server : {
+ files : {
+ "favicon.ico" : "favicon.ico"
+ },
+
+ debug : {
+ files : {
+ "favicon.ico" : "favicon.ico"
+ },
+
+ folders : {
+ "app" : "dist/debug",
+ "assets/js/libs" : "dist/debug"
+ }
+ },
+
+ release : {
+ host : "0.0.0.0",
+ port : process.env.PORT || 8000,
+
+ files : {
+ "favicon.ico" : "favicon.ico"
+ },
+
+ folders : {
+ "app" : "dist/release",
+ "assets/js/libs" : "dist/release",
+ "assets/css" : "dist/release"
+ }
+ }
+ },
+ */
+ }
+
+
+ );
+
+ var getSimpleFileName = function (fullFilePath) {
+ var fileName = fullFilePath.substring(fullFilePath.lastIndexOf('/') + 1);
+ return fileName.substring(0, fileName.indexOf('.'));
+ };
+
+}
+;
@@ -0,0 +1,6 @@
+define([], function() {
+ return {
+ TodoFilter: '',
+ ENTER_KEY: 13
+ };
+});
@@ -0,0 +1,45 @@
+require.config({
+ deps : ["main"],
+ //dir: "../app-build",
+ paths : {
+ // JavaScript folders
+ libs : "../assets/js/libs",
+ plugins : "../assets/js/plugins",
+
+ //Uncompressed Libraries
+ jquery : "../assets/js/libs/jquery", // 1.8.3
+ 'jquerymobile.config' : 'jquerymobile.config',
+ jquerymobile : "../assets/js/libs/jquerymobile", // jquery.mobile-1.3.0-rc.1.js with default template
+ lodash : "../assets/js/libs/lodash",
+ // underscore : "../assets/js/libs/underscore",
+ backbone : "../assets/js/libs/backbone",
+ backbone_super : "../assets/js/libs/backbone_super",
+ localstorage : "../assets/js/libs/localstorage",
+ handlebars : "../assets/js/libs/handlebars",
+ 'handlebars.compiled' : "../dist/debug/handlebars_packaged"
+
+ },
+
+ shim : {
+ backbone : {
+ deps : ["lodash", "jquery"],
+ exports : "Backbone"
+ },
+ backbone_super : {
+ deps : ["backbone"],
+ exports : "_super"
+ },
+ handlebars : {
+ exports : "Handlebars"
+ },
+ 'handlebars.compiled' : ['handlebars'],
+ 'jquerymobile.config' : ['jquery'],
+ jquerymobile : {
+ deps : ["jquery", 'jquerymobile.config']
+ },
+// lodash : {
+// deps : ["backbone"],
+// exports : "_"
+// },
+ }
+});
@@ -0,0 +1,28 @@
+define(['handlebars'], function (Handlebars) {
+
+ return function () {
+ Handlebars.registerHelper('whatis', function (param) {
+ console.log(param);
+ });
+
+ // https://github.com/wycats/handlebars.js/issues/182
+ Handlebars.registerHelper('$', function ( child, options ) {
+ if ( typeof child !== 'object' ) {
+ return '';
+ }
+ child['$_'] = this;
+ return options.fn( child );
+ });
+
+ Handlebars.registerHelper('ifequal', function (val1, val2, fn, elseFn) {
+ if (val1 === val2) {
+ return fn();
+ }
+ else if (elseFn) {
+ return elseFn();
+ }
+ });
+ }();
+});
+
+
@@ -0,0 +1,30 @@
+define(['jquery', 'handlebars'], function ($, Handlebars) {
+ var settings = {};
+ settings.init = function () {
+ Handlebars.templates = window.JST;
+// Handlebars.partials = Handlebars.templates;
+
+ // All navigation that is relative should be passed through the navigate
+ // method, to be processed by the router. If the link has a `data-bypass`
+ // attribute, bypass the delegation completely.
+ $(document).on("click", "a:not([data-bypass])", function (evt) {
+ // Get the anchor href and protcol
+ var href = $(this).attr("href");
+ var protocol = this.protocol + "//";
+
+ // Ensure the protocol is not part of URL, meaning it's relative.
+ if (href && href.slice(0, protocol.length) !== protocol &&
+ href.indexOf("javascript:") !== 0) {
+ // Stop the default event to ensure the link will not cause a page
+ // refresh.
+ evt.preventDefault();
+
+ // `Backbone.history.navigate` is sufficient for all Routers and will
+ // trigger the correct events. The Router's internal `navigate` method
+ // calls this anyways.
+ Backbone.history.navigate(href, true);
+ }
+ });
+ };
+ return settings;
+});
@@ -0,0 +1,28 @@
+define(['jquery'], function ($) {
+
+ $(document).on("mobileinit", function () {
+
+ // disable hash-routing
+ $.mobile.hashListeningEnabled = false;
+// disable anchor-control
+ $.mobile.linkBindingEnabled = false;
+// can cause calling object creation twice and back button issues are solved
+ $.mobile.ajaxEnabled = false;
+// Otherwise on first page load, it needs to be a page present
+ // $.mobile.autoInitializePage = false;
+// we want to handle caching and cleaning the DOM ourselves
+ $.mobile.page.prototype.options.domCache = false;
+
+// consider due to performance & compatibility issues
+// not always supported by browsers
+ $.mobile.pushStateEnabled = false;
+ $.mobile.defaultPageTransition = "none";
+ $.mobile.defaultDialogTransition = "none";
+ $.mobile.page.prototype.options.degradeInputs.date = true;
+// Solving phonegap issues with back button
+ $.mobile.phonegapNavigationEnabled = true;
+
+
+ });
+
+});
@@ -0,0 +1,45 @@
+require([
+ "jquery",
+ "backbone",
+ "backbone_super",
+ "lodash",
+ "handlebars",
+ "initialize.config",
+ "handlebars.compiled",
+ "jquerymobile",
+ "modules/view/TodosView",
+ "modules/TodosCollection",
+ "common",
+ "modules/view/EditTodoPage"
+],
+// jqValidationUnused
+ function ($, Backbone, bbsuperUnused, _, Handlebars, initializeSettings, handlebarscompUnused, jqmUnused, TodosView, TodosCollection, Common, EditTodoPage) { // ExampleDialog
+ initializeSettings.init();
+
+ var Router = Backbone.Router.extend({
+ routes : {
+ "" : "index",
+ "todo" : "index",
+ "todo/:filter" : "filter",
+ "editTodo/:id" : "editTodo",
+ '*path' : 'index'
+ },
+ index : function () {
+ new TodosView();
+ },
+ filter : function (filter) {
+ Common.TodoFilter = filter.trim() === 'all' ? '' : filter.trim() || '';
+ TodosCollection.trigger('filter');
+ },
+ editTodo : function (id){
+ new EditTodoPage({
+ model : TodosCollection.getByCid(id)
+ });
+ }
+ });
+
+ $(function () {
+ window.BackboneRouter = new Router();
+ Backbone.history.start({ pushState : false });
+ });
+ });
Oops, something went wrong.

0 comments on commit 87011c3

Please sign in to comment.