framework7-plugin-keypad v7.0.0
Framework7 Keypad Plugin
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.
Installation
Just grab plugin files from dist/
folder or using npm:
npm install framework7-plugin-keypad
And link them to your app right AFTER Framework7's scripts and styles:
<link rel="stylesheet" href="path/to/framework7.min.css">
<link rel="stylesheet" href="path/to/framework7.keypad.css">
...
<script src="path/to/framework7.min.js"></script>
<script src="path/to/framework7.keypad.js"></script>
Usage
Install & Enable Plugin
After you included plugin script file, you need to install plugin before you init app:
// install plugin to Framework7
Framework7.use(Framework7Keypad);
// init app
var app = new Framework7({
...
})
ES Module
This plugin comes with ready to use ES module:
import Framework7 from 'framework7';
import Framework7Keypad from 'framework7-plugin-keypad';
// install plugin
Framework7.use(Framework7Keypad);
// init app
var app = new Framework7({
...
})
API
Plugin extends initiliazed app
instance with new methods:
app.keypad.create(parameters)
- init Keypad. This method returns initialized Keypad instance.app.keypad.get(keypadEl)
- get Keypad instance by HTML element. Method returns initialized Keypad instance.app.keypad.destroy(keypadEl)
- destroy Keypad instance
Keypad Instance
Keypad can be created and initialized only using JavaScript. We need to use related App's method:
app.keypad.create(parameters)
Where parameters - object - object with Keypad parameters. Required This method returns initialized Keypad instance
For example
var myKeypad = app.keypad.create({
inputEl: '#demo-numpad-limited',
valueMaxLength: 2,
dotButton: false
});
Keypad Parameters
Let's look on list of all available parameters:
Keypad Methods & Properties
After we initialize Keypad we have its initialized instance in variable (like myKeypad
variable in example above) with helpful methods and properties:
Keypad Events
Automatic initialization
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">
Access to Keypad's Instance
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;
CSS Custom Properties
The following CSS custom properties available to customize it:
:root {
--f7-keypad-height: 260px;
--f7-keypad-landscape-height: 200px;
--f7-keypad-inline-height: 200px;
--f7-keypad-inline-calc-height: 260px;
--f7-keypad-popover-width: 300px;
--f7-keypad-button-bg-color: #fcfcfd;
--f7-keypad-button-text-color: #000;
--f7-keypad-button-border-color: rgba(0,0,0,0.1);
--f7-keypad-button-pressed-bg-color: #bcc0c5;
--f7-keypad-button-dark-bg-color: #ddd;
--f7-keypad-button-dark-pressed-bg-color: #fcfcfd;
--f7-keypad-button-number-font-size: 28px;
--f7-keypad-button-number-letters-size: 11px;
--f7-keypad-calc-button-text-color: #fff;
--f7-keypad-calc-button-bg-color: #ff9500;
--f7-keypad-calc-button-pressed-bg-color: #e0750e;
--f7-keypad-calc-button-active-border-color: rgba(0,0,0,0.4);
--f7-keypad-calc-button-active-border-width: 1px;
}
Demo
Plugin comes with demo example to see how it works and looks. To make demo works you need to run in terminal:
$ npm run prod
Contribute
All changes should be done only in src/
folder. This project uses gulp
to build a distributable version.
First you need to install all dependencies:
$ npm install
Then to build plugin's files for testing run:
$ npm run build:dev
If you need a local server while you developing you can run:
$ gulp server
or
$ npm run dev
And working demo will be available at http://localhost:3000/demo/