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
Eugene Shen
todomvc
Commits
284d7de9
Commit
284d7de9
authored
Oct 16, 2014
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1033 from tastejs/thorax-lumbar-update
Update thorax lumbar
parents
1af6b47b
e569cbc7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
130 additions
and
107 deletions
+130
-107
examples/thorax_lumbar/public/base.js
examples/thorax_lumbar/public/base.js
+125
-103
examples/thorax_lumbar/public/todomvc.js
examples/thorax_lumbar/public/todomvc.js
+5
-4
No files found.
examples/thorax_lumbar/public/base.js
View file @
284d7de9
(
function
()
{
'
use strict
'
;
if
(
location
.
hostname
===
'
todomvc.com
'
)
{
window
.
_gaq
=
[[
'
_setAccount
'
,
'
UA-31081062-1
'
],[
'
_trackPageview
'
]];(
function
(
d
,
t
){
var
g
=
d
.
createElement
(
t
),
s
=
d
.
getElementsByTagName
(
t
)[
0
];
g
.
src
=
'
//www.google-analytics.com/ga.js
'
;
s
.
parentNode
.
insertBefore
(
g
,
s
)}(
document
,
'
script
'
));
// Underscore's Template Module
// Courtesy of underscorejs.org
var
_
=
(
function
(
_
)
{
_
.
defaults
=
function
(
object
)
{
if
(
!
object
)
{
return
object
;
}
for
(
var
argsIndex
=
1
,
argsLength
=
arguments
.
length
;
argsIndex
<
argsLength
;
argsIndex
++
)
{
var
iterable
=
arguments
[
argsIndex
];
if
(
iterable
)
{
for
(
var
key
in
iterable
)
{
if
(
object
[
key
]
==
null
)
{
object
[
key
]
=
iterable
[
key
];
}
}
}
}
return
object
;
}
function
getSourcePath
()
{
// If accessed via tastejs.github.io/todomvc/, strip the project path.
if
(
location
.
hostname
.
indexOf
(
'
github.io
'
)
>
0
)
{
return
location
.
pathname
.
replace
(
/todomvc
\/
/
,
''
);
// By default, Underscore uses ERB-style template delimiters, change the
// following template settings to use alternative delimiters.
_
.
templateSettings
=
{
evaluate
:
/<%
([\s\S]
+
?)
%>/g
,
interpolate
:
/<%=
([\s\S]
+
?)
%>/g
,
escape
:
/<%-
([\s\S]
+
?)
%>/g
};
// When customizing `templateSettings`, if you don't want to define an
// interpolation, evaluation or escaping regex, we need one that is
// guaranteed not to match.
var
noMatch
=
/
(
.
)
^/
;
// Certain characters need to be escaped so that they can be put into a
// string literal.
var
escapes
=
{
"
'
"
:
"
'
"
,
'
\\
'
:
'
\\
'
,
'
\r
'
:
'
r
'
,
'
\n
'
:
'
n
'
,
'
\t
'
:
'
t
'
,
'
\
u2028
'
:
'
u2028
'
,
'
\
u2029
'
:
'
u2029
'
};
var
escaper
=
/
\\
|'|
\r
|
\n
|
\t
|
\u
2028|
\u
2029/g
;
// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
_
.
template
=
function
(
text
,
data
,
settings
)
{
var
render
;
settings
=
_
.
defaults
({},
settings
,
_
.
templateSettings
);
// Combine delimiters into one regular expression via alternation.
var
matcher
=
new
RegExp
([
(
settings
.
escape
||
noMatch
).
source
,
(
settings
.
interpolate
||
noMatch
).
source
,
(
settings
.
evaluate
||
noMatch
).
source
].
join
(
'
|
'
)
+
'
|$
'
,
'
g
'
);
// Compile the template source, escaping string literals appropriately.
var
index
=
0
;
var
source
=
"
__p+='
"
;
text
.
replace
(
matcher
,
function
(
match
,
escape
,
interpolate
,
evaluate
,
offset
)
{
source
+=
text
.
slice
(
index
,
offset
)
.
replace
(
escaper
,
function
(
match
)
{
return
'
\\
'
+
escapes
[
match
];
});
if
(
escape
)
{
source
+=
"
'+
\n
((__t=(
"
+
escape
+
"
))==null?'':_.escape(__t))+
\n
'
"
;
}
return
location
.
pathname
;
if
(
interpolate
)
{
source
+=
"
'+
\n
((__t=(
"
+
interpolate
+
"
))==null?'':__t)+
\n
'
"
;
}
if
(
evaluate
)
{
source
+=
"
';
\n
"
+
evaluate
+
"
\n
__p+='
"
;
}
index
=
offset
+
match
.
length
;
return
match
;
});
source
+=
"
';
\n
"
;
// If a variable is not specified, place data values in local scope.
if
(
!
settings
.
variable
)
source
=
'
with(obj||{}){
\n
'
+
source
+
'
}
\n
'
;
function
appendSourceLink
()
{
var
sourceLink
=
document
.
createElement
(
'
a
'
);
var
paragraph
=
document
.
createElement
(
'
p
'
);
var
footer
=
document
.
getElementById
(
'
info
'
);
var
urlBase
=
'
https://github.com/tastejs/todomvc/tree/gh-pages
'
;
source
=
"
var __t,__p='',__j=Array.prototype.join,
"
+
"
print=function(){__p+=__j.call(arguments,'');};
\n
"
+
source
+
"
return __p;
\n
"
;
if
(
footer
)
{
sourceLink
.
href
=
urlBase
+
getSourcePath
(
);
sourceLink
.
appendChild
(
document
.
createTextNode
(
'
Check out the source
'
));
paragraph
.
appendChild
(
sourceLink
)
;
footer
.
appendChild
(
paragraph
)
;
try
{
render
=
new
Function
(
settings
.
variable
||
'
obj
'
,
'
_
'
,
source
);
}
catch
(
e
)
{
e
.
source
=
source
;
throw
e
;
}
if
(
data
)
return
render
(
data
,
_
);
var
template
=
function
(
data
)
{
return
render
.
call
(
this
,
data
,
_
);
};
// Provide the compiled function source as a convenience for precompilation.
template
.
source
=
'
function(
'
+
(
settings
.
variable
||
'
obj
'
)
+
'
){
\n
'
+
source
+
'
}
'
;
return
template
;
};
return
_
;
})({});
if
(
location
.
hostname
===
'
todomvc.com
'
)
{
window
.
_gaq
=
[[
'
_setAccount
'
,
'
UA-31081062-1
'
],[
'
_trackPageview
'
]];(
function
(
d
,
t
){
var
g
=
d
.
createElement
(
t
),
s
=
d
.
getElementsByTagName
(
t
)[
0
];
g
.
src
=
'
//www.google-analytics.com/ga.js
'
;
s
.
parentNode
.
insertBefore
(
g
,
s
)}(
document
,
'
script
'
));
}
function
redirect
()
{
...
...
@@ -34,14 +122,15 @@
}
function
findRoot
()
{
var
base
=
[
'
labs
'
,
'
architecture-examples
'
,
'
dependency-examples
'
].
filter
(
function
(
href
)
{
return
location
.
href
.
match
(
new
RegExp
(
href
));
})[
0
];
return
location
.
href
.
substr
(
0
,
location
.
href
.
indexOf
(
base
));
var
base
=
location
.
href
.
indexOf
(
'
examples/
'
);
return
location
.
href
.
substr
(
0
,
base
);
}
function
getFile
(
file
,
callback
)
{
if
(
!
location
.
host
)
{
return
console
.
info
(
'
Miss the info bar? Run TodoMVC from a server to avoid a cross-origin error.
'
);
}
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'
GET
'
,
findRoot
()
+
file
,
true
);
...
...
@@ -79,9 +168,10 @@
}
if
(
!
framework
&&
document
.
querySelector
(
'
[data-framework]
'
))
{
framework
=
document
.
querySelector
(
'
[data-framework]
'
).
getAttribute
(
'
data-framework
'
)
;
framework
=
document
.
querySelector
(
'
[data-framework]
'
).
dataset
.
framework
;
}
if
(
template
&&
learnJSON
[
framework
])
{
this
.
frameworkJSON
=
learnJSON
[
framework
];
this
.
template
=
template
;
...
...
@@ -90,88 +180,21 @@
}
}
Learn
.
prototype
.
_prepareTemplate
=
function
()
{
var
aside
=
document
.
createElement
(
'
aside
'
);
var
block
=
aside
.
cloneNode
(
aside
);
block
.
innerHTML
=
this
.
template
;
var
header
=
block
.
cloneNode
(
aside
);
header
.
removeChild
(
header
.
querySelector
(
'
ul
'
));
header
.
removeChild
(
header
.
querySelectorAll
(
'
footer
'
)[
1
]);
return
{
header
:
header
,
links
:
block
.
cloneNode
(
aside
).
querySelector
(
'
ul a
'
),
footer
:
block
.
cloneNode
(
aside
).
querySelectorAll
(
'
footer
'
)[
1
]
};
};
Learn
.
prototype
.
_parseTemplate
=
function
()
{
if
(
!
this
.
template
)
{
return
;
}
var
frameworkJSON
=
this
.
frameworkJSON
;
var
template
=
this
.
_prepareTemplate
();
Learn
.
prototype
.
append
=
function
()
{
var
aside
=
document
.
createElement
(
'
aside
'
);
var
linksTemplate
=
template
.
links
.
outerHTML
;
var
parser
=
/
\{\{([^
}
]
*
)\}\}
/g
;
var
header
,
examples
,
links
;
aside
.
innerHTML
=
_
.
template
(
this
.
template
,
this
.
frameworkJSON
);
aside
.
className
=
'
learn
'
;
header
=
template
.
header
.
innerHTML
.
replace
(
parser
,
function
(
match
,
key
)
{
return
frameworkJSON
[
key
];
// Localize demo links
var
demoLinks
=
aside
.
querySelectorAll
(
'
.demo-link
'
);
Array
.
prototype
.
forEach
.
call
(
demoLinks
,
function
(
demoLink
)
{
demoLink
.
setAttribute
(
'
href
'
,
findRoot
()
+
demoLink
.
getAttribute
(
'
href
'
));
});
aside
.
innerHTML
=
header
;
if
(
frameworkJSON
.
examples
)
{
examples
=
frameworkJSON
.
examples
.
map
(
function
(
example
)
{
return
''
+
'
<h5>
'
+
example
.
name
+
'
</h5>
'
+
'
<p>
'
+
'
<a href="https://github.com/tastejs/todomvc/tree/gh-pages/
'
+
(
example
.
source_url
||
example
.
url
)
+
'
">Source</a>
'
+
'
</p>
'
;
}).
join
(
''
);
aside
.
querySelector
(
'
.source-links
'
).
innerHTML
=
examples
;
}
if
(
frameworkJSON
.
link_groups
)
{
links
=
frameworkJSON
.
link_groups
.
map
(
function
(
linkGroup
)
{
return
''
+
'
<h4>
'
+
linkGroup
.
heading
+
'
</h4>
'
+
'
<ul>
'
+
linkGroup
.
links
.
map
(
function
(
link
)
{
return
''
+
'
<li>
'
+
linksTemplate
.
replace
(
parser
,
function
(
match
,
key
)
{
return
link
[
key
];
})
+
'
</li>
'
;
}).
join
(
''
)
+
'
</ul>
'
;
}).
join
(
''
);
aside
.
innerHTML
+=
links
;
aside
.
innerHTML
+=
template
.
footer
.
outerHTML
;
}
return
aside
;
};
Learn
.
prototype
.
append
=
function
()
{
var
aside
=
this
.
_parseTemplate
();
aside
.
className
=
'
learn
'
;
document
.
body
.
className
=
(
document
.
body
.
className
+
'
learn-bar
'
).
trim
();
document
.
body
.
insertAdjacent
Element
(
'
afterBegin
'
,
aside
);
document
.
body
.
insertAdjacent
HTML
(
'
afterBegin
'
,
aside
.
outerHTML
);
};
appendSourceLink
();
redirect
();
getFile
(
'
learn.json
'
,
Learn
);
})();
...
...
@@ -16608,7 +16631,6 @@ if (isIE) {
})();
;;
/**
* Backbone localStorage Adapter
...
...
examples/thorax_lumbar/public/todomvc.js
View file @
284d7de9
Application
[
'
todomvc
'
]
=
(
function
()
{
var
module
=
{
exports
:
{}};
var
exports
=
module
.
exports
;
...
...
@@ -12,7 +13,7 @@ module.routes = {"":"setFilter",":filter":"setFilter"};
// Todo Model
// ----------
// Our basic **Todo** model has `title` and `completed` attributes.
// Our basic **Todo** model has `title`
, `order`,
and `completed` attributes.
window
.
app
.
Todo
=
Thorax
.
Model
.
extend
({
// Default attributes for the todo
...
...
@@ -62,18 +63,18 @@ module.routes = {"":"setFilter",":filter":"setFilter"};
localStorage
:
new
Store
(
'
todos-backbone-thorax
'
),
// Filter down the list of all todo items that are finished.
completed
:
function
()
{
completed
:
function
()
{
return
this
.
where
({
completed
:
true
});
},
// Filter down the list to only todo items that are still not finished.
remaining
:
function
()
{
remaining
:
function
()
{
return
this
.
where
({
completed
:
false
});
},
// We keep the Todos in sequential order, despite being saved by unordered
// GUID in the database. This generates the next order number for new items.
nextOrder
:
function
()
{
nextOrder
:
function
()
{
return
this
.
length
?
this
.
last
().
get
(
'
order
'
)
+
1
:
1
;
},
...
...
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