Commit a715009e authored by Maxim Kadushkin's avatar Maxim Kadushkin

[Common] refactored plugin's messages

parent 0cc19d46
......@@ -258,30 +258,29 @@
};
var _onMessage = function(msg) {
if (msg && msg.frameEditorId == placeholderId) {
var events = _config.events || {},
handler = events[msg.event],
res;
if (msg.event === 'onRequestEditRights' && !handler) {
_applyEditRights(false, 'handler is\'n defined');
if ( msg ) {
if ( msg.type === "onExternalPluginMessage" ) {
_sendCommand(msg);
} else
if (msg.event === 'onInternalMessage' && msg.data && msg.data.type == 'localstorage') {
_callLocalStorage(msg.data.data);
} else {
if (msg.type === "onExternalPluginMessage") {
_sendCommand(msg);
return;
}
if (msg.event === 'onReady') {
_onReady();
}
if ( msg.frameEditorId == placeholderId ) {
var events = _config.events || {},
handler = events[msg.event],
res;
if (msg.event === 'onRequestEditRights' && !handler) {
_applyEditRights(false, 'handler is\'n defined');
} else if (msg.event === 'onInternalMessage' && msg.data && msg.data.type == 'localstorage') {
_callLocalStorage(msg.data.data);
} else {
if (msg.event === 'onReady') {
_onReady();
}
if (handler) {
res = handler.call(_self, { target: _self, data: msg.data });
if (msg.event === 'onSave' && res !== false) {
_processSaveResult(true);
if (handler) {
res = handler.call(_self, {target: _self, data: msg.data});
if (msg.event === 'onSave' && res !== false) {
_processSaveResult(true);
}
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment