Giter Site home page Giter Site logo

akash-manna / jquery.bangla Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dipu-bd/jquery.bangla

0.0 1.0 0.0 1.7 MB

A versatile bangla input tools for the web

Home Page: https://dipu-bd.github.io/jquery.bangla

License: Mozilla Public License 2.0

JavaScript 76.68% CSS 10.86% HTML 12.46%

jquery.bangla's Introduction

Bangla Input Tools

npm (tag) Build Status NPM Downloads Maintainability License GitHub stars

A versatile bangla input tools for the web

Live Demo: https://dipu-bd.github.io/jquery.bangla/

Installation

npm i --save jquery jquery.bangla

Usage

import 'jquery.bangla';

// Or,
require('jquery.bangla');

// Then, on some editable elements...

$('input[type="text"]').bangla(); // input box

$('textarea').bangla(); // text area

$('div[contenteditable="true"]').bangla(); // content editable div

$('.note-editable').bangla() // summer-note (a free WYSWYG editor)

Usage (Browser)

  1. Clone this repository and go to project folder.
  2. Perform npm install
  3. Then npm run build
  4. Copy the script file inside dist/ folder to your static assets directory
  5. See the example in gh-pages branch for usage.

API

Initial Configuration

You an pass the following configs during initialization (all configs are optional):

// all the default values are given here
$('<some-element-selectoor>').bangla({
  enable: false,
  maxSuggestions: 10,
  disableSuggestion: false,
  storeKey: '__avro--candidates',
  store: window.localStorage,
  provider: /* see below */
})

Config: enable

Pass true to enable bangla right after initialization.

Config: maxSuggestions

The maximum number of suggestions that user will see for a word.

Config: disableSuggestion

Pass true if you do not want to display the suggestion box.

Config: storeKey

The key that is used for storing candidate words.

Config: store

The storage to save candidate words. A cadidate word is a bangla word that user had select against an english word. In the next suggestion box for that english word, the cadidate word will be automatically selected.

The store should haeve two fields:

  • getItem(key): Returns the value given the key
  • setItem(key, val): Stores the value against the key to retriee it later.

Config: provider

By default, Avro Phonetic from https://github.com/omicronlab/avro-pad is used. But you can define your own provider. A provider should have three fields.

  • suggest(word): This will return an object containing words field. The field words is an array of possible bangla word for the given english word.
  • candidate(word): This will return previously selected bangla word for the english input.
  • commit(word, bangla): It will save the candidate bangla word for an english word.

Methods

You can customize the input tool after initialization:

  • $('input').bangla('toggle'): Toggles the input option between bangla and english.
  • $('input').bangla('on'): Enables the bangla mode.
  • $('input').bangla('off'): Disables the bangla mode.
  • $('input').bangla('enable'): Get whether the bangla is enabled for a single element.
  • $('input').bangla('enable', true): Enables the bangla mode.
  • $('input').bangla('enable', false): Disable the bangla mode.
  • $('input').bangla('tool'): Access the BanglaInputTool instance for a single element.

License

Mozilla Public License Version 2.0

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.