File: D:/HostingSpaces/SBogers10/kms.komma.pro/wwwroot/public/js/confirm.class.js
(function($) {
$.confirm = function(element, options) {
var defaults = {
url : '',
msg : ''
};
// Reference to this
var t = this;
// Create settings object
t.settings = {};
// jQuery reference to element
var $element = $(element);
var $holder;
// Constructor
t.init = function ()
{
// Extend the defaults with options, save in settings
t.settings = $.extend({}, defaults, options);
// Load the message
t.appendMessage();
};
// Load the message html
t.appendMessage = function()
{
// Make an AJAX call to get the message
var path = window.location.pathname;
var parts = path.split('/');
var lang = parts[1];
$.ajax({ url: '/' + lang + '/confirm/' + t.settings.msg, success : function(data){
// Create a new background
$holder = $('<div/>');
$holder.addClass('dialog_holder');
$holder.html(data);
// Show Dialog
$element.prepend($holder);
setTimeout(function(){ $holder.addClass('show'); },50);
t.addFunctionality();
} });
};
/*
* Add button functionality
*/
t.addFunctionality = function()
{
// Set dialog
var $dialog = $holder.children('.dialog');
// Confirm button
$dialog.children('#confirm').click(function(e)
{
// Remove holder
t.close();
// Return confirm
if ( t.settings.onConfirm !== undefined) {
t.settings.onConfirm(e);
}
})
// Deny button
$dialog.children('#abort').click(function(e)
{
// Remove holder
t.close();
// Return abort
if ( t.settings.onAbort !== undefined) {
t.settings.onAbort(e);
}
});
// Deny on background click
$holder.children('.bg').click(function(e)
{
// Remove holder
t.close();
// Return abort
if ( t.settings.onAbort !== undefined) {
t.settings.onAbort(e);
}
});
};
t.close = function()
{
$holder.removeClass('show');
setTimeout(function(){ $holder.remove(); },300);
};
// Run plugin
t.init();
};
$.fn.confirm = function(options)
{
return this.each(function()
{
// if plugin has not already been attached to the element
//if ($(this).data('confirm') == undefined)
//{
// create a new instance of the plugin
var confirm = new $.confirm(this, options);
$(this).data('confirm', confirm);
//}
});
}
})(jQuery);