3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">/*
9 * Sample Image Organizer utilizing Ext.Direct
10 * Tagging/Organizing into galleries
14 Ext.ns('Imgorg','Imgorg.App');
15 Imgorg.App = function() {
17 SWFUpload.onload = function() {
19 flash_url: "SWFUpload/Flash/swfupload.swf",
20 upload_url: "php/router.php",
21 file_size_limit: "100 MB",
23 file_types_description: "Image Files",
24 file_upload_limit: 100,
25 file_queue_limit: 100,
27 button_placeholder_id: "btnUploadHolder",
28 button_cursor: SWFUpload.CURSOR.HAND,
29 button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
30 file_queued_handler: function(file) {
31 Ext.ux.SwfuMgr.fireEvent('filequeued', this, file);
33 upload_start_handler: function(file) {
34 Ext.ux.SwfuMgr.fireEvent('uploadstart', this, file);
36 upload_progress_handler: function(file, complete, total) {
37 Ext.ux.SwfuMgr.fireEvent('uploadprogress', this, file, complete, total);
39 upload_error_handler: function(file, error, message) {
40 Ext.ux.SwfuMgr.fireEvent('uploaderror', this, file, error, message);
42 upload_success_handler: function(file, data, response) {
43 Ext.ux.SwfuMgr.fireEvent('uploadsuccess', this, file, data);
45 minimum_flash_version: "9.0.28",
47 extAction: 'Images', // The class to use
49 extMethod: 'upload' // The method to execute
50 //needs extTID – Transaction ID to associate with this request.
53 swfu = new SWFUpload(settings);
55 var view, thumbPanel, uploadPanel, tabPanel;
60 Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
62 Ext.BLANK_IMAGE_URL = '../../resources/images/default/s.gif';
63 Ext.Direct.addProvider(Imgorg.REMOTING_API);
65 Ext.ux.SwfuMgr.on('filequeued', this.onFileQueued, this);
70 xtype: 'img-albumtree',
86 Ext.getCmp('album-tree').addAlbum();
97 click: this.onAlbumClick,
106 enableTabScroll: true,
107 items: this.getTabs()
111 tabPanel = Ext.getCmp('img-tabpanel');
112 thumbPanel = tabPanel.getComponent('images-view');
113 Imgorg.TagWin = new Imgorg.TagWindow();
116 getTabs: function() {
118 xtype: 'img-albumspanel',
121 openalbum: this.onOpenAlbum,
125 xtype: 'img-thumbpanel',
127 },this.getImageThumbConfig())];
132 contentEl: 'SWFUpload_Console',
135 Ext.fly('SWFUpload_Console').applyStyles({height: '100%', width: '100%'});
143 getImageThumbConfig: function() {
147 dblclick: function(view, idx, node, e) {
148 var p = this.openImage(view.getStore().getAt(idx));
151 viewitem: function(view, node) {
152 var recs = view.getSelectedRecords();
153 for (var i = 0; i < recs.length; i++) {
154 this.openImage(recs[i]);
163 openImage: function(rec) {
164 return tabPanel.add({
166 title: Ext.util.Format.ellipsis(rec.data.filename,15),
172 onOpenAlbum: function(ap, album, name) {
173 var tab = tabPanel.add(Ext.apply({
174 xtype: 'img-thumbpanel',
176 title: 'Album: '+name
177 },this.getImageThumbConfig()));
185 onAlbumClick: function(node, e) {
186 this.onOpenAlbum(null, node.attributes.id, node.attributes.text);
189 onFileQueued: function(swfu, file) {
191 uploadPanel = Ext.getCmp('img-tabpanel').add({
192 title: 'Upload Queue',
193 xtype: 'img-uploadqueue',
197 uploadPanel.addFile(swfu, file);
209 Ext.onReady(Imgorg.App.init,Imgorg.App);
211 Ext.override(Ext.CompositeElementLite,{
212 removeElement : function(keys, removeDom){
213 var me = this, els = this.elements, el;
214 Ext.each(keys, function(val){
215 if (el = (els[val] || els[val = me.indexOf(val)])) {
217 el.dom ? el.remove() : Ext.removeNode(el);