Skip to content

Commit 51fd478

Browse files
committed
Merge branch 'narcolepticsnowman-master' into master
2 parents 398773e + bd82b94 commit 51fd478

File tree

4 files changed

+65
-88
lines changed

4 files changed

+65
-88
lines changed

frameworks/keyed/fntags/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ const minify = ( file ) => {
1414
return code
1515
}
1616
}
17-
17+
fs.copySync('src/fntags.min.js', 'dist/fntags.min.js')
1818
fs.writeFileSync( 'dist/Main.js', minify( 'src/Main.js' ) )

frameworks/keyed/fntags/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"author": "Robert Kempton",
1515
"dependencies": {
16-
"fntags": "0.3.2"
16+
"fntags": "0.3.5"
1717
},
1818
"devDependencies": {
1919
"fs-extra": "8.1.0",
Lines changed: 62 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fnapp, fnstate, h } from 'https://cdn.jsdelivr.net/npm/[email protected]/src/fntags.min.js'
1+
import { fnstate, h } from './fntags.min.js'
22

33
let data = fnstate( [], d => d.id )
44

@@ -29,94 +29,70 @@ const Button = ( id, title, onclick ) =>
2929
h( 'button', { id, type: 'button', class: 'btn btn-primary btn-block', onclick: onclick }, title )
3030
)
3131

32-
const row = ( item ) => {
33-
const id = h( 'td', {
32+
document.body.append(
33+
h( 'div', { class: 'container' },
34+
h( 'div', { class: 'jumbotron' },
35+
h( 'div', { class: 'row' },
36+
h( 'div', { class: 'col-md-6' },
37+
h( 'h1', 'fntags keyed' )
38+
),
39+
h( 'div', { class: 'col-md-6' },
40+
h( 'div', { class: 'row' },
41+
Button( 'run', 'Create 1,000 rows', () => data( buildData( 1000 ) ) ),
42+
Button( 'runlots', 'Create 10,000 rows', () => data( buildData( 10000 ) ) ),
43+
Button( 'add', 'Append 1,000 rows', () => data( data().concat( buildData( 1000 ) ) ) ),
44+
Button( 'update', 'Update every 10th row', () => {
45+
let items = data()
46+
for( let i = 0; i < items.length; i += 10 ) {
47+
let d = items[ i ]
48+
let it = d()
49+
it.label += ' !!!'
50+
d( it )
51+
}
52+
} ),
53+
Button( 'clear', 'Clear', () => data( [] ) ),
54+
Button( 'swaprows', 'Swap Rows', () => {
55+
const d = data()
56+
if( d.length > 998 ) {
57+
const a = d[ 1 ]
58+
d[ 1 ] = d[ 998 ]
59+
d[ 998 ] = a
60+
}
61+
data( d )
62+
} )
63+
)
64+
)
65+
)
66+
),
67+
h( 'table', { class: 'table table-hover table-striped test-data' },
68+
data.bindValues( h( 'tbody' ), ( item ) =>
69+
h( 'tr', {
70+
id: item().id,
71+
onclick: () => data.select( item().id ),
72+
onselect: ( e ) => e.target.className = 'danger',
73+
ondeselect: ( e ) => e.target.className = ''
74+
},
75+
h( 'td', {
3476
class: 'col-md-1'
3577
},
3678
item().id
37-
)
38-
let currentLabel = item().label
39-
let label = h( 'a', item().label )
40-
let removeBtn = h( 'span', {
41-
onclick: ( e ) => {
42-
e.preventDefault()
43-
e.stopPropagation()
44-
data( data().filter( d => d().id !== item().id ) )
45-
},
46-
class: 'glyphicon glyphicon-remove', 'aria-hidden': 'true'
47-
} )
48-
49-
let isSelected = item().selected
50-
const tr = h( 'tr', {
51-
id: item().id,
52-
class: isSelected ? 'danger' : '',
53-
onclick: () => {
54-
let currentSelection = data().find( d => d().selected )
55-
if( currentSelection ) currentSelection.patch( { selected: false } )
56-
item.patch( { selected: true } )
57-
}
58-
},
59-
id,
60-
h( 'td', { class: 'col-md-4' }, label ),
61-
h( 'td', { class: 'col-md-1' },
62-
h( 'a',
63-
removeBtn
64-
)
65-
),
66-
h( 'td', { class: 'col-md-6' } )
67-
)
68-
69-
item.subscribe( () => {
70-
if( isSelected && !item().selected ) {
71-
tr.className = ''
72-
} else if( !isSelected && item().selected ) {
73-
tr.className = 'danger'
74-
}
75-
isSelected = item().selected
76-
77-
if( currentLabel != item().label ) {
78-
label.innerText = item().label
79-
currentLabel = item().label
80-
}
81-
} )
82-
83-
return tr
84-
}
85-
86-
fnapp( document.body,
87-
h( 'div', { class: 'container' },
88-
h( 'div', { class: 'jumbotron' },
89-
h( 'div', { class: 'row' },
90-
h( 'div', { class: 'col-md-6' },
91-
h( 'h1', 'fntags keyed' )
9279
),
93-
h( 'div', { class: 'col-md-6' },
94-
h( 'div', { class: 'row' },
95-
Button( 'run', 'Create 1,000 rows', () => data( buildData( 1000 ) ) ),
96-
Button( 'runlots', 'Create 10,000 rows', () => data( buildData( 10000 ) ) ),
97-
Button( 'add', 'Append 1,000 rows', () => data( data().concat( buildData( 1000 ) ) ) ),
98-
Button( 'update', 'Update every 10th row', () => {
99-
for( let i = 0; i < data().length; i += 10 ) {
100-
data()[ i ].patch( { label: data()[ i ]().label + ' !!!' } )
101-
}
102-
} ),
103-
Button( 'clear', 'Clear', () => data( [] ) ),
104-
Button( 'swaprows', 'Swap Rows', () => {
105-
const d = data()
106-
if( d.length > 998 ) {
107-
const a = d[ 1 ]
108-
d[ 1 ] = d[ 998 ]
109-
d[ 998 ] = a
110-
}
111-
data( d )
80+
h( 'td', { class: 'col-md-4' },
81+
h('a', { class: 'lbl'}, item.bindAs( () => item().label ) )),
82+
h( 'td', { class: 'col-md-1' },
83+
h( 'a',
84+
h( 'span', {
85+
onclick: ( e ) => {
86+
e.stopPropagation()
87+
data( data().filter( d => d().id !== item().id ) )
88+
},
89+
class: 'glyphicon glyphicon-remove', 'aria-hidden': 'true'
11290
} )
113-
)
114-
)
115-
)
116-
)
117-
),
118-
h( 'table', { class: 'table table-hover table-striped test-data' },
119-
data.bindValues( h( 'tbody' ), row )
120-
),
121-
h( 'span', { class: 'preloadicon glyphicon glyphicon-remove', 'aria-hidden': 'true' } )
91+
)
92+
),
93+
h( 'td', { class: 'col-md-6' } )
94+
) )
95+
),
96+
),
97+
h( 'span', { class: 'preloadicon glyphicon glyphicon-remove', 'aria-hidden': 'true' } )
12298
)

frameworks/keyed/fntags/src/fntags.min.js

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

0 commit comments

Comments
 (0)