define([ 'jquery', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/chainpad-listmap/chainpad-listmap.js', '/common/toolbar2.js', '/common/cryptpad-common.js', '/todo/todo.js', //'/common/media-tag.js', //'/bower_components/file-saver/FileSaver.min.js', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'less!/customize/src/less/cryptpad.less', ], function ($, Crypto, Listmap, Toolbar, Cryptpad, Todo) { var Messages = Cryptpad.Messages; var APP = window.APP = {}; $(function () { var $iframe = $('#pad-iframe').contents(); var $body = $iframe.find('body'); var ifrw = $('#pad-iframe')[0].contentWindow; var $list = $iframe.find('#tasksList'); var removeTips = function () { $('.tippy-popper').remove(); }; var onReady = function () { var todo = Todo.init(APP.lm.proxy, Cryptpad); var deleteTask = function(id) { todo.remove(id); var $els = $list.find('.cp-task').filter(function (i, el) { return $(el).data('id') === id; }); $els.fadeOut(null, function () { $els.remove(); removeTips(); }); //APP.display(); }; // TODO make this actually work, and scroll to bottom... var scrollTo = function (t) { var $list = $iframe.find('#tasksList'); $list.animate({ scrollTop: t, }); }; scrollTo = scrollTo; var makeCheckbox = function (id, cb) { var entry = APP.lm.proxy.data[id]; var checked = entry.state === 1? 'cp-task-checkbox-checked fa-check-square-o': 'cp-task-checkbox-unchecked fa-square-o'; var title = entry.state === 1? Messages.todo_markAsIncompleteTitle: Messages.todo_markAsCompleteTitle; title = title; removeTips(); return $('', { 'class': 'cp-task-checkbox fa ' + checked, //title: title, }).on('click', function () { entry.state = (entry.state + 1) % 2; if (typeof(cb) === 'function') { cb(entry.state); } }); }; var addTaskUI = function (el, animate) { var $taskDiv = $('
', { 'class': 'cp-task' }); if (animate) { $taskDiv.prependTo($list); } else { $taskDiv.appendTo($list); } $taskDiv.data('id', el); makeCheckbox(el, function (/*state*/) { APP.display(); }) .appendTo($taskDiv); var entry = APP.lm.proxy.data[el]; if (entry.state) { $taskDiv.addClass('cp-task-complete'); } $('', { 'class': 'cp-task-text' }) .text(entry.task) .appendTo($taskDiv); /*$('', { 'class': 'cp-task-date' }) .text(new Date(entry.ctime).toLocaleString()) .appendTo($taskDiv);*/ $('