/source/Plug-in/kind/examples/total.html

http://prosporous.googlecode.com/ · HTML · 545 lines · 514 code · 20 blank · 11 comment · 0 complexity · 537f5518a7a8375ff395f0931625442a MD5 · raw file

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>KindEditor Examples</title>
  6. <style>
  7. .ke-tabs-example li {
  8. padding: 0 5px;
  9. }
  10. .ke-icon-example1 {
  11. background-image: url(../skins/default/default.gif);
  12. background-position: 0px -672px;
  13. width: 16px;
  14. height: 16px;
  15. }
  16. .ke-icon-example2 {
  17. background-image: url(../skins/default/default.gif);
  18. background-position: 0px -672px;
  19. width: 16px;
  20. height: 16px;
  21. }
  22. </style>
  23. <link rel="stylesheet" href="../themes/default/default.css" />
  24. <link rel="stylesheet" href="../themes/simple/simple.css" />
  25. <script charset="utf-8" src="../kindeditor-min.js"></script>
  26. <script charset="utf-8" src="../lang/zh_CN.js"></script>
  27. <script>
  28. // ????? #1
  29. KindEditor.lang({
  30. example1 : '??HTML'
  31. });
  32. KindEditor.plugin('example1', function(K) {
  33. var self = this, name = 'example1';
  34. self.clickToolbar(name, function() {
  35. self.insertHtml('<strong>????</strong>');
  36. });
  37. });
  38. // ????? #2
  39. KindEditor.lang({
  40. example2 : 'CLASS??'
  41. });
  42. KindEditor.plugin('example2', function(K) {
  43. var self = this, name = 'example2';
  44. function click(value) {
  45. var cmd = self.cmd;
  46. if (value === 'adv_strikethrough') {
  47. cmd.wrap('<span style="background-color:#e53333;text-decoration:line-through;"></span>');
  48. } else {
  49. cmd.wrap('<span class="' + value + '"></span>');
  50. }
  51. cmd.select();
  52. self.hideMenu();
  53. }
  54. self.clickToolbar(name, function() {
  55. var menu = self.createMenu({
  56. name : name,
  57. width : 150
  58. });
  59. menu.addItem({
  60. title : '????',
  61. click : function() {
  62. click('red');
  63. }
  64. });
  65. menu.addItem({
  66. title : '????',
  67. click : function() {
  68. click('green');
  69. }
  70. });
  71. menu.addItem({
  72. title : '????',
  73. click : function() {
  74. click('yellow');
  75. }
  76. });
  77. menu.addItem({
  78. title : '??????',
  79. click : function() {
  80. click('adv_strikethrough');
  81. }
  82. });
  83. });
  84. });
  85. function getParam(url, name) {
  86. return url.match(new RegExp('[?&]' + name + '=([^?&]+)', 'i')) ? unescape(RegExp.$1) : '';
  87. }
  88. KindEditor.ready(function(K) {
  89. var tabTitleList = ['????', '????', '????', '???', '????', '??????', '????', 'HTML??', 'URL??', '?????', '?????'];
  90. var optionMap = {
  91. 'content0' : {
  92. cssPath : '../plugins/code/prettify.css',
  93. allowFileManager : true
  94. },
  95. 'content1' : {
  96. cssPath : '../plugins/code/prettify.css',
  97. resizeType : 1,
  98. allowPreviewEmoticons : false,
  99. allowImageUpload : false,
  100. items : [
  101. 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
  102. 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
  103. 'insertunorderedlist', '|', 'emoticons', 'image', 'link']
  104. },
  105. 'content2' : {
  106. cssPath : '../plugins/code/prettify.css',
  107. basePath : '../'
  108. },
  109. 'content3' : {
  110. cssPath : '../plugins/code/prettify.css',
  111. langType : 'en'
  112. },
  113. 'content4' : {
  114. cssPath : '../plugins/code/prettify.css',
  115. readonlyMode : true
  116. },
  117. 'content5' : {
  118. cssPath : '../plugins/code/prettify.css',
  119. newlineTag : 'br'
  120. },
  121. 'content6' : {
  122. cssPath : '../plugins/code/prettify.css',
  123. afterChange : function() {
  124. K('#tab6 .word_count1').html(this.count());
  125. K('#tab6 .word_count2').html(this.count('text'));
  126. }
  127. },
  128. 'content7' : {
  129. cssPath : '../plugins/code/prettify.css',
  130. filterMode : true
  131. },
  132. 'content8' : {
  133. cssPath : '../plugins/code/prettify.css',
  134. urlType : ''
  135. },
  136. 'content9' : {
  137. cssPath : '../plugins/code/prettify.css',
  138. themeType : 'simple'
  139. },
  140. 'content10' : {
  141. cssPath : ['../plugins/code/prettify.css', 'index.css'],
  142. items : ['source', 'removeformat', 'example1', 'example2']
  143. }
  144. };
  145. var editor = null;
  146. var tabs = K.tabs({
  147. src : K('#tabs'),
  148. cls : 'ke-tabs-example',
  149. afterSelect : function(i) {
  150. if (editor) {
  151. editor.remove();
  152. editor = null;
  153. }
  154. if (i == 2) {
  155. return;
  156. }
  157. editor = K.create('#tab' + i + ' textarea[name=content]', optionMap['content' + i]);
  158. }
  159. });
  160. K.each(tabTitleList, function(i, title) {
  161. tabs.add({
  162. title : title,
  163. panel : K('#tab' + i)
  164. });
  165. })
  166. var index = parseInt(getParam(location.href, 'tab') || 0, 10);
  167. tabs.select(index);
  168. K('#tab' + index).show();
  169. K('#tab0 input[name=getHtml]').click(function(e) {
  170. alert(editor.html());
  171. });
  172. K('#tab0 input[name=isEmpty]').click(function(e) {
  173. alert(editor.isEmpty());
  174. });
  175. K('#tab0 input[name=getText]').click(function(e) {
  176. alert(editor.text());
  177. });
  178. K('#tab0 input[name=selectedHtml]').click(function(e) {
  179. alert(editor.selectedHtml());
  180. });
  181. K('#tab0 input[name=setHtml]').click(function(e) {
  182. editor.html('<h3>Hello KindEditor</h3>');
  183. });
  184. K('#tab0 input[name=setText]').click(function(e) {
  185. editor.text('<h3>Hello KindEditor</h3>');
  186. });
  187. K('#tab0 input[name=insertHtml]').click(function(e) {
  188. editor.insertHtml('<strong>??HTML</strong>');
  189. });
  190. K('#tab0 input[name=appendHtml]').click(function(e) {
  191. editor.appendHtml('<strong>??HTML</strong>');
  192. });
  193. K('#tab0 input[name=clear]').click(function(e) {
  194. editor.html('');
  195. });
  196. K('#tab2 input[name=load]').click(function() {
  197. K.loadScript('../kindeditor.js', function() {
  198. editor = K.create('#tab2 textarea', optionMap.content2);
  199. });
  200. });
  201. K('#tab2 input[name=remove]').click(function() {
  202. if (editor) {
  203. editor.remove();
  204. editor = null;
  205. }
  206. });
  207. K('#tab3 select[name=lang]').change(function() {
  208. if (editor) {
  209. editor.remove();
  210. editor = null;
  211. }
  212. optionMap.content3.langType = this.value;
  213. editor = K.create('#tab3 textarea', optionMap.content3);
  214. });
  215. K('#tab4 input[name=readonly]').click(function() {
  216. editor.readonly();
  217. });
  218. K('#tab4 input[name=cancel]').click(function() {
  219. editor.readonly(false);
  220. });
  221. K('#tab5 select[name=newlineTag]').change(function() {
  222. if (editor) {
  223. editor.remove();
  224. editor = null;
  225. }
  226. optionMap.content5.newlineTag = this.value;
  227. editor = K.create('#tab5 textarea', optionMap.content5);
  228. });
  229. K('#tab8 select[name=urlType]').change(function() {
  230. if (editor) {
  231. editor.remove();
  232. editor = null;
  233. }
  234. optionMap.content8.urlType = this.value;
  235. editor = K.create('#tab8 textarea', optionMap.content8);
  236. });
  237. K('#tab9 select[name=themeType]').change(function() {
  238. if (editor) {
  239. editor.remove();
  240. editor = null;
  241. }
  242. optionMap.content9.themeType = this.value;
  243. editor = K.create('#tab9 textarea', optionMap.content9);
  244. });
  245. });
  246. </script>
  247. </head>
  248. <body>
  249. <div id="tabs"></div>
  250. <!-- ???? -->
  251. <div id="tab0" style="display:none;">
  252. <form>
  253. <textarea name="content" style="width:800px;height:400px;visibility:hidden;">
  254. <p>
  255. ????:
  256. </p>
  257. <pre class="prettyprint">
  258. &amp;lt;link rel="stylesheet" href="../themes/default/default.css" /&amp;gt;
  259. &amp;lt;script charset="utf-8" src="../kindeditor.js"&amp;gt;&amp;lt;/script&amp;gt;
  260. &amp;lt;script charset="utf-8" src="../lang/zh_CN.js"&amp;gt;&amp;lt;/script&amp;gt;
  261. </pre>
  262. <p>
  263. JavaScript??:
  264. </p>
  265. <pre class="prettyprint">
  266. KindEditor.ready(function(K) {
  267. K.create('textarea[name="content"]', {
  268. allowFileManager : true
  269. });
  270. });
  271. </pre>
  272. <p>
  273. &nbsp;
  274. </p>
  275. </textarea>
  276. <p>
  277. <input type="button" name="getHtml" value="??HTML" />
  278. <input type="button" name="isEmpty" value="??????" />
  279. <input type="button" name="getText" value="????(??img,embed)" />
  280. <input type="button" name="selectedHtml" value="????HTML" />
  281. <br />
  282. <br />
  283. <input type="button" name="setHtml" value="??HTML" />
  284. <input type="button" name="setText" value="????" />
  285. <input type="button" name="insertHtml" value="??HTML" />
  286. <input type="button" name="appendHtml" value="??HTML" />
  287. <input type="button" name="clear" value="????" />
  288. <input type="reset" name="reset" value="Reset" />
  289. </p>
  290. </form>
  291. </div>
  292. <!-- ???? -->
  293. <div id="tab1" style="display:none;">
  294. <textarea name="content" style="width:700px;height:300px;visibility:hidden;">
  295. <p>
  296. ????:
  297. </p>
  298. <pre class="prettyprint">
  299. &amp;lt;link rel="stylesheet" href="../themes/default/default.css" /&amp;gt;
  300. &amp;lt;script charset="utf-8" src="../kindeditor.js"&amp;gt;&amp;lt;/script&amp;gt;
  301. &amp;lt;script charset="utf-8" src="../lang/zh_CN.js"&amp;gt;&amp;lt;/script&amp;gt;
  302. </pre>
  303. <p>
  304. JavaScript??:
  305. </p>
  306. <pre class="prettyprint">
  307. KindEditor.ready(function(K) {
  308. K.create('textarea[name="content"]', {
  309. resizeType : 1,
  310. allowPreviewEmoticons : false,
  311. allowImageUpload : false,
  312. items : [
  313. 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
  314. 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
  315. 'insertunorderedlist', '|', 'emoticons', 'image', 'link']
  316. });
  317. });
  318. </pre>
  319. <p>
  320. &nbsp;
  321. </p>
  322. </textarea>
  323. </div>
  324. <!-- ???? -->
  325. <div id="tab2" style="display:none;">
  326. <textarea name="content" style="width:800px;height:400px;">
  327. ????:
  328. <pre class="prettyprint">
  329. &amp;lt;link rel="stylesheet" href="../themes/default/default.css" /&amp;gt;
  330. </pre>
  331. JavaScript??:
  332. <pre class="prettyprint">
  333. KindEditor.loadScript('../kindeditor.js', function() {
  334. KindEditor.create('#tab2 textarea');
  335. });
  336. </pre>
  337. <p>
  338. &nbsp;
  339. </p>
  340. </textarea>
  341. <p>
  342. <input type="button" name="load" value="??JS??????" />
  343. <input type="button" name="remove" value="?????" />
  344. </p>
  345. </div>
  346. <!-- ??? -->
  347. <div id="tab3" style="display:none;">
  348. <p>
  349. <select name="lang">
  350. <option value="en">English</option>
  351. <option value="zh_CN">????</option>
  352. <option value="zh_TW">????</option>
  353. </select>
  354. </p>
  355. <textarea name="content" style="width:800px;height:400px;">
  356. JavaScript??:
  357. <pre class="prettyprint">
  358. KindEditor.ready(function(K) {
  359. // English: langType : 'en'
  360. // ????: langType : 'zh_CN'
  361. // ????: langType : 'zh_TW'
  362. K.create('textarea[name="content"]', {
  363. langType : 'en'
  364. });
  365. });
  366. </pre>
  367. <p>
  368. &nbsp;
  369. </p>
  370. </textarea>
  371. </div>
  372. <!-- ???? -->
  373. <div id="tab4" style="display:none;">
  374. <textarea name="content" style="width:800px;height:400px;">
  375. JavaScript??:
  376. <pre class="prettyprint">
  377. KindEditor.ready(function(K) {
  378. var editor = K.create('textarea[name="content"]', {
  379. readonlyMode : true
  380. });
  381. // ???????
  382. K('#tab4 input[name=readonly]').click(function() {
  383. editor.readonly();
  384. });
  385. // ??????
  386. K('#tab4 input[name=cancel]').click(function() {
  387. editor.readonly(false);
  388. });
  389. });
  390. </pre>
  391. <p>
  392. &nbsp;
  393. </p>
  394. </textarea>
  395. <p>
  396. <input type="button" name="readonly" value="???????" />
  397. <input type="button" name="cancel" value="??????" />
  398. </p>
  399. </div>
  400. <!-- ?????? -->
  401. <div id="tab5" style="display:none;">
  402. <p>
  403. <select name="newlineTag">
  404. <option value="br">BR??</option>
  405. <option value="p">P??</option>
  406. </select>
  407. </p>
  408. <textarea name="content" style="width:800px;height:400px;">
  409. JavaScript??:
  410. <pre class="prettyprint">
  411. KindEditor.ready(function(K) {
  412. // P??: newlineTag : 'p'
  413. // BR??: newlineTag : 'br'
  414. K.create('textarea[name="content"]', {
  415. newlineTag : 'br'
  416. });
  417. });
  418. </pre>
  419. <p>
  420. &nbsp;
  421. </p>
  422. </textarea>
  423. </div>
  424. <!-- ???? -->
  425. <div id="tab6" style="display:none;">
  426. <textarea name="content" style="width:800px;height:400px;">
  427. JavaScript??:
  428. <pre class="prettyprint">
  429. KindEditor.ready(function(K) {
  430. K.create('textarea[name="content"]', {
  431. afterChange : function() {
  432. K('#tab6 .word_count1').html(this.count());
  433. K('#tab6 .word_count2').html(this.count('text'));
  434. }
  435. });
  436. });
  437. </pre>
  438. <p>
  439. &nbsp;
  440. </p>
  441. </textarea>
  442. <br />
  443. ?????? <span class="word_count1">0</span> ???????????HTML????<br />
  444. ?????? <span class="word_count2">0</span> ???????????????IMG?EMBED????????IMG?EMBED???????
  445. </div>
  446. <!-- HTML?? -->
  447. <div id="tab7" style="display:none;">
  448. <textarea name="content" style="width:800px;height:400px;">
  449. JavaScript??:
  450. <pre class="prettyprint">
  451. KindEditor.ready(function(K) {
  452. K.create('textarea[name="content"]', {
  453. filterMode : true
  454. });
  455. });
  456. </pre>
  457. <p>
  458. &nbsp;
  459. </p>
  460. </textarea>
  461. </div>
  462. <!-- URL?? -->
  463. <div id="tab8" style="display:none;">
  464. <p>
  465. <select name="urlType">
  466. <option value="">URL????</option>
  467. <option value="relative">??URL</option>
  468. <option value="absolute">???????URL</option>
  469. <option value="domain">??????URL</option>
  470. </select>
  471. </p>
  472. <textarea name="content" style="width:800px;height:400px;">
  473. <p>
  474. ?????<img border="0" src="../plugins/emoticons/images/0.gif" /><br />
  475. ?????<img border="0" alt="" src="http://img1.cache.netease.com/img09/logo/logo.gif" /><br />
  476. ???????<a href="demo-19.html" target="_blank">????</a><br />
  477. ???????<a href="http://www.163.com/" target="_blank">????</a><br />
  478. </p>
  479. JavaScript??:
  480. <pre class="prettyprint">
  481. KindEditor.ready(function(K) {
  482. // URL????: urlType : ''
  483. // ??URL: urlType : 'relative'
  484. // ???????URL: urlType : 'absolute'
  485. // ??????URL: urlType : 'domain'
  486. K.create('textarea[name="content"]', {
  487. urlType : ''
  488. });
  489. });
  490. </pre>
  491. <p>
  492. &nbsp;
  493. </p>
  494. </textarea>
  495. </div>
  496. <!-- ????? -->
  497. <div id="tab9" style="display:none;">
  498. <p>
  499. <select name="themeType">
  500. <option value="simple">????</option>
  501. <option value="default">????</option>
  502. </select>
  503. </p>
  504. <textarea name="content" style="width:800px;height:400px;">
  505. JavaScript??:
  506. <pre class="prettyprint">
  507. KindEditor.ready(function(K) {
  508. // ????: themeType : 'simple'
  509. // ????: themeType : 'default'
  510. K.create('textarea[name="content"]', {
  511. themeType : 'simple'
  512. });
  513. });
  514. </pre>
  515. <p>
  516. &nbsp;
  517. </p>
  518. </textarea>
  519. </div>
  520. <!-- ????? -->
  521. <div id="tab10" style="display:none;">
  522. <textarea name="content" style="width:800px;height:400px;"></textarea>
  523. </div>
  524. </body>
  525. </html>