##// END OF EJS Templates
fire tooltips after loading the history
marcink -
r3003:adf8ee7b beta
parent child Browse files
Show More
@@ -1,159 +1,161 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 = 5*60*1000; //cache for 5*60s
42 var CACHE_EXPIRE = 5*60*1000; //cache for 5*60s
43 //used to construct links from the search list
43 //used to construct links from the search list
44 var url_base = '${h.url("files_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}';
44 var url_base = '${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 node_list_url = '${h.url("files_nodelist_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}';
46 var node_list_url = '${h.url("files_nodelist_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}';
47 // send the node history requst to this url
47 // send the node history requst to this url
48 var node_history_url = '${h.url("files_history_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}';
48 var node_history_url = '${h.url("files_history_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}';
49
49
50 var ypjax_links = function(){
50 var ypjax_links = function(){
51 YUE.on(YUQ('.ypjax-link'), 'click',function(e){
51 YUE.on(YUQ('.ypjax-link'), 'click',function(e){
52
52
53 //don't do ypjax on middle click
53 //don't do ypjax on middle click
54 if(e.which == 2 || !History.enabled){
54 if(e.which == 2 || !History.enabled){
55 return true;
55 return true;
56 }
56 }
57
57
58 var el = e.currentTarget;
58 var el = e.currentTarget;
59 var url = el.href;
59 var url = el.href;
60
60
61 var _base_url = '${h.url("files_home",repo_name=c.repo_name,revision='',f_path='')}';
61 var _base_url = '${h.url("files_home",repo_name=c.repo_name,revision='',f_path='')}';
62 _base_url = _base_url.replace('//','/')
62 _base_url = _base_url.replace('//','/')
63
63
64 //extract rev and the f_path from url.
64 //extract rev and the f_path from url.
65 parts = url.split(_base_url)
65 parts = url.split(_base_url)
66 if(parts.length != 2){
66 if(parts.length != 2){
67 return false;
67 return false;
68 }
68 }
69
69
70 var parts2 = parts[1].split('/');
70 var parts2 = parts[1].split('/');
71 var rev = parts2.shift(); // pop the first element which is the revision
71 var rev = parts2.shift(); // pop the first element which is the revision
72 var f_path = parts2.join('/');
72 var f_path = parts2.join('/');
73
73
74 var title = "${_('%s files') % c.repo_name}" + " - " + f_path;
74 var title = "${_('%s files') % c.repo_name}" + " - " + f_path;
75
75
76 var _node_list_url = node_list_url.replace('__REV__',rev).replace('__FPATH__', f_path);
76 var _node_list_url = node_list_url.replace('__REV__',rev).replace('__FPATH__', f_path);
77 var _url_base = url_base.replace('__REV__',rev);
77 var _url_base = url_base.replace('__REV__',rev);
78
78
79 // Change our States and save some data for handling events
79 // Change our States and save some data for handling events
80 var data = {url:url,title:title, url_base:_url_base,
80 var data = {url:url,title:title, url_base:_url_base,
81 node_list_url:_node_list_url, rev:rev, f_path:f_path};
81 node_list_url:_node_list_url, rev:rev, f_path:f_path};
82 History.pushState(data, title, url);
82 History.pushState(data, title, url);
83
83
84 //now we're sure that we can do ypjax things
84 //now we're sure that we can do ypjax things
85 YUE.preventDefault(e);
85 YUE.preventDefault(e);
86 return false;
86 return false;
87 });
87 });
88 }
88 }
89
89
90 var callbacks = function(State){
90 var callbacks = function(State){
91 ypjax_links();
91 ypjax_links();
92 tooltip_activate();
92 tooltip_activate();
93 fileBrowserListeners(State.url, State.data.node_list_url, State.data.url_base);
93 fileBrowserListeners(State.url, State.data.node_list_url, State.data.url_base);
94
94
95 if(YUD.get('hlcode')){
95 if(YUD.get('hlcode')){
96 YUE.on('hlcode', 'mouseup', getSelectionLink);
96 YUE.on('hlcode', 'mouseup', getSelectionLink);
97 }
97 }
98 //console.log(State);
98 //console.log(State);
99 if(YUD.get('load_node_history')){
99 if(YUD.get('load_node_history')){
100 //remove all listeners due to problems of history state
100 //remove all listeners due to problems of history state
101 YUE.removeListener('load_node_history', 'click');
101 YUE.removeListener('load_node_history', 'click');
102 YUE.on('load_node_history', 'click', function(e){
102 YUE.on('load_node_history', 'click', function(e){
103 var _url = node_history_url.replace('__REV__',State.data.rev).replace('__FPATH__', State.data.f_path);
103 var _url = node_history_url.replace('__REV__',State.data.rev).replace('__FPATH__', State.data.f_path);
104 ypjax(_url, 'node_history', function(o){})
104 ypjax(_url, 'node_history', function(o){
105 tooltip_activate();
106 })
105 });
107 });
106 }
108 }
107 // Inform Google Analytics of the change
109 // Inform Google Analytics of the change
108 if ( typeof window.pageTracker !== 'undefined' ) {
110 if ( typeof window.pageTracker !== 'undefined' ) {
109 window.pageTracker._trackPageview(State.url);
111 window.pageTracker._trackPageview(State.url);
110 }
112 }
111 }
113 }
112
114
113 YUE.onDOMReady(function(){
115 YUE.onDOMReady(function(){
114 ypjax_links();
116 ypjax_links();
115 var container = 'files_data';
117 var container = 'files_data';
116 //Bind to StateChange Event
118 //Bind to StateChange Event
117 History.Adapter.bind(window,'statechange',function(){
119 History.Adapter.bind(window,'statechange',function(){
118 var State = History.getState();
120 var State = History.getState();
119 cache_key = State.url;
121 cache_key = State.url;
120 //check if we have this request in cache maybe ?
122 //check if we have this request in cache maybe ?
121 var _cache_obj = CACHE[cache_key];
123 var _cache_obj = CACHE[cache_key];
122 var _cur_time = new Date().getTime();
124 var _cur_time = new Date().getTime();
123 // get from cache if it's there and not yet expired !
125 // get from cache if it's there and not yet expired !
124 if(_cache_obj !== undefined && _cache_obj[0] > _cur_time){
126 if(_cache_obj !== undefined && _cache_obj[0] > _cur_time){
125 YUD.get(container).innerHTML=_cache_obj[1];
127 YUD.get(container).innerHTML=_cache_obj[1];
126 YUD.setStyle(container,'opacity','1.0');
128 YUD.setStyle(container,'opacity','1.0');
127
129
128 //callbacks after ypjax call
130 //callbacks after ypjax call
129 callbacks(State);
131 callbacks(State);
130 }
132 }
131 else{
133 else{
132 ypjax(State.url,container,function(o){
134 ypjax(State.url,container,function(o){
133 //callbacks after ypjax call
135 //callbacks after ypjax call
134 callbacks(State);
136 callbacks(State);
135 if (o !== undefined){
137 if (o !== undefined){
136 //store our request in cache
138 //store our request in cache
137 var _expire_on = new Date().getTime()+CACHE_EXPIRE;
139 var _expire_on = new Date().getTime()+CACHE_EXPIRE;
138 CACHE[cache_key] = [_expire_on, o.responseText];
140 CACHE[cache_key] = [_expire_on, o.responseText];
139 }
141 }
140 });
142 });
141 }
143 }
142 });
144 });
143
145
144 // init the search filter
146 // init the search filter
145 var _State = {
147 var _State = {
146 url: "${h.url.current()}",
148 url: "${h.url.current()}",
147 data: {
149 data: {
148 node_list_url: node_list_url.replace('__REV__',"${c.changeset.raw_id}").replace('__FPATH__', "${h.safe_unicode(c.file.path)}"),
150 node_list_url: node_list_url.replace('__REV__',"${c.changeset.raw_id}").replace('__FPATH__', "${h.safe_unicode(c.file.path)}"),
149 url_base: url_base.replace('__REV__',"${c.changeset.raw_id}"),
151 url_base: url_base.replace('__REV__',"${c.changeset.raw_id}"),
150 rev:"${c.changeset.raw_id}",
152 rev:"${c.changeset.raw_id}",
151 f_path: "${h.safe_unicode(c.file.path)}"
153 f_path: "${h.safe_unicode(c.file.path)}"
152 }
154 }
153 }
155 }
154 fileBrowserListeners(_State.url, _State.data.node_list_url, _State.data.url_base);
156 fileBrowserListeners(_State.url, _State.data.node_list_url, _State.data.url_base);
155 });
157 });
156
158
157 </script>
159 </script>
158
160
159 </%def>
161 </%def>
@@ -1,111 +1,113 b''
1 <div id="node_history">
1 <div id="node_history">
2 %if c.load_full_history:
2 %if c.load_full_history:
3 <%include file='files_history_box.html'/>
3 <%include file='files_history_box.html'/>
4 %else:
4 %else:
5 <div style="padding-bottom:10px">
5 <div style="padding-bottom:10px">
6 <span id="load_node_history" class="ui-btn">${_('Load file history')}</span>
6 <span id="load_node_history" class="ui-btn">${_('Load file history')}</span>
7 </div>
7 </div>
8 %endif
8 %endif
9 </div>
9 </div>
10
10
11
11
12 <div id="body" class="codeblock">
12 <div id="body" class="codeblock">
13 <div class="code-header">
13 <div class="code-header">
14 <div class="stats">
14 <div class="stats">
15 <div class="left img"><img src="${h.url('/images/icons/file.png')}"/></div>
15 <div class="left img"><img src="${h.url('/images/icons/file.png')}"/></div>
16 <div class="left item"><pre class="tooltip" title="${h.tooltip(h.fmt_date(c.file_changeset.date))}">${h.link_to("r%s:%s" % (c.file_changeset.revision,h.short_id(c.file_changeset.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id))}</pre></div>
16 <div class="left item"><pre class="tooltip" title="${h.tooltip(h.fmt_date(c.file_changeset.date))}">${h.link_to("r%s:%s" % (c.file_changeset.revision,h.short_id(c.file_changeset.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id))}</pre></div>
17 <div class="left item"><pre>${h.format_byte_size(c.file.size,binary=True)}</pre></div>
17 <div class="left item"><pre>${h.format_byte_size(c.file.size,binary=True)}</pre></div>
18 <div class="left item last"><pre>${c.file.mimetype}</pre></div>
18 <div class="left item last"><pre>${c.file.mimetype}</pre></div>
19 <div class="buttons">
19 <div class="buttons">
20 %if c.annotate:
20 %if c.annotate:
21 ${h.link_to(_('show source'), h.url('files_home', repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
21 ${h.link_to(_('show source'), h.url('files_home', repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
22 %else:
22 %else:
23 ${h.link_to(_('show annotation'),h.url('files_annotate_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
23 ${h.link_to(_('show annotation'),h.url('files_annotate_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
24 %endif
24 %endif
25 ${h.link_to(_('show as raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
25 ${h.link_to(_('show as raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
26 ${h.link_to(_('download as raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
26 ${h.link_to(_('download as raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
27 % if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
27 % if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
28 % if not c.file.is_binary:
28 % if not c.file.is_binary:
29 ${h.link_to(_('edit'),h.url('files_edit_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
29 ${h.link_to(_('edit'),h.url('files_edit_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
30 % endif
30 % endif
31 % endif
31 % endif
32 </div>
32 </div>
33 </div>
33 </div>
34 <div class="author">
34 <div class="author">
35 <div class="gravatar">
35 <div class="gravatar">
36 <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(c.file_changeset.author),16)}"/>
36 <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(c.file_changeset.author),16)}"/>
37 </div>
37 </div>
38 <div title="${c.file_changeset.author}" class="user">${h.person(c.file_changeset.author)}</div>
38 <div title="${c.file_changeset.author}" class="user">${h.person(c.file_changeset.author)}</div>
39 </div>
39 </div>
40 <div class="commit">${h.urlify_commit(c.file_changeset.message,c.repo_name)}</div>
40 <div class="commit">${h.urlify_commit(c.file_changeset.message,c.repo_name)}</div>
41 </div>
41 </div>
42 <div class="code-body">
42 <div class="code-body">
43 %if c.file.is_binary:
43 %if c.file.is_binary:
44 ${_('Binary file (%s)') % c.file.mimetype}
44 ${_('Binary file (%s)') % c.file.mimetype}
45 %else:
45 %else:
46 % if c.file.size < c.cut_off_limit:
46 % if c.file.size < c.cut_off_limit:
47 %if c.annotate:
47 %if c.annotate:
48 ${h.pygmentize_annotation(c.repo_name,c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
48 ${h.pygmentize_annotation(c.repo_name,c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
49 %else:
49 %else:
50 ${h.pygmentize(c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
50 ${h.pygmentize(c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
51 %endif
51 %endif
52 %else:
52 %else:
53 ${_('File is too big to display')} ${h.link_to(_('show as raw'),
53 ${_('File is too big to display')} ${h.link_to(_('show as raw'),
54 h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path))}
54 h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path))}
55 %endif
55 %endif
56 %endif
56 %endif
57 </div>
57 </div>
58 </div>
58 </div>
59
59
60 <script type="text/javascript">
60 <script type="text/javascript">
61 YUE.onDOMReady(function(){
61 YUE.onDOMReady(function(){
62 function highlight_lines(lines){
62 function highlight_lines(lines){
63 for(pos in lines){
63 for(pos in lines){
64 YUD.setStyle('L'+lines[pos],'background-color','#FFFFBE');
64 YUD.setStyle('L'+lines[pos],'background-color','#FFFFBE');
65 }
65 }
66 }
66 }
67 page_highlights = location.href.substring(location.href.indexOf('#')+1).split('L');
67 page_highlights = location.href.substring(location.href.indexOf('#')+1).split('L');
68 if (page_highlights.length == 2){
68 if (page_highlights.length == 2){
69 highlight_ranges = page_highlights[1].split(",");
69 highlight_ranges = page_highlights[1].split(",");
70
70
71 var h_lines = [];
71 var h_lines = [];
72 for (pos in highlight_ranges){
72 for (pos in highlight_ranges){
73 var _range = highlight_ranges[pos].split('-');
73 var _range = highlight_ranges[pos].split('-');
74 if(_range.length == 2){
74 if(_range.length == 2){
75 var start = parseInt(_range[0]);
75 var start = parseInt(_range[0]);
76 var end = parseInt(_range[1]);
76 var end = parseInt(_range[1]);
77 if (start < end){
77 if (start < end){
78 for(var i=start;i<=end;i++){
78 for(var i=start;i<=end;i++){
79 h_lines.push(i);
79 h_lines.push(i);
80 }
80 }
81 }
81 }
82 }
82 }
83 else{
83 else{
84 h_lines.push(parseInt(highlight_ranges[pos]));
84 h_lines.push(parseInt(highlight_ranges[pos]));
85 }
85 }
86 }
86 }
87 highlight_lines(h_lines);
87 highlight_lines(h_lines);
88
88
89 //remember original location
89 //remember original location
90 var old_hash = location.href.substring(location.href.indexOf('#'));
90 var old_hash = location.href.substring(location.href.indexOf('#'));
91
91
92 // this makes a jump to anchor moved by 3 posstions for padding
92 // this makes a jump to anchor moved by 3 posstions for padding
93 window.location.hash = '#L'+Math.max(parseInt(h_lines[0])-3,1);
93 window.location.hash = '#L'+Math.max(parseInt(h_lines[0])-3,1);
94
94
95 //sets old anchor
95 //sets old anchor
96 window.location.hash = old_hash;
96 window.location.hash = old_hash;
97
97
98 }
98 }
99
99
100 // select code link event
100 // select code link event
101 YUE.on('hlcode', 'mouseup', getSelectionLink);
101 YUE.on('hlcode', 'mouseup', getSelectionLink);
102
102
103 //load history of file
103 //load history of file
104 YUE.on('load_node_history', 'click', function(e){
104 YUE.on('load_node_history', 'click', function(e){
105 var _url = node_history_url.replace('__REV__','${c.file_changeset.raw_id}').replace('__FPATH__', '${c.f_path}');
105 var _url = node_history_url.replace('__REV__','${c.file_changeset.raw_id}').replace('__FPATH__', '${c.f_path}');
106 ypjax(_url, 'node_history', function(o){})
106 ypjax(_url, 'node_history', function(o){
107 tooltip_activate();
108 })
107 });
109 });
108
110
109 });
111 });
110
112
111 </script>
113 </script>
General Comments 0
You need to be logged in to leave comments. Login now