Skip to content
Permalink
Browse files

simpler way to load jquery

  • Loading branch information
ralsina committed Jun 10, 2015
1 parent b55e6e9 commit d209076483829b058bac9697e5e60737f882b9c5
Showing with 22 additions and 26 deletions.
  1. +11 −11 nikola/data/themes/base-jinja/templates/gallery.tmpl
  2. +11 −15 nikola/data/themes/base/templates/gallery.tmpl
@@ -54,6 +54,15 @@
{% endblock %}

{% block extra_js %}

<script>
{% if use_cdn %}
window.jQuery || document.write("<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'>\x3C/script>")
{% else %}
window.jQuery || document.write("<script src='/assets/js/jquery.min.js'>\x3C/script>")
{% endif %}
</script>

<script>
function createGallery() {
jQuery.getScript("/assets/js/flowr.plugin.js");
@@ -93,16 +102,7 @@ function createGallery() {
});
})};

// Load JQuery if it's not there already
if(typeof jQuery=='undefined') {
var headTag = document.getElementsByTagName("head")[0];
var jqTag = document.createElement('script');
jqTag.type = 'text/javascript';
jqTag.src = '//code.jquery.com/jquery-1.11.3.min.js';
jqTag.onload = createGallery;
headTag.appendChild(jqTag);
} else {
createGallery();
}
createGallery();

</script>
{% endblock %}
@@ -54,6 +54,15 @@ ${parent.extra_head()}
</%block>

<%block name="extra_js">

<script>
%if use_cdn:
window.jQuery || document.write("<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'>\x3C/script>")
%else:
window.jQuery || document.write("<script src='/assets/js/jquery.min.js'>\x3C/script>")
%endif
</script>

<script>
function createGallery() {
jQuery.getScript("/assets/js/flowr.plugin.js");
@@ -93,20 +102,7 @@ function createGallery() {
});
})};

// Load JQuery if it's not there already
if(typeof jQuery=='undefined') {
var headTag = document.getElementsByTagName("head")[0];
var jqTag = document.createElement('script');
jqTag.type = 'text/javascript';
% if use_cdn
jqTag.src = '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js';
% else
jqTag.src = '/assets/js/jquery.min.js';
% endif
jqTag.onload = createGallery;
headTag.appendChild(jqTag);
} else {
createGallery();
}
createGallery();

</script>
</%block>

0 comments on commit d209076

Please sign in to comment.