Skip to content

Commit

Permalink
Dev: jquery migrate integration according to debug mode
Browse files Browse the repository at this point in the history
Dev: use .min.js if debug==0
Dev: Fix some issue with map : must move to select2 in place of autocomplete
  • Loading branch information
Shnoulle committed Nov 18, 2016
1 parent 3c1de66 commit 84dd961
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
31 changes: 23 additions & 8 deletions application/config/third_party.php
Expand Up @@ -4,17 +4,32 @@
* This file contains package definition for third party libraries.
* Defining them here allows for easy inclusion in views.
*/
/* Tag if debug is set : debug is set in user config file and this file is directly required in internal.php where $userConfig var arry is set */
/* This allow us to use minified version according to debug */
$debug = isset($userConfig['config']['debug']) ? $userConfig['config']['debug'] : 0;

/* Please : comment the reason, mantis bug link: ajax don't need any package if i don't make error */
/* Ajax must renderPartial (better : always return json) and never render and don't registerScript (IMHO) / Shnoulle on 2016-11-16 */
if (!isset($_GET['isAjax']))
{
$aJquery = array(
'basePath' => 'third_party.jquery',
'js' => array(
'jquery-3.1.1.js',
'jquery-migrate-3.0.0.js',
));
if($debug >=2 ){
/* If debug mode is set to 2 or more : we show whole error of jquery migration : even jquery-ui error */
$aJquery = array(
'basePath' => 'third_party.jquery',
'js' => array(
'jquery-3.1.1.js',
'jquery-migrate-3.0.0.js',
)
);
}else{
$aJquery = array(
'basePath' => 'third_party.jquery',
'js' => array(
'jquery-3.1.1.min.js',
'jquery-migrate-3.0.0.min.js',
)
);
}
}
else
{
Expand Down Expand Up @@ -69,10 +84,10 @@
'jqueryui' => array(
'basePath' => 'third_party.jquery-ui',
'js' => array(
'jquery-ui.js'
($debug >=2 ) ? 'jquery-ui.js' : 'jquery-ui.min.js',
),
'css' => array(
//'css/jquery-ui.css'
'jquery-ui.structure.css', /* else autocomplete or other broken */
),
'depends' => array(
'jquery',
Expand Down
3 changes: 2 additions & 1 deletion application/helpers/qanda_helper.php
Expand Up @@ -3704,7 +3704,7 @@ function do_shortfreetext($ia)
}
elseif((int)($aQuestionAttributes['location_mapservice'])==100)
{
$coreClass .= " map-item geoloc-item";
$coreClass = " map-item geoloc-item";
$currentLocation = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]];
$currentCenter = $currentLatLong = null;

Expand Down Expand Up @@ -3742,6 +3742,7 @@ function do_shortfreetext($ia)

);
App()->getClientScript()->registerPackage('leaflet');
App()->getClientScript()->registerPackage('jqueryui');/* for autocomplete : must replace with select2 or another */
Yii::app()->getClientScript()->registerScript('sGlobalMapScriptVar',"LSmap=".ls_json_encode($aGlobalMapScriptVar).";\nLSmaps= new Array();",CClientScript::POS_HEAD);
Yii::app()->getClientScript()->registerScript('sThisMapScriptVar'.$ia[1],"LSmaps['{$ia[1]}']=".ls_json_encode($aThisMapScriptVar).";",CClientScript::POS_HEAD);
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."map.js");
Expand Down
Expand Up @@ -17,7 +17,7 @@
*/
?>

<div class="question answer-item geoloc-item <?php echo $extraclass; ?> row">
<div class="<?php echo $coreClass; ?> <?php echo $extraclass; ?> row">

<div class="geoname_search col-xs-12 col-sm-12 " >
<div class="input-group">
Expand Down Expand Up @@ -45,6 +45,7 @@ class="form-control"

<div class="col-xs-12 if-no-js col-sm-12 form-inline">
<!-- No javascript need a way to answer -->
<?php /* Where is the answer-item ? answer-item geoloc-item */ ?>
<input
type="hidden"
name="<?php echo $name; ?>"
Expand Down Expand Up @@ -108,7 +109,7 @@ class="mapservice"
</div>

<?php if($questionHelp):?>
<div class="questionhelp">
<div class="questionhelp col-xs-12">
<?php echo $question_text_help; ?>
</div>
<?php endif;?>
Expand Down
5 changes: 3 additions & 2 deletions styles-public/map.css
Expand Up @@ -3,7 +3,7 @@
[dir="ltr"] .coordinate-item{margin:0 0 0 1em}
.geoname_search {
position: relative;
z-index: 10000;
z-index: 1; /* for autocomplete */
float:right;
width:15em;
}
Expand All @@ -16,8 +16,9 @@
top: 0;
left: 0;
cursor: default;
background:#fff;
}
}

.geoname_search .ui-autocomplete {
position: absolute;
top: 0;
Expand Down
4 changes: 3 additions & 1 deletion templates/default/css/template-core.css
Expand Up @@ -18,7 +18,9 @@

/* awesome-bootstrap-checkbox */
li.radio-item,li.checkbox-item{display:block}

/* map item : .input-group-addon.checkbox-item : put awesome padding */
.dir-ltr .input-group-addon.radio-item,.dir-ltr .input-group-addon.checkbox-item {padding-left: 25px;}
.dir-rtl .input-group-addon.radio-item,.dir-rtl .input-group-addon.checkbox-item {padding-right: 25px;}
/* Else big label break*/
.radio-item label,.checkbox-item label {display:block}
.radio-item,.checkbox-item {
Expand Down

0 comments on commit 84dd961

Please sign in to comment.