button.js
5 years ago
collapse.js
5 years ago
component-wrapper.js
5 years ago
list-table-heading.js
5 years ago
list-table-item.js
5 years ago
list-table.js
5 years ago
notice-component.js
5 years ago
notice.js
5 years ago
pagination.js
5 years ago
popup.js
5 years ago
repeater-item.js
5 years ago
repeater.js
5 years ago
tabs-panel.js
5 years ago
tabs.js
5 years ago
title.js
5 years ago
notice.js
52 lines
| 1 | import NoticeComponent from './notice-component'; |
| 2 | |
| 3 | const CXNotice = { |
| 4 | instance: null, |
| 5 | stack: {}, |
| 6 | newInstance: function() { |
| 7 | var NoticeComponentClass = Vue.extend( NoticeComponent ); |
| 8 | |
| 9 | this.instance = new NoticeComponentClass({ |
| 10 | propsData: { type: 'primary' } |
| 11 | }); |
| 12 | |
| 13 | this.instance.$mount(); |
| 14 | document.body.appendChild( this.instance.$el ); |
| 15 | }, |
| 16 | getRandId: function() { |
| 17 | // Generates random string with 10 characters length |
| 18 | return Math.random().toString( 36 ).substring( 2, 7 ) + Math.random().toString( 36 ).substring( 2, 7 ); |
| 19 | }, |
| 20 | add: function( options, id ) { |
| 21 | |
| 22 | id = id || this.getRandId(); |
| 23 | |
| 24 | if ( ! this.instance ) { |
| 25 | this.newInstance(); |
| 26 | } |
| 27 | |
| 28 | options.duration = options.duration || 4500; |
| 29 | options.type = options.type || 'info'; |
| 30 | |
| 31 | this.instance.addToStack( options, id ); |
| 32 | |
| 33 | }, |
| 34 | close: function( id ) { |
| 35 | if ( id ) { |
| 36 | |
| 37 | id = id.toString(); |
| 38 | |
| 39 | if ( this.instance ) { |
| 40 | this.instance.destroyItem( id ); |
| 41 | } |
| 42 | } else { |
| 43 | return false; |
| 44 | } |
| 45 | }, |
| 46 | closeAll: function() { |
| 47 | this.instance.destroyAll(); |
| 48 | }, |
| 49 | }; |
| 50 | |
| 51 | export default CXNotice; |
| 52 |