Skip to content
GitLab
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
1041977d
Commit
1041977d
authored
13 years ago
by
Jacob Thornton
Browse files
Options
Download
Email Patches
Plain Diff
finish up rounding out tests for all js plugins
parent
48aa2093
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
js/bootstrap-popover.js
+2
-2
js/bootstrap-popover.js
js/bootstrap-twipsy.js
+9
-10
js/bootstrap-twipsy.js
js/tests/unit/bootstrap-popover.js
+71
-13
js/tests/unit/bootstrap-popover.js
with
82 additions
and
25 deletions
+82
-25
js/bootstrap-popover.js
+
2
-
2
View file @
1041977d
...
@@ -59,10 +59,10 @@
...
@@ -59,10 +59,10 @@
$
.
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
,
'
popover
'
)
return
this
return
this
}
}
$
.
fn
.
popover
.
defaults
=
$
.
extend
({},
$
.
fn
.
twipsy
.
defaults
,
{
content
:
''
,
placement
:
'
right
'
})
$
.
fn
.
popover
.
defaults
=
$
.
extend
({}
,
$
.
fn
.
twipsy
.
defaults
,
{
content
:
'
content
'
,
placement
:
'
right
'
})
})(
jQuery
||
ender
)
})(
jQuery
||
ender
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/bootstrap-twipsy.js
+
9
-
10
View file @
1041977d
...
@@ -187,35 +187,34 @@
...
@@ -187,35 +187,34 @@
* ======================== */
* ======================== */
$
.
fn
.
twipsy
=
function
(
options
)
{
$
.
fn
.
twipsy
=
function
(
options
)
{
$
.
fn
.
twipsy
.
initWith
.
call
(
this
,
options
,
Twipsy
)
$
.
fn
.
twipsy
.
initWith
.
call
(
this
,
options
,
Twipsy
,
'
twipsy
'
)
return
this
return
this
}
}
$
.
fn
.
twipsy
.
initWith
=
function
(
options
,
Constructor
)
{
$
.
fn
.
twipsy
.
initWith
=
function
(
options
,
Constructor
,
name
)
{
var
twipsy
var
twipsy
,
binder
,
binder
,
eventIn
,
eventIn
,
eventOut
,
eventOut
if
(
options
===
true
)
{
if
(
options
===
true
)
{
return
this
.
data
(
'
twipsy
'
)
return
this
.
data
(
name
)
}
else
if
(
typeof
options
==
'
string
'
)
{
}
else
if
(
typeof
options
==
'
string
'
)
{
twipsy
=
this
.
data
(
'
twipsy
'
)
twipsy
=
this
.
data
(
name
)
if
(
twipsy
)
{
if
(
twipsy
)
{
twipsy
[
options
]()
twipsy
[
options
]()
}
}
return
this
return
this
}
}
options
=
$
.
extend
({},
$
.
fn
.
twipsy
.
defaults
,
options
)
options
=
$
.
extend
({},
$
.
fn
[
name
]
.
defaults
,
options
)
function
get
(
ele
)
{
function
get
(
ele
)
{
var
twipsy
=
$
.
data
(
ele
,
'
twipsy
'
)
var
twipsy
=
$
.
data
(
ele
,
name
)
if
(
!
twipsy
)
{
if
(
!
twipsy
)
{
twipsy
=
new
Constructor
(
ele
,
$
.
fn
.
twipsy
.
elementOptions
(
ele
,
options
))
twipsy
=
new
Constructor
(
ele
,
$
.
fn
.
twipsy
.
elementOptions
(
ele
,
options
))
$
.
data
(
ele
,
'
twipsy
'
,
twipsy
)
$
.
data
(
ele
,
name
,
twipsy
)
}
}
return
twipsy
return
twipsy
...
@@ -264,8 +263,8 @@
...
@@ -264,8 +263,8 @@
this
[
binder
](
eventIn
,
enter
)[
binder
](
eventOut
,
leave
)
this
[
binder
](
eventIn
,
enter
)[
binder
](
eventOut
,
leave
)
}
}
this
.
bind
(
'
twipsy
:show
'
,
enter
)
this
.
bind
(
name
+
'
:show
'
,
enter
)
this
.
bind
(
'
twipsy
:hide
'
,
leave
)
this
.
bind
(
name
+
'
:hide
'
,
leave
)
return
this
return
this
}
}
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/bootstrap-popover.js
+
71
-
13
View file @
1041977d
// $(function () {
$
(
function
()
{
//
// module("bootstrap-popover")
module
(
"
bootstrap-popover
"
)
//
// test("should be defined on jquery object", function () {
test
(
"
should be defined on jquery object
"
,
function
()
{
// ok($(document.body).popover, 'popover method is defined')
var
div
=
$
(
'
<div></div>
'
)
// })
ok
(
div
.
popover
,
'
popover method is defined
'
)
//
})
// test("should return element", function () {
// ok($(document.body).popover()[0] == document.body, 'document.body returned')
test
(
"
should return element
"
,
function
()
{
// })
var
div
=
$
(
'
<div></div>
'
)
//
ok
(
div
.
popover
()
==
div
,
'
document.body returned
'
)
// })
})
\ No newline at end of file
test
(
"
should render popover element
"
,
function
()
{
$
.
support
.
transition
=
false
var
popover
=
$
(
'
<a href="#" data-title="mdo" data-content="http://twitter.com/mdo">@mdo</a>
'
)
.
appendTo
(
'
#qunit-runoff
'
)
.
popover
()
.
trigger
(
'
popover:show
'
)
ok
(
$
(
'
.popover
'
).
length
,
'
popover was inserted
'
)
popover
.
trigger
(
'
popover:hide
'
)
ok
(
!
$
(
"
.popover
"
).
length
,
'
popover removed
'
)
$
(
'
#qunit-runoff
'
).
empty
()
})
test
(
"
should store popover instance in popover data object
"
,
function
()
{
$
.
support
.
transition
=
false
var
popover
=
$
(
'
<a href="#" data-title="mdo" data-content="http://twitter.com/mdo">@mdo</a>
'
)
.
popover
()
ok
(
!!
popover
.
data
(
'
popover
'
),
'
popover instance exists
'
)
})
test
(
"
should get title and content from options
"
,
function
()
{
$
.
support
.
transition
=
false
var
popover
=
$
(
'
<a href="#">@fat</a>
'
)
.
appendTo
(
'
#qunit-runoff
'
)
.
popover
({
title
:
'
@fat
'
,
content
:
'
loves writing tests (╯°□°)╯︵ ┻━┻
'
})
.
trigger
(
'
popover:show
'
)
ok
(
$
(
'
.popover
'
).
length
,
'
popover was inserted
'
)
equals
(
$
(
'
.popover .title
'
).
text
(),
'
@fat
'
,
'
title correctly inserted
'
)
equals
(
$
(
'
.popover .content
'
).
text
(),
'
loves writing tests (╯°□°)╯︵ ┻━┻
'
,
'
content correctly inserted
'
)
popover
.
trigger
(
'
popover:hide
'
)
ok
(
!
$
(
'
.popover
'
).
length
,
'
popover was removed
'
)
$
(
'
#qunit-runoff
'
).
empty
()
})
test
(
"
should get title and content from attributes
"
,
function
()
{
$
.
support
.
transition
=
false
var
popover
=
$
(
'
<a href="#" data-title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>
'
)
.
appendTo
(
'
#qunit-runoff
'
)
.
popover
()
.
trigger
(
'
popover:show
'
)
ok
(
$
(
'
.popover
'
).
length
,
'
popover was inserted
'
)
equals
(
$
(
'
.popover .title
'
).
text
(),
'
@mdo
'
,
'
title correctly inserted
'
)
equals
(
$
(
'
.popover .content
'
).
text
(),
"
loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻
"
,
'
content correctly inserted
'
)
popover
.
trigger
(
'
popover:hide
'
)
ok
(
!
$
(
'
.popover
'
).
length
,
'
popover was 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