change font size of titles acc to no of chars

This commit is contained in:
Sanj 2011-09-28 19:49:07 +05:30
parent eb33e0da95
commit 75b0d7d774

View File

@ -12,8 +12,14 @@ $('#listLeft ul li a').live("click", function() {
'tab_id': tabId, 'tab_id': tabId,
'object_id': objId 'object_id': objId
}, function(data) { }, function(data) {
$('#textRight').text(data.title); $('#textRight').text(data.title).formatTitle();
$('#bottomRight').html(data.html); var searchTerm = $('.searchListField').val();
var html = data.html;
if (searchTerm != '') {
html = highlightWordsNoCase(html, searchTerm);
// html = html.replace(searchTerm, "<span class='highlight'>" + searchTerm + "</span>");
}
$('#bottomRight').html(html);
// console.log(data); // console.log(data);
}); });
return false; return false;
@ -29,6 +35,11 @@ $('.toggleNext').live("click", function(e) {
} }
}); });
function highlightWordsNoCase(data, word)
{
var regex = new RegExp("(" + word + ")", "gi");
return data.replace(regex, "<span class='searchHighlight'>$1</span>");
}
/* Get a jquery <option> row for a sort field, requires s.operator, s.field_name, s.friendly_name */ /* Get a jquery <option> row for a sort field, requires s.operator, s.field_name, s.friendly_name */
function getOption(s) { function getOption(s) {
@ -98,7 +109,7 @@ $(function() {
} else { } else {
/* end if has_list */ /* end if has_list */
$('#textRight').text(data.title); $('#textRight').text(data.title).formatTitle();
var $html = getNoListHtml(data.page.items); var $html = getNoListHtml(data.page.items);
$('#bottomRight').empty().append($html); $('#bottomRight').empty().append($html);
} }
@ -106,24 +117,30 @@ $(function() {
}); });
$('#orderBySelect').change(function(e) { $('#orderBySelect').change(function(e) {
var sortString = $(this).val(); $('.selectMenu').submit();
doListLoading();
$.getJSON("/m/get_list", {
'tab_id': $('.innerSelected').attr("data-id"),
'sort': sortString
}, function(data) {
stopListLoading(data);
displayList(data.items);
});
}); });
$('#searchListIcon').click(function() { $('#searchListIcon').click(function() {
var term = $('.searchListField').val(); $('.selectMenu').submit();
});
$('.searchListField').keyup(function(e) {
e.preventDefault();
if (e.keyCode == 13) {
$('.selectMenu').submit();
}
});
$('.selectMenu').submit(function(e) {
e.preventDefault();
var sortString = $('#orderBySelect').val();
var searchTerm = $('.searchListField').val();
doListLoading(); doListLoading();
$.getJSON("/m/get_list", { $.getJSON("/m/get_list", {
'tab_id': $('.innerSelected').attr("data-id"), 'tab_id': $('.innerSelected').attr("data-id"),
// 'sort': sortString, 'sort': sortString,
'search': term 'search': searchTerm
}, function(data) { }, function(data) {
stopListLoading(data); stopListLoading(data);
displayList(data.items); displayList(data.items);
@ -219,3 +236,17 @@ function getNoListItemHtml(item) {
} }
return $ret; return $ret;
} }
jQuery.fn.formatTitle = function() {
var txt = $(this).text();
var fontSize;
// alert(txt.length);
if (txt.length < 35) {
fontSize = 50;
} else if (txt.length < 60) {
fontSize = 35;
} else {
fontSize = 20;
}
this.css({'fontSize': fontSize + "px"});
}