/**
 *    Copyright 2006 - 2011 Opera Software ASA
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 *
 **/


/**
  * @constructor 
  * @extends ViewBase
  */

var SettingView = function(id, name, container_class)
{
  this.ishidden_in_menu = true;
  this.hidden_in_settings = true;
  this.do_not_reset = true;
  this._sort_by_title = function(a, b)
  {
    return (
    window.views[a].name > window.views[b].name && 1 ||
    window.views[a].name < window.views[b].name && -1 ||
    0);
  }
  this.createView = function(container)
  {
    var views = ViewBase.getSingleViews(['hidden_in_settings']).sort(this._sort_by_title);
    container.render(templates.settings(views));
  }

  this.syncSetting = function(view_id, key_name, is_checked)
  {
    var cs = this.getAllContainers(), c= null, i = 0;
    var inputs = null, input = null, j = 0;
    for( ; c = cs[i]; i++)
    {
      inputs = c.getElementsByTagName('input');
      for( j = 0; input = inputs[j]; j++)
      {
        if( input.getAttribute('view-id') == view_id && input.name == key_name )
        {
          input.checked = is_checked;
        }
      }
    }
  }
  this.init(id, name, container_class);
}

SettingView.prototype = ViewBase;

new SettingView('settings_view', ui_strings.S_BUTTON_LABEL_SETTINGS, 'scroll');
