]> git.parisson.com Git - telemeta.git/commitdiff
Fix tablesorter
authormathieu <mathieu.boye28@gmail.com>
Tue, 31 May 2016 11:53:37 +0000 (13:53 +0200)
committermathieu <mathieu.boye28@gmail.com>
Tue, 31 May 2016 11:53:37 +0000 (13:53 +0200)
Remove parser numerised
Add invisible paragraph in haystack results list in order to keep
sort funtion in this list

1  2 
telemeta/static/telemeta/js/advanceSearch.js
telemeta/static/telemeta/js/playlist.js
telemeta/static/telemeta/js/search.js
telemeta/templates/search/mediacollection_listhaystack.html
telemeta/templates/search/mediaitem_listhaystack.html
telemeta/templates/search/mediaresource_listhaystack.html
telemeta/templates/search/search.html
telemeta/templates/telemeta/lists.html

index 66bb9a50a53d5b7187656079dbb30f3e0b89e501,70f13f582e83c04c666282e24aa64299a8f537c2..1e7305a0c9de039b507b69822d55b169420558eb
@@@ -121,143 -103,4 +121,125 @@@ $(document).ready(function () 
                      });
                  }
              });
 -      });
 +        });
 +
 +    }
 +
 +    activate_autocomplete($('#id_code, #id_instruments, #id_collectors, #id_location'));
 +
 +    var colSort = [];
 +
-     $.tablesorter.addParser({
-         id: 'numerised',
-         is: function (s) {
-             return false;
-         },
-         format: function (s, table, cell) {
-             var _class = $(cell).find('center span').attr('class');
-             _class = _class == undefined ? 1 : 0;
-             return _class;
-         },
-         type: 'number'
-     });
 +    if (sessionStorage['sort'] && sessionStorage['order']) {
 +        $.tablesorter.defaults.sortList = [[sessionStorage['sort'], sessionStorage['order']]];
 +    }
 +    else {
 +        $.tablesorter.defaults.sortList = [[1, 0]];
 +    }
 +
 +    $('#searchtable th').each(function (index) {
 +        colSort[index] = $(this).text();
 +    });
 +
 +
 +    $('#searchtable th').on('click', function () {
 +        var index = colSort.indexOf($(this).text());
 +        var order = $.tablesorter.defaults.headerList[index]['order'];
 +        if (index != sessionStorage['sort']) {
 +            sessionStorage['order'] = 0;
 +        }
 +        else {
 +            sessionStorage['order'] = (sessionStorage['order'] == 0) ? 1 : 0;
 +        }
 +        sessionStorage['sort'] = index;
 +    });
 +
 +    $("#searchtable").tablesorter({
 +        headers: {
 +            0: {sorter: false},
-             2: {sorter: 'numerised'}
 +        }
 +    });
 +
 +
 +    $('#dialog').dialog({
 +        autoOpen: false,
 +        width: '40%',
 +        height: 600,
 +    });
 +
 +    $('.fieldWrapper a').click(function () {
 +        $('#dialog').dialog("open");
 +    });
 +
 +    var deleteButton = '<a class="btn btn-default" id="del" href="#">' + gettrans('delete field') + '</a><br/>';
 +
 +    var tag = $('#copy').clone();
 +    $(tag).children().each(function () {
 +        $(this).val('').prop('checked', false).prop('selected', false);
 +    });
 +
 +    function deleteField(e) {
 +        e.preventDefault();
 +        var number = $('input[name*="text_field"]').length;
 +        if (number == 3) {
 +            $('#del').remove();
 +        }
 +        $('#bloc-' + (number - 1)).remove();
 +        $('#id_form-TOTAL_FORMS').attr('value', number - 1);
 +
 +    }
 +
 +    function addField(e) {
 +        e.preventDefault();
 +        var number = $('input[name*="text_field"]').length;
 +        var tag_field = $(tag).clone().attr('id', 'bloc-' + number);
 +        if (number == 2) {
 +            $('#add').after(deleteButton);
 +            $('#del').click(deleteField);
 +        }
 +        $('#add').before(tag_field);
 +        $('#bloc-' + number).html($('#bloc-' + number).html().replace(/1/g, number));
 +        activate_autocomplete($('#id_form-' + number + '-text_field'), 'instruments');
 +        $('#id_form-TOTAL_FORMS').attr('value', number + 1);
 +    }
 +
 +    $('#add').click(addField);
 +
 +    activate_autocomplete($('#id_form-0-text_field, #id_form-1-text_field'), 'instruments');
 +
 +    var interval = null;
 +    var textInput = "";
 +
 +    $('#dialog form').on('submit change', function (e) {
 +        if (e.type != 'keypress') e.preventDefault();
 +        $.ajax({
 +            url: '/search/booleaninstru/',
 +            dataType: 'json',
 +            data: $(this).serialize(),
 +            success: function (donnees) {
 +                if (e.type == 'submit' && !donnees.result.match(/\[ERROR\]/g)) {
 +                    $("#dialog").dialog("close");
 +                    $('#id_instruments').val(donnees.result);
 +                }
 +                $('#res').html(gettrans('final query') + " :<br/><strong>" + gettrans(donnees.result) + '</strong>');
 +            },
 +        });
 +    });
 +
 +    $('#dialog input[type="text"]').on('focus', function () {
 +        textInput = $(this).val();
 +        var self = this;
 +        interval = setInterval(function () {
 +            if ($(self).val() != textInput) {
 +                textInput = $(self).val();
 +                $('#dialog form').trigger('change');
 +            }
 +        }, 500);
 +    });
 +
 +    $('#dialog input[type="text"]').on('blur', function () {
 +        clearInterval(interval);
 +        textInput = ""
 +    });
 +
 +
 +});
