X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/939f115b73778ebcd99e99abc04e94dbe16d17ff..c6939b2a92556332eaab2cbbfd61a0e6798091c7:/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..0840aa5fa 100644 --- a/apps/wolnelektury_core/static/js/picture.js +++ b/apps/wolnelektury_core/static/js/picture.js @@ -33,6 +33,19 @@ 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() { + 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 +57,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( @@ -75,10 +88,19 @@ 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(); + } } }, @@ -102,7 +124,7 @@ var new_width = ratio * this.initial_size[0]; var new_height = ratio * this.initial_size[1]; var target = { - 'width': new_width, +// 'width': new_width, 'left': Math.max(0, this.initial_position.left - (new_width - this.initial_size[0])/2), @@ -112,7 +134,11 @@ }; this._zoom = level; - this.element.animate(target, 200); // default duration=400 + + this.element.css(target); + this.element.find(".original").width(new_width); + +// this.element.animate(target, 1200); // default duration=400 }, allowedPosition: function(off) { @@ -200,12 +226,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); + } });