diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-04-03 00:50:43 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-04-03 00:50:43 +0000 |
commit | f1cb43430bc84aaa2bcf7bfc99d1ef9dd0138e78 (patch) | |
tree | f7f8ae15106ec67d6b10220a6754c2d67353b048 /modules/organize/js | |
parent | 688376223853bcc07ef0eed9926a2a6fce46ef9e (diff) |
First iteration of the organize functionality (orginally called bulk
edit). There is limited functionality in no edits work. This is
primary a chance for the team to review the ui. It is in a separate
module to isolate the changes. Eventually, it will be moved back into core.
Diffstat (limited to 'modules/organize/js')
-rw-r--r-- | modules/organize/js/organize.js | 172 | ||||
-rw-r--r-- | modules/organize/js/organize_init.js | 24 |
2 files changed, 196 insertions, 0 deletions
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js new file mode 100644 index 00000000..c3e5d3be --- /dev/null +++ b/modules/organize/js/organize.js @@ -0,0 +1,172 @@ +/* + * @todo Trap resize of dialog and resize the child areas (tree, grid and edit form) + */ +var url; +var height; + +function get_album_content() { + var grid_width = $("#gMicroThumbContainer").width(); + url = $("#gMicroThumbContainer").attr("ref"); + url = url.replace("__WIDTH__", grid_width); + url = url.replace("__HEIGHT__", height); + + retrieve_micro_thumbs(url); +} + +function retrieve_micro_thumbs() { + var offset = $("#gMicroThumbGrid li").length; + if (url == null) { + var grid_width = $("#gMicroThumbContainer").width(); + url = $("#gMicroThumbContainer").attr("ref"); + url = url.replace("__WIDTH__", grid_width); + url = url.replace("__HEIGHT__", height); + } + var url_data = url.replace("__OFFSET__", offset); + url_data = url.replace("__ITEM_ID__", item_id); + $.get(url_data, function(data) { + $("#gMicroThumbGrid").append(data); + get_more_data(); + }); +} + +function get_more_data() { + var element = $("#gMicroThumbContainer").get(0); + var scrollHeight = element.scrollHeight; + var scrollTop = element.scrollTop; + var height = $("#gMicroThumbContainer").height(); + var scrollPosition = scrollHeight - (scrollTop + height); + if (scrollPosition > 0 && scrollPosition <= 100) { + retrieve_micro_thumbs(); + } +} + +function toggle_select(event) { + var clone = null; + var id = $(this).attr("id").replace(/[^0-9]/g, ""); + + if ($(this).hasClass("gThumbSelected")) { + $(this).removeClass("gThumbSelected"); + var newSelect = $(".gThumbSelected"); + if (newSelect.size() == 1) { + clone = $(".gThumbSelected").children("img").clone(true); + id = $(".gThumbSelected").attr("id").replace(/[^0-9]/g, ""); + } else { + clone = null; + } + } else { + clone = $(this).children("img").clone(true); + $(this).addClass("gThumbSelected"); + } + switch ($(".gThumbSelected").size()) { + case 0: + reset_edit_select(); + break; + case 1: + $("#gOrganizeFormThumb").empty(); + $("#gOrganizeFormThumb").append(clone); + $("#gOrganizeFormNoImage").hide(); + $("#gOrganizeFormMultipleImages").hide(); + $("#gOrganizeFormThumb").show(); + $("#gOrganizeButtonPane").show(); + $.getJSON($("#gOrganizeFormInfo").attr("ref").replace("__ITEM_ID__", id), function(data) { + $("#gOrganizeFormTitle").text(data.title); + $("#gOrganizeFormOwner").text(data.owner); + $("#gOrganizeFormDate").text(data.date); + $("#gOrganizeFormDescription").text(data.description); + $("#gOrganizeFormInfo").show(); + }); + break; + default: + $("#gOrganizeFormThumb").hide(); + $("#gOrganizeFormInfo").hide(); + $("#gOrganizeFormMultipleImages").show(); + } + event.preventDefault(); +} + +function reset_edit_select() { + $("#gOrganizeFormNoImage").show(); + $("#gOrganizeFormThumb").hide(); + $("#gOrganizeFormMultipleImages").hide(); + $("#gOrganizeButtonPane").hide(); + $("#gOrganizeFormInfo").hide(); +} + +function organize_toggle_children(event) { + var id = $(this).attr("ref"); + var span_children = $("#gOrganizeChildren-" + id); + if ($(this).hasClass("ui-icon-plus")) { + $(this).removeClass("ui-icon-plus"); + $(this).addClass("ui-icon-minus"); + $("#gOrganizeChildren-" + id).removeClass("gBranchCollapsed"); + } else { + $(this).removeClass("ui-icon-minus"); + $(this).addClass("ui-icon-plus"); + $("#gOrganizeChildren-" + id).addClass("gBranchCollapsed"); + } + event.preventDefault(); +} + +function organize_open_folder(event) { + var selected = $(".gBranchSelected"); + if ($(selected).attr("id") != $(this).attr("id")) { + $(selected).removeClass("gBranchSelected"); + $(this).addClass("gBranchSelected"); + item_id = $(this).attr("ref"); + $("#gMicroThumbGrid").empty(); + var url_header = $("#gDialog #hd").attr("ref").replace("__ITEM_ID__", item_id); + $.getJSON(url_header, function(data) { + $("#gOrganizeAlbumTitle").text(data.title); + $("#gOrganizeAlbumDescription").text(data.description); + }); + reset_edit_select(); + retrieve_micro_thumbs(); + } + event.preventDefault(); +} + +function organize_dialog_init() { + var size = viewport_size(); + height = size.height() - 100; + var width = size.width() - 100; + + $("#gDialog").dialog("option", "width", width); + $("#gDialog").dialog("option", "height", height); + + $("#gDialog").dialog("open"); + if ($("#gDialog h1").length) { + $("#gDialog").dialog('option', 'title', $("#gDialog h1:eq(0)").html()); + } else if ($("#gDialog fieldset legend").length) { + $("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html()); + } + + height -= 2 * parseFloat($("#gDialog").css("padding-top")); + height -= 2 * parseFloat($("#gDialog").css("padding-bottom")); + height -= $("#gMicroThumbContainer").position().top; + height -= $("#gDialog #ft").height(); + height = Math.round(height); + + $("#gMicroThumbContainer").height(height); + $("#gOrganizeTreeContainer").height(height); + $("#gOrganizeEditContainer").height(height); + + $(".gOrganizeBranch .ui-icon").click(organize_toggle_children); + $(".gBranchText").click(organize_open_folder); + retrieve_micro_thumbs(item_id); + //showLoading("#gDialog"); +} + +function viewport_size() { + return { + width : function() { + return window.innerWidth + || document.documentElement && document.documentElement.clientWidth + || document.body.clientWidth; + }, + height : function() { + return window.innerHeight + || document.documentElement && document.documentElement.clientHeight + || document.body.clientHeight; + } + }; +} diff --git a/modules/organize/js/organize_init.js b/modules/organize/js/organize_init.js new file mode 100644 index 00000000..70949eab --- /dev/null +++ b/modules/organize/js/organize_init.js @@ -0,0 +1,24 @@ +$("document").ready(function() { + $("#gOrganizeLink").click(function(event) { + event.preventDefault(); + var href = event.target.href; + + $("body").append('<div id="gDialog"></div>'); + + $("#gDialog").dialog({ + autoOpen: false, + autoResize: false, + modal: true, + resizable: true, + close: closeDialog + }); + + //showLoading("#gDialog"); + + $.get(href, function(data) { + $("#gDialog").html(data); + }); + return false; + }); +}); + |