[](https://flattr.com/submit/auto?user_id=nolimits4web&url=https://github.com/nolimits4web/framework7-keypad/&title=Framework7 Keypad&language=JavaScript&tags=github&category=software)
Keypad plugin extends Framework7 with additional custom keyboards. By default it comes with predefined Numpad and Calculator keyboards, but it also can be used to create custom keyboards with custom buttons.
Keypad can be created and initialized only using JavaScript. We need to use related App's method:
myApp.keypad(parameters)
Where parameters - object - object with Keypad parameters. Required This method returns initialized Keypad instance
For example
var myKeypad = myApp.keypad({
input: '#demo-numpad-limited',
valueMaxLength: 2,
dotButton: false
});
Let's look on list of all available parameters:
Parameter | Type | Default | Description |
---|---|---|---|
Common Picker Modal Component Parameters | |||
container | string or HTMLElement | String with CSS selector or HTMLElement where to place generated Keypad HTML. Use only for inline keypad | |
input | string or HTMLElement | String with CSS selector or HTMLElement with related input element | |
scrollToInput | boolean | true | Scroll viewport (page-content) to input when keypad opened |
inputReadOnly | boolean | true | Sets "readonly" attribute on specified input |
convertToPopover | boolean | true | Converts keypad modal to Popover on large screens (on iPad) |
onlyOnPopover | boolean | false | Enable it and Keypad will be always opened in Popover |
cssClass | string | Additional CSS class name to be set on keypad modal | |
toolbar | boolean | true | Enables keypad modal toolbar |
toolbarCloseText | string | 'Done' | Text for Done/Close toolbar button |
toolbarTemplate | string |
Toolbar HTML Template. By default it is HTML string with following template:
|
After we initialize Keypad we have its initialized instance in variable (like myKeypad
variable in example above) with helpful methods and properties:
Properties | |
---|---|
myKeypad.params | Object with passed initialization parameters |
myKeypad.value | Current keypad value |
myKeypad.opened | true if Keypad is currently opened |
myKeypad.inline | true if Keypad is inline Keypad |
myKeypad.container | Dom7 instance with Keypad HTML container |
Methods | |
myKeypad.setValue(value) | Set new keypad value. |
myKeypad.open() | Open Keypad |
myKeypad.close() | Close Keypad |
myKeypad.destroy() | Destroy Keypad instance and remove all events |
Such predefined Numpad and Calculator keypads could be initialized automatically. Just use usual inputs but with special type attribute:
<input type="numpad">
<input type="calculator">
If you initialize Keypad as inline Keypad or using automatic initialization, it is still possible to access to Keypad's instance from its HTML container:
var myKeypad = $$('.keypad-inline')[0].f7Keypad;
$ bower install framework7-keypad