Subversion Repositories SmartDukaan

Rev

Rev 19323 | Rev 19607 | Go to most recent revision | 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');

            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 {
  position: absolute;
  padding: 13px;
  pointer-events: none;
}
.left-addon .glyphicon  { left:  0px;}
.left-addon input  { padding:5px 6px 3px 36px; }
</style>
<?php if($id==6):?>
<div style="background:#58d936;text-align: center;width:100%;font-size:12px;padding:5px 1px 1px 1px;">
        <a href= "<?php echo $base_url."abouts/returnpolicy";?>" style="color:#E9292A;"><strong><u>EASY RETURNS, FREE REPLACEMENT : </strong>
        See detail</a>
        <br>
        <a href= "<?php echo $base_url."abouts/shippingpolicy";?>" style="color:#E9292A;"><strong><u>FREE SHIPPINGS : </strong>
        See how</a>
</div>

<?php endif;?>
<?php //echo strtok($_SERVER["REQUEST_URI"],'?');?>

<?php if($id==6 && $subcategories && array_key_exists($subcategories, $searchableSubCategories)):?>
        <div id= "moreitem">    
            <a onclick="clearFilters()" href="<?php echo $_SERVER['HTTP_REFERER'];?>"><span style="padding:3px" class="glyphicon glyphicon-arrow-left"></span>Showing <?php echo $searchableSubCategories[$subcategories];?></a>
        </div>
    <div class= "inner-addon left-addon" style='padding-top:5px;position: relative;'>
        <i class="glyphicon glyphicon-search"></i>
        <input type="text" id= "searchforbrand" placeholder="Search brands or models"  class="input-block-level">
    </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">