Adding block_default_userforms_css and block_default_userforms_ js config variables to control whether to load css and JavaScript files or not. (#562)

This commit is contained in:
3Dgoo 2017-04-01 20:32:18 +10:30 committed by Damian Mooyman
parent 84eecb0b76
commit d16692d9c1

View File

@ -35,6 +35,20 @@ class UserDefinedForm extends Page
*/
private static $upgrade_on_build = true;
/**
* Set this to true to disable automatic inclusion of CSS files
* @config
* @var bool
*/
private static $block_default_userforms_css = false;
/**
* Set this to true to disable automatic inclusion of JavaScript files
* @config
* @var bool
*/
private static $block_default_userforms_js = false;
/**
* Built in extensions required by this page
* @config
@ -369,9 +383,16 @@ class UserDefinedForm_Controller extends Page_Controller
{
parent::init();
// load the jquery
$lang = i18n::get_lang_from_locale(i18n::get_locale());
$page = $this->data();
// load the css
if (!$page->config()->block_default_userforms_css) {
Requirements::css(USERFORMS_DIR . '/css/UserForm.css');
}
// load the jquery
if (!$page->config()->block_default_userforms_js) {
$lang = i18n::get_lang_from_locale(i18n::get_locale());
Requirements::javascript(FRAMEWORK_DIR .'/thirdparty/jquery/jquery.js');
Requirements::javascript(USERFORMS_DIR . '/thirdparty/jquery-validate/jquery.validate.min.js');
Requirements::add_i18n_javascript(USERFORMS_DIR . '/javascript/lang');
@ -388,11 +409,11 @@ class UserDefinedForm_Controller extends Page_Controller
}
// Bind a confirmation message when navigating away from a partially completed form.
$page = $this->data();
if ($page::config()->enable_are_you_sure) {
Requirements::javascript(USERFORMS_DIR . '/thirdparty/jquery.are-you-sure/jquery.are-you-sure.js');
}
}
}
/**
* Using $UserDefinedForm in the Content area of the page shows