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