EPrints Technical Mailing List Archive

Message: #04911


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: sort order of contributors.Contribution for other languages


Gilles thanks! I'll give it a try and will give feedback when it works!

On 12/10/2015 05:17 μμ, Gilles Fournié wrote:
@Gilles: Your idea sounds nice. What static part should I change in
order to make it work? (eg default.xml?)
I think it's better to add a javascript file in
.../archives/YOURID/cfg/static/javascript/auto/

We use jQuery, so I am not very comfortable with plain javascript and
even less with prototype.
But with jQuery, you could use something like the following and adapt it
to your content.

     // To prevent problems between Prototype and jQuery
     jQuery.noConflict();

     // To run the code after the browser has finished loaded the DOM
     jQuery(document).ready(function($){

          // Code from
     http://stackoverflow.com/questions/12073270/sorting-options-elements-alphabetically-using-jquery
          // ***NOT FULLY TESTED***|

     |    var options = $('select[id$="pays_publication"] option');
          var arr = options.map(function(_, o) {
              return {
                  t: $(o).text(),
                  v: o.value,
                  s: $(o).attr('selected')
              };
          }).get();

          arr.sort(function(o1, o2) {
              return o1.t > o2.t ? 1 : o1.t < o2.t ? -1 : 0;
          });

          options.each(function(i, o) {
              o.value = arr[i].v;
              $(o).text(arr[i].t);
              $(o).attr('selected', arr[i].s);
          });

     });

Of course you'll also need to load the jQuery library.

If you don't use jQuery, it would be better to find the corresponding
code for Prototype so you will not have to load another library just for
this functionality.

Regards
GF


*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/


--
George Mamalakis

IT and Security Officer,
Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),
PhD (Aristotle Univ. of Thessaloniki),
MSc (Imperial College of London)

School of Electrical and Computer Engineering
Aristotle University of Thessaloniki

phone number : +30 (2310) 994379