├── nx
├── __init__.py
├── templates
│ └── search
│ │ └── indexes
│ │ └── nx
│ │ └── note_text.txt
├── search_indexes.py
└── models.py
├── nx2django
├── __init__.py
├── static
│ ├── admin
│ │ ├── img
│ │ │ ├── icon-no.gif
│ │ │ ├── icon-yes.gif
│ │ │ ├── nav-bg.gif
│ │ │ ├── default-bg.gif
│ │ │ ├── icon_alert.gif
│ │ │ ├── icon_clock.gif
│ │ │ ├── icon_error.gif
│ │ │ ├── changelist-bg.gif
│ │ │ ├── icon-unknown.gif
│ │ │ ├── icon_addlink.gif
│ │ │ ├── icon_calendar.gif
│ │ │ ├── icon_success.gif
│ │ │ ├── inline-delete.png
│ │ │ ├── sorting-icons.gif
│ │ │ ├── tooltag-add.png
│ │ │ ├── deleted-overlay.gif
│ │ │ ├── icon_changelink.gif
│ │ │ ├── icon_deletelink.gif
│ │ │ ├── icon_searchbox.png
│ │ │ ├── inline-restore.png
│ │ │ ├── nav-bg-grabber.gif
│ │ │ ├── nav-bg-reverse.gif
│ │ │ ├── nav-bg-selected.gif
│ │ │ ├── selector-icons.gif
│ │ │ ├── selector-search.gif
│ │ │ ├── changelist-bg_rtl.gif
│ │ │ ├── default-bg-reverse.gif
│ │ │ ├── gis
│ │ │ │ ├── move_vertex_on.png
│ │ │ │ └── move_vertex_off.png
│ │ │ ├── inline-delete-8bit.png
│ │ │ ├── inline-splitter-bg.gif
│ │ │ ├── tooltag-arrowright.png
│ │ │ └── inline-restore-8bit.png
│ │ ├── js
│ │ │ ├── jquery.init.js
│ │ │ ├── prepopulate.min.js
│ │ │ ├── collapse.min.js
│ │ │ ├── related-widget-wrapper.js
│ │ │ ├── collapse.js
│ │ │ ├── LICENSE-JQUERY.txt
│ │ │ ├── prepopulate.js
│ │ │ ├── timeparse.js
│ │ │ ├── actions.min.js
│ │ │ ├── inlines.min.js
│ │ │ ├── SelectBox.js
│ │ │ ├── admin
│ │ │ │ ├── RelatedObjectLookups.js
│ │ │ │ └── DateTimeShortcuts.js
│ │ │ ├── actions.js
│ │ │ ├── urlify.js
│ │ │ ├── calendar.js
│ │ │ ├── core.js
│ │ │ ├── SelectFilter2.js
│ │ │ └── inlines.js
│ │ └── css
│ │ │ ├── dashboard.css
│ │ │ ├── login.css
│ │ │ ├── ie.css
│ │ │ ├── rtl.css
│ │ │ ├── changelists.css
│ │ │ ├── forms.css
│ │ │ ├── widgets.css
│ │ │ └── base.css
│ └── rest_framework
│ │ ├── img
│ │ ├── grid.png
│ │ ├── glyphicons-halflings.png
│ │ └── glyphicons-halflings-white.png
│ │ ├── fonts
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.ttf
│ │ └── glyphicons-halflings-regular.woff
│ │ ├── css
│ │ ├── prettify.css
│ │ ├── default.css
│ │ └── bootstrap-tweaks.css
│ │ └── js
│ │ ├── default.js
│ │ ├── prettify-min.js
│ │ └── bootstrap.min.js
├── urls.py
├── wsgi.py
└── settings.py
├── api
├── __init__.py
├── urls.py
└── views.py
├── struct.png
├── screenshots
├── 1.jpg
└── 2.jpg
├── .gitignore
├── requirements.txt
├── .hgignore
├── test_query
└── query.json
├── start.sh
├── manage.py
└── README.md
/nx/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/nx2django/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/api/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'fdhuang'
2 |
--------------------------------------------------------------------------------
/struct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/struct.png
--------------------------------------------------------------------------------
/screenshots/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/screenshots/1.jpg
--------------------------------------------------------------------------------
/screenshots/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/screenshots/2.jpg
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *.pyo
3 | *.db
4 | .DS_Store
5 | .coverage
6 | local_settings.py
7 | /static
8 | .idea
9 | db.sqlite3
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon-no.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon-no.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon-yes.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon-yes.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/nav-bg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/nav-bg.gif
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | django-haystack
2 | django
3 | django-tastypie
4 | djangorestframework
5 | pygeocoder
6 | elasticsearch
7 | django-grappelli
--------------------------------------------------------------------------------
/nx2django/static/admin/img/default-bg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/default-bg.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon_alert.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon_alert.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon_clock.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon_clock.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon_error.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon_error.gif
--------------------------------------------------------------------------------
/.hgignore:
--------------------------------------------------------------------------------
1 | syntax: glob
2 | *.pyc
3 | *.pyo
4 | *.db
5 | .DS_Store
6 | .coverage
7 | local_settings.py
8 |
9 | syntax: regexp
10 | ^static/
11 |
--------------------------------------------------------------------------------
/nx2django/static/admin/img/changelist-bg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/changelist-bg.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon-unknown.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon-unknown.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon_addlink.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon_addlink.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon_calendar.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon_calendar.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon_success.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon_success.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/inline-delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/inline-delete.png
--------------------------------------------------------------------------------
/nx2django/static/admin/img/sorting-icons.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/sorting-icons.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/tooltag-add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/tooltag-add.png
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/img/grid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/rest_framework/img/grid.png
--------------------------------------------------------------------------------
/nx2django/static/admin/img/deleted-overlay.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/deleted-overlay.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon_changelink.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon_changelink.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon_deletelink.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon_deletelink.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/icon_searchbox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/icon_searchbox.png
--------------------------------------------------------------------------------
/nx2django/static/admin/img/inline-restore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/inline-restore.png
--------------------------------------------------------------------------------
/nx2django/static/admin/img/nav-bg-grabber.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/nav-bg-grabber.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/nav-bg-reverse.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/nav-bg-reverse.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/nav-bg-selected.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/nav-bg-selected.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/selector-icons.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/selector-icons.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/selector-search.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/selector-search.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/changelist-bg_rtl.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/changelist-bg_rtl.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/default-bg-reverse.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/default-bg-reverse.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/gis/move_vertex_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/gis/move_vertex_on.png
--------------------------------------------------------------------------------
/nx2django/static/admin/img/inline-delete-8bit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/inline-delete-8bit.png
--------------------------------------------------------------------------------
/nx2django/static/admin/img/inline-splitter-bg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/inline-splitter-bg.gif
--------------------------------------------------------------------------------
/nx2django/static/admin/img/tooltag-arrowright.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/tooltag-arrowright.png
--------------------------------------------------------------------------------
/nx2django/static/admin/img/gis/move_vertex_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/gis/move_vertex_off.png
--------------------------------------------------------------------------------
/nx2django/static/admin/img/inline-restore-8bit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/admin/img/inline-restore-8bit.png
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/img/glyphicons-halflings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/rest_framework/img/glyphicons-halflings.png
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/img/glyphicons-halflings-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/rest_framework/img/glyphicons-halflings-white.png
--------------------------------------------------------------------------------
/test_query/query.json:
--------------------------------------------------------------------------------
1 | {
2 | "query": {
3 | "match_all": {}
4 | },
5 | "sort": [{
6 | "_geo_distance": {
7 | "location": "38.963, 95.239",
8 | "unit": "km"
9 | }
10 | }]
11 | }
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/rest_framework/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/rest_framework/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phodal/django-elasticsearch/master/nx2django/static/rest_framework/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | source /home/www/nx2/bin/activate
3 | nohup /home/www/nx2/bin/gunicorn_django --workers=2 -b 0.0.0.0:9996 --timeout=300&
4 | nohup /usr/local/elasticsearch/elasticsearch-1.4.2/bin/elasticsearch &
5 |
--------------------------------------------------------------------------------
/nx/templates/search/indexes/nx/note_text.txt:
--------------------------------------------------------------------------------
1 | {{ object.title }}
2 | {{ object.body }}
3 | {{ object.number }}
4 | {{ object.price }}
5 | {{ object.phone_number }}
6 | {{ object.get_location }}
7 | {{ object.get_location_info }}
8 |
--------------------------------------------------------------------------------
/nx2django/urls.py:
--------------------------------------------------------------------------------
1 | from django.conf.urls import patterns, include, url
2 | from django.contrib import admin
3 |
4 | urlpatterns = patterns('',
5 | ("^api/", include("api.urls")),
6 | (r'^grappelli/', include('grappelli.urls')),
7 | url(r'^admin/', include(admin.site.urls)),
8 | )
9 |
--------------------------------------------------------------------------------
/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "nx2django.settings")
7 |
8 | from django.core.management import execute_from_command_line
9 |
10 | execute_from_command_line(sys.argv)
11 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/jquery.init.js:
--------------------------------------------------------------------------------
1 | /* Puts the included jQuery into our own namespace using noConflict and passing
2 | * it 'true'. This ensures that the included jQuery doesn't pollute the global
3 | * namespace (i.e. this preserves pre-existing values for both window.$ and
4 | * window.jQuery).
5 | */
6 | var django = django || {};
7 | django.jQuery = jQuery.noConflict(true);
8 |
--------------------------------------------------------------------------------
/api/urls.py:
--------------------------------------------------------------------------------
1 | from django.conf.urls import url, include
2 | from rest_framework import routers
3 |
4 | from api.views import AllListView
5 |
6 | router = routers.DefaultRouter()
7 | router.register(r'all', AllListView, 'all')
8 |
9 |
10 | urlpatterns = [
11 | url(r'^', include(router.urls)),
12 | url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
13 | ]
--------------------------------------------------------------------------------
/nx2django/static/admin/js/prepopulate.min.js:
--------------------------------------------------------------------------------
1 | (function(b){b.fn.prepopulate=function(e,g){return this.each(function(){var a=b(this),d=function(){if(!a.data("_changed")){var f=[];b.each(e,function(h,c){c=b(c);c.val().length>0&&f.push(c.val())});a.val(URLify(f.join(" "),g))}};a.data("_changed",false);a.change(function(){a.data("_changed",true)});a.val()||b(e.join(",")).keyup(d).change(d).focus(d)})}})(django.jQuery);
2 |
--------------------------------------------------------------------------------
/nx2django/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for nx2django project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "nx2django.settings")
12 |
13 | from django.core.wsgi import get_wsgi_application
14 | application = get_wsgi_application()
15 |
--------------------------------------------------------------------------------
/nx2django/static/admin/css/dashboard.css:
--------------------------------------------------------------------------------
1 | /* DASHBOARD */
2 |
3 | .dashboard .module table th {
4 | width: 100%;
5 | }
6 |
7 | .dashboard .module table td {
8 | white-space: nowrap;
9 | }
10 |
11 | .dashboard .module table td a {
12 | display: block;
13 | padding-right: .6em;
14 | }
15 |
16 | /* RECENT ACTIONS MODULE */
17 |
18 | .module ul.actionlist {
19 | margin-left: 0;
20 | }
21 |
22 | ul.actionlist li {
23 | list-style-type: none;
24 | }
25 |
26 | ul.actionlist li {
27 | overflow: hidden;
28 | text-overflow: ellipsis;
29 | -o-text-overflow: ellipsis;
30 | }
31 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/collapse.min.js:
--------------------------------------------------------------------------------
1 | (function(a){a(document).ready(function(){a("fieldset.collapse").each(function(c,b){a(b).find("div.errors").length==0&&a(b).addClass("collapsed").find("h2").first().append(' ('+gettext("Show")+")")});a("fieldset.collapse a.collapse-toggle").click(function(){a(this).closest("fieldset").hasClass("collapsed")?a(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset",[a(this).attr("id")]):a(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset",
2 | [a(this).attr("id")]);return false})})})(django.jQuery);
3 |
--------------------------------------------------------------------------------
/api/views.py:
--------------------------------------------------------------------------------
1 | from rest_framework import serializers, viewsets
2 | from rest_framework.response import Response
3 |
4 | from nx.models import Note
5 |
6 |
7 | class NoteDetailSerializer(serializers.HyperlinkedModelSerializer):
8 |
9 | class Meta:
10 | model = Note
11 | fields = ("username", "email", "phone_number", "title", "body", "price", "number", "province", "city", "address")
12 |
13 | class AllListView(viewsets.ModelViewSet):
14 | serializer_class = NoteDetailSerializer
15 |
16 | def list(self, request):
17 | queryset = Note.objects.filter()
18 | serializer = NoteDetailSerializer(queryset, many=True)
19 | return Response(serializer.data)
--------------------------------------------------------------------------------
/nx/search_indexes.py:
--------------------------------------------------------------------------------
1 | from haystack import indexes
2 |
3 | from .models import Note
4 |
5 |
6 | class NoteIndex(indexes.SearchIndex, indexes.Indexable):
7 | text = indexes.CharField(document=True, use_template=True)
8 | title = indexes.CharField(model_attr='title')
9 | body = indexes.CharField(model_attr='body')
10 | number = indexes.IntegerField(model_attr='number')
11 | price = indexes.IntegerField(model_attr='price')
12 | phone_number = indexes.IntegerField(model_attr='phone_number')
13 | location = indexes.LocationField(model_attr='get_location')
14 | location_info = indexes.CharField(model_attr='get_location_info')
15 |
16 | def get_model(self):
17 | return Note
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/css/prettify.css:
--------------------------------------------------------------------------------
1 | .com { color: #93a1a1; }
2 | .lit { color: #195f91; }
3 | .pun, .opn, .clo { color: #93a1a1; }
4 | .fun { color: #dc322f; }
5 | .str, .atv { color: #D14; }
6 | .kwd, .prettyprint .tag { color: #1e347b; }
7 | .typ, .atn, .dec, .var { color: teal; }
8 | .pln { color: #48484c; }
9 |
10 | .prettyprint {
11 | padding: 8px;
12 | background-color: #f7f7f9;
13 | border: 1px solid #e1e1e8;
14 | }
15 | .prettyprint.linenums {
16 | -webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
17 | -moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
18 | box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
19 | }
20 |
21 | /* Specify class=linenums on a pre to get line numbering */
22 | ol.linenums {
23 | margin: 0 0 0 33px; /* IE indents via margin-left */
24 | }
25 | ol.linenums li {
26 | padding-left: 12px;
27 | color: #bebec5;
28 | line-height: 20px;
29 | text-shadow: 0 1px 0 #fff;
30 | }
--------------------------------------------------------------------------------
/nx2django/static/admin/js/related-widget-wrapper.js:
--------------------------------------------------------------------------------
1 | django.jQuery(function($){
2 | function updateLinks() {
3 | var $this = $(this);
4 | var siblings = $this.nextAll('.change-related, .delete-related');
5 | if (!siblings.length) return;
6 | var value = $this.val();
7 | if (value) {
8 | siblings.each(function(){
9 | var elm = $(this);
10 | elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
11 | });
12 | } else siblings.removeAttr('href');
13 | }
14 | var container = $(document);
15 | container.on('change', '.related-widget-wrapper select', updateLinks);
16 | container.find('.related-widget-wrapper select').each(updateLinks);
17 | container.on('click', '.related-widget-wrapper-link', function(event){
18 | if (this.href) {
19 | showRelatedObjectPopup(this);
20 | }
21 | event.preventDefault();
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/collapse.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $(document).ready(function() {
3 | // Add anchor tag for Show/Hide link
4 | $("fieldset.collapse").each(function(i, elem) {
5 | // Don't hide if fields in this fieldset have errors
6 | if ($(elem).find("div.errors").length == 0) {
7 | $(elem).addClass("collapsed").find("h2").first().append(' (' + gettext("Show") +
9 | ')');
10 | }
11 | });
12 | // Add toggle to anchor tag
13 | $("fieldset.collapse a.collapse-toggle").click(function(ev) {
14 | if ($(this).closest("fieldset").hasClass("collapsed")) {
15 | // Show
16 | $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]);
17 | } else {
18 | // Hide
19 | $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]);
20 | }
21 | return false;
22 | });
23 | });
24 | })(django.jQuery);
25 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/LICENSE-JQUERY.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010 John Resig, http://jquery.com/
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/nx2django/static/admin/css/login.css:
--------------------------------------------------------------------------------
1 | /* LOGIN FORM */
2 |
3 | body.login {
4 | background: #eee;
5 | }
6 |
7 | .login #container {
8 | background: white;
9 | border: 1px solid #ccc;
10 | width: 28em;
11 | min-width: 300px;
12 | margin-left: auto;
13 | margin-right: auto;
14 | margin-top: 100px;
15 | }
16 |
17 | .login #content-main {
18 | width: 100%;
19 | }
20 |
21 | .login form {
22 | margin-top: 1em;
23 | }
24 |
25 | .login .form-row {
26 | padding: 4px 0;
27 | float: left;
28 | width: 100%;
29 | }
30 |
31 | .login .form-row label {
32 | padding-right: 0.5em;
33 | line-height: 2em;
34 | font-size: 1em;
35 | clear: both;
36 | color: #333;
37 | }
38 |
39 | .login .form-row #id_username, .login .form-row #id_password {
40 | clear: both;
41 | padding: 6px;
42 | width: 100%;
43 | -webkit-box-sizing: border-box;
44 | -moz-box-sizing: border-box;
45 | box-sizing: border-box;
46 | }
47 |
48 | .login span.help {
49 | font-size: 10px;
50 | display: block;
51 | }
52 |
53 | .login .submit-row {
54 | clear: both;
55 | padding: 1em 0 0 9.4em;
56 | }
57 |
58 | .login .password-reset-link {
59 | text-align: center;
60 | }
61 |
--------------------------------------------------------------------------------
/nx2django/static/admin/css/ie.css:
--------------------------------------------------------------------------------
1 | /* IE 6 & 7 */
2 |
3 | /* Proper fixed width for dashboard in IE6 */
4 |
5 | .dashboard #content {
6 | *width: 768px;
7 | }
8 |
9 | .dashboard #content-main {
10 | *width: 535px;
11 | }
12 |
13 | /* IE 6 ONLY */
14 |
15 | /* Keep header from flowing off the page */
16 |
17 | #container {
18 | _position: static;
19 | }
20 |
21 | /* Put the right sidebars back on the page */
22 |
23 | .colMS #content-related {
24 | _margin-right: 0;
25 | _margin-left: 10px;
26 | _position: static;
27 | }
28 |
29 | /* Put the left sidebars back on the page */
30 |
31 | .colSM #content-related {
32 | _margin-right: 10px;
33 | _margin-left: -115px;
34 | _position: static;
35 | }
36 |
37 | .form-row {
38 | _height: 1%;
39 | }
40 |
41 | /* Fix right margin for changelist filters in IE6 */
42 |
43 | #changelist-filter ul {
44 | _margin-right: -10px;
45 | }
46 |
47 | /* IE ignores min-height, but treats height as if it were min-height */
48 |
49 | .change-list .filtered {
50 | _height: 400px;
51 | }
52 |
53 | /* IE doesn't know alpha transparency in PNGs */
54 |
55 | .inline-deletelink {
56 | background: transparent url(../img/inline-delete-8bit.png) no-repeat;
57 | }
58 |
59 | /* IE7 doesn't support inline-block */
60 | .change-list ul.toplinks li {
61 | zoom: 1;
62 | *display: inline;
63 | }
64 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ##Ionic ElasticSearch with OpenLayers 3
2 |
3 | > A Demo of ElasticSearch, Django, Ionic
4 |
5 | ##Struct
6 |
7 | 
8 |
9 | ##Tech
10 |
11 | - ElasticSearch
12 | - Django
13 | - Ionic
14 | - OpenLayers 3
15 |
16 | ##Screenshot
17 |
18 | 
19 | 
20 |
21 |
22 | ##Client
23 |
24 | Visit: [https://github.com/phodal/ionic-elasticsearch](https://github.com/phodal/ionic-elasticsearch)
25 |
26 | ##Document
27 |
28 | [Django ElasticSearch Ionic 打造 GIS 移动应用 —— 架构设计](http://www.phodal.com/blog/django-elasticsearch-ionic-build-gis-application/)
29 |
30 | [地图移动应用实战 —— Django Haystack ElasticSearch 环境准备](http://www.phodal.com/blog/django-elasticsearch-ionic-build-gis-application/)
31 |
32 | [地图移动应用实战 —— 服务端构建](http://www.phodal.com/blog/django-elasticsearch-ionic-build-gis-application-create-model/)
33 |
34 | [地图移动应用实战:Ionic ElasticSearch 搜索服务](http://www.phodal.com/blog/ionic-searchview-django-elasticsearch-ionic-build-gis-application/)
35 |
36 | [地图移动应用实战:Ionic OpenLayer 地图显示](http://www.phodal.com/blog/django-elasticsearch-ionic-build-gis-application-show-on-map/)
37 |
38 | [Mac OS Django Geo 环境搭建](http://www.phodal.com/blog/django-elasticsearch-geo-solution/)
39 |
40 | [AWS CentOS Django Geo 环境搭建](http://www.phodal.com/blog/install-geo-django-in-centos/)
41 |
42 |
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/css/default.css:
--------------------------------------------------------------------------------
1 |
2 | /* The navbar is fixed at >= 980px wide, so add padding to the body to prevent
3 | content running up underneath it. */
4 |
5 | h1 {
6 | font-weight: 500;
7 | }
8 |
9 | h2, h3 {
10 | font-weight: 300;
11 | }
12 |
13 | .resource-description, .response-info {
14 | margin-bottom: 2em;
15 | }
16 | .version:before {
17 | content: "v";
18 | opacity: 0.6;
19 | padding-right: 0.25em;
20 | }
21 |
22 | .version {
23 | font-size: 70%;
24 | }
25 |
26 | .format-option {
27 | font-family: Menlo, Consolas, "Andale Mono", "Lucida Console", monospace;
28 | }
29 |
30 | .button-form {
31 | float: right;
32 | margin-right: 1em;
33 | }
34 |
35 | ul.breadcrumb {
36 | margin: 70px 0 0 0;
37 | }
38 |
39 | .breadcrumb li.active a {
40 | color: #777;
41 | }
42 |
43 | form select, form input, form textarea {
44 | width: 90%;
45 | }
46 |
47 | form select[multiple] {
48 | height: 150px;
49 | }
50 |
51 | /* To allow tooltips to work on disabled elements */
52 | .disabled-tooltip-shield {
53 | position: absolute;
54 | top: 0;
55 | right: 0;
56 | bottom: 0;
57 | left: 0;
58 | }
59 |
60 | .errorlist {
61 | margin-top: 0.5em;
62 | }
63 |
64 | pre {
65 | overflow: auto;
66 | word-wrap: normal;
67 | white-space: pre;
68 | font-size: 12px;
69 | }
70 |
71 | .page-header {
72 | border-bottom: none;
73 | padding-bottom: 0px;
74 | }
75 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/prepopulate.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.prepopulate = function(dependencies, maxLength) {
3 | /*
4 | Depends on urlify.js
5 | Populates a selected field with the values of the dependent fields,
6 | URLifies and shortens the string.
7 | dependencies - array of dependent fields ids
8 | maxLength - maximum length of the URLify'd string
9 | */
10 | return this.each(function() {
11 | var prepopulatedField = $(this);
12 |
13 | var populate = function () {
14 | // Bail if the field's value has been changed by the user
15 | if (prepopulatedField.data('_changed')) {
16 | return;
17 | }
18 |
19 | var values = [];
20 | $.each(dependencies, function(i, field) {
21 | field = $(field);
22 | if (field.val().length > 0) {
23 | values.push(field.val());
24 | }
25 | });
26 | prepopulatedField.val(URLify(values.join(' '), maxLength));
27 | };
28 |
29 | prepopulatedField.data('_changed', false);
30 | prepopulatedField.change(function() {
31 | prepopulatedField.data('_changed', true);
32 | });
33 |
34 | if (!prepopulatedField.val()) {
35 | $(dependencies.join(',')).keyup(populate).change(populate).focus(populate);
36 | }
37 | });
38 | };
39 | })(django.jQuery);
40 |
--------------------------------------------------------------------------------
/nx/models.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | from __future__ import absolute_import, division, print_function, unicode_literals
4 | import re
5 | from django.contrib import admin
6 |
7 | from django.contrib.gis.geos import Point
8 | from django.core import validators
9 | from django.utils.translation import ugettext_lazy as _
10 | from django.db import models
11 | from pygeocoder import Geocoder
12 |
13 |
14 | class Note(models.Model):
15 | username = models.CharField("用户名", max_length=30)
16 | email = models.EmailField("邮箱", blank=True)
17 | phone_number = models.CharField("手机号", max_length=11, unique=True,
18 | validators=[
19 | validators.RegexValidator(re.compile('^\+?1?\d{9,15}$'), _('Enter a valid Phone Number.'), 'invalid')
20 | ])
21 | number = models.IntegerField("数量", max_length=10)
22 | price = models.FloatField("价格", max_length=5)
23 | title = models.CharField("标题", max_length=1000)
24 | body = models.TextField("简介")
25 | province = models.CharField("省", max_length=10)
26 | city = models.CharField("市", max_length=20)
27 | address = models.CharField("地址", max_length=40)
28 | timestamp = models.DateTimeField(auto_now=True)
29 | latitude = models.FloatField(blank=True)
30 | longitude = models.FloatField(blank=True)
31 |
32 | def __unicode__(self):
33 | return self.title
34 |
35 | def save(self, *args, **kwargs):
36 | #Geocode the address
37 | results = Geocoder.geocode(self.province + self.city + self.address)
38 | self.latitude = results[0].coordinates[0]
39 | self.longitude = results[0].coordinates[1]
40 | super(Note, self).save(*args, **kwargs)
41 |
42 | def get_location(self):
43 | return Point(self.longitude, self.latitude)
44 |
45 | def get_location_info(self):
46 | return self.province + self.city + self.address
47 |
48 | admin.site.register(Note)
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/js/default.js:
--------------------------------------------------------------------------------
1 | function getCookie(c_name)
2 | {
3 | // From http://www.w3schools.com/js/js_cookies.asp
4 | var c_value = document.cookie;
5 | var c_start = c_value.indexOf(" " + c_name + "=");
6 | if (c_start == -1) {
7 | c_start = c_value.indexOf(c_name + "=");
8 | }
9 | if (c_start == -1) {
10 | c_value = null;
11 | } else {
12 | c_start = c_value.indexOf("=", c_start) + 1;
13 | var c_end = c_value.indexOf(";", c_start);
14 | if (c_end == -1) {
15 | c_end = c_value.length;
16 | }
17 | c_value = unescape(c_value.substring(c_start,c_end));
18 | }
19 | return c_value;
20 | }
21 |
22 | // JSON highlighting.
23 | prettyPrint();
24 |
25 | // Bootstrap tooltips.
26 | $('.js-tooltip').tooltip({
27 | delay: 1000,
28 | container: 'body'
29 | });
30 |
31 | // Deal with rounded tab styling after tab clicks.
32 | $('a[data-toggle="tab"]:first').on('shown', function (e) {
33 | $(e.target).parents('.tabbable').addClass('first-tab-active');
34 | });
35 | $('a[data-toggle="tab"]:not(:first)').on('shown', function (e) {
36 | $(e.target).parents('.tabbable').removeClass('first-tab-active');
37 | });
38 |
39 | $('a[data-toggle="tab"]').click(function(){
40 | document.cookie="tabstyle=" + this.name + "; path=/";
41 | });
42 |
43 | // Store tab preference in cookies & display appropriate tab on load.
44 | var selectedTab = null;
45 | var selectedTabName = getCookie('tabstyle');
46 |
47 | if (selectedTabName) {
48 | selectedTabName = selectedTabName.replace(/[^a-z-]/g, '');
49 | }
50 |
51 | if (selectedTabName) {
52 | selectedTab = $('.form-switcher a[name=' + selectedTabName + ']');
53 | }
54 |
55 | if (selectedTab && selectedTab.length > 0) {
56 | // Display whichever tab is selected.
57 | selectedTab.tab('show');
58 | } else {
59 | // If no tab selected, display rightmost tab.
60 | $('.form-switcher a:first').tab('show');
61 | }
62 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/timeparse.js:
--------------------------------------------------------------------------------
1 | var timeParsePatterns = [
2 | // 9
3 | { re: /^\d{1,2}$/i,
4 | handler: function(bits) {
5 | if (bits[0].length == 1) {
6 | return '0' + bits[0] + ':00';
7 | } else {
8 | return bits[0] + ':00';
9 | }
10 | }
11 | },
12 | // 13:00
13 | { re: /^\d{2}[:.]\d{2}$/i,
14 | handler: function(bits) {
15 | return bits[0].replace('.', ':');
16 | }
17 | },
18 | // 9:00
19 | { re: /^\d[:.]\d{2}$/i,
20 | handler: function(bits) {
21 | return '0' + bits[0].replace('.', ':');
22 | }
23 | },
24 | // 3 am / 3 a.m. / 3am
25 | { re: /^(\d+)\s*([ap])(?:.?m.?)?$/i,
26 | handler: function(bits) {
27 | var hour = parseInt(bits[1]);
28 | if (hour == 12) {
29 | hour = 0;
30 | }
31 | if (bits[2].toLowerCase() == 'p') {
32 | if (hour == 12) {
33 | hour = 0;
34 | }
35 | return (hour + 12) + ':00';
36 | } else {
37 | if (hour < 10) {
38 | return '0' + hour + ':00';
39 | } else {
40 | return hour + ':00';
41 | }
42 | }
43 | }
44 | },
45 | // 3.30 am / 3:15 a.m. / 3.00am
46 | { re: /^(\d+)[.:](\d{2})\s*([ap]).?m.?$/i,
47 | handler: function(bits) {
48 | var hour = parseInt(bits[1]);
49 | var mins = parseInt(bits[2]);
50 | if (mins < 10) {
51 | mins = '0' + mins;
52 | }
53 | if (hour == 12) {
54 | hour = 0;
55 | }
56 | if (bits[3].toLowerCase() == 'p') {
57 | if (hour == 12) {
58 | hour = 0;
59 | }
60 | return (hour + 12) + ':' + mins;
61 | } else {
62 | if (hour < 10) {
63 | return '0' + hour + ':' + mins;
64 | } else {
65 | return hour + ':' + mins;
66 | }
67 | }
68 | }
69 | },
70 | // noon
71 | { re: /^no/i,
72 | handler: function(bits) {
73 | return '12:00';
74 | }
75 | },
76 | // midnight
77 | { re: /^mid/i,
78 | handler: function(bits) {
79 | return '00:00';
80 | }
81 | }
82 | ];
83 |
84 | function parseTimeString(s) {
85 | for (var i = 0; i < timeParsePatterns.length; i++) {
86 | var re = timeParsePatterns[i].re;
87 | var handler = timeParsePatterns[i].handler;
88 | var bits = re.exec(s);
89 | if (bits) {
90 | return handler(bits);
91 | }
92 | }
93 | return s;
94 | }
95 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/actions.min.js:
--------------------------------------------------------------------------------
1 | (function(a){var f;a.fn.actions=function(q){var b=a.extend({},a.fn.actions.defaults,q),g=a(this),e=!1,m=function(c){c?k():l();a(g).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){var c=a(g).filter(":checked").length;a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:_actions_icnt},!0));a(b.allToggle).prop("checked",function(){var a;c==g.length?(a=!0,k()):(a=!1,n());return a})},k=function(){a(b.acrossClears).hide();
2 | a(b.acrossQuestions).show();a(b.allContainer).hide()},p=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},l=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},n=function(){l();a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)};a(b.counterContainer).show();a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);
3 | h();1==a(b.acrossInput).val()&&p()});a(b.allToggle).show().click(function(){m(a(this).prop("checked"));h()});a("a",b.acrossQuestions).click(function(c){c.preventDefault();a(b.acrossInput).val(1);p()});a("a",b.acrossClears).click(function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);n();m(0);h()});f=null;a(g).click(function(c){c||(c=window.event);var d=c.target?c.target:c.srcElement;if(f&&a.data(f)!=a.data(d)&&!0===c.shiftKey){var e=!1;a(f).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,
4 | d.checked);a(g).each(function(){if(a.data(this)==a.data(f)||a.data(this)==a.data(d))e=e?!1:!0;e&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);f=d;h()});a("form#changelist-form table#result_list tr").find("td:gt(0) :input").change(function(){e=!0});a('form#changelist-form button[name="index"]').click(function(a){if(e)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});
5 | a('form#changelist-form input[name="_save"]').click(function(c){var d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return e?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})};
6 | a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"}})(django.jQuery);
7 |
--------------------------------------------------------------------------------
/nx2django/static/rest_framework/css/bootstrap-tweaks.css:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This CSS file contains some tweaks specific to the included Bootstrap theme.
4 | It's separate from `style.css` so that it can be easily overridden by replacing
5 | a single block in the template.
6 |
7 | */
8 |
9 | .form-actions {
10 | background: transparent;
11 | border-top-color: transparent;
12 | padding-top: 0;
13 | text-align: right;
14 | }
15 |
16 | #generic-content-form textarea {
17 | font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;
18 | font-size: 80%;
19 | }
20 |
21 | .navbar-inverse .brand a {
22 | color: #999999;
23 | }
24 | .navbar-inverse .brand:hover a {
25 | color: white;
26 | text-decoration: none;
27 | }
28 |
29 | /* custom navigation styles */
30 | .navbar {
31 | width: 100%;
32 | position: fixed;
33 | left: 0;
34 | top: 0;
35 | z-index: 3;
36 | }
37 |
38 | .navbar {
39 | background: #2C2C2C;
40 | color: white;
41 | border: none;
42 | border-top: 5px solid #A30000;
43 | border-radius: 0px;
44 | }
45 |
46 | .navbar .nav li, .navbar .nav li a, .navbar .brand:hover {
47 | color: white;
48 | }
49 |
50 | .nav-list > .active > a, .nav-list > .active > a:hover {
51 | background: #2C2C2C;
52 | }
53 |
54 | .navbar .dropdown-menu li a, .navbar .dropdown-menu li {
55 | color: #A30000;
56 | }
57 |
58 | .navbar .dropdown-menu li a:hover {
59 | background: #EEEEEE;
60 | color: #C20000;
61 | }
62 |
63 | .pagination>.disabled>a,
64 | .pagination>.disabled>a:hover,
65 | .pagination>.disabled>a:focus {
66 | cursor: not-allowed;
67 | pointer-events: none;
68 | }
69 |
70 | .pager>.disabled>a,
71 | .pager>.disabled>a:hover,
72 | .pager>.disabled>a:focus {
73 | pointer-events: none;
74 | }
75 |
76 | .pager .next {
77 | margin-left: 10px;
78 | }
79 |
80 | /*=== dabapps bootstrap styles ====*/
81 |
82 | html {
83 | width:100%;
84 | background: none;
85 | }
86 |
87 | /*body, .navbar .container-fluid {
88 | max-width: 1150px;
89 | margin: 0 auto;
90 | }*/
91 |
92 | body {
93 | background: url("../img/grid.png") repeat-x;
94 | background-attachment: fixed;
95 | }
96 |
97 | #content {
98 | margin: 0;
99 | padding-bottom: 60px;
100 | }
101 |
102 | /* sticky footer and footer */
103 | html, body {
104 | height: 100%;
105 | }
106 |
107 | .wrapper {
108 | position: relative;
109 | top: 0;
110 | left: 0;
111 | padding-top: 60px;
112 | margin: -60px 0;
113 | min-height: 100%;
114 | }
115 |
116 | .form-switcher {
117 | margin-bottom: 0;
118 | }
119 |
120 | .well {
121 | -webkit-box-shadow: none;
122 | -moz-box-shadow: none;
123 | box-shadow: none;
124 | }
125 |
126 | .well .form-actions {
127 | padding-bottom: 0;
128 | margin-bottom: 0;
129 | }
130 |
131 | .well form {
132 | margin-bottom: 0;
133 | }
134 |
135 | .nav-tabs {
136 | border: 0;
137 | }
138 |
139 | .nav-tabs > li {
140 | float: right;
141 | }
142 |
143 | .nav-tabs li a {
144 | margin-right: 0;
145 | }
146 |
147 | .nav-tabs > .active > a {
148 | background: #F5F5F5;
149 | }
150 |
151 | .nav-tabs > .active > a:hover {
152 | background: #F5F5F5;
153 | }
154 |
155 | .tabbable.first-tab-active .tab-content {
156 | border-top-right-radius: 0;
157 | }
158 |
159 | footer {
160 | position: absolute;
161 | bottom: 0;
162 | left: 0;
163 | clear: both;
164 | z-index: 10;
165 | height: 60px;
166 | width: 95%;
167 | margin: 0 2.5%;
168 | }
169 |
170 | footer p {
171 | text-align: center;
172 | color: gray;
173 | border-top: 1px solid #DDDDDD;
174 | padding-top: 10px;
175 | }
176 |
177 | footer a {
178 | color: gray !important;
179 | font-weight: bold;
180 | }
181 |
182 | footer a:hover {
183 | color: gray;
184 | }
185 |
186 | .page-header {
187 | border-bottom: none;
188 | padding-bottom: 0px;
189 | margin: 0;
190 | }
191 |
192 | /* custom general page styles */
193 | .hero-unit h1, .hero-unit h2 {
194 | color: #A30000;
195 | }
196 |
197 | body a {
198 | color: #A30000;
199 | }
200 |
201 | body a:hover {
202 | color: #c20000;
203 | }
204 |
205 | .request-info {
206 | clear:both;
207 | }
208 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/inlines.min.js:
--------------------------------------------------------------------------------
1 | (function(a){a.fn.formset=function(g){var b=a.extend({},a.fn.formset.defaults,g),i=a(this);g=i.parent();var m=function(e,k,h){var j=RegExp("("+k+"-(\\d+|__prefix__))");k=k+"-"+h;a(e).prop("for")&&a(e).prop("for",a(e).prop("for").replace(j,k));if(e.id)e.id=e.id.replace(j,k);if(e.name)e.name=e.name.replace(j,k)},l=a("#id_"+b.prefix+"-TOTAL_FORMS").prop("autocomplete","off"),d=parseInt(l.val(),10),c=a("#id_"+b.prefix+"-MAX_NUM_FORMS").prop("autocomplete","off");l=c.val()===""||c.val()-l.val()>0;i.each(function(){a(this).not("."+
2 | b.emptyCssClass).addClass(b.formCssClass)});if(i.length&&l){var f;if(i.prop("tagName")=="TR"){i=this.eq(-1).children().length;g.append('
| '+b.addText+" |
");f=g.find("tr:last a")}else{i.filter(":last").after('");f=i.filter(":last").next().find("a")}f.click(function(e){e.preventDefault();var k=a("#id_"+b.prefix+"-TOTAL_FORMS");e=a("#"+
3 | b.prefix+"-empty");var h=e.clone(true);h.removeClass(b.emptyCssClass).addClass(b.formCssClass).attr("id",b.prefix+"-"+d);if(h.is("tr"))h.children(":last").append('");else h.is("ul")||h.is("ol")?h.append(''+b.deleteText+""):h.children(":first").append(''+b.deleteText+"");
4 | h.find("*").each(function(){m(this,b.prefix,k.val())});h.insertBefore(a(e));a(k).val(parseInt(k.val(),10)+1);d+=1;c.val()!==""&&c.val()-k.val()<=0&&f.parent().hide();h.find("a."+b.deleteCssClass).click(function(j){j.preventDefault();j=a(this).parents("."+b.formCssClass);j.remove();d-=1;b.removed&&b.removed(j);j=a("."+b.formCssClass);a("#id_"+b.prefix+"-TOTAL_FORMS").val(j.length);if(c.val()===""||c.val()-j.length>0)f.parent().show();for(var n=0,o=j.length;n b) return 1;
100 | if (a < b) return -1;
101 | }
102 | catch (e) {
103 | // silently fail on IE 'unknown' exception
104 | }
105 | return 0;
106 | } );
107 | },
108 | select_all: function(id) {
109 | var box = document.getElementById(id);
110 | for (var i = 0; i < box.options.length; i++) {
111 | box.options[i].selected = 'selected';
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/nx2django/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for nx2django project.
3 |
4 | For more information on this file, see
5 | https://docs.djangoproject.com/en/1.7/topics/settings/
6 |
7 | For the full list of settings and their values, see
8 | https://docs.djangoproject.com/en/1.7/ref/settings/
9 | """
10 |
11 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
12 | import os
13 | BASE_DIR = os.path.dirname(os.path.dirname(__file__))
14 |
15 |
16 | #########
17 | # PATHS #
18 | #########
19 |
20 | # Full filesystem path to the project.
21 | PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
22 |
23 | # Name of the directory for the project.
24 | PROJECT_DIRNAME = PROJECT_ROOT.split(os.sep)[-1]
25 |
26 | # Every cache key will get prefixed with this value - here we set it to
27 | # the name of the directory the project is in to try and use something
28 | # project specific.
29 | CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_DIRNAME
30 |
31 | # URL prefix for static files.
32 | # Example: "http://media.lawrence.com/static/"
33 | STATIC_URL = "/static/"
34 |
35 | # Absolute path to the directory static files should be collected to.
36 | # Don't put anything in this directory yourself; store your static files
37 | # in apps' "static/" subdirectories and in STATICFILES_DIRS.
38 | # Example: "/home/media/media.lawrence.com/static/"
39 | STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/"))
40 |
41 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a
42 | # trailing slash.
43 | # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
44 | MEDIA_URL = STATIC_URL + "media/"
45 |
46 | # Absolute filesystem path to the directory that will hold user-uploaded files.
47 | # Example: "/home/media/media.lawrence.com/media/"
48 | MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))
49 |
50 | # Package/module name to import the root urlpatterns from for the project.
51 | ROOT_URLCONF = "%s.urls" % PROJECT_DIRNAME
52 |
53 | # Put strings here, like "/home/html/django_templates"
54 | # or "C:/www/django/templates".
55 | # Always use forward slashes, even on Windows.
56 | # Don't forget to use absolute paths, not relative paths.
57 | TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, "templates"),)
58 |
59 | # Quick-start development settings - unsuitable for production
60 | # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
61 |
62 | # SECURITY WARNING: keep the secret key used in production secret!
63 | SECRET_KEY = 'y_6zps4!7ax_u^dvo#i0i1jy0=u4jsjger2v)_3(9n_buq=$e('
64 |
65 | # SECURITY WARNING: don't run with debug turned on in production!
66 | DEBUG = True
67 |
68 | TEMPLATE_DEBUG = True
69 |
70 | ALLOWED_HOSTS = []
71 |
72 |
73 | # Application definition
74 |
75 | INSTALLED_APPS = (
76 | "grappelli",
77 | 'django.contrib.admin',
78 | 'django.contrib.auth',
79 | 'django.contrib.contenttypes',
80 | 'django.contrib.sessions',
81 | 'django.contrib.messages',
82 | 'django.contrib.staticfiles',
83 | "haystack",
84 | "rest_framework",
85 | "nx",
86 | )
87 |
88 | MIDDLEWARE_CLASSES = (
89 | 'django.contrib.sessions.middleware.SessionMiddleware',
90 | 'django.middleware.common.CommonMiddleware',
91 | 'django.middleware.csrf.CsrfViewMiddleware',
92 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
93 | 'django.contrib.messages.middleware.MessageMiddleware',
94 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
95 | )
96 |
97 | TEMPLATE_CONTEXT_PROCESSORS = (
98 | "django.contrib.auth.context_processors.auth",
99 | "django.contrib.messages.context_processors.messages",
100 | "django.core.context_processors.debug",
101 | "django.core.context_processors.i18n",
102 | "django.core.context_processors.static",
103 | "django.core.context_processors.media",
104 | "django.core.context_processors.request",
105 | "django.core.context_processors.tz",
106 | )
107 |
108 | ROOT_URLCONF = 'nx2django.urls'
109 |
110 | WSGI_APPLICATION = 'nx2django.wsgi.application'
111 |
112 |
113 | # Database
114 | # https://docs.djangoproject.com/en/1.7/ref/settings/#databases
115 |
116 | DATABASES = {
117 | 'default': {
118 | 'ENGINE': 'django.db.backends.sqlite3',
119 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
120 | }
121 | }
122 |
123 | # Internationalization
124 | # https://docs.djangoproject.com/en/1.7/topics/i18n/
125 |
126 | LANGUAGE_CODE = 'en-us'
127 |
128 | TIME_ZONE = 'UTC'
129 |
130 | USE_I18N = True
131 |
132 | USE_L10N = True
133 |
134 | USE_TZ = True
135 |
136 |
137 | # Static files (CSS, JavaScript, Images)
138 | # https://docs.djangoproject.com/en/1.7/howto/static-files/
139 |
140 | STATIC_URL = '/static/'
141 |
142 | HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
143 |
144 | HAYSTACK_CONNECTIONS = {
145 | 'default': {
146 | 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
147 | 'URL': 'http://127.0.0.1:9200/',
148 | 'INDEX_NAME': 'django',
149 | },
150 | }
--------------------------------------------------------------------------------
/nx2django/static/admin/js/admin/RelatedObjectLookups.js:
--------------------------------------------------------------------------------
1 | // Handles related-objects functionality: lookup link for raw_id_fields
2 | // and Add Another links.
3 |
4 | function html_unescape(text) {
5 | // Unescape a string that was escaped using django.utils.html.escape.
6 | text = text.replace(/</g, '<');
7 | text = text.replace(/>/g, '>');
8 | text = text.replace(/"/g, '"');
9 | text = text.replace(/'/g, "'");
10 | text = text.replace(/&/g, '&');
11 | return text;
12 | }
13 |
14 | // IE doesn't accept periods or dashes in the window name, but the element IDs
15 | // we use to generate popup window names may contain them, therefore we map them
16 | // to allowed characters in a reversible way so that we can locate the correct
17 | // element when the popup window is dismissed.
18 | function id_to_windowname(text) {
19 | text = text.replace(/\./g, '__dot__');
20 | text = text.replace(/\-/g, '__dash__');
21 | return text;
22 | }
23 |
24 | function windowname_to_id(text) {
25 | text = text.replace(/__dot__/g, '.');
26 | text = text.replace(/__dash__/g, '-');
27 | return text;
28 | }
29 |
30 | function showAdminPopup(triggeringLink, name_regexp) {
31 | var name = triggeringLink.id.replace(name_regexp, '');
32 | name = id_to_windowname(name);
33 | var href = triggeringLink.href;
34 | if (href.indexOf('?') == -1) {
35 | href += '?_popup=1';
36 | } else {
37 | href += '&_popup=1';
38 | }
39 | var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
40 | win.focus();
41 | return false;
42 | }
43 |
44 | function showRelatedObjectLookupPopup(triggeringLink) {
45 | return showAdminPopup(triggeringLink, /^lookup_/);
46 | }
47 |
48 | function dismissRelatedLookupPopup(win, chosenId) {
49 | var name = windowname_to_id(win.name);
50 | var elem = document.getElementById(name);
51 | if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
52 | elem.value += ',' + chosenId;
53 | } else {
54 | document.getElementById(name).value = chosenId;
55 | }
56 | win.close();
57 | }
58 |
59 | function showRelatedObjectPopup(triggeringLink) {
60 | var name = triggeringLink.id.replace(/^(change|add|delete)_/, '');
61 | name = id_to_windowname(name);
62 | var href = triggeringLink.href;
63 | var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
64 | win.focus();
65 | return false;
66 | }
67 |
68 | function dismissAddRelatedObjectPopup(win, newId, newRepr) {
69 | // newId and newRepr are expected to have previously been escaped by
70 | // django.utils.html.escape.
71 | newId = html_unescape(newId);
72 | newRepr = html_unescape(newRepr);
73 | var name = windowname_to_id(win.name);
74 | var elem = document.getElementById(name);
75 | var o;
76 | if (elem) {
77 | var elemName = elem.nodeName.toUpperCase();
78 | if (elemName == 'SELECT') {
79 | o = new Option(newRepr, newId);
80 | elem.options[elem.options.length] = o;
81 | o.selected = true;
82 | } else if (elemName == 'INPUT') {
83 | if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
84 | elem.value += ',' + newId;
85 | } else {
86 | elem.value = newId;
87 | }
88 | }
89 | // Trigger a change event to update related links if required.
90 | django.jQuery(elem).trigger('change');
91 | } else {
92 | var toId = name + "_to";
93 | o = new Option(newRepr, newId);
94 | SelectBox.add_to_cache(toId, o);
95 | SelectBox.redisplay(toId);
96 | }
97 | win.close();
98 | }
99 |
100 | function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
101 | objId = html_unescape(objId);
102 | newRepr = html_unescape(newRepr);
103 | var id = windowname_to_id(win.name).replace(/^edit_/, '');
104 | var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
105 | var selects = django.jQuery(selectsSelector);
106 | selects.find('option').each(function() {
107 | if (this.value == objId) {
108 | this.innerHTML = newRepr;
109 | this.value = newId;
110 | }
111 | });
112 | win.close();
113 | };
114 |
115 | function dismissDeleteRelatedObjectPopup(win, objId) {
116 | objId = html_unescape(objId);
117 | var id = windowname_to_id(win.name).replace(/^delete_/, '');
118 | var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
119 | var selects = django.jQuery(selectsSelector);
120 | selects.find('option').each(function() {
121 | if (this.value == objId) {
122 | django.jQuery(this).remove();
123 | }
124 | }).trigger('change');
125 | win.close();
126 | };
127 |
128 | // Kept for backward compatibility
129 | showAddAnotherPopup = showRelatedObjectPopup;
130 | dismissAddAnotherPopup = dismissAddRelatedObjectPopup;
131 |
--------------------------------------------------------------------------------
/nx2django/static/admin/css/rtl.css:
--------------------------------------------------------------------------------
1 | body {
2 | direction: rtl;
3 | }
4 |
5 | /* LOGIN */
6 |
7 | .login .form-row {
8 | float: right;
9 | }
10 |
11 | .login .form-row label {
12 | float: right;
13 | padding-left: 0.5em;
14 | padding-right: 0;
15 | text-align: left;
16 | }
17 |
18 | .login .submit-row {
19 | clear: both;
20 | padding: 1em 9.4em 0 0;
21 | }
22 |
23 | /* GLOBAL */
24 |
25 | th {
26 | text-align: right;
27 | }
28 |
29 | .module h2, .module caption {
30 | text-align: right;
31 | }
32 |
33 | .addlink, .changelink {
34 | padding-left: 0px;
35 | padding-right: 12px;
36 | background-position: 100% 0.2em;
37 | }
38 |
39 | .deletelink {
40 | padding-left: 0px;
41 | padding-right: 12px;
42 | background-position: 100% 0.25em;
43 | }
44 |
45 | .object-tools {
46 | float: left;
47 | }
48 |
49 | thead th:first-child,
50 | tfoot td:first-child {
51 | border-left: 1px solid #ddd !important;
52 | }
53 |
54 | /* LAYOUT */
55 |
56 | #user-tools {
57 | right: auto;
58 | left: 0;
59 | text-align: left;
60 | }
61 |
62 | div.breadcrumbs {
63 | text-align: right;
64 | }
65 |
66 | #content-main {
67 | float: right;
68 | }
69 |
70 | #content-related {
71 | float: left;
72 | margin-left: -19em;
73 | margin-right: auto;
74 | }
75 |
76 | .colMS {
77 | margin-left: 20em !important;
78 | margin-right: 10px !important;
79 | }
80 |
81 | /* SORTABLE TABLES */
82 |
83 | table thead th.sorted .sortoptions {
84 | float: left;
85 | }
86 |
87 | thead th.sorted .text {
88 | padding-right: 0;
89 | padding-left: 42px;
90 | }
91 |
92 | /* dashboard styles */
93 |
94 | .dashboard .module table td a {
95 | padding-left: .6em;
96 | padding-right: 12px;
97 | }
98 |
99 | /* changelists styles */
100 |
101 | .change-list .filtered {
102 | background: white url(../img/changelist-bg_rtl.gif) top left repeat-y !important;
103 | }
104 |
105 | .change-list .filtered table {
106 | border-left: 1px solid #ddd;
107 | border-right: 0px none;
108 | }
109 |
110 | #changelist-filter {
111 | right: auto;
112 | left: 0;
113 | border-left: 0px none;
114 | border-right: 1px solid #ddd;
115 | }
116 |
117 | .change-list .filtered .results, .change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull {
118 | margin-right: 0px !important;
119 | margin-left: 160px !important;
120 | }
121 |
122 | #changelist-filter li.selected {
123 | border-left: 0px none;
124 | padding-left: 0px;
125 | margin-left: 0;
126 | border-right: 5px solid #ccc;
127 | padding-right: 5px;
128 | margin-right: -10px;
129 | }
130 |
131 | .filtered .actions {
132 | border-left:1px solid #DDDDDD;
133 | margin-left:160px !important;
134 | border-right: 0 none;
135 | margin-right:0 !important;
136 | }
137 |
138 | #changelist table tbody td:first-child, #changelist table tbody th:first-child {
139 | border-right: 0;
140 | border-left: 1px solid #ddd;
141 | }
142 |
143 | /* FORMS */
144 |
145 | .aligned label {
146 | padding: 0 0 3px 1em;
147 | float: right;
148 | }
149 |
150 | .submit-row {
151 | text-align: left
152 | }
153 |
154 | .submit-row p.deletelink-box {
155 | float: right;
156 | }
157 |
158 | .submit-row .deletelink {
159 | background: url(../img/icon_deletelink.gif) 0 50% no-repeat;
160 | padding-right: 14px;
161 | }
162 |
163 | .vDateField, .vTimeField {
164 | margin-left: 2px;
165 | }
166 |
167 | form ul.inline li {
168 | float: right;
169 | padding-right: 0;
170 | padding-left: 7px;
171 | }
172 |
173 | input[type=submit].default, .submit-row input.default {
174 | float: left;
175 | }
176 |
177 | fieldset .field-box {
178 | float: right;
179 | margin-left: 20px;
180 | margin-right: 0;
181 | }
182 |
183 | .errorlist li {
184 | background-position: 100% .3em;
185 | padding: 4px 25px 4px 5px;
186 | }
187 |
188 | .errornote {
189 | background-position: 100% .3em;
190 | padding: 4px 25px 4px 5px;
191 | }
192 |
193 | /* WIDGETS */
194 |
195 | .calendarnav-previous {
196 | top: 0;
197 | left: auto;
198 | right: 0;
199 | }
200 |
201 | .calendarnav-next {
202 | top: 0;
203 | right: auto;
204 | left: 0;
205 | }
206 |
207 | .calendar caption, .calendarbox h2 {
208 | text-align: center;
209 | }
210 |
211 | .selector {
212 | float: right;
213 | }
214 |
215 | .selector .selector-filter {
216 | text-align: right;
217 | }
218 |
219 | .inline-deletelink {
220 | float: left;
221 | }
222 |
223 | /* MISC */
224 |
225 | .inline-related h2, .inline-group h2 {
226 | text-align: right
227 | }
228 |
229 | .inline-related h3 span.delete {
230 | padding-right: 20px;
231 | padding-left: inherit;
232 | left: 10px;
233 | right: inherit;
234 | float:left;
235 | }
236 |
237 | .inline-related h3 span.delete label {
238 | margin-left: inherit;
239 | margin-right: 2px;
240 | }
241 |
242 | /* IE7 specific bug fixes */
243 |
244 | div.colM {
245 | position: relative;
246 | }
247 |
248 | .submit-row input {
249 | float: left;
250 | }
251 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/actions.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | var lastChecked;
3 |
4 | $.fn.actions = function(opts) {
5 | var options = $.extend({}, $.fn.actions.defaults, opts);
6 | var actionCheckboxes = $(this);
7 | var list_editable_changed = false;
8 | var checker = function(checked) {
9 | if (checked) {
10 | showQuestion();
11 | } else {
12 | reset();
13 | }
14 | $(actionCheckboxes).prop("checked", checked)
15 | .parent().parent().toggleClass(options.selectedClass, checked);
16 | },
17 | updateCounter = function() {
18 | var sel = $(actionCheckboxes).filter(":checked").length;
19 | // _actions_icnt is defined in the generated HTML
20 | // and contains the total amount of objects in the queryset
21 | $(options.counterContainer).html(interpolate(
22 | ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), {
23 | sel: sel,
24 | cnt: _actions_icnt
25 | }, true));
26 | $(options.allToggle).prop("checked", function() {
27 | var value;
28 | if (sel == actionCheckboxes.length) {
29 | value = true;
30 | showQuestion();
31 | } else {
32 | value = false;
33 | clearAcross();
34 | }
35 | return value;
36 | });
37 | },
38 | showQuestion = function() {
39 | $(options.acrossClears).hide();
40 | $(options.acrossQuestions).show();
41 | $(options.allContainer).hide();
42 | },
43 | showClear = function() {
44 | $(options.acrossClears).show();
45 | $(options.acrossQuestions).hide();
46 | $(options.actionContainer).toggleClass(options.selectedClass);
47 | $(options.allContainer).show();
48 | $(options.counterContainer).hide();
49 | },
50 | reset = function() {
51 | $(options.acrossClears).hide();
52 | $(options.acrossQuestions).hide();
53 | $(options.allContainer).hide();
54 | $(options.counterContainer).show();
55 | },
56 | clearAcross = function() {
57 | reset();
58 | $(options.acrossInput).val(0);
59 | $(options.actionContainer).removeClass(options.selectedClass);
60 | };
61 | // Show counter by default
62 | $(options.counterContainer).show();
63 | // Check state of checkboxes and reinit state if needed
64 | $(this).filter(":checked").each(function(i) {
65 | $(this).parent().parent().toggleClass(options.selectedClass);
66 | updateCounter();
67 | if ($(options.acrossInput).val() == 1) {
68 | showClear();
69 | }
70 | });
71 | $(options.allToggle).show().click(function() {
72 | checker($(this).prop("checked"));
73 | updateCounter();
74 | });
75 | $("a", options.acrossQuestions).click(function(event) {
76 | event.preventDefault();
77 | $(options.acrossInput).val(1);
78 | showClear();
79 | });
80 | $("a", options.acrossClears).click(function(event) {
81 | event.preventDefault();
82 | $(options.allToggle).prop("checked", false);
83 | clearAcross();
84 | checker(0);
85 | updateCounter();
86 | });
87 | lastChecked = null;
88 | $(actionCheckboxes).click(function(event) {
89 | if (!event) { event = window.event; }
90 | var target = event.target ? event.target : event.srcElement;
91 | if (lastChecked && $.data(lastChecked) != $.data(target) && event.shiftKey === true) {
92 | var inrange = false;
93 | $(lastChecked).prop("checked", target.checked)
94 | .parent().parent().toggleClass(options.selectedClass, target.checked);
95 | $(actionCheckboxes).each(function() {
96 | if ($.data(this) == $.data(lastChecked) || $.data(this) == $.data(target)) {
97 | inrange = (inrange) ? false : true;
98 | }
99 | if (inrange) {
100 | $(this).prop("checked", target.checked)
101 | .parent().parent().toggleClass(options.selectedClass, target.checked);
102 | }
103 | });
104 | }
105 | $(target).parent().parent().toggleClass(options.selectedClass, target.checked);
106 | lastChecked = target;
107 | updateCounter();
108 | });
109 | $('form#changelist-form table#result_list tr').find('td:gt(0) :input').change(function() {
110 | list_editable_changed = true;
111 | });
112 | $('form#changelist-form button[name="index"]').click(function(event) {
113 | if (list_editable_changed) {
114 | return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."));
115 | }
116 | });
117 | $('form#changelist-form input[name="_save"]').click(function(event) {
118 | var action_changed = false;
119 | $('select option:selected', options.actionContainer).each(function() {
120 | if ($(this).val()) {
121 | action_changed = true;
122 | }
123 | });
124 | if (action_changed) {
125 | if (list_editable_changed) {
126 | return confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action."));
127 | } else {
128 | return confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."));
129 | }
130 | }
131 | });
132 | };
133 | /* Setup plugin defaults */
134 | $.fn.actions.defaults = {
135 | actionContainer: "div.actions",
136 | counterContainer: "span.action-counter",
137 | allContainer: "div.actions span.all",
138 | acrossInput: "div.actions input.select-across",
139 | acrossQuestions: "div.actions span.question",
140 | acrossClears: "div.actions span.clear",
141 | allToggle: "#action-toggle",
142 | selectedClass: "selected"
143 | };
144 | })(django.jQuery);
145 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/urlify.js:
--------------------------------------------------------------------------------
1 | var LATIN_MAP = {
2 | 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE', 'Ç':
3 | 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', 'Î': 'I',
4 | 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö':
5 | 'O', 'Ő': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', 'Ü': 'U', 'Ű': 'U',
6 | 'Ý': 'Y', 'Þ': 'TH', 'Ÿ': 'Y', 'ß': 'ss', 'à':'a', 'á':'a', 'â': 'a', 'ã':
7 | 'a', 'ä': 'a', 'å': 'a', 'æ': 'ae', 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e',
8 | 'ë': 'e', 'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', 'ð': 'd', 'ñ': 'n', 'ò':
9 | 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ő': 'o', 'ø': 'o', 'ù': 'u',
10 | 'ú': 'u', 'û': 'u', 'ü': 'u', 'ű': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y'
11 | };
12 | var LATIN_SYMBOLS_MAP = {
13 | '©':'(c)'
14 | };
15 | var GREEK_MAP = {
16 | 'α':'a', 'β':'b', 'γ':'g', 'δ':'d', 'ε':'e', 'ζ':'z', 'η':'h', 'θ':'8',
17 | 'ι':'i', 'κ':'k', 'λ':'l', 'μ':'m', 'ν':'n', 'ξ':'3', 'ο':'o', 'π':'p',
18 | 'ρ':'r', 'σ':'s', 'τ':'t', 'υ':'y', 'φ':'f', 'χ':'x', 'ψ':'ps', 'ω':'w',
19 | 'ά':'a', 'έ':'e', 'ί':'i', 'ό':'o', 'ύ':'y', 'ή':'h', 'ώ':'w', 'ς':'s',
20 | 'ϊ':'i', 'ΰ':'y', 'ϋ':'y', 'ΐ':'i',
21 | 'Α':'A', 'Β':'B', 'Γ':'G', 'Δ':'D', 'Ε':'E', 'Ζ':'Z', 'Η':'H', 'Θ':'8',
22 | 'Ι':'I', 'Κ':'K', 'Λ':'L', 'Μ':'M', 'Ν':'N', 'Ξ':'3', 'Ο':'O', 'Π':'P',
23 | 'Ρ':'R', 'Σ':'S', 'Τ':'T', 'Υ':'Y', 'Φ':'F', 'Χ':'X', 'Ψ':'PS', 'Ω':'W',
24 | 'Ά':'A', 'Έ':'E', 'Ί':'I', 'Ό':'O', 'Ύ':'Y', 'Ή':'H', 'Ώ':'W', 'Ϊ':'I',
25 | 'Ϋ':'Y'
26 | };
27 | var TURKISH_MAP = {
28 | 'ş':'s', 'Ş':'S', 'ı':'i', 'İ':'I', 'ç':'c', 'Ç':'C', 'ü':'u', 'Ü':'U',
29 | 'ö':'o', 'Ö':'O', 'ğ':'g', 'Ğ':'G'
30 | };
31 | var RUSSIAN_MAP = {
32 | 'а':'a', 'б':'b', 'в':'v', 'г':'g', 'д':'d', 'е':'e', 'ё':'yo', 'ж':'zh',
33 | 'з':'z', 'и':'i', 'й':'j', 'к':'k', 'л':'l', 'м':'m', 'н':'n', 'о':'o',
34 | 'п':'p', 'р':'r', 'с':'s', 'т':'t', 'у':'u', 'ф':'f', 'х':'h', 'ц':'c',
35 | 'ч':'ch', 'ш':'sh', 'щ':'sh', 'ъ':'', 'ы':'y', 'ь':'', 'э':'e', 'ю':'yu',
36 | 'я':'ya',
37 | 'А':'A', 'Б':'B', 'В':'V', 'Г':'G', 'Д':'D', 'Е':'E', 'Ё':'Yo', 'Ж':'Zh',
38 | 'З':'Z', 'И':'I', 'Й':'J', 'К':'K', 'Л':'L', 'М':'M', 'Н':'N', 'О':'O',
39 | 'П':'P', 'Р':'R', 'С':'S', 'Т':'T', 'У':'U', 'Ф':'F', 'Х':'H', 'Ц':'C',
40 | 'Ч':'Ch', 'Ш':'Sh', 'Щ':'Sh', 'Ъ':'', 'Ы':'Y', 'Ь':'', 'Э':'E', 'Ю':'Yu',
41 | 'Я':'Ya'
42 | };
43 | var UKRAINIAN_MAP = {
44 | 'Є':'Ye', 'І':'I', 'Ї':'Yi', 'Ґ':'G', 'є':'ye', 'і':'i', 'ї':'yi', 'ґ':'g'
45 | };
46 | var CZECH_MAP = {
47 | 'č':'c', 'ď':'d', 'ě':'e', 'ň': 'n', 'ř':'r', 'š':'s', 'ť':'t', 'ů':'u',
48 | 'ž':'z', 'Č':'C', 'Ď':'D', 'Ě':'E', 'Ň': 'N', 'Ř':'R', 'Š':'S', 'Ť':'T',
49 | 'Ů':'U', 'Ž':'Z'
50 | };
51 | var POLISH_MAP = {
52 | 'ą':'a', 'ć':'c', 'ę':'e', 'ł':'l', 'ń':'n', 'ó':'o', 'ś':'s', 'ź':'z',
53 | 'ż':'z', 'Ą':'A', 'Ć':'C', 'Ę':'E', 'Ł':'L', 'Ń':'N', 'Ó':'O', 'Ś':'S',
54 | 'Ź':'Z', 'Ż':'Z'
55 | };
56 | var LATVIAN_MAP = {
57 | 'ā':'a', 'č':'c', 'ē':'e', 'ģ':'g', 'ī':'i', 'ķ':'k', 'ļ':'l', 'ņ':'n',
58 | 'š':'s', 'ū':'u', 'ž':'z', 'Ā':'A', 'Č':'C', 'Ē':'E', 'Ģ':'G', 'Ī':'I',
59 | 'Ķ':'K', 'Ļ':'L', 'Ņ':'N', 'Š':'S', 'Ū':'U', 'Ž':'Z'
60 | };
61 | var ARABIC_MAP = {
62 | 'أ':'a', 'ب':'b', 'ت':'t', 'ث': 'th', 'ج':'g', 'ح':'h', 'خ':'kh', 'د':'d',
63 | 'ذ':'th', 'ر':'r', 'ز':'z', 'س':'s', 'ش':'sh', 'ص':'s', 'ض':'d', 'ط':'t',
64 | 'ظ':'th', 'ع':'aa', 'غ':'gh', 'ف':'f', 'ق':'k', 'ك':'k', 'ل':'l', 'م':'m',
65 | 'ن':'n', 'ه':'h', 'و':'o', 'ي':'y'
66 | };
67 | var LITHUANIAN_MAP = {
68 | 'ą':'a', 'č':'c', 'ę':'e', 'ė':'e', 'į':'i', 'š':'s', 'ų':'u', 'ū':'u',
69 | 'ž':'z',
70 | 'Ą':'A', 'Č':'C', 'Ę':'E', 'Ė':'E', 'Į':'I', 'Š':'S', 'Ų':'U', 'Ū':'U',
71 | 'Ž':'Z'
72 | };
73 | var SERBIAN_MAP = {
74 | 'ђ':'dj', 'ј':'j', 'љ':'lj', 'њ':'nj', 'ћ':'c', 'џ':'dz', 'đ':'dj',
75 | 'Ђ':'Dj', 'Ј':'j', 'Љ':'Lj', 'Њ':'Nj', 'Ћ':'C', 'Џ':'Dz', 'Đ':'Dj'
76 | };
77 | var AZERBAIJANI_MAP = {
78 | 'ç':'c', 'ə':'e', 'ğ':'g', 'ı':'i', 'ö':'o', 'ş':'s', 'ü':'u',
79 | 'Ç':'C', 'Ə':'E', 'Ğ':'G', 'İ':'I', 'Ö':'O', 'Ş':'S', 'Ü':'U'
80 | };
81 |
82 | var ALL_DOWNCODE_MAPS = [
83 | LATIN_MAP,
84 | LATIN_SYMBOLS_MAP,
85 | GREEK_MAP,
86 | TURKISH_MAP,
87 | RUSSIAN_MAP,
88 | UKRAINIAN_MAP,
89 | CZECH_MAP,
90 | POLISH_MAP,
91 | LATVIAN_MAP,
92 | ARABIC_MAP,
93 | LITHUANIAN_MAP,
94 | SERBIAN_MAP,
95 | AZERBAIJANI_MAP
96 | ];
97 |
98 | var Downcoder = {
99 | 'Initialize': function() {
100 | if (Downcoder.map) { // already made
101 | return;
102 | }
103 | Downcoder.map = {};
104 | Downcoder.chars = [];
105 | for (var i=0; i=0) && parseFloat(navigator.appVersion);
5 | var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
6 |
7 | // Cross-browser event handlers.
8 | function addEvent(obj, evType, fn) {
9 | if (obj.addEventListener) {
10 | obj.addEventListener(evType, fn, false);
11 | return true;
12 | } else if (obj.attachEvent) {
13 | var r = obj.attachEvent("on" + evType, fn);
14 | return r;
15 | } else {
16 | return false;
17 | }
18 | }
19 |
20 | function removeEvent(obj, evType, fn) {
21 | if (obj.removeEventListener) {
22 | obj.removeEventListener(evType, fn, false);
23 | return true;
24 | } else if (obj.detachEvent) {
25 | obj.detachEvent("on" + evType, fn);
26 | return true;
27 | } else {
28 | return false;
29 | }
30 | }
31 |
32 | function cancelEventPropagation(e) {
33 | if (!e) e = window.event;
34 | e.cancelBubble = true;
35 | if (e.stopPropagation) e.stopPropagation();
36 | }
37 |
38 | // quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
39 | function quickElement() {
40 | var obj = document.createElement(arguments[0]);
41 | if (arguments[2]) {
42 | var textNode = document.createTextNode(arguments[2]);
43 | obj.appendChild(textNode);
44 | }
45 | var len = arguments.length;
46 | for (var i = 3; i < len; i += 2) {
47 | obj.setAttribute(arguments[i], arguments[i+1]);
48 | }
49 | arguments[1].appendChild(obj);
50 | return obj;
51 | }
52 |
53 | // "a" is reference to an object
54 | function removeChildren(a) {
55 | while (a.hasChildNodes()) a.removeChild(a.lastChild);
56 | }
57 |
58 | // ----------------------------------------------------------------------------
59 | // Cross-browser xmlhttp object
60 | // from http://jibbering.com/2002/4/httprequest.html
61 | // ----------------------------------------------------------------------------
62 | var xmlhttp;
63 | /*@cc_on @*/
64 | /*@if (@_jscript_version >= 5)
65 | try {
66 | xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
67 | } catch (e) {
68 | try {
69 | xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
70 | } catch (E) {
71 | xmlhttp = false;
72 | }
73 | }
74 | @else
75 | xmlhttp = false;
76 | @end @*/
77 | if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
78 | xmlhttp = new XMLHttpRequest();
79 | }
80 |
81 | // ----------------------------------------------------------------------------
82 | // Find-position functions by PPK
83 | // See http://www.quirksmode.org/js/findpos.html
84 | // ----------------------------------------------------------------------------
85 | function findPosX(obj) {
86 | var curleft = 0;
87 | if (obj.offsetParent) {
88 | while (obj.offsetParent) {
89 | curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
90 | obj = obj.offsetParent;
91 | }
92 | // IE offsetParent does not include the top-level
93 | if (isIE && obj.parentElement){
94 | curleft += obj.offsetLeft - obj.scrollLeft;
95 | }
96 | } else if (obj.x) {
97 | curleft += obj.x;
98 | }
99 | return curleft;
100 | }
101 |
102 | function findPosY(obj) {
103 | var curtop = 0;
104 | if (obj.offsetParent) {
105 | while (obj.offsetParent) {
106 | curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop);
107 | obj = obj.offsetParent;
108 | }
109 | // IE offsetParent does not include the top-level
110 | if (isIE && obj.parentElement){
111 | curtop += obj.offsetTop - obj.scrollTop;
112 | }
113 | } else if (obj.y) {
114 | curtop += obj.y;
115 | }
116 | return curtop;
117 | }
118 |
119 | //-----------------------------------------------------------------------------
120 | // Date object extensions
121 | // ----------------------------------------------------------------------------
122 |
123 | Date.prototype.getTwelveHours = function() {
124 | hours = this.getHours();
125 | if (hours == 0) {
126 | return 12;
127 | }
128 | else {
129 | return hours <= 12 ? hours : hours-12
130 | }
131 | }
132 |
133 | Date.prototype.getTwoDigitMonth = function() {
134 | return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1);
135 | }
136 |
137 | Date.prototype.getTwoDigitDate = function() {
138 | return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate();
139 | }
140 |
141 | Date.prototype.getTwoDigitTwelveHour = function() {
142 | return (this.getTwelveHours() < 10) ? '0' + this.getTwelveHours() : this.getTwelveHours();
143 | }
144 |
145 | Date.prototype.getTwoDigitHour = function() {
146 | return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours();
147 | }
148 |
149 | Date.prototype.getTwoDigitMinute = function() {
150 | return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes();
151 | }
152 |
153 | Date.prototype.getTwoDigitSecond = function() {
154 | return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds();
155 | }
156 |
157 | Date.prototype.getHourMinute = function() {
158 | return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();
159 | }
160 |
161 | Date.prototype.getHourMinuteSecond = function() {
162 | return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond();
163 | }
164 |
165 | Date.prototype.strftime = function(format) {
166 | var fields = {
167 | c: this.toString(),
168 | d: this.getTwoDigitDate(),
169 | H: this.getTwoDigitHour(),
170 | I: this.getTwoDigitTwelveHour(),
171 | m: this.getTwoDigitMonth(),
172 | M: this.getTwoDigitMinute(),
173 | p: (this.getHours() >= 12) ? 'PM' : 'AM',
174 | S: this.getTwoDigitSecond(),
175 | w: '0' + this.getDay(),
176 | x: this.toLocaleDateString(),
177 | X: this.toLocaleTimeString(),
178 | y: ('' + this.getFullYear()).substr(2, 4),
179 | Y: '' + this.getFullYear(),
180 | '%' : '%'
181 | };
182 | var result = '', i = 0;
183 | while (i < format.length) {
184 | if (format.charAt(i) === '%') {
185 | result = result + fields[format.charAt(i + 1)];
186 | ++i;
187 | }
188 | else {
189 | result = result + format.charAt(i);
190 | }
191 | ++i;
192 | }
193 | return result;
194 | }
195 |
196 | // ----------------------------------------------------------------------------
197 | // String object extensions
198 | // ----------------------------------------------------------------------------
199 | String.prototype.pad_left = function(pad_length, pad_string) {
200 | var new_string = this;
201 | for (var i = 0; new_string.length < pad_length; i++) {
202 | new_string = pad_string + new_string;
203 | }
204 | return new_string;
205 | }
206 |
207 | String.prototype.strptime = function(format) {
208 | var split_format = format.split(/[.\-/]/);
209 | var date = this.split(/[.\-/]/);
210 | var i = 0;
211 | while (i < split_format.length) {
212 | switch (split_format[i]) {
213 | case "%d":
214 | var day = date[i];
215 | break;
216 | case "%m":
217 | var month = date[i] - 1;
218 | break;
219 | case "%Y":
220 | var year = date[i];
221 | break;
222 | case "%y":
223 | var year = date[i];
224 | break;
225 | }
226 | ++i;
227 | };
228 | return new Date(year, month, day);
229 | }
230 |
231 | // ----------------------------------------------------------------------------
232 | // Get the computed style for and element
233 | // ----------------------------------------------------------------------------
234 | function getStyle(oElm, strCssRule){
235 | var strValue = "";
236 | if(document.defaultView && document.defaultView.getComputedStyle){
237 | strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
238 | }
239 | else if(oElm.currentStyle){
240 | strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
241 | return p1.toUpperCase();
242 | });
243 | strValue = oElm.currentStyle[strCssRule];
244 | }
245 | return strValue;
246 | }
247 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/SelectFilter2.js:
--------------------------------------------------------------------------------
1 | /*
2 | SelectFilter2 - Turns a multiple-select box into a filter interface.
3 |
4 | Requires core.js, SelectBox.js and addevent.js.
5 | */
6 | (function($) {
7 | function findForm(node) {
8 | // returns the node of the form containing the given node
9 | if (node.tagName.toLowerCase() != 'form') {
10 | return findForm(node.parentNode);
11 | }
12 | return node;
13 | }
14 |
15 | window.SelectFilter = {
16 | init: function(field_id, field_name, is_stacked, admin_static_prefix) {
17 | if (field_id.match(/__prefix__/)){
18 | // Don't initialize on empty forms.
19 | return;
20 | }
21 | var from_box = document.getElementById(field_id);
22 | from_box.id += '_from'; // change its ID
23 | from_box.className = 'filtered';
24 |
25 | var ps = from_box.parentNode.getElementsByTagName('p');
26 | for (var i=0; i, because it just gets in the way.
29 | from_box.parentNode.removeChild(ps[i]);
30 | } else if (ps[i].className.indexOf("help") != -1) {
31 | // Move help text up to the top so it isn't below the select
32 | // boxes or wrapped off on the side to the right of the add
33 | // button:
34 | from_box.parentNode.insertBefore(ps[i], from_box.parentNode.firstChild);
35 | }
36 | }
37 |
38 | // or
39 | var selector_div = quickElement('div', from_box.parentNode);
40 | selector_div.className = is_stacked ? 'selector stacked' : 'selector';
41 |
42 | //
43 | var selector_available = quickElement('div', selector_div);
44 | selector_available.className = 'selector-available';
45 | var title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name]));
46 | quickElement('img', title_available, '', 'src', admin_static_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of available %s. You may choose some by selecting them in the box below and then clicking the "Choose" arrow between the two boxes.'), [field_name]));
47 |
48 | var filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter');
49 | filter_p.className = 'selector-filter';
50 |
51 | var search_filter_label = quickElement('label', filter_p, '', 'for', field_id + "_input");
52 |
53 | var search_selector_img = quickElement('img', search_filter_label, '', 'src', admin_static_prefix + 'img/selector-search.gif', 'class', 'help-tooltip', 'alt', '', 'title', interpolate(gettext("Type into this box to filter down the list of available %s."), [field_name]));
54 |
55 | filter_p.appendChild(document.createTextNode(' '));
56 |
57 | var filter_input = quickElement('input', filter_p, '', 'type', 'text', 'placeholder', gettext("Filter"));
58 | filter_input.id = field_id + '_input';
59 |
60 | selector_available.appendChild(from_box);
61 | var choose_all = quickElement('a', selector_available, gettext('Choose all'), 'title', interpolate(gettext('Click to choose all %s at once.'), [field_name]), 'href', 'javascript: (function(){ SelectBox.move_all("' + field_id + '_from", "' + field_id + '_to"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_add_all_link');
62 | choose_all.className = 'selector-chooseall';
63 |
64 | //
65 | var selector_chooser = quickElement('ul', selector_div);
66 | selector_chooser.className = 'selector-chooser';
67 | var add_link = quickElement('a', quickElement('li', selector_chooser), gettext('Choose'), 'title', gettext('Choose'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_from","' + field_id + '_to"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_add_link');
68 | add_link.className = 'selector-add';
69 | var remove_link = quickElement('a', quickElement('li', selector_chooser), gettext('Remove'), 'title', gettext('Remove'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_to","' + field_id + '_from"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_remove_link');
70 | remove_link.className = 'selector-remove';
71 |
72 | //
73 | var selector_chosen = quickElement('div', selector_div);
74 | selector_chosen.className = 'selector-chosen';
75 | var title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name]));
76 | quickElement('img', title_chosen, '', 'src', admin_static_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of chosen %s. You may remove some by selecting them in the box below and then clicking the "Remove" arrow between the two boxes.'), [field_name]));
77 |
78 | var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name'));
79 | to_box.className = 'filtered';
80 | var clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'title', interpolate(gettext('Click to remove all chosen %s at once.'), [field_name]), 'href', 'javascript: (function() { SelectBox.move_all("' + field_id + '_to", "' + field_id + '_from"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_remove_all_link');
81 | clear_all.className = 'selector-clearall';
82 |
83 | from_box.setAttribute('name', from_box.getAttribute('name') + '_old');
84 |
85 | // Set up the JavaScript event handlers for the select box filter interface
86 | addEvent(filter_input, 'keypress', function(e) { SelectFilter.filter_key_press(e, field_id); });
87 | addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); });
88 | addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); });
89 | addEvent(from_box, 'change', function(e) { SelectFilter.refresh_icons(field_id) });
90 | addEvent(to_box, 'change', function(e) { SelectFilter.refresh_icons(field_id) });
91 | addEvent(from_box, 'dblclick', function() { SelectBox.move(field_id + '_from', field_id + '_to'); SelectFilter.refresh_icons(field_id); });
92 | addEvent(to_box, 'dblclick', function() { SelectBox.move(field_id + '_to', field_id + '_from'); SelectFilter.refresh_icons(field_id); });
93 | addEvent(findForm(from_box), 'submit', function() { SelectBox.select_all(field_id + '_to'); });
94 | SelectBox.init(field_id + '_from');
95 | SelectBox.init(field_id + '_to');
96 | // Move selected from_box options to to_box
97 | SelectBox.move(field_id + '_from', field_id + '_to');
98 |
99 | if (!is_stacked) {
100 | // In horizontal mode, give the same height to the two boxes.
101 | var j_from_box = $(from_box);
102 | var j_to_box = $(to_box);
103 | var resize_filters = function() { j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight()); }
104 | if (j_from_box.outerHeight() > 0) {
105 | resize_filters(); // This fieldset is already open. Resize now.
106 | } else {
107 | // This fieldset is probably collapsed. Wait for its 'show' event.
108 | j_to_box.closest('fieldset').one('show.fieldset', resize_filters);
109 | }
110 | }
111 |
112 | // Initial icon refresh
113 | SelectFilter.refresh_icons(field_id);
114 | },
115 | refresh_icons: function(field_id) {
116 | var from = $('#' + field_id + '_from');
117 | var to = $('#' + field_id + '_to');
118 | var is_from_selected = from.find('option:selected').length > 0;
119 | var is_to_selected = to.find('option:selected').length > 0;
120 | // Active if at least one item is selected
121 | $('#' + field_id + '_add_link').toggleClass('active', is_from_selected);
122 | $('#' + field_id + '_remove_link').toggleClass('active', is_to_selected);
123 | // Active if the corresponding box isn't empty
124 | $('#' + field_id + '_add_all_link').toggleClass('active', from.find('option').length > 0);
125 | $('#' + field_id + '_remove_all_link').toggleClass('active', to.find('option').length > 0);
126 | },
127 | filter_key_press: function(event, field_id) {
128 | var from = document.getElementById(field_id + '_from');
129 | // don't submit form if user pressed Enter
130 | if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
131 | from.selectedIndex = 0;
132 | SelectBox.move(field_id + '_from', field_id + '_to');
133 | from.selectedIndex = 0;
134 | event.preventDefault()
135 | return false;
136 | }
137 | },
138 | filter_key_up: function(event, field_id) {
139 | var from = document.getElementById(field_id + '_from');
140 | var temp = from.selectedIndex;
141 | SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value);
142 | from.selectedIndex = temp;
143 | return true;
144 | },
145 | filter_key_down: function(event, field_id) {
146 | var from = document.getElementById(field_id + '_from');
147 | // right arrow -- move across
148 | if ((event.which && event.which == 39) || (event.keyCode && event.keyCode == 39)) {
149 | var old_index = from.selectedIndex;
150 | SelectBox.move(field_id + '_from', field_id + '_to');
151 | from.selectedIndex = (old_index == from.length) ? from.length - 1 : old_index;
152 | return false;
153 | }
154 | // down arrow -- wrap around
155 | if ((event.which && event.which == 40) || (event.keyCode && event.keyCode == 40)) {
156 | from.selectedIndex = (from.length == from.selectedIndex + 1) ? 0 : from.selectedIndex + 1;
157 | }
158 | // up arrow -- wrap around
159 | if ((event.which && event.which == 38) || (event.keyCode && event.keyCode == 38)) {
160 | from.selectedIndex = (from.selectedIndex == 0) ? from.length - 1 : from.selectedIndex - 1;
161 | }
162 | return true;
163 | }
164 | }
165 |
166 | })(django.jQuery);
167 |
--------------------------------------------------------------------------------
/nx2django/static/admin/js/inlines.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Django admin inlines
3 | *
4 | * Based on jQuery Formset 1.1
5 | * @author Stanislaus Madueke (stan DOT madueke AT gmail DOT com)
6 | * @requires jQuery 1.2.6 or later
7 | *
8 | * Copyright (c) 2009, Stanislaus Madueke
9 | * All rights reserved.
10 | *
11 | * Spiced up with Code from Zain Memon's GSoC project 2009
12 | * and modified for Django by Jannis Leidel, Travis Swicegood and Julien Phalip.
13 | *
14 | * Licensed under the New BSD License
15 | * See: http://www.opensource.org/licenses/bsd-license.php
16 | */
17 | (function($) {
18 | $.fn.formset = function(opts) {
19 | var options = $.extend({}, $.fn.formset.defaults, opts);
20 | var $this = $(this);
21 | var $parent = $this.parent();
22 | var updateElementIndex = function(el, prefix, ndx) {
23 | var id_regex = new RegExp("(" + prefix + "-(\\d+|__prefix__))");
24 | var replacement = prefix + "-" + ndx;
25 | if ($(el).prop("for")) {
26 | $(el).prop("for", $(el).prop("for").replace(id_regex, replacement));
27 | }
28 | if (el.id) {
29 | el.id = el.id.replace(id_regex, replacement);
30 | }
31 | if (el.name) {
32 | el.name = el.name.replace(id_regex, replacement);
33 | }
34 | };
35 | var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS").prop("autocomplete", "off");
36 | var nextIndex = parseInt(totalForms.val(), 10);
37 | var maxForms = $("#id_" + options.prefix + "-MAX_NUM_FORMS").prop("autocomplete", "off");
38 | // only show the add button if we are allowed to add more items,
39 | // note that max_num = None translates to a blank string.
40 | var showAddButton = maxForms.val() === '' || (maxForms.val()-totalForms.val()) > 0;
41 | $this.each(function(i) {
42 | $(this).not("." + options.emptyCssClass).addClass(options.formCssClass);
43 | });
44 | if ($this.length && showAddButton) {
45 | var addButton;
46 | if ($this.prop("tagName") == "TR") {
47 | // If forms are laid out as table rows, insert the
48 | // "add" button in a new table row:
49 | var numCols = this.eq(-1).children().length;
50 | $parent.append('
| ' + options.addText + " |
");
51 | addButton = $parent.find("tr:last a");
52 | } else {
53 | // Otherwise, insert it immediately after the last form:
54 | $this.filter(":last").after('
");
55 | addButton = $this.filter(":last").next().find("a");
56 | }
57 | addButton.click(function(e) {
58 | e.preventDefault();
59 | var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS");
60 | var template = $("#" + options.prefix + "-empty");
61 | var row = template.clone(true);
62 | row.removeClass(options.emptyCssClass)
63 | .addClass(options.formCssClass)
64 | .attr("id", options.prefix + "-" + nextIndex);
65 | if (row.is("tr")) {
66 | // If the forms are laid out in table rows, insert
67 | // the remove button into the last table cell:
68 | row.children(":last").append('
");
69 | } else if (row.is("ul") || row.is("ol")) {
70 | // If they're laid out as an ordered/unordered list,
71 | // insert an
- after the last list item:
72 | row.append('
- ' + options.deleteText + "
");
73 | } else {
74 | // Otherwise, just insert the remove button as the
75 | // last child element of the form's container:
76 | row.children(":first").append('
' + options.deleteText + "");
77 | }
78 | row.find("*").each(function() {
79 | updateElementIndex(this, options.prefix, totalForms.val());
80 | });
81 | // Insert the new form when it has been fully edited
82 | row.insertBefore($(template));
83 | // Update number of total forms
84 | $(totalForms).val(parseInt(totalForms.val(), 10) + 1);
85 | nextIndex += 1;
86 | // Hide add button in case we've hit the max, except we want to add infinitely
87 | if ((maxForms.val() !== '') && (maxForms.val()-totalForms.val()) <= 0) {
88 | addButton.parent().hide();
89 | }
90 | // The delete button of each row triggers a bunch of other things
91 | row.find("a." + options.deleteCssClass).click(function(e) {
92 | e.preventDefault();
93 | // Remove the parent form containing this button:
94 | var row = $(this).parents("." + options.formCssClass);
95 | row.remove();
96 | nextIndex -= 1;
97 | // If a post-delete callback was provided, call it with the deleted form:
98 | if (options.removed) {
99 | options.removed(row);
100 | }
101 | // Update the TOTAL_FORMS form count.
102 | var forms = $("." + options.formCssClass);
103 | $("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length);
104 | // Show add button again once we drop below max
105 | if ((maxForms.val() === '') || (maxForms.val()-forms.length) > 0) {
106 | addButton.parent().show();
107 | }
108 | // Also, update names and ids for all remaining form controls
109 | // so they remain in sequence:
110 | for (var i=0, formCount=forms.length; i
122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]+/],["dec",/^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^