Skip to content

Commit

Permalink
Dev: added global setting for js debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Dec 14, 2017
1 parent 5cea34f commit bcfccca
Show file tree
Hide file tree
Showing 17 changed files with 2,744 additions and 100 deletions.
2 changes: 1 addition & 1 deletion application/config/internal.php
Expand Up @@ -120,7 +120,7 @@
),
// These are defaults and are later overwritten in LSYii_Application by a path based on config tempdir/tempurl
'assetManager' => array(
'excludeFiles' => array("config.xml", "node_modules/*", "src/*"),
'excludeFiles' => array("config.xml", "node_modules", "src"),
'class' => 'application.core.LSYii_AssetManager'
),

Expand Down
22 changes: 18 additions & 4 deletions application/config/packages.php
Expand Up @@ -134,9 +134,14 @@
'pjax' => array(
'devBaseUrl' => 'assets/packages/pjax/',
'basePath' => 'core.pjax',
'js' => array(
'pjax'.$minVersion.'.js',
'loadPjax'.$minVersion.'.js'
'js' => ($debug > 0 ?
array(
'pjax.js',
'loadPjax.js'
)
: array(
'min/pjax.min.js',
)
),
),
'adminpanel' => array(
Expand Down Expand Up @@ -168,10 +173,18 @@
'adminbasics',
)
),
'lslog' => array(
'devBaseUrl' => 'assets/packages/lslog/',
'basePath' => 'core.lslog',
'js' => array(
// 'build/lslog'.$minVersion.'.js',
'build/lslog.js',
)
),
'adminbasics' => array(
'devBaseUrl' => 'assets/packages/adminbasics/',
'basePath' => 'core.adminbasics',
'position' =>CClientScript::POS_BEGIN,
'position' =>CClientScript::POS_HEAD,
'css' => array(
'css/lime-admin-common.css',
'css/jcarousel.responsive.css',
Expand All @@ -187,6 +200,7 @@
'depends' => array(
'jquery',
'pjax',
'lslog',
)
),

Expand Down
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -17,5 +17,5 @@
$config['dbversionnumber'] = 329;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '3019';
$config['assetsversionnumber'] = '3020';
return $config;
3 changes: 3 additions & 0 deletions application/controllers/admin/globalsettings.php
Expand Up @@ -225,6 +225,9 @@ private function _saveSettings()
setGlobalSetting('defaulthtmleditormode', sanitize_paranoid_string($_POST['defaulthtmleditormode']));
setGlobalSetting('defaultquestionselectormode', sanitize_paranoid_string(Yii::app()->getRequest()->getPost('defaultquestionselectormode', 'default')));
setGlobalSetting('defaultthemeteeditormode', sanitize_paranoid_string(Yii::app()->getRequest()->getPost('defaultthemeteeditormode', 'default')));
setGlobalSetting('javascriptdebugbcknd', sanitize_paranoid_string(Yii::app()->getRequest()->getPost('javascriptdebugbcknd', false)));
setGlobalSetting('javascriptdebugfrntnd', sanitize_paranoid_string(Yii::app()->getRequest()->getPost('javascriptdebugfrntnd', false)));

if (!Yii::app()->getConfig('demoMode')) {
$sTemplate = Yii::app()->getRequest()->getPost("defaulttheme");
if (array_key_exists($sTemplate, getTemplateList())) {
Expand Down
17 changes: 10 additions & 7 deletions application/core/LSYii_ClientScript.php
Expand Up @@ -400,8 +400,11 @@ public function renderHead(&$output)
}

//Propagate our debug settings into the javascript realm
$debug = Yii::app()->getConfig('debug', 0);
$html .= "<script type='text/javascript'>window.debugState=".$debug.";</script>";

$debugFrontend = (int) getGlobalSetting('javascriptdebugfrntnd');

This comment has been minimized.

Copy link
@olleharstedt

olleharstedt Dec 15, 2017

Collaborator

This breaks the installer. See Travis.

This comment has been minimized.

Copy link
@olleharstedt

olleharstedt Dec 15, 2017

Collaborator

It seems like the settings helper file assumes there's a database setup, which there is not during installation.

$debugBackend = (int) getGlobalSetting('javascriptdebugbcknd');

$html .= "<script type='text/javascript'>window.debugState = {frontend : (".$debugFrontend." === 1), backend : (".$debugBackend." === 1)};</script>";

if ($this->enableJavaScript) {
if (isset($this->scriptFiles[self::POS_HEAD])) {
Expand Down Expand Up @@ -530,11 +533,11 @@ public function renderBodyEnd(&$output)
}
}
if (App()->getConfig('debug') > 0) {
$scripts[] = "jQuery(document).off('pjax:scriptsuccess.debugger').on('pjax:scriptsuccess.debugger',function(e) { console.log('PJAX scriptsuccess', e); });";
$scripts[] = "jQuery(document).off('pjax:scripterror.debugger').on('pjax:scripterror.debugger',function(e) { console.log('PJAX scripterror', e); });";
$scripts[] = "jQuery(document).off('pjax:scripttimeout.debugger').on('pjax:scripttimeout.debugger',function(e) { console.log('PJAX scripttimeout', e); });";
$scripts[] = "jQuery(document).off('pjax:success.debugger').on('pjax:success.debugger',function(e) { console.log('PJAX success', e);});";
$scripts[] = "jQuery(document).off('pjax:error.debugger').on('pjax:error.debugger',function(e) { console.log('PJAX error', e);});";
$scripts[] = "jQuery(document).off('pjax:scriptsuccess.debugger').on('pjax:scriptsuccess.debugger',function(e) { console.ls.log('PJAX scriptsuccess', e); });";
$scripts[] = "jQuery(document).off('pjax:scripterror.debugger').on('pjax:scripterror.debugger',function(e) { console.ls.log('PJAX scripterror', e); });";
$scripts[] = "jQuery(document).off('pjax:scripttimeout.debugger').on('pjax:scripttimeout.debugger',function(e) { console.ls.log('PJAX scripttimeout', e); });";
$scripts[] = "jQuery(document).off('pjax:success.debugger').on('pjax:success.debugger',function(e) { console.ls.log('PJAX success', e);});";
$scripts[] = "jQuery(document).off('pjax:error.debugger').on('pjax:error.debugger',function(e) { console.ls.log('PJAX error', e);});";
}

//All scripts are wrapped into a section to be able to reload them accordingly
Expand Down
58 changes: 47 additions & 11 deletions application/views/admin/global_settings/_general.php
Expand Up @@ -18,7 +18,7 @@
<div class="ls-flex-column ls-space padding left-5 right-5 col-md-7">
<!-- Global sitename -->
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='sitename'>
<?php eT("Site name:"); echo ((Yii::app()->getConfig("demoMode")==true)?'*':''); ?>
</label>
Expand All @@ -29,7 +29,7 @@
</div>
<!-- Default Template -->
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for="defaulttheme">
<?php eT("Default theme:"); echo ((Yii::app()->getConfig("demoMode")==true)?'*':'');?>
</label>
Expand All @@ -46,7 +46,7 @@
</div>
<!-- Administrative Template -->
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for="admintheme">
<?php eT("Administration theme:"); ?>
</label>
Expand All @@ -69,7 +69,7 @@
</div>
</div>
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='timeadjust'>
<?php eT("Time difference (in hours):"); ?>
</label>
Expand Down Expand Up @@ -99,7 +99,7 @@
</div>
<?php endif; ?>
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='ipInfoDbAPIKey'>
<?php eT("IP Info DB API Key:"); ?>
</label>
Expand All @@ -109,7 +109,7 @@
</div>
</div>
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='googleMapsAPIKey'>
<?php eT("Google Maps API key:"); ?>
</label>
Expand All @@ -120,7 +120,7 @@
</div>

<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='googleanalyticsapikey'>
<?php eT("Google Analytics Tracking ID:"); ?>
</label>
Expand All @@ -130,7 +130,7 @@
</div>
</div>
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='googletranslateapikey'>
<?php eT("Google Translate API key:"); ?>
</label>
Expand Down Expand Up @@ -165,7 +165,7 @@
<div class="ls-flex-column ls-space padding left-5 right-5 col-md-5">
<!-- Default Editor mode -->
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='defaulthtmleditormode'>
<?php eT("Default HTML editor mode:"); echo ((Yii::app()->getConfig("demoMode")==true)?'*':''); ?>
</label>
Expand Down Expand Up @@ -208,7 +208,7 @@
</div>
<!-- Default question type selector mode -->
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='defaultquestionselectormode'>
<?php eT("Question type selector:"); echo((Yii::app()->getConfig("demoMode")==true)?'*':''); ?>
</label>
Expand All @@ -228,7 +228,7 @@
</div>
<!-- Default theme editor mode -->
<div class="row ls-space margin top-10">
<div class="form-group">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='defaultthemeteeditormode'>
<?php eT("Template editor:"); echo ((Yii::app()->getConfig("demoMode")==true)?'*':''); ?>
</label>
Expand All @@ -246,6 +246,42 @@
</div>
</div>
</div>
<!-- Default theme editor mode -->
<div class="row ls-space margin top-10">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='javascriptdebugbcknd'>
<?php eT("JS-Debug mode [Backend]:"); echo ((Yii::app()->getConfig("demoMode")==true)?'*':''); ?>
</label>
<div class="col-sm-12">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'javascriptdebugbcknd',
'id'=>'javascriptdebugbcknd',
'value' => getGlobalSetting('javascriptdebugbcknd'),
'onLabel'=>gT('On'),
'offLabel' => gT('Off')
));
?>
</div>
</div>
</div>
<!-- Default theme editor mode -->
<div class="row ls-space margin top-10">
<div class="form-group col-xs-12">
<label class="col-sm-12 text-left control-label" for='javascriptdebugfrntnd'>
<?php eT("JS-Debug mode [Frontend]:"); echo ((Yii::app()->getConfig("demoMode")==true)?'*':''); ?>
</label>
<div class="col-sm-12">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'javascriptdebugfrntnd',
'id'=>'javascriptdebugfrntnd',
'value' => getGlobalSetting('javascriptdebugfrntnd'),
'onLabel'=>gT('On'),
'offLabel' => gT('Off')
));
?>
</div>
</div>
</div>
</div>
</div>

Expand Down
6 changes: 3 additions & 3 deletions assets/packages/adminbasics/js/admin_core.js
Expand Up @@ -20,7 +20,7 @@ var LS = LS || { onDocumentReady: {} };
/* Set a variable to test if browser have HTML5 form ability
* Need to be replaced by some polyfills see #8009
*/
hasFormValidation= typeof document.createElement( 'input' ).checkValidity == 'function';
window.hasFormValidation= typeof document.createElement( 'input' ).checkValidity == 'function';

/* See function */
fixAccordionPosition();
Expand Down Expand Up @@ -244,8 +244,8 @@ function surveyQuickActionTrigger(){
// html contains the buttons
success : function(data, statut){
var newState = parseInt(data.newState);
console.log('quickaction resolve', data);
console.log('quickaction new state', newState);
console.ls.log('quickaction resolve', data);
console.ls.log('quickaction new state', newState);
$self.data('active', newState);
if(newState === 1){
$('#survey-action-container').slideDown(500);
Expand Down
1 change: 1 addition & 0 deletions assets/packages/emailtemplates/emailtemplates.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bcfccca

Please sign in to comment.