fix html5 clipboard on ie

pull/312/head
nightwing 2016-05-25 20:49:24 +04:00
rodzic 9973c0ea35
commit d2c77b4f42
1 zmienionych plików z 21 dodań i 11 usunięć

Wyświetl plik

@ -52,20 +52,18 @@ define(function(require, exports, module) {
if (notSupported(type))
return;
type = convertType(type);
if (nativeObject) {
nativeObject.setData(type, data);
handleClipboardData(nativeObject, type, data);
return true;
}
var setData = function(e) {
if (list) {
list.forEach(function(type) {
e.clipboardData.setData(type, data);
handleClipboardData(e.clipboardData, type, data);
});
}
e.clipboardData.setData(type, data);
handleClipboardData(e.clipboardData, type, data);
e.preventDefault();
e.stopPropagation();
@ -83,16 +81,14 @@ define(function(require, exports, module) {
if (notSupported(type))
return;
type = convertType(type);
if (!full && nativeObject)
return nativeObject.getData(type);
return handleClipboardData(nativeObject, type);
var data;
var getData = function(e) {
data = full
? e.clipboardData
: e.clipboardData.getData(type);
: handleClipboardData(nativeObject, type);
e.preventDefault();
e.stopPropagation();
};
@ -120,8 +116,22 @@ define(function(require, exports, module) {
return !/text($|\/)/.test(type);
}
function convertType(type) {
return document.all ? "Text" : type;
function handleClipboardData(clipboardData, type, data, forceIEMime) {
if (!clipboardData)
return;
// using "Text" doesn't work on old webkit but ie needs it
var mime = forceIEMime ? "Text" : type;
try {
if (data) {
// Safari 5 has clipboardData object, but does not handle setData()
return clipboardData.setData(mime, data) !== false;
} else {
return clipboardData.getData(mime);
}
} catch(e) {
if (!forceIEMime)
return handleClipboardData(clipboardData, type, data, true);
}
}
function wrap(obj) {