Browse Source

Small fixes for this change

* Removed redundant code.
* Renamed function to better reflect its behaviour.
* Marked `noDisable` and `noMobile` as optional.
tags/2.6.0
Jeroen Akkerman 7 months ago
parent
commit
f50c96bc01
3 changed files with 9 additions and 9 deletions
  1. 1
    1
      dist/easymde.min.js
  2. 6
    6
      src/js/easymde.js
  3. 2
    2
      types/easymde.d.ts

+ 1
- 1
dist/easymde.min.js
File diff suppressed because it is too large
View File


+ 6
- 6
src/js/easymde.js View File

@@ -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 || {};
var el = document.createElement('button');
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');
}

if (options.noMobile || options.className.indexOf('no-mobile') !== -1) {
if (options.noMobile) {
el.classList.add('no-mobile');
}

@@ -159,7 +159,7 @@ function createIcon(options, enableTooltips, shortcuts) {
var icon = document.createElement('i');
for (var iconClassIndex = 0; iconClassIndex < iconClasses.length; iconClassIndex++) {
var iconClass = iconClasses[iconClassIndex];
icon.classList.add(iconClass)
icon.classList.add(iconClass);
}
el.appendChild(icon);

@@ -1841,7 +1841,7 @@ EasyMDE.prototype.createToolbar = function (items) {
if (item === '|') {
el = createSep();
} else {
el = createIcon(item, self.options.toolbarTips, self.options.shortcuts);
el = createToolbarButton(item, self.options.toolbarTips, self.options.shortcuts);
}

// bind events, special for info

+ 2
- 2
types/easymde.d.ts View File

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

interface Options {

Loading…
Cancel
Save