Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7272 amit.gupta 1
$(document).ready(function(){
2
 
3
	/* Home */
4
	if($("#products:visible").length == 1){
5
 
6
		// Product Title
7
		$(".productItem .productDetails .title a").each(function(){
8
			var str = charLimit($(this), $(this).text(), 2, 20);
9
			$(this).text(str);
10
		});
11
 
12
		// Product Description
13
		$(".productItem .productDetails .productDesp").each(function(){
14
			if($("ul", this).length != 1){
15
				var str = charLimit($(this), $(this).text(), 5, 24);
16
				$(this).text(str);
17
			}
18
		});
19
	}
20
 
21
	/* Product Category : Browse Tab */
22
	if($("#browseContent:visible").length == 1){
23
 
24
		// Product Title
25
		$(".productItem .productDetails .title a").each(function(){
26
			var str = charLimit($(this), $(this).text(), 2, 20);
27
			$(this).text(str);
28
		});
29
 
30
		// Product Description
31
		$(".productItem .productDetails .productDesp").each(function(){
32
			if($("ul", this).length != 1){
33
				var str = charLimit($(this), $(this).text(), 5, 24);
34
				$(this).text(str);
35
			}
36
		});
37
	}
38
 
39
	/* Product Category : Other Tab */
40
	if($("#otherTabContent:visible").length == 1){
41
 
42
		// Product Title
43
		$(".productItem .productDetails .title a").each(function(){
44
			var str = charLimit($(this), $(this).text(), 2, 20);
45
			$(this).text(str);
46
		});
47
 
48
		// Product Description
49
		$(".productItem .productDetails .productDesp").each(function(){
50
			if($("ul", this).length != 1){
51
				var str = charLimit($(this), $(this).text(), 5, 24);
52
				$(this).text(str);
53
			}
54
		});
55
	}
56
 
57
	/* Search Result */
58
	if($("#searchResult:visible").length == 1){
59
 
60
		// Product Title
61
		$(".productItem .productDetails .title a").each(function(){
62
			var str = charLimit($(this), $(this).text(), 2, 32);
63
			$(this).text(str);
64
		});
65
 
66
		// Product Description
67
		$(".productItem .productDetails .productDesp").each(function(){
68
			if($("ul", this).length != 1){
69
				var str = charLimit($(this), $(this).text(), 4, 40);
70
				$(this).text(str);
71
			}
72
		});
73
	}
74
 
75
 
76
});
77
 
78
/*
79
 * param : selector, characters, no. of lines, each line char limit
80
*/
81
function charLimit(selector, chars, line, limit){
82
	var temp = "";
83
	var str  = jQuery.trim(chars);
84
	var len  = str.length;
85
 
86
	limit = line * limit;
87
 
88
	if(len > limit){
89
		$(selector).attr("title", str);
90
		temp = str.substr(0, limit-3) + "...";
91
 
92
		return temp;
93
	}else{
94
		return str;
95
	}	
96
}