1/** 2 * @file 3 * Attaches behaviors for the Clientside Validation jQuery module. 4 */ 5(function ($, Drupal, debounce, CKEDITOR) { 6 /** 7 * Attaches jQuery validate behavoir to forms. 8 * 9 * @type {Drupal~behavior} 10 * 11 * @prop {Drupal~behaviorAttach} attach 12 * Attaches the outline behavior to the right context. 13 */ 14 Drupal.behaviors.cvJqueryValidateCKEditor = { 15 attach: function (context) { 16 if (typeof CKEDITOR === 'undefined') { 17 return; 18 } 19 var ignore = ':hidden'; 20 var not = []; 21 for (var instance in CKEDITOR.instances) { 22 if (CKEDITOR.instances.hasOwnProperty(instance)) { 23 not.push('#' + instance); 24 } 25 } 26 ignore += not.length ? ':not(' + not.join(', ') + ')' : ''; 27 $('form').each(function () { 28 var validator = $(this).data('validator'); 29 if (!validator) { 30 return; 31 } 32 validator.settings.ignore = ignore; 33 validator.settings.errorPlacement = function(place, $element) { 34 var id = $element.attr('id'); 35 var afterElement = $element[0]; 36 if (CKEDITOR.instances.hasOwnProperty(id)) { 37 afterElement = CKEDITOR.instances[id].container.$; 38 } 39 place.insertAfter(afterElement); 40 }; 41 }); 42 var updateText = function (instance) { 43 return debounce(function (e) { 44 instance.updateElement(); 45 var event = $.extend(true, {}, e.data.$); 46 delete event.target; 47 delete event.explicitOriginalTarget; 48 delete event.originalTarget; 49 delete event.currentTarget; 50 $(instance.element.$).trigger(new $.Event(e.name, event)); 51 }, 250); 52 }; 53 CKEDITOR.on('instanceReady', function () { 54 for (var instance in CKEDITOR.instances) { 55 if (CKEDITOR.instances.hasOwnProperty(instance)) { 56 CKEDITOR.instances[instance].document.on("keyup", updateText(CKEDITOR.instances[instance])); 57 CKEDITOR.instances[instance].document.on("paste", updateText(CKEDITOR.instances[instance])); 58 CKEDITOR.instances[instance].document.on("keypress", updateText(CKEDITOR.instances[instance])); 59 CKEDITOR.instances[instance].document.on("blur", updateText(CKEDITOR.instances[instance])); 60 CKEDITOR.instances[instance].document.on("change", updateText(CKEDITOR.instances[instance])); 61 } 62 } 63 }); 64 } 65 }; 66})(jQuery, Drupal, Drupal.debounce, (typeof CKEDITOR === 'undefined') ? undefined : CKEDITOR);
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.