Subversion Repositories SmartDukaan

Rev

Rev 20691 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<script>
    $(document).ready(function(){
    setTimeout(function(){
            $('#searchforbrand').css({'background-color':'orange'});
            setTimeout(function(){$('#searchforbrand').css({'background-color':''})}, 1500);
        }, 1000);
    
    var statepushed = false;
    if($("#searchforbrand").length != 0 ) {
      if (window.history && window.history.pushState) {

        $(window).on('popstate', function() {
            $('#searchforbrand').val("");
            $("#regularcontent").removeClass('hidden');
            $("#searchedcontent").addClass('hidden');
            $('.scrollselector').jscrollobj({
                loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
                autoTriggerUntil: 3,
                padding: 20,
                callback:loadCartDetails
            });
            statepushed = false;
        });

      }
    }       
        trigger = false;
        var footertop = $(window).height();
        setInterval(function() {
        if(parseInt(footertop)!=parseInt($(window).height())){
        $("div.pmfooter").hide();
        }else{
        $("div.pmfooter").show();
        }
        },100);

        var new_msg="";
        var typingTimer;                
        var doneTypingInterval = 1000; 
        $('#searchforbrand').keyup(function(e){
            var keycode = e.keyCode || e.which;
            //dont do anything if invalid key has been pressed.
             var valid = 
                (keycode > 47 && keycode < 58)   || // number keys
                keycode == 32 || keycode == 13   || // spacebar & return key(s) (if you want to allow carriage returns)
                (keycode > 64 && keycode < 91)   || // letter keys
                (keycode > 95 && keycode < 112)  || // numpad keys
                (keycode > 185 && keycode < 193) || // ;=,-./` (in order)
                (keycode > 218 && keycode < 223) ||
                keycode==8 || keycode == 0 || keycode==229;
            if(!valid){
                return;
            }
            clearTimeout(typingTimer);

            var s ="";  
            s = encodeURIComponent($(this).val().trim());            
            if(s.length > 0 && $('#searchforbrand').val()!= "") {
                if(!statepushed) {
                    if (window.history && window.history.pushState) {
                        window.history.pushState('forward', null, window.location);
                        statepushed = true;
                    }
                }
            
                if ($('#searchforbrand').val) {
                    typingTimer = setTimeout(function doneTyping(){
                        $("#searchloader").removeClass('hidden');
                        $.ajax({
                            method: "GET",
                            url:  "<?php echo $base_url;?>categories/getdealsforsearchterm/"+s + "?subcategories="+getJsonFromUrl()["subcategories"],
                        },'json')
                        .done(function(msg){
                                if( c != typingTimer) {
                                        $("#searchloader").addClass('hidden');
                                        return; 
                                }
                                $(window).one('scroll', function(){
                                        $("#searchforbrand").blur();
                                });
                                                        $("#popovertrigger5").popover('hide').remove();
                            var cart_details = localStorage.getItem("cart_details");
                            if(cart_details!=undefined){
                                var cartDetailsObj = JSON.parse(cart_details);
                                if(cartDetailsObj.totalCartQuantity > 0){
                                    var totalCartValue = cartDetailsObj.totalCartValue;
                                    var priceChangeMap = {};
                                    $.each(cartDetailsObj.cartItems, function(key,val) {
                                        var newUnitPrice = $(msg).find("div.number-spinner button[data-id='"+key+"']").data('price');
                                        if(newUnitPrice!=null){
                                            $(msg).find("div.number-spinner button[data-id='"+key+"']").closest('.number-spinner').find('input').val(val.quantity);
                                            if(parseInt(newUnitPrice)!=parseInt(val.unitprice)){
                                                totalCartValue = totalCartValue - (parseInt(val.unitprice)*parseInt(val.quantity)) + (parseInt(newUnitPrice)*parseInt(val.quantity));
                                                priceChangeMap[key] = newUnitPrice;
                                            }
                                        }
                                    });
                                    if(totalCartValue!=undefined){
                                        cartDetailsObj.totalCartValue = totalCartValue;
                                    }
                                    var cartItems = cartDetailsObj.cartItems;
                                    $.each(priceChangeMap, function(key,val) {
                                        cartItems[key].unitprice = val;
                                    });
                                    cartDetailsObj.cartItems = cartItems;
                                    localStorage.setItem('cart_details',JSON.stringify(cartDetailsObj));
                                }
                            }
                            $("#regularcontent").addClass('hidden');
                            $("#searchloader").addClass('hidden');
                            $("#searchedcontent").html('<div class="row scroll cscrollselector">'+msg+'</div>');
                            $("#searchedcontent").removeClass('hidden');
                            if($('.cscrollselector > .card').length>0) {
                                if(typeof noscrolling == 'undefined') {
                                    $('#searchedcontent').find('.cscrollselector').jscroll({
                                        loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
                                        autoTriggerUntil: 3,
                                        padding: 20,
                                        callback:loadCartDetails
                                    });
                                }
                            }
                            $('.data-up:visible:first').append('<a id="popovertrigger5"  data-container="body" data-toggle="popover" data-placement="left" data-content="Quick buy multiple items together"></a>');
                            setPopOver("popovertrigger5", ".plusqtybutton", 'click');
                        });
                    }, doneTypingInterval);
                    c = typingTimer;
                }
            }
            else
            {
                c = 0;
                $("#regularcontent").removeClass('hidden');
                $("#searchedcontent").addClass('hidden');
                $('#popovertrigger5').popover('hide').remove();
                $('.data-up:visible:first').append('<a id="popovertrigger5"  data-container="body" data-toggle="popover" data-placement="left" data-content="Quick buy multiple items together"></a>');
                setPopOver("popovertrigger5", ".plusqtybutton", 'click');
                $('.scrollselector').jscrollobj({
                    loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
                    autoTriggerUntil: 3,
                    padding: 20,
                    callback:loadCartDetails
                });
                if(statepushed){
                    statepushed = false;
                    window.history.back();
                }
            } 
        });

        

    });

