From dfd8ab3545b3065b93fd20bf3c2ccc2727ef92e0 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 17 Jun 2015 20:48:56 +0100 Subject: [PATCH] Detect mouse paste in Import nodes dialog --- editor/js/ui/clipboard.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/editor/js/ui/clipboard.js b/editor/js/ui/clipboard.js index 5a8385ca9..2db0f17ec 100644 --- a/editor/js/ui/clipboard.js +++ b/editor/js/ui/clipboard.js @@ -72,8 +72,22 @@ RED.clipboard = (function() { var importNodesDialog = '
'+ ''+ '
'; - - + + function validateImport() { + var importInput = $("#clipboard-import"); + var v = importInput.val(); + try { + JSON.parse(v); + importInput.removeClass("input-error"); + $("#clipboard-dialog-ok").button("enable"); + } catch(err) { + if (v !== "") { + importInput.addClass("input-error"); + } + $("#clipboard-dialog-ok").button("disable"); + } + } + function importNodes() { dialogContainer.empty(); dialogContainer.append($(importNodesDialog)); @@ -81,22 +95,12 @@ RED.clipboard = (function() { $("#clipboard-dialog-cancel").show(); $("#clipboard-dialog-close").hide(); $("#clipboard-dialog-ok").button("disable"); - $("#clipboard-import").keyup(function() { - var v = $(this).val(); - try { - JSON.parse(v); - $(this).removeClass("input-error"); - $("#clipboard-dialog-ok").button("enable"); - } catch(err) { - if (v !== "") { - $(this).addClass("input-error"); - } - $("#clipboard-dialog-ok").button("disable"); - } - }); + $("#clipboard-import").keyup(validateImport); + $("#clipboard-import").on('paste',function() { setTimeout(validateImport,10)}); + dialog.dialog("option","title","Import nodes").dialog("open"); } - + function exportNodes() { dialogContainer.empty(); dialogContainer.append($(exportNodesDialog));