summaryrefslogtreecommitdiff
path: root/frontend/delta/js/Clipperz/Style.js
Unidiff
Diffstat (limited to 'frontend/delta/js/Clipperz/Style.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/delta/js/Clipperz/Style.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/frontend/delta/js/Clipperz/Style.js b/frontend/delta/js/Clipperz/Style.js
new file mode 100644
index 0000000..acbe71b
--- a/dev/null
+++ b/frontend/delta/js/Clipperz/Style.js
@@ -0,0 +1,89 @@
1/*
2
3Copyright 2008-2013 Clipperz Srl
4
5This file is part of Clipperz, the online password manager.
6For further information about its features and functionalities please
7refer to http://www.clipperz.com.
8
9* Clipperz is free software: you can redistribute it and/or modify it
10 under the terms of the GNU Affero General Public License as published
11 by the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14* Clipperz is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU Affero General Public License for more details.
18
19* You should have received a copy of the GNU Affero General Public
20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
21
22*/
23
24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
25if (typeof(Clipperz.Style) == 'undefined') { Clipperz.Style = {}; }
26
27Clipperz.Style.VERSION = "0.1";
28Clipperz.Style.NAME = "Clipperz.DOM";
29
30MochiKit.Base.update(Clipperz.Style, {
31
32 //-------------------------------------------------------------------------
33
34 '__repr__': function () {
35 return "[" + this.NAME + " " + this.VERSION + "]";
36 },
37
38 //-------------------------------------------------------------------------
39
40 'toString': function () {
41 return this.__repr__();
42 },
43
44 //-------------------------------------------------------------------------
45
46 'applyZebraStylesToTable': function(aTable) {
47 var tbody;
48 var tbodyRows;
49 var i,c;
50
51 tbody = MochiKit.DOM.getFirstElementByTagAndClassName('tbody', null, aTable);
52 tbodyRows = tbody.childNodes;
53 // tbodyRows = MochiKit.DOM.getElementsByTagAndClassName('tr', null, tbody)
54 c = tbodyRows.length;
55 for (i=0; i<c; i++) {
56 var element;
57
58 element = YAHOO.Element.get(tbodyRows[i]);
59 element.addClass(((i%2 == 0) ? "zebra_odd": "zebra_even"));
60 element.removeClass(((i%2 == 1) ? "zebra_odd": "zebra_even"));
61 }
62 },
63
64 //-------------------------------------------------------------------------
65
66 'getSizeAndPosition': function (anElement) {
67 var result;
68
69 if (anElement != null) {
70 result ={ dimensions:MochiKit.Style.getElementDimensions(anElement), position:MochiKit.Style.getElementPosition(anElement)};
71 } else {
72 result ={ dimensions:MochiKit.Style.getViewportDimensions(), position:MochiKit.Style.getViewportPosition()};
73 }
74
75 return result;
76 },
77
78 'setBackgroundGradient': function (anElement, someParameters) {
79 // background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ff9955), to(#ff6622), color-stop(1,#333333));
80 // background: -moz-linear-gradient(0% 100% 90deg,#ff6622, #ff9955);
81 MochiKit.Style.setStyle(anElement, {'background': '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + someParameters['from'] + '), to(' + someParameters['to'] + '), color-stop(1,#333333))'});
82 MochiKit.Style.setStyle(anElement, {'background': '-moz-linear-gradient(0% 100% 90deg,' + someParameters['to'] + ', ' + someParameters['from'] + ')'});
83 },
84
85 //-------------------------------------------------------------------------
86 __syntaxFix__: "syntax fix"
87
88});
89