Changeset 13481

Show
Ignore:
Timestamp:
02/20/12 07:01:29 (1 year ago)
Author:
mbrevda
Message:

upstream changes, make colapsible gui eleent section actually work

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.10/amp_conf/htdocs/admin/assets/js/script.legacy.js

    r12976 r13481  
    723723    var txt = $(this).find('.guielToggleBut'); 
    724724    var el = $(this).data('toggle_class'); 
     725    var section = $.urlParam('display') + '#' + el; 
     726     
     727    //true = hide 
     728    //false = dont hide 
    725729    switch(txt.text().replace(/ /g,'')) { 
    726730      case '-': 
    727731        txt.text('+ '); 
    728         $('.'+el).hide() 
     732        $('.' + el).hide(); 
     733   
     734        //set cookie of hidden section 
     735        guielToggle = $.parseJSON($.cookie('guielToggle')) || {}; 
     736        guielToggle[section] = false; 
     737        $.cookie('guielToggle', JSON.stringify(guielToggle)); 
    729738        break; 
    730739      case '+': 
    731740        txt.text('-  '); 
    732741        $('.'+el).show(); 
     742         
     743        //set cookie of hidden section 
     744        guielToggle = $.parseJSON($.cookie('guielToggle')) || {}; 
     745        if (guielToggle.hasOwnProperty(section)){ 
     746          guielToggle[section] = true; 
     747          $.cookie('guielToggle', JSON.stringify(guielToggle)); 
     748        } 
    733749        break; 
    734750    } 
  • freepbx/branches/2.10/amp_conf/htdocs/admin/config.php

    r13119 r13481  
    241241if ($display != '' && isset($configpageinits) && is_array($configpageinits) ) { 
    242242 
    243   $currentcomponent = new component($display,$type); 
    244  
     243  $CC = $currentcomponent = new component($display,$type); 
    245244  // call every modules _configpageinit function which should just 
    246245  // register the gui and process functions for each module, if relevant 
  • freepbx/branches/2.10/amp_conf/htdocs/admin/libraries/components.class.php

    r12995 r13481  
    2727 
    2828  function component($compname, $type = 'setup') { 
     29    global $display; 
    2930    $this->_compname = $compname; 
    3031    $this->_type = $type; 
     
    3435    $this->_sorted_guifuncs = true; 
    3536    $this->_sorted_processfuncs = true; 
     37     
     38    //set section to hidden if requested by user 
     39    $user_hidden = isset($_COOKIE['guielToggle']) ? json_decode($_COOKIE['guielToggle']) : array(); 
     40    foreach($user_hidden as $k => $v) { 
     41      list($page, $section) = explode('#', $k); 
     42      if ($page == $display) { 
     43        $this->_opts[$section]['guielToggle'] = $v ? true :false; 
     44      } 
     45    } 
     46  } 
     47   
     48  /* 
     49   * Toggle open state 
     50   * true = open, false = closed 
     51   * wont over write a users settings 
     52   */ 
     53  function sectionToggle($section, $state = false) { 
     54    $section = preg_replace('/[^A-Za-z]/', '' ,$section); 
     55    if (!isset($this->_opts[$section]['guielToggle'])) { 
     56      $this->_opts[$section]['guielToggle'] = $state; 
     57    } 
    3658  } 
    3759   
     
    284306      $this->sortguielems(); 
    285307 
     308 
    286309    // Start of form 
    287310     
     
    306329      } 
    307330    } 
    308      
     331 
    309332    // Middle 
    310333    if ( is_array($this->_guielems_middle) ) { 
     
    318341          $htmlout .= "\t\t<td colspan=\"2\">"; 
    319342          if ($section) { 
    320             $state = isset($this_opts[$section]['guielToggle']) && $this_opts[$section]['guielToggle'] == true  
    321                 ? '+' : '-  '; 
     343            $mysec = preg_replace('/[^A-Za-z]/', '' ,$section); 
     344            $state = isset($this->_opts[$mysec]['guielToggle']) && $this->_opts[$mysec]['guielToggle'] == false 
     345                ? '+' : '-  '; 
    322346            $htmlout .= "<h5>"  
    323347                . "<span class=\"guielToggleBut\">$state</span>"  
     
    456480  var $_html; 
    457481  var $_javascript; 
    458  
     482  var $_opts; 
     483   
    459484  function guielement($elemname, $html = '', $javascript = '') { 
     485    global $CC; 
    460486    // name that will be the id tag 
    461487    $this->_elemname = $elemname; 
     
    466492    $this->_html = $html; 
    467493    $this->_javascript = $javascript; 
     494     
     495 
     496    $this->_opts = & $CC->_opts; 
    468497  } 
    469498   
     
    524553   
    525554  function guiinput($elemname, $currentvalue = '', $prompttext = '', $helptext = '', $jsvalidation = '', $failvalidationmsg = '', $canbeempty = true, $jsvalidationtest='') { 
     555 
    526556    // call parent class contructor 
    527557    guielement::guielement($elemname, '', ''); 
     
    581611    // start new row 
    582612    if ($section) { 
    583       $output .= "\t<tr class=\"$section\">\n"; 
     613      $mysec = preg_replace('/[^A-Za-z]/', '' ,$section); 
     614      $output .= '<tr class="' . $section . '" ' 
     615          . ((isset($this->_opts[$mysec]['guielToggle']) && $this->_opts[$mysec]['guielToggle'] == false)  
     616            ? ' style="display:none" '  
     617            : '') 
     618          .' >' . "\n"; 
    584619    } else { 
    585620      $output .= "\t<tr>\n"; 
     
    775810    // this effectivly creates the template using the html_text 
    776811    // we would expect the $html_text to be set by the child class 
    777  
     812     
    778813    $output = ''; 
    779814     
    780815    // start new row 
    781816    if ($section) { 
    782       $output .= "\t<tr class=\"$section\">\n"; 
     817      $mysec = preg_replace('/[^A-Za-z]/', '' ,$section); 
     818      $output .= '<tr class="' . $section . '" ' 
     819          . ((isset($this->_opts[$mysec]['guielToggle']) && $this->_opts[$mysec]['guielToggle'] == false)  
     820            ? ' style="display:none" '  
     821            : '') 
     822          .' >' . "\n"; 
    783823    } else { 
    784824      $output .= "\t<tr>\n"; 
     
    838878class gui_link extends guitext { 
    839879  function gui_link($elemname, $text, $url, $uselang = true) { 
     880     
    840881    // call parent class contructor 
    841882    $parent_class = get_parent_class($this); 
  • freepbx/branches/2.10/amp_conf/htdocs/admin/views/footer.php

    r13443 r13481  
    147147 
    148148//add IE specifc styling polyfills 
    149 $html .= '<!--[if lte IE 10]>'; 
    150 $html .= '<link rel="stylesheet" href="assets/css/progress-polyfill.css" type="text/css">'; 
    151 $html .= '<script type="text/javascript" src="assets/js/progress-polyfill.min.js"></script>'; 
    152 $html .= '<![endif]-->'; 
     149if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { 
     150  $html .= '<!--[if lte IE 10]>'; 
     151  $html .= '<link rel="stylesheet" href="assets/css/progress-polyfill.css" type="text/css">'; 
     152  $html .= '<script type="text/javascript" src="assets/js/progress-polyfill.min.js"></script>'; 
     153  $html .= '<![endif]-->'; 
     154 
     155  //offer google chrome frame for the richest experience 
     156  $html .= <<<END 
     157  <!--[if IE]> 
     158    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script> 
     159    <script> 
     160      !$.cookie('skip_cf_check') //skip check if skip_cf_check cookie is active 
     161        && CFInstall  //make sure CFInstall is loaded  
     162        && !!window.attachEvent //attachEvent is ie only, should never fire in other browsers 
     163        && window.attachEvent("onload", function() { 
     164         CFInstall.check({ 
     165          preventPrompt: true, 
     166          onmissing: function() { 
     167            $('<div></div>') 
     168              .html('Unfortunately, some features may not work correctly in your ' 
     169                + 'current browser. We suggest that you activate Chrome Frame, ' 
     170                + 'which will offer you the richest posible experience. ') 
     171              .dialog({ 
     172                title: 'Activate Chrome Frame', 
     173                resizable: false, 
     174                modal: true, 
     175                position: ['center', 'center'], 
     176                close: function (e) { 
     177                  $.cookie('skip_cf_check', 'true'); 
     178                  $(e.target).dialog("destroy").remove(); 
     179                }, 
     180                buttons: [ 
     181                  { 
     182                    text: 'Activate', 
     183                    click: function() { 
     184                        window.location = 'http://www.google.com/chromeframe/?redirect=true'; 
     185                    } 
     186 
     187                  }, 
     188                  { 
     189                    text: fpbx.msg.framework.cancel, 
     190                    click: function() { 
     191                        //set cookie to prevent prompting again in this session 
     192                        $.cookie('skip_cf_check', 'true'); 
     193                        $(this).dialog("destroy").remove(); 
     194                      } 
     195                  } 
     196                  ] 
     197              }); 
     198          } 
     199        }); 
     200 
     201      }); 
     202  </script> 
     203  <![endif]--> 
     204END; 
     205
     206 
    153207 
    154208//offer google chrome frame for the richest experience