kopia lustrzana https://github.com/wagtail/wagtail
stylistic tweaks to b7158bb3fa
(camel case for js vars; using a dict rather than adding vars indefinitely to the window scope; avoiding potentially dynamic code inside compress blocks)
rodzic
d9219a8515
commit
2f13e5211a
|
@ -41,9 +41,9 @@
|
||||||
|
|
||||||
if lastSelection.collapsed
|
if lastSelection.collapsed
|
||||||
# TODO: don't hard-code this, as it may be changed in urls.py
|
# TODO: don't hard-code this, as it may be changed in urls.py
|
||||||
url = window.page_chooser+'?allow_external_link=true&allow_email_link=true&prompt_for_link_text=true'
|
url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true&prompt_for_link_text=true'
|
||||||
else
|
else
|
||||||
url = window.page_chooser+'?allow_external_link=true&allow_email_link=true'
|
url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true'
|
||||||
|
|
||||||
ModalWorkflow
|
ModalWorkflow
|
||||||
url: url
|
url: url
|
||||||
|
|
|
@ -4,7 +4,7 @@ function createPageChooser(id, pageType, openAtParentId) {
|
||||||
var input = $('#' + id);
|
var input = $('#' + id);
|
||||||
|
|
||||||
$('.action-choose', chooserElement).click(function() {
|
$('.action-choose', chooserElement).click(function() {
|
||||||
var initialUrl = window.page_chooser;
|
var initialUrl = window.chooserUrls.pageChooser;
|
||||||
if (openAtParentId) {
|
if (openAtParentId) {
|
||||||
initialUrl += openAtParentId + '/';
|
initialUrl += openAtParentId + '/';
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,15 +29,18 @@
|
||||||
<script src="{{ STATIC_URL }}wagtaildocs/js/document-chooser.js"></script>
|
<script src="{{ STATIC_URL }}wagtaildocs/js/document-chooser.js"></script>
|
||||||
<script src="{{ STATIC_URL }}wagtailsnippets/js/snippet-chooser.js"></script>
|
<script src="{{ STATIC_URL }}wagtailsnippets/js/snippet-chooser.js"></script>
|
||||||
<script src="{{ STATIC_URL }}admin/js/urlify.js"></script>
|
<script src="{{ STATIC_URL }}admin/js/urlify.js"></script>
|
||||||
<script type='text/javascript'>
|
|
||||||
window.document_chooser='{% url "wagtaildocs_chooser" %}';
|
|
||||||
window.image_chooser='{% url "wagtailimages_chooser" %}';
|
|
||||||
window.embeds_chooser='{% url "wagtailembeds_chooser" %}';
|
|
||||||
window.page_chooser='{% url "wagtailadmin_choose_page" %}';
|
|
||||||
window.snippet_chooser='{% url "wagtailsnippets_choose_generic" %}';
|
|
||||||
</script>
|
|
||||||
{% endcompress %}
|
{% endcompress %}
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
window.chooserUrls = {
|
||||||
|
'documentChooser': '{% url "wagtaildocs_chooser" %}',
|
||||||
|
'imageChooser': '{% url "wagtailimages_chooser" %}',
|
||||||
|
'embedsChooser': '{% url "wagtailembeds_chooser" %}',
|
||||||
|
'pageChooser': '{% url "wagtailadmin_choose_page" %}',
|
||||||
|
'snippetChooser': '{% url "wagtailsnippets_choose_generic" %}'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
function fixPrefix(str) {return str;}
|
function fixPrefix(str) {return str;}
|
||||||
|
|
|
@ -5,7 +5,7 @@ function createDocumentChooser(id) {
|
||||||
|
|
||||||
$('.action-choose', chooserElement).click(function() {
|
$('.action-choose', chooserElement).click(function() {
|
||||||
ModalWorkflow({
|
ModalWorkflow({
|
||||||
'url': window.document_chooser,
|
'url': window.chooserUrls.documentChooser,
|
||||||
'responses': {
|
'responses': {
|
||||||
'documentChosen': function(docData) {
|
'documentChosen': function(docData) {
|
||||||
input.val(docData.id);
|
input.val(docData.id);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
button.on "click", (event) ->
|
button.on "click", (event) ->
|
||||||
lastSelection = widget.options.editable.getSelection()
|
lastSelection = widget.options.editable.getSelection()
|
||||||
ModalWorkflow
|
ModalWorkflow
|
||||||
url: window.document_chooser
|
url: window.chooserUrls.documentChooser
|
||||||
responses:
|
responses:
|
||||||
documentChosen: (docData) ->
|
documentChosen: (docData) ->
|
||||||
a = document.createElement('a')
|
a = document.createElement('a')
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
lastSelection = widget.options.editable.getSelection()
|
lastSelection = widget.options.editable.getSelection()
|
||||||
insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last()
|
insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last()
|
||||||
ModalWorkflow
|
ModalWorkflow
|
||||||
url: window.embeds_chooser
|
url: window.chooserUrls.embedsChooser
|
||||||
responses:
|
responses:
|
||||||
embedChosen: (embedData) ->
|
embedChosen: (embedData) ->
|
||||||
elem = $(embedData).get(0)
|
elem = $(embedData).get(0)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
lastSelection = widget.options.editable.getSelection()
|
lastSelection = widget.options.editable.getSelection()
|
||||||
insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last()
|
insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last()
|
||||||
ModalWorkflow
|
ModalWorkflow
|
||||||
url: window.image_chooser+'?select_format=true'
|
url: window.chooserUrls.imageChooser + '?select_format=true'
|
||||||
responses:
|
responses:
|
||||||
imageChosen: (imageData) ->
|
imageChosen: (imageData) ->
|
||||||
elem = $(imageData.html).get(0)
|
elem = $(imageData.html).get(0)
|
||||||
|
|
|
@ -5,7 +5,7 @@ function createImageChooser(id) {
|
||||||
|
|
||||||
$('.action-choose', chooserElement).click(function() {
|
$('.action-choose', chooserElement).click(function() {
|
||||||
ModalWorkflow({
|
ModalWorkflow({
|
||||||
'url': window.image_chooser,
|
'url': window.chooserUrls.imageChooser,
|
||||||
'responses': {
|
'responses': {
|
||||||
'imageChosen': function(imageData) {
|
'imageChosen': function(imageData) {
|
||||||
input.val(imageData.id);
|
input.val(imageData.id);
|
||||||
|
|
|
@ -5,7 +5,7 @@ function createSnippetChooser(id, contentType) {
|
||||||
|
|
||||||
$('.action-choose', chooserElement).click(function() {
|
$('.action-choose', chooserElement).click(function() {
|
||||||
ModalWorkflow({
|
ModalWorkflow({
|
||||||
'url': window.snippet_chooser + contentType + '/',
|
'url': window.chooserUrls.snippetChooser + contentType + '/',
|
||||||
'responses': {
|
'responses': {
|
||||||
'snippetChosen': function(snippetData) {
|
'snippetChosen': function(snippetData) {
|
||||||
input.val(snippetData.id);
|
input.val(snippetData.id);
|
||||||
|
|
Ładowanie…
Reference in New Issue