Skip to content

Commit

Permalink
Fixed issue #7709: Javascript broken : select for question type
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Apr 4, 2013
1 parent 37c5f91 commit 9c5e631
Show file tree
Hide file tree
Showing 66 changed files with 105 additions and 2,546 deletions.
1 change: 1 addition & 0 deletions application/config/internal.php
Expand Up @@ -10,6 +10,7 @@
'runtimePath' => dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'runtime',
'name' => 'LimeSurvey',
'defaultController' => 'survey',
'preload' => array('bootstrap'),
'import' => array(
'application.core.*',
'application.models.*',
Expand Down
8 changes: 0 additions & 8 deletions application/config/third_party.php
Expand Up @@ -147,12 +147,4 @@
'jquery'
)
),
'jquery-msdropdown' => array(
'baseUrl' => 'third_party/jquery-msdropdown/',
'js' => array('js/msdropdown/jquery.dd.js'),
'css' => array('css/msdropdown/dd.css'),
'depends' => array('jquery')
)


);
19 changes: 14 additions & 5 deletions application/extensions/Menu/MenuWidget.php
Expand Up @@ -448,11 +448,20 @@ protected function renderSelect($item)
{
$listData = $item['values'];
}
$result .= CHtml::dropDownList($item['name'], $item['value'], $listData, array(
'id' => $item['name'],
'prompt' => gT('Please choose...')
));

$result .= $this->widget('ext.bootstrap.widgets.TbSelect2', array(
'name' => $item['name'],
'value' => $item['value'],
'data' => $listData,
'options' => array(
'minimumResultsForSearch' => 20,
'placeholder' => gT('Please choose...')
),
'htmlOptions' => array(
'class' => 'select',
'id' => $item['name'],
'prompt' => ''//gT('Please choose...')
)
), true);
return $result;
}

Expand Down
37 changes: 35 additions & 2 deletions application/views/admin/survey/Question/editQuestion_view.php
Expand Up @@ -101,6 +101,7 @@
<div class="htmleditor">
<textarea cols='50' rows='4' id='question_<?php echo $addlanguage; ?>' name='question_<?php echo $addlanguage; ?>'></textarea>
</div>

<?php echo getEditor("question-text","question_".$addlanguage, "[".$clang->gT("Question:", "js")."](".$addlanguage.")",$surveyid,$gid,$qid,$action); ?>
</li><li>
<label for='help_<?php echo $addlanguage; ?>'><?php $clang->eT("Help:"); ?></label>
Expand All @@ -116,13 +117,45 @@
<ul>
<li><label for='question_type'><?php $clang->eT("Question Type:"); ?></label>
<?php if ($activated != "Y")
{ ?>
{

foreach (getQuestionTypeList($eqrow['type'], 'array') as $key=> $questionType)
{
if (!isset($groups[$questionType['group']]))
{
$groups[$questionType['group']] = array();
}
$groups[$questionType['group']][$key] = $questionType['description'];

}
$this->widget('ext.bootstrap.widgets.TbSelect2', array(
'data' => $groups,
'name' => 'type',
'options' => array(
'width' => '300px',
'minimumResultsForSearch' => 1000
),
'events' => array(
),
'htmlOptions' => array(
'id' => 'question_type'
)
));
$script = '$("#question_type option").addClass("questionType");';
App()->getClientScript()->registerScript('add_class_to_options', $script);
/*
* ?>
<select id='question_type' style='margin-bottom:5px' name='type' class='<?php echo $selectormodeclass; ?>'>
<?php echo getQuestionTypeList($eqrow['type'],'group'); ?>
</select>
<?php }
<?php
*
*/

}
else
{

Expand Down
63 changes: 31 additions & 32 deletions scripts/admin/admin_core.js
Expand Up @@ -115,48 +115,46 @@ $(document).ready(function(){

function qTypeDropdownInit()
{
$("#question_type_child li.enabled").each(function(index,element){
$(document).ready(function () {
$("#question_type option").each(function(index,element){
$(element).qtip({
style: {
classes: 'qtip-questiontype'
},
content: getToolTip($(element).text()),
position: {
my : 'top left',
at: 'top right',
target: $('label[for=question_type]'),
viewport: $(window),
adjust: {
x: 20
}

$(element).qtip({
style: {
classes: 'qtip-questiontype'
},
content: getToolTip($(element).text()),
position: {
my: 'top left',
at: 'middle right',
viewport: $(window),
adjust: {
x: 16
}
}
});

});

});
});
$("#question_type option").each(function(index,element){

$(element).qtip({
style: {
classes: 'qtip-questiontype'
},
content: getToolTip($(element).text()),
position: {
my: 'top left',
at: 'middle right',
viewport: $(window),
adjust: {
x: 16
}
$(document).ready(function() {
$('body').on('mouseenter mouseleave', 'li.questionType', function(e) {
if (e.type = 'mouseenter')
{
// Hide all others if we show a new one.
$('#question_type option').qtip('hide');
$($(e.currentTarget).data().select2Data.element).qtip('option', 'position.target', $(e.currentTarget)).qtip('show');
}
else
{
$($(e.currentTarget).data().select2Data.element).qtip('hide');
}


});

});
}




var aToolTipData = {

};
Expand Down Expand Up @@ -390,6 +388,7 @@ function ev_gecko_select_keyup_ev(Ev) {
}

function init_gecko_select_hack() {
return true;
var selects = document.getElementsByTagName("SELECT");
for(i=0; i<selects.length; i++)
selects.item(i).addEventListener("keyup", ev_gecko_select_keyup_ev, false);
Expand Down
24 changes: 24 additions & 0 deletions styles/adminstyle.css
Expand Up @@ -51,10 +51,34 @@ div.htmleditor {
}
.menubar a{display:inline-block;}


.menubar select {
margin-bottom: 0px;

}
.qtip-questiontype {
z-index: 100000;
background-color: white;
border: 1px solid #ddd;
max-width: 468px;
width: 468px;
}


/******************************************************************************/
/* Bootstrap overrides. */
/******************************************************************************/
label {display: inline-block !important;}
.select{
width: 250px;
margin-left: 10px;
}

.select * {
-moz-box-sizing: border-box;
box-sizing: border-box;
}

li input {
margin: 0px;
}

0 comments on commit 9c5e631

Please sign in to comment.