Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
face
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
face
Commits
04f2d6f8
Commit
04f2d6f8
authored
Jun 05, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
it's working
parent
4ca7ca1b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
17 deletions
+125
-17
DOM.js
examples/examples-browser/public/js/DOM.js
+117
-17
colors.js
examples/examples-browser/public/js/colors.js
+8
-0
tryon.html
examples/examples-browser/views/tryon.html
+0
-0
tryonold.html
examples/examples-browser/views/tryonold.html
+0
-0
No files found.
examples/examples-browser/public/js/DOM.js
View file @
04f2d6f8
...
@@ -16,6 +16,8 @@ NS.apply = function(a,b) {
...
@@ -16,6 +16,8 @@ NS.apply = function(a,b) {
};
};
(
function
(
NS
,
glob
,
document
){
(
function
(
NS
,
glob
,
document
){
var
ArraySlice
=
[].
slice
;
var
svgNS
=
'http://www.w3.org/2000/svg'
;
var
svgNS
=
'http://www.w3.org/2000/svg'
;
var
setters
=
{
var
setters
=
{
...
@@ -54,10 +56,10 @@ NS.apply = function(a,b) {
...
@@ -54,10 +56,10 @@ NS.apply = function(a,b) {
if
(
typeOfType
===
'function'
){
if
(
typeOfType
===
'function'
){
// factory passed
// factory passed
return
type
(
cfg
,
[].
s
lice
.
call
(
arguments
,
2
));
return
type
(
cfg
,
ArrayS
lice
.
call
(
arguments
,
2
));
}
else
if
(
typeof
type
===
'object'
&&
type
.
hook
){
}
else
if
(
typeof
type
===
'object'
&&
type
.
hook
){
// hooked future element creation
// hooked future element creation
return
type
.
hook
(
cfg
,
[].
s
lice
.
call
(
arguments
,
2
));
return
type
.
hook
(
cfg
,
ArrayS
lice
.
call
(
arguments
,
2
));
}
}
...
@@ -166,7 +168,7 @@ NS.apply = function(a,b) {
...
@@ -166,7 +168,7 @@ NS.apply = function(a,b) {
};
};
'div,template,span,input,label,canvas,span,textarea,table,tr,td,th,tBody,tHead'
.
split
(
','
).
forEach
(
function
(
name
){
'div,template,span,input,label,canvas,span,textarea,table,tr,td,th,tBody,tHead'
.
split
(
','
).
forEach
(
function
(
name
){
D
[
name
]
=
function
(){
D
[
name
]
=
function
(){
return
domEl
.
apply
(
null
,
[
name
].
concat
(
[].
s
lice
.
call
(
arguments
)))
return
domEl
.
apply
(
null
,
[
name
].
concat
(
ArrayS
lice
.
call
(
arguments
)))
};
};
}
);
}
);
...
@@ -188,13 +190,13 @@ NS.apply = function(a,b) {
...
@@ -188,13 +190,13 @@ NS.apply = function(a,b) {
cfg
=
{};
cfg
=
{};
}
}
cfg
.
el
=
createElementSVG
(
name
);
cfg
.
el
=
createElementSVG
(
name
);
return
domEl
.
apply
(
null
,
[
null
].
concat
(
[].
s
lice
.
call
(
arguments
)))
return
domEl
.
apply
(
null
,
[
null
].
concat
(
ArrayS
lice
.
call
(
arguments
)))
};
};
}
);
}
);
D
.
html
=
function
(
cfg
){
D
.
html
=
function
(
cfg
){
var
el
=
domEl
(
'div'
,
cfg
);
var
el
=
domEl
(
'div'
,
cfg
);
el
.
innerHTML
=
[].
s
lice
.
call
(
arguments
,
1
).
join
(
'
\
n'
);
el
.
innerHTML
=
ArrayS
lice
.
call
(
arguments
,
1
).
join
(
'
\
n'
);
return
el
;
return
el
;
};
};
D
.
h
=
domEl
;
D
.
h
=
domEl
;
...
@@ -224,25 +226,53 @@ NS.apply = function(a,b) {
...
@@ -224,25 +226,53 @@ NS.apply = function(a,b) {
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
subEl
,
'beforeRemoveFromDOM'
);
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
subEl
,
'beforeRemoveFromDOM'
);
el
.
removeChild
(
subEl
);
el
.
removeChild
(
subEl
);
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
subEl
,
'afterRemoveFromDOM'
);
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
subEl
,
'afterRemoveFromDOM'
);
}
}
};
};
var
DFragment
=
DocumentFragment
;
var
DFragment
=
DocumentFragment
;
D
.
insertBefore
=
function
(
newChild
,
refChild
)
{
var
f
=
document
.
createDocumentFragment
();
D
.
appendChild
(
f
,
newChild
);
var
el
=
refChild
.
parentNode
,
subEl
=
newChild
;
var
isInDOM
=
D
.
isInDOM
(
el
);
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
f
,
'beforeAddToDOM'
);
el
.
insertBefore
(
f
,
refChild
);
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
{
childNodes
:
newChild
},
'afterAddToDOM'
);
};
D
.
appendChild
=
function
(
el
,
subEl
){
D
.
appendChild
=
function
(
el
,
subEl
){
var
type
=
typeof
subEl
;
var
type
=
typeof
subEl
;
if
(
subEl
===
null
){
if
(
subEl
===
null
){
return
;
return
;
}
}
if
(
type
!==
'object'
){
var
notObject
=
type
!==
'object'
;
var
isHook
=
!
notObject
&&
(
'hook'
in
subEl
);
if
(
isHook
){
type
=
'function'
;
notObject
=
true
;
}
if
(
notObject
){
// TODO : add hook
// TODO : add hook
if
(
type
===
'function'
){
if
(
type
===
'function'
){
var
tmp
=
D
.
Text
(
''
);
//( {cls: 'zero-wrapper'} );
var
tmp
=
D
.
Text
(
''
);
//( {cls: 'zero-wrapper'} );
el
.
appendChild
(
tmp
);
el
.
appendChild
(
tmp
);
var
list
=
[];
var
list
=
[];
subEl
(
function
(){
el
.
setAttribute
(
'data-hooked'
,
'yep'
);
// maybe do it through outer weak map?
el
.
__un
=
el
.
__un
||
[];
var
hookFn
;
if
(
isHook
){
hookFn
=
function
(
val
){
// TODO: append 2 TextNodes and remove children between them
// TODO: append 2 TextNodes and remove children between them
if
(
list
.
length
===
1
){
list
[
0
].
textContent
=
val
;
}
else
{
if
(
el
instanceof
DFragment
){
if
(
el
instanceof
DFragment
){
el
=
tmp
.
parentNode
;
el
=
tmp
.
parentNode
;
}
}
...
@@ -253,13 +283,41 @@ NS.apply = function(a,b) {
...
@@ -253,13 +283,41 @@ NS.apply = function(a,b) {
list
[
i
].
parentNode
===
el
&&
el
.
removeChild
(
list
[
i
]
);
list
[
i
].
parentNode
===
el
&&
el
.
removeChild
(
list
[
i
]
);
}
}
var
fragment
=
document
.
createDocumentFragment
();
var
fragment
=
document
.
createDocumentFragment
();
D
.
appendChild
(
fragment
,
[].
slice
.
call
(
arguments
)
);
D
.
appendChild
(
fragment
,
ArraySlice
.
call
(
arguments
)
);
list
=
[].
slice
.
call
(
fragment
.
childNodes
);
list
=
ArraySlice
.
call
(
fragment
.
childNodes
);
if
(
!
tmp
||
!
tmp
.
parentNode
)
return
;
el
.
insertBefore
(
fragment
,
tmp
);
}
};
el
.
__un
.
push
(
subEl
.
hook
(
hookFn
));
}
else
{
hookFn
=
function
(){
// TODO: append 2 TextNodes and remove children between them
if
(
el
instanceof
DFragment
){
el
=
tmp
.
parentNode
;
}
if
(
!
el
)
return
;
for
(
var
i
=
0
,
_i
=
list
.
length
;
i
<
_i
;
i
++
){
list
[
i
].
parentNode
===
el
&&
el
.
removeChild
(
list
[
i
]
);
}
var
fragment
=
document
.
createDocumentFragment
();
D
.
appendChild
(
fragment
,
ArraySlice
.
call
(
arguments
)
);
list
=
ArraySlice
.
call
(
fragment
.
childNodes
);
if
(
!
tmp
||
!
tmp
.
parentNode
)
if
(
!
tmp
||
!
tmp
.
parentNode
)
return
;
return
;
el
.
insertBefore
(
fragment
,
tmp
);
el
.
insertBefore
(
fragment
,
tmp
);
}
)
};
el
.
__un
.
push
(
subEl
(
hookFn
));
}
}
else
if
(
subEl
!==
void
0
&&
subEl
!==
false
&&
subEl
!==
null
){
}
else
if
(
subEl
!==
void
0
&&
subEl
!==
false
&&
subEl
!==
null
){
el
.
appendChild
(
D
.
Text
(
subEl
)
);
el
.
appendChild
(
D
.
Text
(
subEl
)
);
}
}
...
@@ -267,7 +325,8 @@ NS.apply = function(a,b) {
...
@@ -267,7 +325,8 @@ NS.apply = function(a,b) {
var
isInDOM
=
D
.
isInDOM
(
el
);
var
isInDOM
=
D
.
isInDOM
(
el
);
subEl
.
dom
.
__cmp
=
subEl
;
subEl
.
dom
.
__cmp
=
subEl
;
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
subEl
.
dom
,
'beforeAddToDOM'
);
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
subEl
.
dom
,
'beforeAddToDOM'
);
el
.
appendChild
(
subEl
.
dom
);
D
.
appendChild
(
el
,
subEl
.
dom
);
//el.appendChild( subEl.dom );
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
subEl
.
dom
,
'afterAddToDOM'
);
isInDOM
&&
D
.
_recursiveCmpCall
(
el
,
subEl
.
dom
,
'afterAddToDOM'
);
//subEl
//subEl
...
@@ -446,7 +505,7 @@ NS.apply = function(a,b) {
...
@@ -446,7 +505,7 @@ NS.apply = function(a,b) {
}
}
};
};
var
log
=
function
(
evt
)
{
var
log
=
function
(
evt
)
{
_log
.
push
({
type
:
'log'
,
evt
:
evt
,
args
:
[].
s
lice
.
call
(
arguments
,
1
)});
_log
.
push
({
type
:
'log'
,
evt
:
evt
,
args
:
ArrayS
lice
.
call
(
arguments
,
1
)});
if
(
!
later
)
if
(
!
later
)
later
=
setTimeout
(
realLog
,
3000
);
later
=
setTimeout
(
realLog
,
3000
);
...
@@ -454,7 +513,8 @@ NS.apply = function(a,b) {
...
@@ -454,7 +513,8 @@ NS.apply = function(a,b) {
var
emptyFn
=
function
()
{};
var
emptyFn
=
function
()
{};
D
.
Unsubscribe
=
function
(
fn
)
{
D
.
Unsubscribe
=
function
(
fn
)
{
this
.
fn
=
[
fn
];
this
.
fn
=
[];
fn
&&
this
.
fn
.
push
(
fn
);
};
};
D
.
Unsubscribe
.
prototype
=
{
D
.
Unsubscribe
.
prototype
=
{
un
:
function
()
{
un
:
function
()
{
...
@@ -474,12 +534,13 @@ NS.apply = function(a,b) {
...
@@ -474,12 +534,13 @@ NS.apply = function(a,b) {
}
}
}
}
};
};
var
unsubscribable
=
function
(
name
)
{
var
unsubscribable
=
function
(
name
)
{
return
function
(
el
,
fn
)
{
return
function
(
el
,
fn
,
arg
)
{
typeof
fn
!==
'function'
&&
(
fn
=
getCallableFunction
(
fn
));
typeof
fn
!==
'function'
&&
(
fn
=
getCallableFunction
(
fn
));
el
.
addEventListener
(
name
,
fn
);
el
.
addEventListener
(
name
,
fn
,
arg
);
return
new
D
.
Unsubscribe
(
function
()
{
return
new
D
.
Unsubscribe
(
function
()
{
el
.
removeEventListener
(
name
,
fn
);
el
.
removeEventListener
(
name
,
fn
,
arg
);
});
});
};
};
};
};
...
@@ -490,7 +551,46 @@ NS.apply = function(a,b) {
...
@@ -490,7 +551,46 @@ NS.apply = function(a,b) {
over
:
unsubscribable
(
'mouseover'
),
over
:
unsubscribable
(
'mouseover'
),
};
};
D
.
AnimationFrame
=
function
(
fn
)
{
var
requested
=
false
,
arg
,
update
=
function
()
{
fn
.
call
(
null
,
arg
);
requested
=
false
;
};
return
function
(
a
)
{
arg
=
a
;
if
(
!
requested
){
requestAnimationFrame
(
update
);
requested
=
true
;
}
};
};
D
.
overlay
=
{
inited
:
false
,
show
:
function
()
{
this
.
init
();
this
.
el
.
style
.
display
=
'block'
;
},
hide
:
function
()
{
this
.
init
();
this
.
el
.
style
.
display
=
'none'
;
},
init
:
function
()
{
if
(
this
.
inited
)
return
;
this
.
inited
=
true
;
this
.
el
=
D
.
div
({
renderTo
:
document
.
body
,
cls
:
'D-overlay'
,
style
:
{
display
:
'none'
,
position
:
'absolute'
,
zIndex
:
10000
,
left
:
0
,
right
:
0
,
top
:
0
,
bottom
:
0
}})
this
.
el
.
addEventListener
(
'mousemove'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
},
true
)
}
};
})(
window
[
'NS'
],
typeof
window
!==
"undefined"
?
window
:
})(
window
[
'NS'
],
typeof
window
!==
"undefined"
?
window
:
typeof
WorkerGlobalScope
!==
"undefined"
?
self
:
typeof
WorkerGlobalScope
!==
"undefined"
?
self
:
typeof
global
!==
"undefined"
?
global
:
typeof
global
!==
"undefined"
?
global
:
...
...
examples/examples-browser/public/js/colors.js
View file @
04f2d6f8
...
@@ -315,3 +315,10 @@ function rgbToHsl(r, g, b) {
...
@@ -315,3 +315,10 @@ function rgbToHsl(r, g, b) {
return
[
h
,
s
,
l
];
return
[
h
,
s
,
l
];
}
}
function
HEX2RGB
(
hex
){
var
color
=
(
hex
+
''
).
substr
(
1
)
||
''
,
r
=
parseInt
(
color
[
0
]
+
color
[
1
],
16
),
g
=
parseInt
(
color
[
2
]
+
color
[
3
],
16
),
b
=
parseInt
(
color
[
4
]
+
color
[
4
],
16
);
return
[
r
,
g
,
b
];
}
\ No newline at end of file
examples/examples-browser/views/tryon.html
View file @
04f2d6f8
This diff is collapsed.
Click to expand it.
examples/examples-browser/views/tryonold.html
0 → 100644
View file @
04f2d6f8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment