Sha256: d0315c435718bec46c1ed9de247cd4679fb4953dca56b8e585dc7e5692c221ad

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 KB

Contents

/* -*- coding: utf-8 -*-
 *
 * Copyright 2013 whiteleaf. All rights reserved.
 */

/*
 * キュー関係のコード
 */
$(document).ready(function() {
  "use strict";

  /*
   * キューに積まれた数を表示
   */
  var notification = Narou.Notification.instance();
  var $queue = $("#queue");
  function highlightQueuBoxIcon(size) {
    if (size > 0) {
      $("#queue-text").addClass("active");
    }
    else {
      $("#queue-text").removeClass("active");
    }
  }
  notification.on("notification.queue", function(data) {
    var before_size = $queue.text();
    $queue.text(data);
    highlightQueuBoxIcon(data);
    // キューのスタック数の横に +1 が浮かび上がって消えるアニメーション
    var diff = data - before_size;
    if (diff <= 0) return;
    var $plus = $("<span>+" + diff + "</span>");
    $plus.addClass("queue-plus").css({
      position: "absolute",
      left: $queue.offset().left + $queue.outerWidth() + 1 - $(document).scrollLeft(),
      top: $queue.offset().top - 3 - $(document).scrollTop(),
    });
    $(".navbar").append($plus);
    $plus.delay(100).animate({
      top: - $plus.outerHeight(),
      opacity: 0,
    }, 3000, function() {
      $(this).remove();
    });
  });
  $.get("/api/get_queue_size", function(json) {
    $queue.text(json.size);
    highlightQueuBoxIcon(json.size);
  });
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
narou-2.8.3.1 lib/web/public/resources/narou.queue.js
narou-2.8.3 lib/web/public/resources/narou.queue.js
narou-2.8.2 lib/web/public/resources/narou.queue.js
narou-2.8.1 lib/web/public/resources/narou.queue.js
narou-2.8.0 lib/web/public/resources/narou.queue.js
narou-2.7.2 lib/web/public/resources/narou.queue.js
narou-2.7.1 lib/web/public/resources/narou.queue.js
narou-2.7.0 lib/web/public/resources/narou.queue.js