diff --git a/js/plugins/backdropimage/plugin.js b/js/plugins/backdropimage/plugin.js index 273bdb4..88fc1fc 100644 --- a/js/plugins/backdropimage/plugin.js +++ b/js/plugins/backdropimage/plugin.js @@ -17,14 +17,14 @@ let node = editor.selection.getNode(); let existingValues = {}; - if (node.nodeName == 'IMG') { + if (node.nodeName === 'IMG') { let attribs = node.getAttributeNames(); for (let i = 0; i < attribs.length; i++) { let name = attribs[i]; if (name.startsWith('data-mce')) { continue; } - existingValues[name] = node.attributes[name]['value']; + existingValues[name] = node.attributes[name].value; } let parentFigure = editor.dom.getParents(node, 'FIGURE'); if (parentFigure.length) { @@ -33,7 +33,7 @@ } return existingValues; - } + }; /** * Opens a Backdrop dialog. @@ -46,7 +46,7 @@ let saveCallback = function(returnValues) { let image = buildImage(editor, returnValues); let selected = editor.selection.getNode(); - if (selected.nodeName == 'IMG') { + if (selected.nodeName === 'IMG') { let parentFigure = editor.dom.getParents(selected, 'FIGURE'); let parentLink = editor.dom.getParents(selected, 'A'); if (parentFigure.length) { @@ -64,13 +64,13 @@ imgToSize.onload = function() { imgDomnode.setAttribute('width', this.width); imgDomnode.setAttribute('height', this.height); - } + }; imgToSize.src = src; } }; Backdrop.tinymce.openDialog(editor, dialogUrl, existingValues, saveCallback, dialogSettings); - } + }; /** * Builds the image markup. @@ -101,10 +101,10 @@ node = editor.dom.create('figure', figAttrib); let img = editor.dom.create('img'); for (let key in values) { - if (key == 'data-has-caption') { + if (key === 'data-has-caption') { continue; } - if (key == 'data-file-id' && !values[key]) { + if (key === 'data-file-id' && !values[key]) { continue; } img.setAttribute(key, values[key]); @@ -123,7 +123,7 @@ if (parentFigure.length) { let parent = parentFigure[0]; for (let i = 0; i < parent.childNodes.length; i++) { - if (parent.childNodes[i].nodeName == 'FIGCAPTION') { + if (parent.childNodes[i].nodeName === 'FIGCAPTION') { captiontext = parent.childNodes[i].innerHTML; break; } @@ -135,10 +135,10 @@ else { let img = editor.dom.create('img'); for (let key in values) { - if (key == 'data-has-caption') { + if (key === 'data-has-caption') { continue; } - if (key == 'data-file-id' && !values[key]) { + if (key === 'data-file-id' && !values[key]) { continue; } img.setAttribute(key, values[key]); @@ -152,7 +152,7 @@ } } return node.outerHTML; - } + }; /** * Parses an array of AstNodes into a string. @@ -181,7 +181,7 @@ } } return dummy.innerHTML; - } + }; /** * Turns an attribute string into an AstNode instance. @@ -198,7 +198,7 @@ for (let i = 0; i < domNode.childNodes.length; i++) { let n = domNode.childNodes[i]; - if (n.nodeName == '#text') { + if (n.nodeName === '#text') { let text = new tinymce.html.Node('#text', 3); text.value = n.textContent; caption.append(text); @@ -213,7 +213,7 @@ } } return caption; - } + }; /** * Checks if a dom node is relevant for this plugin. @@ -225,7 +225,7 @@ * True if this tag is something, this plugin handles. */ const isRegularImg = function (node) { - if (node.nodeName != 'IMG') { + if (node.nodeName !== 'IMG') { return false; } if (node.hasAttribute('data-mce-object') || node.hasAttribute('data-mce-placeholder')) { @@ -235,7 +235,7 @@ return false; } return true; - } + }; // Register plugin features. tinymce.PluginManager.add('backdropimage', function(editor, url) { @@ -246,11 +246,11 @@ // These "node" are AstNode, not dom node. // @see https://www.tiny.cloud/docs/tinymce/6/apis/tinymce.html.node/#Node let link; - if (nodes[i].parent.name == 'a') { + if (nodes[i].parent.name === 'a') { link = nodes[i].parent.clone(); nodes[i].parent.unwrap(); } - if (nodes[i].parent.name == 'p') { + if (nodes[i].parent.name === 'p') { nodes[i].parent.unwrap(); } let img = nodes[i].clone(); @@ -343,7 +343,7 @@ }); // @see https://github.com/backdrop-contrib/tinymce/issues/56 editor.on('ObjectSelected', function (obj) { - if (obj.target.nodeName != 'IMG') { + if (obj.target.nodeName !== 'IMG') { return; } editor.selection.select(obj.target); diff --git a/js/plugins/backdroplink/plugin.js b/js/plugins/backdroplink/plugin.js index 9032012..5300e44 100644 --- a/js/plugins/backdroplink/plugin.js +++ b/js/plugins/backdroplink/plugin.js @@ -19,7 +19,7 @@ let saveCallback = function(returnValues) { let link = buildLink(editor, returnValues); - if (typeof existingValues.href == 'undefined') { + if (typeof existingValues.href === 'undefined') { editor.execCommand('mceInsertContent', false, link); } else { @@ -28,7 +28,7 @@ }; Backdrop.tinymce.openDialog(editor, dialogUrl, existingValues, saveCallback, dialogSettings); - } + }; /** * @param object editor @@ -42,11 +42,11 @@ let existingValues = {}; // This image is already wrapped in a link. - if (node.nodeName == 'IMG' && node.parentNode.nodeName == 'A') { + if (node.nodeName === 'IMG' && node.parentNode.nodeName === 'A') { node = node.parentNode; } - if (node.nodeName == 'A') { + if (node.nodeName === 'A') { // Expand selection to whole anchor to prevent inserting a link into a link. editor.selection.select(node); if (node.textContent) { @@ -59,10 +59,10 @@ if (name.startsWith('data-mce')) { continue; } - existingValues[name] = node.attributes[name]['value']; + existingValues[name] = node.attributes[name].value; } } - else if (node.nodeName != 'IMG') { + else if (node.nodeName !== 'IMG') { let content = editor.selection.getContent({ format: 'text' }); existingValues = { text: content @@ -70,7 +70,7 @@ } return existingValues; - } + }; /** * Builds link markup. @@ -88,23 +88,23 @@ let a = editor.dom.create('a'); for (let key in values) { - if (key == 'text') { + if (key === 'text') { textContent = values[key]; continue; } - if (key == 'data-file-id' && !values[key]) { + if (key === 'data-file-id' && !values[key]) { continue; } a.setAttribute(key, values[key]); } let node = editor.selection.getNode(); - if (node.nodeName == 'IMG') { + if (node.nodeName === 'IMG') { let clone = node.cloneNode(true); clone.removeAttribute('data-mce-src'); a.appendChild(clone); } - else if (node.nodeName == 'A' && node.childNodes.length) { + else if (node.nodeName === 'A' && node.childNodes.length) { for (let i = 0; i < node.childNodes.length; i++) { let clone = node.childNodes[i].cloneNode(true); a.appendChild(clone); @@ -121,7 +121,7 @@ return a.innerHTML; } return a.outerHTML; - } + }; // Register plugin features. tinymce.PluginManager.add('backdroplink', function(editor, url) { @@ -136,7 +136,7 @@ editor.on('SelectionChange', function () { let node = editor.selection.getNode(); // The anchor plugin marks its links as not editable. - if (node.nodeName == 'A' && node.isContentEditable) { + if (node.nodeName === 'A' && node.isContentEditable) { api.setActive(true); } else { @@ -155,7 +155,7 @@ api.setEnabled(false); editor.on('SelectionChange', function () { let node = editor.selection.getNode(); - if (node.nodeName == 'A' || node.parentNode.nodeName == 'A') { + if (node.nodeName === 'A' || node.parentNode.nodeName === 'A') { api.setEnabled(true); } else { diff --git a/js/plugins/backdroplistprop/plugin.js b/js/plugins/backdroplistprop/plugin.js index a328c46..3a98d96 100644 --- a/js/plugins/backdroplistprop/plugin.js +++ b/js/plugins/backdroplistprop/plugin.js @@ -68,7 +68,7 @@ api.close(); } }); - } + }; /** * Get the Dom parent OL if exists. @@ -79,11 +79,11 @@ */ const getOlParent = function (node) { const closestLi = node.closest('li'); - if (closestLi && closestLi.parentNode.nodeName == 'OL') { + if (closestLi && closestLi.parentNode.nodeName === 'OL') { return closestLi.parentNode; } return false; - } + }; // Register plugin features. tinymce.PluginManager.add('backdroplistprop', function(editor, url) { diff --git a/js/plugins/liststyle/plugin.js b/js/plugins/liststyle/plugin.js index bb48b22..8f35d5c 100644 --- a/js/plugins/liststyle/plugin.js +++ b/js/plugins/liststyle/plugin.js @@ -13,7 +13,7 @@ let attrValue = nodes[i].attr('data-list-style'); let otherStyles = nodes[i].attr('style'); let listStyle = 'list-style-type: ' + attrValue + ';'; - if (typeof otherStyles == 'undefined') { + if (typeof otherStyles === 'undefined') { nodes[i].attr('style', listStyle); } else { @@ -24,7 +24,7 @@ }); editor.serializer.addAttributeFilter('style', function (nodes) { for (let i = 0; i < nodes.length; i++) { - if (nodes[i].name != 'ul' && nodes[i].name != 'ol') { + if (nodes[i].name !== 'ul' && nodes[i].name !== 'ol') { continue; } let styles = nodes[i].attr('style'); @@ -35,7 +35,7 @@ continue; } let keyVal = stylesArr[n].split(':'); - if (keyVal[0].trim() == 'list-style-type') { + if (keyVal[0].trim() === 'list-style-type') { nodes[i].attr('data-list-style', keyVal[1].trim()); } else { diff --git a/js/tinymce-admin.js b/js/tinymce-admin.js index 23df3f0..e952a89 100644 --- a/js/tinymce-admin.js +++ b/js/tinymce-admin.js @@ -9,7 +9,7 @@ Backdrop.behaviors.tinymceAdmin = { attach: function (context, settings) { let selectedEditor = $('select[name="editor"]').val(); - if (selectedEditor != 'tinymce') { + if (selectedEditor !== 'tinymce') { return; } let selectProfile = $('#edit-editor-settings-tinymce-settings-profile'); @@ -28,7 +28,7 @@ Backdrop.behaviors.tinymceAdmin = { }, detach: function () { let selected = $('#edit-editor-settings-tinymce-settings-profile').val(); - if (typeof selected == 'undefined') { + if (typeof selected === 'undefined') { return; } let featureList = Backdrop.behaviors.tinymceAdmin.buildFeatures(); diff --git a/js/tinymce-dragdrop.js b/js/tinymce-dragdrop.js index c7bc04f..b9a11c1 100644 --- a/js/tinymce-dragdrop.js +++ b/js/tinymce-dragdrop.js @@ -26,21 +26,21 @@ // Keyboard navigation. $('#edit-tb .tinybutton').on('keydown', function (ev) { - if ($(this).parent().attr('id') == 'buttons-active') { + if ($(this).parent().attr('id') === 'buttons-active') { // 39 = Arrow right. - if (ev.which == 39) { + if (ev.which === 39) { $(this).insertAfter($(this).next()); $(this).focus(); updateFormItem(); } // 37 = Arrow left. - else if (ev.which == 37) { + else if (ev.which === 37) { $(this).insertBefore($(this).prev()); $(this).focus(); updateFormItem(); } // 173 = "-" key. - else if (ev.which == 173) { + else if (ev.which === 173) { $(this).next().focus(); $(this).appendTo('#buttons-available'); let message = Backdrop.t('%button removed from active elements.', { @@ -52,7 +52,7 @@ } else { // 171 = "+" key. - if (ev.which == 171) { + if (ev.which === 171) { $(this).appendTo('#buttons-active'); $(this).focus(); let message = Backdrop.t('%button added to active elements.', { @@ -80,7 +80,7 @@ }); $('#edit-toolbar').val(toolbarconf); }, 500); - } + }; } - } + }; })(jQuery, Backdrop); diff --git a/js/tinymce-integration.js b/js/tinymce-integration.js index 353d0e9..fd07588 100644 --- a/js/tinymce-integration.js +++ b/js/tinymce-integration.js @@ -36,8 +36,8 @@ // Layouts block editing: image dialog opened from a block dialog, // results in upload (paste) handler to be undefined (nested iframes). // Only happens, if js aggregation is off. - if (typeof tinymceImageUploadHandler == 'function') { - options.images_upload_handler = tinymceImageUploadHandler; + if (typeof tinymceImageUploadHandler === 'function') { + options.images_upload_handler = tinymceImageUploadHandler;// jshint ignore:line } else { // We turn off pasting images in this case. Selecting via library, or @@ -50,14 +50,14 @@ let contentLang = options.language; // If this element's form has a language select list, toggle content lang // based on that value. - if (element.form.querySelector('#edit-langcode') != null) { + if (element.form.querySelector('#edit-langcode') !== null) { let languageToggle = element.form.querySelector('#edit-langcode'); - if (languageToggle.value != 'und') { + if (languageToggle.value !== 'und') { contentLang = languageToggle.value; } languageToggle.addEventListener('change', function (ev) { let langcode = ev.target.value; - if (langcode == 'und') { + if (langcode === 'und') { langcode = options.language; } let event = new CustomEvent('contentLangSwitch', { detail: langcode }); @@ -78,7 +78,7 @@ // @see https://github.com/tinymce/tinymce/issues/4830 editor.contentDocument.documentElement.setAttribute('lang', contentLang); // Unregister formats, if any. - if (typeof format.editorSettings.unregisterFmts != 'undefined') { + if (typeof format.editorSettings.unregisterFmts !== 'undefined') { let fmts = format.editorSettings.unregisterFmts; for (let i = 0; i < fmts.length; i++) { editor.formatter.unregister(fmts[i]); @@ -89,7 +89,7 @@ editor.addCommand('indent', function () {}); editor.addCommand('outdent', function () {}); // Register custom icons provided by plugins. - if (typeof format.editorSettings.iconRegistry != 'undefined') { + if (typeof format.editorSettings.iconRegistry !== 'undefined') { let icons = format.editorSettings.iconRegistry; for (let name in icons) { editor.ui.registry.addIcon(name, icons[name]); @@ -115,7 +115,7 @@ }, detach: function (element, format, trigger) { - if (trigger == 'serialize') { + if (trigger === 'serialize') { tinymce.triggerSave(); return; } @@ -142,7 +142,7 @@ autoResize: true, modal: true, target: '#tinymce-modal' - } + }; new Backdrop.ajax('tinymce-modal', $content.find('a').get(0), { accepts: 'application/vnd.backdrop-dialog', dialog: dialogSettings, @@ -165,7 +165,7 @@ }, 500); Backdrop.tinymce.saveCallback = saveCallback; } - } + }; $(window).on('dialog:beforecreate', function (e, dialog, $element, settings) { $('.tinymce-dialog-loading').animate({top: '-40px'}, function () { $(this).remove(); @@ -181,7 +181,7 @@ // Fires when hitting dialog Save or Close buttons. $(window).on('dialogclose', function(event, ui) { - if (event.target.id == 'tinymce-modal' && tinymce.activeEditor) { + if (event.target.id === 'tinymce-modal' && tinymce.activeEditor) { tinymce.activeEditor.iframeElement.focus(); } });