Subversion Repositories SmartDukaan

Rev

Rev 10796 | Rev 11184 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10582 lgm 1
      <script src="<?php echo base_url();?>assets/js/jquery.js" type="text/javascript"></script>
2
      <script src="<?php echo base_url();?>assets/js/jquery.nouislider.js" type="text/javascript"></script>
3
      <script src="<?php echo base_url();?>assets/css/jquery.nouislider.css" type="text/css"></script>
4
 
5
 
6
      <?php //print_r($search_list);
7
      if(isset($search_list[0]->result->results) && (!empty($search_list[0]->result->results))) {
8
        $selectedFilters = array();
9
        $results = $search_list[0]->result?>
10
      <div class="pd-info-head ">
11
        <div class="name-hldr clearfix">
12
          <div>
13
            <?php if(isset($results->label) && !empty($results->label))?>
14
            <span><?php echo $results->label;?></span>
15
            <?php if((isset($results->totalCount)) && (!empty($results->totalCount))){
16
              $TotalPage = ceil($results->totalCount/10);?>
17
            <span>&#40;<?php echo $results->totalCount;?> results&#41;</span></div>
18
            <?php } ?>
19
          <div onclick="toggleListview(event);"></div>
20
        </div>
21
      </div><!--pd-info-head-->
22
      <div class="filter-div clearfix">
23
          <div onclick="toggleRefine(event)" class="sort">
24
            <span>
25
              <?php
26
              if(isset($results->sortedBy) && !empty($results->sortedBy)){               
27
              foreach($results->sortOptions as $key=>$value){ 
28
                if($results->sortedBy == $key){
10961 lgm 29
                  $sortedBy = $results->sortedBy;
30
                  echo $value;  
10582 lgm 31
                }
32
                 }
33
              }else{ echo "sort by";}  ?>
34
            </span>
35
          </div>
36
          <div onclick="toggleRefine(event)" class="filter">
37
            <span>
38
              Filter
39
            </span>
40
          </div>
41
          <!-- <div onclick="toggleRefine(event)" class="deals">
42
            <span>
43
             All
44
            </span>
45
          </div> -->
46
                   <div class="sort-by" style="display:none;" onclick="fireSort(event)">
47
         <?php foreach($results->sortOptions as $key=>$value){ ?>
10961 lgm 48
              <div <?php if(isset($sortedBy) && $sortedBy == $key){ echo 'class="opt selected"';}?> data-val="<?php echo $key;?>" ><?php echo $value;?></div>
10582 lgm 49
          <?php }?>
50
        </div><!--sort-by-->
51
        <div class="filter-by" style="display:none" onclick="fireFilter(event)">
52
          <div class="filter-head clearfix">
53
            <div class="clear" onclick="clearfilter(event)">Clear</div>
54
            <div class="apply" onclick="applyFilter1(event)">Apply</div>
55
          </div><!--btn-hldr-->
56
           <div class="filter-name">Price(Rs.)<span>+</span></div>
57
          <div class="filter-options clearfix" style="display:none" >
58
          <div style="position:relative; height:40px; width: 87%;padding:10px;box-sizing: border-box;-webkit-box-sizing: border-box;">
59
            <span id="exTO" class="slider-input"><?php echo $results->minPrice; ?></span>
60
            <span id="exFR" class="slider-input"><?php echo $results->maxPrice; ?></span>
61
          </div>
62
          <div class="clear"></div>
63
 
64
            <div class="noUiSlider"></div>
65
            <div id="minprice" class="oprice" style="display:<?php if(isset($results->dynamicPriceMap) && !empty($results->dynamicPriceMap)){echo 'block';}else{echo 'none';} ?>"><?php if(isset($results->dynamicPriceMap) && !empty($results->dynamicPriceMap)) { echo $results->dynamicPriceMap->min; } else { echo $results->minPrice; }?></div>
66
            <div id="maxprice" class="oprice max" style="display:<?php if(isset($results->dynamicPriceMap) && !empty($results->dynamicPriceMap)){echo 'block';}else{echo 'none';} ?>"><?php if(isset($results->dynamicPriceMap) && !empty($results->dynamicPriceMap)) { echo $results->dynamicPriceMap->max; } else { echo $results->maxPrice; } ?></div>
67
          </div><!--filter-options -->
68
          <?php foreach($results->facets as $facets){ ?>
69
          <div class="filter-name"><?php if(isset($facets->displayText) && !empty($facets->displayText)) echo $facets->displayText;?><span>+</span></div>
70
          <div class="filter-options" style="display:none" >
71
          <?php $i=0;
72
          foreach($facets->filterOptions as $filterOptions){ ?>
73
            <div id="<?php echo $filterOptions->value;?>" <?php if(($filterOptions->value == 'Mobile Accessories') || ($filterOptions->value == 'Basic Phones')){ ?> onclick="filterAccess('main')"<?php }else{ ?> onclick="filterAccess('brand')" <?php }?> data-parent="<?php echo $facets->displayText;?>" data-key="<?php echo $filterOptions->key; ?>" data-value="<?php echo $filterOptions->value; ?>" 
74
              <?php if($filterOptions->selected == 'true'){ 
75
                $selectedFilters[$i] = $filterOptions->value; $i++;?> 
76
                class="opt selected" <?php } else{?> class="opt"  <?php }?> >
77
                <?php  if(isset($filterOptions->nestedOptions) && !empty($filterOptions->nestedOptions)){ ?>
78
                +
79
                <?php }else{ ?>
80
                &#9633; 
81
                <?php } ?>
82
              <?php echo $filterOptions->value; ?>
83
             <span>&#40;<?php if($filterOptions->count != 1) echo $filterOptions->count." items";  else echo $filterOptions->count." item"; ?>&#41;</span></div>
84
 
85
 
86
                <?php  if(isset($filterOptions->nestedOptions) && !empty($filterOptions->nestedOptions)){ ?>
87
                  <div class='sub-filter' <?php if($filterOptions->selected == 'true'){ ?>style='display:block' <?php } else {?> style="display:none"<?php } ?>>
88
                <?php
89
                            foreach($filterOptions->nestedOptions as $nestedOptions){ ?>
90
                              <div data-key="<?php echo $nestedOptions->key; ?>" data-parent="<?php echo $filterOptions->value;?>" data-value="<?php echo $nestedOptions->value; ?>" 
91
                                 class="opt" <?php if($filterOptions->value == 'Mobile Accessories'){ ?> onclick="filterAccess('sub')" <?php }else{ ?> onclick="filter(brand)" <?php } ?> >
92
                                &#9633; <?php echo $nestedOptions->value;?>
93
                                <span>
94
                                  &#40;<?php if($nestedOptions->count != 1) echo $nestedOptions->count." items";  else echo $nestedOptions->count." item"; ?>&#41;
95
                                </span>
96
                              </div>
97
                            <?php } ?>
98
                    </div>  
99
                          <?php }
100
                  } ?>
101
 
102
          </div>
103
          <?php } ?>
104
          <div class="filter-head clearfix">
105
            <div class="clear" onclick="clearfilter(event)">Clear</div>
106
            <div class="apply" onclick="applyFilter1(event)">Apply</div>
107
          </div><!--btn-hldr-->
108
        </div><!--filter-by-->
109
      <div class="refine-mask" onclick="toggleRefine(event)"></div>
110
      </div><!--filter-div-->
111
 
112
      <div id="page" style="display:none">1</div>
113
      <input type = "hidden" id="count" value="<?=$TotalPage?>"/>
114
      <div id="appendlist" class="pd-list-hldr clearfix" >
115
        <?php foreach ($results->results as $result) { ?>
10796 lgm 116
        <a class="pd-list" href="<?php echo base_url().$result->url;?>">
117
          <div class="pd-image" style='background:url("<?php echo str_replace("'","&#039;",$result->image_url);?>")no-repeat center center;background-size:contain;'></div>
10582 lgm 118
          <div class="pd-info">
119
            <div class="pdt-name"><?php echo $result->title;?></div>
10796 lgm 120
            <div class="pdt-price">
121
              <?php if(isset($result->price) || isset($result->mrp)){?>
122
              <span class="pr">Rs</span>
123
              <?php if(isset($result->mrp) && $result->mrp != 0){ echo "<span class='pr-linethrough'>".$result->mrp. "</span>"; } ?>
124
              <?php if(isset($result->price) && $result->price != 0){?><span class="pr-original"><?php echo $result->price;?></span><?php }?>
125
            <?php }?>
126
            </div>
10582 lgm 127
            <div class="pdt-spec"><?php echo $result->description;?> </div>
128
          </div> 
129
        </a>
130
        <?php } ?>
131
      </div>
132
      <div id="showmorebutton" class="load-more" style="display:none" onclick="showMore('<?php echo $_GET['q']?>');">Show More</div>
133
      <?php } ?>
