tags:

views:

32

answers:

0

OK I am posting the whole code. So any tag with name=modal will render the modal. Hope this will help finding the flicker issue.

This is how it is triggered:

<a tp='#dialog' name='modal' tgt='bob' title='Send message'>Send message</a>

JavaScript code:

    $(document).ready(function () {      
      initmodal();
      $("#dialog #modalclose").click(function (e) {
         $('#mask, .window').hide();
      });
   });
   function initmodal() {      
      $('a[name=modal]').click(function (e) {
         e.preventDefault(); 
         $("#modalsend").attr('disabled', false);
         var id = $(this).attr('tp');
         var tgt = $(this).attr('tgt');
         var ttl = $(this).attr('title'); if (ttl !== '' && ttl != undefined) ttl = ttl.toLowerCase();
         if (tgt !== undefined && tgt !== '') $("#users").val(tgt);
         $("#valres").text(''); $("#message").val('');         

         var maskHeight = $(document).height(); var maskWidth = $(window).width();
         $('#mask').css({ 'width': maskWidth, 'height': maskHeight });
         $('#mask').fadeIn(100); 
         $('#mask').fadeTo(200, 0.01);
         var winH = $(window).height(); var winW = $(window).width();
         $(id).css('top', winH / 2 - $(id).height() / 2); $(id).css('left', winW / 2 - $(id).width() / 2);
         $(id).fadeIn(250);
      });
   }