Changeset 3066

Show
Ignore:
Timestamp:
11/23/10 20:44:53
Author:
johnsa
Message:

bwTimePicker: provide option for multiple fields to be set

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/deployment/resources/javascript/bedework/bwClock.js

    r3057 r3066  
    3232     
    3333    var defaults = {   
    34       hour24: false, 
    35       withPadding: false, 
    36       attachToId: null, 
    37       hourId: null, 
    38       minuteId: null, 
    39       ampmId: null 
     34      hour24: false,      // are we in 24 hour clock mode? 
     35      withPadding: false, // pad the hours with a zero if below 10 
     36      attachToId: null,   // id of element which when clicked will launch the time picker 
     37      hourIds: null,      // array of ids - one for each hour element to be updated 
     38      minuteIds: null,    // array of ids - one for each minute element to be updated 
     39      ampmIds: null       // array of ids - one for each am/pm element to be updated 
    4040    };   
    4141    var options = $.extend(defaults, options); 
     
    8787              hours = "0" + hours;  
    8888            } 
    89             $("#" + options.hourId).val(hours); 
     89            for (var i=0; i < options.hourIds.length; i++) { 
     90              $("#" + options.hourIds[i]).val(hours); 
     91            } 
    9092          }); 
    9193          $("#" + options.attachToId + " .bwTimePicker .bwTimePickerMinutes li").click(function(){ 
    9294            $("#" + options.attachToId + " .bwTimePicker .bwTimePickerMinutes li").removeClass('bwTimePickerSelected'); 
    9395            $(this).addClass('bwTimePickerSelected'); 
    94             $("#" + options.minuteId).val($(this).html()); 
     96            for (var i=0; i < options.minuteIds.length; i++) { 
     97              $("#" + options.minuteIds[i]).val($(this).html()); 
     98            } 
    9599          }); 
    96100          $("#" + options.attachToId + " .bwTimePicker .bwTimePickerAmPm li").click(function(){ 
    97101            $("#" + options.attachToId + " .bwTimePicker .bwTimePickerAmPm li").removeClass('bwTimePickerSelected'); 
    98102            $(this).addClass('bwTimePickerSelected'); 
    99             $("#" + options.ampmId).val($(this).html()); 
     103            for (var i=0; i < options.ampmIds.length; i++) { 
     104              $("#" + options.ampmIds[i]).val($(this).html()); 
     105            } 
    100106          }); 
    101107        },