From 5e37e337167dbb7341f7299d17dd9baa92108cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20de=20la=20Torre?= Date: Tue, 15 Oct 2019 22:09:13 +0200 Subject: Added support to split messages #133 --- ihatemoney/static/js/tagsinput.js | 381 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 381 insertions(+) create mode 100644 ihatemoney/static/js/tagsinput.js (limited to 'ihatemoney/static/js') diff --git a/ihatemoney/static/js/tagsinput.js b/ihatemoney/static/js/tagsinput.js new file mode 100644 index 0000000..a5a4e84 --- /dev/null +++ b/ihatemoney/static/js/tagsinput.js @@ -0,0 +1,381 @@ +//Credits https://bootsnipp.com/snippets/exqd3 +/* jQuery Tags Input Revisited Plugin + * + * Copyright (c) Krzysztof Rusnarczyk + * Licensed under the MIT license */ + +(function($) { + var delimiter = []; + var inputSettings = []; + var callbacks = []; + + $.fn.addTag = function(value, options) { + options = jQuery.extend({ + focus: false, + callback: true + }, options); + + this.each(function() { + var id = $(this).attr('id'); + + var tagslist = $(this).val().split(_getDelimiter(delimiter[id])); + if (tagslist[0] === '') tagslist = []; + + value = jQuery.trim(value); + + if ((inputSettings[id].unique && $(this).tagExist(value)) || !_validateTag(value, inputSettings[id], tagslist, delimiter[id])) { + $('#' + id + '_tag').addClass('error'); + return false; + } + + $('', {class: 'tag'}).append( + $('', {class: 'tag-text'}).text(value), + $('