UNPKG

safeframe

Version:

SafeFrame provides a consistent JS API to include 3rd party content

1,179 lines (642 loc) 30.8 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="generator" content="JsDoc Toolkit" /> <title>$sf.lib.lang | SafeFrames JS API</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <meta name="mobileoptimized" content="0" /> <link rel="stylesheet" href="../css/all.css" media="all" /> <link rel="stylesheet" href="../css/handheld.css" media="only screen and (max-width: 660px)" /> <link rel="stylesheet" href="../css/handheld.css" media="handheld" /> <link rel="stylesheet" href="../css/screen.css" media="screen and (min-width: 661px)" /> <script src="../javascript/all.js"></script> <!--[if lt IE 9]> <script src="../javascript/html5.js"></script> <![endif]--> </head> <body> <div class="index"> <div class="menu"> <div class="indexLinks"> </div> <h2 class="heading1">Classes</h2> <input type="text" name="classFilter" class="classFilter" id="ClassFilter" placeholder="Filter"></input> <nav> <ul class="classList" id="ClassList"> <li><a href="../symbols/%24sf.html">$sf</a></li> <li><a href="../symbols/%24sf.env.html">$sf<span class='break'> </span>.<span class='break'> </span>env</a></li> <li><a href="../symbols/%24sf.env.ua.html">$sf<span class='break'> </span>.<span class='break'> </span>env<span class='break'> </span>.<span class='break'> </span>ua</a></li> <li><a href="../symbols/%24sf.lib.html">$sf<span class='break'> </span>.<span class='break'> </span>lib</a></li> <li><a href="../symbols/%24sf.lib.dom.html">$sf<span class='break'> </span>.<span class='break'> </span>lib<span class='break'> </span>.<span class='break'> </span>dom</a></li> <li><a href="../symbols/%24sf.lib.dom.iframes.html">$sf<span class='break'> </span>.<span class='break'> </span>lib<span class='break'> </span>.<span class='break'> </span>dom<span class='break'> </span>.<span class='break'> </span>iframes</a></li> <li><a href="../symbols/%24sf.lib.dom.msghost.html">$sf<span class='break'> </span>.<span class='break'> </span>lib<span class='break'> </span>.<span class='break'> </span>dom<span class='break'> </span>.<span class='break'> </span>msghost</a></li> <li><a href="../symbols/%24sf.lib.lang.html">$sf<span class='break'> </span>.<span class='break'> </span>lib<span class='break'> </span>.<span class='break'> </span>lang</a></li> <li><a href="../symbols/%24sf.lib.lang.ParamHash.html">$sf<span class='break'> </span>.<span class='break'> </span>lib<span class='break'> </span>.<span class='break'> </span>lang<span class='break'> </span>.<span class='break'> </span>ParamHash</a></li> <li><a href="../symbols/%24sf.pub.html">$sf<span class='break'> </span>.<span class='break'> </span>pub</a></li> <li><a href="../symbols/%24sf.pub.Config.html">$sf<span class='break'> </span>.<span class='break'> </span>pub<span class='break'> </span>.<span class='break'> </span>Config</a></li> <li><a href="../symbols/%24sf.pub.PosConfig.html">$sf<span class='break'> </span>.<span class='break'> </span>pub<span class='break'> </span>.<span class='break'> </span>PosConfig</a></li> <li><a href="../symbols/%24sf.pub.Position.html">$sf<span class='break'> </span>.<span class='break'> </span>pub<span class='break'> </span>.<span class='break'> </span>Position</a></li> <li><a href="../symbols/%24sf.vend.html">$sf<span class='break'> </span>.<span class='break'> </span>vend</a></li> </ul> </nav> </div> <div class="fineprint" style="clear:both"> <footer> Documentation generator: <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0<br /> Template: <a href="" target="_blank">Codeview</a> 1.2.1<br /> Generated on: <time datetime='2012-7-6' pubdate>2012-7-6 16:05</time> </footer> </div> </div> <div class="index indexStatic"></div> <div class="content"> <div class="innerContent"> <article> <header> <h1 class="classTitle"> Namespace <span>$sf.lib.lang</span> </h1> <div class="intro"> <p class="description summary"> $sf.lib.lang Defines helper functions / objects for JavaScript common needs, such as type conversion and object serialization </p> <ul class="summary"> </ul> </div> </header> <!-- #### METHODS SUMMARY --> <section> <div class="props"> <h2 class="sectionTitle">Method Summary</h2> <nav> <table class="summaryTable" id="MethodsList" cellspacing="0" summary="A summary of the methods documented in the class $sf.lib.lang."> <thead> <tr> <th scope="col">Method Attributes</th> <th scope="col">Method Name and Description</th> </tr> </thead> <tbody> <tr class='item0' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.callable">callable</a></b>(A) </div> <div class="description">Checks that a function reference can be called safely.</div> </td> </tr> <tr class='item1' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.cbool">cbool</a></b>(val) </div> <div class="description">Forces type conversion of any JavaScript variable to a boolean.</div> </td> </tr> <tr class='item2' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.cnum">cnum</a></b>(val, defVal, minVal, maxVal) </div> <div class="description">Forces type convertion of any JavaScript variable to a number.</div> </td> </tr> <tr class='item3' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.cstr">cstr</a></b>(str) </div> <div class="description">Forces type conversion of any JavaScript variable to a string value.</div> </td> </tr> <tr class='item4' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.def">def</a></b>(str_ns, aug, root, no_ovr) </div> <div class="description">Define a JavaScript Namespace within a given context</div> </td> </tr> <tr class='item5' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.guid">guid</a></b>(prefix) </div> <div class="description">Generate a unique id string</div> </td> </tr> <tr class='item6' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.jssafe_html">jssafe_html</a></b>(str) </div> <div class="description">Given a string of HTML escape quote marks and seperate script tags so that browsers don't get tripped up during processing.</div> </td> </tr> <tr class='item7' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.mix">mix</a></b>(r, s, owned, skipFuncs, no_ovr) </div> <div class="description">Mixed the properties of one object into another object.</div> </td> </tr> <tr class='item8' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.noop">noop</a></b>() </div> <div class="description">A function reference that does nothing.</div> </td> </tr> <tr class='item9' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.ns">ns</a></b>(str_ns, root) </div> <div class="description">Checks for the existence of a JavaScript namespace as opposed to def, which will automatically define the namespace with a given context.</div> </td> </tr> <tr class='item10' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.rand">rand</a></b>() </div> <div class="description">Return a random integer anywhere from 0 to 99</div> </td> </tr> <tr class='item11' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.time">time</a></b>() </div> <div class="description">Return the current time in milliseconds, from the epoch</div> </td> </tr> <tr class='item12' > <td class="attributes">&lt;static&gt; &nbsp;</td> <td class="nameDescription"> <div class="fixedFont">$sf.lib.lang.<b><a href="../symbols/%24sf.lib.lang.html#.trim">trim</a></b>(str) </div> <div class="description">Trim the begining and ending whitespace from a string.</div> </td> </tr> </tbody> </table> </nav> </div> </section> <!-- #### EVENTS SUMMARY --> <!-- #### CONSTRUCTOR DETAILS --> <!-- #### FIELD DETAILS --> <!-- #### METHOD DETAILS --> <section> <div class="details props"> <div class="innerProps"> <h2 class="sectionTitle"> Method Detail </h2> <ul class="methodDetail" id="MethodDetail"> <li class='item0' > <div class="fixedFont heading" id=".callable"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{Boolean}</span> <span class="light">$sf.lib.lang.</span><b>callable</b>(A) </div> <div class="description"> Checks that a function reference can be called safely. Sometimes function references are part of objects that may have been garbage collected (such as a function reference from another window or dom element). This method checks the reference by making sure it has a constructor and toString properties. Note that this doesn't mean that the function itself when called (or its subsquent call stack), can't throw an error. . . simply that you are able to call it. . . </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <span class="light fixedFont">{Function}</span> <b>A</b> </dt> <dd>reference to a JavaScript function</dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{Boolean}</span> true if function can be called safely, otherwise false.</dd> </dl> <div class="hr"></div> </li> <li class='item1' > <div class="fixedFont heading" id=".cbool"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{Boolean}</span> <span class="light">$sf.lib.lang.</span><b>cbool</b>(val) </div> <div class="description"> Forces type conversion of any JavaScript variable to a boolean. "Falsy" values such as "", 0, null, and undefined all return false String values of "0", "false", "no", "undefined", "null" also return false </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <span class="light fixedFont">{*}</span> <b>val</b> </dt> <dd>Any JavaScript reference / value</dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{Boolean}</span> The normalized boolean value</dd> </dl> <div class="hr"></div> </li> <li class='item2' > <div class="fixedFont heading" id=".cnum"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{Number|NaN|*}</span> <span class="light">$sf.lib.lang.</span><b>cnum</b>(val, defVal, minVal, maxVal) </div> <div class="description"> Forces type convertion of any JavaScript variable to a number. Values / objects that cannot be converted, will be returned as NaN, unless a default value is specified, in which case the default value is used. </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <span class="light fixedFont">{*}</span> <b>val</b> </dt> <dd>Any JavaScript reference / value</dd> <dt> <span class="light fixedFont">{*}</span> <b>defVal</b> <i>Optional</i> </dt> <dd>use this value if original value cannot be converted to a number, or if value is less than min value, or if value is less than max value.</dd> <dt> <span class="light fixedFont">{Number}</span> <b>minVal</b> <i>Optional</i> </dt> <dd>specifies the lowest numerical value, if original value is less than this value, the defVal will be returned.</dd> <dt> <span class="light fixedFont">{Number}</span> <b>maxVal</b> <i>Optional</i> </dt> <dd>specifies the greatest numerical value, if original value is greater than this value, the defVal will be returned.</dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{Number|NaN|*}</span> the converted value, otherwise NaN or default value</dd> </dl> <div class="hr"></div> </li> <li class='item3' > <div class="fixedFont heading" id=".cstr"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{String}</span> <span class="light">$sf.lib.lang.</span><b>cstr</b>(str) </div> <div class="description"> Forces type conversion of any JavaScript variable to a string value. Note that "falsy" values or values that cannot be converted will be returned as an empty string (""). </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <span class="light fixedFont">{*}</span> <b>str</b> </dt> <dd>Any object that needs to be converted to a string value.</dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{String}</span> The normalized string value.</dd> </dl> <div class="hr"></div> </li> <li class='item4' > <div class="fixedFont heading" id=".def"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{Object}</span> <span class="light">$sf.lib.lang.</span><b>def</b>(str_ns, aug, root, no_ovr) </div> <div class="description"> Define a JavaScript Namespace within a given context </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <span class="light fixedFont">{String}</span> <b>str_ns</b> </dt> <dd>The name of the namespace in dot notation as a string (e.g. "Foo.bar")</dd> <dt> <span class="light fixedFont">{Object}</span> <b>aug</b> <i>Optional</i> </dt> <dd>defines the object at the end of the namespace. If namespace is already specified, and this object is provided, the namespace will be augmented with properties from this object. If nothing is passed in, defaults to using an empty object.</dd> <dt> <span class="light fixedFont">{Object}</span> <b>root</b> <i>Optional</i> </dt> <dd>the root object from which the namespace is defined. If not passed in defaults to the global/window object</dd> <dt> <span class="light fixedFont">{Boolean}</span> <b>no_ovr</b> <i>Optional</i> </dt> <dd>if true, properties already defined on root with the same name will be ignored</dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{Object}</span> The object at the end of the namespace</dd> </dl> <div class="hr"></div> </li> <li class='item5' > <div class="fixedFont heading" id=".guid"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{String}</span> <span class="light">$sf.lib.lang.</span><b>guid</b>(prefix) </div> <div class="description"> Generate a unique id string </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <span class="light fixedFont">{String}</span> <b>prefix</b> <i>Optional</i> </dt> <dd>a substring to use a prefix</dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{String}</span> unique id string</dd> </dl> <div class="hr"></div> </li> <li class='item6' > <div class="fixedFont heading" id=".jssafe_html"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{String}</span> <span class="light">$sf.lib.lang.</span><b>jssafe_html</b>(str) </div> <div class="description"> Given a string of HTML escape quote marks and seperate script tags so that browsers don't get tripped up during processing. </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <span class="light fixedFont">{String}</span> <b>str</b> </dt> <dd>A string of HTML markup to be processed</dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{String}</span> </dd> </dl> <div class="hr"></div> </li> <li class='item7' > <div class="fixedFont heading" id=".mix"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{Object}</span> <span class="light">$sf.lib.lang.</span><b>mix</b>(r, s, owned, skipFuncs, no_ovr) </div> <div class="description"> Mixed the properties of one object into another object. Note that this function is recursive </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <span class="light fixedFont">{Object}</span> <b>r</b> </dt> <dd>The object that will receive properties</dd> <dt> <span class="light fixedFont">{Object}</span> <b>s</b> </dt> <dd>The object that will deliever properties</dd> <dt> <span class="light fixedFont">{Boolean}</span> <b>owned</b> <i>Optional</i> </dt> <dd>Whether or not to skip over properties that are part of the object prototype</dd> <dt> <span class="light fixedFont">{Boolean}</span> <b>skipFuncs</b> <i>Optional</i> </dt> <dd>Whether or not to skip over function references</dd> <dt> <span class="light fixedFont">{Boolean}</span> <b>no_ovr</b> <i>Optional</i> </dt> <dd>Whether or not to overwrite properties that may have already been filled out</dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{Object}</span> The receiver object passed in with potentially new properties added</dd> </dl> <div class="hr"></div> </li> <li class='item8' > <div class="fixedFont heading" id=".noop"> <span class='lighter'> &lt;static&gt; </span> <span class="light">$sf.lib.lang.</span><b>noop</b>() </div> <div class="description"> A function reference that does nothing. </div> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd>undefined</dd> </dl> <div class="hr"></div> </li> <li class='item9' > <div class="fixedFont heading" id=".ns"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{*}</span> <span class="light">$sf.lib.lang.</span><b>ns</b>(str_ns, root) </div> <div class="description"> Checks for the existence of a JavaScript namespace as opposed to def, which will automatically define the namespace with a given context. </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <span class="light fixedFont">{String}</span> <b>str_ns</b> </dt> <dd>A string with . or [] notation of a JavaScript namesace (e.g. "foo.bar.show", or "foo['bar']['show']").</dd> <dt> <span class="light fixedFont">{Object}</span> <b>root</b> <i>Optional</i> </dt> <dd>the root object to check within. .defaults to global / window</dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{*}</span> The endpoint reference of the namespace or false if not found</dd> </dl> <div class="hr"></div> </li> <li class='item10' > <div class="fixedFont heading" id=".rand"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{Number}</span> <span class="light">$sf.lib.lang.</span><b>rand</b>() </div> <div class="description"> Return a random integer anywhere from 0 to 99 </div> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{Number}</span> random number</dd> </dl> <div class="hr"></div> </li> <li class='item11' > <div class="fixedFont heading" id=".time"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{Number}</span> <span class="light">$sf.lib.lang.</span><b>time</b>() </div> <div class="description"> Return the current time in milliseconds, from the epoch </div> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{Number}</span> current time</dd> </dl> <div class="hr"></div> </li> <li class='item12' > <div class="fixedFont heading" id=".trim"> <span class='lighter'> &lt;static&gt; </span> <span class="light">{String}</span> <span class="light">$sf.lib.lang.</span><b>trim</b>(str) </div> <div class="description"> Trim the begining and ending whitespace from a string. Note that this function will convert an argument to a string first for type safety purposes. If string cannot be converted, and empty string is returned </div> <dl class="detailList params"> <dt class="heading">Parameters:</dt> <dt> <b>str</b> </dt> <dd></dd> </dl> <dl class="detailList nomargin"> <dt class="heading">Returns:</dt> <dd><span class="light fixedFont">{String}</span> trimmed string</dd> </dl> </li> </ul> </div> </div> </section> <!-- #### EVENT DETAILS --> </article> </div> </div> <script type="text/javascript"> wbos.CssTools.MediaQueryFallBack.LoadCss('../css/screen.css', '../css/handheld.css', 660) codeview.classFilter.Init() </script> </body> </html>