This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import View from './view'; | |
| import Model from './model'; | |
| import Controller from './controller'; | |
| export default class Clipboard { | |
| constructor(options) { | |
| this.model = new Model(); | |
| this.controller = new Controller(this.model); | |
| this.view = new View(this.controller, options); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Clipboard from '../lib/clipboard'; | |
| import Tooltip from '../lib/tooltip'; | |
| export default function init() { | |
| const clipboards = new Clipboard({ | |
| nodes: document.queryAll('[data-clipboard]'), | |
| targets: document.queryAll('[data-clipboard-target]'), | |
| }).init(); | |
| clipboards.each((instance) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import View from './view'; | |
| export default class ModalView extends View { | |
| constructor(controller, options) { | |
| super(controller); | |
| this.node = options.node; | |
| this.overlay = options.overlay; | |
| this.triggers = options.triggers; | |
| this.init(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class View { | |
| constructor(controller) { | |
| this.controller = controller; | |
| this.controller.model.registerObserver(this); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Controller from './controller'; | |
| export default class ModalController extends Controller { | |
| open(e) { | |
| this.model.isOpen = true; | |
| } | |
| close(e) { | |
| this.model.isOpen = false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default class Controller { | |
| constructor(model) { | |
| this.model = model; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Model from './model'; | |
| export default class ModalModel extends Model { | |
| constructor() { | |
| super(); | |
| // Modal offen, oder nicht? | |
| this._isOpen = false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default class Model { | |
| constructor() { | |
| // Speicher alle Beobachter | |
| this.observers = []; | |
| } | |
| // Füge einen neuen Beobachter hinzu | |
| registerObserver(observer) { | |
| this.observers.push(observer); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import View from './view'; | |
| import Model from './model'; | |
| import Controller from './controller'; | |
| export default class Modal { | |
| constructor(options) { | |
| this.model = new Model(); | |
| this.controller = new Controller(this.model); | |
| this.view = new View(this.controller, options); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Modal from './container'; | |
| import Manager from './manager'; | |
| // Wir erstellen uns ein paar Standard-Werte, | |
| // damit wir nicht jedes mal alles konfigurieren müssen. | |
| const DEFAULTS = { | |
| id: 'data-modal', | |
| overlay: 'data-modal-overlay', | |
| openTrigger: 'data-modal-open', | |
| closeTrigger: 'data-modal-close', |