Small fixes for this change

* Removed redundant code.
* Renamed function to better reflect its behaviour.
* Marked `noDisable` and `noMobile` as optional.
pull/58/head
Jeroen Akkerman 5 years ago
parent 4385d733e5
commit f50c96bc01

File diff suppressed because one or more lines are too long

@ -113,9 +113,9 @@ function fixShortcut(name) {
/** /**
* Create icon element for toolbar. * Create button element for toolbar.
*/ */
function createIcon(options, enableTooltips, shortcuts) { function createToolbarButton(options, enableTooltips, shortcuts) {
options = options || {}; options = options || {};
var el = document.createElement('button'); var el = document.createElement('button');
el.className = options.name; el.className = options.name;
@ -131,11 +131,11 @@ function createIcon(options, enableTooltips, shortcuts) {
} }
} }
if (options.noDisable || options.className.indexOf('no-disable') !== -1) { if (options.noDisable) {
el.classList.add('no-disable'); el.classList.add('no-disable');
} }
if (options.noMobile || options.className.indexOf('no-mobile') !== -1) { if (options.noMobile) {
el.classList.add('no-mobile'); el.classList.add('no-mobile');
} }
@ -159,7 +159,7 @@ function createIcon(options, enableTooltips, shortcuts) {
var icon = document.createElement('i'); var icon = document.createElement('i');
for (var iconClassIndex = 0; iconClassIndex < iconClasses.length; iconClassIndex++) { for (var iconClassIndex = 0; iconClassIndex < iconClasses.length; iconClassIndex++) {
var iconClass = iconClasses[iconClassIndex]; var iconClass = iconClasses[iconClassIndex];
icon.classList.add(iconClass) icon.classList.add(iconClass);
} }
el.appendChild(icon); el.appendChild(icon);
@ -1841,7 +1841,7 @@ EasyMDE.prototype.createToolbar = function (items) {
if (item === '|') { if (item === '|') {
el = createSep(); el = createSep();
} else { } else {
el = createIcon(item, self.options.toolbarTips, self.options.shortcuts); el = createToolbarButton(item, self.options.toolbarTips, self.options.shortcuts);
} }
// bind events, special for info // bind events, special for info

@ -81,8 +81,8 @@ declare namespace EasyMDE {
action: string|((editor: EasyMDE) => void); action: string|((editor: EasyMDE) => void);
className: string; className: string;
title: string; title: string;
noDisable: boolean; noDisable?: boolean;
noMobile: boolean; noMobile?: boolean;
} }
interface Options { interface Options {

Loading…
Cancel
Save