1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
$( function() {
var word = $("#word"), allFields = $( []).add(word), tips = $("#validateTips");
function updateTips(t) {
tips.text(t).effect("highlight", {}, 1500);
}
function checkLength(o, n, min) {
if (o.attr("value").length < min) {
o.addClass('ui-state-error');
updateTips("The word to blacklist can not be empty !!");
return false;
} else {
return true;
}
}
$('#add-word').click( function() {
$('#add-to-blacklist_dialog').dialog('open');
return false;
}).hover( function() {
$(this).addClass("ui-state-hover");
}, function() {
$(this).removeClass("ui-state-hover");
}).mousedown( function() {
$(this).addClass("ui-state-active");
}).mouseup( function() {
$(this).removeClass("ui-state-active");
});
$("#add-to-blacklist_dialog").dialog(
{
bgiframe : true,
autoOpen : false,
height : 220,
modal : true,
resizable : false,
buttons : {
'Ok' : function() {
var bValid = true;
allFields.removeClass('ui-state-error');
bValid = bValid&& checkLength(word,"word", 1);
if (bValid) {
$('.replacement') .replaceWith(
'<span style=" font-weight: bold;color: red;">' + word.attr("value") + '</span>');
$('#confirm_word_add_dialog').dialog('open');
return false;
$(this).dialog('close');
}
},
Cancel : function() {
$(this).dialog('close');
}
},
close : function() {
allFields.val('').removeClass('ui-state-error');
}
});
$("#confirm_word_add_dialog").dialog( {
bgiframe : true,
autoOpen : false,
height : 200,
width : 400,
resizable : false,
modal : true,
buttons : {
Cancel : function() {
$(this).dialog('close');
mot_interdit.text(' ');
},
'Ok' : function() {
//somecode
$(this).dialog('close');
$("#add-to-blacklist_dialog").dialog('close');
return false;
}
},
close : function() {
}
});
}); |
Partager