Giter Site home page Giter Site logo

joaopaulovieira / clappr-context-menu-plugin Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 3.0 18.77 MB

A context menu for Clappr player.

License: BSD 3-Clause "New" or "Revised" License

JavaScript 80.92% HTML 13.10% SCSS 3.40% Shell 2.59%
clappr clappr-player clappr-plugin context-menu contextmenu clappr-plugins

clappr-context-menu-plugin's Introduction

npm bundle size Travis (.com) Coveralls github

Clappr context menu plugin

screenshot

Demo

https://joaopaulovieira.github.io/clappr-context-menu-plugin/

Table of Contents

Features

  • Default actions:
    • Copy URL of the site where Clappr is playing;
    • Copy URL with the current time of the video;
    • Enable/Disable loop state;
  • Default info:
    • Clappr version;
  • Support to add new custom actions;
  • Support to add custom style;

Usage

You can use it from JSDelivr:

https://cdn.jsdelivr.net/npm/clappr-context-menu-plugin@latest/dist/clappr-context-menu-plugin.min.js
# Using yarn
yarn add clappr-context-menu-plugin

# Using npm
npm i clappr-context-menu-plugin

Then just add ContextMenuPlugin into the list of plugins of your player instance

var player = new Clappr.Player({
  source: 'http://your.video/here.mp4',
  plugins: [ContextMenuPlugin]
});

Configuration

The options for the plugin go in the contextMenu property as shown below

var player = new Clappr.Player({
  source: 'http://your.video/here.mp4',
  plugins: [ContextMenuPlugin],
  contextMenu: {
    menuItems: [`copyURL`, `copyURLCurrentTime`, `loop`, `playerVersion`],
    extraOptions: [
      {
        name: 'test',
        label: 'Test Label',
        //optional
        callback: function() {
          console.log('A absolutely awesome extra context menu item action')
        }
      }
    ],
    customStyle: {
      container: {
        'display': 'block'
      },
      list: {
        'background-color': 'gray'
      },
      items: {
        'color': 'yellow'
      }
    }
  }
});

menuItems {Array}

An array where each item is a name that matches one of the default menu items. The valid values are: ['copyURL', 'copyURLCurrentTime', 'loop', 'playerVersion']

extraOptions {Array}

An array of items to add on the context menu. Each context menu item on this array is an object which contains the parameters name, label, and callback

  • name {String}

    Name of the extra item

  • label {String}

    The label that will be displayed on the menu

  • callback {Function}

    A method that will be triggered when clicking on the item label. This option is not required if your desired menu item not have one action to call on click (like the playerVersion default menu item)

customStyle {Object}

Styles to apply to mapped elements on the context menu. This option is an object with the parameters container, list and items

  • container {Object}

    Attributes that will be applied in the main element. This option is an object that receives CSS attributes like the options example at the beginning of this section

  • list {Object}

    Attributes that will be applied in the <ul> element. This option is an object that receives CSS attributes like the options example at the beginning of this section

  • items {Object}

    Attributes that will be applied in each <li> element. This option is an object that receives CSS attributes like the options example at the beginning of this section

Development

Install dependencies: npm install

Run: npm start

Test: npm test

Lint: npm run lint

Build: npm run build

Minified version: npm run release

clappr-context-menu-plugin's People

Contributors

joaopaulovieira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vahidx4876 guzz

clappr-context-menu-plugin's Issues

Any way to disable it on startup?

I've implemented the plugin but the context menu is opened by default when a video starts.
How to make it closed by default and opened on right click only?

Also, how to style it to look like on the demo image, with semi-transparent background?

Thanks

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.