aboutsummaryrefslogtreecommitdiff
path: root/data/assets/js
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-05-24 21:14:13 -0400
committerPaul Duncan <pabs@pablotron.org>2016-05-24 21:14:13 -0400
commitc5da1e620c07697c2b7b5d4b51db73ef0fc143e4 (patch)
tree395c5d57bf9025d8ffc544fb2f4c32efc5efc883 /data/assets/js
parentfbff52e48d4591a752d83fbebb49a3a355eef5ae (diff)
downloadguff-c5da1e620c07697c2b7b5d4b51db73ef0fc143e4.tar.bz2
guff-c5da1e620c07697c2b7b5d4b51db73ef0fc143e4.zip
add state filter and dropdown.js
Diffstat (limited to 'data/assets/js')
-rw-r--r--data/assets/js/admin/tabs/posts.js23
-rw-r--r--data/assets/js/dropdown.js29
2 files changed, 34 insertions, 18 deletions
diff --git a/data/assets/js/admin/tabs/posts.js b/data/assets/js/admin/tabs/posts.js
index 6fc0afd..5b27cf6 100644
--- a/data/assets/js/admin/tabs/posts.js
+++ b/data/assets/js/admin/tabs/posts.js
@@ -30,9 +30,10 @@ jQuery(function($) {
.find('.loading').toggleClass('hidden');
send('post/get_posts', {
- post_type: $('#posts-filter-type li.active a').data('id'),
- q: $('#posts-q').data('q'),
- page: 1,
+ type: $('#posts-filter-type li.active a').data('id'),
+ state: $('#posts-filter-state li.active a').data('id'),
+ q: $('#posts-q').data('q'),
+ page: 1,
}).always(function() {
$('#posts-reload').removeClass('disabled')
.find('.loading').toggleClass('hidden');
@@ -99,21 +100,7 @@ jQuery(function($) {
reload();
});
- $('.posts-filter-menu').on('click', 'a', function() {
- var data = $(this).data(),
- ul = $(this).parents('ul'),
- is_default = (data.id == ul.data('default'));
-
- ul.find('li').removeClass('active');
- $(this).parents('li').addClass('active');
- ul.prev('a')
- .toggleClass('btn-default', is_default)
- .toggleClass('btn-primary', !is_default)
- .find('span').text(data.text);
-
- // hide dropdown
- $('body').trigger('click');
-
+ $('.posts-filter-menu').on('guff.choose', function() {
// reload posts
reload();
diff --git a/data/assets/js/dropdown.js b/data/assets/js/dropdown.js
new file mode 100644
index 0000000..1ab5785
--- /dev/null
+++ b/data/assets/js/dropdown.js
@@ -0,0 +1,29 @@
+jQuery(function($) {
+ "use strict";
+
+ $('.guff-dropdown').on('click', 'a', function() {
+ var data = $(this).data(),
+ ul = $(this).parents('ul'),
+ is_default = (data.id == ul.data('default'));
+
+ // update ui
+ ul.find('li').removeClass('active');
+ $(this).parents('li').addClass('active');
+ ul.prev('a')
+ .toggleClass('btn-default', is_default)
+ .toggleClass('btn-primary', !is_default)
+ .find('span').text(data.name);
+
+ // hide dropdown
+ $('body').trigger('click');
+
+ // trigger choose
+ $(this).trigger({
+ type: 'guff.choose',
+ item: $(this).data(),
+ });
+
+ // stop event
+ return false;
+ });
+});