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

	mw.PluginManager.add( 'smartContainer', mw.KBaseComponent.extend({

		defaultConfig: {
			'parent': 'controlsContainer',
			"align": "right",
			'order': 100,
			'width': 220,
			'showTooltip': true,
			'displayImportance': "high",
			'tooltip': null,
			'iconClass': 'icon-cog',
			'config':{}
		},

		menuOpened: false,
		$menu: null,

		setup: function( embedPlayer ) {
			if ( $.isEmptyObject(this.getConfig("config")) ){
				this.setConfig( "visible", false ); // remove plugin if no config was specified
				return;
			}
			this.addBindings();
			this.getMenu(); // create menu
		},
		getComponent: function() {
			var _this = this;
			if( !this.$el ) {
				this.$el = $( '<button />' )
					.addClass( this.getConfig('iconClass') + " btn " + this.getCssClass() )
					.click( function(e) {
						_this.toggleMenu( e.clientX ); // pass the mouse pointer x position to set the menu position
					});
				if (this.getConfig("tooltip")){
					this.$el.attr( 'title', this.getConfig('tooltip') )
				}
			}
			return this.$el;
		},
		addBindings: function() {
			var _this = this;
			this.bind( 'layoutBuildDone updatePropertyEvent', function(){
				// hide specified plugins
				var config = _this.getConfig('config');
				config.plugins.forEach(function (plugin, index) {
					_this.embedPlayer.setKalturaConfig( plugin.pluginName, "visible", false );
				});
			});

			this.bind( 'onOpenFullScreen onCloseFullScreen', function(){
				_this.closeMenu();
			});

			var _this = this;
		},
		toggleMenu: function(x) {
			if ( this.isDisabled ){return};
			if ( this.menuOpened ){
				this.closeMenu();
			}else{
				this.openMenu(x);
			}
		},

		openMenu: function(x){
			// set menu position
			var rightPosition = this.embedPlayer.getVideoHolder().width() - x - 20; // set right position for the menu according to the mouse click x position
			var bottomPosition = 0; // set the menu bottom to the video holder bottom
			if  ( this.embedPlayer.getKalturaConfig( "controlBarContainer", "hover" ) === true ){
				bottomPosition = this.embedPlayer.getInterface().find(".controlBarContainer").height(); // for hovering controls, update the menu bottom to the controls bar height
			}
			this.getMenu().css({"bottom": bottomPosition, "right": rightPosition}).show();
			this.menuOpened = true;
			this.getPlayer().triggerHelper( 'onDisableKeyboardBinding' );
		},

		closeMenu: function(){
			this.getMenu().hide();
			this.menuOpened = false;
			this.getPlayer().triggerHelper( 'onEnableKeyboardBinding' );
		},

		getMenu: function(){
			if ( !this.$menu ){
				var _this = this;
				// add menu DIV
				this.$menu = $('<div class="smartContainerMenu"></div>').width(this.getConfig("width"));
				this.$menu.close = function(){
					_this.closeMenu();
				}
				// render menu
				this.renderMenu();
				this.embedPlayer.getVideoHolder().append( this.$menu.hide() );<commit_msg>set position according to button width<commit_after>( function( mw, $ ) {"use strict";

	mw.PluginManager.add( 'smartContainer', mw.KBaseComponent.extend({

		defaultConfig: {
			'parent': 'controlsContainer',
			"align": "right",
			'order': 100,
			'width': 220,
			'showTooltip': true,
			'displayImportance': "high",
			'tooltip': null,
			'iconClass': 'icon-cog',
			'config':{}
		},

		menuOpened: false,
		$menu: null,

		setup: function( embedPlayer ) {
			if ( $.isEmptyObject(this.getConfig("config")) ){
				this.setConfig( "visible", false ); // remove plugin if no config was specified
				return;
			}
			this.addBindings();
			this.getMenu(); // create menu
		},
		getComponent: function() {
			var _this = this;
			if( !this.$el ) {
				this.$el = $( '<button />' )
					.addClass( this.getConfig('iconClass') + " btn " + this.getCssClass() )
					.click( function(e) {
						_this.toggleMenu( e.clientX ); // pass the mouse pointer x position to set the menu position
					});
				if (this.getConfig("tooltip")){
					this.$el.attr( 'title', this.getConfig('tooltip') )
				}
			}
			return this.$el;
		},
		addBindings: function() {
			var _this = this;
			this.bind( 'layoutBuildDone updatePropertyEvent', function(){
				// hide specified plugins
				var config = _this.getConfig('config');
				config.plugins.forEach(function (plugin, index) {
					_this.embedPlayer.setKalturaConfig( plugin.pluginName, "visible", false );
				});
			});

			this.bind( 'onOpenFullScreen onCloseFullScreen', function(){
				_this.closeMenu();
			});
		},
		toggleMenu: function(x) {
			if ( this.isDisabled ){return};
			if ( this.menuOpened ){
				this.closeMenu();
			}else{
				this.openMenu(x);
			}
		},

		openMenu: function(x){
			// set menu position
			var rightPosition = this.embedPlayer.getVideoHolder().width() - x - this.getComponent().width()/2; // set right position for the menu according to the mouse click x position
			var bottomPosition = 0; // set the menu bottom to the video holder bottom
			if  ( this.embedPlayer.getKalturaConfig( "controlBarContainer", "hover" ) === true ){
				bottomPosition = this.embedPlayer.getInterface().find(".controlBarContainer").height(); // for hovering controls, update the menu bottom to the controls bar height
			}
			this.getMenu().css({"bottom": bottomPosition, "right": rightPosition}).show();
			this.menuOpened = true;
			this.getPlayer().triggerHelper( 'onDisableKeyboardBinding' );
		},

		closeMenu: function(){
			this.getMenu().hide();
			this.menuOpened = false;
			this.getPlayer().triggerHelper( 'onEnableKeyboardBinding' );
		},

		getMenu: function(){
			if ( !this.$menu ){
				var _this = this;
				// add menu DIV
				this.$menu = $('<div class="smartContainerMenu"></div>').width(this.getConfig("width"));
				this.$menu.close = function(){
					_this.closeMenu();
				}
				// render menu
				this.renderMenu();
				this.embedPlayer.getVideoHolder().append( this.$menu.hide() );
{'fraction_non_alphanumeric': 0.16163500678426052, 'fraction_numerical': 0.0028833107191316145, 'mean_word_length': 3.3974645786726323, 'pattern_counts': {'":': 6, '<': 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': '820985', 'n_tokens_mistral': 2217, 'n_tokens_neox': 1817, 'n_words': 432}