init commit
BIN
plugins/identity_switch/assets/Pic01.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/identity_switch/assets/Pic02.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
plugins/identity_switch/assets/Pic03.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
plugins/identity_switch/assets/Pic04.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
plugins/identity_switch/assets/Pic05.png
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
plugins/identity_switch/assets/Pic06.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
plugins/identity_switch/assets/alert.gif
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
plugins/identity_switch/assets/alert.ico
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
plugins/identity_switch/assets/alert.mp3
Normal file
71
plugins/identity_switch/assets/identity_switch-form.js
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Identity switch RoundCube Bundle
|
||||
*
|
||||
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
|
||||
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
|
||||
// Reformat tables
|
||||
var fld = $('table[class="propform"]');
|
||||
fld.attr('class', 'propform cols-sm-6-6');
|
||||
var fld = $('td[class="title col-sm-4"]');
|
||||
fld.attr('class', 'title col-sm-6');
|
||||
var fld = $('td[class="col-sm-8"]');
|
||||
fld.attr('class', 'col-sm-6');
|
||||
|
||||
var fld = $('input[name="_enabled"]');
|
||||
if (fld.prop('value') == 0)
|
||||
fld.prop('checked', false);
|
||||
|
||||
identity_switch_enabled();
|
||||
});
|
||||
|
||||
function identity_switch_enabled() {
|
||||
|
||||
var fld = $('input[name="_enabled"]');
|
||||
|
||||
if (fld.prop('value') == undefined)
|
||||
return;
|
||||
|
||||
if (!fld.is(':checked')) {
|
||||
var val = 0;
|
||||
var dis = true;
|
||||
} else {
|
||||
var val = 1;
|
||||
var dis = false;
|
||||
}
|
||||
|
||||
fld.prop('value', val);
|
||||
$('input[name="_label"]').attr('disabled', dis);
|
||||
$('input[name="_imap_host"]').attr('disabled', dis);
|
||||
$('input[name="_imap_port"]').attr('disabled', dis);
|
||||
$('select[name="_imap_auth"]').attr('disabled', dis);
|
||||
$('input[name="_imap_user"]').attr('disabled', dis);
|
||||
$('input[name="_imap_pwd"]').attr('disabled', dis);
|
||||
$('input[name="_imap_delim"]').attr('disabled', dis);
|
||||
$('input[name="_smtp_host"]').attr('disabled', dis);
|
||||
$('input[name="_smtp_port"]').attr('disabled', dis);
|
||||
$('select[name="_smtp_auth"]').attr('disabled', dis);
|
||||
$('input[name="_check_all_folder"]').attr('disabled', dis);
|
||||
$('input[name="_notify_basic"]').attr('disabled', dis);
|
||||
$('input[name="_notify_desktop"]').attr('disabled', dis);
|
||||
$('select[name="_notify_timeout"]').attr('disabled', dis);
|
||||
$('input[name="_notify_sound"]').attr('disabled', dis);
|
||||
$('select[name="_refresh_interval"]').attr('disabled', dis);
|
||||
|
||||
// Disable all links
|
||||
$('a[name^="_notify"]').each(function(i, obj) {
|
||||
if (dis) {
|
||||
obj.setAttribute('save', obj.getAttribute('onclick'));
|
||||
obj.removeAttribute('href');
|
||||
obj.removeAttribute('onclick');
|
||||
} else {
|
||||
if (obj.getAttribute('save'))
|
||||
obj.setAttribute('onclick', obj.getAttribute('save'));
|
||||
obj.setAttribute('href', '#');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
2
plugins/identity_switch/assets/identity_switch-form.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
$(function(){var fld=$('table[class="propform"]');fld.attr('class','propform cols-sm-6-6');var fld=$('td[class="title col-sm-4"]');fld.attr('class','title col-sm-6');var fld=$('td[class="col-sm-8"]');fld.attr('class','col-sm-6');var fld=$('input[name="_enabled"]');if(fld.prop('value')==0)fld.prop('checked',false);identity_switch_enabled();});function identity_switch_enabled(){var fld=$('input[name="_enabled"]');if(fld.prop('value')==undefined)return;if(!fld.is(':checked')){var val=0;var dis=true;}else{var val=1;var dis=false;}fld.prop('value',val);$('input[name="_label"]').attr('disabled',dis);$('input[name="_imap_host"]').attr('disabled',dis);$('input[name="_imap_port"]').attr('disabled',dis);$('select[name="_imap_auth"]').attr('disabled',dis);$('input[name="_imap_user"]').attr('disabled',dis);$('input[name="_imap_pwd"]').attr('disabled',dis);$('input[name="_imap_delim"]').attr('disabled',dis);$('input[name="_smtp_host"]').attr('disabled',dis);$('input[name="_smtp_port"]').attr('disabled',dis);$('select[name="_smtp_auth"]').attr('disabled',dis);$('input[name="_check_all_folder"]').attr('disabled',dis);$('input[name="_notify_basic"]').attr('disabled',dis);$('input[name="_notify_desktop"]').attr('disabled',dis);$('select[name="_notify_timeout"]').attr('disabled',dis);$('input[name="_notify_sound"]').attr('disabled',dis);$('select[name="_refresh_interval"]').attr('disabled',dis);$('a[name^="_notify"]').each(function(i,obj){if(dis){obj.setAttribute('save',obj.getAttribute('onclick'));obj.removeAttribute('href');obj.removeAttribute('onclick');}else{if(obj.getAttribute('save'))obj.setAttribute('onclick',obj.getAttribute('save'));obj.setAttribute('href','#');}});}
|
131
plugins/identity_switch/assets/identity_switch.css
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Identity switch RoundCube Bundle
|
||||
*
|
||||
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
|
||||
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#identity_switch_menu {
|
||||
margin-right: 0px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-top: -65px;
|
||||
font-weight: bold;
|
||||
padding-left: 2rem;
|
||||
text-align: left;
|
||||
width: 240px;
|
||||
border: 1px solid #ccc !important;
|
||||
border-radius: .4em;
|
||||
background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") no-repeat left .75rem center/8px 10px;
|
||||
top: 10px;
|
||||
left: 200px;
|
||||
position: relative;
|
||||
float: inline-start;
|
||||
}
|
||||
|
||||
#identity_switch_dropdown {
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
padding: 0 .5rem 0 0;
|
||||
min-width: 240px;
|
||||
max-width: 240px;
|
||||
will-change: transform;
|
||||
top: 0;
|
||||
left: 168px;
|
||||
margin-left: 0;
|
||||
margin-top: 18px;
|
||||
width: 240px;
|
||||
transform: translate3d(63px, 49px, 0px);
|
||||
border-bottom-color: rgb(212, 219, 222);
|
||||
box-shadow: 3px 3px 5px #414141;
|
||||
max-height: 150px;
|
||||
overflow-x: hidden;
|
||||
color: #212529;
|
||||
display: none;
|
||||
margin-left: -.5rem;
|
||||
border-color: #d4dbde;
|
||||
border-radius: .4rem;
|
||||
border-bottom: 1px solid #f7f7f7;
|
||||
background-color: rgba(255, 255, 255);
|
||||
font-weight: 400;
|
||||
line-height: 35px;
|
||||
}
|
||||
|
||||
#identity_switch_dropdown ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#identity_switch_dropdown li {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
left: 0px;
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
#identity_switch_dropdown a {
|
||||
padding: 0 .5rem;
|
||||
white-space: nowrap;
|
||||
color: #2c363a;
|
||||
background: none;
|
||||
}
|
||||
|
||||
#identity_switch_dropdown li:hover {
|
||||
background-color: rgb(236, 236, 236);
|
||||
}
|
||||
|
||||
#identity_switch_dropdown a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#identity_switch_dropdown .unseen {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
min-width: 2em;
|
||||
line-height: 1.4rem;
|
||||
margin: 7.7px 0px 7.7px 0px;
|
||||
padding: 0 .3em;
|
||||
border-radius: .4em;
|
||||
background: #37beff;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
html.dark-mode #identity_switch_menu {
|
||||
margin-right: 0px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-top: 5px;
|
||||
font-weight: bold;
|
||||
padding-left: 2rem;
|
||||
text-align: left;
|
||||
width: 240px;
|
||||
border: 1px solid #ccc !important;
|
||||
border-radius: .4em;
|
||||
background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='beige' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") no-repeat left .75rem center/8px 10px;
|
||||
top: 10px;
|
||||
left: inherit;
|
||||
position: relative;
|
||||
float: inline-start;
|
||||
}
|
||||
|
||||
html.dark-mode #identity_switch_dropdown {
|
||||
background-color: #343a40;
|
||||
border-color: #4d6066;
|
||||
box-shadow: 3px 3px 5px #374549;
|
||||
}
|
||||
|
||||
html.dark-mode #identity_switch_dropdown a {
|
||||
color: #c5d1d3;
|
||||
}
|
||||
|
||||
html.dark-mode #identity_switch_dropdown li:hover {
|
||||
background-color: #374549;
|
||||
}
|
||||
|
||||
|
241
plugins/identity_switch/assets/identity_switch.js
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Identity switch RoundCube Bundle
|
||||
*
|
||||
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
|
||||
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
$sw = $('#identity_switch_menu');
|
||||
isOk = false;
|
||||
|
||||
switch (rcmail.env['skin']) {
|
||||
case 'larry':
|
||||
isOk = identity_switch_addCbLarry($sw);
|
||||
break;
|
||||
|
||||
case 'classic':
|
||||
isOk = identity_switch_addCbClassic($sw);
|
||||
break;
|
||||
|
||||
case 'elastic':
|
||||
case 'hivemail':
|
||||
isOk = identity_switch_addCbElastic($sw);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (isOk)
|
||||
$sw.show();
|
||||
});
|
||||
|
||||
// Catch all mouse clicks
|
||||
$(document).click(function(event) {
|
||||
|
||||
// Check for left button
|
||||
if (event.button == 0) {
|
||||
var id = event.target.id;
|
||||
var d = $('#identity_switch_dropdown');
|
||||
if (id != 'identity_switch_menu' && !d.is(':hidden'))
|
||||
d.hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Plugin initialization
|
||||
function identity_switch_init() {
|
||||
rcmail.addEventListener('plugin.identity_switch_notify', identity_switch_notify)
|
||||
.addEventListener('init', function() {
|
||||
// Bind to messages list select event, so favicon will be reverted on message preview too
|
||||
if (rcmail.message_list)
|
||||
rcmail.message_list.addEventListener('select', identity_switch_stop_notify);
|
||||
});
|
||||
}
|
||||
|
||||
// Set menu position
|
||||
function identity_switch_addCbLarry($sw) {
|
||||
var $truName = $('.topright .username');
|
||||
|
||||
if ($truName.length > 0) {
|
||||
if ($sw.length > 0) {
|
||||
$sw.prependTo('#taskbar');
|
||||
$truName.hide();
|
||||
// Move our selection menu a bit to the right
|
||||
$('#identity_switch_menu').css('padding-top', '4px').css('padding-bottom', '4px');
|
||||
$('#identity_switch_dropdown').css('margin-left', '-92px');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set menu position
|
||||
function identity_switch_addCbClassic($sw) {
|
||||
var $taskBar = $('#taskbar');
|
||||
|
||||
if ($taskBar.length > 0) {
|
||||
$taskBar.prepend($sw);
|
||||
// Move our selection menu a bit to the right
|
||||
$('#identity_switch_menu').css('left', '-10px')
|
||||
.css('top', '-5px');
|
||||
$('#identity_switch_dropdown')
|
||||
.css('left', '190px')
|
||||
.css('top', '-40px');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set menu position
|
||||
function identity_switch_addCbElastic($sw) {
|
||||
var $taskBar = $('.header-title.username');
|
||||
|
||||
$sw.css('background-color', 'transparent').css('padding','4px 0 0 2rem');
|
||||
if ($taskBar.length > 0) {
|
||||
$taskBar.prepend($sw);
|
||||
$taskBar.css('margin-left', '20px');
|
||||
|
||||
// Remove text from <span>
|
||||
var $node = $('.header-title.username');
|
||||
|
||||
var newNode = $('<' + $node[0].nodeName + '/>');
|
||||
$.each( $node[0].attributes, function ( i, attribute ) {
|
||||
newNode.attr(attribute.name, attribute.value);
|
||||
});
|
||||
$node.children().each(function(){
|
||||
newNode.append(this);
|
||||
});
|
||||
$node.replaceWith(newNode);
|
||||
|
||||
// Move our selection menu a bit to the bottom
|
||||
$('#identity_switch_menu')
|
||||
.css('height', '30px')
|
||||
.css('width', '180px');
|
||||
$('#identity_switch_dropdown')
|
||||
.css('left', '9px')
|
||||
.css('margin-top', '0');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Change userid in composer window to select proper identity
|
||||
function identity_switch_fixIdent(iid) {
|
||||
if (parseInt(iid) > 0)
|
||||
$("#_from").val(iid);
|
||||
}
|
||||
|
||||
// Open/close menu
|
||||
function identity_switch_toggle_menu() {
|
||||
var d = $('#identity_switch_dropdown');
|
||||
|
||||
if (d.is(':hidden')) {
|
||||
// reload window to show new mail counter in menu
|
||||
d.load(location.href + ' #identity_switch_dropdown > *', '');
|
||||
d.show();
|
||||
$('#messagelist-fixedcopy').css('z-index', 'auto');
|
||||
} else
|
||||
d.hide();
|
||||
}
|
||||
|
||||
// Switch identity
|
||||
function identity_switch_run(iid) {
|
||||
rcmail.env.unread_counts = {};
|
||||
rcmail.http_post('plugin.identity_switch_do', { 'identity_switch_iid': iid });
|
||||
}
|
||||
|
||||
// Perform notification
|
||||
function identity_switch_notify(ctl) {
|
||||
|
||||
var autoplay = decodeURI(ctl[0].autoplay);
|
||||
var notification = decodeURI(ctl[0].notification);
|
||||
var title = decodeURI(ctl[0].title);
|
||||
|
||||
for (var i = 1; i < ctl.length; i++) {
|
||||
var e = $('#identity_switch_opt_' + ctl[i].iid);
|
||||
if (ctl[i].unseen == '0')
|
||||
e.text('');
|
||||
else
|
||||
e.text(ctl[i].unseen);
|
||||
|
||||
if (ctl[i].basic !== undefined)
|
||||
identity_switch_basic();
|
||||
if (ctl[i].desktop !== undefined)
|
||||
identity_switch_desktop(title, ctl[i].desktop.text, ctl[i].desktop.timeout, notification);
|
||||
if (ctl[i].sound !== undefined)
|
||||
identity_switch_sound(autoplay);
|
||||
}
|
||||
}
|
||||
|
||||
// Stop notification
|
||||
function identity_switch_stop_notify(prop)
|
||||
{
|
||||
// Revert original favicon
|
||||
if (rcmail.env.favicon_href && rcmail.env.favicon_changed && (!prop || prop.action != 'check-recent')) {
|
||||
$('<link rel="shortcut icon" href="'+rcmail.env.favicon_href+'"/>').replaceAll('link[rel="shortcut icon"]');
|
||||
rcmail.env.favicon_changed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Browser notification: window.focus and favicon change
|
||||
function identity_switch_basic()
|
||||
{
|
||||
var w = rcmail.is_framed() ? window.parent : window;
|
||||
w.focus();
|
||||
|
||||
var src = rcmail.assets_path('plugins/identity_switch/assets');
|
||||
|
||||
// We cannot simply change a href attribute, we must to replace the link element (at least in FF)
|
||||
var link = $('<link rel="shortcut icon">').attr('href', src + '/alert.ico');
|
||||
var olink = $('link[rel="shortcut icon"]', w.document);
|
||||
if (!rcmail.env.favicon_href)
|
||||
rcmail.env.favicon_href = olink.attr('href');
|
||||
|
||||
rcmail.env.favicon_changed = 1;
|
||||
link.replaceAll(olink);
|
||||
}
|
||||
|
||||
// Desktop notification
|
||||
// - Require window.Notification API support (Chrome 22+ or Firefox 22+)
|
||||
function identity_switch_desktop(title, msg, timeout, errmsg)
|
||||
{
|
||||
if (!('Notification' in window) || window.Notification.permission !== "granted") {
|
||||
alert(decodeURIComponent(errmsg));
|
||||
window.Notification.requestPermission();
|
||||
return;
|
||||
}
|
||||
|
||||
var popup = new window.Notification(decodeURIComponent(title), {
|
||||
dir: "auto",
|
||||
lang: "",
|
||||
body: decodeURIComponent(msg),
|
||||
icon: rcmail.assets_path('plugins/identity_switch/assets/alert.gif')
|
||||
});
|
||||
popup.onclick = function() { this.close(); };
|
||||
setTimeout(function() { popup.close(); }, timeout * 1000);
|
||||
}
|
||||
|
||||
// Sound notification
|
||||
function identity_switch_sound(errmsg) {
|
||||
var src = rcmail.assets_path('plugins/identity_switch/assets/alert');
|
||||
|
||||
if (!('Notification' in window) || window.Notification.silent) {
|
||||
alert(decodeURIComponent(errmsg));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!('Navigator' in window) && window.Navigator.getAutoplayPolicy &&
|
||||
window.Navigator.getAutoplayPolicy('mediaelement') != 'allowed') {
|
||||
alert(decodeURIComponent(errmsg));
|
||||
window.Notification.requestPermission();
|
||||
return;
|
||||
}
|
||||
|
||||
new Audio(src + '.mp3').play();
|
||||
}
|
123
plugins/identity_switch/assets/identity_switch.min.css
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
#identity_switch_menu {
|
||||
margin-right: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-top: 5px;
|
||||
font-weight: 700;
|
||||
padding-left: 2rem;
|
||||
text-align: left;
|
||||
width: 240px;
|
||||
height: 21px;
|
||||
border: 1px solid #ccc !important;
|
||||
border-radius: .4em;
|
||||
background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") no-repeat left .75rem center/8px 10px;
|
||||
top: -65px;
|
||||
left: 240px;
|
||||
position: relative;
|
||||
float: inline-start
|
||||
}
|
||||
|
||||
#identity_switch_dropdown {
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
padding: 0 .5rem 0 0;
|
||||
/* min-width: 250px; */
|
||||
max-width: 260px;
|
||||
width: 260px;
|
||||
will-change: transform;
|
||||
top: 14px;
|
||||
left: 178px;
|
||||
margin-left: 0;
|
||||
margin-top: 0;
|
||||
transform: translate3d(63px, 49px, 0);
|
||||
border-bottom-color: #78b3cc;
|
||||
box-shadow: 0px 3px 5px #414141a1 !important;
|
||||
max-height: 150px;
|
||||
overflow-x: hidden;
|
||||
color: #212529;
|
||||
display: none;
|
||||
border-color: #d4dbde;
|
||||
border-radius: .4rem;
|
||||
border-bottom: 1px solid #f7f7f7;
|
||||
background-color: rgba(255, 255, 255);
|
||||
font-weight: 400;
|
||||
line-height: 35px
|
||||
}
|
||||
|
||||
#identity_switch_dropdown ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0
|
||||
}
|
||||
|
||||
#identity_switch_dropdown li {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
left: 0;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
#identity_switch_dropdown a {
|
||||
padding: 0 .5rem;
|
||||
white-space: nowrap;
|
||||
color: #2c363a;
|
||||
background: 0 0;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#identity_switch_dropdown li:hover {
|
||||
background-color: #bbe6f8
|
||||
}
|
||||
|
||||
#identity_switch_dropdown a:hover {
|
||||
text-decoration: none
|
||||
}
|
||||
|
||||
#identity_switch_dropdown .unseen {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
min-width: 2em;
|
||||
line-height: 1.4rem;
|
||||
margin: 7.7px 0 7.7px 0;
|
||||
padding: 0 .3em;
|
||||
border-radius: .4em;
|
||||
background: #37beff;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
font-weight: 700
|
||||
}
|
||||
|
||||
html.dark-mode #identity_switch_menu {
|
||||
margin-right: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-top: 5px;
|
||||
font-weight: 700;
|
||||
padding-left: 2rem;
|
||||
text-align: left;
|
||||
width: 240px;
|
||||
border: 1px solid #ccc !important;
|
||||
border-radius: .4em;
|
||||
background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='beige' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") no-repeat left .75rem center/8px 10px;
|
||||
top: 10px;
|
||||
left: inherit;
|
||||
position: relative;
|
||||
float: inline-start
|
||||
}
|
||||
|
||||
html.dark-mode #identity_switch_dropdown {
|
||||
background-color: #343a40;
|
||||
border-color: #4d6066;
|
||||
box-shadow: 3px 3px 5px #374549
|
||||
}
|
||||
|
||||
html.dark-mode #identity_switch_dropdown a {
|
||||
color: #c5d1d3
|
||||
}
|
||||
|
||||
html.dark-mode #identity_switch_dropdown li:hover {
|
||||
background-color: #374549
|
||||
}
|
4
plugins/identity_switch/assets/identity_switch.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
$(function(){$sw=$('#identity_switch_menu');isOk=false;switch(rcmail.env['skin']){case'larry':isOk=identity_switch_addCbLarry($sw);break;case'classic':isOk=identity_switch_addCbClassic($sw);break;case'elastic':case'hivemail':isOk=identity_switch_addCbElastic($sw);default:break;}if(isOk)$sw.show();});$(document).click(function(event){if(event.button==0){var id=event.target.id;var d=$('#identity_switch_dropdown');if(id!='identity_switch_menu'&&!d.is(':hidden'))d.hide();}});function identity_switch_init(){rcmail.addEventListener('plugin.identity_switch_notify',identity_switch_notify).addEventListener('init',function(){if(rcmail.message_list)rcmail.message_list.addEventListener('select',identity_switch_stop_notify);});}function identity_switch_addCbLarry($sw){var $truName=$('.topright .username');if($truName.length>0){if($sw.length>0){$sw.prependTo('#taskbar');$truName.hide();$('#identity_switch_menu').css('padding-top','4px').css('padding-bottom','4px');$('#identity_switch_dropdown').css('margin-left','-92px');return true;}}return false;}function identity_switch_addCbClassic($sw){var $taskBar=$('#taskbar');if($taskBar.length>0){$taskBar.prepend($sw);$('#identity_switch_menu').css('left','-10px').css('top','-5px');$('#identity_switch_dropdown').css('left','190px').css('top','-40px');return true;}return false;}function identity_switch_addCbElastic($sw){var $taskBar=$('.header-title.username');$sw.css('background-color','transparent').css('padding','4px 0 0 2rem');if($taskBar.length>0){$taskBar.prepend($sw);$taskBar.css('margin-left','20px');var $node=$('.header-title.username');var newNode=$('<'+$node[0].nodeName+'/>');$.each($node[0].attributes,function(i,attribute){newNode.attr(attribute.name,attribute.value);});$node.children().each(function(){newNode.append(this);});$node.replaceWith(newNode);$('#identity_switch_menu').css('height','30px').css('width','180px');$('#identity_switch_dropdown').css('left','9px').css('margin-top','0');return true;}return false;}function identity_switch_fixIdent(iid){if(parseInt(iid)>0)$("#_from").val(iid);}function identity_switch_toggle_menu(){var d=$('#identity_switch_dropdown');if(d.is(':hidden')){d.load(location.href+' #identity_switch_dropdown > *','');d.show();$('#messagelist-fixedcopy').css('z-index','auto');}else
|
||||
d.hide();}function identity_switch_run(iid){rcmail.env.unread_counts={};rcmail.http_post('plugin.identity_switch_do',{'identity_switch_iid':iid});}function identity_switch_notify(ctl){var autoplay=decodeURI(ctl[0].autoplay);var notification=decodeURI(ctl[0].notification);var title=decodeURI(ctl[0].title);for(var i=1;i<ctl.length;i++){var e=$('#identity_switch_opt_'+ctl[i].iid);if(ctl[i].unseen=='0')e.text('');else
|
||||
e.text(ctl[i].unseen);if(ctl[i].basic!==undefined)identity_switch_basic();if(ctl[i].desktop!==undefined)identity_switch_desktop(title,ctl[i].desktop.text,ctl[i].desktop.timeout,notification);if(ctl[i].sound!==undefined)identity_switch_sound(autoplay);}}function identity_switch_stop_notify(prop){if(rcmail.env.favicon_href&&rcmail.env.favicon_changed&&(!prop||prop.action!='check-recent')){$('<link rel="shortcut icon" href="'+rcmail.env.favicon_href+'"/>').replaceAll('link[rel="shortcut icon"]');rcmail.env.favicon_changed=0;}}function identity_switch_basic(){var w=rcmail.is_framed()?window.parent:window;w.focus();var src=rcmail.assets_path('plugins/identity_switch/assets');var link=$('<link rel="shortcut icon">').attr('href',src+'/alert.ico');var olink=$('link[rel="shortcut icon"]',w.document);if(!rcmail.env.favicon_href)rcmail.env.favicon_href=olink.attr('href');rcmail.env.favicon_changed=1;link.replaceAll(olink);}function identity_switch_desktop(title,msg,timeout,errmsg){if(!('Notification'in window)||window.Notification.permission!=="granted"){alert(decodeURIComponent(errmsg));window.Notification.requestPermission();return;}var popup=new window.Notification(decodeURIComponent(title),{dir:"auto",lang:"",body:decodeURIComponent(msg),icon:rcmail.assets_path('plugins/identity_switch/assets/alert.gif')});popup.onclick=function(){this.close();};setTimeout(function(){popup.close();},timeout*1000);}function identity_switch_sound(errmsg){var src=rcmail.assets_path('plugins/identity_switch/assets/alert');if(!('Notification'in window)||window.Notification.silent){alert(decodeURIComponent(errmsg));return;}if(!('Navigator'in window)&&window.Navigator.getAutoplayPolicy&&window.Navigator.getAutoplayPolicy('mediaelement')!='allowed'){alert(decodeURIComponent(errmsg));window.Notification.requestPermission();return;}new Audio(src+'.mp3').play();}
|