summaryrefslogtreecommitdiff
path: root/core/js/quick.js
blob: 457b6d4a2d8b7776f2360564a30ab07adcfe6219 (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
73
74
75
$(document).ready(function() {
  if ($("#gAlbumGrid").length) {
	// @todo Add quick edit pane for album (meta, move, permissions, delete)
	//$("#gInfo").hover(show_quick, function() {});
	$(".gItem").hover(show_quick, function() {});
  }
  if ($("#gItem").length) {
	// @todo Apply quick edit to resize view
  }
});

var show_quick = function() {
  var cont = $(this);
  var quick = $(this).find(".gQuick");
  $("#gQuickPane").remove();
  cont.append("<div id=\"gQuickPane\"></div>");
  var img = cont.find(".gThumbnail");
  var pos = cont.position();
  $("#gQuickPane").css({
    "position": "absolute",
    "top": pos.top,
    "left": pos.left,
    "width": cont.innerWidth() + 1,
    "height": 32
  }).hide();
  cont.hover(function() {}, hide_quick);
  $.get(
    quick.attr("href"),
    {},
    function(data, textStatus) {
      $("#gQuickPane").html(data).slideDown("fast");
      $("#gQuickPane a").click(function(e) {
        e.preventDefault();
        quick_do(cont, $(this), img);
      });
    }
  );
};

var quick_do = function(cont, pane, img) {
  if (pane.hasClass("gDialogLink")) {
    openDialog(pane, function() { window.location.reload(); });
  } else {
    img.css("opacity", "0.1");
    cont.addClass("gLoadingLarge");
    $.ajax({
      type: "GET",
      url: pane.attr("href"),
      dataType: "json",
      success: function(data) {
	img.css("opacity", "1");
	cont.removeClass("gLoadingLarge");
	if (data.src) {
	  img.attr("width", data.width);
	  img.attr("height", data.height);
	  img.attr("src", data.src);
	  if (data.height > data.width) {
	    img.css("margin-top", -32);
	  } else {
	    img.css("margin-top", 0);
	  }
        } else if (data.location) {
          window.location = data.location;
	} else if (data.reload) {
          window.location.reload();
	}
      }
    });
  }
  return false;
};

var hide_quick = function() {
  $("#gQuickPane").remove();
};