diff --git a/sdkjs-plugins/v1/plugins.dev.js b/sdkjs-plugins/v1/plugins.dev.js index f12d252f..9105a671 100644 --- a/sdkjs-plugins/v1/plugins.dev.js +++ b/sdkjs-plugins/v1/plugins.dev.js @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -18,234 +18,234 @@ (function(window, undefined){ - window.Asc = window.Asc || {}; - window.Asc.plugin = {}; + window.Asc = window.Asc || {}; + window.Asc.plugin = {}; - // ie channel - window.Asc.plugin.ie_channel = null; - window.Asc.plugin.ie_channel_check = function(e) { - var uagent = navigator.userAgent.toLowerCase(); - if (uagent.indexOf("msie") > -1 || uagent.indexOf("trident") > -1) - { - if (e.ports && e.ports[0]) - this.ie_channel = e.ports[0]; - } - }; + // ie channel + window.Asc.plugin.ie_channel = null; + window.Asc.plugin.ie_channel_check = function(e) { + var uagent = navigator.userAgent.toLowerCase(); + if (uagent.indexOf("msie") > -1 || uagent.indexOf("trident") > -1) + { + if (e.ports && e.ports[0]) + this.ie_channel = e.ports[0]; + } + }; - function _sendMessageToParent(data) { - if (window.Asc.plugin.ie_channel) - window.Asc.plugin.ie_channel.postMessage(data); - else - window.parent.postMessage(data, "*"); - } + function _sendMessageToParent(data) { + if (window.Asc.plugin.ie_channel) + window.Asc.plugin.ie_channel.postMessage(data); + else + window.parent.postMessage(data, "*"); + } - window.Asc.plugin.tr_init = false; - window.Asc.plugin.tr = function(val) { return val; } + window.Asc.plugin.tr_init = false; + window.Asc.plugin.tr = function(val) { return val; } - window.Asc.scope = {}; - window.Asc.scope.prototype = { - clear : function() { - for (var i in window.Asc.scope) - delete window.Asc.scope[i]; - } - }; + window.Asc.scope = {}; + window.Asc.scope.prototype = { + clear : function() { + for (var i in window.Asc.scope) + delete window.Asc.scope[i]; + } + }; - function extend(obj, plugin) { - if (!obj || !("object" == typeof(obj) || "array" == typeof(obj))) - return obj; + function extend(obj, plugin) { + if (!obj || !("object" == typeof(obj) || "array" == typeof(obj))) + return obj; - var dst = (plugin === undefined) ? {} : plugin; - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - dst[prop] = (obj[prop] && "object" === typeof obj[prop]) ? extend(obj[prop]) : obj[prop]; - } - } - return dst; - } + var dst = (plugin === undefined) ? {} : plugin; + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + dst[prop] = (obj[prop] && "object" === typeof obj[prop]) ? extend(obj[prop]) : obj[prop]; + } + } + return dst; + } - function getSearchParam(name) { - var _windowSearch = window.location.search; - var _nameSearch = name + "="; - var _pos1 = _windowSearch.indexOf(_nameSearch); - if (_pos1 >= 0) - { - _pos1 += _nameSearch.length; - var _pos2 = _windowSearch.indexOf("&", _pos1); - if (_pos2 < 0) - _pos2 = _windowSearch.length; + function getSearchParam(name) { + var _windowSearch = window.location.search; + var _nameSearch = name + "="; + var _pos1 = _windowSearch.indexOf(_nameSearch); + if (_pos1 >= 0) + { + _pos1 += _nameSearch.length; + var _pos2 = _windowSearch.indexOf("&", _pos1); + if (_pos2 < 0) + _pos2 = _windowSearch.length; - return _windowSearch.substring(_pos1, _pos2); - } - return undefined; - } + return _windowSearch.substring(_pos1, _pos2); + } + return undefined; + } - function checkPluginWindow() { - var windowID = getSearchParam("windowID"); - if (windowID) { - window.Asc.plugin.windowID = windowID; + function checkPluginWindow() { + var windowID = getSearchParam("windowID"); + if (windowID) { + window.Asc.plugin.windowID = windowID; - if (!window.Asc.plugin.guid) - window.Asc.plugin.guid = decodeURIComponent(getSearchParam("guid")); - } + if (!window.Asc.plugin.guid) + window.Asc.plugin.guid = decodeURIComponent(getSearchParam("guid")); + } - return (undefined !== windowID) ? true : false; - } + return (undefined !== windowID) ? true : false; + } - window.onload = function() - { - if (!window.Asc || !window.Asc.plugin) - return; + window.onload = function() + { + if (!window.Asc || !window.Asc.plugin) + return; - var xhr = new XMLHttpRequest(); - xhr.open("get", "./config.json", true); - xhr.responseType = "json"; - xhr.onload = function() { - if (!window.Asc || !window.Asc.plugin) - return; - - if (xhr.status === 404) - return xhr.onerror(); + var xhr = new XMLHttpRequest(); + xhr.open("get", "./config.json", true); + xhr.responseType = "json"; + xhr.onload = function() { + if (!window.Asc || !window.Asc.plugin) + return; + + if (xhr.status === 404) + return xhr.onerror(); - if (xhr.status == 200 || (xhr.status == 0 && xhr.readyState == 4)) { - var objConfig = xhr.response; - if ((typeof objConfig) == "string") - objConfig = JSON.parse(objConfig); + if (xhr.status == 200 || (xhr.status == 0 && xhr.readyState == 4)) { + var objConfig = xhr.response; + if ((typeof objConfig) == "string") + objConfig = JSON.parse(objConfig); - extend(objConfig, window.Asc.plugin); + extend(objConfig, window.Asc.plugin); - var obj = { - type : "initialize", - guid : window.Asc.plugin.guid - }; + var obj = { + type : "initialize", + guid : window.Asc.plugin.guid + }; - if (checkPluginWindow()) { - obj.windowID = window.Asc.plugin.windowID; - } + if (checkPluginWindow()) { + obj.windowID = window.Asc.plugin.windowID; + } - var _body = document.body; - if (_body && true !== window.Asc.plugin.enableDrops) { - _body.ondrop = function(e) { - if (e && e.preventDefault) - e.preventDefault(); - return false; - }; - _body.ondragenter = function(e) { - if (e && e.preventDefault) - e.preventDefault(); - return false; - }; - _body.ondragover = function(e) { - if (e && e.preventDefault) - e.preventDefault(); - if (e && e.dataTransfer) - e.dataTransfer.dropEffect = "none"; - return false; - }; - } + var _body = document.body; + if (_body && true !== window.Asc.plugin.enableDrops) { + _body.ondrop = function(e) { + if (e && e.preventDefault) + e.preventDefault(); + return false; + }; + _body.ondragenter = function(e) { + if (e && e.preventDefault) + e.preventDefault(); + return false; + }; + _body.ondragover = function(e) { + if (e && e.preventDefault) + e.preventDefault(); + if (e && e.dataTransfer) + e.dataTransfer.dropEffect = "none"; + return false; + }; + } - // ie11 not support message from another domain - window.Asc.plugin._initInternal = true; - window.parent.postMessage(JSON.stringify(obj), "*"); - } - }; - xhr.onerror = function() { - if (!window.Asc || !window.Asc.plugin) - return; + // ie11 not support message from another domain + window.Asc.plugin._initInternal = true; + window.parent.postMessage(JSON.stringify(obj), "*"); + } + }; + xhr.onerror = function() { + if (!window.Asc || !window.Asc.plugin) + return; - if (checkPluginWindow()) { - var obj = { - type : "initialize", - guid : window.Asc.plugin.guid - }; - obj.windowID = window.Asc.plugin.windowID; + if (checkPluginWindow()) { + var obj = { + type : "initialize", + guid : window.Asc.plugin.guid + }; + obj.windowID = window.Asc.plugin.windowID; - // ie11 not support message from another domain - window.Asc.plugin._initInternal = true; - window.parent.postMessage(JSON.stringify(obj), "*"); - } - } - xhr.send(); - }; + // ie11 not support message from another domain + window.Asc.plugin._initInternal = true; + window.parent.postMessage(JSON.stringify(obj), "*"); + } + } + xhr.send(); + }; - window.Asc.supportOrigins = {}; - window.Asc.supportOrigins[window.origin] = true; + window.Asc.supportOrigins = {}; + window.Asc.supportOrigins[window.origin] = true; - function onMessage(event) { - if (!window.Asc || !window.Asc.plugin) - return; + function onMessage(event) { + if (!window.Asc || !window.Asc.plugin) + return; - if (window.plugin_onMessage) { - if (!window.Asc.supportOrigins[event.origin]) - return; - window.plugin_onMessage(event); - return; - } + if (window.plugin_onMessage) { + if (!window.Asc.supportOrigins[event.origin]) + return; + window.plugin_onMessage(event); + return; + } - if (!window.Asc.plugin._initInternal) - return; + if (!window.Asc.plugin._initInternal) + return; - if (typeof(event.data) == "string") { - var pluginData = {}; - try { - pluginData = JSON.parse(event.data); - } - catch(err) { - pluginData = {}; - } + if (typeof(event.data) == "string") { + var pluginData = {}; + try { + pluginData = JSON.parse(event.data); + } + catch(err) { + pluginData = {}; + } - if (pluginData.type == "plugin_init") { - window.Asc.supportOrigins[event.origin] = true; - window.Asc.plugin.ie_channel_check(event); - eval(pluginData.data); - } - } - } + if (pluginData.type == "plugin_init") { + window.Asc.supportOrigins[event.origin] = true; + window.Asc.plugin.ie_channel_check(event); + eval(pluginData.data); + } + } + } - if (window.addEventListener) - window.addEventListener("message", onMessage, false); - else - window.attachEvent("onmessage", onMessage); + if (window.addEventListener) + window.addEventListener("message", onMessage, false); + else + window.attachEvent("onmessage", onMessage); - window.Asc.plugin._attachCustomMenuClickEvent = function(type, id, action) - { - if (!this[type]) - this[type] = {}; + window.Asc.plugin._attachCustomMenuClickEvent = function(type, id, action) + { + if (!this[type]) + this[type] = {}; - this[type][id] = action; - }; - window.Asc.plugin._onCustomMenuClick = function(type, id) - { - // parse data from id: text from item. - var itemId = id; - var itemData = undefined; - var itemPos = itemId.indexOf("_oo_sep_"); - if (-1 !== itemPos) - { - itemData = itemId.substring(itemPos + 8); - itemId = itemId.substring(0, itemPos); - } + this[type][id] = action; + }; + window.Asc.plugin._onCustomMenuClick = function(type, id) + { + // parse data from id: text from item. + var itemId = id; + var itemData = undefined; + var itemPos = itemId.indexOf("_oo_sep_"); + if (-1 !== itemPos) + { + itemData = itemId.substring(itemPos + 8); + itemId = itemId.substring(0, itemPos); + } - if (this[type] && this[type][itemId]) - this[type][itemId].call(this, itemData); - }; + if (this[type] && this[type][itemId]) + this[type][itemId].call(this, itemData); + }; - window.Asc.plugin.attachContextMenuClickEvent = function(id, action) - { - this._attachCustomMenuClickEvent("contextMenuEvents", id, action); - }; - window.Asc.plugin.event_onContextMenuClick = function(id) - { - this._onCustomMenuClick("contextMenuEvents", id); - }; + window.Asc.plugin.attachContextMenuClickEvent = function(id, action) + { + this._attachCustomMenuClickEvent("contextMenuEvents", id, action); + }; + window.Asc.plugin.event_onContextMenuClick = function(id) + { + this._onCustomMenuClick("contextMenuEvents", id); + }; - window.Asc.plugin.attachToolbarMenuClickEvent = function(id, action) - { - this._attachCustomMenuClickEvent("toolbarMenuEvents", id, action); - }; - window.Asc.plugin.event_onToolbarMenuClick = function(id) - { - this._onCustomMenuClick("toolbarMenuEvents", id); - }; + window.Asc.plugin.attachToolbarMenuClickEvent = function(id, action) + { + this._attachCustomMenuClickEvent("toolbarMenuEvents", id, action); + }; + window.Asc.plugin.event_onToolbarMenuClick = function(id) + { + this._onCustomMenuClick("toolbarMenuEvents", id); + }; window.Asc.plugin.event_onContentControlButtonClick = function(data) { const eventName = "ContentControlButtonEvents"; @@ -269,55 +269,55 @@ this[eventName][buttonId] = action; }; - window.Asc.plugin.attachEvent = function(id, action) - { - var pluginObj = window.Asc.plugin; - if (!pluginObj._events) - pluginObj._events = {}; + window.Asc.plugin.attachEvent = function(id, action) + { + var pluginObj = window.Asc.plugin; + if (!pluginObj._events) + pluginObj._events = {}; - pluginObj._events[id] = action; - }; - window.Asc.plugin.detachEvent = function(id) - { - var pluginObj = window.Asc.plugin; - if (pluginObj._events && pluginObj._events[id]) - delete pluginObj._events[id]; - }; - window.Asc.plugin.onEvent = function(id, data) - { - var pluginObj = window.Asc.plugin; - if (pluginObj._events && pluginObj._events[id]) - pluginObj._events[id].call(pluginObj, data); - }; + pluginObj._events[id] = action; + }; + window.Asc.plugin.detachEvent = function(id) + { + var pluginObj = window.Asc.plugin; + if (pluginObj._events && pluginObj._events[id]) + delete pluginObj._events[id]; + }; + window.Asc.plugin.onEvent = function(id, data) + { + var pluginObj = window.Asc.plugin; + if (pluginObj._events && pluginObj._events[id]) + pluginObj._events[id].call(pluginObj, data); + }; - window.Asc.plugin.attachEditorEvent = function(id, action) - { - window.Asc.plugin["event_" + id] = action.bind(window.Asc.plugin); + window.Asc.plugin.attachEditorEvent = function(id, action) + { + window.Asc.plugin["event_" + id] = action.bind(window.Asc.plugin); - _sendMessageToParent(JSON.stringify({ - "guid" : window.Asc.plugin.guid, - "type" : "attachEvent", - "name" : id - })); - }; - window.Asc.plugin.detachEditorEvent = function(id) - { - if (window.Asc.plugin["event_" + id]) - delete window.Asc.plugin["event_" + id]; + _sendMessageToParent(JSON.stringify({ + "guid" : window.Asc.plugin.guid, + "type" : "attachEvent", + "name" : id + })); + }; + window.Asc.plugin.detachEditorEvent = function(id) + { + if (window.Asc.plugin["event_" + id]) + delete window.Asc.plugin["event_" + id]; - _sendMessageToParent(JSON.stringify({ - "guid" : window.Asc.plugin.guid, - "type" : "detachEvent", - "name" : id - })); - }; + _sendMessageToParent(JSON.stringify({ + "guid" : window.Asc.plugin.guid, + "type" : "detachEvent", + "name" : id + })); + }; - window.onunload = function() { - if (window.addEventListener) - window.removeEventListener("message", onMessage, false); - else - window.detachEvent("onmessage", onMessage); - }; + window.onunload = function() { + if (window.addEventListener) + window.removeEventListener("message", onMessage, false); + else + window.detachEvent("onmessage", onMessage); + }; })(window, undefined); @@ -477,7 +477,7 @@ { let item = { id : this.id, - text : translateItem(this.text) + text : translateItem(this.text) }; if (this.hint !== null) @@ -566,12 +566,12 @@ }; ButtonContextMenu.prototype.onContextMenuShowAnalyze = function(options, parent) - { + { return false; }; ButtonContextMenu.prototype.onContextMenuShowExtendItem = function(options, item) - { + { }; ButtonContextMenu.prototype.onContextMenuShow = function(options, parent) @@ -600,7 +600,7 @@ parent.items = []; let curItem = this.toItem(); - this.onContextMenuShowExtendItem(options, curItem); + this.onContextMenuShowExtendItem(options, curItem); if (this.childs) { @@ -636,7 +636,7 @@ }; ButtonToolbar.prototype.toItem = function(items) - { + { let item = Button.prototype.toItem.call(this); item.type = this.type; return item; diff --git a/sdkjs-plugins/v1/plugins.js b/sdkjs-plugins/v1/plugins.js index a521dd9d..7bdecad7 100644 --- a/sdkjs-plugins/v1/plugins.js +++ b/sdkjs-plugins/v1/plugins.js @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,20 +16,23 @@ * */ -(function(b,p){function r(a){b.Asc.plugin.ie_channel?b.Asc.plugin.ie_channel.postMessage(a):b.parent.postMessage(a,"*")}function n(a,d){if(!a||"object"!=typeof a&&"array"!=typeof a)return a;d=d===p?{}:d;for(var f in a)a.hasOwnProperty(f)&&(d[f]=a[f]&&"object"===typeof a[f]?n(a[f]):a[f]);return d}function m(a){var d=b.location.search,f=a+"=";a=d.indexOf(f);return 0<=a?(a+=f.length,f=d.indexOf("&",a),0>f&&(f=d.length),d.substring(a,f)):p}function k(){var a=m("windowID");a&&(b.Asc.plugin.windowID=a, -b.Asc.plugin.guid||(b.Asc.plugin.guid=decodeURIComponent(m("guid"))));return p!==a?!0:!1}function l(a){if(b.Asc&&b.Asc.plugin)if(b.plugin_onMessage)b.Asc.supportOrigins[a.origin]&&b.plugin_onMessage(a);else if(b.Asc.plugin._initInternal&&"string"==typeof a.data){var d={};try{d=JSON.parse(a.data)}catch(f){d={}}"plugin_init"==d.type&&(b.Asc.supportOrigins[a.origin]=!0,b.Asc.plugin.ie_channel_check(a),eval(d.data))}}b.Asc=b.Asc||{};b.Asc.plugin={};b.Asc.plugin.ie_channel=null;b.Asc.plugin.ie_channel_check= -function(a){var d=navigator.userAgent.toLowerCase();(-1f&&(f=c.length),c.substring(a,f)):t}function l(){var a=m("windowID");a&&(b.Asc.plugin.windowID=a, +b.Asc.plugin.guid||(b.Asc.plugin.guid=decodeURIComponent(m("guid"))));return t!==a?!0:!1}function n(a){if(b.Asc&&b.Asc.plugin)if(b.plugin_onMessage)b.Asc.supportOrigins[a.origin]&&b.plugin_onMessage(a);else if(b.Asc.plugin._initInternal&&"string"==typeof a.data){var c={};try{c=JSON.parse(a.data)}catch(f){c={}}"plugin_init"==c.type&&(b.Asc.supportOrigins[a.origin]=!0,b.Asc.plugin.ie_channel_check(a),eval(c.data))}}b.Asc=b.Asc||{};b.Asc.plugin={};b.Asc.plugin.ie_channel=null;b.Asc.plugin.ie_channel_check= +function(a){var c=navigator.userAgent.toLowerCase();(-1