Changeset 7879


Ignore:
Timestamp:
Nov 26, 2010, 12:11:13 AM (10 years ago)
Author:
LucMorizur
Message:

Validity date

Location:
extensions/event_cats
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/admin/template/autolog_new.js

    r7864 r7879  
    4141var ec_selected_action          = '-1';
    4242var maintenant                  = new Date();
     43var validity_date               = new Date();
    4344var ec_JS_message               = new Array();
    4445var ec_duplic_codes             = new Array();
     
    5455    ec_lists['comment']         = new Array();
    5556var d                           = document;
    56 var validity_date               = maintenant;
    5757
    5858function de(ec_id) {
     
    726726  tp.setMilliseconds(0);
    727727  tp.setSeconds(0);
    728   maintenant = tp;
     728  maintenant.setTime(tp.getTime());
    729729  tp.setTime(maintenant.getTime() + 120000); // PHP will not allow that
    730730  // [date & time] is less than [one minute more than current [date & time]].
     
    737737  ec_get_validity();
    738738  if (Number(validity_date.getTime()) < Number(tp.getTime()))
    739    validity_date = tp;
     739   validity_date.setTime(tp.getTime());
    740740  ec_set_validity();
    741741}
     
    743743function ec_mark_now() {
    744744  maintenant = new Date();
     745  maintenant.setMilliseconds(0);
     746  maintenant.setSeconds(0);
    745747  validity_date.setTime(maintenant.getTime() + 120000); // See two minutes
    746748   // explanation in function ec_validity_check_min
     
    788790  var tp = new Date();
    789791  var ts = 0;
    790   maintenant = tp;
     792  tp.setMilliseconds(0);
     793  tp.setSeconds(0);
     794  maintenant.setTime(tp.getTime());
    791795  tp.setTime(maintenant.getTime() + 120000); // See two minutes
    792796   // explanation in function ec_validity_check_min
     
    799803  ec_set_validity();
    800804  ec_validity_check_min();
     805}
     806
     807function ec_check_validity_on() {
     808  $('.ec_valid_ctl').attr('disabled', !ec_validity_on);
     809  $('img.ui-datepicker-trigger').css(
     810    'display', (ec_validity_on) ? 'inline' : 'none'
     811  );
     812  $('#ec_tmp_img').css(
     813    'display', (ec_validity_on) ? 'none' : 'inline'
     814  );
    801815}
    802816
     
    850864   null, "#ec_min_date_id", null);
    851865  $(document).ready(function(){
     866    maintenant = new Date();
     867    maintenant.setMilliseconds(0);
     868    maintenant.setSeconds(0);
     869    validity_date.setTime(maintenant.getTime());
     870    ec_check_validity_on();
     871    $('#ec_tmp_img').attr(
     872      'src', $('img.ui-datepicker-trigger:first').attr('src')
     873    );
    852874    $('.ui-datepicker').click(function(){
    853875      ec_validity_check_min();
     
    859881      'backgroundColor', $('#content').css('backgroundColor')
    860882    );
     883    $('#ec_validity_sel_day').css(
     884      'color', $('#content').css('color')
     885    );
     886    $('.ec_valid_ctl').attr('disabled', 'disabled');
     887    $('#ec_valid_date_on_id').change(function(){
     888      ec_validity_on = $(this).attr('checked');
     889      ec_check_validity_on();
     890    });
    861891  });
    862892 
  • extensions/event_cats/admin/template/autolog_new.tpl

    r7864 r7879  
    315315    <!--
    316316      Next steps:
    317         _ check if initialize validity date with JS is doable ;   DONE
    318         _ check if ' onchange = "ec_update_ts();" ' can be used ; DONE
    319         _ implement JS ; DONE
     317        _ check if initialize validity date with JS is doable;   DONE
     318        _ check if ' onchange = "ec_update_ts();" ' can be used; DONE
     319        _ implement JS:
     320          _ tick checkboxes when necessary;
     321          _ throw proper information when submitting form.
    320322        _ implement PHP ;
    321323        _ commit, and drink a pint!
     
    336338            </label>
    337339          </p>
    338           <p style = "text-align:left;{* padding:0.5em; border:1px solid #666666; *}">
    339             <input type = "text" id = "ec_validity_sel_day" style = "text-align:right; border:none;" disabled = "disabled">&nbsp;
    340             <select id = "ec_validity_day_id" name = "ec_validity_day" class = "ec_datepicker">
     340          <p style = "text-align:left;">
     341            <input type = "text" id = "ec_validity_sel_day" style = "text-align:right; border:none; cursor:default;" disabled = "disabled">&nbsp;
     342            <select id = "ec_validity_day_id" name = "ec_validity_day" class = "ec_valid_ctl ec_datepicker">
    341343              <option value = "0">--</option>
    342344              {section name=day start=1 loop=32}
     
    346348              {/section}
    347349            </select>
    348             <select id = "ec_validity_month_id" name = "ec_validity_month" class = "ec_datepicker">
     350            <select id = "ec_validity_month_id" name = "ec_validity_month" class = "ec_valid_ctl ec_datepicker">
    349351              {html_options options=$month_list}
    350352            </select>
    351353            <input id = "ec_validity_year_id" name = "ec_validity_year" type = "text" size = "4"
    352              maxlength = "4" style = "text-align:right; " class = "ec_datepicker">
    353             <input id = "ec_validity_time_id" name = "ec_validity_time" type = "text" class = "ec_datepicker"
     354             maxlength = "4" style = "text-align:right; " class = "ec_valid_ctl ec_datepicker">
     355            <input id = "ec_validity_time_id" name = "ec_validity_time" type = "text" class = "ec_valid_ctl ec_datepicker"
    354356             size = "5" maxlength = "5" title = "{'Hours field tooltip'|@translate}" style = "text-align:right; ">
    355357            <input id = "ec_linked_date_id" name = "ec_linked_date_id" type = "hidden" size = "10" disabled = "disabled">
     358            <img id = "ec_tmp_img" class = "ui-datepicker-trigger" src = "{$EVNTCATS_URLS.ROOT}icon/tmp.png" alt = "" title = "" style = "display:none;">
    356359          </p>
    357360          <p style = "text-align:left;">
    358361            <input id = "ec_date_today_btn_id" type = "button" value = "{'Now + 2 mn'|@translate}"
    359              class = "submit" title = "{'Now button tooltip'|@translate}" onclick = "ec_mark_now();">&nbsp;—&nbsp;
     362             class = "ec_valid_ctl submit" title = "{'Now button tooltip'|@translate}" onclick = "ec_mark_now();">&nbsp;—&nbsp;
    360363            <input id = "ec_set_time_to_btn_id" type = "button" value = "{'Set time to'|@translate}"
    361              class = "submit" onclick = "ec_valid_set_time_to(document.getElementById('ec_set_time_to_id').selectedIndex);">&nbsp;
    362             <select id = "ec_set_time_to_id" name = "ec_set_time_to" onchange = "ec_valid_set_time_to(this.selectedIndex);">
     364             class = "ec_valid_ctl submit" onclick = "ec_valid_set_time_to(document.getElementById('ec_set_time_to_id').selectedIndex);">&nbsp;
     365            <select id = "ec_set_time_to_id" name = "ec_set_time_to" onchange = "ec_valid_set_time_to(this.selectedIndex);" class = "ec_valid_ctl">
    363366              {section name=time start=0 loop=24}
    364367                <option label = "{if strlen($smarty.section.time.index) lt 2}0{/if}{$smarty.section.time.index}:00" value = "{$smarty.section.time.index}">
     
    369372          </p>
    370373          <p style = "text-align:left;">
    371             <input id = "ec_date_add_btn_id" type = "button" value = "{'Add'|@translate}" title = "{'Add button tooltip'|@translate}" class = "submit"
     374            <input id = "ec_date_add_btn_id" type = "button" value = "{'Add'|@translate}" title = "{'Add button tooltip'|@translate}" class = "ec_valid_ctl submit"
    372375             onclick = "ec_add_time(document.getElementById('ec_date_add_val_id').value, document.getElementById('ec_date_add_kind_id').selectedIndex);">&nbsp;
    373             <input id = "ec_date_add_val_id" type = "text" size = "5" maxlength = "5" value = "" style = "text-align:right;">&nbsp;
    374             <select id = "ec_date_add_kind_id" name = "ec_date_add_kind">
     376            <input id = "ec_date_add_val_id" type = "text" size = "5" maxlength = "5" value = "" style = "text-align:right;" class = "ec_valid_ctl">&nbsp;
     377            <select id = "ec_date_add_kind_id" name = "ec_date_add_kind" class = "ec_valid_ctl">
    375378              <option label = "{'Minutes'|@translate}" value = "minutes">{'Minutes'|@translate}</option>
    376379              <option label = "{'Hours'|@translate}"   value = "hours"  >{'Hours'|@translate}</option>
     
    393396                  <li style = "margin-bottom:0;">
    394397                    <label for = "ec_notify_user_id">
    395                       <input type = "checkbox" name = "ec_notify_user" id = "ec_notify_user_id">
     398                      <input type = "checkbox" name = "ec_notify_user" id = "ec_notify_user_id" class = "ec_valid_ctl">
    396399                      {'The user'|@translate}
    397400                    </label>
     
    399402                  <li style = "margin-bottom:0;">
    400403                    <label for = "ec_notify_webm_id">
    401                       <input type = "checkbox" name = "ec_notify_webm" id = "ec_notify_webm_id">
     404                      <input type = "checkbox" name = "ec_notify_webm" id = "ec_notify_webm_id" class = "ec_valid_ctl">
    402405                      {'The webmaster'|@translate}
    403406                    </label>
     
    405408                  <li style = "margin-bottom:0;">
    406409                    <label for = "ec_notify_admins_id">
    407                       <input type = "checkbox" name = "ec_notify_admins" id = "ec_notify_admins_id">
     410                      <input type = "checkbox" name = "ec_notify_admins" id = "ec_notify_admins_id" class = "ec_valid_ctl">
    408411                      {'All administrators'|@translate}
    409412                    </label>
     
    449452                  <li style = "margin-bottom:0;">
    450453                    <label for = "ec_date_unknown_0_id">
    451                       <input type = "radio" name = "ec_date_unknown" value = "0" id = "ec_date_unknown_0_id">
     454                      <input type = "radio" name = "ec_date_unknown" value = "0" id = "ec_date_unknown_0_id" class = "ec_valid_ctl">
    452455                      {'Home'|@translate}
    453456                    </label>
     
    455458                  <li style = "margin-bottom:0;">
    456459                    <label for = "ec_date_unknown_1_id">
    457                       <input type = "radio" name = "ec_date_unknown" value = "1" id = "ec_date_unknown_1_id">
     460                      <input type = "radio" name = "ec_date_unknown" value = "1" id = "ec_date_unknown_1_id" class = "ec_valid_ctl">
    458461                      {'Access denied'|@translate}
    459462                    </label>
     
    461464                  {* <!-- Additionnal Page, provided the plugin is activated and at least one Add. P. is available --> *}
    462465                  <li {if !$ec_ap_ok or count($ec_lists.add_pages) == 0} style = "display:none;" {else} style = "margin-bottom:0;" {/if} >
    463                     <label class = "ec_date_block" for = "ec_date_in_up_aps_id">
    464                       <input type = "radio" name = "ec_date_unknown" value = "2" id = "ec_date_unknown_2_id">
     466                    <label for = "ec_date_in_up_aps_id">
     467                      <input type = "radio" name = "ec_date_unknown" value = "2" id = "ec_date_unknown_2_id" class = "ec_valid_ctl">
    465468                      {'Additional Page'|@translate}<br>
    466                       <select class = "categoryList" name = "ec_date_in_up_aps" size = "30" id = "ec_date_in_up_aps_id" >
     469                      <select class = "ec_valid_ctl categoryList" name = "ec_date_in_up_aps" size = "30" id = "ec_date_in_up_aps_id" >
    467470                        {html_options options = $ec_lists.add_pages}
    468471                      </select>
Note: See TracChangeset for help on using the changeset viewer.