app:download
| Widget Name | appcelerator download |
| Element | <app:download> |
| Author | Hamed Hashemi |
| Homepage | http://www.appcelerator.org |
| Description | download widget |
- Required Attributes (1)
- Optional Attributes (4)
- Examples (1)
- Source code
| Name | Type | Description | Default value |
|---|---|---|---|
| service | Unknown | Not specified | Not specified |
| Name | Type | Description | Default value |
|---|---|---|---|
| fileProperty | Unknown | Not specified | file |
| mimetype | Unknown | Not specified | application/octet-stream |
| mimetypeProperty | Unknown | Not specified | type |
| error | Unknown | Not specified | Not specified |
Back to menuExample: Simple Example
This is a simple example that uses the <app:download>.
<app:download> </app:download>
1 /* 2 * This file is part of Appcelerator. 3 * 4 * Copyright (C) 2006-2008 by Appcelerator, Inc. All Rights Reserved. 5 * For more information, please visit http://www.appcelerator.org 6 * 7 * Appcelerator is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * 20 */ 21 22 23 Appcelerator.Widget.Download = 24 { 25 getName: function() 26 { 27 return 'appcelerator download'; 28 }, 29 getDescription: function() 30 { 31 return 'download widget'; 32 }, 33 getVersion: function() 34 { 35 return 1.0; 36 }, 37 getSpecVersion: function() 38 { 39 return 1.0; 40 }, 41 getAuthor: function() 42 { 43 return 'Hamed Hashemi'; 44 }, 45 getModuleURL: function () 46 { 47 return 'http://www.appcelerator.org'; 48 }, 49 isWidget: function () 50 { 51 return true; 52 }, 53 getWidgetName: function() 54 { 55 return 'app:download'; 56 }, 57 getActions: function() 58 { 59 return ['execute']; 60 }, 61 getAttributes: function() 62 { 63 return [{name: 'service', optional: false}, 64 {name: 'fileProperty', optional: true, defaultValue: 'file'}, 65 {name: 'mimetype', optional: true, defaultValue: 'application/octet-stream'}, 66 {name: 'mimetypeProperty', optional: true, defaultValue: 'type'}, 67 {name: 'error', optional: true}]; 68 }, 69 execute: function(id,parameters,data,scope) 70 { 71 parameters['idcount'] = parameters['idcount'] + 1; 72 var targetid = parameters['id']+'_target_'+parameters['idcount']; 73 74 for (var k in data) 75 { 76 if (typeof(data[k]) == 'string') 77 { 78 parameters['src'] += '&' + k + '=' + data[k]; 79 } 80 } 81 82 var html = '<iframe name="'+ targetid+'" id="'+targetid+'" width="1" height="1" src="'+parameters['src']+'" style="position:absolute;top:-400px;left:-400px;width:1px;height:1px;"></iframe>'; 83 new Insertion.Bottom(document.body, html); 84 }, 85 buildWidget: function(element,parameters,state) 86 { 87 var download = Appcelerator.ServerConfig['download'].value; 88 var fileProperty = parameters['fileProperty']; 89 var mimetype = parameters['mimetype']; 90 var mimetypeProperty = parameters['mimetypeProperty']; 91 var src = download+'?type='+parameters['service']+'&fileProperty='+fileProperty+'&mimetype='+mimetype+'&mimetypeProperty='+mimetypeProperty; 92 93 if (parameters['error']) 94 { 95 src += '&error=' + error; 96 } 97 parameters['src'] = src; 98 parameters['idcount'] = 0; 99 100 return { 101 'position' : Appcelerator.Compiler.POSITION_REPLACE, 102 'presentation' : '' 103 }; 104 } 105 }; 106 107 Appcelerator.Widget.register('app:download',Appcelerator.Widget.Download); 108
Chapters
- Web Expressions (Interaction)
- Web Expressions (Visual)
- Web Expression Macros
-
Widget Reference
- app:as_flexflow
- app:box
- app:button
- app:calendar
- app:chart
- app:content
- app:datacache
- app:datatable
- » app:download
- app:editinplace
- app:ext_grid
- app:ext_paging_grid
- app:ext_tree
- app:field
- app:folder
- app:graphical_music_player
- app:http
- app:if
- app:imagetransition
- app:iterator
- app:message
- app:modalbox
- app:modaldialog
- app:mp3player
- app:music_player
- app:pagination
- app:panel
- app:progressbar
- app:script
- app:search
- app:security
- app:shadowbox
- app:simple_panel
- app:statemachine
- app:stopwatch
- app:tabpanel
- app:template
- app:tooltip
- app:upload
- app:validation
- app:widget
- app:yui_map
- CSS Helper Classes
- Advanced Configuration
- Debugging
- Forms
- Localization
- Interpolation
- Javascript Variables
- Javascript Functions
- Service Broker