Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

571 linhas
26 KiB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Javascript Utilities &mdash; Documentation</title>
  7. <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '',
  12. VERSION: '',
  13. COLLAPSE_MODINDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="_static/jquery.js"></script>
  19. <script type="text/javascript" src="_static/doctools.js"></script>
  20. <link rel="top" title="Documentation" href="index.html" />
  21. <link rel="up" title="4. Client Side API" href="client_side_widgets.html" />
  22. <link rel="next" title="Page Structure and Navigation" href="navigation.html" />
  23. <link rel="prev" title="Autosuggest" href="autosuggest.html" />
  24. </head>
  25. <body>
  26. <div style="background-color: #FFF; text-align: left; padding: 8px 0px"><img src="_static/banner300910.gif"></div>
  27. <div class="related">
  28. <h3>Navigation</h3>
  29. <ul>
  30. <li class="right" style="margin-right: 10px">
  31. <a href="genindex.html" title="General Index"
  32. accesskey="I">index</a></li>
  33. <li class="right" >
  34. <a href="modindex.html" title="Global Module Index"
  35. accesskey="M">modules</a> |</li>
  36. <li class="right" >
  37. <a href="navigation.html" title="Page Structure and Navigation"
  38. accesskey="N">next</a> |</li>
  39. <li class="right" >
  40. <a href="autosuggest.html" title="Autosuggest"
  41. accesskey="P">previous</a> |</li>
  42. <li><a href="index.html">Documentation</a> &raquo;</li>
  43. <li><a href="client_side_widgets.html" accesskey="U">4. Client Side API</a> &raquo;</li>
  44. </ul>
  45. </div>
  46. <div class="sphinxsidebar">
  47. <div class="sphinxsidebarwrapper">
  48. <h3><a href="index.html">Table Of Contents</a></h3>
  49. <ul>
  50. <li><a class="reference external" href="">Javascript Utilities</a><ul>
  51. <li><a class="reference external" href="#ajax-server-calls">AJAX - Server Calls</a></li>
  52. <li><a class="reference external" href="#title">Title</a></li>
  53. <li><a class="reference external" href="#events">Events</a></li>
  54. <li><a class="reference external" href="#string">String</a></li>
  55. <li><a class="reference external" href="#lists">Lists</a></li>
  56. <li><a class="reference external" href="#dictionaries">Dictionaries</a></li>
  57. <li><a class="reference external" href="#datatype-conversion">Datatype Conversion</a></li>
  58. <li><a class="reference external" href="#dom-manipulation">DOM Manipulation</a></li>
  59. <li><a class="reference external" href="#style">Style</a></li>
  60. <li><a class="reference external" href="#tables">Tables</a></li>
  61. <li><a class="reference external" href="#select-element">Select Element</a></li>
  62. <li><a class="reference external" href="#positioning">Positioning</a></li>
  63. <li><a class="reference external" href="#url">URL</a></li>
  64. <li><a class="reference external" href="#user-image">User Image</a></li>
  65. <li><a class="reference external" href="#miscelleanous">Miscelleanous</a></li>
  66. </ul>
  67. </li>
  68. </ul>
  69. <h4>Previous topic</h4>
  70. <p class="topless"><a href="autosuggest.html"
  71. title="previous chapter">Autosuggest</a></p>
  72. <h4>Next topic</h4>
  73. <p class="topless"><a href="navigation.html"
  74. title="next chapter">Page Structure and Navigation</a></p>
  75. <h3>This Page</h3>
  76. <ul class="this-page-menu">
  77. <li><a href="_sources/javascript_utils.txt"
  78. rel="nofollow">Show Source</a></li>
  79. </ul>
  80. <div id="searchbox" style="display: none">
  81. <h3>Quick search</h3>
  82. <form class="search" action="search.html" method="get">
  83. <input type="text" name="q" size="18" />
  84. <input type="submit" value="Go" />
  85. <input type="hidden" name="check_keywords" value="yes" />
  86. <input type="hidden" name="area" value="default" />
  87. </form>
  88. <p class="searchtip" style="font-size: 90%">
  89. Enter search terms or a module, class or function name.
  90. </p>
  91. </div>
  92. <script type="text/javascript">$('#searchbox').show(0);</script>
  93. </div>
  94. </div>
  95. <div class="document">
  96. <div class="documentwrapper">
  97. <div class="bodywrapper">
  98. <div class="body">
  99. <div class="section" id="javascript-utilities">
  100. <h1>Javascript Utilities<a class="headerlink" href="#javascript-utilities" title="Permalink to this headline">¶</a></h1>
  101. <div class="section" id="ajax-server-calls">
  102. <h2>AJAX - Server Calls<a class="headerlink" href="#ajax-server-calls" title="Permalink to this headline">¶</a></h2>
  103. <dl class="function">
  104. <dt>
  105. <tt class="descname">$c(command, args, call_back, on_timeout, no_spinner, freeze_msg)</tt></dt>
  106. <dd><p>call a function on the server, where</p>
  107. <ul class="simple">
  108. <li><cite>cmd</cite> is the command to the handler</li>
  109. <li><cite>args</cite> dictionary of arguments (form data)</li>
  110. <li><cite>call_back</cite> - function to be called on complete</li>
  111. <li><cite>on_timeout</cite> - function to be called on timeout</li>
  112. <li><cite>no_spinner</cite> - do not show the &#8220;Loading...&#8221; spinner</li>
  113. <li><cite>freeze_msg</cite> - freeze the user page while showing with the given message</li>
  114. </ul>
  115. </dd></dl>
  116. <dl class="function">
  117. <dt>
  118. <tt class="descname">$c_obj(doclist, method, arg, call_back, no_spinner, freeze_msg)</tt></dt>
  119. <dd><p>call an object on the server, where:</p>
  120. <ul class="simple">
  121. <li><cite>doclist</cite> - the doclist of the calling doc or a string with the name of a Control Doctype</li>
  122. <li><cite>method</cite> - method to be called</li>
  123. <li><cite>arg</cite> - string argument</li>
  124. <li><cite>call_back</cite> - function to be called on completion</li>
  125. <li><cite>no_spinner</cite> - do not show the &#8220;Loading...&#8221; spinner</li>
  126. <li><cite>freeze_msg</cite> - freeze the user page while showing with the given message</li>
  127. </ul>
  128. </dd></dl>
  129. <dl class="function">
  130. <dt>
  131. <tt class="descname">$c_obj_csv(doclist, method, arg, call_back, no_spinner, freeze_msg)</tt></dt>
  132. <dd><p>call an object on the server and return the output as CSV.</p>
  133. <p><em>Note:</em> There will be no callback. The output must be a list-in-a-list</p>
  134. </dd></dl>
  135. <dl class="function">
  136. <dt>
  137. <tt class="descname">$c_js(path, callback)</tt></dt>
  138. <dd>Load a Javascript library. Path must be relative to the js folder. For example: <cite>widgets/calendar.js</cite></dd></dl>
  139. </div>
  140. <div class="section" id="title">
  141. <h2>Title<a class="headerlink" href="#title" title="Permalink to this headline">¶</a></h2>
  142. <dl class="data">
  143. <dt id="title_prefix">
  144. <tt class="descname">title_prefix</tt><a class="headerlink" href="#title_prefix" title="Permalink to this definition">¶</a></dt>
  145. <dd>Standard prefix to the title</dd></dl>
  146. <dl class="function">
  147. <dt id="set_title">
  148. <tt class="descname">set_title</tt><big>(</big><em>t</em><big>)</big><a class="headerlink" href="#set_title" title="Permalink to this definition">¶</a></dt>
  149. <dd>set Page <cite>title</cite>, if <cite>title_prefix</cite> is set, then appends it to the prefix</dd></dl>
  150. </div>
  151. <div class="section" id="events">
  152. <h2>Events<a class="headerlink" href="#events" title="Permalink to this headline">¶</a></h2>
  153. <dl class="function">
  154. <dt>
  155. <tt class="descname">addEvent(ev, fn) {</tt></dt>
  156. <dd><p>Add a listener to the given event. Example:</p>
  157. <div class="highlight-python"><pre>addEvent('click', function(e, target) { .. });</pre>
  158. </div>
  159. </dd></dl>
  160. </div>
  161. <div class="section" id="string">
  162. <h2>String<a class="headerlink" href="#string" title="Permalink to this headline">¶</a></h2>
  163. <dl class="function">
  164. <dt id="clean_smart_quotes">
  165. <tt class="descname">clean_smart_quotes</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#clean_smart_quotes" title="Permalink to this definition">¶</a></dt>
  166. <dd>Returns string with MS Word &#8220;Smart&#8221; quotes removed</dd></dl>
  167. <dl class="function">
  168. <dt id="replace_newlines">
  169. <tt class="descname">replace_newlines</tt><big>(</big><em>t</em><big>)</big><a class="headerlink" href="#replace_newlines" title="Permalink to this definition">¶</a></dt>
  170. <dd>Replaces newline charcter \n with &#8216;&lt;br&gt;&#8217;</dd></dl>
  171. <dl class="function">
  172. <dt id="esc_quotes">
  173. <tt class="descname">esc_quotes</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#esc_quotes" title="Permalink to this definition">¶</a></dt>
  174. <dd>Returns string with single quote &#8216; escaped</dd></dl>
  175. <dl class="function">
  176. <dt id="strip">
  177. <tt class="descname">strip</tt><big>(</big><em>s</em>, <em>chars</em><big>)</big><a class="headerlink" href="#strip" title="Permalink to this definition">¶</a></dt>
  178. <dd>Python-like function returns string with leading and lagging characters from <cite>chars</cite> removed.
  179. If <cite>chars</cite> is null, removes whitespace.</dd></dl>
  180. <dl class="function">
  181. <dt id="lstrip">
  182. <tt class="descname">lstrip</tt><big>(</big><em>s</em>, <em>chars</em><big>)</big><a class="headerlink" href="#lstrip" title="Permalink to this definition">¶</a></dt>
  183. <dd>Strips <cite>chars</cite> from left side</dd></dl>
  184. <dl class="function">
  185. <dt id="rstrip">
  186. <tt class="descname">rstrip</tt><big>(</big><em>s</em>, <em>chars</em><big>)</big><a class="headerlink" href="#rstrip" title="Permalink to this definition">¶</a></dt>
  187. <dd>Strips <cite>chars</cite> from right side</dd></dl>
  188. <dl class="function">
  189. <dt>
  190. <tt class="descname">repl_all(s, s1, s2) {</tt></dt>
  191. <dd>Replaces all <cite>s1</cite> to <cite>s2</cite> in <cite>s</cite></dd></dl>
  192. <dl class="function">
  193. <dt id="repl">
  194. <tt class="descname">repl</tt><big>(</big><em>s</em>, <em>dict</em><big>)</big><a class="headerlink" href="#repl" title="Permalink to this definition">¶</a></dt>
  195. <dd><p>Python-like string replacement. Example:</p>
  196. <div class="highlight-python"><div class="highlight"><pre><span class="n">s</span> <span class="o">=</span> <span class="n">repl</span><span class="p">(</span><span class="s">&quot;Hello </span><span class="si">%(name)s</span><span class="s">, welcome to </span><span class="si">%(location)s</span><span class="s">&quot;</span><span class="p">,</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span><span class="s">&#39;ABC&#39;</span><span class="p">,</span> <span class="n">location</span><span class="p">:</span><span class="s">&#39;Mumbai&#39;</span><span class="p">});</span>
  197. </pre></div>
  198. </div>
  199. </dd></dl>
  200. <dl class="function">
  201. <dt>
  202. <tt class="descname">esc_quotes</tt><big>(</big><em>s</em><big>)</big></dt>
  203. <dd>Returns string with single quote &#8216; escaped</dd></dl>
  204. <dl class="function">
  205. <dt>
  206. <tt class="descname">strip</tt><big>(</big><em>s</em>, <em>chars</em><big>)</big></dt>
  207. <dd>Python-like function returns string with leading and lagging characters from <cite>chars</cite> removed.
  208. If <cite>chars</cite> is null, removes whitespace.</dd></dl>
  209. <dl class="function">
  210. <dt>
  211. <tt class="descname">lstrip</tt><big>(</big><em>s</em>, <em>chars</em><big>)</big></dt>
  212. <dd>Strips <cite>chars</cite> from left side</dd></dl>
  213. <dl class="function">
  214. <dt>
  215. <tt class="descname">rstrip</tt><big>(</big><em>s</em>, <em>chars</em><big>)</big></dt>
  216. <dd>Strips <cite>chars</cite> from right side</dd></dl>
  217. <dl class="function">
  218. <dt>
  219. <tt class="descname">repl_all(s, s1, s2) {</tt></dt>
  220. <dd>Replaces all <cite>s1</cite> to <cite>s2</cite> in <cite>s</cite></dd></dl>
  221. <dl class="function">
  222. <dt>
  223. <tt class="descname">repl</tt><big>(</big><em>s</em>, <em>dict</em><big>)</big></dt>
  224. <dd><p>Python-like string replacement. Example:</p>
  225. <div class="highlight-python"><div class="highlight"><pre><span class="n">s</span> <span class="o">=</span> <span class="n">repl</span><span class="p">(</span><span class="s">&quot;Hello </span><span class="si">%(name)s</span><span class="s">, welcome to </span><span class="si">%(location)s</span><span class="s">&quot;</span><span class="p">,</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span><span class="s">&#39;ABC&#39;</span><span class="p">,</span> <span class="n">location</span><span class="p">:</span><span class="s">&#39;Mumbai&#39;</span><span class="p">});</span>
  226. </pre></div>
  227. </div>
  228. </dd></dl>
  229. </div>
  230. <div class="section" id="lists">
  231. <h2>Lists<a class="headerlink" href="#lists" title="Permalink to this headline">¶</a></h2>
  232. <dl class="function">
  233. <dt id="in_list">
  234. <tt class="descname">in_list</tt><big>(</big><em>list</em>, <em>item</em><big>)</big><a class="headerlink" href="#in_list" title="Permalink to this definition">¶</a></dt>
  235. <dd>Returns true if <cite>item</cite> is in <cite>list</cite></dd></dl>
  236. <dl class="function">
  237. <dt id="inList">
  238. <tt class="descname">inList</tt><big>(</big><em>list</em>, <em>item</em><big>)</big><a class="headerlink" href="#inList" title="Permalink to this definition">¶</a></dt>
  239. <dd>Returns true if <cite>item</cite> is in <cite>list</cite>. Same as <cite>in_list</cite></dd></dl>
  240. <dl class="function">
  241. <dt id="has_common">
  242. <tt class="descname">has_common</tt><big>(</big><em>list1</em>, <em>list2</em><big>)</big><a class="headerlink" href="#has_common" title="Permalink to this definition">¶</a></dt>
  243. <dd>Returns true if <cite>list1</cite> and <cite>list2</cite> has common items</dd></dl>
  244. </div>
  245. <div class="section" id="dictionaries">
  246. <h2>Dictionaries<a class="headerlink" href="#dictionaries" title="Permalink to this headline">¶</a></h2>
  247. <dl class="function">
  248. <dt id="keys">
  249. <tt class="descname">keys</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#keys" title="Permalink to this definition">¶</a></dt>
  250. <dd>Python-like function returns keys of a dictionary</dd></dl>
  251. <dl class="function">
  252. <dt id="values">
  253. <tt class="descname">values</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#values" title="Permalink to this definition">¶</a></dt>
  254. <dd>Python-like function returns values of a dictionary</dd></dl>
  255. <dl class="function">
  256. <dt id="copy_dict">
  257. <tt class="descname">copy_dict</tt><big>(</big><em>d</em><big>)</big><a class="headerlink" href="#copy_dict" title="Permalink to this definition">¶</a></dt>
  258. <dd>Makes a copy of the dictionary</dd></dl>
  259. </div>
  260. <div class="section" id="datatype-conversion">
  261. <h2>Datatype Conversion<a class="headerlink" href="#datatype-conversion" title="Permalink to this headline">¶</a></h2>
  262. <dl class="function">
  263. <dt id="cint">
  264. <tt class="descname">cint</tt><big>(</big><em>v</em>, <em>def</em><big>)</big><a class="headerlink" href="#cint" title="Permalink to this definition">¶</a></dt>
  265. <dd>Convert a value to integer, if NaN, then return <cite>def</cite></dd></dl>
  266. <dl class="function">
  267. <dt id="cstr">
  268. <tt class="descname">cstr</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#cstr" title="Permalink to this definition">¶</a></dt>
  269. <dd>Convet to string</dd></dl>
  270. <dl class="function">
  271. <dt id="flt">
  272. <tt class="descname">flt</tt><big>(</big><em>v</em>, <em>decimals</em><big>)</big><a class="headerlink" href="#flt" title="Permalink to this definition">¶</a></dt>
  273. <dd>Convert to float, with <cite>decimal</cite> places</dd></dl>
  274. <dl class="function">
  275. <dt id="fmt_money">
  276. <tt class="descname">fmt_money</tt><big>(</big><em>v</em><big>)</big><a class="headerlink" href="#fmt_money" title="Permalink to this definition">¶</a></dt>
  277. <dd><p>Convert number to string with commas for thousands, millions etc and 2 decimals. Example:</p>
  278. <div class="highlight-python"><pre>fmt_money(2324); // equals '2,324.00'</pre>
  279. </div>
  280. </dd></dl>
  281. <dl class="function">
  282. <dt id="is_null">
  283. <tt class="descname">is_null</tt><big>(</big><em>v</em><big>)</big><a class="headerlink" href="#is_null" title="Permalink to this definition">¶</a></dt>
  284. <dd>Returns true if value is null or empty string.
  285. Returns false is value is 0</dd></dl>
  286. <dl class="function">
  287. <dt id="d2h">
  288. <tt class="descname">d2h</tt><big>(</big><em>d</em><big>)</big><a class="headerlink" href="#d2h" title="Permalink to this definition">¶</a></dt>
  289. <dd>Convert decimal to hex</dd></dl>
  290. <dl class="function">
  291. <dt id="h2d">
  292. <tt class="descname">h2d</tt><big>(</big><em>h</em><big>)</big><a class="headerlink" href="#h2d" title="Permalink to this definition">¶</a></dt>
  293. <dd>Convert hex to decimal</dd></dl>
  294. </div>
  295. <div class="section" id="dom-manipulation">
  296. <h2>DOM Manipulation<a class="headerlink" href="#dom-manipulation" title="Permalink to this headline">¶</a></h2>
  297. <dl class="function">
  298. <dt>
  299. <tt class="descname">$i(id)</tt></dt>
  300. <dd>Shortcut for document.getElementById(id). Returns the element of the given ID</dd></dl>
  301. <dl class="function">
  302. <dt>
  303. <tt class="descname">$a(parent, newtag, className, style)</tt></dt>
  304. <dd><p>Add element to the given <cite>parent</cite>. Example:</p>
  305. <div class="highlight-python"><pre>div = $a(body, 'div', '', {padding: '2px'});</pre>
  306. </div>
  307. </dd></dl>
  308. <dl class="function">
  309. <dt>
  310. <tt class="descname">$a_input(parent, in_type, attributes, style)</tt></dt>
  311. <dd><p>Add and INPUT element to the given parent, with given attributes (Fix for IE6 since it does not accept
  312. <cite>type</cite>). Example:</p>
  313. <div class="highlight-python"><pre>chk = $a_input(body, 'checkbox', null, {border: '0px'});</pre>
  314. </div>
  315. </dd></dl>
  316. </div>
  317. <div class="section" id="style">
  318. <h2>Style<a class="headerlink" href="#style" title="Permalink to this headline">¶</a></h2>
  319. <dl class="function">
  320. <dt>
  321. <tt class="descname">$y(ele, s)</tt></dt>
  322. <dd><p>Set Element style. Example:</p>
  323. <div class="highlight-python"><pre>$y(div,{height:'4px'});</pre>
  324. </div>
  325. </dd></dl>
  326. <dl class="function">
  327. <dt>
  328. <tt class="descname">$dh(d)</tt></dt>
  329. <dd>Hide element, set <cite>display</cite> = &#8216;none&#8217;</dd></dl>
  330. <dl class="function">
  331. <dt>
  332. <tt class="descname">$ds(d)</tt></dt>
  333. <dd>set <cite>display</cite> = &#8216;block&#8217; (Show element)</dd></dl>
  334. <dl class="function">
  335. <dt>
  336. <tt class="descname">$di(d)</tt></dt>
  337. <dd>set <cite>display</cite> = &#8216;inline&#8217; (Show element)</dd></dl>
  338. <dl class="function">
  339. <dt>
  340. <tt class="descname">$op(e,w)</tt></dt>
  341. <dd>Same as <a title="set_opacity" class="reference internal" href="#set_opacity"><tt class="xref docutils literal"><span class="pre">set_opacity()</span></tt></a></dd></dl>
  342. <dl class="function">
  343. <dt id="set_style">
  344. <tt class="descname">set_style</tt><big>(</big><em>txt</em><big>)</big><a class="headerlink" href="#set_style" title="Permalink to this definition">¶</a></dt>
  345. <dd><p>Declare css classes in txt. Example:</p>
  346. <div class="highlight-python"><div class="highlight"><pre><span class="n">set_style</span><span class="p">(</span><span class="s">&#39;div.myclass { width: 400px }&#39;</span><span class="p">);</span>
  347. </pre></div>
  348. </div>
  349. </dd></dl>
  350. <dl class="function">
  351. <dt id="set_opacity">
  352. <tt class="descname">set_opacity</tt><big>(</big><em>ele</em>, <em>opacity</em><big>)</big><a class="headerlink" href="#set_opacity" title="Permalink to this definition">¶</a></dt>
  353. <dd><p>Set the opacity property of the element
  354. opacity between 0 and 100</p>
  355. <p>Same As: $op(e,w)</p>
  356. </dd></dl>
  357. <dl class="function">
  358. <dt id="animate">
  359. <tt class="descname">animate</tt><big>(</big><em>ele</em>, <em>style_key</em>, <em>from</em>, <em>to</em>, <em>callback</em><big>)</big><a class="headerlink" href="#animate" title="Permalink to this definition">¶</a></dt>
  360. <dd>Animate transition of style property</dd></dl>
  361. <dl class="function">
  362. <dt id="get_darker_shade">
  363. <tt class="descname">get_darker_shade</tt><big>(</big><em>col</em>, <em>factor</em><big>)</big><a class="headerlink" href="#get_darker_shade" title="Permalink to this definition">¶</a></dt>
  364. <dd>Get a darker shade of the given colour, <cite>col</cite> in HEX, <cite>factor</cite> between 0 and 1</dd></dl>
  365. </div>
  366. <div class="section" id="tables">
  367. <h2>Tables<a class="headerlink" href="#tables" title="Permalink to this headline">¶</a></h2>
  368. <dl class="function">
  369. <dt id="make_table">
  370. <tt class="descname">make_table</tt><big>(</big><em>parent</em>, <em>nr</em>, <em>nc</em>, <em>table_width</em>, <em>widths</em>, <em>cell_style</em><big>)</big><a class="headerlink" href="#make_table" title="Permalink to this definition">¶</a></dt>
  371. <dd><p>Make a new table in parent with</p>
  372. <ul class="simple">
  373. <li>rows <cite>nr</cite></li>
  374. <li>columns <cite>nc</cite></li>
  375. <li>with columns with widths <cite>widths</cite></li>
  376. <li>cell with default style <cite>cell_style</cite></li>
  377. </ul>
  378. <p>Example:</p>
  379. <div class="highlight-python"><pre>var t = make_table(div, 5, 2, '400px', ['100px', '300px'], {padding: '2px'})</pre>
  380. </div>
  381. </dd></dl>
  382. <dl class="function">
  383. <dt id="append_row">
  384. <tt class="descname">append_row</tt><big>(</big><em>t</em><big>)</big><a class="headerlink" href="#append_row" title="Permalink to this definition">¶</a></dt>
  385. <dd>Append a new row to the table with same number of columns as the first row</dd></dl>
  386. <dl class="function">
  387. <dt>
  388. <tt class="descname">$td(t,r,c)</tt></dt>
  389. <dd>Returns table cell. Shortcut for t.rows[r].cells[c]</dd></dl>
  390. <dl class="function">
  391. <dt>
  392. <tt class="descname">$sum(t, cidx) {</tt></dt>
  393. <dd>Returns sum of values in a table column</dd></dl>
  394. <dl class="function">
  395. <dt>
  396. <tt class="descname">$yt(tab, r, c, s)</tt></dt>
  397. <dd><p>Set style on tables with wildcards, Examples:</p>
  398. <div class="highlight-python"><pre>// hilight row 3
  399. $yt(t, 3, '*', {backgroundColor:'#EEE'})
  400. // border to all cells
  401. $yt(t, '*', '*', {border:'1px solid #000'})</pre>
  402. </div>
  403. </dd></dl>
  404. </div>
  405. <div class="section" id="select-element">
  406. <h2>Select Element<a class="headerlink" href="#select-element" title="Permalink to this headline">¶</a></h2>
  407. <dl class="function">
  408. <dt id="empty_select">
  409. <tt class="descname">empty_select</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#empty_select" title="Permalink to this definition">¶</a></dt>
  410. <dd>Empty all OPTIONs of the SELECT (or SelectWidget) element</dd></dl>
  411. <dl class="function">
  412. <dt id="sel_val">
  413. <tt class="descname">sel_val</tt><big>(</big><em>sel</em><big>)</big><a class="headerlink" href="#sel_val" title="Permalink to this definition">¶</a></dt>
  414. <dd>Returns the selected value of the given SELECT (or SelectWidget) element</dd></dl>
  415. <dl class="function">
  416. <dt id="add_sel_options">
  417. <tt class="descname">add_sel_options</tt><big>(</big><em>s</em>, <em>list</em>, <em>sel_val</em>, <em>o_style</em><big>)</big><a class="headerlink" href="#add_sel_options" title="Permalink to this definition">¶</a></dt>
  418. <dd>Adds options to the SELECT (or SelectWidget) element s, where sel_val is the default selected value</dd></dl>
  419. </div>
  420. <div class="section" id="positioning">
  421. <h2>Positioning<a class="headerlink" href="#positioning" title="Permalink to this headline">¶</a></h2>
  422. <dl class="function">
  423. <dt id="objpos">
  424. <tt class="descname">objpos</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#objpos" title="Permalink to this definition">¶</a></dt>
  425. <dd>Returns {x: <cite>x-cord</cite>, y:<cite>y-cord</cite>}
  426. co-ordinates of the given object (for absolute positioning)</dd></dl>
  427. <dl class="function">
  428. <dt>
  429. <tt class="descname">get_screen_dims() {</tt></dt>
  430. <dd>Returns {w: <cite>width</cite>, h:<cite>height</cite>} of the screen</dd></dl>
  431. </div>
  432. <div class="section" id="url">
  433. <h2>URL<a class="headerlink" href="#url" title="Permalink to this headline">¶</a></h2>
  434. <dl class="function">
  435. <dt id="get_url_arg">
  436. <tt class="descname">get_url_arg</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#get_url_arg" title="Permalink to this definition">¶</a></dt>
  437. <dd>Return the value of the argument <cite>name</cite> from the URL</dd></dl>
  438. </div>
  439. <div class="section" id="user-image">
  440. <h2>User Image<a class="headerlink" href="#user-image" title="Permalink to this headline">¶</a></h2>
  441. <dl class="function">
  442. <dt id="set_user_img">
  443. <tt class="descname">set_user_img</tt><big>(</big><em>img</em>, <em>username</em><big>)</big><a class="headerlink" href="#set_user_img" title="Permalink to this definition">¶</a></dt>
  444. <dd>Sets the user image or No Image tag to the given <cite>img</cite></dd></dl>
  445. </div>
  446. <div class="section" id="miscelleanous">
  447. <h2>Miscelleanous<a class="headerlink" href="#miscelleanous" title="Permalink to this headline">¶</a></h2>
  448. <dl class="function">
  449. <dt>
  450. <tt class="descname">$s(ele, v, ftype, fopt)</tt></dt>
  451. <dd><p>Add the value to the Element <cite>ele</cite> based on <cite>fieldtype</cite> and <cite>fieldoptions</cite></p>
  452. <ul class="simple">
  453. <li>Covnerts <cite>Link</cite> type to hyperlink</li>
  454. <li>Converts <cite>Date</cite> in user format</li>
  455. <li>Converts <cite>Check</cite> to image with check</li>
  456. </ul>
  457. </dd></dl>
  458. <dl class="function">
  459. <dt id="validate_email">
  460. <tt class="descname">validate_email</tt><big>(</big><em>id</em><big>)</big><a class="headerlink" href="#validate_email" title="Permalink to this definition">¶</a></dt>
  461. <dd>Returns true for a valid email</dd></dl>
  462. <dl class="function">
  463. <dt id="DocLink">
  464. <tt class="descname">DocLink</tt><big>(</big><em>p</em>, <em>doctype</em>, <em>name</em>, <em>onload</em><big>)</big><a class="headerlink" href="#DocLink" title="Permalink to this definition">¶</a></dt>
  465. <dd>Creates a hyperlink to load the record (<cite>doctype</cite>, <cite>name</cite>)</dd></dl>
  466. <dl class="function">
  467. <dt id="doc_link">
  468. <tt class="descname">doc_link</tt><big>(</big><em>p</em>, <em>doctype</em>, <em>name</em>, <em>onload</em><big>)</big><a class="headerlink" href="#doc_link" title="Permalink to this definition">¶</a></dt>
  469. <dd>Creates a hyperlink to load the record (<cite>doctype</cite>, <cite>name</cite>). Same as DocLink</dd></dl>
  470. </div>
  471. </div>
  472. </div>
  473. </div>
  474. </div>
  475. <div class="clearer"></div>
  476. </div>
  477. <div class="related">
  478. <h3>Navigation</h3>
  479. <ul>
  480. <li class="right" style="margin-right: 10px">
  481. <a href="genindex.html" title="General Index"
  482. >index</a></li>
  483. <li class="right" >
  484. <a href="modindex.html" title="Global Module Index"
  485. >modules</a> |</li>
  486. <li class="right" >
  487. <a href="navigation.html" title="Page Structure and Navigation"
  488. >next</a> |</li>
  489. <li class="right" >
  490. <a href="autosuggest.html" title="Autosuggest"
  491. >previous</a> |</li>
  492. <li><a href="index.html">Documentation</a> &raquo;</li>
  493. <li><a href="client_side_widgets.html" >4. Client Side API</a> &raquo;</li>
  494. </ul>
  495. </div>
  496. <div class="footer">
  497. &copy; Copyright 2010, Rushabh Mehta.
  498. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
  499. </div>
  500. </body>
  501. </html>