<commit_before>/*##################################################|*/
/* #CMS# */
(function($) {
// CMS.$ will be passed for $
$(document).ready(function () {
	/*!
	 * StructureBoard
	 * handles drag & drop, mode switching and
	 */
	CMS.StructureBoard = new CMS.Class({

		implement: [CMS.API.Helpers],

		options: {
			'speed': 300
		},

		initialize: function (options) {
			this.container = $('.cms_structure');
			this.options = $.extend(true, {}, this.options, options);
			this.config = CMS.config;
			this.settings = this.getSettings();

			// elements
			this.toolbar = $('#cms_toolbar');
			this.sortables = $('.cms_draggables'); // use global scope
			this.plugins = $('.cms_plugin');
			this.placeholders = $('.cms_placeholder');
			this.dragitems = $('.cms_draggable');
			this.dropareas = $('.cms_droppable');

			// states
			this.click = (document.ontouchstart !== null) ? 'click.cms' : 'tap.cms';
			this.timer = function () {};
			this.state = false;
			this.dragging = false;

			// setup initial stuff
			this._setup();

			// setup events
			this._events();
		},

		_setup: function () {
			var that = this;

			// setup toolbar mode
			if(this.settings.mode === 'structure') setTimeout(function () { that.show(); }, 100);

			// check if modes should be visible
			if(this.placeholders.length) {
				this.toolbar.find('.cms_toolbar-item-cms-mode-switcher').show();
			}

			// add drag & drop functionality
			this._drag();
			// prevent click events to detect double click
			this._preventEvents();
		},

		_events: function () {
			var that = this;
			var modes = this.toolbar.find('.cms_toolbar-item-cms-mode-switcher a');

			// show edit mode
			modes.eq(0).bind(this.click, function (e) {
				e.preventDefault();
				// cancel if already active
				if(that.settings.mode === 'edit') return false;
				// otherwise hide
				that.hide();
			});
			// show structure mode
			modes.eq(1).bind(this.click, function (e) {
				e.preventDefault();
				// cancel if already active
				if(that.settings.mode === 'structure') return false;
				// otherwise show
				that.show();
			});

			// keyboard handling
			$(document).bind('keydown', function (e) {
				// check if we have an important focus
				var fields = $('*:focus');
				// 32 = space
				if(e.keyCode === 32 && that.settings.mode === 'structure' && !fields.length) {
					e.preventDefault();
					that.hide();
				} else if(e.keyCode === 32 && that.settings.mode === 'edit' && !fields.length) {
					e.preventDefault();
					that.show();
				}
			});
		},

		// public methods
		show: function () {
			// set active item
			var modes = this.toolbar.find('.cms_toolbar-item-cms-mode-switcher a');
				modes.removeClass('cms_btn-active').eq(1).addClass('cms_btn-active');

			// show clipboard in structure mode
			this.container.find('.cms_clipboard').fadeIn(this.options.speed);

			// apply new settings
			this.settings.mode = 'structure';
			this.setSettings(this.settings);

			// show canvas
			this._showBoard();
		},

		hide: function () {
			// set active item
			var modes = this.toolbar.find('.cms_toolbar-item-cms-mode-switcher a');
				modes.removeClass('cms_btn-active').eq(0).addClass('cms_btn-active');

			// hide clipboard if in edit mode
			this.container.find('.cms_clipboard').hide();

			this.settings.mode = 'edit';
			this.setSettings(this.settings);

			// hide canvas
			this._hideBoard();
		},

		getId: function (el) {
			// cancel if no element is defined
			if(el === undefined || el === null || el.length <= 0) return false;

			var id = null;

			if(el.hasClass('cms_plugin')) {
				id = el.attr('id').replace('cms_plugin-', '');
			} else if(el.hasClass('cms_draggable')) {
				id = el.attr('id').replace('cms_draggable-', '');
			} else {
				id = el.attr('id').replace('cms_placeholder-', '');
			}

			return id;
		},

		getIds: function (els) {
			var that = this;
			var array = [];
			els.each(function () {
				array.push(that.getId($(this)));
			});
			return array;
		},

		setActive: function (id) {
			// reset active statesdragholders
			this.dragitems.removeClass('cms_draggable-selected');
			this.plugins.removeClass('cms_plugin-active');

			// if false is provided, only remove classes<commit_msg>fix issue where id is not set corectly anymore<commit_after>/*##################################################|*/
/* #CMS# */
(function($) {
// CMS.$ will be passed for $
$(document).ready(function () {
	/*!
	 * StructureBoard
	 * handles drag & drop, mode switching and
	 */
	CMS.StructureBoard = new CMS.Class({

		implement: [CMS.API.Helpers],

		options: {
			'speed': 300
		},

		initialize: function (options) {
			this.container = $('.cms_structure');
			this.options = $.extend(true, {}, this.options, options);
			this.config = CMS.config;
			this.settings = this.getSettings();

			// elements
			this.toolbar = $('#cms_toolbar');
			this.sortables = $('.cms_draggables'); // use global scope
			this.plugins = $('.cms_plugin');
			this.placeholders = $('.cms_placeholder');
			this.dragitems = $('.cms_draggable');
			this.dropareas = $('.cms_droppable');

			// states
			this.click = (document.ontouchstart !== null) ? 'click.cms' : 'tap.cms';
			this.timer = function () {};
			this.state = false;
			this.dragging = false;

			// setup initial stuff
			this._setup();

			// setup events
			this._events();
		},

		_setup: function () {
			var that = this;

			// setup toolbar mode
			if(this.settings.mode === 'structure') setTimeout(function () { that.show(); }, 100);

			// check if modes should be visible
			if(this.placeholders.length) {
				this.toolbar.find('.cms_toolbar-item-cms-mode-switcher').show();
			}

			// add drag & drop functionality
			this._drag();
			// prevent click events to detect double click
			this._preventEvents();
		},

		_events: function () {
			var that = this;
			var modes = this.toolbar.find('.cms_toolbar-item-cms-mode-switcher a');

			// show edit mode
			modes.eq(0).bind(this.click, function (e) {
				e.preventDefault();
				// cancel if already active
				if(that.settings.mode === 'edit') return false;
				// otherwise hide
				that.hide();
			});
			// show structure mode
			modes.eq(1).bind(this.click, function (e) {
				e.preventDefault();
				// cancel if already active
				if(that.settings.mode === 'structure') return false;
				// otherwise show
				that.show();
			});

			// keyboard handling
			$(document).bind('keydown', function (e) {
				// check if we have an important focus
				var fields = $('*:focus');
				// 32 = space
				if(e.keyCode === 32 && that.settings.mode === 'structure' && !fields.length) {
					e.preventDefault();
					that.hide();
				} else if(e.keyCode === 32 && that.settings.mode === 'edit' && !fields.length) {
					e.preventDefault();
					that.show();
				}
			});
		},

		// public methods
		show: function () {
			// set active item
			var modes = this.toolbar.find('.cms_toolbar-item-cms-mode-switcher a');
				modes.removeClass('cms_btn-active').eq(1).addClass('cms_btn-active');

			// show clipboard in structure mode
			this.container.find('.cms_clipboard').fadeIn(this.options.speed);

			// apply new settings
			this.settings.mode = 'structure';
			this.setSettings(this.settings);

			// show canvas
			this._showBoard();
		},

		hide: function () {
			// set active item
			var modes = this.toolbar.find('.cms_toolbar-item-cms-mode-switcher a');
				modes.removeClass('cms_btn-active').eq(0).addClass('cms_btn-active');

			// hide clipboard if in edit mode
			this.container.find('.cms_clipboard').hide();

			this.settings.mode = 'edit';
			this.setSettings(this.settings);

			// hide canvas
			this._hideBoard();
		},

		getId: function (el) {
			// cancel if no element is defined
			if(el === undefined || el === null || el.length <= 0) return false;

			var id = null;

			if(el.hasClass('cms_plugin')) {
				id = el.attr('class').replace('cms_plugin cms_plugin-', '');
			} else if(el.hasClass('cms_draggable')) {
				id = el.attr('class').replace('cms_draggable cms_draggable-', '');
			} else {
				id = el.attr('class').replace('cms_placeholder cms_placeholder-', '');
			}

			return id;
		},

		getIds: function (els) {
			var that = this;
			var array = [];
			els.each(function () {
				array.push(that.getId($(this)));
			});
			return array;
		},

		setActive: function (id) {
			// reset active statesdragholders
			this.dragitems.removeClass('cms_draggable-selected');
			this.plugins.removeClass('cms_plugin-active');

			// if false is provided, only remove classes
{'fraction_non_alphanumeric': 0.18503337627356833, 'fraction_numerical': 0.00398173088183628, 'mean_word_length': 2.9906542056074765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4815700', 'n_tokens_mistral': 3324, 'n_tokens_neox': 2658, 'n_words': 594}