summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-02 23:56:18 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-02 23:56:18 (UTC)
commitef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (unidiff)
treec403752d66a2c4775f00affd4fa8431b29c5b68c /frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js
parent597ecfbc0249d83e1b856cbd558340c01237a360 (diff)
downloadclipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.zip
clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.gz
clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.bz2
First version of the newly restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js165
1 files changed, 165 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js
new file mode 100644
index 0000000..7aaca3e
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js
@@ -0,0 +1,165 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer 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
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
32if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; }
33
34//#############################################################################
35
36Clipperz.PM.Components.RecordDetail.HeaderComponent = function(anElement, args) {
37 args = args || {};
38
39 Clipperz.PM.Components.RecordDetail.HeaderComponent.superclass.constructor.call(this, anElement, args);
40 this.mainComponent().addEditComponent(this);
41
42 this._saveButton = null;
43
44 this.render();
45
46 return this;
47}
48
49//=============================================================================
50
51YAHOO.extendX(Clipperz.PM.Components.RecordDetail.HeaderComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, {
52
53 'toString': function() {
54 return "Clipperz.PM.Components.RecordDetail.HeaderComponent component";
55 },
56
57 //-------------------------------------------------------------------------
58
59 'render': function() {
60 var editButton;
61
62//MochiKit.Logging.logDebug(">>> RecordDetail.HeaderComponent.appendTo");
63 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'recordDetailButtonsBox', children:[
64 {tag:'div', id:this.getId('editButtonBox'), children:[
65 {tag:'table', cls:'recordDetailButtonsTABLE', border:'0', cellpadding:'0', cellspacing:'0', children:[
66 {tag:'tbody', children:[
67 {tag:'tr', children:[
68 {tag:'td', align:'center', children:[
69 {tag:'div', id:this.getId('editButton')}
70 ]}
71 ]}
72 ]}
73 ]}
74 ]},
75 {tag:'div', id:this.getId('saveCancelButtonBox'), children:[
76 {tag:'table', cls:'recordDetailButtonsTABLE', border:'0', cellpadding:'0', cellspacing:'0', children:[
77 {tag:'tbody', children:[
78 {tag:'tr', children:[
79 {tag:'td', width:'49%', align:'right', children:[
80 {tag:'div', id:this.getId('saveButton')}
81 ]},
82 {tag:'td', html:'&nbsp'},
83 {tag:'td', width:'49%', align:'left', children:[
84 {tag:'div', id:this.getId('cancelButton')}
85 ]}
86 ]}
87 ]}
88 ]}
89 ]}
90 ]});
91
92 this.getElement('editButtonBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY);
93 this.getElement('saveCancelButtonBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY);
94
95 editButton = new YAHOO.ext.Button(this.getDom('editButton'), {text:Clipperz.PM.Strings['recordDetailEditButtonLabel'], handler:this.editButtonHandler, scope:this});
96 this.setSaveButton(new YAHOO.ext.Button(this.getDom('saveButton'), {text:Clipperz.PM.Strings['recordDetailSaveButtonLabel'], handler:this.saveButtonHandler, scope:this}));
97 new YAHOO.ext.Button(this.getDom('cancelButton'), {text:Clipperz.PM.Strings['recordDetailCancelButtonLabel'], handler:this.cancelButtonHandler, scope:this});
98
99 if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) {
100 editButton.disable();
101 }
102
103 this.update();
104//MochiKit.Logging.logDebug("<<< RecordDetail.HeaderComponent.appendTo");
105 },
106
107 //-------------------------------------------------------------------------
108
109 'updateViewMode': function() {
110//MochiKit.Logging.logDebug(">>> HeaderComponent.updateViewMode");
111 this.getElement('editButtonBox').show();
112 this.getElement('saveCancelButtonBox').hide();
113//MochiKit.Logging.logDebug("<<< HeaderComponent.updateViewMode");
114 },
115
116 //-------------------------------------------------------------------------
117
118 'updateEditMode': function() {
119 this.getElement('editButtonBox').hide();
120 this.getElement('saveCancelButtonBox').show();
121 if (this.mainComponent().enableSaveButton() == true) {
122//MochiKit.Logging.logDebug("--- HeaderComponent.updateViewMode - ENABLE");
123 this.saveButton().enable();
124 } else {
125 this.saveButton().disable();
126 }
127 },
128
129 //-------------------------------------------------------------------------
130
131 'saveButton': function() {
132 return this._saveButton;
133 },
134
135 'setSaveButton': function(aValue) {
136 this._saveButton = aValue;
137 },
138
139 //-------------------------------------------------------------------------
140
141 'editButtonHandler': function(anEvent) {
142 this.mainComponent().setEditMode('EDIT');
143 },
144
145 //-------------------------------------------------------------------------
146
147 'saveButtonHandler': function(anEvent) {
148//MochiKit.Logging.logDebug(">>> RecordDetail.HeaderComponent.saveButtonHandler");
149 this.mainComponent().setEditMode('VIEW', this.getElement('saveButton'));
150//MochiKit.Logging.logDebug("<<< RecordDetail.HeaderComponent.saveButtonHandler");
151 },
152
153 //-------------------------------------------------------------------------
154
155 'cancelButtonHandler': function(anEvent) {
156 this.record().cancelChanges();
157//MochiKit.Logging.logDebug("--- HeaderComponent.cancelButtonHandler - " + Clipperz.Base.serializeJSON(this.record().currentDataSnapshot()));
158 this.mainComponent().setEditMode('VIEW', null, true);
159 },
160
161 //-------------------------------------------------------------------------
162
163 __syntaxFix__: "syntax fix"
164});
165