Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on Aug 7, 2008
  1. @pudge
  2. @pudge

    Add myask()

    pudge authored
  3. @pudge

    Whitespace

    pudge authored
Commits on Aug 6, 2008
  1. TagUI work, ready for all admin use

    authored
    ...sorry for the giant commit; too close to deadline to split this one up :-(
  2. @jamiemccarthy
Commits on Aug 5, 2008
  1. @tvroom
  2. @tvroom
  3. @tvroom

    Updates for metamod view

    tvroom authored
Commits on Aug 4, 2008
  1. Teach firehose to hold focus around updates; autocomplete ESC=clear, …

    authored
    …SPACE=submit
    
    Caveat: saving/restoring focus only applies to the tag input field.  If the
    autocompleter menu is up, it will still drop, and drop the selection to the end.
    This badness is in the autocompleter itself, and will take more time (perhaps
    than it is worth) to sort it out.
  2. @tvroom
Commits on Aug 3, 2008
  1. Smarter nearest_parent() -- :first _may_ be fast, but each+early exit…

    authored
    … _must_ be
    
    jQuery's $.each and $().each functions support early termination.  If your
    callback returns false, the loop is done.  One hopes that's how ':first' is
    implemented internally ... but for this case, it's worth ensuring because the
    consequences are horrible.  Imagine:
    
    	$this.nearest_parent(':has(span)')
    
    If the search for ':has(span)' is performed at each successive parent, and only
    _then_ a ':first' selected, you've just done an imense amount of work
    (potentially exponential relative to the depth of the tree).  Since this is
    exactly the kind of search for which I require nearest_parent(), it's worth
    avoiding the bad case.
  2. Add global and jQuery-specific list splitting functions 'separate'

    authored
    jQuery and Perl have a similar 'grep' function applicable to arrays.  It returns
    a new array comprising exactly the elements for which the supplied predicate
    evaluates to true. The annoying part is that sometimes you want to do one thing
    to all the elements that match, and a different thing to all those that don't
    --- particularly annoying if the thing you want to do is send the filtered lists
    to different places.
    
    For arbitrary JS arrays, that problem can now be solved with 'separate':
    
    	var passed, failed;
    	[ passed, failed ] = separate(list, fn);
    
    passed and failed are now lists comprising excactly the elements from the
    original list that passed or failed, respectively, the test in fn.  E.g.,
    
    	var evens, odds;
    	[evens, odds] = separate([1, 2, 3, 4, 5], function(v){
    		return !(v % 2)
    	});
    
    	// evens == [2, 4]; odds == [1, 3, 5]
    
    I've provided similar functionality for jQuery by extending it with a new
    function of the same name.  The single argument can be either a function,
    as above, or else a jQuery selector:
    
    	[ $good, $bad ] = $(expr).separate(expr)
    
    	[ $articles, $others ] = $(expr).separate('.article')
  3. Bugfix: broken use of jQuery made my click handler over eager

    authored
    $().is() cannot look backwards, at least as formulated in this snippet:
    
    	$target.is('.tmenu li')
    
    I meant that to ask if the target of the click was an <li> child of a .tmenu.
    jQuery always answers true.  A right way to ask this question is:
    
    	$target.parent().is('.tmenu')
    
    You have been warned.
  4. Bugfix: broken decision has made the [+] button collapse entries

    authored
    My logic error using jQuery.  Even an empty jQuery wrapped selection is 'true';
    use either .is or .length when you want a boolean result.
  5. Tag widget visibility fixes

    authored
    Make background transparent.  Tag displays now mark inserted tags 'p' (for
    private) on creation, so nothing will show until it's known that the tag _isn't_
    actually private.
  6. The nod/nix reasons widget _doesn't_ have to be a special case

    authored
    Tag displays now notice when they become empty/non-empty, and mark themselves
    with the CSS class 'no-tags', accordingly.  CSS rules can now hide them.  When
    the user nods/nixs, the context is set and the reasons appear.  When the user
    clicks a reason, the context is set again, but this time to something that
    empties the nod/nix reasons display... and because it's empty, it immediately
    gets marked as such, and the CSS hides it.
    
    Tried to pick some more sensible names for some things.
  7. toggleClassTo(css_class, expr): a new operation on a jQuery selection

    authored
    I'm tired of writing code like:
    
    	if ( some_test )
    		$this.addClass('foo');
    	else
    		$this.removeClass('foo');
    
    Even the short form leaves me cold:
    
    	$this[ some_test ? 'addClass' : 'removeClass' ]('foo')
    
    This seems like such a common operation.  Why doesn't jQuery have it built in?
    Well now it does (an example from tagui.js):
    
    	$(this).toggleClassTo('no-tags', if_empty)
    
    Named to tie in with jQuery's factory built-in toggleClass('foo'), which can be
    expressed as (at least for an individual item):
    
    	$this.toggleClassTo('foo', ! $this.hasClass('foo'))
Commits on Aug 2, 2008
  1. Too many notes! One (smarter) click-handler per display instead of pe…

    authored
    …r tag
    
    Thus a single firehose entry will have around six* (that stay put) instead of
    twenty-five (that come and go as the tags change).  The changed logic in
    click_tag() should be clearer and more robust, as well.
    
    * on: (1) the nod/nix capsule, (2) nod/nix "reasons" display, (3) user, (4) top,
      (5) and system tag displays, (6) the bottom "suggestions" display
  2. A smarter tag command `normalizer'

    authored
    The old normalizer was used to perform three fixes to a string of tag commands:
    - s/!nod/nix/g; s/!nix/nod/g (as nod and nix are already opposites of each
      other, and aren't set up to be opposites in the '!' way)
    - any occurance of 'nod' becomes 'nod -nix' (similarly when starting with 'nix')
      to handle a funny situation where---believe it or not---an item can be both
      nodded and nixed at once
    - for feedback only, to remove nod/nix (of every spelling) from the string to
      prevent it from showing up in the user tag display
    
    This commit adds additional optimization tasks:
    - remove duplicates or opposites, yields minmal sequence for the same result
    - optionally filter against your current tags (so you don't try to add again, or
      to deactivate a tag you don't actually have)
    - this means an entire command sequence could be "optimized away", so now check
      for that and don't bother sending an ajax request
    
    normalize_tag_command() is fairly heavily commented, so it looks bulkier than it
    is.  The meat is in the $.map near the end.  Everything above that is really
    just about massaging the input parameters.
    
    Also added: cached_user_tags(), which finds a descendent user tag display and
    extracts those tags (along with a 'nod' or a 'nix' if you've voted).  This is
    how normalize_tag_commands() gets a list to filter against if you passed in a
    jQuery selector for its second param.
  3. Rename: s/split_if_string/list_as_array/; add counter-part, list_as_s…

    authored
    …tring
    
    All the tagui code deals with lists of tags and/or commands.  Most of the code
    doesn't care whether that list is represented by an array of strings or by a
    single string delimited by whitespace (or, where order is unimportant, as a hash
    of the individual strings).  It usually has to end up, though, as an array for
    iteration or manipulation.  This function gives me the flexibility to write
    functions that can be anywhere in the processing stack: who ever gets the list
    first turns it into an array.  Everybody below benefits.
    
    The new name, list_as_array, and the counter-part function, list_as_string, make
    the model more obvious (at least to me).
  4. Teach nearest_parent to provide nearest parents for _each_ wrapped el…

    authored
    …ement
    
    nearest_parent (lacking a previous description in commit messages) finds the
    nearest enclosing dom element (including the starting element) that matches the
    provided selector.  For example, to find the containing firehose entry from a
    click handler:
    
      $(event.target).nearest_parent('[id^=firehose-]')
    
    That works even if the event target happened to be the firehose entry itself.
    
    To find the clicked tag:
    
      $(event.target).nearest_parent(':has(span.tag)')
    
    I use this function everywhere to get to the DOM element that has the tag ajax
    code (usually the firehose entry itself), e.g.,
    
      $(this).nearest_parent('[tag-server]')
    
    This improvement means that you could find a minimal set of parents across a
    collection of elements, e.g., get all the firehose entries associated with the
    elements you're currently holding, even when elements share the same entry as an
    ancestor.
    
    - ':first' may provide better performance than .eq(0)
    - this.map lets me handle wrapped elements individually
    - $.unique makes the answer minimal
    - this.pushStack makes .end() do the right thing after using nearest_parent
  5. Use ':first' instead of .eq(0) when reasonable

    authored
    With $(expr).eq(0), you've already done the work (e.g., finding 200 different
    DOM elements).  With $('expr:first'), jQuery at least has the _opportunity_ to
    stop the search immediately.  I don't know that it _does_, but if not now it may
    in the future.  And perhaps $('.article:first') is more obvious to the reader
    than $('.article').eq(0).
  6. Delete unused functions

    authored
    - refresh_tags
    - close_tag_widget_event
  7. Bugfix: jQuery's autocompleter doesn't handle "story\t999" the same w…

    authored
    …ay YAHOO's does
    
    Jamie helpfully sends a score along with each tag.  jQuery's autocompleter needs
    each return row to contain only a single item.  This probably only matters
    because we have 'autofill' turned on, so the first match immediately gets
    stuffed into the input field, but unmunged by our oh-so-careful formatItem().
    
    In fact, we now don't even need our own formatItem.
Commits on Aug 1, 2008
  1. @jamiemccarthy
  2. @jamiemccarthy

    Comment neediness fixes

    jamiemccarthy authored
    Allow metanod/metanix to adjust comment neediness, as well as nod/nix.
    Also tweak the algorithm a little so agreement means less-needy and
    controversy means more.
  3. @tvroom

    Fixed metanod/metanix marking

    tvroom authored
  4. @pudge

    update

    pudge authored
  5. @jamiemccarthy

    add tagboxes/Metamod

    jamiemccarthy authored
  6. @jamiemccarthy
  7. @jamiemccarthy
  8. @jamiemccarthy

    Add minor debug warning

    jamiemccarthy authored
Commits on Jul 31, 2008
  1. tag-widget: punch-list, renames, `tag-server' element, contexts, spli…

    authored
    …t widget, no tmpl for server response
Something went wrong with that request. Please try again.