Skip to content
This repository was archived by the owner on Nov 21, 2017. It is now read-only.

Commit 7dcbbf1

Browse files
committed
Merge pull request #153 from Deesen/master
Check if TinyMCE is defined before initializing #152
2 parents aaebf89 + 00e606e commit 7dcbbf1

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

assets/tvs/multitv/js/multitv.js

+28-24
Original file line numberDiff line numberDiff line change
@@ -698,14 +698,16 @@
698698
}
699699
},
700700
clearInputs: function (el) {
701-
$('.tabEditor', el).each(function () {
702-
var editorId = $(this).attr('id');
703-
if(tinyMCE.majorVersion == 4) {
704-
tinyMCE.execCommand('mceRemoveEditor', false, editorId);
705-
} else {
706-
tinyMCE.execCommand('mceRemoveControl', false, editorId);
707-
}
708-
});
701+
if (typeof tinyMCE !== 'undefined') {
702+
$('.tabEditor', el).each(function () {
703+
var editorId = $(this).attr('id');
704+
if(tinyMCE.majorVersion == 4) {
705+
tinyMCE.execCommand('mceRemoveEditor', false, editorId);
706+
} else {
707+
tinyMCE.execCommand('mceRemoveControl', false, editorId);
708+
}
709+
});
710+
}
709711
$(':input', el).each(function () {
710712
var inputtype = $(this).attr('type');
711713
var inputid = $(this).attr('id');
@@ -980,24 +982,26 @@
980982
$('.formtabradio:not(.active) input[type="radio"]', _this.fieldEditArea).prop('checked', false);
981983
$('.formtabradio.active input[type="radio"]', _this.fieldEditArea).prop('checked', true);
982984
}
983-
$('.tabEditor', _this.fieldEditArea).each(function () {
984-
var editorId = $(this).attr('id');
985-
if(tinyMCE.majorVersion == 4) {
986-
if(modxRTEbridge_tinymce4 != undefined) {
987-
var configObj = window[modxRTEbridge_tinymce4.default];
988-
configObj['selector'] = '#'+editorId;
989-
tinymce.init(configObj);
985+
if (typeof tinyMCE !== 'undefined') {
986+
$('.tabEditor', _this.fieldEditArea).each(function () {
987+
var editorId = $(this).attr('id');
988+
if(tinyMCE.majorVersion == 4) {
989+
if(modxRTEbridge_tinymce4 != undefined) {
990+
var configObj = window[modxRTEbridge_tinymce4.default];
991+
configObj['selector'] = '#'+editorId;
992+
tinyMCE.init(configObj);
993+
} else {
994+
tinyMCE.execCommand('mceAddEditor', false, editorId);
995+
}
990996
} else {
991-
tinyMCE.execCommand('mceAddEditor', false, editorId);
997+
tinyMCE.execCommand('mceAddControl', false, editorId);
992998
}
993-
} else {
994-
tinyMCE.execCommand('mceAddControl', false, editorId);
995-
}
996-
tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'height', '200px');
997-
tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'height', 'auto');
998-
tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'width', '100%');
999-
tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'width', '100%');
1000-
});
999+
tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'height', '200px');
1000+
tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'height', 'auto');
1001+
tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'width', '100%');
1002+
tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'width', '100%');
1003+
});
1004+
}
10011005
setTimeout(function () {
10021006
_this.editBox.colorbox.resize();
10031007
}, 250)

0 commit comments

Comments
 (0)