Mercurial > hg > rc1
diff plugins/thunderbird_labels/thunderbird_labels.php @ 26:b2b6c0af2383
remove _ from name, lots of other hacks to get label context menu working
| author | Charlie Root |
|---|---|
| date | Sun, 28 Jan 2018 11:32:20 -0500 |
| parents | 4b2bc456ce42 |
| children | e097905863b9 |
line wrap: on
line diff
--- a/plugins/thunderbird_labels/thunderbird_labels.php Thu Jan 18 07:54:45 2018 -0500 +++ b/plugins/thunderbird_labels/thunderbird_labels.php Sun Jan 28 11:32:20 2018 -0500 @@ -44,7 +44,7 @@ $this->add_hook('messages_list', array($this, 'read_flags')); $this->add_hook('message_load', array($this, 'read_single_flags')); $this->add_hook('template_object_messageheaders', array($this, 'color_headers')); - $this->add_hook('render_page', array($this, 'tb_label_popup')); + $this->add_hook('render_page', array($this, 'tblabelpopup')); $this->include_stylesheet($this->local_skin_path() . '/tb_label.css'); $this->name = get_class($this); @@ -55,20 +55,35 @@ } $this->message_tb_labels = array(); + # This builds the toolbar button, but + # it's also used by the ctxtmenu initialisation + # contextmenu.js:rcube_context_menu to build + # the context menu, and that somehow + # ends up with display: none??? + # Bother, missed it, it's before this.container.show + # Afeter ul.appendnd -- inside menu.show on 307 + # 567? Yes -- that's calling 'hide', but overriding + # doesn't fix :-( + rcube::write_log('lab','add_button'); $this->add_button( array( - 'command' => 'plugin.thunderbird_labels.rcm_tb_label_submenu', - 'id' => 'tb_label_popuplink', + #'command' => 'plugin.thunderbird_labels.rcm_tb_label_submenu', + 'name' => 'tblabellink', + 'id' => 'tblabelpopuplink', + #'domain' => $this->ID, + 'type' => 'link', + 'class' => 'button tblabel', + 'label' => $this->gettext('tb_label_button_label'), 'title' => 'tb_label_button_title', - 'domain' => $this->ID, - 'type' => 'link', - 'content' => $this->gettext('tb_label_button_label'), - 'class' => 'button buttonPas disabled', - 'classact' => 'button', + 'onclick' => "UI.toggle_popup('tblabelpopup',event);return false", + 'aria-haspopup' => true, + 'aria-expanded' => false, + 'aria-owns' => 'plugin.thunderbird_labels.rcm_tb_label_submenu-menu' + #'classact' => 'listbutton add', ), 'toolbar' ); - + // JS function "set_flags" => PHP function "set_flags" $this->register_action('plugin.thunderbird_labels.set_flags', array($this, 'set_flags')); @@ -80,10 +95,10 @@ { if ($this->rc->action == 'list') $this->add_hook('render_mailboxlist', array($this, 'show_tb_label_contextmenu')); - #rcube::write_log('lab','ctxt: '.$this->rc->action); + rcube::write_log('lab','ctxt: '.$this->rc->action); } else { - #rcube::write_log('lab','no ctxt'); + rcube::write_log('lab','no ctxt'); } } elseif ($this->rc->task == 'settings') @@ -264,17 +279,19 @@ } public function show_tb_label_contextmenu($args) + # never called? { #$this->api->output->add_label('copymessage.copyingmessage'); - #rcube::write_log('lab',"stblc"); $li = html::tag('li', array('class' => 'submenu'), '<span>'.rcube::Q($this->gettext('tb_label_contextmenu_title')).'</span>' . $this->_gen_label_submenu($args, 'tb_label_ctxm_submenu')); $out .= html::tag('ul', array('id' => 'tb_label_ctxm_mainmenu'), $li); + rcube::write_log('lab',"stblc $out"); $this->api->output->add_footer(html::div(array('style' => 'display: none;'), $out)); } private function _gen_label_submenu($args, $id) + # never called? { $out = ''; $custom_labels = $this->rc->config->get('tb_label_custom_labels'); @@ -513,21 +530,22 @@ $this->api->output->send(); } - function tb_label_popup() + function tblabelpopup() { $custom_labels = $this->rc->config->get('tb_label_custom_labels'); $max_id = $this->rc->config->get('tb_max_label'); - $out = '<div id="tb_label_popup" class="popupmenu"> + $out = '<div id="tblabelpopup" class="popupmenu"> <ul class="toolbarmenu">'; for ($i = 0; $i <= $max_id; $i++) { $separator = ($i == 0)? ' separator_below' :''; - $out .= '<li class="label'.$i.$separator.'"><a href="#" class="active">'.$i.' '.$custom_labels[$i].'</a></li>'; + $out .= '<li class="label'.$i.$separator.'"><a href="#" id="tblabel'.$i.'" class="active">'.$i.' '.$custom_labels[$i].'</a></li>'; } $out .= '</ul> </div>'; - $this->rc->output->add_gui_object('tb_label_popup_obj', 'tb_label_popup'); - $this->rc->output->add_footer($out); + $this->rc->output->add_gui_object('tblabelpopup_obj', 'tblabelpopup'); + rcube::write_log('lab',"tblp $out"); + $this->rc->output->add_footer($out); } }
