Skip to content

Commit

Permalink
replace var with let and const.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwins committed Oct 4, 2017
1 parent be2c06f commit b4f9711
Show file tree
Hide file tree
Showing 27 changed files with 706 additions and 705 deletions.
26 changes: 12 additions & 14 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ module.exports = function (grunt) {
version: '8.0',
platform: 'windows XP'
},
'SL_EDGE': {
base: 'SauceLabs',
browserName: 'microsoftedge',
version: 'latest',
platform: 'windows 10'
},
'SL_SAFARI': {
base: 'SauceLabs',
browserName: 'safari',
  version: 'latest',
  platform: 'OS X 10.12'
},
*/
'SL_IE9': {
base: 'SauceLabs',
Expand All @@ -28,20 +40,6 @@ module.exports = function (grunt) {
version: '11.0',
platform: 'windows 8.1'
},
/* TODO comment below
'SL_EDGE': {
base: 'SauceLabs',
browserName: 'microsoftedge',
version: 'latest',
platform: 'windows 10'
},
*/
'SL_SAFARI': {
base: 'SauceLabs',
browserName: 'safari',
  version: 'latest',
  platform: 'OS X 10.12'
},
'SL_CHROME': {
base: 'SauceLabs',
browserName: 'chrome',
Expand Down
34 changes: 17 additions & 17 deletions src/js/base/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class Context {
* destory modules and other resources and initialize it again
*/
reset() {
var disabled = this.isDisabled();
const disabled = this.isDisabled();
this.code(dom.emptyPara);
this._destroy();
this._initialize();
Expand All @@ -55,12 +55,12 @@ export default class Context {

_initialize() {
// add optional buttons
var buttons = $.extend({}, this.options.buttons);
const buttons = $.extend({}, this.options.buttons);
Object.keys(buttons).forEach((key) => {
this.memo('button.' + key, buttons[key]);
});

var modules = $.extend({}, this.options.modules, $.summernote.plugins || {});
const modules = $.extend({}, this.options.modules, $.summernote.plugins || {});

// add and initialize modules
Object.keys(modules).forEach((key) => {
Expand All @@ -86,7 +86,7 @@ export default class Context {
}

code(html) {
var isActivated = this.invoke('codeview.isActivated');
const isActivated = this.invoke('codeview.isActivated');

if (html === undefined) {
this.invoke('codeview.sync');
Expand Down Expand Up @@ -124,18 +124,18 @@ export default class Context {
}

triggerEvent() {
var namespace = lists.head(arguments);
var args = lists.tail(lists.from(arguments));
const namespace = lists.head(arguments);
const args = lists.tail(lists.from(arguments));

var callback = this.options.callbacks[func.namespaceToCamel(namespace, 'on')];
const callback = this.options.callbacks[func.namespaceToCamel(namespace, 'on')];
if (callback) {
callback.apply(this.$note[0], args);
}
this.$note.trigger('summernote.' + namespace, args);
}

initializeModule(key) {
var module = this.modules[key];
const module = this.modules[key];
module.shouldInitialize = module.shouldInitialize || func.ok;
if (!module.shouldInitialize()) {
return;
Expand Down Expand Up @@ -165,7 +165,7 @@ export default class Context {
}

removeModule(key) {
var module = this.modules[key];
const module = this.modules[key];
if (module.shouldInitialize()) {
if (module.events) {
dom.detachEvents(this.$note, module.events);
Expand Down Expand Up @@ -207,21 +207,21 @@ export default class Context {
createInvokeHandler(namespace, value) {
return (event) => {
event.preventDefault();
var $target = $(event.target);
const $target = $(event.target);
this.invoke(namespace, value || $target.closest('[data-value]').data('value'), $target);
};
}

invoke() {
var namespace = lists.head(arguments);
var args = lists.tail(lists.from(arguments));
const namespace = lists.head(arguments);
const args = lists.tail(lists.from(arguments));

var splits = namespace.split('.');
var hasSeparator = splits.length > 1;
var moduleName = hasSeparator && lists.head(splits);
var methodName = hasSeparator ? lists.last(splits) : lists.head(splits);
const splits = namespace.split('.');
const hasSeparator = splits.length > 1;
const moduleName = hasSeparator && lists.head(splits);
const methodName = hasSeparator ? lists.last(splits) : lists.head(splits);

var module = this.modules[moduleName || 'editor'];
const module = this.modules[moduleName || 'editor'];
if (!moduleName && this[methodName]) {
return this[methodName].apply(this, args);
} else if (module && module[methodName] && module.shouldInitialize()) {
Expand Down
4 changes: 2 additions & 2 deletions src/js/base/core/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function readFileAsDataURL(file) {
return $.Deferred((deferred) => {
$.extend(new FileReader(), {
onload: (e) => {
var dataURL = e.target.result;
const dataURL = e.target.result;
deferred.resolve(dataURL);
},
onerror: (err) => {
Expand All @@ -32,7 +32,7 @@ export function readFileAsDataURL(file) {
*/
export function createImage(url) {
return $.Deferred((deferred) => {
var $img = $('<img>');
const $img = $('<img>');

$img.one('load', () => {
$img.off('error abort');
Expand Down
Loading

0 comments on commit b4f9711

Please sign in to comment.