</script>
<style>

.shadow {
    -webkit-box-shadow: 0px 0px 12px 4px #ffffff;
    -moz-box-shadow: 0px 0px 12px 4px #ffffff;
    box-shadow: 0px 0px 12px 4px #ffffff;
    -webkit-transition: all 0.5s linear;
    -o-transition: all 0.5s linear;
    -moz-transition: all 0.5s linear;
    -ms-transition: all 0.5s linear;
    -kthtml-transition: all 0.5s linear;
    transition: all 0.5s linear;
}

#searchforbrand {
    width: 100%;
    -webkit-transition: all 0.5s linear;
    -o-transition: all 0.5s linear;
    -moz-transition: all 0.5s linear;
    -ms-transition: all 0.5s linear;
    -kthtml-transition: all 0.5s linear;
    transition: all 0.5s linear;
}

#searchloader{
    position:absolute;
    /*top:40%;*/
    left:50%;
    z-index:2001;
}
.black_overlay{
    /*display: none;*/
    position: absolute;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index:2000;
    -moz-opacity: 0.8;
    opacity:.80;
    filter: alpha(opacity=80);
}
#moreitem{
    margin: 2px auto;
    height: 30px;
    color: #555;
    background-color: #f5f5f5;
    padding:4px;
}
.inner-addon .glyphicon {
  top : 0px; 
  position: absolute;
  padding: 13px;
  pointer-events: none;
}
.left-addon .glyphicon  { left:  0px;}
.left-addon input  { padding:5px 6px 3px 36px; }

.accmenu>li {
        padding : 0px ;
}
</style>

