/**
 *    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.
 *
 **/





window.cls.InspectableObjectView = function(rt_id, obj_id, name, root)
{
  this.model = new cls.InspectableJSObject(rt_id, obj_id, name);
  this.show_root = root == undefined ? true : false;
  this.expanded = false;
};


window.cls.InspectableObjectView.prototype =
{
  render: function()
  {
    var tpl = window.templates.inspected_js_object(this.model, this.show_root);
    if (!tpl)
    {
      opera.postError(ui_strings.S_DRAGONFLY_INFO_MESSAGE + " Inspectable object template yielded no data");
    }
    return tpl;
  },

  expand: function(cb)
  {
    this.model.expand(function(){this.expanded = true; cb();}.bind(this));
  }
};


window.cls.InspectableDomNodeView = function(rt_id, obj_id, name, root)
{
  this.obj_id = obj_id;
  this.model = new cls.InspectableDOMNode(rt_id, obj_id);
  this.show_root = root == undefined ? true : false;
  this.expanded = false;
};

window.cls.InspectableDomNodeView.prototype =
{

  render: function()
  {
    var tpl = window.templates.inspected_dom_node(this.model, this.show_root);
    return tpl;
  },

  expand: function(cb)
  {
    var obj_id = this.obj_id;
    this.model.expand(function(){this.expanded = true; cb();}.bind(this), obj_id, "subtree");
  }
};
