Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some vacation_sieve enhancements #16

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
hide: null,
autoOpen: false,
multiple: true,
position: {}
position: {},
appendTo: "body"
},

_create: function() {
Expand All @@ -55,7 +56,7 @@
// jQuery UI 1.9+, and otherwise fallback to a custom string.
this._namespaceID = this.eventNamespace || ('multiselect' + multiselectID);

var button = (this.button = $('<button type="button"><span class="ui-icon ui-icon-triangle-2-n-s"></span></button>'))
var button = (this.button = $('<button type="button"><span class="ui-icon ui-icon-triangle-1-s"></span></button>'))
.addClass('ui-multiselect ui-widget ui-state-default ui-corner-all')
.addClass(o.classes)
.attr({ 'title':el.attr('title'), 'aria-haspopup':true, 'tabIndex':el.attr('tabIndex') })
Expand All @@ -68,7 +69,7 @@
menu = (this.menu = $('<div />'))
.addClass('ui-multiselect-menu ui-widget ui-widget-content ui-corner-all')
.addClass(o.classes)
.appendTo(document.body),
.appendTo($(o.appendTo)),

header = (this.header = $('<div />'))
.addClass('ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix')
Expand Down Expand Up @@ -135,8 +136,8 @@
el.find('option').each(function(i) {
var $this = $(this);
var parent = this.parentNode;
var title = this.innerHTML;
var description = this.title;
var description = this.innerHTML;
var title = this.title;
var value = this.value;
var inputID = 'ui-multiselect-' + (this.id || id + '-option-' + i);
var isDisabled = this.disabled;
Expand Down Expand Up @@ -169,7 +170,7 @@
html += '<li class="' + liClasses + '">';

// create the label
html += '<label for="' + inputID + '" title="' + description + '" class="' + labelClasses.join(' ') + '">';
html += '<label for="' + inputID + '" title="' + title + '" class="' + labelClasses.join(' ') + '">';
html += '<input id="' + inputID + '" name="multiselect_' + id + '" type="' + (o.multiple ? "checkbox" : "radio") + '" value="' + value + '" title="' + title + '"';

// pre-selected?
Expand All @@ -185,7 +186,7 @@
}

// add the title and close everything off
html += ' /><span>' + title + '</span></label></li>';
html += ' /><span>' + description + '</span></label></li>';
});

// insert into the DOM
Expand Down Expand Up @@ -222,7 +223,7 @@
if($.isFunction(o.selectedText)) {
value = o.selectedText.call(this, numChecked, $inputs.length, $checked.get());
} else if(/\d/.test(o.selectedList) && o.selectedList > 0 && numChecked <= o.selectedList) {
value = $checked.map(function() { return $(this).next().html(); }).get().join(', ');
value = $checked.map(function() { return $(this).next().text(); }).get().join(', ');
} else {
value = o.selectedText.replace('#', numChecked).replace('#', $inputs.length);
}
Expand Down Expand Up @@ -399,8 +400,15 @@
});

// close each widget when clicking on any other element/anywhere else on the page
$doc.bind('mousedown.' + this._namespaceID, function(e) {
if(self._isOpen && !$.contains(self.menu[0], e.target) && !$.contains(self.button[0], e.target) && e.target !== self.button[0]) {
$doc.bind('mousedown.' + this._namespaceID, function(event) {
var target = event.target;

if(self._isOpen
&& target !== self.button[0]
&& target !== self.menu[0]
&& !$.contains(self.menu[0], target)
&& !$.contains(self.button[0], target)
) {
self.close();
}
});
Expand All @@ -416,7 +424,8 @@

// set button width
_setButtonWidth: function() {
var width = this.element.outerWidth();
// account for the ui-icon
var width = this.element.outerWidth() + this.button.children('span').outerWidth() + 2;
var o = this.options;

if(/\d/.test(o.minWidth) && width < o.minWidth) {
Expand All @@ -439,7 +448,7 @@
var moveToLast = which === 38 || which === 37;

// select the first li that isn't an optgroup label / disabled
$next = $start.parent()[moveToLast ? 'prevAll' : 'nextAll']('li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup-label)')[ moveToLast ? 'last' : 'first']();
var $next = $start.parent()[moveToLast ? 'prevAll' : 'nextAll']('li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup-label)').first();

// if at the first/last element
if(!$next.length) {
Expand Down Expand Up @@ -571,10 +580,10 @@
// show the menu, maybe with a speed/effect combo
$.fn.show.apply(menu, args);

// select the first option
// select the first not disabled option
// triggering both mouseover and mouseover because 1.4.2+ has a bug where triggering mouseover
// will actually trigger mouseenter. the mouseenter trigger is there for when it's eventually fixed
this.labels.eq(0).trigger('mouseover').trigger('mouseenter').find('input').trigger('focus');
this.labels.filter(':not(.ui-state-disabled)').eq(0).trigger('mouseover').trigger('mouseenter').find('input').trigger('focus');

button.addClass('ui-state-active');
this._isOpen = true;
Expand Down Expand Up @@ -661,7 +670,7 @@

// use the position utility if it exists and options are specifified
if($.ui.position && !$.isEmptyObject(o.position)) {
o.position.of = o.position.of || button;
o.position.of = o.position.of || this.button;

this.menu
.show()
Expand Down

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion plugins/vacation_sieve/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class model
public $vacation_end = 0;
public $vacation_endtime = 12;
public $append_subject = true;
public $append_subject = true;
public $vacation_subject = 'Out of office'; // overwrite in config.inc.php
public $vacation_message = 'I am in Holidays...'; // overwrite in config.inc.php
public $every = 1;
Expand Down
6 changes: 3 additions & 3 deletions plugins/vacation_sieve/styles.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@

/* Section headers for the orms */
td.section-first
.vacation td.section-first
{
font-size:larger;
font-weight:bold;
padding-bottom:4pt;
}

td.section
.vacation td.section
{
font-size:larger;
font-weight:bold;
padding-top:10pt;
padding-bottom:4pt;
}

td.top
.vacation td.top
{
vertical-align:top;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/vacation_sieve/vacation_sieve.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (window.rcmail)

// Adjust the eight of the identities list
$(function () {
$('select#addressed_to').multiselect({header:false, selectedList: 2, height:"auto"});
$('select#addressed_to').multiselect({header:false, selectedList: 2, height:"auto", minWidth:"auto"});
// Make sure we have one address selected. On select 'null' select the default.
$("select#addressed_to").change(function(){
if ( $(this).val() == null ) {
Expand Down
6 changes: 3 additions & 3 deletions plugins/vacation_sieve/vacation_sieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ public function vacation_sieve_save()
$this->app->output->set_pagetitle($this->gettext('vacation'));
rcmail_overwrite_action('plugin.vacation_sieve');
$this->app->output->send('plugin');
$this->api->output->command('display_message', $this->gettext('filtersaved'), 'confirmation');
$this->api->output->command('display_message', $this->gettext('filtersaved'), 'confirmation');
}
catch ( Exception $exc)
{
$this->log_error('Fail to save: '.$exc->getMessage());
$this->api->output->command('display_message', $this->gettext('filtersaveerror'), 'error');
$this->api->output->command('display_message', $this->gettext('filtersaveerror'), 'error');
}
}

Expand Down Expand Up @@ -285,7 +285,7 @@ public function vacation_sieve_form()
{
try
{
$table = new html_table(array('cols' => 2, 'class' => 'propform'));
$table = new html_table(array('cols' => 2, 'class' => 'propform vacation'));

$format = $this->app->config->get('date_format');

Expand Down