# HG changeset patch # User Marcin Kuzminski # Date 1321729202 -7200 # Node ID 623b228cf3250f050a6c452eb271da2c76d74d98 # Parent 8fdabc8cce1a39da76b09dfd90e2d53a3c3efcbb cleaned up JS files in files templates. - fixed some small issues with editing/adding git files using codemirror - small css fixes - separated files/dir browsing into separate template diff -r 8fdabc8cce1a -r 623b228cf325 rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css Fri Nov 18 16:31:36 2011 +0200 +++ b/rhodecode/public/css/style.css Sat Nov 19 21:00:02 2011 +0200 @@ -1919,6 +1919,9 @@ 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 @@ } .right .changes .changed_total { - border: 1px solid #DDD; + border: 0px solid #DDD; display: block; float: right; text-align: center; @@ -1986,6 +1989,10 @@ 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 -r 8fdabc8cce1a -r 623b228cf325 rhodecode/public/js/rhodecode.js --- a/rhodecode/public/js/rhodecode.js Fri Nov 18 16:31:36 2011 +0200 +++ b/rhodecode/public/js/rhodecode.js Sat Nov 19 21:00:02 2011 +0200 @@ -7,10 +7,10 @@ } -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 @@ * * @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 @@ /* 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 @@ } },args); -} +}; /** * tooltip activate @@ -206,7 +206,7 @@ hidedelay:5, showdelay:20, }); -} +}; /** * show more @@ -217,7 +217,7 @@ YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); YUD.setStyle(el.parentNode,'display','none'); }); -} +}; /** @@ -284,7 +284,7 @@ } } -} +}; var ajaxPOST = function(url,postData,success) { var sUrl = url; @@ -302,7 +302,7 @@ /** comments **/ var removeInlineForm = function(form) { form.parentNode.removeChild(form); -} +}; var tableTr = function(cls,body){ var form = document.createElement('tr'); @@ -311,7 +311,7 @@ ''+ '{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 @@ 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 @@ } 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 -r 8fdabc8cce1a -r 623b228cf325 rhodecode/templates/files/files.html --- a/rhodecode/templates/files/files.html Fri Nov 18 16:31:36 2011 +0200 +++ b/rhodecode/templates/files/files.html Sat Nov 19 21:00:02 2011 +0200 @@ -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 -r 8fdabc8cce1a -r 623b228cf325 rhodecode/templates/files/files_add.html --- a/rhodecode/templates/files/files_add.html Fri Nov 18 16:31:36 2011 +0200 +++ b/rhodecode/templates/files/files_add.html Sat Nov 19 21:00:02 2011 +0200 @@ -83,26 +83,8 @@ ${h.end_form()} diff -r 8fdabc8cce1a -r 623b228cf325 rhodecode/templates/files/files_browser.html --- a/rhodecode/templates/files/files_browser.html Fri Nov 18 16:31:36 2011 +0200 +++ b/rhodecode/templates/files/files_browser.html Sat Nov 19 21:00:02 2011 +0200 @@ -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 -r 8fdabc8cce1a -r 623b228cf325 rhodecode/templates/files/files_edit.html --- a/rhodecode/templates/files/files_edit.html Fri Nov 18 16:31:36 2011 +0200 +++ b/rhodecode/templates/files/files_edit.html Sat Nov 19 21:00:02 2011 +0200 @@ -50,13 +50,8 @@ ${h.end_form()} diff -r 8fdabc8cce1a -r 623b228cf325 rhodecode/templates/files/files_source.html --- a/rhodecode/templates/files/files_source.html Fri Nov 18 16:31:36 2011 +0200 +++ b/rhodecode/templates/files/files_source.html Sat Nov 19 21:00:02 2011 +0200 @@ -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 -r 8fdabc8cce1a -r 623b228cf325 rhodecode/templates/files/files_ypjax.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rhodecode/templates/files/files_ypjax.html Sat Nov 19 21:00:02 2011 +0200 @@ -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