jQuery -> $('#forum-comment-span').delegate '[id = forum-translation-choice]','click', (evt) -> setTranslationLanguage(event.target) $('#forum-translation-language').click -> showMe({id:'forum-translation-choices'}) $('#forum-translation-language').mouseleave -> hideMe({id:'forum-translation-choices'}) $('#forum-translation-language').change -> hideMe({id:'forum-translation-choices'}) $('#forum-comment-span').delegate 'textarea[id= forum-translation-suggestion]','dblclick', (evt) -> makeThisTheTranslations(event.target) makeThisTheTranslations=(which)-> $('#forum-comment-translation').val(which.value) window.getTranslationLanguage=-> $('#forum-translation-language').val() window.setTranslationState = -> comment_span = document.getElementById('forum-comment-span') the_span=$("[data-id="+comment_span.dataset.target+']').get()[0] if comment_span.dataset.translating == 'true' comment_span.dataset.translating = false hideMe({id: 'forum-translation-span'}) document.getElementById('forum-comment-translation').innerHTML='' document.getElementById('forum-comment').innerHTML='' else comment_span.dataset.translating = true blockMe({id: 'forum-translation-span'}) if the_span.dataset.needs_translation =='true' my_list=JSON.parse(the_span.dataset.needy_list ) $('[name=add-forum-translation]').get()[0].classList.add('hot') colorList('forum-translation-choices',my_list) setLinkTranslations() if document.getElementById('forum-comment').value== '' setCommentSpan() setTranslationLanguage=(selected)-> document.getElementById('forum-translation-language').value= selected.dataset.display hideMe(id:'forum-translation-choices') if isModerator() then $.post('xforum/forum_ajax',{function:'get translations',topic:getTopic(),language:getTranslationLanguage()},saveTranslationSuggestions) colorList=(the_list,data_list)-> items=document.getElementById(the_list).children for i in [0...items.length] if items[i].dataset.choice in data_list items[i].classList.add('needy') else items[i].classList.remove('needy') window.checkForSuggestedTranslations=(id)-> page=document.getElementById('forum-senate') $('#forum-comment-translation').val(page.dataset["translation-"+id ] ) $('[id=forum-translation-suggestion]').remove() suggestions =page.dataset['suggestedtranslation-'+id] if suggestions != undefined suggestion_list = JSON.parse(suggestions) list_parent=document.getElementById('forum-translation-scroll') for i in [0...suggestion_list.length] suggestion = document.createElement('textarea') suggestion.value = suggestion_list[i] suggestion.id='forum-translation-suggestion' suggestion.className='senate-new' list_parent.appendChild(suggestion) window.saveTranslationSuggestions=(params)-> if params? && params.length>0 && params[0].forum_id? page = document.getElementById('forum-senate') for i in [0...params.length] if params[i].suggestion if page.dataset['suggestedtranslation-' + params[i].forum_id] == undefined temp=[params[i].translation] else temp=JSON.parse(page.dataset['suggestedtranslation-' + params[i].forum_id] ) temp.push(params[i].translation) page.dataset['suggestedtranslation-' + params[i].forum_id]= JSON.stringify(temp) else page.dataset['translation-'+ params[i].forum_id]= params[i].translation window.setLinkTranslations=-> hideMe({id:'forum-add-hyperlink-span'}) showMe({id:'forum-translate-hyperlink-span'}) comment_span=document.getElementById('forum-comment-span') link_ref=comment_span.dataset.link_ref unless link_ref == undefined link_ref=parseInt(link_ref) hyper=document.getElementById('forum-translate-hyperlink-span') for i in [0...link_ref] span= document.createElement('span') span.id='translation-span-id-'+i space= document.createElement('span') space.innerHTML=' ' span.appendChild(space) label_it=document.createElement('label') label_it.innerHTML= comment_span.dataset['link_text-'+i] span.appendChild(label_it) text_in=document.createElement('input') text_in.type='text' text_in.id= 'hyperlink-translation-input' text_in.name=i text_in.className= "admin-edit-field" span.appendChild(text_in) hyper.appendChild(span) window.addLinkTranslations=(params)-> comment_span=document.getElementById('forum-comment-span') link_ref=comment_span.dataset.link_ref translations= $('[id=hyperlink-translation-input]') unless link_ref == undefined || translations.length == 0 link_ref=parseInt(link_ref) for i in [0...link_ref] data= params['link-'+i] alert data data['translation']= translations[i].value params['link-'+i]=data params