<commit_before>(function($) {
// CMS.$ will be passed for $
$(document).ready(function () {

	CKEDITOR.plugins.add('cmsplugins', {

		// Register the icons. They must match command names.
		icons: 'cmsplugins',

		// The plugin initialization logic goes inside this method.
		init: function(editor) {
			var that = this;

			this.options = CMS.CKEditor.options.settings;
			this.editor = editor;

			// don't do anything if there are no plugins defined
			if(this.options === undefined || this.options.plugins === undefined) return false;

			this.setupDialog();

			// add the button
			this.editor.ui.add('cmsplugins', CKEDITOR.UI_PANELBUTTON, {
				'toolbar': 'cms,0',
				'label': this.options.lang.toolbar,
				'title': this.options.lang.toolbar,
				'className' : 'cke_panelbutton__cmsplugins',
				'modes': { wysiwyg:1 },
				'editorFocus': 1,

				'panel': {
					'css': [CKEDITOR.skin.getPath('editor')].concat(that.editor.config.contentsCss),
					'attributes': { role: 'cmsplugins', 'aria-label': this.options.lang.aria }
				},

				// this is called when creating the dropdown list
				'onBlock': function (panel, block) {
					block.element.setHtml(that.editor.plugins.cmsplugins.setupDropdown());

					var anchors = $(block.element.$).find('.cke_panel_listItem a');
						anchors.bind('click', function (e) {
							e.preventDefault();

							that.addPlugin($(this), panel);
						});
				}
			});

			// handle edit event via context menu
			if(this.editor.contextMenu) {
				this.setupContextMenu();
				this.editor.addCommand('cmspluginsEdit', {
					exec: function () {
						var selection = that.editor.getSelection();
						var element = selection.getSelectedElement() || selection.getCommonAncestor().getAscendant('a', true);
						that.editPlugin(element);
					}
				});
			}

			// handle edit event on double click
			// if event is a jQuery event (touchend), than we mutate
			// event a bit so we make the payload similar to what ckeditor.event produces
			var handleEdit = function(event) {
				if (event.type === 'touchend') {
					var element = event.currentTarget;
					event.data = event.data ||  {};
				} else {
					var selection = that.editor.getSelection();
					var element = selection.getSelectedElement() || selection.getCommonAncestor().getAscendant('a', true);
				}
				if(element && element.getAttribute('id').indexOf('plugin_obj_') === 0) {
					event.data.dialog = '';
					that.editPlugin(element);
				}
			}
			this.editor.on('doubleclick', handleEdit);
			this.editor.on('instanceReady', function () {
				CMS.$('img[id*="plugin_obj_"]', CMS.$('iframe.cke_wysiwyg_frame')[0].contentWindow.document.documentElement).on('touchend', handleEdit);
			});

			// setup CKEDITOR.htmlDataProcessor
			this.setupDataProcessor();
		},<commit_msg>split up the line<commit_after>(function($) {
// CMS.$ will be passed for $
$(document).ready(function () {

	CKEDITOR.plugins.add('cmsplugins', {

		// Register the icons. They must match command names.
		icons: 'cmsplugins',

		// The plugin initialization logic goes inside this method.
		init: function(editor) {
			var that = this;

			this.options = CMS.CKEditor.options.settings;
			this.editor = editor;

			// don't do anything if there are no plugins defined
			if(this.options === undefined || this.options.plugins === undefined) return false;

			this.setupDialog();

			// add the button
			this.editor.ui.add('cmsplugins', CKEDITOR.UI_PANELBUTTON, {
				'toolbar': 'cms,0',
				'label': this.options.lang.toolbar,
				'title': this.options.lang.toolbar,
				'className' : 'cke_panelbutton__cmsplugins',
				'modes': { wysiwyg:1 },
				'editorFocus': 1,

				'panel': {
					'css': [CKEDITOR.skin.getPath('editor')].concat(that.editor.config.contentsCss),
					'attributes': { role: 'cmsplugins', 'aria-label': this.options.lang.aria }
				},

				// this is called when creating the dropdown list
				'onBlock': function (panel, block) {
					block.element.setHtml(that.editor.plugins.cmsplugins.setupDropdown());

					var anchors = $(block.element.$).find('.cke_panel_listItem a');
						anchors.bind('click', function (e) {
							e.preventDefault();

							that.addPlugin($(this), panel);
						});
				}
			});

			// handle edit event via context menu
			if(this.editor.contextMenu) {
				this.setupContextMenu();
				this.editor.addCommand('cmspluginsEdit', {
					exec: function () {
						var selection = that.editor.getSelection();
						var element = selection.getSelectedElement() || selection.getCommonAncestor().getAscendant('a', true);
						that.editPlugin(element);
					}
				});
			}

			// handle edit event on double click
			// if event is a jQuery event (touchend), than we mutate
			// event a bit so we make the payload similar to what ckeditor.event produces
			var handleEdit = function(event) {
				if (event.type === 'touchend') {
					var element = event.currentTarget;
					event.data = event.data ||  {};
				} else {
					var selection = that.editor.getSelection();
					var element = selection.getSelectedElement() || selection.getCommonAncestor().getAscendant('a', true);
				}
				if(element && element.getAttribute('id').indexOf('plugin_obj_') === 0) {
					event.data.dialog = '';
					that.editPlugin(element);
				}
			}
			this.editor.on('doubleclick', handleEdit);
			this.editor.on('instanceReady', function () {
				CMS.$('img[id*="plugin_obj_"]', CMS.$('iframe.cke_wysiwyg_frame')[0]
					.contentWindow.document.documentElement).on('touchend', handleEdit);
			});

			// setup CKEDITOR.htmlDataProcessor
			this.setupDataProcessor();
		},
{'fraction_non_alphanumeric': 0.15354330708661418, 'fraction_numerical': 0.0017895490336435219, 'mean_word_length': 3.332558139534884, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5400755', 'n_tokens_mistral': 2149, 'n_tokens_neox': 1690, 'n_words': 370}