Skip to content

Commit

Permalink
Feature/remove jquery (#229)
Browse files Browse the repository at this point in the history
* remove jquery
  • Loading branch information
nitely committed Aug 26, 2018
1 parent 74b11f1 commit d02b5d2
Show file tree
Hide file tree
Showing 108 changed files with 5,147 additions and 9,109 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ indent_size = 2
indent_style = space
indent_size = 2

[*.coffee]
indent_style = space
indent_size = 4

# Override for Makefile
[{Makefile, makefile, GNUmakefile}]
indent_style = tab
Expand Down
8 changes: 3 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ gulp.task('_sass', function () {
gulp.task('_css-minify', ['_sass'], function() {
var path = cssPath + 'vendors/';
return gulp.src([
path + '*.min.css',
cssPath + 'styles.css',
path + '*.css',
cssPath + 'styles.css'
])
.pipe(minifyCss({compatibility: 'ie8', target: cssPath, relativeTo: cssPath}))
.pipe(concat('styles.all.min.css'))
Expand All @@ -42,11 +42,9 @@ gulp.task('coffee', function() {
var pathCoffee = jsPath + 'src/';
var pathJs = jsPath + 'js/';
return gulp.src([
pathVendors + 'jquery.min.js',
pathVendors + 'atwho/jquery.caret.min.js',
pathVendors + 'atwho/jquery.atwho.min.js',
pathVendors + '**/*.js',
pathVendors + '**/*.coffee',
pathCoffee + 'modules.coffee',
pathCoffee + 'util.coffee',
pathCoffee + 'tab.coffee',
pathCoffee + 'editor_file_upload.coffee',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1 class="headline">{% trans "Comment history" %}</h1>
</div>
</div>

</div>
</div>
{% endfor %}

</div>
Expand All @@ -49,14 +49,11 @@ <h1 class="headline">{% trans "Comment history" %}</h1>

<script>

$( document ).ready(function() {
document.addEventListener('DOMContentLoaded', function() {
hljs.initHighlightingOnLoad();
stModules.commentDiff(document.querySelectorAll('.comment-text'));
});

hljs.initHighlightingOnLoad();

$('.comment-text').comment_diff();

});

</script>
</script>

{% endblock %}
117 changes: 63 additions & 54 deletions spirit/comment/templates/spirit/comment/_editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="comment-text js-box-preview-content" style="display:none;"></div>
<ul class="reply-markdown">
<li><a class="js-box-bold" href="#" title="{% trans "Bold" %}"><i class="fa fa-bold"></i></a></li><!--
<li><a class="js-box-bold" href="#" title="{% trans "Bold" %}"><i class="fa fa-bold"></i></a></li><!--
--><li><a class="js-box-italic" href="#" title="{% trans "Italic" %}"><i class="fa fa-italic"></i></a></li><!--
--><li><a class="js-box-list" href="#" title="{% trans "List" %}"><i class="fa fa-list"></i></a></li><!--
--><li><a class="js-box-url" href="#" title="{% trans "URL" %}"><i class="fa fa-link"></i></a></li><!--
Expand All @@ -18,9 +18,9 @@
</ul>

<script>
$( document ).ready(function() {
document.addEventListener('DOMContentLoaded', function() {

marked.setOptions( {
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true,
tables: false,
Expand All @@ -29,60 +29,69 @@
sanitize: true,
smartLists: false,
smartypants: false
} );
});

$( '.js-reply' ).find( 'textarea' )
{% if st_settings.ST_UPLOAD_IMAGE_ENABLED %}
.editor_image_upload( {
csrfToken: "{{ csrf_token }}",
target: "{% url "spirit:comment:image-upload-ajax" %}",
placeholderText: "{% trans "uploading {name}" %}",
allowedFileMedia: "{% get_allowed_image_types %}"
} )
{% endif %}
{% if st_settings.ST_UPLOAD_FILE_ENABLED %}
.editor_file_upload({
csrfToken: "{{ csrf_token }}",
target: "{% url "spirit:comment:file-upload-ajax" %}",
placeholderText: "{% trans "uploading {name}" %}",
allowedFileMedia: "{% get_allowed_file_types %}"
} )
{% endif %}
.editor( {
boldedText: "{% trans "bolded text" %}",
italicisedText: "{% trans "italicised text" %}",
listItemText: "{% trans "list item" %}",
linkText: "{% trans "link text" %}",
linkUrlText: "{% trans "link url" %}",
imageText: "{% trans "image text" %}",
imageUrlText: "{% trans "image url" %}",
fileText: "{% trans "file text" %}",
fileUrlText: "{% trans "file url" %}",
pollTitleText: "{% trans "Title" %}",
pollChoiceText: "{% trans "Description" %}"
} )
.atwho({
at: ':',
tpl: "<li data-value=':${name}:'><i class=\"tw tw-${class_name}\"></i> ${name} </li>",
data: $.emoji_list(),
callbacks: {
before_save: function(data) {return data}, // Avoid extra work
tpl_eval: function(tpl, map) {
map.class_name = map.name
.split('_').join('-')
.split('+').join('plus');
(function () {
var editorElms = document.querySelectorAll('.js-reply');

try {
return tpl.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
return map[key]
});
} catch (error) {
return "";
}
}
{% if st_settings.ST_UPLOAD_IMAGE_ENABLED %}
stModules.editorImageUpload(editorElms, {
csrfToken: "{{ csrf_token }}",
target: "{% url "spirit:comment:image-upload-ajax" %}",
placeholderText: "{% trans "uploading {name}" %}",
allowedFileMedia: "{% get_allowed_image_types %}"
});
{% endif %}

{% if st_settings.ST_UPLOAD_FILE_ENABLED %}
stModules.editorFileUpload(editorElms, {
csrfToken: "{{ csrf_token }}",
target: "{% url "spirit:comment:file-upload-ajax" %}",
placeholderText: "{% trans "uploading {name}" %}",
allowedFileMedia: "{% get_allowed_file_types %}"
});
{% endif %}

}
});
stModules.editor(editorElms, {
boldedText: "{% trans "bolded text" %}",
italicisedText: "{% trans "italicised text" %}",
listItemText: "{% trans "list item" %}",
linkText: "{% trans "link text" %}",
linkUrlText: "{% trans "link url" %}",
imageText: "{% trans "image text" %}",
imageUrlText: "{% trans "image url" %}",
fileText: "{% trans "file text" %}",
fileUrlText: "{% trans "file url" %}",
pollTitleText: "{% trans "Title" %}",
pollChoiceText: "{% trans "Description" %}"
});

var editor = new Textcomplete.editors.Textarea(
document.querySelector('.js-reply').querySelector('textarea'));
var textcomplete = new Textcomplete(editor, {
dropdown: {className: 'textcomplete', maxCount: 5}});
textcomplete.register([{
match: /(^|\s):([a-z0-9+\-\_]*)$/,
search: function (term, callback) {
callback(stModules.emojiList.filter(function (emoji) {
return emoji.startsWith(term);
}));
},
replace: function (value) {
return '$1:' + value + ': ';
},
template: function (name) {
var clsName = name
.split('_').join('-')
.split('+').join('plus');
return "<li><i class=\"tw tw-" + clsName + "\"></i> " + name + "</li>"
}
}]);
textcomplete.on('rendered', function () {
// Auto select first item
textcomplete.dropdown.items[0].activate();
});
})();

});
</script>
9 changes: 6 additions & 3 deletions spirit/comment/templates/spirit/comment/_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@


<script>
$( document ).ready(function() {
document.addEventListener('DOMContentLoaded', function() {

$( ".reply" ).find( "textarea" ).store( "comment-thread-{{ topic_id }}" );
stModules.store(
document.querySelector('.reply').querySelector('textarea'),
'comment-thread-{{ topic_id }}'
);

});
</script>
</script>
Loading

0 comments on commit d02b5d2

Please sign in to comment.