Skip to content

Commit 1a950d4

Browse files
committed
feat: Lang-aware font family & csk.ui.toggleDisabled
Also bumped version from `1.3.17` to `1.3.18`.
1 parent b718368 commit 1a950d4

File tree

5 files changed

+121
-34
lines changed

5 files changed

+121
-34
lines changed

css/admin.css

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179

180180
--cs-color-default: var(--bs-body-color, #212529);
181181
--cs-color-blue-navbar: #0c314c;
182-
--cs-font-family-default: 'Roboto', 'Noto Kufi Arabic', Tahoma, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
182+
--cs-font-family-default: 'Roboto', Tahoma, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
183183
--cs-font-size-default: .8125rem;
184184
--cs-font-size-small: .75rem;
185185
--cs-font-size-h1: 1.438rem;
@@ -190,6 +190,44 @@
190190
--cs-font-size-h6: .562rem;
191191
}
192192

193+
/* Arabic and Persian */
194+
:root[lang="ar"],
195+
:root[lang="fa"] {
196+
--cs-font-family-default: 'Noto Kufi Arabic', 'Roboto', Tahoma, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
197+
}
198+
199+
/* Japanese */
200+
:root[lang="ja"] {
201+
--cs-font-family-default: 'Noto Sans JP', 'Roboto', Tahoma, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
202+
}
203+
204+
/* Korean */
205+
:root[lang="ko"] {
206+
--cs-font-family-default: 'Noto Sans KR', 'Roboto', Tahoma, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
207+
}
208+
209+
/* Simplified Chinese (China) */
210+
:root[lang="zh"],
211+
:root[lang="zh-cn"] {
212+
--cs-font-family-default: 'Noto Sans SC', 'Roboto', Tahoma, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
213+
}
214+
215+
/* Traditional Chinese (Taiwan) */
216+
:root[lang="zh-tw"] {
217+
--cs-font-family-default: 'Noto Sans TC', 'Roboto', Tahoma, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
218+
}
219+
220+
/* Cyrillic languages (Bulgarian, Russian) */
221+
:root[lang="bg"],
222+
:root[lang="ru"] {
223+
--cs-font-family-default: 'Noto Sans', 'Roboto', Tahoma, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
224+
}
225+
226+
/* Devanagari (Hindi) */
227+
:root[lang="hi"] {
228+
--cs-font-family-default: 'Noto Sans Devanagari', 'Roboto', Tahoma, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
229+
}
230+
193231
html, body {
194232
block-size: 100%;
195233
}
@@ -319,6 +357,15 @@ textarea {
319357
font-size: inherit;
320358
}
321359

360+
.btn:disabled,
361+
.btn.disabled,
362+
button:disabled,
363+
button.disabled {
364+
opacity: .45;
365+
cursor: not-allowed;
366+
pointer-events: none;
367+
}
368+
322369
.no-resize {
323370
resize: none !important;
324371
}
@@ -346,7 +393,6 @@ textarea {
346393
padding: .5rem .625rem;
347394
font-size: var(--cs-font-size-default);
348395
font-weight: 500;
349-
line-height: 1;
350396
}
351397

352398
.page-link {
@@ -2148,7 +2194,7 @@ table td>input[type="checkbox"] {
21482194
left: 50%;
21492195
top: 50%;
21502196
transform: translate(-50%, -50%);
2151-
white-space: normal;
2197+
white-space: nowrap;
21522198
z-index: 1;
21532199
}
21542200

css/admin.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/admin.js

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,50 @@
360360

361361
// Remove the class after blink sequence
362362
setTimeout(() => target.classList.remove('highlight-focus'), 4000);
363+
},
364+
/**
365+
* Enables or disable one or more elements.
366+
* @since 3.10.1
367+
*
368+
* @param {HTMLElement|NodeList|Array} els - Element(s) to toggle.
369+
* @param {boolean} disabled - Whether to disable (true) or enable (false).
370+
*/
371+
toggleDisabled: function(els, disabled) {
372+
if (!els) return;
373+
374+
// Handle single element
375+
if (els instanceof HTMLElement) {
376+
els = [els];
377+
}
378+
// Handle NodeList
379+
else if (els instanceof NodeList) {
380+
els = Array.from(els);
381+
}
382+
// Handle jQuery object
383+
else if (window.jQuery && els instanceof jQuery) {
384+
els = els.toArray();
385+
}
386+
// Handle array-like objects (e.g. HTMLCollection)
387+
else if (!Array.isArray(els) && typeof els.length === "number") {
388+
els = Array.from(els);
389+
}
390+
391+
// Bail if still not iterable
392+
if (!Array.isArray(els)) return;
393+
394+
els.forEach(function(el) {
395+
if (!(el instanceof HTMLElement)) return;
396+
397+
el.disabled = disabled;
398+
399+
if (disabled) {
400+
el.setAttribute("disabled", "disabled");
401+
el.classList.add("disabled");
402+
} else {
403+
el.removeAttribute("disabled");
404+
el.classList.remove("disabled");
405+
}
406+
});
363407
}
364408
};
365409

@@ -526,7 +570,7 @@
526570
}).appendTo(that);
527571

