1Drupal.locale = { 'pluralFormula': function ($n) { return Number(($n!=1)); }, 'strings': {"":{"An AJAX HTTP error occurred.":"Tapahtui AJAX HTTP virhe.","HTTP Result Code: !status":"HTTP koodi: !status","An AJAX HTTP request terminated abnormally.":"AJAX HTTP pyynt\u00f6 keskeytyi odottamatta.","Debugging information follows.":"Seuraavassa virhetiedot.","Path: !uri":"Polku: !url","StatusText: !statusText":"Tilanneteksti: !statusText","ResponseText: !responseText":"Vastausteksti: !responseText","ReadyState: !readyState":"ReadyState: !readyState","Hide":"Piilossa","Show":"N\u00e4yt\u00e4","Re-order rows by numerical weight instead of dragging.":"Uudelleenlajittele rivit numeerisen painon mukaan ved\u00e4-pudota toiminnon sijaan.","Show row weights":"N\u00e4yt\u00e4 rivien painokertoimet","Hide row weights":"Piilota rivien painokertoimet","Drag to re-order":"J\u00e4rjestele vet\u00e4m\u00e4ll\u00e4","Changes made in this table will not be saved until the form is submitted.":"Muutokset otetaan k\u00e4ytt\u00f6\u00f6n vasta kun valitset \u003Cem\u003Etallenna\u003C\/em\u003E.","Customize dashboard":"Mukauta ty\u00f6p\u00f6yt\u00e4\u00e4","Edit":"Muokkaa","Not published":"Ei julkaistu","(active tab)":"(aktiivinen v\u00e4lilehti)","Enabled":"K\u00e4yt\u00f6ss\u00e4","Configure":"M\u00e4\u00e4rittele","Disabled":"Ei k\u00e4yt\u00f6ss\u00e4","This field is required.":"T\u00e4m\u00e4 kentt\u00e4 on pakollinen.","Add":"Lis\u00e4\u00e4","Hide summary":"Piilota yhteenveto","Edit summary":"Muokkaa yhteenvetoa","none":"ei yht\u00e4\u00e4n","Upload":"Siirr\u00e4","Done":"Tehty","1 hour":"1 tunti","@count hours":"@count tuntia","1 day":"1 p\u00e4iv\u00e4","@count days":"@count p\u00e4iv\u00e4\u00e4","Select all rows in this table":"Valitse kaikki taulukon rivit","Deselect all rows in this table":"Poista kaikkien rivien valinnat","Please wait...":"Odota hetki...","Loading":"Ladataan","1 year":"1 vuosi","@count years":"@count vuotta","1 week":"1 viikko","@count weeks":"@count viikkoa","1 min":"1 min","@count min":"@count min","1 sec":"1 s","@count sec":"@count s","1 month":"Yksi kuukausi","@count months":"@count kuukautta","Not in menu":"Ei valikossa","New revision":"Uusi versio","No revision":"Ei versiota","By @name on @date":"@name p\u00e4iv\u00e4n\u00e4 @date","By @name":"@name","Automatic alias":"Ei aliasta","Alias: @alias":"Alias: @alias","No alias":"Ei aliasta","@number comments per page":"@number kommenttia sivua kohti","Autocomplete popup":"Automaattisen t\u00e4ydennyksen ponnahdusikkuna","Searching for matches...":"Haetaan tuloksia...","This permission is inherited from the authenticated user role.":"Oikeus on periytetty k\u00e4ytt\u00e4j\u00e4roolista \u0022autentikoitu k\u00e4ytt\u00e4j\u00e4\u0022.","Not restricted":"Ei rajoitettu","Restricted to certain pages":"Rajoitettu tiettyihin sivuihin","Not customizable":"Ei mukautettavissa","The changes to these blocks will not be saved until the \u003Cem\u003ESave blocks\u003C\/em\u003E button is clicked.":"Lohkojen muutoksia ei tallenneta ennen kuin klikkaat \u003Cem\u003ETallenna\u003C\/em\u003E-painiketta.","The block cannot be placed in this region.":"Lohkoa ei voi asettaa t\u00e4h\u00e4n alueeseen.","Requires a title":"Vaatii otsikon","Don\u0027t display post information":"\u00c4l\u00e4 n\u00e4yt\u00e4 l\u00e4hetyksen tietoja","The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions.":"Tiedostoa %filename ei voida ladata. Sallitut tiedostop\u00e4\u00e4tteet: %extensions.","The title should be more than 10 characters":"Otsikon tulee olla yli 10 merkki\u00e4 pitk\u00e4","The Question is necessary and can not be empty":"Kysymyskentt\u00e4\u00e4 ei voi j\u00e4tt\u00e4\u00e4 tyhj\u00e4ksi","The Question must be more than 30 and less than 800 characters":"Kysymyksen on oltava v\u00e4hint\u00e4\u00e4n 30 ja enint\u00e4\u00e4n 800 merkki\u00e4 pitk\u00e4","The Category must choose":"Kategoria on valittava","The E-mail address is necessary and can not be empty":"S\u00e4hk\u00f6postiosoite on pakollinen","E-mail address is not valid":"S\u00e4hk\u00f6postiosoite ei ole validi","No Record found!":"Ei tuloksia","Only files with the following extensions are allowed: %files-allowed.":"Vain seuraavat tiedostop\u00e4\u00e4tteet ovat sallittuja: %files-allowed.","0 sec":"0 s","The title is mandatory and can not be empty":"Otsikko on pakollinen ja sit\u00e4 ei voi j\u00e4tt\u00e4\u00e4 tyhj\u00e4ksi","@title dialog":"@title dialogi","Done, Thank y
1ou.":"Tehty, kiitos.","Sending...":"L\u00e4hetet\u00e4\u00e4n ...","Faild":"Faild","Select All":"Kaikki"}} };; 2(function ($) { 3 4Drupal.behaviors.textarea = { 5 attach: function (context, settings) { 6 $('.form-textarea-wrapper.resizable', context).once('textarea', function () { 7 var staticOffset = null; 8 var textarea = $(this).addClass('resizable-textarea').find('textarea'); 9 var grippie = $('<div class="grippie"></div>').mousedown(startDrag); 10 11 grippie.insertAfter(textarea); 12 13 function startDrag(e) { 14 staticOffset = textarea.height() - e.pageY; 15 textarea.css('opacity', 0.25); 16 $(document).mousemove(performDrag).mouseup(endDrag); 17 return false; 18 } 19 20 function performDrag(e) { 21 textarea.height(Math.max(32, staticOffset + e.pageY) + 'px'); 22 return false; 23 } 24 25 function endDrag(e) { 26 $(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag); 27 textarea.css('opacity', 1); 28 } 29 }); 30 } 31}; 32 33})(jQuery); 34; 35/** 36 * @file 37 * JavaScript behaviors for the front-end display of webforms. 38 */ 39 40(function ($) { 41 42 "use strict"; 43 44 Drupal.behaviors.webform = Drupal.behaviors.webform || {}; 45 46 Drupal.behaviors.webform.attach = function (context) { 47 // Calendar datepicker behavior. 48 Drupal.webform.datepicker(context); 49 50 // Conditional logic. 51 if (Drupal.settings.webform && Drupal.settings.webform.conditionals) { 52 Drupal.webform.conditional(context); 53 } 54 }; 55 56 Drupal.webform = Drupal.webform || {}; 57 58 Drupal.webform.datepicker = function (context) { 59 $('div.webform-datepicker').each(function () { 60 var $webformDatepicker = $(this); 61 var $calendar = $webformDatepicker.find('input.webform-calendar'); 62 63 // Ensure the page we're on actually contains a datepicker. 64 if ($calendar.length == 0) { 65 return; 66 } 67 68 var startDate = $calendar[0].className.replace(/.*webform-calendar-start-(\d{4}-\d{2}-\d{2}).*/, '$1').split('-'); 69 var endDate = $calendar[0].className.replace(/.*webform-calendar-end-(\d{4}-\d{2}-\d{2}).*/, '$1').split('-'); 70 var firstDay = $calendar[0].className.replace(/.*webform-calendar-day-(\d).*/, '$1'); 71 // Convert date strings into actual Date objects. 72 startDate = new Date(startDate[0], startDate[1] - 1, startDate[2]); 73 endDate = new Date(endDate[0], endDate[1] - 1, endDate[2]); 74 75 // Ensure that start comes before end for datepicker. 76 if (startDate > endDate) { 77 var laterDate = startDate; 78 startDate = endDate; 79 endDate = laterDate; 80 } 81 82 var startYear = startDate.getFullYear(); 83 var endYear = endDate.getFullYear(); 84 85 // Set up the jQuery datepicker element. 86 $calendar.datepicker({ 87 dateFormat: 'yy-mm-dd', 88 yearRange: startYear + ':' + endYear, 89 firstDay: parseInt(firstDay), 90 minDate: startDate, 91 maxDate: endDate, 92 onSelect: function (dateText, inst) { 93 var date = dateText.split('-'); 94 $webformDatepicker.find('select.year, input.year').val(+date[0]).trigger('change'); 95 $webformDatepicker.find('select.month').val(+date[1]).trigger('change'); 96 $webformDatepicker.find('select.day').val(+date[2]).trigger('change'); 97 }, 98 beforeShow: function (input, inst) { 99 // Get the select list values. 100 var year = $webformDatepicker.find('select.year, input.year').val(); 101 var month = $webformDatepicker.find('select.month').val(); 102 var day = $webformDatepicker.find('select.day').val(); 103 104 // If empty, default to the current year/month/day in the popup. 105 var today = new Date(); 106 year = year ? year : today.getFullYear(); 107 month = month ? month : today.getMonth() + 1; 108 day = day ? day : today.getDate(); 109 110 // Make sure that the default year fits in the available options. 111 year = (year < startYear || year > endYear) ? startYear : year; 112 113 // jQuery UI Datepicker will read the input field and base its date 114 // off of that, even though in our case the input field is a button. 115 $(input).val(year + '-' + month + '-' + day); 116 } 117 }); 118 119 // Prevent the calendar button from submitting the form. 120 $calendar.click(function (event) { 121 $(this).focus(); 122 event.preventDefault(); 123 }); 124 }); 125 }; 126 127 Drupal.webform.conditional = function (context) { 128 // Add the bindings to each webform on the page. 129 $.each(Drupal.settings.webform.conditionals, function (formKey, settings) { 130 var $form = $('.' + formKey + ':not(.webform-conditional-processed)'); 131 $form.each(function (index, currentForm) { 132 var $currentForm = $(currentForm); 133 $currentForm.addClass('webform-conditional-processed'); 134 $currentForm.bind('change', {'settings': settings}, Drupal.webform.conditionalCheck); 135 136 // Trigger all the elements that cause conditionals on this form. 137 Drupal.webform.doConditions($currentForm, settings); 138 }); 139 }); 140 }; 141 142 /** 143 * Event handler to respond to field changes in a form. 144 * 145 * This event is bound to the entire form, not individual fields. 146 */ 147 Drupal.webform.conditionalCheck = function (e) { 148 var $triggerElement = $(e.target).closest('.webform-component'); 149 var $form = $triggerElement.closest('form'); 150 var triggerElementKey = $triggerElement.attr('class').match(/webform-component--[^ ]+/)[0]; 151 var settings = e.data.settings; 152 if (settings.sourceMap[triggerElementKey]) { 153 Drupal.webform.doConditions($form, settings); 154 } 155 }; 156 157 /** 158 * Processes all conditional. 159 */ 160 Drupal.webform.doConditions = function ($form, settings) { 161 162 var stackPointer; 163 var resultStack; 164 165 /** 166 * Initializes an execution stack for a conditional group's rules. 167 * 168 * Also initializes sub-conditional rules. 169 */ 170 function executionStackInitialize(andor) { 171 stackPointer = -1; 172 resultStack = []; 173 executionStackPush(andor); 174 } 175 176 /** 177 * Starts a new subconditional for the given and/or operator. 178 */ 179 function executionStackPush(andor) { 180 resultStack[++stackPointer] = { 181 results: [], 182 andor: andor, 183 }; 184 } 185 186 /** 187 * Adds a rule's result to the current sub-conditional. 188 */ 189 function executionStackAccumulate(result) { 190 resultStack[stackPointer]['results'].push(result); 191 } 192 193 /** 194 * Finishes a sub-conditional and adds the result to the parent stack frame. 195 */ 196 function executionStackPop() { 197 // Calculate the and/or result. 198 var stackFrame = resultStack[stackPointer]; 199 // Pop stack and protect against stack underflow. 200 stackPointer = Math.max(0, stackPointer - 1); 201 var $conditionalResults = stackFrame['results']; 202 var filteredResults = $.map($conditionalResults, function (val) { 203 return val ? val : null; 204 }); 205 return stackFrame['andor'] === 'or' 206 ? filteredResults.length > 0 207 : filteredResults.length === $conditionalResults.length; 208 } 209 210 // Track what has been set/hidden for each target component's elements. 211 // Hidden elements must be disabled because if they are required and don't 212 // have a value, they will prevent submission due to html5 validation. 213 // Each execution of the conditionals adds a temporary class 214 // webform-disabled-flag so that elements hidden or set can be disabled and 215 // also be prevented from being re-enabled by another conditional (such as a 216 // parent fieldset). After processing conditionals, this temporary class 217 // must be removed in preparation for the next execution of the 218 // conditionals. 219 $.each(settings.ruleGroups, function (rgid_key, rule_group) { 220 var ruleGroup = settings.ruleGroups[rgid_key]; 221 222 // Perform the comparison callback and build the results for this group. 223 executionStackInitialize(ruleGroup['andor']); 224 $.each(ruleGroup['rules'], function (m, rule) { 225 switch (rule['source_type']) { 226 case 'component':
227 var elementKey = rule['source']; 228 var element = $form.find('.' + elementKey)[0]; 229 var existingValue = settings.values[elementKey] ? settings.values[elementKey] : null; 230 executionStackAccumulate(window['Drupal']['webform'][rule.callback](element, existingValue, rule['value'])); 231 break; 232 233 case 'conditional_start': 234 executionStackPush(rule['andor']); 235 break; 236 237 case 'conditional_end': 238 executionStackAccumulate(executionStackPop()); 239 break; 240 } 241 }); 242 var conditionalResult = executionStackPop(); 243 244 $.each(ruleGroup['actions'], function (aid, action) { 245 var $target = $form.find('.' + action['target']); 246 var actionResult = action['invert'] ? !conditionalResult : conditionalResult; 247 switch (action['action']) { 248 case 'show': 249 var changed = actionResult != Drupal.webform.isVisible($target); 250 if (actionResult) { 251 $target.find('.webform-conditional-disabled:not(.webform-disabled-flag)') 252 .removeClass('webform-conditional-disabled') 253 .webformProp('disabled', false); 254 $target 255 .removeClass('webform-conditional-hidden') 256 .show(); 257 $form.find('.chosen-disabled').prev().trigger('chosen:updated.chosen'); 258 } 259 else { 260 $target 261 .hide() 262 .addClass('webform-conditional-hidden') 263 .find(':input') 264 .addClass('webform-conditional-disabled webform-disabled-flag') 265 .webformProp('disabled', true); 266 } 267 if (changed && $target.is('tr')) { 268 Drupal.webform.restripeTable($target.closest('table').first()); 269 } 270 break; 271 272 case 'require': 273 var $requiredSpan = $target.find('.form-required, .form-optional').first(); 274 if (actionResult != $requiredSpan.hasClass('form-required')) { 275 var $targetInputElements = $target.find("input:text,textarea,input[type='email'],select,input:radio,input:file"); 276 // Rather than hide the required tag, remove it so that other 277 // jQuery can respond via Drupal behaviors. 278 Drupal.detachBehaviors($requiredSpan); 279 $targetInputElements 280 .webformProp('required', actionResult) 281 .toggleClass('required', actionResult); 282 if (actionResult) { 283 $requiredSpan.replaceWith('<span class="form-required" title="' + Drupal.t('This field is required.') + '">*</span>'); 284 } 285 else { 286 $requiredSpan.replaceWith('<span class="form-optional"></span>'); 287 } 288 Drupal.attachBehaviors($requiredSpan); 289 } 290 break; 291 292 case 'set': 293 var $texts = $target.find("input:text,textarea,input[type='email']"); 294 var $selects = $target.find('select,select option,input:radio,input:checkbox'); 295 var $markups = $target.filter('.webform-component-markup'); 296 if (actionResult) { 297 var multiple = $.map(action['argument'].split(','), $.trim); 298 $selects 299 .webformVal(multiple) 300 .webformProp('disabled', true) 301 .addClass('webform-disabled-flag'); 302 $texts 303 .val([action['argument']]) 304 .webformProp('readonly', true) 305 .addClass('webform-disabled-flag'); 306 // A special case is made for markup. It is sanitized with 307 // filter_xss_admin on the server. otherwise text() should be used 308 // to avoid an XSS vulnerability. text() however would preclude 309 // the use of tags like <strong> or <a>. 310 $markups.html(action['argument']); 311 } 312 else { 313 $selects.not('.webform-disabled-flag') 314 .webformProp('disabled', false); 315 $texts.not('.webform-disabled-flag') 316 .webformProp('readonly', false); 317 // Markup not set? Then restore original markup as provided in 318 // the attribute data-webform-markup. 319 $markups.each(function () { 320 var $this = $(this); 321 var original = $this.data('webform-markup'); 322 if (original !== undefined) { 323 $this.html(original); 324 } 325 }); 326 } 327 break; 328 } 329 }); // End look on each action for one conditional. 330 }); // End loop on each conditional. 331 332 $form.find('.webform-disabled-flag').removeClass('webform-disabled-flag'); 333 }; 334 335 /** 336 * Event handler to prevent propagation of events. 337 * 338 * Typically click for disabling radio and checkboxes. 339 */ 340 Drupal.webform.stopEvent = function () { 341 return false;
342 }; 343 344 Drupal.webform.conditionalOperatorStringEqual = function (element, existingValue, ruleValue) { 345 var returnValue = false; 346 var currentValue = Drupal.webform.stringValue(element, existingValue); 347 $.each(currentValue, function (n, value) { 348 if (value.toLowerCase() === ruleValue.toLowerCase()) { 349 returnValue = true; 350 return false; // break. 351 } 352 }); 353 return returnValue; 354 }; 355 356 Drupal.webform.conditionalOperatorStringNotEqual = function (element, existingValue, ruleValue) { 357 var found = false; 358 var currentValue = Drupal.webform.stringValue(element, existingValue); 359 $.each(currentValue, function (n, value) { 360 if (value.toLowerCase() === ruleValue.toLowerCase()) { 361 found = true; 362 } 363 }); 364 return !found; 365 }; 366 367 Drupal.webform.conditionalOperatorStringContains = function (element, existingValue, ruleValue) { 368 var returnValue = false; 369 var currentValue = Drupal.webform.stringValue(element, existingValue); 370 $.each(currentValue, function (n, value) { 371 if (value.toLowerCase().indexOf(ruleValue.toLowerCase()) > -1) { 372 returnValue = true; 373 return false; // break. 374 } 375 }); 376 return returnValue; 377 }; 378 379 Drupal.webform.conditionalOperatorStringDoesNotContain = function (element, existingValue, ruleValue) { 380 var found = false; 381 var currentValue = Drupal.webform.stringValue(element, existingValue); 382 $.each(currentValue, function (n, value) { 383 if (value.toLowerCase().indexOf(ruleValue.toLowerCase()) > -1) { 384 found = true; 385 } 386 }); 387 return !found; 388 }; 389 390 Drupal.webform.conditionalOperatorStringBeginsWith = function (element, existingValue, ruleValue) { 391 var returnValue = false; 392 var currentValue = Drupal.webform.stringValue(element, existingValue); 393 $.each(currentValue, function (n, value) { 394 if (value.toLowerCase().indexOf(ruleValue.toLowerCase()) === 0) { 395 returnValue = true; 396 return false; // break. 397 } 398 }); 399 return returnValue; 400 }; 401 402 Drupal.webform.conditionalOperatorStringEndsWith = function (element, existingValue, ruleValue) { 403 var returnValue = false; 404 var currentValue = Drupal.webform.stringValue(element, existingValue); 405 $.each(currentValue, function (n, value) { 406 if (value.toLowerCase().lastIndexOf(ruleValue.toLowerCase()) === value.length - ruleValue.length) { 407 returnValue = true; 408 return false; // break. 409 } 410 }); 411 return returnValue; 412 }; 413 414 Drupal.webform.conditionalOperatorStringEmpty = function (element, existingValue, ruleValue) { 415 var currentValue = Drupal.webform.stringValue(element, existingValue); 416 var returnValue = true; 417 $.each(currentValue, function (n, value) { 418 if (value !== '') { 419 returnValue = false; 420 return false; // break. 421 } 422 }); 423 return returnValue; 424 }; 425 426 Drupal.webform.conditionalOperatorStringNotEmpty = function (element, existingValue, ruleValue) { 427 return !Drupal.webform.conditionalOperatorStringEmpty(element, existingValue, ruleValue); 428 }; 429 430 Drupal.webform.conditionalOperatorSelectGreaterThan = function (element, existingValue, ruleValue) { 431 var currentValue = Drupal.webform.stringValue(element, existingValue); 432 return Drupal.webform.compare_select(currentValue[0], ruleValue, element) > 0; 433 }; 434 435 Drupal.webform.conditionalOperatorSelectGreaterThanEqual = function (element, existingValue, ruleValue) { 436 var currentValue = Drupal.webform.stringValue(element, existingValue); 437 var comparison = Drupal.webform.compare_select(currentValue[0], ruleValue, element); 438 return comparison > 0 || comparison === 0; 439 }; 440 441 Drupal.webform.conditionalOperatorSelectLessThan = function (element, existingValue, ruleValue) { 442 var currentValue = Drupal.webform.stringValue(element, existingValue); 443 return Drupal.webform.compare_select(currentValue[0], ruleValue, element) < 0; 444 }; 445 446 Drupal.webform.conditionalOperatorSelectLessThanEqual = function (element, existingValue, ruleValue) { 447 var currentValue = Drupal.webform.stringValue(element, existingV
447alue); 448 var comparison = Drupal.webform.compare_select(currentValue[0], ruleValue, element); 449 return comparison < 0 || comparison === 0; 450 }; 451 452 Drupal.webform.conditionalOperatorNumericEqual = function (element, existingValue, ruleValue) { 453 // See float comparison: http://php.net/manual/en/language.types.float.php 454 var currentValue = Drupal.webform.stringValue(element, existingValue); 455 var epsilon = 0.000001; 456 // An empty string does not match any number. 457 return currentValue[0] === '' ? false : (Math.abs(parseFloat(currentValue[0]) - parseFloat(ruleValue)) < epsilon); 458 }; 459 460 Drupal.webform.conditionalOperatorNumericNotEqual = function (element, existingValue, ruleValue) { 461 // See float comparison: http://php.net/manual/en/language.types.float.php 462 var currentValue = Drupal.webform.stringValue(element, existingValue); 463 var epsilon = 0.000001; 464 // An empty string does not match any number. 465 return currentValue[0] === '' ? true : (Math.abs(parseFloat(currentValue[0]) - parseFloat(ruleValue)) >= epsilon); 466 }; 467 468 Drupal.webform.conditionalOperatorNumericGreaterThan = function (element, existingValue, ruleValue) { 469 var currentValue = Drupal.webform.stringValue(element, existingValue); 470 return parseFloat(currentValue[0]) > parseFloat(ruleValue); 471 }; 472 473 Drupal.webform.conditionalOperatorNumericGreaterThanEqual = function (element, existingValue, ruleValue) { 474 return Drupal.webform.conditionalOperatorNumericGreaterThan(element, existingValue, ruleValue) || 475 Drupal.webform.conditionalOperatorNumericEqual(element, existingValue, ruleValue); 476 }; 477 478 Drupal.webform.conditionalOperatorNumericLessThan = function (element, existingValue, ruleValue) { 479 var currentValue = Drupal.webform.stringValue(element, existingValue); 480 return parseFloat(currentValue[0]) < parseFloat(ruleValue); 481 }; 482 483 Drupal.webform.conditionalOperatorNumericLessThanEqual = function (element, existingValue, ruleValue) { 484 return Drupal.webform.conditionalOperatorNumericLessThan(element, existingValue, ruleValue) || 485 Drupal.webform.conditionalOperatorNumericEqual(element, existingValue, ruleValue); 486 }; 487 488 Drupal.webform.conditionalOperatorDateEqual = function (element, existingValue, ruleValue) { 489 var currentValue = Drupal.webform.dateValue(element, existingValue); 490 return currentValue === ruleValue; 491 }; 492 493 Drupal.webform.conditionalOperatorDateNotEqual = function (element, existingValue, ruleValue) { 494 return !Drupal.webform.conditionalOperatorDateEqual(element, existingValue, ruleValue); 495 }; 496 497 Drupal.webform.conditionalOperatorDateBefore = function (element, existingValue, ruleValue) { 498 var currentValue = Drupal.webform.dateValue(element, existingValue); 499 return (currentValue !== false) && currentValue < ruleValue; 500 }; 501 502 Drupal.webform.conditionalOperatorDateBeforeEqual = function (element, existingValue, ruleValue) { 503 var currentValue = Drupal.webform.dateValue(element, existingValue); 504 return (currentValue !== false) && (currentValue < ruleValue || currentValue === ruleValue); 505 }; 506 507 Drupal.webform.conditionalOperatorDateAfter = function (element, existingValue, ruleValue) { 508 var currentValue = Drupal.webform.dateValue(element, existingValue); 509 return (currentValue !== false) && currentValue > ruleValue; 510 }; 511 512 Drupal.webform.conditionalOperatorDateAfterEqual = function (element, existingValue, ruleValue) { 513 var currentValue = Drupal.webform.dateValue(element, existingValue); 514 return (currentValue !== false) && (currentValue > ruleValue || currentValue === ruleValue); 515 }; 516 517 Drupal.webform.conditionalOperatorTimeEqual = function (element, existingValue, ruleValue) { 518 var currentValue = Drupal.webform.timeValue(element, existingValue); 519 return currentValue === ruleValue; 520 }; 521 522 Drupal.webform.conditionalOperatorTimeNotEqual = function (element, existingValue, ruleValue) { 523 return !Drupal.webform.conditionalOperatorTimeEqual(element, existingValue, ruleValue); 524 }; 525 526 Drupal.webform.conditionalOperatorTimeBefore = function (element, existingV
526alue, ruleValue) { 527 // Date and time operators intentionally exclusive for "before". 528 var currentValue = Drupal.webform.timeValue(element, existingValue); 529 return (currentValue !== false) && (currentValue < ruleValue); 530 }; 531 532 Drupal.webform.conditionalOperatorTimeBeforeEqual = function (element, existingValue, ruleValue) { 533 // Date and time operators intentionally exclusive for "before". 534 var currentValue = Drupal.webform.timeValue(element, existingValue); 535 return (currentValue !== false) && (currentValue < ruleValue || currentValue === ruleValue); 536 }; 537 538 Drupal.webform.conditionalOperatorTimeAfter = function (element, existingValue, ruleValue) { 539 // Date and time operators intentionally inclusive for "after". 540 var currentValue = Drupal.webform.timeValue(element, existingValue); 541 return (currentValue !== false) && (currentValue > ruleValue); 542 }; 543 544 Drupal.webform.conditionalOperatorTimeAfterEqual = function (element, existingValue, ruleValue) { 545 // Date and time operators intentionally inclusive for "after". 546 var currentValue = Drupal.webform.timeValue(element, existingValue); 547 return (currentValue !== false) && (currentValue > ruleValue || currentValue === ruleValue); 548 }; 549 550 /** 551 * Utility function to compare values of a select component. 552 * 553 * @param string a 554 * First select option key to compare 555 * @param string b 556 * Second select option key to compare 557 * @param array options 558 * Associative array where the a and b are within the keys 559 * 560 * @return integer based upon position of $a and $b in $options 561 * -N if $a above (<) $b 562 * 0 if $a = $b 563 * +N if $a is below (>) $b 564 */ 565 Drupal.webform.compare_select = function (a, b, element) { 566 var optionList = []; 567 $('option,input:radio,input:checkbox', element).each(function () { 568 optionList.push($(this).val()); 569 }); 570 var a_position = optionList.indexOf(a); 571 var b_position = optionList.indexOf(b); 572 return (a_position < 0 || b_position < 0) ? null : a_position - b_position; 573 }; 574 575 /** 576 * Utility to return current visibility. 577 * 578 * Uses actual visibility, except for hidden components which use the applied 579 * disabled class. 580 */ 581 Drupal.webform.isVisible = function ($element) { 582 return $element.hasClass('webform-component-hidden') 583 ? !$element.find('input').first().hasClass('webform-conditional-disabled') 584 : $element.closest('.webform-conditional-hidden').length == 0; 585 }; 586 587 /** 588 * Function to get a string value from a select/radios/text/etc. field. 589 */ 590 Drupal.webform.stringValue = function (element, existingValue) { 591 var value = []; 592 if (element) { 593 var $element = $(element); 594 if (Drupal.webform.isVisible($element)) { 595 // Checkboxes and radios. 596 $element.find('input[type=checkbox]:checked,input[type=radio]:checked').each(function () { 597 value.push(this.value); 598 }); 599 // Select lists. 600 if (!value.length) { 601 var selectValue = $element.find('select').val(); 602 if (selectValue) { 603 if ($.isArray(selectValue)) { 604 value = selectValue; 605 } 606 else { 607 value.push(selectValue); 608 } 609 } 610 } 611 // Simple text fields. This check is done last so that the select list 612 // in select-or-other fields comes before the "other" text field. 613 if (!value.length) { 614 $element.find('input:not([type=checkbox],[type=radio]),textarea').each(function () { 615 value.push(this.value); 616 }); 617 } 618 } 619 } 620 else { 621 switch ($.type(existingValue)) { 622 case 'array':
623 value = existingValue; 624 break; 625 626 case 'string': 627 value.push(existingValue); 628 break; 629 } 630 } 631 return value; 632 }; 633 634 /** 635 * Utility function to calculate a second-based timestamp from a time field. 636 */ 637 Drupal.webform.dateValue = function (element, existingValue) { 638 var value = false; 639 if (element) { 640 var $element = $(element); 641 if (Drupal.webform.isVisible($element)) { 642 var day = $element.find('[name*=day]').val(); 643 var month = $element.find('[name*=month]').val(); 644 var year = $element.find('[name*=year]').val(); 645 // Months are 0 indexed in JavaScript. 646 if (month) { 647 month--; 648 } 649 if (year !== '' && month !== '' && day !== '') { 650 value = Date.UTC(year, month, day) / 1000; 651 } 652 } 653 } 654 else { 655 if ($.type(existingValue) === 'array' && existingValue.length) { 656 existingValue = existingValue[0]; 657 } 658 if ($.type(existingValue) === 'string') { 659 existingValue = existingV
659alue.split('-'); 660 } 661 if (existingValue.length === 3) { 662 value = Date.UTC(existingValue[0], existingValue[1], existingValue[2]) / 1000; 663 } 664 } 665 return value; 666 }; 667 668 /** 669 * Utility function to calculate a millisecond timestamp from a time field. 670 */ 671 Drupal.webform.timeValue = function (element, existingValue) { 672 var value = false; 673 if (element) { 674 var $element = $(element); 675 if (Drupal.webform.isVisible($element)) { 676 var hour = $element.find('[name*=hour]').val(); 677 var minute = $element.find('[name*=minute]').val(); 678 var ampm = $element.find('[name*=ampm]:checked').val(); 679 680 // Convert to integers if set. 681 hour = (hour === '') ? hour : parseInt(hour); 682 minute = (minute === '') ? minute : parseInt(minute); 683 684 if (hour !== '') { 685 hour = (hour < 12 && ampm == 'pm') ? hour + 12 : hour; 686 hour = (hour === 12 && ampm == 'am') ? 0 : hour; 687 } 688 if (hour !== '' && minute !== '') { 689 value = Date.UTC(1970, 0, 1, hour, minute) / 1000; 690 } 691 } 692 } 693 else { 694 if ($.type(existingValue) === 'array' && existingValue.length) {
695 existingValue = existingValue[0]; 696 } 697 if ($.type(existingValue) === 'string') { 698 existingValue = existingValue.split(':'); 699 } 700 if (existingValue.length >= 2) { 701 value = Date.UTC(1970, 0, 1, existingValue[0], existingValue[1]) / 1000; 702 } 703 } 704 return value; 705 }; 706 707 /** 708 * Make a prop shim for jQuery < 1.9. 709 */ 710 $.fn.webformProp = $.fn.webformProp || function (name, value) { 711 if (value) { 712 return $.fn.prop ? this.prop(name, true) : this.attr(name, true); 713 } 714 else { 715 return $.fn.prop ? this.prop(name, false) : this.removeAttr(name); 716 } 717 }; 718 719 /** 720 * Make a multi-valued val() function. 721 * 722 * This is for setting checkboxes, radios, and select elements. 723 */ 724 $.fn.webformVal = function (values) { 725 this.each(function () { 726 var $this = $(this); 727 var value = $this.val(); 728 var on = $.inArray($this.val(), values) != -1; 729 if (this.nodeName == 'OPTION') { 730 $this.webformProp('selected', on ? value : false); 731 } 732 else { 733 $this.val(on ? [value] : false); 734 } 735 }); 736 return this; 737 }; 738 739 /** 740 * Given a table's DOM element, restripe the odd/even classes. 741 */ 742 Drupal.webform.restripeTable = function (table) { 743 // :even and :odd are reversed because jQuery counts from 0 and 744 // we count from 1, so we're out of sync. 745 // Match immediate children of the parent element to allow nesting. 746 $('> tbody > tr, > tr', table) 747 .filter(':visible:odd').filter('.odd') 748 .removeClass('odd').addClass('even') 749 .end().end() 750 .filter(':visible:even').filter('.even') 751 .removeClass('even').addClass('odd'); 752 }; 753 754})(jQuery); 755;
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.