Kaynağa Gözat

Evolution #357: Maj interface d'ajout

Sevajol Bastien 12 yıl önce
ebeveyn
işleme
b26735270d

+ 2 - 0
app/Resources/translations/userui.fr.yml Dosyayı Görüntüle

78
   tag_strict:       Chaques tag doit être trouvé
78
   tag_strict:       Chaques tag doit être trouvé
79
   
79
   
80
 element_add:
80
 element_add:
81
+  prop_tags:
82
+    text:     "Proposition de tags:"
81
   url:
83
   url:
82
     name:     http://
84
     name:     http://
83
     help:     |
85
     help:     |

+ 50 - 1
src/Muzich/CoreBundle/Controller/ElementController.php Dosyayı Görüntüle

8
 use Muzich\CoreBundle\Entity\ElementTagsProposition;
8
 use Muzich\CoreBundle\Entity\ElementTagsProposition;
9
 use Symfony\Component\HttpFoundation\Request;
9
 use Symfony\Component\HttpFoundation\Request;
10
 use Muzich\CoreBundle\Entity\Element;
10
 use Muzich\CoreBundle\Entity\Element;
11
+use Muzich\CoreBundle\Util\TagLike;
11
 
12
 
12
 class ElementController extends Controller
13
 class ElementController extends Controller
13
 {
14
 {
871
     ));
872
     ));
872
   }
873
   }
873
   
874
   
875
+  protected function findTagsWithProposeds($tags)
876
+  {
877
+    $tag_like = new TagLike($this->getDoctrine());
878
+    $tags_with_likes = array();
879
+    foreach ($tags as $tag_name)
880
+    {
881
+      // On va determiner si on connais ces tags
882
+      $tag_like_tag = $tag_like->getSimilarTags($tag_name, $this->getUserId());
883
+      
884
+      // Premièrement: Si on a trouvé des équivalents en base
885
+      if (array_key_exists('tags', $tag_like_tag))
886
+      {
887
+        if (count($tag_like_tag['tags']))
888
+        {
889
+          // Deuxièmement: Si nos algorythmes on déterminés qu'on l'a en base
890
+          if ($tag_like_tag['same_found'])
891
+          {
892
+            // A ce moment là on le considère comme "bon"
893
+            // Et on prend le premier
894
+            $tags_with_likes[] = array(
895
+              'original_name' => $tag_name,
896
+              'like_found'    => true,
897
+              'like'          => $tag_like_tag['tags'][0]
898
+            );
899
+          }
900
+          // On considère ce tag comme inconnu, l'utilisateur peut toute fois 
901
+          // l'ajouté a notre base.
902
+          else
903
+          {
904
+            $tags_with_likes[] = array(
905
+              'original_name' => $tag_name,
906
+              'like_found'    => false,
907
+              'like'          => array()
908
+            );
909
+          }
910
+        }
911
+      }
912
+    }
913
+    
914
+    return $tags_with_likes;
915
+  }
874
   
916
   
875
   public function getDatasApiAction(Request $request)
917
   public function getDatasApiAction(Request $request)
876
   {
918
   {
886
     $factory = new ElementManager($element, $this->getEntityManager(), $this->container);
928
     $factory = new ElementManager($element, $this->getEntityManager(), $this->container);
887
     $factory->proceedFill($this->getUser());
929
     $factory->proceedFill($this->getUser());
888
     
930
     
931
+    // On gère les tags proposés
932
+    $tags_propositions = array();
933
+    if (count($tags = $element->getProposedTags()))
934
+    {
935
+      $tags_propositions = $this->findTagsWithProposeds($tags);
936
+    }
937
+    
889
     return $this->jsonResponse(array(
938
     return $this->jsonResponse(array(
890
       'status' => 'success',
939
       'status' => 'success',
891
       'name'   => $element->getProposedName(),
940
       'name'   => $element->getProposedName(),
892
-      'tags'   => $element->getProposedTags(),
941
+      'tags'   => $tags_propositions,
893
       'thumb'  => $element->getThumbnailUrl() 
942
       'thumb'  => $element->getThumbnailUrl() 
894
     ));
943
     ));
895
   }
944
   }

+ 5 - 0
src/Muzich/CoreBundle/Entity/Element.php Dosyayı Görüntüle

916
     return null;
916
     return null;
917
   }
917
   }
918
   
918
   
919
+  /**
920
+   *
921
+   * @return type 
922
+   */
919
   public function getProposedTags()
923
   public function getProposedTags()
920
   {
924
   {
921
     if (count($tags = $this->getData(self::DATA_TAGS)))
925
     if (count($tags = $this->getData(self::DATA_TAGS)))
922
     {
926
     {
923
       return $tags;
927
       return $tags;
924
     }
928
     }
929
+    return array();
925
   }
930
   }
926
   
931
   
927
 }
932
 }

+ 60 - 25
src/Muzich/CoreBundle/Resources/views/Element/form.add.html.twig Dosyayı Görüntüle

2
 
2
 
3
 {{ form_errors(form) }}
3
 {{ form_errors(form) }}
4
 
4
 
5
-<span class="help">{{ 'element_add.url.help'|trans({}, 'userui') }}</span>
6
-
7
-<div class="field fom_add_url">
8
-  {{ form_errors(form.url) }}
9
-  {{ form_widget(form.url, { 'attr': {
10
-    'placeholder': 'element_add.url.name'|trans({}, 'userui')},
11
-    'type': 'URL'
12
-  }) }}
5
+<div id="form_add_first_part">
6
+
7
+  <span class="help">{{ 'element_add.url.help'|trans({}, 'userui') }}</span>
8
+
9
+  <div class="field fom_add_url">
10
+    {{ form_errors(form.url) }}
11
+    {{ form_widget(form.url, { 'attr': {
12
+      'placeholder': 'element_add.url.name'|trans({}, 'userui')},
13
+      'type': 'URL'
14
+    }) }}
15
+
16
+    <a href="#" id="form_add_check_url" class="button">
17
+      {{ 'home.check_url'|trans({}, 'navigationui') }}
18
+    </a>
19
+
20
+
21
+    <img id="form_add_loader" class="tag_loader" style="display: none;" 
22
+      src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" 
23
+    />
24
+
25
+  </div>
13
     
26
     
14
-  <a href="#" id="form_add_check_url" class="button">
15
-    {{ 'home.check_url'|trans({}, 'navigationui') }}
16
-  </a>
17
 </div>
27
 </div>
18
 
28
 
19
-<div class="form_add_second_part" style="display: none;">
20
-  <div class="field fom_add_name">
21
-    {{ form_errors(form.name) }}
22
-    {{ form_widget(form.name, { 'attr': {'placeholder': 'element_add.name.name'|trans({}, 'userui')} }) }}
23
-  </div>
29
+<div id="form_add_second_part" style="display: none;">
30
+  
31
+  <table>
32
+    <tr>
33
+      <td style="vertical-align: top;">
34
+        <div id="form_add_thumb">
35
+          <img src="{{ asset('bundles/muzichcore/img/nothumb.png') }}" />
36
+        </div>
37
+      </td>
38
+      <td style="vertical-align: top;">
39
+        <div class="field fom_add_name">
40
+          {{ form_errors(form.name) }}
41
+          {{ form_widget(form.name, { 'attr': {'placeholder': 'element_add.name.name'|trans({}, 'userui')} }) }}
42
+        </div>
24
 
43
 
25
-    {% include "MuzichCoreBundle:Tag:tagsPrompt.html.twig" with { 
26
-      'form_name'     : form_name
27
-    } %}
44
+          <p id="form_add_prop_tags_text" style="display: none;">
45
+            {{ 'element_add.prop_tags.text'|trans({}, 'userui') }}
46
+          </p>
47
+          <ul id="form_add_prop_tags" style="display: none;"></ul>
28
 
48
 
29
-    {{ form_widget(form.tags, { 'attr': {'class': 'tagBox_tags_ids'} }) }}
49
+          {% include "MuzichCoreBundle:Tag:tagsPrompt.html.twig" with { 
50
+            'form_name'     : form_name
51
+          } %}
30
 
52
 
31
-  <div class="field">
32
-    {{ form_errors(form.need_tags) }}
33
-    {{ form_widget(form.need_tags) }}
34
-    {{ form_label(form.need_tags, 'element_add.need_tags.name'|trans({}, 'userui')) }}
35
-  </div>
53
+          {{ form_widget(form.tags, { 'attr': {'class': 'tagBox_tags_ids'} }) }}
54
+
55
+        <div class="field">
56
+          {{ form_errors(form.need_tags) }}
57
+          {{ form_widget(form.need_tags) }}
58
+          {{ form_label(form.need_tags, 'element_add.need_tags.name'|trans({}, 'userui')) }}
59
+        </div>
60
+      </td>
61
+    </tr>
62
+  </table>
63
+  
64
+  
65
+  
66
+  
67
+  
68
+    
69
+  <input type="submit" value="Partager cette ressource" />
70
+    
36
 </div>
