Sha256: 187e99e0981309abe5e9f59ff4edcd48f71f3d180b7a421d5e3f3d904543f409

Contents?: true

Size: 1.58 KB

Versions: 29

Compression:

Stored size: 1.58 KB

Contents

/**
 * Makes the #select-identity-button to open a popup for the user to
 * select with which identity he wants to perform an action.
 *
 */
$(document).ready(function () {

  let button = $("#select-identity-button"),
      refreshUrl = null,
      userIdentitiesDialog = $("#user-identities");

  if (userIdentitiesDialog.length) {
    refreshUrl = userIdentitiesDialog.data("refresh-url");

    button.click(function () {
      $.ajax(refreshUrl).done(function(response) {
        userIdentitiesDialog.html(response).foundation("open");
        button.trigger("ajax:success")
      });
    });
  }
});


/**
 * Manage the identity selector for endorsements.
 *
 */
$(document).ready(function () {
  $("#select-identity-button").on("ajax:success", function() {
    // once reveal popup has been rendered register event callbacks
    $("#user-identities ul.reveal__list li").each(function(index, elem) {
      let liTag = $(elem)
      liTag.on("click", function() {
        let method = liTag.data("method")
        let url = liTag.data("url")
        $.ajax({
          url: url,
          method: method,
          dataType: "script",
          success: function() {
            if (liTag.hasClass("selected")) {
              liTag.removeClass("selected")
              liTag.find(".icon--circle-check").addClass("invisible")
              liTag.data("method", "post")
            } else {
              liTag.addClass("selected")
              liTag.find(".icon--circle-check").removeClass("invisible")
              liTag.data("method", "delete")
            }
          }
        })
      })
    });
  });
})

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
decidim-proposals-0.21.0 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.20.1 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.20.0 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.19.1 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.18.1 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.19.0 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.17.2 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.18.0 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.17.1 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.16.1 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.17.0 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.16.0 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.15.2 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.15.1 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.15.0 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.14.4 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.14.3 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.14.2 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.14.1 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6
decidim-proposals-0.13.1 app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6