delete img src="null" when pressing cancel in image prompt Button Bar

This discussion is related to the Button Bar addon.
jackmaessenjackmaessen ✭✭✭
edited November 2014 in Feedback

I noticed that the embedded plugin Button Bar in 2.1 prompts with clicking on image button and url button.
There is only one thing i find disturbing, that when you press Cancel in the prompt, he returns null in the textarea

img src="null"

So i put an if statement in the case to disable this text:

The original case:


           case 'image':
           var urlOpts = {};
           var thisOpts = $.extend(htmlOpts, {
              closetype: 'short'
           });

           var PromptText = gdn.definition('ButtonBarImageUrl', 'ButtonBar.ImageUrlText');
           NewURL = prompt(PromptText);
           urlOpts.src = NewURL;         

           $(TextArea).insertRoundTag('img',thisOpts,urlOpts);
           break;

Customized case:


           case 'image':
           var urlOpts = {};
           var thisOpts = $.extend(htmlOpts, {
              closetype: 'short'
           });

           var PromptText = gdn.definition('ButtonBarImageUrl', 'ButtonBar.ImageUrlText');
           NewURL = prompt(PromptText);
           if(NewURL != null){ // condition added
           urlOpts.src = NewURL;


           $(TextArea).insertRoundTag('img',thisOpts,urlOpts);
            } // end if
           break;

Maybe helpfull for other people who wants to disable the

img src="null"

in the textarea when pressing Cancel

Tagged:
mirXhgtonight

Comments

Sign In or Register to comment.