source: extensions/GrumPluginClasses/js/ui.download.js @ 17735

Last change on this file since 17735 was 17735, checked in by grum, 12 years ago

version 3.5.4 - fix minor bug & add new functions to framework

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1/**
2 * -----------------------------------------------------------------------------
3 * file: ui.download.js
4 * file version: 1.0.0
5 * date: 2012-09-04
6 *
7 * A jQuery plugin provided by the piwigo's plugin "GrumPluginClasses"
8 *
9 * -----------------------------------------------------------------------------
10 * Author     : Grum
11 *   email    : grum@piwigo.com
12 *   website  : http://www.grum.fr
13 *
14 *   << May the Little SpaceFrog be with you ! >>
15 * -----------------------------------------------------------------------------
16 *
17 *
18 *
19 *
20 * :: HISTORY ::
21 *
22 * | release | date       |
23 * | 1.0.0   | 2012/09/04 | first release
24 * |         |            |
25 * |         |            |
26 * |         |            |
27 * |         |            |
28 * |         |            |
29 * |         |            |
30 *
31 */
32
33
34
35/**
36 * Allows to download a file without having to open/refresh a page
37 *
38 * $.download(url)
39 *  => download file with the given url
40 *
41 * @param String url: a valid url
42 */
43$.download = function (url)
44{
45  var timer=null,
46      hif=null,
47
48    /**
49     * initialise the context
50     */
51    init = function (url)
52      {
53        hif=$('<iframe/>',
54            {
55              id:'hif',
56              style:'display:none;',
57              src:url
58            }
59          ).load(startDownload);
60        $('body').append(hif);
61      },
62
63    /**
64     * start file download
65     */
66    startDownload = function ()
67      {
68        timer=window.setInterval(
69            function ()
70            {
71              window.clearInterval(timer);
72              $(hif).remove();
73            }, 1500
74          );
75      };
76
77
78  init(url);
79} // $.downloadUrl
Note: See TracBrowser for help on using the repository browser.