mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Merge pull request #326 from matthojo/admin-temp-removal
Removed `admin-ui-temp.js` and moved code to it's relative places
This commit is contained in:
commit
09cd68e43c
@ -1,109 +0,0 @@
|
||||
// # Temporary Admin UI
|
||||
|
||||
/*global window, document, _, $ */
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
// UTILS
|
||||
|
||||
/**
|
||||
* Allows to check contents of each element exactly
|
||||
* @param obj
|
||||
* @param index
|
||||
* @param meta
|
||||
* @param stack
|
||||
* @returns {boolean}
|
||||
*/
|
||||
$.expr[":"].containsExact = function (obj, index, meta, stack) {
|
||||
return (obj.textContent || obj.innerText || $(obj).text() || "") === meta[3];
|
||||
};
|
||||
|
||||
var positionCenter = _.debounce(function (e) {
|
||||
|
||||
var loginContainer = $(".js-login-container"),
|
||||
marginTop = Math.floor((loginContainer.parent().height() - loginContainer.height()) / 2) - 15;
|
||||
loginContainer.animate({'margin-top': marginTop}, 200);
|
||||
$(window).trigger('centered');
|
||||
|
||||
}, 100); // Maximum run of once per 100 milliseconds
|
||||
|
||||
function fadeInAndFocus() {
|
||||
$(".js-login-container").fadeIn(750, function () {
|
||||
$("[name='email']").focus();
|
||||
});
|
||||
}
|
||||
|
||||
$(window).on('resize', positionCenter);
|
||||
$(window).one('centered', fadeInAndFocus);
|
||||
|
||||
// Allow notifications to be dismissed
|
||||
$(document).on('click', '.js-notification.notification-passive .close', function () {
|
||||
$(this).parent().fadeOut(200, function () { $(this).remove(); });
|
||||
});
|
||||
|
||||
$(document).on('click', '.js-notification.notification-persistent .close', function () {
|
||||
var self = this;
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: '/api/v0.1/notifications/' + $(this).data('id')
|
||||
}).done(function (result) {
|
||||
if ($(self).parent().parent().hasClass('js-bb-notification')) {
|
||||
$(self).parent().parent().fadeOut(200, function () { $(self).remove(); });
|
||||
} else {
|
||||
$(self).parent().fadeOut(200, function () { $(self).remove(); });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Example of how to add a persistent notification.
|
||||
*/
|
||||
// $(document).on('click', '.add-persistent-notification', function (event) {
|
||||
// event.preventDefault();
|
||||
// var msg = {
|
||||
// type: 'error',
|
||||
// message: 'This is an error',
|
||||
// status: 'persistent',
|
||||
// id: 'per-' + $('.notification-persistent').length + 1
|
||||
// };
|
||||
|
||||
// $.ajax({
|
||||
// type: "POST",
|
||||
// url: '/api/v0.1/notifications/',
|
||||
// data: msg
|
||||
// }).done(function (result) {
|
||||
// var fcv;
|
||||
// fcv = new Ghost.Views.FlashCollectionView({
|
||||
// model: [msg]
|
||||
// });
|
||||
// console.log(fcv);
|
||||
// });
|
||||
// });
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// LOGIN SCREEN
|
||||
$(window).trigger('resize');
|
||||
|
||||
|
||||
// EDITOR / NOTIFICATIONS
|
||||
|
||||
$('.entry-content header, .entry-preview header').on('click', function () {
|
||||
$('.entry-content, .entry-preview').removeClass('active');
|
||||
$(this).closest('section').addClass('active');
|
||||
});
|
||||
|
||||
$('.entry-title .icon-fullscreen').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$('body').toggleClass('fullscreen');
|
||||
});
|
||||
|
||||
$('.options.up').on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
$(this).next("ul").fadeToggle(200);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}());
|
2
ghost/admin/assets/lib/jquery-utils.js
vendored
2
ghost/admin/assets/lib/jquery-utils.js
vendored
@ -33,7 +33,7 @@
|
||||
'margin-left': -this.outerWidth() / 2 + 'px',
|
||||
'margin-top': -this.outerHeight() / 2 + 'px'
|
||||
});
|
||||
|
||||
$(window).trigger('centered');
|
||||
return this;
|
||||
};
|
||||
|
||||
|
@ -90,6 +90,10 @@
|
||||
Ghost.Views.Notification = Ghost.View.extend({
|
||||
templateName: 'notification',
|
||||
className: 'js-bb-notification',
|
||||
events: {
|
||||
'click .js-notification.notification-passive .close': 'closePassive',
|
||||
'click .js-notification.notification-persistent .close': 'closePersistent'
|
||||
},
|
||||
template: function (data) {
|
||||
return JST[this.templateName](data);
|
||||
},
|
||||
@ -97,8 +101,25 @@
|
||||
var html = this.template(this.model);
|
||||
this.$el.html(html);
|
||||
return this;
|
||||
},
|
||||
closePassive: function (e) {
|
||||
$(e.currentTarget).parent().fadeOut(200, function () { $(this).remove(); });
|
||||
},
|
||||
closePersistent: function (e) {
|
||||
var self = e.currentTarget;
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: '/api/v0.1/notifications/' + $(this).data('id')
|
||||
}).done(function (result) {
|
||||
if ($(self).parent().parent().hasClass('js-bb-notification')) {
|
||||
$(self).parent().parent().fadeOut(200, function () { $(self).remove(); });
|
||||
} else {
|
||||
$(self).parent().fadeOut(200, function () { $(self).remove(); });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* This handles Notification groups
|
||||
|
@ -228,6 +228,21 @@
|
||||
this.initMarkdown();
|
||||
this.renderPreview();
|
||||
|
||||
$('.entry-content header, .entry-preview header').on('click', function () {
|
||||
$('.entry-content, .entry-preview').removeClass('active');
|
||||
$(this).closest('section').addClass('active');
|
||||
});
|
||||
|
||||
$('.entry-title .icon-fullscreen').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$('body').toggleClass('fullscreen');
|
||||
});
|
||||
|
||||
$('.options.up').on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
$(this).next("ul").fadeToggle(200);
|
||||
});
|
||||
|
||||
this.$('.CodeMirror-scroll').on('scroll', this.syncScroll);
|
||||
|
||||
// Shadow on Markdown if scrolled
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
initialize: function (options) {
|
||||
this.render();
|
||||
$(window).trigger('resize');
|
||||
},
|
||||
|
||||
template: function (data) {
|
||||
@ -19,7 +20,14 @@
|
||||
},
|
||||
|
||||
render: function () {
|
||||
var self = this;
|
||||
this.$el.html(this.template());
|
||||
|
||||
$(window).on('resize', _.debounce(function (e) {
|
||||
$(".js-login-container").center();
|
||||
}, 100));
|
||||
|
||||
$(window).one('centered', self.fadeInAndFocus);
|
||||
return this;
|
||||
},
|
||||
|
||||
@ -49,6 +57,12 @@
|
||||
}));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
fadeInAndFocus: function () {
|
||||
$(".js-login-container").fadeIn(750, function () {
|
||||
$("[name='email']").focus();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user