Browse Source

Evolution #564: Compatibilité placeholder

Sevajol Bastien 12 years ago
parent
commit
038d28a25e

+ 117 - 2
src/Muzich/CoreBundle/Resources/public/js/TagPrompt.js View File

35
   {
35
   {
36
     if (!tag_id)
36
     if (!tag_id)
37
     {
37
     {
38
-      this.openTagSubmission(tag_name);
38
+      openTagSubmission(tag_name);
39
     }
39
     }
40
     else
40
     else
41
     {
41
     {
44
     }
44
     }
45
   }
45
   }
46
   
46
   
47
+  var openTagSubmission = function (tag_name)
48
+  {
49
+    // TODO : Cette partie du code n'est pas encore refactorisé
50
+    
51
+    // Effet fade-in du fond opaque
52
+    $('body').append($('<div>').attr('id', 'fade')); 
53
+    //Apparition du fond - .css({'filter' : 'alpha(opacity=80)'}) pour corriger les bogues de IE
54
+    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
55
+    
56
+    // En premier lieux on fait apparaître la fenêtre de confirmation
57
+    var popup = $('<div>')
58
+    .attr('id', 'add_tag')
59
+    .addClass('popin_block')
60
+    .css('width', '400px')
61
+      //.append($('<h2>').append(string_tag_add_title))
62
+    .append($('<form>')
63
+      .attr('action', url_add_tag)
64
+      .attr('method', 'post')
65
+      .attr('name', 'add_tag')
66
+      .ajaxForm(function(response) {
67
+        /*
68
+        *
69
+        */
70
+  
71
+        if (response.status == 'mustbeconnected')
72
+        {
73
+          $(location).attr('href', url_index);
74
+        }
75
+  
76
+        if (response.status == 'success')
77
+        {
78
+          var tag = new Tag(response.tag_id, response.tag_name);
79
+          addTagToProposedTags(tag);
80
+          addTagToSelectedTags(tag);
81
+          _tag_prompt_connector.updateOutput(tags_selected);
82
+  
83
+          $('#fade').fadeOut(400, function(){$('#fade').remove();});
84
+          $('#add_tag').remove();
85
+        }
86
+  
87
+        if (response.status == 'error')
88
+        {
89
+          $('form[name="add_tag"]').find('ul.error_list').remove();
90
+          var ul_errors = $('<ul>').addClass('error_list');
91
+  
92
+          for (i in response.errors)
93
+          {
94
+            ul_errors.append($('<li>').append(response.errors[i]));
95
+          }
96
+  
97
+          $('form[name="add_tag"]').prepend(ul_errors);
98
+        }
99
+  
100
+        return false;
101
+      })
102
+  
103
+      .append($('<div>').addClass('tag')
104
+        .append($('<ul>')
105
+          .append($('<li>').addClass('button')
106
+            .append(tag_name))))
107
+      .append($('<p>').append(string_tag_add_text))
108
+      .append($('<p>').append(string_tag_add_argument))
109
+      .append($('<textarea>').attr('name', 'argument'))
110
+      .append($('<div>').addClass('inputs')
111
+        .append($('<input>')
112
+          .attr('type', 'button')
113
+          .attr('value', string_tag_add_inputs_cancel)
114
+          .addClass('button')
115
+          .click(function(){
116
+            $('#fade').fadeOut(1000, function(){$('#fade').remove();});
117
+            $('#add_tag').remove();
118
+  
119
+            return false;
120
+          })
121
+        )
122
+        .append($('<input>')
123
+          .attr('type', 'submit')
124
+          .attr('value', string_tag_add_inputs_submit)
125
+          .addClass('button')
126
+          .click(function(){
127
+  
128
+            // TODO: loader gif
129
+  
130
+          })
131
+        )
132
+        .append($('<input>').attr('type', 'hidden').attr('name', 'tag_name').val(tag_name))
133
+      ))
134
+    ;
135
+  
136
+    // Il faut ajouter le popup au dom avant de le positionner en css
137
+    // Sinon la valeur height n'est pas encore calculable
138
+    $('body').prepend(popup);
139
+  
140
+    //Récupération du margin, qui permettra de centrer la fenêtre - on ajuste de 80px en conformité avec le CSS
141
+    var popMargTop = (popup.height() + 50) / 2;
142
+    var popMargLeft = (popup.width() + 50) / 2;
143
+  
144
+    //On affecte le margin
145
+    $(popup).css({
146
+      'margin-top' : -popMargTop,
147
+      'margin-left' : -popMargLeft
148
+    });
149
+  
150
+    return false;
151
+  }
152
+  
47
   this.openTagSubmission = function (tag_name)
153
   this.openTagSubmission = function (tag_name)
