X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/939f115b73778ebcd99e99abc04e94dbe16d17ff..29a13b9e77d5a7ac5d26c95488028f88e6b57c2f:/apps/wolnelektury_core/static/js/picture.js diff --git a/apps/wolnelektury_core/static/js/picture.js b/apps/wolnelektury_core/static/js/picture.js index bcbdbc177..052392a32 100644 --- a/apps/wolnelektury_core/static/js/picture.js +++ b/apps/wolnelektury_core/static/js/picture.js @@ -33,6 +33,20 @@ var original = self.element.find('img.original').get(0); self._original = false; + self.original_loeaded = undefined; // callback + self._original_loaded = false; + + self.spinner = $("#spinner").progressSpin(); + + $(original).load(function() { + console.log("loaded original"); + self._original_loaded = true; + self.spinner.stop(); + var cb = self.original_loaded; + self.original_loaded = undefined; + if (cb) + cb() + }); if (self.options.max <= 0) { self.options.max = original.naturalWidth @@ -44,7 +58,7 @@ }); self.element.offset(self.initial_position); - self.element.draggable({containment:"parent"}); + // self.element.draggable({containment:"parent"}); if (self.options.plus_button) self.options.plus_button.click( @@ -67,18 +81,27 @@ return self; }, - natural_size: function() { - var img = this.element.find('img').get(0); + natural_size: function() { + var img = this.element.find('img.original').get(0); return [ img.naturalWidth, img.naturalHeight ] }, currentZoom: function() { return this._zoom; }, initOriginal: function() { + var self = this; + function subst_original() { + self.element.find("img.initial").remove(); + self.element.find("img.loading").removeClass("loading"); + self._original = true; + } if (!this._original) { - this.element.find("img.initial").remove(); - this.element.find("img.loading").removeClass("loading"); - this._original = true; + if (this._original_loaded) { + return subst_original(); + } else { + self.original_loaded = subst_original; + self.spinner.start(); + } } }, @@ -112,7 +135,11 @@ }; this._zoom = level; - this.element.animate(target, 200); // default duration=400 + + this.element.css(target); + + +// this.element.animate(target, 1200); // default duration=400 }, allowedPosition: function(off) { @@ -200,12 +227,19 @@ $(document).ready(function(){ $($t.attr('href')).hide().insertAfter(this); }); - $('.toolbar a.dropdown').toggle(function() { - $(this).addClass('selected'); - $($(this).attr('href')).slideDown('fast'); - }, function() { + function closeDD() { $(this).removeClass('selected'); $($(this).attr('href')).slideUp('fast'); + + } + $('.toolbar a.dropdown').click(function() { + if ($(this).hasClass('selected')) { + closeDD.call(this); + } else { + $(this).addClass('selected'); + $($(this).attr('href')).slideDown('fast'); + $(this).parent().siblings(".button:has(.dropdown)").children(".dropdown").each(closeDD); + } });