134
      <script type="text/javascript">
135
      var items = <?php echo json_encode($selectedFilters);?>
136
      </script>
137
       <script>
138
      debugger;
139
      //max, min values for slider initialization
140
         var max = document.getElementById("maxprice").innerHTML;
141
         max = parseInt(max);
142
        var min = document.getElementById("minprice").innerHTML;
143
        min = parseInt(min);
144
          var smin = document.getElementById("exTO").innerHTML
145
          smin = parseInt(smin);
146
          var smax = document.getElementById("exFR").innerHTML
147
          smax = parseInt(smax);
148
        // Run noUiSlider
149
 
150
 
151
        $('.noUiSlider').noUiSlider({
152
          set: function(){
153
                var left = $($(".noUiSlider").find("a")[0]).offset().left;
154
                var right = $($(".noUiSlider").find("a")[1]).offset().left;
155
                var width = $(".noUiSlider").width();
156
 
157
 
158
            $("#exTO").css({
159
              left: ((left/width * 100) - 8 ) + '%'
160
            });
161
              $("#exFR").css({
162
                left: ((right/width * 100) - 12 ) + '%'
163
              });  
164
          },
165
           range: [min, max],
166
           start: [smin, smax],
167
           step: 1,
168
           handles: 2,
169
           slide:function(){
170
             var maxWidth = document.getElementsByClassName('filter-by')[0].clientWidth;
171
             var value = $(this).val();
172
              var from = value[0];
173
              var to = value[1];
174
 
175
            $("#exTO").text(value[0]);
176
            $("#exFR").text(value[1]);
177
 
178
          left = $($(".noUiSlider").find("a")[0]).offset().left;
179
          right = $($(".noUiSlider").find("a")[1]).offset().left;
180
          width = $(".noUiSlider").width();
181
 
182
          if(left < 0){
183
            left = 1;
184
          }
185
 
186
          if((right - left) > 70)
187
          {
188
            $("#exTO").css({
189
              left: ((left/width * 100) - 8 ) + '%'
190
            });
191
            if(right < maxWidth){
192
              $("#exFR").css({
193
                left: ((right/width * 100) - 12 ) + '%'
194
              })  
195
            }
196
          }
197
           }
198
 
199
        });
