Changeset - d66201a7ce6e
[Not reviewed]
default
0 2 0
Mads Kiilerich - 7 years ago 2018-12-25 20:23:42
mads@kiilerich.com
files: change "callbacks" function to the more descriptive name "post_load_state" and let it take an actual state data object

Makes the function more independent of native.history.js .
2 files changed with 10 insertions and 16 deletions:
0 comments (0 inline, 0 general)
kallithea/templates/files/files.html
Show inline comments
 
@@ -90,20 +90,19 @@ var ypjax_links = function(){
 
    });
 
}
 

	
 
// callbacks needed to process the ypjax filebrowser
 
var callbacks = function(State){
 
var post_load_state = function(state) {
 
    ypjax_links();
 
    tooltip_activate();
 

	
 
    if(State !== undefined){
 
    if(state !== undefined) {
 
        //initially loaded stuff
 
        var _f_path = State.data.f_path;
 
        var _rev = State.data.rev;
 
        var _f_path = state.f_path;
 
        var _rev = state.rev;
 

	
 
        fileBrowserListeners(State.data.node_list_url, State.data.url_base);
 
        fileBrowserListeners(state.node_list_url, state.url_base);
 
        // Inform Google Analytics of the change
 
        if ( typeof window.pageTracker !== 'undefined' ) {
 
            window.pageTracker._trackPageview(State.url);
 
            window.pageTracker._trackPageview(state.url);
 
        }
 
    }
 

	
 
@@ -211,12 +210,11 @@ $(document).ready(function(){
 
        if(_cache_obj !== undefined && _cache_obj[0] > _cur_time){
 
            $files_data.html(_cache_obj[1]);
 
            $files_data.css('opacity','1.0');
 
            //callbacks after ypjax call
 
            callbacks(State);
 
            post_load_state(State.data);
 
        }
 
        else{
 
            asynchtml(State.url, $files_data, function(){
 
                    callbacks(State);
 
                    post_load_state(State.data);
 
                    var expire_on = new Date().getTime() + CACHE_EXPIRE;
 
                    CACHE[cache_key] = [expire_on, $files_data.html()];
 
                });
kallithea/templates/files/files_source.html
Show inline comments
 
@@ -80,16 +80,12 @@
 

	
 
<script>
 
    $(document).ready(function(){
 
        // fake html5 history state
 
        var _State = {
 
           url: ${h.js(h.url.current())},
 
           data: {
 
        var state = {
 
             node_list_url: node_list_url.replace('__REV__',${h.js(c.changeset.raw_id)}).replace('__FPATH__', ${h.js(h.safe_unicode(c.file.path))}),
 
             url_base: url_base.replace('__REV__',${h.js(c.changeset.raw_id)}),
 
             rev:${h.js(c.changeset.raw_id)},
 
             f_path: ${h.js(h.safe_unicode(c.file.path))}
 
           }
 
        }
 
        callbacks(_State); // defined in files.html, main callbacks. Triggered in pjax calls
 
        post_load_state(State.data); // defined in files.html
 
    });
 
</script>
0 comments (0 inline, 0 general)