index a4975a048f91753a8170c4d252ae6882ad24f608,3e4a0810b31dc625120b0304fd621a903514de6b..31430d0f38fa78d19573339c290d1a6e557b70da
@@@ -45,11 -45,13 +45,13 @@@ var playlistUtils = 
      id: '', // ID var: used to edit playlist
      title: '',
      description: '',
+     state: 'stop', // state var: to state play or pause glyphicon
+     playing: '', // playing var: used to know if an audio is already playing or not
  
 -    addPlaylist: function(name, id){
 +    addPlaylist: function (name, id) {
          this.playlists.push({
 -            'name':name,
 -            'id':id
 +            'name': name,
 +            'id': id
          });
      },
  
index 8b2a5066418b5a8d088a3da6e4cb658350d1f8ff,8b2a5066418b5a8d088a3da6e4cb658350d1f8ff..5f62908711e87870b2907d55ac464b15de6ab126
@@@ -66,4 -66,4 +66,39 @@@ $(function() 
                      });
                  }
              });
++
++                var colSort = [];
++
++    if (sessionStorage['sort'] && sessionStorage['order']) {
++        $.tablesorter.defaults.sortList = [[sessionStorage['sort'], sessionStorage['order']]];
++    }
++    else {
++        $.tablesorter.defaults.sortList = [[1, 0]];
++    }
++
++    $('#searchtable th').each(function (index) {
++        colSort[index] = $(this).text();
++    });
++
++
++    $('#searchtable th').on('click', function () {
++        var index = colSort.indexOf($(this).text());
++        var order = $.tablesorter.defaults.headerList[index]['order'];
++        if (index != sessionStorage['sort']) {
++            sessionStorage['order'] = 0;
++        }
++        else {
++            sessionStorage['order'] = (sessionStorage['order'] == 0) ? 1 : 0;
++        }
++        sessionStorage['sort'] = index;
++    });
++
++    $("#searchtable").tablesorter({
++        headers: {
++
++            0: {sorter: false},
++        }
++
++    });
++
        });
index 99ace6d5072498bfb5cbc5968cfb12e6ea4b641f,621fac942976a57628bc7a57f3ae284c4b3b7149..c8c37046d646e509aace2cc55d00e81d8da8cf8c
@@@ -29,7 -26,7 +29,7 @@@
          </td>
          <td>
            {% if result.object.has_mediafile %}
--           <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"></span></center>
++           <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"><p style="opacity:0;font-size:0">d</p></span></center>
            {% endif %}
          </td>
  
@@@ -57,7 -53,7 +57,7 @@@
          </td>
          <td>
            {% if result.object.has_mediafile %}
--           <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"></span></center>
++           <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"><p style="opacity:0;font-size:0">d</p></span></center>
            {% endif %}
          </td>
  
