mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
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:
parent
84eecb0b76
commit
d16692d9c1
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user