equal
deleted
inserted
replaced
1 /*globals window, document, jQuery, _, Backbone, _wpmejsSettings */ |
1 /* global _wpmejsSettings, MediaElementPlayer */ |
2 |
2 |
3 (function ($, _, Backbone) { |
3 (function ($, _, Backbone) { |
4 "use strict"; |
4 'use strict'; |
|
5 |
|
6 /** @namespace wp */ |
|
7 window.wp = window.wp || {}; |
5 |
8 |
6 var WPPlaylistView = Backbone.View.extend({ |
9 var WPPlaylistView = Backbone.View.extend({ |
7 initialize : function (options) { |
10 initialize : function (options) { |
8 this.index = 0; |
11 this.index = 0; |
9 this.settings = {}; |
12 this.settings = {}; |
29 this.playerNode.attr( 'src', this.current.get( 'src' ) ); |
32 this.playerNode.attr( 'src', this.current.get( 'src' ) ); |
30 |
33 |
31 _.bindAll( this, 'bindPlayer', 'bindResetPlayer', 'setPlayer', 'ended', 'clickTrack' ); |
34 _.bindAll( this, 'bindPlayer', 'bindResetPlayer', 'setPlayer', 'ended', 'clickTrack' ); |
32 |
35 |
33 if ( ! _.isUndefined( window._wpmejsSettings ) ) { |
36 if ( ! _.isUndefined( window._wpmejsSettings ) ) { |
34 this.settings = _wpmejsSettings; |
37 this.settings = _.clone( _wpmejsSettings ); |
35 } |
38 } |
36 this.settings.success = this.bindPlayer; |
39 this.settings.success = this.bindPlayer; |
37 this.setPlayer(); |
40 this.setPlayer(); |
38 }, |
41 }, |
39 |
42 |
162 |
165 |
163 this.loadCurrent(); |
166 this.loadCurrent(); |
164 } |
167 } |
165 }); |
168 }); |
166 |
169 |
167 $(document).ready(function () { |
170 /** |
168 $('.wp-playlist').each( function() { |
171 * Initialize media playlists in the document. |
169 return new WPPlaylistView({ el: this }); |
172 * |
|
173 * Only initializes new playlists not previously-initialized. |
|
174 * |
|
175 * @since 4.9.3 |
|
176 * @returns {void} |
|
177 */ |
|
178 function initialize() { |
|
179 $( '.wp-playlist:not(:has(.mejs-container))' ).each( function() { |
|
180 new WPPlaylistView( { el: this } ); |
170 } ); |
181 } ); |
171 }); |
182 } |
|
183 |
|
184 /** |
|
185 * Expose the API publicly on window.wp.playlist. |
|
186 * |
|
187 * @namespace wp.playlist |
|
188 * @since 4.9.3 |
|
189 * @type {object} |
|
190 */ |
|
191 window.wp.playlist = { |
|
192 initialize: initialize |
|
193 }; |
|
194 |
|
195 $( document ).ready( initialize ); |
172 |
196 |
173 window.WPPlaylistView = WPPlaylistView; |
197 window.WPPlaylistView = WPPlaylistView; |
174 |
198 |
175 }(jQuery, _, Backbone)); |
199 }(jQuery, _, Backbone)); |