Mercurial > kallithea
diff rhodecode/templates/files/files.html @ 3001:37c7abd34d44 beta
implements #636, lazy loading of history and authors to speed up page responsiveness.
- loading full history is not always needed, and it's very heavy operation. Now this is lazy loaded
when clicking on button
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 13 Nov 2012 22:26:06 +0100 |
parents | cff9d4e1d821 |
children | adf8ee7b8f2a |
line wrap: on
line diff
--- a/rhodecode/templates/files/files.html Sat Nov 10 19:04:23 2012 +0100 +++ b/rhodecode/templates/files/files.html Tue Nov 13 22:26:06 2012 +0100 @@ -39,11 +39,13 @@ <script type="text/javascript"> var CACHE = {}; -var CACHE_EXPIRE = 60*1000; //cache for 60s +var CACHE_EXPIRE = 5*60*1000; //cache for 5*60s //used to construct links from the search list var url_base = '${h.url("files_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; //send the nodelist request to this url var node_list_url = '${h.url("files_nodelist_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; +// send the node history requst to this url +var node_history_url = '${h.url("files_history_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; var ypjax_links = function(){ YUE.on(YUQ('.ypjax-link'), 'click',function(e){ @@ -76,7 +78,7 @@ // Change our States and save some data for handling events var data = {url:url,title:title, url_base:_url_base, - node_list_url:_node_list_url}; + node_list_url:_node_list_url, rev:rev, f_path:f_path}; History.pushState(data, title, url); //now we're sure that we can do ypjax things @@ -89,8 +91,19 @@ ypjax_links(); tooltip_activate(); fileBrowserListeners(State.url, State.data.node_list_url, State.data.url_base); - YUE.on('hlcode','mouseup',getSelectionLink("${_('Selection link')}")); - + + if(YUD.get('hlcode')){ + YUE.on('hlcode', 'mouseup', getSelectionLink); + } + //console.log(State); + if(YUD.get('load_node_history')){ + //remove all listeners due to problems of history state + YUE.removeListener('load_node_history', 'click'); + YUE.on('load_node_history', 'click', function(e){ + var _url = node_history_url.replace('__REV__',State.data.rev).replace('__FPATH__', State.data.f_path); + ypjax(_url, 'node_history', function(o){}) + }); + } // Inform Google Analytics of the change if ( typeof window.pageTracker !== 'undefined' ) { window.pageTracker._trackPageview(State.url); @@ -133,7 +146,9 @@ url: "${h.url.current()}", data: { node_list_url: node_list_url.replace('__REV__',"${c.changeset.raw_id}").replace('__FPATH__', "${h.safe_unicode(c.file.path)}"), - url_base: url_base.replace('__REV__',"${c.changeset.raw_id}") + url_base: url_base.replace('__REV__',"${c.changeset.raw_id}"), + rev:"${c.changeset.raw_id}", + f_path: "${h.safe_unicode(c.file.path)}" } } fileBrowserListeners(_State.url, _State.data.node_list_url, _State.data.url_base);