Skip to content

Commit

Permalink
Merge helpers.js from disable-submit
Browse files Browse the repository at this point in the history
  • Loading branch information
yashikagarg13 committed Nov 9, 2015
1 parent 169cb06 commit 3a44a0c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions js/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
"use strict";

var Freya = Freya || {};
Freya.confs = {
changeSubmitButtonHTML: true,
submitButtonHTMLForAjaxInProcess: '<span class="icon-spinner animate-spin"></span>'
};


// Get real width and height even for hidden element
Freya.getRealDimensions = function ($el, outer) {
Expand Down Expand Up @@ -72,6 +77,22 @@ Freya.sanitize_html = function(value, allowedTags) {
});
};

Freya.disableSubmitBtn = function($btn) {
$btn.prop("disabled", true);
if(Freya.confs.changeSubmitButtonHTML) {
var currentHTML = $btn.html();
$btn.html(Freya.confs.submitButtonHTMLForAjaxInProcess);
return currentHTML;
}
};

Freya.enableSubmitBtn = function($btn, previousHTML) {
$btn.prop("disabled", false);
if(Freya.confs.changeSubmitButtonHTML) {
$btn.html(previousHTML);
}
};

// Tests for sanitize_html
//var str, newstr;
//var allowedTags = ['em', 'p', 'ul', 'ol', 'li', 'br', 'a', 'span', 'div', 'strong'];
Expand Down

0 comments on commit 3a44a0c

Please sign in to comment.