Commits on Nov 3, 2015
  1. @coberschulte

    updated dependencies

    coberschulte committed with Nov 3, 2015
Commits on Jun 18, 2014
  1. switched to node-qunit-phantomjs for headless testing

    in the process, removed ANSI colorization; this didn't work on OS X and
    I couldn't be bothered to track down BSD sed idiosyncrasies
    committed Jun 18, 2014
Commits on Oct 25, 2013
  1. reorganized methods

    moving the low-level `filter` method to the bottom
    committed Oct 25, 2013
Commits on Sep 22, 2013
  1. fixed syntax

    committed Sep 22, 2013
  2. added links to demo and test suite

    committed Sep 22, 2013
Commits on Sep 16, 2013
  1. clarified motivation

    ... hopefully
    committed Sep 16, 2013
  2. added README

    committed Sep 16, 2013
  3. simplified dummy URIs for avatars

    this avoids annoying 404 requests, at least via file:///
    committed Sep 16, 2013
  4. renamed module to match contents

    committed Sep 16, 2013
Commits on Sep 15, 2013
  1. added test coverage

    using Blanket.js (
    currently only supported via the UI
    committed Sep 15, 2013
  2. improved test output

    coloring failures, ignoring testing library in stack traces
    committed Sep 15, 2013
  3. automated testing via PhantomJS

    this also allows for CI usage
    note that the target and dependency were committed prematurely in
    committed Sep 15, 2013
  4. added jQuery-specific API

    this is just a thin wrapper around the existing functionality, thus not
    tying ourselves to this particular ecosystem
    (though we're not currently accepting any arguments/options yet)
    note that this renders moot the issue mentioned in the previous commit
    (3b82708) regarding multiple contact
    committed Sep 15, 2013
  5. turned UI elements into instance attributes

    this simplifies event handlers and eliminates the need for overly
    specific DOM traversal, thus improving encapsulation (e.g. allowing for
    painless future changes in the DOM structure)
    we're now accepting a variety of types for the contacts reference, thus
    making the API more palatable - however, this also allows for multiple
    lists to be passed in (via a selector or jQuery collection), which is
    not supported, but not currently being validated
    note that we don't need to augment event handlers' execution context
    anymore; using `jQuery.proxy` to remap execution context to instance
    committed Sep 15, 2013
  6. refactored event handler augmentation

    seems less noisy this way; functional programming FTW
    `augmentContext` is very similar to `jQuery#proxy` and could be improved
    to match that API, e.g. for `preserveContext(this, "onFilter", "field")`
    committed Sep 15, 2013
  7. provided event handlers with access to the respective instance

    this allows us to track/cache the checkbox state on the instance rather
    than reading it from the DOM every time, thus improving encapsulation
    (and perhaps performance)
    consequently, `filter` is now an instance method with simpler signature
    there are two ways to provide event handlers with access to the
    * using closures as done here
    * annotating the respective container element to retain a reference to
      the instance object (e.g. using `jQuery#data`), which would make it
      event handlers' responsibility to find that container and retrieve the
      instance object
    committed Sep 15, 2013
  8. refactored filtering to separate string comparisons from DOM operations

    this makes it easier to reason about the respective functionality (i.e.
    separation of concerns) - we might even test the string filtering
    note that we're using a class (or perhaps namespaced) function rather
    than an instance method[1] - this is because event handlers don't have
    access to the instance; we'll address that soon
    also note that `startsWith` is neither of those; it's just a free
    utility function - this is inconsistent on purpose to illustrate that we
    have a variety of options in structuring our code
    [1] cf. terminology caveat in previous commit
    committed Sep 15, 2013
  9. started rewriting widget as class

    the benefits of this will become apparent with subsequent commits
    note that this changes the API slightly, but significantly: `new` is now
    we could also have used `Object.create`, a modern - and arguably "purer"
    - alternative to the pseudo-classical syntax:
    pro: no need for `new`, simpler ("just objects")
    contra: no convention for initialization function
    aside: arguably the term "class" is misleading in a prototypal language,
    but I'm not aware of an adequate alternative
    committed Sep 14, 2013
  10. applied revealing module pattern to explicitly expose API

    this way the module internals are isolated from (unaware of) external
    circumstances (in this case: `window`); the module merely returns
    (reveals) its API
    note that it's perfectly fine to use different names for private vs.
    public/exposed variables
    using all-caps as per convention for global variables
    we could also have taken advantage of function hoisting (again),
    returning at the very top:
        "use strict";
        return function(contactList) {
            // ...
        function onFilter(ev) {
            // ...
    whether that benefits or detracts from readability is a matter of
    note that this commit should have happened earlier; right after
    committed Sep 14, 2013
  11. added case sensitivity test

    this is slightly obscure due to nested timeout callbacks - researching
    how to make such things more readable is left as an exercise to the
    reader ( might be a decent starting point)
    committed Sep 14, 2013
  12. refactored and expanded tests

    seems cleaner this way
    also testing checkbox existence now
    arguably though, such initialization tests are overly specific, thus
    hampering future refactoring - but these seem alright, particularly
    given the context of general education
    committed Sep 14, 2013
  13. ensured reliable DOM scope in tests

    this isn't strictly necessary, but it ensures that we're operating
    within a known environment, free of unexpected side-effects
    committed Sep 14, 2013
  14. ensured filtering is re-evaluated when case-sensitivity setting changes

    this further highlights the lack of encapsulation:
    * relying on very specific DOM structures is brittle
    * simulating an event seems a little hacky; the change handler shouldn't
      require awareness of which event triggers the (re-)filtering
    committed Sep 14, 2013
  15. added toggle for case-sensitive filtering

    via a checkbox
    this highlights a few issues:
    * there appears to be a lack of proper encapsulation, as the event
      handler is growing uncomfortably complex
    * with the addition of another set of elements, the DOM structure
      becomes significantly more unwieldy - we should more seriously
      consider a wrapping container now (cf.
    * we now have component-specific CSS - which is not (yet) scoped to that
      component though (see container consideration above)
    committed Sep 6, 2013
  16. separated widget module from initialization

    moving widget functionality to separate file required adding a new
    module which assumes responsibility for initialization ("glue code"),
    since that doesn't happen automatically anymore (cf. previous commit;
    committed Sep 6, 2013
Commits on Sep 14, 2013
  1. added API for widget initialization

    previously the widget was being initialized automatically on startup (as
    soon as the script was loaded), which - among other things - prevented
    it from being initialized dynamically/on-demand
    this way we can decouple ourselves from the page's lifecycle
    for now we're just attaching our function (entry point) to the global
    `window` object in order to expose it outside the module's IIFE
    * `setup` encapsulates widget initialization and caches the DOM
      reference (`this` is always the respective module object)
    * using `self` to capture `this` for the timeout callback, turning that
      into a closure
    committed Sep 6, 2013
  2. removed unused variable

    committed Sep 6, 2013
  3. introduced local aliases

    this improves readability somewhat (though it shouldn't be abused)
    again leveraging IIFEs; arguments passed in below and accepted under a
    different name
    using regular local variables instead of the arguments trick for QUnit
    to keep the IIFE's signature manageable
    committed Sep 6, 2013
  4. enabled strict mode

    this protects against various common issues, e.g. implicitly global
    doing this within the IIFEs for explicit scoping
    committed Sep 6, 2013
  5. added IIFE wrappers to avoid global variables

    this essentially creates self-contained modules
    committed Sep 6, 2013
  6. added animations for filtered elements

    animations are async (another common example for asynchronous operations
    is AJAX of course), so we have to adjust the test accordingly
    committed Sep 6, 2013
  7. added basic test

    checking that the UI element is injected and the list is filtered on
    using sample markup within fixture to ensure a clean slate for each run
    also requires adding our widget along with its dependencies (i.e.
    jQuery) to the test's HTML page
    * using `strictEqual` to avoid implicit type conversion (or "coercion")
    * using `call` to convert pseudo- to proper array (though one might also
      use `` instead of `jQuery#map`)
    committed Sep 6, 2013
  8. added testing infrastructure

    using QUnit - of course nowadays there are quite a few alternatives,
    some of which take a conceptually different approach (e.g. BDD)
    committed Sep 5, 2013