Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
exis9 committed Apr 30, 2022
1 parent cd544dd commit 7fe6b56
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 31 deletions.
36 changes: 21 additions & 15 deletions sq.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ if ( typeof _JQ === 'undefined' )
//if (!op.fill) op.fill = 'both'
el.animate( kf, op ).onfinish = ()=>{
if ( cb ) cb.bind( el )()
if ( cb2 ) cb2.bind( el )(), console.log('aaa')
if ( cb2 ) cb2.bind( el )()
}
}
fadeIn( el, ms, cb, d='inline-block' ){
let o = parseFloat(el.style.opacity)
if ( isNaN(o) )
o = 1

this.animate( el, [{'opacity': o}, {'opacity': 1}], {
easing: 'ease-in'
}, ms, ()=>{
Expand All @@ -66,18 +66,20 @@ if ( typeof _JQ === 'undefined' )
}
each(el, f, i){return f.apply(el, [i])}
}

class _SF {
constructor(){
this.b = 0
this.el0 = []
this.el = []
this.disp = []
this.fOb = {}
this.v = undefined
}
_setEl(el){
this.el = []
if ( el ){
this.v = el?.value
let n = el.length
if ( n || el instanceof NodeList )
this.el = Array.from(el)
Expand Down Expand Up @@ -109,7 +111,7 @@ if ( typeof _JQ === 'undefined' )
let d = 'block'
if ( !_jq.isW(el) && el !== document )
d = window.getComputedStyle(el).display

if ( d && d !== 'none' )
this.disp[cnt] = d
}
Expand Down Expand Up @@ -191,7 +193,7 @@ if ( typeof _JQ === 'undefined' )
this.el?.forEach(el => {_jq.animate( el, kf, op, sp, cb, f)})
return this
}

each( f ){
let i = 0
this.el?.every(el => {
Expand All @@ -205,15 +207,15 @@ if ( typeof _JQ === 'undefined' )
if( !this.el || !this.el[0] ) return undefined;
if ( v === undefined )
return this.el[0].getAttribute(a)

this.el.forEach(el => el.setAttribute(a,v))
return this
}
prop(p, v){
if( !this.el || !this.el[0] ) return undefined;
if ( v === undefined )
return this.el[0][p]

this.el.forEach(el => el[p]=v)
return this
}
Expand All @@ -239,7 +241,11 @@ if ( typeof _JQ === 'undefined' )
return this._fv( 'innerHTML', v )
}
text(v=null){return this._fv( 'innerText', v )}
val(v=null){return this._fv( 'value', v )}
val(v=null){
if ( v===null && typeof this.v !== 'undefined' )
return this.v
return this._fv( 'value', v )
}
css(c, v=null){
if( !this.el || !this.el[0] ) return undefined;
if ( c )
Expand Down Expand Up @@ -444,8 +450,8 @@ if ( typeof _JQ === 'undefined' )
}
return this
}


_setAC(ev,f){
let i = _jq.ac.length
_jq.ac[i] = {'ev':ev, 'f':f}
Expand All @@ -469,7 +475,7 @@ if ( typeof _JQ === 'undefined' )
let tg = e.target
while (tg) {
if (tg.matches(s)){
if ( f.bind( e.target/*el.querySelectorAll(s)*/ )(e) === false )
if ( f.bind( /*e.target*/el.querySelectorAll(s) )(e) === false )
{
e.preventDefault()
e.stopImmediatePropagation()
Expand All @@ -487,7 +493,8 @@ if ( typeof _JQ === 'undefined' )
}
on(ev, f){
let u=(e)=>{
if ( f.bind( e.target/*this.el*/ )(e) === false )
//console.log('u: ', e.path, e.target)
if ( f.bind( e.currentTarget/*this.e.target or this.el*/ )(e) === false )
{
e.preventDefault()
e.stopImmediatePropagation()
Expand Down Expand Up @@ -522,7 +529,7 @@ if ( typeof _JQ === 'undefined' )
}
trg(ev){this.el?.forEach(el=>el.dispatchEvent(new Event(ev)));return this}
trigger(ev){this.trg(ev)}

_f( funcName, ...args ){this.el?.forEach(el => {_jq[funcName]( el, ...args )});return this}
remove(){return this._f('remove')}
before( h ){return this._f('before', h)}
Expand All @@ -534,7 +541,7 @@ if ( typeof _JQ === 'undefined' )
hasClass( n ){return this.el[0]?.classList.contains(n)?true:false}
removeClass( n ){return this._f('removeClass', n)}
toggleClass( n ){return this._f('toggleClass', n)}


_fsd( funcName, ...args ){
if( !this.el ) return this
Expand Down Expand Up @@ -572,5 +579,4 @@ if ( typeof _JQ === 'undefined' )
}
}, sQuery = sq, _SQ = _SF.prototype;
}

export {sQuery, sq, _SQ}

0 comments on commit 7fe6b56

Please sign in to comment.