Skip to content

Commit 6b14b6c

Browse files
committed
Merge branch 'develop'
2 parents 1ac3eb8 + 92c43d8 commit 6b14b6c

39 files changed

Lines changed: 727 additions & 202 deletions

.editorconfig-checker.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"Exclude": [
3+
"utils/natural-sorting/dist"
4+
]
5+
}

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ jobs:
1717
run: |
1818
yarn install
1919
yarn lint
20+
yarn test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
*.xml
66
node_modules
77
yarn.lock
8+
package-lock.json

assets/css/index.css

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,37 @@ iframe {
2727
position: absolute;
2828
bottom: 10px;
2929
left: 10px;
30-
}
31-
32-
.icon-buttons .view-example {
33-
display: none;
30+
display: flex;
31+
flex-direction: column;
32+
gap: 10px;
33+
z-index: 1000;
3434
}
3535

3636
.icon-buttons a {
37-
display: block;
37+
display: flex;
38+
align-items: center;
39+
justify-content: center;
3840
border-radius: 50%;
3941
width: 40px;
4042
height: 40px;
41-
margin-top: 10px;
43+
margin: 0;
4244
padding: 0;
4345
text-align: center;
46+
transition: all 0.2s;
47+
}
48+
49+
.icon-buttons a:hover {
50+
transform: scale(1.1);
51+
}
52+
53+
.icon-buttons a.active {
54+
background: var(--bs-primary);
55+
color: white;
56+
transform: scale(1.1);
4457
}
4558

4659
.icon-buttons i {
47-
font-size: 24px;
60+
font-size: 20px;
4861
line-height: 40px;
62+
margin: 0;
4963
}

assets/css/template.css

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,52 @@ body {
1919

2020
#viewSource,
2121
#viewExample,
22-
.source-pre {
22+
.source-pre,
23+
.data-pre {
2324
display: none;
2425
}
2526

27+
/* Source code view styles - support dark/light themes */
28+
.source-pre {
29+
background: var(--bs-tertiary-bg);
30+
}
31+
32+
.source-pre code {
33+
background: var(--bs-tertiary-bg) !important;
34+
color: var(--bs-body-color) !important;
35+
}
36+
37+
/* Override highlight.js default background in all themes */
38+
.hljs {
39+
background: var(--bs-tertiary-bg) !important;
40+
}
41+
42+
/* Data configuration container styles */
43+
.data-pre {
44+
padding: 1rem;
45+
}
46+
47+
.data-pre h4 {
48+
margin-top: 1.5rem;
49+
margin-bottom: 0.5rem;
50+
font-size: 1rem;
51+
color: var(--bs-body-color);
52+
border-bottom: 1px solid var(--bs-border-color);
53+
padding-bottom: 0.5rem;
54+
}
55+
56+
.data-pre h4:first-child {
57+
margin-top: 0;
58+
}
59+
60+
.data-pre pre {
61+
margin: 0;
62+
padding: 1rem;
63+
background: var(--bs-tertiary-bg);
64+
border-radius: 4px;
65+
overflow-x: auto;
66+
}
67+
2668
.title-desc {
2769
min-height: 162px;
2870
}

assets/js/index.js

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ const { computed, createApp, onMounted, ref } = window.Vue
44
const Utils = {
55
getUrl () {
66
let href = location.hash.substring(1)
7-
let isViewSource = false
7+
let viewType = 'example' // default value
88

9-
if (href.includes('view-source')) {
9+
// Parse view type
10+
if (href.includes('#view-')) {
11+
const parts = href.split('#view-')
12+
13+
viewType = parts[1] || 'example'
14+
href = parts[0].replace('#', '')
15+
} else if (href.includes('view-source')) {
16+
// Backward compatibility for legacy view-source hash
1017
href = href.replace('#view-source', '').replace('view-source', '')
11-
isViewSource = true
18+
viewType = 'html'
1219
}
20+
1321
return {
1422
href: href || 'welcome.html',
15-
isViewSource
23+
viewType: ['example', 'html', 'data'].includes(viewType) ? viewType : 'example'
1624
}
1725
},
1826

19-
loadUrl (theme, href, isViewSource) {
27+
loadUrl (theme, href, viewType) {
2028
let template = 'template'
2129

2230
if (theme) {
@@ -27,9 +35,12 @@ const Utils = {
2735
if (isDebug) {
2836
url = `${template}.html?t=${+new Date()}&url=${href}`
2937
}
30-
if (isViewSource) {
31-
url = `${template}.html?v=VERSION&view-source&url=${href}#view-source`
38+
39+
// Pass view type to iframe
40+
if (viewType !== 'example') {
41+
url += `&view-type=${viewType}#view-${viewType}`
3242
}
43+
3344
$('iframe').attr('src', url)
3445
},
3546

@@ -60,27 +71,32 @@ const Utils = {
6071
}, 100)
6172
},
6273

63-
initViewSource () {
64-
const isSource = /view-source$/.test(location.hash)
65-
66-
if (isSource) {
67-
$('.view-example').css('display', 'block')
68-
$('.view-source').css('display', 'none')
69-
} else {
70-
$('.view-example').css('display', 'none')
71-
$('.view-source').css('display', 'block')
72-
}
73-
74-
$('.view-example, .view-source').off('click').click(function () {
75-
if (isSource) {
76-
location.hash = location.hash.replace('#view-source', '')
77-
} else if (!location.hash.includes('view-source')) {
78-
location.hash += '#view-source'
79-
}
80-
})
74+
initViewToggle () {
75+
const { href, viewType } = Utils.getUrl()
76+
77+
// Update button states
78+
$('.icon-buttons .view-example, .icon-buttons .view-html, .icon-buttons .view-data').removeClass('active')
79+
$(`.view-${viewType}`).addClass('active')
80+
81+
// Bind click events using on() method and prevent default behavior
82+
$('.view-example, .view-html, .view-data')
83+
.off('click.viewToggle')
84+
.on('click.viewToggle', function (e) {
85+
e.preventDefault()
86+
const newType = $(this).hasClass('view-example') ? 'example' :
87+
$(this).hasClass('view-html') ? 'html' : 'data'
88+
const currentHref = location.hash.slice(1).split('#')[0] || 'welcome.html'
89+
90+
// example is the default view, no need to add #view-example
91+
if (newType === 'example') {
92+
location.hash = currentHref
93+
} else {
94+
location.hash = `${currentHref}#view-${newType}`
95+
}
96+
})
8197

82-
$('.view-online').attr('href', `https://live.bootstrap-table.com/example/${
83-
location.hash.slice(1).split('#')[0] || 'welcome.html'}`)
98+
// Update online editor link
99+
$('.view-online').attr('href', `https://live.bootstrap-table.com/example/${href}`)
84100
}
85101
}
86102

@@ -144,13 +160,13 @@ const setup = () => {
144160
})
145161
}
146162
const initData = () => {
147-
const { href, isViewSource } = Utils.getUrl()
163+
const { href, viewType } = Utils.getUrl()
148164

149-
Utils.loadUrl(theme.value, href, isViewSource)
165+
Utils.loadUrl(theme.value, href, viewType)
150166

151167
currentHref.value = `#${href}`
152168

153-
Utils.initViewSource()
169+
Utils.initViewToggle()
154170
}
155171
const initViews = () => {
156172
$('[data-bs-toggle="tooltip"]').tooltip()

0 commit comments

Comments
 (0)