Skip to content

Commit 7c619df

Browse files
committed
- fix bug: root or container params with NodeList value are not
treated as array, which should. - support `zmgr` directly in object. - use zmgr fallback instead of old zstack to simplify code logic - rename `ldloader` zmgr api ( from `set-zmgr` to `zmgr` ) - rename `ldld.js`, `ldld.css` to `index.js`, `index.css`, including minimized version. - bump version
1 parent 8d8c714 commit 7c619df

File tree

17 files changed

+108
-72
lines changed

17 files changed

+108
-72
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change Log
22

3+
## v2.0.0
4+
5+
- fix bug: `root` or `container` params with `NodeList` value are not treated as array, which should.
6+
- support `zmgr` directly in object.
7+
- use zmgr fallback instead of old zstack to simplify code logic
8+
- rename `ldloader` zmgr api ( from `set-zmgr` to `zmgr` )
9+
- rename `ldld.js`, `ldld.css` to `index.js`, `index.css`, including minimized version.
10+
11+
312
## v1.2.1
413

514
- deprecate `ldLoader`. use `ldloader` instead.

build

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env bash
22
rm -rf dist
33
mkdir -p dist
4-
echo "build src/ldld.ls -> dist/ldld.js ..."
5-
./node_modules/.bin/lsc -cp --no-header src/ldld.ls > dist/ldld.js
6-
echo "build src/ldld.styl -> dist/ldld.css ..."
7-
./node_modules/.bin/stylus -p src/ldld.styl > dist/ldld.css
8-
echo "minifying ldld.js ..."
9-
./node_modules/.bin/uglifyjs dist/ldld.js > dist/ldld.min.js
10-
echo "minifying ldld.css ..."
11-
./node_modules/.bin/uglifycss dist/ldld.css > dist/ldld.min.css
4+
echo "build src/ldld.ls -> dist/index.js ..."
5+
./node_modules/.bin/lsc -cp --no-header src/ldld.ls > dist/index.js
6+
echo "build src/ldld.styl -> dist/index.css ..."
7+
./node_modules/.bin/stylus -p src/ldld.styl > dist/index.css
8+
echo "minifying index.js ..."
9+
./node_modules/.bin/uglifyjs dist/index.js > dist/index.min.js
10+
echo "minifying index.css ..."
11+
./node_modules/.bin/uglifycss dist/index.css > dist/index.min.css
1212
echo "done."
1313
echo "Copy dist/ to web/ ..."
1414
rm -rf web/static/assets/lib/ldloader/dev/
File renamed without changes.