71
 </div>
37
 
72
 
38
 {{ form_row(form._token) }}
73
 {{ form_row(form._token) }}

+ 5 - 1
src/Muzich/CoreBundle/Resources/views/layout.html.twig Dosyayı Görüntüle

16
 	<link href="{{ asset('bundles/muzichcore/css/base.css') }}" rel="stylesheet" media="screen" type="text/css" />
16
 	<link href="{{ asset('bundles/muzichcore/css/base.css') }}" rel="stylesheet" media="screen" type="text/css" />
17
 	<link href="{{ asset('bundles/muzichcore/css/main.css') }}" rel="stylesheet" media="screen" type="text/css" />
17
 	<link href="{{ asset('bundles/muzichcore/css/main.css') }}" rel="stylesheet" media="screen" type="text/css" />
18
   {% block css %}{% endblock %}
18
   {% block css %}{% endblock %}
19
-	<script src="{{ asset('js/jquery-1.6.4.min.js') }}" type="text/javascript"></script>
19
+  {% if  app.environment != 'prod' %}  
20
+	<script src="{{ asset('js/jquery-1.8.2.dev.js') }}" type="text/javascript"></script>
21
+  {% else %}
22
+	<script src="{{ asset('js/jquery-1.8.2.prod.js') }}" type="text/javascript"></script>
23
+  {% endif %}
20
   <script src="{{ asset('js/jquery-ui-1.8.7.min.js') }}" type="text/javascript"></script>
24
   <script src="{{ asset('js/jquery-ui-1.8.7.min.js') }}" type="text/javascript"></script>
21
 	<script src="{{ asset('bundles/muzichcore/js/muzich.js') }}" type="text/javascript"></script>
25
 	<script src="{{ asset('bundles/muzichcore/js/muzich.js') }}" type="text/javascript"></script>
22
   <script src="{{ asset('js/tags/jquery.autoGrowInput.js') }}" type="text/javascript"></script>
26
   <script src="{{ asset('js/tags/jquery.autoGrowInput.js') }}" type="text/javascript"></script>

+ 12 - 5
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig Dosyayı Görüntüle

24
   </div>
24
   </div>
25
   #}
25
   #}
26
 
26
 
27
-  <div id="element_add_box">    
28
-    
29
-    <img class="tag_loader" style="display: none;" 
30
-      src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" 
31
-    />
32
 
27
 
28
+
29
+  <div id="element_add_box" style="display: none;">    
30
+    
31
+    <a href="#" id="element_add_close_link" class="button">
32
+      &lt;&lt; {{ 'home.add_element_box.close'|trans({}, 'navigationui') }}
33
+    </a>
34
+    
33
     <form novalidate name="{{ add_form_name }}" action="{{ path('element_add') }}" method="post" {{ form_enctype(add_form) }}>
35
     <form novalidate name="{{ add_form_name }}" action="{{ path('element_add') }}" method="post" {{ form_enctype(add_form) }}>
34
 
36
 
