Git Product home page Git Product logo

ionic-timepicker's Introduction

bitHound Score

##Introduction:

This is an ionic-timepicker bower component, which can be used in any Ionic framework's application. No additional plugins are required for this component. This plugin is completely open source. Please rate this plugin @ Ionic Market

From version 0.5.0, this component has got so many new features and the way you should use is different from the older versions of this component. If you wish to see the documentation for the previous versions of this component, please check the previous releases

View Demo

##Prerequisites.

  • node.js, npm
  • ionic
  • bower
  • gulp

##How to use:

  1. In your project folder, please install this plugin using bower

bower install ionic-timepicker --save

This will install the latest version of ionic-timepicker. If you wish to install any specific version(eg : 0.4.0) then

bower install ionic-timepicker#0.4.0 --save

  1. Specify the path of ionic-timepicker.bundle.min.js in your index.html file.
<!-- path to ionic -->
<script src="lib/ionic-timepicker/dist/ionic-timepicker.bundle.min.js"></script>
  1. In your application's main module, inject the dependency ionic-timepicker, in order to work with this plugin
angular.module('mainModuleName', ['ionic', 'ionic-timepicker']){
//
}
  1. You can configure this time picker at application level in the config method using the ionicTimePicker provider. Your config method may look like this if you wish to setup the configuration. But this is not mandatory step.
.config(function (ionicTimePickerProvider) {
    var timePickerObj = {
      inputTime: (((new Date()).getHours() * 60 * 60) + ((new Date()).getMinutes() * 60)),
      format: 12,
      step: 15,
      setLabel: 'Set',
      closeLabel: 'Close'
    };
    ionicTimePickerProvider.configTimePicker(timePickerObj);
  })

In the above code i am not configuring all the properties, but you can configure as many properties as you can.

The properties you can configure are as follows.

a) inputTime(Optional) : This is the input epoch time which we can pass to the component. You can give any valid epoch time. Default value is (((new Date()).getHours() * 60 * 60) + ((new Date()).getMinutes() * 60)).

b) format(Optional) : This takes two values 12 or 24. If we give 12 as the value, then it will be 12 format time picker or else if you give 24 as the value, then it will be 24 hour format time picker. Default value is 12.

c) step(Optional) : This is the value which will be used to increment/decrement the values of the minutes. You can give any value like 10/15/20/30. Default value is 15.

d) setLabel(Optional) : The label for Set button. Default value is Set

e) closeLabel(Optional) : The label for Close button. Default value is Close

  1. Inject ionicTimePicker in the controller, where you wish to use this component. Then using the below method you can call the timepicker.
.controller('HomeCtrl', function ($scope, ionicTimePicker) {

  var ipObj1 = {
    callback: function (val) {      //Mandatory
      if (typeof (val) === 'undefined') {
        console.log('Time not selected');
      } else {
        var selectedTime = new Date(val * 1000);
        console.log('Selected epoch is : ', val, 'and the time is ', selectedTime.getUTCHours(), 'H :', selectedTime.getUTCMinutes(), 'M');
      }
    },
    inputTime: 50400,   //Optional
    format: 12,         //Optional
    step: 15,           //Optional
    setLabel: 'Set2'    //Optional
  };
  
  ionicTimePicker.openTimePicker(ipObj1);
};

Apart from the config method, you can re configure all options in the controller also. If you again set any of the properties, they will be overridden by the values mentioned in the controller. This will be useful if there are multiple time pickers in the app, which has different properties.

In all the above steps, only mandatory property is the callback where you will get the selected time value.

##Screen Shots:

Once you are successfully done with the above steps, you should be able to use this plugin.

The first screen shot shows the popup and the second shows the modal of this plugin.

iOS :

Android :

##CSS Classes:

###popup

1) heading

2) time_picker_arrows

3) time_picker_box_text

4) time_picker_colon

5) button_set

6) button_close

You can use the below css class as the main class to customise popup.
####ionic_timepicker_popup

The css class names for the buttons are as follows

a) For Set button the class name is button_set

b) For Close button the class name is button_close

##Versions:

1) v0.1.0

The whole time picker functionality has been implemented, and can be installed with

bower install ionic-timepicker --save

2) v0.1.1

Directive name has been modified.

3) v0.1.2

If the minutes and hours are less than 10, then 0 will be prepended to the value of minutes/hours.

4) v0.2.0

Callback function added to get the selected time in to the controller.

5) v0.2.1

Class names modified as per this bug.

6) v0.3.0

Features added to customize this component.

7) v0.4.0

Bug fixes : #48, #53, #51

PR : #54,

Few additional enhancements added.

8) v0.5.0

Features

a) You can configure the ionic-timepicker from the config method.

9) v0.5.1

BugFix : #75

10) v0.6.0

BugFixes : #80, #86

##License: MIT

##Contact: Gmail : [email protected]

Github : https://github.com/rajeshwarpatlolla

Twitter : https://twitter.com/rajeshwar_9032

Facebook : https://www.facebook.com/rajeshwarpatlolla

Paypal : [email protected]

Comment or Rate it : http://market.ionic.io/plugins/ionictimepicker

ionic-timepicker's People

Contributors

dts avatar focopeazy avatar irxground avatar khamasaki avatar rajeshwarpatlolla avatar spriz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ionic-timepicker's Issues

npm support

Please add support of installing through npm

Popover issue

Your example is fine, you are using timepicker in page. I am having issue when i use time-picker in ionic popover page. See below image.

image

If user clicks time multiple times then multiple timepicker is displayed and application crashes. Is it possible to close timepicker when user click outside?

Cannot set initial time

Hi

I'm unable to set the initial time inputEpochTime. Even the example does not work.

I read the value set from localstorage and set inputEpochTime with that value i.e. 24420

setting title of timepicker

Hello,
Thanks for this timepicker, it works great.
Can you tell me how to set the title of the timepicker, I tried:
<ionic-timepicker etime="slotsStart.epochTime" format="slotsStart.format" step="slotsStart.step" callback="setStartTime" title="test">
but this isn't working.

Change step by default

Hello, I'm rendering a time picker when an ion-toogle makes true a variable. I have a case when the variable is true since the beginning and the object is declared with the default step (15) and I need to set it in 5.

Any solution?

Button text doesn't update automatically

I'm having the same issue with ionic-datepicker too.
Everything works, the callback is triggering and logging the right information. The buttons start with the default text, but it doesn't update after the selection.

Template:





Controller:

$scope.timePickerObject = {
inputEpochTime: ((new Date()).getHours() * 60 * 60), //Optional
step: 15, //Optional
format: 12, //Optional
titleLabel: '12-hour Format', //Optional
setLabel: 'Set', //Optional
closeLabel: 'Close', //Optional
setButtonType: 'button-positive', //Optional
closeButtonType: 'button-stable', //Optional
callback: function (val) { //Mandatory
timePickerCallback(val);
}
};
function timePickerCallback(val) {
if (typeof (val) === 'undefined') {
console.log('Time not selected');
} else {
var selectedTime = new Date(val * 1000);

      console.log('Selected epoch is : ', val, 'and the time is ', selectedTime.getUTCHours(), ':', selectedTime.getUTCMinutes(), 'in UTC');
    }
  }

Steps can get corrupted

If I use the current time as the starting time and that time is not a factor of the defined step parameter, the time selector display gets corrupted, meaning you can get negative numbers and numbers that are not valid minutes

Selecting 12:00 AM Bug

I believe there is a bug with the 12-hour display when 12:00 AM is selected. Steps to reproduce:

  • Open a time picker and configure it to 12:00 AM
  • Select time
  • Re-open the time picker

The time picker will re-appear as 00:00 AM. Note it is displaying "00" instead of "12".

How to convert string time to epoch time

This is what I get back from the database:
1) 02:30 PM
2) 12:00 AM
3) 08:50 PM

How can I convert string time to epoch time in order to use your ionic-timepicker control?

.col missing templates

Hello.
Devices with android 4.2.2 and low resolution may display incorrect with included template.
To prevent popup display incorrect add .col to span class:

Thx! Great job anyway!!

Sorry my english :)

It can not change button css

I have set button_set class

.button_set{
background-color: #0a9dc7;
}

but it doesn't work

I even change ionic-timepicker.style.css, then got the same result

Random vs Current time

Whenever I open the picker, the time it displays seems to be randomly chosen. Is there a way to make sure it always opens to the current time?

Time Picker as an inline control

Can I display the ionic-timepicker as an inline control on my form so it is always visible when the user navigates to that view? If so, how?

Can you provide bundle.js not minified to allow editions in code?

I'm using ionic-timepicker and it's working very well, but in an specific project I want to customize the library in something, for example:

  1. Change the order of button "Set" and "Cancel", putting the "Set" in right position and "Cancel" in left position.

  2. Do not reset hour number when it reaches 24.

  3. Change label in Popup Header to show, for example:
    If time is 15:30 -> Label: 15:30 minutes
    If time is 15:00 -> Label: 15 minutes
    If time is 01:00 -> Label: 1 minute
    If time is 00:30 -> Label: 30 seconds
    If time is 00:01 -> Label: 1 second

The purpose of this project is to select how many minutes and seconds to retrieve this value to me, then I'm using hour area to select minutes and minute area to select seconds, because this I would like to change somethings in the library. Is it possible to provide not minified version to compile?

Thanks in advance

inputTime error

Hi man,

See an error using inputTime: http://screencast.com/t/kkB7tdkO0

I'm getting the inputTime with the code of the example:

inputTime : (($scope.myDate.getHours() * 60 * 60) + ($scope.myDate.getMinutes() * 60))

Regards, Nicholls

CSS issue

Hello,

Component creates css style in index.html just below the included js file. Problem is with using classname same as core ionic css classes. It is creating unnecessary css issues for our app. Can we use more specific class names to prevent style conflicts

.bar.bar-stable, .tabs {
    box-shadow: 0 0 5px #555;
}

Why everything is shaking while the values are changing?

Not sure if this problem only happens on me or not. I noticed that when I was clicking the time arrow up or down, everything is shaking a little bit. (Either in my program or in the demo) Is there a way to do a quick fix on this issue? I would appreciate for any reply.

Enable numeric keyboard

I need user to enter specific time as 3:35, but they have press down 35 times to show up exact minute. What do you suggest?

Header-bar/sub-header-bar content a shadow

After I added timepicker into my project, the header-bar/sub-header-bar content shadow. I had try looking the timepicker css also, but I cannot found where to change it? before I added timepicker plugin, its working fine without shadow. thanks for help.

unable to use setLabel and closeLabel together with ng-translate

Hi,

Thanks for the hardworking for this plugin, it is awesome.

I do have problem to use the setLabel and closeLabel settings together with ng-translate. ng-translate will return a promise which means that I cannot get the result immediately(when the directive being init/render). I tried the following two methods, but failed.

  1. Put the entire $scope.timePickerObject = {...} inside the ng-translate promise
    Result: ionic-timepicker return error because timePickerObject is missing during init

  2. Put the entire $scope.timePickerObject = {...} outside the ng-translate promise, but keeping $scope.timePickerObject.setLabel and closeLabel inside the ng-translate promise
    Result: ionic-timepicker runs fine but setLabel and closeLabel settings are not used since the link fxn only runs once at the beginning and there's where setLabel and closeLabel being aside.

Any good idea to resolve this problem? Adding a watch for setLabel and closeLabel will be pretty inefficient though.

Thanks.

Class starting with a digit are invalid

Your classes 12HourTimePickerChildDiv and 24HourTimePickerChildDiv are invalid.

To be valid the first character must be an underscore (_), a hyphen (-), or a letter(aโ€“z).

This prevent the popup to be customized a little.

Cannot format time properly unless using your directives

I have tried repeatedly to use the picker without your directives for formatting the resulting time and it never work correctly... Is it possible for you to add a sample that does not require your standardTimeNoMeridian and standardTimeMeridian directives? Or just embed them as options for the timePicker?

Popup Issue

Hi rajeshwarpatlolla,

Perhaps you can help me. I am having an issue wherein the popup for your timepicker does not show correctly on a mobile device. It grays out the content behind it but the popup is not visible. Please see the below code and attached pictures. (the code is basically not changed from your original implementation)

//CONTROLLER
$scope.timePickerObject = {
inputEpochTime: ((new Date()).getHours() * 60 * 60), //Optional
step: 15, //Optional
format: 12, //Optional
titleLabel: '12-hour Format', //Optional
setLabel: 'Set', //Optional
closeLabel: 'Close', //Optional
setButtonType: 'button-positive', //Optional
closeButtonType: 'button-stable', //Optional
callback: function (val) { //Mandatory
timePickerCallback(val);
}
};

//HTML (I tried to add it here but it doesnt show. sorry new to github.)


</standard-time-meridian

I have also ensured that the module is required in my app module.
before click
after click

Prepend zero on open

If you open datepicker with minutes at zero, the time picker only shows one number, but then if you increase it and go back to zero, it shows 2.
Image of Yaktocat

Use unix timestamp for inputTime and return value

Problem

  • Return value (number of seconds) is "local time"
  • Turning number of seconds into usable representation (unix timestamp / moment.js) requires unnecessary effort (if timezone offset or DST has to be taken into account)

Possible solution
Always use a unix timestamp representation, both for specifying inputTime and also for return value.

Workaround
image

Callback method is not fired with time picker.

I have my time picker in an ionic modal with date picker as well,, the time picker sets the model value correctly,, but not calling the call back method,. on the other hand datepicker is working just fine..

here is my code:

  <ionic-timepicker etime="filterStartTimeDisplay.epochTime"        format="filterStartTimeDisplay.format" step="filterStartTimeDisplay.step"   callback="timePickerCallback">   
         <p > <standard-time-meridian  etime='filterStartTimeDisplay.epochTime'></standard-time-  meridian></p>
          </ionic-timepicker>


 $scope.timePickerCallback = function (val) {
           if (typeof (val) === 'undefined') {
            console.log('Time not selected');
           } else {
             console.log('Selected time is : ', val);    // `val` will contain the selected time in epoch
           }
        };

as you can see the object filterStartTimeDisplay is set correctly,, but the time picker callback function is not working... the log is not generated.

Dependencies out of date...

Hi Rajesh, the dependencies on your project are out of date. Ionic just went 1.0.

This is the error I'm getting:

Unable to find a suitable version for ionic, please choose one:
    1) ionic#~0.9.27 which resolved to 0.9.27 and is required by ionic-timepicker#0.1.2
    2) ionic#1.0.0 which resolved to 1.0.0 and is required by HelloIonic

Prefix the choice with ! to persist it to bower.json

? Answer: 

Failed to instantiate module ionic-timepicker

When I inject the dependency ionic-timepicker to the app module, it get this console error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to: Error: [$injector:modulerr] Failed to instantiate module ionic-timepicker due to: Error: [$injector:nomod] Module 'ionic-timepicker' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.3.13/$injector/nomod?p0=ionic-timepicker

And my whole app went blank... why is that?

Time format

function timePickerCallback(val) {
if (typeof (val) === 'undefined') {
console.log('Time not selected');
} else {
var selectedTime = new Date(val * 1000);
console.log('Selected epoch is : ', val, 'and the time is ', selectedTime.getUTCHours(), ':', selectedTime.getUTCMinutes(), 'in UTC');
}
}

at the code above, return value "val" is in what format? second?

Set time to current time at popup time picker

Right now, when I click the button to change the time, the popup showed the current hour, let's say right now is 03:30 PM, but the popup showed only 03:00 PM. So where can I adjust the default time? I had changed it before at .directive, but it still got the same output. Thanks for help.

Keyboard annoyance

First of all, thanks for the timepicker.

I have a form with several time fields, and when user taps the time field, I trigger the timepicker. The problem is the keyboard comes up, then the timepicker comes up. Then when you tap anywhere on timepicker the keyboard goes away. I can see this being rather annoying for users since in that scenario the keyboard came up for no reason, and that also adjusts the position of the timepicker. But I also want the user to be able to key in the value if they want too. Is the only solution to use a separate button element to trigger the timepicker? Is there any way to maintain the keyboard open while tapping inside the timepicker? And hide keyboard on timepicker Set or Close?

Any ideas for a solution?

gulp build => mising ionic-timepicker.templates

Hello,

After running gulp build on master (no local changes), I get a 404 on the ionic-timepicker.html template. The ionic-timepicker.bundle.min.js is not generated exactly the same as the one in your repository. One difference is shown below - the ionic-timepicker.templates module is no longer present.

From master:

angular.module("ionic-timepicker",["ionic-timepicker.provider","ionic-timepicker.templates"]),angular.module("ionic-timepicker.provider",[]).provider("ionicTimePicker",function(){

After running gulp build on master:

angular.module("ionic-timepicker",["ionic-timepicker.provider"]),angular.module("ionic-timepicker.provider",[]).provider("ionicTimePicker",function(){

It looks like ng-html2js npm module is responsible for this maniplation. I get 2.0.2 when doing npm install. Maybe you have a different version?

Or should I not use gulp build, but instead some other command? Obviously without making any changes there is no point. But I plan to make changes including #73 and then allow changing date +/- a few as well.

Time Picker Popup issues

Hi First of all thanks for great plugin. I had an issues like when I am selecting time as 12PM it is showing the popup as 12AM . If we select 12AM in popup then it is showing 12PM .It is working reverse only in the case of 12 AM and 12 PM for other hours it is working fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.