Permalink
Browse files

config for ReguqireJS updated to not use shim, which is not needed, b…

…ecause CanJS already support AMD - Thanks to Justin Meyer (core CanJS member)
  • Loading branch information...
1 parent 83241c5 commit 0c53311c86efb005f1aff5fe471d981dc44b0287 Jens Krause committed Aug 30, 2012
View
@@ -12,11 +12,10 @@
<script data-main="js/main-optimized" src="js/libs/require.js"></script>
-->
-
-
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
+
</head>
<body>
<section id="todoapp">
View
@@ -1,21 +1,16 @@
'use strict';
require.config({
- shim: {
- 'can': {
- exports: 'can'
- }
- },
paths: {
- jquery: 'libs/jquery-1.8.0.min',
- can: 'libs/can.jquery-1.0.7',
- json: 'libs/json2'
- }
+ jquery: ['http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min', 'libs/jquery-1.8.0.min'],
+ json: ['http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2', 'libs/json2'],
+ can: ['http://canjs.us/release/1.0.7/can.jquery', 'libs/can.jquery-1.0.7']
+ },
+ waitSeconds: 15
});
-require(['jquery', 'models/Todo', 'models/TodoList', 'controllers/Todos'], function($, Todo, TodoList, Todos) {
+require(['jquery', 'json', 'can', 'models/Todo', 'models/TodoList', 'controllers/Todos'], function($, can, json, Todo, TodoList, Todos) {
return $(function() {
- console.log('jQuery version: ' + $().jquery);
return Todo.findAll({}, function(todos) {
return new Todos('#todoapp', {
todos: todos
@@ -1,6 +1,6 @@
'use strict';
-define("controllers/Todos", ['can', 'models/Todo'], function(can, Todo) {
+define(['can', 'models/Todo'], function(can, Todo) {
var Todos;
return Todos = can.Control({
init: function() {
@@ -1,7 +1,7 @@
-define("models/Todo", ['can'], function(can) {
+define('models/Todo',['can'], function(can) {
var Todo;
return Todo = can.Model({
localStore: function(cb) {
@@ -82,7 +82,7 @@ define("models/Todo", ['can'], function(can) {
-define("models/TodoList", ['can', 'models/Todo'], function(can, Todo) {
+define('models/TodoList',['can', 'models/Todo'], function(can, Todo) {
return Todo.List = can.Model.List({
completed: function() {
var counter;
@@ -104,7 +104,7 @@ define("models/TodoList", ['can', 'models/Todo'], function(can, Todo) {
-define("controllers/Todos", ['can', 'models/Todo'], function(can, Todo) {
+define('controllers/Todos',['can', 'models/Todo'], function(can, Todo) {
var Todos;
return Todos = can.Control({
init: function() {
@@ -179,21 +179,16 @@ define("controllers/Todos", ['can', 'models/Todo'], function(can, Todo) {
require.config({
- shim: {
- 'can': {
- exports: 'can'
- }
- },
paths: {
- jquery: 'libs/jquery-1.8.0.min',
- can: 'libs/can.jquery-1.0.7',
- json: 'libs/json2'
- }
+ jquery: ['http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min', 'libs/jquery-1.8.0.min'],
+ json: ['http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2', 'libs/json2'],
+ can: ['http://canjs.us/release/1.0.7/can.jquery', 'libs/can.jquery-1.0.7']
+ },
+ waitSeconds: 15
});
-require(['jquery', 'models/Todo', 'models/TodoList', 'controllers/Todos'], function($, Todo, TodoList, Todos) {
+require(['jquery', 'json', 'can', 'models/Todo', 'models/TodoList', 'controllers/Todos'], function($, can, json, Todo, TodoList, Todos) {
return $(function() {
- console.log('jQuery version: ' + $().jquery);
return Todo.findAll({}, function(todos) {
return new Todos('#todoapp', {
todos: todos
View
@@ -1,6 +1,6 @@
'use strict';
-define("models/Todo", ['can'], function(can) {
+define(['can'], function(can) {
var Todo;
return Todo = can.Model({
localStore: function(cb) {
@@ -1,6 +1,6 @@
'use strict';
-define("models/TodoList", ['can', 'models/Todo'], function(can, Todo) {
+define(['can', 'models/Todo'], function(can, Todo) {
return Todo.List = can.Model.List({
completed: function() {
var counter;
View
@@ -1,26 +1,38 @@
'use strict'
require.config
- # The shim config allows us to configure dependencies for
- # scripts that do not call define() to register a module
- shim:
- 'can':
- exports: 'can'
-
+ # pathes with inline callbacks,
+ # if the CDN location fails, it loads from local path
+ # @see: http://requirejs.org/docs/api.html#pathsfallbacks
paths:
- jquery: 'libs/jquery-1.8.0.min',
- can: 'libs/can.jquery-1.0.7',
- json: 'libs/json2'
+ jquery: [
+ 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min',
+ # If the CDN location fails, load from this location
+ 'libs/jquery-1.8.0.min'
+ ],
+ json: [
+ 'http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2',
+ 'libs/json2'
+ ],
+ can: [
+ 'http://canjs.us/release/1.0.7/can.jquery',
+ 'libs/can.jquery-1.0.7'
+ ]
+
+ # Increasing the the default 7 sec. to 15
+ # @see: http://requirejs.org/docs/api.html#config-waitSeconds
+ waitSeconds: 15
+
require([
'jquery',
+ 'json',
+ 'can'
'models/Todo',
'models/TodoList',
'controllers/Todos'
-], ($, Todo, TodoList, Todos) ->
+], ($, can, json, Todo, TodoList, Todos) ->
+ # bootstrap the app
$ () ->
- console.log 'jQuery version: ' + $().jquery
-
-
Todo.findAll {}, (todos)->
new Todos '#todoapp', todos: todos
)
@@ -1,5 +1,5 @@
'use strict'
-define "controllers/Todos", ['can', 'models/Todo'], (can, Todo) ->
+define ['can', 'models/Todo'], (can, Todo) ->
Todos = can.Control
@@ -28,7 +28,7 @@ define "controllers/Todos", ['can', 'models/Todo'], (can, Todo) ->
el.val ""
# Handle a newly created Todo
- # '{Todo} created': (list, ev, item) ->
+ # "{Todo} created": (list, ev, item) ->
# @options.todos.push item
# Listen for editing a Todo
@@ -69,7 +69,4 @@ define "controllers/Todos", ['can', 'models/Todo'], (can, Todo) ->
"#clear-completed click": ->
for i in [@options.todos.length - 1..0] by -1
todo = @options.todos[i]
- todo.destroy() if todo.attr('complete')
-
-
-
+ todo.destroy() if todo.attr('complete')
View
@@ -1,5 +1,5 @@
'use strict'
-define "models/Todo", ['can'], (can) ->
+define ['can'], (can) ->
Todo = can.Model
localStore: (cb)->
@@ -1,5 +1,5 @@
'use strict'
-define "models/TodoList", ['can', 'models/Todo'], (can, Todo) ->
+define ['can', 'models/Todo'], (can, Todo) ->
Todo.List = can.Model.List
completed: ->

0 comments on commit 0c53311

Please sign in to comment.