Skip to content

Commit

Permalink
long overdue update of this plugins git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiemoya committed Jul 20, 2012
1 parent 9504c54 commit dcc1bce
Show file tree
Hide file tree
Showing 4 changed files with 357 additions and 134 deletions.
93 changes: 51 additions & 42 deletions media-categories-script.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@


/**
* jQuery for Media Categories plugin
*
* @author Eddie Moya
* @since 1.1
*
*/

jQuery(document).ready(function($){

$('tr.category_metabox input').live('click', function(){

var form_fields = $(this).closest("tbody");

var checked = form_fields.find(".category_metabox input:checked");
var slug_list = '';

checked.each(function(index){

if(slug_list.length > 0)
slug_list += ',' + $(this).val();
else
slug_list += $(this).val();
$.each(taxonomy, function(index, tax){

$('.media-upload-form tr.'+ tax + '').hide();
$('.media-upload-form tr.' + tax + '_metabox input').live('click', function(){

var form_fields = $(this).closest("tbody");

var checked = form_fields.find("." + tax + "_metabox input:checked");
var slug_list = '';

checked.each(function(index){

if(slug_list.length > 0)
slug_list += ',' + $(this).val();
else
slug_list += $(this).val();
});

form_fields.find("tr."+ tax +" > td.field > input.text").val(slug_list);
})

$.extend($.expr[":"], {
"icontains": function(elem, i, match, array) {
return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
/**
* The following javascript is borrowed (with few modifications) from Jason Corradino's
* 'Searchable Categories' plugin. It allows the category metabox to be filtered
* as the user types. To do this with your category meta boxes on pages and posts,
* download his plugin.
*
* http://wordpress.org/extend/plugins/searchable-categories/
*/

$('#' + tax + '-search').keyup(function() {
var val = $('#' + tax + '-search').val();
var lis = $("#"+ tax +"checklist li");
lis.hide();

// find li labels's containing term, then back to parent li
var containingLabels = $("#"+ tax +"checklist label:icontains('" + val + "')");
containingLabels.closest('li').find('li').andSelf().show();
containingLabels.parents('#'+ tax +'checklist li').show();
});

form_fields.find("tr.category > td.field > input.text").val(slug_list);
})

$.extend($.expr[":"], {
"icontains": function(elem, i, match, array) {
return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
/**
* The following javascript is borrowed from Jason Corradino's 'Searchable Categories' plugin.
* It allows the category metabox to be filtered as the user types. To do this with your
* category meta boxes on pages and posts, download his plugin.
*
* http://wordpress.org/extend/plugins/searchable-categories/
*/

$('#catsearch').keyup(function() {
var val = $('#catsearch').val(), lis = $("#categorychecklist li");

lis.hide();

// find li labels's containing term, then back to parent li
var containingLabels = $("#categorychecklist label:icontains('" + val + "')");
containingLabels.closest('li').find('li').andSelf().show();
containingLabels.parents('#categorychecklist li').show();
});

})
3 changes: 2 additions & 1 deletion media-categories-style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.media-upload-form .category-tabs,
.media-upload-form tr.category,
.media-upload-form #category-adder{
.media-upload-form #category-adder,
.media-upload-form .wp-hidden-children{
display:none;
}

Expand Down
Loading

0 comments on commit dcc1bce

Please sign in to comment.