diff --git a/plugins/tasklist/skins/larry/print.css b/plugins/tasklist/skins/larry/print.css new file mode 100644 index 00000000..3117a2b2 --- /dev/null +++ b/plugins/tasklist/skins/larry/print.css @@ -0,0 +1,94 @@ +/*** Printing styles for Tasklist plugin ***/ + +body { + margin: 0; + color: #000; + background: #fff; +} + +body, td, th, div, p, h3, select, input, textarea { + font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; + font-size: 8pt; +} + +#tasks { + position: relative; + top: 0; + left: 0; + height: auto; + margin: 5em auto 0 auto; + overflow: visible; +} + +#printconfig { + position: fixed; + top: 0; + left: 0; + width: 100%; + z-index: 10000; + padding: 0.5em; + background: #ebebeb; + border-bottom: 1px solid #999; + box-shadow: 0 3px 4px #ccc; + -moz-box-shadow: 0 3px 4px #ccc; + -webkit-box-shadow: 0 3px 4px #ccc; +} + +#printconfig .prop { + padding-right: 2em; +} + +#message { + position: absolute; + top: 5.5em; + left: 1em; +} + +#message div.loading { + color: #666; + font-style: italic; +} + +#tasklist { + margin: 0; + padding: 0 10px; +} + +.pagewidth { + width: 700px; + margin: 0 auto; +} + +.rightalign { + float: right; + padding-top: 0.3em; +} + +@media print { + .noprint, + .fc-header-right span { + display: none; + } + + #tasks { + margin-top: 0; + } +} + +#tasklist .description { + display: block; + white-space: pre; +} + +#tasklist .title { + font-weight: bold; +} + +.taskhead { + border-radius: 0; + border: 0; + border-bottom: 1px solid #bbb; + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} diff --git a/plugins/tasklist/skins/larry/templates/print.html b/plugins/tasklist/skins/larry/templates/print.html new file mode 100644 index 00000000..c9620fa6 --- /dev/null +++ b/plugins/tasklist/skins/larry/templates/print.html @@ -0,0 +1,23 @@ + + + +<roundcube:object name="pagetitle" /> + + + +
+
+ + + +
+
+ + + +
+ +
+ + + diff --git a/plugins/tasklist/tasklist.js b/plugins/tasklist/tasklist.js index 34cd97c0..9d92f25d 100644 --- a/plugins/tasklist/tasklist.js +++ b/plugins/tasklist/tasklist.js @@ -112,6 +112,7 @@ function rcube_tasklist_ui(settings) /* public methods */ this.init = init; this.edit_task = task_edit_dialog; + this.print_tasks = print_tasks; this.delete_task = delete_task; this.add_childtask = add_childtask; this.quicksearch = quicksearch; @@ -136,6 +137,11 @@ function rcube_tasklist_ui(settings) */ function init() { + if (rcmail.env.action == 'print' && rcmail.task == 'tasks') { + data_ready({data: rcmail.env.tasks}); + return; + } + // initialize task list selectors for (var id in me.tasklists) { if (settings.selected_list && me.tasklists[settings.selected_list] && !me.tasklists[settings.selected_list].active) { @@ -846,6 +852,11 @@ function rcube_tasklist_ui(settings) id = listindex[i]; rec = listdata[id]; if (match_filter(rec, cache)) { + if (rcmail.env.action == 'print') { + render_task_printmode(rec); + continue; + } + render_task(rec); count++; @@ -859,6 +870,9 @@ function rcube_tasklist_ui(settings) } } + if (rcmail.env.action == 'print') + return; + fix_tree_toggles(); update_tagcloud(activetags); @@ -1314,6 +1328,37 @@ function rcube_tasklist_ui(settings) } } + /** + * Render the given task into the tasks list (in print mode) + */ + function render_task_printmode(rec) + { + var label_id = rcmail.html_identifier(rec.id) + '-title', + div = $('
').addClass('taskhead') + .append($('').attr('id', label_id).text(rec.title)), + parent = rec.parent_id ? $('li[rel="'+rec.parent_id+'"] > ul.childtasks', rcmail.gui_objects.resultlist) : null, + li = $('
  • ').attr('rel', rec.id).addClass('taskitem') + .append(div) + .append('
      '); + + if (rec.description) + div.append($('').text(rec.description)); +/* + if (is_complete(rec)) + div.addClass('complete'); + if (rec.flagged) + div.addClass('flagged'); + if (!rec.date) + div.addClass('nodate'); + if (rec.mask & FILTER_MASK_OVERDUE) + div.addClass('overdue'); +*/ + if (!parent || !parent.length) + li.appendTo(rcmail.gui_objects.resultlist); + else + li.appendTo(parent); + } + /** * Move the given task item to the right place in the list */ @@ -2835,6 +2880,18 @@ function rcube_tasklist_ui(settings) } + // method to show the print dialog. + function print_tasks() + { + var param = {}, active = active_lists(); + + if (active.length) { + param = {filter: filtermask, lists: active.join(','), q: search_query}; + rcmail.open_window(rcmail.url('print', param), true, true); + } + }; + + /**** Utility functions ****/ // same as str.split(delimiter) but it ignores delimiters within quoted strings @@ -3010,7 +3067,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) { // register button commands rcmail.register_command('newtask', function(){ rctasks.edit_task(null, 'new', {}); }, true); - //rcmail.register_command('print', function(){ rctasks.print_list(); }, true); + rcmail.register_command('print', function(){ rctasks.print_tasks(); }, true); rcmail.register_command('list-create', function(){ rctasks.list_edit_dialog(null); }, true); rcmail.register_command('list-edit', function(){ rctasks.list_edit_dialog(rctasks.selected_list); }, false); diff --git a/plugins/tasklist/tasklist.php b/plugins/tasklist/tasklist.php index b2607142..06fad645 100644 --- a/plugins/tasklist/tasklist.php +++ b/plugins/tasklist/tasklist.php @@ -112,6 +112,7 @@ class tasklist extends rcube_plugin $this->register_action('tasklist', array($this, 'tasklist_action')); $this->register_action('counts', array($this, 'fetch_counts')); $this->register_action('fetch', array($this, 'fetch_tasks')); + $this->register_action('print', array($this, 'print_tasks')); $this->register_action('inlineui', array($this, 'get_inline_ui')); $this->register_action('mail2task', array($this, 'mail_message2task')); $this->register_action('get-attachment', array($this, 'attachment_get')); @@ -1009,6 +1010,44 @@ class tasklist extends rcube_plugin )); } + /** + * Handler for printing calendars + */ + public function print_tasks() + { + // Add CSS stylesheets to the page header + $skin_path = $this->local_skin_path(); + + $this->include_stylesheet($skin_path . '/print.css'); + $this->include_script('tasklist.js'); + + $this->rc->output->add_handlers(array( + 'plugin.tasklist_print' => array($this, 'print_tasks_list'), + )); + + $this->rc->output->set_pagetitle($this->gettext('print')); + $this->rc->output->send('tasklist.print'); + } + + /** + * Handler for printing calendars + */ + public function print_tasks_list($attrib) + { + $f = intval(rcube_utils::get_input_value('filter', rcube_utils::INPUT_GPC)); + $search = rcube_utils::get_input_value('q', rcube_utils::INPUT_GPC); + $lists = rcube_utils::get_input_value('lists', rcube_utils::INPUT_GPC); + $filter = array('mask' => $f, 'search' => $search); + + $data = $this->tasks_data($this->driver->list_tasks($filter, $lists), $f); + + // we'll build the tasks table in javascript on page load + // where we have sorting methods, etc. + $this->rc->output->set_env('tasks', $data); + + return $this->ui->tasks_resultview($attrib); + } + /** * Prepare and sort the given task records to be sent to the client */