Skip to content

Commit 85833a1

Browse files
committed
- support zmgr for proper z-indexing
- bump version
1 parent 6adc167 commit 85833a1

7 files changed

+59
-10
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Logs
22

3+
## v0.0.9
4+
5+
- support zmgr for proper z-indexing
6+
7+
38
## v0.0.8
49

510
- proper handle invalid input

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Constructor options:
4848
- `iy`: suggested y position if mode is `in-place`.
4949
- by default, mode will be `out-place` with `container` option set.
5050
- Set `mode` to `fixed` if the container is a fixed element (such as dialog)
51+
- `zmgr`: optional. if provided, widget will be auto z-indexing based on this zmgr.
5152

5253

5354
## API

dist/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
this._enabled = {
99
time: !(opt.time != null) || opt.time
1010
};
11+
this._zmgr = opt.zmgr || null;
1112
this._mode = (ref$ = opt.mode) === 'in-place' || ref$ === 'out-place' || ref$ === 'fixed'
1213
? opt.mode
1314
: opt.fixed
@@ -208,7 +209,16 @@
208209
return this.root.classList.contains('active');
209210
},
210211
_toggle: function(v){
211-
return this.root.classList.toggle('active', v);
212+
var setOn;
213+
setOn = v || (!(v != null) && !this.isOn());
214+
if (this._zmgr) {
215+
if (setOn) {
216+
this.root.style.zIndex = this._zmgr.add();
217+
} else {
218+
this._zmgr.remove(this.root.style.zIndex);
219+
}
220+
}
221+
return this.root.classList.toggle('active', setOn);
212222
},
213223
toggle: function(v){
214224
var c, h, n, hb, cb, ref$, x, y, nscroll, nstack, countScroll, s, stackb, scrollb, scroll, rscroll, _cb, vy, vx, iy, ix;

dist/index.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+20-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"name": "lddatetimepicker",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "vanilla date/time picker",
55
"browser": "dist/index.min.js",
66
"main": "dist/index.js",
7-
"files": ["dist/**/*"],
7+
"files": [
8+
"dist/**/*"
9+
],
810
"scripts": {
911
"start": "npx server -r web -o true"
1012
},
@@ -13,7 +15,13 @@
1315
"type": "git",
1416
"url": "https://github.com/loadingio/lddatetimepicker"
1517
},
16-
"keywords": ["date","time","datetime","datepicker","datetimepicker"],
18+
"keywords": [
19+
"date",
20+
"time",
21+
"datetime",
22+
"datepicker",
23+
"datetimepicker"
24+
],
1725
"author": "zbryikt",
1826
"license": "MIT",
1927
"devDependencies": {
@@ -29,7 +37,8 @@
2937
"proxise": "^1.0.1",
3038
"stylus": "^0.57.0",
3139
"uglify-js": "^3.15.3",
32-
"uglifycss": "^0.0.29"
40+
"uglifycss": "^0.0.29",
41+
"zmgr": "^2.2.3"
3342
},
3443
"frontendDependencies": {
3544
"root": "web/static/assets/lib",
@@ -41,6 +50,7 @@
4150
"bootstrap",
4251
"ldcover",
4352
"ldview",
53+
"zmgr",
4454
"proxise"
4555
]
4656
},

src/index.ls

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ html = '''
1919
lddatetimepicker = (opt = {})->
2020
@opt = opt
2121
@_enabled = time: !(opt.time?) or opt.time
22+
@_zmgr = opt.zmgr or null
2223
@_mode = if opt.mode in <[in-place out-place fixed]> => opt.mode
2324
else if opt.fixed => \fixed #legacy
2425
else if opt.container => \out-place
@@ -147,7 +148,12 @@ lddatetimepicker.prototype = Object.create(Object.prototype) <<< do
147148
on: (n, cb) -> (if Array.isArray(n) => n else [n]).map (n) ~> @evthdr.[][n].push cb
148149
fire: (n, ...v) -> for cb in (@evthdr[n] or []) => cb.apply @, v
149150
is-on: -> @root.classList.contains \active
150-
_toggle: (v) -> @root.classList.toggle \active, v
151+
_toggle: (v) ->
152+
set-on = v or (!(v?) and !@is-on!)
153+
if @_zmgr =>
154+
if set-on => @root.style.zIndex = @_zmgr.add!
155+
else @_zmgr.remove @root.style.zIndex
156+
@root.classList.toggle \active, set-on
151157
toggle: (v) ->
152158
if arguments.length == 0 => v = !@is-on!
153159
if !v =>

0 commit comments

Comments
 (0)