Skip to content

Commit

Permalink
Allow usage of multiple media partials on create views
Browse files Browse the repository at this point in the history
* Issue 213

Js issue

* Issue 213

Js issue

* Issue 213

Js issue

* Issue 213

Js issue
  • Loading branch information
motchju authored and nWidart committed Jul 8, 2016
1 parent 21ca858 commit 01abd70
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
11 changes: 6 additions & 5 deletions Resources/views/admin/fields/new-file-link-multiple.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@
}
</style>
<script>
if (typeof window.openMediaWindow === 'undefined') {
if (typeof window.openMediaWindowMultiple === 'undefined') {
window.mediaZone = '';
window.openMediaWindow = function (event, zone) {
window.openMediaWindowMultiple = function (event, zone) {
window.single = false;
window.mediaZone = zone;
window.zoneWrapper = $(event.currentTarget).siblings('.jsThumbnailImageWrapper');
window.open('{!! route('media.grid.select') !!}', '_blank', 'menubar=no,status=no,toolbar=no,scrollbars=yes,height=500,width=1000');
};
}
if (typeof window.includeMedia === 'undefined') {
window.includeMedia = function (mediaId, filePath) {
if (typeof window.includeMediaMultiple === 'undefined') {
window.includeMediaMultiple = function (mediaId, filePath) {
var html = '<figure data-id="' + mediaId + '">' +
'<img src="' + filePath + '" alt=""/>' +
'<a class="jsRemoveLink" href="#" data-id="' + mediaId + '">' +
Expand All @@ -64,7 +65,7 @@
{!! Form::label($zone, ucwords(str_replace('_', ' ', $zone)) . ':') !!}
<div class="clearfix"></div>
<?php $url = route('media.grid.select') ?>
<a class="btn btn-primary btn-upload" onclick="openMediaWindow(event, '{{ $zone }}')"><i class="fa fa-upload"></i>
<a class="btn btn-primary btn-upload" onclick="openMediaWindowMultiple(event, '{{ $zone }}')"><i class="fa fa-upload"></i>
{{ trans('media::media.Browse') }}
</a>
<div class="clearfix"></div>
Expand Down
11 changes: 6 additions & 5 deletions Resources/views/admin/fields/new-file-link-single.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
}
</style>
<script>
if (typeof window.openMediaWindow === 'undefined') {
if (typeof window.openMediaWindowSingle === 'undefined') {
window.mediaZone = '';
window.openMediaWindow = function (event, zone) {
window.openMediaWindowSingle = function (event, zone) {
window.single = true;
window.mediaZone = zone;
window.zoneWrapper = $(event.currentTarget).siblings('.jsThumbnailImageWrapper');
window.open('{!! route('media.grid.select') !!}', '_blank', 'menubar=no,status=no,toolbar=no,scrollbars=yes,height=500,width=1000');
};
}
if (typeof window.includeMedia === 'undefined') {
window.includeMedia = function (mediaId, filePath) {
if (typeof window.includeMediaSingle === 'undefined') {
window.includeMediaSingle = function (mediaId, filePath) {
var html = '<figure data-id="'+ mediaId +'"><img src="' + filePath + '" alt=""/>' +
'<a class="jsRemoveSimpleLink" href="#" data-id="' + mediaId + '">' +
'<i class="fa fa-times-circle removeIcon"></i></a>' +
Expand All @@ -45,7 +46,7 @@
{!! Form::label($zone, ucwords(str_replace('_', ' ', $zone)) . ':') !!}
<div class="clearfix"></div>

<a class="btn btn-primary btn-browse" onclick="openMediaWindow(event, '{{ $zone }}');" <?php echo (isset(${$zone}->path))?'style="display:none;"':'' ?>><i class="fa fa-upload"></i>
<a class="btn btn-primary btn-browse" onclick="openMediaWindowSingle(event, '{{ $zone }}');" <?php echo (isset(${$zone}->path))?'style="display:none;"':'' ?>><i class="fa fa-upload"></i>
{{ trans('media::media.Browse') }}
</a>

Expand Down
7 changes: 6 additions & 1 deletion Resources/views/admin/grid/general.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
e.preventDefault();
var mediaId = $(this).data('id'),
filePath = $(this).data('file-path');
window.opener.includeMedia(mediaId, filePath);
if(window.opener.single)
+ {
+ window.opener.includeMediaSingle(mediaId, filePath);
+ } else {
+ window.opener.includeMediaMultiple(mediaId, filePath);
+ }
window.close();
});
});
Expand Down

0 comments on commit 01abd70

Please sign in to comment.