X-Git-Url: https://git.mdrn.pl/emels.git/blobdiff_plain/228c34b6fb564b8f5444a72ceaec83448594c5a5..1b2d6e07836c08be40d19fcf35aa8b3080db7c7e:/emels/static/admin/js/prepopulate.js diff --git a/emels/static/admin/js/prepopulate.js b/emels/static/admin/js/prepopulate.js deleted file mode 100644 index 5d4b0e8..0000000 --- a/emels/static/admin/js/prepopulate.js +++ /dev/null @@ -1,42 +0,0 @@ -/*global URLify*/ -(function($) { - 'use strict'; - $.fn.prepopulate = function(dependencies, maxLength, allowUnicode) { - /* - Depends on urlify.js - Populates a selected field with the values of the dependent fields, - URLifies and shortens the string. - dependencies - array of dependent fields ids - maxLength - maximum length of the URLify'd string - allowUnicode - Unicode support of the URLify'd string - */ - return this.each(function() { - var prepopulatedField = $(this); - - var populate = function() { - // Bail if the field's value has been changed by the user - if (prepopulatedField.data('_changed')) { - return; - } - - var values = []; - $.each(dependencies, function(i, field) { - field = $(field); - if (field.val().length > 0) { - values.push(field.val()); - } - }); - prepopulatedField.val(URLify(values.join(' '), maxLength, allowUnicode)); - }; - - prepopulatedField.data('_changed', false); - prepopulatedField.change(function() { - prepopulatedField.data('_changed', true); - }); - - if (!prepopulatedField.val()) { - $(dependencies.join(',')).keyup(populate).change(populate).focus(populate); - } - }); - }; -})(django.jQuery);