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
28ec1509
Commit
28ec1509
authored
May 09, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add alert modal and close profile modal on save
parent
64754fa3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
20 deletions
+93
-20
css/converse.css
css/converse.css
+2
-0
css/inverse.css
css/inverse.css
+2
-0
sass/_core.scss
sass/_core.scss
+6
-0
src/converse-modal.js
src/converse-modal.js
+58
-6
src/converse-profile.js
src/converse-profile.js
+9
-14
src/templates/alert_modal.html
src/templates/alert_modal.html
+16
-0
No files found.
css/converse.css
View file @
28ec1509
...
@@ -6953,6 +6953,8 @@ body.reset {
...
@@ -6953,6 +6953,8 @@ body.reset {
color
:
#818479
;
}
color
:
#818479
;
}
#conversejs
.modal
{
#conversejs
.modal
{
background-color
:
rgba
(
0
,
0
,
0
,
0.4
);
}
background-color
:
rgba
(
0
,
0
,
0
,
0.4
);
}
#conversejs
.modal
.modal-body
p
{
padding
:
0.25rem
0
;
}
#conversejs
.selected
{
#conversejs
.selected
{
color
:
#578EA9
!important
;
}
color
:
#578EA9
!important
;
}
#conversejs
.circle
{
#conversejs
.circle
{
...
...
css/inverse.css
View file @
28ec1509
...
@@ -6953,6 +6953,8 @@ body.reset {
...
@@ -6953,6 +6953,8 @@ body.reset {
color
:
#818479
;
}
color
:
#818479
;
}
#conversejs
.modal
{
#conversejs
.modal
{
background-color
:
rgba
(
0
,
0
,
0
,
0.4
);
}
background-color
:
rgba
(
0
,
0
,
0
,
0.4
);
}
#conversejs
.modal
.modal-body
p
{
padding
:
0.25rem
0
;
}
#conversejs
.selected
{
#conversejs
.selected
{
color
:
#578EA9
!important
;
}
color
:
#578EA9
!important
;
}
#conversejs
.circle
{
#conversejs
.circle
{
...
...
sass/_core.scss
View file @
28ec1509
...
@@ -176,6 +176,12 @@ body.reset {
...
@@ -176,6 +176,12 @@ body.reset {
.modal
{
.modal
{
background-color
:
rgba
(
0
,
0
,
0
,
0
.4
);
background-color
:
rgba
(
0
,
0
,
0
,
0
.4
);
.modal-body
{
p
{
padding
:
0
.25rem
0
;
}
}
}
}
.selected
{
.selected
{
...
...
src/converse-modal.js
View file @
28ec1509
...
@@ -8,15 +8,15 @@
...
@@ -8,15 +8,15 @@
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
define
([
define
([
"
converse-core
"
,
"
converse-core
"
,
"
tpl!alert_modal
"
,
"
bootstrap
"
,
"
bootstrap
"
,
"
underscore
"
,
"
backbone
"
,
"
backbone.vdomview
"
"
backbone.vdomview
"
],
factory
);
],
factory
);
}
}
}(
this
,
function
(
converse
,
bootstrap
,
_
,
Backbone
)
{
}(
this
,
function
(
converse
,
tpl_alert_modal
,
bootstrap
)
{
"
use strict
"
;
"
use strict
"
;
const
{
Strophe
,
Backbone
,
_
}
=
converse
.
env
;
converse
.
plugins
.
add
(
'
converse-modal
'
,
{
converse
.
plugins
.
add
(
'
converse-modal
'
,
{
...
@@ -44,12 +44,64 @@
...
@@ -44,12 +44,64 @@
},
},
show
(
ev
)
{
show
(
ev
)
{
ev
.
preventDefault
();
if
(
ev
)
{
this
.
trigger_el
=
ev
.
target
;
ev
.
preventDefault
();
this
.
trigger_el
.
classList
.
add
(
'
selected
'
);
this
.
trigger_el
=
ev
.
target
;
this
.
trigger_el
.
classList
.
add
(
'
selected
'
);
}
this
.
modal
.
show
();
this
.
modal
.
show
();
}
}
});
});
_converse
.
Alert
=
_converse
.
BootstrapModal
.
extend
({
initialize
()
{
_converse
.
BootstrapModal
.
prototype
.
initialize
.
apply
(
this
,
arguments
);
this
.
model
.
on
(
'
change
'
,
this
.
render
,
this
);
},
toHTML
()
{
return
tpl_alert_modal
(
this
.
model
.
toJSON
());
}
});
/************************ BEGIN API ************************/
// We extend the default converse.js API to add methods specific to MUC chat rooms.
let
alert
_
.
extend
(
_converse
.
api
,
{
'
alert
'
:
{
'
show
'
(
type
,
title
,
messages
)
{
if
(
_
.
isString
(
messages
))
{
messages
=
[
messages
];
}
if
(
type
===
Strophe
.
LogLevel
.
ERROR
)
{
type
=
'
alert-danger
'
;
}
else
if
(
type
===
Strophe
.
LogLevel
.
INFO
)
{
type
=
'
alert-info
'
;
}
else
if
(
type
===
Strophe
.
LogLevel
.
WARN
)
{
type
=
'
alert-warning
'
;
}
if
(
_
.
isUndefined
(
alert
))
{
const
model
=
new
Backbone
.
Model
({
'
title
'
:
title
,
'
messages
'
:
messages
,
'
type
'
:
type
})
alert
=
new
_converse
.
Alert
({
'
model
'
:
model
});
}
else
{
alert
.
model
.
set
({
'
title
'
:
title
,
'
messages
'
:
messages
,
'
type
'
:
type
});
}
alert
.
show
();
}
}
});
}
}
});
});
}));
}));
src/converse-profile.js
View file @
28ec1509
...
@@ -90,22 +90,17 @@
...
@@ -90,22 +90,17 @@
setVCard
(
body
,
data
)
{
setVCard
(
body
,
data
)
{
_converse
.
api
.
vcard
.
set
(
data
)
_converse
.
api
.
vcard
.
set
(
data
)
.
then
(()
=>
{
.
then
(()
=>
_converse
.
api
.
vcard
.
update
(
this
.
model
.
vcard
,
true
))
_converse
.
api
.
vcard
.
update
(
this
.
model
.
vcard
,
true
);
.
catch
((
err
)
=>
{
const
html
=
tpl_alert
({
'
message
'
:
__
(
'
Profile data succesfully saved
'
),
'
type
'
:
'
alert-primary
'
});
body
.
insertAdjacentHTML
(
'
afterBegin
'
,
html
);
}).
catch
((
err
)
=>
{
_converse
.
log
(
err
,
Strophe
.
LogLevel
.
FATAL
);
_converse
.
log
(
err
,
Strophe
.
LogLevel
.
FATAL
);
const
html
=
tpl_alert
({
_converse
.
api
.
alert
.
show
(
'
message
'
:
__
(
'
An error happened while trying to save your profile data
'
),
Strophe
.
LogLevel
.
ERROR
,
'
type
'
:
'
alert-danger
'
__
(
'
Error
'
),
});
[
__
(
"
Sorry, an error happened while trying to save your profile data.
"
),
body
.
insertAdjacentHTML
(
'
afterBegin
'
,
html
);
__
(
"
You can check your browser's developer console for any error output.
"
)]
)
});
});
this
.
modal
.
hide
();
},
},
onFormSubmitted
(
ev
)
{
onFormSubmitted
(
ev
)
{
...
...
src/templates/alert_modal.html
0 → 100644
View file @
28ec1509
<div
class=
"modal"
tabindex=
"-1"
role=
"dialog"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header {{{o.type}}}"
>
<h5
class=
"modal-title"
>
{{{o.title}}}
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body"
>
{[ _.each(o.messages, function (message) { ]}
<p>
{{{message}}}
</p>
{[ }) ]}
</div>
</div>
</div>
</div>
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