Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

notie

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notie

notie - a clean and simple notification, input, and selection suite for javascript, with no dependencies

  • 4.0.0-rc.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
decreased by-22.77%
Maintainers
1
Weekly downloads
 
Created
Source

notie

js-standard-style

notie is a clean and simple notification, input, and selection suite for javascript, with no dependencies. demo: https://jaredreich.com/projects/notie

With notie you can:
  • Alert users
  • Confirm user choices
  • Allow users to input information
  • Allow users to select choices
  • Allow users to select dates

Alt text

Features

  • Pure JavaScript, no dependencies, written in ES6
  • Easily customizable
  • Change colors to match your style/brand
  • Modify styling with the sass file (notie.scss) or overwrite the CSS
  • Font size auto-adjusts based on screen size

Browser Support

  • IE 10+
  • Chrome 11+
  • Firefox 4+
  • Safari 5.1+
  • Opera 11.5+

Installation

HTML:

<head>
  ...
  <link rel="stylesheet" type="text/css" href="https://unpkg.com/notie/dist/notie.min.css">
</head>
<body>
  ...
  <!-- Bottom of body -->
  <script src="https://unpkg.com/notie"></script>
</body>

npm:

npm install notie

Usage

notie.alert({
  type: Number|String, // optional, default = 4, enum: [1, 2, 3, 4, 5, 'success', 'warning', 'error', 'info', 'neutral']
  message: String,
  stay: Boolean, // optional, default = false
  time: Number // optional, default = 3, minimum = 1
})

notie.force({
  type: Number|String, // optional, default = 5, enum: [1, 2, 3, 4, 5, 'success', 'warning', 'error', 'info', 'neutral']
  text: String,
  buttonText: String // optional, default = 'OK'
}, callback())

notie.confirm({
  text: String,
  yesText: String, // optional, default = 'Yes'
  noText: String // optional, default = 'Cancel'
}, yesCallbackOptional(), noCallbackOptional())

notie.input({
  text: String,
  submitText: String, // optional, default = 'Submit'
  cancelText: String // optional, default = 'Cancel'
  autocapitalize: 'words', // default: 'none'
  autocomplete: 'on', // default: 'off'
  autocorrect: 'off', // default: 'off'
  autofocus: 'true', // default: 'true'
  inputmode: 'latin', // default: 'verbatim'
  max: '10000',// default: ''
  maxlength: '10', // default: ''
  min: '5', // default: ''
  minlength: '1', // default: ''
  placeholder: 'Jane Smith', // default: ''
  spellcheck: 'false', // default: 'default'
  step: '5', // default: 'any'
  type: 'text', // default: 'text'
  allowed: ['an', 's'] // Default: null, 'an' = alphanumeric, 'a' = alpha, 'n' = numeric, 's' = spaces allowed. Can be custom RegExp, ex. allowed: new RegExp('[^0-9]', 'g')
}, submitCallbackOptional(value), cancelCallbackOptional(value))

notie.select({
  text: String,
  cancelText: String,
  choices: [
    {
      type: Number|String, // optional, default = 1
      text: String,
      handler: Function
    }
    ...
  ]
})

notie.date({
  value: Date,
  submitText: String, // optional, default = 'OK'
  cancelText: String // optional, default = 'Cancel'
}, submitCallbackOptional(date), cancelCallbackOptional(date))

For example:

