message-box
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -8,3 +8,3 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -37,11 +37,10 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function MessageBox() { | ||
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
escape = _ref.escape, | ||
evaluate = _ref.evaluate, | ||
initialLanguage = _ref.initialLanguage, | ||
interpolate = _ref.interpolate, | ||
messages = _ref.messages, | ||
tracker = _ref.tracker; | ||
var initialLanguage = _ref.initialLanguage; | ||
var messages = _ref.messages; | ||
var tracker = _ref.tracker; | ||
var interpolate = _ref.interpolate; | ||
var evaluate = _ref.evaluate; | ||
var escape = _ref.escape; | ||
_classCallCheck(this, MessageBox); | ||
@@ -51,4 +50,8 @@ | ||
this.messageList = messages || {}; | ||
if (tracker) this.trackerDep = new tracker.Dependency(); | ||
if (tracker) { | ||
this.tracker = tracker; | ||
this.trackerDep = new tracker.Dependency(); | ||
} | ||
// Template options | ||
@@ -61,5 +64,13 @@ this.interpolate = interpolate || MessageBox.interpolate || DEFAULT_INTERPOLATE; | ||
_createClass(MessageBox, [{ | ||
key: 'messages', | ||
value: function messages(_messages) { | ||
(0, _lodash2.default)(this.messageList, _messages); | ||
key: 'clone', | ||
value: function clone() { | ||
var copy = new MessageBox({ | ||
escape: this.escape, | ||
evaluate: this.evaluate, | ||
initialLanguage: this.language, | ||
interpolate: this.interpolate, | ||
tracker: this.tracker | ||
}); | ||
copy.messages(this.messageList); | ||
return copy; | ||
} | ||
@@ -93,7 +104,6 @@ }, { | ||
value: function message(errorInfo) { | ||
var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
context = _ref2.context, | ||
language = _ref2.language; | ||
var language = _ref2.language; | ||
var context = _ref2.context; | ||
// Error objects can optionally include a preformatted message, | ||
@@ -106,6 +116,5 @@ // in which case we use that. | ||
var _getMessages = this.getMessages(language); | ||
var _getMessages = this.getMessages(language), | ||
messages = _getMessages.messages; | ||
var messages = _getMessages.messages; | ||
var message = messages[errorInfo.type]; | ||
@@ -132,2 +141,7 @@ | ||
}, { | ||
key: 'messages', | ||
value: function messages(_messages) { | ||
(0, _lodash2.default)(this.messageList, _messages); | ||
} | ||
}, { | ||
key: 'setLanguage', | ||
@@ -147,10 +161,9 @@ value: function setLanguage(language) { | ||
value: function defaults() { | ||
var _ref3 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
escape = _ref3.escape, | ||
evaluate = _ref3.evaluate, | ||
initialLanguage = _ref3.initialLanguage, | ||
interpolate = _ref3.interpolate, | ||
messages = _ref3.messages; | ||
var initialLanguage = _ref3.initialLanguage; | ||
var messages = _ref3.messages; | ||
var interpolate = _ref3.interpolate; | ||
var evaluate = _ref3.evaluate; | ||
var escape = _ref3.escape; | ||
if (typeof initialLanguage === 'string') MessageBox.language = initialLanguage; | ||
@@ -157,0 +170,0 @@ |
{ | ||
"name": "message-box", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "A package for defining and getting validation error messages, with support for Meteor Tracker reactivity", | ||
@@ -22,6 +22,4 @@ "author": "Eric Dobbertin <aldeed@gmail.com>", | ||
"lint": "eslint .", | ||
"jscs": "jscs .", | ||
"lint:fix": "eslint . --fix || true", | ||
"jscs:fix": "jscs . --fix || true", | ||
"prepublish": "npm run build", | ||
"prepare": "npm run build", | ||
"test": "mocha --compilers js:babel-core/register --recursive 'lib/**/*.tests.js'", | ||
@@ -46,5 +44,4 @@ "test:watch": "npm test -- --watch" | ||
"expect": "^1.20.1", | ||
"jscs": "^3.0.4", | ||
"mocha": "^2.5.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14769
12
5
143