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
f4df18ba
Commit
f4df18ba
authored
Dec 03, 2012
by
spsawchuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
animate developer quotes randomly.
parent
45e277d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
14 deletions
+94
-14
index.html
index.html
+1
-1
site/js/main.js
site/js/main.js
+93
-13
No files found.
index.html
View file @
f4df18ba
...
...
@@ -110,7 +110,7 @@
</div>
<hr>
<div
class=
"row"
>
<div
class=
"span6"
>
<div
class=
"span6
quotes
"
>
<blockquote
class=
"quote speech-bubble"
>
<p></p>
<footer>
...
...
site/js/main.js
View file @
f4df18ba
...
...
@@ -35,28 +35,108 @@
});
};
var
Quotes
=
{};
Quotes
.
build
=
function
(
quotes
,
template
)
{
var
quoteContainer
=
document
.
createElement
(
'
q
'
),
quoteElemCount
=
0
,
quoteCount
=
quotes
.
length
;
$
.
fn
.
quote
=
function
(
data
)
{
var
$this
=
this
;
var
createQuoteElems
=
function
()
{
var
quote
=
quotes
[
quoteElemCount
],
el
=
$
(
template
).
hide
();
function
update
()
{
var
el
=
data
[
Math
.
floor
(
Math
.
random
()
*
data
.
length
)
];
el
.
children
(
'
p
'
).
text
(
quote
.
quote
);
el
.
find
(
'
a
'
).
text
(
quote
.
person
.
name
).
attr
(
'
href
'
,
quote
.
link
);
el
.
find
(
'
img
'
).
attr
(
'
src
'
,
quote
.
person
.
gravatar
);
$this
.
children
(
'
p
'
).
text
(
el
.
quote
);
$this
.
find
(
'
a
'
).
text
(
el
.
person
.
name
);
$this
.
find
(
'
a
'
).
attr
(
'
href
'
,
el
.
person
.
link
);
$this
.
find
(
'
img
'
).
attr
(
'
src
'
,
el
.
person
.
gravatar
);
setTimeout
(
update
,
25000
);
}
quoteContainer
.
appendChild
(
el
[
0
]);
if
(
quoteCount
>
++
quoteElemCount
)
{
createQuoteElems
();
}
return
quoteContainer
.
innerHTML
;
};
return
createQuoteElems
();
};
Quotes
.
random
=
function
(
quotes
)
{
var
quoteCount
=
quotes
.
length
,
randomQuotes
=
[];
var
randomQuote
=
function
()
{
var
randomQuoteIndex
=
Math
.
floor
(
Math
.
random
()
*
quoteCount
);
if
(
$
.
inArray
(
randomQuoteIndex
,
randomQuotes
)
>
-
1
)
{
return
randomQuote
();
}
if
(
randomQuotes
.
length
===
quoteCount
-
1
)
{
randomQuotes
=
[];
}
randomQuotes
.
push
(
randomQuoteIndex
);
return
randomQuoteIndex
;
};
return
randomQuote
;
};
Quotes
.
animate
=
function
(
container
,
animSpeed
)
{
var
fader
=
function
(
fadeOut
,
fadeIn
)
{
var
fadeOutCallback
=
function
(){
fadeIn
.
fadeIn
(
500
,
fadeInCallback
);
};
var
fadeInCallback
=
function
(){
window
.
setTimeout
(
swap
,
animSpeed
);
};
update
();
fadeOut
.
fadeOut
(
500
,
fadeOutCallback
);
};
var
quotes
=
container
.
children
(),
selectRandomQuoteIndex
=
Quotes
.
random
(
quotes
),
quoteElems
=
{},
activeQuoteIndex
=
selectRandomQuoteIndex
(),
prevQuoteElem
=
$
(
quotes
[
activeQuoteIndex
]);
var
swap
=
function
()
{
if
(
!
quoteElems
[
activeQuoteIndex
])
{
quoteElems
[
activeQuoteIndex
]
=
$
(
quotes
[
activeQuoteIndex
]);
}
var
activeQuoteElem
=
quoteElems
[
activeQuoteIndex
];
fader
(
prevQuoteElem
,
activeQuoteElem
);
activeQuoteIndex
=
selectRandomQuoteIndex
();
prevQuoteElem
=
activeQuoteElem
;
};
return
swap
();
};
Quotes
.
init
=
function
(
quotes
)
{
var
container
=
$
(
this
),
template
=
$
(
this
).
html
(),
quotesHTML
=
Quotes
.
build
(
quotes
,
template
);
container
.
html
(
quotesHTML
);
Quotes
.
animate
(
container
,
25000
);
};
$
.
fn
.
quote
=
function
(
quotes
)
{
return
this
.
each
(
function
(){
Quotes
.
init
.
call
(
this
,
quotes
);
});
};
// Apps popover
$
(
'
.applist a
'
).
persistantPopover
();
// Quotes
$
(
'
.quote
'
).
quote
([{
$
(
'
.quote
s
'
).
quote
([{
quote
:
'
TodoMVC is a godsend for helping developers find what well-developed frameworks match their mental model of application architecture.
'
,
person
:
{
name
:
'
Paul Irish
'
,
...
...
@@ -86,4 +166,4 @@
}
}]);
}());
}());
\ No newline at end of file
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