Annotation of autoform/www/jsdoc/overview-summary-preferences_elements_ListPreference.js.html, revision 1.1

1.1     ! kessler     1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
        !             2: <HTML>
        !             3: <HEAD>
        !             4: <TITLE>
        !             5: autoform.mozdev.org Overview
        !             6: </TITLE>
        !             7: <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
        !             8: <SCRIPT>
        !             9: function asd()
        !            10: {
        !            11: parent.document.title=" Overview";
        !            12: }
        !            13: </SCRIPT>
        !            14: </HEAD>
        !            15: <BODY BGCOLOR="white" onload="asd();">
        !            16: 
        !            17: <!-- ========== START OF NAVBAR ========== -->
        !            18: <A NAME="navbar_top"><!-- --></A>
        !            19: <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
        !            20: <TR>
        !            21: <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
        !            22: <A NAME="navbar_top_firstrow"><!-- --></A>
        !            23: <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
        !            24:   <TR ALIGN="center" VALIGN="top">
        !            25:   
        !            26:   
        !            27:   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-summary.html"><FONT CLASS="NavBarFont1"><b>Overview</b></FONT></A>&nbsp;</TD>
        !            28:   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev">        &nbsp;<FONT CLASS="NavBarFont1Rev"><b>File</b></FONT>&nbsp;</TD>
        !            29:   
        !            30: 
        !            31:   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1">   <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
        !            32:   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><b>Tree</b></FONT></A>&nbsp;</TD>
        !            33:   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-all.html"--><FONT CLASS="NavBarFont1"><b>Index</b></FONT></A>&nbsp;</TD>
        !            34:   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><b>Help</b></FONT></A>&nbsp;</TD>
        !            35:   </TR>
        !            36: </TABLE>
        !            37: </TD>
        !            38: <TD BGCOLOR="#EEEEFF" ALIGN="right" VALIGN="top">
        !            39: <EM>
        !            40: <b>autoform.mozdev.org</b></EM>
        !            41: </TD>
        !            42: </TR>
        !            43: 
        !            44: <TR>
        !            45: <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
        !            46: &nbsp;PREV&nbsp;
        !            47: &nbsp;NEXT</FONT></TD>
        !            48: <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
        !            49:   <A HREF="index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;
        !            50: &nbsp;<A HREF="overview-summary.html" TARGET="_top"><B>NO FRAMES</B></A>
        !            51: &nbsp;&nbsp;
        !            52: <SCRIPT>
        !            53:   <!--
        !            54:   if(window==top) {
        !            55:     document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
        !            56:   }
        !            57:   //-->
        !            58: </SCRIPT>
        !            59: <NOSCRIPT>
        !            60: <A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>
        !            61: </NOSCRIPT>
        !            62: </FONT></TD>
        !            63: </TR>
        !            64: </TABLE>
        !            65: <!-- =========== END OF NAVBAR =========== -->
        !            66: 
        !            67: <HR>
        !            68: <CENTER>
        !            69: 
        !            70:    <H2>preferences/elements/ListPreference.js</H2>
        !            71: 
        !            72: </CENTER>
        !            73:         
        !            74:             
        !            75:         
        !            76:         
        !            77:         <h4>Summary</h4>
        !            78:         <p>
        !            79:         
        !            80:            No overview generated for 'preferences/elements/ListPreference.js'<BR/><BR/>
        !            81:            
        !            82:         </p>
        !            83: 
        !            84: <HR>
        !            85: 
        !            86: 
        !            87: 
        !            88: 
        !            89: <!-- START SOURCECODE -->
        !            90: <pre class="sourceview">
        !            91: <span class="comment">/* ***** BEGIN LICENSE BLOCK *****
        !            92:  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
        !            93:  *
        !            94:  * The contents of this file are subject to the Mozilla Public License Version
        !            95:  * 1.1 (the "License"); you may not use this file except in compliance with
        !            96:  * the License. You may obtain a copy of the License at
        !            97:  * http://www.mozilla.org/MPL/
        !            98:  *
        !            99:  * Software distributed under the License is distributed on an "AS IS" basis,
        !           100:  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
        !           101:  * for the specific language governing rights and limitations under the
        !           102:  * License.
        !           103:  *
        !           104:  * The Original Code is from autoform.
        !           105:  *
        !           106:  * The Initial Developer of the Original Code is
        !           107:  * Michael Kessler, Bluewin AG &lt;michael.kessler<span class="attrib">@team</span>.bluewin.com&gt;.
        !           108:  * Portions created by the Initial Developer are Copyright (C) 2005
        !           109:  * the Initial Developer. All Rights Reserved.
        !           110:  *
        !           111:  * Contributor(s):
        !           112:  *
        !           113:  * Alternatively, the contents of this file may be used under the terms of
        !           114:  * either the GNU General Public License Version 2 or later (the "GPL"), or
        !           115:  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
        !           116:  * in which case the provisions of the GPL or the LGPL are applicable instead
        !           117:  * of those above. If you wish to allow use of your version of this file only
        !           118:  * under the terms of either the GPL or the LGPL, and not to allow others to
        !           119:  * use your version of this file under the terms of the MPL, indicate your
        !           120:  * decision by deleting the provisions above and replace them with the notice
        !           121:  * and other provisions required by the GPL or the LGPL. If you do not delete
        !           122:  * the provisions above, a recipient may use your version of this file under
        !           123:  * the terms of any one of the MPL, the GPL or the LGPL.
        !           124:  *
        !           125:  * ***** END LICENSE BLOCK ***** */</span>
        !           126: 
        !           127:  <span class="comment">/**
        !           128:  * Manages list style preferences.
        !           129:  * Represents a XUL listbox element.
        !           130:  * Provides template methods for 
        !           131:  * different implementations (user listbox
        !           132:  * and regexp user context preferences)
        !           133:  *
        !           134:  * <span class="attrib">@param</span> elementId the xul element id in the dialog
        !           135:  *
        !           136:  * <span class="attrib">@constructor</span>
        !           137:  */</span>
        !           138: <span class="reserved">function</span> ListPreference(elementId) {
        !           139: <span class="comment">
        !           140:    // inherit</span>
        !           141:    <span class="reserved">this</span>.superclass = PreferencesService;
        !           142:    <span class="reserved">this</span>.superclass();
        !           143:    
        !           144:    <span class="reserved">this</span>.elementId = elementId;
        !           145:    
        !           146:    <span class="comment">/**
        !           147:     * put preference values to its gui representation
        !           148:     */</span>
        !           149:    <span class="reserved">this</span>.loadElement = <span class="reserved">function</span>() {
        !           150: <span class="comment">      // clear list</span>
        !           151:       var listBox = document.getElementById(<span class="reserved">this</span>.elementId);
        !           152:       <span class="reserved">while</span>(listBox.getRowCount() != 0) {
        !           153:          listBox.removeItemAt(0);
        !           154:       }
        !           155: <span class="comment">      // load values</span>
        !           156:       var prefs = <span class="reserved">this</span>.getListBranch();
        !           157:       var count = { value : 0 };
        !           158:       var childList = prefs.getChildList(<span class="literal">""</span>, count);      
        !           159:       <span class="reserved">for</span>(i = 0; i &lt; count.value; i++) {
        !           160:          listBox.appendItem(prefs.getCharPref(childList[i]), childList[i]);
        !           161:       }
        !           162:    };
        !           163: 
        !           164:    <span class="comment">/**
        !           165:     * store list entry to the preference store
        !           166:     */</span>
        !           167:    <span class="reserved">this</span>.saveElement = <span class="reserved">function</span>() {
        !           168: <span class="comment">      // clear branch</span>
        !           169:       var prefs = <span class="reserved">this</span>.getListBranch();
        !           170:       prefs.deleteBranch(<span class="literal">""</span>);
        !           171: <span class="comment">      // save values</span>
        !           172:       var listBox = document.getElementById(<span class="reserved">this</span>.elementId);
        !           173:       <span class="reserved">for</span>(i = 0; i &lt; listBox.getRowCount(); i++) {
        !           174:          prefs.setCharPref(listBox.getItemAtIndex(i).value, listBox.getItemAtIndex(i).label);
        !           175:       }
        !           176:    }
        !           177:    
        !           178:    <span class="comment">/**
        !           179:     * returns the list values as array
        !           180:     */</span>
        !           181:    <span class="reserved">this</span>.getValueArray = <span class="reserved">function</span>() {
        !           182: <span class="comment">      // load values</span>
        !           183:       var prefs = <span class="reserved">this</span>.getListBranch();
        !           184:       var count = { value : 0 };
        !           185:       var childList = prefs.getChildList(<span class="literal">""</span>, count); 
        !           186:       var valueArray = new Array(count.value);     
        !           187:       <span class="reserved">for</span>(i = 0; i &lt; count.value; i++) {
        !           188:          valueArray[i] = prefs.getCharPref(childList[i]);
        !           189:       }
        !           190:       <span class="reserved">return</span> valueArray;
        !           191:    };
        !           192: 
        !           193:    <span class="comment">/**
        !           194:     * add a new list entry
        !           195:     */</span>
        !           196:    <span class="reserved">this</span>.addEntry = <span class="reserved">function</span>() {
        !           197:       var value = window.prompt(<span class="reserved">this</span>.stringBundle.getString(<span class="literal">"addentry"</span>), <span class="literal">""</span>);
        !           198:       <span class="reserved">if</span> (!<span class="reserved">this</span>.validateEntry(value)) {
        !           199:          <span class="reserved">return</span>;
        !           200:       }
        !           201:       <span class="reserved">if</span> (value != <span class="literal">""</span>) {
        !           202:          var listBox = document.getElementById(<span class="reserved">this</span>.elementId);
        !           203:          listBox.appendItem(value, <span class="reserved">this</span>.elementId + listBox.getRowCount());
        !           204:          <span class="reserved">this</span>.saveElement();
        !           205:       }
        !           206:    }
        !           207:    
        !           208:    <span class="comment">/**
        !           209:     * edit the selected list entry
        !           210:     */</span>
        !           211:    <span class="reserved">this</span>.editEntry = <span class="reserved">function</span>() {
        !           212:       var listBox = document.getElementById(<span class="reserved">this</span>.elementId);
        !           213:       <span class="reserved">for</span>(i = 0; i &lt; listBox.selectedCount; i++) {
        !           214:          var selectedItem = listBox.getSelectedItem(i);
        !           215:          var value = window.prompt(<span class="reserved">this</span>.stringBundle.getString(<span class="literal">"editentry"</span>), selectedItem.label);
        !           216:          <span class="reserved">if</span> (!<span class="reserved">this</span>.validateEntry(value)) {
        !           217:             <span class="reserved">return</span>;
        !           218:          }
        !           219:          <span class="reserved">if</span> (value != <span class="literal">""</span>) {
        !           220:             selectedItem.label = value;
        !           221:             <span class="reserved">this</span>.saveElement();
        !           222:          }
        !           223:       }
        !           224:    }
        !           225:    
        !           226:    <span class="comment">/**
        !           227:     * remove the selected list entry
        !           228:     */</span>
        !           229:    <span class="reserved">this</span>.removeEntry = <span class="reserved">function</span>() {
        !           230:       var listBox = document.getElementById(<span class="reserved">this</span>.elementId);
        !           231:       <span class="reserved">for</span>(i = 0; i &lt; listBox.selectedCount; i++) {
        !           232:          listBox.removeItemAt(listBox.getIndexOfItem(listBox.getSelectedItem(i)));
        !           233:       }
        !           234:    }
        !           235:    
        !           236:    <span class="comment">/**
        !           237:     * returns the list branch
        !           238:     * Template method for subclasses
        !           239:     */</span>
        !           240:    <span class="reserved">this</span>.getListBranch = <span class="reserved">function</span>() {
        !           241:       <span class="reserved">return</span> <span class="reserved">this</span>.getUserPreferenceStoreBranch(<span class="reserved">this</span>.elementId);
        !           242:    }
        !           243:    
        !           244:    <span class="comment">/**
        !           245:     * validate list entry 
        !           246:     * Template method for subclasses
        !           247:     */</span>
        !           248:    <span class="reserved">this</span>.validateEntry = <span class="reserved">function</span>(value) {
        !           249: <span class="comment">      //template method accepts everything</span>
        !           250:       <span class="reserved">return</span> true;
        !           251:    }
        !           252:    
        !           253:    <span class="comment">/**
        !           254:     * string representation
        !           255:     */</span>
        !           256:    <span class="reserved">this</span>.toString = <span class="reserved">function</span>() {
        !           257:       <span class="reserved">return</span> <span class="literal">"ListPreference "</span> + <span class="reserved">this</span>.elementId + <span class="literal">" = "</span> + <span class="reserved">this</span>.getValueArray();
        !           258:    };
        !           259: } 
        !           260: <span class="comment">
        !           261: 
        !           262: // inherit</span>
        !           263: ListPreference.<span class="reserved">prototype</span> = new PreferencesService();
        !           264: 
        !           265: </pre>
        !           266: <!-- END SOURCECODE -->
        !           267: <HR>
        !           268: 
        !           269: 
        !           270: 
        !           271: 
        !           272: <!-- ========== START OF NAVBAR ========== -->
        !           273: <A NAME="navbar_top"><!-- --></A>
        !           274: <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
        !           275: <TR>
        !           276: <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
        !           277: <A NAME="navbar_top_firstrow"><!-- --></A>
        !           278: <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
        !           279:   <TR ALIGN="center" VALIGN="top">
        !           280:   
        !           281:   
        !           282:   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-summary.html"><FONT CLASS="NavBarFont1"><b>Overview</b></FONT></A>&nbsp;</TD>
        !           283:   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev">        &nbsp;<FONT CLASS="NavBarFont1Rev"><b>File</b></FONT>&nbsp;</TD>
        !           284:   
        !           285: 
        !           286:   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
        !           287:   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><b>Tree</b></FONT></A>&nbsp;</TD>
        !           288:   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-all.html"--><FONT CLASS="NavBarFont1"><b>Index</b></FONT></A>&nbsp;</TD>
        !           289:   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><b>Help</b></FONT></A>&nbsp;</TD>
        !           290:   </TR>
        !           291: </TABLE>
        !           292: </TD>
        !           293: <TD BGCOLOR="#EEEEFF" ALIGN="right" VALIGN="top"><EM>
        !           294: <b>autoform.mozdev.org</b></EM>
        !           295: </TD>
        !           296: </TR>
        !           297: 
        !           298: <TR>
        !           299: <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
        !           300: &nbsp;PREV&nbsp;
        !           301: &nbsp;NEXT</FONT></TD>
        !           302: <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
        !           303:   <A HREF="index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;
        !           304: &nbsp;<A HREF="overview-summary.html" TARGET="_top"><B>NO FRAMES</B></A>
        !           305: &nbsp;&nbsp;
        !           306: <SCRIPT>
        !           307:   <!--
        !           308:   if(window==top) {
        !           309:     document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
        !           310:   }
        !           311:   //-->
        !           312: </SCRIPT>
        !           313: <NOSCRIPT>
        !           314: <A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>
        !           315: </NOSCRIPT>
        !           316: </FONT></TD>
        !           317: </TR>
        !           318: </TABLE>
        !           319: <!-- =========== END OF NAVBAR =========== -->
        !           320: 
        !           321: <hr>
        !           322: <FONT SIZE="-1">
        !           323: 
        !           324: </FONT>
        !           325: <div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/">JSDoc</a> on Wed Mar 30 16:06:04 2005</div>
        !           326: </BODY>
        !           327: </HTML>

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