File:  [mozdev] / annozilla / src / content / annozilla / bindings / languageBindings.xml
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sun Mar 20 14:35:16 2005 UTC (14 years, 5 months ago) by matthew
Branches: MAIN
CVS tags: HEAD, ANNOZILLA-ES-CHANGES, ANNOZILLA-ES, ANNOZILLA-CGH-CHANGES, ANNOZILLA-0-6-7-BRANCH, ANNOZILLA-0-6-7, ANNOZILLA-0-6-6, ANNOZILLA-0-6-5, ANNOZILLA-0-6-1, ANNOZILLA-0-5-4
Move 'bindings' files into their own subdirectory

<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
          xmlns:html="http://www.w3.org/1999/xhtml"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
          type="application/x-javascript">

    <binding id="languageSelector">
        <content>
            <xul:stringbundle src="chrome://global/locale/languageNames.properties" />
            <xul:menulist>
                <xul:menupopup>
                </xul:menupopup>
            </xul:menulist>

        </content>

        <implementation>
            <constructor>
                <![CDATA[
                var bdl = document.getAnonymousNodes(this).item(0);
                var bundle = bdl.stringBundle;

                var languageCodes =  bundle.getSimpleEnumeration();
                var languageCodesArray = new Array();
                var languageNames = new Object();
                while (languageCodes.hasMoreElements()) {
                    var lang = languageCodes.getNext();
                    var prop = lang.QueryInterface
                        (Components.interfaces.nsIPropertyElement);
                    languageCodesArray.push (prop.key);
                    languageNames[prop.key] = prop.value;
                }

                languageCodesArray = languageCodesArray.sort(
                    function (a,b) {
                        if (languageNames[a] < languageNames[b]) return -1;
                        if (languageNames[a] > languageNames[b]) return +1;
                        return 0;
                    }
                );

                var mlist = document.getAnonymousNodes(this).item(1);
                var mpopup = mlist.firstChild;

                for (lcix=0; lcix < languageCodesArray.length; lcix++) {
                    var lc = languageCodesArray[lcix];
                    var languageName = languageNames[lc];

                    var mitem = document.createElementNS
                        ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "xul:menuitem");
                    mitem.setAttribute ("value",lc);
                    mitem.setAttribute ("label",languageName);

                    mpopup.appendChild (mitem);
                }
             ]]>
            </constructor>

            <property name="value" attribute="value"
                type="application/x-javascript">
                <getter>
                    return document.getAnonymousNodes(this).item(1).value;
                </getter>
                <setter>
                    document.getAnonymousNodes(this).item(1).value = val;
                    return val;
                </setter>
            </property>
        </implementation>

    </binding>
</bindings>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>