summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2012-01-23 20:18:08 +0100
committerJochen Topf <jochen@topf.org>2012-01-23 20:18:19 +0100
commitf24d2a6fbe7d1906f485f86d7e62f27a0a3a8bc4 (patch)
tree12aff7a81196665563133b22c228f49eb06b9753 /web
parenta4ad712062678203d1a02ecf21f89848cc98c8c7 (diff)
downloadtaginfo-f24d2a6fbe7d1906f485f86d7e62f27a0a3a8bc4.tar
taginfo-f24d2a6fbe7d1906f485f86d7e62f27a0a3a8bc4.tar.gz
Javascript cleanup, remove taglink css class
Diffstat (limited to 'web')
-rw-r--r--web/lib/utils.rb8
-rw-r--r--web/public/css/taginfo.css2
-rw-r--r--web/public/js/taginfo.js243
3 files changed, 123 insertions, 130 deletions
diff --git a/web/lib/utils.rb b/web/lib/utils.rb
index dee90c7..731f765 100644
--- a/web/lib/utils.rb
+++ b/web/lib/utils.rb
@@ -133,9 +133,9 @@ def link_to_key(key)
k = escape(key)
if key.match(/[=\/]/)
- return '<a class="taglink" href="/keys/?key=' + k + '">' + pp_key(key) + '</a>'
+ return '<a href="/keys/?key=' + k + '">' + pp_key(key) + '</a>'
else
- return '<a class="taglink" href="/keys/' + k + '">' + pp_key(key) + '</a>'
+ return '<a href="/keys/' + k + '">' + pp_key(key) + '</a>'
end
end
@@ -144,9 +144,9 @@ def link_to_value(key, value)
v = escape(value)
if key.match(/[=\/]/) || value.match(/[=\/]/)
- return '<a class="taglink" href="/tags/?key=' + k + '&value=' + v + '">' + pp_value(value) + '</a>'
+ return '<a href="/tags/?key=' + k + '&value=' + v + '">' + pp_value(value) + '</a>'
else
- return '<a class="taglink" href="/tags/' + k + '=' + v + '">' + pp_value(value) + '</a>'
+ return '<a href="/tags/' + k + '=' + v + '">' + pp_value(value) + '</a>'
end
end
diff --git a/web/public/css/taginfo.css b/web/public/css/taginfo.css
index 7b35831..e9b3cd4 100644
--- a/web/public/css/taginfo.css
+++ b/web/public/css/taginfo.css
@@ -116,7 +116,7 @@ span.disabled {
/* ========== */
.tipsy { font-size: 80%; position: absolute; padding: 5px; z-index: 100000; }
-.tipsy-inner { background-color: #000; color: #FFF; max-width: 180px; padding: 5px 8px 4px 8px; text-align: center; }
+.tipsy-inner { background-color: #000; color: #FFF; max-width: 220px; padding: 5px 8px 4px 8px; text-align: center; }
/* Rounded corners */
.tipsy-inner { border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; }
diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js
index b7232b2..4429e3f 100644
--- a/web/public/js/taginfo.js
+++ b/web/public/js/taginfo.js
@@ -1,8 +1,41 @@
// taginfo.js
+// capitalize a string
+String.prototype.capitalize = function() {
+ return this.substr(0, 1).toUpperCase() + this.substr(1);
+}
+
+// print a number as percent value with two digits after the decimal point
+Number.prototype.print_as_percent = function() {
+ return (this * 100).toFixed(2) + '%';
+};
+
+/* ============================ */
+
var grids = {};
var current_grid = '';
+/* ============================ */
+
+function init_tipsy() {
+ jQuery('*[tipsy]').each(function(index, obj) {
+ obj = jQuery(obj);
+ obj.tipsy({ opacity: 1, delayIn: 500, gravity: obj.attr('tipsy') });
+ });
+}
+
+function resize_box() {
+ var height = jQuery(window).height();
+
+ height -= jQuery('div#header').outerHeight(true);
+ height -= jQuery('div.pre').outerHeight(true);
+ height -= jQuery('.ui-tabs-nav').outerHeight(true);
+ height -= jQuery('div#footer').outerHeight(true);
+
+ var wrapper = jQuery('.resize,.ui-tabs-panel');
+ wrapper.outerHeight(height);
+}
+
function resize_home() {
var tagcloud = jQuery('#tagcloud');
tagcloud.empty();
@@ -34,18 +67,6 @@ function resize_home() {
}
}
-function resize_box() {
- var height = jQuery(window).height();
-
- height -= jQuery('div#header').outerHeight(true);
- height -= jQuery('div.pre').outerHeight(true);
- height -= jQuery('.ui-tabs-nav').outerHeight(true);
- height -= jQuery('div#footer').outerHeight(true);
-
- var wrapper = jQuery('.resize,.ui-tabs-panel');
- wrapper.outerHeight(height);
-}
-
function resize_grid() {
if (grids[current_grid]) {
var grid = grids[current_grid][0].grid;
@@ -58,6 +79,8 @@ function resize_grid() {
}
}
+/* ============================ */
+
function hover_expand(text) {
return '<span class="overflow">' + text + '</span>';
}
@@ -84,12 +107,28 @@ function print_language(code, native_name, english_name) {
return '<span class="lang" title="' + native_name + ' (' + english_name + ')">' + code + '</span> ' + native_name;
}
-function print_key_list(list) {
- return jQuery.map(list, function(key, i) {
- return link_to_key(key);
- }).join(' &bull; ');
+function print_image(type) {
+ type = type.replace(/s$/, '');
+ var name;
+ if (type == 'all') {
+ name = texts.misc.all;
+ } else {
+ name = texts.osm[type];
+ }
+ return '<img src="/img/types/' + type + '.16.png" alt="[' + name + ']" title="' + name + '" width="16" height="16"/>';
}
+// print a number with thousand separator
+function print_with_ts(value) {
+ if (value === null) {
+ return '-';
+ } else {
+ return value.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1&thinsp;');
+ }
+}
+
+/* ============================ */
+
function print_key_or_tag_list(list) {
return jQuery.map(list, function(tag, i) {
if (tag.match(/=/)) {
@@ -106,7 +145,7 @@ function print_prevalent_value_list(key, list) {
return empty(texts.misc.values_less_than_one_percent);
}
return jQuery.map(list, function(item, i) {
- return link_to_value_with_title(key, item.value, '(' + (item.fraction * 100).toFixed(2) + '%)');
+ return link_to_value_with_title(key, item.value, '(' + item.fraction.print_as_percent() + ')');
}).join(' &bull; ');
}
@@ -116,54 +155,18 @@ function link_to_value_with_title(key, value, extra) {
title = html_escape(value) + ' ' + extra;
if (key.match(/[=\/]/) || value.match(/[=\/]/)) {
- return '<a class="taglink" href="/tags/?key=' + k + '&value=' + v + '" title="' + title + '">' + pp_value(value) + '</a>';
+ return '<a href="/tags/?key=' + k + '&value=' + v + '" title="' + title + '" tipsy="e">' + pp_value(value) + '</a>';
} else {
- return '<a class="taglink" href="/tags/' + k + '=' + v + '" title="' + title + '">' + pp_value(value) + '</a>';
+ return '<a href="/tags/' + k + '=' + v + '" title="' + title + '" tipsy="e">' + pp_value(value) + '</a>';
}
}
-function print_tag_list(key, list) {
- return jQuery.map(list, function(value, i) {
- return link_to_value(key, value);
- }).join(' &bull; ');
-}
-
function print_value_with_percent(value, fraction) {
var v1 = print_with_ts(value),
v2 = fraction.print_as_percent();
return '<div class="value">' + v1 + '</div><div class="fraction">' + v2 + '</div><div class="bar" style="width: ' + (fraction*100).toFixed() + 'px;"></div>';
}
-// capitalize a string
-String.prototype.capitalize = function() {
- return this.substr(0, 1).toUpperCase() + this.substr(1);
-}
-
-function print_image(type) {
- type = type.replace(/s$/, '');
- var name;
- if (type == 'all') {
- name = texts.misc.all;
- } else {
- name = texts.osm[type];
- }
- return '<img src="/img/types/' + type + '.16.png" alt="[' + name + ']" title="' + name + '" width="16" height="16"/>';
-}
-
-// print a number with thousand separator
-function print_with_ts(value) {
- if (value === null) {
- return '-';
- } else {
- return value.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1&thinsp;');
- }
-}
-
-// print a number as percent value with two digits after the decimal point
-Number.prototype.print_as_percent = function() {
- return (this * 100).toFixed(2) + '%';
-};
-
var pp_chars = '!"#$%&()*+,-/;<=>?@[\\]^`{|}~' + "'";
function pp_key(key) {
@@ -211,18 +214,8 @@ function pp_value_with_highlight(value, highlight) {
return values.join('<b>' + highlight + '</b>');
}
-function link_to_key_with_highlight(key, highlight) {
- var k = encodeURIComponent(key);
-
- if (key.match(/[=\/]/)) {
- return '<a class="taglink" href="/keys/?key=' + k + '">' + pp_key_with_highlight(key, highlight) + '</a>';
- } else {
- return '<a class="taglink" href="/keys/' + k + '">' + pp_key_with_highlight(key, highlight) + '</a>';
- }
-}
-
function link_to_value_with_highlight(key, value, highlight) {
- return '<a class="taglink" href="' + url_to_value(key, value) + '">' + pp_value_with_highlight(value, highlight) + '</a>';
+ return '<a href="' + url_to_value(key, value) + '">' + pp_value_with_highlight(value, highlight) + '</a>';
}
function html_escape(text) {
@@ -233,29 +226,25 @@ function link_to_key(key) {
var k = encodeURIComponent(key);
if (key.match(/[=\/]/)) {
- return '<a class="taglink" href="/keys/?key=' + k + '">' + pp_key(key) + '</a>';
+ return '<a href="/keys/?key=' + k + '">' + pp_key(key) + '</a>';
} else {
- return '<a class="taglink" href="/keys/' + k + '">' + pp_key(key) + '</a>';
+ return '<a href="/keys/' + k + '">' + pp_key(key) + '</a>';
}
}
function link_to_key_with_highlight(key, highlight) {
var k = encodeURIComponent(key);
- var re = new RegExp('(' + highlight + ')', 'g');
+ var re = new RegExp('(' + highlight + ')', 'gi');
var hk = key.replace(re, "<b>$1</b>");
if (key.match(/[=\/]/)) {
- return '<a class="taglink" href="/keys/?key=' + k + '">' + hk + '</a>';
+ return '<a href="/keys/?key=' + k + '">' + hk + '</a>';
} else {
- return '<a class="taglink" href="/keys/' + k + '">' + hk + '</a>';
+ return '<a href="/keys/' + k + '">' + hk + '</a>';
}
}
-function link_to_value(key, value) {
- return '<a class="taglink" href="' + url_to_value(key, value) + '">' + pp_value(value) + '</a>';
-}
-
function url_to_value(key, value) {
var k = encodeURIComponent(key),
v = encodeURIComponent(value);
@@ -270,6 +259,10 @@ function link_to_tag(key, value) {
return link_to_key(key) + '=' + link_to_value(key, value);
}
+function link_to_value(key, value) {
+ return '<a href="' + url_to_value(key, value) + '">' + pp_value(value) + '</a>';
+}
+
function link_to_key_or_tag(key, value) {
var link = link_to_key(key);
if (value && value != '') {
@@ -280,56 +273,6 @@ function link_to_key_or_tag(key, value) {
return link;
}
-jQuery(document).ready(function() {
- jQuery('#javascriptmsg').remove();
-
- jQuery('select').customStyle();
-
- jQuery.getQueryString = (function(a) {
- if (a == "") return {};
- var b = {};
- for (var i = 0; i < a.length; i++) {
- var p=a[i].split('=');
- b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
- }
- return b;
- })(window.location.search.substr(1).split('&'))
-
- jQuery('*[tipsy]').each(function(index, obj) {
- obj = jQuery(obj);
- obj.tipsy({ opacity: 1, delayIn: 500, gravity: obj.attr('tipsy') });
- });
-
- resize_box();
-
- if (typeof page_init === 'function') {
- page_init();
- }
-
- jQuery('#locale').bind('change', function() {
- jQuery('#set_language').submit();
- });
-
- jQuery('#search').autocomplete({
- minLength: 2,
- source: '/search/suggest?format=simple',
- delay: 10,
- select: function(event, ui) {
- var query = ui.item.value;
- if (query.match(/=/)) {
- window.location = '/tags/' + ui.item.value;
- } else {
- window.location = '/keys/' + ui.item.value;
- }
- }
- }).focus();
-
- jQuery(window).resize(function() {
- resize_box();
- resize_grid();
- });
-});
-
/* ============================ */
var flexigrid_defaults = {
@@ -340,6 +283,7 @@ var flexigrid_defaults = {
usepager : true,
useRp : false,
onSuccess : function(grid) {
+ init_tipsy();
grid.fixHeight();
}
};
@@ -391,3 +335,52 @@ function init_tabs(params) {
});
}
+/* ============================ */
+
+jQuery(document).ready(function() {
+ jQuery('#javascriptmsg').remove();
+
+ jQuery('select').customStyle();
+
+ jQuery.getQueryString = (function(a) {
+ if (a == "") return {};
+ var b = {};
+ for (var i = 0; i < a.length; i++) {
+ var p=a[i].split('=');
+ b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
+ }
+ return b;
+ })(window.location.search.substr(1).split('&'));
+
+ init_tipsy();
+
+ resize_box();
+
+ if (typeof page_init === 'function') {
+ page_init();
+ }
+
+ jQuery('#locale').bind('change', function() {
+ jQuery('#set_language').submit();
+ });
+
+ jQuery('#search').autocomplete({
+ minLength: 2,
+ source: '/search/suggest?format=simple',
+ delay: 10,
+ select: function(event, ui) {
+ var query = ui.item.value;
+ if (query.match(/=/)) {
+ window.location = '/tags/' + ui.item.value;
+ } else {
+ window.location = '/keys/' + ui.item.value;
+ }
+ }
+ }).focus();
+
+ jQuery(window).resize(function() {
+ resize_box();
+ resize_grid();
+ });
+});
+