Skip to content

Commit

Permalink
Merge pull request #26 from peckadesign/0-inpNumber-pri-inicializaci-…
Browse files Browse the repository at this point in the history
…respektuje-disabled

Extension `inpNumber` respektuje při inicializaci `disabled` na inputu
  • Loading branch information
zipper authored Oct 13, 2021
2 parents 52bdedc + 4935a93 commit 9b27e4d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# pd.ajax
Vlastní extensions pro nette.ajax

## Changelog
### 1.4.10
- Extension `inpNumber` respektuje při inicializaci `disabled` na inputu. Programová změna za běhu není reflektována, je nutné zavolat ručně metodu `$('#foo').data('inpNumber').setDisabledBtns()` pro daný `.inp-number`.

## Changelog
### 1.4.9
- Ošetření popstate handleru v případě, že není `state` nebo instance `pdBox`.
Expand Down
8 changes: 5 additions & 3 deletions extensions/inpNumber.ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@
.data('disabled', false)
.removeClass('inp-number__btn--disabled');

if (value === this.min) {
if (value === this.min || this.$input.is(':disabled')) {
this.$dec
.data('disabled', true)
.addClass('inp-number__btn--disabled');
}
if (value === this.max) {
if (value === this.max || this.$input.is(':disabled')) {
this.$inc
.data('disabled', true)
.addClass('inp-number__btn--disabled');
Expand Down Expand Up @@ -119,7 +119,8 @@
e.preventDefault();

// už zpracováváme z click event -> desktop, takže longtap ignorujeme
if (e.type === 'longtap' && this.rapidChangeFlag) {
// nebo je tlačítko disabled
if ((e.type === 'longtap' && this.rapidChangeFlag) || this.isClickedBtnDisabled(e)) {
return;
}

Expand Down Expand Up @@ -198,6 +199,7 @@
.find(this.selector)
.each(function() {
var inpNumber = new InpNumber(this);
$(this).data('inpNumber', inpNumber);
});
}
});
Expand Down
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.ajax",
"title": "pd.ajax",
"description": "Collection of nette ajax extensions, including `pd` for creating disabled-by-deafult extensions",
"version": "1.4.9",
"version": "1.4.10",
"author": "PeckaDesign, s.r.o <[email protected]>",
"contributors": [
"Radek Šerý <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion pd.ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright Copyright (c) 2015 Jiří Pudil
* @license MIT
*
* @version 1.4.8
* @version 1.4.10
*/
(function ($, undefined) {
var extensions = {};
Expand Down

0 comments on commit 9b27e4d

Please sign in to comment.