Skip to content

Commit

Permalink
create iOS + Android plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
VitaliiBlagodir committed Oct 8, 2013
0 parents commit 38f31df
Show file tree
Hide file tree
Showing 9 changed files with 953 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
20 changes: 20 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

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.
181 changes: 181 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# DatePicker iOS Plugin for using PhoneGap / Cordova 3.0 (iOS 7 beta ready)

This is a re-write of the iOS DatePicker plugin hosted on [https://github.com/phonegap/phonegap-plugins/tree/master/iOS/DatePicker](https://github.com/phonegap/phonegap-plugins/tree/master/iOS/DatePicker) to run with PhoneGap/Cordova 3.0.

It includes [more options](#options) and it is ready for iPhone and iPad.

## Screen shots

### iPhone (iOS 6)
![screen shot iPhone](https://raw.github.com/sectore/phonegap3-ios-datepicker-plugin/master/assets/screenshot.jpg)

### iPhone (iOS 7)
![screen shot iPhone](https://raw.github.com/sectore/phonegap3-ios-datepicker-plugin/master/assets/screenshot_ios7.jpg)

### iPad (iOS 6)
![screen shot iPad](https://raw.github.com/sectore/phonegap3-ios-datepicker-plugin/master/assets/screenshot_ipad.jpg)

### iPad (iOS 7)
![screen shot iPad](https://raw.github.com/sectore/phonegap3-ios-datepicker-plugin/master/assets/screenshot_ipad_ios7.jpg)

## Installation

1) Make sure that you have [Node](http://nodejs.org/) and [Cordova CLI](https://github.com/apache/cordova-cli) or [PhoneGap's CLI](https://github.com/mwbrooks/phonegap-cli) or [Cordova Plugman](https://github.com/apache/cordova-plugman/) installed on your machine.

Also you will need Xcode v.4.2 or newer to support the feature called ["Automatic Reference Counting"](http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_4_2.html)

2) Add a plugin to your project using [Cordova CLI](https://github.com/apache/cordova-cli):

```bash
cordova plugin add https://github.com/sectore/phonegap3-ios-datepicker-plugin
```

Or using [PhoneGap CLI](https://github.com/mwbrooks/phonegap-cli):

```bash
phonegap local plugin add https://github.com/sectore/phonegap3-ios-datepicker-plugin
```

Or using [plugman CLI](https://github.com/apache/cordova-plugman#command-line-usage):

```bash
plugman --platform ios --project ./platforms/ios --plugin https://github.com/sectore/phonegap3-ios-datepicker-plugin
```


3a) Register plugin within `config.xml` of your app

```xml
<feature name="DatePicker">
<param name="ios-package" value="DatePicker"/>
</feature>
```

3b) If you are using [PhoneGap build service](https://build.phonegap.com/) add to `config.xml`

```xml
<gap:plugin name="de.websector.datepicker" />
```

4) The `clobber` definition of the plugin is called `datePicker`. So you can reference to the plugin from anywhere in your code.

Example:

```js
// defining options
var options = {
date: new Date(),
mode: 'date'
};
// calling show() function with options and a result handler
datePicker.show(options, function(date){
console.log("date result " + date);
});
```

Check section ["Options"](#options) below to see all options.

## Options

### mode
The mode of the date picker.

Typ: `String`

Values: `"date"` / `"time"` / `"datetime"`

Default: `'datetime'`

### date
Selected date.

Typ: `String`

Default: `new Date()`

### allowOldDates
Shows or hide dates earlier then selected date.

Typ: `Boolean`

Values: `true` / `false`

Default: `true`

### allowFutureDates
Shows or hide dates after selected date.

Typ: `Boolean`

Values: `true` / `false`

Default: `true`

### minDate (new)
Minimum date.

Typ: `Date` or empty `String`

Default: `''` (empty String)

### maxDate (new)
Maximum date.

Typ: `Date` or empty `String`

Default: `''` (empty String)

### doneButtonLabel (new)
Label of done button.

Typ: `String`

Default: `'Done'`

### doneButtonColor (new)
Hex color of done button.

Typ: `String`

Default: `'#0000FF'`

### cancelButtonLabel (new)
Label of cancel button.

Typ: `String`

Default: `'Cancel'`

### cancelButtonColor (new)
Hex color of cancel button.

Typ: `String`

Default: `'#000000'`

### x (new)
X position of date picker (iPad only). The position is absolute to the root view of the application.

Typ: `String`

Default: `'0'`

### y (new)
Y position of date picker (iPad only). The position is absolute to the root view of the application.

Typ: `String`

Default: `'0'`

## Requirements
- PhoneGap 3.0 or newer /Cordova 3.0 or newer
- iOS 5 or newer

## Author of migration to PhoneGap 3.0
Jens Krause // [WEBSECTOR.DE](http://www.websector.de)




[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/sectore/phonegap3-ios-datepicker-plugin/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

41 changes: 41 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>

<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
id="de.websector.datepicker"
version="0.3.0">

<name>Datepicker</name>
<description>Cordova Datepicker Plugin</description>
<license>MIT</license>
<keywords>cordova,datepicker,ios,android</keywords>

<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="DatePicker">
<param name="android-package" value="com.plugin.datepicker.DatePicker"/>
</feature>
</config-file>

<source-file src="src/android/DatePicker.java" target-dir="src/com/plugin/datepicker" />
</platform>

<!-- ios -->
<platform name="ios">

<config-file target="config.xml" parent="/*">
<feature name="DatePicker">
<param name="ios-package" value="DatePicker"/>
</feature>
</config-file>

<js-module src="www/ios/DatePicker.js" name="DatePicker">
<clobbers target="datePicker" />
</js-module>

<header-file src="src/ios/DatePicker.h" />
<source-file src="src/ios/DatePicker.m" />

</platform>

</plugin>
Loading

0 comments on commit 38f31df

Please sign in to comment.