notie.alert({ text: 'Info!')
notie.alert({ type: 1, text: 'Success!', stay: true) // Never hides unless clicked, or escape or enter is pressed
notie.alert({ type: 'success', text: 'Success!', time: 2 }) // Hides after 2 seconds
notie.alert({ type: 2, text: 'Warning<br><b>with</b><br><i>HTML</i><br><u>included.</u>' })
notie.alert({ type: 'warning', text: 'Watch it...' })
notie.alert({ type: 3, text: 'Error.' })
notie.alert({ type: 'error', text: 'Oops!' })
notie.alert({ type: 4, text: 'Information.' })
notie.alert({ type: 'info', text: 'FYI, blah blah blah.' })

notie.force({
  type: 3,
  text: 'You cannot do that, sending you back.',
  buttonText: 'OK'
}, function () {
  notie.alert({ type: 3, text: 'Maybe when you\'re older...' })
})

notie.confirm({
  text: 'Are you sure you want to do that?',
  yesText: 'Yes',
  noText: 'Cancel'
}, function () {
  notie.alert({ type: 1, text: 'Good choice!' })
}, function () {
  notie.alert({ type: 3, text: 'Aw, why not? :(' })
})
notie.confirm({ text: 'Are you sure?' }, function() {
  notie.confirm({ text: 'Are you <b>really</b> sure?' }, function() {
    notie.confirm({ text: 'Are you <b>really</b> <i>really</i> sure?' }, function() {
      notie.alert({ text: 'Okay, jeez...' })
    })
  })
})

notie.input({
  text: 'Please enter your email:',
  submitText: 'Submit',
  cancelText: 'Cancel',
  value: 'jane@doe.com',
  type: 'email',
  placeholder: 'name@example.com'
}, function(value) {
  notie.alert({ type: 1, text: 'You entered: ' + value })
}, function(value) {
  notie.alert({ type: 3, text: 'You cancelled with this value: ' + value })
})

notie.input({
  text: 'Please enter your name:',
  type: 'text',
  placeholder: 'Jane Doe',
  allowed: ['a', 's']
}, function(value) {
  notie.alert({ type: 1, text: 'You entered: ' + value })
}, function(value) {
  notie.alert({ type: 3, text: 'You cancelled with this value: ' + value })
})

notie.input({
  text: 'Please enter the price:',
  type: 'text',
  placeholder: '500',
  allowed: new RegExp('[^0-9]', 'g')
}, function(value) {
  notie.alert({ type: 1, text: 'You entered: ' + value })
}, function(value) {
  notie.alert({ type: 3, text: 'You cancelled with this value: ' + value })
})

notie.select({
  text: 'Demo item #1, owner is Jane Smith',
  cancelText: 'Cancel',
  choices: [
    {
      text: 'Share',
      handler: function () {
        notie.alert({ type: 1, text: 'Share item!' })
      }
    },
    {
      text: 'Open',
      handler: function () {
        notie.alert({ type: 1, text: 'Open item!' })
      }
    },
    {
      type: 2,
      text: 'Edit',
      handler: function () {
        notie.alert({ type: 2, text: 'Edit item!' })
      }
    },
    {
      type: 3,
      text: 'Delete',
      handler: function () {
        notie.alert({ type: 3, text: 'Delete item!' })
      }
    }
  ]
})

notie.date({
  value: new Date(2015, 8, 27),
  submitText: 'Submit',
  cancelText: 'Cancel'
}, function (date) {
  notie.alert({ type: 1, text: 'You selected: ' + date.toISOString() })
}, function (date) {
  notie.alert({ type: 3, text: 'You cancelled: ' + date.toISOString() })
})
Use ES6 to inherit 'this' while using notie
notie.confirm('Is ES6 great?', 'Yes', 'Cancel', () => {
  this.location.href = 'htts://google.com'
})

Options

General
// Showing all available options with defaults
notie.setOptions({
  alertTime: 3,
  dateMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
  overlayClickDismiss: true,
  overlayOpacity: 0.75,
  transitionCurve: 'ease',
  transitionDuration: 0.3,
  transitionSelector: 'all'
  classes: {
    container: 'notie-container',
    textbox: 'notie-textbox',
    textboxInner: 'notie-textbox-inner',
    button: 'notie-button',
    element: 'notie-element',
    elementHalf: 'notie-element-half',
    elementThird: 'notie-element-third',
    overlay: 'notie-overlay',
    backgroundSuccess: 'notie-background-success',
    backgroundWarning: 'notie-background-warning',
    backgroundError: 'notie-background-error',
    backgroundInfo: 'notie-background-info',
    backgroundNeutral: 'notie-background-neutral',
    backgroundOverlay: 'notie-background-overlay',
    alert: 'notie-alert',
    inputField: 'notie-input-field',
    selectChoiceRepeated: 'notie-select-choice-repeated',
    dateSelectorInner: 'notie-date-selector-inner',
    dateSelectorUp: 'notie-date-selector-up'
  },
  ids: {
    overlay: 'notie-overlay'
  }
})

Other Methods

// programmatically hide all alerts with an optional callback function
notie.hideAlerts(callbackOptional)

License

MIT

Keywords

FAQs

Package last updated on 26 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc