• Stars
    star
    128
  • Rank 281,044 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple and clean instructional dialog plugin for Vue2, dialog type including Modal, Alert, Mask and Toast

v-dialogs

CircleCI code coverage npm version license npm

A simple and clean instructional dialog plugin for Vue2, dialog type including Modal, Alert, Mask and Toast

Examples and Documentation

Live Examples on CodePen, more examples and documentation please visit below

The jQuery version: bDialog

The Dialog Icon

The icons in alert dialog used are made by Elegant Themes

The control icon, toast icon used are come from IconFont

Installation

npm i -S v-dialogs

Include plugin in your project

import Vue from 'vue'
import Dialogs from 'v-dialogs'
Vue.use(Dialogs, {
  // global config options...
})

Usage

Alert

// Functional open alert dialog
DialogAlert(message, [callback], [option])
// Open alert dialog with globally v-dialogs instance
this.$dlg.alert(message, [callback], [options])

// Examples
import { DialogAlert } from 'v-dialogs'
function deleteUser (userId) {
  DialogAlert('Deleted data cannot be recovered, are you sure?', () => {
    executeDeleteUser(userId).then(() => {
      DialogAlert('Delete complete.', { messageType: 'success' })
    })
  }, { messageType: 'confirm' })
}

Modal

// Functional open modal dialog
DialogModal(component, [options])
// Open modal dialog with globally v-dialogs instance
this.$dlg.modal(component, [options])

// Examples
import { DialogModal, DialogAlert } from 'v-dialogs'
import Page from './Page.vue'

DialogModal(Page, {
  width: 400,
  height: 300,
  title: 'User Profile',
  params: {
    userId: 1,
    userName: 'Terry Zeng'
  },
  callback: data => {
    DialogAlert(`Received message: ${data}`)
  }
})

// Globally instance example
this.$dlg.modal(Page, {
  ...
  callback: data => {
    this.$dlg.alert(`Received message: ${data}`)
  }
})

Toast

// Functional open toast dialog
DialogToast(message, [callback], [option])
// Open toast dialog with globally v-dialogs instance
this.$dlg.toast(message, [callback], [options])

// Examples
import { DialogToast } from 'v-dialogs'
// Display message in toast
DialogToast(message)
// Display message with callback
DialogToast(message, callback)
// Display message with options
DialogToast(message, options)
// Display message with callaback and options
DialogToast(message, callback, options)

Mask

// Functional open mask dialog
DialogMask([message], [callback], [options])
// Open mask dialog with globally v-dialogs instance
this.$dlg.mask([message], [callback], [options])

import { DialogMask } from 'v-dialogs'
// Display default message
DialogMask()
// Display specify message
DialogMask('Data loading, please hold on a moment...')

DialogHelper

Dialog helper collection

close(key?: string): void

Close a dialog, when no specified key parameter, will close the last one opened dialog

import { DialogMask, DialogHelper } from 'v-dialogs'

const key = DialogMask()
// do your job stuff
doSomeJobStuff().then(() => {
  // close mask with key
  DialogHelper.close(key)
})

closeAll(): void

Close all dialogs at once

import { DialogHelper } from 'v-dialogs'

fetchData()
  .then(() => {
    // Do fetch data success work
    ...
  })
  .catch(error => {
    // Login state timeout for example
    if (error.isLoginTimeout) {
      // Close all opened dialogs
      DialogHelper.closeAll()
      // Redirect to login page
      router.push({ path: '/login' })
    }
  })

More Repositories

1

v-region

提供 5 种应用形式的 4 级行政区划选择器 A simple region cascade selector, provide 4 levels Chinese administrative division data
JavaScript
866
star
2

SelectPage

A simple style and powerful selector, including ajax remote data, autocomplete, pagination, tags, i18n and keyboard navigation features
JavaScript
731
star
3

SelectMenu

Simple, easily and diversity menu solution
JavaScript
297
star
4

v-uploader

A Vue2 plugin make files upload simple and easier, single file upload with image preview, multiple upload with drag and drop
Vue
238
star
5

v-selectpage

SelectPage for Vue2, list or table view of pagination, use tags for multiple selection, i18n and server side resources supports
JavaScript
236
star
6

v-selectmenu

SelectMenu for Vuejs, A simple, easier and highly customized menu solution
JavaScript
187
star
7

bDialog

Extend the Bootstrap Modal features, making dialog more functions and easier to use, dialog type including modal, alert, mask and toast types
JavaScript
175
star
8

bTabs

A jQuery plugin open pages in tab, based on Bootstrap2,3
JavaScript
127
star
9

frontend-develops-skill-summary

Development experience with javascript, jQuery, Vuejs, Wechat MiniProgram and so on
122
star
10

bPage

Based on bootstrap style, static page jump can also be asynchronous page processing pagination plugin
JavaScript
102
star
11

v-page

A simple and useful pagination component for vue2 and vue3
JavaScript
90
star
12

v-suggest

A Vue2 plugin for input content suggestions, support using keyboard to navigate and quick pick, it make use experience like search engine input element
JavaScript
75
star
13

v-gallery

A Vue2 plugin for images show in gallery or carousel
Vue
62
star
14

vuepress-login

Add user authorization for VuePress
JavaScript
41
star
15

v-ztree

A simple tree for Vue2, support single or multiple(check) select tree, and support server side data
Vue
36
star
16

v-playback

A Vue2 plugin to make video play easier
Vue
18
star
17

v-dropdown

A dropdown container layer plugin for vue
JavaScript
15
star
18

vue-plugins

vue plugins development environment
JavaScript
11
star
19

v-tablegrid

A simpler to use and practical datatable
Vue
9
star
20

TerryZ.github.io

Main Page
HTML
5
star
21

grid-improve

grid-improve
HTML
1
star