init.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. This file is part of Ext JS 4
  3. Copyright (c) 2011 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  7. If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
  8. */
  9. Ext.ns('Ext.samples');
  10. (function() {
  11. var basePath = document.URL.substring(0, document.URL.lastIndexOf("mes/")+4);
  12. Ext.define('Ext.samples.SamplePanel', {
  13. extend: 'Ext.view.View',
  14. alias: 'widget.samplepanel',
  15. autoHeight : true,
  16. frame : false,
  17. cls : 'demos',
  18. itemSelector : 'dl',
  19. overItemCls : 'over',
  20. trackOver : true,
  21. tpl : Ext.create('Ext.XTemplate',
  22. '<div id="sample-ct">',
  23. '<tpl for=".">',
  24. '<div><a name="{id}"></a><h2><div>{title}</div></h2>',
  25. '<dl>',
  26. '<tpl for="items">',
  27. '<dd ext:url="' + basePath + 'jsps/common/{url}"><img src="' + basePath + 'resource/images/screens/{icon}"/>',
  28. '<div><h4>{text}',
  29. '<tpl if="this.isNew(values.status)">',
  30. '<span class="new-sample"> (New)</span>',
  31. '</tpl>',
  32. '<tpl if="this.isUpdated(values.status)">',
  33. '<span class="updated-sample"> (Updated)</span>',
  34. '</tpl>',
  35. '<tpl if="this.isExperimental(values.status)">',
  36. '<span class="new-sample"> (Experimental)</span>',
  37. '</tpl>',
  38. '</h4><p>{desc}</p></div>',
  39. '</dd>',
  40. '</tpl>',
  41. '<div style="clear:left"></div></dl></div>',
  42. '</tpl>',
  43. '</div>', {
  44. isExperimental: function(status){
  45. return status == 'experimental';
  46. },
  47. isNew: function(status){
  48. return status == 'new';
  49. },
  50. isUpdated: function(status){
  51. return status == 'updated';
  52. }
  53. }),
  54. onContainerClick: function(e) {
  55. var group = e.getTarget('h2', 3, true);
  56. if (group) {
  57. group.up('div').toggleCls('collapsed');
  58. }
  59. },
  60. onItemClick : function(record, item, index, e){
  61. var t = e.getTarget('dd', 5, true);
  62. if (t && !e.getTarget('a', 2)) {
  63. var url = t.getAttributeNS('ext', 'url');
  64. window.open(url);
  65. }
  66. return this.callParent(arguments);
  67. }
  68. });
  69. })();
  70. Ext.onReady(function() {
  71. (Ext.defer(function() {
  72. var catalog = Ext.samples.samplesCatalog;
  73. for (var i = 0, c; c = catalog[i]; i++) {
  74. c.id = 'sample-' + i;
  75. }
  76. var store = Ext.create('Ext.data.JsonStore', {
  77. idProperty : 'id',
  78. fields : ['id', 'title', 'items'],
  79. data : catalog
  80. });
  81. Ext.create('Ext.Panel', {
  82. frame : false,
  83. renderTo : Ext.get('all-demos'),
  84. height : 'auto',
  85. autoScroll : true,
  86. items : Ext.create('Ext.samples.SamplePanel', {
  87. store : store
  88. })
  89. });
  90. Ext.select('#sample-spacer').remove();
  91. },500));
  92. });