Skip to content

Commit

Permalink
JS cleanups
Browse files Browse the repository at this point in the history
* using google's cached js file
* removed app-specific js in application.js
  • Loading branch information
Tammer Saleh committed Oct 29, 2009
1 parent 5e13774 commit 2345d84
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 4,533 deletions.
4 changes: 3 additions & 1 deletion assets/app/views/layouts/_javascript.html.haml
@@ -1,2 +1,4 @@
= javascript_include_tag "jquery-1.3.2", "application", :cache => true
= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"
= javascript_include_tag "application"

= yield :javascript
73 changes: 0 additions & 73 deletions assets/public/javascripts/application.js
@@ -1,73 +0,0 @@
function toggle_contents(node, content_class) {
var contents = node.find(content_class);
if (contents.is(":visible")) {
node.addClass("closed");
node.removeClass("opened");
contents.slideUp();
} else {
node.removeClass("closed");
node.addClass("opened");
contents.slideDown();
}
};

function hide_or_show_notes_by_company(checkbox_node) {
var checkbox = $(checkbox_node);
var company_name = $.trim(checkbox.val());
$(".note").each(function() {
if ($.trim($(this).children(".company_name").text()) == company_name) {
if (checkbox.is(":checked")) {
$(this).fadeIn("normal", function() {$(this).show()});
} else {
$(this).fadeOut("normal", function() {$(this).hide()});
};
};
});
};

function open_external_links_in_new_window() {
$(".external").attr("target", "_blank");
}

$(document).ready(function() {
$('#participating_company_filters input').change(function() {
hide_or_show_notes_by_company(this);
});

$('.pages-show .notes .note').each(function() {
var note = $(this);
$(note).find('.contents').hide();
$(note).find('.note_type').hide();
note.find('.title').click(function(event) {
toggle_contents(note, ".contents");
toggle_contents(note, ".note_type")
event.preventDefault();
});
note.find('.note_type').click(function(event) {
toggle_contents(note, ".contents");
toggle_contents(note, ".note_type")
event.preventDefault();
});
});

$('.pages-show #filter_notes').each(function() {
var filter = $(this);
$(filter).find('.companies').hide();
filter.find('.title').click(function(event) {
toggle_contents(filter, ".companies");
event.preventDefault();
});
});

$('.user').each(function() {
var owner = $(this);
owner.find('.name').click(function(event) {
toggle_contents(owner, ".owner_contents");
event.preventDefault();
});
$(owner).find('.owner_contents').hide();
});

open_external_links_in_new_window();
});

4 changes: 3 additions & 1 deletion gold/app/views/layouts/_javascript.html.haml
@@ -1,2 +1,4 @@
= javascript_include_tag "jquery-1.3.2", "application", :cache => true
= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"
= javascript_include_tag "application"

= yield :javascript
73 changes: 0 additions & 73 deletions gold/public/javascripts/application.js
@@ -1,73 +0,0 @@
function toggle_contents(node, content_class) {
var contents = node.find(content_class);
if (contents.is(":visible")) {
node.addClass("closed");
node.removeClass("opened");
contents.slideUp();
} else {
node.removeClass("closed");
node.addClass("opened");
contents.slideDown();
}
};

function hide_or_show_notes_by_company(checkbox_node) {
var checkbox = $(checkbox_node);
var company_name = $.trim(checkbox.val());
$(".note").each(function() {
if ($.trim($(this).children(".company_name").text()) == company_name) {
if (checkbox.is(":checked")) {
$(this).fadeIn("normal", function() {$(this).show()});
} else {
$(this).fadeOut("normal", function() {$(this).hide()});
};
};
});
};

function open_external_links_in_new_window() {
$(".external").attr("target", "_blank");
}

$(document).ready(function() {
$('#participating_company_filters input').change(function() {
hide_or_show_notes_by_company(this);
});

$('.pages-show .notes .note').each(function() {
var note = $(this);
$(note).find('.contents').hide();
$(note).find('.note_type').hide();
note.find('.title').click(function(event) {
toggle_contents(note, ".contents");
toggle_contents(note, ".note_type")
event.preventDefault();
});
note.find('.note_type').click(function(event) {
toggle_contents(note, ".contents");
toggle_contents(note, ".note_type")
event.preventDefault();
});
});

$('.pages-show #filter_notes').each(function() {
var filter = $(this);
$(filter).find('.companies').hide();
filter.find('.title').click(function(event) {
toggle_contents(filter, ".companies");
event.preventDefault();
});
});

$('.user').each(function() {
var owner = $(this);
owner.find('.name').click(function(event) {
toggle_contents(owner, ".owner_contents");
event.preventDefault();
});
$(owner).find('.owner_contents').hide();
});

open_external_links_in_new_window();
});

0 comments on commit 2345d84

Please sign in to comment.