-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposts2.php
124 lines (116 loc) · 3.88 KB
/
posts2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<link rel="stylesheet" href="style_posts.css"/>
<script>
$('document').ready(function() {
$('#posts_feed').load('posts_search.php?search=<?php if(isset($_GET['search'])) { echo $_GET['search']; } ?>&all=on', function() { $('.loader').hide(); });
$('#all').prop('checked', true);
$('#real_form').submit(function(e) {
e.preventDefault();
});
$('#search').keypress(function(e) {
if(e.which == 13) {
$('#send').trigger('click');
}
});
$('#posts_feed').on('click', '.article', function() {
if ($(this).attr('id').startsWith('h')) {
window.open($(this).attr('id'));
} else {
$('.loader').show();
$('#content').load('post_display.php?id='+$(this).attr("id"), function() { $('.loader').hide(); });
history.pushState({url: 'post_display.php?id='+$(this).attr("id")}, "", "/posts/"+$(this).attr("id"), false);
}
});
$("#all").change(function() {
if(this.checked) {
$('.checkbox').prop('checked', false);
}
});
$(".checkbox").change(function() {
if (this.checked) {
$('#all').prop('checked', false);
}
});
$('#send').click(function() {
$('.loader').show();
history.pushState({url: 'posts.php?search='+$('#search').val()+'&all=on'}, "", "/posts/"+$('#search').val());
$.get('posts_search.php', $('#real_form').serialize()).done(function(data) {
$('#posts_feed').empty().append(data);
$('.loader').hide();
});
});
$('#posts_feed').on('click', '.link_cat', function(e) {
e.preventDefault();
e.stopPropagation();
$('#search').val("");
$('#all').prop('checked', false);
$('.checkbox').prop('checked', false);
$('input[value="'+$(this).attr('href')+'"]').prop('checked', true);
$('#send').trigger('click');
});
$.fn.animateRotate = function(angle, duration, easing, complete) {
var args = $.speed(duration, easing, complete);
var step = args.step;
return this.each(function(i, e) {
args.complete = $.proxy(args.complete, e);
args.step = function(now) {
$.style(e, 'transform', 'rotate(' + now + 'deg)');
if (step) return step.apply(e, arguments);
};
$({deg: 0}).animate({deg: angle}, args);
});
};
$('#display_search').click(function() {
var one, two;
if ($(this).hasClass("icon-arrow--down")) {
one = "icon-arrow--down";
two = "icon-arrow--up";
$('#form').slideDown();
} else {
$('#form').slideUp();
two = "icon-arrow--down";
one = "icon-arrow--up";
}
$(this).animateRotate(180, 500, "swing", function() {
$(this).removeClass(one).addClass(two).css("transform", "");
});
});
});
</script>
<style>
</style>
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$categories = json_decode($_SESSION['categories'], true);
$categories['rss'] = "Flux RSS";
?>
<div id="content_posts">
<div id="container" class="grid-2-small-1">
<div>
<h1 id="title" >Billets et actualités</h1>
</div>
<div id="search_block">
<div id="mobile_search" class="flex-container"><span class="item-fluid">Recherche<i class="fa fa-search" style="padding-left: 5px;"></i></span><i id="display_search" class="icon-arrow--down item-last" style="cursor: pointer"></i></div>
<div id="form" class="right">
<form id="real_form">
<div id="field" class="flex-container">
<input value="<?php if (isset($_GET['search'])) { echo $_GET['search']; } ?>" type="search" class="item-fluid" name="search" id="search"/>
<div class="w10 flex-container"><i class="fa fa-search item-center" id="launch" ></i></div>
</div>
<table id="selector">
<tr><td><input type="checkbox" name="all" id="all" class="switch"/></td><td>Tout</td></tr>
<?php
foreach ($categories as $key=>$value) {
?><tr><td><input type="checkbox" class="checkbox" name="cat[]" value="<?php echo $key; ?>"></td><td><?php echo $value; ?></td></tr><?php
}
?>
</table>
<button type="button" class="btn--inverse" id="send"><i class="fa fa-search fa-x"></i></button>
</form>
</div>
</div>
</div>
<div id="posts_feed" >
</div>
</div>