mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API: Remove js/css requirements include from form fields.
API: Remove InlineFormAction::includeDefaultJS() Developers must now take responsibility for including the necessary JS and CSS themselves. This has been implemented in the admin, but not in other use-cases.
This commit is contained in:
parent
a6049ec383
commit
8e89d08e7b
@ -501,27 +501,6 @@ class AssetField extends FileField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
|
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/ssui.core.js');
|
|
||||||
Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/client/lang');
|
|
||||||
|
|
||||||
Requirements::combine_files('uploadfield.js', array(
|
|
||||||
// @todo jquery templates is a project no longer maintained and should be retired at some point.
|
|
||||||
THIRDPARTY_DIR . '/javascript-templates/tmpl.js',
|
|
||||||
THIRDPARTY_DIR . '/javascript-loadimage/load-image.js',
|
|
||||||
THIRDPARTY_DIR . '/jquery-fileupload/jquery.iframe-transport.js',
|
|
||||||
THIRDPARTY_DIR . '/jquery-fileupload/cors/jquery.xdr-transport.js',
|
|
||||||
THIRDPARTY_DIR . '/jquery-fileupload/jquery.fileupload.js',
|
|
||||||
THIRDPARTY_DIR . '/jquery-fileupload/jquery.fileupload-ui.js',
|
|
||||||
FRAMEWORK_DIR . '/client/dist/js/UploadField_uploadtemplate.js',
|
|
||||||
FRAMEWORK_DIR . '/client/dist/js/UploadField_downloadtemplate.js',
|
|
||||||
FRAMEWORK_DIR . '/client/dist/js/UploadField.js',
|
|
||||||
));
|
|
||||||
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); // TODO hmmm, remove it?
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/UploadField.css');
|
|
||||||
|
|
||||||
// Calculated config as per jquery.fileupload-ui.js
|
// Calculated config as per jquery.fileupload-ui.js
|
||||||
$config = array(
|
$config = array(
|
||||||
'allowedMaxFileNumber' => 1, // Only one file allowed for AssetField
|
'allowedMaxFileNumber' => 1, // Only one file allowed for AssetField
|
||||||
|
@ -54,8 +54,6 @@ class CheckboxSetField extends MultiSelectField {
|
|||||||
* @return DBHTMLText
|
* @return DBHTMLText
|
||||||
*/
|
*/
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/CheckboxSetField.css');
|
|
||||||
|
|
||||||
$properties = array_merge($properties, array(
|
$properties = array_merge($properties, array(
|
||||||
'Options' => $this->getOptions()
|
'Options' => $this->getOptions()
|
||||||
));
|
));
|
||||||
|
@ -172,10 +172,6 @@ class ConfirmedPasswordField extends FormField {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/ConfirmedPasswordField.js');
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/ConfirmedPasswordField.css');
|
|
||||||
|
|
||||||
$content = '';
|
$content = '';
|
||||||
|
|
||||||
if($this->showOnClick) {
|
if($this->showOnClick) {
|
||||||
|
@ -85,16 +85,10 @@ class DateField_View_JQuery extends Object
|
|||||||
public function onAfterRender($html)
|
public function onAfterRender($html)
|
||||||
{
|
{
|
||||||
if ($this->getField()->getConfig('showcalendar')) {
|
if ($this->getField()->getConfig('showcalendar')) {
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
|
||||||
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
|
||||||
|
|
||||||
// Include language files (if required)
|
// Include language files (if required)
|
||||||
if ($this->jqueryLocaleFile) {
|
if ($this->jqueryLocaleFile) {
|
||||||
Requirements::javascript($this->jqueryLocaleFile);
|
Requirements::javascript($this->jqueryLocaleFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . "/client/dist/js/DateField.js");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
|
@ -118,7 +118,6 @@ class DatetimeField extends FormField {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/DatetimeField.css');
|
|
||||||
return parent::Field($properties);
|
return parent::Field($properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,16 +306,6 @@ class GridField extends FormField {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function FieldHolder($properties = array()) {
|
public function FieldHolder($properties = array()) {
|
||||||
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/GridField.css');
|
|
||||||
|
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/i18n.js');
|
|
||||||
Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/client/lang');
|
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/GridField.js');
|
|
||||||
|
|
||||||
$columns = $this->getColumns();
|
$columns = $this->getColumns();
|
||||||
|
|
||||||
$list = $this->getManipulatedList();
|
$list = $this->getManipulatedList();
|
||||||
|
@ -464,16 +464,7 @@ class TinyMCEConfig extends HTMLEditorConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
// These should be 'provides' by bundle-dist.js
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . "/thirdparty/jquery/jquery.js");
|
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
|
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/ssui.core.js');
|
|
||||||
|
|
||||||
// include TinyMCE Javascript
|
// include TinyMCE Javascript
|
||||||
Requirements::javascript($this->getScriptURL());
|
Requirements::javascript($this->getScriptURL());
|
||||||
Requirements::javascript(FRAMEWORK_DIR ."/client/dist/js/HtmlEditorField.js");
|
|
||||||
|
|
||||||
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,11 @@ use SilverStripe\View\Requirements;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Render a button that will submit the form its contained in through ajax.
|
* Render a button that will submit the form its contained in through ajax.
|
||||||
* If you want to add custom behaviour, please set {@link includeDefaultJS()} to FALSE
|
|
||||||
*
|
*
|
||||||
* @see framework/client/dist/js/InlineFormAction.js
|
* @see framework/client/dist/js/InlineFormAction.js
|
||||||
*/
|
*/
|
||||||
class InlineFormAction extends FormField {
|
class InlineFormAction extends FormField {
|
||||||
|
|
||||||
protected $includeDefaultJS = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new action button.
|
* Create a new action button.
|
||||||
*
|
*
|
||||||
@ -35,13 +32,6 @@ class InlineFormAction extends FormField {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
if($this->includeDefaultJS) {
|
|
||||||
Requirements::javascriptTemplate(
|
|
||||||
FRAMEWORK_DIR . '/client/dist/js/InlineFormAction.js',
|
|
||||||
array('ID'=>$this->ID())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FormField::create_tag('input', array(
|
return FormField::create_tag('input', array(
|
||||||
'type' => 'submit',
|
'type' => 'submit',
|
||||||
'name' => sprintf('action_%s', $this->getName()),
|
'name' => sprintf('action_%s', $this->getName()),
|
||||||
@ -54,14 +44,4 @@ class InlineFormAction extends FormField {
|
|||||||
public function Title() {
|
public function Title() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Optionally disable the default javascript include (framework/client/dist/js/InlineFormAction.js),
|
|
||||||
* which routes to an "admin-custom"-URL.
|
|
||||||
*
|
|
||||||
* @param $bool boolean
|
|
||||||
*/
|
|
||||||
public function includeDefaultJS($bool) {
|
|
||||||
$this->includeDefaultJS = (bool)$bool;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ class MemberDatetimeOptionsetField extends OptionsetField {
|
|||||||
private $descriptionTemplate = '';
|
private $descriptionTemplate = '';
|
||||||
|
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/MemberDatetimeOptionsetField.js');
|
|
||||||
$options = array();
|
$options = array();
|
||||||
$odd = false;
|
$odd = false;
|
||||||
|
|
||||||
|
@ -118,10 +118,6 @@ class SelectionGroup extends CompositeField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function FieldHolder($properties = array()) {
|
public function FieldHolder($properties = array()) {
|
||||||
Requirements::javascript(THIRDPARTY_DIR .'/jquery/jquery.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/SelectionGroup.js');
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/SelectionGroup.css');
|
|
||||||
|
|
||||||
return parent::FieldHolder($properties);
|
return parent::FieldHolder($properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,16 +124,6 @@ class TabSet extends CompositeField {
|
|||||||
* @return DBHTMLText|string
|
* @return DBHTMLText|string
|
||||||
*/
|
*/
|
||||||
public function FieldHolder($properties = array()) {
|
public function FieldHolder($properties = array()) {
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-cookie/jquery.cookie.js');
|
|
||||||
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css');
|
|
||||||
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/TabSet.js');
|
|
||||||
|
|
||||||
$obj = $properties ? $this->customise($properties) : $this;
|
$obj = $properties ? $this->customise($properties) : $this;
|
||||||
|
|
||||||
return $obj->renderWith($this->getTemplates());
|
return $obj->renderWith($this->getTemplates());
|
||||||
|
@ -38,13 +38,6 @@ class ToggleCompositeField extends CompositeField {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function FieldHolder($properties = array()) {
|
public function FieldHolder($properties = array()) {
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/ToggleCompositeField.js');
|
|
||||||
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css');
|
|
||||||
|
|
||||||
$context = $this;
|
$context = $this;
|
||||||
|
|
||||||
if(count($properties)) {
|
if(count($properties)) {
|
||||||
|
@ -224,16 +224,6 @@ class TreeDropdownField extends FormField {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/client/lang');
|
|
||||||
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jstree/jquery.jstree.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/TreeDropdownField.js');
|
|
||||||
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css');
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/TreeDropdownField.css');
|
|
||||||
|
|
||||||
$item = DataObject::singleton($this->sourceObject);
|
$item = DataObject::singleton($this->sourceObject);
|
||||||
$emptyTitle = _t(
|
$emptyTitle = _t(
|
||||||
'DropdownField.CHOOSE_MODEL',
|
'DropdownField.CHOOSE_MODEL',
|
||||||
|
@ -104,16 +104,6 @@ class TreeMultiselectField extends TreeDropdownField {
|
|||||||
* @return DBHTMLText
|
* @return DBHTMLText
|
||||||
*/
|
*/
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/client/lang');
|
|
||||||
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jstree/jquery.jstree.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/TreeDropdownField.js');
|
|
||||||
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css');
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/TreeDropdownField.css');
|
|
||||||
|
|
||||||
$value = '';
|
$value = '';
|
||||||
$titleArray = array();
|
$titleArray = array();
|
||||||
$idArray = array();
|
$idArray = array();
|
||||||
|
@ -956,27 +956,6 @@ class UploadField extends FileField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
|
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/ssui.core.js');
|
|
||||||
Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/client/lang');
|
|
||||||
|
|
||||||
Requirements::combine_files('uploadfield.js', array(
|
|
||||||
// @todo jquery templates is a project no longer maintained and should be retired at some point.
|
|
||||||
THIRDPARTY_DIR . '/javascript-templates/tmpl.js',
|
|
||||||
THIRDPARTY_DIR . '/javascript-loadimage/load-image.js',
|
|
||||||
THIRDPARTY_DIR . '/jquery-fileupload/jquery.iframe-transport.js',
|
|
||||||
THIRDPARTY_DIR . '/jquery-fileupload/cors/jquery.xdr-transport.js',
|
|
||||||
THIRDPARTY_DIR . '/jquery-fileupload/jquery.fileupload.js',
|
|
||||||
THIRDPARTY_DIR . '/jquery-fileupload/jquery.fileupload-ui.js',
|
|
||||||
FRAMEWORK_DIR . '/client/dist/js/UploadField_uploadtemplate.js',
|
|
||||||
FRAMEWORK_DIR . '/client/dist/js/UploadField_downloadtemplate.js',
|
|
||||||
FRAMEWORK_DIR . '/client/dist/js/UploadField.js',
|
|
||||||
));
|
|
||||||
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); // TODO hmmm, remove it?
|
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/UploadField.css');
|
|
||||||
|
|
||||||
// Calculated config as per jquery.fileupload-ui.js
|
// Calculated config as per jquery.fileupload-ui.js
|
||||||
$allowedMaxFileNumber = $this->getAllowedMaxFileNumber();
|
$allowedMaxFileNumber = $this->getAllowedMaxFileNumber();
|
||||||
$config = array(
|
$config = array(
|
||||||
|
@ -84,9 +84,6 @@ class PermissionCheckboxSetField extends FormField {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/CheckboxSetField.css');
|
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/PermissionCheckboxSetField.js');
|
|
||||||
|
|
||||||
$uninheritedCodes = array();
|
$uninheritedCodes = array();
|
||||||
$inheritedCodes = array();
|
$inheritedCodes = array();
|
||||||
$records = ($this->records) ? $this->records : new ArrayList();
|
$records = ($this->records) ? $this->records : new ArrayList();
|
||||||
|
Loading…
Reference in New Issue
Block a user