Skip to content

Commit

Permalink
Item12511: adding HTML5 data attr when init'ing
Browse files Browse the repository at this point in the history
* defaulting to yyy-mm-dd for jquery-ui date picker
  • Loading branch information
MichaelDaum committed Feb 23, 2016
1 parent f260fea commit 208b381
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// initializer for the ui-datepicker plugin
jQuery(function($) {
'use strict';

var datepickerDefaults = {
dateFormat:'d M yy',
dateFormat:'yy-mm-dd',
firstDay: 1,
showOn: 'button',
buttonText: "<i class='fa fa-calendar'></i>"
};

$(".jqUIDatepicker").livequery(function() {
var $this = $(this),
opts = $.extend({}, datepickerDefaults, $this.metadata(), $this.data()),
maxZIndex = 1;
opts = $.extend({}, datepickerDefaults, $this.data(), $this.metadata()),
maxZIndex = 1, val = $this.val();

$this.parents().each(function() {
var zIndex = parseInt($(this).css("z-index"), 10);
Expand All @@ -24,7 +25,12 @@ jQuery(function($) {
"position": "relative",
"z-index": maxZIndex + 1
});

$this.datepicker(opts);

if (val !== '') {
$this.datepicker("setDate", new Date(val));
}

});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// initializer for the ui-dialog plugin
jQuery(function($) {
'use strict';

var dialogDefaults = {
width: 300,
Expand All @@ -18,7 +19,7 @@ jQuery(function($) {
// dialog
$(".jqUIDialog").livequery(function() {
var $this = $(this),
opts = $.extend({}, dialogDefaults, $this.metadata(), $this.data()),
opts = $.extend({}, dialogDefaults, $this.data(), $this.metadata()),
buttons = [];

if (!opts.cached) {
Expand Down Expand Up @@ -59,7 +60,7 @@ jQuery(function($) {
$this.find("form:first").submit();
};
}
$.extend(button, $button.metadata());
$.extend(button, $button.data(), $button.metadata());

if (typeof(button.click) === 'undefined') {
button.click = function() {};
Expand Down Expand Up @@ -112,7 +113,7 @@ jQuery(function($) {
$(document).on("click", ".jqUIDialogLink", function() {
var $this = $(this),
href = $this.attr("href"),
opts = $.extend({}, dialogLinkDefaults, $this.metadata());
opts = $.extend({}, dialogLinkDefaults, $this.data(), $this.metadata());

if (href.match(/^(https?:)|\//)) {
// this is a link to remote data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
jQuery(function($) {

$(".jqUITabs").livequery(function() {
var $this = $(this), opts = $.extend({}, $this.metadata(), $this.data());
var $this = $(this), opts = $.extend({}, $this.data(), $this.metadata());
$this.removeClass("jqUITabs").tabs(opts);
});

Expand Down

0 comments on commit 208b381

Please sign in to comment.