Ignore:
Timestamp:
02/20/10 10:22:59 (10 years ago)
Author:
gogo
Message:

ticket:1502

Add support for attributes being set in MootoolsFileManager? for images.
Split out the "modes" of MootoolsFileManager? into different javascript files.

Location:
trunk/plugins/MootoolsFileManager/mootools-filemanager/Source
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/MootoolsFileManager/mootools-filemanager/Source/Additions.js

    r1239 r1245  
    8888                if (this.options.content) this.el.getElement('div').adopt(this.options.content); 
    8989                 
    90                 Array.each(this.options.buttons, function(v){ 
     90                Array.each(this.options.buttons, function(v){            
    9191                        new Element('button', {'class': 'fm-dialog-' + v, text: this.options.language[v]}).addEvent('click', (function(e){ 
    9292                                if (e) e.stop(); 
  • trunk/plugins/MootoolsFileManager/mootools-filemanager/Source/FileManager.js

    r1239 r1245  
    4040  - onHide: event fired when FileManager closes 
    4141  - onPreview: event fired when the user clicks an image in the preview 
     42  - onDetails: event fired when the details are updated after user picking a file 
     43  - onHidePreview: event fired when the "preview" is hidden (usually, user uploading file, or changing directory) 
    4244... 
    4345*/ 
     
    5658                onShow: $empty, 
    5759                onHide: $empty, 
    58                 onPreview: $empty*/ 
     60                onPreview: $empty, 
     61                onDetails: $empty, // Xinha: Fired when an item is picked form the files list, supplied object (eg {width: 123, height:456} ) 
     62                onHidePreview: $empty, // Xinha: Fired when the preview is hidden (eg when uploading) */ 
    5963                directory: '', 
    6064                url: null, 
     
    103107                         
    104108                        if (self.Current) self.Current.removeClass('selected'); 
    105                         self.Current = this.addClass('selected'); 
     109                        self.Current = this.addClass('selected'); // NB: Also sets self.Current 
     110       
     111      // Xinha: We need to have Current assigned before fillInfo because fillInfo adds to it       
    106112      self.fillInfo(file); 
    107113                        self.switchButton(); 
     
    109115                this.browser = new Element('ul', {'class': 'filemanager-browser'}).addEvents({ 
    110116                        click: (function(){ 
    111                                 return self.deselect(); 
     117                                // return self.deselect(); 
    112118                        }), 
    113119                        'click:relay(li span.fi)': this.relayClick 
    114120                }).inject(this.el); 
    115121                 
    116                 this.addMenuButton('create'); 
     122                if (this.options.upload)     this.addMenuButton('create'); // Xinha: Create directory permission = upload 
    117123                if (this.options.selectable) this.addMenuButton('open'); 
    118124                 
     
    124130                ]); 
    125131 
    126                 this.info.adopt([head, new Element('h2', {text: this.language.information})]); 
     132    // Xinha: We need to groupt he headers and lists togethor because we will 
     133    // use some CSS to reorganise a bit.  So we create "infoarea" which  
     134    // will contain the h2 and list for the "Information", that is 
     135    // modification date, size, directory etc... 
     136    var infoarea = new Element('div', {'class': 'filemanager-info-area'}); 
     137 
     138                this.info.adopt([head, infoarea.adopt(new Element('h2', {text: this.language.information}))]); 
    127139 
    128140                new Element('dl').adopt([ 
     
    135147                        new Element('dt', {text: this.language.dir}), 
    136148                        new Element('dd', {'class': 'filemanager-dir'}) 
    137                 ]).inject(this.info); 
     149                ]).inject(infoarea); 
    138150                 
    139151                this.preview = new Element('div', {'class': 'filemanager-preview'}).addEvent('click:relay(img.preview)', function(){ 
    140152                        self.fireEvent('preview', [this.get('src')]); 
    141153                }); 
    142                 this.info.adopt([ 
     154                 
     155        // Xinha: We need to group the headers and lists togethor because we will 
     156    // use some CSS to reorganise a bit.  So we create "filemanager-preview-area" which  
     157    // will contain the h2 for the preview and also the preview content returned from 
     158    // Backend/FileManager.php 
     159                this.info.adopt((new Element('div', {'class': 'filemanager-preview-area'})).adopt([ 
    143160                        new Element('h2', {'class': 'filemanager-headline', text: this.language.preview}), 
    144161                        this.preview 
    145                 ]); 
     162                ])); 
    146163                 
    147164                this.closeIcon = new Element('div', { 
     
    239256                 
    240257                this.fireEvent('complete', [ 
     258      // Xinha: The URL path returned by normal MootoolsFileManager is odd, it includes the last component 
     259      // of the base directory, that is, if your base is /foo/bar/images then we get something like 
     260      // images/narf.jpg. 
     261      // To work around this we take the URL which was worked out by Backend/FileManager.php 
     262      // and return that as the url.        
    241263                        this.normalize(this.Current.file_data ? this.Current.file_data.url : this.Directory + '/' + this.Current.retrieve('file').name), 
    242264                        this.Current.retrieve('file') 
     
    342364        }, 
    343365 
    344         rename: function(e, file){ 
     366        rename: function(e, file){       
    345367                e.stop(); 
    346368                this.tips.hide(); 
     
    439461                        self.relayClick.apply(el); 
    440462                }; 
     463                 
     464                if(0) // This (drag to move into subdirectory) is breaking IE, we don't need it that badly 
     465          // See: http://github.com/cpojer/mootools-filemanager/issues#issue/11 
    441466                $$(els[0]).makeDraggable({ 
    442467                        droppables: $$(this.droppables, els[1]), 
     
    538563                this.fireHooks('cleanup'); 
    539564                this.preview.empty(); 
    540  
     565                     
     566    // Xinha: We need to remove our custom attributes form when the preview is hidden  
     567    this.fireEvent('hidePreview'); 
     568     
    541569                this.info.getElement('h1').set('text', file.name); 
    542570                this.info.getElement('dd.filemanager-modified').set('text', file.date); 
     
    587615                                }); 
    588616                                 
     617                                // Xinha: We need to add in a form for setting the attributes of images etc, 
     618                                // so we add this event and pass it the information we have about the item  
     619                                // as returned by Backend/FileManager.php 
     620                                this.fireEvent('details', [j]); 
     621                                 
     622                                // Xinha: We also want to hold onto the data so we can access it 
     623                                // when selecting the image. 
    589624                                if(this.Current) this.Current.file_data = j; 
    590625                        }).bind(this), 
     
    642677         
    643678        initialize: function(options, filebrowser){ 
     679    // Xinha: We need ALL requests from the FileManager to have our authorisation data on it 
     680    // normal MootoolsFileManager only has the flash send it :-(     
    644681    if(filebrowser) 
    645682    {       
     
    647684    } 
    648685     
     686    // Xinha: We also need to clean up the url because our backend already includes a query string 
     687    // and MootoolsFileManager adds ?event=..... indiscriminately, our query string always 
     688    // ends in an ampersand, so we can just clean up '&?event=' to be '&event=' 
    649689    options.url = options.url.replace(/&\?event=/, '&event='); 
    650690     
  • trunk/plugins/MootoolsFileManager/mootools-filemanager/Source/Uploader.js

    r1239 r1245  
    7676                        }), 
    7777                        list: new Element('ul', {'class': 'filemanager-uploader-list'}), 
    78                         uploader: new Element('div', {opacity: 0}).adopt( 
     78                        uploader: new Element('div', {opacity: 0, 'class': 'filemanager-uploader-area'}).adopt( 
    7979                                new Element('h2', {text: this.language.upload}), 
    8080                                new Element('div', {'class': 'filemanager-uploader'}) 
     
    223223                                self.fillInfo(); 
    224224                                self.info.getElement('h2.filemanager-headline').setStyle('display', 'none'); 
    225                                 self.preview.adopt(self.upload.uploader); 
     225                                self.info.adopt(self.upload.uploader); 
    226226                                self.upload.uploader.fade(1); 
    227227                        }, 
Note: See TracChangeset for help on using the changeset viewer.