ng-alertify
Advanced tools
Comparing version 0.8.0 to 0.9.0
{ | ||
"name": "ng-alertify", | ||
"main": "ng-alertify.js", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"license": "MIT", | ||
@@ -18,7 +18,7 @@ "ignore": [ | ||
"keywords": [ | ||
"alertify", | ||
"angular", | ||
"angularjs", | ||
"message", | ||
"popup", | ||
"message", | ||
"alertify", | ||
"angularjs", | ||
"wrapper" | ||
@@ -25,0 +25,0 @@ ], |
/** | ||
ng-alertify@0.8.0 | ||
ng-alertify@0.9.0 | ||
AngularJS wrapper around alertify popup library | ||
@@ -648,72 +648,87 @@ Gleb Bahmutov <gleb@kensho.com> | ||
angular.module('Alertify', []) | ||
// need name that does not clash with other libraries / modules | ||
.constant('meta', { | ||
name: 'ng-alertify', | ||
description: 'AngularJS wrapper around alertify popup library', | ||
version: '0.8.0', | ||
author: 'Gleb Bahmutov <gleb@kensho.com>' | ||
}) | ||
.factory('Alertify', ['$q', function ($q) { | ||
function alertifyFactory($q) { | ||
if (typeof alertify === 'undefined') { | ||
throw new Error('Missing alertify object'); | ||
} | ||
if (typeof alertify === 'undefined') { | ||
throw new Error('Missing alertify object'); | ||
} | ||
var alertifyProxy = Object.create(alertify); | ||
var alertifyProxy = Object.create(alertify); | ||
function anyToString(x) { | ||
if (typeof x === 'string') { | ||
return x; | ||
} | ||
if (x instanceof Error) { | ||
return x.message; | ||
} | ||
return JSON.stringify(x, null, 2); | ||
function anyToString(x) { | ||
if (typeof x === 'string') { | ||
return x; | ||
} | ||
function newlineToBreak(x) { | ||
return typeof x === 'string' ? x.replace(/\n/g, '<br>') : x; | ||
if (x instanceof Error) { | ||
return x.message; | ||
} | ||
return JSON.stringify(x, null, 2); | ||
} | ||
// make sure the newlines are formatted in the output html | ||
var messageMethods = ['log', 'error', 'success', 'alert']; | ||
function newlineToBreak(x) { | ||
return typeof x === 'string' ? x.replace(/\n/g, '<br>') : x; | ||
} | ||
// overwrite .log(), .error(), and other simple popups | ||
messageMethods.forEach(function (name) { | ||
alertifyProxy[name] = function () { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
var strings = args.map(anyToString).map(newlineToBreak); | ||
return alertify[name].call(alertify, strings.join(' ')); | ||
}; | ||
}); | ||
// make sure the newlines are formatted in the output html | ||
var messageMethods = ['log', 'error', 'success', 'alert']; | ||
// transform .confirm(message) into promise-returning method | ||
alertifyProxy.confirm = function (message, cssClass) { | ||
var defer = $q.defer(); | ||
alertify.confirm(message, function (answer) { | ||
if (answer) { | ||
defer.resolve(answer); | ||
} else { | ||
defer.reject(answer); | ||
} | ||
}, cssClass); | ||
return defer.promise; | ||
// overwrite .log(), .error(), and other simple popups | ||
messageMethods.forEach(function (name) { | ||
alertifyProxy[name] = function () { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
var strings = args.map(anyToString).map(newlineToBreak); | ||
return alertify[name].call(alertify, strings.join(' ')); | ||
}; | ||
}); | ||
// transform .prompt(message) into promise-returning method | ||
alertifyProxy.prompt = function (message, defaultValue, cssClass) { | ||
var defer = $q.defer(); | ||
alertify.prompt(message, function (yes, answer) { | ||
if (yes) { | ||
defer.resolve(answer); | ||
} else { | ||
defer.reject(); | ||
} | ||
}, defaultValue, cssClass); | ||
return defer.promise; | ||
}; | ||
alertifyProxy.json = function alertifyJson(title, object) { | ||
if (typeof title === 'object') { | ||
object = title; | ||
title = 'JSON output'; | ||
} | ||
if (typeof title !== 'string') { | ||
throw new Error('Expected title to be a string'); | ||
} | ||
// pop an "alert" style dialog | ||
var str = JSON.stringify(object); | ||
alertify.prompt(title, undefined, str); | ||
}; | ||
return alertifyProxy; | ||
}]); | ||
// transform .confirm(message) into promise-returning method | ||
alertifyProxy.confirm = function alertifyConfirm(message, cssClass) { | ||
var defer = $q.defer(); | ||
alertify.confirm(message, function (answer) { | ||
if (answer) { | ||
defer.resolve(answer); | ||
} else { | ||
defer.reject(answer); | ||
} | ||
}, cssClass); | ||
return defer.promise; | ||
}; | ||
// transform .prompt(message) into promise-returning method | ||
alertifyProxy.prompt = function alertifyPrompt(message, defaultValue, cssClass) { | ||
var defer = $q.defer(); | ||
alertify.prompt(message, function (yes, answer) { | ||
if (yes) { | ||
defer.resolve(answer); | ||
} else { | ||
defer.reject(); | ||
} | ||
}, defaultValue, cssClass); | ||
return defer.promise; | ||
}; | ||
return alertifyProxy; | ||
} | ||
angular.module('Alertify', []) | ||
// need name that does not clash with other libraries / modules | ||
.constant('meta', { | ||
name: 'ng-alertify', | ||
description: 'AngularJS wrapper around alertify popup library', | ||
version: '0.9.0', | ||
author: 'Gleb Bahmutov <gleb@kensho.com>' | ||
}) | ||
.factory('Alertify', ['$q', alertifyFactory]); | ||
}(window.angular, window.alertify)); |
// mock AngularJS proxy to window.alertify | ||
(function (angular, alertify) { | ||
angular.module('Alertify', []) | ||
// need name that does not clash with other libraries / modules | ||
.constant('meta', { | ||
name: '%%name%%', | ||
description: '%%description%%', | ||
version: '%%version%%', | ||
author: '%%author%%' | ||
}) | ||
.factory('Alertify', ['$q', function ($q) { | ||
function alertifyFactory($q) { | ||
if (typeof alertify === 'undefined') { | ||
throw new Error('Missing alertify object'); | ||
} | ||
if (typeof alertify === 'undefined') { | ||
throw new Error('Missing alertify object'); | ||
} | ||
var alertifyProxy = Object.create(alertify); | ||
var alertifyProxy = Object.create(alertify); | ||
function anyToString(x) { | ||
if (typeof x === 'string') { | ||
return x; | ||
} | ||
if (x instanceof Error) { | ||
return x.message; | ||
} | ||
return JSON.stringify(x, null, 2); | ||
function anyToString(x) { | ||
if (typeof x === 'string') { | ||
return x; | ||
} | ||
function newlineToBreak(x) { | ||
return typeof x === 'string' ? x.replace(/\n/g, '<br>') : x; | ||
if (x instanceof Error) { | ||
return x.message; | ||
} | ||
return JSON.stringify(x, null, 2); | ||
} | ||
// make sure the newlines are formatted in the output html | ||
var messageMethods = ['log', 'error', 'success', 'alert']; | ||
function newlineToBreak(x) { | ||
return typeof x === 'string' ? x.replace(/\n/g, '<br>') : x; | ||
} | ||
// overwrite .log(), .error(), and other simple popups | ||
messageMethods.forEach(function (name) { | ||
alertifyProxy[name] = function () { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
var strings = args.map(anyToString).map(newlineToBreak); | ||
return alertify[name].call(alertify, strings.join(' ')); | ||
}; | ||
}); | ||
// make sure the newlines are formatted in the output html | ||
var messageMethods = ['log', 'error', 'success', 'alert']; | ||
// transform .confirm(message) into promise-returning method | ||
alertifyProxy.confirm = function (message, cssClass) { | ||
var defer = $q.defer(); | ||
alertify.confirm(message, function (answer) { | ||
if (answer) { | ||
defer.resolve(answer); | ||
} else { | ||
defer.reject(answer); | ||
} | ||
}, cssClass); | ||
return defer.promise; | ||
// overwrite .log(), .error(), and other simple popups | ||
messageMethods.forEach(function (name) { | ||
alertifyProxy[name] = function () { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
var strings = args.map(anyToString).map(newlineToBreak); | ||
return alertify[name].call(alertify, strings.join(' ')); | ||
}; | ||
}); | ||
// transform .prompt(message) into promise-returning method | ||
alertifyProxy.prompt = function (message, defaultValue, cssClass) { | ||
var defer = $q.defer(); | ||
alertify.prompt(message, function (yes, answer) { | ||
if (yes) { | ||
defer.resolve(answer); | ||
} else { | ||
defer.reject(); | ||
} | ||
}, defaultValue, cssClass); | ||
return defer.promise; | ||
}; | ||
alertifyProxy.json = function alertifyJson(title, object) { | ||
if (typeof title === 'object') { | ||
object = title; | ||
title = 'JSON output'; | ||
} | ||
if (typeof title !== 'string') { | ||
throw new Error('Expected title to be a string'); | ||
} | ||
// pop an "alert" style dialog | ||
var str = JSON.stringify(object); | ||
alertify.prompt(title, undefined, str); | ||
}; | ||
return alertifyProxy; | ||
}]); | ||
// transform .confirm(message) into promise-returning method | ||
alertifyProxy.confirm = function alertifyConfirm(message, cssClass) { | ||
var defer = $q.defer(); | ||
alertify.confirm(message, function (answer) { | ||
if (answer) { | ||
defer.resolve(answer); | ||
} else { | ||
defer.reject(answer); | ||
} | ||
}, cssClass); | ||
return defer.promise; | ||
}; | ||
// transform .prompt(message) into promise-returning method | ||
alertifyProxy.prompt = function alertifyPrompt(message, defaultValue, cssClass) { | ||
var defer = $q.defer(); | ||
alertify.prompt(message, function (yes, answer) { | ||
if (yes) { | ||
defer.resolve(answer); | ||
} else { | ||
defer.reject(); | ||
} | ||
}, defaultValue, cssClass); | ||
return defer.promise; | ||
}; | ||
return alertifyProxy; | ||
} | ||
angular.module('Alertify', []) | ||
// need name that does not clash with other libraries / modules | ||
.constant('meta', { | ||
name: '%%name%%', | ||
description: '%%description%%', | ||
version: '%%version%%', | ||
author: '%%author%%' | ||
}) | ||
.factory('Alertify', ['$q', alertifyFactory]); | ||
}(window.angular, window.alertify)); |
{ | ||
"name": "ng-alertify", | ||
"description": "AngularJS wrapper around alertify popup library", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"author": "Gleb Bahmutov <gleb@kensho.com>", | ||
@@ -12,10 +12,10 @@ "bugs": { | ||
"angular": "1.4.0", | ||
"angular-mocks": "1.4.0", | ||
"angular-mocks": "1.5.0-beta.0", | ||
"check-more-types": "1.4.0", | ||
"check-types": "1.4.0", | ||
"es5-shim": "4.1.3", | ||
"es5-shim": "4.1.13", | ||
"grunt": "0.4.5", | ||
"grunt-clean-console": "0.3.0", | ||
"grunt-contrib-concat": "0.5.1", | ||
"grunt-contrib-jshint": "0.11.2", | ||
"grunt-contrib-jshint": "0.11.3", | ||
"grunt-contrib-watch": "0.6.1", | ||
@@ -25,14 +25,14 @@ "grunt-deps-ok": "0.8.0", | ||
"grunt-karma": "0.11.0", | ||
"grunt-nice-package": "0.9.2", | ||
"grunt-nice-package": "0.9.4", | ||
"grunt-npm2bower-sync": "0.9.1", | ||
"karma": "0.12.32", | ||
"karma-chrome-launcher": "0.1.12", | ||
"karma-mocha": "0.1.10", | ||
"karma-chrome-launcher": "0.2.0", | ||
"karma-mocha": "0.2.0", | ||
"karma-nested-reporter": "0.1.3", | ||
"karma-phantomjs-launcher": "0.2.0", | ||
"lazy-ass": "0.5.8", | ||
"karma-phantomjs-launcher": "0.2.1", | ||
"lazy-ass": "0.6.0", | ||
"lazy-ass-helpful": "0.6.1", | ||
"matchdep": "0.3.0", | ||
"ng-describe": "0.10.2", | ||
"pre-git": "0.2.1" | ||
"pre-git": "0.6.2" | ||
}, | ||
@@ -44,7 +44,7 @@ "engines": { | ||
"keywords": [ | ||
"alertify", | ||
"angular", | ||
"angularjs", | ||
"message", | ||
"popup", | ||
"message", | ||
"alertify", | ||
"angularjs", | ||
"wrapper" | ||
@@ -51,0 +51,0 @@ ], |
@@ -48,2 +48,4 @@ # ng-alertify | ||
); | ||
// Pops dialog with JSON of the object | ||
Alertify.json(object); | ||
}); | ||
@@ -50,0 +52,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
267648
6152
91