OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / scripts / fckeditor2.6.6 / editor / plugins / Marquee2 / marquee.js
1 /*\r
2  * FCKMarquee2Command\r
3  *\r
4  * LICENSE: This source file is licensed under the terms of the GNU General Public License.\r
5  *\r
6  * @package    Magic3 Framework\r
7  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>\r
8  * @copyright  Copyright 2006-2010 Magic3 Project.\r
9  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License\r
10  * @version    SVN: $Id: marquee.js 3742 2010-10-27 02:28:44Z fishbone $\r
11  * @link       http://www.magic3.org\r
12  */\r
13 var editorObj = window.parent.InnerDialogLoaded();\r
14 var FCK                 = editorObj.FCK ;\r
15 var FCKLang             = editorObj.FCKLang ;\r
16 var FCKConfig   = editorObj.FCKConfig ;\r
17 var FCKTools    = editorObj.FCKTools ;\r
18 \r
19 function Import(aSrc) {\r
20    document.write('<scr'+'ipt type="text/javascript" src="' + aSrc + '"></sc' + 'ript>');\r
21 }\r
22 Import(FCKConfig.FullBasePath + 'dialog/common/fck_dialog_common.js');\r
23 \r
24 // 選択範囲の読み込み\r
25 var marqueeObj = FCK.Selection.GetSelectedElement();\r
26 /*if (!marqueeObj || marqueeObj.tagName != 'MARQUEE')\r
27 {\r
28         marqueeObj = FCK.Selection.GetParentElement() ;\r
29         if (!marqueeObj || marqueeObj.tagName != 'MARQUEE') marqueeObj = null ;\r
30 }*/\r
31 \r
32 function OnLoad()\r
33 {\r
34         // 各言語対応の変換\r
35         editorObj.FCKLanguageManager.TranslatePage(document);\r
36 \r
37         // カラーテーブルの作成\r
38         CreateBasicColorTable();\r
39         CreateColorTable();\r
40 \r
41         // 設定データ読み込み\r
42         LoadSelection();\r
43         \r
44         // ボタンの設定\r
45         window.parent.SetOkButton(true);\r
46         window.parent.SetAutoSize(true);\r
47 }\r
48 \r
49 function CreateColorTable()\r
50 {\r
51         // Get the target table.\r
52         var oTable = document.getElementById('ColorTable');\r
53 \r
54         // Create the base colors array.\r
55         var aColors = ['00','33','66','99','cc','ff'];\r
56 \r
57         // This function combines two ranges of three values from the color array into a row.\r
58         function AppendColorRow( rangeA, rangeB )\r
59         {\r
60                 for ( var i = rangeA; i < rangeA + 3; i++ )\r
61                 {\r
62                         var oRow = oTable.insertRow(-1);\r
63 \r
64                         for ( var j = rangeB; j < rangeB + 3; j++ )\r
65                         {\r
66                                 for ( var n = 0; n < 6; n++ )\r
67                                 {\r
68                                         AppendColorCell( oRow, '#' + aColors[j] + aColors[n] + aColors[i] );\r
69                                 }\r
70                         }\r
71                 }\r
72         }\r
73 \r
74         // This function create a single color cell in the color table.\r
75         function AppendColorCell( targetRow, color )\r
76         {\r
77                 var oCell = targetRow.insertCell(-1);\r
78                 oCell.className = 'ColorCell';\r
79                 oCell.bgColor = color;\r
80 \r
81                 oCell.onmouseover = function()\r
82                 {\r
83                         document.getElementById('hicolor').style.backgroundColor = this.bgColor;\r
84                         document.getElementById('hicolortext').innerHTML = this.bgColor;\r
85                 }\r
86 \r
87                 oCell.onclick = function()\r
88                 {\r
89                         document.getElementById('selhicolor').style.backgroundColor = this.bgColor;\r
90                         document.getElementById('txtBgcolor').value = this.bgColor;\r
91                 }\r
92         }\r
93 \r
94         AppendColorRow( 0, 0 );\r
95         AppendColorRow( 3, 0 );\r
96         AppendColorRow( 0, 3 );\r
97         AppendColorRow( 3, 3 );\r
98 }\r
99 \r
100 function CreateBasicColorTable()\r
101 {\r
102         var oTable = document.getElementById('BasicColorTable') ;\r
103     var aColors = ['#000000', '#333333', '#666666', '#999999', '#cccccc', '#ffffff',\r
104                    '#ff0000', '#00ff00', '#0000ff', '#ffff00', '#00ffff', '#ff00ff'] ;\r
105     for (var i = 0 ; i < 12 ; i++ )\r
106     {\r
107         var oRow = oTable.insertRow(-1) ;\r
108         AppendColorCell(oRow, aColors[i] );\r
109     }\r
110         // This function create a single color cell in the color table.\r
111         function AppendColorCell( targetRow, color )\r
112         {\r
113                 var oCell = targetRow.insertCell(-1);\r
114                 oCell.className = 'ColorCell';\r
115                 oCell.bgColor = color;\r
116 \r
117                 oCell.onmouseover = function()\r
118                 {\r
119                         document.getElementById('hicolor').style.backgroundColor = this.bgColor;\r
120                         document.getElementById('hicolortext').innerHTML = this.bgColor;\r
121                 }\r
122 \r
123                 oCell.onclick = function()\r
124                 {\r
125                         document.getElementById('selhicolor').style.backgroundColor = this.bgColor;\r
126                         document.getElementById('txtBgcolor').value = this.bgColor;\r
127                 }\r
128         }\r
129 }\r
130 \r
131 function Clear()\r
132 {\r
133         document.getElementById('selhicolor').style.backgroundColor = '';\r
134         document.getElementById('txtBgcolor').value = '';\r
135 }\r
136 \r
137 function ClearActual()\r
138 {\r
139         document.getElementById('hicolor').style.backgroundColor = '';\r
140         document.getElementById('hicolortext').innerHTML = '&nbsp;';\r
141 }\r
142 \r
143 function UpdateColor()\r
144 {\r
145         try               { document.getElementById('selhicolor').style.backgroundColor = document.getElementById('txtBgcolor').value; }\r
146         catch (e) { Clear(); }\r
147 }\r
148 \r
149 function Ok()\r
150 {\r
151         if (marqueeObj){\r
152                 SetAttribute(marqueeObj, 'style', '');\r
153                 if (GetE('cmbDirection').value != '') SetAttribute(marqueeObj, '-wap-marquee-dir', GetE('cmbDirection').value);\r
154                 if (GetE('cmbBehavior').value != '') SetAttribute(marqueeObj, '-wap-marquee-style', GetE('cmbBehavior').value);\r
155                 if (GetE('txtBgcolor').value != '') SetAttribute(marqueeObj, 'background-color', GetE('txtBgcolor').value);\r
156                 if (GetE('txtLoop').value && GetE('txtLoop').value.match(/^\d{1,2}$/)) SetAttribute(marqueeObj, '-wap-marquee-loop', GetE('txtLoop').value);\r
157         } else {\r
158                 var styleDef = FCK.Commands.LoadedCommands.Marquee2.styleDef ;\r
159                 if (GetE('cmbDirection').value != '') styleDef.Styles['-wap-marquee-dir'] = GetE('cmbDirection').value;\r
160                 if (GetE('cmbBehavior').value != '') styleDef.Styles['-wap-marquee-style'] = GetE('cmbBehavior').value;\r
161                 if (GetE('txtBgcolor').value != '') styleDef.Styles['background-color'] = GetE('txtBgcolor').value;\r
162                 if (GetE('txtLoop').value && GetE('txtLoop').value.match(/^\d{1,2}$/)) styleDef.Styles['-wap-marquee-loop'] = GetE('txtLoop').value;\r
163 \r
164                 // 選択範囲に反映\r
165                 FCK.Commands.LoadedCommands.Marquee2.ApplyStyle();\r
166         }\r
167         return true;\r
168 }\r
169 \r
170 function LoadSelection()\r
171 {\r
172         if (!marqueeObj) return;\r
173 \r
174         GetE('cmbDirection').value    = GetAttribute(marqueeObj, '-wap-marquee-dir', '');\r
175         GetE('cmbBehavior').value       = GetAttribute(marqueeObj, '-wap-marquee-style', '');\r
176     GetE('txtLoop').value       = GetAttribute(marqueeObj, '-wap-marquee-loop', '' );\r
177         GetE('txtBgcolor').value        = marqueeObj.getAttribute('background-color');\r
178 \r
179     UpdateColor();\r
180 }\r