Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lukas Niegsch
erp5
Commits
6f4e3905
Commit
6f4e3905
authored
Dec 17, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Add domsugar lib
parent
407522f3
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
470 additions
and
0 deletions
+470
-0
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_domsugar_js.js
...js_ui/PathTemplateItem/web_page_module/rjs_domsugar_js.js
+140
-0
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_domsugar_js.xml
...s_ui/PathTemplateItem/web_page_module/rjs_domsugar_js.xml
+330
-0
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_domsugar_js.js
0 → 100644
View file @
6f4e3905
// DOM sugar
// ==================================================================
// Modified version of "Sugared DOM" https://gist.github.com/jacobrask/3524145
//
// Usage
// ------------------------------------------------------------------
// var make = domsugar(document);
//
// make( 'p.foo#bar', { hidden: true }, [ make( 'span' ) ] );
// => <p class="foo" id="bar" hidden><span></span></p>
//
// make( '.bar', [ '<b></b>' ] );
// make( '.bar', { text: '<b></b>' } );
// => <div class="bar"><b></b></div>
//
// make( 'div', [ make( 'b', [ 'Foo', make( 'i' ) ] ) ] );
// make( 'div', { html: '<b>Foo<i></i></b>' } );
// => <div><b>Foo<i></i></b></div>
//
// var myDiv = document.createElement( 'div' );
// make( myDiv, { id: 'foo' } );
// => <div id="foo"></div>
(
function
(
window
,
document
)
{
'
use strict
'
;
// Some properties need to be direct, other are common ones and setting
// them directly is faster than setAttribute.
var
direct_property_dict
=
{
'
class
'
:
'
className
'
,
className
:
'
className
'
,
defaultValue
:
'
defaultValue
'
,
'
for
'
:
'
htmlFor
'
,
html
:
'
innerHTML
'
,
id
:
'
id
'
,
name
:
'
name
'
,
src
:
'
src
'
,
text
:
'
textContent
'
,
title
:
'
title
'
,
value
:
'
value
'
},
// Object lookup is faster than indexOf.
boolean_property_dict
=
{
checked
:
1
,
defaultChecked
:
1
,
disabled
:
1
,
hidden
:
1
,
multiple
:
1
,
selected
:
1
,
required
:
1
,
readonly
:
1
,
autofocus
:
1
,
spellcheck
:
1
};
// splitter = /(#|\.)/;
function
setProperty
(
el
,
key
,
value
)
{
var
prop
=
direct_property_dict
[
key
];
if
(
prop
)
{
el
[
prop
]
=
(
value
===
null
?
''
:
String
(
value
));
}
else
if
(
boolean_property_dict
[
key
])
{
el
[
key
]
=
!!
value
;
}
else
if
(
value
===
null
)
{
el
.
removeAttribute
(
key
);
}
else
{
el
.
setAttribute
(
key
,
String
(
value
));
}
}
function
appendChildren
(
el
,
children
)
{
var
i
,
l
,
node
;
for
(
i
=
0
,
l
=
children
.
length
;
i
<
l
;
i
+=
1
)
{
node
=
children
[
i
];
if
(
node
)
{
if
(
node
instanceof
Array
)
{
appendChildren
(
el
,
node
);
}
else
{
if
(
typeof
node
===
'
string
'
)
{
node
=
document
.
createTextNode
(
node
);
}
el
.
appendChild
(
node
);
}
}
}
}
window
.
domsugar
=
function
(
tag
,
props
,
children
)
{
if
(
props
instanceof
Array
)
{
children
=
props
;
props
=
null
;
}
var
el
,
prop
;
/*
if ( !tag ) { tag = 'div'; createDocumentFragment }
var parts, name, el,
i, j, l, node, prop;
if ( typeof tag === 'string' && splitter.test( tag ) ) {
parts = tag.split( splitter );
tag = parts[0];
if ( !props ) { props = {}; }
for ( i = 1, j = 2, l = parts.length; j < l; i += 2, j += 2 ) {
name = parts[j];
if ( parts[i] === '#' ) {
props.id = name;
} else {
props.className = props.className ?
props.className + ' ' + name : name;
}
}
}
el = typeof tag === 'string' ? doc.createElement( tag ) : tag;
*/
if
(
typeof
tag
===
'
string
'
)
{
el
=
document
.
createElement
(
tag
);
}
else
if
(
tag
)
{
el
=
tag
;
// Empty the element
while
(
el
.
firstChild
)
{
el
.
firstChild
.
remove
();
}
}
else
{
el
=
document
.
createDocumentFragment
();
}
if
(
props
)
{
for
(
prop
in
props
)
{
if
(
props
.
hasOwnProperty
(
prop
)
&&
(
props
[
prop
]
!==
undefined
))
{
setProperty
(
el
,
prop
,
props
[
prop
]);
}
}
}
if
(
children
)
{
appendChildren
(
el
,
children
);
}
return
el
;
};
/*global document, window*/
}(
window
,
document
));
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_domsugar_js.xml
0 → 100644
View file @
6f4e3905
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