blob: 6115297d02d860b935ba7a5382802d375ec22158 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
(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>";
// We keep track of the open vs. closed state by looking to see if there'
// an orig_text attr. If that attr is missing, then the panel is closed
// and we want to open it
var should_open = !$(element).attr("orig_text");
// Close any open panels and reset their button text
if ($("#gPanel").length) {
$("#gPanel").slideUp("slow").remove();
$.each($(".gPanelLink"),
function() {
if ($(this).attr("orig_text")) {
$(this).children(".gButtonText").text($(this).attr("orig_text"));
$(this).attr("orig_text", "");
}
}
);
}
if (should_open) {
$(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;
});
},
_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);
|