48
   {
154
   {
49
     // TODO : Cette partie du code n'est pas encore refactorisé
155
     // TODO : Cette partie du code n'est pas encore refactorisé
245
   
351
   
246
   var cleanInput = function()
352
   var cleanInput = function()
247
   {
353
   {
248
-    _input.val('');
354
+    // hack pour ie < 10 ne supportant pas le placeholder
355
+    if ($.browser.version < 10 && $.browser.msie)
356
+    {
357
+      _input.addClass('placeholder');
358
+      _input.val(_input.attr('placeholder'));
359
+    }
360
+    else
361
+    {
362
+      _input.val('');
363
+    }
249
   }
364
   }
250
   
365
   
251
   var showPromptLoader = function()
366
   var showPromptLoader = function()

+ 14 - 2
src/Muzich/CoreBundle/Resources/public/js/muzich.js View File

432
      li.find('a.element_embed_open_link_text').show();
432
      li.find('a.element_embed_open_link_text').show();
433
      $(this).hide();
433
      $(this).hide();
434
      
434
      
435
-     window.players_manager.get(li.attr('id')).close();
435
+     var player = window.players_manager.get(li.attr('id'));
436
+     if (player)
437
+     {
438
+       player.close();
439
+     }
440
+     else
441
+     {
442
+      alert('noplayer!');
443
+     }
436
      
444
      
437
      return false;
445
      return false;
438
   });
446
   });
2515
   /* Sou-menus page mon compte (myaccount) */
2523
   /* Sou-menus page mon compte (myaccount) */
2516
   $('div#myaccount h2').click(function(){
2524
   $('div#myaccount h2').click(function(){
2517
     $('div#myaccount div.myaccount_part:visible').slideUp();
2525
     $('div#myaccount div.myaccount_part:visible').slideUp();
2518
-    console.log($(this).data('open'));
2519
     $('div#'+$(this).data('open')).slideDown();
2526
     $('div#'+$(this).data('open')).slideDown();
2520
   });
2527
   });
2521
   
2528
   
2528
   {
2535
   {
2529
     if ($.browser.version < 10)
2536
     if ($.browser.version < 10)
2530
     {
2537
     {
2538
+      $('[placeholder]').each(function(){
2539
+        $(this).addClass('placeholder');
2540
+        $(this).val($(this).attr('placeholder'));
2541
+      });
2542
+      
2531
       $('[placeholder]').focus(function() {
2543
       $('[placeholder]').focus(function() {
2532
           var input = $(this);
2544
           var input = $(this);
2533
           if (input.val() == input.attr('placeholder')) {
2545
           if (input.val() == input.attr('placeholder')) {

+ 0 - 1
src/Muzich/CoreBundle/Resources/views/Menu/main_menu.html.twig View File

34
       {{ 'container_menu.my_favorites'|trans({}, 'navigationui') }}
34
       {{ 'container_menu.my_favorites'|trans({}, 'navigationui') }}
35
     </a>
35
     </a>
36
   </li>
36
   </li>
37
-  <li class="separator"></li>
38
 </ul>
37
 </ul>

+ 0 - 2
src/Muzich/CoreBundle/Resources/views/Tag/tagsPrompt.html.twig View File

35
 <script language="javascript" type="text/javascript">
35
 <script language="javascript" type="text/javascript">
36
   $(document).ready(function(){
36
   $(document).ready(function(){
37
     
37
     
38
-    $('form[name="{{ form_name }}"] input.tag_prompt').val('');
39
-    
40
     window.{{ form_name }}_tag_prompt_connector = new TagPromptConnector(
38
     window.{{ form_name }}_tag_prompt_connector = new TagPromptConnector(
41
       $('form[name="{{ form_name }}"] input.tag_prompt'),
39
       $('form[name="{{ form_name }}"] input.tag_prompt'),
42
       $('form[name="{{ form_name }}"] input.tagBox_tags_ids'),
40
       $('form[name="{{ form_name }}"] input.tagBox_tags_ids'),

+ 2 - 4
web/css/main.css View File

59
   margin: 0px;
59
   margin: 0px;
60
   padding: 0px;
60
   padding: 0px;
61
   height: 80px;
61
   height: 80px;
62
-  margin-left: 210px;
63
-  width: 560px;
62
+  margin-left: 200px;
63
+  width: 580px;
64
 }
64
 }
65
 
65
 
66
 #header_menu li a, #register_and_login li a, #parameters li a
66
 #header_menu li a, #register_and_login li a, #parameters li a
1642
   text-align: left;
1642
   text-align: left;
1643
 }
1643
 }
1644
 
1644
 
1645
-.placeholder { color:#999; }
1646
-
1647
 div.reputation img
1645
 div.reputation img
1648
 {
1646
 {
1649
   float: left;
1647
   float: left;