Πέμπτη 3 Ιανουαρίου 2013

Keeping Tab and Window State with EXTJS!

Εδώ θα σας παρουσιάσω ένα αναλυτικό παράδειγμα σε JavaScript με EXT JS.
Παρακάτω σας παραθέτω τον πηγαίο κώδικα.
Χρειαζόμαστε 2 αρχεία ένα JS και ένα HTML
Ή ενσωματώνουμε το javascript στο html.

Πιο αναλυτικά:

Source of tabstate.js:
  1. // vim: sw=4:ts=4:nu:nospell:fdc=4
  2. /*global Ext */
  3. /**
  4. * Keeping Active Tab and Window State Example by Saki
  5. *
  6. * @author Ing. Jozef Sakáloš
  7. * @copyright (c) 2009, by Ing. Jozef Sakáloš
  8. * @date 15. January 2009
  9. * @version $Id: tabstate.js 111 2009-01-30 01:10:43Z jozo $
  10. *
  11. * @license tabstate.js is licensed under the terms of the Open Source
  12. * LGPL 3.0 license. Commercial use is permitted to the extent that the
  13. * code/component(s) do NOT become part of another Open Source or Commercially
  14. * licensed development library or toolkit without explicit permission.
  15. *
  16. * License details: http://www.gnu.org/licenses/lgpl.html
  17. */
  18. Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';
  19. Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
  20. // application main entry point
  21. Ext.onReady(function() {
  22. var w = new Ext.Window({
  23. title: Ext.fly('page-title').dom.innerHTML
  24. ,renderTo: Ext.getBody()
  25. ,width:340
  26. ,height:300
  27. ,closable:false
  28. ,stateId:'window'
  29. ,border:false
  30. ,layout:'fit'
  31. ,items:[{
  32. xtype:'tabpanel'
  33. ,activeTab:0
  34. ,stateId:'tabpanel'
  35. ,stateEvents:['tabchange']
  36. ,getState:function() {
  37. return {
  38. activeTab:this.items.indexOf(this.getActiveTab())
  39. };
  40. }
  41. ,defaults:{layout:'fit', border:false, bodyStyle:'padding:8px'}
  42. ,items:[{
  43. title:'First'
  44. ,html: 'First'
  45. },{
  46. title:'Second'
  47. ,html: 'Second'
  48. },{
  49. title:'Third'
  50. ,html: 'Third'
  51. },{
  52. title:'Fourth'
  53. ,html: 'Fourth'
  54. }]
  55. }]
  56. });
  57. w.show();
  58. }); // eo function onReady

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Source of tabstate.html:
  1. <!-- vim: ts=2:sw=2:nu:fdc=2:spell
  2. Keeping active tab and window position state
  3. @author Ing.Jozef Sakáloš
  4. @copyright (c) 2009, by Ing. Jozef Sakáloš
  5. @date 15. January 2009
  6. @version $Id: tabstate.html 108 2009-01-15 14:37:41Z jozo $
  7. @license tabstate.html is licensed under the terms of the Open Source
  8. LGPL 3.0 license. Commercial use is permitted to the extent that the
  9. code/component(s) do NOT become part of another Open Source or Commercially
  10. licensed development library or toolkit without explicit permission.
  11. License details: http://www.gnu.org/licenses/lgpl.html
  12. -->
  13. <html>
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  16. <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" />
  17. <link id="theme" rel="stylesheet" type="text/css" href="css/empty.css" />
  18. <link rel="stylesheet" type="text/css" href="css/icons.css" />
  19. <link rel="shortcut icon" href="img/extjs.ico" />
  20. <script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
  21. <script type="text/javascript" src="ext/ext-all-debug.js"></script>
  22. <script type="text/javascript" src="tabstate.js"></script>
  23. <title id="page-title">Keeping Active Tab and Window State by Saki</title>
  24. </head>
  25. <body>
  26. <div class="adsense" style="margin:4px">
  27. <script type="text/javascript"><!--
  28. google_ad_client = "pub-2768521146228687";
  29. /* 728x90, for examples ifram */
  30. google_ad_slot = "5477402227";
  31. google_ad_width = 728;
  32. google_ad_height = 90;
  33. //-->
  34. </script>
  35. <script type="text/javascript"
  36. src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  37. </script>
  38. </div>
  39. <!-- delete following line if you don not want stats included -->
  40. <?if("examples.extjs.eu"===$_SERVER["SERVER_NAME"]){$page='tabstate';include("stats.php");}?>
  41. </body>
  42. </html>
  43. <!-- eof -->
 ΠΗΓΗ: http://examples.extjs.eu/

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου