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 onReady = function () { var todo = Todo.init(APP.lm.proxy, Cryptpad); var deleteTask = function(id) { todo.remove(id); 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? 'fa-check-square-o': 'fa-square-o'; return $('', { 'class': 'cp-task-checkbox fa ' + checked, }).on('click', function () { entry.state = (entry.state + 1) % 2; if (typeof(cb) === 'function') { cb(entry.state); } }); }; var display = APP.display = function () { var $list = $iframe.find('#tasksList'); $list.empty(); APP.lm.proxy.order.forEach(function(el) { var $taskDiv = $('
', { 'class': 'cp-task' }).appendTo($list); makeCheckbox(el, function (state) { display(); }).appendTo($taskDiv); var entry = APP.lm.proxy.data[el]; $('', { 'class': 'cp-task-text' }) .text(entry.task) .appendTo($taskDiv); $('', { 'class': 'cp-task-date' }) .text(new Date(entry.ctime).toLocaleString()) .appendTo($taskDiv); $('