Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
todomvc
Commits
6d3e6498
Commit
6d3e6498
authored
Dec 13, 2013
by
Pascal Hartig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backbone: upgrade to 1.1
parent
9addb398
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
4862 additions
and
5540 deletions
+4862
-5540
architecture-examples/backbone/bower.json
architecture-examples/backbone/bower.json
+3
-3
architecture-examples/backbone/bower_components/backbone.localStorage/backbone.localStorage.js
...components/backbone.localStorage/backbone.localStorage.js
+45
-15
architecture-examples/backbone/bower_components/backbone/backbone.js
...e-examples/backbone/bower_components/backbone/backbone.js
+140
-130
architecture-examples/backbone/bower_components/jquery/jquery.js
...cture-examples/backbone/bower_components/jquery/jquery.js
+4524
-5292
architecture-examples/backbone/bower_components/underscore/underscore.js
...amples/backbone/bower_components/underscore/underscore.js
+150
-100
No files found.
architecture-examples/backbone/bower.json
View file @
6d3e6498
...
...
@@ -2,9 +2,9 @@
"name"
:
"todomvc-backbone"
,
"version"
:
"0.0.0"
,
"dependencies"
:
{
"backbone"
:
"~1.
0
.0"
,
"underscore"
:
"~1.
4.4
"
,
"jquery"
:
"~
1.9.1
"
,
"backbone"
:
"~1.
1
.0"
,
"underscore"
:
"~1.
5.0
"
,
"jquery"
:
"~
2.0.0
"
,
"todomvc-common"
:
"~0.1.4"
,
"backbone.localStorage"
:
"~1.1.0"
}
...
...
architecture-examples/backbone/bower_components/backbone.localStorage/backbone.localStorage.js
View file @
6d3e6498
/**
* Backbone localStorage Adapter
* Version 1.1.
0
* Version 1.1.
7
*
* https://github.com/jeromegn/Backbone.localStorage
*/
(
function
(
root
,
factory
)
{
if
(
typeof
define
===
"
function
"
&&
define
.
amd
)
{
if
(
typeof
exports
===
'
object
'
&&
typeof
require
===
'
function
'
)
{
module
.
exports
=
factory
(
require
(
"
underscore
"
),
require
(
"
backbone
"
));
}
else
if
(
typeof
define
===
"
function
"
&&
define
.
amd
)
{
// AMD. Register as an anonymous module.
define
([
"
underscore
"
,
"
backbone
"
],
function
(
_
,
Backbone
)
{
// Use global variables if the locals
is
undefined.
// Use global variables if the locals
are
undefined.
return
factory
(
_
||
root
.
_
,
Backbone
||
root
.
Backbone
);
});
}
else
{
// RequireJS isn't being used. Assume underscore and backbone
is
loaded in <script> tags
// RequireJS isn't being used. Assume underscore and backbone
are
loaded in <script> tags
factory
(
_
,
Backbone
);
}
}(
this
,
function
(
_
,
Backbone
)
{
...
...
@@ -37,6 +39,9 @@ function guid() {
// with a meaningful name, like the name you'd give a table.
// window.Store is deprectated, use Backbone.LocalStorage instead
Backbone
.
LocalStorage
=
window
.
Store
=
function
(
name
)
{
if
(
!
this
.
localStorage
)
{
throw
"
Backbone.localStorage: Environment does not support localStorage.
"
}
this
.
name
=
name
;
var
store
=
this
.
localStorage
().
getItem
(
this
.
name
);
this
.
records
=
(
store
&&
store
.
split
(
"
,
"
))
||
[];
...
...
@@ -77,7 +82,8 @@ _.extend(Backbone.LocalStorage.prototype, {
// Return the array of all models currently in storage.
findAll
:
function
()
{
return
_
(
this
.
records
).
chain
()
// Lodash removed _#chain in v1.0.0-rc.1
return
(
_
.
chain
||
_
)(
this
.
records
)
.
map
(
function
(
id
){
return
this
.
jsonData
(
this
.
localStorage
().
getItem
(
this
.
name
+
"
-
"
+
id
));
},
this
)
...
...
@@ -100,21 +106,43 @@ _.extend(Backbone.LocalStorage.prototype, {
localStorage
:
function
()
{
return
localStorage
;
},
// fix for "illegal access" error on Android when JSON.parse is passed null
jsonData
:
function
(
data
)
{
return
data
&&
JSON
.
parse
(
data
);
},
// Clear localStorage for specific collection.
_clear
:
function
()
{
var
local
=
this
.
localStorage
(),
itemRe
=
new
RegExp
(
"
^
"
+
this
.
name
+
"
-
"
);
// Remove id-tracking item (e.g., "foo").
local
.
removeItem
(
this
.
name
);
// Lodash removed _#chain in v1.0.0-rc.1
// Match all data items (e.g., "foo-ID") and remove.
(
_
.
chain
||
_
)(
local
).
keys
()
.
filter
(
function
(
k
)
{
return
itemRe
.
test
(
k
);
})
.
each
(
function
(
k
)
{
local
.
removeItem
(
k
);
});
this
.
records
.
length
=
0
;
},
// Size of localStorage.
_storageSize
:
function
()
{
return
this
.
localStorage
().
length
;
}
});
// localSync delegate to the model or collection's
// *localStorage* property, which should be an instance of `Store`.
// window.Store.sync and Backbone.localSync is deprec
t
ated, use Backbone.LocalStorage.sync instead
// window.Store.sync and Backbone.localSync is deprecated, use Backbone.LocalStorage.sync instead
Backbone
.
LocalStorage
.
sync
=
window
.
Store
.
sync
=
Backbone
.
localSync
=
function
(
method
,
model
,
options
)
{
var
store
=
model
.
localStorage
||
model
.
collection
.
localStorage
;
var
resp
,
errorMessage
,
syncDfd
=
$
.
Deferred
&&
$
.
Deferred
();
//If $ is having Deferred - use it.
var
resp
,
errorMessage
,
syncDfd
=
Backbone
.
$
.
Deferred
&&
Backbone
.
$
.
Deferred
();
//If $ is having Deferred - use it.
try
{
...
...
@@ -134,37 +162,39 @@ Backbone.LocalStorage.sync = window.Store.sync = Backbone.localSync = function(m
}
}
catch
(
error
)
{
if
(
error
.
code
===
DOMException
.
QUOTA_EXCEEDED_ERR
&&
window
.
localStorage
.
length
===
0
)
if
(
error
.
code
===
22
&&
store
.
_storageSize
()
===
0
)
errorMessage
=
"
Private browsing is unsupported
"
;
else
errorMessage
=
error
.
message
;
}
if
(
resp
)
{
if
(
options
&&
options
.
success
)
if
(
options
&&
options
.
success
)
{
if
(
Backbone
.
VERSION
===
"
0.9.10
"
)
{
options
.
success
(
model
,
resp
,
options
);
}
else
{
options
.
success
(
resp
);
}
if
(
syncDfd
)
}
if
(
syncDfd
)
{
syncDfd
.
resolve
(
resp
);
}
}
else
{
errorMessage
=
errorMessage
?
errorMessage
:
"
Record Not Found
"
;
if
(
options
&&
options
.
error
)
if
(
Backbone
.
VERSION
===
"
0.9.10
"
)
{
options
.
error
(
model
,
errorMessage
,
options
);
}
else
{
options
.
error
(
errorMessage
);
}
if
(
syncDfd
)
syncDfd
.
reject
(
errorMessage
);
}
// add compatibility with $.ajax
// always execute callback for success and error
if
(
options
&&
options
.
complete
)
options
.
complete
(
resp
);
...
...
@@ -189,4 +219,4 @@ Backbone.sync = function(method, model, options) {
};
return
Backbone
.
LocalStorage
;
}));
\ No newline at end of file
}));
architecture-examples/backbone/bower_components/backbone/backbone.js
View file @
6d3e6498
This diff is collapsed.
Click to expand it.
architecture-examples/backbone/bower_components/jquery/jquery.js
View file @
6d3e6498
This diff is collapsed.
Click to expand it.
architecture-examples/backbone/bower_components/underscore/underscore.js
View file @
6d3e6498
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment