Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
d335173f
Commit
d335173f
authored
Jul 02, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bootstrap markup for auto-generated forms
parent
1540d811
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
70 additions
and
46 deletions
+70
-46
css/converse.css
css/converse.css
+0
-5
dist/converse.js
dist/converse.js
+44
-21
sass/_chatrooms.scss
sass/_chatrooms.scss
+0
-6
src/converse-muc-views.js
src/converse-muc-views.js
+1
-1
src/templates/form_checkbox.html
src/templates/form_checkbox.html
+4
-2
src/templates/form_input.html
src/templates/form_input.html
+5
-5
src/templates/form_select.html
src/templates/form_select.html
+4
-4
src/templates/registration_form.html
src/templates/registration_form.html
+1
-1
src/utils/form.js
src/utils/form.js
+11
-1
No files found.
css/converse.css
View file @
d335173f
...
@@ -8712,11 +8712,6 @@ body.reset {
...
@@ -8712,11 +8712,6 @@ body.reset {
#conversejs
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
.validation-message
{
#conversejs
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
.validation-message
{
font-size
:
90%
;
font-size
:
90%
;
color
:
#A53214
;
}
color
:
#A53214
;
}
#conversejs
.converse-embedded
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
.chatroom-form
label
,
#conversejs
.converse-embedded
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
.chatroom-form
input
[
type
=
text
],
#conversejs
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
.chatroom-form
label
,
#conversejs
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
.chatroom-form
input
[
type
=
text
]
{
display
:
block
;
}
#conversejs
.converse-embedded
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
input
[
type
=
button
],
#conversejs
.converse-embedded
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
input
[
type
=
button
],
#conversejs
.converse-embedded
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
input
[
type
=
submit
],
#conversejs
.converse-embedded
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
input
[
type
=
submit
],
#conversejs
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
input
[
type
=
button
],
#conversejs
.chatroom
.box-flyout
.chatroom-body
.chatroom-form-container
input
[
type
=
button
],
...
...
dist/converse.js
View file @
d335173f
...
@@ -76473,7 +76473,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
...
@@ -76473,7 +76473,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
fieldset_el.insertAdjacentHTML('beforeend', `<legend>${title}</legend>`);
fieldset_el.insertAdjacentHTML('beforeend', `<legend>${title}</legend>`);
if (instructions && instructions !== title) {
if (instructions && instructions !== title) {
fieldset_el.insertAdjacentHTML('beforeend', `<p class="
instructions
">${instructions}</p>`);
fieldset_el.insertAdjacentHTML('beforeend', `<p class="
form-help
">${instructions}</p>`);
}
}
_.each(fields, function (field) {
_.each(fields, function (field) {
...
@@ -85041,18 +85041,23 @@ return __p
...
@@ -85041,18 +85041,23 @@ return __p
var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./node_modules/lodash/escape.js")};
var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./node_modules/lodash/escape.js")};
module.exports = function(o) {
module.exports = function(o) {
var __t, __p = '', __e = _.escape;
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
__p += '<!-- src/templates/form_checkbox.html -->\n<label class="checkbox" for="' +
function print() { __p += __j.call(arguments, '') }
__p += '<!-- src/templates/form_checkbox.html -->\n<div class="form-group">\n <input id="' +
__e(o.id) +
'" name="' +
__e(o.name) +
__e(o.name) +
'" type="checkbox" ' +
__e(o.checked) +
' ';
if (o.required) { ;
__p += ' required ';
} ;
__p += ' >\n <label class="form-check-label" for="' +
__e(o.id) +
'">' +
'">' +
__e(o.label) +
__e(o.label) +
'<input name="' +
'</label>\n</div>\n';
__e(o.name) +
'" type="' +
__e(o.type) +
'" ' +
__e(o.checked) +
'></label>\n\n';
return __p
return __p
};
};
...
@@ -85069,13 +85074,17 @@ var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./no
...
@@ -85069,13 +85074,17 @@ var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./no
module.exports = function(o) {
module.exports = function(o) {
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
function print() { __p += __j.call(arguments, '') }
__p += '<!-- src/templates/form_input.html -->\n<label>\n ' +
__p += '<!-- src/templates/form_input.html -->\n<div class="form-group">\n <label for="' +
__e(o.id) +
'">' +
__e(o.label) +
__e(o.label) +
'
\n <input
name="' +
'
</label>\n <input class="form-control"
name="' +
__e(o.name) +
__e(o.name) +
'" type="' +
'" type="' +
__e(o.type) +
__e(o.type) +
'" \n ';
'" id="' +
__e(o.id) +
'"\n ';
if (o.placeholder) { ;
if (o.placeholder) { ;
__p += ' placeholder="' +
__p += ' placeholder="' +
__e(o.placeholder) +
__e(o.placeholder) +
...
@@ -85089,9 +85098,9 @@ __e(o.value) +
...
@@ -85089,9 +85098,9 @@ __e(o.value) +
} ;
} ;
__p += '\n ';
__p += '\n ';
if (o.required) { ;
if (o.required) { ;
__p += '
class="required"
';
__p += '
required
';
} ;
} ;
__p += ' >\n</
label
>\n';
__p += ' >\n</
div
>\n';
return __p
return __p
};
};
...
@@ -85108,17 +85117,21 @@ var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./no
...
@@ -85108,17 +85117,21 @@ var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./no
module.exports = function(o) {
module.exports = function(o) {
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
function print() { __p += __j.call(arguments, '') }
__p += '<!-- src/templates/form_select.html -->\n<label>\n ' +
__p += '<!-- src/templates/form_select.html -->\n<div class="form-group">\n <label for="' +
__e(o.id) +
'">' +
__e(o.label) +
__e(o.label) +
'\n <select name="' +
'</label>\n <select class="form-control" id="' +
__e(o.id) +
'" name="' +
__e(o.name) +
__e(o.name) +
'"
';
'" ';
if (o.multiple) { ;
if (o.multiple) { ;
__p += ' multiple="multiple" ';
__p += ' multiple="multiple" ';
} ;
} ;
__p += '>' +
__p += '>' +
((__t = (o.options)) == null ? '' : __t) +
((__t = (o.options)) == null ? '' : __t) +
'</select>\n</
label
>\n';
'</select>\n</
div
>\n';
return __p
return __p
};
};
...
@@ -85855,7 +85868,7 @@ __e(o.__("Account Registration:")) +
...
@@ -85855,7 +85868,7 @@ __e(o.__("Account Registration:")) +
__e(o.domain) +
__e(o.domain) +
'</legend>\n<p class="title">' +
'</legend>\n<p class="title">' +
__e(o.title) +
__e(o.title) +
'</p>\n<p class="instructions">' +
'</p>\n<p class="
form-help
instructions">' +
__e(o.instructions) +
__e(o.instructions) +
'</p>\n<div class="form-errors hidden"></div>\n\n<fieldset class="buttons">\n <input type="submit" class="btn btn-primary" value="' +
'</p>\n<div class="form-errors hidden"></div>\n\n<fieldset class="buttons">\n <input type="submit" class="btn btn-primary" value="' +
__e(o.__('Register')) +
__e(o.__('Register')) +
...
@@ -87673,6 +87686,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
...
@@ -87673,6 +87686,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}));
}));
};
};
u.getUniqueId = function () {
return 'xxxxxxxx-xxxx'.replace(/[x]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c === 'x' ? r : r & 0x3 | 0x8;
return v.toString(16);
});
};
u.xForm2webForm = function (field, stanza, domain) {
u.xForm2webForm = function (field, stanza, domain) {
/* Takes a field in XMPP XForm (XEP-004: Data Forms) format
/* Takes a field in XMPP XForm (XEP-004: Data Forms) format
* and turns it into an HTML field.
* and turns it into an HTML field.
...
@@ -87699,6 +87720,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
...
@@ -87699,6 +87720,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
return tpl_form_select({
return tpl_form_select({
'id': u.getUniqueId(),
'name': field.getAttribute('var'),
'name': field.getAttribute('var'),
'label': field.getAttribute('label'),
'label': field.getAttribute('label'),
'options': options.join(''),
'options': options.join(''),
...
@@ -87718,8 +87740,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
...
@@ -87718,8 +87740,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
} else if (field.getAttribute('type') === 'boolean') {
} else if (field.getAttribute('type') === 'boolean') {
return tpl_form_checkbox({
return tpl_form_checkbox({
'id': u.getUniqueId(),
'name': field.getAttribute('var'),
'name': field.getAttribute('var'),
'type': XFORM_TYPE_MAP[field.getAttribute('type')],
'label': field.getAttribute('label') || '',
'label': field.getAttribute('label') || '',
'checked': _.get(field.querySelector('value'), 'textContent') === "1" && 'checked="1"' || '',
'checked': _.get(field.querySelector('value'), 'textContent') === "1" && 'checked="1"' || '',
'required': !_.isNil(field.querySelector('required'))
'required': !_.isNil(field.querySelector('required'))
...
@@ -87740,6 +87762,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
...
@@ -87740,6 +87762,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
});
} else {
} else {
return tpl_form_input({
return tpl_form_input({
'id': u.getUniqueId(),
'label': field.getAttribute('label') || '',
'label': field.getAttribute('label') || '',
'name': field.getAttribute('var'),
'name': field.getAttribute('var'),
'placeholder': null,
'placeholder': null,
sass/_chatrooms.scss
View file @
d335173f
...
@@ -249,12 +249,6 @@
...
@@ -249,12 +249,6 @@
font-size
:
90%
;
font-size
:
90%
;
color
:
$error-color
;
color
:
$error-color
;
}
}
.chatroom-form
{
label
,
input
[
type
=
text
]
{
display
:
block
;
}
}
input
[
type
=
button
],
input
[
type
=
button
],
input
[
type
=
submit
]
{
input
[
type
=
submit
]
{
margin
:
0
0
.5em
;
margin
:
0
0
.5em
;
...
...
src/converse-muc-views.js
View file @
d335173f
...
@@ -1045,7 +1045,7 @@
...
@@ -1045,7 +1045,7 @@
fieldset_el
.
insertAdjacentHTML
(
'
beforeend
'
,
`<legend>
${
title
}
</legend>`
);
fieldset_el
.
insertAdjacentHTML
(
'
beforeend
'
,
`<legend>
${
title
}
</legend>`
);
if
(
instructions
&&
instructions
!==
title
)
{
if
(
instructions
&&
instructions
!==
title
)
{
fieldset_el
.
insertAdjacentHTML
(
'
beforeend
'
,
`<p class="
instructions
">
${
instructions
}
</p>`
);
fieldset_el
.
insertAdjacentHTML
(
'
beforeend
'
,
`<p class="
form-help
">
${
instructions
}
</p>`
);
}
}
_
.
each
(
fields
,
function
(
field
)
{
_
.
each
(
fields
,
function
(
field
)
{
fieldset_el
.
insertAdjacentHTML
(
'
beforeend
'
,
u
.
xForm2webForm
(
field
,
stanza
));
fieldset_el
.
insertAdjacentHTML
(
'
beforeend
'
,
u
.
xForm2webForm
(
field
,
stanza
));
...
...
src/templates/form_checkbox.html
View file @
d335173f
<label
class=
"checkbox"
for=
"{{{o.name}}}"
>
{{{o.label}}}
<input
name=
"{{{o.name}}}"
type=
"{{{o.type}}}"
{{{
o
.
checked
}}}
></label>
<div
class=
"form-group"
>
<input
id=
"{{{o.id}}}"
name=
"{{{o.name}}}"
type=
"checkbox"
{{{
o
.
checked
}}}
{[
if
(
o
.
required
)
{
]}
required
{[
}
]}
>
<label
class=
"form-check-label"
for=
"{{{o.id}}}"
>
{{{o.label}}}
</label>
</div>
src/templates/form_input.html
View file @
d335173f
<
label
>
<
div
class=
"form-group"
>
{{{o.label}}}
<label
for=
"{{{o.id}}}"
>
{{{o.label}}}
</label>
<input
name=
"{{{o.name}}}"
type=
"{{{o.type}}}"
<input
class=
"form-control"
name=
"{{{o.name}}}"
type=
"{{{o.type}}}"
id=
"{{{o.id}}}"
{[
if
(
o
.
placeholder
)
{
]}
placeholder=
"{{{o.placeholder}}}"
{[
}
]}
{[
if
(
o
.
placeholder
)
{
]}
placeholder=
"{{{o.placeholder}}}"
{[
}
]}
{[
if
(
o
.
value
)
{
]}
value=
"{{{o.value}}}"
{[
}
]}
{[
if
(
o
.
value
)
{
]}
value=
"{{{o.value}}}"
{[
}
]}
{[
if
(
o
.
required
)
{
]}
class=
"required"
{[
}
]}
>
{[
if
(
o
.
required
)
{
]}
required
{[
}
]}
>
</
label
>
</
div
>
src/templates/form_select.html
View file @
d335173f
<
label
>
<
div
class=
"form-group"
>
{{{o.label}}}
<label
for=
"{{{o.id}}}"
>
{{{o.label}}}
</label>
<select
name=
"{{{o.name}}}"
{[
if
(
o
.
multiple
)
{
]}
multiple=
"multiple"
{[
}
]}
>
{{o.options}}
</select>
<select
class=
"form-control"
id=
"{{{o.id}}}"
name=
"{{{o.name}}}"
{[
if
(
o
.
multiple
)
{
]}
multiple=
"multiple"
{[
}
]}
>
{{o.options}}
</select>
</
label
>
</
div
>
src/templates/registration_form.html
View file @
d335173f
<legend>
{{{o.__("Account Registration:")}}} {{{o.domain}}}
</legend>
<legend>
{{{o.__("Account Registration:")}}} {{{o.domain}}}
</legend>
<p
class=
"title"
>
{{{o.title}}}
</p>
<p
class=
"title"
>
{{{o.title}}}
</p>
<p
class=
"instructions"
>
{{{o.instructions}}}
</p>
<p
class=
"
form-help
instructions"
>
{{{o.instructions}}}
</p>
<div
class=
"form-errors hidden"
></div>
<div
class=
"form-errors hidden"
></div>
<fieldset
class=
"buttons"
>
<fieldset
class=
"buttons"
>
...
...
src/utils/form.js
View file @
d335173f
...
@@ -73,6 +73,14 @@
...
@@ -73,6 +73,14 @@
);
);
};
};
u
.
getUniqueId
=
function
()
{
return
'
xxxxxxxx-xxxx
'
.
replace
(
/
[
x
]
/g
,
function
(
c
)
{
var
r
=
Math
.
random
()
*
16
|
0
,
v
=
c
===
'
x
'
?
r
:
r
&
0x3
|
0x8
;
return
v
.
toString
(
16
);
});
};
u
.
xForm2webForm
=
function
(
field
,
stanza
,
domain
)
{
u
.
xForm2webForm
=
function
(
field
,
stanza
,
domain
)
{
/* Takes a field in XMPP XForm (XEP-004: Data Forms) format
/* Takes a field in XMPP XForm (XEP-004: Data Forms) format
* and turns it into an HTML field.
* and turns it into an HTML field.
...
@@ -104,6 +112,7 @@
...
@@ -104,6 +112,7 @@
}
}
);
);
return
tpl_form_select
({
return
tpl_form_select
({
'
id
'
:
u
.
getUniqueId
(),
'
name
'
:
field
.
getAttribute
(
'
var
'
),
'
name
'
:
field
.
getAttribute
(
'
var
'
),
'
label
'
:
field
.
getAttribute
(
'
label
'
),
'
label
'
:
field
.
getAttribute
(
'
label
'
),
'
options
'
:
options
.
join
(
''
),
'
options
'
:
options
.
join
(
''
),
...
@@ -122,8 +131,8 @@
...
@@ -122,8 +131,8 @@
});
});
}
else
if
(
field
.
getAttribute
(
'
type
'
)
===
'
boolean
'
)
{
}
else
if
(
field
.
getAttribute
(
'
type
'
)
===
'
boolean
'
)
{
return
tpl_form_checkbox
({
return
tpl_form_checkbox
({
'
id
'
:
u
.
getUniqueId
(),
'
name
'
:
field
.
getAttribute
(
'
var
'
),
'
name
'
:
field
.
getAttribute
(
'
var
'
),
'
type
'
:
XFORM_TYPE_MAP
[
field
.
getAttribute
(
'
type
'
)],
'
label
'
:
field
.
getAttribute
(
'
label
'
)
||
''
,
'
label
'
:
field
.
getAttribute
(
'
label
'
)
||
''
,
'
checked
'
:
_
.
get
(
field
.
querySelector
(
'
value
'
),
'
textContent
'
)
===
"
1
"
&&
'
checked="1"
'
||
''
,
'
checked
'
:
_
.
get
(
field
.
querySelector
(
'
value
'
),
'
textContent
'
)
===
"
1
"
&&
'
checked="1"
'
||
''
,
'
required
'
:
!
_
.
isNil
(
field
.
querySelector
(
'
required
'
))
'
required
'
:
!
_
.
isNil
(
field
.
querySelector
(
'
required
'
))
...
@@ -144,6 +153,7 @@
...
@@ -144,6 +153,7 @@
});
});
}
else
{
}
else
{
return
tpl_form_input
({
return
tpl_form_input
({
'
id
'
:
u
.
getUniqueId
(),
'
label
'
:
field
.
getAttribute
(
'
label
'
)
||
''
,
'
label
'
:
field
.
getAttribute
(
'
label
'
)
||
''
,
'
name
'
:
field
.
getAttribute
(
'
var
'
),
'
name
'
:
field
.
getAttribute
(
'
var
'
),
'
placeholder
'
:
null
,
'
placeholder
'
:
null
,
...
...
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