web/static/admin/js/prepopulate.js
changeset 104 b62a2a3e272d
parent 103 5578dcb54f4d
child 105 6094ab306d77
--- a/web/static/admin/js/prepopulate.js	Mon May 09 18:57:23 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-(function($) {
-    $.fn.prepopulate = function(dependencies, maxLength) {
-        /*
-            Depends on urlify.js
-            Populates a selected field with the values of the dependent fields,
-            URLifies and shortens the string. 
-            dependencies - selected jQuery object of dependent fields
-            maxLength - maximum length of the URLify'd string 
-        */
-        return this.each(function() {
-            var field = $(this);
-
-            field.data('_changed', false);
-            field.change(function() {
-                field.data('_changed', true);
-            });
-
-            var populate = function () {
-                // Bail if the fields value has changed
-                if (field.data('_changed') == true) return;
- 
-                var values = [];
-                dependencies.each(function() {
-                    if ($(this).val().length > 0) {
-                        values.push($(this).val());
-                    }
-                });
-                field.val(URLify(values.join(' '), maxLength));
-            };
-
-            dependencies.keyup(populate).change(populate).focus(populate);
-        });
-    };
-})(django.jQuery);