Commit faf7c79eb2d0c380b692be413953d206f2984b0b

Authored by Dmitriy Zaporozhets
1 parent 4df4b381

lil js refactoring

app/assets/javascripts/merge_requests.js 0 → 100644
app/assets/javascripts/merge_requests.js.coffee
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -# Place all the behaviors and hooks related to the matching controller here.  
2 -# All this logic will automatically be available in application.js.  
3 -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/  
app/assets/javascripts/projects.js
1 $(document).ready(function(){ 1 $(document).ready(function(){
2 - $('#tree-slider td.tree-item-file-name a, #tree-breadcrumbs a').live("click", function() {  
3 - history.pushState({ path: this.path }, '', this.href)  
4 - })  
5 -  
6 - $("#tree-slider tr.tree-item").live('click', function(e){  
7 - if(e.target.nodeName != "A") {  
8 - e.stopPropagation();  
9 - link = $(this).find("td.tree-item-file-name a")  
10 - link.click();  
11 - return false;  
12 - }  
13 - });  
14 -  
15 $("#projects-list .project").live('click', function(e){ 2 $("#projects-list .project").live('click', function(e){
16 if(e.target.nodeName != "A" && e.target.nodeName != "INPUT") { 3 if(e.target.nodeName != "A" && e.target.nodeName != "INPUT") {
17 location.href = $(this).attr("url"); 4 location.href = $(this).attr("url");
app/assets/javascripts/tree.js 0 → 100644
@@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
  1 +/**
  2 + * Tree slider for code browse
  3 + *
  4 + */
  5 +var Tree = {
  6 + init:
  7 + function() {
  8 + $('#tree-slider td.tree-item-file-name a, #tree-breadcrumbs a').live("click", function() {
  9 + history.pushState({ path: this.path }, '', this.href)
  10 + })
  11 +
  12 + $("#tree-slider tr.tree-item").live('click', function(e){
  13 + if(e.target.nodeName != "A") {
  14 + e.stopPropagation();
  15 + link = $(this).find("td.tree-item-file-name a");
  16 + link.click();
  17 + return false;
  18 + }
  19 + });
  20 + }
  21 +}
app/views/refs/tree.html.haml
1 #tree-holder= render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @tree} 1 #tree-holder= render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @tree}
  2 +
  3 +:javascript
  4 + $(function() {
  5 + Tree.init();
  6 + });