replaced coffeescript js with compiled, vanilla js

pull/137/head
Dave Cranwell 2014-03-04 16:45:13 +00:00
rodzic 4f807cb4e2
commit 9c14d41e9b
11 zmienionych plików z 256 dodań i 222 usunięć

Wyświetl plik

@ -1,28 +0,0 @@
# Hallo - a rich text editing jQuery UI widget
# (c) 2011 Henri Bergius, IKS Consortium
# Hallo may be freely distributed under the MIT license
((jQuery) ->
jQuery.widget "IKS.hallohr",
options:
editable: null
toolbar: null
uuid: ''
buttonCssClass: null
populateToolbar: (toolbar) ->
buttonset = jQuery "<span class=\"#{@widgetName}\"></span>"
buttonElement = jQuery '<span></span>'
buttonElement.hallobutton
uuid: @options.uuid
editable: @options.editable
label: "Horizontal rule"
command: "insertHorizontalRule"
icon: "icon-horizontalrule"
cssClass: @options.buttonCssClass
buttonset.append buttonElement
buttonset.hallobuttonset()
toolbar.append buttonset
)(jQuery)

Wyświetl plik

@ -0,0 +1,31 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function(jQuery) {
return jQuery.widget("IKS.hallohr", {
options: {
editable: null,
toolbar: null,
uuid: '',
buttonCssClass: null
},
populateToolbar: function(toolbar) {
var buttonElement, buttonset;
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
buttonElement = jQuery('<span></span>');
buttonElement.hallobutton({
uuid: this.options.uuid,
editable: this.options.editable,
label: "Horizontal rule",
command: "insertHorizontalRule",
icon: "icon-horizontalrule",
cssClass: this.options.buttonCssClass
});
buttonset.append(buttonElement);
buttonset.hallobuttonset();
return toolbar.append(buttonset);
}
});
})(jQuery);
}).call(this);

Wyświetl plik

@ -1,68 +0,0 @@
# plugin for hallo.js to allow inserting links using Wagtail's page chooser
(($) ->
$.widget "IKS.hallowagtaillink",
options:
uuid: ''
editable: null
populateToolbar: (toolbar) ->
widget = this
getEnclosingLink = () ->
# if cursor is currently within a link element, return it, otherwise return null
node = widget.options.editable.getSelection().commonAncestorContainer
return $(node).parents('a').get(0)
# Create an element for holding the button
button = $('<span></span>')
button.hallobutton
uuid: @options.uuid
editable: @options.editable
label: 'Links'
icon: 'icon-link'
command: null
queryState: (event) ->
button.hallobutton('checked', !!getEnclosingLink())
# Append the button to toolbar
toolbar.append button
button.on "click", (event) ->
enclosingLink = getEnclosingLink()
if enclosingLink
# remove existing link
$(enclosingLink).replaceWith(enclosingLink.innerHTML)
button.hallobutton('checked', false)
widget.options.editable.element.trigger('change')
else
# commence workflow to add a link
lastSelection = widget.options.editable.getSelection()
if lastSelection.collapsed
# TODO: don't hard-code this, as it may be changed in urls.py
url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true&prompt_for_link_text=true'
else
url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true'
ModalWorkflow
url: url
responses:
pageChosen: (pageData) ->
a = document.createElement('a')
a.setAttribute('href', pageData.url)
if pageData.id
a.setAttribute('data-id', pageData.id)
a.setAttribute('data-linktype', 'page')
if (not lastSelection.collapsed) and lastSelection.canSurroundContents()
# use the selected content as the link text
lastSelection.surroundContents(a)
else
# no text is selected, so use the page title as link text
a.appendChild(document.createTextNode pageData.title)
lastSelection.insertNode(a)
widget.options.editable.element.trigger('change')
)(jQuery)

Wyświetl plik

