Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
48aa2093
Commit
48aa2093
authored
13 years ago
by
Jacob Thornton
Browse files
Options
Download
Email Patches
Plain Diff
more tests, more js goodness
parent
79d5f907
No related merge requests found
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
docs/index.html
+1
-1
docs/index.html
docs/javascript.html
+4
-4
docs/javascript.html
js/bootstrap-modal.js
+15
-15
js/bootstrap-modal.js
js/bootstrap-popover.js
+1
-0
js/bootstrap-popover.js
js/bootstrap-twipsy.js
+4
-0
js/bootstrap-twipsy.js
js/tests/unit/bootstrap-modal.js
+37
-13
js/tests/unit/bootstrap-modal.js
js/tests/unit/bootstrap-popover.js
+13
-0
js/tests/unit/bootstrap-popover.js
js/tests/unit/bootstrap-tabs.js
+49
-0
js/tests/unit/bootstrap-tabs.js
js/tests/unit/bootstrap-twipsy.js
+81
-0
js/tests/unit/bootstrap-twipsy.js
with
205 additions
and
33 deletions
+205
-33
docs/index.html
+
1
-
1
View file @
48aa2093
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<script
src=
"http://autobahn.tablesorter.com/jquery.tablesorter.min.js"
></script>
<script
src=
"http://autobahn.tablesorter.com/jquery.tablesorter.min.js"
></script>
<script
src=
"assets/js/google-code-prettify/prettify.js"
></script>
<script
src=
"assets/js/google-code-prettify/prettify.js"
></script>
<script>
$
(
function
()
{
prettyPrint
()
})
</script>
<script>
$
(
function
()
{
prettyPrint
()
})
</script>
<script
src=
"
assets
/js/bootstrap-dropdown.js"
></script>
<script
src=
"
..
/js/bootstrap-dropdown.js"
></script>
<script
src=
"assets/js/application.js"
></script>
<script
src=
"assets/js/application.js"
></script>
<script
src=
"assets/js/application-scrollspy.js"
></script>
<script
src=
"assets/js/application-scrollspy.js"
></script>
...
...
This diff is collapsed.
Click to expand it.
docs/javascript.html
+
4
-
4
View file @
48aa2093
...
@@ -89,12 +89,12 @@ $('#modal-content').modal({
...
@@ -89,12 +89,12 @@ $('#modal-content').modal({
<h4>
modal:toggle
</h4>
<h4>
modal:toggle
</h4>
<p>
Toggle the modal open state.
</p>
<p>
Toggle the modal open state.
</p>
<pre
class=
"prettyprint linenums"
>
$('#modal-content').trigger('modal:toggle')
</pre>
<pre
class=
"prettyprint linenums"
>
$('#modal-content').trigger('modal:toggle')
</pre>
<h4>
modal:
open
</h4>
<h4>
modal:
show
</h4>
<p>
Opens the modal.
</p>
<p>
Opens the modal.
</p>
<pre
class=
"prettyprint linenums"
>
$('#modal-content').trigger('modal:
open
')
</pre>
<pre
class=
"prettyprint linenums"
>
$('#modal-content').trigger('modal:
show
')
</pre>
<h4>
modal:
clos
e
</h4>
<h4>
modal:
hid
e
</h4>
<p>
Closes the modal.
</p>
<p>
Closes the modal.
</p>
<pre
class=
"prettyprint linenums"
>
$('#modal-content').trigger('modal:
clos
e')
</pre>
<pre
class=
"prettyprint linenums"
>
$('#modal-content').trigger('modal:
hid
e')
</pre>
<h3>
Demo
</h3>
<h3>
Demo
</h3>
<!-- sample modal content -->
<!-- sample modal content -->
...
...
This diff is collapsed.
Click to expand it.
js/bootstrap-modal.js
+
15
-
15
View file @
48aa2093
...
@@ -40,10 +40,10 @@
...
@@ -40,10 +40,10 @@
}
}
this
.
$element
=
$
(
content
)
this
.
$element
=
$
(
content
)
.
bind
(
'
modal:
open
'
,
$
.
proxy
(
this
.
open
,
this
))
.
bind
(
'
modal:
show
'
,
$
.
proxy
(
this
.
show
,
this
))
.
bind
(
'
modal:
clos
e
'
,
$
.
proxy
(
this
.
clos
e
,
this
))
.
bind
(
'
modal:
hid
e
'
,
$
.
proxy
(
this
.
hid
e
,
this
))
.
bind
(
'
modal:toggle
'
,
$
.
proxy
(
this
.
toggle
,
this
))
.
bind
(
'
modal:toggle
'
,
$
.
proxy
(
this
.
toggle
,
this
))
.
delegate
(
'
.close
'
,
'
click
'
,
$
.
proxy
(
this
.
clos
e
,
this
))
.
delegate
(
'
.close
'
,
'
click
'
,
$
.
proxy
(
this
.
hid
e
,
this
))
return
this
return
this
}
}
...
@@ -51,12 +51,12 @@
...
@@ -51,12 +51,12 @@
Modal
.
prototype
=
{
Modal
.
prototype
=
{
toggle
:
function
()
{
toggle
:
function
()
{
return
this
[
!
this
.
is
Ope
n
?
'
open
'
:
'
clos
e
'
]()
return
this
[
!
this
.
is
Show
n
?
'
show
'
:
'
hid
e
'
]()
}
}
,
open
:
function
()
{
,
show
:
function
()
{
var
that
=
this
var
that
=
this
this
.
is
Ope
n
=
true
this
.
is
Show
n
=
true
_
.
escape
.
call
(
this
)
_
.
escape
.
call
(
this
)
_
.
backdrop
.
call
(
this
)
_
.
backdrop
.
call
(
this
)
...
@@ -73,12 +73,12 @@
...
@@ -73,12 +73,12 @@
return
this
return
this
}
}
,
clos
e
:
function
(
e
)
{
,
hid
e
:
function
(
e
)
{
e
&&
e
.
preventDefault
()
e
&&
e
.
preventDefault
()
var
that
=
this
var
that
=
this
this
.
is
Ope
n
=
false
this
.
is
Show
n
=
false
_
.
escape
.
call
(
this
)
_
.
escape
.
call
(
this
)
_
.
backdrop
.
call
(
this
)
_
.
backdrop
.
call
(
this
)
...
@@ -108,11 +108,11 @@
...
@@ -108,11 +108,11 @@
backdrop
:
function
()
{
backdrop
:
function
()
{
var
that
=
this
var
that
=
this
,
animate
=
this
.
$element
.
hasClass
(
'
fade
'
)
?
'
fade
'
:
''
,
animate
=
this
.
$element
.
hasClass
(
'
fade
'
)
?
'
fade
'
:
''
if
(
this
.
is
Ope
n
&&
this
.
settings
.
backdrop
)
{
if
(
this
.
is
Show
n
&&
this
.
settings
.
backdrop
)
{
this
.
$backdrop
=
$
(
'
<div class="modal-backdrop
'
+
animate
+
'
" />
'
)
this
.
$backdrop
=
$
(
'
<div class="modal-backdrop
'
+
animate
+
'
" />
'
)
.
click
(
function
()
{
that
.
close
()
}
)
.
click
(
$
.
proxy
(
this
.
hide
,
this
)
)
.
appendTo
(
document
.
body
)
.
appendTo
(
document
.
body
)
}
else
if
(
!
this
.
is
Ope
n
&&
this
.
$backdrop
)
{
}
else
if
(
!
this
.
is
Show
n
&&
this
.
$backdrop
)
{
this
.
$backdrop
.
removeClass
(
'
in
'
)
this
.
$backdrop
.
removeClass
(
'
in
'
)
function
removeElement
()
{
function
removeElement
()
{
...
@@ -128,13 +128,13 @@
...
@@ -128,13 +128,13 @@
,
escape
:
function
()
{
,
escape
:
function
()
{
var
that
=
this
var
that
=
this
if
(
this
.
is
Ope
n
&&
this
.
settings
.
closeOnEscape
)
{
if
(
this
.
is
Show
n
&&
this
.
settings
.
closeOnEscape
)
{
$
(
'
body
'
).
bind
(
'
keyup.modal.escape
'
,
function
(
e
)
{
$
(
'
body
'
).
bind
(
'
keyup.modal.escape
'
,
function
(
e
)
{
if
(
e
.
which
==
27
)
{
if
(
e
.
which
==
27
)
{
that
.
clos
e
()
that
.
hid
e
()
}
}
})
})
}
else
if
(
!
this
.
is
Ope
n
)
{
}
else
if
(
!
this
.
is
Show
n
)
{
$
(
'
body
'
).
unbind
(
'
keyup.modal.escape
'
)
$
(
'
body
'
).
unbind
(
'
keyup.modal.escape
'
)
}
}
}
}
...
@@ -156,7 +156,7 @@
...
@@ -156,7 +156,7 @@
$
.
fn
.
modal
.
defaults
=
{
$
.
fn
.
modal
.
defaults
=
{
backdrop
:
false
backdrop
:
false
,
clos
eOnEscape
:
false
,
hid
eOnEscape
:
false
}
}
})(
jQuery
||
ender
)
})(
jQuery
||
ender
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/bootstrap-popover.js
+
1
-
0
View file @
48aa2093
...
@@ -60,6 +60,7 @@
...
@@ -60,6 +60,7 @@
$
.
fn
.
popover
=
function
(
options
)
{
$
.
fn
.
popover
=
function
(
options
)
{
if
(
typeof
options
==
'
object
'
)
options
=
$
.
extend
({},
$
.
fn
.
popover
.
defaults
,
options
)
if
(
typeof
options
==
'
object
'
)
options
=
$
.
extend
({},
$
.
fn
.
popover
.
defaults
,
options
)
$
.
fn
.
twipsy
.
initWith
.
call
(
this
,
options
,
Popover
)
$
.
fn
.
twipsy
.
initWith
.
call
(
this
,
options
,
Popover
)
return
this
}
}
$
.
fn
.
popover
.
defaults
=
$
.
extend
({},
$
.
fn
.
twipsy
.
defaults
,
{
content
:
''
,
placement
:
'
right
'
})
$
.
fn
.
popover
.
defaults
=
$
.
extend
({},
$
.
fn
.
twipsy
.
defaults
,
{
content
:
''
,
placement
:
'
right
'
})
...
...
This diff is collapsed.
Click to expand it.
js/bootstrap-twipsy.js
+
4
-
0
View file @
48aa2093
...
@@ -188,6 +188,7 @@
...
@@ -188,6 +188,7 @@
$
.
fn
.
twipsy
=
function
(
options
)
{
$
.
fn
.
twipsy
=
function
(
options
)
{
$
.
fn
.
twipsy
.
initWith
.
call
(
this
,
options
,
Twipsy
)
$
.
fn
.
twipsy
.
initWith
.
call
(
this
,
options
,
Twipsy
)
return
this
}
}
$
.
fn
.
twipsy
.
initWith
=
function
(
options
,
Constructor
)
{
$
.
fn
.
twipsy
.
initWith
=
function
(
options
,
Constructor
)
{
...
@@ -263,6 +264,9 @@
...
@@ -263,6 +264,9 @@
this
[
binder
](
eventIn
,
enter
)[
binder
](
eventOut
,
leave
)
this
[
binder
](
eventIn
,
enter
)[
binder
](
eventOut
,
leave
)
}
}
this
.
bind
(
'
twipsy:show
'
,
enter
)
this
.
bind
(
'
twipsy:hide
'
,
leave
)
return
this
return
this
}
}
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/bootstrap-modal.js
+
37
-
13
View file @
48aa2093
...
@@ -3,30 +3,54 @@ $(function () {
...
@@ -3,30 +3,54 @@ $(function () {
module
(
"
bootstrap-modal
"
)
module
(
"
bootstrap-modal
"
)
test
(
"
should be defined on jquery object
"
,
function
()
{
test
(
"
should be defined on jquery object
"
,
function
()
{
ok
(
$
(
document
.
body
).
modal
,
'
modal method is defined
'
)
var
div
=
$
(
"
<div id='modal-test'></div>
"
)
ok
(
div
.
modal
,
'
modal method is defined
'
)
})
})
test
(
"
should not return element
"
,
function
()
{
test
(
"
should return element
"
,
function
()
{
ok
(
!
$
(
document
.
body
).
modal
()[
0
],
'
document.body not returned
'
)
var
div
=
$
(
"
<div id='modal-test'></div>
"
)
ok
(
div
.
modal
()
==
div
,
'
document.body returned
'
)
})
})
test
(
"
should
return instance of modal clas
s
"
,
function
()
{
test
(
"
should
expose defaults var for setting
s
"
,
function
()
{
ok
(
$
(
document
.
body
).
modal
()
instanceof
$
.
fn
.
modal
.
Modal
,
'
document.body return
ed
'
)
ok
(
$
.
fn
.
modal
.
defaults
,
'
default object expos
ed
'
)
})
})
test
(
"
should expose defaults var for settings
"
,
{
test
(
"
should insert into dom when modal:show event is called
"
,
function
()
{
ok
(
!!
$
.
fn
.
modal
.
default
,
'
default object exposed
'
)
$
.
support
.
transition
=
false
var
div
=
$
(
"
<div id='modal-test'></div>
"
)
div
.
modal
().
trigger
(
"
modal:show
"
)
ok
(
$
(
'
#modal-test
'
).
length
,
'
modal insterted into dom
'
)
div
.
remove
()
})
})
test
(
"
should insert into dom when open is called
"
,
function
()
{
test
(
"
should remove from dom when close is called
"
,
function
()
{
var
div
=
$
(
"
<div></div>
"
)
$
.
support
.
transition
=
false
div
.
modal
().
open
()
var
div
=
$
(
"
<div id='modal-test'></div>
"
)
div
.
modal
().
trigger
(
"
modal:show
"
)
ok
(
$
(
'
#modal-test
'
).
length
,
'
modal insterted into dom
'
)
div
.
trigger
(
"
modal:hide
"
)
ok
(
!
$
(
'
#modal-test
'
).
length
,
'
modal removed from dom
'
)
div
.
remove
()
})
})
test
(
"
should
remove from dom when clos
e is called
"
,
function
()
{
test
(
"
should
toggle when toggl
e is called
"
,
function
()
{
$
.
support
.
transition
=
false
$
.
support
.
transition
=
false
re
var
div
=
$
(
"
<div id='modal-test'></div>
"
)
div
.
modal
().
trigger
(
"
modal:toggle
"
)
ok
(
$
(
'
#modal-test
'
).
length
,
'
modal insterted into dom
'
)
div
.
trigger
(
"
modal:toggle
"
)
ok
(
!
$
(
'
#modal-test
'
).
length
,
'
modal removed from dom
'
)
div
.
remove
()
})
})
test
(
"
should remove from dom when click .close
"
)
test
(
"
should remove from dom when click .close
"
,
function
()
{
$
.
support
.
transition
=
false
var
div
=
$
(
"
<div id='modal-test'><span class='close'></span></div>
"
)
div
.
modal
().
trigger
(
"
modal:toggle
"
)
ok
(
$
(
'
#modal-test
'
).
length
,
'
modal insterted into dom
'
)
div
.
find
(
'
.close
'
).
click
()
ok
(
!
$
(
'
#modal-test
'
).
length
,
'
modal removed from dom
'
)
div
.
remove
()
})
})
})
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/tests/unit/bootstrap-popover.js
+
13
-
0
View file @
48aa2093
// $(function () {
//
// module("bootstrap-popover")
//
// test("should be defined on jquery object", function () {
// ok($(document.body).popover, 'popover method is defined')
// })
//
// test("should return element", function () {
// ok($(document.body).popover()[0] == document.body, 'document.body returned')
// })
//
// })
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/tests/unit/bootstrap-tabs.js
+
49
-
0
View file @
48aa2093
$
(
function
()
{
module
(
"
bootstrap-tabs
"
)
test
(
"
should be defined on jquery object
"
,
function
()
{
ok
(
$
(
document
.
body
).
tabs
,
'
tabs method is defined
'
)
})
test
(
"
should return element
"
,
function
()
{
ok
(
$
(
document
.
body
).
tabs
()[
0
]
==
document
.
body
,
'
document.body returned
'
)
})
test
(
"
should activate element by tab id
"
,
function
()
{
var
tabsHTML
=
'
<ul class="tabs">
'
+
'
<li class="active"><a href="#home">Home</a></li>
'
+
'
<li><a href="#profile">Profile</a></li>
'
+
'
</ul>
'
$
(
'
<ul><li id="home"></li><li id="profile"></li></ul>
'
).
appendTo
(
"
#qunit-runoff
"
)
$
(
tabsHTML
).
tabs
().
find
(
'
a
'
).
last
().
click
()
equals
(
$
(
"
#qunit-runoff
"
).
find
(
'
.active
'
).
attr
(
'
id
'
),
"
profile
"
)
$
(
tabsHTML
).
tabs
().
find
(
'
a
'
).
first
().
click
()
equals
(
$
(
"
#qunit-runoff
"
).
find
(
'
.active
'
).
attr
(
'
id
'
),
"
home
"
)
$
(
"
#qunit-runoff
"
).
empty
()
})
test
(
"
should activate element by pill id
"
,
function
()
{
var
pillsHTML
=
'
<ul class="pills">
'
+
'
<li class="active"><a href="#home">Home</a></li>
'
+
'
<li><a href="#profile">Profile</a></li>
'
+
'
</ul>
'
$
(
'
<ul><li id="home"></li><li id="profile"></li></ul>
'
).
appendTo
(
"
#qunit-runoff
"
)
$
(
pillsHTML
).
pills
().
find
(
'
a
'
).
last
().
click
()
equals
(
$
(
"
#qunit-runoff
"
).
find
(
'
.active
'
).
attr
(
'
id
'
),
"
profile
"
)
$
(
pillsHTML
).
pills
().
find
(
'
a
'
).
first
().
click
()
equals
(
$
(
"
#qunit-runoff
"
).
find
(
'
.active
'
).
attr
(
'
id
'
),
"
home
"
)
$
(
"
#qunit-runoff
"
).
empty
()
})
})
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/tests/unit/bootstrap-twipsy.js
+
81
-
0
View file @
48aa2093
$
(
function
()
{
module
(
"
bootstrap-twipsy
"
)
test
(
"
should be defined on jquery object
"
,
function
()
{
var
div
=
$
(
"
<div></div>
"
)
ok
(
div
.
twipsy
,
'
popover method is defined
'
)
})
test
(
"
should return element
"
,
function
()
{
var
div
=
$
(
"
<div></div>
"
)
ok
(
div
.
twipsy
()
==
div
,
'
document.body returned
'
)
})
test
(
"
should expose default settings
"
,
function
()
{
ok
(
!!
$
.
fn
.
twipsy
.
defaults
,
'
defaults is defined
'
)
})
test
(
"
should remove title attribute
"
,
function
()
{
var
twipsy
=
$
(
'
<a href="#" rel="twipsy" title="Another twipsy"></a>
'
).
twipsy
()
ok
(
!
twipsy
.
attr
(
'
title
'
),
'
title tag was removed
'
)
})
test
(
"
should add data attribute for referencing original title
"
,
function
()
{
var
twipsy
=
$
(
'
<a href="#" rel="twipsy" title="Another twipsy"></a>
'
).
twipsy
()
equals
(
twipsy
.
attr
(
'
data-original-title
'
),
'
Another twipsy
'
,
'
original title preserved in data attribute
'
)
})
test
(
"
should place tooltips relative to placement option
"
,
function
()
{
$
.
support
.
transition
=
false
var
twipsy
=
$
(
'
<a href="#" rel="twipsy" title="Another twipsy"></a>
'
)
.
appendTo
(
'
#qunit-runoff
'
)
.
twipsy
({
placement
:
'
below
'
})
.
trigger
(
'
twipsy:show
'
)
ok
(
$
(
"
.twipsy
"
).
hasClass
(
'
fade below in
'
),
'
has correct classes applied
'
)
twipsy
.
trigger
(
'
twipsy:hide
'
)
ok
(
!
$
(
"
.twipsy
"
).
length
,
'
twipsy removed
'
)
$
(
'
#qunit-runoff
'
).
empty
()
})
test
(
"
should add a fallback in cases where elements have no title tag
"
,
function
()
{
$
.
support
.
transition
=
false
var
twipsy
=
$
(
'
<a href="#" rel="twipsy"></a>
'
)
.
appendTo
(
'
#qunit-runoff
'
)
.
twipsy
({
fallback
:
'
@fat
'
})
.
trigger
(
'
twipsy:show
'
)
equals
(
$
(
"
.twipsy
"
).
text
(),
"
@fat
"
,
'
has correct default text
'
)
twipsy
.
trigger
(
'
twipsy:hide
'
)
ok
(
!
$
(
"
.twipsy
"
).
length
,
'
twipsy removed
'
)
$
(
'
#qunit-runoff
'
).
empty
()
})
test
(
"
should not allow html entities
"
,
function
()
{
$
.
support
.
transition
=
false
var
twipsy
=
$
(
'
<a href="#" rel="twipsy" title="<b>@fat</b>"></a>
'
)
.
appendTo
(
'
#qunit-runoff
'
)
.
twipsy
()
.
trigger
(
'
twipsy:show
'
)
ok
(
!
$
(
'
.twipsy b
'
).
length
,
'
b tag was not inserted
'
)
twipsy
.
trigger
(
'
twipsy:hide
'
)
ok
(
!
$
(
"
.twipsy
"
).
length
,
'
twipsy removed
'
)
$
(
'
#qunit-runoff
'
).
empty
()
})
test
(
"
should allow html entities if html option set to true
"
,
function
()
{
$
.
support
.
transition
=
false
var
twipsy
=
$
(
'
<a href="#" rel="twipsy" title="<b>@fat</b>"></a>
'
)
.
appendTo
(
'
#qunit-runoff
'
)
.
twipsy
({
html
:
true
})
.
trigger
(
'
twipsy:show
'
)
ok
(
$
(
'
.twipsy b
'
).
length
,
'
b tag was inserted
'
)
twipsy
.
trigger
(
'
twipsy:hide
'
)
ok
(
!
$
(
"
.twipsy
"
).
length
,
'
twipsy removed
'
)
$
(
'
#qunit-runoff
'
).
empty
()
})
})
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets