2009-12-12 17:39:18 +00:00
|
|
|
(function($) {
|
|
|
|
var _current_path = "";
|
|
|
|
|
|
|
|
$.fn.gallery3_client = function() {
|
|
|
|
return this.each(function(i) {
|
|
|
|
ajaxifyLoginForm(this);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function ajaxifyLoginForm(obj) {
|
|
|
|
var login = $(obj).find("#g-login-form form");
|
|
|
|
if (login.length > 0) {
|
|
|
|
$(login).ajaxForm({
|
|
|
|
dataType: "json",
|
|
|
|
beforeSubmit: function(formData, form, options) {
|
|
|
|
form.find(":submit")
|
|
|
|
.addClass("ui-state-disabled")
|
|
|
|
.attr("disabled", "disabled");
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
success: function(data) {
|
|
|
|
$(obj).html(data.content);
|
|
|
|
if (data.status == "ok") {
|
|
|
|
initializeDetail(obj);
|
|
|
|
} else {
|
|
|
|
ajaxifyLoginForm(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
initializeDetail(obj);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function initializeDetail(obj) {
|
|
|
|
$(".ui-icon-plus", obj).live("click", function (event) {
|
|
|
|
var siblings = $("~ ul", this);
|
|
|
|
if (siblings.length > 0) {
|
|
|
|
siblings.show();
|
|
|
|
$(this).removeClass("ui-icon-plus");
|
|
|
|
$(this).addClass("ui-icon-minus");
|
|
|
|
} else {
|
|
|
|
var parent = $(this).parent("li");
|
|
|
|
$.get("/g3_client/index.php/g3_client/albums",
|
|
|
|
{path: $(parent).attr("ref")},
|
|
|
|
function(data, textStatus) {
|
|
|
|
$(parent).replaceWith(data);
|
|
|
|
});
|
|
|
|
}
|
2009-12-15 20:23:32 +00:00
|
|
|
return false;
|
2009-12-12 17:39:18 +00:00
|
|
|
});
|
2009-12-15 20:23:32 +00:00
|
|
|
|
2009-12-12 17:39:18 +00:00
|
|
|
$(".ui-icon-minus", obj).live("click", function (event) {
|
|
|
|
$("~ ul", this).hide();
|
|
|
|
$(this).removeClass("ui-icon-minus");
|
|
|
|
$(this).addClass("ui-icon-plus");
|
2009-12-15 20:23:32 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#center a.child-link").live("click", function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
var path = $(this).parent("li").attr("ref");
|
|
|
|
var url = $(this).attr("href");
|
|
|
|
|
|
|
|
$.get("/g3_client/index.php/g3_client/detail", {path: path}, function(data, textStatus) {
|
|
|
|
$("#center").html(data);
|
|
|
|
var album = $("#album_tree [ref='" + path + "']");
|
|
|
|
if (album.length > 0) {
|
|
|
|
$(".ui-selected").removeClass("ui-selected");
|
|
|
|
$(".tree-title", album).addClass("ui-selected");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
2009-12-12 17:39:18 +00:00
|
|
|
});
|
2009-12-15 20:23:32 +00:00
|
|
|
|
2009-12-12 17:39:18 +00:00
|
|
|
$(".tree-title", obj).click(function (event) {
|
2009-12-15 20:23:32 +00:00
|
|
|
$.get("/g3_client/index.php/g3_client/detail",
|
|
|
|
{path: $(this).parent("li").attr("ref")},
|
|
|
|
function(data, textStatus) {
|
2009-12-12 17:39:18 +00:00
|
|
|
$("#center").html(data);
|
2009-12-15 20:23:32 +00:00
|
|
|
});
|
2009-12-12 17:39:18 +00:00
|
|
|
$(".ui-selected").removeClass("ui-selected");
|
|
|
|
$(this).addClass("ui-selected");
|
2009-12-15 20:23:32 +00:00
|
|
|
return false;
|
2009-12-12 17:39:18 +00:00
|
|
|
});
|
|
|
|
$("#album_tree [ref=''] .tree-title:first").addClass("ui-selected");
|
|
|
|
};
|
|
|
|
})(jQuery);
|