<commit_before>/**
 * The Core timed Text interface object
 *
 * handles class mappings for:
 * 	menu display ( jquery.ui themeable )
 * 	timed text loading request
 *  timed text edit requests
 * 	timed text search & seek interface ( version 2 )
 *
 * @author: <NAME>
 *
 */
mw.includeAllModuleMessages();

( function( mw, $ ) {"use strict";

	// Merge in timed text related attributes:
	mw.mergeConfig( 'EmbedPlayer.SourceAttributes', [
  	   'srclang',
  	   'kind',
	   'label'
	]);
	
	/**
	 * Timed Text Object
	 * @param embedPlayer Host player for timedText interfaces
	 */
	mw.TimedText = function( embedPlayer ) {
		return this.init( embedPlayer);
	};
	
	mw.TimedText.prototype = {

		/**
		* Preferences config order is presently:
		* 1) user cookie
		* 2) defaults provided in this config var:
		*/
		config: {
			// Layout for basic "timedText" type can be 'ontop', 'off', 'below'
			'layout' : 'ontop',

			//Set the default local ( should be grabbed from the browser )
			'userLanguage' : 'en',

			//Set the default kind of timedText to display ( un-categorized timed-text is by default "subtitles" )
			'userKind' : 'subtitles'
		},
		
		// The default display mode is 'ontop'
		defaultDisplayMode : 'ontop',
		
		// Save last layout mode
		lastLayout : 'ontop',
		
		// The bind prefix:
		bindPostFix: '.timedText',
		
		// Default options are empty
		options: {},
		
		/**
		 * The list of enabled sources
		 */
		enabledSources: [],

		/**
		 * The current language key
		 */
		currentLangKey : null,

		/**
		 * Stores the last text string per kind to avoid dom checks
		 * for updated text
		 */
		prevText: [],

		/**
		* Text sources ( a set of textSource objects )
		*/
		textSources: [],

		/**
		* Valid "Track" categories
		*/
		validCategoriesKeys: [
			"CC",
			"SUB",
			"TAD",
			"KTV",
			"TIK",
			"AR",
			"NB",
			"META",
			"TRX",
			"LRC",
			"LIN",
			"CUE"
		],

		/**
		 * @constructor
		 * @param {Object} embedPlayer Host player for timedText interfaces
		 */
		init: function( embedPlayer ) {
			var _this = this;
			mw.log("TimedText: init() ");
			this.embedPlayer = embedPlayer;	
			// Load user preferences config:
			var preferenceConfig = $.cookie( 'TimedText.Preferences' );
			if( preferenceConfig !== "false" && preferenceConfig != null ) {
				this.config = JSON.parse(  preferenceConfig );
			}
			// remove any old bindings on change media: 
			$( this.embedPlayer ).bind('onChangeMedia', function(){
				_this.destroy();
			});
			// Remove any old bindings before we add the current bindings: 
			_this.destroy();
			// Add player bindings
			_this.addPlayerBindings();
		},
		destroy: function(){
			// remove any old player bindings; 
			$( this.embedPlayer ).unbind( this.bindPostFix );
			// Clear out enabled sources:
			this.enabledSources = [];
			// Clear out text sources:
			this.textSources = [];
		},
		/**
		 * Add timed text related player bindings
		 * @return
		 */
		addPlayerBindings: function(){
			var _this = this;
			var embedPlayer = this.embedPlayer;
			
			// Check for timed text support:
			_this.addInterface();
			
			$( embedPlayer ).bind( 'monitorEvent' + this.bindPostFix, function() {
				_this.monitor();
			} );

			$( embedPlayer ).bind( 'firstPlay' + this.bindPostFix, function() {
				// Will load and setup timedText sources (if not loaded already loaded )
				_this.setupTextSources();
				// Hide the caption menu if presently displayed
				$( '#textMenuContainer_' + embedPlayer.id ).remove();
			} );
			
			// Resize the timed text font size per window width
			$( embedPlayer ).bind( 'onCloseFullScreen'+ this.bindPostFix + ' onOpenFullScreen'+ this.bindPostFix, function() {
				// Check if we are in fullscreen or not, if so add an additional bottom offset of 
				// double the default bottom padding. 
				var textOffset = _this.embedPlayer.controlBuilder.inFullScreen ? 
						mw.getConfig("TimedText.BottomPadding") * 2 : 
						mw.getConfig("TimedText.BottomPadding");
						
				var textCss = _this.getInterfaceSizeTextCss({<commit_msg>Fixed subtitles remaining on screen after changing media - QC 2417<commit_after>/**
 * The Core timed Text interface object
 *
 * handles class mappings for:
 * 	menu display ( jquery.ui themeable )
 * 	timed text loading request
 *  timed text edit requests
 * 	timed text search & seek interface ( version 2 )
 *
 * @author: <NAME>
 *
 */
mw.includeAllModuleMessages();

( function( mw, $ ) {"use strict";

	// Merge in timed text related attributes:
	mw.mergeConfig( 'EmbedPlayer.SourceAttributes', [
  	   'srclang',
  	   'kind',
	   'label'
	]);
	
	/**
	 * Timed Text Object
	 * @param embedPlayer Host player for timedText interfaces
	 */
	mw.TimedText = function( embedPlayer ) {
		return this.init( embedPlayer);
	};
	
	mw.TimedText.prototype = {

		/**
		* Preferences config order is presently:
		* 1) user cookie
		* 2) defaults provided in this config var:
		*/
		config: {
			// Layout for basic "timedText" type can be 'ontop', 'off', 'below'
			'layout' : 'ontop',

			//Set the default local ( should be grabbed from the browser )
			'userLanguage' : 'en',

			//Set the default kind of timedText to display ( un-categorized timed-text is by default "subtitles" )
			'userKind' : 'subtitles'
		},
		
		// The default display mode is 'ontop'
		defaultDisplayMode : 'ontop',
		
		// Save last layout mode
		lastLayout : 'ontop',
		
		// The bind prefix:
		bindPostFix: '.timedText',
		
		// Default options are empty
		options: {},
		
		/**
		 * The list of enabled sources
		 */
		enabledSources: [],

		/**
		 * The current language key
		 */
		currentLangKey : null,

		/**
		 * Stores the last text string per kind to avoid dom checks
		 * for updated text
		 */
		prevText: [],

		/**
		* Text sources ( a set of textSource objects )
		*/
		textSources: [],

		/**
		* Valid "Track" categories
		*/
		validCategoriesKeys: [
			"CC",
			"SUB",
			"TAD",
			"KTV",
			"TIK",
			"AR",
			"NB",
			"META",
			"TRX",
			"LRC",
			"LIN",
			"CUE"
		],

		/**
		 * @constructor
		 * @param {Object} embedPlayer Host player for timedText interfaces
		 */
		init: function( embedPlayer ) {
			var _this = this;
			mw.log("TimedText: init() ");
			this.embedPlayer = embedPlayer;	
			// Load user preferences config:
			var preferenceConfig = $.cookie( 'TimedText.Preferences' );
			if( preferenceConfig !== "false" && preferenceConfig != null ) {
				this.config = JSON.parse(  preferenceConfig );
			}
			// remove any old bindings on change media: 
			$( this.embedPlayer ).bind( 'onChangeMedia', function(){
				_this.destroy();
			});
			// Remove any old bindings before we add the current bindings: 
			_this.destroy();
			// Add player bindings
			_this.addPlayerBindings();
		},
		destroy: function(){
			// remove any old player bindings; 
			$( this.embedPlayer ).unbind( this.bindPostFix );
			// Clear out enabled sources:
			this.enabledSources = [];
			// Clear out text sources:
			this.textSources = [];
		},
		/**
		 * Add timed text related player bindings
		 * @return
		 */
		addPlayerBindings: function(){
			var _this = this;
			var embedPlayer = this.embedPlayer;
			
			// Check for timed text support:
			_this.addInterface();
			
			$( embedPlayer ).bind( 'monitorEvent' + this.bindPostFix, function() {
				_this.monitor();
			} );

			$( embedPlayer ).bind( 'firstPlay' + this.bindPostFix, function() {
				// Will load and setup timedText sources (if not loaded already loaded )
				_this.setupTextSources();
				// Hide the caption menu if presently displayed
				$( '#textMenuContainer_' + embedPlayer.id ).remove();
			} );
			
			// Re-Initialize when changing media
			$( embedPlayer ).bind( 'onChangeMedia' + this.bindPostFix, function() {
				_this.destroy();
				_this.updateLayout();
				_this.setupTextSources();
				$( '#textMenuContainer_' + embedPlayer.id ).remove();
			} );

			// Resize the timed text font size per window width
			$( embedPlayer ).bind( 'onCloseFullScreen'+ this.bindPostFix + ' onOpenFullScreen'+ this.bindPostFix, function() {
				// Check if we are in fullscreen or not, if so add an additional bottom offset of 
				// double the default bottom padding. 
				var textOffset = _this.embedPlayer.controlBuilder.inFullScreen ? 
						mw.getConfig("TimedText.BottomPadding") * 2 : 
						mw.getConfig("TimedText.BottomPadding");
						
				var textCss = _this.getInterfaceSizeTextCss({
{'fraction_non_alphanumeric': 0.12944675788221296, 'fraction_numerical': 0.0014277215942891136, 'mean_word_length': 2.8630514705882355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1190695', 'n_tokens_mistral': 3119, 'n_tokens_neox': 2518, 'n_words': 778}