6

1

I wrote this today and figured I'd share the love since I've used your examples so much in the last couple of weeks while writing BugMonkey scripts and full-featured plugins.

This just moves the 'My Filters' section above 'Shared Filters' in the Filters dropdown. Tested in 8.3.42, but it likely works in other versions.

name:          Filter Re-Sorter
description:   Puts 'My Filters' above 'Shared Filters' in the Filters dropdown
author:        Daniel Jennings
version:       1.0.0.0

js:

   var $divs = $('#filterPopup div');
   if (!$divs) return;

   $filterListDiv = $($divs[0]);
   //console.log($filterListDiv);
   var deletedItems = [];
   var isDeleting = false;
   $filterListDiv.children().each(function () {
      var $this = $(this);
      if ($this.text() == 'Shared Filters')
         isDeleting = true;
      var thisTagName = $this.get(0).tagName;
      if (isDeleting || $this.attr('href') == "default.asp?pg=pgFilter") {
         deletedItems.push(this);
         $this.remove();
      }
      if (isDeleting && thisTagName == 'HR') {
         isDeleting = false;
      }
   });
   $filterListDiv.append(deletedItems);

I'm a bit of a jQuery noob, so I might've done things a little bit weird, but it works, so if this is helpful, let me know here :)

flag
Cool! FWIW, $this.get(0).tagName == "HR" can be abbreviated to $this.is("hr") – Daniel LeCheminant May 6 2011 at 12:42
Much appreciated. :) I'm a YUI3 kind of guy, so this jQuery stuff is a bit new to me. – Daniel Jennings May 10 2011 at 19:55

1 Answer

1

Nice! Thanks for the contribution.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.