35
       {% include "MuzichCoreBundle:Element:form.add.html.twig" with { 
37
       {% include "MuzichCoreBundle:Element:form.add.html.twig" with { 
40
     </form>
42
     </form>
41
   </div>
43
   </div>
42
 
44
 
45
+
46
+  <a href="#" id="element_add_link" class="button">
47
+    {{ 'home.add_element'|trans({}, 'navigationui') }} &gt;&gt;
48
+  </a>
49
+
43
   <div id="added_element_to_group" style="display: none;">
50
   <div id="added_element_to_group" style="display: none;">
44
     <img class="loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
51
     <img class="loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
45
     <p class="help">
52
     <p class="help">

+ 8 - 1
web/bundles/muzichcore/css/main.css Dosyayı Görüntüle

996
   text-align: center;
996
   text-align: center;
997
 }
997
 }
998
 
998
 
999
-input#element_add_url, input#element_add_name
999
+input#element_add_url
1000
 {
1000
 {
1001
   width: 70%;
1001
   width: 70%;
1002
   font-size: 110%;
1002
   font-size: 110%;
1003
   font-weight: bold;
1003
   font-weight: bold;
1004
 }
1004
 }
1005
 
1005
 
1006
+input#element_add_name
1007
+{
1008
+  width: 65%;
1009
+  font-size: 110%;
1010
+  font-weight: bold;
1011
+}
1012
+
1006
 label#element_add_url, label#element_add_name
1013
 label#element_add_url, label#element_add_name
1007
 {
1014
 {
1008
   
1015
   

+ 213 - 122
web/bundles/muzichcore/js/muzich.js Dosyayı Görüntüle

851
             // Si le tag ne semble pas connu en base
851
             // Si le tag ne semble pas connu en base
852
             if (!data.same_found)
852
             if (!data.same_found)
853
             {
853
             {
854
-              // Cette variable nous permettra de stocker le lien nouveau tag
855
-              var link_add_tag = null;
856
-              
857
               li_tag = 
854
               li_tag = 
858
                 $('<li>').addClass('new').append(
855
                 $('<li>').addClass('new').append(
859
                   $('<a>').attr('href','#new#'+$.trim(input.val()))
856
                   $('<a>').attr('href','#new#'+$.trim(input.val()))
860
                   // qui réagit quand on clique dessus
857
                   // qui réagit quand on clique dessus
861
-                  .click(function(e){
862
-                    
863
-                    // Effet fade-in du fond opaque
864
-                    $('body').append($('<div>').attr('id', 'fade')); 
865
-                    //Apparition du fond - .css({'filter' : 'alpha(opacity=80)'}) pour corriger les bogues de IE
866
-                    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
867
-                    
868
-                    // On met le lien cliqué dans la variabke prévu
869
-                    link_add_tag = $(this);
870
-                    
871
-                    // En premier lieux on fait apparaître la fenêtre de confirmation
872
-                    var popup = $('<div>')
873
-                    .attr('id', 'add_tag')
874
-                    .addClass('popin_block')
875
-                    .css('width', '400px')
876
-                      //.append($('<h2>').append(string_tag_add_title))
877
-                   .append($('<form>')
878
-                     .attr('action', url_add_tag)
879
-                     .attr('method', 'post')
880
-                     .attr('name', 'add_tag')
881
-                     .ajaxForm(function(response) {
882
-                       /*
883
-                        *
884
-                        */
885
-
886
-                        if (response.status == 'mustbeconnected')
887
-                        {
888
-                          $(location).attr('href', url_index);
889
-                        }
890
-
891
-                        if (response.status == 'success')
892
-                        {
893
-                          var tag_id   = response.tag_id;
894
-                          var tag_name = response.tag_name;
895
-
896
-                          $('input#tags_selected_tag_'+form_name).val(tag_id);
897
-                          inputTag.val(tag_name);
898
-                          // Et on execute l'évènement selectTag de l'input
899
-                          inputTag.trigger("selectTag");
900
-                          // On cache la liste puisque le choix vient d'être fait
901
-                          divtags.hide();
902
-                          inputTag.val(tag_text_help); 
903
-
904
-                          link_add_tag.parents('div.search_tag_list').find('img.tag_loader').hide();
905
-
906
-                          $('#fade').fadeOut(400, function(){$('#fade').remove();});
907
-                          $('#add_tag').remove();
908
-                        }
909
-                        
910
-                        if (response.status == 'error')
911
-                        {
912
-                          $('form[name="add_tag"]').find('ul.error_list').remove();
913
-                          var ul_errors = $('<ul>').addClass('error_list');
914
-
915
-                          for (i in response.errors)
916
-                          {
917
-                            ul_errors.append($('<li>').append(response.errors[i]));
918
-                          }
919
-
920
-                          $('form[name="add_tag"]').prepend(ul_errors);
921
-                        }
922
-                        
923
-                        return false;
924
-                     })
925
-                     
926
-                      .append($('<div>').addClass('tag')
927
-                        .append($('<ul>')
928
-                          .append($('<li>').addClass('button')
929
-                            .append($(this).text()))))
930
-                      .append($('<p>').append(string_tag_add_text))
931
-                      .append($('<p>').append(string_tag_add_argument))
932
-                      .append($('<textarea>').attr('name', 'argument'))
933
-                      .append($('<div>').addClass('inputs')
934
-                        .append($('<input>')
935
-                          .attr('type', 'button')
936
-                          .attr('value', string_tag_add_inputs_cancel)
937
-                          .addClass('button')
938
-                          .click(function(){
939
-                            $('#fade').fadeOut(1000, function(){$('#fade').remove();});
940
-                            $('#add_tag').remove();
941
-                            
942
-                            return false;
943
-                          })
944
-                        )
945
-                        .append($('<input>')
946
-                          .attr('type', 'submit')
947
-                          .attr('value', string_tag_add_inputs_submit)
948
-                          .addClass('button')
949
-                          .click(function(){
950
-                            
951
-                            link_add_tag.parents('div.search_tag_list').find('img.tag_loader').show();
952
-                          
953
-                          })
954
-                        )
955
-                        .append($('<input>').attr('type', 'hidden').attr('name', 'tag_name').val($(this).text()))
956
-                      ))
957
-                    ;
958
-                    
959
-                    // Il faut ajouter le popup au dom avant de le positionner en css
960
-                    // Sinon la valeur height n'est pas encore calculable
961
-                    $('body').prepend(popup);
962
-                    
963
-                    //Récupération du margin, qui permettra de centrer la fenêtre - on ajuste de 80px en conformité avec le CSS
964
-                    var popMargTop = (popup.height() + 50) / 2;
965
-                    var popMargLeft = (popup.width() + 50) / 2;
966
-                    
967
-                    //On affecte le margin
968
-                    $(popup).css({
969
-                      'margin-top' : -popMargTop,
970
-                      'margin-left' : -popMargLeft
971
-                    });
972
-                    
973
-                    return false;
974
-                    
975
-                  })
858
+                  .click({
859
+                    inputTag: inputTag,
860
+                    form_name: form_name,
861
+                    divtags: divtags
862
+                  }, event_click_new_tag_proposition)
976
                   .append($.trim(input.val()))
863
                   .append($.trim(input.val()))
977
               );
864
               );
978
               search_tag_list.append(li_tag);
865
               search_tag_list.append(li_tag);
991
       
878
       
992
     }
879
     }
993
   }
880
   }
881
+  
882
+  function event_click_new_tag_proposition(event)
883
+  {
884
+    form_add_open_dialog_for_new_tag($(event.target), event.data.inputTag, event.data.form_name, event.data.divtags);
885
+  }
994
  
886
  
887
+  function form_add_open_dialog_for_new_tag(link_add_tag, inputTag, form_name, divtags)
888
+  {       
889
+    
890
+    
891
+    // Effet fade-in du fond opaque
892
+    $('body').append($('<div>').attr('id', 'fade')); 
893
+    //Apparition du fond - .css({'filter' : 'alpha(opacity=80)'}) pour corriger les bogues de IE
894
+    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
895
+    
896
+    // En premier lieux on fait apparaître la fenêtre de confirmation
897
+    var popup = $('<div>')
898
+    .attr('id', 'add_tag')
899
+    .addClass('popin_block')
900
+    .css('width', '400px')
901
+      //.append($('<h2>').append(string_tag_add_title))
902
+    .append($('<form>')
903
+      .attr('action', url_add_tag)
904
+      .attr('method', 'post')
905
+      .attr('name', 'add_tag')
906
+      .ajaxForm(function(response) {
907
+        /*
908
+        *
909
+        */
910
+
911
+        if (response.status == 'mustbeconnected')
912
+        {
913
+          $(location).attr('href', url_index);
914
+        }
915
+
916
+        if (response.status == 'success')
917
+        {
918
+          var tag_id   = response.tag_id;
919
+          var tag_name = response.tag_name;
920
+
921
+          $('input#tags_selected_tag_'+form_name).val(tag_id);
922
+          inputTag.val(tag_name);
923
+          // Et on execute l'évènement selectTag de l'input
924
+          inputTag.trigger("selectTag");
925
+          // On cache la liste puisque le choix vient d'être fait
926
+          divtags.hide();
927
+          inputTag.val(tag_text_help); 
928
+
929
+          link_add_tag.parents('div.search_tag_list').find('img.tag_loader').hide();
930
+
931
+          $('#fade').fadeOut(400, function(){$('#fade').remove();});
932
+          $('#add_tag').remove();
933
+        }
934
+
935
+        if (response.status == 'error')
936
+        {
937
+          $('form[name="add_tag"]').find('ul.error_list').remove();
938
+          var ul_errors = $('<ul>').addClass('error_list');
939
+
940
+          for (i in response.errors)
941
+          {
942
+            ul_errors.append($('<li>').append(response.errors[i]));
943
+          }
944
+
945
+          $('form[name="add_tag"]').prepend(ul_errors);
946
+        }
947
+
948
+        return false;
949
+      })
950
+
951
+      .append($('<div>').addClass('tag')
952
+        .append($('<ul>')
953
+          .append($('<li>').addClass('button')
954
+            .append(link_add_tag.text()))))
955
+      .append($('<p>').append(string_tag_add_text))
956
+      .append($('<p>').append(string_tag_add_argument))
957
+      .append($('<textarea>').attr('name', 'argument'))
958
+      .append($('<div>').addClass('inputs')
959
+        .append($('<input>')
960
+          .attr('type', 'button')
961
+          .attr('value', string_tag_add_inputs_cancel)
962
+          .addClass('button')
963
+          .click(function(){
964
+            $('#fade').fadeOut(1000, function(){$('#fade').remove();});
965
+            $('#add_tag').remove();
966
+
967
+            return false;
968
+          })
969
+        )
970
+        .append($('<input>')
971
+          .attr('type', 'submit')
972
+          .attr('value', string_tag_add_inputs_submit)
973
+          .addClass('button')
974
+          .click(function(){
975
+
976
+            link_add_tag.parents('div.search_tag_list').find('img.tag_loader').show();
977
+
978
+          })
979
+        )
980
+        .append($('<input>').attr('type', 'hidden').attr('name', 'tag_name').val(link_add_tag.text()))
981
+      ))
982
+    ;
983
+
984
+    // Il faut ajouter le popup au dom avant de le positionner en css
985
+    // Sinon la valeur height n'est pas encore calculable
986
+    $('body').prepend(popup);
987
+
988
+    //Récupération du margin, qui permettra de centrer la fenêtre - on ajuste de 80px en conformité avec le CSS
989
+    var popMargTop = (popup.height() + 50) / 2;
990
+    var popMargLeft = (popup.width() + 50) / 2;
991
+
992
+    //On affecte le margin
993
+    $(popup).css({
994
+      'margin-top' : -popMargTop,
995
+      'margin-left' : -popMargLeft
996
+    });
997
+
998
+    return false;
999
+  }
995
  
1000
  
996
   var last_keypress = 0;
1001
   var last_keypress = 0;
997
   
1002
   
1146
     }
1151
     }
