├── LICENSE.md ├── README.md ├── clearsearch.jquery.json └── src └── jquery.clearsearch.js /LICENSE.md: -------------------------------------------------------------------------------- 1 | # jQuery ClearSearch License 2 | 3 | Copyright (c) 2012, Was los.de GmbH & Co. KG. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the "Was los.de GmbH & Co. KG" nor the names of its 17 | contributors may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jQuery ClearSearch 2 | 3 | ClearSearch - A search input field plugin for jQuery. 4 | 5 | http://jsfiddle.net/wldaunfr/FERw3/ -------------------------------------------------------------------------------- /clearsearch.jquery.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clearsearch", 3 | "version": "1.0.3", 4 | "title": "jQuery ClearSearch", 5 | "author": { 6 | "name": "Was los.de GmbH & Co. KG", 7 | "url": "https://github.com/waslos" 8 | }, 9 | "licenses": [{ 10 | "type": "BSD-3-Clause", 11 | "url": "https://github.com/waslos/jquery-clearsearch/blob/v1.0.3/LICENSE.md" 12 | }], 13 | "dependencies": { 14 | "jquery": ">=1.7.2" 15 | }, 16 | "description": "A search input field plugin for jQuery.", 17 | "keywords": ["search", "form", "input", "clear"], 18 | "homepage": "https://github.com/waslos/jquery-clearsearch", 19 | "docs": "https://github.com/waslos/jquery-clearsearch", 20 | "demo": "http://jsfiddle.net/wldaunfr/FERw3", 21 | "bugs": "https://github.com/waslos/jquery-clearsearch/issues" 22 | } -------------------------------------------------------------------------------- /src/jquery.clearsearch.js: -------------------------------------------------------------------------------- 1 | /* ============================================================================ 2 | * jquery.clearsearch.js v1.0.3 3 | * https://github.com/waslos/jquery-clearsearch 4 | * ============================================================================ 5 | * Copyright (c) 2012, Was los.de GmbH & Co. KG 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 18 | * 3. Neither the name of the "Was los.de GmbH & Co. KG" nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | * ========================================================================= */ 34 | (function($) { 35 | $.fn.clearSearch = function(options) { 36 | var settings = $.extend({ 37 | 'clearClass' : 'clear_input', 38 | 'focusAfterClear' : true, 39 | 'linkText' : '×' 40 | }, options); 41 | return this.each(function() { 42 | var $this = $(this), btn, 43 | divClass = settings.clearClass + '_div'; 44 | 45 | if (!$this.parent().hasClass(divClass)) { 46 | $this.wrap('