Skip to content

Allow proper use in AMD/Common.js Environments #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};


var banner =
'\'use strict\';\n' +
'(function (root, factory) {\n' +
'if (typeof define === \'function\' && define.amd) {\n' +
'define([\'angular\', \'moment\'], function (angular, moment) {\n' +
'return factory({}, angular, moment);\n' +
'});\n' +
'}\n' +
'else if (typeof exports === \'object\') {\n' +
'module.exports = factory({}, require(\'angular\'), require(\'moment\'));\n' +
'}\n' +
'else if (angular) {\n' +
'factory(root, root.angular, root.moment);\n' +
'}\n' +
'}(this, function (global, angular, moment) {\n';

var footer ='}));';


module.exports = function (grunt) {
// load all grunt tasks
require('load-grunt-tasks')(grunt);
Expand Down Expand Up @@ -191,8 +211,8 @@ module.exports = function (grunt) {
src: ['<%= yeoman.app %>/scripts/{datePicker,input,dateRange,datePickerUtils}.js', '<%= yeoman.tmp %>/templates.js'],
dest: '<%= yeoman.dist %>/angular-datepicker.js',
options: {
banner:'\'use strict\';\n(function(angular){\n',
footer:'})(angular);',
banner:banner,
footer:footer,
// Replace all 'use strict' statements in the code with a single one at the top
process: function(src) {
return src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
Expand Down
334 changes: 120 additions & 214 deletions dist/angular-datepicker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
'use strict';
(function(angular){
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['angular', 'moment'], function (angular, moment) {
return factory({}, angular, moment);
});
}
else if (typeof exports === 'object') {
module.exports = factory({}, require('angular'), require('moment'));
}
else if (angular) {
factory(root, root.angular, root.moment);
}
}(this, function (global, angular, moment) {
/* global moment */
var Module = angular.module('datePicker', []);

Expand Down Expand Up @@ -909,220 +921,114 @@ Module.directive('dateTime', ['$compile', '$document', '$filter', 'dateTimeConfi

angular.module('datePicker').run(['$templateCache', function($templateCache) {
$templateCache.put('templates/datepicker.html',
"<div ng-switch=\"view\">\r" +
"\n" +
" <div ng-switch-when=\"date\">\r" +
"\n" +
" <table>\r" +
"\n" +
" <thead>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <th ng-click=\"prev()\">&lsaquo;</th>\r" +
"\n" +
" <th colspan=\"5\" class=\"switch\" ng-click=\"setView('month')\" ng-bind=\"date|mFormat:'YYYY MMMM':tz\"></th>\r" +
"\n" +
" <th ng-click=\"next()\">&rsaquo;</i></th>\r" +
"\n" +
" </tr>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <th ng-repeat=\"day in weekdays\" style=\"overflow: hidden\" ng-bind=\"day|mFormat:'ddd':tz\"></th>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </thead>\r" +
"\n" +
" <tbody>\r" +
"\n" +
" <tr ng-repeat=\"week in weeks\" ng-init=\"$index2 = $index\">\r" +
"\n" +
" <td ng-repeat=\"day in week\">\r" +
"\n" +
" <span\r" +
"\n" +
" ng-class=\"classes[$index2][$index]\"\r" +
"\n" +
" ng-click=\"selectDate(day)\" ng-bind=\"day|mFormat:'DD':tz\"></span>\r" +
"\n" +
" </td>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </tbody>\r" +
"\n" +
" </table>\r" +
"\n" +
" </div>\r" +
"\n" +
" <div ng-switch-when=\"year\">\r" +
"\n" +
" <table>\r" +
"\n" +
" <thead>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <th ng-click=\"prev(10)\">&lsaquo;</th>\r" +
"\n" +
" <th colspan=\"5\" class=\"switch\"ng-bind=\"years[0].year()+' - '+years[years.length-1].year()\"></th>\r" +
"\n" +
" <th ng-click=\"next(10)\">&rsaquo;</i></th>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </thead>\r" +
"\n" +
" <tbody>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <td colspan=\"7\">\r" +
"\n" +
" <span ng-class=\"classes[$index]\"\r" +
"\n" +
" ng-repeat=\"year in years\"\r" +
"\n" +
" ng-click=\"selectDate(year)\" ng-bind=\"year.year()\"></span>\r" +
"\n" +
" </td>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </tbody>\r" +
"\n" +
" </table>\r" +
"\n" +
" </div>\r" +
"\n" +
" <div ng-switch-when=\"month\">\r" +
"\n" +
" <table>\r" +
"\n" +
" <thead>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <th ng-click=\"prev()\">&lsaquo;</th>\r" +
"\n" +
" <th colspan=\"5\" class=\"switch\" ng-click=\"setView('year')\" ng-bind=\"date|mFormat:'YYYY':tz\"></th>\r" +
"\n" +
" <th ng-click=\"next()\">&rsaquo;</i></th>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </thead>\r" +
"\n" +
" <tbody>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <td colspan=\"7\">\r" +
"\n" +
" <span ng-repeat=\"month in months\"\r" +
"\n" +
" ng-class=\"classes[$index]\"\r" +
"\n" +
" ng-click=\"selectDate(month)\"\r" +
"\n" +
" ng-bind=\"month|mFormat:'MMM':tz\"></span>\r" +
"\n" +
" </td>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </tbody>\r" +
"\n" +
" </table>\r" +
"\n" +
" </div>\r" +
"\n" +
" <div ng-switch-when=\"hours\">\r" +
"\n" +
" <table>\r" +
"\n" +
" <thead>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <th ng-click=\"prev(24)\">&lsaquo;</th>\r" +
"\n" +
" <th colspan=\"5\" class=\"switch\" ng-click=\"setView('date')\" ng-bind=\"date|mFormat:'DD MMMM YYYY':tz\"></th>\r" +
"\n" +
" <th ng-click=\"next(24)\">&rsaquo;</i></th>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </thead>\r" +
"\n" +
" <tbody>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <td colspan=\"7\">\r" +
"\n" +
" <span ng-repeat=\"hour in hours\"\r" +
"\n" +
" ng-class=\"classes[$index]\"\r" +
"\n" +
" ng-click=\"selectDate(hour)\" ng-bind=\"hour|mFormat:'HH:mm':tz\"></span>\r" +
"\n" +
" </td>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </tbody>\r" +
"\n" +
" </table>\r" +
"\n" +
" </div>\r" +
"\n" +
" <div ng-switch-when=\"minutes\">\r" +
"\n" +
" <table>\r" +
"\n" +
" <thead>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <th ng-click=\"prev()\">&lsaquo;</th>\r" +
"\n" +
" <th colspan=\"5\" class=\"switch\" ng-click=\"setView('hours')\" ng-bind=\"date|mFormat:'DD MMMM YYYY':tz\"></th>\r" +
"\n" +
" <th ng-click=\"next()\">&rsaquo;</i></th>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </thead>\r" +
"\n" +
" <tbody>\r" +
"\n" +
" <tr>\r" +
"\n" +
" <td colspan=\"7\">\r" +
"\n" +
" <span ng-repeat=\"minute in minutes\"\r" +
"\n" +
" ng-class=\"classes[$index]\"\r" +
"\n" +
" ng-click=\"selectDate(minute)\"\r" +
"\n" +
" ng-bind=\"minute|mFormat:'HH:mm':tz\"></span>\r" +
"\n" +
" </td>\r" +
"\n" +
" </tr>\r" +
"\n" +
" </tbody>\r" +
"\n" +
" </table>\r" +
"\n" +
" </div>\r" +
"\n" +
"<div ng-switch=\"view\">\n" +
" <div ng-switch-when=\"date\">\n" +
" <table>\n" +
" <thead>\n" +
" <tr>\n" +
" <th ng-click=\"prev()\">&lsaquo;</th>\n" +
" <th colspan=\"5\" class=\"switch\" ng-click=\"setView('month')\" ng-bind=\"date|mFormat:'YYYY MMMM':tz\"></th>\n" +
" <th ng-click=\"next()\">&rsaquo;</i></th>\n" +
" </tr>\n" +
" <tr>\n" +
" <th ng-repeat=\"day in weekdays\" style=\"overflow: hidden\" ng-bind=\"day|mFormat:'ddd':tz\"></th>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" <tr ng-repeat=\"week in weeks\" ng-init=\"$index2 = $index\">\n" +
" <td ng-repeat=\"day in week\">\n" +
" <span\n" +
" ng-class=\"classes[$index2][$index]\"\n" +
" ng-click=\"selectDate(day)\" ng-bind=\"day|mFormat:'DD':tz\"></span>\n" +
" </td>\n" +
" </tr>\n" +
" </tbody>\n" +
" </table>\n" +
" </div>\n" +
" <div ng-switch-when=\"year\">\n" +
" <table>\n" +
" <thead>\n" +
" <tr>\n" +
" <th ng-click=\"prev(10)\">&lsaquo;</th>\n" +
" <th colspan=\"5\" class=\"switch\"ng-bind=\"years[0].year()+' - '+years[years.length-1].year()\"></th>\n" +
" <th ng-click=\"next(10)\">&rsaquo;</i></th>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" <tr>\n" +
" <td colspan=\"7\">\n" +
" <span ng-class=\"classes[$index]\"\n" +
" ng-repeat=\"year in years\"\n" +
" ng-click=\"selectDate(year)\" ng-bind=\"year.year()\"></span>\n" +
" </td>\n" +
" </tr>\n" +
" </tbody>\n" +
" </table>\n" +
" </div>\n" +
" <div ng-switch-when=\"month\">\n" +
" <table>\n" +
" <thead>\n" +
" <tr>\n" +
" <th ng-click=\"prev()\">&lsaquo;</th>\n" +
" <th colspan=\"5\" class=\"switch\" ng-click=\"setView('year')\" ng-bind=\"date|mFormat:'YYYY':tz\"></th>\n" +
" <th ng-click=\"next()\">&rsaquo;</i></th>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" <tr>\n" +
" <td colspan=\"7\">\n" +
" <span ng-repeat=\"month in months\"\n" +
" ng-class=\"classes[$index]\"\n" +
" ng-click=\"selectDate(month)\"\n" +
" ng-bind=\"month|mFormat:'MMM':tz\"></span>\n" +
" </td>\n" +
" </tr>\n" +
" </tbody>\n" +
" </table>\n" +
" </div>\n" +
" <div ng-switch-when=\"hours\">\n" +
" <table>\n" +
" <thead>\n" +
" <tr>\n" +
" <th ng-click=\"prev(24)\">&lsaquo;</th>\n" +
" <th colspan=\"5\" class=\"switch\" ng-click=\"setView('date')\" ng-bind=\"date|mFormat:'DD MMMM YYYY':tz\"></th>\n" +
" <th ng-click=\"next(24)\">&rsaquo;</i></th>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" <tr>\n" +
" <td colspan=\"7\">\n" +
" <span ng-repeat=\"hour in hours\"\n" +
" ng-class=\"classes[$index]\"\n" +
" ng-click=\"selectDate(hour)\" ng-bind=\"hour|mFormat:'HH:mm':tz\"></span>\n" +
" </td>\n" +
" </tr>\n" +
" </tbody>\n" +
" </table>\n" +
" </div>\n" +
" <div ng-switch-when=\"minutes\">\n" +
" <table>\n" +
" <thead>\n" +
" <tr>\n" +
" <th ng-click=\"prev()\">&lsaquo;</th>\n" +
" <th colspan=\"5\" class=\"switch\" ng-click=\"setView('hours')\" ng-bind=\"date|mFormat:'DD MMMM YYYY':tz\"></th>\n" +
" <th ng-click=\"next()\">&rsaquo;</i></th>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" <tr>\n" +
" <td colspan=\"7\">\n" +
" <span ng-repeat=\"minute in minutes\"\n" +
" ng-class=\"classes[$index]\"\n" +
" ng-click=\"selectDate(minute)\"\n" +
" ng-bind=\"minute|mFormat:'HH:mm':tz\"></span>\n" +
" </td>\n" +
" </tr>\n" +
" </tbody>\n" +
" </table>\n" +
" </div>\n" +
"</div>"
);

}]);
})(angular);
}));
Loading