Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Printing/Record.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/Printing/Record.js | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Printing/Record.js b/frontend/beta/js/Clipperz/PM/Components/Printing/Record.js new file mode 100644 index 0000000..910d4b1 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Printing/Record.js | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | it and/or modify it under the terms of the GNU Affero General Public | ||
15 | License as published by the Free Software Foundation, either version | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | */ | ||
28 | |||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Printing) == 'undefined') { Clipperz.PM.Components.Printing = {}; } | ||
33 | |||
34 | Clipperz.PM.Components.Printing.Record = function(args) { | ||
35 | args = args || {}; | ||
36 | |||
37 | this._record = args['record']; | ||
38 | |||
39 | return this; | ||
40 | } | ||
41 | |||
42 | MochiKit.Base.update(Clipperz.PM.Components.Printing.Record.prototype, { | ||
43 | |||
44 | 'record': function() { | ||
45 | return this._record; | ||
46 | }, | ||
47 | |||
48 | //------------------------------------------------------------------------- | ||
49 | |||
50 | 'deferredDrawToWindow': function(aWindow) { | ||
51 | vardeferredResult; | ||
52 | |||
53 | deferredResult = new MochiKit.Async.Deferred(); | ||
54 | deferredResult.addCallback(MochiKit.Base.method(this.record(), 'deferredData')); | ||
55 | deferredResult.addCallback(MochiKit.Base.method(this, 'appendToWindow', aWindow)); | ||
56 | deferredResult.callback(); | ||
57 | return deferredResult; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'appendToWindow': function(aWindow) { | ||
63 | MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function() { | ||
64 | var newBlock; | ||
65 | var fields; | ||
66 | |||
67 | fields = MochiKit.Base.concat( | ||
68 | MochiKit.Base.map(MochiKit.Base.bind(function(aField) { | ||
69 | var result; | ||
70 | var dt, dd; | ||
71 | var label, value; | ||
72 | |||
73 | label = aField.label(); | ||
74 | value = aField.value(); | ||
75 | dt = MochiKit.DOM.createDOM('DT', null, label); | ||
76 | dd = MochiKit.DOM.createDOM('DD', null, value) | ||
77 | result = [dt, dd]; | ||
78 | |||
79 | return result | ||
80 | }, this), MochiKit.Base.values(this.record().currentVersion().fields())) | ||
81 | ); | ||
82 | |||
83 | newBlock = MochiKit.DOM.DIV({'class': 'recordBlock'}, | ||
84 | MochiKit.DOM.H2(null, this.record().label()), | ||
85 | MochiKit.DOM.DIV({'class': 'recordNotes'}, MochiKit.Base.map(MochiKit.Base.partial(MochiKit.DOM.P, null), this.record().notes().split("\n"))), | ||
86 | MochiKit.DOM.createDOM('DL', null, fields) | ||
87 | ); | ||
88 | MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, newBlock); | ||
89 | |||
90 | }, this)); | ||
91 | }, | ||
92 | |||
93 | //------------------------------------------------------------------------- | ||
94 | __syntaxFix__: "syntax fix" | ||
95 | }); | ||