Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom jquery #301

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Contents
:numbered: 1

installation
settings
usage


Expand Down
2 changes: 0 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@
url(r'^chaining/', include('smart_selects.urls')),
)
```

4. You will also need to include jQuery in every page that includes a field from `smart_selects`, or set `JQUERY_URL = True` in your project's `settings.py`.
10 changes: 0 additions & 10 deletions docs/settings.md

This file was deleted.

2 changes: 1 addition & 1 deletion smart_selects/static/smart-selects/admin/js/bindfields.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@
}
});
});
}(jQuery || django.jQuery));
}(django.jQuery));
2 changes: 1 addition & 1 deletion smart_selects/static/smart-selects/admin/js/chainedfk.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@
}
};
}();
}(jQuery || django.jQuery));
}(django.jQuery));
2 changes: 1 addition & 1 deletion smart_selects/static/smart-selects/admin/js/chainedm2m.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@
}
};
}();
}(jQuery || django.jQuery));
}(django.jQuery));
27 changes: 8 additions & 19 deletions smart_selects/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@

get_model = apps.get_model

USE_DJANGO_JQUERY = getattr(settings, "USE_DJANGO_JQUERY", False)
JQUERY_URL = getattr(
settings,
"JQUERY_URL",
"https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js",
)

URL_PREFIX = getattr(settings, "SMART_SELECTS_URL_PREFIX", "")


Expand All @@ -31,21 +24,17 @@ def media(self):

js = []

if JQUERY_URL:
js.append(JQUERY_URL)
elif JQUERY_URL is not False:
vendor = "vendor/jquery/"
extra = "" if settings.DEBUG else ".min"
vendor = "" if django.VERSION < (1, 9, 0) else "vendor/jquery/"
extra = "" if settings.DEBUG else ".min"

jquery_paths = [
"{}jquery{}.js".format(vendor, extra),
"jquery.init.js",
]
jquery_paths = [
"{}jquery{}.js".format(vendor, extra),
"jquery.init.js",
]

if USE_DJANGO_JQUERY:
jquery_paths = ["admin/js/{}".format(path) for path in jquery_paths]
jquery_paths = ["admin/js/{}".format(path) for path in jquery_paths]

js.extend(jquery_paths)
js.extend(jquery_paths)

media += Media(js=js)
return media
Expand Down