summaryrefslogtreecommitdiff
path: root/core/js/quick.js
blob: 858ba3f27aadf592e11af1bea40bfd571aed8ad5 (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
$(document).ready(function() {
  $(".gQuick").hover(show_quick, function() {});
});

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

var quick_do = function(quick, pane, img) {
  img.css("opacity", "0.2");
  quick.addClass("gLoadingLarge");
  $.ajax({
    type: "GET",
    url: pane.attr("quick_link"),
    dataType: "json",
    success: function(data) {
      img.css("opacity", "1");
      img.attr("width", data.width);
      img.attr("height", data.height);
      img.attr("src", data.src);
      var pos = img.position();
      quick.removeClass("gLoadingLarge");
      $("#gQuickPane").css({
        "position": "absolute",
        "top": pos.top,
        "left": pos.left,
        "width": img.innerWidth() + 1,
        "height": 32
      });
    }
  });
};

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