diff --git a/rhodecode/public/css/style.css b/rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css +++ b/rhodecode/public/css/style.css @@ -1919,6 +1919,9 @@ h3.files_location { border: 1px solid #CCC; padding: 10px; height: 45px; + -webkit-border-radius: 6px 6px 0px 0px; + -moz-border-radius: 6px 6px 0px 0px; + border-radius: 6px 6px 0px 0px; } #graph_content #rev_range_container { @@ -1978,7 +1981,7 @@ h3.files_location { } .right .changes .changed_total { - border: 1px solid #DDD; + border: 0px solid #DDD; display: block; float: right; text-align: center; @@ -1986,6 +1989,10 @@ h3.files_location { cursor: pointer; background: #FD8; font-weight: bold; + -webkit-border-radius: 0px 0px 0px 6px; + -moz-border-radius: 0px 0px 0px 6px; + border-radius: 0px 0px 0px 6px; + padding: 2px; } .right .changes .added,.changed,.removed { diff --git a/rhodecode/public/js/rhodecode.js b/rhodecode/public/js/rhodecode.js --- a/rhodecode/public/js/rhodecode.js +++ b/rhodecode/public/js/rhodecode.js @@ -7,10 +7,10 @@ if (typeof console == "undefined" || typ } -function str_repeat(i, m) { +var str_repeat = function(i, m) { for (var o = []; m > 0; o[--m] = i); return o.join(''); -} +}; /** * INJECT .format function into String @@ -55,7 +55,7 @@ String.prototype.format = function() { * * @returns {ColorGenerator} */ -function ColorGenerator(){ +var ColorGenerator = function(){ this.GOLDEN_RATIO = 0.618033988749895; this.CURRENT_RATIO = 0.22717784590367374 // this can be random this.HSV_1 = 0.75;//saturation @@ -129,7 +129,7 @@ var push_state_enabled = Boolean( /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) ) -) +); /** * Partial Ajax Implementation @@ -179,7 +179,7 @@ function ypjax(url,container,s_call,f_ca } },args); -} +}; /** * tooltip activate @@ -206,7 +206,7 @@ var tooltip_activate = function(){ hidedelay:5, showdelay:20, }); -} +}; /** * show more @@ -217,7 +217,7 @@ var show_more_event = function(){ YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); YUD.setStyle(el.parentNode,'display','none'); }); -} +}; /** @@ -284,7 +284,7 @@ var q_filter = function(target,nodes,dis } } -} +}; var ajaxPOST = function(url,postData,success) { var sUrl = url; @@ -302,7 +302,7 @@ var ajaxPOST = function(url,postData,suc /** comments **/ var removeInlineForm = function(form) { form.parentNode.removeChild(form); -} +}; var tableTr = function(cls,body){ var form = document.createElement('tr'); @@ -311,7 +311,7 @@ var tableTr = function(cls,body){ ''+ '{0}'.format(body); return form; -} +}; var createInlineForm = function(parent_tr, f_path, line) { var tmpl = YUD.get('comment-inline-form-template').innerHTML; @@ -327,7 +327,8 @@ var createInlineForm = function(parent_t YUD.removeClass(parent_tr, 'form-open'); }); return form -} +}; + var getLineNo = function(tr) { var line; var o = tr.children[0].id.split('_'); @@ -340,4 +341,206 @@ var getLineNo = function(tr) { } return line -} \ No newline at end of file +}; + + +var fileBrowserListeners = function(current_url, node_list_url, url_base){ + var current_url_branch = +"?branch=__BRANCH__"; + var url = url_base; + var node_url = node_list_url; + + YUE.on('stay_at_branch','click',function(e){ + if(e.target.checked){ + var uri = current_url_branch; + uri = uri.replace('__BRANCH__',e.target.value); + window.location = uri; + } + else{ + window.location = current_url; + } + }) + + var n_filter = YUD.get('node_filter'); + var F = YAHOO.namespace('node_filter'); + + url = url.replace('__REPO__','${c.repo_name}'); + url = url.replace('__REVISION__','${c.changeset.raw_id}'); + url = url.replace('__FPATH__','${c.files_list.path}'); + + node_url = node_url.replace('__REPO__','${c.repo_name}'); + node_url = node_url.replace('__REVISION__','${c.changeset.raw_id}'); + + F.filterTimeout = null; + var nodes = null; + + F.initFilter = function(){ + YUD.setStyle('node_filter_box_loading','display',''); + YUD.setStyle('search_activate_id','display','none'); + YUD.setStyle('add_node_id','display','none'); + YUC.initHeader('X-PARTIAL-XHR',true); + YUC.asyncRequest('GET',url,{ + success:function(o){ + nodes = JSON.parse(o.responseText); + YUD.setStyle('node_filter_box_loading','display','none'); + YUD.setStyle('node_filter_box','display',''); + }, + failure:function(o){ + console.log('failed to load'); + } + },null); + } + + F.updateFilter = function(e) { + + return function(){ + // Reset timeout + F.filterTimeout = null; + var query = e.target.value; + var match = []; + var matches = 0; + var matches_max = 20; + if (query != ""){ + for(var i=0;i matches_max){ + break; + } + + var n = nodes[i]; + var n_hl = n.substring(0,pos) + +"{0}".format(n.substring(pos,pos+query.length)) + +n.substring(pos+query.length) + match.push('{1}'.format(node_url.replace('__FPATH__',n),n_hl)); + } + if(match.length >= matches_max){ + match.push('{0}'.format("${_('search truncated')}")); + } + + } + } + + if(query != ""){ + YUD.setStyle('tbody','display','none'); + YUD.setStyle('tbody_filtered','display',''); + + if (match.length==0){ + match.push('{0}'.format("${_('no matching files')}")); + } + + YUD.get('tbody_filtered').innerHTML = match.join(""); + } + else{ + YUD.setStyle('tbody','display',''); + YUD.setStyle('tbody_filtered','display','none'); + } + + } + }; + + YUE.on(YUD.get('filter_activate'),'click',function(){ + F.initFilter(); + }) + YUE.on(n_filter,'click',function(){ + n_filter.value = ''; + }); + YUE.on(n_filter,'keyup',function(e){ + clearTimeout(F.filterTimeout); + F.filterTimeout = setTimeout(F.updateFilter(e),600); + }); +}; + + +var initCodeMirror = function(textAreadId,resetUrl){ + var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ + mode: "null", + lineNumbers:true + }); + YUE.on('reset','click',function(e){ + window.location=resetUrl + }); + + YUE.on('file_enable','click',function(){ + YUD.setStyle('editor_container','display',''); + YUD.setStyle('upload_file_container','display','none'); + YUD.setStyle('filename_container','display',''); + }); + + YUE.on('upload_file_enable','click',function(){ + YUD.setStyle('editor_container','display','none'); + YUD.setStyle('upload_file_container','display',''); + YUD.setStyle('filename_container','display','none'); + }); +}; + + + +var getIdentNode = function(n){ + //iterate thru nodes untill matched interesting node ! + + if (typeof n == 'undefined'){ + return -1 + } + + if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ + return n + } + else{ + return getIdentNode(n.parentNode); + } +}; + +var getSelectionLink = function(selection_link_label) { + return function(){ + //get selection from start/to nodes + if (typeof window.getSelection != "undefined") { + s = window.getSelection(); + + from = getIdentNode(s.anchorNode); + till = getIdentNode(s.focusNode); + + f_int = parseInt(from.id.replace('L','')); + t_int = parseInt(till.id.replace('L','')); + + if (f_int > t_int){ + //highlight from bottom + offset = -35; + ranges = [t_int,f_int]; + + } + else{ + //highligth from top + offset = 35; + ranges = [f_int,t_int]; + } + + if (ranges[0] != ranges[1]){ + if(YUD.get('linktt') == null){ + hl_div = document.createElement('div'); + hl_div.id = 'linktt'; + } + anchor = '#L'+ranges[0]+'-'+ranges[1]; + hl_div.innerHTML = ''; + l = document.createElement('a'); + l.href = location.href.substring(0,location.href.indexOf('#'))+anchor; + l.innerHTML = selection_link_label; + hl_div.appendChild(l); + + YUD.get('body').appendChild(hl_div); + + xy = YUD.getXY(till.id); + + YUD.addClass('linktt','yui-tt'); + YUD.setStyle('linktt','top',xy[1]+offset+'px'); + YUD.setStyle('linktt','left',xy[0]+'px'); + YUD.setStyle('linktt','visibility','visible'); + } + else{ + YUD.setStyle('linktt','visibility','hidden'); + } + } + } +}; diff --git a/rhodecode/templates/files/files.html b/rhodecode/templates/files/files.html --- a/rhodecode/templates/files/files.html +++ b/rhodecode/templates/files/files.html @@ -32,24 +32,15 @@
- %if c.files_list: -

- ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.changeset.raw_id,c.files_list.path)} -