index 2fd5306b83f5f937b50dcd56fca93f393edb5e61,47bf9da0db28b2a660900254130ccff36a4441e4..e7a4fe8325ecc3ea9948f2f0ac9a5eb4ec093d44
@@@ -34,7 -31,7 +34,7 @@@
          <td align="center">
              {% if result.object.file %}
               <a href="{% url "telemeta-item-detail" result.object.public_id %}">
--              <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"></span></center>
++              <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"><p style="opacity:0;font-size:0">d</p></span></center>
              {% endif %}
          </td>
  
@@@ -63,7 -59,7 +63,7 @@@
          <td align="center">
              {% if result.object.file %}
               <a href="{% url "telemeta-item-detail" result.object.public_id %}">
--              <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"></span></center>
++              <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"><p style="opacity:0;font-size:0">d</p></span></center>
              {% endif %}
          </td>
  
index 123ae9654735c4c0475e969faea428034e03332c,533c32f01fc0c764fbf6b20425d97f35a89c2292..ed1ca57b0b73f8e389db53d8ec91376490b268fe
@@@ -27,7 -24,7 +27,7 @@@
          </td>
          <td>
            {% if result.object.has_mediafile %}
--           <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"></span></center>
++           <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"><p style="opacity:0;font-size:0">d</p></span></center>
            {% endif %}
          </td>
  
@@@ -47,7 -43,7 +47,7 @@@
          </td>
          <td>
            {% if result.object.has_mediafile %}
--           <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"></span></center>
++           <center><span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"><p style="opacity:0;font-size:0">d</p></span></center>
            {% endif %}
          </td>
  
Simple merge
index ff6177c63fcee8533458fb3d7f0bc0289ed4c607,9c8725c9dde00b97b06ad8348033daf500136274..32be5f95639d97cc6659c72b5208e8bcd19d51a8
@@@ -45,9 -40,7 +45,9 @@@
  
          $.tablesorter.defaults.sortList = [[2,0]];
          {% for playlist in playlists %}
 -            $("#{{playlist.playlist.public_id}}tb").tablesorter({headers: {6:{sorter:false}}} );
 +              {% if playlist.resources|length != 0 %}
-                       $("#{{playlist.playlist.public_id}}tb").tablesorter({headers: {6:{sorter:false}}} );
++                      $("#{{playlist.playlist.public_id}}tb").tablesorter({headers: {0:{sorter:false}}} );
 +              {% endif %}
          {% endfor %}
      });
  </script>
                  </td>
                  <td align="center" style="vertical-align:middle;">
                      {% if resource.element.file or resource.element.has_mediafile %}
-                         <!--<a class="playButton" href="javascript:">-->
-                             <span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"><p style="opacity:0;font-size:0">d</p></span>
-                         <!--</a>-->
+                         <span class="glyphicon glyphicon-ok" style="font-size: 1.3em;color: green;"><p style="opacity:0;font-size:0">d</p></span>
                      {% endif %}
                  </td>
-                 <td style="vertical-align:middle">
-                 <a href="#" onclick="if(confirm(gettrans('delete the resource from the playlist permanently?'))){playlistUtils.removeResource('{{resource.public_id}}', '{{ forloop.parentloop.counter0 }}');};return false;" class="component_icon button icon_cancel" style="padding: 4px 12px;"></a>
+                 <td align="center" style="vertical-align:middle;">
 -                    <a href="#" onclick="if(confirm(gettrans('delete the resource from the playlist permanently?'))){playlistUtils.removeResource('{{resource.public_id}}');};return false;">
 -                        <span class="glyphicon glyphicon-trash" style="font-size: 1.3em;color: black;"><p style="opacity:0;font-size:0">d</p></span>
 -                    </a>
++                <a href="#" onclick="if(confirm(gettrans('delete the resource from the playlist permanently?'))){playlistUtils.removeResource('{{resource.public_id}}', '{{ forloop.parentloop.counter0 }}');};return false;">
++                     <span class="glyphicon glyphicon-trash" style="font-size: 1.3em;color: black;"><p style="opacity:0;font-size:0">d</p></span>
++                </a>
                  </td>
              </tr>
              {% endfor %}