Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Gitlab has been updated. More info
here
and
there
.
Show more breadcrumbs
w2pext
plugin_dbui
Commits
4e30bcae
Commit
4e30bcae
authored
14 years ago
by
Renaud Le Gac
Browse files
Options
Downloads
Patches
Plain Diff
Add a new class to download file pressing a button.
parent
5e7109f3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
static/plugin_dbui/src/appbuttondownload.js
+62
-0
62 additions, 0 deletions
static/plugin_dbui/src/appbuttondownload.js
with
62 additions
and
0 deletions
static/plugin_dbui/src/appbuttondownload.js
0 → 100644
+
62
−
0
View file @
4e30bcae
/**
* A button to download file from the server
*
* @extends Ext.Button
* @version $Id$
*
*/
Ext
.
namespace
(
'
App
'
);
App
.
ButtonDownload
=
Ext
.
extend
(
Ext
.
Button
,
{
/**
* @cfg{String} url pointing to the server controller
* which will return the file
*/
url
:
undefined
,
/**
* private method requests by the component model of ExtJS
*/
initComponent
:
function
()
{
// initialize the underlying class
App
.
ButtonDownload
.
superclass
.
initComponent
.
call
(
this
);
// download when the button is pressed
this
.
on
(
'
click
'
,
this
.
onDownload
,
this
);
},
/**
* Handler to download the file
* The scope is the button.
*
* NOTE: this method add and iframe at the end of the DOM document
* the source of the iframe is the url pointing on the server conroller.
* The latter returun a document which is automatically loaded.
*
* Method suggested on the sencha forum:
* www.sencha.com/forum/showthread.php?26471-Download-File-on%28-click-%29
*/
onDownload
:
function
(
button
,
event
)
{
// remove existing iframe
try
{
Ext
.
destroy
(
Ext
.
get
(
'
downloadIframe
'
));
}
catch
(
err
)
{}
// create a fresh iframe
Ext
.
DomHelper
.
append
(
document
.
body
,
{
tag
:
'
iframe
'
,
id
:
'
downloadIframe
'
,
frameBorder
:
0
,
width
:
0
,
height
:
0
,
css
:
'
display:none;visibility:hidden;height:0px;
'
,
src
:
this
.
url
});
}
});
Ext
.
reg
(
'
xbuttondownload
'
,
App
.
ButtonDownload
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment