/* For licensing terms, see /license.txt */ console.log('h5p extras is active'); /** * Find CKEditor's instance and add an H5P button to it */ function installInTinyH5p(){ if (window.jQuery) { var btnLength = $(".cke_button__source").length; if(btnLength>0){ if($(".cke_button__extras_h5p").length==0){ var gi = '  '; gi += ''; gi += ''; $(".cke_button__source").after(gi); } } var inputID = $("#idTitle").length; if(inputID>0){ if($("#idTitle").val()==''){ $("#idTitle").val("New document !"); } } } setTimeout(function(){installInTinyH5p();},600); } setTimeout(function(){installInTinyH5p();},600); //#H5P:1# /** * Load H5P objects through CKEditor */ function loadExtrasObjectsH5p(){ insertExtrasObjectsH5p(); $(".cke_dialog_background_cover").css('display','block'); $("#extrasobjectH5p").css('display','block'); } /** * Insert H5P objects in the body of the area edited through CKEditor */ function insertExtrasObjectsH5p(){ if($(".cke_dialog_background_cover").length==0){ $("body").append(''); } if($("#extrasobjectH5p").length==0){ $("body").append('
'+inExtrasObjectsH5p()+'
'); showEditH5pLoad(); }else{ loadDataH5Pbase(); } } /** * Generate the HTML to insert H5P objects in an HTML document * @returns {string} */ function inExtrasObjectsH5p(){ var h = ''; h += '
  H5P Helper
'; h += '
X
'; h += '
'; return h; } /** * Visually remove H5P objects from CKEditor */ function closeExtrasH5p(){ $("#extrasobjectH5p").css('display','none'); $(".cke_dialog_background_cover").css('display','none'); } /** * Show the H5P options */ function showEditH5pLoad(){ $(".cke_dialog_background_cover").css('z-index','97'); $("#extrasobjectH5p").css('z-index','98'); var h = ''; h += '

H5P URL path

'; h += '

'; h += ' '; h += '

'; h += '

Select a content

'; h += '
'; h += '
Multiplication quiz
'; h += '
Simple drag and drop
'; h += '
'; h += '

'; h += ''; h += '

'; $("#innerEditH5p").html(h); $("#innerEditH5p").css("display","block"); loadDataH5Pbase(); } /** * Load (AJAX) the H5P node types */ function loadDataH5Pbase(){ $('.bloch5pGrid').html('

'); var urlpath = _p['web_plugin'] +'h5p/resources/ajax/getnodes.php'; $.ajax({ url : urlpath,cache : false }).done(function(codeHtml){ var urlH5p = _p['web_plugin'] +'h5p/list.php'; codeHtml += ' '; $('.bloch5pGrid').html(codeHtml); }).error(function(xhr, ajaxOptions, thrownError){ var h = 'Reload'; $('.bloch5pGrid').html(h); }); } /** * Select a type of node for the base element of an H5P object * @param id * @param node_type */ function selectH5Pbase(id,node_type){ $(".bloch5pLine").css("background-color","white").css("color","black"); $(".bloch5pLine" + id).css("background-color","#2575be").css("color","white"); var pgid = "h5p/cache-h5p/launch/source-" + id + ".html?tn=" + node_type; $("#inputSelH5PUrl").val(pgid); } /** * Add an H5P object in CKEditor */ function addObjectH5PInCKEDITORByBase(){ var pg = $("#inputSelH5PUrl").val(); if(pg!=''){ pg = _p['web_plugin'] + pg; var h5pc = '