/* For licensing terms, see /license.txt */ /** * When the document is ready, do some preparation for the dictionary H5P content type elements */ $(document).ready(function () { var u = window.top.location.href if (u.indexOf('action=edit') == -1) { $('#dictionary').css('display', 'none') var btn = '' btn += 'Create Page

' //$("#dictionary").parent().prepend(btn); } $('#dictionary_title').parent().parent().css('display', 'none') $('#dictionary_node_type').parent().parent().css('display', 'none') $('#dictionary_submit').parent().parent().css('display', 'none') $('#dictionary_descript').parent().parent().css('display', 'none') $('#dictionary_terms_a').parent().parent().css('display', 'none') $('#dictionary_terms_b').parent().parent().css('display', 'none') $('#dictionary_terms_c').parent().parent().css('display', 'none') $('#dictionary_terms_d').parent().parent().css('display', 'none') $('#dictionary_terms_e').parent().parent().css('display', 'none') $('#dictionary_terms_f').parent().parent().css('display', 'none') $('#dictionary_opt_1').parent().parent().css('display', 'none') $('#dictionary_opt_2').parent().parent().css('display', 'none') $('#dictionary_opt_3').parent().parent().css('display', 'none') $('#dictionary_submit').parent().prepend('' + $('#h5p_cancel').html() + '') $('#dictionary_submit').click(function (e) { var pagetype = $('#dictionary_node_type').val() if (pagetype == 'dialogcard') { if (controlsFieldsdialogcard() == false) { e.preventDefault() } } var title = $('#dictionary_title').val() if (title == '') { $('#dictionary_title').css('background', 'pink') e.preventDefault() } else { if (u.indexOf('action=edit') == -1) { if (pagetype == '') { e.preventDefault() } } } }) }) /** * Add an H5P option to the breadcrumb bar */ $(document).ready(function () { var menuBc = '
  •   ' menuBc += 'H5P  
  • ' var btn = '  ').dialog({ modal: true, width: '80%', title: 'Select your file', zIndex: 99999, create: function (event, ui) { $(this).elfinder({ resizable: false, url: '../../main/inc/lib/elfinder/connectorAction.php', commandsOptions: { getfile: { oncomplete: 'destroy' } }, getFileCallback: function (file) { $('#' + targetInputImg).val(file.url) var imgBlok = targetInputImg.replace('imagecard', 'imageBlockPreview') var imgPath = $('#' + targetInputImg).val() $('.' + imgBlok).css('background-image', 'url(' + imgPath + ')') jQuery('a.ui-dialog-titlebar-close[role="button"]').click() jQuery('button.ui-dialog-titlebar-close[role="button"]').click() } }).elfinder('instance') } }) } /** * Get an element by Id * @param n * @returns {string|*} */ function getbyelem (n) { if (document.getElementById(n)) { var tagName = document.getElementById(n).tagName if (tagName == 'SELECT') { var get_id = document.getElementById(n) var resultselect = get_id.options[get_id.selectedIndex].value //console.log(resultselect); return resultselect } if (tagName == 'INPUT') { return document.getElementById(n).value } if (tagName == 'TEXTAREA') { var ct = document.getElementById(n).value ct = ct.replace('\n', '
    ') return ct } } else { return '-' } } /** * Check the given radio button * @param r */ function checkRadio (r) { $('#rad' + r).prop('checked', true) $('#dictionary_node_type').val(r) } /** * Show the interface for the words match H5P element type */ function interfacewordsmatch () { $('.dataTables_wrapper').css('display', 'none') $('#dictionary_node_type').parent().parent().css('display', 'none') $('#nodeselection').parent().parent().css('display', 'none') $('#dictionary_title').parent().parent().css('display', '') $('#dictionary_title').parent().append('' + $('#h5p_title_help').html() + '') $('#dictionary_submit').parent().parent().css('display', '') $('#dictionary_descript').parent().parent().css('display', '') $('#dictionary_descript').parent().append('' + $('#h5p_descr_help').html() + '') $('#dictionary_descript').val($('#h5p_wordsmatch_tutor').html()) $('#dictionary').css('display', '') $('#addElement').css('display', 'none') $('#nodeselection').css('display', 'none') $('#dictionary_terms_a').parent().parent().css('display', '') $('#dictionary_terms_a').val($('#h5p_wordsmatch_load').html()) $('#dictionary_terms_a').parent().append('' + $('#h5p_wordsmatch_help').html() + '') interfaceNameLabel('terms_a', $('#h5p_wordsmatch_term_a').html()) } /** * Show the interface for the Name Label H5P element type */ function interfaceNameLabel (idjq, name) { $('label').each(function (index) { var forSrcAttr = $(this).attr('for') if (typeof forSrcAttr === 'undefined') { forSrcAttr = '' } if (forSrcAttr.indexOf('_' + idjq) != -1) { $(this).html(name) } }) } /** * Show the interface for the Memory H5P element type */ function interfacememory () { interfacedialogcard() } /** * Show the interface for the Dialog Card H5P element type */ function interfacedialogcard () { $('.dataTables_wrapper').css('display', 'none') $('#dictionary_node_type').parent().parent().css('display', 'none') $('#nodeselection').parent().parent().css('display', 'none') $('#dictionary_title').parent().parent().css('display', '') $('#dictionary_title').parent().append('' + $('#h5p_title_help').html() + '') $('#dictionary_submit').parent().parent().css('display', '') $('#dictionary_descript').parent().parent().css('display', '') $('#dictionary_descript').parent().append('' + $('#h5p_dialogcard_help').html() + '') $('#dictionary_descript').val($('#h5p_dialogcard_tutor').html()) $('#dictionary').css('display', '') $('#addElement').css('display', 'none') $('#nodeselection').css('display', 'none') $('#dictionary_terms_a').parent().parent().css('display', '') var dterma = $('#dictionary_terms_a').val() $('#dictionary_terms_a').parent().append(interfaceCard('a', dterma)) interfaceNameLabel('terms_a', $('#h5p_dialogcard_term_a').html()) $('#dictionary_terms_b').parent().parent().css('display', '') var dtermb = $('#dictionary_terms_b').val() $('#dictionary_terms_b').parent().append(interfaceCard('b', dtermb)) interfaceNameLabel('terms_b', '') $('#dictionary_terms_c').parent().parent().css('display', '') var dtermc = $('#dictionary_terms_c').val() $('#dictionary_terms_c').parent().append(interfaceCard('c', dtermc)) interfaceNameLabel('terms_c', '') $('#dictionary_terms_d').parent().parent().css('display', '') var dtermd = $('#dictionary_terms_d').val() $('#dictionary_terms_d').parent().append(interfaceCard('d', dtermd)) interfaceNameLabel('terms_d', '') $('#dictionary_terms_e').parent().parent().css('display', '') var dterme = $('#dictionary_terms_e').val() $('#dictionary_terms_e').parent().append(interfaceCard('e', dterme)) interfaceNameLabel('terms_e', '') $('#dictionary_terms_f').parent().parent().css('display', '') var dtermf = $('#dictionary_terms_f').val() $('#dictionary_terms_f').parent().append(interfaceCard('f', dtermf)) interfaceNameLabel('terms_f', '') plusDialogCard() setTimeout(function () { interfaceEvents(dterma, 'a') interfaceEvents(dtermb, 'b') interfaceEvents(dtermc, 'c') interfaceEvents(dtermd, 'd') interfaceEvents(dterme, 'e') interfaceEvents(dtermf, 'f') displayInterfaceCardAll() }, 200) setTimeout(function () { compileInterfaceCardAll() }, 500) } /** * Add a dialog card */ function plusDialogCard () { var h = '
    ' h += '' h += '
    ' $('#dictionary_terms_f').parent().append(h) } /** * Add a dialog card process */ function plusDialogCardProcess () { if (lastCardBlockId == 'a') { $('.cardBlockEditb').css('display', 'block') $('#outrecto' + 'b').val('?') } if (lastCardBlockId == 'b') { $('.cardBlockEditc').css('display', 'block') $('#outrecto' + 'c').val('?') } if (lastCardBlockId == 'c') { $('.cardBlockEditd').css('display', 'block') $('#outrecto' + 'd').val('?') } if (lastCardBlockId == 'd') { $('.cardBlockEdite').css('display', 'block') $('#outrecto' + 'e').val('?') } if (lastCardBlockId == 'e') { $('.cardBlockEditf').css('display', 'block') $('#outrecto' + 'f').val('?') } displayInterfaceCardAll() } /** * Show the interface for the Card H5P element type */ function interfaceCard (letterId, collTerms) { $('#dictionary_terms_' + letterId).css('display', 'none') $('#dictionary_terms_' + letterId).parent().parent().css('margin-bottom', '0px') var h = '
    ' h += '

    Front : 
    ' h += '
    ' if (GlobalTypeNode == 'memory') { h += '