<?php //if($id==6):?>
<div class = "row" style="background:white;padding:5px 0px;">   
                <hr style="margin-top:0px;margin-bottom:4px;">
        
        <div class= "col-xs-9" style="padding:0px;">
                
                
                <div style="width:100%;font-size:12px;padding:5px 1px 1px 1px;margin-left:5px;<?php if($id==6):?>margin-top: 1px;<?php endif;?>">
                        <?php if($id==6):?>
                                <!--<a href= "<?php echo $base_url."abouts/returnpolicy";?>" style="color:#3399fe;">Easy Returns, Free Replacement:
                                <span style="border: #3399fe 1px solid;padding:2px;font-size:11px;"> See detail </span></a>
                                <br>
                                <a href= "<?php echo $base_url."abouts/shippingpolicy";?>" style="color:#3399fe;">Free Shippings: 
                                <span style="border: #3399fe 1px solid;padding:2px;font-size:11px;"> See how </span></a>-->
                        <?php elseif($id==3):?>
                                <div id="wrapper3" style="background:white;">
                                        <div id="scroller3">
                                                <ul>                                                            
                                                        <!--    <li class="quickclick"><a href= "<?php //echo $clearancesale;?>" class="linkdeal">Clearance Sale</a></li>-->
                                                        <!-- <li class="quickclick"><a href= "<?php echo $base_url."categories/linkdeal/".$id."?filtertype=below1000";?>" class="linkdeal quickclick">Feature phone below 1000</a></li>-->
                                                                <li class="quickclick"><a href= "<?php echo $base_url."categories/linkdeal/".$id."?filtertype=exclusive";?>" class="linkdeal quickclick">Direct Deals</a></li>
                                                        
                                            </ul>
                                        </div>
                                </div>
                        
<!--                            <span class="glyphicon glyphicon-bookmark"></span>                       -->
                                
                        <?php endif;?>
                </div>
                
                
                <?php //echo strtok($_SERVER["REQUEST_URI"],'?');?>
        </div>
        
        <div class ="col-xs-3" style="padding:0px;">
                <?php if(isset($id)):?>
                                                                <ul class="nav">
                                                                        <li class="tab_layout" style="height: 28px !important;">
                                                                                
                                                                                <div class="dropdown pull-right" style="padding: 4px 4px 0px;">
                                                                                        
                                                                                        <button class="btn btn-default btn-xs dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
                                                                                                
                                                                                                <?php if($id == 6 && (isset($brands) && !empty($brands)) || (isset($subcategories) && !empty($subcategories))):?>                                                                                               
                                                                                                        <i class="glyphicon glyphicon-sort"></i> SORT
                                                                                                <?php else:?>
                                                                                                         FILTER
                                                                                                <?php endif;?>
                                                                                        </button>
                                                                                        <ul class="dropdown-menu dropdown-menu-right accmenu" role="menu" aria-labelledby="dropdownMenu1" style="right:4px;">
                                                                                        
                                                                                        <?php if($id == 6 && (isset($brands) && !empty($brands)) || (isset($subcategories) && !empty($subcategories))):?>
                                                                                        <?php else:?>   
                                                                                                <?php if($id == 6):?>
                                                                                                        <li role="presentation" class="menu-item"><a role="menuitem" tabindex="-1" href="<?php echo $base_url;?>subcategoryfilter/subcategory<?php if(isset($id)):?>/<?php echo $id;?><?php endif;?>/?<?php echo $_SERVER["QUERY_STRING"];?>" >By Product <span class="greyarrow"></span></a></li>
                                                                                                <?php endif;?>
                                                                                                <li role="presentation" class="menu-item"><a role="menuitem" tabindex="-1" href="<?php echo $base_url;?>filter/brand<?php if(isset($id)):?>/<?php echo $id;?><?php endif;?>/?<?php echo $_SERVER["QUERY_STRING"];?>">By Brands <span class="greyarrow"></span></a></li>
                                                                                                <li role="presentation" class="dropdown-header menu-item" style="padding-left: 20px;">SORT</li>
                                                                                                
                                                                                        <?php endif;?>
                                                                                                <li role="presentation" class="menu-item <?php if(isset($sortlabel) && $sortlabel == 'bestseller'):?>selected<?php endif;?>"><a role="menuitem" tabindex="-1" href="?sort=bestSellerPoints&direction=-1<?php if(isset($filterstr)):?><?php echo $filterstr;?><?php endif;?><?php if(isset($whatfirst) && !empty($whatfirst)):?><?php echo "&whatfirst=".$whatfirst;?><?php endif;?>">Bestsellers</a></li>
                                                                                                <li role="presentation" class="menu-item<?php if(isset($sortlabel) && $sortlabel == 'pricelow'):?> selected<?php endif;?>"><a role="menuitem" tabindex="-1" href="?sort=available_price&direction=1<?php echo $filterstr;?><?php if(isset($whatfirst) && !empty($whatfirst)):?><?php echo "&whatfirst=".$whatfirst;?><?php endif;?>">Price- Low to High</a></li>
                                                                                                <li role="presentation" class="menu-item<?php if(isset($sortlabel) && $sortlabel == 'pricehigh'):?> selected<?php endif;?>"><a role="menuitem" tabindex="-1" href="?sort=available_price&direction=-1<?php echo $filterstr;?><?php if(isset($whatfirst) && !empty($whatfirst)):?><?php echo "&whatfirst=".$whatfirst;?><?php endif;?>">Price- High to Low</a></li>      
                                                                                                <li role="presentation" class="menu-item<?php if(isset($sortlabel) && $sortlabel == 'recommended'):?> selected<?php endif;?>"><a role="menuitem" tabindex="-1" href="?sort=-1<?php echo $filterstr;?><?php if(isset($whatfirst) && !empty($whatfirst)):?><?php echo "&whatfirst=".$whatfirst;?><?php endif;?>">Recommended</a></li>
                                                                                                
                                                                                        </ul>
                                                                                </div>
                                                                                
                                                                        </li>   
                                                                </ul>
                                                                
                <?php else:?>
                                &nbsp;
                <?php endif;?>
        </div>  
        
        
