1 2var ajax_url = _p.web_ajax + 'chat.ajax.php'; 3var online_button = '<img src="' + _p.web_img + 'statusonline.png">'; 4var offline_button = '<img src="' + _p.web_img + 'statusoffline.png">'; 5var connect_lang = 'Chat\u0020\u0028Connected\u0029'; 6var disconnect_lang = 'Chat\u0020\u0028Disconnected\u0029'; 7var chatLang = 'Chat'; 8 9 var hide_chat_video = false; 10 11$(function() { 12 addMainEvent(window, 'unload', courseLogout ,false); 13 14 $("#open-view-list").click(function(){ 15 $("#student-list-work").fadeIn(300); 16 }); 17 $("#closed-view-list").click(function(){ 18 $("#student-list-work").fadeOut(300); 19 }); 20 21 checkBrand(); 22 23 var id; 24 $(window).resize(function() { 25 clearTimeout(id); 26 id = setTimeout(doneResizing, 200); 27 }); 28 29 // Removes the yellow input in Chrome 30 if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) { 31 $(window).on("load", function () { 32 $('input:-webkit-autofill').each(function(){ 33 var text = $(this).val(); 34 var name = $(this).attr('name'); 35 $(this).after(this.outerHTML).remove(); 36 $('input[name=' + name + ']').val(text); 37 }); 38 }); 39 } 40 41 $(".accordion_jquery").accordion({ 42 autoHeight: false, 43 active: false, // all items closed by default 44 collapsible: true, 45 header: ".accordion-heading" 46 }); 47 48 // Start modals 49 // class='ajax' loads a page in a modal 50 $('body').on('click', 'a.ajax', function(e) { 51 e.preventDefault(); 52 53 var globalModal = $('#global-modal'); 54 if ($(this).hasClass('no-close-button')) { 55 globalModal.find('.close').hide(); 56 } 57 58 if ($(this).hasClass('no-header')) { 59 globalModal.find('.modal-header').hide(); 60 } 61 62 var blockDiv = $(this).attr('data-block-closing'); 63 if (blockDiv != '') { 64 globalModal.attr('data-backdrop', 'static'); 65 globalModal.attr('data-keyboard', 'false'); 66 } 67 var contentUrl = this.href; 68 var self = $(this); 69 70 if (contentUrl == 'javascript:void(0);') { 71 var 72 modalSize = self.data('size'), 73 modalWidth = self.data('width'), 74 modalTitle = self.data('title'); 75 modalContent = self.data('content'); 76 77 globalModal.find('.modal-title').text(modalTitle); 78 globalModal.find('.modal-body').html(modalContent); 79 globalModal.modal('show'); 80 81 return true; 82 } 83 84 if (contentUrl) { 85 var loadModalContent = $.get(contentUrl); 86 87 $.when(loadModalContent).done(function (modalContent) { 88 var modalDialog = globalModal.find('.modal-dialog'), 89 modalSize = self.data('size') || get_url_params(contentUrl, 'modal_size'), 90 modalWidth = self.data('width') || get_url_params(contentUrl, 'width'), 91 modalTitle = self.data('title') || ' '; 92 93 modalDialog.removeClass('modal-lg modal-sm').css('width', ''); 94 if (modalSize && modalSize.length != 0) { 95 switch (modalSize) { 96 case 'lg': 97 modalDialog.addClass('modal-lg'); 98 break; 99 case 'sm': 100 modalDialog.addClass('modal-sm'); 101 break; 102 } 103 } else if (modalWidth) { 104 modalDialog.css('width', modalWidth + 'px'); 105 } 106 107 globalModal.find('.modal-title').text(modalTitle); 108 globalModal.find('.modal-body').html(modalContent); 109 globalModal.modal('show'); 110 }); 111 } 112 }); 113 114 // Expands an image modal 115 $('a.expand-image').on('click', function(e) { 116 e.preventDefault(); 117 var title = $(this).attr('title'); 118 var image = new Image(); 119 image.onload = function() { 120 if (title) {
121 $('#expand-image-modal').find('.modal-title').text(title); 122 } else { 123 $('#expand-image-modal').find('.modal-title').html(' '); 124 } 125 126 $('#expand-image-modal').find('.modal-body').html(image); 127 $('#expand-image-modal').modal({ 128 show: true 129 }); 130 }; 131 image.src = this.href; 132 }); 133 134 // Delete modal 135 $('#confirm-delete').on('show.bs.modal', function(e) { 136 $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href')); 137 var message = 'Are\u0020you\u0020sure\u0020to\u0020delete: <strong>' + $(e.relatedTarget).data('item-title') + '</strong>'; 138 139 if ($(e.relatedTarget).data('item-question')) { 140 message = $(e.relatedTarget).data('item-question'); 141 } 142 143 $('.debug-url').html(message); 144 }); 145 // End modals 146 147 // old jquery.menu.js 148 $('#navigation a').stop().animate({ 149 'marginLeft':'50px' 150 },1000); 151 152 $('#navigation div').hover( 153 function () { 154 $('a',$(this)).stop().animate({ 155 'marginLeft':'1px' 156 },200); 157 }, 158 function () { 159 $('a',$(this)).stop().animate({ 160 'marginLeft':'50px' 161 },200); 162 } 163 ); 164 165 /* Make responsive image maps */ 166 $('map').imageMapResize(); 167 168 jQuery.fn.filterByText = function(textbox) { 169 return this.each(function() { 170 var select = this; 171 var options = []; 172 $(select).find('option').each(function() { 173 options.push({value: $(this).val(), text: $(this).text()}); 174 }); 175 $(select).data('options', options); 176 177 $(textbox).bind('change keyup', function() { 178 var options = $(select).empty().data('options'); 179 var search = $.trim($(this).val()); 180 var regex = new RegExp(search,"gi"); 181 182 $.each(options, function(i) { 183 var option = options[i]; 184 if(option.text.match(regex) !== null) { 185 $(select).append( 186 $('<option>').text(option.text).val(option.value) 187 ); 188 } 189 }); 190 }); 191 }); 192 }; 193
194 $(".black-shadow").mouseenter(function() { 195 $(this).addClass('hovered-course'); 196 }).mouseleave(function() { 197 $(this).removeClass('hovered-course'); 198 }); 199 200 $("[data-toggle=popover]").each(function(i, obj) { 201 $(this).popover({ 202 html: true, 203 content: function() { 204 var id = $(this).attr('id') 205 return $('#popover-content-' + id).html(); 206 } 207 }); 208 }); 209 210 $('.scrollbar-inner').scrollbar(); 211 212 // Date time settings. 213 moment.locale('en'); 214 $.datepicker.setDefaults($.datepicker.regional["en"]); 215 $.datepicker.regional["local"] = $.datepicker.regional["en"]; 216 217 // Fix old calls of "inc/lib/mediaplayer/player.swf" and convert to <audio> tag, then rendered by media element js 218 // see BT#13405 219 $('embed').each( function () { 220 var flashVars = $(this).attr('flashvars'); 221 if (flashVars && flashVars.indexOf("file") == -1) { 222 var audioId = Math.floor( Math.random()*99999 ); 223 flashVars = flashVars.replace('&autostart=false', ''); 224 flashVars = flashVars.replace('&autostart=true', ''); 225 var audioDiv = '<audio id="'+audioId+'" controls="controls" style="width:400px;" width:"400px;" src="'+flashVars+'" ><source src="'+flashVars+'" type="audio/mp3" ></source></audio>'; 226 $(this).hide(); 227 $(this).after(audioDiv); 228 } 229 }); 230 231 // Chosen select 232 $(".chzn-select").chosen({ 233 disable_search_threshold: 10, 234 no_results_text: 'No\u0020search\u0020results\u0020found', 235 placeholder_text_multiple: 'Select\u0020some\u0020options', 236 placeholder_text_single: 'Please\u0020select\u0020an\u0020option', 237 width: "100%" 238 }); 239 240 // Bootstrap tabs. 241 $('.tab-wrapper a').click(function (e) { 242 e.preventDefault(); 243 $(this).tab('show'); 244 245 //$('#tabs a:first').tab('show') // Select first tab 246 }); 247 248 // Fixes bug when loading links inside a tab. 249 $('.tab-wrapper .tab-pane a').unbind(); 250 251 /** 252 * Advanced options 253 * Usage 254 * <a id="link" href="url">Advanced</a> 255 * <div id="link_options"> 256 * hidden content :) 257 * </div> 258 * */ 259 $(".advanced_options").on("click", function (event) { 260 event.preventDefault(); 261 var id = $(this).attr('id') + '_options'; 262 var button = $(this); 263 $("#" + id).toggle(); 264 }); 265 266 /** 267 * <a class="advanced_options_open" href="http://" rel="div_id">Open</a> 268 * <a class="advanced_options_close" href="http://" rel="div_id">Close</a> 269 * <div id="div_id">Div content</div> 270 * */ 271 $(".advanced_options_open").on("click", function (event) { 272 event.preventDefault(); 273 var id = $(this).attr('rel'); 274 $("#" + id).show(); 275 }); 276 277 $(".advanced_options_close").on("click", function (event) { 278 event.preventDefault(); 279 var id = $(this).attr('rel'); 280 $("#" + id).hide(); 281 }); 282 283 // Adv multi-select search input. 284 $('.select_class_filter').each( function () { 285 var inputId = $(this).attr('id'); 286 inputId = inputId.replace('-filter', ''); 287 $("#" + inputId).filterByText($("#" + inputId + "-filter")); 288 }); 289 290 // Mediaelement 291 if ( 1 == 1) { 292 $('video:not(.skip), audio:not(.skip)').mediaelementplayer({ 293 pluginPath: _p.web_lib + 'javascript/mediaelement/', 294 //renderers: ['html5', 'flash_video', 'native_flv'], 295 features: ['playpause','current','progress','duration','tracks','volume','fullscreen','vrview','markersrolls'], 296 success: function(mediaElement, originalNode, instance) { 297 298 var $originalNode = $(originalNode), 299 qMarkersRolls = $originalNode.data('q-markersrolls') || [], 300 qMarkersColor = $originalNode.data('q-markersrolls-color') || 'rgba(186,206,151,100)'; 301 302 if (0 == qMarkersRolls.length) { 303 return; 304 } 305 306 instance.options.markersRollsColor = qMarkersColor; 307 instance.options.markersRollsWidth = 2; 308 instance.options.markersRolls = {}; 309
310 qMarkersRolls.forEach(function (qMarkerRoll) { 311 var url = 'https://avivae.com/teleformacion/main/exercise/exercise_submit.php?&' 312 + $.param({ 313 exerciseId: qMarkerRoll[1], 314 learnpath_id: 0, 315 learnpath_item_id: 0, 316 learnpath_item_view_id: 0 317 }); 318 319 instance.options.markersRolls[qMarkerRoll[0]] = url; 320 }); 321 322 instance.buildmarkersrolls(instance, instance.controls, instance.layers, instance.media); 323 324 }, 325 vrPath: _p.web + 'web/assets/vrview/build/vrview.js' 326 }); 327 } 328 329 // Table highlight. 330 $("form .data_table input:checkbox").click(function () { 331 if ($(this).is(":checked")) { 332 $(this).parentsUntil("tr").parent().addClass("row_selected"); 333 } else { 334 $(this).parentsUntil("tr").parent().removeClass("row_selected"); 335 } 336 }); 337 338 /* For non HTML5 browsers */ 339 if ($("#formLogin".length > 1)) { 340 $("input[name=login]").focus(); 341 } 342 343 // Tool tip (in exercises) 344 var tip_options = { 345 placement: 'right' 346 }; 347 $('.boot-tooltip').tooltip(tip_options); 348 var more = 'See\u0020more'; 349 var close = 'Close'; 350 351 $('.list-teachers').readmore({ 352 speed: 75, 353 moreLink: '<a href="#">' + more + '</a>', 354 lessLink: '<a href="#">' + close + '</a>', 355 collapsedHeight: 35, 356 blockCSS: 'display: block; width: 100%;' 357 }); 358 359 $('.star-rating li a').on('click', function(event) { 360 var id = $(this).parents('ul').attr('id'); 361 $('#vote_label2_' + id).html("Loading"); 362 $.ajax({
363 url: $(this).attr('data-link'), 364 success: function(data) { 365 $("#rating_wrapper_"+id).html(data); 366 if (data == 'added') { 367 //$('#vote_label2_' + id).html("Saved."); 368 } 369 if (data == 'updated') { 370 //$('#vote_label2_' + id).html("Saved."); 371 } 372 } 373 }); 374 }); 375 376 $("#notifications").load(_p.web_ajax + "online.ajax.php?a=get_users_online"); 377 378 $('video:not(.skip)').attr('preload', 'metadata'); 379 380 function socialLikes() { 381 } 382 383 socialLikes(); 384}); 385 386$(window).resize(function() { 387 checkBrand(); 388}); 389 390$(document).scroll(function() { 391 var valor = $('body').outerHeight() - 700; 392 if ($(this).scrollTop() > 100) { 393 $('.bottom_actions').addClass('bottom_actions_fixed'); 394 } else { 395 $('.bottom_actions').removeClass('bottom_actions_fixed'); 396 } 397 398 if ($(this).scrollTop() > valor) { 399 $('.bottom_actions').removeClass('bottom_actions_fixed'); 400 } else { 401 $('.bottom_actions').addClass('bottom_actions_fixed'); 402 } 403 404 // Exercise warning fixed at the top 405 var fixed = $("#exercise_clock_warning"); 406 if (fixed.length) { 407 if (!fixed.attr('data-top')) { 408 // If already fixed, then do nothing 409 if (fixed.hasClass('subnav-fixed')) return; 410 // Remember top position 411 var offset = fixed.offset(); 412 fixed.attr('data-top', offset.top); 413 fixed.css('width', '100%'); 414 } 415 416 if (fixed.attr('data-top') - fixed.outerHeight() <= $(this).scrollTop()) { 417 fixed.addClass('navbar-fixed-top'); 418 fixed.css('width', '100%'); 419 } else { 420 fixed.removeClass('navbar-fixed-top'); 421 fixed.css('width', '100%'); 422 } 423 } 424 425 // Admin -> Settings toolbar. 426 if ($('body').width() > 959) { 427 if ($('.new_actions').length) { 428 if (!$('.new_actions').attr('data-top')) { 429 // If already fixed, then do nothing 430 if ($('.new_actions').hasClass('new_actions-fixed')) return; 431 // Remember top position 432 var offset = $('.new_actions').offset(); 433 434 var more_top = 0; 435 if ($('.subnav').hasClass('new_actions-fixed')) { 436 more_top = 50; 437 } 438 $('.new_actions').attr('data-top', offset.top + more_top); 439 } 440 // Check if the height is enough before fixing the icons menu (or otherwise removing it) 441 // Added a 30px offset otherwise sometimes the menu plays ping-pong when scrolling to 442 // the bottom of the page on short pages. 443 if ($('.new_actions').attr('data-top') - $('.new_actions').outerHeight() <= $(this).scrollTop() + 30) { 444 $('.new_actions').addClass('new_actions-fixed'); 445 } else { 446 $('.new_actions').removeClass('new_actions-fixed'); 447 } 448 } 449 } 450}); 451 452function get_url_params(q, attribute) { 453 var hash; 454 if (q != undefined) { 455 q = q.split('&'); 456 for(var i = 0; i < q.length; i++){ 457 hash = q[i].split('='); 458 if (hash[0] == attribute) { 459 return hash[1]; 460 } 461 } 462 } 463} 464 465function checkBrand() { 466 if ($('.subnav').length) { 467 if ($(window).width() >= 969) { 468 $('.subnav .brand').hide(); 469 } else { 470 $('.subnav .brand').show(); 471 } 472 } 473} 474 475function setCheckbox(value, table_id) { 476 checkboxes = $("#"+table_id+" input:checkbox"); 477 $.each(checkboxes, function(index, checkbox) { 478 checkbox.checked = value; 479 if (value) { 480 $(checkbox).parentsUntil("tr").parent().addClass("row_selected"); 481 } else { 482 $(checkbox).parentsUntil("tr").parent().removeClass("row_selected"); 483 } 484 }); 485 return false; 486} 487 488function action_click(element, table_id) { 489 var d = $("#"+table_id); 490 if (!confirm('Please\u0020confirm\u0020your\u0020choice')) { 491 return false; 492 } else { 493 var action =$(element).attr("data-action"); 494 $('#'+table_id+' input[name="action"] ').attr("value", action); 495 d.submit(); 496 return false; 497 } 498} 499 500/** 501 * Generic function to replace the deprecated jQuery toggle function 502 * @param inId : id of block to hide / unhide 503 * @param inIdTxt : id of the button 504 * @param inTxtHide : text one of the button 505 * @param inTxtUnhide : text two of the button 506 * @todo : allow to detect if text is from a button or from a <a> 507 */ 508function hideUnhide(inId, inIdTxt, inTxtHide, inTxtUnhide) { 509 if ($('#'+inId).css("display") == "none") { 510 $('#'+inId).show(400); 511 $('#'+inIdTxt).attr("value", inTxtUnhide); 512 } else { 513 $('#'+inId).hide(400); 514 $('#'+inIdTxt).attr("value", inTxtHide); 515 } 516} 517 518function expandColumnToogle(buttonSelector, col1Info, col2Info) { 519 $(buttonSelector).on('click', function (e) { 520 e.preventDefault(); 521 522 col1Info = $.extend({ 523 selector: '', 524 width: 4 525 }, col1Info); 526 col2Info = $.extend({ 527 selector: '', 528 width: 8 529 }, col2Info); 530 531 if (!col1Info.selector || !col2Info.selector) { 532 return; 533 } 534 535 var col1 = $(col1Info.selector), 536 col2 = $(col2Info.selector); 537 538 $('#expand').toggleClass('hide'); 539 $('#contract').toggleClass('hide'); 540 541 if (col2.is('.col-md-' + col2Info.width)) { 542 col2.removeClass('col-md-' + col2Info.width).addClass('col-md-12'); 543 col1.removeClass('col-md-' + col1Info.width).addClass('hide'); 544 545 return; 546 } 547 548 col2.removeClass('col-md-12').addClass('col-md-' + col2Info.width); 549 col1.removeClass('hide').addClass('col-md-' + col1Info.width); 550 });
551} 552 553// Load ckeditor plugins 554if (typeof CKEDITOR !== 'undefined') { 555 // External plugins not part of the default Ckeditor package. 556 var plugins = [ 557 'asciimath', 558 'asciisvg', 559 'audio', 560 'blockimagepaste', 561 'ckeditor_wiris', 562 'dialogui', 563 'glossary', 564 'leaflet', 565 'mapping', 566 'maximize', 567 'mathjax', 568 'oembed', 569 'toolbar', 570 'toolbarswitch', 571 'video', 572 'wikilink', 573 'wordcount', 574 'youtube', 575 'flash', 576 'inserthtml', 577 'qmarkersrolls', 578 'ckeditor_vimeo_embed', 579 'image2_chamilo' 580 ]; 581 582 plugins.forEach(function (plugin) { 583 CKEDITOR.plugins.addExternal( 584 plugin, 585 _p.web_lib + 'javascript/ckeditor/plugins/' + plugin + '/' 586 ); 587 }); 588 589 /** 590 * Function use to load templates in a div 591 **/ 592 var showTemplates = function (ckeditorName) { 593 var editorName = 'content'; 594 if (ckeditorName && ckeditorName.length > 0) { 595 editorName = ckeditorName; 596 } 597 CKEDITOR.editorConfig(CKEDITOR.config); 598 CKEDITOR.loadTemplates(CKEDITOR.config.templates_files, function (a) { 599 var templatesConfig = CKEDITOR.getTemplates("default"); 600 var $templatesUL = $("<ul>"); 601 if (templatesConfig) { 602 $.each(templatesConfig.templates, function () { 603 var template = this; 604 var $templateLi = $("<li>"); 605 var templateHTML = "<img src=\"" + templatesConfig.imagesPath + template.image + "\" ><div>"; 606 templateHTML += "<b>" + template.title + "</b>"; 607 608 if (template.description) { 609 templateHTML += "<div class=description>" + template.description + "</div>"; 610 } 611 templateHTML += "</div>"; 612 613 $("<a>", { 614 href: "#", 615 html: templateHTML, 616 click: function (e) { 617 e.preventDefault(); 618 if (CKEDITOR.instances[editorName]) { 619 CKEDITOR.instances[editorName].setData(template.html, function () { 620 this.checkDirty(); 621 }); 622 } 623 } 624 }).appendTo($templateLi); 625 $templatesUL.append($templateLi); 626 }); 627 } 628 $templatesUL.appendTo("#frmModel"); 629 }); 630 }; 631} 632 633function doneResizing() { 634 var widthWindow = $(window).width(); 635 if ((widthWindow>=1024) && (widthWindow>=768)) { 636 $("#profileCollapse").addClass("in"); 637 $("#courseCollapse").addClass("in"); 638 $("#skillsCollapse").addClass("in"); 639 $("#sn-sidebar-collapse").addClass("in"); 640 $("#user_image_block").removeClass("text-muted"); 641 } else { 642 $("#profileCollapse").removeClass("in"); 643 $("#courseCollapse").removeClass("in"); 644 $("#skillsCollapse").removeClass("in"); 645 $("#sn-avatar-one").removeClass("in"); 646 $("#user_image_block").addClass("text-muted"); 647 } 648} 649 650function addMainEvent(elm, evType, fn, useCapture) { 651 if (elm.addEventListener) { 652 elm.addEventListener(evType, fn, useCapture); 653 return true; 654 } else if (elm.attachEvent) { 655 elm.attachEvent('on' + evType, fn); 656 } else { 657 elm['on'+evType] = fn; 658 } 659} 660 661function copyTextToClipBoard(elementId) 662{ 663 /* Get the text field */ 664 var copyText = document.getElementById(elementId); 665 666 /* Select the text field */ 667 copyText.select(); 668 669 /* Copy the text inside the text field */ 670 document.execCommand("copy"); 671}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.