200
 
201
 
202
         function filterAccess(el){
203
           debugger
204
           if(event.toElement.className.indexOf('selected') != -1){
205
             event.toElement.className =  event.toElement.className.replace('selected', '');
206
             event.toElement.nextElementSibling.style.display = 'none'
207
              return false;
208
           }else{
209
             event.toElement.className = event.toElement.className + ' selected'; 
210
           }
211
           var url1, sp = event.toElement.getAttribute('data-value').replace(' ','+');
212
           if(el == 'main'){
213
               url1 = window.location.href.split('&')[0]+'&fq='+event.toElement.getAttribute('data-key')+':'+sp;  
214
           }else if(el == 'brand'){
215
             url1 = window.location.href +'&fq='+event.toElement.getAttribute('data-key')+':'+sp;
216
           }else if(el == 'sub'){
217
             eUrl = window.location.href;
218
             if( (localStorage.getItem("prev") != null) && (eUrl.indexOf(localStorage.getItem('prev').replace(' ','+')) != -1) ){
219
               url1 = eUrl.replace(localStorage.getItem('prev').replace(' ','+') , sp);
220
             }else{
221
               url1 = window.location.href +'&fq='+event.toElement.getAttribute('data-key')+':'+sp;
222
             }
223
            localStorage.setItem("prev", event.toElement.getAttribute('data-value') );
224
           }else{
225
            url1 = window.location.href
226
            url1 = url1.split('&');
227
            url1 = url1[0]+'&fq='+event.toElement.getAttribute('data-key')+':'+sp;
228
           }
229
           window.location.assign(url1);
230
           event.stopPropagation();
231
 
232
         }
233
         function applyFilter1(){
234
           var url1 = window.location.href +'&minPrice'+document.getElementById('exTO').innerHTML+'&maxPrice='+document.getElementById('exFR').innerHTML;
235
            window.location.assign(url1);
236
         }
237
      </script>