| | |
| | | scroll_speed: 20, |
| | | save_state: false, |
| | | keyboard: true, |
| | | tabexit: true, |
| | | check_droptarget: function(node) { return !node.virtual; } |
| | | }, p || {}); |
| | | |
| | |
| | | tree_state, |
| | | ui_droppable, |
| | | ui_draggable, |
| | | draggable_opts, |
| | | droppable_opts, |
| | | list_id = (container.attr('id') || p.id_prefix || '0'), |
| | | me = this; |
| | | |
| | |
| | | this.get_item = get_item; |
| | | this.get_node = get_node; |
| | | this.get_selection = get_selection; |
| | | this.is_search = is_search; |
| | | this.reset_search = reset_search; |
| | | |
| | | /////// startup code (constructor) |
| | | |
| | |
| | | /** |
| | | * |
| | | */ |
| | | function reset() |
| | | function reset(keep_content) |
| | | { |
| | | select(''); |
| | | |
| | |
| | | indexbyid = {}; |
| | | drag_active = false; |
| | | |
| | | container.html(''); |
| | | if (keep_content) { |
| | | if (draggable_opts) { |
| | | if (ui_draggable) |
| | | draggable('destroy'); |
| | | draggable(draggable_opts); |
| | | } |
| | | |
| | | if (droppable_opts) { |
| | | if (ui_droppable) |
| | | droppable('destroy'); |
| | | droppable(droppable_opts); |
| | | } |
| | | |
| | | update_data(); |
| | | } |
| | | else { |
| | | container.html(''); |
| | | } |
| | | |
| | | reset_search(); |
| | | } |
| | |
| | | var li, sli; |
| | | if (!node.virtual && !node.deleted && String(node.text).toLowerCase().indexOf(q) >= 0 && hits.indexOf(node.id) < 0) { |
| | | li = id2dom(node.id); |
| | | |
| | | // skip already filtered nodes |
| | | if (li.data('filtered')) |
| | | return; |
| | | |
| | | sli = $('<li>') |
| | | .attr('id', li.attr('id') + '--xsR') |
| | | .attr('class', li.attr('class')) |
| | | .addClass('searchresult__') |
| | | .append(li.children().first().clone(true, true)) |
| | | // append all elements like links and inputs, but not sub-trees |
| | | .append(li.children(':not(div.treetoggle,ul)').clone(true, true)) |
| | | .appendTo(container); |
| | | hits.push(node.id); |
| | | } |
| | |
| | | searchfield.val(''); |
| | | |
| | | $(container).children('li.searchresult__').remove(); |
| | | $(container).children('li').show(); |
| | | $(container).children('li').filter(function() { return !$(this).data('filtered'); }).show(); |
| | | |
| | | search_active = false; |
| | | |
| | |
| | | |
| | | if (selection) |
| | | select(selection); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | function is_search() |
| | | { |
| | | return search_active; |
| | | } |
| | | |
| | | /** |
| | |
| | | var target = e.target || {}, |
| | | keyCode = rcube_event.get_keycode(e); |
| | | |
| | | if (!has_focus || target.nodeName == 'INPUT' || target.nodeName == 'TEXTAREA' || target.nodeName == 'SELECT') |
| | | if (!has_focus || target.nodeName == 'INPUT' && keyCode != 38 && keyCode != 40 || target.nodeName == 'TEXTAREA' || target.nodeName == 'SELECT') |
| | | return true; |
| | | |
| | | switch (keyCode) { |
| | |
| | | return false; |
| | | |
| | | case 9: // Tab |
| | | if (p.keyboard) { |
| | | if (p.keyboard && p.tabexit) { |
| | | // jump to last/first item to move focus away from the treelist widget by tab |
| | | var limit = rcube_event.get_modifier(e) == SHIFT_KEY ? 'first' : 'last'; |
| | | focus_noscroll(container.find('li[role=treeitem]:has(a)')[limit]().find('a:'+limit)); |
| | |
| | | { |
| | | if (!opts) opts = {}; |
| | | |
| | | if ($.type(opts) == 'string') { |
| | | if (opts == 'destroy') { |
| | | ui_droppable = null; |
| | | } |
| | | $('li:not(.virtual)', container).droppable(opts); |
| | | return this; |
| | | } |
| | | |
| | | droppable_opts = opts; |
| | | |
| | | var my_opts = $.extend({ |
| | | greedy: true, |
| | | tolerance: 'pointer', |
| | |
| | | opts.over(e, ui); |
| | | }; |
| | | |
| | | $(selector ? selector : 'li:not(.virtual)', container).droppable(my_opts); |
| | | $('li:not(.virtual)', container).droppable(my_opts); |
| | | |
| | | return this; |
| | | } |
| | |
| | | { |
| | | if (!opts) opts = {}; |
| | | |
| | | if ($.type(opts) == 'string') { |
| | | if (opts == 'destroy') { |
| | | ui_draggable = null; |
| | | } |
| | | $('li:not(.virtual)', container).draggable(opts); |
| | | return this; |
| | | } |
| | | |
| | | draggable_opts = opts; |
| | | |
| | | var my_opts = $.extend({ |
| | | appendTo: 'body', |
| | | revert: 'invalid', |
| | | iframeFix: true, |
| | | addClasses: false, |
| | | cursorAt: {left: -20, top: 5}, |
| | | create: function(e, ui) { ui_draggable = ui; }, |
| | | helper: function(e) { |
| | | return $('<div>').attr('id', 'rcmdraglayer') |
| | | .text($.trim($(e.target).first().text())); |