Skip to content

Commit

Permalink
Merge pull request #50 from peckadesign/generovani-css-class-ve-vlast…
Browse files Browse the repository at this point in the history
…ni-metode

Generování CSS class pro chybovou hlášku obstarává samostatná metoda
  • Loading branch information
zipper authored Mar 30, 2022
2 parents a8faa87 + 62a11cd commit 7a38deb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pd-forms",
"title": "pdForms",
"description": "Customization of netteForms for use in PeckaDesign.",
"version": "3.5.0",
"version": "3.6.0",
"author": "PeckaDesign, s.r.o <[email protected]>",
"contributors": [
"Radek Šerý <[email protected]>",
Expand Down
21 changes: 12 additions & 9 deletions src/assets/pdForms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @name pdForms
* @author Radek Šerý <[email protected]>
* @version 3.5.0
* @version 3.6.0
*
* Features:
* - live validation
Expand Down Expand Up @@ -45,7 +45,7 @@

var pdForms = window.pdForms || {};

pdForms.version = '3.5.0';
pdForms.version = '3.6.0';


/**
Expand Down Expand Up @@ -399,6 +399,14 @@
};


/**
* Returns class name used for generated message.
*/
pdForms.getMessageClassName = function (isGlobalMessage, tagName, type) {
return (tagName === 'p') ? ('message message--' + type) : ('inp-' + type);
}


/**
* Display message. Either input associated or (if appropriate selector not found) as "global" form message.
* Message placeholding:
Expand Down Expand Up @@ -434,17 +442,12 @@
return false;
}

var tagName = 'label';
var className = 'inp-' + type;

if (placeholder.isGlobal) {
tagName = 'p';
}
var tagName = placeholder.isGlobal ? 'p' : 'label';

// global message or non-error message or first error message
if (placeholder.isGlobal || type !== pdForms.constants.MESSAGE_ERROR || (type === pdForms.constants.MESSAGE_ERROR && ((' ' + placeholder.elem.className + ' ').indexOf(' ' + type + ' ') === -1))) {
tagName = placeholder.elem.getAttribute('data-pdforms-messages-tagname') || tagName;
className = (tagName === 'p') ? 'message message--' + type : className;
var className = pdForms.getMessageClassName(placeholder.isGlobal, tagName, type);

var msg = document.createElement(tagName);

Expand Down

0 comments on commit 7a38deb

Please sign in to comment.