1/* 2 * iPhorm WordPress jQuery plugin 3 */ 4;(function($) { 5 $.iPhorm = function ($form, options) { 6 var _this = this, 7 settings = {}, 8 extraData = { 9 iphorm_ajax: 1 10 }, 11 submitted = false, 12 uploaders = [], 13 uploadQueue = [], 14 swfUploadError = false, 15 supportsSwfUpload = typeof swfobject === 'object' && swfobject.hasFlashPlayerVersion('9.0.28'), 16 $successMessage = $('.iphorm-success-message', $form), 17 $loadingSpinner = $('.iphorm-loading-wrap', $form); 18 19 // Expose the form to the outside world 20 _this.$form = $form; 21 22 // Load in any options 23 if (options) { 24 $.extend(settings, options); 25 } 26 27 /** 28 * Add an SWFUpload element to the form 29 * 30 * @param object element JavaScript object containing the element information 31 */ 32 _this.addUploader = function (element) { 33 if (supportsSwfUpload) { 34 // Hide the normal file element 35 $('.' + element.name + '-input-wrap', $form).hide(); 36 $('.' + element.name + '-add-another-upload', $form).hide(); 37 38 // Show the SWFUpload element 39 $('#' + element.uniqueId + '-swfupload').show(); 40 41 var $queue = $('#' + element.uniqueId + '-file-queue'), 42 $queueErrors = $('#' + element.uniqueId + '-file-queue-errors'), 43 browseButton = getHiddenDimensions($('#' + element.uniqueId + '-browse')), swfu; 44 45 // Define SWFUpload handles 46 function fileDialogStart () { 47 $queueErrors.hide().empty(); 48 } 49 50 function fileQueued (file) { 51 var $close = $('<div class="iphorm-upload-queue-remove">X</div>').click(function () { 52 swfu.cancelUpload(file.id); 53 for (var i = 0; i < uploadQueue.length; i++) { 54 if (uploadQueue[i].file.id == file.id) { 55 uploadQueue.splice(i, 1); 56 } 57 } 58 $(this).parent().remove(); 59 60 if ($queue.children().length == 0) { 61 $queue.hide(); 62 } 63 }); 64 65 uploadQueue.push({ 66 file: file, 67 uploaderId: swfu.movieName 68 }); 69 70 $queue.append($('<div id="' + file.id + '" class="iphorm-upload-queue-file"><div class="iphorm-upload-queue-filename">' + file.name + ' (' + formatFileSize(file.size) + ')</div></div>').append($close)).show(); 71 } 72 73 function fileQueueError (file, errorCode, message) { 74 $queueErrorsList = $('<div class="iphorm-queue-errors-list iphorm-clearfix"></div>'); 75 76 switch (errorCode) { 77 case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED: 78 $queueErrorsList.append('<div class="iphorm-queue-error">' + iphormL10n.swfupload_too_many + '</div>'); 79 break; 80 case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: 81 $queueErrorsList.append('<div class="iphorm-queue-error">' + file.name + ' - ' + iphormL10n.swfupload_file_too_big + '</div>'); 82 break; 83 case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: 84 $queueErrorsList.append('<div class="iphorm-queue-error">' + file.name + ' - ' + iphormL10n.swfupload_file_empty + '</div>'); 85 break; 86 case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: 87 $queueErrorsList.append('<div class="iphorm-queue-error">' + file.name + ' - ' + iphormL10n.swfupload_file_type_not_allowed + '</div>'); 88 break; 89 default: 90 $queueErrorsList.append('<div class="iphorm-queue-error">' + iphormL10n.swfupload_unknown_queue_error + '</div>'); 91 break; 92 } 93 94 $queueErrors.append($queueErrorsList).show(); 95 } 96 97 function uploadStart(file) { 98 // Show the upload progress bar 99 $('.iphom-upload-progress-wrap').show(); 100 } 101 102 function uploadProgress(file, bytesLoaded, bytesTotal) {
103 $('.iphorm-upload-progress-bar').css('width', ((bytesLoaded / file.size) * 100) + '%'); 104 $('.iphorm-upload-filename').text(file.name); 105 } 106 107 function uploadError(file, errorCode, message) { 108 switch (errorCode) { 109 case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: 110 swfUploadError = true; 111 $('.iphorm-upload-error', $form).text(iphormL10n.swfupload_upload_error).show(); 112 break; 113 case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: 114 swfUploadError = true; 115 $('.iphorm-upload-error', $form).text(iphormL10n.swfupload_upload_failed).show(); 116 break; 117 case SWFUpload.UPLOAD_ERROR.IO_ERROR: 118 swfUploadError = true; 119 $('.iphorm-upload-error', $form).text(iphormL10n.swfupload_server_io).show(); 120 break; 121 case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: 122 swfUploadError = true; 123 $('.iphorm-upload-error', $form).text(iphormL10n.swfupload_security_error).show(); 124 break; 125 case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: 126 swfUploadError = true; 127 $('.iphorm-upload-error', $form).text(iphormL10n.swfupload_limit_exceeded).show(); 128 break; 129 case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: 130 swfUploadError = true; 131 $('.iphorm-upload-error', $form).text(iphormL10n.swfupload_validation_failed).show(); 132 break; 133 case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: 134 break; 135 case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: 136 swfUploadError = true; 137 $('.iphorm-upload-error', $form).text(iphormL10n.swfupload_upload_stopped).show(); 138 break; 139 default: 140 swfUploadError = true; 141 $('.iphorm-upload-error', $form).text(iphormL10n.swfupload_unknown_upload_error).show(); 142 break; 143 } 144 } 145 146 function uploadSuccess(file, response) { 147 if (response) { 148 var response = $.parseJSON(response); 149 150 if (typeof response == 'object' && response.type == 'error') { 151 swfUploadError = true; 152 $('.iphorm-upload-error', $form).text(file.name + ' - ' + response.data[0]).show(); 153 $('#' + file.id, $form).remove(); 154 } 155 } 156 } 157 158 function uploadComplete(file) { 159 if (!swfUploadError) { 160 // Show the file as uploaded successfully 161 $('#' + file.id, $form).find('.iphorm-upload-queue-remove').removeClass('iphorm-upload-queue-remove').addClass('iphorm-upload-queue-success').unbind('click'); 162 163 if (uploadQueue.length > 0) { 164 var next = uploadQueue.shift(); 165 getUploader(next.uploaderId).startUpload(next.file.id); 166 } else { 167 // Nothing left in the queue so this time we submit the form 168 $('.iphom-upload-progress-wrap').hide(); 169 _this.submit(); 170 } 171 } else { 172 // Hide the loading spinner 173 $loadingSpinner.hide(); 174 resetSWFUpload(); 175 submitted = false; 176 } 177 } 178 179 swfu = new SWFUpload({ 180 button_height: browseButton.outerHeight, 181 button_width: browseButton.outerWidth, 182 button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, 183 button_placeholder_id: element.uniqueId + '-object', 184 button_cursor: SWFUpload.CURSOR.HAND, 185 186 flash_url: iphormL10n.swfupload_flash_url, 187 upload_url: iphormL10n.swfupload_upload_url, 188 file_post_name: element.name, 189 190 file_dialog_start_handler: fileDialogStart, 191 file_queued_handler: fileQueued, 192 file_queue_error_handler: fileQueueError, 193 upload_start_handler: uploadStart, 194 upload_progress_handler: uploadProgress, 195 upload_error_handler: uploadError, 196 upload_success_handler: uploadSuccess, 197 upload_complete_handler: uploadComplete, 198 199 post_params: { 200 iphorm_id: settings.id, 201 iphorm_form_uniq_id: settings.uniqueId, 202 iphorm_element_id: element.id, 203 iphorm_element_name: element.name, 204 PHPSESSID: settings.PHPSESSID 205 }, 206 207 prevent_swf_caching: true, 208 209 file_types : element.fileTypes, 210 file_types_description: element.fileTypesDescription, 211 file_size_limit : element.fileSizeLimit, 212 file_upload_limit : element.fileUploadLimit, 213 214 debug: false 215 }); 216 217 uploaders.push(swfu); 218 } 219 }; // End addUploader 220 221 /** 222 * Bind to the submit event of the form 223 */ 224 if (settings.useAjax) { 225 $form.bind('submit', function(event) { 226 // Can't submit during preview 227 if (settings.preview === true) { 228 alert(iphormL10n.preview_no_submit); 229 return false;
230 } 231 232 // Prevent double submit 233 if (submitted) { 234 return false; 235 } else { 236 submitted = true; 237 } 238 239 // Show loading image 240 $loadingSpinner.fadeIn('slow'); 241 242 // Prevent the browser submitting the form normally 243 event.preventDefault(); 244 245 // Remove any previous upload error 246 $('.iphorm-upload-error', $form).hide().text(''); 247 248 // Detect if there are any SWFUpload files in the queue and upload them first 249 if (uploadQueue.length > 0) { 250 extraData.iphorm_swfu = 1; 251 var next = uploadQueue.shift(); 252 getUploader(next.uploaderId).startUpload(next.file.id); 253 } else { 254 // There are no uploads in the queue, submit the form normally 255 _this.submit(); 256 } 257 }); // End bind 258 } // if settings.useAjax 259 260 /** 261 * Submits the form 262 */ 263 _this.submit = function () { 264 // Bind the form submit to use the ajax form plugin 265 $form.ajaxSubmit({ 266 async: false, 267 dataType: 'json', 268 data: extraData, 269 iframe: true, 270 url: '', 271 success: function(response) { 272 // Reload the recaptcha, we can't use it twice 273 if (typeof Recaptcha === 'object') { 274 try { // Catching errors due to conflict with another plugin 275 Recaptcha.reload(); 276 } catch (e) {} 277 } 278 279 // Prepares the form to be submitted again 280 var prepareForm = function () { 281 // Hide the loading spinner 282 $loadingSpinner.hide(); 283 284 // Hide any previous errors or success messages 285 $('.iphorm-errors-wrap', $form).hide(); 286 $('.iphorm-errors-list, .iphorm-error', $form).remove(); 287 $('.iphorm-queue-errors', $form).hide().empty(); 288 $successMessage.hide(); 289 $('.iphorm-element-error', $form).removeClass('iphorm-element-error'); 290 291 // Allow the form to be submitted again 292 submitted = false; 293 }; 294 295 // Check if the form submission was successful 296 if (response === null) { 297 // Hide the loading spinner 298 $loadingSpinner.hide(); 299 300 // Allow resubmitting 301 submitted = false; 302 303 alert(iphormL10n.error_submitting_form); 304 } else if (typeof response === 'object') { 305 if (response.type == 'success') { 306 prepareForm(); 307 // Reset the captcha 308 $('.iphorm-captcha-image', $form).trigger('click'); 309 310 // Reset the form 311 $form.resetForm(); 312 313 // Call blur on element to reset inline labels 314 $('input[type="text"], textarea', $form).blur(); 315 316 // Hide dynamically added file inputs 317 $('.iphorm-add-another-file-wrap', $form).remove(); 318 319 // Reset conditional logic 320 _this.applyAllLogic(); 321 322 // Sync uniform with underlying elements 323 if (typeof $.uniform === 'object' && typeof $.uniform.update === 'function') { 324 $.uniform.update(); 325 } 326 327 // Reset SWF upload stats 328 resetSWFUpload(); 329 330 // Hide any tooltips 331 $('.qtip').hide(); 332 333 if (typeof response.redirect === 'string') { 334 if (response.redirect == '') { 335 window.location.reload(); 336 } else { 337 window.location = response.redirect; 338 } 339 } else { 340 // Then fade in the success message 341 $successMessage.html(response.data).fadeIn('slow').show(0, function() { 342 // Set timeout 343 if (settings.successMessageTimeout > 0) { 344 setTimeout(function () { 345 $successMessage.fadeOut(400); 346 }, (settings.successMessageTimeout * 1000)); 347 } 348 349 // Custom success callback 350 if (typeof settings.success === 'function') { 351 settings.success(); 352 } 353 }); 354 355 // Scroll to the success message if it's not in view 356 if (!isScrolledIntoView($successMessage) && $.isFunction($.smoothScroll)) { 357 $.smoothScroll({ 358 scrollTarget: $successMessage, 359 offset: -50, 360 speed: 500 361 }); 362 } 363 } 364 } else if (response.type == 'error') { 365 prepareForm(); 366 367 var $errors = $(); 368 369 // Go through each element containing errors 370 $.each(response.data, function(index, info) { 371 // If there are errors for this element 372 if (info.errors != undefined && info.errors.length > 0) { 373 // Save a reference to this element 374 var $elementWrap = $("." + index + "-element-wrap", $form), 375 $errorsWrap = $elementWrap.find('.iphorm-errors-wrap'); 376 377 // If the returned element exists 378 if ($elementWrap.length && $errorsWrap.length) { 379 // Create a blank error list 380 var $errorList = $('<div class="iphorm-errors-list iphorm-clearfix"></div>'); 381 382 // Go through each error for this field 383 $.each(info.errors, function(i, e) { 384 // Append the error to the list as a list item
385 $errorList.append('<div class="iphorm-error">' + e + '</div>'); 386 return false; // Just display one error per element 387 }); 388 389 $errors = $errors.add($elementWrap); 390 391 // Add the error list after the element's wrapper 392 $errorsWrap.append($errorList); 393 394 // Add an error class to the element wrapper 395 $elementWrap.addClass('iphorm-element-error'); 396 } 397 } 398 }); 399 400 // Fade all errors in 401 $('.iphorm-errors-wrap', $form).fadeIn(1000).show(); 402 403 // Scroll to the first error 404 if ($errors.size()) { 405 var $targetError = $errors.get(0); 406 if (!isScrolledIntoView($targetError) && $.isFunction($.smoothScroll)) { 407 $.smoothScroll({ 408 scrollTarget: $targetError, 409 offset: -50, 410 speed: 700 411 }); 412 } 413 } 414 415 // Custom error callback 416 if (typeof settings.error === 'function') { 417 settings.error(); 418 } 419 } // End reponse.type == error 420 } // End typeof response == object 421 }, // End success callback 422 error: function () { 423 // Hide the loading spinner 424 $loadingSpinner.hide(); 425 426 // Allow resubmitting 427 submitted = false; 428 429 alert(iphormL10n.error_submitting_form); 430 } 431 }); // End ajaxSubmit() 432 }; // End submit() 433 434 /** 435 * Adds a datepicker to the element with the given unique ID 436 * 437 * @param string uniqueId 438 */ 439 _this.addDatepicker = function (uniqueId, options) { 440 if ($.isFunction($.fn.datepicker)) { 441 var $daySelect = $('#' + uniqueId + '_day'), 442 $monthSelect = $('#' + uniqueId + '_month'), 443 $yearSelect = $('#' + uniqueId + '_year'), 444 $datePicker = $('.iphorm-datepicker', '#' + uniqueId).datepicker($.extend({}, { 445 onSelect: function (dateText, inst) { 446 $daySelect.val(inst.selectedDay); 447 $monthSelect.val(inst.selectedMonth + 1); 448 $yearSelect.val(inst.selectedYear); 449 if (typeof $.uniform === 'object' && typeof $.uniform.update === 'function') { 450 $.uniform.update($daySelect.add($monthSelect).add($yearSelect)); 451 } 452 }, 453 beforeShow: function (input, inst) { 454 var currentTime = new Date(), 455 dayToSet = ($daySelect.val().length > 0) ? $daySelect.val() : currentTime.getDate(), 456 monthToSet = ($monthSelect.val().length > 0) ? $monthSelect.val()-1 : currentTime.getMonth(), 457 yearToSet = ($yearSelect.val().length > 0) ? $yearSelect.val() : currentTime.getFullYear(); 458 459 $datePicker.datepicker('setDate', new Date(yearToSet, monthToSet, dayToSet)); 460 }}, options) 461 ); 462 463 $('.iphorm-datepicker-icon', '#' + uniqueId).click(function () { 464 $datePicker.datepicker('show'); 465 }).show(); 466 } 467 }; 468 469 /** 470 * Applies the the logic to all elements 471 * 472 * If loading is true, bind the logic triggers and do not animate the logic 473 * 474 * @param boolean loading 475 */ 476 _this.applyAllLogic = function (loading) { 477 _this.applyLogic(settings.clElementIds, loading); 478 479 if (loading) { 480 _this.applyDependentLogic(settings.clDependentElementIds); 481 } 482 }; 483 484 /** 485 * Applies logic to show or hide the elements with the given IDs 486 * 487 * @param array elementIds The element IDs to apply the logic to 488 * @param boolean loading True if we are applying initial logic (to skip animating) 489 */ 490 _this.applyLogic = function (elementIds, loading) { 491 for (var i = 0; i < elementIds.length; i++) { 492 _this.applyElementLogic(elementIds[i], loading); 493 } 494 }; 495 496 /** 497 * Apply logic to the given element ID 498 * 499 * @param int elementId 500 * @param boolean loading True if we are applying initial logic (to skip animating) 501 */ 502 _this.applyElementLogic = function (elementId, loading) { 503 if (iPhorm.logic[settings.id] && iPhorm.logic[settings.id].logic) { 504 var logic = iPhorm.logic[settings.id].logic[elementId]; 505 506 if (logic && logic.rules && logic.rules.length) { 507 var matchedValues = 0; 508 for (var i = 0; i < logic.rules.length; i++) { 509 var rule = logic.rules[i];
510 if ((rule.operator == 'eq' && _this.elementHasValue(rule.element_id, rule.value)) || (rule.operator == 'neq' && !_this.elementHasValue(rule.element_id, rule.value))) { 511 matchedValues++; 512 } 513 } 514 515 if ((logic.match == 'any' && matchedValues > 0) || (logic.match == 'all' && matchedValues == logic.rules.length)) { 516 var action = logic.action; 517 } else { 518 var action = logic.action == 'show' ? 'hide' : 'show'; 519 } 520 521 var $element = $('.iphorm_'+settings.id+'_'+elementId+'-element-wrap, .iphorm_'+settings.id+'_'+elementId+'-group-wrap', $form); 522 523 if (!loading && iPhorm.logic[settings.id].animate) { 524 if (action == 'show') { 525 $element.slideDown(400, function () { 526 centerFancybox(); 527 }); 528 } else { 529 $element.slideUp(400, function () { 530 centerFancybox(); 531 }); 532 } 533 } else { 534 if (action == 'show') { 535 $element.show(); 536 } else { 537 $element.hide(); 538 } 539 540 if (!loading) { 541 centerFancybox(); 542 } 543 } 544 } 545 } 546 }; 547 548 /** 549 * Binds the conditional logic events to the elements 550 * 551 * @param array elementIds 552 */ 553 _this.applyDependentLogic = function (elementIds) { 554 if (iPhorm.logic[settings.id] && iPhorm.logic[settings.id].dependents) { 555 for (var i = 0; i < elementIds.length; i++) { 556 var dependentElementIds = iPhorm.logic[settings.id].dependents[elementIds[i]], 557 $input = $('.iphorm_' + settings.id + '_' + elementIds[i], $form); 558 559 if ($input.length) { 560 var bind; 561 if ($input.is('select')) { 562 bind = 'change.iphorm'; 563 } else if ($input.is('input[type=checkbox]') || $input.is('input[type=radio]')) { 564 bind = 'click.iphorm'; 565 } 566 567 if (bind) { 568 (function (deps) { 569 $input.bind(bind, function () { 570 _this.applyLogic(deps); 571 }); 572 })(dependentElementIds); 573 } 574 } 575 } 576 } 577 }; 578 579 /** 580 * Does the element of the given ID has the given value? 581 * 582 * @param int elementId 583 * @param string value 584 * @return boolean 585 */ 586 _this.elementHasValue = function (elementId, value) { 587 var $input = $('.iphorm_' + settings.id + '_' + elementId, $form); 588 589 if ($input.length) { 590 if ($input.is('select')) { 591 if ($input.val() == value) { 592 return true; 593 } 594 } else if ($input.is('input[type=checkbox]') || $input.is('input[type=radio]')) { 595 var hasValue = false; 596 $.each($input, function () { 597 if ($(this).is(':checked') && $(this).val() == value) { 598 hasValue = true; 599 return false; 600 } 601 }); 602 return hasValue; 603 } 604 } 605 606 return false; 607 }; 608
609 /** 610 * Clears the default value and saves it and unbind the focus event, 611 * if reset is true a blur event is bound to show the default value 612 * again on blur if left empty. 613 * 614 * @param boolean reset 615 */ 616 _this.clearDefaultValue = function (reset) { 617 $(this).data('iphorm-default-value', $(this).val()).val('').unbind('focus'); 618 619 if (reset) { 620 $(this).bind('blur', function () { 621 _this.resetDefaultValue.call(this); 622 }); 623 } 624 }; 625 626 /** 627 * Resets the default value of the element 628 */ 629 _this.resetDefaultValue = function () { 630 if ($(this).val() == '') { 631 $(this).val($(this).data('iphorm-default-value')).unbind('blur').bind('focus', function () { 632 _this.clearDefaultValue.call(this, true); 633 }); 634 } 635 }; 636 637 /** 638 * Center the fancybox inside the viewport 639 */ 640 function centerFancybox() 641 { 642 if (settings.centerFancybox && typeof $.fancybox === 'function' && typeof $.fancybox.center === 'function' && $('#fancybox-wrap').length && $('#fancybox-wrap').is(':visible')) { 643 $.fancybox.center(settings.centerFancyboxSpeed); 644 } 645 } 646 647 /** 648 * Format a file size given in bytes to a human readable value 649 * 650 * @param int File size in bytes 651 * @return string 652 */ 653 function formatFileSize(size) { 654 if (size >= 1073741824) { 655 size = (Math.round((size / 1073741824) * 10) / 10) + ' GB'; 656 } else if (size >= 1048576) { 657 size = (Math.round((size / 1048576) * 10) / 10) + ' MB'; 658 } else if (size >= 1024) { 659 size = (Math.round((size / 1024) * 10) / 10) + ' KB'; 660 } else { 661 size = size + ' bytes'; 662 } 663 664 return size; 665 } 666 667 /** 668 * Get the SWFUploader with the given ID 669 * 670 * @param string The uploader movie ID 671 * @return object|null 672 */ 673 function getUploader(uploaderId) 674 { 675 for (var i = 0; i < uploaders.length; i++) { 676 if (uploaders[i].movieName == uploaderId) { 677 return uploaders[i]; 678 } 679 } 680 681 return null; 682 } 683 684 /** 685 * Is the element in or scrolled out of the current viewport 686 * 687 * @param DOMElement element 688 * @return boolean 689 */ 690 function isScrolledIntoView(elem) { 691 var docViewTop = $(window).scrollTop(); 692 var docViewBottom = docViewTop + $(window).height(); 693 694 var elemTop = $(elem).offset().top; 695 var elemBottom = elemTop + $(elem).height(); 696 697 return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) 698 && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) ); 699 } 700 701 /** 702 * Reset all the SWFUpload fields and stats 703 */ 704 function resetSWFUpload() 705 { 706 // Reset the SWFUpload stats and queues 707 $('.iphorm-file-queue').hide().empty(); 708 for (var i = 0; i < uploaders.length; i++) { 709 try { 710 uploaders[i].setStats({ 711 in_progress: 0, 712 files_queued : 0, 713 successful_uploads : 0, 714 upload_errors : 0, 715 upload_cancelled : 0, 716 queue_errors : 0 717 }); 718 } catch (e) {} 719 } 720 } 721 722 /** 723 * Get the dimensions of the given element even if it is hidden 724 * 725 * @param DOMElement element 726 * @param boolean includeMargin Include margin in outerWidth? 727 * @return object Object with all dimensions 728 */ 729 function getHiddenDimensions(element, includeMargin) { 730 var $item = $(element), 731 props = { position: 'absolute', visibility: 'hidden', display: 'block' }, 732 dim = { width:0, height:0, innerWidth: 0, innerHeight: 0,outerWidth: 0,outerHeight: 0 }, 733 $hiddenParents = $item.parents().andSelf().not(':visible'), 734 includeMargin = (includeMargin == null)? false : includeMargin; 735 736 var oldProps = []; 737 $hiddenParents.each(function() { 738 var old = {}; 739 740 for ( var name in props ) { 741 old[ name ] = this.style[ name ]; 742 this.style[ name ] = props[ name ]; 743 } 744 745 oldProps.push(old); 746 }); 747 748 dim.width = $item.width(); 749 dim.outerWidth = $item.outerWidth(includeMargin); 750 dim.innerWidth = $item.innerWidth(); 751 dim.height = $item.height();
752 dim.innerHeight = $item.innerHeight(); 753 dim.outerHeight = $item.outerHeight(includeMargin); 754 755 $hiddenParents.each(function(i) { 756 var old = oldProps[i]; 757 for ( var name in props ) { 758 this.style[ name ] = old[ name ]; 759 } 760 }); 761 762 return dim; 763 }; 764 }; // End $.iPhorm() 765 766 $.fn.iPhorm = function(options) { 767 return this.each(function () { 768 iPhorm.instance = new $.iPhorm($(this), options); 769 }); 770 }; // End $.fn.iPhorm 771 772 // Preload the images in the base theme 773 $(window).load(function () { 774 window.iPhorm.preload([ 775 'file-upload-tick.png', 776 'captcha-refresh-icon.png', 777 'default-loading.gif', 778 'error.png', 779 'success.png' 780 ], iphormL10n.plugin_url + '/images/'); 781 }); 782})(jQuery); // End jQuery wrapper
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.