| 7272 |
amit.gupta |
1 |
/**
|
|
|
2 |
* Author : Raj Kumar Bharti
|
|
|
3 |
* Creation Date : 06 Dec 2010
|
|
|
4 |
* Project : Shop2020
|
|
|
5 |
* Copyright 2010 Evon Technologies
|
|
|
6 |
*/
|
|
|
7 |
|
|
|
8 |
$(document).ready(function(){
|
|
|
9 |
|
|
|
10 |
// Variables for pagination result of browse, other tab content and search result
|
|
|
11 |
x = y = z = 0;
|
|
|
12 |
var arrBrowsePaginationResult = [];
|
|
|
13 |
arrBrowsePaginationResult.push([0, 0]);
|
|
|
14 |
|
|
|
15 |
var arrOtherPaginationResult = [];
|
|
|
16 |
arrOtherPaginationResult.push([0, 0]);
|
|
|
17 |
|
|
|
18 |
var arrSearchPaginationResult = [];
|
|
|
19 |
arrSearchPaginationResult.push([0, 0]);
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
// Setting tab button id attr to empty
|
|
|
23 |
$('#tabButton div').each(function(){
|
|
|
24 |
$("a", this).attr("id", "");
|
|
|
25 |
});
|
|
|
26 |
|
|
|
27 |
// Activating Browse tab
|
|
|
28 |
activeTab("catTab1");
|
|
|
29 |
|
|
|
30 |
// Hide other tab common content for best deals, latest arrivals, best sellers
|
|
|
31 |
hideShowTabContent("otherTabContent", "hide");
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
// Filter by heading slideup and slidedown
|
|
|
35 |
filterByOptionSlide();
|
|
|
36 |
|
|
|
37 |
// Filter by values selection
|
|
|
38 |
filterByValues();
|
|
|
39 |
|
|
|
40 |
// Sort Search Results
|
|
|
41 |
sortSearchResult();
|
|
|
42 |
|
|
|
43 |
// Align properly new icon in search result pages for a product
|
|
|
44 |
var newIconLeft = $("#searchResult #productListCenter .productItem .productImg img").css("left");
|
|
|
45 |
$("#searchResult #productListCenter .productItem .productImg .newIcon").css("left", newIconLeft);
|
|
|
46 |
});
|
|
|
47 |
|
|
|
48 |
/*
|
|
|
49 |
* sort search results
|
|
|
50 |
*/
|
|
|
51 |
function sortSearchResult(){
|
|
|
52 |
$("#sortBy a").click(function(){
|
|
|
53 |
id = $(this).attr("id");
|
|
|
54 |
|
|
|
55 |
if(id == "sortByPrice"){
|
|
|
56 |
$(this).removeClass('active').addClass('active');
|
|
|
57 |
$("#sortByRelevance, #sortByPopularity").removeClass('active');
|
|
|
58 |
// Ajax call to fecth data in page class
|
|
|
59 |
|
|
|
60 |
}else if(id == "sortByRelevance"){
|
|
|
61 |
$(this).removeClass('active').addClass('active');
|
|
|
62 |
$("#sortByPrice, #sortByPopularity").removeClass('active');
|
|
|
63 |
// Ajax call to fecth data in page class
|
|
|
64 |
}else if (id =="sortByPopularity"){
|
|
|
65 |
$(this).removeClass('active').addClass('active');
|
|
|
66 |
$("#sortByPrice,#sortByRelevance").removeClass('active');
|
|
|
67 |
}
|
|
|
68 |
});
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
/*
|
|
|
72 |
* Filter by values selection
|
|
|
73 |
*/
|
|
|
74 |
function filterByValues(){
|
|
|
75 |
// Data Connectivity
|
|
|
76 |
$("#filterByDataConnectivity .filterOption a").click(function(){
|
|
|
77 |
var v = $(this).text();
|
|
|
78 |
});
|
|
|
79 |
|
|
|
80 |
// Note for price slider value see priceSlider.js
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
/*
|
|
|
84 |
* Filter by heading slideup and slidedown
|
|
|
85 |
*/
|
|
|
86 |
function filterByOptionSlide(){
|
|
|
87 |
$("#filterBy .filterHeading").click(function(){
|
|
|
88 |
|
|
|
89 |
// Image angle change
|
|
|
90 |
if($(this).parent().find(".filterArrow").length == 1){
|
|
|
91 |
$(this).parent().find(".filterArrow").removeClass('filterArrow').addClass('filterArrowRotate');
|
|
|
92 |
}else if($(this).parent().find(".filterArrowRotate").length == 1){
|
|
|
93 |
$(this).parent().find(".filterArrowRotate").removeClass('filterArrowRotate').addClass('filterArrow');
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
// Content slideup and slide down
|
|
|
97 |
if($(this).parent().find(".filterOption").length == 1){
|
|
|
98 |
$(this).parent().find(".filterOption").slideToggle();
|
|
|
99 |
}else{
|
|
|
100 |
$(this).parent().find("#priceSlider").slideToggle();
|
|
|
101 |
}
|
|
|
102 |
});
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
/*
|
|
|
106 |
* Browse content
|
|
|
107 |
*/
|
|
|
108 |
function browseContentCallback(page_index, jq){
|
|
|
109 |
|
|
|
110 |
// Show page content
|
|
|
111 |
$('#browseContent #productListCenter1 div.page:visible').hide();
|
|
|
112 |
$('#browseContent #productListCenter1 div.page:eq(' + page_index + ')').show();
|
|
|
113 |
|
|
|
114 |
x = arrBrowsePaginationResult[page_index][0];
|
|
|
115 |
y = arrBrowsePaginationResult[page_index][1];
|
|
|
116 |
z = $('#browseContent #productListCenter1 div.page .productItem').length;
|
|
|
117 |
|
|
|
118 |
result = x + ' to ' + y + ' of <span class="resultLimit">' + z + '</span> <span class="style1">results</span>';
|
|
|
119 |
|
|
|
120 |
$("#browseContent .productListResult").html(result);
|
|
|
121 |
|
|
|
122 |
return false;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
/*
|
|
|
126 |
* Browse content
|
|
|
127 |
*/
|
|
|
128 |
function otherTabContentCallback(page_index, jq){
|
|
|
129 |
|
|
|
130 |
// Show page content
|
|
|
131 |
$('#otherTabContent #productListCenter2 div.page:visible').hide();
|
|
|
132 |
$('#otherTabContent #productListCenter2 div.page:eq(' + page_index + ')').show();
|
|
|
133 |
|
|
|
134 |
x = arrOtherPaginationResult[page_index][0];
|
|
|
135 |
y = arrOtherPaginationResult[page_index][1];
|
|
|
136 |
z = $('#otherTabContent #productListCenter2 div.page .productItem').length;
|
|
|
137 |
|
|
|
138 |
result = x + ' to ' + y + ' of <span class="resultLimit">' + z + '</span> ' + $("#otherTabContent .productListHeading").text();
|
|
|
139 |
|
|
|
140 |
$("#otherTabContent .productListResult").html(result);
|
|
|
141 |
|
|
|
142 |
return false;
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
/*
|
|
|
146 |
* Search Result content pagination
|
|
|
147 |
*/
|
|
|
148 |
function initSearchResultPagination(){
|
|
|
149 |
if($('#searchResult:visible').length == 1){
|
|
|
150 |
// Total page length
|
|
|
151 |
totalPages = $('#searchResult #searchResultContent div.page').length;
|
|
|
152 |
|
|
|
153 |
if(totalPages > 0){
|
|
|
154 |
defaultPaginationLen = 6; // Length of pages to show in pagination
|
|
|
155 |
|
|
|
156 |
// Whether to show ellipse or not, if yes then how many
|
|
|
157 |
edgePaginationLen = (totalPages >= defaultPaginationLen) ? 1 : 0;
|
|
|
158 |
|
|
|
159 |
// Number of pages to display in pagination
|
|
|
160 |
numOfPageDisplay = (totalPages >= defaultPaginationLen) ? defaultPaginationLen : totalPages;
|
|
|
161 |
|
|
|
162 |
// Select current page in pagination
|
|
|
163 |
curPageSelection = 0;
|
|
|
164 |
|
|
|
165 |
$("#searchResult #searchResultContent .pagination1").pagination(totalPages, {
|
|
|
166 |
num_display_entries : numOfPageDisplay,
|
|
|
167 |
num_edge_entries : edgePaginationLen,
|
|
|
168 |
current_page : curPageSelection,
|
|
|
169 |
items_per_page : 1,
|
|
|
170 |
callback : searchContentCallback,
|
|
|
171 |
link_to : 'javascript: void(0);'
|
|
|
172 |
});
|
|
|
173 |
|
|
|
174 |
// Show result no
|
|
|
175 |
curPageItemNo = $('#searchResult #searchResultContent div.page:eq(0) .productItem').length;
|
|
|
176 |
|
|
|
177 |
x = 1;
|
|
|
178 |
y = curPageItemNo;
|
|
|
179 |
z = $('#searchResult #searchResultContent div.page .productItem').length;
|
|
|
180 |
result = x + ' to ' + y + ' of <span class="resultLimit">' + z + '</span> <span class="style1">results</span>';
|
|
|
181 |
|
|
|
182 |
len = arrSearchPaginationResult.length;
|
|
|
183 |
for(var i=0; i<len; i++){
|
|
|
184 |
arrSearchPaginationResult.pop();
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
$('#searchResult #searchResultContent div.page').each(function(){
|
|
|
188 |
arrSearchPaginationResult.push([x, y]);
|
|
|
189 |
|
|
|
190 |
x = y + 1;
|
|
|
191 |
y = x + ($('.productItem', this).length - 1);
|
|
|
192 |
});
|
|
|
193 |
|
|
|
194 |
$("#searchResult #searchResultContent .productListResult").html(result);
|
|
|
195 |
}else{
|
|
|
196 |
result = '0 to 0 of <span class="resultLimit"> 0 </span> <span class="style1">results</span>';
|
|
|
197 |
|
|
|
198 |
$("#searchResult #searchResultContent .productListResult").html(result);
|
|
|
199 |
}
|
|
|
200 |
}
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
/*
|
|
|
204 |
* Search result content
|
|
|
205 |
*/
|
|
|
206 |
function searchContentCallback(page_index, jq){
|
|
|
207 |
|
|
|
208 |
// Show page content
|
|
|
209 |
$('#searchResult #searchResultContent div.page:visible').hide();
|
|
|
210 |
$('#searchResult #searchResultContent div.page:eq(' + page_index + ')').show();
|
|
|
211 |
|
|
|
212 |
x = arrSearchPaginationResult[page_index][0];
|
|
|
213 |
y = arrSearchPaginationResult[page_index][1];
|
|
|
214 |
z = $('#searchResult #searchResultContent div.page .productItem').length;
|
|
|
215 |
|
|
|
216 |
result = x + ' to ' + y + ' of <span class="resultLimit">' + z + '</span> <span class="style1">results</span>';
|
|
|
217 |
|
|
|
218 |
$("#searchResult #searchResultContent .productListResult").html(result);
|
|
|
219 |
|
|
|
220 |
return false;
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
/*
|
|
|
224 |
* Remove last active tab state
|
|
|
225 |
*/
|
|
|
226 |
function removeLastActiveState(){
|
|
|
227 |
if($('#tabButton a#activeTab').length == 1){
|
|
|
228 |
|
|
|
229 |
$('#tabButton div').each(function(){
|
|
|
230 |
if($("a", this).attr("id") == "activeTab"){
|
|
|
231 |
$("a", this).attr("id", "");
|
|
|
232 |
}
|
|
|
233 |
});
|
|
|
234 |
|
|
|
235 |
}
|
|
|
236 |
}
|
|
|
237 |
|
|
|
238 |
/*
|
|
|
239 |
* Make active tab
|
|
|
240 |
*/
|
|
|
241 |
function activeTab(id){
|
|
|
242 |
$("#" + id + " a").attr("class","category-tabs activeTab");
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
/*
|
|
|
246 |
* Hide tab content
|
|
|
247 |
*/
|
|
|
248 |
function hideShowTabContent(id, state){
|
|
|
249 |
if(state == "hide"){
|
|
|
250 |
$("#" + id).hide();
|
|
|
251 |
}else if(state == "show"){
|
|
|
252 |
$("#" + id).show();
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
if(id == "multifacetedSearch"){
|
|
|
256 |
if(state == "hide"){
|
|
|
257 |
$("#productCat .top .left").css("background", "#fff");
|
|
|
258 |
$("#productCat .bottom .left").css("background", "url(/images/product-detail-bottom-left.jpg) no-repeat");
|
|
|
259 |
$("#productCat .middle .content").css("background-image", "none");
|
|
|
260 |
|
|
|
261 |
$("#productList").css("width", "100%");
|
|
|
262 |
$("#productList").css("margin-left", "0");
|
|
|
263 |
|
|
|
264 |
$("#productList #productListCenter .floatLeft").css("margin-left", "70px");
|
|
|
265 |
$("#productList #productListCenter .floatRight").css("margin-right", "70px");
|
|
|
266 |
}else if(state == "show"){
|
|
|
267 |
$("#productCat .top .left").css("background", "#efeff0");
|
|
|
268 |
$("#productCat .bottom .left").css("background", "url(/images/product-cat-bottom-left.jpg) no-repeat");
|
|
|
269 |
$("#productCat .middle .content").css("background", "#ffffff url(/images/grey-ver-bar.gif) repeat-y");
|
|
|
270 |
|
|
|
271 |
$("#productList").css("width", "515px");
|
|
|
272 |
$("#productList").css("margin-left", "1px");
|
|
|
273 |
|
|
|
274 |
$("#productList #productListCenter .floatLeft").css("margin-left", "16px");
|
|
|
275 |
$("#productList #productListCenter .floatRight").css("margin-right", "16px");
|
|
|
276 |
}
|
|
|
277 |
}
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
/*
|
|
|
281 |
* Set content heading on tab click
|
|
|
282 |
*/
|
|
|
283 |
function setContentHeading(str){
|
|
|
284 |
if($("#otherTabContent:visible").length == 1){
|
|
|
285 |
$("#otherTabContent .productListHeading").text(str);
|
|
|
286 |
}
|
|
|
287 |
}
|