Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New issue, issue edit, bulk issue edit tagcloud. New UI
- Loading branch information
1 parent
c5a1a54
commit 529787d
Showing
6 changed files
with
169 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
<a id="cloud_trigger"><%= t(:tags_in_project) %></a> | ||
<a id="cloud_trigger"><b><%= t(:tags_in_project) %></b></a> | ||
<span id="cloud_content"> — | ||
<% | ||
tag_cloud_in_project(@project) do |tag, factor| | ||
options = {:style => "font-size: #{10 * factor + 9}pt" } | ||
style = "font-size: #{10 * factor + 9}pt" | ||
%> | ||
<%= link_to_project_tag_filter(@project, tag, {}, options) %> | ||
<a class="tag_item" | ||
data-tag="<%= tag_without_sharp(tag) %>" | ||
style="<%= style %>"> | ||
<%= tag %> | ||
</a> | ||
<% end %> | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// IE compatibility | ||
if (!Array.prototype.indexOf) { | ||
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { | ||
"use strict" | ||
if (this == null) { | ||
throw new TypeError() | ||
} | ||
var t = Object(this) | ||
var len = t.length >>> 0 | ||
if (len === 0) { | ||
return -1 | ||
} | ||
var n = 0 | ||
if (arguments.length > 1) { | ||
n = Number(arguments[1]); | ||
if (n != n) { // shortcut for verifying if it's NaN | ||
n = 0 | ||
} else if (n != 0 && n != Infinity && n != -Infinity) { | ||
n = (n > 0 || -1) * Math.floor(Math.abs(n)); | ||
} | ||
} | ||
if (n >= len) { | ||
return -1 | ||
} | ||
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); | ||
for (; k < len; k++) { | ||
if (k in t && t[k] === searchElement) { | ||
return k | ||
} | ||
} | ||
return -1 | ||
} | ||
} | ||
|
||
(function ($) { | ||
$.fn.toggleCloudViaFor = function(cloud_trigger, tag_container) { | ||
var tag_cloud = $(this) | ||
|
||
cloud_trigger.click(function(e) { | ||
tag_cloud.toggle() | ||
e.preventDefault() | ||
}) | ||
|
||
var tag_items = tag_cloud.children() | ||
|
||
$(tag_items).click(function(e) { | ||
var tag_value = $(this).attr("data-tag") | ||
$(this).toggleTagFor(tag_value, tag_container) | ||
|
||
show_selected_tags_from(tag_container, tag_cloud) | ||
|
||
e.preventDefault() | ||
}) | ||
|
||
$(this).toggle() | ||
show_selected_tags_from(tag_container, tag_cloud) | ||
|
||
tag_container.keyup(function(e) { | ||
show_selected_tags_from(tag_container, tag_cloud) | ||
}) | ||
|
||
tag_container.change(function(e) { | ||
show_selected_tags_from(tag_container, tag_cloud) | ||
}) | ||
} | ||
|
||
function show_selected_tags_from(tag_container, tag_cloud) { | ||
var current_tags = tags_to_array(tag_container.attr("value")) | ||
update_selected_tags(current_tags, tag_cloud) | ||
} | ||
|
||
function update_selected_tags(selected_tags, tag_cloud) { | ||
tag_cloud.children().each(function(index, tag_child) { | ||
var tag_value = $(tag_child).attr("data-tag") | ||
if(selected_tags.indexOf(tag_value) == -1) | ||
$(tag_child).removeClass("selected") | ||
else { | ||
$(tag_child).addClass("selected") | ||
} | ||
}) | ||
} | ||
|
||
$.fn.toggleTagFor = function(tag_name, tag_container) { | ||
var content_tags = tags_to_array(tag_container.attr("value")) | ||
|
||
var this_tag_index = content_tags.indexOf(tag_name) | ||
|
||
if(this_tag_index == -1) { | ||
content_tags.push(tag_name) | ||
} else { | ||
content_tags.splice(this_tag_index, 1) | ||
} | ||
|
||
tag_container.attr("value", content_tags.join(" ")) | ||
} | ||
|
||
function tags_to_array(tags) { | ||
dirty_items = tags.split(/[,#\s]+/) | ||
return $.grep(dirty_items, function(val, i){ | ||
return (val.length > 0) | ||
}) | ||
} | ||
})(jQuery) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
span.tagMatches { | ||
margin-left: 10px; | ||
} | ||
|
||
span.tagMatches span { | ||
padding: 2px; | ||
margin-right: 4px; | ||
background-color: #0000AB; | ||
color: #fff; | ||
cursor: pointer; | ||
} | ||
|
||
#cloud_trigger, #cloud_content a { | ||
cursor: pointer; | ||
|
||
text-decoration: none; | ||
border-bottom: 1px dashed; | ||
} | ||
|
||
#cloud_trigger { | ||
font-weight: bold; | ||
} | ||
|
||
#cloud_content a { | ||
margin: 0.1em; | ||
} | ||
|
||
#cloud_content .selected { | ||
background: #0000AB; | ||
color: #fff; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters