Standardize select image from media db/show preview process.
This used to be two seperate processes for the category icon and images selected in plugin/theme config. It has now been simplified to use just one process, which also uses the same markup and JS. This adds to the consistency of the UI/UX, but it also saves some CSS and a lot of JS, most of the latter of the expensive kind that modifies the DOM.
This commit is contained in:
@ -131,13 +131,15 @@
|
|||||||
<div id="category_preview" class="clearfix additional_info">
|
<div id="category_preview" class="clearfix additional_info">
|
||||||
<div class="form_field">
|
<div class="form_field">
|
||||||
<label for="category_icon">{$CONST.CATEGORY} {$CONST.IMAGE}</label>
|
<label for="category_icon">{$CONST.CATEGORY} {$CONST.IMAGE}</label>
|
||||||
<input id="category_icon" name="serendipity[cat][icon]" type="text" value="{$this_cat.category_icon|default:""|escape}">
|
|
||||||
<button id="insert_image" type="button" name="insImage" title="{$CONST.MEDIA_LIBRARY}"><span class="icon-picture"></span><span class="visuallyhidden"> {$CONST.MEDIA_LIBRARY}</span></button>
|
<input id="category_icon" class="change_preview" name="serendipity[cat][icon]" type="text" data-configitem="category_icon" value="{$this_cat.category_icon|default:""|escape}">
|
||||||
|
|
||||||
|
<button class="choose_media" type="button" name="insImage" title="{$CONST.MEDIA_LIBRARY}"><span class="icon-picture"></span><span class="visuallyhidden"> {$CONST.MEDIA_LIBRARY}</span></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<figure id="preview">
|
<figure id="category_icon_preview">
|
||||||
<figcaption>{$CONST.PREVIEW}</figcaption>
|
<figcaption>{$CONST.PREVIEW}</figcaption>
|
||||||
<img id="imagepreview" src="{$this_cat.category_icon|default:""|escape}" alt="">
|
<img src="{$this_cat.category_icon|default:""|escape}" alt="">
|
||||||
</figure>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -56,12 +56,17 @@
|
|||||||
{elseif $ctype == 'media'}
|
{elseif $ctype == 'media'}
|
||||||
<div class="clearfix form_field media_choose">
|
<div class="clearfix form_field media_choose">
|
||||||
<label for="serendipity[{$postKey}][{$config_item}]">{$cname}{if $cdesc != ''} <button class="toggle_info button_link" type="button" data-href="#{$postKey}_{$config_item}_info"><span class="icon-info-circled"></span><span class="visuallyhidden"> {$CONST.MORE}</span></button>{/if}</label>
|
<label for="serendipity[{$postKey}][{$config_item}]">{$cname}{if $cdesc != ''} <button class="toggle_info button_link" type="button" data-href="#{$postKey}_{$config_item}_info"><span class="icon-info-circled"></span><span class="visuallyhidden"> {$CONST.MORE}</span></button>{/if}</label>
|
||||||
|
|
||||||
<input id="serendipity[{$postKey}][{$config_item}]" class="change_preview" name="serendipity[{$postKey}][{$config_item}]" type="text" data-configitem="{$config_item}" data-pmwidth="{$preview_width}" data-pmheight="{$preview_height}" value="{$value}">{* This should maybe be input[type=file] *}
|
|
||||||
|
|
||||||
<button class="icon_link choose_media" type="button" title="{$CONST.MEDIA_LIBRARY}"><span class="icon-picture"></span><span class="visuallyhidden">{$CONST.MEDIA_LIBRARY}</span></a>
|
<input id="serendipity[{$postKey}][{$config_item}]" class="change_preview" name="serendipity[{$postKey}][{$config_item}]" type="text" data-configitem="{$config_item}" value="{$value}">{* This should maybe be input[type=file] *}
|
||||||
|
|
||||||
|
<button class="choose_media" type="button" title="{$CONST.MEDIA_LIBRARY}"><span class="icon-picture"></span><span class="visuallyhidden">{$CONST.MEDIA_LIBRARY}</span></button>
|
||||||
|
|
||||||
{if $cdesc != ''}<span id="{$postKey}_{$config_item}_info" class="field_info additional_info">{$cdesc}</span>{/if}
|
{if $cdesc != ''}<span id="{$postKey}_{$config_item}_info" class="field_info additional_info">{$cdesc}</span>{/if}
|
||||||
|
|
||||||
|
<figure id="{$config_item}_preview">
|
||||||
|
<figcaption>{$CONST.PREVIEW}</figcaption>
|
||||||
|
<img src="{$value}" alt="">
|
||||||
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
{elseif $ctype == 'sequence'}
|
{elseif $ctype == 'sequence'}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
@ -150,14 +150,11 @@
|
|||||||
}
|
}
|
||||||
/* end Better-Editor functions */
|
/* end Better-Editor functions */
|
||||||
|
|
||||||
// Switches preview of image selected from media db by changing the
|
// Switches preview of image selected from media db
|
||||||
// container's background image
|
serendipity.change_preview = function(input, output) {
|
||||||
serendipity.change_preview = function(id) {
|
var filename = document.getElementById(input).value;
|
||||||
var text_box = document.getElementById('serendipity[template][' + id + ']');
|
var $target = $('#' + output + '_preview > img');
|
||||||
var image_box = document.getElementById(id + '_preview');
|
$target.attr('src', filename);
|
||||||
var filename = text_box.value;
|
|
||||||
|
|
||||||
image_box.style.backgroundImage = 'url(' + filename + ')';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opens media db image selection in new window
|
// Opens media db image selection in new window
|
||||||
@ -1080,28 +1077,10 @@ $(function() {
|
|||||||
$('.show_config_option_now').click();
|
$('.show_config_option_now').click();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config option add media
|
|
||||||
if($('.media_choose').length > 0) {
|
|
||||||
var $el = $('.media_choose');
|
|
||||||
var $item = $el.find('> input');
|
|
||||||
var configItem = $item.attr('data-configitem');
|
|
||||||
var mWidth = $item.attr('data-pmwidth');
|
|
||||||
var mHeight = $item.attr('data-pmheight');
|
|
||||||
if($item.val() != '') {
|
|
||||||
var bgImg = 'url(' + $item.val() + ')';
|
|
||||||
} else {
|
|
||||||
var bgImg = 'none';
|
|
||||||
}
|
|
||||||
$('<div id="'+configItem+'_preview" class="preview"/>').appendTo($el)
|
|
||||||
.css({
|
|
||||||
backgroundImage: bgImg,
|
|
||||||
// minWidth: mWidth,
|
|
||||||
minHeight: mHeight
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$('.change_preview').change(function() {
|
$('.change_preview').change(function() {
|
||||||
serendipity.change_preview($(this).attr('data-configitem'));
|
console.log('ID: ' + $(this).attr('id'));
|
||||||
|
console.log('CI: ' + $(this).attr('data-configitem'));
|
||||||
|
serendipity.change_preview($(this).attr('id'), $(this).attr('data-configitem'));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.choose_media').click(function() {
|
$('.choose_media').click(function() {
|
||||||
@ -1134,15 +1113,6 @@ $(function() {
|
|||||||
{/if}
|
{/if}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Category icon preview
|
|
||||||
$('#insert_image').click(function(e) {
|
|
||||||
serendipity.choose_media('category_icon');
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#category_icon').change(function() {
|
|
||||||
$('#imagepreview').attr('src', $('#category_icon').val());
|
|
||||||
});
|
|
||||||
|
|
||||||
// Selection for multidelete
|
// Selection for multidelete
|
||||||
$('.multidelete').click(function() {
|
$('.multidelete').click(function() {
|
||||||
var $el = $(this);
|
var $el = $(this);
|
||||||
|
@ -964,6 +964,7 @@ input[type=checkbox],
|
|||||||
|
|
||||||
.importer_data dd,
|
.importer_data dd,
|
||||||
.form_buttons > input,
|
.form_buttons > input,
|
||||||
|
.js .media_choose label,
|
||||||
.quick_list ol > li {
|
.quick_list ol > li {
|
||||||
margin-bottom: .75em;
|
margin-bottom: .75em;
|
||||||
}
|
}
|
||||||
@ -976,7 +977,7 @@ input[type=checkbox],
|
|||||||
.serendipity_commentDirection,
|
.serendipity_commentDirection,
|
||||||
.entry_info,
|
.entry_info,
|
||||||
.pagination,
|
.pagination,
|
||||||
.media_choose .preview,
|
.media_choose figure,
|
||||||
.media_file_metadata dt,
|
.media_file_metadata dt,
|
||||||
#serendipity_comments_list details,
|
#serendipity_comments_list details,
|
||||||
.configure_plugin .cke {
|
.configure_plugin .cke {
|
||||||
@ -1244,13 +1245,6 @@ summary {
|
|||||||
max-width: 75%;
|
max-width: 75%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media_choose .preview {
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
height: auto;
|
|
||||||
margin: .75em 0;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editor_toolbar button,
|
.editor_toolbar button,
|
||||||
.comment_data dt,
|
.comment_data dt,
|
||||||
#serendipityScaleForm .form_field label {
|
#serendipityScaleForm .form_field label {
|
||||||
@ -2140,8 +2134,8 @@ label .perm_name,
|
|||||||
.no-js .toggle_comment_full,
|
.no-js .toggle_comment_full,
|
||||||
.no-js #add_upload,
|
.no-js #add_upload,
|
||||||
.no-js .choose_media,
|
.no-js .choose_media,
|
||||||
.no-js #insert_image,
|
.no-js .media_choose figure,
|
||||||
.no-js #category_preview #preview,
|
.no-js #category_preview figure,
|
||||||
.no-js .media_show_info,
|
.no-js .media_show_info,
|
||||||
.no-js .media_rename,
|
.no-js .media_rename,
|
||||||
.no-js .template_show_info,
|
.no-js .template_show_info,
|
||||||
|
Reference in New Issue
Block a user