-
Notifications
You must be signed in to change notification settings - Fork 780
Basic UI: several fix for selection and switch with mappings #3368
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -455,8 +455,10 @@ | |
var | ||
_t = this; | ||
|
||
_t.value = _t.parentNode.querySelector(o.formValue); | ||
_t.hasValue = _t.parentNode.getAttribute("data-has-value") === "true"; | ||
_t.value = _t.parentNode.parentNode.querySelector(o.formValue); | ||
_t.count = _t.parentNode.getAttribute("data-count") * 1; | ||
_t.suppressUpdateButtons = false; | ||
_t.reset = function() { | ||
_t.buttons.forEach(function(button) { | ||
button.classList.remove(o.buttonActiveClass); | ||
|
@@ -478,28 +480,37 @@ | |
item: _t.item, | ||
value: value | ||
})); | ||
_t.suppressUpdate(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [1] I understand that you need to obtain some properties from server so you don't want to suppress the callback entirely... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [6] |
||
_t.suppressUpdateButtons = true; | ||
}; | ||
_t.valueMap = {}; | ||
_t.buttons = [].slice.call(_t.parentNode.querySelectorAll(o.controlButton)); | ||
_t.setValuePrivate = function(value) { | ||
if (_t.value !== null) { | ||
_t.setValuePrivate = function(value, itemState) { | ||
if (_t.value !== null && _t.hasValue) { | ||
_t.value.innerHTML = value; | ||
} | ||
|
||
if (_t.count === 1) { | ||
return; | ||
} | ||
|
||
if (_t.suppressUpdateButtons) { | ||
_t.suppressUpdateButtons = false; | ||
return; | ||
} | ||
|
||
_t.reset(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [2] ...but could you please implement another way to suppress the useless call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [4]
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [5] This has to do with animations and avoiding touching DOM too much |
||
if ( | ||
(_t.valueMap !== undefined) && | ||
(_t.valueMap[value] !== undefined) | ||
(_t.valueMap[itemState] !== undefined) | ||
) { | ||
_t.valueMap[value].classList.add(o.buttonActiveClass); | ||
_t.valueMap[itemState].classList.add(o.buttonActiveClass); | ||
} | ||
}; | ||
|
||
_t.setValueColor = function(color) { | ||
_t.value.style.color = color; | ||
}; | ||
|
||
_t.buttons.forEach.call(_t.buttons, function(button) { | ||
var | ||
value = button.getAttribute("data-value") + ""; | ||
|
@@ -575,15 +586,19 @@ | |
}); | ||
}; | ||
|
||
_t.setValuePrivate = function(value) { | ||
_t.value = "" + value; | ||
if (_t.valueMap[value] !== undefined) { | ||
_t.valueNode.innerHTML = _t.valueMap[value]; | ||
_t.setValuePrivate = function(value, itemState) { | ||
_t.value = "" + itemState; | ||
if (_t.valueMap[itemState] !== undefined) { | ||
_t.valueNode.innerHTML = _t.valueMap[itemState]; | ||
} else { | ||
_t.valueNode.innerHTML = ""; | ||
} | ||
}; | ||
|
||
_t.setValueColor = function(color) { | ||
_t.valueNode.style.color = color; | ||
}; | ||
|
||
_t.parentNode.parentNode.addEventListener("click", _t.showModal); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[3] For example,
_t.suppressReset = false
here.