add wrappers for alertifyjs
This commit is contained in:
parent
85702f2706
commit
3d3c6e4800
@ -1,7 +1,8 @@
|
|||||||
define([
|
define([
|
||||||
'/bower_components/chainpad-crypto/crypto.js',
|
'/bower_components/chainpad-crypto/crypto.js',
|
||||||
|
'/bower_components/alertifyjs/dist/js/alertify.js',
|
||||||
'/bower_components/jquery/dist/jquery.min.js',
|
'/bower_components/jquery/dist/jquery.min.js',
|
||||||
], function (Crypto) {
|
], function (Crypto, Alertify) {
|
||||||
/* This file exposes functionality which is specific to Cryptpad, but not to
|
/* This file exposes functionality which is specific to Cryptpad, but not to
|
||||||
any particular pad type. This includes functions for committing metadata
|
any particular pad type. This includes functions for committing metadata
|
||||||
about pads to your local storage for future use and improved usability.
|
about pads to your local storage for future use and improved usability.
|
||||||
@ -9,6 +10,7 @@ define([
|
|||||||
Additionally, there is some basic functionality for import/export.
|
Additionally, there is some basic functionality for import/export.
|
||||||
*/
|
*/
|
||||||
var $ = window.jQuery;
|
var $ = window.jQuery;
|
||||||
|
|
||||||
var common = {};
|
var common = {};
|
||||||
|
|
||||||
var isArray = function (o) { return Object.prototype.toString.call(o) === '[object Array]'; };
|
var isArray = function (o) { return Object.prototype.toString.call(o) === '[object Array]'; };
|
||||||
@ -186,5 +188,43 @@ define([
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var styleAlerts = common.styleAlerts = function (href) {
|
||||||
|
href = href || '/customize/alertify.css';
|
||||||
|
$('head').append($('<link>', {
|
||||||
|
rel: 'stylesheet',
|
||||||
|
id: 'alertifyCSS',
|
||||||
|
href: href,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
common.alert = function (msg, cb) {
|
||||||
|
Alertify.alert(msg, cb);
|
||||||
|
};
|
||||||
|
|
||||||
|
common.prompt = function (msg, def, cb, opt) {
|
||||||
|
opt = opt || {};
|
||||||
|
Alertify
|
||||||
|
.defaultValue(def || '')
|
||||||
|
.okBtn(opt.ok || 'OK')
|
||||||
|
.cancelBtn(opt.cancel || 'Cancel')
|
||||||
|
.prompt(msg, function (val, ev) {
|
||||||
|
cb(val, ev);
|
||||||
|
}, function (ev) {
|
||||||
|
cb(null, ev);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
common.confirm = function (msg, cb, opt) {
|
||||||
|
opt = opt || {};
|
||||||
|
Alertify
|
||||||
|
.okBtn(opt.ok || 'OK')
|
||||||
|
.cancelBtn(opt.cancel || 'Cancel')
|
||||||
|
.confirm(msg, function () {
|
||||||
|
cb(true);
|
||||||
|
}, function () {
|
||||||
|
cb(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return common;
|
return common;
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user