FCKeditor 2.6.6
[freeside.git] / httemplate / elements / fckeditor / editor / filemanager / browser / default / js / common.js
1 /*\r
2  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
3  * Copyright (C) 2003-2010 Frederico Caldeira Knabben\r
4  *\r
5  * == BEGIN LICENSE ==\r
6  *\r
7  * Licensed under the terms of any of the following licenses at your\r
8  * choice:\r
9  *\r
10  *  - GNU General Public License Version 2 or later (the "GPL")\r
11  *    http://www.gnu.org/licenses/gpl.html\r
12  *\r
13  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
14  *    http://www.gnu.org/licenses/lgpl.html\r
15  *\r
16  *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
17  *    http://www.mozilla.org/MPL/MPL-1.1.html\r
18  *\r
19  * == END LICENSE ==\r
20  *\r
21  * Common objects and functions shared by all pages that compose the\r
22  * File Browser dialog window.\r
23  */\r
24 \r
25 // Automatically detect the correct document.domain (#1919).\r
26 (function()\r
27 {\r
28         var d = document.domain ;\r
29 \r
30         while ( true )\r
31         {\r
32                 // Test if we can access a parent property.\r
33                 try\r
34                 {\r
35                         var test = window.top.opener.document.domain ;\r
36                         break ;\r
37                 }\r
38                 catch( e )\r
39                 {}\r
40 \r
41                 // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...\r
42                 d = d.replace( /.*?(?:\.|$)/, '' ) ;\r
43 \r
44                 if ( d.length == 0 )\r
45                         break ;         // It was not able to detect the domain.\r
46 \r
47                 try\r
48                 {\r
49                         document.domain = d ;\r
50                 }\r
51                 catch (e)\r
52                 {\r
53                         break ;\r
54                 }\r
55         }\r
56 })() ;\r
57 \r
58 function AddSelectOption( selectElement, optionText, optionValue )\r
59 {\r
60         var oOption = document.createElement("OPTION") ;\r
61 \r
62         oOption.text    = optionText ;\r
63         oOption.value   = optionValue ;\r
64 \r
65         selectElement.options.add(oOption) ;\r
66 \r
67         return oOption ;\r
68 }\r
69 \r
70 var oConnector  = window.parent.oConnector ;\r
71 var oIcons              = window.parent.oIcons ;\r
72 \r
73 \r
74 function StringBuilder( value )\r
75 {\r
76     this._Strings = new Array( value || '' ) ;\r
77 }\r
78 \r
79 StringBuilder.prototype.Append = function( value )\r
80 {\r
81     if ( value )\r
82         this._Strings.push( value ) ;\r
83 }\r
84 \r
85 StringBuilder.prototype.ToString = function()\r
86 {\r
87     return this._Strings.join( '' ) ;\r
88 }\r