sbDataRemoteUtils.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25  */
26 
27 //
28 // sbIDataRemote wrapper
29 //
30 // This object provides the ability to set key-value pairs
31 // into a global "data store," and to have various callback
32 // effects occur when anyone changes an observed value.
33 //
34 // The callback binding can be placed on a dom element to
35 // change its properties or attributes based upon the value
36 // (either directly, or as a boolean, and/or as the result
37 // of a given evaluation expression).
38 //
39 // The mozilla preferences system is used as the underlying
40 // data storage layer to power this interface. Because the
41 // preferences are available to all open windows in xulrunner,
42 // these data remotes should function as globals across
43 // the application. This is both powerful and dangerous, and
44 // while this interface is available to all, everyone should
45 // be very careful to properly namespace their data strings.
46 //
47 // SBDataBindElementProperty Param List:
48 // key - The data ID to bind upon
49 // elem - The element ID to be bound
50 // attr - The name of the property or attribute to change
51 // bool - Optionally assign the data as BOOLEAN data (true/false props, "true"/"false" attrs)
52 // not - Optionally assign the data as a boolean NOT of the value
53 // eval - Optionally apply an eval string where `value = eval( eval_string );`
54 
55 Components.utils.import("resource://app/jsmodules/SBDataRemoteUtils.jsm");
56 
57 const SB_NewDataRemote = new Components.Constructor("@songbirdnest.com/Songbird/DataRemote;1", "sbIDataRemote", "init");
58 
78 function SBDataBindElementProperty( aKey, aElement, aProperty, aIsBool, aIsNot, aEvalString )
79 {
80  var retval = null;
81  try {
82  var obj = ( typeof(aElement) == "object" ) ? aElement : document.getElementById( aElement );
83  if ( obj ) {
84  retval = SB_NewDataRemote( aKey, null );
85  retval.bindProperty( obj, aProperty, aIsBool, aIsNot, aEvalString );
86  }
87  else {
88  Components.utils.reportError( "SBDataBindElementProperty: Can't find " + aElement );
89  }
90  }
91  catch ( err ) {
92  Components.utils.reportError( err );
93  }
94  return retval;
95 }
96 
116 function SBDataBindElementAttribute( aKey, aElement, aAttribute, aIsBool, aIsNot, aEvalString )
117 {
118  var retval = null;
119  try {
120  var obj = ( typeof(aElement) == "object" ) ? aElement : document.getElementById( aElement );
121  if ( obj ) {
122  retval = SB_NewDataRemote( aKey, null );
123  retval.bindAttribute( obj, aAttribute, aIsBool, aIsNot, aEvalString );
124  }
125  else {
126  Components.utils.reportError( "SBDataBindElementAttribute: Can't find " + aElement );
127  }
128  }
129  catch ( err ) {
130  Components.utils.reportError( "ERROR! Binding attribute did not succeed.\n" + err + "\n" );
131  }
132  return retval;
133 }
134 
function SBDataBindElementProperty(aKey, aElement, aProperty, aIsBool, aIsNot, aEvalString)
Create a DataRemote and bind an Element's property to the data. This method creates a DataRemote asso...
function SBDataBindElementAttribute(aKey, aElement, aAttribute, aIsBool, aIsNot, aEvalString)
Create a DataRemote and bind an Element's attribute to the data. This method creates a DataRemote ass...
const SB_NewDataRemote
return null
Definition: FeedWriter.js:1143
_getWindowDimension aAttribute