CARVIEW |
Select Language
HTTP/2 301
location: https://raw.githubusercontent.com/sloria/AreYouSure.js/master/areyousure.js
accept-ranges: bytes
age: 0
date: Wed, 23 Jul 2025 13:50:43 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210026-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753278642.120078,VS0,VE1129
vary: Accept-Encoding
x-fastly-request-id: 0d420308844b70409cef66872da4e200c007733e
content-length: 0
HTTP/2 200
cache-control: max-age=300
content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
content-type: text/plain; charset=utf-8
etag: W/"73920d1b548e6e606cb521451bf0be25ad3bc27c4f08565d5eff80550625cd41"
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: deny
x-xss-protection: 1; mode=block
x-github-request-id: D32F:25676B:144C5B:2EFDDC:6880E8B2
content-encoding: gzip
accept-ranges: bytes
date: Wed, 23 Jul 2025 13:50:43 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210040-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753278643.306473,VS0,VE261
vary: Authorization,Accept-Encoding
access-control-allow-origin: *
cross-origin-resource-policy: cross-origin
x-fastly-request-id: cdffd49a80fa921007db9b6caa3f7ff66f6504cf
expires: Wed, 23 Jul 2025 13:55:43 GMT
source-age: 0
content-length: 1139
(function() {
var $, AreYouSure, asAnchor, defaults, namespace, noop;
$ = jQuery;
namespace = "areyousure";
asAnchor = function(text, action) {
return "" + text + "";
};
noop = function() {};
defaults = {
text: "Are you sure?",
confirmText: 'Yes',
cancelText: 'No',
sep: " | ",
reverse: false,
yes: noop,
no: noop,
additional: []
};
AreYouSure = (function() {
function AreYouSure(element, options) {
var text, txt;
this.element = element;
this.element.wrap("");
this.options = $.extend({}, defaults, options);
this.cancelText = asAnchor(this.options.cancelText, 'cancel');
this.confirmText = asAnchor(this.options.confirmText, 'confirm');
if (this.options.additional.length > 0) {
this.additional = ((function() {
var _i, _len, _ref, _results;
_ref = this.options.additional;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
txt = _ref[_i];
_results.push(asAnchor(txt));
}
return _results;
}).call(this)).join(this.options.sep);
} else {
this.additional = '';
}
if (this.options.reverse) {
text = "" + this.options.text + " " + this.cancelText + this.options.sep + this.confirmText;
} else {
text = "" + this.options.text + " " + this.confirmText + this.options.sep + this.cancelText;
}
this.confirmElem = " " + text + (this.additional ? this.options.sep + this.additional : '') + "";
this.element.after(this.confirmElem);
this.outer = this.element.parent();
this.dialog = this.outer.find("[data-ays-dialog]");
this.init();
}
AreYouSure.prototype.init = function() {
var self;
self = this;
this.element.on("click", function(evt) {
evt.preventDefault();
return self.activate();
});
this.outer.on('click', "." + namespace + "-link", function(evt) {
var callback;
evt.preventDefault();
callback = $(this).data('ays-action') === "confirm" ? "yes" : "no";
return $.when(self.options[callback].call(self, evt)).then(function() {
return self.deactivate();
});
});
return this;
};
AreYouSure.prototype.activate = function() {
this.dialog.show() && this.element.hide();
return this;
};
AreYouSure.prototype.deactivate = function() {
this.dialog.hide() && this.element.show();
return this;
};
return AreYouSure;
})();
$.fn.areyousure = function(options) {
return this.each(function() {
if (!$.data(this, "plugin_" + namespace)) {
return $.data(this, "plugin_" + namespace, new AreYouSure($(this), options));
}
});
};
AreYouSure.discover = function() {
return $("[data-areyousure]").each(function() {
var $this;
$this = $(this);
return new AreYouSure($this, {
text: $this.data('areyousure') || defaults.text,
confirmText: $this.data("confirm") || defaults.confirmText,
cancelText: $this.data("cancel") || defaults.cancelText,
reverse: $this.data("reversed"),
sep: $this.data('separator')
});
});
};
window.AreYouSure = AreYouSure;
AreYouSure.auto = true;
$(function() {
if (AreYouSure.auto) {
return AreYouSure.discover();
}
});
}).call(this);