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

Update for jQuery 3 changes. #422

Open
wants to merge 2 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
22 changes: 11 additions & 11 deletions src/javascript/add-on/jplayer.playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@
};

// Create a ready event handler to initialize the playlist
$(this.cssSelector.jPlayer).bind($.jPlayer.event.ready, function() {
$(this.cssSelector.jPlayer).on($.jPlayer.event.ready, function() {
self._init();
});

// Create an ended event handler to move to the next item
$(this.cssSelector.jPlayer).bind($.jPlayer.event.ended, function() {
$(this.cssSelector.jPlayer).on($.jPlayer.event.ended, function() {
self.next();
});

// Create a play event handler to pause other instances
$(this.cssSelector.jPlayer).bind($.jPlayer.event.play, function() {
$(this.cssSelector.jPlayer).on($.jPlayer.event.play, function() {
$(this).jPlayer("pauseOthers");
});

// Create a resize event handler to show the title in full screen mode.
$(this.cssSelector.jPlayer).bind($.jPlayer.event.resize, function(event) {
$(this.cssSelector.jPlayer).on($.jPlayer.event.resize, function(event) {
if(event.jPlayer.options.fullScreen) {
$(self.cssSelector.details).show();
} else {
Expand All @@ -100,19 +100,19 @@
});

// Create click handlers for the extra buttons that do playlist functions.
$(this.cssSelector.previous).click(function(e) {
$(this.cssSelector.previous).on('click', function(e) {
e.preventDefault();
self.previous();
self.blur(this);
});

$(this.cssSelector.next).click(function(e) {
$(this.cssSelector.next).on('click', function(e) {
e.preventDefault();
self.next();
self.blur(this);
});

$(this.cssSelector.shuffle).click(function(e) {
$(this.cssSelector.shuffle).on('click', function(e) {
e.preventDefault();
if(self.shuffled && $(self.cssSelector.jPlayer).jPlayer("option", "useStateClassSkin")) {
self.shuffle(false);
Expand All @@ -121,7 +121,7 @@
}
self.blur(this);
});
$(this.cssSelector.shuffleOff).click(function(e) {
$(this.cssSelector.shuffleOff).on('click', function(e) {
e.preventDefault();
self.shuffle(false);
self.blur(this);
Expand Down Expand Up @@ -229,7 +229,7 @@
$(this.cssSelector.playlist + " ul").slideUp(displayTime, function() {
var $this = $(this);
$(this).empty();

$.each(self.playlist, function(i) {
$this.append(self._createListItem(self.playlist[i]));
});
Expand Down Expand Up @@ -294,7 +294,7 @@
// Create live handlers that disable free media links to force access via right click
$(this.cssSelector.playlist).off("click", "a." + this.options.playlistOptions.freeItemClass).on("click", "a." + this.options.playlistOptions.freeItemClass, function(e) {
e.preventDefault();
$(this).parent().parent().find("." + self.options.playlistOptions.itemClass).click();
$(this).parent().parent().find("." + self.options.playlistOptions.itemClass).trigger('click');
self.blur(this);
});

Expand Down Expand Up @@ -489,7 +489,7 @@
},
blur: function(that) {
if($(this.cssSelector.jPlayer).jPlayer("option", "autoBlur")) {
$(that).blur();
$(that).trigger('blur');
}
}
};
Expand Down
56 changes: 28 additions & 28 deletions src/javascript/add-on/jquery.jplayer.inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
idPrefix: "jplayer_inspector_",
visible: false
};

var methods = {
init: function(options) {
var self = this;
var $this = $(this);

var config = $.extend({}, $.jPlayerInspector.defaults, options);
$(this).data("jPlayerInspector", config);

Expand All @@ -42,30 +42,30 @@
config.eventResetId = config.idPrefix + "event_reset_" + $.jPlayerInspector.i;
config.updateId = config.idPrefix + "update_" + $.jPlayerInspector.i;
config.eventWindowId = config.idPrefix + "event_window_" + $.jPlayerInspector.i;

config.eventId = {};
config.eventJq = {};
config.eventTimeout = {};
config.eventOccurrence = {};

$.each($.jPlayer.event, function(eventName,eventType) {
config.eventId[eventType] = config.idPrefix + "event_" + eventName + "_" + $.jPlayerInspector.i;
config.eventOccurrence[eventType] = 0;
});
var structure =
'<p><a href="#" id="' + config.toggleId + '">' + (config.visible ? "Hide" : "Show") + '</a> jPlayer Inspector</p>'

var structure =
'<p><a href="#" id="' + config.toggleId + '">' + (config.visible ? "Hide" : "Show") + '</a> jPlayer Inspector</p>'
+ '<div id="' + config.windowId + '">'
+ '<div id="' + config.statusId + '"></div>'
+ '<div id="' + config.eventWindowId + '" style="padding:5px 5px 0 5px;background-color:#eee;border:1px dotted #000;">'
+ '<p style="margin:0 0 10px 0;"><strong>jPlayer events that have occurred over the past 1 second:</strong>'
+ '<br />(Backgrounds: <span style="padding:0 5px;background-color:#eee;border:1px dotted #000;">Never occurred</span> <span style="padding:0 5px;background-color:#fff;border:1px dotted #000;">Occurred before</span> <span style="padding:0 5px;background-color:#9f9;border:1px dotted #000;">Occurred</span> <span style="padding:0 5px;background-color:#ff9;border:1px dotted #000;">Multiple occurrences</span> <a href="#" id="' + config.eventResetId + '">reset</a>)</p>';

// MJP: Would use the next 3 lines for ease, but the events are just slapped on the page.
// $.each($.jPlayer.event, function(eventName,eventType) {
// structure += '<div id="' + config.eventId[eventType] + '" style="float:left;">' + eventName + '</div>';
// });

var eventStyle = "float:left;margin:0 5px 5px 0;padding:0 5px;border:1px dotted #000;";
// MJP: Doing it longhand so order and layout easier to control.
structure +=
Expand Down Expand Up @@ -120,7 +120,7 @@
+ '<div id="' + config.configId + '"></div>'
+ '</div>';
$(this).html(structure);

config.windowJq = $("#" + config.windowId);
config.statusJq = $("#" + config.statusId);
config.configJq = $("#" + config.configId);
Expand All @@ -131,8 +131,8 @@
$.each($.jPlayer.event, function(eventName,eventType) {
config.eventJq[eventType] = $("#" + config.eventId[eventType]);
config.eventJq[eventType].text(eventName + " (" + config.eventOccurrence[eventType] + ")"); // Sets the text to the event name and (0);
config.jPlayer.bind(eventType + ".jPlayerInspector", function(e) {

config.jPlayer.on(eventType + ".jPlayerInspector", function(e) {
config.eventOccurrence[e.type]++;
if(config.eventOccurrence[e.type] > 1) {
config.eventJq[e.type].css("background-color","#ff9");
Expand All @@ -156,7 +156,7 @@
});
});

config.jPlayer.bind($.jPlayer.event.ready + ".jPlayerInspector", function(e) {
config.jPlayer.on($.jPlayer.event.ready + ".jPlayerInspector", function(e) {
$this.jPlayerInspector("updateConfig");
});

Expand All @@ -169,22 +169,22 @@
} else {
$(this).text("Hide");
config.windowJq.show();
config.updateJq.click();
config.updateJq.trigger('click');
}
config.visible = !config.visible;
$(this).blur();
$(this).trigger('blur');
return false;
});

config.eventResetJq.click(function() {
config.eventResetJq.on('click', function() {
$.each($.jPlayer.event, function(eventName,eventType) {
config.eventJq[eventType].css("background-color","#eee");
});
$(this).blur();
$(this).trigger('blur');
return false;
});

config.updateJq.click(function() {
config.updateJq.on('click', function() {
$this.jPlayerInspector("updateStatus");
$this.jPlayerInspector("updateConfig");
return false;
Expand All @@ -195,22 +195,22 @@
} else {
// config.updateJq.click();
}

$.jPlayerInspector.i++;

return this;
},
destroy: function() {
$(this).data("jPlayerInspector") && $(this).data("jPlayerInspector").jPlayer.unbind(".jPlayerInspector");
$(this).data("jPlayerInspector") && $(this).data("jPlayerInspector").jPlayer.off(".jPlayerInspector");
$(this).empty();
},
updateConfig: function() { // This displays information about jPlayer's configuration in inspector

var jPlayerInfo = "<p>This jPlayer instance is running in your browser where:<br />"

for(i = 0; i < $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions.length; i++) {
var solution = $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions[i];
jPlayerInfo += "&nbsp;jPlayer's <strong>" + solution + "</strong> solution is";
jPlayerInfo += "&nbsp;jPlayer's <strong>" + solution + "</strong> solution is";
if($(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].used) {
jPlayerInfo += " being <strong>used</strong> and will support:<strong>";
for(format in $(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].support) {
Expand Down Expand Up @@ -247,7 +247,7 @@
} else {
jPlayerInfo += "</p>";
}

jPlayerInfo += "<p><code>status.src = '" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.src + "'</code></p>";

jPlayerInfo += "<p><code>status.media = {<br />";
Expand Down Expand Up @@ -282,9 +282,9 @@
+ "&nbsp;supplied: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "supplied") + "',<br />"

+ "&nbsp;preload: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "preload") + "',<br />"

+ "&nbsp;volume: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "volume") + ",<br />"

+ "&nbsp;muted: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "muted") + ",<br />"

+ "&nbsp;backgroundColor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "backgroundColor") + "',<br />"
Expand All @@ -295,7 +295,7 @@

var cssSelector = $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector");
for(prop in cssSelector) {

// jPlayerInfo += "<br />&nbsp;&nbsp;" + prop + ": '" + cssSelector[prop] + "'," // This works too of course, but want to use option method for deep keys.
jPlayerInfo += "<br />&nbsp;&nbsp;" + prop + ": '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector." + prop) + "',"
}
Expand All @@ -305,7 +305,7 @@
jPlayerInfo += "<br />&nbsp;},<br />"

+ "&nbsp;errorAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "errorAlerts") + ",<br />"

+ "&nbsp;warningAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "warningAlerts") + "<br />"

+ "});</code></p>";
Expand Down Expand Up @@ -333,6 +333,6 @@
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.jPlayerInspector' );
}
}
};
})(jQuery);
Loading