1// ========================================================================== 2// FUNCTIONS 3// ========================================================================== 4 5/* 6* Permet de transformer une string en camel case 7*/ 8function toCamelCase(string) { 9 return string.replace(/[-_]([a-z])/g, function (g) { return g[1].toUpperCase(); }) 10} 11 12 13/* 14* Permet de merger 2 tableaux de paramètres 15*/ 16function dataAttrToParams(initParams, newParams) { 17 delete newParams.ride; 18 delete newParams.toggle; 19 20 $.each(newParams, function(index, val) { 21 // console.log(val); 22 var newIndex = toCamelCase(index); 23 initParams[newIndex] = newParams[index]; 24 }); 25 26 return initParams; 27} 28 29 30 31 32// ========================================================================== 33// PLUGINS 34// ========================================================================== 35 36 37$(function() { 38 39 var $octopus = $('.octopus, .gform_wrapper'); 40 41 // COMPONSANT FASTCLICK 42 // if (typeof FastClick != "undefined" && typeof is_touch_device != 'undefined') { 43 // if (!is_touch_device) { 44 // window.addEventListener('load', function() { 45 // new FastClick(document.body); 46 // }, false); 47 // } 48 // } 49 50 51 // Permet d'ajouter une classe "collapsed" sur les éléments replié 52 $octopus.find('.form-group .collapse').each(function(index, el) { 53 var $el = $(el), 54 $elParent = $el.parent('.form-group, .form-block'); 55 56 57 $elParent.find('label').on('click', function(event) { 58 if (!$(this).hasClass('collapsed')) { 59 event.preventDefault(); 60 } 61 }); 62 if (!$el.hasClass('in')) { 63 $elParent.addClass('collapsed').find('label[data-toggle="collapse"]').addClass('collapsed'); 64 } 65 66 $el.on('show.bs.collapse', function () { 67 $elParent.removeClass('collapsed'); 68 }); 69 70 $el.on('hide.bs.collapse', function () { 71 $elParent.addClass('collapsed'); 72 }); 73 }); 74 75 76 // COMPONSANT MULTISELECT 77 if($.fn.multiselect) { 78 // if (typeof is_touch_device != 'undefined' && is_touch_device) { 79 // $('body').append('<div class="octopus-overlay"></div>');
80 // var $overlay = $('.octopus-overlay'); 81 // $overlay.on('click', function(event) { 82 // event.preventDefault(); 83 // }); 84 // } 85 86 $octopus.find('select').each(function(index, el) { 87 88 var $el = $(el); 89 90 if ($el.data('disabled-plugin') == true) 91 return; 92 93 if ( (typeof $el.attr('multiple') == 'undefined' && typeof $el.data('enabled-plugin') == 'undefined') || $el.data('enabled-plugin') == false) 94 return; 95 96 var initParams = { 97 buttonContainer: '<div class="multiselect-wrapper">', 98 // enableClickableOptGroups: true, 99 nonSelectedText: 'Choisissez des éléments', 100 buttonClass: 'form-control', 101 nSelectedText: 'éléments sélectionés', 102 numberDisplayed: 2, 103 // includeSelectAllOption: true, 104 // selectAllText: 'Check all!' 105 enableFiltering: false, 106 enableCaseInsensitiveFiltering: false, 107 filterPlaceholder: 'Rechercher un élément', 108 allSelectedText: 'Tous séléctionés', 109 onDropdownShown: function(event) { 110 // if (is_touch_device) { 111 // $overlay.fadeIn(); 112 // } 113 if ($(event.currentTarget).find('.multiselect-search').length > 0) { 114 $(event.currentTarget).find('.multiselect-search').focus(); 115 } 116 }, 117 onDropdownHidden: function(event) { 118 // if (is_touch_device) { 119 // $overlay.fadeOut(); 120 // } 121 if ($(event.currentTarget).find('.multiselect-search').length > 0) { 122 setTimeout(function() { 123 $(event.currentTarget).find('.multiselect-search').val('').keydown(); 124 }, 1); 125 } 126 } 127 }; 128 129 var newParams = $el.data(); 130 131 newParams = dataAttrToParams(initParams, newParams); 132 $el.multiselect(newParams); 133 134 }); 135 } 136 137 function octopusInputFile( $el ) { 138 139 if ($el.data('disabled-plugin') == true) 140 return; 141 142 if ($el.siblings('.file-input-name').length < 1) { 143 $el.after('<span class="file-input-name placeholder">Aucun fichier choisi</span>'); 144 } 145 $el.attr('title', 'Parcourir').bootstrapFileInput(); 146 147 $el.closest('.file-input').on('dragover', function(e) { 148 $el.addClass('active').find('.file-input-wrapper > span').text('Déposez votre fichier'); 149 }).on('dragleave', function(e) { 150 $el.removeClass('active').find('.file-input-wrapper > span').text('Parcourir'); 151 }).on('drop', function(event) { 152 $el.removeClass('active').find('.file-input-wrapper > span').text('Parcourir'); 153 }); 154 } 155 156 if ( $.fn.bootstrapFileInput ) { 157 158 var $fileInputs = $octopus.find('input[type=file]').not('.gform_hidden').not('[multiple]'); 159 if ($fileInputs.length > 0) { 160 161 $fileInputs.each(function(index, el) { 162 var $el = $(el); 163 octopusInputFile( $el ); 164 }); 165 } 166 167 $('.ginput_container_fileupload').on('click', function(event) { 168 var $this = $( this ); 169 if ( $this.find('[id^="gform_multifile_upload"]').length == 0 ) { 170 if ( $( event.target ).hasClass( 'gform_delete' ) ) { 171 if ( $.trim( $this.find('[id^="gform_preview_"]').html() ) == '' ) { 172 octopusInputFile( $this.find('input[type="file"]') ); 173 } 174 } 175 } 176 }); 177 178 } 179 180});
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.