From 689ee9c7ea48c2e3de8790dcaae4500207567508 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 3 Apr 2016 03:56:46 -0400 Subject: add ckeditor --- data/stuff/test/tab-posts.js | 151 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 data/stuff/test/tab-posts.js (limited to 'data/stuff/test') diff --git a/data/stuff/test/tab-posts.js b/data/stuff/test/tab-posts.js new file mode 100644 index 0000000..b9692a5 --- /dev/null +++ b/data/stuff/test/tab-posts.js @@ -0,0 +1,151 @@ +jQuery(function($) { + "use strict"; + + var TEMPLATES = new LuigiTemplate.Cache({ + user: [ + "", + "", + "", + " ", + "%{user_name|h} (%{email|h})", + + "", + "%{role_name|h}", + "", + "", + ], + + loading: [ + "", + "", + " ", + "Loading...", + "", + ], + + error: [ + "", + "", + " ", + "Error: %{responseText|h}", + "", + ], + }); + + + var POST_TYPES = { + type: { + last: false, + name: "Type", + }, + + blog: { + last: true, + name: "Blog Post", + + cbs: { + show: function() { + $('#post-new-blog-name').val(''); + $('#post-new-blog-slug').val(''); + $('#post-new-blog-body').val(''); + }, + + shown: function() { + $('#post-new-blog-name').focus(); + }, + }, + }, + + page: { + last: true, + name: "Page", + }, + + project: { + last: true, + name: "Project", + }, + }; + + $('#post-new-dialog').on('show.bs.modal', function() { + $('#post-new-type-blog').click(); + + $('#post-new-tab-type').parent().removeClass('active') + $('#post-new-tab-type').click(); + }); + + $.each(POST_TYPES, function(id, data) { + $('#post-new-tab-' + id).on('show.bs.tab', function() { + // update buttons + $('#post-new-back').toggleClass('disabled', !data.last); + $('#post-new-next').toggleClass('hidden', data.last); + $('#post-new-confirm').toggleClass('hidden', !data.last) + .find('span.name').text(data.name); + }); + + if (data.cbs) { + // add event handlers + $.each(data.cbs, function(ev_id, fn) { + $('#post-new-tab-' + id).on(ev_id + '.bs.tab', fn); + }); + } + }); + + $('#post-new-back').click(function() { + $('#post-new-tab-type').click(); + + // stop event + return false; + }); + + $('#post-new-next').click(function() { + $.each(POST_TYPES, function(id, data) { + if ($('#post-new-type-' + id).is(':checked')) { + // select tab + $('#post-new-tab-' + id).click(); + + return false; + } + }); + + // stop event + return false; + }); + + $('#post-new-confirm').click(function() { + if (me.hasClass('disabled')) + return false; + + // TODO: see #user-add-confirm + alert('TODO: create'); + + // stop event + return false; + }); + + $('#post-new-tab-pane-type label').dblclick(function() { + $(this).find('input[type="radio"]').prop('checked', true); + $('#post-new-next').click(); + + // stop event + return false; + }); + + $('#post-new-tab-blog').one('shown.bs.tab', function() { + // lazy-init editor + console.log('initializing editor'); +/* + * tinymce.init({ + * selector: '#post-new-blog-body', + * plugins: 'fullscreen', + * }); + */ + CKEDITOR.replace('post-new-blog-body'); + }); +}); -- cgit v1.2.3