Hi List,

I am currently completely lost on my quest to migrate a simple custom widget.
I've attached the 0.7.4-style class to give an idea of what is should do.

Here's my problem: I'm completely lost somewhere between 'bom', 'dom' and
'html' ;)
I tried to understand the concept by reading the "Custom Widgets"[1]
documentation but somehow I think I am not going into the right direction.

The "widget" I've attached should do the following:
1) Be a singleton...there can be (needs to be) only one
2) Depending on the client engine ("mshtml" vs. "default") insert a
   <bgsound> or a <embed> HTML-Element.
3) Inserts itself (once) into the DOM somewhere

So the widget itself is relatively simple...but as I mentioned above, I'm more
confused than I like to be :-/

Do I really have to implement a class in 'html' *and* 'bom' namespace (like
IFrame or Flash e.g.)?

As you can see, I replaced (removeChild, appendChild) the complete element on
each _syncHtml() call; this might not necessary anymore, because if I am
understanding the new concept correct, I can overwrite the _applyProperty
method, can't I?

Can anybody point me into the right direction?

Thank you in advance,
  Peter


[1] http://qooxdoo.org/documentation/1.0/ui_develop


/**
 * Simple class to play audio directly from the browser.
 */
qx.Class.define("infodesk.ui.sound.Sound",
{
  extend : qx.ui.embed.HtmlEmbed,
  type   : "singleton",




  /*
  *****************************************************************************
     CONSTRUCTOR
  *****************************************************************************
  */

  /**
   * Creates one instance of a sound object
   */
  construct : function()
  {
    this.base(arguments);
    this.addToDocument();
  },




  /*
  *****************************************************************************
     PROPERTIES
  *****************************************************************************
  */

  properties :
  {
    /** URI of the sound to be played */
    uri : {
      check    : "String",
      nullable : true,
      apply    : "_applyHtml"
    }
  },





  /*
  *****************************************************************************
     MEMBERS
  *****************************************************************************
  */

  members :
  {
    /**
     * Play sound.
     * If <code>vUri</code> is omitted, this will play the last sound again.
     *
     * @type member
     * @param vUri {String|null} optional sound URI to play
     * @return {void}
     */
    play : function (vUri)
    {
      if (vUri != null) {
        this.setUri(vUri);
      }

      if (this.isEnabled() && this._isCreated) {
        this._syncHtml();
      }
    },


    /*
    ---------------------------------------------------------------------------
      HTML GENERATOR
    ---------------------------------------------------------------------------
    */

    /**
     * Overwritten. Will be called when the layout managers think it's time to
     * re-layout some DOM code. Here the DOM Element is inserted/updated.
     *
     * @type member
     * @return {void}
     */
    _syncHtml : qx.core.Variant.select("qx.client",
    {
      "mshtml" : function ()
      {
        var html = [];

        html.push('<bgsound id="');
        html.push(this.toHashCode());//needed?
        html.push('" src="');
        html.push(this.getUri()||"");
        html.push('" loop="1" autostart="true"></bgsound>');

        var targetNode = this._getTargetNode();

        if (targetNode.firstChild) { // remove for replacement
          targetNode.removeChild(targetNode.firstChild);
        }

        targetNode.appendChild(document.createElement(html.join("")));
      },
      "default" : function ()
      {
        var html = [];

        html.push('<embed style="height:0" id="');
        html.push(this.toHashCode());//needed?
        html.push('" src="');
        html.push(this.getUri()||"");
        html.push('" loop="false" autostart="true" hidden="true"/>');

        this._getTargetNode().innerHTML = html.join("");
      }
    })

  }

});


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to