Changeset 11000

Show
Ignore:
Timestamp:
01/17/11 15:53:57 (2 years ago)
Author:
mbrevda
Message:

allow advanced settings to be saved even when there of type BOOL

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.9/core/advancedsettings.js

    r10997 r11000  
    11$(document).ready(function() { 
    2   //hope this isnt to much to ask for... Not sure why this doent happen automaticaly, but this kludge works! 
    3   //if(url_pram('display') == 'advancedsettings'){$('#footer').remove().appendTo($('#wrapper'));} 
    42  //save settings 
    53  function savebinder(e) { 
     
    86      return false; 
    97    } 
    10     mythis = $(this); 
    11     mykey = $(this).attr('data-key'); 
     8    var mythis = $(this); 
     9    var mykey = $(this).attr('data-key'); 
     10    switch ($(this).attr('data-type')) { 
     11      case 'BOOL': 
     12        var myval = $('input[name="' + mykey + '"]:checked').val(); 
     13        break; 
     14      default: 
     15        var myval = $('#' + mykey).val(); 
     16        break; 
     17    } 
     18    //console.log('saving ',mykey,'as',myval,'which is a',$(this).attr('type')) 
    1219    $.ajax({ 
    1320      type: 'POST', 
     
    1926          action: 'setkey', 
    2027          keyword: mykey, 
    21           value: $('#' + mykey).val() 
     28          value: myval 
    2229          }, 
    23       beforeSend: function(XMLHttpRequest) { 
     30      beforeSend: function(XMLHttpRequest, set) { 
     31        //console.log('set',set) 
    2432        mythis.attr({src: 'images/spinner.gif'}) 
    2533      }, 
     
    3038        } else { 
    3139          mythis.parent().delay(500).fadeOut(); 
     40        } 
     41         
     42        //reset data-valueinput-orig to new value 
     43        switch (mythis.attr('data-type')) { 
     44          case 'BOOL': 
     45            $('input[name="' + mykey + '"]').attr('data-valueinput-orig', mykey); 
     46            break; 
     47          default: 
     48            var myval = $('#' + mykey).attr('data-valueinput-orig', mykey); 
     49            break; 
    3250        } 
    3351      }, 
     
    4563  $('.valueinput').bind('keyup keypress keydown paste change', function(){ 
    4664    var myel = $(this).parent().next().next(); 
     65    //console.log(myel) 
    4766    if($(this).val() != $(this).attr('data-valueinput-orig')){ 
    4867       
    49       myel.stop(true, true).delay(1000).fadeIn(); 
     68      myel.stop(true, true).delay(500).fadeIn(); 
    5069      //only bind if not already bound 
    5170      if (myel.children(".save").data("events") == undefined 
     
    5473      } 
    5574    } else { 
    56       myel.stop(true, true).delay(1000).fadeOut(); 
     75      myel.stop(true, true).delay(500).fadeOut(); 
    5776      myel.children('.save').unbind('click', savebinder); 
    5877    } 
  • modules/branches/2.9/core/page.advancedsettings.php

    r10994 r11000  
    11<?php /* $Id */ 
    2  
     2$tabindex = isset($tabindex) ? $tabindex : 0; 
    33// TODO: localize if needed 
    44// TODO: Get rid of undefined in http log. Sigh 
     
    99} 
    1010 
     11//dbug('$var',$var); 
    1112if($var['action'] === 'setkey') { 
    12   //set value, then return a value 
    1313  if ($freepbx_conf->conf_setting_exists($var['keyword'])) { 
    14     $freepbx_conf->set_conf_values(array($keyword => $value),true); 
     14    if ($freepbx_conf->set_conf_values(array($var['keyword'] => $var['value']),true)) { 
     15      echo 'ok'; 
     16    } 
    1517  } 
    1618  exit; 
     
    6466      case CONF_TYPE_BOOL: 
    6567?> 
    66   <input class="valueinput" data-valueinput-orig="<?php echo $amp_conf[$c['keyword']]?1:0 ?>" id="<?php echo $c['keyword'] ?>-true" type="radio" name="<?php echo $c['keyword'] ?>" value="1" tabindex="<?php echo ++$tabindex;?>"<?php echo $amp_conf[$c['keyword']]?"checked=\"yes\"":""?>/> 
     68  <input class="valueinput" data-valueinput-orig="<?php echo $amp_conf[$c['keyword']] ? 1 : 0 ?>" id="<?php echo $c['keyword'] ?>-true" type="radio" name="<?php echo $c['keyword'] ?>" value="1" tabindex="<?php echo ++$tabindex;?>"<?php echo $amp_conf[$c['keyword']]?"checked=\"yes\"":""?>/> 
    6769  <label for="<?php echo $c['keyword'] ?>-true"><?php echo _("True") ?></label> 
    68   <input class="valueinput" data-valueinput-orig="<?php echo $amp_conf[$c['keyword']]?1:0 ?>" id="<?php echo $c['keyword'] ?>-false" type="radio" name="<?php echo $c['keyword'] ?>" value="0" tabindex="<?php echo ++$tabindex;?>"<?php echo !$amp_conf[$c['keyword']]?"checked=\"yes\"":""?>/> 
     70  <input class="valueinput" data-valueinput-orig="<?php echo $amp_conf[$c['keyword']] ? 1 : 0 ?>" id="<?php echo $c['keyword'] ?>-false" type="radio" name="<?php echo $c['keyword'] ?>" value="0" tabindex="<?php echo ++$tabindex;?>"<?php echo !$amp_conf[$c['keyword']]?"checked=\"yes\"":""?>/> 
    6971  <label for="<?php echo $c['keyword'] ?>-false"><?php echo _("False") ?></label> 
    7072<?php 
     
    7779    if(!$c['readonly']){ 
    7880      echo '<td><input type="image" class="adv_set_default" src="images/default-option.png" data-key="'.$c['keyword'].'" data-default="'.$c['defaultval'].'" name="default" title="'._('Revert to Default').'"></td>'; 
    79       echo '<td class="savetd"><input type="image" class="save" src="images/accept.png" name="save" data-key="'.$c['keyword'].'" title="'._('Save').'"></td>'; 
    80       //echo '<td><input type="image" class="delete"  src="images/trash.png" name="delete" data-key="'.$c['keyword'].'" title="'._('Delete').'"></td>';  
     81      echo '<td class="savetd"><input type="image" class="save" src="images/accept.png" name="save" data-key="' 
     82        . $c['keyword']  
     83        . '" title="' . _('Save') . '"' 
     84        . 'data-type="' . (($c['type'] == CONF_TYPE_BOOL) ? 'BOOL' : '') . '" '  
     85        . '></td>'; 
    8186    } 
    8287    echo '</tr>';