Commit b2a118ca authored by JC Brand's avatar JC Brand

Refactor slide methods in utils and use them for toolbar menus

parent ce2548c8
......@@ -148,7 +148,7 @@ css/mobile.min.css:: stamp-npm sass/*
.PHONY: watch
watch: stamp-bundler
$(SASS) --watch -I ./node_modules/bourbon/app/assets/stylesheets/ sass/converse/converse.scss:css/converse.css sass/_muc_embedded.scss:css/converse-muc-embedded.css
$(SASS) --watch -I ./node_modules/bourbon/app/assets/stylesheets/ sass/converse/converse.scss:css/converse.css sass/_muc_embedded.scss:css/converse-muc-embedded.css sass/inverse/inverse.scss:css/inverse.css
.PHONY: watchjs
watchjs: stamp-npm
......
This diff is collapsed.
This diff is collapsed.
......@@ -272,14 +272,6 @@
text-decoration: none;
text-shadow: none;
}
.emoji-picker {
margin-bottom: $toolbar-height + 5px;
}
.toolbar-picker-panel {
a {
color: $link-color;
}
}
.chat-toolbar-text {
font-size: 12px;
padding-right: 3px;
......@@ -287,7 +279,7 @@
.unencrypted a,
.unencrypted {
color: $text-color;
.toolbar-picker-panel {
.toolbar-menu {
a {
color: $link-color;
}
......@@ -307,84 +299,84 @@
float: right;
}
li {
cursor: pointer;
display: inline-block;
list-style: none;
padding: 0 3px 0 3px;
cursor: pointer;
margin-top: 1px;
}
li:hover {
cursor: pointer;
}
ul {
background: #fff;
bottom: 100%;
box-shadow: -1px -1px 2px 0 rgba(0, 0, 0, 0.4);
font-size: 12px;
margin: 0;
position: absolute;
right: 0;
li {
padding: 0 3px 0 3px;
&:hover {
cursor: pointer;
list-style: none;
position: relative;
a:hover {
color: #8f2831;
}
}
}
li {
margin-left: 0;
}
.toggle-smiley {
color: $text-color;
padding-left: 5px;
ul {
&.emoji-category-picker {
z-index: 100;
.picked {
background-color: $highlight-color;
}
.toolbar-menu {
background-color: #fff;
bottom: 100%;
box-shadow: -1px -1px 2px 0 rgba(0, 0, 0, 0.4);
font-size: 12px;
margin: 0;
position: absolute;
right: 0;
a {
color: $link-color;
}
&.emoji-picker {
height: 250px;
overflow: scroll;
ul {
&.emoji-category-picker {
box-shadow: -1px -1px 2px 0 rgba(0, 0, 0, 0.4);
z-index: 100;
.picked {
background-color: $highlight-color;
}
}
&.emoji-picker {
height: 250px;
overflow: scroll;
}
li {
margin-left: 0;
cursor: pointer;
list-style: none;
position: relative;
a:hover {
color: #8f2831;
}
}
}
left: 0;
li {
font-size: $font-size;
padding: 5px;
z-index: 98;
&.emoji {
a {
font-size: $font-size-huge;
}
&.toggle-toolbar-menu {
color: $text-color;
ul {
li {
&:hover {
background-color: $highlight-color;
}
}
}
li:hover {
background-color: $highlight-color;
}
&.toggle-smiley {
padding-left: 5px;
ul {
left: 0;
li {
padding: 5px;
z-index: 98;
&.emoji {
a {
font-size: $font-size-huge;
}
}
}
}
}
}
.toggle-otr {
ul {
li {
padding: 7px;
background-color: white;
display: block;
&.toggle-otr {
ul {
z-index: 99;
a {
-moz-transition: background-color 0.2s ease-in-out;
-webkit-transition: background-color 0.2s ease-in-out;
transition: background-color 0.2s ease-in-out;
li {
display: block;
padding: 1px;
text-decoration: none;
padding: 7px;
a {
display: block;
}
}
}
li:hover {
background-color: $highlight-color;
}
}
}
}
......
......@@ -74,6 +74,10 @@
opacity: 0;
display: none;
}
.collapsed {
height: 0;
overflow: hidden;
}
.locked {
padding-right: 22px;
......
......@@ -54,14 +54,13 @@
//
registerGlobalEventHandlers: function () {
this.__super__.registerGlobalEventHandlers();
document.addEventListener('click', function () {
if ($('.toggle-smiley ul').is(':visible')) {
_.each(
document.querySelectorAll('.toggle-smiley .emoji-picker-container'),
utils.hideElement
);
document.addEventListener(
'click', function () {
utils.slideInAllElements(
document.querySelectorAll('.toolbar-menu')
)
}
});
);
},
ChatBoxViews: {
......@@ -114,7 +113,7 @@
});
_converse.EmojiPickerView = Backbone.View.extend({
className: 'emoji-picker-container hidden',
className: 'emoji-picker-container toolbar-menu collapsed',
events: {
'click .emoji-category-picker li a': 'chooseCategory',
},
......@@ -710,7 +709,16 @@
return;
}
}
utils.toggleElement(this.emoji_picker_view.el);
const elements = _.difference(
document.querySelectorAll('.toolbar-menu'),
[this.emoji_picker_view.el]
);
utils.slideInAllElements(elements).then(
_.partial(
utils.slideToggleElement,
this.emoji_picker_view.el
)
);
},
toggleCall (ev) {
......
......@@ -42,6 +42,7 @@
OTR_CLASS_MAPPING[VERIFIED] = 'verified';
OTR_CLASS_MAPPING[FINISHED] = 'finished';
converse.plugins.add('converse-otr', {
overrides: {
......@@ -51,15 +52,6 @@
//
// New functions which don't exist yet can also be added.
registerGlobalEventHandlers () {
this.__super__.registerGlobalEventHandlers();
document.addEventListener('click', function () {
if ($('.toggle-otr ul').is(':visible')) {
_.each($('.toggle-otr ul', this), utils.hideElement);
}
});
},
ChatBox: {
initialize () {
this.__super__.initialize.apply(this, arguments);
......@@ -347,7 +339,6 @@
},
startOTRFromToolbar (ev) {
$(ev.target).parent().parent().slideUp();
ev.stopPropagation();
this.model.initiateOTR();
},
......@@ -392,7 +383,17 @@
toggleOTRMenu (ev) {
ev.stopPropagation();
utils.toggleElement(this.el.querySelector('.toggle-otr ul'));
const menu = this.el.querySelector('.toggle-otr ul');
const elements = _.difference(
document.querySelectorAll('.toolbar-menu'),
[menu]
);
utils.slideInAllElements(elements).then(
_.partial(
utils.slideToggleElement,
menu
)
);
},
getOTRTooltip () {
......
......@@ -70,7 +70,7 @@
});
this.hide();
if (this.list_model.get('toggle-state') !== _converse.OPENED) {
this.el.querySelector('.open-rooms-list').classList.add('hidden');
this.el.querySelector('.open-rooms-list').classList.add('collapsed');
}
this.model.each(this.renderRoomsListElement.bind(this));
const controlboxview = _converse.chatboxviews.get('controlbox');
......@@ -142,13 +142,13 @@
if (ev && ev.preventDefault) { ev.preventDefault(); }
const el = ev.target;
if (el.classList.contains("icon-opened")) {
utils.slideUp(this.el.querySelector('.open-rooms-list')).then(() => {
utils.slideIn(this.el.querySelector('.open-rooms-list')).then(() => {
this.list_model.save({'toggle-state': _converse.CLOSED});
el.classList.remove("icon-opened");
el.classList.add("icon-closed");
});
} else {
utils.slideDown(this.el.querySelector('.open-rooms-list')).then(() => {
utils.slideOut(this.el.querySelector('.open-rooms-list')).then(() => {
this.list_model.save({'toggle-state': _converse.OPENED});
el.classList.remove("icon-closed");
el.classList.add("icon-opened");
......
<ul class="emoji-category-picker">
{[ _.forEach(emojis_by_category, function (obj, category) { ]}
<li data-category="{{{category}}}" class="emoji-category {[ if (current_category === category) { ]} picked {[ } ]}">
<a href="#" data-category="{{{category}}}"> {{ emojione.shortnameToUnicode(emojis_by_category[category][0]._shortname) }} </a>
</li>
{[ }); ]}
</ul>
{[ _.forEach(emojis_by_category, function (obj, category) { ]}
<ul class="emoji-picker emoji-picker-{{{category}}} {[ if (current_category !== category) { ]} hidden {[ } ]}">
{[ _.forEach(emojis_by_category[category], function (emoji) { ]}
......@@ -14,3 +7,10 @@
{[ }); ]}
</ul>
{[ }); ]}
<ul class="emoji-category-picker">
{[ _.forEach(emojis_by_category, function (obj, category) { ]}
<li data-category="{{{category}}}" class="emoji-category {[ if (current_category === category) { ]} picked {[ } ]}">
<a href="#" data-category="{{{category}}}"> {{ emojione.shortnameToUnicode(emojis_by_category[category][0]._shortname) }} </a>
</li>
{[ }); ]}
</ul>
{[ if (use_emoji) { ]}
<li class="toggle-smiley icon-happy" title="{{{label_insert_smiley}}}">
<li class="toggle-toolbar-menu toggle-smiley icon-happy" title="{{{label_insert_smiley}}}">
<ul class="emoji-picker"></ul>
</li>
{[ } ]}
......
{[ if (allow_otr) { ]}
<li class="toggle-otr {{{otr_status_class}}}" title="{{{otr_tooltip}}}">
<li class="toggle-toolbar-menu toggle-otr {{{otr_status_class}}}" title="{{{otr_tooltip}}}">
<span class="chat-toolbar-text">{{{otr_translated_status}}}</span>
{[ if (otr_status == UNENCRYPTED) { ]}
<span class="icon-unlocked"></span>
......@@ -13,7 +13,7 @@
{[ if (otr_status == FINISHED) { ]}
<span class="icon-unlocked"></span>
{[ } ]}
<ul class="toolbar-picker-panel">
<ul class="toolbar-menu collapsed">
{[ if (otr_status == UNENCRYPTED) { ]}
<li><a class="start-otr" href="#">{{{label_start_encrypted_conversation}}}</a></li>
{[ } ]}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment