From d918e1993166047a20e3f8babd538afda214f7c0 Mon Sep 17 00:00:00 2001 From: Stephen Burrows Date: Fri, 15 Jul 2011 14:44:59 -0400 Subject: [PATCH] Removed TagCreation.js and the admin widget that used it. --- philo/admin/widgets.py | 30 +------- philo/static/philo/js/TagCreation.js | 111 --------------------------- 2 files changed, 1 insertion(+), 140 deletions(-) delete mode 100644 philo/static/philo/js/TagCreation.js diff --git a/philo/admin/widgets.py b/philo/admin/widgets.py index c753850..637475e 100644 --- a/philo/admin/widgets.py +++ b/philo/admin/widgets.py @@ -1,6 +1,6 @@ from django import forms from django.conf import settings -from django.contrib.admin.widgets import FilteredSelectMultiple, url_params_from_lookup_dict +from django.contrib.admin.widgets import url_params_from_lookup_dict from django.utils.html import escape from django.utils.safestring import mark_safe from django.utils.text import truncate_words @@ -37,32 +37,4 @@ class ModelLookupWidget(forms.TextInput): output.append(' %s' % escape(truncate_words(value_object, 14))) except value_class.DoesNotExist: pass - return mark_safe(u''.join(output)) - - -class TagFilteredSelectMultiple(FilteredSelectMultiple): - """ - A SelectMultiple with a JavaScript filter interface. - - Note that the resulting JavaScript assumes that the jsi18n - catalog has been loaded in the page - """ - class Media: - js = ( - settings.ADMIN_MEDIA_PREFIX + "js/core.js", - settings.ADMIN_MEDIA_PREFIX + "js/SelectBox.js", - settings.ADMIN_MEDIA_PREFIX + "js/SelectFilter2.js", - "philo/js/TagCreation.js", - ) - - def render(self, name, value, attrs=None, choices=()): - if attrs is None: attrs = {} - attrs['class'] = 'selectfilter' - if self.is_stacked: attrs['class'] += 'stacked' - output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)] - output.append(u'\n' % \ - (name, self.verbose_name.replace('"', '\\"'), int(self.is_stacked), settings.ADMIN_MEDIA_PREFIX, name)) return mark_safe(u''.join(output)) \ No newline at end of file diff --git a/philo/static/philo/js/TagCreation.js b/philo/static/philo/js/TagCreation.js deleted file mode 100644 index a23e609..0000000 --- a/philo/static/philo/js/TagCreation.js +++ /dev/null @@ -1,111 +0,0 @@ -var tagCreation = window.tagCreation; - -(function($) { - location_re = new RegExp("^https?:\/\/" + window.location.host + "/") - - $('html').ajaxSend(function(event, xhr, settings) { - function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = $.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; - } - if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url)) || location_re.test(settings.url)) { - // Only send the token to relative URLs i.e. locally. - xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); - } - }); - tagCreation = { - 'cache': {}, - 'addTagFromSlug': function(triggeringLink) { - var id = triggeringLink.id.replace(/^ajax_add_/, '') + '_input'; - var slug = document.getElementById(id).value; - - var name = slug.split(' '); - for(var i=0;i