fix dropbox on second load

The problem was that the dropbox saver checks to see if it's already
run before adding buttons. the lightbox was actually running the saver
a second time. on pages with multiple download buttons, the buttons
would get added only on the first lightbox.
pull/1/head
eric 2014-05-25 00:26:47 -04:00
parent 2e41e2a33d
commit 8d1a9f44b0
2 changed files with 6 additions and 5 deletions

View File

@ -8,7 +8,7 @@
{% block extra_js %}
<script type="text/javascript" src="/static/js/embed.js"></script>
<script type="text/javascript" src="/static/js/download_page.js"></script>
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" ></script>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function() {
@ -139,7 +139,6 @@ $j(document).ready(function() {
<a href="{% url download_ebook ebook.id %}">{{ ebook.format }}</a>
{% if ebook.is_direct %}<a class="dropbox-saver" href="{{ ebook.download_url }}" data-filename="unglueit-{{ work.id }}.{{ ebook.format }}"></a>{% endif %}
</p>
{% if not forloop.last %}<br /><br />{% endif %}
{% endfor %}
@ -399,7 +398,6 @@ $j(document).ready(function() {
{% endif %}
</div>
</div>
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" ></script>
{% endblock %}
{% endwith %}

View File

@ -22,8 +22,11 @@ $j(document).ready(function() {
});
if ($j(this).attr("href").indexOf("download") !== -1) {
jQuery.getScript('/static/js/download_page.js');
jQuery.getScript('https://www.dropbox.com/static/api/2/dropins.js');
$j.getScript('/static/js/download_page.js');
if(typeof(Dropbox) != "undefined"){
Dropbox._dropinsjs_loaded=false;
}
$j.getScript('https://www.dropbox.com/static/api/2/dropins.js');
var work_page = $j(this).attr("href").split("download")[0];
$j.cookie('next', work_page, {path: '/'});
}