From 8ee6d21fa1d78b327eab91ff4b3cae8c6146efd9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 12 Dec 2011 20:08:04 +0200 Subject: [PATCH] lil js refactoring --- app/assets/javascripts/merge_requests.js | 0 .../javascripts/merge_requests.js.coffee | 3 --- app/assets/javascripts/projects.js | 13 ------------ app/assets/javascripts/tree.js | 21 +++++++++++++++++++ app/views/refs/tree.html.haml | 5 +++++ 5 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 app/assets/javascripts/merge_requests.js delete mode 100644 app/assets/javascripts/merge_requests.js.coffee create mode 100644 app/assets/javascripts/tree.js diff --git a/app/assets/javascripts/merge_requests.js b/app/assets/javascripts/merge_requests.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/app/assets/javascripts/merge_requests.js.coffee b/app/assets/javascripts/merge_requests.js.coffee deleted file mode 100644 index 761567942fc..00000000000 --- a/app/assets/javascripts/merge_requests.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/projects.js b/app/assets/javascripts/projects.js index 4ffbd140d6e..7d21f061703 100644 --- a/app/assets/javascripts/projects.js +++ b/app/assets/javascripts/projects.js @@ -1,17 +1,4 @@ $(document).ready(function(){ - $('#tree-slider td.tree-item-file-name a, #tree-breadcrumbs a').live("click", function() { - history.pushState({ path: this.path }, '', this.href) - }) - - $("#tree-slider tr.tree-item").live('click', function(e){ - if(e.target.nodeName != "A") { - e.stopPropagation(); - link = $(this).find("td.tree-item-file-name a") - link.click(); - return false; - } - }); - $("#projects-list .project").live('click', function(e){ if(e.target.nodeName != "A" && e.target.nodeName != "INPUT") { location.href = $(this).attr("url"); diff --git a/app/assets/javascripts/tree.js b/app/assets/javascripts/tree.js new file mode 100644 index 00000000000..6edd7e49c5a --- /dev/null +++ b/app/assets/javascripts/tree.js @@ -0,0 +1,21 @@ +/** + * Tree slider for code browse + * + */ +var Tree = { + init: + function() { + $('#tree-slider td.tree-item-file-name a, #tree-breadcrumbs a').live("click", function() { + history.pushState({ path: this.path }, '', this.href) + }) + + $("#tree-slider tr.tree-item").live('click', function(e){ + if(e.target.nodeName != "A") { + e.stopPropagation(); + link = $(this).find("td.tree-item-file-name a"); + link.click(); + return false; + } + }); + } +} diff --git a/app/views/refs/tree.html.haml b/app/views/refs/tree.html.haml index e59bbf05ee3..46eeb6f5c29 100644 --- a/app/views/refs/tree.html.haml +++ b/app/views/refs/tree.html.haml @@ -1 +1,6 @@ #tree-holder= render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @tree} + +:javascript + $(function() { + Tree.init(); + });