From 937f12e5e03f9ca58c3708b99b61fe0bcba0bb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Sat, 5 Aug 2017 22:07:37 -0700 Subject: [PATCH] Update jquery.typing to 0.3.2 --- assets/static/filters.js | 2 +- assets/static/jquery.typing-0.2.0.js | 82 --------------------- assets/static/jquery.typing-0.3.2.js | 104 +++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 83 deletions(-) delete mode 100644 assets/static/jquery.typing-0.2.0.js create mode 100644 assets/static/jquery.typing-0.3.2.js diff --git a/assets/static/filters.js b/assets/static/filters.js index 357f517b7..077486556 100644 --- a/assets/static/filters.js +++ b/assets/static/filters.js @@ -4,7 +4,7 @@ const $ = window.$ = window.jQuery = require("jquery"); const sha1 = require("js-sha1"); const Cookies = require("js-cookie"); -require("./jquery.typing-0.2.0.js"); +require("./jquery.typing-0.3.2.js"); require("corejs-typeahead"); require("bootstrap-tagsinput"); require("bootstrap-tagsinput/dist/bootstrap-tagsinput.css"); diff --git a/assets/static/jquery.typing-0.2.0.js b/assets/static/jquery.typing-0.2.0.js deleted file mode 100644 index be35319ab..000000000 --- a/assets/static/jquery.typing-0.2.0.js +++ /dev/null @@ -1,82 +0,0 @@ -// jQuery-typing -// -// Version: 0.2.0 -// Website: http://narf.pl/jquery-typing/ -// License: public domain -// Author: Maciej Konieczny - -(function ($) { - - //-------------------- - // jQuery extension - //-------------------- - - $.fn.typing = function (options) { - return this.each(function (i, elem) { - listenToTyping(elem, options); - }); - }; - - - //------------------- - // actual function - //------------------- - - function listenToTyping(elem, options) { - // override default settings - var settings = $.extend({ - start: null, - stop: null, - delay: 400 - }, options); - - // create other function-scope variables - var $elem = $(elem), - typing = false, - delayedCallback; - - // start typing - function startTyping(event) { - if (!typing) { - // set flag and run callback - typing = true; - if (settings.start) { - settings.start(event, $elem); - } - } - } - - // stop typing - function stopTyping(event, delay) { - if (typing) { - // discard previous delayed callback and create new one - clearTimeout(delayedCallback); - delayedCallback = setTimeout(function () { - // set flag and run callback - typing = false; - if (settings.stop) { - settings.stop(event, $elem); - } - }, delay >= 0 ? delay : settings.delay); - } - } - - // listen to regular keypresses - $elem.keypress(startTyping); - - // listen to backspace and delete presses - $elem.keydown(function (event) { - if (event.keyCode === 8 || event.keyCode === 46) { - startTyping(event); - } - }); - - // listen to keyups - $elem.keyup(stopTyping); - - // listen to blurs - $elem.blur(function (event) { - stopTyping(event, 0); - }); - } -})(jQuery); diff --git a/assets/static/jquery.typing-0.3.2.js b/assets/static/jquery.typing-0.3.2.js new file mode 100644 index 000000000..d0fa38dec --- /dev/null +++ b/assets/static/jquery.typing-0.3.2.js @@ -0,0 +1,104 @@ +// jQuery-typing +// +// Version: 0.3.2 +// Website: http://tnajdek.github.io/jquery-typing/ +// License: public domain +// Author: Maciej Konieczny +// Author (Events & data-api): Tom Najdek + +(function ($) { + + //-------------------- + // jQuery extension + //-------------------- + + $.fn.typing = function (options) { + return this.each(function (i, elem) { + var $elem = $(elem), + api; + + if(!$elem.data('typing')) { + api = new Typing(elem, options); + $elem.data('typing', api); + } + }); + }; + + + //------------------- + // actual function + //------------------- + + var Typing = function(elem, options) { + // create other function-scope variables + var $elem = $(elem), + typing = false, + delayedCallback, + // override default settings + settings = $.extend({ + start: null, + stop: null, + delay: 400 + }, options); + + //export settings to the api + this.settings = settings; + + + // start typing + function startTyping(event) { + if (!typing) { + // set flag and run callback + typing = true; + $elem.trigger('typing:start'); + if (settings.start) { + settings.start(event, $elem); + } + } + } + + // stop typing + function stopTyping(event, delay) { + if (typing) { + // discard previous delayed callback and create new one + clearTimeout(delayedCallback); + delayedCallback = setTimeout(function () { + // set flag and run callback + typing = false; + $elem.trigger('typing:stop'); + if (settings.stop) { + settings.stop(event, $elem); + } + }, delay >= 0 ? delay : settings.delay); + } + } + + // listen to regular keypresses + $elem.keypress(startTyping); + + // listen to backspace and delete presses + $elem.keydown(function (event) { + if (event.keyCode === 8 || event.keyCode === 46) { + startTyping(event); + } + }); + + // listen to keyups + $elem.keyup(stopTyping); + + // listen to blurs + $elem.blur(function (event) { + stopTyping(event, 0); + }); + }; + + //provide data-api bootstrap style (http://rc.getbootstrap.com/javascript.html) + $(document).on('focus.typing.data-api', '[data-provide=typing]', function (e) { + var $this = $(this), + delay = $this.data('typingDelay'); + $this.typing( { + delay: delay + }); + }); + +})(jQuery);