918b664606b292cbeaf015046327f336641ad2eb.svn-base 11 KB

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