528572
// Enable submit button abck
529-
$(that).closest('form').find("[type=submit]").prop("disabled", false).removeClass("disabled");
573+
csk.ui.toggleDisabled($(that).closest('form').find("[type=submit]"), false);
530574
}
531575
}
532576
});
@@ -779,11 +823,7 @@
779823
target.attr("data-fields", "id:" + Array.from(multiSelect).join(","));
780824
table.attr("data-selected", multiSelect);
781825

782-
if (multiSelect.size === 0) {
783-
$(".bulk-action").prop("disabled", true).addClass("disabled");
784-
} else {
785-
$(".bulk-action").prop("disabled", false).removeClass("disabled");
786-
}
826+
csk.ui.toggleDisabled(document.querySelectorAll(".bulk-action"), multiSelect.size === 0);
787827
});
788828

789829
/**
@@ -816,12 +856,12 @@
816856
},
817857
beforeSend: function() {
818858
if (!$that.prop("disabled")) {
819-
$that.prop("disabled", true).addClass("disabled");
859+
csk.ui.toggleDisabled($that[0], true);
820860
}
821861
},
822862
success: function(data, textStatus, jqXHR) {
823863
csk.ajax._response(data);
824-
$that.removeProp("disabled").removeClass("disabled");
864+
csk.ui.toggleDisabled($that[0], false);
825865
setTimeout(location.reload.bind(location), 2000);
826866
}
827867
});
@@ -836,11 +876,11 @@
836876
},
837877
beforeSend: function() {
838878
if (!$that.prop("disabled")) {
839-
$that.prop("disabled", true).addClass("disabled");
879+
csk.ui.toggleDisabled($that[0], true);
840880
}
841881
},
842882
complete: function() {
843-
$that.removeProp("disabled").removeClass("disabled");
883+
csk.ui.toggleDisabled($that[0], false);
844884
window.location.href = location.href;
845885
}
846886
});
@@ -864,13 +904,14 @@
864904
* @since 1.20
865905
*/
866906
$(document).on("submit", "form", function(e) {
867-
var $form = $(this);
868-
$("[type=submit]").prop("disabled", true).addClass("disabled");
907+
const $form = $(this);
908+
909+
// Disable only submit buttons in this form
910+
csk.ui.toggleDisabled($form.find("[type=submit]"), true);
911+
912+
// Prevent re-submission
913+
$form.on("submit", () => false);
869914

870-
/** Disable the submit event. */
871-
$form.submit(function() {
872-
return false;
873-
});
874915
return true;
875916
});
876917

@@ -906,13 +947,13 @@
906947
}
907948

908949
/** We disable the element before proceeding. */
909-
$that.prop("disabled", true).addClass("disabled");
950+
csk.ui.toggleDisabled($that[0], true);
910951
},
911952
success: function(data, textStatus, jqXHR) {
912953
/** let _response handle response/ */
913954
csk.ajax._response(data);
914955
/** remove disabled property and reload page. */
915-
$that.removeProp("disabled").removeClass("disabled");
956+
csk.ui.toggleDisabled($that[0], false);
916957
setTimeout(location.reload.bind(location), 1500);
917958
}
918959
});
@@ -924,9 +965,9 @@
924965
* @since 1.30
925966
*/
926967
$(document).on("submit", "form[rel]", function(e) {
927-
var $that = $(this),
928-
rel = $that.attr("rel"),
929-
href = $that.attr("ajaxify") || $that.attr("action");
968+
var $form = $(this),
969+
rel = $form.attr("rel"),
970+
href = $form.attr("ajaxify") || $form.attr("action");
930971

931972
/** No action provided? Nothing to do... */
932973
if (typeof href === "undefined" || !href.length) {
@@ -940,16 +981,16 @@
940981
csk.ajax.request(href, {
941982
el: this,
942983
type: "POST",
943-
data: $that.serializeArray(),
984+
data: $form.serializeArray(),
944985
beforeSend: function() {
945-
if ($that.prop("disabled")) {
986+
if ($form.prop("disabled")) {
946987
return;
947988
}
948-
$that.find("[type=submit]").prop("disabled", true).addClass("disabled");
989+
csk.ui.toggleDisabled($form.find("[type=submit]"), true);
949990
},
950991
complete: function() {
951-
$that.trigger("reset");
952-
$that.find("[type=submit]").prop("disabled", false).removeClass("disabled");
992+
$form.trigger("reset");
993+
csk.ui.toggleDisabled($form.find("[type=submit]"), false);
953994
setTimeout(location.reload.bind(location), 1500);
954995
}
955996
});
@@ -1017,13 +1058,13 @@
10171058
}
10181059

10191060
/** We disable the element before proceeding. */
1020-
$that.prop("disabled", true).addClass("disabled");
1061+
csk.ui.toggleDisabled($that[0], true);
10211062
},
10221063
success: function(data, textStatus, jqXHR) {
10231064
/** let _response handle response/ */
10241065
csk.ajax._response(data);
10251066
/** remove disabled property and reload page. */
1026-
$that.removeProp("disabled").removeClass("disabled");
1067+
csk.ui.toggleDisabled($that[0], false);
10271068
setTimeout(location.reload.bind(location), 1500);
10281069
}
10291070
});

0 commit comments

Comments
 (0)