@ -0,0 +1,74 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function($) {
return $.widget("IKS.hallowagtaillink", {
options: {
uuid: '',
editable: null
},
populateToolbar: function(toolbar) {
var button, getEnclosingLink, widget;
widget = this;
getEnclosingLink = function() {
var node;
node = widget.options.editable.getSelection().commonAncestorContainer;
return $(node).parents('a').get(0);
};
button = $('<span></span>');
button.hallobutton({
uuid: this.options.uuid,
editable: this.options.editable,
label: 'Links',
icon: 'icon-link',
command: null,
queryState: function(event) {
return button.hallobutton('checked', !!getEnclosingLink());
}
});
toolbar.append(button);
return button.on("click", function(event) {
var enclosingLink, lastSelection, url;
enclosingLink = getEnclosingLink();
if (enclosingLink) {
$(enclosingLink).replaceWith(enclosingLink.innerHTML);
button.hallobutton('checked', false);
return widget.options.editable.element.trigger('change');
} else {
lastSelection = widget.options.editable.getSelection();
if (lastSelection.collapsed) {
url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true&prompt_for_link_text=true';
} else {
url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true';
}
return ModalWorkflow({
url: url,
responses: {
pageChosen: function(pageData) {
var a;
a = document.createElement('a');
a.setAttribute('href', pageData.url);
if (pageData.id) {
a.setAttribute('data-id', pageData.id);
a.setAttribute('data-linktype', 'page');
}
if ((!lastSelection.collapsed) && lastSelection.canSurroundContents()) {
lastSelection.surroundContents(a);
} else {
a.appendChild(document.createTextNode(pageData.title));
lastSelection.insertNode(a);
}
return widget.options.editable.element.trigger('change');
}
}
});
}
});
}
});
})(jQuery);
}).call(this);

Wyświetl plik

@ -13,16 +13,16 @@
<script src="{{ STATIC_URL }}wagtailadmin/js/expanding_formset.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/modal-workflow.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/hallo-plugins/hallo-wagtail-toolbar.js"></script>
<script type="text/coffeescript" src="{{ STATIC_URL }}wagtailadmin/js/hallo-plugins/hallo-wagtaillink.coffee"></script>
<script type="text/coffeescript" src="{{ STATIC_URL }}wagtailadmin/js/hallo-plugins/hallo-hr.coffee"></script>
<script type="text/coffeescript" src="{{ STATIC_URL }}wagtailimages/js/hallo-plugins/hallo-wagtailimage.coffee"></script>
<script type="text/coffeescript" src="{{ STATIC_URL }}wagtailembeds/js/hallo-plugins/hallo-wagtailembeds.coffee"></script>
<script type="text/coffeescript" src="{{ STATIC_URL }}wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.coffee"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/hallo-plugins/hallo-wagtaillink.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/hallo-plugins/hallo-hr.js"></script>
<script src="{{ STATIC_URL }}wagtailimages/js/hallo-plugins/hallo-wagtailimage.js"></script>
<script src="{{ STATIC_URL }}wagtailembeds/js/hallo-plugins/hallo-wagtailembeds.js"></script>
<script src="{{ STATIC_URL }}wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/page-editor.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/page-chooser.js"></script>
{% comment %}
TODO: have a mechanism to specify image-chooser.js (and hallo-wagtailimage.coffee)
TODO: have a mechanism to specify image-chooser.js (and hallo-wagtailimage.js)
within the wagtailimages app -
ideally wagtailadmin shouldn't have to know anything at all about wagtailimages
TODO: a method of injecting these sorts of things on demand when the modal is spawned.

Wyświetl plik

@ -1,45 +0,0 @@
# plugin for hallo.js to allow inserting links using Wagtail's page chooser
(($) ->
$.widget "IKS.hallowagtaildoclink",
options:
uuid: ''
editable: null
populateToolbar: (toolbar) ->
widget = this
# Create an element for holding the button
button = $('<span></span>')
button.hallobutton
uuid: @options.uuid
editable: @options.editable
label: 'Documents'
icon: 'icon-file-text-alt'
command: null
# Append the button to toolbar
toolbar.append button
button.on "click", (event) ->
lastSelection = widget.options.editable.getSelection()
ModalWorkflow
url: window.chooserUrls.documentChooser
responses:
documentChosen: (docData) ->
a = document.createElement('a')
a.setAttribute('href', docData.url)
a.setAttribute('data-id', docData.id)
a.setAttribute('data-linktype', 'document')
if (not lastSelection.collapsed) and lastSelection.canSurroundContents()
# use the selected content as the link text
lastSelection.surroundContents(a)
else
# no text is selected, so use the doc title as link text
a.appendChild(document.createTextNode docData.title)
lastSelection.insertNode(a)
widget.options.editable.element.trigger('change')
)(jQuery)

Wyświetl plik

