Diffstat (limited to 'frontend/delta/js/Clipperz/YUI/Utils.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/delta/js/Clipperz/YUI/Utils.js | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/frontend/delta/js/Clipperz/YUI/Utils.js b/frontend/delta/js/Clipperz/YUI/Utils.js new file mode 100644 index 0000000..4def842 --- a/dev/null +++ b/frontend/delta/js/Clipperz/YUI/Utils.js | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2013 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz, the online password manager. | ||
6 | For further information about its features and functionalities please | ||
7 | refer 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 | |||
24 | if (typeof YAHOO == 'undefined') { YAHOO = {}; }; | ||
25 | if (typeof YAHOO.util == 'undefined') { YAHOO.util = {}; }; | ||
26 | if (typeof YAHOO.util.Dom == 'undefined') { YAHOO.util.Dom = {}; }; | ||
27 | |||
28 | YAHOO.extend = function(subc, superc, overrides) { | ||
29 | var F = function() {}; | ||
30 | F.prototype=superc.prototype; | ||
31 | subc.prototype=new F(); | ||
32 | subc.prototype.constructor=subc; | ||
33 | subc.superclass=superc.prototype; | ||
34 | if (superc.prototype.constructor == Object.prototype.constructor) { | ||
35 | superc.prototype.constructor=superc; | ||
36 | } | ||
37 | |||
38 | if (overrides) { | ||
39 | for (var i in overrides) { | ||
40 | subc.prototype[i]=overrides[i]; | ||
41 | } | ||
42 | } | ||
43 | }; | ||
44 | |||
45 | YAHOO.override = function(origclass, overrides){ | ||
46 | if(overrides){ | ||
47 | var p = origclass.prototype; | ||
48 | for(var method in overrides){ | ||
49 | p[method] = overrides[method]; | ||
50 | } | ||
51 | } | ||
52 | }; | ||
53 | |||
54 | YAHOO.extendX = function(subclass, superclass, overrides){ | ||
55 | YAHOO.extend(subclass, superclass); | ||
56 | subclass.override = function(o){ | ||
57 | YAHOO.override(subclass, o); | ||
58 | }; | ||
59 | if(!subclass.prototype.override){ | ||
60 | subclass.prototype.override = function(o){ | ||
61 | for(var method in o){ | ||
62 | this[method] = o[method]; | ||
63 | } | ||
64 | }; | ||
65 | } | ||
66 | if(overrides){ | ||
67 | subclass.override(overrides); | ||
68 | }; | ||
69 | |||
70 | }; | ||
71 | |||
72 | YAHOO.util.Dom.get = function(el) { | ||
73 | if (!el) { return null; } // nothing to work with | ||
74 | |||
75 | if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is | ||
76 | return el; | ||
77 | } | ||
78 | |||
79 | if (typeof el == 'string') { // ID | ||
80 | return document.getElementById(el); | ||
81 | } | ||
82 | else { // array of ID's and/or elements | ||
83 | var collection = []; | ||
84 | for (var i = 0, len = el.length; i < len; ++i) { | ||
85 | collection[collection.length] = YAHOO.util.Dom.get(el[i]); | ||
86 | } | ||
87 | |||
88 | return collection; | ||
89 | } | ||
90 | |||
91 | return null; // safety, should never happen | ||
92 | }; | ||
93 | |||