[Common] refactored plugin's messages

This commit is contained in:
Maxim Kadushkin 2017-03-03 12:45:37 +03:00
parent 0cc19d4640
commit a715009eee

View file

@ -258,22 +258,20 @@
}; };
var _onMessage = function(msg) { var _onMessage = function(msg) {
if (msg && msg.frameEditorId == placeholderId) { if ( msg ) {
if ( msg.type === "onExternalPluginMessage" ) {
_sendCommand(msg);
} else
if ( msg.frameEditorId == placeholderId ) {
var events = _config.events || {}, var events = _config.events || {},
handler = events[msg.event], handler = events[msg.event],
res; res;
if (msg.event === 'onRequestEditRights' && !handler) { if (msg.event === 'onRequestEditRights' && !handler) {
_applyEditRights(false, 'handler is\'n defined'); _applyEditRights(false, 'handler is\'n defined');
} else } else if (msg.event === 'onInternalMessage' && msg.data && msg.data.type == 'localstorage') {
if (msg.event === 'onInternalMessage' && msg.data && msg.data.type == 'localstorage') {
_callLocalStorage(msg.data.data); _callLocalStorage(msg.data.data);
} else { } else {
if (msg.type === "onExternalPluginMessage") {
_sendCommand(msg);
return;
}
if (msg.event === 'onReady') { if (msg.event === 'onReady') {
_onReady(); _onReady();
} }
@ -286,6 +284,7 @@
} }
} }
} }
}
}; };
var _checkConfigParams = function() { var _checkConfigParams = function() {