diff --git a/src/css/video-js.css b/src/css/video-js.css index 0dc2b9ad0..2bed570d8 100644 --- a/src/css/video-js.css +++ b/src/css/video-js.css @@ -102,6 +102,12 @@ body.vjs-full-window { /* Hide disabled or unsupported controls */ .vjs-default-skin .vjs-hidden { display: none; } +.vjs-lock-showing { + display: block !important; + opacity: 1; + visibility: visible; +} + /* DEFAULT SKIN (override in another file to create new skins) ================================================================================ Instead of editing this file, I recommend creating your own skin CSS file to be included after this file, diff --git a/src/js/component.js b/src/js/component.js index caf86562f..ac6f98588 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -545,10 +545,7 @@ vjs.Component.prototype.fadeOut = function(){ * @return {vjs.Component} */ vjs.Component.prototype.lockShowing = function(){ - var style = this.el_.style; - style.display = 'block'; - style.opacity = 1; - style.visibility = 'visible'; + this.addClass('vjs-lock-showing'); return this; }; @@ -557,10 +554,7 @@ vjs.Component.prototype.lockShowing = function(){ * @return {vjs.Component} */ vjs.Component.prototype.unlockShowing = function(){ - var style = this.el_.style; - style.display = ''; - style.opacity = ''; - style.visibility = ''; + this.removeClass('vjs-lock-showing'); return this; }; diff --git a/src/js/core-object.js b/src/js/core-object.js index 46484c912..6c30926a8 100644 --- a/src/js/core-object.js +++ b/src/js/core-object.js @@ -22,7 +22,8 @@ vjs.CoreObject.extend = function(props){ props = props || {}; // Set up the constructor using the supplied init method // or using the init of the parent object - init = props.init || this.prototype.init || function(){}; + // Make sure to check the unobfuscated version for external libs + init = props['init'] || props.init || this.prototype['init'] || this.prototype.init || function(){}; // In Resig's simple class inheritance (previously used) the constructor // is a function that calls `this.init.apply(arguments)` // However that would prevent us from using `ParentObject.call(this);` diff --git a/src/js/core.js b/src/js/core.js index ffb0c1a62..59ab8fe85 100644 --- a/src/js/core.js +++ b/src/js/core.js @@ -52,6 +52,7 @@ var vjs = function(id, options, ready){ // Extended name, also available externally, window.videojs var videojs = vjs; +window.videojs = window.vjs = vjs; // CDN Version. Used to target right flash swf. vjs.CDN_VERSION = 'GENERATED_CDN_VSN'; diff --git a/src/js/events.js b/src/js/events.js index c160b0b3e..8933b867f 100644 --- a/src/js/events.js +++ b/src/js/events.js @@ -189,6 +189,9 @@ vjs.fixEvent = function(event) { // Stop the default browser action event.preventDefault = function () { + if (old.preventDefault) { + old.preventDefault(); + } event.returnValue = false; event.isDefaultPrevented = returnTrue; }; @@ -197,6 +200,9 @@ vjs.fixEvent = function(event) { // Stop the event from bubbling event.stopPropagation = function () { + if (old.stopPropagation) { + old.stopPropagation(); + } event.cancelBubble = true; event.isPropagationStopped = returnTrue; }; @@ -205,6 +211,9 @@ vjs.fixEvent = function(event) { // Stop the event from bubbling and executing other handlers event.stopImmediatePropagation = function () { + if (old.stopImmediatePropagation) { + old.stopImmediatePropagation(); + } event.isImmediatePropagationStopped = returnTrue; event.stopPropagation(); }; diff --git a/src/js/media.html5.js b/src/js/media.html5.js index 76cfabf0a..7e6aa14b4 100644 --- a/src/js/media.html5.js +++ b/src/js/media.html5.js @@ -12,15 +12,15 @@ vjs.Html5 = vjs.MediaTechController.extend({ /** @constructor */ init: function(player, options, ready){ + // volume cannot be changed from 1 on iOS + this.features.volumeControl = vjs.Html5.canControlVolume(); + + // In iOS, if you move a video element in the DOM, it breaks video playback. + this.features.movingMediaElementInDOM = !vjs.IS_IOS; + vjs.MediaTechController.call(this, player, options, ready); - // volume cannot be changed from 1 on iOS - this.features.volumeControl = vjs.Html5.canControlVolume(); - - // In iOS, if you move a video element in the DOM, it breaks video playback. - this.features.movingMediaElementInDOM = !vjs.IS_IOS; - - var source = options['source']; + var source = options['source']; // If the element source is already set, we may have missed the loadstart event, and want to trigger it. // We don't want to set the source again and interrupt playback. diff --git a/src/js/setup.js b/src/js/setup.js index ddb7eefc4..9a89e62a8 100644 --- a/src/js/setup.js +++ b/src/js/setup.js @@ -58,4 +58,5 @@ vjs.one(window, 'load', function(){ }); // Run Auto-load players -vjs.autoSetup(); +// You have to wait at least once in case this script is loaded after your video in the DOM (weird behavior only with minified version) +vjs.autoSetupTimeout(1); diff --git a/src/js/slider.js b/src/js/slider.js index 2f8304ee3..bda8180d8 100644 --- a/src/js/slider.js +++ b/src/js/slider.js @@ -135,9 +135,7 @@ vjs.Slider.prototype.calculateDistance = function(event){ boxW = boxW - handleW; } - // This is done because on Android, event.pageX is always 0 and the actual - // values live under the changedTouches array. - if (pageX === 0 && event.changedTouches) { + if (event.changedTouches) { pageX = event.changedTouches[0].pageX; } @@ -161,4 +159,4 @@ vjs.Slider.prototype.onKeyPress = function(event){ vjs.Slider.prototype.onBlur = function(){ vjs.off(document, 'keyup', vjs.bind(this, this.onKeyPress)); -}; \ No newline at end of file +}; diff --git a/test/unit/controls.js b/test/unit/controls.js index 97de11c20..5b58fa738 100644 --- a/test/unit/controls.js +++ b/test/unit/controls.js @@ -75,3 +75,27 @@ test('should test and toggle volume control on `loadstart`', function(){ ok(muteToggle.el().className.indexOf('vjs-hidden') < 0, 'muteToggle does not show itself'); }); + +test('calculateDistance should use changedTouches, if available', function() { + var noop, player, slider, event; + noop = function(){}; + player = { + id: noop, + on: noop, + ready: noop + }; + slider = new vjs.Slider(player); + document.body.appendChild(slider.el_); + slider.el_.style.position = 'absolute'; + slider.el_.style.width = '200px'; + slider.el_.style.left = '0px'; + + event = { + pageX: 10, + changedTouches: [{ + pageX: 100 + }] + }; + + equal(slider.calculateDistance(event), 0.5, 'we should have touched exactly in the center, so, the ratio should be half'); +});