Skip to content

Commit 5d4172d

Browse files
committed
Gallery items picker
1 parent e4b86e9 commit 5d4172d

File tree

4 files changed

+52
-28
lines changed

4 files changed

+52
-28
lines changed

controllers/ajax_file.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,17 @@ public function post_image_list_add()
370370

371371
if($where == 'galleries') {
372372

373-
$data = View::make('cms::interface.partials.gallery_new_item')
374-
->with('file', $file)
375-
->with('list_id', $list_id);
373+
$data = array(
374+
'file' => $file->to_array(),
375+
'list_id' => $list_id,
376+
'del_btn' => LL('cms::button.delete', CMSLANG)->get()
377+
);
376378

377379
} else if($where == 'banners') {
378380

379381
}
380382

381-
return $data;
383+
return json_encode($data);
382384

383385
}
384386

public/js/cms.js

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,34 @@ $.cms = {
558558
rel: rel
559559
}, function(data) {
560560
if(data) {
561-
$('table.listing').find('tbody').append(data);
562-
$('#modal-image-list').find('tr[rel='+fid+']').remove();
561+
562+
var list_tpl = '<tr rel="'+ data.file.id +'">' +
563+
'<td>' +
564+
'<a href="'+ BASE+data.file.path +'" class="thumbnail fancy" rel="tooltip" data-original-title="'+data.file.name+'">' +
565+
'<img src="'+BASE+data.file.thumb+'">' +
566+
'</a>' +
567+
'</td>' +
568+
'<td class="v-middle"><small>'+data.file.name+'</small></td>' +
569+
'<td>' +
570+
'<a href="#" class="btn btn-mini btn-danger pull-right list-delete" data-file="'+data.file.id+'" data-list="'+data.list_id+'" data-rel="galleries">'+data.del_btn+'</a>' +
571+
'</td>' +
572+
'</tr>';
573+
574+
var order_tpl = '<li class="span1" id="'+data.list_id+'_'+data.file.id+'" rel="'+data.file.id+'">' +
575+
'<a href="'+ BASE+data.file.path +'" class="thumbnail" data-original-title="'+data.file.name+'" rel="tooltip">' +
576+
'<img src="'+BASE+data.file.thumb+'" />' +
577+
'</a>' +
578+
'</li>';
579+
580+
$('table.listing > tbody').append(list_tpl);
581+
$('ul.thumbnails').append(order_tpl);
582+
583+
$('*[rel=empty]').remove();
584+
$('#modal-media tr[rel='+fid+']').remove();
585+
563586
};
564587

565-
});
588+
}, 'json');
566589

567590
return false;
568591
});
@@ -578,13 +601,23 @@ $.cms = {
578601
var fid = $(this).attr('data-file');
579602
var rel = $(this).attr('data-rel');
580603

581-
$.post(BASE+'/cms/ajax/image/list/del', {
582-
lid: lid,
583-
fid: fid,
584-
rel: rel
585-
}, function(status) {
586-
if(status) $('tr[rel='+fid+']').remove();
587-
});
604+
if(lid && fid && rel) {
605+
606+
$.post(BASE+'/cms/ajax/image/list/del', {
607+
lid: lid,
608+
fid: fid,
609+
rel: rel
610+
}, function(status) {
611+
612+
if(status) {
613+
614+
$('tr[rel='+fid+']').remove();
615+
$('li[rel='+fid+']').remove();
616+
617+
}
618+
});
619+
620+
}
588621

589622
return false;
590623
});

views/interface/pages/gallery_new_edit.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</td>
8181
</tr>
8282
@empty
83-
<tr>
83+
<tr rel="empty">
8484
<td colspan="3" class="toleft">
8585
{{LL('cms::alert.list_empty', CMSLANG)}}
8686
</td>
@@ -124,13 +124,13 @@
124124
<ul class="thumbnails sortable">
125125

126126
@forelse ($files as $file)
127-
<li class="span1" id="{{$gallery_id}}_{{$file->id}}">
127+
<li class="span1" id="{{$gallery_id}}_{{$file->id}}" rel="{{$file->id}}">
128128
<a href="{{BASE.$file->path}}" class="thumbnail" data-original-title="{{$file->name}}" rel="tooltip">
129129
<img src="{{BASE.$file->thumb}}" />
130130
</a>
131131
</li>
132132
@empty
133-
<li>
133+
<li rel="empty">
134134
{{LL('cms::alert.list_empty', CMSLANG)}}
135135
</li>
136136
@endforelse

views/interface/partials/gallery_new_item.blade.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)