init commit

This commit is contained in:
2025-02-23 20:52:25 +01:00
parent 5b272d6536
commit 9971cd719b
1719 changed files with 281982 additions and 2 deletions

View File

@ -0,0 +1,35 @@
{
"name": "angular-jquery-timepicker",
"version": "0.13.1",
"homepage": "https://github.com/Recras/angular-jquery-timepicker",
"description": "An AngularJS directive for jQuery Timepicker",
"main": "./src/timepickerdirective.js",
"authors": [
"https://github.com/Recras/angular-jquery-timepicker/graphs/contributors"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": ">= 1.3",
"jquery-timepicker-jt": "1.2 - 1.8"
},
"devDependencies": {
"angular-mocks": "~1.x",
"moment": "~2.9.0"
},
"_release": "0.13.1",
"_resolution": {
"type": "version",
"tag": "0.13.1",
"commit": "bd97ee88e11614e32d37c0510893a8c98ceef701"
},
"_source": "https://github.com/Recras/angular-jquery-timepicker.git",
"_target": "~0.13",
"_originalSource": "angular-jquery-timepicker"
}

View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 Recras
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,53 @@
angular-jquery-timepicker [![Build Status](https://travis-ci.org/Recras/angular-jquery-timepicker.png?branch=master)](https://travis-ci.org/Recras/angular-jquery-timepicker)
=====================
An AngularJS directive for [jquery-timepicker](https://github.com/jonthornton/jquery-timepicker)
[See a demo here](http://recras.github.io/angular-jquery-timepicker/)
# Requirements
- AngularJS
- JQuery
- [jquery-timepicker](https://github.com/jonthornton/jquery-timepicker)
# Usage
You can use Bower or NPM to install this directive.
bower install angular-jquery-timepicker
or for NPM:
npm install angular-jquery-timepicker
Add the timepicker module as a dependency to your applicatin module:
var myAppModule = angular.module('MyApp', ['ui.timepicker'])
Apply the directive to your form elements. This directive expects ng-model to be a valid javascript Date object (or null).
<input ui-timepicker ng-model="someDateObject">
You can specify a base-date that will be used to initialize the ng-model when it is null
<input ui-timepicker ng-model="someNullObject" base-date"someDateObject">
Configure timepicker at a global level. Use the 'asMoment' to use moment.js instead of Date as the ng-model. Note: moment.js timezones will be discarded.
angular.module('ui.timepicker').value('uiTimepickerConfig',{
step: 5,
asMoment: true
});
Adding custom options to timepicker.
$scope.timePickerOptions = {
step: 20,
timeFormat: 'g:ia',
appendTo: 'body'
};
<input ui-timepicker="timePickerOptions" ng-model="someDateObject">

View File

@ -0,0 +1,26 @@
{
"name": "angular-jquery-timepicker",
"version": "0.13.1",
"homepage": "https://github.com/Recras/angular-jquery-timepicker",
"description": "An AngularJS directive for jQuery Timepicker",
"main": "./src/timepickerdirective.js",
"authors": [
"https://github.com/Recras/angular-jquery-timepicker/graphs/contributors"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": ">= 1.3",
"jquery-timepicker-jt": "1.2 - 1.8"
},
"devDependencies": {
"angular-mocks": "~1.x",
"moment": "~2.9.0"
}
}

View File

@ -0,0 +1,48 @@
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task.
grunt.registerTask('default', ['jshint', 'uglify', 'karma']);
var testConfig = function(configFile, customOptions) {
var options = { configFile: configFile, keepalive: true };
var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' };
return grunt.util._.extend(options, customOptions, travisOptions);
};
// Project configuration.
grunt.initConfig({
karma: {
unit: {
options: testConfig('test/test.conf.js')
}
},
jshint:{
files:['src/timepickerdirective.js', 'test/**/*.js'],
options:{
curly:true,
eqeqeq:true,
immed:true,
latedef:true,
newcap:true,
noarg:true,
sub:true,
boss:true,
eqnull:true,
globals:{}
}
},
uglify: {
dist: {
files: {
'src/timepickerdirective.min.js': ['src/timepickerdirective.js']
}
}
}
});
};

View File

@ -0,0 +1,26 @@
{
"name": "angular-jquery-timepicker",
"version": "0.13.1",
"description": "An AngularJS directive for jQuery Timepicker",
"main": "./src/timepickerdirective.js",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-uglify": "~0.3.3",
"grunt-karma": "~0.6.2"
},
"dependencies": {},
"scripts": {
"test": "grunt karma"
},
"repository": {
"type": "git",
"url": "git@github.com:Recras/angular-jquery-timepicker.git"
},
"author": "https://github.com/Recras/angular-jquery-timepicker/graphs/contributors",
"license": "MIT",
"bugs": {
"url": "https://github.com/Recras/angular-jquery-timepicker/issues"
},
"homepage": "https://github.com/Recras/angular-jquery-timepicker"
}

View File

@ -0,0 +1,126 @@
/*global angular */
/*
Directive for jQuery UI timepicker (http://jonthornton.github.io/jquery-timepicker/)
*/
var m = angular.module('ui.timepicker', []);
m.value('uiTimepickerConfig', {
'step': 15
});
m.directive('uiTimepicker', ['uiTimepickerConfig', '$parse', '$window', function(uiTimepickerConfig, $parse, $window) {
var moment = $window.moment;
var isAMoment = function(date) {
return moment !== undefined && moment.isMoment(date) && date.isValid();
};
var isDateOrMoment = function(date) {
return date !== null && (angular.isDate(date) || isAMoment(date));
};
return {
restrict: 'A',
require: 'ngModel',
scope: {
ngModel: '=',
baseDate: '=',
uiTimepicker: '=',
},
priority: 1,
link: function(scope, element, attrs, ngModel) {
'use strict';
var config = angular.copy(uiTimepickerConfig);
var asMoment = config.asMoment || false;
delete config.asMoment;
ngModel.$render = function() {
var date = ngModel.$modelValue;
if (!angular.isDefined(date)) {
return;
}
if (date !== null && date !== '' && !isDateOrMoment(date)) {
throw new Error('ng-Model value must be a Date or Moment object - currently it is a ' + typeof date + '.');
}
if (isAMoment(date)) {
date = date.toDate();
}
if (!element.is(':focus') && !invalidInput()) {
element.timepicker('setTime', date);
}
if(date === null){
resetInput();
}
};
scope.$watch('ngModel', function() {
ngModel.$render();
}, true);
scope.$watch('uiTimepicker', function() {
element.timepicker(
'option',
angular.extend(
config, scope.uiTimepicker ?
scope.uiTimepicker :
{}
)
);
ngModel.$render();
}, true);
config.appendTo = config.appendTo || element.parent();
element.timepicker(
angular.extend(
config, scope.uiTimepicker ?
scope.uiTimepicker :
{}
)
);
var resetInput = function(){
element.timepicker('setTime', null);
};
var userInput = function() {
return element.val().trim();
};
var invalidInput = function() {
return userInput() && ngModel.$modelValue === null;
};
element.on('$destroy', function() {
element.timepicker('remove');
});
var asDate = function() {
var baseDate = ngModel.$modelValue ? ngModel.$modelValue : scope.baseDate;
return isAMoment(baseDate) ? baseDate.toDate() : baseDate;
};
var asMomentOrDate = function(date) {
return asMoment ? moment(date) : date;
};
if (element.is('input')) {
ngModel.$parsers.unshift(function(viewValue) {
var date = element.timepicker('getTime', asDate());
return date ? asMomentOrDate(date) : date;
});
ngModel.$validators.time = function(modelValue) {
return (!attrs.required && !userInput()) ? true : isDateOrMoment(modelValue);
};
} else {
element.on('changeTime', function() {
scope.$evalAsync(function() {
var date = element.timepicker('getTime', asDate());
ngModel.$setViewValue(date);
});
});
}
}
};
}]);

View File

@ -0,0 +1 @@
var m=angular.module("ui.timepicker",[]);m.value("uiTimepickerConfig",{step:15}),m.directive("uiTimepicker",["uiTimepickerConfig","$parse","$window",function(a,b,c){var d=c.moment,e=function(a){return void 0!==d&&d.isMoment(a)&&a.isValid()},f=function(a){return null!==a&&(angular.isDate(a)||e(a))};return{restrict:"A",require:"ngModel",scope:{ngModel:"=",baseDate:"=",uiTimepicker:"="},priority:1,link:function(b,c,g,h){"use strict";var i=angular.copy(a),j=i.asMoment||!1;delete i.asMoment,h.$render=function(){var a=h.$modelValue;if(angular.isDefined(a)){if(null!==a&&""!==a&&!f(a))throw new Error("ng-Model value must be a Date or Moment object - currently it is a "+typeof a+".");e(a)&&(a=a.toDate()),c.is(":focus")||m()||c.timepicker("setTime",a),null===a&&k()}},b.$watch("ngModel",function(){h.$render()},!0),b.$watch("uiTimepicker",function(){c.timepicker("option",angular.extend(i,b.uiTimepicker?b.uiTimepicker:{})),h.$render()},!0),i.appendTo=i.appendTo||c.parent(),c.timepicker(angular.extend(i,b.uiTimepicker?b.uiTimepicker:{}));var k=function(){c.timepicker("setTime",null)},l=function(){return c.val().trim()},m=function(){return l()&&null===h.$modelValue};c.on("$destroy",function(){c.timepicker("remove")});var n=function(){var a=h.$modelValue?h.$modelValue:b.baseDate;return e(a)?a.toDate():a},o=function(a){return j?d(a):a};c.is("input")?(h.$parsers.unshift(function(a){var b=c.timepicker("getTime",n());return b?o(b):b}),h.$validators.time=function(a){return g.required||l()?f(a):!0}):c.on("changeTime",function(){b.$evalAsync(function(){var a=c.timepicker("getTime",n());h.$setViewValue(a)})})}}}]);