mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-03 23:34:09 +02:00
Allow only px values in custom items in edit-design plugin
This commit is contained in:
parent
934cba7251
commit
5896f8e35a
Resources/Plugins/edit-design
@ -8,7 +8,7 @@ Edit layout & design
|
|||||||
chylex
|
chylex
|
||||||
|
|
||||||
[version]
|
[version]
|
||||||
1.1.5
|
1.1.6
|
||||||
|
|
||||||
[website]
|
[website]
|
||||||
https://tweetduck.chylex.com
|
https://tweetduck.chylex.com
|
||||||
|
@ -173,28 +173,44 @@ enabled(){
|
|||||||
}
|
}
|
||||||
// SELECTS
|
// SELECTS
|
||||||
else if (tag === "SELECT"){
|
else if (tag === "SELECT"){
|
||||||
if (!item.val(me.config[key]).val()){
|
let optionCustom = item.find("option[value^='custom']");
|
||||||
let custom = item.find("option[value='custom']");
|
|
||||||
|
let resetMyValue = () => {
|
||||||
if (custom.length === 1){
|
if (!item.val(me.config[key]).val() && optionCustom.length === 1){
|
||||||
item.val("custom");
|
item.val(optionCustom.attr("value"));
|
||||||
custom.text(getTextForCustom(key));
|
optionCustom.text(getTextForCustom(key));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
resetMyValue();
|
||||||
|
|
||||||
item.change(function(){ // TODO change doesn't fire when Custom is already selected
|
item.change(function(){ // TODO change doesn't fire when Custom is already selected
|
||||||
let val = item.val();
|
let val = item.val();
|
||||||
|
|
||||||
if (val === "custom"){
|
if (val === "custom-px"){
|
||||||
val = prompt("Enter custom value:");
|
val = (prompt("Enter custom value (px):") || "").trim();
|
||||||
|
|
||||||
if (val){
|
if (val){
|
||||||
updateKey(key, val);
|
if (val.endsWith("px")){
|
||||||
item.find("option[value='custom']").text(getTextForCustom(key));
|
val = val.slice(0, -2).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^[0-9]+$/.test(val)){
|
||||||
|
updateKey(key, val+"px");
|
||||||
|
optionCustom.text(getTextForCustom(key));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
alert("Invalid value, only px values are supported.");
|
||||||
|
resetMyValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
resetMyValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
updateKey(key, item.val());
|
updateKey(key, item.val());
|
||||||
|
optionCustom.text("Custom");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<option value="310px">Medium (310px)</option>
|
<option value="310px">Medium (310px)</option>
|
||||||
<option value="350px">Wide (350px)</option>
|
<option value="350px">Wide (350px)</option>
|
||||||
<option value="400px">Extreme (400px)</option>
|
<option value="400px">Extreme (400px)</option>
|
||||||
<option value="custom">Custom</option>
|
<option value="custom-px">Custom</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<option disabled></option>
|
<option disabled></option>
|
||||||
<optgroup label="Dynamic width">
|
<optgroup label="Dynamic width">
|
||||||
@ -59,7 +59,7 @@
|
|||||||
<option value="14px">Medium (14px)</option>
|
<option value="14px">Medium (14px)</option>
|
||||||
<option value="15px">Large (15px)</option>
|
<option value="15px">Large (15px)</option>
|
||||||
<option value="16px">Largest (16px)</option>
|
<option value="16px">Largest (16px)</option>
|
||||||
<option value="custom">Custom</option>
|
<option value="custom-px">Custom</option>
|
||||||
</select>
|
</select>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input data-td-key="increaseQuoteTextSize" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
<input data-td-key="increaseQuoteTextSize" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||||
|
Loading…
Reference in New Issue
Block a user