aboutsummaryrefslogtreecommitdiff
path: root/data/stuff/test
diff options
context:
space:
mode:
Diffstat (limited to 'data/stuff/test')
-rw-r--r--data/stuff/test/tab-posts.js133
1 files changed, 30 insertions, 103 deletions
diff --git a/data/stuff/test/tab-posts.js b/data/stuff/test/tab-posts.js
index b9692a5..90c26de 100644
--- a/data/stuff/test/tab-posts.js
+++ b/data/stuff/test/tab-posts.js
@@ -38,114 +38,41 @@ jQuery(function($) {
],
});
-
- 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);
+ $.each(['blog', 'page', 'project'], function(i, id) {
+ var p = '#' + id + '-edit-';
+
+ $(p + 'dialog').one('shown.bs.modal', function() {
+ // lazy-init editor
+ CKEDITOR.replace(id + '-edit-body');
+ }).on('show.bs.modal', function() {
+ // reset close confirmation
+ $(this).data('close-dialog-confirmed', false);
+
+ // TODO load post
+ $(p + 'name').val('');
+ $(p + 'slug').val('');
+ }).on('shown.bs.modal', function() {
+ $(p + 'name').focus();
+ }).on('hide.bs.modal', function() {
+ return (
+ $(this).data('close-dialog-confirmed') ||
+ confirm('Close without saving changes?')
+ );
+ }).find('button[data-dismiss="modal"]').click(function() {
+ // override close confirmation
+ // FIXME: should this only be on save?
+ $(p + 'dialog').data('close-dialog-confirmed', true);
});
-
- 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();
+ $(p + 'confirm').click(function() {
+ if ($(this).hasClass('disabled'))
return false;
- }
- });
- // stop event
- return false;
- });
+ // TODO: see #user-add-confirm
+ alert('TODO: create');
- $('#post-new-confirm').click(function() {
- if (me.hasClass('disabled'))
+ // stop event
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');
+ });
});
});