jQuery(function($) {
"use strict";
var TEMPLATES = new LuigiTemplate.Cache({
user: [
"",
"",
"",
" ",
"%{user_name|h} (%{email|h})",
"",
"%{role_name|h}",
"",
"",
],
loading: [
"",
"",
" ",
"Loading...",
"",
],
error: [
"",
"",
" ",
"Error: %{responseText|h}",
"",
],
});
$.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);
});
$(p + 'confirm').click(function() {
if ($(this).hasClass('disabled'))
return false;
// TODO: see #user-add-confirm
alert('TODO: create');
// stop event
return false;
});
});
});