summaryrefslogtreecommitdiff
path: root/lib/gallery.panel.js
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2009-08-29 14:17:48 -0700
committerAndy Staudacher <andy.st@gmail.com>2009-08-29 14:17:48 -0700
commita5dfc81a8f7bef0305b62254252de6df23684199 (patch)
tree4851cb68abede6920208871449dedd2e939c1a16 /lib/gallery.panel.js
parentd5660d2d3ea6e8172272f1eb27e8071a1a42d87b (diff)
parenta9fcec755a835e284465bafcc9aba9ec9c2f0f62 (diff)
Merge commit 'upstream/master'
Conflicts: modules/akismet/views/admin_akismet.html.php modules/comment/helpers/comment_rss.php modules/gallery/helpers/gallery_rss.php modules/gallery/libraries/I18n.php modules/gallery/views/permissions_browse.html.php modules/gallery/views/simple_uploader.html.php modules/info/views/info_block.html.php modules/organize/controllers/organize.php modules/organize/views/organize.html.php modules/organize/views/organize_album.html.php themes/default/views/album.html.php themes/default/views/movie.html.php themes/default/views/photo.html.php
Diffstat (limited to 'lib/gallery.panel.js')
-rw-r--r--lib/gallery.panel.js116
1 files changed, 56 insertions, 60 deletions
diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js
index 022e4878..e0bf4259 100644
--- a/lib/gallery.panel.js
+++ b/lib/gallery.panel.js
@@ -1,62 +1,58 @@
-/**
- * Fire togglePanel() and prevent links from opening
- * @see togglePanel()
- */
-function handlePanelEvent(event) {
- togglePanel(event.currentTarget);
- event.preventDefault();
-}
+(function($) {
+ $.widget("ui.gallery_panel", {
+ _init: function() {
+ var self = this;
+ this.element.click(function(event) {
+ event.preventDefault();
+ var element = event.currentTarget;
+ var parent = $(element).parent().parent();
+ var sHref = $(element).attr("href");
+ var parentClass = $(parent).attr("class");
+ var ePanel = "<tr id=\"gPanel\"><td colspan=\"6\"></td></tr>";
-function togglePanel(element, on_success) {
- var parent = $(element).parent().parent();
- var sHref = $(element).attr("href");
- var parentClass = $(parent).attr("class");
- var ePanel = "<tr id=\"gPanel\"><td colspan=\"6\"></td></tr>";
+ if ($("#gPanel").length) {
+ $("#gPanel").slideUp("slow").remove();
+ if ($(element).attr("orig_text")) {
+ $(element).children(".gButtonText").text($(element).attr("orig_text"));
+ }
+ } else {
+ $(parent).after(ePanel);
+ $("#gPanel td").html(sHref);
+ $.get(sHref, function(data) {
+ $("#gPanel td").html(data);
+ self._ajaxify_panel();
+ if ($(element).attr("open_text")) {
+ $(element).attr("orig_text", $(element).children(".gButtonText").text());
+ $(element).children(".gButtonText").text($(element).attr("open_text"));
+ }
+ $("#gPanel").addClass(parentClass).show().slideDown("slow");
+ });
+ }
+ return false;
+ });
+ },
- if ($("#gPanel").length) {
- $("#gPanel").slideUp("slow");
- $("#gPanel *").remove();
- $("#gPanel").remove();
- if ($(element).attr("orig_text")) {
- $(element).children(".gButtonText").text($(element).attr("orig_text"));
- }
- //togglePanel(element, on_success);
- } else {
- $(parent).after(ePanel);
- //showLoading("#here");
- $("#gPanel td").html(sHref);
- $("#gPanel").addClass(parentClass).show().slideDown("slow");
- $.get(sHref, function(data) {
- $("#gPanel td").html(data);
- ajaxify_panel = function() {
- $("#gPanel td form").ajaxForm({
- dataType: "json",
- success: function(data) {
- if (data.form) {
- $("#gPanel td form").replaceWith(data.form);
- ajaxify_panel();
- }
- if (data.result == "success") {
- if (on_success) {
- on_success();
- } else if (data.location) {
- window.location = data.location;
- } else {
- window.location.reload();
- }
- }
- }
- });
- if ($("#gPanel td").hasClass("gLoadingLarge")) {
- showLoading("#gPanel td");
- }
- };
- ajaxify_panel();
- if ($(element).attr("open_text")) {
- $(element).attr("orig_text", $(element).children(".gButtonText").text());
- $(element).children(".gButtonText").text($(element).attr("open_text"));
- }
- });
- }
- return false;
-}
+ _ajaxify_panel: function () {
+ var self = this;
+ $("#gPanel td form").ajaxForm({
+ dataType: "json",
+ success: function(data) {
+ if (data.form) {
+ $("#gPanel td form").replaceWith(data.form);
+ self._ajaxify_panel();
+ }
+ if (data.result == "success") {
+ self._trigger("success", null, {});
+ if (data.location) {
+ window.location = data.location;
+ } else {
+ window.location.reload();
+ }
+ }
+ }
+ });
+ },
+
+ success: function(event, ui) {}
+ });
+ })(jQuery);