mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Rendering DateField instances with button by default in CMS
This commit is contained in:
parent
f0c94696c9
commit
9a595fbd25
@ -235,6 +235,9 @@ class LeftAndMain extends Controller {
|
||||
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.AddForm.js');
|
||||
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.Preview.js');
|
||||
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.BatchActions.js');
|
||||
|
||||
// Handled by LeftAndMain.js
|
||||
Requirements::block(SAPPHIRE_DIR . '/javascript/DateField.js');
|
||||
|
||||
Requirements::themedCSS('typography');
|
||||
|
||||
|
@ -276,6 +276,29 @@
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Duplicates functionality in DateField.js, but due to using entwine we can match
|
||||
* the DOM element on creation, rather than onclick - which allows us to decorate
|
||||
* the field with a calendar icon
|
||||
*/
|
||||
$('.LeftAndMain .field.date input.text').entwine({
|
||||
onmatch: function() {
|
||||
var holder = $(this).parents('.field.date:first'), config = holder.metadata({type: 'class'});
|
||||
if(!config.showcalendar) return;
|
||||
|
||||
config.showOn = 'button';
|
||||
if(config.locale && $.datepicker.regional[config.locale]) {
|
||||
config = $.extend(config, $.datepicker.regional[config.locale], {});
|
||||
}
|
||||
|
||||
$(this).datepicker(config);
|
||||
// // Unfortunately jQuery UI only allows configuration of icon images, not sprites
|
||||
// this.next('button').button('option', 'icons', {primary : 'ui-icon-calendar'});
|
||||
|
||||
this._super();
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
}(jQuery));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user