@ -0,0 +1,51 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function($) {
return $.widget("IKS.hallowagtaildoclink", {
options: {
uuid: '',
editable: null
},
populateToolbar: function(toolbar) {
var button, widget;
widget = this;
button = $('<span></span>');
button.hallobutton({
uuid: this.options.uuid,
editable: this.options.editable,
label: 'Documents',
icon: 'icon-file-text-alt',
command: null
});
toolbar.append(button);
return button.on("click", function(event) {
var lastSelection;
lastSelection = widget.options.editable.getSelection();
return ModalWorkflow({
url: window.chooserUrls.documentChooser,
responses: {
documentChosen: function(docData) {
var a;
a = document.createElement('a');
a.setAttribute('href', docData.url);
a.setAttribute('data-id', docData.id);
a.setAttribute('data-linktype', 'document');
if ((!lastSelection.collapsed) && lastSelection.canSurroundContents()) {
lastSelection.surroundContents(a);
} else {
a.appendChild(document.createTextNode(docData.title));
lastSelection.insertNode(a);
}
return widget.options.editable.element.trigger('change');
}
}
});
});
}
});
})(jQuery);
}).call(this);

Wyświetl plik

@ -1,36 +0,0 @@
# plugin for hallo.js to allow inserting embeds
(($) ->
$.widget "IKS.hallowagtailembeds",
options:
uuid: ''
editable: null
populateToolbar: (toolbar) ->
widget = this
# Create an element for holding the button
button = $('<span></span>')
button.hallobutton
uuid: @options.uuid
editable: @options.editable
label: 'Embed'
icon: 'icon-media'
command: null
# Append the button to toolbar
toolbar.append button
button.on "click", (event) ->
lastSelection = widget.options.editable.getSelection()
insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last()
ModalWorkflow
url: window.chooserUrls.embedsChooser
responses:
embedChosen: (embedData) ->
elem = $(embedData).get(0)
lastSelection.insertNode(elem)
if elem.getAttribute('contenteditable') == 'false'
insertRichTextDeleteControl(elem)
widget.options.editable.element.trigger('change')
)(jQuery)

Wyświetl plik

@ -0,0 +1,47 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function($) {
return $.widget("IKS.hallowagtailembeds", {
options: {
uuid: '',
editable: null
},
populateToolbar: function(toolbar) {
var button, widget;
widget = this;
button = $('<span></span>');
button.hallobutton({
uuid: this.options.uuid,
editable: this.options.editable,
label: 'Embed',
icon: 'icon-media',
command: null
});
toolbar.append(button);
return button.on("click", function(event) {
var insertionPoint, lastSelection;
lastSelection = widget.options.editable.getSelection();
insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last();
return ModalWorkflow({
url: window.chooserUrls.embedsChooser,
responses: {
embedChosen: function(embedData) {
var elem;
elem = $(embedData).get(0);
lastSelection.insertNode(elem);
if (elem.getAttribute('contenteditable') === 'false') {
insertRichTextDeleteControl(elem);
}
return widget.options.editable.element.trigger('change');
}
}
});
});
}
});
})(jQuery);
}).call(this);

Wyświetl plik

@ -1,39 +0,0 @@
# plugin for hallo.js to allow inserting images from the Wagtail image library
(($) ->
$.widget "IKS.hallowagtailimage",
options:
uuid: ''
editable: null
populateToolbar: (toolbar) ->
widget = this
# Create an element for holding the button
button = $('<span></span>')
button.hallobutton
uuid: @options.uuid
editable: @options.editable
label: 'Images'
icon: 'icon-picture'
command: null
# Append the button to toolbar
toolbar.append button
button.on "click", (event) ->
lastSelection = widget.options.editable.getSelection()
insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last()
ModalWorkflow
url: window.chooserUrls.imageChooser + '?select_format=true'
responses:
imageChosen: (imageData) ->
elem = $(imageData.html).get(0)
lastSelection.insertNode(elem)
if elem.getAttribute('contenteditable') == 'false'
insertRichTextDeleteControl(elem)
widget.options.editable.element.trigger('change')
)(jQuery)

Wyświetl plik

@ -0,0 +1,47 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function($) {
return $.widget("IKS.hallowagtailimage", {
options: {
uuid: '',
editable: null
},
populateToolbar: function(toolbar) {
var button, widget;
widget = this;
button = $('<span></span>');
button.hallobutton({
uuid: this.options.uuid,
editable: this.options.editable,
label: 'Images',
icon: 'icon-picture',
command: null
});
toolbar.append(button);
return button.on("click", function(event) {
var insertionPoint, lastSelection;
lastSelection = widget.options.editable.getSelection();
insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last();
return ModalWorkflow({
url: window.chooserUrls.imageChooser + '?select_format=true',
responses: {
imageChosen: function(imageData) {
var elem;
elem = $(imageData.html).get(0);
lastSelection.insertNode(elem);
if (elem.getAttribute('contenteditable') === 'false') {
insertRichTextDeleteControl(elem);
}
return widget.options.editable.element.trigger('change');
}
}
});
});
}
});
})(jQuery);
}).call(this);