0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

Merge pull request #4469 from PaulAdamDavis/permalink-improvs

Improvements to the permalinks UI
This commit is contained in:
Hannah Wolfe 2014-11-19 20:46:32 +00:00
commit 0c38a839b0
2 changed files with 83 additions and 40 deletions

View file

@ -338,12 +338,14 @@
// Custom permalink //
// Custom Permalinks
// --------------------------------------------------
.permalink-input-wrapper { .permalink-input-wrapper {
position: relative; position: relative;
outline: 0; // Kills the blue outline we get by adding tabindex="0" outline: 0; // Kills the blue outline we get by adding tabindex="0"
padding-top: 6px; padding: 2px 0 2px 6px;
padding-bottom: 6px;
&:focus, &:focus,
&.focus { &.focus {
@ -359,42 +361,46 @@
.permalink-fake-input { .permalink-fake-input {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
margin-right: 26px; align-items: center;
margin-right: 40px;
} }
.permalink-domain { .permalink-domain {
padding-right: 3px; margin: 5px -1px 3px 0;
color: #7E878B; color: #7E878B;
} }
// A collection of labels showing the URL structure
.permalink-structure {
.permalink-parameter { .permalink-parameter {
position: relative; position: relative;
top: -2px; padding: 3px 6px 4px;
margin-left: 6px; margin: 4px 0 4px 9px;
max-height: 18px;
// The slash before each parameter // Change default label styles
&:before { background: #E3EDF2;
box-shadow: inset 0px 0px 0px 1px #CDD5D9;
color: #7E878B;
// The slash before each parameter (using :after)
// Using `:before` does funky stuff here in Safari
&:after {
content: "/"; content: "/";
position: absolute; position: absolute;
top: 4px; top: 2px;
left: -8px; left: -7px;
font-size: 1.4rem; font-size: 1.4rem;
color: #7E878B; color: #7E878B;
} }
} }
}
// The actual input, which resets some styles inherited from the global input style // The actual input, which resets some styles inherited from the global input style
.permalink-input { .permalink-input {
flex: 1 0; flex: 1 0;
margin: -6px 0 -6px -2px; margin: 0;
padding: 0 4px; padding: 0 4px;
margin-right: -4px;
background: transparent; background: transparent;
min-width: 60px; min-width: 60px;
min-height: 30px;
border: 0; border: 0;
} }
@ -426,5 +432,6 @@
// Shift the popover (than opens over the top of everything) to the left a bit // Shift the popover (than opens over the top of everything) to the left a bit
.popover-item { .popover-item {
margin-left: -5px; margin-left: -5px;
min-width: 320px;
} }
}//.permalink-input-wrapper }//.permalink-input-wrapper

View file

@ -128,13 +128,16 @@
<div class="permalink-fake-input"> <div class="permalink-fake-input">
<span class="permalink-domain">http://myblog.ghost.io</span> <span class="permalink-domain">http://myblog.ghost.io</span>
<span class="permalink-structure">
<span class="permalink-parameter label label-default">journal</span> <span class="permalink-parameter label label-default">journal</span>
<span class="permalink-parameter label label-default">year</span> <span class="permalink-parameter label label-default">year</span>
<span class="permalink-parameter label label-default">month</span> <span class="permalink-parameter label label-default">hello</span>
<span class="permalink-parameter label label-default">day</span> <span class="permalink-parameter label label-default">agaian</span>
<span class="permalink-parameter label label-default">title</span> <span class="permalink-parameter label label-default">this</span>
</span> <span class="permalink-parameter label label-default">is</span>
<span class="permalink-parameter label label-default">nice</span>
<span class="permalink-parameter label label-default">yo</span>
<span class="permalink-parameter label label-default">yo</span>
<span class="permalink-parameter label label-default">yo</span>
<input id="blog-permalinks" class="permalink-input" type="text" name="general[permalinks]"> <input id="blog-permalinks" class="permalink-input" type="text" name="general[permalinks]">
</div> </div>
@ -191,24 +194,57 @@
<script> <script>
$(function(){ $(function(){
$("#blog-permalinks").on("focus", function(){ $('.permalink-input-wrapper').on('click', function(){
$(".permalink-input-wrapper").addClass("focus"); $(this).addClass('focus');
$("#blog-permalinks").focus(); $('#blog-permalinks').focus();
});
$("#blog-permalinks").on("blur", function(){
$(".permalink-input-wrapper").removeClass("focus");
}); });
$(".hover-me").hover(function(){ $('#blog-permalinks').on('blur', function(){
$(this).next(".popover-item").addClass("open fade-in").removeClass("closed fade-out"); $('.permalink-input-wrapper').removeClass('focus');
});
$('.hover-me').hover(function(){
$(this).next('.popover-item').addClass('open fade-in').removeClass('closed fade-out');
}, function(){ }, function(){
$(this).next(".popover-item").removeClass("fade-in").addClass("fade-out"); $(this).next('.popover-item').removeClass('fade-in').addClass('fade-out');
$(this).next(".popover-item").on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', function (event) { $(this).next('.popover-item').on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', function (event) {
if (event.originalEvent.animationName === 'fade-out') { if (event.originalEvent.animationName === 'fade-out') {
$(this).removeClass("open fade-out").addClass("closed"); $(this).removeClass('open fade-out').addClass('closed');
} }
}); });
}); });
function convertToSlug(Text){
return Text.toLowerCase().replace(/[^\w ]+/g,'').replace(/ +/g,'-').trim();
}
$('#blog-permalinks').on('keyup', function(e){
// 188 = comma
// Append the new parameter when pressing comma
if (e.keyCode === 188) {
var input_val = convertToSlug($(this).val());
var the_param = '<span class="permalink-parameter label label-default">' + input_val + '</span>';
// If a parameter exists, append after it.
// Else append after the domain
if ($('.permalink-parameter').length) {
$('.permalink-parameter:last').after(the_param);
} else {
$('.permalink-domain').after(the_param);
}
$(this).val('');
}
// 8 = backspace
// When backspace is pressed AND the input is empty, delete the last parameter
if (e.keyCode === 8 && $(this).val() == '') {
$('.permalink-parameter:last').remove();
}
});
}); });
</script> </script>