Browse Source

fix js for popin

Bastien Sevajol 11 years ago
parent
commit
3edf71eccb
1 changed files with 35 additions and 25 deletions
  1. 35 25
      src/Muzich/CoreBundle/Resources/public/js/muzich.js

+ 35 - 25
src/Muzich/CoreBundle/Resources/public/js/muzich.js View File

8
 // Messages flashs
8
 // Messages flashs
9
 var myMessages = ['info','warning','error','success']; // define the messages types
9
 var myMessages = ['info','warning','error','success']; // define the messages types
10
 var window_login_or_subscription_opened = false;
10
 var window_login_or_subscription_opened = false;
11
+var popin_opened = false;
11
 
12
 
12
 function hideAllMessages()
13
 function hideAllMessages()
13
 {
14
 {
2934
   });
2935
   });
2935
   
2936
   
2936
   $('a#helpbox_close').live('click', function(){
2937
   $('a#helpbox_close').live('click', function(){
2937
-    // Fond gris
2938
-    $('#fade').fadeOut(1000, function(){$('#fade').remove();});
2939
-    // On cache le lecteur
2940
-    $('#helpbox').remove();
2938
+    close_popin();
2941
   });
2939
   });
2942
    
2940
    
2943
     // Hide add_tag
2941
     // Hide add_tag
3034
              
3032
              
3035
             if (response.status === 'success')
3033
             if (response.status === 'success')
3036
             {
3034
             {
3037
-              $('#fade').fadeOut(1000, function(){$('#fade').remove();});
3038
-              $('#helpbox').remove();
3035
+              close_popin();
3039
               $('a.tags_prompt_favorites').trigger('click');
3036
               $('a.tags_prompt_favorites').trigger('click');
3040
             }
3037
             }
3041
 
3038
 
3054
 
3051
 
3055
 function open_ajax_popin(url, callback)
3052
 function open_ajax_popin(url, callback)
3056
 {
3053
 {
3057
-  $('body').append(
3058
-    '<div id="helpbox" class="popin_block"><img src="/bundles/muzichcore/img/ajax-loader.gif" alt="loading..." /></div>'
3059
-  );
3060
-  open_popin_dialog('helpbox');
3061
-  JQueryJson(url, {}, function(response){
3062
-    if (response.status == 'success')
3063
-    {
3064
-      $('div#helpbox').html(
3065
-        '<a href="javascript:void(0);" id="helpbox_close" >'+
3066
-          '<img src="/bundles/muzichcore/img/1317386146_cancel.png" alt="close" />'+
3067
-        '</a>'+
3068
-        response.data
3069
-      );
3070
-      
3071
-      if (callback)
3054
+  if (!popin_opened)
3055
+  {
3056
+    popin_opened = true;
3057
+    $('body').append(
3058
+      '<div id="helpbox" class="popin_block"><img src="/bundles/muzichcore/img/ajax-loader.gif" alt="loading..." /></div>'
3059
+    );
3060
+    open_popin_dialog('helpbox');
3061
+    JQueryJson(url, {}, function(response){
3062
+      if (response.status == 'success')
3072
       {
3063
       {
3073
-        callback();
3064
+        $('div#helpbox').html(
3065
+          '<a href="javascript:void(0);" id="helpbox_close" >'+
3066
+            '<img src="/bundles/muzichcore/img/1317386146_cancel.png" alt="close" />'+
3067
+          '</a>'+
3068
+          response.data
3069
+        );
3070
+
3071
+        if (callback)
3072
+        {
3073
+          callback();
3074
+        }
3074
       }
3075
       }
3075
-    }
3076
-  });
3077
-  $('html, body').animate({ scrollTop: 0 }, 'fast');
3076
+    });
3077
+    $('html, body').animate({ scrollTop: 0 }, 'fast');
3078
+  }
3078
 }
3079
 }
3079
 
3080
 
3080
 function open_connection_or_subscription_window(open_login_part)
3081
 function open_connection_or_subscription_window(open_login_part)
3133
     });
3134
     });
3134
   }
3135
   }
3135
 }
3136
 }
3137
+
3138
+function close_popin()
3139
+{
3140
+  // Fond gris
3141
+  $('#fade').fadeOut(1000, function(){$('#fade').remove();});
3142
+  // On cache le lecteur
3143
+  $('#helpbox').remove();
3144
+  popin_opened = false;
3145
+}