Sha256: d767af7089227167cbe9554369b09fda2c78d108b0565a55914f611eba41e7d4

Contents?: true

Size: 860 Bytes

Versions: 2

Compression:

Stored size: 860 Bytes

Contents

$(function () {

  // Copy text action
  $(".translations .actions .copy").click(function (e) {
    e.preventDefault();

    var row = $(this).parents("tr")
      , original = row.find(".phrase .original").text();

    row.find(".translation textarea").addClass("dirty").val(original.trim());

    // Bind the dirty callback after copy
    window.onbeforeunload = confirm;
  });

  // avoid lose data
  $(".translations textarea").bind("blur", function () {
    if ($(this).is(".dirty")) {
      window.onbeforeunload = confirm;
    }
  });

  $(".translations textarea").bind("keydown", function () {
    $(this).addClass("dirty");
  });

  $("input.save, input.apply").click(function () {
    window.onbeforeunload = null;
  });

  function confirm() {
    return "You are leaving this page with non-saved data. Are you sure you want to continue?";
  }

});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tolk-1.3.9 app/assets/javascripts/tolk/actions.js
tolk-1.3.8 app/assets/javascripts/tolk/actions.js