- %if c.files_list.is_dir(): - <%include file='files_browser.html'/> - %else: - <%include file='files_source.html'/> - %endif - %else: -

- ${_('Go back')} - ${_('No files at given path')}: "${c.f_path or "/"}" -

- %endif - + <%include file='files_ypjax.html'/>
- - \ No newline at end of file + + \ No newline at end of file diff --git a/rhodecode/templates/files/files_add.html b/rhodecode/templates/files/files_add.html --- a/rhodecode/templates/files/files_add.html +++ b/rhodecode/templates/files/files_add.html @@ -83,26 +83,8 @@ ${h.end_form()} diff --git a/rhodecode/templates/files/files_browser.html b/rhodecode/templates/files/files_browser.html --- a/rhodecode/templates/files/files_browser.html +++ b/rhodecode/templates/files/files_browser.html @@ -35,120 +35,6 @@ @@ -171,7 +57,7 @@ %if c.files_list.parent: - ${h.link_to('..',h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.files_list.parent.path),class_="browser-dir")} + ${h.link_to('..',h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.files_list.parent.path),class_="browser-dir ypjax-link")} @@ -184,7 +70,7 @@ %for cnt,node in enumerate(c.files_list): - ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=h.safe_unicode(node.path)),class_=file_class(node))} + ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=h.safe_unicode(node.path)),class_=file_class(node)+" ypjax-link")} %if node.is_file(): diff --git a/rhodecode/templates/files/files_edit.html b/rhodecode/templates/files/files_edit.html --- a/rhodecode/templates/files/files_edit.html +++ b/rhodecode/templates/files/files_edit.html @@ -50,13 +50,8 @@ ${h.end_form()} diff --git a/rhodecode/templates/files/files_source.html b/rhodecode/templates/files/files_source.html --- a/rhodecode/templates/files/files_source.html +++ b/rhodecode/templates/files/files_source.html @@ -98,77 +98,10 @@ YUE.onDOMReady(function(){ YUE.on('show_rev','click',function(e){ YUE.preventDefault(e); - var cs = YAHOO.util.Dom.get('diff1').value; + var cs = YUD.get('diff1').value; var url = "${h.url('files_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs); window.location = url; }); - - function getIdentNode(n){ - //iterate thru nodes untill matched interesting node ! - - if (typeof n == 'undefined'){ - return -1 - } - - if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ - return n - } - else{ - return getIdentNode(n.parentNode); - } - } - - function getSelectionLink() { - //get selection from start/to nodes - if (typeof window.getSelection != "undefined") { - s = window.getSelection(); - - from = getIdentNode(s.anchorNode); - till = getIdentNode(s.focusNode); - - f_int = parseInt(from.id.replace('L','')); - t_int = parseInt(till.id.replace('L','')); - - if (f_int > t_int){ - //highlight from bottom - offset = -35; - ranges = [t_int,f_int]; - - } - else{ - //highligth from top - offset = 35; - ranges = [f_int,t_int]; - } - - if (ranges[0] != ranges[1]){ - if(YUD.get('linktt') == null){ - hl_div = document.createElement('div'); - hl_div.id = 'linktt'; - } - anchor = '#L'+ranges[0]+'-'+ranges[1]; - hl_div.innerHTML = ''; - l = document.createElement('a'); - l.href = location.href.substring(0,location.href.indexOf('#'))+anchor; - l.innerHTML = "${_('Selection link')}" - hl_div.appendChild(l); - - YUD.get('body').appendChild(hl_div); - - xy = YUD.getXY(till.id); - - YUD.addClass('linktt','yui-tt'); - YUD.setStyle('linktt','top',xy[1]+offset+'px'); - YUD.setStyle('linktt','left',xy[0]+'px'); - YUD.setStyle('linktt','visibility','visible'); - } - else{ - YUD.setStyle('linktt','visibility','hidden'); - } - } - } - - YUE.on('hlcode','mouseup',getSelectionLink) - + YUE.on('hlcode','mouseup',getSelectionLink("${_('Selection link')}")) }); diff --git a/rhodecode/templates/files/files_ypjax.html b/rhodecode/templates/files/files_ypjax.html new file mode 100644 --- /dev/null +++ b/rhodecode/templates/files/files_ypjax.html @@ -0,0 +1,15 @@ +%if c.files_list: +

+ ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.changeset.raw_id,c.files_list.path)} +

+ %if c.files_list.is_dir(): + <%include file='files_browser.html'/> + %else: + <%include file='files_source.html'/> + %endif +%else: +

+ ${_('Go back')} + ${_('No files at given path')}: "${c.f_path or "/"}" +

+%endif