Sha256: 0498aae5bf8c3d8c34b0c34304cc8745226f7f00473835db61d9593b80885a7d
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 KB
Contents
/* global Fae */ 'use strict'; /** * Fae form cancel * @namespace form.cancel * @memberof form */ Fae.form.cancel = { init: function() { this.detectCancelledUrls(); this.addCancelParam(); }, /** * If URL has cancelled param, update the history */ detectCancelledUrls: function() { var params = window.location.search; if (params.length && params.toLowerCase().indexOf("cancelled") >= 0 && params.indexOf("&") !== 0) { window.history.replaceState(null, null, window.location.pathname); }; }, /** * Once any field changes, add cancelled param to button to ensure user knows data will be lost */ addCancelParam: function() { var updateCancel = function () { var $cancel_btn = $('#main_content-header-save-cancel'); var new_href = $cancel_btn.attr('href') + '?cancelled=true'; $cancel_btn.attr('href', new_href); $('form').off('change', 'input, textarea, select', updateCancel); } $('form').on('change', 'input, textarea, select', updateCancel); } };
Version data entries
4 entries across 4 versions & 1 rubygems