Skip to content

Commit

Permalink
AeriaSection Remove Background
Browse files Browse the repository at this point in the history
  • Loading branch information
vincio87 committed Nov 10, 2015
1 parent 684e16f commit 574ddc3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 17 deletions.
9 changes: 4 additions & 5 deletions classes/AeriaSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function($post) use ($args){
$s++;
}

update_post_meta( $post_id, 'post_sections', addslashes(serialize($sections)) );
if(!empty($sections)) update_post_meta( $post_id, 'post_sections', addslashes(serialize($sections)) );

});

Expand Down Expand Up @@ -141,6 +141,7 @@ public static function render_sections($post_id, $args){

?>
<div class="box-reorder">
<p>Prima di utilizzare questa funzionalità assicurati di aver <b>salvato</b> tutto il lavoro.</p>
<?php
if($sections){
$s = 0;
Expand All @@ -151,7 +152,7 @@ public static function render_sections($post_id, $args){
$s++;
}
echo '</ul>';
echo '<button class="button button-large button-primary" type="button" data-section-sortable-save ><span class="dashicons dashicons-yes"></span> Save</button>';
echo '<button class="button button-large button-primary" type="button" data-section-sortable-save ><span class="dashicons dashicons-yes"></span> Confirm</button>';

}
?>
Expand All @@ -167,9 +168,6 @@ public static function render_sections($post_id, $args){
AeriaSection::render_section($section,$s,$section['columns'],$args);
$s++;
}
}else{
// Default Section (First)
AeriaSection::render_section([],0,1,$args);
}
?>
</div>
Expand Down Expand Up @@ -236,6 +234,7 @@ public static function render_section($section_passed = [], $key = 0, $ncol = 1,
<div class="box-section" data-section-num=<?= $key ?>>
<input type="hidden" data-section-columns name="post_section_columns_<?= $key ?>" value="<?= $section['columns'] ?>">
<div class="header-section" >
<div class="remove_background" data-remove-background>x</div>
<div class="background" data-section-background style="background-image:url(<?= stripslashes($section['background']) ?>);">
<input type="hidden" name="post_section_background_<?= $key ?>" id="post_section_background_<?= $key ?>" value="<?= $section['background'] ?>" />
</div>
Expand Down
14 changes: 14 additions & 0 deletions resources/css/section.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
background-color: #FFF;
display: table;
width: 100%;
position: relative;
}
.box-section .header-section .background {
width: 20%;
Expand Down Expand Up @@ -115,3 +116,16 @@
.box-section .wp-editor-wrap{
margin-top: 10px;
}
.remove_background {
position: absolute;
z-index: 1;
left: 0;
top: 0;
background-color: rgba(255,255,255,0.8);
font-size: 15px;
font-weight: bold;
padding: 3px 6px 6px 3px;
border-bottom-right-radius: 50%;
cursor: pointer;
color: #464C50;
}
47 changes: 35 additions & 12 deletions resources/js/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,36 @@ jQuery(function($){

var box_reorder = $('.box-reorder');

$('[data-section-add]').on('click', function (e) {
e.preventDefault();
$('[data-section-add]').on('click', function (e) {
e.preventDefault();
if(!box_reorder.is(':visible')) {
var last_section = $('.box-sections > .box-section').last();
var new_section_num;
if(typeof last_section.data('section-num') === 'undefined'){
new_section_num = 0;
}else{
new_section_num = parseInt(last_section.data('section-num'))+1;
}
var ncol = $('#ncol').val();

$.post(window.ajaxurl, { action: 'add_section', section : parseInt(last_section.data('section-num'))+1, ncol : parseInt(ncol) }, function(response) {
$.post(window.ajaxurl, { action: 'add_section', section : new_section_num, ncol : parseInt(ncol) }, function(response) {
$('.box-sections').append(response);
engineSelectBg();
});
}
});
});

$('[data-section-expand-all]').on('click', function(e) {
e.preventDefault();
$('[data-section-expand-all]').on('click', function(e) {
e.preventDefault();
if(!box_reorder.is(':visible')) {
$('.box-sections').find('.body-section').slideDown();
$('.box-sections').find('.body-section').slideDown();
}
});
});

$('[data-section-expand]').on('click', function(e) {
e.preventDefault();
$(this).parents('.box-section').find('.body-section').slideToggle();
});
$('[data-section-expand]').on('click', function(e) {
e.preventDefault();
$(this).parents('.box-section').find('.body-section').slideToggle();
});

$('[data-section-remove]').on('click', function(e) {
e.preventDefault();
Expand Down Expand Up @@ -54,6 +60,14 @@ jQuery(function($){

$.post(window.ajaxurl, { action: 'sort_section', order : order, post_id : post_id }, function(response) {
location.reload();
/*
var $button_save_draft = $('#save-post');
if($button_save_draft.length){
$button_save_draft.trigger('click');
}else{
$('#publish').trigger('click');
}
*/
});
});

Expand Down Expand Up @@ -98,6 +112,15 @@ jQuery(function($){
// Opens the media library frame.
meta_image_frame.open();
});

$('[data-remove-background]').on('click', function () {
var container = $(this).parent().find('[data-section-background]');
var input = container.find('input');

input.val('');
container.css('background-image' , 'url()');

});
}


Expand Down

0 comments on commit 574ddc3

Please sign in to comment.