MINOR Rendering DateField instances with button by default in CMS

This commit is contained in:
Ingo Schommer 2011-04-30 18:34:14 +12:00
parent f0c94696c9
commit 9a595fbd25
2 changed files with 26 additions and 0 deletions

View File

@ -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');

View File

@ -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));