<commit_before>(function (mw, $) {
	"use strict";

	mw.PluginManager.add('playlistAPI', mw.KBaseMediaList.extend({

		defaultConfig: {
			'templatePath': 'components/playlist/playList.tmpl.html',
			'initItemEntryId': null,
			'autoContinue': false,
			'autoPlay': false,
			'kpl0Name': null,
			'kpl0Url': null,
			'kpl0Id': null,
			'titleLimit': 36,
			'descriptionLimit': 32,
			'resizeThumbnails': true,
			'thumbnailWidth': 86,
			'thumbnailHeight': 48,
			'mediaItemWidth': null,
			'mediaItemHeight': 70,
			'includeThumbnail': true,
			'includeItemNumberPattern': false,
			'includeMediaItemDuration': true,
			'horizontalHeaderHeight': 43,
			'verticalHeaderHeight': 65,
			'hideClipPoster': true,
			'loop': false,
			'overflow': false,
			'cssFileName': 'modules/KalturaSupport/components/playlist/playList.css',
			'showControls': true,
			'MinClips': 2,
			'MaxClips': 25,
			'selectedIndex': 0,
			'includeHeader': true,
			'renderWhenEmpty': false,
			'paging': false,
			'pageSize': 25,
			'showEmptyPlaylistError': true
		},


		loadingEntry: null,      // flag to store the current loading entry
		firstLoad: true,         // Flag for setting initial entry in first load
		kClient: null,           // kClient for API calls
		firstPlay: true,         // firstPlay is used to check if we need to check for autoMute or keep the player volume from previous clip

		currentClipIndex: null,  // currently playing clip index
		currentPlaylistIndex: 0, // current playlist index (when we have more than 1 play lists)
		playlistSet: [],        // array holding all the play lists returned from the server

		videoWidth: null,        // used to save the video width when exiting to full screen and returning
		minClips: null,          // saves the MinClips Flashvar when we switch playlists
		multiplePlayListsReady: false, //Indicate if multiplaylist selector is ready
		playerIsReady: false,
		redrawOnResize: true,
		widthSetByUser: true,    // assuming the user specified the required playlist width. Will be changed if needed in the setup function
		page: 1,                 // start page for paging
		pagingInProgress: false, // flag to block paging call during previous paging
		pagingDone: false,       // flag for when there are no more entries in the next page so no need to load it
		playlistInterfaceHeight: null,

		setup: function (embedPlayer) {
			if ( $(".playlistInterface").length === 0 ){
				$(".mwPlayerContainer").wrap('<div class="playlistInterface" style="position: relative; width: 100%; height: 100%"></div>');
			}
			this.playlistInterfaceHeight = $(".playlistInterface").height();
			if (this.getConfig('includeInLayout') === false) { // support hidden playlists - force onPage and hide its div.
				this.setConfig('onPage', true);
			}
			this.minClips = parseInt(this.getConfig('MinClips'));
			//Backward compatibility setting - set autoplay on embedPlayer instead of playlist
			this.getPlayer().autoplay = (this.getConfig('autoPlay') == true);
			mw.setConfig("autoPlay", this.getPlayer().autoplay);

			if ( !this.getConfig( 'mediaItemWidth') ){
				this.widthSetByUser = false;           // user did not specify a required width. We will set to 320 and apply responsive logic on resizeEvent event
				if ( this.getLayout() === "horizontal" ){
					var width = this.getConfig("fixedControls") ? $( ".playlistInterface" ).width() - this.getConfig("horizontalControlsWidth")*2 : $( ".playlistInterface" ).width();
					this.setConfig( 'mediaItemWidth', Math.floor(width / this.getConfig("MinClips")) );
				}else{
					this.setConfig( 'mediaItemWidth',320); // set default width to 320 if not defined by user
				}
			}

			if (!this.getConfig("includeHeader")){
				this.setConfig('horizontalHeaderHeight', 0);
				this.setConfig('verticalHeaderHeight', 0);
			}
			this.embedPlayer.playlist = true;
			this.addBindings();
			this.loadPlaylists();
			if ( this.getConfig("renderWhenEmpty") ){
				this.getComponent();
			}
		},
		addBindings: function () {
			var _this = this;

			$(this.embedPlayer).unbind(this.bindPostFix);
			this.bind('playerReady', function (e, newState) {
				_this.playerIsReady = true;
				if (_this.playlistSet.length > 0) {
					_this.selectPlaylist(_this.currentPlaylistIndex);
					//Revert block player display after selecting playlist entry
					_this.getPlayer()['data-blockPlayerDisplay'] = false;
				}

				// prevent iframe resize layout refresh  on iOS8
				if ( mw.isIOS8_9() ){
					_this.redrawOnResize = false;
				}

				_this.unbind('playerReady'); // we want to select the playlist only the first time the player loads
			});

			this.bind('mediaError', function (e) {
				_this.loadingEntry = null; // reset loadingEntry if we got a media error (also media loading error will trigger this event)
				_this.onEnable();
			});

			this.bind('updateLayout', function () {
				if (_this.firstLoad){
					_this.redrawPlaylist();
				}
			});

			// API support + backward compatibility
			$(this.embedPlayer).bind('Kaltura_SetKDPAttribute' + this.bindPostFix, function (event, componentName, property, value) {
				mw.log("PlaylistAPI::Kaltura_SetKDPAttribute:" + property + ' value:' + value);
				switch (componentName) {
					case "playlistAPI.dataProvider":
					case "playlistAPI":
						if (property == "selectedIndex") {
							_this.playMedia(value);
						}
						break;
					case 'tabBar':
					case 'playList':
						if (property == "selectedIndex" && value < _this.playlistSet.length) {
							_this.switchPlaylist(value);
						}
						break;
				}
			});

			$(this.embedPlayer).bind('Kaltura_SendNotification' + this.bindPostFix, function (event, notificationName, notificationData) {
				switch (notificationName) {
					case 'playlistPlayNext':
						_this.playNext();
						break;
					case 'playlistPlayPrevious':
						_this.playPrevious();
						break;
				}
			});

			$(this.embedPlayer).bind('playNextClip', function (event) {
				_this.playNext(true);
			});

			$(this.embedPlayer).bind('playPreviousClip', function (event) {
				_this.playPrevious(true);
			});

			$( this.embedPlayer ).bind('onOpenFullScreen', function() {
				_this.redrawOnResize = false;
				clearTimeout(window.redrawTimeOutID);
			});

			$( this.embedPlayer ).bind('onCloseFullScreen', function() {
				window.redrawTimeOutID = setTimeout(function(){_this.redrawOnResize = true;},2000);
			});

			$( this.embedPlayer ).bind("scrollEnd", function(){
				if ( _this.getConfig('paging') ===  true && !_this.pagingDone && !_this.pagingInProgress ){
					_this.pagingInProgress = true;
					_this.page++; // move to next page
					mw.log("Playlist:: scrollEnd event. paging: true: trying to load next playlist page: page="+_this.page+", pageSize"+_this.getConfig('pageSize'));

					var playlistRequest;
					if (_this.playlistSet[_this.currentPlaylistIndex].playlistParams) {
						// use saved params and extend them with paging params
						playlistRequest = $.extend(_this.playlistSet[_this.currentPlaylistIndex].playlistParams, {
							'pager:objectType': 'KalturaFilterPager',
							'pager:pageIndex': _this.page,
							'pager:pageSize': _this.getConfig('pageSize')<commit_msg>FEC-4596 #comment return playlist height to 100% when entering full screen<commit_after>(function (mw, $) {
	"use strict";

	mw.PluginManager.add('playlistAPI', mw.KBaseMediaList.extend({

		defaultConfig: {
			'templatePath': 'components/playlist/playList.tmpl.html',
			'initItemEntryId': null,
			'autoContinue': false,
			'autoPlay': false,
			'kpl0Name': null,
			'kpl0Url': null,
			'kpl0Id': null,
			'titleLimit': 36,
			'descriptionLimit': 32,
			'resizeThumbnails': true,
			'thumbnailWidth': 86,
			'thumbnailHeight': 48,
			'mediaItemWidth': null,
			'mediaItemHeight': 70,
			'includeThumbnail': true,
			'includeItemNumberPattern': false,
			'includeMediaItemDuration': true,
			'horizontalHeaderHeight': 43,
			'verticalHeaderHeight': 65,
			'hideClipPoster': true,
			'loop': false,
			'overflow': false,
			'cssFileName': 'modules/KalturaSupport/components/playlist/playList.css',
			'showControls': true,
			'MinClips': 2,
			'MaxClips': 25,
			'selectedIndex': 0,
			'includeHeader': true,
			'renderWhenEmpty': false,
			'paging': false,
			'pageSize': 25,
			'showEmptyPlaylistError': true
		},


		loadingEntry: null,      // flag to store the current loading entry
		firstLoad: true,         // Flag for setting initial entry in first load
		kClient: null,           // kClient for API calls
		firstPlay: true,         // firstPlay is used to check if we need to check for autoMute or keep the player volume from previous clip

		currentClipIndex: null,  // currently playing clip index
		currentPlaylistIndex: 0, // current playlist index (when we have more than 1 play lists)
		playlistSet: [],        // array holding all the play lists returned from the server

		videoWidth: null,        // used to save the video width when exiting to full screen and returning
		minClips: null,          // saves the MinClips Flashvar when we switch playlists
		multiplePlayListsReady: false, //Indicate if multiplaylist selector is ready
		playerIsReady: false,
		redrawOnResize: true,
		widthSetByUser: true,    // assuming the user specified the required playlist width. Will be changed if needed in the setup function
		page: 1,                 // start page for paging
		pagingInProgress: false, // flag to block paging call during previous paging
		pagingDone: false,       // flag for when there are no more entries in the next page so no need to load it
		playlistInterfaceHeight: null,

		setup: function (embedPlayer) {
			if ( $(".playlistInterface").length === 0 ){
				$(".mwPlayerContainer").wrap('<div class="playlistInterface" style="position: relative; width: 100%; height: 100%"></div>');
			}
			this.playlistInterfaceHeight = $(".playlistInterface").height();
			if (this.getConfig('includeInLayout') === false) { // support hidden playlists - force onPage and hide its div.
				this.setConfig('onPage', true);
			}
			this.minClips = parseInt(this.getConfig('MinClips'));
			//Backward compatibility setting - set autoplay on embedPlayer instead of playlist
			this.getPlayer().autoplay = (this.getConfig('autoPlay') == true);
			mw.setConfig("autoPlay", this.getPlayer().autoplay);

			if ( !this.getConfig( 'mediaItemWidth') ){
				this.widthSetByUser = false;           // user did not specify a required width. We will set to 320 and apply responsive logic on resizeEvent event
				if ( this.getLayout() === "horizontal" ){
					var width = this.getConfig("fixedControls") ? $( ".playlistInterface" ).width() - this.getConfig("horizontalControlsWidth")*2 : $( ".playlistInterface" ).width();
					this.setConfig( 'mediaItemWidth', Math.floor(width / this.getConfig("MinClips")) );
				}else{
					this.setConfig( 'mediaItemWidth',320); // set default width to 320 if not defined by user
				}
			}

			if (!this.getConfig("includeHeader")){
				this.setConfig('horizontalHeaderHeight', 0);
				this.setConfig('verticalHeaderHeight', 0);
			}
			this.embedPlayer.playlist = true;
			this.addBindings();
			this.loadPlaylists();
			if ( this.getConfig("renderWhenEmpty") ){
				this.getComponent();
			}
		},
		addBindings: function () {
			var _this = this;

			$(this.embedPlayer).unbind(this.bindPostFix);
			this.bind('playerReady', function (e, newState) {
				_this.playerIsReady = true;
				if (_this.playlistSet.length > 0) {
					_this.selectPlaylist(_this.currentPlaylistIndex);
					//Revert block player display after selecting playlist entry
					_this.getPlayer()['data-blockPlayerDisplay'] = false;
				}

				// prevent iframe resize layout refresh  on iOS8
				if ( mw.isIOS8_9() ){
					_this.redrawOnResize = false;
				}

				_this.unbind('playerReady'); // we want to select the playlist only the first time the player loads
			});

			this.bind('mediaError', function (e) {
				_this.loadingEntry = null; // reset loadingEntry if we got a media error (also media loading error will trigger this event)
				_this.onEnable();
			});

			this.bind('updateLayout', function () {
				if (_this.firstLoad){
					_this.redrawPlaylist();
				}
			});

			// API support + backward compatibility
			$(this.embedPlayer).bind('Kaltura_SetKDPAttribute' + this.bindPostFix, function (event, componentName, property, value) {
				mw.log("PlaylistAPI::Kaltura_SetKDPAttribute:" + property + ' value:' + value);
				switch (componentName) {
					case "playlistAPI.dataProvider":
					case "playlistAPI":
						if (property == "selectedIndex") {
							_this.playMedia(value);
						}
						break;
					case 'tabBar':
					case 'playList':
						if (property == "selectedIndex" && value < _this.playlistSet.length) {
							_this.switchPlaylist(value);
						}
						break;
				}
			});

			$(this.embedPlayer).bind('Kaltura_SendNotification' + this.bindPostFix, function (event, notificationName, notificationData) {
				switch (notificationName) {
					case 'playlistPlayNext':
						_this.playNext();
						break;
					case 'playlistPlayPrevious':
						_this.playPrevious();
						break;
				}
			});

			$(this.embedPlayer).bind('playNextClip', function (event) {
				_this.playNext(true);
			});

			$(this.embedPlayer).bind('playPreviousClip', function (event) {
				_this.playPrevious(true);
			});

			$( this.embedPlayer ).bind('onOpenFullScreen', function() {
				$( ".playlistInterface").height("100%");
				_this.redrawOnResize = false;
				clearTimeout(window.redrawTimeOutID);
			});

			$( this.embedPlayer ).bind('onCloseFullScreen', function() {
				window.redrawTimeOutID = setTimeout(function(){_this.redrawOnResize = true;},2000);
			});

			$( this.embedPlayer ).bind("scrollEnd", function(){
				if ( _this.getConfig('paging') ===  true && !_this.pagingDone && !_this.pagingInProgress ){
					_this.pagingInProgress = true;
					_this.page++; // move to next page
					mw.log("Playlist:: scrollEnd event. paging: true: trying to load next playlist page: page="+_this.page+", pageSize"+_this.getConfig('pageSize'));

					var playlistRequest;
					if (_this.playlistSet[_this.currentPlaylistIndex].playlistParams) {
						// use saved params and extend them with paging params
						playlistRequest = $.extend(_this.playlistSet[_this.currentPlaylistIndex].playlistParams, {
							'pager:objectType': 'KalturaFilterPager',
							'pager:pageIndex': _this.page,
							'pager:pageSize': _this.getConfig('pageSize')
{'fraction_non_alphanumeric': 0.13027827772393744, 'fraction_numerical': 0.00802990447182611, 'mean_word_length': 3.5921805467260013, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4662410', 'n_tokens_mistral': 5297, 'n_tokens_neox': 4310, 'n_words': 1118}