Show More
@@ -1,142 +1,144 b'' | |||
|
1 | 1 | <%inherit file="/base/base.html"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${_('%s files') % c.repo_name} - ${c.rhodecode_name} |
|
5 | 5 | </%def> |
|
6 | 6 | |
|
7 | 7 | <%def name="breadcrumbs_links()"> |
|
8 | 8 | ${h.link_to(_(u'Home'),h.url('/'))} |
|
9 | 9 | » |
|
10 | 10 | ${h.link_to(c.repo_name,h.url('files_home',repo_name=c.repo_name))} |
|
11 | 11 | » |
|
12 | 12 | ${_('files')} |
|
13 | 13 | %if c.file: |
|
14 | 14 | @ r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} |
|
15 | 15 | %endif |
|
16 | 16 | </%def> |
|
17 | 17 | |
|
18 | 18 | <%def name="page_nav()"> |
|
19 | 19 | ${self.menu('files')} |
|
20 | 20 | </%def> |
|
21 | 21 | |
|
22 | 22 | <%def name="main()"> |
|
23 | 23 | <div class="box"> |
|
24 | 24 | <!-- box / title --> |
|
25 | 25 | <div class="title"> |
|
26 | 26 | ${self.breadcrumbs()} |
|
27 | 27 | <ul class="links"> |
|
28 | 28 | <li> |
|
29 | 29 | <span style="text-transform: uppercase;"><a href="#">${_('branch')}: ${c.changeset.branch}</a></span> |
|
30 | 30 | </li> |
|
31 | 31 | </ul> |
|
32 | 32 | </div> |
|
33 | 33 | <div class="table"> |
|
34 | 34 | <div id="files_data"> |
|
35 | 35 | <%include file='files_ypjax.html'/> |
|
36 | 36 | </div> |
|
37 | 37 | </div> |
|
38 | 38 | </div> |
|
39 | 39 | |
|
40 | 40 | <script type="text/javascript"> |
|
41 | 41 | var CACHE = {}; |
|
42 | 42 | var CACHE_EXPIRE = 60*1000; //cache for 60s |
|
43 | 43 | //used to construct links from the search list |
|
44 | 44 | var node_list_url = '${h.url("files_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; |
|
45 | 45 | //send the nodelist request to this url |
|
46 | 46 | var url_base = '${h.url("files_nodelist_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; |
|
47 | 47 | |
|
48 | 48 | var ypjax_links = function(){ |
|
49 | 49 | YUE.on(YUQ('.ypjax-link'), 'click',function(e){ |
|
50 | 50 | |
|
51 | 51 | //don't do ypjax on middle click |
|
52 | 52 | if(e.which == 2 || !History.enabled){ |
|
53 | 53 | return true; |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | var el = e.currentTarget; |
|
57 | 57 | var url = el.href; |
|
58 | 58 | |
|
59 | 59 | var _base_url = '${h.url("files_home",repo_name=c.repo_name,revision='',f_path='')}'; |
|
60 | 60 | _base_url = _base_url.replace('//','/') |
|
61 | 61 | |
|
62 | 62 | //extract rev and the f_path from url. |
|
63 | 63 | parts = url.split(_base_url) |
|
64 | 64 | if(parts.length != 2){ |
|
65 | 65 | return false; |
|
66 | 66 | } |
|
67 | 67 | |
|
68 | 68 | var parts2 = parts[1].split('/'); |
|
69 | 69 | var rev = parts2.shift(); // pop the first element which is the revision |
|
70 | 70 | var f_path = parts2.join('/'); |
|
71 | 71 | |
|
72 | 72 | var title = "${_('%s files') % c.repo_name}" + " - " + f_path; |
|
73 | 73 | |
|
74 | 74 | var _node_list_url = node_list_url.replace('__REV__',rev); |
|
75 | 75 | var _url_base = url_base.replace('__REV__',rev).replace('__FPATH__', f_path); |
|
76 | 76 | |
|
77 | 77 | // Change our States and save some data for handling events |
|
78 | 78 | var data = {url:url,title:title, url_base:_url_base, |
|
79 | 79 | node_list_url:_node_list_url}; |
|
80 | 80 | History.pushState(data, title, url); |
|
81 | 81 | |
|
82 | 82 | //now we're sure that we can do ypjax things |
|
83 | 83 | YUE.preventDefault(e) |
|
84 | 84 | return false; |
|
85 | 85 | }); |
|
86 | 86 | } |
|
87 | 87 | |
|
88 | 88 | var callbacks = function(State){ |
|
89 | 89 | ypjax_links(); |
|
90 | 90 | tooltip_activate(); |
|
91 | 91 | fileBrowserListeners(State.url, State.data.node_list_url, State.data.url_base); |
|
92 | YUE.on('hlcode','mouseup',getSelectionLink("${_('Selection link')}")); | |
|
93 | ||
|
92 | 94 | // Inform Google Analytics of the change |
|
93 | 95 | if ( typeof window.pageTracker !== 'undefined' ) { |
|
94 | 96 | window.pageTracker._trackPageview(State.url); |
|
95 | 97 | } |
|
96 | 98 | } |
|
97 | 99 | |
|
98 | 100 | YUE.onDOMReady(function(){ |
|
99 | 101 | ypjax_links(); |
|
100 | 102 | var container = 'files_data'; |
|
101 | 103 | //Bind to StateChange Event |
|
102 | 104 | History.Adapter.bind(window,'statechange',function(){ |
|
103 | 105 | var State = History.getState(); |
|
104 | 106 | cache_key = State.url; |
|
105 | 107 | //check if we have this request in cache maybe ? |
|
106 | 108 | var _cache_obj = CACHE[cache_key]; |
|
107 | 109 | var _cur_time = new Date().getTime(); |
|
108 | 110 | // get from cache if it's there and not yet expired ! |
|
109 | 111 | if(_cache_obj !== undefined && _cache_obj[0] > _cur_time){ |
|
110 | 112 | YUD.get(container).innerHTML=_cache_obj[1]; |
|
111 | 113 | YUD.setStyle(container,'opacity','1.0'); |
|
112 | 114 | |
|
113 | 115 | //callbacks after ypjax call |
|
114 | 116 | callbacks(State); |
|
115 | 117 | } |
|
116 | 118 | else{ |
|
117 | 119 | ypjax(State.url,container,function(o){ |
|
118 | 120 | //callbacks after ypjax call |
|
119 | 121 | callbacks(State); |
|
120 | 122 | if (o !== undefined){ |
|
121 | 123 | //store our request in cache |
|
122 | 124 | var _expire_on = new Date().getTime()+CACHE_EXPIRE; |
|
123 | 125 | CACHE[cache_key] = [_expire_on, o.responseText]; |
|
124 | 126 | } |
|
125 | 127 | }); |
|
126 | 128 | } |
|
127 | 129 | }); |
|
128 | 130 | |
|
129 | 131 | // init the search filter |
|
130 | 132 | var _State = { |
|
131 | 133 | url: "${h.url.current()}", |
|
132 | 134 | data: { |
|
133 | 135 | node_list_url: node_list_url.replace('__REV__',"${c.changeset.raw_id}"), |
|
134 | 136 | url_base: url_base.replace('__REV__',"${c.changeset.raw_id}").replace('__FPATH__', "${h.safe_unicode(c.file.path)}") |
|
135 | 137 | } |
|
136 | 138 | } |
|
137 | 139 | fileBrowserListeners(_State.url, _State.data.node_list_url, _State.data.url_base); |
|
138 | 140 | }); |
|
139 | 141 | |
|
140 | 142 | </script> |
|
141 | 143 | |
|
142 | 144 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now