summaryrefslogtreecommitdiff
path: root/modules/organize/js/organize.js
blob: 6b4a5934a178b5cc52c1b0d187e0821cb3936b6d (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
(function($) {
  $.organize = {
    /**
     * Dynamically initialize the organize dialog when it is displayed
     */
    init: function(data) {
      // Resize with 50 pixels padding all around
      var size = $.getViewportSize();
      $("#gDialog").dialog("option", "height", size.height() - 100)
	.dialog("option", "width", size.width() - 100)
	.dialog("option", "position", "center");

      // Deal with ui.jquery bug: http://dev.jqueryui.com/ticket/4475 (target 1.8?)
      $(".sf-menu li.sfHover ul").css("z-index", 70);

      var height = $("#gOrganizeDetail").innerHeight();
      $("#gMicroThumbPanel").height(height - $("#gOrganizeEditDrawerHandle").outerHeight());

      $("#gDialog #gMicroThumbDone").click(function(event) {
        $("#gDialog").dialog("close");
        window.location.reload();
      });

      $(".gBranchText span").click($.organize.collapse_or_expand_tree);
      $(".gBranchText").click($.organize.show_album);
    },

    /**
     * Open or close a branch.
     */
    collapse_or_expand_tree: function(event) {
      event.stopPropagation();
      $(event.currentTarget).toggleClass("ui-icon-minus").toggleClass("ui-icon-plus");
      $("#gOrganizeChildren-" + $(event.currentTarget).attr("ref")).toggle();
    },

    /**
     * When the text of a selection is clicked, then show that albums contents
     */
    show_album: function(event) {
      event.preventDefault();
      if ($(event.currentTarget).hasClass("gBranchSelected")) {
        return;
      }
      var id = $(event.currentTarget).attr("ref");
      $(".gBranchSelected").removeClass("gBranchSelected");
      $("#gOrganizeBranch-" + id).addClass("gBranchSelected");
      var url = $("#gMicroThumbPanel").attr("ref").replace("__ITEM_ID__", id).replace("__OFFSET__", 0);
      $.get(url, function(data) {
        $("#gMicroThumbGrid").html(data);
      });
    }
  };
})(jQuery);