1/*jslint browser: true, nomen: true, white: true */ 2/* global jQuery, $ */ 3 4/* 5 * Customisation on top of bootstrap's modal css to allow modals to become slide-in docks 6 * 7 * Works with bootstraps modal html init methods with modifications: 8 * * Add a modal-docked class to the modal 9 * * Use data-toggle="modal-docked" for the trigger (rather than data-toggle="modal") 10 * * Use data-dismiss="modal-docked" to the modal's close button (rather than data-dismiss="modal") 11 */ 12var dock = {}; 13jQuery(function($) { 14 "use strict"; 15 16 /* 17 * Control the hiding of our dock and trigger the necessary events 18 */ 19 dock.hide = function() { 20 window.setTimeout(function(){ 21 $(window).trigger('colresize'); 22 }, 300); 23 24 $('.modal-docked').each( function() { 25 $(this).removeClass('active'); 26 $(this).addClass('closed'); 27 }); 28 29 $('body, .navbar-fixed-top').width('auto'); 30 $('body').removeClass('modal-open modal-open-docked'); 31 }; 32 33 /* 34 * Control showing out dock and trigger the necessary events 35 * 36 * @param newblock | Object, replaceContent Boolean, hasContent Boolean (for prefilled modals) 37 */ 38 dock.show = function(newblock, replaceContent, hasContent) { 39 var contentArea = newblock.find('.modal-body'), 40 content = this.getLoadingIndicator(); 41 42 // If we are filling the modal dynamically (c.f page builder) 43 if (hasContent) { 44 // Dock alreay has content 45 } 46 else { 47 // Open form here even though it's currently empty (its quicker) 48 newblock.find('.modal-title').html(get_string('loading')); 49 50 if (replaceContent) { 51 contentArea.html(content); 52 } 53 else { 54 contentArea.append(content); 55 contentArea.find('.block-inner').addClass('hidden'); 56 } 57 } 58 59 // Prevent disappearing scroll bars from interfering with smooth animation 60 $('body, .navbar-fixed-top').width($('body').width()); 61 $('body').addClass('modal-open modal-open-docked'); 62 newblock.removeClass('hidden').removeClass('closed').addClass('active'); 63 }; 64 65 dock.getLoadingIndicator = function() { 66 return '<div class="modal-loading"></div>'; 67 }; 68 69 dock.init = function(scope){ 70 71 scope.find('[data-toggle="modal-docked"]').on('click', function(e){ 72 e.preventDefault(); 73 74 var targetID = $(this).attr('data-target'), 75 target = $(targetID); 76 77 dock.show(target, false, true); 78 }); 79 80 scope.find('[data-dismiss="modal-docked"]').on('click', function(e){ 81 e.preventDefault(); 82 dock.hide(); 83 }); 84 85 scope.find('.submitcancel').on('click', function(){ 86 dock.hide(); 87 }); 88 }; 89 90 dock.init($(document)); 91});
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.