1147
   }
1152
   }
1148
 
1153
 
1149
-  // Ajout d'un element #ajouter
1154
+  // Ajout d'un element #ajouter (première partie)
1150
   
1155
   
1151
   // Click sur "ajouter" (l'url)
1156
   // Click sur "ajouter" (l'url)
1152
   $('a#form_add_check_url').click(function(){
1157
   $('a#form_add_check_url').click(function(){
1153
     
1158
     
1159
+    // On fait tourner notre gif loader
1160
+    $('img#form_add_loader').show();
1161
+    
1154
     $.ajax({
1162
     $.ajax({
1155
       type: 'POST',
1163
       type: 'POST',
1156
       url: url_datas_api,
1164
       url: url_datas_api,
1157
       data: {'url':$('input#element_add_url').val()},
1165
       data: {'url':$('input#element_add_url').val()},
1158
       success: function(response){
1166
       success: function(response){
1159
         
1167
         
1160
-        console.debug(response);
1161
-        
1162
         if (response.status == 'mustbeconnected')
1168
         if (response.status == 'mustbeconnected')
1163
         {
1169
         {
1164
           $(location).attr('href', url_index);
1170
           $(location).attr('href', url_index);
1166
 
1172
 
1167
         if (response.status == 'success')
1173
         if (response.status == 'success')
1168
         {
1174
         {
1169
-
1175
+          // On cache notre gif loader.
1176
+          $('img#form_add_loader').hide();
1177
+          
1178
+          // On commence par renseigner les champs si on a du concret
1179
+          // name
1180
+          if (response.name)
1181
+          {
1182
+            $('input#element_add_name').val(response.name);
1183
+          }
1184
+          
1185
+          // thumb
1186
+          $('div#form_add_thumb img').attr('src', '/bundles/muzichcore/img/nothumb.png');
1187
+          if (response.thumb)
1188
+          {
1189
+            $('div#form_add_thumb img').attr('src', response.thumb);
1190
+          }
1191
+          
1192
+          // Proposition de tags
1193
+          if (response.tags)
1194
+          {
1195
+            $('ul#form_add_prop_tags li').remove();
1196
+            $('ul#form_add_prop_tags').show();
1197
+            $('ul#form_add_prop_tags_text').show();
1198
+            
1199
+            for (tags_index = 0; tags_index < response.tags.length; tags_index++)
1200
+            {
1201
+              var tag = response.tags[tags_index];
1202
+              var tag_id = '';
1203
+              var tag_name = tag.original_name;
1204
+              // Si il y a des équivalent en base.
1205
+              if (tag.like_found)
1206
+              {
1207
+                tag_id = tag.like.id;
1208
+                tag_name = tag.like.name;
1209
+              }
1210
+                
1211
+              // On aura plus qu'a vérifie le href pour savoir si c'est une demande d'ajout de tags =)
1212
+              $('ul#form_add_prop_tags').append(
1213
+                '<li>'+
1214
+                  '<a href="#'+tag_id+'" class="form_add_prop_tag">'+
1215
+                    tag_name+
1216
+                  '</a>'+
1217
+                '</li>'
1218
+              );
1219
+            }
1220
+          }
1221
+          
1222
+          // On a plus qu'a afficher les champs
1223
+          $('div#form_add_second_part').slideDown();
1224
+          $('div#form_add_first_part').slideUp();
1225
+            
1170
         }
1226
         }
1171
       },
1227
       },
1172
       dataType: 'json'
1228
       dataType: 'json'
1174
     
1230
     
1175
   });
1231
   });
1176
   
1232
   
1233
+  /*
1234
+   * Formulaire d'ajout: click sur proposition de tags du a une api
1235
+   */
1236
+  
1237
+  $('a.form_add_prop_tag').live('click', function(){
1238
+    
1239
+    var form_name = "add";
1240
+    var tag_id = str_replace('#', '', $(this).attr('href'));
1241
+    var input_tag = $("div.tags_prompt ul.tagbox li.input input");
1242
+    
1243
+    // Si on connait le tag id (pas un nouveau tag donc)
1244
+    if (tag_id)
1245
+    {
1246
+      $('input#tags_selected_tag_'+form_name).val(tag_id);
1247
+      input_tag.val($(this).text());
1248
+      // Et on execute l'évènement selectTag de l'input
1249
+      input_tag.trigger("selectTag");
1250
+      input_tag.val(tag_text_help); 
1251
+    }
1252
+    else
1253
+    {
1254
+      // Cette var sert a rien ici, mais c'est la refactorisation qui
1255
+      //  pose problmeme (corrigeable cela dit)
1256
+      var divtags = $("#search_tag_"+form_name);
1257
+      form_add_open_dialog_for_new_tag($(this), input_tag, form_name, divtags);
1258
+    }
1259
+    
1260
+  });
1177
   
1261
   
1262
+  // #ajouter ajouter un élément (envoi du formulaire)
1178
   $('form[name="add"] input[type="submit"]').live('click', function(){
1263
   $('form[name="add"] input[type="submit"]').live('click', function(){
1179
     $('form[name="add"]').find('img.tag_loader').show();
1264
     $('form[name="add"]').find('img.tag_loader').show();
1180
   });
1265
   });
1187
     $('form[name="add"] img.tag_loader').hide();
1272
     $('form[name="add"] img.tag_loader').hide();
1188
     element_add_proceed_json_response(response);
1273
     element_add_proceed_json_response(response);
1189
     
1274
     
1275
+    $('div#element_add_box').slideUp();
1276
+    $('div#form_add_first_part').show();
1277
+    $('div#form_add_second_part').hide();
1278
+    $('ul#form_add_prop_tags').hide();
1279
+    $('ul#form_add_prop_tags_text').hide();
1280
+    
1190
     return false;
1281
     return false;
1191
   });
1282
   });
1192
   
1283
   

Dosya farkı çok büyük olduğundan ihmal edildi
+ 9440 - 0
web/js/jquery-1.8.2.dev.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 2 - 0
web/js/jquery-1.8.2.prod.js