</div>
<?php //endif;?>
        
        <?php if($id==6 && $subcategories && array_key_exists($subcategories, $searchableSubCategories)):?>
                <div style="padding-top: 1px;background:white;">
                
                    <div class= "inner-addon left-addon" style='padding-top:4px;position: relative;margin-top:1px;'>
                        <i class="glyphicon glyphicon-search"></i>
                        <input type="text" id= "searchforbrand" placeholder="Search brands or models"  class="input-block-level">
                    </div>
                    
                    <hr style="margin-top:0px;margin-bottom:4px;">
                </div>
        <?php //elseif(isset($searchfor) && !empty($searchfor)):?>
<!--    <div id= "moreitem">     -->
<!--        <a href="<?php //echo $_SERVER['HTTP_REFERER'];?>"><span style="padding:3px" class="glyphicon glyphicon-arrow-left"></span>Showing <?php //echo $searchfor;?> items</a>-->
<!--    </div> -->
        <?php endif;?>


<div class="text-center hidden" id="searchloader">
    <br><br><br><br>
          <div class="hexdots-loader"></div>         
</div>



<div class="content" id="regularcontent">

  <div class="row scroll scrollselector">
        <?php echo $this->element('deals');?>    
  </div>
  <script type="text/javascript">
        function getCookie(cname,forceCookie) {
            if(typeof(Storage) !== "undefined" && !forceCookie) {
                return localStorage.getItem(cname);
            } else {       
                var name = cname + "=";
                var ca = document.cookie.split(';');
                for(var i=0; i<ca.length; i++) {
                    var c = ca[i];
                    while (c.charAt(0)==' ') c = c.substring(1);
                    if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
                }
                return "";
            }
        }
        if(getCookie('fresh', true)=="0"){       
                if(typeof localStorage.pages != "undefined") {
                        document.getElementsByClassName('scrollselector')[0].innerHTML = localStorage.pages;
                        localStorage.removeItem('pages');
                }
        }
  </script>
  
</div>
 
<div class='content hidden' id='searchedcontent'>

</div>

<!-- <script type="text/javascript" src="/js/jquery.jscroll.js"></script> -->
<script type="text/javascript" src="/js/jquery.jscroll.min.js?v=<?php echo $staticversion;?>"></script>
<script type="text/javascript" src="/js/profittill.js?v=<?php echo $staticversion;?>"></script>
<script type="text/javascript" src="/js/checkout.js?v=<?php echo $staticversion;?>"></script>
<link rel="stylesheet" href="/css/hexdots.css" type="text/css">