Skip to content

Commit

Permalink
Fixed issue #14162: Functionality ranking questions breaks with relev… (
Browse files Browse the repository at this point in the history
#1154)

Fixed issue : Same choice height work again
Dev: update and depend actual
Dev: review css selector
  • Loading branch information
Shnoulle committed Oct 23, 2018
1 parent b9b371b commit a6469d0
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 554 deletions.
2 changes: 1 addition & 1 deletion application/config/questiontypes.php
Expand Up @@ -34,7 +34,7 @@
'scripts/ranking.js',
),
'depends' => array(
'jquery',
'jquery','jquery-actual',
)
),
/* numeric slider question : numerci question type with slider */
Expand Down
2 changes: 1 addition & 1 deletion application/config/third_party.php
Expand Up @@ -395,7 +395,7 @@
'position' => CClientScript::POS_BEGIN,
'basePath' => 'third_party.jquery-actual', /* for samechoiceheight/samelistheight */
'js' => array(
'jquery.actual.min.js'
'jquery.actual'.$minVersion.'.js'
),
),
/* Used by short text with map by leaflet */
Expand Down
1 change: 0 additions & 1 deletion application/helpers/qanda_helper.php
Expand Up @@ -1894,7 +1894,6 @@ function do_ranking($ia)
$inputnames[] = $myfname;
}

Yii::app()->getClientScript()->registerPackage("question-ranking", CClientScript::POS_BEGIN);
$rankingTranslation = 'LSvar.lang.rankhelp="'.gT("Double-click or drag-and-drop items in the left list to move them to the right - your highest ranking item should be on the top right, moving through to your lowest ranking item.", 'js').'";';
App()->getClientScript()->registerScript("rankingTranslation", $rankingTranslation, CClientScript::POS_BEGIN);

Expand Down
Expand Up @@ -72,7 +72,7 @@ try{
ranking{{qId}}.init()
} catch(e){}
{% endset %}

{{ registerPackage('question-ranking') }}
{{ registerScript( 'RankingQuestion'~qId, script, 'POS_POSTSCRIPT') }}


Expand Down
44 changes: 19 additions & 25 deletions assets/packages/questions/ranking/scripts/ranking.js
Expand Up @@ -147,32 +147,26 @@ var RankingQuestion = function (options) {
},

fixChoiceListHeight = function() {
//Keep the target field as big as the source field
var minHeight = $('#sortable-choice-' + questionId).height();
$('#sortable-choice-' + questionId).css('min-height', minHeight);
$('#sortable-rank-' + questionId).css('min-height', minHeight);

// if (samechoiceheight) {
// var maxHeight = 0;
// $('#sortable-choice-' + questionId + ' li,#sortable-rank-' + questionId + ' li').each(function () {
// if ($(this).actual('height') > maxHeight) {
// maxHeight = $(this).actual('height');
// }
// });
// $('#sortable-choice-' + questionId + ' li,#sortable-rank-' + questionId + ' li').css('min-height', maxHeight + 'px');
// }

// if (samelistheight) {
// var totalHeight = 0;
// $('#sortable-choice-' + questionId + ' li,#sortable-rank-' + questionId + ' li').each(function () {
// totalHeight = totalHeight + $(this).actual('outerHeight', {
// includeMargin: true
// }); /* Border not inside */
// });
// /* Add the padding to min-height */
// $('#sortable-choice-' + questionId + ',#sortable-rank-' + questionId).css('min-height', totalHeight + 'px').addClass("ls-sameheight");
// }
if (samechoiceheight) {
var maxHeight = 0;
$('#question' + questionId + ' .list-samechoiceheight .ls-choice').each(function () {
if ($(this).actual('height') > maxHeight) {
maxHeight = $(this).actual('height');
}
});
$('#question' + questionId + ' .list-samechoiceheight .ls-choice').height(maxHeight);
}

if (samelistheight) {
var totalHeight = 0;
$('#question' + questionId + ' .list-samelistheight .ls-choice').each(function () {
totalHeight = totalHeight + $(this).actual('outerHeight', {
includeMargin: true
}); /* Border not inside */
});
/* Add the padding to min-height */
$('#sortable-choice-' + questionId + ',#sortable-rank-' + questionId).height(totalHeight);
}
},

triggerEmRelevanceSortable = function() {
Expand Down
2 changes: 0 additions & 2 deletions third_party/jquery-actual/.gitignore

This file was deleted.

71 changes: 0 additions & 71 deletions third_party/jquery-actual/CHANGELOG.md

This file was deleted.

12 changes: 10 additions & 2 deletions third_party/jquery-actual/README.md
Expand Up @@ -27,7 +27,7 @@ jQuery has trouble finding the width/height of invisible DOM elements. With elem

## Requires

- jQuery 1.2.3 ~ 1.8.0
- jQuery >= 1.2.3



Expand Down Expand Up @@ -89,6 +89,10 @@ Example code:
// please see demo/css3pie in action
$( '.hidden' ).actual( 'width', { clone : true });

// if it is not a block element. By default { display: 'block' }.
// for example a inline element
$( '.hidden' ).actual( 'width', { display: 'inline-block' });



## Credits
Expand All @@ -97,11 +101,15 @@ Example code:
- [Jon Tara](https://github.com/jtara)
- [Matt Hinchliffe](https://github.com/i-like-robots)
- [Ryan Millikin](https://github.com/dhamma)
- [Jacob Quant](https://github.com/jacobq)
- [ejn](https://github.com/ejn)
- [Rudolf](https://github.com/qakovalyov)
- [jamesallchin](https://github.com/jamesallchin)



## License

The expandable plugin is licensed under the MIT License (LICENSE.txt).

Copyright (c) 2012 [Ben Lin](http://dreamerslab.com)
Copyright (c) 2012 [Ben Lin](http://dreamerslab.com)

0 comments on commit a6469d0

Please sign in to comment.