Changeset 35101


Ignore:
Timestamp:
2021-04-23T11:02:20+12:00 (3 years ago)
Author:
davidb
Message:

Topped up with the ability to 'remember' through the hash-part of the URL what has previously been opened

Location:
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/js
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/js/jquery.show-more.js

    r34972 r35101  
    4141
    4242                            if (element.css('max-height') != 'none') {
     43                var url = window.location.href;
     44
     45                var url_hash = window.location.hash;
     46                var currentid_re = new RegExp(currentid);
     47                if (!currentid_re.test(url_hash)) {
     48                    var new_url = url;
     49                    if (url_hash == "") {
     50                    new_url += "#" + currentid;
     51                    }
     52                    else {
     53                    new_url += "," + currentid;
     54                    }
     55                    history.replaceState(null,null,new_url);
     56                }
     57               
    4358                                element.css('height', settings.minheight).css('max-height', '').animate({height:fullheight}, settings.animationspeed, function () { showMoreButton.html(settings.buttontxtless); });
    44                             } else {
     59                            }
     60                else {
     61
     62                var url = window.location.href;
     63                var url_hash = window.location.hash;
     64
     65                var currentid_re = new RegExp(currentid);
     66                if (currentid_re.test(url_hash)) {
     67                    var new_url_hash = url_hash.replace(currentid,"");
     68                    // tidy-up
     69                    var new_url_hash = new_url_hash.replace(/,,/,",").replace(/^#,/,"#").replace(/,$/,"");
     70                   
     71                    var new_url = url.replace(/#.*$/,"");
     72                    if (new_url_hash != "#") {
     73                    new_url += new_url_hash;
     74                    }
     75                    history.replaceState(null,null,new_url);
     76                }
     77               
    4578                                element.animate({height:settings.minheight}, settings.animationspeed, function () { showMoreButton.html(settings.buttontxtmore); element.css('max-height', settings.minheight); });
    4679                            }
     
    6497
    6598}(jQuery));
     99
     100
     101$(document).ready(function() {
     102
     103    var url_hash = window.location.hash.replace(/^#/,"");
     104    var showmore_ids = url_hash.split(",");
     105
     106    for (var i=0; i<showmore_ids.length; i++) {
     107    var showmore_id = showmore_ids[i];
     108    var $showmore_button = $('#showmore-button-'+showmore_id);
     109   
     110    if ($showmore_button.length>0) {
     111        $showmore_button.click();
     112    }
     113    }
     114});
Note: See TracChangeset for help on using the changeset viewer.