loleaflet/src/layer/tile/TileLayer.js | 43 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 19 deletions(-)
New commits: commit 125e445a6b00b04e5581ce156d2d79f3558bcb80 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Thu Jan 21 20:57:23 2016 +0100 loleaflet: dedup - move clipboard func. to Compatibility class diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 38e4e70..d1544aa 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -12,6 +12,27 @@ if (typeof String.prototype.startsWith !== 'function') { }; } +L.Compatibility = { + clipboardGet: function (event) { + var text = null; + if (event.clipboardData) { // Standard + text = event.clipboardData.getData('text/plain'); + } + else if (window.clipboardData) { // IE 11 + text = window.clipboardData.getData('Text'); + } + return text; + }, + clipboardSet: function (event, text) { + if (event.clipboardData) { // Standard + event.clipboardData.setData('text/plain', text); + } + else if (window.clipboardData) { // IE 11 + window.clipboardData.setData('Text', text); + } + } +}; + L.TileLayer = L.GridLayer.extend({ options: { @@ -988,12 +1009,7 @@ L.TileLayer = L.GridLayer.extend({ e = e.originalEvent; e.preventDefault(); if (this._selectionTextContent) { - if (e.clipboardData) { // Standard - e.clipboardData.setData('text/plain', this._selectionTextContent); - } - else if (window.clipboardData) { // IE 11 - window.clipboardData.setData('Text', this._selectionTextContent); - } + L.Compatibility.clipboardSet(e, this._selectionTextContent); } }, @@ -1001,12 +1017,7 @@ L.TileLayer = L.GridLayer.extend({ e = e.originalEvent; e.preventDefault(); if (this._selectionTextContent) { - if (e.clipboardData) { // Standard - e.clipboardData.setData('text/plain', this._selectionTextContent); - } - else if (window.clipboardData) { // IE 11 - window.clipboardData.setData('Text', this._selectionTextContent); - } + L.Compatibility.clipboardSet(e, this._selectionTextContent); this._map._socket.sendMessage('uno .uno:Cut'); } }, @@ -1014,13 +1025,7 @@ L.TileLayer = L.GridLayer.extend({ _onPaste: function (e) { e = e.originalEvent; e.preventDefault(); - var pasteString = null; - if (e.clipboardData) { // Standard - pasteString = e.clipboardData.getData('text/plain'); - } - else if (window.clipboardData) { // IE 11 - pasteString = window.clipboardData.getData('Text'); - } + var pasteString = L.Compatibility.clipboardGet(e); if (pasteString) { this._map._socket.sendMessage('paste mimetype=text/plain;charset=utf-8\n' + pasteString); }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits