kopia lustrzana https://github.com/wagtail/wagtail
Move chooser widget JS from insert_editor_js hook into widget media
rodzic
67795603fb
commit
994e793773
|
|
@ -1,9 +1,8 @@
|
|||
from django.conf import settings
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
from django.template.response import TemplateResponse
|
||||
from django.urls import reverse
|
||||
from django.utils.html import format_html, format_html_join
|
||||
from django.utils.html import format_html
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext, ungettext
|
||||
|
||||
|
|
@ -57,14 +56,7 @@ def register_documents_menu_item():
|
|||
|
||||
@hooks.register('insert_editor_js')
|
||||
def editor_js():
|
||||
js_files = [
|
||||
static('wagtaildocs/js/document-chooser.js'),
|
||||
]
|
||||
js_includes = format_html_join(
|
||||
'\n', '<script src="{0}"></script>',
|
||||
((filename, ) for filename in js_files)
|
||||
)
|
||||
return js_includes + format_html(
|
||||
return format_html(
|
||||
"""
|
||||
<script>
|
||||
window.chooserUrls.documentChooser = '{0}';
|
||||
|
|
|
|||
|
|
@ -30,3 +30,6 @@ class AdminDocumentChooser(AdminChooser):
|
|||
|
||||
def render_js_init(self, id_, name, value):
|
||||
return "createDocumentChooser({0});".format(json.dumps(id_))
|
||||
|
||||
class Media:
|
||||
js = ['wagtaildocs/js/document-chooser.js']
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from django.conf.urls import include, url
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
from django.urls import reverse
|
||||
from django.utils.html import format_html, format_html_join
|
||||
from django.utils.html import format_html
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext, ungettext
|
||||
|
||||
|
|
@ -48,14 +47,7 @@ def register_images_menu_item():
|
|||
|
||||
@hooks.register('insert_editor_js')
|
||||
def editor_js():
|
||||
js_files = [
|
||||
static('wagtailimages/js/image-chooser.js'),
|
||||
]
|
||||
js_includes = format_html_join(
|
||||
'\n', '<script src="{0}"></script>',
|
||||
((filename, ) for filename in js_files)
|
||||
)
|
||||
return js_includes + format_html(
|
||||
return format_html(
|
||||
"""
|
||||
<script>
|
||||
window.chooserUrls.imageChooser = '{0}';
|
||||
|
|
|
|||
|
|
@ -30,3 +30,6 @@ class AdminImageChooser(AdminChooser):
|
|||
|
||||
def render_js_init(self, id_, name, value):
|
||||
return "createImageChooser({0});".format(json.dumps(id_))
|
||||
|
||||
class Media:
|
||||
js = ['wagtailimages/js/image-chooser.js']
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from django.conf.urls import include, url
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
from django.urls import reverse
|
||||
from django.utils.html import format_html
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
|
@ -39,10 +38,8 @@ def register_snippets_menu_item():
|
|||
def editor_js():
|
||||
return format_html(
|
||||
"""
|
||||
<script src="{0}"></script>
|
||||
<script>window.chooserUrls.snippetChooser = '{1}';</script>
|
||||
<script>window.chooserUrls.snippetChooser = '{0}';</script>
|
||||
""",
|
||||
static('wagtailsnippets/js/snippet-chooser.js'),
|
||||
reverse('wagtailsnippets:choose_generic')
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -39,3 +39,6 @@ class AdminSnippetChooser(AdminChooser):
|
|||
model=json.dumps('{app}/{model}'.format(
|
||||
app=model._meta.app_label,
|
||||
model=model._meta.model_name)))
|
||||
|
||||
class Media:
|
||||
js = ['wagtailsnippets/js/snippet-chooser.js']
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue