From 51fd95b69c59d3e20da541dec00d36d47dc4b492 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 22 May 2015 15:24:50 +0000 Subject: [PATCH] Do not allow to drag an invalid email address in compose --- mail/js/app.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/mail/js/app.js b/mail/js/app.js index bcd6ea33f5..d808d1ee3a 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -4140,10 +4140,17 @@ app.classes.mail = AppJS.extend( }); } var zIndex = 100; - var dragItem = jQuery('div.ms-sel-item:not(div.ui-draggable)'); - if (dragItem.length > 0) + var dragItems = jQuery('div.ms-sel-item:not(div.ui-draggable)'); + dragItems.each(function(i,item){ + var $isErr = jQuery(item).find('.ui-state-error'); + if ($isErr.length > 0) + { + delete dragItems.splice(i,1); + } + }); + if (dragItems.length > 0) { - dragItem.draggable({ + dragItems.draggable({ appendTo:'body', //Performance wise better to not add ui-draggable class to items since we are not using that class containment:'document', @@ -4190,7 +4197,7 @@ app.classes.mail = AppJS.extend( }).draggable('disable'); window.setTimeout(function(){ - if(dragItem && dragItem.data() && typeof dragItem.data()['uiDraggable'] !== 'undefined') dragItem.draggable('enable'); + if(dragItems && dragItems.data() && typeof dragItems.data()['uiDraggable'] !== 'undefined') dragItems.draggable('enable'); },100); } @@ -4256,9 +4263,17 @@ app.classes.mail = AppJS.extend( .removeClass('mailCompose_copyEmail') .css('cursor','move'); } - + + var dragItems = jQuery('div.ms-sel-item'); + dragItems.each(function(i,item){ + var $isErr = jQuery(item).find('.ui-state-error'); + if ($isErr.length > 0) + { + delete dragItems.splice(i,1); + } + }); //Destroy draggables after dropping, we need to enable them again - jQuery('div.ms-sel-item').draggable('destroy'); + dragItems.draggable('destroy'); } } });