From 24695948d2eda3298aac9f3acdf3b3d25e1efec6 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 28 Oct 2014 16:16:00 +1000 Subject: [PATCH] Fixes API compatibility issues with new date picker, moves moment to it's own folder since it might be used for other things. --- .../bootstrap-datetimepicker.js | 27 +++++++++++++++++++ .../moment-with-locales.js | 0 .../datepicker/datepicker.controller.js | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) rename src/Umbraco.Web.UI.Client/lib/{datetimepicker => moment}/moment-with-locales.js (100%) diff --git a/src/Umbraco.Web.UI.Client/lib/datetimepicker/bootstrap-datetimepicker.js b/src/Umbraco.Web.UI.Client/lib/datetimepicker/bootstrap-datetimepicker.js index 0f2c9f2e34..1ec2e9374d 100644 --- a/src/Umbraco.Web.UI.Client/lib/datetimepicker/bootstrap-datetimepicker.js +++ b/src/Umbraco.Web.UI.Client/lib/datetimepicker/bootstrap-datetimepicker.js @@ -1373,12 +1373,39 @@ THE SOFTWARE. }; $.fn.datetimepicker = function (options) { + + ////////MODIFICATION FOR COMPATIBILITY WITH OLD DATEPICKER + //store the orig method args + var methodArgs = arguments; + ///////END MODIFICATION FOR COMPATIBILTIY + return this.each(function () { var $this = $(this), data = $this.data('DateTimePicker'); if (!data) { $this.data('DateTimePicker', new DateTimePicker(this, options)); } + else { + ////////MODIFICATION FOR COMPATIBILITY WITH OLD DATEPICKER + //this is how the old api was accessed, now it is accessed directly by the + // .data("DateTimePicker") of the element that is assigned. + if (methodArgs.length == 0) { + return; + } + var method = data[methodArgs[0]]; + if (!(typeof method == "function")) { + return; + } + var args = []; + //remove first argument, note that arguments is not a true array! so we need to do this manually + for (var i = 1; i < methodArgs.length; i++) { + args.push(methodArgs[i]); + } + //call the method + method.apply(this, args); + + ///////END MODIFICATION FOR COMPATIBILTIY + } }); }; diff --git a/src/Umbraco.Web.UI.Client/lib/datetimepicker/moment-with-locales.js b/src/Umbraco.Web.UI.Client/lib/moment/moment-with-locales.js similarity index 100% rename from src/Umbraco.Web.UI.Client/lib/datetimepicker/moment-with-locales.js rename to src/Umbraco.Web.UI.Client/lib/moment/moment-with-locales.js diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/datepicker/datepicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/datepicker/datepicker.controller.js index d9f138163c..9ad177285c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/datepicker/datepicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/datepicker/datepicker.controller.js @@ -48,7 +48,7 @@ function dateTimePickerController($scope, notificationsService, assetsService, a assetsService.loadCss('lib/datetimepicker/bootstrap-datetimepicker.min.css').then(function() { - var filesToLoad = ["lib/datetimepicker/moment-with-locales.js", + var filesToLoad = ["lib/moment/moment-with-locales.js", "lib/datetimepicker/bootstrap-datetimepicker.js"];