diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-08-10 23:05:05 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-08-10 23:07:50 -0700 |
commit | cbba45fffc7368280e9529f55e108d0080175b6a (patch) | |
tree | ff21dad0410f80e92084815315b75fda677f639d /lib | |
parent | 790545ac97358dd92ce954e617d5255e6644c1a7 (diff) |
Create the concept of an "ajax link" and use it for thumbnail rotation
and album covers in the context menu.
Notes:
- This requires context_menu() to have a CSS selector that refers to the
<img> that we're operating on, otherwise we don't know how to find the
thumbnail, etc.
- Create Menu_Element_Ajax_Link which has an ajax_handler attribute
that contains a snippet of JS that we're going to run when the ajax
call returns.
- Add $.gallery_replace_image in gallery.common.js
- Add lib/gallery.ajax.js which can be used to ajaxify any link, and have
ui.init.js in the themes call that on all .gAjaxLink elements.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gallery.ajax.js | 15 | ||||
-rw-r--r-- | lib/gallery.common.js | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/gallery.ajax.js b/lib/gallery.ajax.js new file mode 100644 index 00000000..4f26745d --- /dev/null +++ b/lib/gallery.ajax.js @@ -0,0 +1,15 @@ +(function($) { + $.widget("ui.gallery_ajax", { + _init: function() { + this.element.click(function(event) { + eval("var ajax_handler = " + $(event.currentTarget).attr("ajax_handler")); + $.get($(event.currentTarget).attr("href"), function(data) { + eval("var data = " + data); + ajax_handler(data); + }); + event.preventDefault(); + return false; + }); + } + }); +})(jQuery); diff --git a/lib/gallery.common.js b/lib/gallery.common.js index fdb7a1cc..53c2fafb 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -104,5 +104,9 @@ ); }; + // Ajax handler for replacing an image, used in Ajax thumbnail rotation + $.gallery_replace_image = function(data, thumb) { + $(thumb).attr({src: data.src, width: data.width, height: data.height}); + }; })(jQuery); |