source: trunk/plugins/ImageManager/assets/editorFrame.js @ 999

Last change on this file since 999 was 999, checked in by ray, 11 years ago

#1195 Allow to specify an external url to load a plugin from

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 3.1 KB
Line 
1/**
2 * Javascript used by the editorFrame.php, it basically initializes the frame.
3 * @author $Author:ray $
4 * @version $Id:editorFrame.js 677 2007-01-19 22:24:36Z ray $
5 * @package ImageManager
6 */
7
8var topDoc = window.top.document;
9
10var t_cx = topDoc.getElementById('cx');
11var t_cy = topDoc.getElementById('cy');
12var t_cw = topDoc.getElementById('cw');
13var t_ch = topDoc.getElementById('ch');
14
15var m_sx = topDoc.getElementById('sx');
16var m_sy = topDoc.getElementById('sy');
17var m_w = topDoc.getElementById('mw');
18var m_h = topDoc.getElementById('mh');
19var m_a = topDoc.getElementById('ma');
20var m_d = topDoc.getElementById('md');
21
22var s_sw = topDoc.getElementById('sw');
23var s_sh = topDoc.getElementById('sh');
24
25var r_ra = topDoc.getElementById('ra');
26
27var pattern = "img/2x2.gif";
28
29function doSubmit(action)
30{
31    if (action == 'crop')
32    {
33        // backend_url is set by the calling page. For now we assume it contains
34                  // a trailing &
35
36        var url = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=crop&params="+parseInt(t_cx.value)+','+parseInt(t_cy.value)+','+ parseInt(t_cw.value)+','+parseInt(t_ch.value);
37
38        //alert(url);
39        location.href = url;
40
41        //location.reload();
42    }   
43    else if (action == 'scale')
44    {
45        var url = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=scale&params="+parseInt(s_sw.value)+','+parseInt(s_sh.value);
46        //alert(url);
47        location.href = url;
48       
49    }
50    else if (action == 'rotate')
51    {
52        var flip = topDoc.getElementById('flip');
53
54        if(flip.value == 'hoz' || flip.value == 'ver')
55            location.href = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=flip&params="+flip.value;
56        else if (isNaN(parseFloat(r_ra.value))==false)
57            location.href = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=rotate&params="+parseFloat(r_ra.value);
58    }
59    else if(action == 'save') {
60        var s_file = topDoc.getElementById('save_filename');
61        var s_format = topDoc.getElementById('save_format');
62        var s_quality = topDoc.getElementById('quality');
63
64        var format = s_format.value.split(",");
65        if(s_file.value.length <= 0)
66                {
67            alert(i18n('Please enter a filename to save.'));
68        }
69        else
70        {
71            var filename = encodeURI(s_file.value);
72            var quality = parseInt(s_quality.value);
73            var url = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=save&params="+format[0]+","+quality+"&file="+filename;
74            //alert(url);
75            location.href = url;
76        }
77    }
78}
79
80
81function addEvent(obj, evType, fn)
82{
83        if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; }
84        else if (obj.attachEvent) {  var r = obj.attachEvent("on"+evType, fn);  return r;  }
85        else {  return false; }
86}
87
88var jg_doc
89
90init = function()
91{
92        jg_doc = new jsGraphics("imgCanvas"); // draw directly into document
93        jg_doc.setColor("#000000"); // black
94
95        initEditor();
96};
97
98addEvent(window, 'load', init);
Note: See TracBrowser for help on using the repository browser.