Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added utils.events.dispatch #62

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ make-rollups.sh
tmp
.build.properties
download

*.swp
10 changes: 5 additions & 5 deletions demo/bar-ui/css/bar-ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -549,25 +549,25 @@
background-image: none, url(../image/icomoon/entypo-25px-000000/SVG/volume.svg);
}

.menu {
.sm2-menu-button {
background-image: url(../image/icomoon/entypo-25px-ffffff/PNG/list2.png);
background-image: none, url(../image/icomoon/entypo-25px-ffffff/SVG/list2.svg);
background-size: 58%;
background-position: 54% 51%;
}

.previous {
.sm2-previous {
background-image: url(../image/icomoon/entypo-25px-ffffff/PNG/first.png);
background-image: none, url(../image/icomoon/entypo-25px-ffffff/SVG/first.svg);
}

.next {
.sm2-next {
background-image: url(../image/icomoon/entypo-25px-ffffff/PNG/last.png);
background-image: none, url(../image/icomoon/entypo-25px-ffffff/SVG/last.svg);
}

.previous,
.next {
.sm2-previous,
.sm2-next {
background-size: 49.5%;
background-position: 50% 50%;
}
Expand Down
17 changes: 15 additions & 2 deletions demo/bar-ui/script/bar-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,15 @@

events: (function() {

var add, remove, preventDefault;
var dispatch, add, remove, preventDefault;

dispatch = function(evtName) {
// create new event with the name we give
var event = new Event(evtName);

// Dispatch the event.
return window.dispatchEvent(event);
};

add = function(o, evtName, evtHandler) {
// return an object with a convenient detach method.
Expand Down Expand Up @@ -326,6 +334,7 @@
};

return {
dispatch: dispatch,
add: add,
preventDefault: preventDefault,
remove: remove
Expand Down Expand Up @@ -809,6 +818,8 @@
// if this is an <li> with an inner link, grab and use the text from that.
var links = item.getElementsByTagName('a');

utils.events.dispatch('sm2-bar-ui-setTitle');

if (links.length) {
item = links[0];
}
Expand Down Expand Up @@ -1462,6 +1473,8 @@
// playlist
dom.playlistContainer.style.height = (isOpen ? dom.playlistContainer.scrollHeight : 0) + 'px';

utils.events.dispatch('sm2-bar-ui-menu');

},

adjustVolume: function(e) {
Expand Down Expand Up @@ -1596,4 +1609,4 @@
window.sm2BarPlayers = players;
window.SM2BarPlayer = Player;

}(window));
}(window));