web/static/assets/lib/ldloader/dev/ldld.js renamed to dist/index.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,11 @@
169169
zmgr = this$._zmgr || ldloader._zmgr;
170170
if (running) {
171171
this$.z = zmgr.add(this$.opt.baseZ);
172-
/*
173-
if zmgr => @z = zmgr.add @opt.base-z
174-
else
175-
@z = (ldloader.zstack[* - 1] or @opt.base-z) + 1
176-
ldloader.zstack.push z
177-
*/
178172
this$.root.map(function(it){
179173
return it.style.zIndex = this$.z;
180174
});
181175
} else {
182176
zmgr.remove(this$.z);
183-
/*
184-
if zmgr => zmgr.remove @z
185-
else
186-
if (idx = ldloader.zstack.indexOf(@z)) < 0 => return res!
187-
ldloader.zstack.splice(idx, 1)
188-
*/
189177
this$.root.map(function(it){
190178
return it.style.zIndex = "";
191179
});
@@ -194,11 +182,6 @@
194182
});
195183
}
196184
});
197-
/*
198-
ldloader <<< do
199-
zstack: []
200-
zmgr: -> if it? => @_zmgr = it else @_zmgr
201-
*/
202185
import$(ldloader, {
203186
_zmgr: {
204187
add: function(v){
File renamed without changes.

web/static/assets/lib/ldloader/dev/ldld.min.js renamed to dist/index.min.js

File renamed without changes.

dist/ldld.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

package-lock.json

Lines changed: 21 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "ldloader",
44
"license": "MIT",
55
"description": "loader manipulation library",
6-
"version": "1.2.1",
6+
"version": "2.0.0",
77
"files": [
88
"dist/**/*"
99
],
@@ -20,6 +20,7 @@
2020
"start": "npx server -r web -o true"
2121
},
2222
"devDependencies": {
23+
"@loadingio/debounce.js": "^0.0.1",
2324
"@loadingio/ldquery": "^2.1.0",
2425
"@loadingio/loading.css": "^2.0.1",
2526
"bootstrap": "^4.5.3",
@@ -31,17 +32,20 @@
3132
"stylus": "^0.54.5",
3233
"template": "github:zbryikt/template#v2.3.13",
3334
"uglify-js": "=3.2.0",
34-
"uglifycss": "0.0.29"
35+
"uglifycss": "0.0.29",
36+
"zmgr": "^1.0.0"
3537
},
3638
"frontendDependencies": {
3739
"root": "web/static/assets/lib",
3840
"modules": [
3941
"@loadingio/ldquery",
4042
"@loadingio/loading.css",
43+
"@loadingio/debounce.js",
4144
"ldbutton",
4245
"ldcover",
4346
"bootstrap",
44-
"bootstrap.ldui"
47+
"bootstrap.ldui",
48+
"zmgr"
4549
]
4650
}
4751
}

src/ldld.ls

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
ldloader = (opt={}) ->
22
@opt = {active-class: \running, base-z: 4000, auto-z: false, class-name: '', atomic: true} <<< opt
3+
if opt.zmgr => @zmgr opt.zmgr
34
<[root container]>.map (n) ~> if opt[n] =>
4-
@[n] = (if Array.isArray(opt[n]) => opt[n] else [opt[n]]).map ->
5+
list = if Array.isArray(opt[n]) => opt[n]
6+
else if opt[n] instanceof NodeList => Array.from(opt[n])
7+
else [opt[n]]
8+
@[n] = list.map ->
59
ret = if typeof(it) == \string => document.querySelector(it) else it
610
if !ret => console.warn "[ldloader] warning: no node found for #it"
711
ret
812
if !@container => @container = if @root => @root.map(-> it.parentNode) else [document.body]
913
if !@root => @root = @container.map ->
10-
node = document.createElement("div")
11-
it.appendChild node
12-
return node
14+
node = document.createElement("div")
15+
it.appendChild node
16+
return node
1317
@root.map ~>
1418
it.classList.add.apply it.classList, (@opt.class-name or '').split(' ').filter(->it)
1519
it.classList.remove opt.active-class
@@ -18,6 +22,7 @@ ldloader = (opt={}) ->
1822
@
1923

2024
ldloader.prototype = Object.create(Object.prototype) <<< do
25+
zmgr: -> if it? => @_zmgr = it else @_zmgr
2126
is-on: -> return @running
2227
on: (delay=0) -> @toggle true, delay
2328
off: (delay=0, force = false) -> @toggle false, delay, force
@@ -55,23 +60,21 @@ ldloader.prototype = Object.create(Object.prototype) <<< do
5560
@running = running = @root.0.classList.contains(@opt.active-class)
5661
if @opt.ctrl => @render!
5762
if !@opt.auto-z => return res!
63+
zmgr = @_zmgr or ldloader._zmgr
5864
if running =>
59-
if ldloader.zmgr => @z = ldloader.zmgr.add @opt.base-z
60-
else
61-
@z = (ldloader.zstack[* - 1] or @opt.base-z) + 1
62-
ldloader.zstack.push z
65+
@z = zmgr.add @opt.base-z
6366
@root.map ~> it.style.zIndex = @z
6467
else
65-
if ldloader.zmgr => ldloader.zmgr.remove @z
66-
else
67-
if (idx = ldloader.zstack.indexOf(@z)) < 0 => return res!
68-
ldloader.zstack.splice(idx, 1)
68+
zmgr.remove @z
6969
@root.map ~> it.style.zIndex = ""
7070
res!
7171

7272
ldloader <<< do
73-
zstack: []
74-
set-zmgr: -> @zmgr = it
73+
_zmgr: do
74+
add: (v) -> @[]s.push(z = Math.max(v or 0, (@s[* - 1] or 0) + 1)); return z
75+
remove: (v) -> if (i = @[]s.indexOf(v)) < 0 => return else @s.splice(i,1)
76+
zmgr: -> if it? => @_zmgr = it else @_zmgr
77+
7578

7679
if module? => module.exports = ldloader
7780
else window.ldloader = window.ldLoader = ldloader

0 commit comments

Comments
 (0)