Sha256: 62bbbfa3cd7923c70382f83c69f1f9e9bf532364d0e735244dfc5dbd2697e170

Contents?: true

Size: 949 Bytes

Versions: 66

Compression:

Stored size: 949 Bytes

Contents

// = require ./progressFixed
// = require_self

$(() => {
  const $projects = $('#projects, #project');
  const $budgetSummaryTotal = $('.budget-summary__total');
  const $budgetExceedModal = $('#budget-excess');

  const totalBudget = parseInt($budgetSummaryTotal.attr('data-total-budget'), 10);

  const cancelEvent = (event) => {
    event.stopPropagation();
    event.preventDefault();
  };

  $projects.on('click', '.budget--list__action', (event) => {
    const currentBudget = parseInt($('.budget-summary__progressbox').attr('data-current-budget'), 10);
    const $currentTarget = $(event.currentTarget);
    const projectBudget = parseInt($currentTarget.attr('data-budget'), 10);

    if ($currentTarget.attr('disabled')) {
      cancelEvent(event);

    } else if ($currentTarget.attr('data-add') && ((currentBudget + projectBudget) > totalBudget)) {
      $budgetExceedModal.foundation('toggle');
      cancelEvent(event);
    }
  });
});

Version data entries

66 entries across 66 versions & 2 rubygems

Version Path
decidim-budgets-0.10.1 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.10.0 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.9.3 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.9.2 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.9.1 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.9.0 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.8.4 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.8.3 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.8.2 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.8.1 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.8.0 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.7.4 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.7.3 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.7.2 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.7.1 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.7.0 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.6.8 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-0.6.8 decidim-budgets/app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-budgets-0.6.7 app/assets/javascripts/decidim/budgets/projects.js.es6
decidim-0.6.7 decidim-budgets/app/assets/javascripts/decidim/budgets/projects.js.es6