# Code coverage report for lib/ui/SaveAsCloseForm.js

## Statements: 79.17% (19 / 24) Branches: 62.5% (5 / 8) Functions: 33.33% (2 / 6) Lines: 100% (19 / 19) Ignored: none

All files » lib/ui/ » SaveAsCloseForm.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    371
    1

    1
    1
    1

    1
    2

    2

    2

    2

    1

    1
    2
    2
    2
    2
    2
    2

    1
     var blessed = require('blessed');
    var _ = require('lazy.js');

    var Slap = require('./Slap');
    var SaveAsForm = require('./SaveAsForm');
    var Button = require('./Button');

    function SaveAsCloseForm (opts) {
      var self = this;

      Iif (!(self instanceof blessed.Node)) return new SaveAsCloseForm(opts);

      SaveAsForm.call(self, _(Slap.global.options.saveAsCloseForm).merge(opts || {}).toObject());

      self.discardChangesButton = new Button(_({
          parent: self,
          content: "Discard changes",
          top: 0,
          right: 0
        })
        .merge(Slap.global.options.button.warning || {})
        .merge(self.options.discardChangesButton || {})
        .toObject());
    }
    SaveAsCloseForm.prototype.__proto__ = SaveAsForm.prototype;

    SaveAsCloseForm.prototype._initHandlers = function () {
      var self = this;
      self.on('show', function () { self.slap.header.message("unsaved changes, please save or discard", 'warning'); });
      self.on('save', function () { self.pane.close(); });
      self.on('discardChanges', function () { self.pane.close(); });
      self.discardChangesButton.on('press', function () { self.emit('discardChanges'); });
      return SaveAsForm.prototype._initHandlers.apply(self, arguments);
    }

    module.exports = SaveAsCloseForm;