1 $.fn
.translatize = function (options
) {
2 return this.each(function(i
, o
){
4 sensitivity
: 1, interval
: 200, timeout
: 500,
6 $(".translations", o
).slideDown("slow");
9 $(".translations", o
).slideUp("slow");
12 jQuery(".add_translation", o
).after(
13 '<div class="add_translation_box">\
14 <div class="header">Add word</div>\
15 <form method="post" action="/w/ajax/word/add-translation/">\
16 <input type="text" class="word_ac">\
17 <input type="hidden" name="other_word">\
18 <input type="hidden" name="word"><br>\
19 <input type="submit" class="add_it" value="Add it">\
21 <a href="#f" class="not_really">Not really</a>\
24 jQuery("input[@name=word]").val(get_word_id(o
));
25 jQuery(".add_translation", o
).unbind().click(function(){
27 jQuery(".add_translation_box", o
).toggle("slow");
28 $("input.word_ac", o
).val("").get(0).focus();
31 jQuery(".not_really", o
).unbind().click(function(){
32 jQuery(".add_translation_box", o
).toggle("hide");
35 var search_url
= "/w/ajax/search/?exclude_word=" + get_word_id(o
);
36 search_url
+= "&exclude_language=" + get_class_data(o
, "lang_");
37 jQuery("input.word_ac", o
).autocomplete(
40 onItemSelect: function(li
){
41 $("input[@name=other_word]", o
).val(li
.extra
);
45 jQuery("li", o
).each(function(i2
, o2
){
47 '<img class="dnone remover" \
48 src="/media/img/admin/icon_deletelink.gif">\
50 Are you sure to remove this?\
51 <form method="post" action="/w/ajax/word/remove-translation/">\
52 <input type="hidden" name="other_word">\
53 <input type="hidden" name="word"><br>\
54 <input type="submit" value="Remove it">\
56 <a href="#f" class="not_really">Not really</a>\
59 $("input[@name=word]", o2
).val(get_word_id(o
));
60 $("input[@name=other_word]", o2
).val(get_word_id(o2
));
61 $("img.remover, a.not_really", o2
).click(function(){
62 $("div", o2
).toggle();
65 jQuery(o2
).hover(function(){
66 jQuery("img", o2
).show();
68 jQuery("img", o2
).hide();
74 function get_word_id(o
){
75 var classes
= jQuery(o
).attr("class").split(" ");
77 $.each(classes
, function(i
, cls
){
78 if(cls
.indexOf("w_") == 0){
79 word_id
= cls
.substring(2);