svn: /web/doc-editor/trunk/js/ui/cmp/ FilePanel.js

[email protected] (Hannes Magnusson)
Newsgroups php.doc.web
Message-ID <[email protected]>
bjori                                    Wed, 08 Jun 2011 18:58:23 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=311937

Log:
Only asked to save the file if it has been modified

Changed paths:
    U   web/doc-editor/trunk/js/ui/cmp/FilePanel.js

Modified: web/doc-editor/trunk/js/ui/cmp/FilePanel.js
===================================================================
--- web/doc-editor/trunk/js/ui/cmp/FilePanel.js	2011-06-08 17:16:55 UTC (rev 311936)
+++ web/doc-editor/trunk/js/ui/cmp/FilePanel.js	2011-06-08 18:58:23 UTC (rev 311937)
@@ -811,15 +811,23 @@
                 hidden : !(this.lang === 'en' && this.fname.substr(-3) === 'xml'),
                 tooltip: _('<b>Preview</b> in a popup'),
                 handler: function() {
-                    Ext.Msg.alert(_('Information'), _('You must save your file in order to preview the result.'), function(btn){
+                    var needsave  = Ext.getCmp(id_prefix + '-FILE-' + this.fid).cmpFile.isModified;
+                    if (needsave) {
+                        Ext.Msg.alert(_('Information'), _('You must save your file in order to preview the result.'), function(btn){
+                            if (btn == 'ok'){
+                                new ui.cmp.PreviewFile({
+                                    path: this.lang + this.fpath + this.fname
+                                });
+                            }
+                        }, this);
+                    }
+                    else {
                         if (btn == 'ok'){
                             new ui.cmp.PreviewFile({
                                 path: this.lang + this.fpath + this.fname
                             });
                         }
-                    }, this);
-
-
+                    }
                 }
             },'->',
             new ui.cmp._FilePanel.tbar.items.usernotes({
@@ -1022,4 +1030,4 @@
         });
         ui.cmp.FilePanel.superclass.initComponent.call(this);
     }
-});
\ No newline at end of file
+});
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.