code cleanind, delete deprecated files
This commit is contained in:
-145
@@ -1,145 +0,0 @@
|
||||
jQuery(function ($) {
|
||||
var contact = {
|
||||
message: null,
|
||||
init: function () {
|
||||
$('a.contact').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
// load the contact form using ajax
|
||||
var act = $(this).attr('id');
|
||||
var page = $('div.page').attr('id');
|
||||
$.get("data/contact.php?act=edit&fid="+act+"", function(data){
|
||||
// create a modal dialog with the data
|
||||
$(data).modal({
|
||||
closeHTML: "<a href='#' title='Закрыть' class='modal-close'>x</a>",
|
||||
position: ["15%",],
|
||||
overlayId: 'contact-overlay',
|
||||
containerId: 'contact-container',
|
||||
onOpen: contact.open,
|
||||
onShow: contact.show,
|
||||
onClose: contact.close
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
open: function (dialog) {
|
||||
// dynamically determine height
|
||||
var h = 480;
|
||||
if ($('#contact-subject').length) {
|
||||
h += 26;
|
||||
}
|
||||
if ($('#contact-cc').length) {
|
||||
h += 22;
|
||||
}
|
||||
|
||||
var title = $('#contact-container .contact-title').html();
|
||||
$('#contact-container .contact-title').html('Открытие...');
|
||||
dialog.overlay.fadeIn(200, function () {
|
||||
dialog.container.fadeIn(200, function () {
|
||||
dialog.data.fadeIn(200, function () {
|
||||
$('#contact-container .contact-content').animate({
|
||||
height: h
|
||||
}, function () {
|
||||
$('#contact-container .contact-title').html(title);
|
||||
$('#contact-container form').fadeIn(200, function () {
|
||||
$('#contact-container #contact-name').focus();
|
||||
|
||||
$('#contact-container .contact-cc').click(function () {
|
||||
var cc = $('#contact-container #contact-cc');
|
||||
cc.is(':checked') ? cc.attr('checked', '') : cc.attr('checked', 'checked');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
show: function (dialog) {
|
||||
$('#contact-container .contact-send').click(function (e) {
|
||||
e.preventDefault();
|
||||
// validate form
|
||||
if (contact.validate()) {
|
||||
var msg = $('#contact-container .contact-message');
|
||||
msg.fadeOut(function () {
|
||||
msg.removeClass('contact-error').empty();
|
||||
});
|
||||
$('#contact-container .contact-title').html('Обработка...');
|
||||
$('#contact-container form').fadeOut(200);
|
||||
$('#contact-container .contact-content').animate({
|
||||
height: '80px'
|
||||
}, function () {
|
||||
$('#contact-container .contact-loading').fadeIn(200, function () {
|
||||
$.ajax({
|
||||
url: 'data/contact.php',
|
||||
data: $('#contact-container form').serialize() + '&act=send',
|
||||
type: 'GET',
|
||||
cache: false,
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
$('#contact-container .contact-loading').fadeOut(200, function () {
|
||||
$('#contact-container .contact-title').html('Успешно ...');
|
||||
msg.html(data).fadeIn(200);
|
||||
});
|
||||
},
|
||||
error: contact.error
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
if ($('#contact-container .contact-message:visible').length > 0) {
|
||||
var msg = $('#contact-container .contact-message div');
|
||||
msg.fadeOut(200, function () {
|
||||
msg.empty();
|
||||
contact.showError();
|
||||
msg.fadeIn(200);
|
||||
});
|
||||
}
|
||||
else {
|
||||
$('#contact-container .contact-message').animate({
|
||||
height: '30px'
|
||||
}, contact.showError);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
close: function (dialog) {
|
||||
$('#contact-container .contact-message').fadeOut();
|
||||
$('#contact-container .contact-title').html('Закрываю...');
|
||||
$('#contact-container form').fadeOut(200);
|
||||
$('#contact-container .contact-content').animate({
|
||||
height: 40
|
||||
}, function () {
|
||||
dialog.data.fadeOut(200, function () {
|
||||
dialog.container.fadeOut(200, function () {
|
||||
dialog.overlay.fadeOut(200, function () {
|
||||
$.modal.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
error: function (xhr) {
|
||||
alert(xhr.statusText);
|
||||
},
|
||||
validate: function () {
|
||||
contact.message = '';
|
||||
if (!$('#contact-container #contact-message').val()) {
|
||||
contact.message += 'Введите сообщение.';
|
||||
}
|
||||
|
||||
if (contact.message.length > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
showError: function () {
|
||||
$('#contact-container .contact-message').html($('<div class="contact-error"></div>').append(contact.message)).fadeIn(200);
|
||||
}
|
||||
};
|
||||
|
||||
contact.init();
|
||||
|
||||
});
|
||||
@@ -1,145 +0,0 @@
|
||||
function extend(Child, Parent) {
|
||||
var F = function() { }
|
||||
F.prototype = Parent.prototype
|
||||
Child.prototype = new F()
|
||||
Child.prototype.constructor = Child
|
||||
Child.superclass = Parent.prototype
|
||||
}
|
||||
|
||||
function MagicInput(options, data, callback) {
|
||||
this.data = data;
|
||||
this.options = options;
|
||||
this._callback = callback;
|
||||
}
|
||||
|
||||
MagicInput.prototype.toString = function() {
|
||||
return 'This is MagicInput object';
|
||||
}
|
||||
|
||||
MagicInput.prototype.callback = function() {
|
||||
this._callback.apply(this, arguments);
|
||||
}
|
||||
|
||||
MagicInput.instance = function(el, data, callback) {
|
||||
el = $(el);
|
||||
var options = {};
|
||||
options['action'] = el.attr('mi-action');
|
||||
options['title'] = el.attr('mi-title');
|
||||
options['iface'] = el.attr('mi-iface');
|
||||
options['data'] = el.attr('mi-data');
|
||||
try {
|
||||
$.extend(data, options.data ? $.parseJSON(options.data) : {});
|
||||
delete options.data;
|
||||
options.iface = 'mi' + options.iface.substring(0, 1).toUpperCase() + options.iface.substring(1);
|
||||
return input = new window[options.iface](options, data, callback);
|
||||
} catch(e) {
|
||||
console.log('MagicInput::instance ' + e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function miNone(options, callback) {
|
||||
miNote.superclass.constructor.apply(this, arguments);
|
||||
this.callback();
|
||||
}
|
||||
extend(miNone, MagicInput);
|
||||
|
||||
miNone.prototype.toString = function() {
|
||||
return 'This is miNone object';
|
||||
}
|
||||
|
||||
function miNote(options, callback) {
|
||||
miNote.superclass.constructor.apply(this, arguments);
|
||||
if(confirm('Использовать "'+this.options.title+'" сейчас?')) {
|
||||
this.callback()
|
||||
}
|
||||
}
|
||||
extend(miNote, MagicInput);
|
||||
|
||||
miNote.prototype.toString = function() {
|
||||
return 'This is miNote object';
|
||||
}
|
||||
|
||||
function miDialog(options, data, callback, content, dialogOptions) {
|
||||
miDialog.superclass.constructor.apply(this, arguments);
|
||||
var mi = this;
|
||||
this.dialog = content.dialog($.extend({}, {
|
||||
title: this.options.title,
|
||||
resizable: false,
|
||||
minHeight: 20,
|
||||
dialogClass: 'sand-style mi-container',
|
||||
beforeClose: function(e, ui) {
|
||||
var tmp = true;
|
||||
if(1 * $(this).attr('submit')) {
|
||||
mi._collect.call(mi);
|
||||
if(tmp = mi._validation.call(mi)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$(this).attr('submit', 0);
|
||||
return tmp;
|
||||
},
|
||||
close: function(e, ui) {
|
||||
if(1 * $(this).attr('submit')) {
|
||||
mi.callback();
|
||||
}
|
||||
mi.destroy();
|
||||
}
|
||||
}, dialogOptions)).on('click','.dialog-submit',function() { $(this).closest('.ui-dialog-content').attr('submit', 1).dialog('close')})
|
||||
}
|
||||
|
||||
extend(miDialog, MagicInput);
|
||||
|
||||
miDialog.prototype.toString = function() {
|
||||
return 'This is ABSTRACT miDialog object';
|
||||
}
|
||||
|
||||
miDialog.prototype.destroy = function() {
|
||||
this.dialog.dialog('destroy').remove();
|
||||
}
|
||||
|
||||
miDialog._oneInput = function(p) {
|
||||
var i = $('<input type="'+(p.type ? p.type : 'text')+'" onkeyup="'+(p.onkeyup ? p.onkeyup : 'return false;')+'" onchange="'+(p.onchange ? p.onchange : 'return false;')+'" class="'+(p.clas ? p.clas : 'text')+'" value="'+(p.value ? p.value : '')+'" />').attr('name', p.name);
|
||||
if(p.grabber) {
|
||||
h[p.grabber].set(i);
|
||||
} else {
|
||||
i.select();
|
||||
}
|
||||
return $('<div class=oneinput></div>').append('<input type=button class="button dialog-submit" value=" »» ">').append($('<div></div>').append(i));
|
||||
}
|
||||
|
||||
miDialog._hiddenInput = function(p) {
|
||||
var i = $('<input type="hidden" class="text" />').attr('name', p.name).attr('value', p.value);
|
||||
if(p.grabber) {
|
||||
h[p.grabber].set(i);
|
||||
} else {
|
||||
i.select();
|
||||
}
|
||||
return $('<div class=oneinput></div>').append($('<div></div>').append(i));
|
||||
}
|
||||
|
||||
miDialog._simpleInput = function(p) {
|
||||
var i = $('<input type="'+(p.type ? p.type : 'text')+'" value="'+(p.value ? p.value : '')+'" class="text" />').attr('name', p.name);
|
||||
if(p.grabber) {
|
||||
h[p.grabber].set(i);
|
||||
} else {
|
||||
i.select();
|
||||
}
|
||||
return $('<div class=oneinput></div>').append($('<div></div>').append(i));
|
||||
}
|
||||
|
||||
miDialog.prototype._collect = function() {
|
||||
var mi = this;
|
||||
this.dialog.find('[name]').each(function() {
|
||||
var el = $(this);
|
||||
if(el.is('input[type="checkbox"]')) {
|
||||
mi.data[el.attr('name')] = ~~el.is(':checked');
|
||||
return;
|
||||
}
|
||||
mi.data[el.attr('name')] = el.val();
|
||||
})
|
||||
}
|
||||
|
||||
miDialog.prototype._validation = function() {
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user