You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

236 lines
8.0 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 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
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. /*
  16. * Sample Image Organizer utilizing Ext.Direct
  17. * Tagging/Organizing into galleries
  18. * Image uploading
  19. */
  20. Ext.ns('Imgorg','Imgorg.App');
  21. Imgorg.App = function() {
  22. var swfu;
  23. SWFUpload.onload = function() {
  24. var settings = {
  25. flash_url: "SWFUpload/Flash/swfupload.swf",
  26. upload_url: "php/router.php",
  27. file_size_limit: "100 MB",
  28. file_types: "*.*",
  29. file_types_description: "Image Files",
  30. file_upload_limit: 100,
  31. file_queue_limit: 100,
  32. debug: false,
  33. button_placeholder_id: "btnUploadHolder",
  34. button_cursor: SWFUpload.CURSOR.HAND,
  35. button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
  36. file_queued_handler: function(file) {
  37. Ext.ux.SwfuMgr.fireEvent('filequeued', this, file);
  38. },
  39. upload_start_handler: function(file) {
  40. Ext.ux.SwfuMgr.fireEvent('uploadstart', this, file);
  41. },
  42. upload_progress_handler: function(file, complete, total) {
  43. Ext.ux.SwfuMgr.fireEvent('uploadprogress', this, file, complete, total);
  44. },
  45. upload_error_handler: function(file, error, message) {
  46. Ext.ux.SwfuMgr.fireEvent('uploaderror', this, file, error, message);
  47. },
  48. upload_success_handler: function(file, data, response) {
  49. Ext.ux.SwfuMgr.fireEvent('uploadsuccess', this, file, data);
  50. },
  51. minimum_flash_version: "9.0.28",
  52. post_params: {
  53. extAction: 'Images', // The class to use
  54. extUpload: true,
  55. extMethod: 'upload' // The method to execute
  56. //needs extTID – Transaction ID to associate with this request.
  57. }
  58. };
  59. swfu = new SWFUpload(settings);
  60. };
  61. var view, thumbPanel, uploadPanel, tabPanel;
  62. return {
  63. debugSWF: false,
  64. init: function() {
  65. Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
  66. Ext.QuickTips.init();
  67. Ext.BLANK_IMAGE_URL = '../../resources/images/default/s.gif';
  68. Ext.Direct.addProvider(Imgorg.REMOTING_API);
  69. Ext.ux.SwfuMgr.on('filequeued', this.onFileQueued, this);
  70. new Ext.Viewport({
  71. layout: 'border',
  72. items: [{
  73. xtype: 'img-albumtree',
  74. id: 'album-tree',
  75. region: 'west',
  76. width: 180,
  77. minWidth: 180,
  78. maxWidth: 180,
  79. collapsible: true,
  80. split: true,
  81. collapseMode: 'mini',
  82. margins: '5 0 5 5',
  83. cmargins: '0 0 0 0',
  84. tbar: [{
  85. text: 'Add Album',
  86. iconCls: 'add',
  87. scale: 'large',
  88. handler: function() {
  89. Ext.getCmp('album-tree').addAlbum();
  90. }
  91. },{
  92. text: 'Upload',
  93. iconCls: 'upload',
  94. scale: 'large',
  95. handler: function() {
  96. swfu.selectFiles();
  97. }
  98. }],
  99. listeners: {
  100. click: this.onAlbumClick,
  101. scope: this
  102. }
  103. },{
  104. xtype: 'tabpanel',
  105. region: 'center',
  106. id: 'img-tabpanel',
  107. margins: '5 5 5 0',
  108. activeItem: 0,
  109. enableTabScroll: true,
  110. items: this.getTabs()
  111. }]
  112. });
  113. tabPanel = Ext.getCmp('img-tabpanel');
  114. thumbPanel = tabPanel.getComponent('images-view');
  115. Imgorg.TagWin = new Imgorg.TagWindow();
  116. },
  117. getTabs: function() {
  118. var tabs = [{
  119. xtype: 'img-albumspanel',
  120. title: 'Albums',
  121. listeners: {
  122. openalbum: this.onOpenAlbum,
  123. scope: this
  124. }
  125. },Ext.apply({
  126. xtype: 'img-thumbpanel',
  127. itemId:'images-view'
  128. },this.getImageThumbConfig())];
  129. if (this.debugSWF) {
  130. tabs.push({
  131. title: 'debug',
  132. contentEl: 'SWFUpload_Console',
  133. listeners: {
  134. render: function() {
  135. Ext.fly('SWFUpload_Console').applyStyles({height: '100%', width: '100%'});
  136. }
  137. }
  138. });
  139. }
  140. return tabs;
  141. },
  142. getImageThumbConfig: function() {
  143. return {
  144. dvConfig: {
  145. listeners: {
  146. dblclick: function(view, idx, node, e) {
  147. var p = this.openImage(view.getStore().getAt(idx));
  148. p.show();
  149. },
  150. viewitem: function(view, node) {
  151. var recs = view.getSelectedRecords();
  152. for (var i = 0; i < recs.length; i++) {
  153. this.openImage(recs[i]);
  154. }
  155. },
  156. scope: this
  157. }
  158. }
  159. };
  160. },
  161. openImage: function(rec) {
  162. return tabPanel.add({
  163. xtype: 'img-panel',
  164. title: Ext.util.Format.ellipsis(rec.data.filename,15),
  165. url: rec.data.url,
  166. imageData: rec.data
  167. });
  168. },
  169. onOpenAlbum: function(ap, album, name) {
  170. var tab = tabPanel.add(Ext.apply({
  171. xtype: 'img-thumbpanel',
  172. closable: true,
  173. title: 'Album: '+name
  174. },this.getImageThumbConfig()));
  175. tab.albumFilter({
  176. id: album,
  177. text: name
  178. });
  179. tab.show();
  180. },
  181. onAlbumClick: function(node, e) {
  182. this.onOpenAlbum(null, node.attributes.id, node.attributes.text);
  183. },
  184. onFileQueued: function(swfu, file) {
  185. if (!uploadPanel) {
  186. uploadPanel = Ext.getCmp('img-tabpanel').add({
  187. title: 'Upload Queue',
  188. xtype: 'img-uploadqueue',
  189. swfu: swfu
  190. });
  191. uploadPanel.show();
  192. uploadPanel.addFile(swfu, file);
  193. } else {
  194. uploadPanel.show();
  195. }
  196. },
  197. getSwf: function() {
  198. return swfu;
  199. }
  200. }
  201. }();
  202. Ext.onReady(Imgorg.App.init,Imgorg.App);
  203. Ext.override(Ext.CompositeElementLite,{
  204. removeElement : function(keys, removeDom){
  205. var me = this, els = this.elements, el;
  206. Ext.each(keys, function(val){
  207. if (el = (els[val] || els[val = me.indexOf(val)])) {
  208. if(removeDom)
  209. el.dom ? el.remove() : Ext.removeNode(el);
  210. els.splice(val, 1);
  211. }
  212. });
  213. return this;
  214. }
  215. });