-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
168 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,119 @@ | ||
jQuery( | ||
function ($) { | ||
var file_frame; | ||
$( document ).on( | ||
'click', | ||
'.select-image-box', | ||
function (e) { | ||
var wallery_element = $( this ).parent( '.wallery' ); | ||
var wallery_id = $( wallery_element ).attr( 'id' ); | ||
e.preventDefault(); | ||
if (file_frame) { | ||
file_frame.close(); | ||
} | ||
file_frame = wp.media.frames.file_frame = wp.media( | ||
{ | ||
title: $( this ).data( 'uploader-title' ), | ||
button: { | ||
text: $( this ).data( 'uploader-button-text' ), | ||
}, | ||
multiple: true | ||
} | ||
); | ||
file_frame.on( | ||
'select', | ||
function () { | ||
var listIndex = $( wallery_element ).find( '.images-list .image' ).index( $( wallery_element ).find( '.images-list .image:last' ) ), | ||
selection = file_frame.state().get( 'selection' ); | ||
selection.map( | ||
function (attachment, i) { | ||
attachment = attachment.toJSON(); | ||
index = listIndex + (i + 1); | ||
firstImage = attachment.sizes.thumbnail ? attachment.sizes.thumbnail : _.head( Object.values( attachment.sizes ) ); | ||
$( wallery_element ).find( '.images-list' ).append( | ||
'<div class="wallery-image image"><div class="image-inner"><input type="hidden" name="' + wallery_id + '[' + index + ']" value="' + attachment.id + '"><img class="image-preview" src="' + firstImage.url + '"><a class="wallary-action change-image" href="#" data-uploader-title="Change image" data-uploader-button-text="Change image"><span class="wallery-retweet"></span></a><br><a class="wallary-action remove-image" href="#"><span class="wallery-trash"></span></a></div></div>' | ||
); | ||
} | ||
); | ||
} | ||
); | ||
makeSortable(); | ||
file_frame.open(); | ||
} | ||
); | ||
function ($) { | ||
var file_frame; | ||
$(document).on( | ||
'click', | ||
'.select-image-box', | ||
function (e) { | ||
var wallery_element = $(this).parent('.wallery'); | ||
var wallery_id = $(wallery_element).attr('id'); | ||
e.preventDefault(); | ||
if (file_frame) { | ||
file_frame.close(); | ||
} | ||
file_frame = wp.media.frames.file_frame = wp.media( | ||
{ | ||
title: $(this).data('uploader-title'), | ||
button: { | ||
text: $(this).data('uploader-button-text'), | ||
}, | ||
multiple: true | ||
} | ||
); | ||
file_frame.on( | ||
'select', | ||
function () { | ||
var listIndex = $(wallery_element).find('.images-list .image').index($(wallery_element).find('.images-list .image:last')), | ||
selection = file_frame.state().get('selection'); | ||
selection.map( | ||
function (attachment, i) { | ||
attachment = attachment.toJSON(); | ||
index = listIndex + (i + 1); | ||
firstImage = attachment.sizes.thumbnail ? attachment.sizes.thumbnail : _.head(Object.values(attachment.sizes)); | ||
$(wallery_element).find('.images-list').append( | ||
'<div class="wallery-image image"><div class="image-inner"><input type="hidden" name="' + wallery_id + '[' + index + ']" value="' + attachment.id + '"><img class="image-preview" src="' + firstImage.url + '"><a class="wallary-action change-image" href="#" data-uploader-title="Change image" data-uploader-button-text="Change image"><span class="wallery-retweet"></span></a><br><a class="wallary-action remove-image" href="#"><span class="wallery-trash"></span></a></div></div>' | ||
); | ||
} | ||
); | ||
} | ||
); | ||
makeSortable(); | ||
file_frame.open(); | ||
} | ||
); | ||
|
||
$( document ).on( | ||
'click', | ||
'.images-list a.change-image', | ||
function (e) { | ||
$(document).on( | ||
'click', | ||
'.images-list a.change-image', | ||
function (e) { | ||
|
||
e.preventDefault(); | ||
var that = $( this ); | ||
if (file_frame) { | ||
file_frame.close(); | ||
} | ||
file_frame = wp.media.frames.file_frame = wp.media( | ||
{ | ||
title: $( this ).data( 'uploader-title' ), | ||
button: { | ||
text: $( this ).data( 'uploader-button-text' ), | ||
}, | ||
multiple: false | ||
} | ||
); | ||
file_frame.on( | ||
'select', | ||
function () { | ||
attachment = file_frame.state().get( 'selection' ).first().toJSON(); | ||
firstImage = attachment.sizes.thumbnail ? attachment.sizes.thumbnail : _.head( Object.values( attachment.sizes ) ); | ||
that.parent().find( 'input:hidden' ).attr( 'value', attachment.id ); | ||
that.parent().find( 'img.image-preview' ).attr( 'src', firstImage.url ); | ||
} | ||
); | ||
file_frame.open(); | ||
} | ||
); | ||
e.preventDefault(); | ||
var that = $(this); | ||
if (file_frame) { | ||
file_frame.close(); | ||
} | ||
file_frame = wp.media.frames.file_frame = wp.media( | ||
{ | ||
title: $(this).data('uploader-title'), | ||
button: { | ||
text: $(this).data('uploader-button-text'), | ||
}, | ||
multiple: false | ||
} | ||
); | ||
file_frame.on( | ||
'select', | ||
function () { | ||
attachment = file_frame.state().get('selection').first().toJSON(); | ||
firstImage = attachment.sizes.thumbnail ? attachment.sizes.thumbnail : _.head(Object.values(attachment.sizes)); | ||
that.parent().find('input:hidden').attr('value', attachment.id); | ||
that.parent().find('img.image-preview').attr('src', firstImage.url); | ||
} | ||
); | ||
file_frame.open(); | ||
} | ||
); | ||
|
||
function resetIndex() { | ||
$( '.images-list .image' ).each( | ||
function (i) { | ||
var wallery_id = $( this ).parents( '.images-list' ).parent().attr( 'id' ); | ||
$( this ).find( 'input:hidden' ).attr( 'name', wallery_id + '[' + i + ']' ); | ||
} | ||
); | ||
} | ||
function resetIndex() | ||
{ | ||
$('.images-list .image').each( | ||
function (i) { | ||
var wallery_id = $(this).parents('.images-list').parent().attr('id'); | ||
$(this).find('input:hidden').attr('name', wallery_id + '[' + i + ']'); | ||
} | ||
); | ||
} | ||
|
||
function makeSortable() { | ||
$( '.images-list' ).sortable( | ||
{ | ||
opacity: 0.6, | ||
float: 'left', | ||
stop: function () { | ||
resetIndex(); | ||
} | ||
} | ||
); | ||
} | ||
$( document ).on( | ||
'click', | ||
'.images-list a.remove-image', | ||
function (e) { | ||
e.preventDefault(); | ||
$( this ).parents( '.image' ).animate( | ||
{ | ||
opacity: 0 | ||
}, | ||
200, | ||
function () { | ||
$( this ).remove(); | ||
resetIndex(); | ||
} | ||
); | ||
} | ||
); | ||
function makeSortable() | ||
{ | ||
$('.images-list').sortable( | ||
{ | ||
opacity: 0.6, | ||
float: 'left', | ||
stop: function () { | ||
resetIndex(); | ||
} | ||
} | ||
); | ||
} | ||
$(document).on( | ||
'click', | ||
'.images-list a.remove-image', | ||
function (e) { | ||
e.preventDefault(); | ||
$(this).parents('.image').animate( | ||
{ | ||
opacity: 0 | ||
}, | ||
200, | ||
function () { | ||
$(this).remove(); | ||
resetIndex(); | ||
} | ||
); | ||
} | ||
); | ||
|
||
makeSortable(); | ||
} | ||
makeSortable(); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
<div class="wallery-image image"> | ||
<div class="image-inner"> | ||
<input type="hidden" name="<?php echo $wallery_id; ?>[<?php echo $index; ?>]" value="<?php echo $image['id']; ?>"> | ||
<img class="image-preview" src="<?php echo $image['src']; ?>"> | ||
<a | ||
class="wallary-action change-image" | ||
href="#" | ||
data-uploader-title="<?php _e( 'Change Images', 'wallery' ); ?>" | ||
data-uploader-button-text="<?php _e( 'Change Images', 'wallery' ); ?>" | ||
> | ||
<span class="wallery-retweet"></span> | ||
</a> | ||
<a class="wallary-action remove-image" href="#"><span class="wallery-trash"></span></a> | ||
</div> | ||
<div class="image-inner"> | ||
<input type="hidden" name="<?php echo $wallery_id; ?>[<?php echo $index; ?>]" value="<?php echo $image['id']; ?>"> | ||
<img class="image-preview" src="<?php echo $image['src']; ?>"> | ||
<a | ||
class="wallary-action change-image" | ||
href="#" | ||
data-uploader-title="<?php _e('Change Images', 'wallery'); ?>" | ||
data-uploader-button-text="<?php _e('Change Images', 'wallery'); ?>" | ||
> | ||
<span class="wallery-retweet"></span> | ||
</a> | ||
<a class="wallary-action remove-image" href="#"><span class="wallery-trash"></span></a> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<div class="toolbar image-layouts"> | ||
<h2 class="heading-images"> | ||
<?php echo esc_html($heading_text); ?> | ||
</h2> | ||
<div class="layouts"> | ||
<div class="layout layout-list"> | ||
<span class="wallery-list"></span> | ||
</div> | ||
<div class="layout layout-thumbnail"> | ||
<span class="wallery-layout"></span> | ||
</div> | ||
<?php do_action( 'wallery_layouts' ); ?> | ||
<div class="clearfix"></div> | ||
</div> | ||
<div class="clearfix"></div> | ||
<h2 class="heading-images"> | ||
<?php echo esc_html($heading_text); ?> | ||
</h2> | ||
<div class="layouts"> | ||
<div class="layout layout-list"> | ||
<span class="wallery-list"></span> | ||
</div> | ||
<div class="layout layout-thumbnail"> | ||
<span class="wallery-layout"></span> | ||
</div> | ||
<?php do_action('wallery_layouts'); ?> | ||
<div class="clearfix"></div> | ||
</div> | ||
<div class="clearfix"></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
<div id="<?php echo $wallery_id; ?>" class="wallery"> | ||
<div class="select-image-box"> | ||
<div class="wrapper"> | ||
<div class="outline"> | ||
<i class="wallery-upload"></i> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="wallery-toolbars"> | ||
<?php if ( has_action( 'wallery_left_toolbars' ) || has_action( 'wallery_right_toolbars' ) ) : ?> | ||
<div class="wallery-toolbar-inner"> | ||
<div class="wallery-left-toolbar"> | ||
<?php do_action( 'wallery_left_toolbars' ); ?> | ||
</div> | ||
<div class="wallery-right-toolbar"> | ||
<?php do_action( 'wallery_right_toolbars' ); ?> | ||
</div> | ||
</div> | ||
<?php endif; ?> | ||
<div class="wallery-toolbar-inner"> | ||
<?php do_action( 'wallery_toolbars' ); ?> | ||
</div> | ||
</div> | ||
<div class="images-list"> | ||
<?php | ||
foreach ( $images as $index => $image ) { | ||
wallery_load_template( 'image-content', compact( 'index', 'image', 'wallery_id' ) ); | ||
} | ||
?> | ||
</div> | ||
<div class="select-image-box"> | ||
<div class="wrapper"> | ||
<div class="outline"> | ||
<i class="wallery-upload"></i> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="wallery-toolbars"> | ||
<?php if (has_action('wallery_left_toolbars') || has_action('wallery_right_toolbars')) : ?> | ||
<div class="wallery-toolbar-inner"> | ||
<div class="wallery-left-toolbar"> | ||
<?php do_action('wallery_left_toolbars'); ?> | ||
</div> | ||
<div class="wallery-right-toolbar"> | ||
<?php do_action('wallery_right_toolbars'); ?> | ||
</div> | ||
</div> | ||
<?php endif; ?> | ||
<div class="wallery-toolbar-inner"> | ||
<?php do_action('wallery_toolbars'); ?> | ||
</div> | ||
</div> | ||
<div class="images-list"> | ||
<?php | ||
foreach ($images as $index => $image) { | ||
wallery_load_template('image-content', compact('index', 'image', 'wallery_id')); | ||
} | ||
?> | ||
</div> | ||
</div> |