Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@grssam
Created June 21, 2013 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grssam/5834212 to your computer and use it in GitHub Desktop.
Save grssam/5834212 to your computer and use it in GitHub Desktop.
Arguments Overloading FTW
/**
* Converts any input box on a page to a CSS selector search and suggestion box.
*
* @constructor
* @param {nsIDOMDocument} aContentDocument
* The content document which inspector is attached to.
* @param {nsiInputElement|String} aInputNode
* The input element or the selector for teh input element to which the
* panel will be attached and from where search input will be taken.
* @param {Object} aOptions
* The options provided to the selector. Current available options are:
* - TODO
* @arguments The following combinations of the above three arguments is possible
* - (aContentDocument, aInputNode[, aOptions])
* - (aContentDocument, String[, aOptions])
* - (aInputNode[, aOptions])
* - (String[, aOptions])
*/
function SelectorSearch() {
this.searchBox = (typeof arguments[0] == "string")
? (this.doc = document).querySelector(arguments[0])
: (!arguments[0].ownerDocument)
? ((this.doc = arguments[0]) && typeof arguments[1] == "string")
? this.doc.querySelector(arguments[1])
: arguments[1]
: (this.doc = arguments[0].ownerDocument, arguments[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment