Commit 41acec84 authored by Vasyl Bodnaruk's avatar Vasyl Bodnaruk

fix bug in filter

parent 6c402101
...@@ -149,28 +149,37 @@ $(document).ready(function() { ...@@ -149,28 +149,37 @@ $(document).ready(function() {
// console.log(data); // console.log(data);
// ajaxPost('/news/', data); // ajaxPost('/news/', data);
}); });
// $(actionView).on('click', function(e) {
// e.preventDefault();
// var data = actionData(this);
// ajaxPost('/news/', data);
// });
//
// $(actionEdit).on('click', function(e) {
// e.preventDefault();
// var data = actionData(this);
// ajaxPost('/news/', data);
// });
}); });
//$('.text-white').on('click', function(e) { function getUrlParameter(name) {
// var getHref = $(this).attr('href'); name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
// var url = window.location.href; var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
// window.location.href = url + getHref; var results = regex.exec(location.search);
// console.log(window.location.search) return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, ' '));
// e.preventDefault(); };
//
//}) $('.text-white').on('click', function(e) {
e.preventDefault();
var from = getUrlParameter('from_date');
var to = getUrlParameter('to_date');
var media = getUrlParameter('media');
var word = getUrlParameter('search');
var order = getUrlParameter('order_by');
var reverse = getUrlParameter('reverse');
var res = '?';
if (from){res += 'from_date=' + from + '&'}
if (to){res += 'to_date=' + to + '&'}
if (media){res += 'media=' + media + '&'}
if (word){res += 'search=' + word + '&'}
var orderName = $(this).attr('href').replace("?order_by=", "")
if (order == orderName){res +='order_by=' + orderName + '&' + 'reverse=' + '1&'} else
{
res += 'order_by=' + orderName + '&'
}
window.location.href = res;
})
// Index Page // Index Page
......
...@@ -45,28 +45,26 @@ ...@@ -45,28 +45,26 @@
{% paginate news %} {% paginate news %}
{{ request.get_full_path }}
{{ request.GET.itervalues }}
<form class="form"> <form class="form">
<table class="table table-hover"> <table class="table table-hover">
<thead class="thead-inverse"> <thead class="thead-inverse">
<tr> <tr>
<th><a class="text-white" href="order_by=title{% if request.GET.order_by == 'title' and request.GET.reverse != '1' %}&amp;reverse=1{% endif %}"> <th><a class="text-white" href="?order_by=title">
Title {% if request.GET.order_by == 'title' and request.GET.reverse != '1' %}&uarr; Title {% if request.GET.order_by == 'title' and request.GET.reverse != '1' %}&uarr;
{% elif request.GET.order_by == 'title' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th> {% elif request.GET.order_by == 'title' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th>
<th><a class="text-white" href="?order_by=media_id{% if request.GET.order_by == 'media_id' and request.GET.reverse != '1' %}&amp;reverse=1{% endif %}"> <th><a class="text-white" href="?order_by=media_id">
Media {% if request.GET.order_by == 'media_id' and request.GET.reverse != '1' %}&uarr; Media {% if request.GET.order_by == 'media_id' and request.GET.reverse != '1' %}&uarr;
{% elif request.GET.order_by == 'media_id' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th> {% elif request.GET.order_by == 'media_id' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th>
<th><a class="text-white" href="?order_by=type_id{% if request.GET.order_by == 'type_id' and request.GET.reverse != '1' %}&amp;reverse=1{% endif %}"> <th><a class="text-white" href="?order_by=type_id">
Type {% if request.GET.order_by == 'type_id' and request.GET.reverse != '1' %}&uarr; Type {% if request.GET.order_by == 'type_id' and request.GET.reverse != '1' %}&uarr;
{% elif request.GET.order_by == 'type_id' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th> {% elif request.GET.order_by == 'type_id' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th>
<th><a class="text-white" href="?order_by=region_id{% if request.GET.order_by == 'region_id' and request.GET.reverse != '1' %}&amp;reverse=1{% endif %}"> <th><a class="text-white" href="?order_by=region_id">
Region {% if request.GET.order_by == 'region_id' and request.GET.reverse != '1' %}&uarr; Region {% if request.GET.order_by == 'region_id' and request.GET.reverse != '1' %}&uarr;
{% elif request.GET.order_by == 'region_id' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th> {% elif request.GET.order_by == 'region_id' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th>
<th><a class="text-white" href="?order_by=publish_date{% if request.GET.order_by == 'publish_date' and request.GET.reverse != '1' %}&amp;reverse=1{% endif %}"> <th><a class="text-white" href="?order_by=publish_date">
Publish date {% if request.GET.order_by == 'publish_date' and request.GET.reverse != '1' %}&uarr; Publish date {% if request.GET.order_by == 'publish_date' and request.GET.reverse != '1' %}&uarr;
{% elif request.GET.order_by == 'publish_date' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th> {% elif request.GET.order_by == 'publish_date' and request.GET.reverse == '1' %}&darr;{% endif %}</a></th>
</tr> </tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment