sample.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. // Sample desktop configuration
  8. MyDesktop = new Ext.app.App({
  9. init :function(){
  10. Ext.QuickTips.init();
  11. },
  12. getModules : function(){
  13. return [
  14. new MyDesktop.GridWindow(),
  15. new MyDesktop.TabWindow(),
  16. new MyDesktop.AccordionWindow(),
  17. new MyDesktop.BogusMenuModule(),
  18. new MyDesktop.BogusModule()
  19. ];
  20. },
  21. // config for the start menu
  22. getStartConfig : function(){
  23. return {
  24. title: 'Tommy Maintz',
  25. iconCls: 'user',
  26. toolItems: [{
  27. text:'Settings',
  28. iconCls:'settings',
  29. scope:this
  30. },'-',{
  31. text:'Logout',
  32. iconCls:'logout',
  33. scope:this
  34. }]
  35. };
  36. }
  37. });
  38. /*
  39. * Example windows
  40. */
  41. MyDesktop.GridWindow = Ext.extend(Ext.app.Module, {
  42. id:'grid-win',
  43. init : function(){
  44. this.launcher = {
  45. text: 'Grid Window',
  46. iconCls:'icon-grid',
  47. handler : this.createWindow,
  48. scope: this
  49. }
  50. },
  51. createWindow : function(){
  52. var desktop = this.app.getDesktop();
  53. var win = desktop.getWindow('grid-win');
  54. if(!win){
  55. win = desktop.createWindow({
  56. id: 'grid-win',
  57. title:'Grid Window',
  58. width:740,
  59. height:480,
  60. iconCls: 'icon-grid',
  61. shim:false,
  62. animCollapse:false,
  63. constrainHeader:true,
  64. layout: 'fit',
  65. items:
  66. new Ext.grid.GridPanel({
  67. border:false,
  68. ds: new Ext.data.Store({
  69. reader: new Ext.data.ArrayReader({}, [
  70. {name: 'company'},
  71. {name: 'price', type: 'float'},
  72. {name: 'change', type: 'float'},
  73. {name: 'pctChange', type: 'float'}
  74. ]),
  75. data: Ext.grid.dummyData
  76. }),
  77. cm: new Ext.grid.ColumnModel([
  78. new Ext.grid.RowNumberer(),
  79. {header: "Company", width: 120, sortable: true, dataIndex: 'company'},
  80. {header: "Price", width: 70, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
  81. {header: "Change", width: 70, sortable: true, dataIndex: 'change'},
  82. {header: "% Change", width: 70, sortable: true, dataIndex: 'pctChange'}
  83. ]),
  84. viewConfig: {
  85. forceFit:true
  86. },
  87. //autoExpandColumn:'company',
  88. tbar:[{
  89. text:'Add Something',
  90. tooltip:'Add a new row',
  91. iconCls:'add'
  92. }, '-', {
  93. text:'Options',
  94. tooltip:'Modify options',
  95. iconCls:'option'
  96. },'-',{
  97. text:'Remove Something',
  98. tooltip:'Remove the selected item',
  99. iconCls:'remove'
  100. }]
  101. })
  102. });
  103. }
  104. win.show();
  105. }
  106. });
  107. MyDesktop.TabWindow = Ext.extend(Ext.app.Module, {
  108. id:'tab-win',
  109. init : function(){
  110. this.launcher = {
  111. text: 'Tab Window',
  112. iconCls:'tabs',
  113. handler : this.createWindow,
  114. scope: this
  115. }
  116. },
  117. createWindow : function(){
  118. var desktop = this.app.getDesktop();
  119. var win = desktop.getWindow('tab-win');
  120. if(!win){
  121. win = desktop.createWindow({
  122. id: 'tab-win',
  123. title:'Tab Window',
  124. width:740,
  125. height:480,
  126. iconCls: 'tabs',
  127. shim:false,
  128. animCollapse:false,
  129. border:false,
  130. constrainHeader:true,
  131. layout: 'fit',
  132. items:
  133. new Ext.TabPanel({
  134. activeTab:0,
  135. items: [{
  136. title: 'Tab Text 1',
  137. header:false,
  138. html : '<p>Something useful would be in here.</p>',
  139. border:false
  140. },{
  141. title: 'Tab Text 2',
  142. header:false,
  143. html : '<p>Something useful would be in here.</p>',
  144. border:false
  145. },{
  146. title: 'Tab Text 3',
  147. header:false,
  148. html : '<p>Something useful would be in here.</p>',
  149. border:false
  150. },{
  151. title: 'Tab Text 4',
  152. header:false,
  153. html : '<p>Something useful would be in here.</p>',
  154. border:false
  155. }]
  156. })
  157. });
  158. }
  159. win.show();
  160. }
  161. });
  162. MyDesktop.AccordionWindow = Ext.extend(Ext.app.Module, {
  163. id:'acc-win',
  164. init : function(){
  165. this.launcher = {
  166. text: 'Accordion Window',
  167. iconCls:'accordion',
  168. handler : this.createWindow,
  169. scope: this
  170. }
  171. },
  172. createWindow : function(){
  173. var desktop = this.app.getDesktop();
  174. var win = desktop.getWindow('acc-win');
  175. if(!win){
  176. win = desktop.createWindow({
  177. id: 'acc-win',
  178. title: 'Accordion Window',
  179. width:250,
  180. height:400,
  181. iconCls: 'accordion',
  182. shim:false,
  183. animCollapse:false,
  184. constrainHeader:true,
  185. tbar:[{
  186. tooltip:{title:'Rich Tooltips', text:'Let your users know what they can do!'},
  187. iconCls:'connect'
  188. },'-',{
  189. tooltip:'Add a new user',
  190. iconCls:'user-add'
  191. },' ',{
  192. tooltip:'Remove the selected user',
  193. iconCls:'user-delete'
  194. }],
  195. layout:'accordion',
  196. border:false,
  197. layoutConfig: {
  198. animate:false
  199. },
  200. items: [
  201. new Ext.tree.TreePanel({
  202. id:'im-tree',
  203. title: 'Online Users',
  204. rootVisible:false,
  205. lines:false,
  206. autoScroll:true,
  207. tools:[{
  208. id:'refresh',
  209. on:{
  210. click: function(){
  211. var tree = Ext.getCmp('im-tree');
  212. tree.body.mask('Loading', 'x-mask-loading');
  213. tree.root.reload(function() {
  214. tree.body.unmask();
  215. });
  216. }
  217. }
  218. }],
  219. dataUrl: 'get-users.json',
  220. root: {
  221. nodeType: 'async',
  222. text: 'Online',
  223. expanded: true
  224. }
  225. }), {
  226. title: 'Settings',
  227. html:'<p>Something useful would be in here.</p>',
  228. autoScroll:true
  229. },{
  230. title: 'Even More Stuff',
  231. html : '<p>Something useful would be in here.</p>'
  232. },{
  233. title: 'My Stuff',
  234. html : '<p>Something useful would be in here.</p>'
  235. }
  236. ]
  237. });
  238. }
  239. win.show();
  240. }
  241. });
  242. // for example purposes
  243. var windowIndex = 0;
  244. MyDesktop.BogusModule = Ext.extend(Ext.app.Module, {
  245. init : function(){
  246. this.launcher = {
  247. text: 'Window '+(++windowIndex),
  248. iconCls:'bogus',
  249. handler : this.createWindow,
  250. scope: this,
  251. windowId:windowIndex
  252. }
  253. },
  254. createWindow : function(src){
  255. var desktop = this.app.getDesktop();
  256. var win = desktop.getWindow('bogus'+src.windowId);
  257. if(!win){
  258. win = desktop.createWindow({
  259. id: 'bogus'+src.windowId,
  260. title:src.text,
  261. width:640,
  262. height:480,
  263. html : '<p>Something useful would be in here.</p>',
  264. iconCls: 'bogus',
  265. shim:false,
  266. animCollapse:false,
  267. constrainHeader:true
  268. });
  269. }
  270. win.show();
  271. }
  272. });
  273. MyDesktop.BogusMenuModule = Ext.extend(MyDesktop.BogusModule, {
  274. init : function(){
  275. this.launcher = {
  276. text: 'Bogus Submenu',
  277. iconCls: 'bogus',
  278. handler: function() {
  279. return false;
  280. },
  281. menu: {
  282. items:[{
  283. text: 'Bogus Window '+(++windowIndex),
  284. iconCls:'bogus',
  285. handler : this.createWindow,
  286. scope: this,
  287. windowId: windowIndex
  288. },{
  289. text: 'Bogus Window '+(++windowIndex),
  290. iconCls:'bogus',
  291. handler : this.createWindow,
  292. scope: this,
  293. windowId: windowIndex
  294. },{
  295. text: 'Bogus Window '+(++windowIndex),
  296. iconCls:'bogus',
  297. handler : this.createWindow,
  298. scope: this,
  299. windowId: windowIndex
  300. },{
  301. text: 'Bogus Window '+(++windowIndex),
  302. iconCls:'bogus',
  303. handler : this.createWindow,
  304. scope: this,
  305. windowId: windowIndex
  306. },{
  307. text: 'Bogus Window '+(++windowIndex),
  308. iconCls:'bogus',
  309. handler : this.createWindow,
  310. scope: this,
  311. windowId: windowIndex
  312. }]
  313. }
  314. }
  315. }
  316. });
  317. // Array data for the grid
  318. Ext.grid.dummyData = [
  319. ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
  320. ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
  321. ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
  322. ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
  323. ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
  324. ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
  325. ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
  326. ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'],
  327. ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am'],
  328. ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am'],
  329. ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
  330. ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am'],
  331. ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am'],
  332. ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am'],
  333. ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am'],
  334. ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am'],
  335. ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am'],
  336. ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am'],
  337. ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am'],
  338. ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'9/1 12:00am']
  339. ];