Changeset 23647
- Timestamp:
- 11/05/09 22:16:02 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/pkToolkitPlugin/trunk/lib/helper/pkSubCrudHelper.php
r23411 r23647 228 228 ob_start(); 229 229 include_stylesheets_for_form($form); 230 include_javascripts_for_form($form);231 230 echo $form; 232 231 ?> … … 236 235 </ul> 237 236 <?php 237 // Do this after the form so that we can do things like disabling stuff that 238 // gets created by JS in widgets 239 include_javascripts_for_form($form); 238 240 return ob_get_clean(); 239 241 } plugins/pkToolkitPlugin/trunk/web/js/pkControls.js
r23417 r23647 523 523 // when the checkbox is checked? Here's your answer 524 524 525 function pkCheckboxEnables(boxSelector, itemsSelector) 525 // The optional hideItemsSelector contains items that should be hidden rather than disabled. 526 // You can pass undefined for itemsSelector if you are only interested in hiding items. This 527 // combination is useful if you want to fully disable a datepicker with an input field 528 // (disable-able) and a calendar icon (not disable-able, but hide-able). 529 530 // Both selector arguments are optional. To skip itemsSelector, pass undefined (not null) 531 // for that argument. 532 533 function pkCheckboxEnables(boxSelector, itemsSelector, hideItemsSelector) 526 534 { 527 535 $(boxSelector).data('pkCheckboxEnablesItemsSelector', itemsSelector); 536 $(boxSelector).data('pkCheckboxEnablesHideItemsSelector', hideItemsSelector); 528 537 $(boxSelector).click(function() { 529 538 update(this); … … 533 542 { 534 543 var itemsSelector = $(checkbox).data('pkCheckboxEnablesItemsSelector'); 544 var hideItemsSelector = $(checkbox).data('pkCheckboxEnablesHideItemsSelector'); 535 545 if ($(checkbox).attr('checked')) 536 546 { 537 $(itemsSelector).removeAttr('disabled'); 547 if (itemsSelector !== undefined) 548 { 549 $(itemsSelector).removeAttr('disabled'); 550 } 551 if (hideItemsSelector !== undefined) 552 { 553 $(hideItemsSelector).show(); 554 } 538 555 } 539 556 else 540 557 { 541 $(itemsSelector).attr('disabled', 'disabled'); 558 if (itemsSelector !== undefined) 559 { 560 $(itemsSelector).attr('disabled', 'disabled'); 561 } 562 if (hideItemsSelector !== undefined) 563 { 564 $(hideItemsSelector).hide(); 565 } 542 566 } 543 567 } 544 $(boxSelector).each(function() { update(this) }); 568 // At DOMready so we can affect controls created by js widgets in the form 569 $(function() { 570 $(boxSelector).each(function() { update(this) }); 571 }); 545 572 } 546 573 … … 551 578 // when "Other" is chosen from an "Institution Type" menu. 552 579 553 function pkSelectEnables(selectSelector, itemsSelectors) 580 // If desired a second hash of option values pointing to item selectors that 581 // should be shown/hidden rather than enabled/disabled can also be passed. 582 583 // Both selector arguments are optional. To skip itemsSelectors, pass undefined (not null) 584 // for that argument. 585 586 function pkSelectEnables(selectSelector, itemsSelectors, hideItemsSelectors) 554 587 { 555 588 $(selectSelector).data('pkSelectEnablesItemsSelectors', itemsSelectors); 589 $(selectSelector).data('pkSelectEnablesHideItemsSelectors', hideItemsSelectors); 556 590 $(selectSelector).change(function() { 557 591 update(this); … … 561 595 { 562 596 var itemsSelectors = $(select).data('pkSelectEnablesItemsSelectors'); 563 for (var option in itemsSelectors) 597 var hideItemsSelectors = $(select).data('pkSelectEnablesHideItemsSelectors'); 598 if (itemsSelectors !== undefined) 564 599 { 565 $(itemsSelectors[option]).attr('disabled', 'disabled'); 600 for (var option in itemsSelectors) 601 { 602 $(itemsSelectors[option]).attr('disabled', 'disabled'); 603 } 604 var option = select.value; 605 if (itemsSelectors[option]) 606 { 607 $(itemsSelectors[option]).removeAttr('disabled'); 608 } 566 609 } 567 var option = select.value; 568 if (itemsSelectors[option]) 610 if (hideItemsSelectors !== undefined) 569 611 { 570 $(itemsSelectors[option]).removeAttr('disabled'); 612 for (var option in hideItemsSelectors) 613 { 614 $(hideItemsSelectors[option]).hide(); 615 } 616 var option = select.value; 617 if (hideItemsSelectors[option]) 618 { 619 $(hideItemsSelectors[option]).show(); 620 } 571 621 } 572 622 } 573 $(selectSelector).each(function() { update(this) }); 623 $(function() { 624 $(selectSelector).each(function() { update(this) }); 625 }); 574 626 } 575 627