Enkodowanie nazw plików do UTF-8 przed przekazaniem ich do localrepo.commit. Powinno...
[redakcja.git] / project / static / js / plugins / test / test.js
1 /**\r
2  * Plugin designed for test prupose. It add a button (that manage an alert) and a select (that allow to insert tags) in the toolbar.\r
3  * This plugin also disable the "f" key in the editarea, and load a CSS and a JS file\r
4  */  \r
5 var EditArea_test= {\r
6         /**\r
7          * Get called once this file is loaded (editArea still not initialized)\r
8          *\r
9          * @return nothing       \r
10          */                     \r
11         init: function(){       \r
12                 //      alert("test init: "+ this._someInternalFunction(2, 3));\r
13                 editArea.load_css(this.baseURL+"css/test.css");\r
14                 editArea.load_script(this.baseURL+"test2.js");\r
15         }\r
16         /**\r
17          * Returns the HTML code for a specific control string or false if this plugin doesn't have that control.\r
18          * A control can be a button, select list or any other HTML item to present in the EditArea user interface.\r
19          * Language variables such as {$lang_somekey} will also be replaced with contents from\r
20          * the language packs.\r
21          * \r
22          * @param {string} ctrl_name: the name of the control to add      \r
23          * @return HTML code for a specific control or false.\r
24          * @type string or boolean\r
25          */     \r
26         ,get_control_html: function(ctrl_name){\r
27                 switch(ctrl_name){\r
28                         case "test_but":\r
29                                 // Control id, button img, command\r
30                                 return parent.editAreaLoader.get_button_html('test_but', 'test.gif', 'test_cmd', false, this.baseURL);\r
31                         case "test_select":\r
32                                 html= "<select id='test_select' onchange='javascript:editArea.execCommand(\"test_select_change\")' fileSpecific='no'>"\r
33                                         +"                      <option value='-1'>{$test_select}</option>"\r
34                                         +"                      <option value='h1'>h1</option>"\r
35                                         +"                      <option value='h2'>h2</option>"\r
36                                         +"                      <option value='h3'>h3</option>"\r
37                                         +"                      <option value='h4'>h4</option>"\r
38                                         +"                      <option value='h5'>h5</option>"\r
39                                         +"                      <option value='h6'>h6</option>"\r
40                                         +"              </select>";\r
41                                 return html;\r
42                 }\r
43                 return false;\r
44         }\r
45         /**\r
46          * Get called once EditArea is fully loaded and initialised\r
47          *       \r
48          * @return nothing\r
49          */                     \r
50         ,onload: function(){ \r
51                 alert("test load");\r
52         }\r
53         \r
54         /**\r
55          * Is called each time the user touch a keyboard key.\r
56          *       \r
57          * @param (event) e: the keydown event\r
58          * @return true - pass to next handler in chain, false - stop chain execution\r
59          * @type boolean         \r
60          */\r
61         ,onkeydown: function(e){\r
62                 var str= String.fromCharCode(e.keyCode);\r
63                 // desactivate the "f" character\r
64                 if(str.toLowerCase()=="f"){\r
65                         return true;\r
66                 }\r
67                 return false;\r
68         }\r
69         \r
70         /**\r
71          * Executes a specific command, this function handles plugin commands.\r
72          *\r
73          * @param {string} cmd: the name of the command being executed\r
74          * @param {unknown} param: the parameter of the command  \r
75          * @return true - pass to next handler in chain, false - stop chain execution\r
76          * @type boolean        \r
77          */\r
78         ,execCommand: function(cmd, param){\r
79                 // Handle commands\r
80                 switch(cmd){\r
81                         case "test_select_change":\r
82                                 var val= document.getElementById("test_select").value;\r
83                                 if(val!=-1)\r
84                                         parent.editAreaLoader.insertTags(editArea.id, "<"+val+">", "</"+val+">");\r
85                                 document.getElementById("test_select").options[0].selected=true; \r
86                                 return false;\r
87                         case "test_cmd":\r
88                                 alert("user clicked on test_cmd");\r
89                                 return false;\r
90                 }\r
91                 // Pass to next handler in chain\r
92                 return true;\r
93         }\r
94         \r
95         /**\r
96          * This is just an internal plugin method, prefix all internal methods with a _ character.\r
97          * The prefix is needed so they doesn't collide with future EditArea callback functions.\r
98          *\r
99          * @param {string} a Some arg1.\r
100          * @param {string} b Some arg2.\r
101          * @return Some return.\r
102          * @type unknown\r
103          */\r
104         ,_someInternalFunction : function(a, b) {\r
105                 return a+b;\r
106         }\r
107 };\r
108 \r
109 // Adds the plugin class to the list of available EditArea plugins\r
110 editArea.add_plugin("test", EditArea_test);\r