Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// This file is part of VPL for Moodle - http://vpl.dis.ulpgc.es/
//
// VPL for Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// VPL for Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with VPL for Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Binary files extension method. Add to VPLFile object.
*
* @package mod_vpl
* @copyright 2013 Juan Carlos Rodríguez-del-Pino
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Juan Carlos Rodríguez-del-Pino <jcrodriguez@dis.ulpgc.es>
*/
define(
[
'jquery',
'mod_vpl/vplutil',
],
function($, VPLUtil) {
return function() {
this.isBinary = function() {
return true;
};
this.setContent = function(c) {
this.setmodified();
this.setContent(c);
this.updateDataURL();
};
this.updateDataURL = function() {
var fileName = this.getFileName();
var value = this.getContent();
var tid = this.getTId();
if (VPLUtil.isImage(fileName)) {
var prevalue = 'data:' + VPLUtil.getMIME(fileName) + ';base64,';
$(tid).find('img').attr('src', prevalue + value);
} else {
$(tid).find('img').attr('src', '');
}
};
this.adjustSize = function() {
if (!this.isOpen()) {
return false;
}
var editTag = $(this.getTId());
if (editTag.length === 0) {
return false;
}
var tabs = editTag.parent();
var newHeight = tabs.height();
newHeight -= editTag.position().top;
if (newHeight != editTag.height()) {
editTag.height(newHeight);
return true;
}
return false;
};
this.open = function() {
this.showFileName();
var fileName = this.getFileName();
var tid = this.getTId();
this.setOpen(true);
if (VPLUtil.isImage(fileName)) {
$(tid).addClass('vpl_ide_img').append('<img />');
this.updateDataURL();
} else {
$(tid).addClass('vpl_ide_binary').text(VPLUtil.str('binaryfile'));
}
};
this.close = function() {
this.setOpen(false);
};
};
}
);