<commit_before>/*##################################################|*/
/* #CMS.TOOLBAR# */
(function($) {
// CMS.$ will be passed for $
$(document).ready(function () {
	/*!
	 * Toolbar
	 * @version: 2.0.0
	 * @description: Adds toolbar, sideframe, messages and modal
	 */
	CMS.Toolbar = new CMS.Class({

		implement: [CMS.API.Helpers],

		options: {
			'csrf': '',
			'authenticated': false,
			'debug': false, // not yet required
			'preventSwitch': false,
			'preventSwitchMessage': 'Switching is disabled.',
			'clipboard': null,
			'sideframeDuration': 300,
			'sideframeWidth': 320,
			'messageDelay': 2000,
			'modalDuration': 300,
			'modalWidth': 800,
			'modalHeight': 400,
			'urls': {
				'settings': '', // url to save settings
				'static': '/static/',
				'css_modal': 'cms/css/plugins/cms.toolbar.modal.css',
				'css_sideframe': 'cms/css/plugins/cms.toolbar.sideframe.css'
			},
			'settings': {
				'version': '3.0.0', // this is required to flush storage on new releases
				'toolbar': 'expanded', // expanded or collapsed
				'mode': 'edit', // live, draft, edit or layout
				'states': [],
				'sideframe': {
					'url': null,
					'hidden': false,
					'maximized': false
				}
			}
		},

		initialize: function (container, options) {
			this.container = $(container);
			this.options = $.extend(true, {}, this.options, options);
			this.settings = this.getSettings() || this.setSettings(this.options.settings);
			// class variables
			this.toolbar = this.container.find('.cms_toolbar');
			this.toolbar.hide();
			this.toolbarTrigger = this.container.find('.cms_toolbar-trigger');

			this.navigations = this.container.find('.cms_toolbar-item-navigation');
			this.buttons = this.container.find('.cms_toolbar-item-buttons');
			this.modes = this.container.find('.cms_toolbar-item-cms-mode-switcher a');
			this.switcher = this.container.find('.cms_toolbar-item_switch');

			this.body = $('html');
			this.sideframe = this.container.find('.cms_sideframe');
			this.messages = this.container.find('.cms_messages');
			this.modal = this.container.find('.cms_modal');
			this.tooltip = this.container.find('.cms_placeholders-tooltip');
			this.bars = $('.cms_placeholder-bar');
			this.click = (document.ontouchstart !== null) ? 'click.cms' : 'touchend.cms';

			this.plugins = $('.cms_plugin');
			this.placeholders = $('.cms_placeholder');

			this.lockToolbar = false;
			this.minimized = false;
			this.maximized = false;
			this.timer = function () {};

			// setup initial stuff
			this._setup();

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

		// initial methods
		_setup: function () {
			// reset settings if version does not match
			if(this.settings.version !== this.options.settings.version) this.resetSettings();

			// setup toolbar visibility, we need to reverse the options to set the correct state
			(this.settings.toolbar === 'expanded') ? this._showToolbar(0, true) : this._hideToolbar(0, true);
			// setup toolbar mode
			(this.settings.mode === 'drag') ? this._enableDragMode(300, true) : this._enableEditMode(300, true);

			// load initial states
			this._load();

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

			// hide publish button
			var publishBtn = $('.cms_btn-publish').parent();
				publishBtn.hide();
			if($('.cms_btn-publish-active').length) publishBtn.show();

			// add toolbar ready class to body
			$('body').addClass('cms_toolbar-ready');

			// check if debug is true
			if(this.options.debug) this._debug();
		},

		_load: function () {
			// reset some settings if not authenticated
			if(!this.options.authenticated) this._reset();
			// check if we should show the sideframe
			if(this.settings.sideframe.url) {
				this.openSideframe(this.settings.sideframe.url, false);
			}
		},

		_events: function () {
			var that = this;

			// attach event to the trigger handler
			this.toolbarTrigger.bind(this.click, function (e) {
				e.preventDefault();
				that.toggleToolbar();
			});

			// attach event to the navigation elements
			this.navigations.each(function () {
				var item = $(this);
				var lists = item.find('li');
				var root = 'cms_toolbar-item-navigation';
				var hover = 'cms_toolbar-item-navigation-hover';
				var disabled = 'cms_toolbar-item-navigation-disabled';
				var children = 'cms_toolbar-item-navigation-children';

				// remove events from first level
				item.find('a').bind(that.click, function (e) {
					e.preventDefault();
					if($(this).attr('href') !== ''
						&& $(this).attr('href') !== '#'
						&& !$(this).parent().hasClass(disabled)
						&& !$(this).parent().hasClass(disabled)) {
						that._delegate($(this));
						reset();
						return false;
					}
				});

				// handle click states
				lists.bind(that.click, function (e) {
					e.stopPropagation();
					var el = $(this);

					// close if el is first item
					if(el.parent().hasClass(root) && el.hasClass(hover) || el.hasClass(disabled)) {
						reset();
						return false;
					} else {
						reset();
						el.addClass(hover);
					}

					// activate hover selection
					item.find('> li').bind('mouseenter', function () {
						// cancel if item is already active
						if($(this).hasClass(hover)) return false;
						$(this).trigger(that.click);
					});

					// create the document event
					$(document).bind(that.click, reset);
				});

				// attach hover
				lists.find('li').bind('mouseenter mouseleave', function (e) {
					// reset
					lists.find('li').removeClass(hover);

					var el = $(this);
					var parent = el.closest('.cms_toolbar-item-navigation-children');
					var hasChildren = el.hasClass(children) || parent.length;

					// do not attach hover effect if disabled
					if(el.hasClass(disabled)) return false;
<commit_msg>event not required<commit_after>/*##################################################|*/
/* #CMS.TOOLBAR# */
(function($) {
// CMS.$ will be passed for $
$(document).ready(function () {
	/*!
	 * Toolbar
	 * @version: 2.0.0
	 * @description: Adds toolbar, sideframe, messages and modal
	 */
	CMS.Toolbar = new CMS.Class({

		implement: [CMS.API.Helpers],

		options: {
			'csrf': '',
			'authenticated': false,
			'debug': false, // not yet required
			'preventSwitch': false,
			'preventSwitchMessage': 'Switching is disabled.',
			'clipboard': null,
			'sideframeDuration': 300,
			'sideframeWidth': 320,
			'messageDelay': 2000,
			'modalDuration': 300,
			'modalWidth': 800,
			'modalHeight': 400,
			'urls': {
				'settings': '', // url to save settings
				'static': '/static/',
				'css_modal': 'cms/css/plugins/cms.toolbar.modal.css',
				'css_sideframe': 'cms/css/plugins/cms.toolbar.sideframe.css'
			},
			'settings': {
				'version': '3.0.0', // this is required to flush storage on new releases
				'toolbar': 'expanded', // expanded or collapsed
				'mode': 'edit', // live, draft, edit or layout
				'states': [],
				'sideframe': {
					'url': null,
					'hidden': false,
					'maximized': false
				}
			}
		},

		initialize: function (container, options) {
			this.container = $(container);
			this.options = $.extend(true, {}, this.options, options);
			this.settings = this.getSettings() || this.setSettings(this.options.settings);
			// class variables
			this.toolbar = this.container.find('.cms_toolbar');
			this.toolbar.hide();
			this.toolbarTrigger = this.container.find('.cms_toolbar-trigger');

			this.navigations = this.container.find('.cms_toolbar-item-navigation');
			this.buttons = this.container.find('.cms_toolbar-item-buttons');
			this.modes = this.container.find('.cms_toolbar-item-cms-mode-switcher a');
			this.switcher = this.container.find('.cms_toolbar-item_switch');

			this.body = $('html');
			this.sideframe = this.container.find('.cms_sideframe');
			this.messages = this.container.find('.cms_messages');
			this.modal = this.container.find('.cms_modal');
			this.tooltip = this.container.find('.cms_placeholders-tooltip');
			this.bars = $('.cms_placeholder-bar');
			this.click = (document.ontouchstart !== null) ? 'click.cms' : 'touchend.cms';

			this.plugins = $('.cms_plugin');
			this.placeholders = $('.cms_placeholder');

			this.lockToolbar = false;
			this.minimized = false;
			this.maximized = false;
			this.timer = function () {};

			// setup initial stuff
			this._setup();

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

		// initial methods
		_setup: function () {
			// reset settings if version does not match
			if(this.settings.version !== this.options.settings.version) this.resetSettings();

			// setup toolbar visibility, we need to reverse the options to set the correct state
			(this.settings.toolbar === 'expanded') ? this._showToolbar(0, true) : this._hideToolbar(0, true);
			// setup toolbar mode
			(this.settings.mode === 'drag') ? this._enableDragMode(300, true) : this._enableEditMode(300, true);

			// load initial states
			this._load();

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

			// hide publish button
			var publishBtn = $('.cms_btn-publish').parent();
				publishBtn.hide();
			if($('.cms_btn-publish-active').length) publishBtn.show();

			// add toolbar ready class to body
			$('body').addClass('cms_toolbar-ready');

			// check if debug is true
			if(this.options.debug) this._debug();
		},

		_load: function () {
			// reset some settings if not authenticated
			if(!this.options.authenticated) this._reset();
			// check if we should show the sideframe
			if(this.settings.sideframe.url) {
				this.openSideframe(this.settings.sideframe.url, false);
			}
		},

		_events: function () {
			var that = this;

			// attach event to the trigger handler
			this.toolbarTrigger.bind(this.click, function (e) {
				e.preventDefault();
				that.toggleToolbar();
			});

			// attach event to the navigation elements
			this.navigations.each(function () {
				var item = $(this);
				var lists = item.find('li');
				var root = 'cms_toolbar-item-navigation';
				var hover = 'cms_toolbar-item-navigation-hover';
				var disabled = 'cms_toolbar-item-navigation-disabled';
				var children = 'cms_toolbar-item-navigation-children';

				// remove events from first level
				item.find('a').bind(that.click, function (e) {
					e.preventDefault();
					if($(this).attr('href') !== ''
						&& $(this).attr('href') !== '#'
						&& !$(this).parent().hasClass(disabled)
						&& !$(this).parent().hasClass(disabled)) {
						that._delegate($(this));
						reset();
						return false;
					}
				});

				// handle click states
				lists.bind(that.click, function (e) {
					e.stopPropagation();
					var el = $(this);

					// close if el is first item
					if(el.parent().hasClass(root) && el.hasClass(hover) || el.hasClass(disabled)) {
						reset();
						return false;
					} else {
						reset();
						el.addClass(hover);
					}

					// activate hover selection
					item.find('> li').bind('mouseenter', function () {
						// cancel if item is already active
						if($(this).hasClass(hover)) return false;
						$(this).trigger(that.click);
					});

					// create the document event
					$(document).bind(that.click, reset);
				});

				// attach hover
				lists.find('li').bind('mouseenter mouseleave', function () {
					// reset
					lists.find('li').removeClass(hover);

					var el = $(this);
					var parent = el.closest('.cms_toolbar-item-navigation-children');
					var hasChildren = el.hasClass(children) || parent.length;

					// do not attach hover effect if disabled
					if(el.hasClass(disabled)) return false;

{'fraction_non_alphanumeric': 0.17602739726027397, 'fraction_numerical': 0.0056506849315068495, 'mean_word_length': 3.1348672566371683, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5988010', 'n_tokens_mistral': 4519, 'n_tokens_neox': 3534, 'n_words': 787}