Skip to content

Commit bae83fb

Browse files
features added to customize the component
1 parent 6955d98 commit bae83fb

16 files changed

+343
-279
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea/
22
node_modules/
33
bower_components/
4+
npm-debug.log

README.md

+52-12
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,15 @@ This is a `ionic-timepicker` bower component which can be used with any Ionic fr
1313

1414
1) In your project repository install the ionic time picker using bower
1515

16-
bower install ionic-timepicker --save-dev
16+
`bower install ionic-timepicker --save-dev`
1717

18-
2) Then you can see the following directory structure see in your project folder
19-
20-
![Directory Structure](https://lh3.googleusercontent.com/_s2lFLFfgYSUfhdmZO0r4w6td80dEErTN4pLc7Louo8=w200-h300-p-no "Directory Structure")
21-
22-
Give the path of `style.css, templates.js and ionic-timepicker.js` in your `index.html` file.
18+
2) Give the path of `ionic-timepicker.bundle.min.js` in your `index.html` file.
2319

2420
````html
2521
<link href="lib/ionic-timepicker/dist/style.css" rel="stylesheet">
2622

2723
<!-- path to ionic/angularjs js -->
28-
<script src="lib/ionic-timepicker/dist/templates.js"></script>
29-
<script src="lib/ionic-timepicker/dist/ionic-timepicker.js"></script>
24+
<script src="lib/ionic-timepicker/dist/ionic-timepicker.bundle.min.js"></script>
3025
````
3126

3227
3) In your application module inject the dependency `ionic-timepicker`, in order to work with the ionic time picker
@@ -40,7 +35,19 @@ angular.module('modulename', ['ionic', 'ionic-timepicker']){
4035
4) Use the below format in your template's corresponding controller
4136

4237
````javascript
43-
$scope.slots = {epochTime: 12600, format: 12, step: 15};
38+
$scope.timePickerObject = {
39+
inputEpochTime: ((new Date()).getHours() * 60 * 60), //Optional
40+
step: 15, //Optional
41+
format: 12, //Optional
42+
titleLabel: '12-hour Format', //Optional
43+
setLabel: 'Set', //Optional
44+
closeLabel: 'Close', //Optional
45+
setButtonType: 'button-positive', //Optional
46+
closeButtonType: 'button-stable', //Optional
47+
callback: function (val) { //Mandatory
48+
timePickerCallback(val);
49+
}
50+
};
4451

4552
$scope.timePickerCallback = function (val) {
4653
if (typeof (val) === 'undefined') {
@@ -51,13 +58,43 @@ $scope.timePickerCallback = function (val) {
5158
};
5259
````
5360

54-
a) `timePickerCallback` is the callback function which we have to pass to the `ionic-timepicker` directive.
61+
**$scope.timePickerObject** is the main object, that we need to pass to the directive. The properties of this object are as follows.
62+
63+
**a) inputEpochTime**(Optional) : This the input epoch time to which the time will set initially. Default value is current hour. This is mandatory if you wish to show this on the button before opening the popup.
64+
65+
**b) step**(Optional) : This the minute increment / decrement step. Default value is `15`
66+
67+
**c) format**(Optional) : This the format of the time. It can can two values i.e.`12` or `24`. Default value is `24`
68+
69+
**d) titleLabel**(Optional) : The label for `Title` of the popup. Default value is `Time Picker`
70+
71+
**e) setLabel**(Optional) : The label for the `Set` button. Default value is `Set`
72+
73+
**f) closeLabel**(Optional) : The label for the `Close` button. Default value is `Close`
74+
75+
**g) setButtonType**(Optional) : This the type of the `Set` button. Default value is `button-positive`. You can give any valid ionic framework's button classes.
76+
77+
**h) closeButtonType**(Optional) : This the type of the `Close` button. Default value is `button-stable`. You can give any valid ionic framework's button classes.
78+
79+
**i) callback**(Mandatory) : This the callback function, which will get the selected time in to the controller. You can define this function as follows.
80+
````javascript
81+
function timePickerCallback(val) {
82+
if (typeof (val) === 'undefined') {
83+
console.log('Time not selected');
84+
} else {
85+
var selectedTime = new Date(val * 1000);
86+
console.log('Selected epoch is : ', val, 'and the time is ', selectedTime.getUTCHours(), ':', selectedTime.getUTCMinutes(), 'in UTC');
87+
}
88+
}
89+
````
5590

5691
5) Then use the below format in your template / html file
5792

5893
````html
59-
<ionic-timepicker etime="slots.epochTime" format="slots.format" step="slots.step" callback="timePickerCallback">
60-
<button class="button button-block button-positive"> {{slots.epochTime}} </button>
94+
<ionic-timepicker input-obj="timePickerObject">
95+
<button class="button button-block button-positive overflowShow">
96+
<standard-time-meridian etime='timePickerObject.inputEpochTime'></standard-time-meridian>
97+
</button>
6198
</ionic-timepicker>
6299
````
63100

@@ -98,6 +135,9 @@ Callback function added to get the selected time in to the controller.
98135
### 5) v0.2.1
99136
Class names modified as per [this bug](https://github.com/rajeshwarpatlolla/ionic-timepicker/issues/41).
100137

138+
### 6) v0.3.0
139+
Features added to customize this component.
140+
101141
##License:
102142
[MIT](https://github.com/rajeshwarpatlolla/ionic-timepicker/blob/master/LICENSE.MD "MIT")
103143

bower.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
{
22
"name": "ionic-timepicker",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"authors": [
55
"rajeshwarpatlolla <[email protected]>"
66
],
77
"description": "A timepicker component for Ionic framework",
88
"main": [
9-
"./dist/templates.js",
10-
"./dist/ionic-timepicker.js",
11-
"./dist/style.css"
9+
"./dist/ionic-timepicker.bundle.min.js"
1210
],
1311
"keywords": [
1412
"ionic-timepicker",

dist/ionic-timepicker.bundle.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ionic-timepicker.js

-1
This file was deleted.

dist/style.css

-1
This file was deleted.

dist/templates.js

-1
This file was deleted.

gulpfile.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,42 @@
1-
var path = require('path');
21
var gulp = require('gulp');
3-
var clean = require('gulp-clean');
2+
var del = require('del');
43
var concat = require('gulp-concat');
54
var uglify = require('gulp-uglify');
65
var ngHtml2Js = require("gulp-ng-html2js");
76
var minifyHtml = require("gulp-minify-html");
8-
var minifycss = require("gulp-minify-css");
9-
7+
var css2js = require("gulp-css2js");
108

119
gulp.task('html2js', function () {
12-
gulp.src(['./src/*.html'])
10+
return gulp.src(['./src/*.html'])
1311
.pipe(minifyHtml())
1412
.pipe(ngHtml2Js({
1513
moduleName: "ionic-timepicker.templates"
1614
}))
1715
.pipe(concat("templates.js"))
18-
.pipe(uglify())
16+
//.pipe(uglify())
1917
.pipe(gulp.dest("./dist"));
2018
});
2119

22-
gulp.task('build', ['html2js', 'cssminify'], function () {
23-
gulp.src(['./src/ionic-timepicker.js'])
20+
gulp.task('css2js', function () {
21+
return gulp.src("./src/*.css")
22+
.pipe(css2js())
23+
//.pipe(uglify())
24+
.pipe(gulp.dest("./dist/"));
25+
});
26+
27+
gulp.task('make-bundle', ['del', 'html2js', 'css2js'], function () {
28+
return gulp.src(['dist/*', './src/*.js'])
29+
.pipe(concat('ionic-timepicker.bundle.min.js'))
2430
.pipe(uglify())
25-
.pipe(gulp.dest("./dist"));
31+
.pipe(gulp.dest('dist/'));
2632
});
2733

28-
gulp.task('cssminify', function () {
29-
return gulp.src('./src/*.css')
30-
.pipe(minifycss())
31-
.pipe(gulp.dest('./dist'));
34+
gulp.task('del-temp-files', ['make-bundle'], function () {
35+
del(['dist/templates.js', 'dist/ionic-timepicker.styles.js']);
3236
});
3337

34-
gulp.task('clean', function () {
35-
return gulp.src('dist', {read: false})
36-
.pipe(clean());
38+
gulp.task('del', function () {
39+
del(['dist/*']);
3740
});
3841

39-
gulp.task('default', ['clean', 'build']);
42+
gulp.task('build', ['del-temp-files']);

0 commit comments

Comments
 (0)