mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Improved modal creation, now includes info and action types.
This commit is contained in:
parent
3057945b70
commit
b089e67154
5 changed files with 97 additions and 15 deletions
|
@ -109,8 +109,12 @@
|
|||
}
|
||||
|
||||
.markdown-help {
|
||||
position: relative;
|
||||
top: -5px;
|
||||
right: -5px;
|
||||
@include icon($i-question, '', lighten($brown, 15%));
|
||||
float:right;
|
||||
padding: 5px;
|
||||
|
||||
&:hover {
|
||||
@include icon($i-question, '', $brown)
|
||||
|
|
|
@ -899,11 +899,21 @@ nav {
|
|||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1000;
|
||||
z-index: 999;
|
||||
|
||||
&.dark {
|
||||
background: rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.modal-background {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -921,12 +931,21 @@ body.blur > *:not(#modal-container) {
|
|||
border: 6px solid rgba(0,0,0,0.5);
|
||||
border-radius: $rounded;
|
||||
overflow:auto;
|
||||
z-index: 1001;
|
||||
|
||||
&.fadeIn {
|
||||
@include animation(fadeIn 0.3s linear 1);
|
||||
}
|
||||
}
|
||||
|
||||
.modal-info {
|
||||
@extend %modal;
|
||||
}
|
||||
|
||||
.modal-action {
|
||||
@extend %modal;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
position: relative;
|
||||
padding: 20px;
|
||||
|
@ -964,6 +983,17 @@ body.blur > *:not(#modal-container) {
|
|||
padding: 20px;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
padding: 20px;
|
||||
padding-top: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.modal-style-wide {
|
||||
@extend %modal;
|
||||
width: 550px;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Main Elements
|
||||
========================================================================== */
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
<article class="modal{{#if type}}-{{type}}{{/if}} {{animation}} js-modal">
|
||||
<header class="modal-header"><h1>{{title}}</h1><a class="close" href="#"><span class="hidden">Close</span></a></header>
|
||||
<aside class="modal-background"></aside>
|
||||
<article class="modal{{#if options.type}}-{{options.type}}{{/if}} {{#if options.style}}modal-style-{{options.style}}{{/if}} {{options.animation}} js-modal">
|
||||
<header class="modal-header"><h1>{{content.title}}</h1>{{#if options.close}}<a class="close" href="#"><span class="hidden">Close</span></a>{{/if}}</header>
|
||||
<section class="modal-content">
|
||||
</section>
|
||||
{{#if options.confirm}}
|
||||
<footer class="modal-footer">
|
||||
<button class="button-add js-button-accept">{{options.confirm.accept.text}}</button>
|
||||
<button class="button-delete js-button-reject">{{options.confirm.reject.text}}</button>
|
||||
</footer>
|
||||
{{/if}}
|
||||
</article>
|
|
@ -1,4 +1,4 @@
|
|||
/*global window, document, Ghost, $, _, Backbone, JST */
|
||||
/*global window, document, Ghost, $, _, Backbone, JST, shortcut */
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
|
@ -145,12 +145,33 @@
|
|||
className: 'js-bb-modal',
|
||||
initialize: function () {
|
||||
this.render();
|
||||
var self = this;
|
||||
if (!this.model.options.confirm) {
|
||||
shortcut.add("ESC", function () {
|
||||
self.removeItem();
|
||||
});
|
||||
$(document).on('click', '.modal-background', function (e) {
|
||||
self.removeItem(e);
|
||||
});
|
||||
} else {
|
||||
// Initiate functions for buttons here so models don't get tied up.
|
||||
this.acceptModal = function () {
|
||||
this.model.options.confirm.accept.func();
|
||||
};
|
||||
this.rejectModal = function () {
|
||||
this.model.options.confirm.reject.func();
|
||||
};
|
||||
shortcut.remove("ESC");
|
||||
$(document).off('click', '.modal-background');
|
||||
}
|
||||
},
|
||||
template: function (data) {
|
||||
return JST[this.templateName](data);
|
||||
},
|
||||
events: {
|
||||
'click .close': 'removeItem'
|
||||
'click .close': 'removeItem',
|
||||
'click .js-button-accept': 'acceptModal',
|
||||
'click .js-button-reject': 'rejectModal'
|
||||
},
|
||||
render: function () {
|
||||
this.$el.html(this.template(this.model));
|
||||
|
@ -164,15 +185,25 @@
|
|||
}
|
||||
return this;
|
||||
},
|
||||
remove: function () {
|
||||
this.undelegateEvents();
|
||||
this.$el.empty();
|
||||
this.stopListening();
|
||||
return this;
|
||||
},
|
||||
removeItem: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
$(e.currentTarget).closest('.js-modal').fadeOut(300, function () {
|
||||
e.stopPropagation();
|
||||
}
|
||||
$('.js-modal').fadeOut(300, function () {
|
||||
$(this).remove();
|
||||
$("#modal-container").removeClass('active dark');
|
||||
if (document.body.style.filter !== undefined) {
|
||||
$("body").removeClass("blur");
|
||||
}
|
||||
});
|
||||
this.remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -283,11 +283,16 @@
|
|||
showHelp: function () {
|
||||
this.addSubview(new Ghost.Views.Modal({
|
||||
model: {
|
||||
title: 'Markdown Help',
|
||||
content: {
|
||||
template: 'markdown'
|
||||
},
|
||||
options: {
|
||||
close: true,
|
||||
type: "info",
|
||||
style: "wide",
|
||||
animation: 'fadeIn'
|
||||
},
|
||||
content: {
|
||||
template: 'markdown',
|
||||
title: 'Markdown Help'
|
||||
}
|
||||
}
|
||||
}));
|
||||
},
|
||||
|
@ -340,11 +345,16 @@
|
|||
showHTML: function () {
|
||||
this.addSubview(new Ghost.Views.Modal({
|
||||
model: {
|
||||
title: 'Copied HTML',
|
||||
content: {
|
||||
template: 'copyToHTML'
|
||||
},
|
||||
options: {
|
||||
close: true,
|
||||
type: "info",
|
||||
style: "wide",
|
||||
animation: 'fadeIn'
|
||||
},
|
||||
content: {
|
||||
template: 'copyToHTML',
|
||||
title: 'Copied HTML'
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue