Skip to content

Commit 2cf85da

Browse files
committed
Popup/Tooltip: Fix tab order and add notifications (on select) in
video-player demo.
1 parent fbe982b commit 2cf85da

File tree

2 files changed

+43
-22
lines changed

2 files changed

+43
-22
lines changed

demos/tooltip/video-player.html

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,40 @@
1414
<link type="text/css" href="../demos.css" rel="stylesheet" />
1515
<script type="text/javascript">
1616
$(function() {
17+
function notify( input ) {
18+
var msg = "Selected " + $.trim($(input).text());
19+
$("<div/>").appendTo(document.body).text(msg).addClass("notification ui-state-highlight").position({
20+
my: "center top+20",
21+
at: "center top",
22+
of: window
23+
}).delay(1000).fadeOut("slow", function() {
24+
$(this).remove();
25+
});
26+
}
27+
$("ul").menu({
28+
select: function(event, ui) {
29+
// stop button from handling the click
30+
$(this).popup("close");
31+
notify(ui.item);
32+
}
33+
}).popup();
34+
1735
$("button").each(function() {
1836
$(this).button({
1937
icons: {
2038
primary: $(this).data("icon")
2139
},
2240
text: !!$(this).attr("title")
41+
}).click(function() {
42+
// TODO don't notify if the button is opening a popup
43+
notify(this);
2344
});
2445
});
25-
$(".set").buttonset();
26-
27-
$("ul").menu({
28-
select: function() {
29-
// would also execute some other action here
30-
$(this).popup("close");
31-
}
32-
}).popup({
33-
trigger: $(".menu")
46+
$(".set").buttonset({
47+
items: "button"
3448
});
3549

50+
3651
$(".demo").tooltip({
3752
position: {
3853
my: "center top",
@@ -57,6 +72,10 @@
5772
background: rgba(20, 20, 20, 1);
5873
color: white;
5974
}
75+
76+
.set { display: inline-block; }
77+
78+
.notification { position: absolute; display: inline-block; font-size: 2em; padding: 1em; border-radius: 15px; box-shadow: 2px 2px 5px -2px rgba(0,0,0,0.5); }
6079
</style>
6180
</head>
6281
<body>
@@ -69,23 +88,23 @@
6988
<button data-icon="ui-icon-circle-arrow-n" title="I like this">Like</button>
7089
<button data-icon="ui-icon-circle-arrow-s">I dislike this</button>
7190
</span>
72-
<span class="set">
91+
<div class="set">
7392
<button data-icon="ui-icon-circle-plus" title="Add to Watch Later">Add to</button>
7493
<button class="menu" data-icon="ui-icon-triangle-1-s">Add to favorites or playlist</button>
75-
</span>
94+
<ul>
95+
<li>
96+
<a href="#">Favorites</a>
97+
</li>
98+
<li>
99+
<a href="#">Watch Later</a>
100+
</li>
101+
<li>
102+
<a href="#">New Playlist...</a>
103+
</li>
104+
</ul>
105+
</div>
76106
<button title="Share this video">Share</button>
77107
<button data-icon="ui-icon-alert">Flag as inappropiate</button>
78-
<ul>
79-
<li>
80-
<a href="#">Favorites</a>
81-
</li>
82-
<li>
83-
<a href="#">Watch Later</a>
84-
</li>
85-
<li>
86-
<a href="#">New Playlist...</a>
87-
</li>
88-
</ul>
89108
</div>
90109
</div>
91110

tests/visual/menu/popup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ $.widget( "ui.popup", {
4343
if (event.keyCode == $.ui.keyCode.SPACE) {
4444
event.preventDefault()
4545
}
46+
// TODO handle keydown to open popup?
47+
//if (event.keyCode == $.ui.keyCode.SPACE) { .. }
4648
},
4749
click: function( event ) {
4850
event.preventDefault();

0 commit comments

Comments
 (0)