Skip to content

Commit

Permalink
Merge pull request #582 from evancooper/master
Browse files Browse the repository at this point in the history
Image Slider QC + Sorting
  • Loading branch information
aembler committed Aug 4, 2014
2 parents 4228908 + eab245a commit 3623aeb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 16 deletions.
59 changes: 45 additions & 14 deletions web/concrete/blocks/image_slider/form_setup_html.php
Expand Up @@ -16,14 +16,31 @@
});
}

var attachSortDesc = function($obj) {
$obj.click(function(){
var myContainer = $(this).closest($('.ccm-image-slider-entry'));
myContainer.insertAfter(myContainer.next('.ccm-image-slider-entry'));
doSortCount();
});
}

var attachSortAsc = function($obj) {
$obj.click(function(){
var myContainer = $(this).closest($('.ccm-image-slider-entry'));
myContainer.insertBefore(myContainer.prev('.ccm-image-slider-entry'));
doSortCount();
});
}

var attachFileManagerLaunch = function($obj) {
$obj.click(function(){
var oldLauncher = $(this);
ConcreteFileManager.launchDialog(function (data) {
ConcreteFileManager.getFileDetails(data.fID, function(r) {
jQuery.fn.dialog.hideLoader();
var file = r.files[0];
oldLauncher.html('<img src="' + file.thumbnailLevel1 + '" />');
console.log(file.resultsThumbnailImg);
oldLauncher.html(file.resultsThumbnailImg);
oldLauncher.next('.image-fID').val(file.fID)
});
});
Expand All @@ -41,7 +58,7 @@
sliderEntriesContainer.append(_templateSlide({
fID: '<?php echo $row['fID'] ?>',
<?php if(File::getByID($row['fID'])) { ?>
image_url: '<?php echo File::getByID($row['fID'])->getURL();?>',
image_url: '<?php echo File::getByID($row['fID'])->getThumbnailURL('file_manager_listing');?>',
<?php } else { ?>
image_url: '',
<?php } ?>
Expand All @@ -55,14 +72,9 @@

doSortCount();

//sliderEntriesContainer.sortable({
// stop: function( event, ui ) {
// doSortCount(); // recount every time icon divs are resorted.
// }
//});

$('.ccm-add-image-slider-entry').click(function(){
var newSlide = sliderEntriesContainer.append(_templateSlide({
var thisModal = $(this).closest('.ui-dialog-content');
sliderEntriesContainer.append(_templateSlide({
fID: '',
title: '',
link_url: '',
Expand All @@ -71,14 +83,20 @@
sort_order: '',
image_url: ''
}));
$(newSlide).find('.redactor-content').redactor({
var newSlide = $('.ccm-image-slider-entry').last();
thisModal.scrollTop(newSlide.offset().top);
newSlide.find('.redactor-content').redactor({
minHeight: '200'
});
attachDelete($(newSlide).find('.ccm-delete-image-slider-entry'));
attachFileManagerLaunch($(newSlide).find('.ccm-pick-slide-image'));
attachDelete(newSlide.find('.ccm-delete-image-slider-entry'));
attachFileManagerLaunch(newSlide.find('.ccm-pick-slide-image'));
attachSortDesc(newSlide.find('i.fa-sort-desc'));
attachSortAsc(newSlide.find('i.fa-sort-asc'));
doSortCount();
});
attachDelete($('.ccm-delete-image-slider-entry'));
attachSortAsc($('i.fa-sort-asc'));
attachSortDesc($('i.fa-sort-desc'));
attachFileManagerLaunch($('.ccm-pick-slide-image'));
$(function() { // activate redactors
$('.redactor-content').redactor({
Expand Down Expand Up @@ -124,10 +142,22 @@



.ccm-image-slider-block-container i.fa-arrows {
.ccm-image-slider-block-container i.fa-sort-asc {
position: absolute;
top: 10px;
right: 10px;
cursor: pointer;
}

.ccm-image-slider-block-container i:hover {
color: #5cb85c;
}

.ccm-image-slider-block-container i.fa-sort-desc {
position: absolute;
top: 15px;
cursor: pointer;
right: 10px;
}
</style>
<div class="ccm-image-slider-block-container">
Expand All @@ -150,7 +180,8 @@
</div>
<script type="text/template" id="imageTemplate">
<div class="ccm-image-slider-entry well">
<i class="fa fa-arrows"></i>
<i class="fa fa-sort-desc"></i>
<i class="fa fa-sort-asc"></i>
<div class="form-group">
<label><?php echo t('Image') ?></label>
<div class="ccm-pick-slide-image">
Expand Down
11 changes: 9 additions & 2 deletions web/concrete/blocks/image_slider/view.php
@@ -1,4 +1,10 @@
<? defined('C5_EXECUTE') or die("Access Denied.");?>
<? defined('C5_EXECUTE') or die("Access Denied.");
$c = Page::getCurrentPage();
if ($c->isEditMode()) { ?>
<div class="ccm-edit-mode-disabled-item" style="width: <? echo $width; ?>; height: <? echo $height; ?>">
<div style="padding: 40px 0px 40px 0px"><? echo t('Image Slider disabled in edit mode.')?></div>
</div>
<? } else { ?>
<script>
$(document).ready(function(){
$(function () {
Expand Down Expand Up @@ -42,4 +48,5 @@
</div>

</div>
</div>
</div>
<?php } ?>

0 comments on commit 3623aeb

Please sign in to comment.