forked from raylight75/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
def535a
commit 21c9617
Showing
1 changed file
with
87 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,95 @@ | ||
// Ajax pagination | ||
$(window).on('hashchange', function() { | ||
if (window.location.hash) { | ||
var page = window.location.hash.replace('#', ''); | ||
if (page == Number.NaN || page <= 0) { | ||
return false; | ||
} else { | ||
getProducts(page); | ||
$(window).on('hashchange', function () { | ||
if (window.location.hash) { | ||
var page = window.location.hash.replace('#', ''); | ||
if (page == Number.NaN || page <= 0) { | ||
return false; | ||
} else { | ||
getProducts(page); | ||
} | ||
} | ||
} | ||
}); | ||
$(function() { | ||
$('#ajaxproducts').on('click', '.pagination a', function (e) { | ||
var url = $(this).attr('href'); | ||
var hashes = url.split("?")[1]; | ||
var page = $(this).attr('href').split('page=')[1]; | ||
getProducts(hashes.split('page').reverse()[1],page); | ||
e.preventDefault(); | ||
}); | ||
$(function () { | ||
$('#ajaxproducts').on('click', '.pagination a', function (e) { | ||
var url = $(this).attr('href'); | ||
var hashes = url.split("?")[1]; | ||
var page = $(this).attr('href').split('page=')[1]; | ||
getProducts(hashes.split('page').reverse()[1], page); | ||
e.preventDefault(); | ||
}); | ||
}); | ||
function getProducts(data,page) { | ||
$.ajax({ | ||
url : '?' + data + 'page='+ page, | ||
type: "GET", | ||
dataType: 'json', | ||
}).done(function (data) { | ||
$('#ajaxproducts').html(data); | ||
}).fail(function () { | ||
alert('Posts could not be loaded.'); | ||
}); | ||
function getProducts(data, page) { | ||
$.ajax({ | ||
url: '?' + data + 'page=' + page, | ||
type: "GET", | ||
dataType: 'json', | ||
}).done(function (data) { | ||
$('#ajaxproducts').html(data); | ||
}).fail(function () { | ||
alert('Posts could not be loaded.'); | ||
}); | ||
} | ||
// End Ajax pagination | ||
$(function() { | ||
$('#categories input:checkbox').on('click', function() { | ||
if ($(this).is(":checked")) | ||
$("#categories").submit(); | ||
if ($('input:checkbox').is(':checked')) | ||
$("#categories").submit(); | ||
}); | ||
$(".submit").hide(); | ||
}); | ||
$("input[name=price]").on('change', function() { | ||
$("input[name=price]").not(this).prop('checked', false); | ||
}); | ||
$("input[name=name]").on('change', function() { | ||
$("input[name=name]").not(this).prop('checked', false); | ||
//Start checkbox filter | ||
$(document).ready(function () { | ||
function showValues() { | ||
var baseUrl = document.location.origin; | ||
var url = $(this).attr('href'); | ||
console.log(url); | ||
var segments = url.split( '/' ); | ||
var parentId = segments[3]; | ||
var categ = ''; | ||
var size = ''; | ||
$("input:checkbox").each(function () { | ||
categ = $('input[name="categ[]"]:checked').serialize(); | ||
size = $('input[name="size[]"]:checked').serialize(); | ||
}); | ||
var main_string = categ+"&"+size; | ||
//main_string = main_string.substring(1, main_string.length) | ||
console.log(main_string); | ||
console.log(parentId); | ||
|
||
$.ajax({ | ||
type: "GET", | ||
url: baseUrl + "/filter/products/"+parentId, | ||
data: main_string, | ||
dataType: 'json', | ||
}).done(function (data) { | ||
$('#ajaxproducts').html(data); | ||
}).fail(function () { | ||
alert('Items could not be loaded.'); | ||
}); | ||
} | ||
$("input[type='checkbox']").on("click", showValues); | ||
//console.log(categ); | ||
}); | ||
//End checkbox filter | ||
/*$(function() { | ||
$('#categories input:checkbox').on('click', function() { | ||
if ($(this).is(":checked")) | ||
$("#categories").submit(); | ||
if ($('input:checkbox').is(':checked')) | ||
$("#categories").submit(); | ||
}); | ||
$(".submit").hide(); | ||
}); | ||
$("input[name=price]").on('change', function() { | ||
$("input[name=price]").not(this).prop('checked', false); | ||
}); | ||
$("input[name=name]").on('change', function() { | ||
$("input[name=name]").not(this).prop('checked', false); | ||
});*/ | ||
/* $(document).ready(function(){ | ||
$("li.pagination a, li.prev a, li.next a, li.active a ").click(function() { | ||
$.ajax({ | ||
type: "GET", | ||
url: $(this).attr('href'), | ||
dataType: 'html', | ||
success: function(html){ | ||
var $page_data = $(html); | ||
$('#container').html($page_data.find('div#container')); | ||
} | ||
}); | ||
return false; | ||
}); | ||
}); */ | ||
$("li.pagination a, li.prev a, li.next a, li.active a ").click(function() { | ||
$.ajax({ | ||
type: "GET", | ||
url: $(this).attr('href'), | ||
dataType: 'html', | ||
success: function(html){ | ||
var $page_data = $(html); | ||
$('#container').html($page_data.find('div#container')); | ||
} | ||
}); | ||
return false; | ||
}); | ||
}); */ |