mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-02-10 18:05:06 +08:00
Format code and minimize dev script
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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();(-1<d.indexOf("msie")||-1<d.indexOf("trident"))&&a.ports&&a.ports[0]&&(this.ie_channel=a.ports[0])};b.Asc.plugin.tr_init=!1;b.Asc.plugin.tr=function(a){return a};b.Asc.scope={};b.Asc.scope.prototype={clear:function(){for(var a in b.Asc.scope)delete b.Asc.scope[a]}};b.onload=function(){if(b.Asc&&b.Asc.plugin){var a=new XMLHttpRequest;a.open("get","./config.json",!0);a.responseType="json";a.onload=function(){if(b.Asc&&b.Asc.plugin){if(404===a.status)return a.onerror();
|
||||
if(200==a.status||0==a.status&&4==a.readyState){var d=a.response;"string"==typeof d&&(d=JSON.parse(d));n(d,b.Asc.plugin);d={type:"initialize",guid:b.Asc.plugin.guid};k()&&(d.windowID=b.Asc.plugin.windowID);var f=document.body;f&&!0!==b.Asc.plugin.enableDrops&&(f.ondrop=function(c){c&&c.preventDefault&&c.preventDefault();return!1},f.ondragenter=function(c){c&&c.preventDefault&&c.preventDefault();return!1},f.ondragover=function(c){c&&c.preventDefault&&c.preventDefault();c&&c.dataTransfer&&(c.dataTransfer.dropEffect=
|
||||
"none");return!1});b.Asc.plugin._initInternal=!0;b.parent.postMessage(JSON.stringify(d),"*")}}};a.onerror=function(){if(b.Asc&&b.Asc.plugin&&k()){var d={type:"initialize",guid:b.Asc.plugin.guid};d.windowID=b.Asc.plugin.windowID;b.Asc.plugin._initInternal=!0;b.parent.postMessage(JSON.stringify(d),"*")}};a.send()}};b.Asc.supportOrigins={};b.Asc.supportOrigins[b.origin]=!0;b.addEventListener?b.addEventListener("message",l,!1):b.attachEvent("onmessage",l);b.Asc.plugin._attachCustomMenuClickEvent=function(a,
|
||||
d,f){this[a]||(this[a]={});this[a][d]=f};b.Asc.plugin._onCustomMenuClick=function(a,d){var f=p,c=d.indexOf("_oo_sep_");-1!==c&&(f=d.substring(c+8),d=d.substring(0,c));this[a]&&this[a][d]&&this[a][d].call(this,f)};b.Asc.plugin.attachContextMenuClickEvent=function(a,d){this._attachCustomMenuClickEvent("contextMenuEvents",a,d)};b.Asc.plugin.event_onContextMenuClick=function(a){this._onCustomMenuClick("contextMenuEvents",a)};b.Asc.plugin.attachToolbarMenuClickEvent=function(a,d){this._attachCustomMenuClickEvent("toolbarMenuEvents",
|
||||
a,d)};b.Asc.plugin.event_onToolbarMenuClick=function(a){this._onCustomMenuClick("toolbarMenuEvents",a)};b.Asc.plugin.attachEvent=function(a,d){var f=b.Asc.plugin;f._events||(f._events={});f._events[a]=d};b.Asc.plugin.detachEvent=function(a){var d=b.Asc.plugin;d._events&&d._events[a]&&delete d._events[a]};b.Asc.plugin.onEvent=function(a,d){var f=b.Asc.plugin;f._events&&f._events[a]&&f._events[a].call(f,d)};b.Asc.plugin.attachEditorEvent=function(a,d){b.Asc.plugin["event_"+a]=d.bind(b.Asc.plugin);r(JSON.stringify({guid:b.Asc.plugin.guid,
|
||||
type:"attachEvent",name:a}))};b.Asc.plugin.detachEditorEvent=function(a){b.Asc.plugin["event_"+a]&&delete b.Asc.plugin["event_"+a];r(JSON.stringify({guid:b.Asc.plugin.guid,type:"detachEvent",name:a}))};b.onunload=function(){b.addEventListener?b.removeEventListener("message",l,!1):b.detachEvent("onmessage",l)}})(window,void 0);
|
||||
(function(b,p){function r(){function c(){return(65536+e[h++]).toString(16).substring(1)}if(!b.crypto||!b.crypto.getRandomValues){function g(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return g()+g()+"-"+g()+"-"+g()+"-"+g()+"-"+g()+g()+g()}var e=new Uint16Array(8);b.crypto.getRandomValues(e);var h=0;return c()+c()+"-"+c()+"-"+c()+"-"+c()+"-"+c()+c()+c()}function n(c){return b.Asc.plugin.tr(c)}function m(c,e){this.itemType=f.None;this.editors=["word","cell","slide"];this.id=
|
||||
e===p?r():e;this.icons=null;this.text="";this.hint=null;this.data="";this.separator=!1;this.lockInViewMode=!0;this.disabled=this.enableToggle=!1;this.parent=c?c:null;this.childs=null;this.parent&&(this.parent.childs||(this.parent.childs=[]),this.parent.childs.push(this))}function k(c,e){m.call(this,c,e);this.itemType=f.ContextMenu;this.showOnOptionsType=[];a.Buttons.ButtonsContextMenu.push(this)}function l(c,e){m.call(this,c,e);this.itemType=f.Toolbar;this.type=d.BigButton;this.tab="";a.Buttons.ButtonsToolbar.push(this)}
|
||||
b.Asc=b.Asc||{};var a=b.Asc;a.Buttons={};a.Buttons.ButtonsContextMenu=[];a.Buttons.ButtonsToolbar=[];a.Buttons.registerContextMenu=function(){b.Asc.plugin.attachEvent("onContextMenuShow",function(c){if(c){var e={guid:b.Asc.plugin.guid};for(let h=0,g=a.Buttons.ButtonsContextMenu.length;h<g;h++){let q=a.Buttons.ButtonsContextMenu[h];if(null===q.parent)q.onContextMenuShow(c,e)}e.items&&b.Asc.plugin.executeMethod("AddContextMenuItem",[e])}})};a.Buttons.registerToolbarMenu=function(){let c={guid:b.Asc.plugin.guid,
|
||||
tabs:[]};for(let e=0,h=a.Buttons.ButtonsToolbar.length;e<h;e++){let g=a.Buttons.ButtonsToolbar[e];null===g.parent&&g.toToolbar(c);if(g.menu)for(item of g.menu)item.onclick&&b.Asc.plugin.attachToolbarMenuClickEvent(item.id,item.onclick)}0<c.tabs.length&&b.Asc.plugin.executeMethod("AddToolbarMenuItem",[c])};var d={Button:"button",BigButton:"big-button"},f={None:0,ContextMenu:1,Toolbar:2};m.prototype.toItem=function(){let c={id:this.id,text:n(this.text)};null!==this.hint&&(c.hint=n(""===this.hint?this.hint:
|
||||
this.text));this.separator&&(c.separator=!0);this.data&&(c.data=this.data);this.lockInViewMode&&(c.lockInViewMode=!0);this.enableToggle&&(c.enableToggle=!0);this.disabled&&(c.disabled=!0);this.icons&&(c.icons=this.icons);this.itemType===f.Toolbar&&(c.type=this.type);this.menu&&(c.items=this.menu.map(function(e){e.text=n(e.text);return e}));this.split&&(c.split=!0);return c};m.prototype.attachOnClick=function(c){};m.prototype.onClick=function(){console.log("BUTTON: "+this.text)};k.prototype=Object.create(m.prototype);
|
||||
k.prototype.constructor=k;k.prototype.copy=function(){let c=new k(this.parent,this.id);c.editors=this.editors;c.separator=this.separator;c.lockInViewMode=this.lockInViewMode;c.enableToggle=this.enableToggle;c.disabled=this.disabled;c.showOnOptionsType=this.showOnOptionsType.slice();return c};k.prototype.addCheckers=function(){let c=arguments.length;this.showOnOptionsType=Array(c);for(let e=0;e<c;e++)this.showOnOptionsType[e]=arguments[e]};k.prototype.attachOnClick=function(c){b.Asc.plugin.attachContextMenuClickEvent(this.id,
|
||||
c)};k.prototype.onContextMenuShowAnalyze=function(c,e){return!1};k.prototype.onContextMenuShowExtendItem=function(c,e){};k.prototype.onContextMenuShow=function(c,e){if(!this.onContextMenuShowAnalyze(c,e)){var h=!1;for(let g=0,q=this.editors.length;g<q;g++)if(a.plugin.info.editorType===this.editors[g]){h=!0;break}if(h)for(let g=0,q=this.showOnOptionsType.length;g<q;g++)if(c.type===this.showOnOptionsType[g]||"All"===this.showOnOptionsType[g]){e.items||(e.items=[]);h=this.toItem();this.onContextMenuShowExtendItem(c,
|
||||
h);if(this.childs)for(let t=0,u=this.childs.length;t<u;t++)this.childs[t].onContextMenuShow(c,h);e.items.push(h);break}}};l.prototype=Object.create(m.prototype);l.prototype.constructor=l;l.prototype.attachOnClick=function(c){b.Asc.plugin.attachToolbarMenuClickEvent(this.id,c)};l.prototype.toItem=function(c){c=m.prototype.toItem.call(this);c.type=this.type;return c};l.prototype.toToolbar=function(c){if(null===this.parent){var e={id:this.id,text:n(this.text),items:[]};null!==this.hint&&(e.hint=n(""===
|
||||
this.hint?this.hint:this.text));c.tabs.push(e)}else e=this.toItem(),c.items||(c.items=[]),c.items.push(e);if(this.childs)for(let h=0,g=this.childs.length;h<g;h++)this.childs[h].toToolbar(e)};a.ToolbarButtonType=d;a.ButtonContextMenu=k;a.ButtonToolbar=l})(window);
|
||||
(function(b,t){function v(a){b.Asc.plugin.ie_channel?b.Asc.plugin.ie_channel.postMessage(a):b.parent.postMessage(a,"*")}function q(a,c){if(!a||"object"!=typeof a&&"array"!=typeof a)return a;c=c===t?{}:c;for(var f in a)a.hasOwnProperty(f)&&(c[f]=a[f]&&"object"===typeof a[f]?q(a[f]):a[f]);return c}function m(a){var c=b.location.search,f=a+"=";a=c.indexOf(f);return 0<=a?(a+=f.length,f=c.indexOf("&",a),0>f&&(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<c.indexOf("msie")||-1<c.indexOf("trident"))&&a.ports&&a.ports[0]&&(this.ie_channel=a.ports[0])};b.Asc.plugin.tr_init=!1;b.Asc.plugin.tr=function(a){return a};b.Asc.scope={};b.Asc.scope.prototype={clear:function(){for(var a in b.Asc.scope)delete b.Asc.scope[a]}};b.onload=function(){if(b.Asc&&b.Asc.plugin){var a=new XMLHttpRequest;a.open("get","./config.json",!0);a.responseType="json";a.onload=function(){if(b.Asc&&b.Asc.plugin){if(404===a.status)return a.onerror();
|
||||
if(200==a.status||0==a.status&&4==a.readyState){var c=a.response;"string"==typeof c&&(c=JSON.parse(c));q(c,b.Asc.plugin);c={type:"initialize",guid:b.Asc.plugin.guid};l()&&(c.windowID=b.Asc.plugin.windowID);var f=document.body;f&&!0!==b.Asc.plugin.enableDrops&&(f.ondrop=function(h){h&&h.preventDefault&&h.preventDefault();return!1},f.ondragenter=function(h){h&&h.preventDefault&&h.preventDefault();return!1},f.ondragover=function(h){h&&h.preventDefault&&h.preventDefault();h&&h.dataTransfer&&(h.dataTransfer.dropEffect=
|
||||
"none");return!1});b.Asc.plugin._initInternal=!0;b.parent.postMessage(JSON.stringify(c),"*")}}};a.onerror=function(){if(b.Asc&&b.Asc.plugin&&l()){var c={type:"initialize",guid:b.Asc.plugin.guid};c.windowID=b.Asc.plugin.windowID;b.Asc.plugin._initInternal=!0;b.parent.postMessage(JSON.stringify(c),"*")}};a.send()}};b.Asc.supportOrigins={};b.Asc.supportOrigins[b.origin]=!0;b.addEventListener?b.addEventListener("message",n,!1):b.attachEvent("onmessage",n);b.Asc.plugin._attachCustomMenuClickEvent=function(a,
|
||||
c,f){this[a]||(this[a]={});this[a][c]=f};b.Asc.plugin._onCustomMenuClick=function(a,c){var f=t,h=c.indexOf("_oo_sep_");-1!==h&&(f=c.substring(h+8),c=c.substring(0,h));this[a]&&this[a][c]&&this[a][c].call(this,f)};b.Asc.plugin.attachContextMenuClickEvent=function(a,c){this._attachCustomMenuClickEvent("contextMenuEvents",a,c)};b.Asc.plugin.event_onContextMenuClick=function(a){this._onCustomMenuClick("contextMenuEvents",a)};b.Asc.plugin.attachToolbarMenuClickEvent=function(a,c){this._attachCustomMenuClickEvent("toolbarMenuEvents",
|
||||
a,c)};b.Asc.plugin.event_onToolbarMenuClick=function(a){this._onCustomMenuClick("toolbarMenuEvents",a)};b.Asc.plugin.event_onContentControlButtonClick=function(a){let c=a&&a.buttonId?a.buttonId:null;a=a&&a.contentControlId?a.contentControlId:null;c&&a&&this.ContentControlButtonEvents&&this.ContentControlButtonEvents[c]&&this.ContentControlButtonEvents[c].call(this,a)};b.Asc.plugin._attachContentControlButtonClickEvent=function(a,c){this.ContentControlButtonEvents||(this.ContentControlButtonEvents=
|
||||
{});this.ContentControlButtonEvents[a]=c};b.Asc.plugin.attachEvent=function(a,c){var f=b.Asc.plugin;f._events||(f._events={});f._events[a]=c};b.Asc.plugin.detachEvent=function(a){var c=b.Asc.plugin;c._events&&c._events[a]&&delete c._events[a]};b.Asc.plugin.onEvent=function(a,c){var f=b.Asc.plugin;f._events&&f._events[a]&&f._events[a].call(f,c)};b.Asc.plugin.attachEditorEvent=function(a,c){b.Asc.plugin["event_"+a]=c.bind(b.Asc.plugin);v(JSON.stringify({guid:b.Asc.plugin.guid,type:"attachEvent",name:a}))};
|
||||
b.Asc.plugin.detachEditorEvent=function(a){b.Asc.plugin["event_"+a]&&delete b.Asc.plugin["event_"+a];v(JSON.stringify({guid:b.Asc.plugin.guid,type:"detachEvent",name:a}))};b.onunload=function(){b.addEventListener?b.removeEventListener("message",n,!1):b.detachEvent("onmessage",n)}})(window,void 0);
|
||||
(function(b,t){function v(){function d(){return(65536+e[k++]).toString(16).substring(1)}if(!b.crypto||!b.crypto.getRandomValues){function g(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return g()+g()+"-"+g()+"-"+g()+"-"+g()+"-"+g()+g()+g()}var e=new Uint16Array(8);b.crypto.getRandomValues(e);var k=0;return d()+d()+"-"+d()+"-"+d()+"-"+d()+"-"+d()+d()+d()}function q(d){return b.Asc.plugin.tr(d)}function m(d,e){this.itemType=h.None;this.editors=["word","cell","slide"];this.id=
|
||||
e===t?v():e;this.icons=null;this.text="";this.hint=null;this.data="";this.separator=!1;this.lockInViewMode=!0;this.disabled=this.enableToggle=!1;this.parent=d?d:null;this.childs=null;this.parent&&(this.parent.childs||(this.parent.childs=[]),this.parent.childs.push(this))}function l(d,e){m.call(this,d,e);this.itemType=h.ContextMenu;this.showOnOptionsType=[];c.Buttons.ButtonsContextMenu.push(this)}function n(d,e){m.call(this,d,e);this.itemType=h.Toolbar;this.type=f.BigButton;this.tab="";c.Buttons.ButtonsToolbar.push(this)}
|
||||
function a(d,e){m.call(this,d,e);this.itemType=h.ContentControl;this.checker=null;0===c.Buttons.ButtonsContentControl.length&&c.Buttons.registerContentControl();c.Buttons.ButtonsContentControl.push(this)}b.Asc=b.Asc||{};var c=b.Asc;c.Buttons={};c.Buttons.ButtonsContextMenu=[];c.Buttons.ButtonsToolbar=[];c.Buttons.ButtonsContentControl=[];c.Buttons.registerContextMenu=function(){b.Asc.plugin.attachEvent("onContextMenuShow",function(d){if(d){var e={guid:b.Asc.plugin.guid};for(let k=0,g=c.Buttons.ButtonsContextMenu.length;k<
|
||||
g;k++){let p=c.Buttons.ButtonsContextMenu[k];if(null===p.parent)p.onContextMenuShow(d,e)}e.items&&b.Asc.plugin.executeMethod("AddContextMenuItem",[e])}})};c.Buttons.registerToolbarMenu=function(){let d={guid:b.Asc.plugin.guid,tabs:[]};for(let e=0,k=c.Buttons.ButtonsToolbar.length;e<k;e++){let g=c.Buttons.ButtonsToolbar[e];null===g.parent&&g.toToolbar(d);if(g.menu)for(item of g.menu)item.onclick&&b.Asc.plugin.attachToolbarMenuClickEvent(item.id,item.onclick)}0<d.tabs.length&&b.Asc.plugin.executeMethod("AddToolbarMenuItem",
|
||||
[d])};c.Buttons.registerContentControl=function(){b.Asc.plugin.attachEvent("onShowContentControlTrack",function(d){let e={guid:b.Asc.plugin.guid,items:{}},k=[];for(let g=0,p=c.Buttons.ButtonsContentControl.length;g<p;++g)k.push(c.Buttons.ButtonsContentControl[g].onShowTrack(d,e.items));Promise.all(k).then(function(){for(let g in e.items){b.Asc.plugin.executeMethod("AddContentControlButtons",[e]);break}})})};var f={Button:"button",BigButton:"big-button"},h={None:0,ContextMenu:1,Toolbar:2,ContentControl:3};
|
||||
m.prototype.toItem=function(){let d={id:this.id,text:q(this.text)};null!==this.hint&&(d.hint=q(""===this.hint?this.hint:this.text));this.separator&&(d.separator=!0);this.data&&(d.data=this.data);this.lockInViewMode&&(d.lockInViewMode=!0);this.enableToggle&&(d.enableToggle=!0);this.disabled&&(d.disabled=!0);this.icons&&(d.icons=this.icons);this.itemType===h.Toolbar&&(d.type=this.type);this.menu&&(d.items=this.menu.map(function(e){e.text=q(e.text);return e}));this.split&&(d.split=!0);return d};m.prototype.attachOnClick=
|
||||
function(d){};m.prototype.onClick=function(){console.log("BUTTON: "+this.text)};l.prototype=Object.create(m.prototype);l.prototype.constructor=l;l.prototype.copy=function(){let d=new l(this.parent,this.id);d.editors=this.editors;d.separator=this.separator;d.lockInViewMode=this.lockInViewMode;d.enableToggle=this.enableToggle;d.disabled=this.disabled;d.showOnOptionsType=this.showOnOptionsType.slice();return d};l.prototype.addCheckers=function(){let d=arguments.length;this.showOnOptionsType=Array(d);
|
||||
for(let e=0;e<d;e++)this.showOnOptionsType[e]=arguments[e]};l.prototype.attachOnClick=function(d){b.Asc.plugin.attachContextMenuClickEvent(this.id,d)};l.prototype.onContextMenuShowAnalyze=function(d,e){return!1};l.prototype.onContextMenuShowExtendItem=function(d,e){};l.prototype.onContextMenuShow=function(d,e){if(!this.onContextMenuShowAnalyze(d,e)){var k=!1;for(let g=0,p=this.editors.length;g<p;g++)if(c.plugin.info.editorType===this.editors[g]){k=!0;break}if(k)for(let g=0,p=this.showOnOptionsType.length;g<
|
||||
p;g++)if(d.type===this.showOnOptionsType[g]||"All"===this.showOnOptionsType[g]){e.items||(e.items=[]);k=this.toItem();this.onContextMenuShowExtendItem(d,k);if(this.childs)for(let r=0,x=this.childs.length;r<x;r++)this.childs[r].onContextMenuShow(d,k);e.items.push(k);break}}};n.prototype=Object.create(m.prototype);n.prototype.constructor=n;n.prototype.attachOnClick=function(d){b.Asc.plugin.attachToolbarMenuClickEvent(this.id,d)};n.prototype.toItem=function(d){d=m.prototype.toItem.call(this);d.type=
|
||||
this.type;return d};n.prototype.toToolbar=function(d){if(null===this.parent){var e={id:this.id,text:q(this.text),items:[]};null!==this.hint&&(e.hint=q(""===this.hint?this.hint:this.text));d.tabs.push(e)}else e=this.toItem(),d.items||(d.items=[]),d.items.push(e);if(this.childs)for(let k=0,g=this.childs.length;k<g;k++)this.childs[k].toToolbar(e)};a.prototype=Object.create(m.prototype);a.prototype.constructor=a;a.prototype.attachOnClick=function(d){b.Asc.plugin._attachContentControlButtonClickEvent(this.id,
|
||||
d)};a.prototype.addChecker=function(d){d&&"function"===typeof d&&(this.checker=d)};a.prototype.onShowTrack=function(d,e){let k=this.checker,g=[],p=this.toItem();for(let r=0,x=d.length;r<x;++r){let w=d[r];g.push((new Promise(function(u){if(k){let y=k(w);y instanceof Promise?y.then(function(z){u(z)}):u(!!y)}else u(!0)})).then(function(u){u&&(e[w]||(e[w]=[]),e[w].push(p))}))}return Promise.all(g)};c.ToolbarButtonType=f;c.ButtonContextMenu=l;c.ButtonToolbar=n;c.ButtonContentControl=a})(window);
|
||||
|
||||
Reference in New Issue
Block a user