OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / scripts / m3plus1.6.1.js
1 /**\r
2  * Magic3標準追加用JavaScriptライブラリ\r
3  *\r
4  * JavaScript 1.5\r
5  *\r
6  * LICENSE: This source file is licensed under the terms of the GNU General Public License.\r
7  *\r
8  * @package    Magic3 Framework\r
9  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>\r
10  * @copyright  Copyright 2006-2013 Magic3 Project.\r
11  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License\r
12  * @version    SVN: $Id: m3plus1.6.1.js 6010 2013-05-19 11:38:31Z fishbone $\r
13  * @link       http://www.magic3.org\r
14  */\r
15 // 親ウィンドウを更新\r
16 function m3UpdateParentWindow()\r
17 {\r
18         var href =      window.opener.location.href.split('#');\r
19         window.opener.location.href = href[0];\r
20 }\r
21 // 各種端末用プレビューウィンドウ表示\r
22 function m3ShowPreviewWindow(type, url)\r
23 {\r
24         var width, height;\r
25         \r
26         switch (type){\r
27                 case 0:         // PC用\r
28                 default:\r
29                         width = 1000;\r
30                         height = 800;\r
31                         break;\r
32                 case 1:         // 携帯用\r
33                         width = 240;\r
34                         height = 320;\r
35                         break;\r
36                 case 2:         // スマートフォン用\r
37                         width = 320;\r
38                         height = 480;\r
39                         break;\r
40         }\r
41         window.open(url, "", "toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);\r
42 }\r
43 /**\r
44  * TextAreaをHTMLエディターに変更\r
45  *\r
46  * @param string id                     TextAreaタグのIDまたはname\r
47  * @param bool  isMobile        携帯用のツールバー表示\r
48  * @return なし\r
49  */\r
50 function m3_setHtmlEditor(id, isMobile)\r
51 {\r
52         var oFCKeditor          = new FCKeditor(id);\r
53         oFCKeditor.BasePath     = M3_ROOT_URL + '/scripts/fckeditor2.6.6/';\r
54         oFCKeditor.Config['CustomConfigurationsPath'] = M3_ROOT_URL + '/scripts/m3/fckconfig.js';\r
55         if (isMobile == null || isMobile == false){\r
56                 oFCKeditor.ToolbarSet   = "M3Default";                  // ツールバーリソース名\r
57         } else {\r
58                 oFCKeditor.ToolbarSet   = "M3MobileDefault";    // ツールバーリソース名\r
59         }\r
60         oFCKeditor.Width        = "100%";\r
61         oFCKeditor.Height       = "100%";\r
62         oFCKeditor.Value        = 'This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.';\r
63         oFCKeditor.ReplaceTextarea();\r
64 }\r
65 /**\r
66  * TextAreaをWYSIWYGエディターに変更\r
67  *\r
68  * @param string id                     TextAreaタグのIDまたはname\r
69  * @param int height            エディター領域の高さ\r
70  * @param bool toolbarVisible   ツールバーを表示するかどうか\r
71  * @param string barType                ツールバータイプ(full=全項目,layout=レイアウト用)\r
72  * @return なし\r
73  */\r
74 function m3SetWysiwygEditor(id, height, toolbarVisible, barType)\r
75 {\r
76         if (M3_WYSIWYG_EDITOR == 'ckeditor'){\r
77                 var config = {};\r
78                 config['customConfig'] = M3_ROOT_URL + '/scripts/m3/ckconfig.js';\r
79                 if (height) config['height'] = height;\r
80                 if (toolbarVisible != null && !toolbarVisible) config['toolbarStartupExpanded'] = false;\r
81                 if (barType){\r
82                         switch (barType){\r
83                         case 'full':\r
84                         default:\r
85                                 config['toolbar'] = 'Full';\r
86                                 break;\r
87                         case 'layout':\r
88                                 config['toolbar'] = 'Layout';\r
89                                 break;\r
90                         }\r
91                 } else {\r
92                         config['toolbar'] = 'Full';\r
93                 }\r
94                 CKEDITOR.replace(id, config);\r
95         } else {\r
96                 var oFCKeditor          = new FCKeditor(id);\r
97                 oFCKeditor.BasePath     = M3_ROOT_URL + '/scripts/fckeditor2.6.6/';\r
98                 oFCKeditor.Config['CustomConfigurationsPath'] = M3_ROOT_URL + '/scripts/m3/fckconfig.js';\r
99                 oFCKeditor.ToolbarSet   = "M3Default";                  // ツールバーリソース名\r
100                 if (height) oFCKeditor.Height = String(height) + 'px';\r
101                 oFCKeditor.Value        = 'This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.';\r
102                 oFCKeditor.ReplaceTextarea();\r
103         }\r
104 }\r