12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- (function () {'use strict';
- var pathID,
- saveMessage = 'webapp-save',
- readMessage = 'webapp-read',
- excludedMessages = [readMessage, saveMessage];
- window.addEventListener('message', function(e) {
- if (e.origin !== window.location.origin ||
- (!Array.isArray(e.data) || excludedMessages.indexOf(e.data[0]) > -1)
- ) {
- return;
- }
- var svgString,
- messageType = e.data[0];
- switch (messageType) {
- case 'webapp-view':
-
- pathID = e.data[1];
-
- svgString = e.data[2];
- svgEditor.loadFromString(svgString);
-
-
- break;
- case 'webapp-save-end':
- alert('save complete for pathID ' + e.data[1] + '!');
- break;
- default:
- throw 'Unexpected mode';
- }
- }, false);
- window.postMessage([readMessage], window.location.origin !== 'null' ? window.location.origin : '*');
- svgEditor.addExtension('WebAppFind', function() {
- return {
- name: 'WebAppFind',
- svgicons: svgEditor.curConfig.extPath + 'executablebuilder-icocreator.svg',
- buttons: [{
- id: 'webappfind_ico_export',
- type: 'app_menu',
- title: 'Export ICO Image back to Disk',
- position: 4,
- events: {
- click: function () {
- if (!pathID) {
- return;
- }
- window.postMessage([saveMessage, pathID, svgEditor.canvas.getSvgString()], window.location.origin);
- }
- }
- }]
- };
- });
- }());
|