FEATURE: add lock to URL
This commit is contained in:
@@ -3,15 +3,15 @@
|
||||
<label>
|
||||
@lang('admin/contents.field_title')
|
||||
|
||||
<input type="text" name="title" placeholder="@lang('admin/contents.field_title')"
|
||||
<input type="text" name="title" class="slug-source" placeholder="@lang('admin/contents.field_title')"
|
||||
value="{{old('title', $page->title)}}" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="columns large-6">
|
||||
<div class="columns large-4">
|
||||
<label>
|
||||
@lang('admin/contents.field_url')
|
||||
|
||||
<input type="text" name="url" placeholder="@lang('admin/contents.field_url')"
|
||||
<input type="text" name="url" class="slug-target" placeholder="@lang('admin/contents.field_url')"
|
||||
value="{{old('url', $page->url)}}" />
|
||||
|
||||
@if (isset($errors) && $errors->has('url'))
|
||||
@@ -21,6 +21,13 @@
|
||||
@endif
|
||||
</label>
|
||||
</div>
|
||||
<div class="column large-2 text-center">
|
||||
<label>
|
||||
@lang('admin/contents.lockUrl')<br />
|
||||
|
||||
<input type="checkbox" value="1" id="lockUrl" @if(old('lockUrl') || ($page->id > 0 && \Illuminate\Support\Str::slug($page->title) != $page->url)) checked @endif name="lockUrl" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
@@ -1,6 +1,40 @@
|
||||
// initialize Foundation
|
||||
$ (document).foundation ();
|
||||
|
||||
/**
|
||||
* Makes slug from input string
|
||||
*
|
||||
* @param text
|
||||
* @param trimSpaces
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
function slugify(text, trimSpaces) {
|
||||
text = text.toString ().toLowerCase ();
|
||||
|
||||
if (trimSpaces)
|
||||
text = text.trim ();
|
||||
|
||||
return text.replace (/ /g, '-')
|
||||
.replace (/[àáâãäå]/g, "a")
|
||||
.replace (/[čç]/g, "c")
|
||||
.replace (/[ěèéêë]/g, "e")
|
||||
.replace (/[ùúûüů]/g, "u")
|
||||
.replace (/[ìíîï]/g, "i")
|
||||
.replace (/[ňńñ]/g, "n")
|
||||
.replace (/[òóôõö]/g, "o")
|
||||
.replace (/[ýÿ]/g, "y")
|
||||
.replace (/œ/g, "oe")
|
||||
.replace (/ď/g, "d")
|
||||
.replace (/ř/g, "r")
|
||||
.replace (/š/g, "s")
|
||||
.replace (/ž/g, "z")
|
||||
.replace (/ť/g, "t")
|
||||
.replace (/æ/g, "ae")
|
||||
.replace (/[^a-z0-9\-]+/g, '')
|
||||
.replace (/\-\-+/g, '-');
|
||||
}
|
||||
|
||||
// bind some custom methods
|
||||
$ (document).ready (function () {
|
||||
$ ('.confirm').click (function () {
|
||||
@@ -11,8 +45,24 @@ $ (document).ready (function () {
|
||||
confirmMessage = 'Really?';
|
||||
}
|
||||
|
||||
var confirmation = confirm (confirmMessage);
|
||||
return confirm (confirmMessage);
|
||||
});
|
||||
|
||||
return confirmation;
|
||||
$('#lockUrl').change(function () {
|
||||
$ ('.slug-source').keyup ();
|
||||
});
|
||||
|
||||
$ ('.slug-target').keyup (function () {
|
||||
$ (this).val (slugify ($ (this).val (), false));
|
||||
$('#lockUrl').prop('checked', true);
|
||||
});
|
||||
|
||||
$ ('.slug-source').keyup (function () {
|
||||
var source = $ (this);
|
||||
var target = $ ('.slug-target');
|
||||
var locked = $ ('#lockUrl');
|
||||
|
||||
if (!locked.is (':checked'))
|
||||
target.val (slugify (source.val (), true));
|
||||
});
|
||||
});
|
||||
@@ -42,6 +42,6 @@ return [
|
||||
'noHomepage' => 'You have not set up your homepage yet, or your current homepage is draft! Try to select another one.',
|
||||
'homepageProtected' => 'Your homepage is displayed only for logged in users. This may or may not be an error.',
|
||||
'parentPage' => 'Parent page',
|
||||
'alreadyHomepage' => 'Homepage'
|
||||
|
||||
'alreadyHomepage' => 'Homepage',
|
||||
'lockUrl' => 'Keep URL'
|
||||
];
|
||||
@@ -3,15 +3,15 @@
|
||||
<label>
|
||||
@lang('admin/contents.field_title')
|
||||
|
||||
<input type="text" name="title" placeholder="@lang('admin/contents.field_title')"
|
||||
<input type="text" name="title" class="slug-source" placeholder="@lang('admin/contents.field_title')"
|
||||
value="{{old('title', $page->title)}}" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="columns large-6">
|
||||
<div class="columns large-4">
|
||||
<label>
|
||||
@lang('admin/contents.field_url')
|
||||
|
||||
<input type="text" name="url" placeholder="@lang('admin/contents.field_url')"
|
||||
<input type="text" name="url" class="slug-target" placeholder="@lang('admin/contents.field_url')"
|
||||
value="{{old('url', $page->url)}}" />
|
||||
|
||||
@if (isset($errors) && $errors->has('url'))
|
||||
@@ -21,6 +21,13 @@
|
||||
@endif
|
||||
</label>
|
||||
</div>
|
||||
<div class="column large-2 text-center">
|
||||
<label>
|
||||
@lang('admin/contents.lockUrl')<br />
|
||||
|
||||
<input type="checkbox" value="1" id="lockUrl" @if(old('lockUrl') || ($page->id > 0 && \Illuminate\Support\Str::slug($page->title) != $page->url)) checked @endif name="lockUrl" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user