Skip to content

Commit

Permalink
MINOR Rendering DateField instances with button by default in CMS
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed May 1, 2011
1 parent f0c9469 commit 9a595fb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions admin/code/LeftAndMain.php
Expand Up @@ -235,6 +235,9 @@ function init() {
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');

Expand Down
23 changes: 23 additions & 0 deletions admin/javascript/LeftAndMain.js
Expand Up @@ -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));

Expand Down

0 comments on commit 9a595fb

Please sign in to comment.