popup.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <?php
  2. /**
  3. * Plugin Icons: Popup helper
  4. *
  5. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  6. * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  7. * @copyright (C) 2015-2018, Giuseppe Di Terlizzi
  8. */
  9. if (!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../../../');
  10. define('DOKU_MEDIAMANAGER', 1); // needed to get proper CSS/JS
  11. global $lang;
  12. global $conf;
  13. global $JSINFO;
  14. require_once(DOKU_INC.'inc/init.php');
  15. require_once(DOKU_INC.'inc/template.php');
  16. require_once(DOKU_INC.'inc/lang/en/lang.php');
  17. require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php');
  18. $JSINFO['id'] = '';
  19. $JSINFO['namespace'] = '';
  20. $tmp = array();
  21. trigger_event('MEDIAMANAGER_STARTED', $tmp);
  22. session_write_close(); //close session
  23. $icons_plugin = plugin_load('action','icons');
  24. $use_font_awesome = $icons_plugin->getConf('loadFontAwesome');
  25. $use_material_icons = $icons_plugin->getConf('loadMaterialIcons');
  26. $use_typicons = $icons_plugin->getConf('loadTypicons');
  27. $use_font_linux = $icons_plugin->getConf('loadFontlinux');
  28. $use_rpg_awesome = $icons_plugin->getConf('loadRpgAwesome');
  29. $use_glyphicons = false;
  30. # Load Bootstrap3 Template assets
  31. if ($conf['template'] == 'bootstrap3') {
  32. include_once(DOKU_INC.'lib/tpl/bootstrap3/tpl_functions.php');
  33. include_once(DOKU_INC.'lib/tpl/bootstrap3/tpl_global.php');
  34. # Glyphicons if bundled into Bootstrap 3.x
  35. $use_glyphicons = true;
  36. }
  37. $list_material_icons = include(dirname(__FILE__) . '/list-material-icons.php');
  38. $list_font_awesome = include(dirname(__FILE__) . '/list-font-awesome.php');
  39. $list_glyphicon = include(dirname(__FILE__) . '/list-glyphicon.php');
  40. $list_typicons = include(dirname(__FILE__) . '/list-typicons.php');
  41. $list_font_linux = include(dirname(__FILE__) . '/list-font-linux.php');
  42. $list_rpg_awesome = include(dirname(__FILE__) . '/list-rpg-awesome.php');
  43. header('Content-Type: text/html; charset=utf-8');
  44. header('X-UA-Compatible: IE=edge,chrome=1');
  45. ?><!DOCTYPE html>
  46. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $conf['lang'] ?>" lang="<?php echo $conf['lang'] ?>" dir="<?php echo $lang['direction'] ?>" class="no-js">
  47. <head>
  48. <meta charset="UTF-8" />
  49. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  50. <title>Icons Plugin</title>
  51. <script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
  52. <meta name="viewport" content="width=device-width,initial-scale=1" />
  53. <?php echo tpl_favicon(array('favicon', 'mobile')) ?>
  54. <?php tpl_metaheaders() ?>
  55. <style type="text/css">
  56. body { padding: 20px; }
  57. .btn-icon { margin: 4px; padding: 4px; }
  58. .tab-icons { overflow-y: auto; height: 300px; }
  59. <?php if (! $use_glyphicons): ?>
  60. footer { bottom: 20px; position: fixed; }
  61. .col-sm-6 { width:50%; float: left; }
  62. .tab-pane, .hide { display: none; }
  63. button.active { border-style: inset; }
  64. <?php endif; ?>
  65. </style>
  66. <script type="text/javascript">
  67. jQuery(document).ready(function() {
  68. var is_bootstrap = (typeof jQuery.fn.modal !== "undefined");
  69. var $icon_pack = jQuery('#icon_pack'),
  70. $icon_name = jQuery('#icon_name'),
  71. $icon_size = jQuery('#icon_size'),
  72. $icon_align = jQuery('#icon_align'),
  73. $output = jQuery('#output'),
  74. $preview = jQuery('#preview');
  75. if (! is_bootstrap) {
  76. jQuery('.tab-pane').hide();
  77. }
  78. jQuery('button[data-icon-size]').on('click', function() {
  79. jQuery('button[data-icon-size]').removeClass('active');
  80. jQuery(this).addClass('active');
  81. $icon_size.val(jQuery(this).data('icon-size'));
  82. jQuery(document).trigger('popup:build');
  83. });
  84. jQuery('button[data-icon-align]').on('click', function() {
  85. jQuery('button[data-icon-align]').removeClass('active');
  86. jQuery(this).addClass('active');
  87. $icon_align.val(jQuery(this).data('icon-align'));
  88. jQuery(document).trigger('popup:build');
  89. });
  90. jQuery('ul.nav a').on('click', function() {
  91. if (! is_bootstrap) {
  92. jQuery('.tab-pane').hide();
  93. jQuery('ul.nav li.active').removeClass('active');
  94. jQuery(jQuery(this).attr('href')).show();
  95. jQuery(this).parent().addClass('active');
  96. }
  97. $icon_pack.val(jQuery(this).data('pack'));
  98. jQuery('.preview-box').removeClass('hide');
  99. jQuery(document).trigger('popup:reset');
  100. });
  101. jQuery('.btn-icon').on('click', function() {
  102. $icon_name.val(jQuery(this).data('icon-name'));
  103. jQuery(document).trigger('popup:build');
  104. });
  105. jQuery(document).on('popup:build', function() {
  106. var icon_pack = $icon_pack.val(),
  107. icon_size = $icon_size.val(),
  108. icon_align = $icon_align.val(),
  109. icon_name = $icon_name.val();
  110. if (! icon_name) {
  111. return false;
  112. }
  113. var syntax = [ '{{' ];
  114. syntax.push(icon_pack);
  115. syntax.push('>' + icon_name);
  116. var icon_size_pixel = 0;
  117. switch (icon_size) {
  118. case 'small':
  119. icon_size_pixel = 24;
  120. break;
  121. case 'medium':
  122. icon_size_pixel = 32;
  123. break;
  124. case 'large':
  125. icon_size_pixel = 48;
  126. break;
  127. }
  128. if (icon_size_pixel) {
  129. syntax.push('?' + icon_size_pixel);
  130. }
  131. if (icon_align) {
  132. syntax.push('&align=' + icon_align);
  133. }
  134. syntax.push('}}');
  135. $output.val(syntax.join(''));
  136. $preview.text(syntax.join(''));
  137. });
  138. jQuery('#btn-reset').on('click', function() {
  139. jQuery(document).trigger('popup:reset');
  140. });
  141. jQuery(document).on('popup:reset', function() {
  142. jQuery('form').each(function(){
  143. jQuery(this)[0].reset();
  144. });
  145. $output.val('');
  146. $preview.text('');
  147. });
  148. jQuery('#btn-preview, #btn-insert').on('click', function() {
  149. if (jQuery(this).attr('id') === 'btn-insert') {
  150. opener.insertAtCarret('wiki__text', $output.val());
  151. opener.focus();
  152. }
  153. });
  154. });
  155. </script>
  156. </head>
  157. <body class="container-fluid dokuwiki">
  158. <ul class="tabs nav nav-tabs" role="tablist">
  159. <?php if ($use_font_awesome): ?>
  160. <li>
  161. <a data-toggle="tab" href="#tab-font-awesome" data-pack="fa">Font-Awesome</a>
  162. </li>
  163. <?php endif; ?>
  164. <?php if ($use_glyphicons): ?>
  165. <li>
  166. <a data-toggle="tab" href="#tab-glyphicon" data-pack="glyphicon">Glyphicons</a>
  167. </li>
  168. <?php endif; ?>
  169. <?php if ($use_material_icons): ?>
  170. <li>
  171. <a data-toggle="tab" href="#tab-material" data-pack="material">Material Icons</a>
  172. </li>
  173. <?php endif; ?>
  174. <?php if ($use_typicons): ?>
  175. <li>
  176. <a data-toggle="tab" href="#tab-typicons" data-pack="typcn">Typicons</a>
  177. </li>
  178. <?php endif; ?>
  179. <?php if ($use_font_linux): ?>
  180. <li>
  181. <a data-toggle="tab" href="#tab-font-linux" data-pack="fl">Font-Linux</a>
  182. </li>
  183. <?php endif; ?>
  184. <?php if ($use_rpg_awesome): ?>
  185. <li>
  186. <a data-toggle="tab" href="#tab-rpg-awesome" data-pack="fl">RPG-Awesome</a>
  187. </li>
  188. <?php endif; ?>
  189. </ul>
  190. <main class="tab-content">
  191. <div id="tab-font-awesome" class="tab-pane fade">
  192. <div class="row tab-icons">
  193. <?php foreach($list_font_awesome as $icon): ?>
  194. <div class="col-sm-6">
  195. <button class="btn btn-default btn-xs btn-icon" title="<?php echo $icon ?>" data-icon-name="<?php echo $icon ?>">
  196. <i class="fa fa-fw fa-2x fa-<?php echo $icon ?>"></i>
  197. </button>
  198. <small><?php echo $icon ?></small>
  199. </div>
  200. <?php endforeach ?>
  201. </div>
  202. </div>
  203. <div id="tab-rpg-awesome" class="tab-pane fade">
  204. <div class="row tab-icons">
  205. <?php foreach($list_rpg_awesome as $icon): ?>
  206. <div class="col-sm-6">
  207. <button class="btn btn-default btn-xs btn-icon" title="<?php echo $icon ?>" data-icon-name="<?php echo $icon ?>">
  208. <i class="ra ra-fw ra-2x ra-<?php echo $icon ?>"></i>
  209. </button>
  210. <small><?php echo $icon ?></small>
  211. </div>
  212. <?php endforeach ?>
  213. </div>
  214. </div>
  215. <div id="tab-material" class="tab-pane fade">
  216. <div class="row tab-icons">
  217. <?php foreach($list_material_icons as $icon): ?>
  218. <div class="col-sm-6">
  219. <button class="btn btn-default btn-xs btn-icon material-icons" title="<?php echo $icon ?>" data-icon-name="<?php echo $icon ?>"><?php echo $icon ?></button>
  220. <small><?php echo $icon ?></small>
  221. </div>
  222. <?php endforeach ?>
  223. </div>
  224. </div>
  225. <div id="tab-glyphicon" class="tab-pane fade">
  226. <div class="row tab-icons">
  227. <?php foreach($list_glyphicon as $icon): ?>
  228. <div class="col-sm-6">
  229. <button class="btn btn-default btn-xs btn-icon" title="<?php echo $icon ?>" data-icon-name="<?php echo $icon ?>">
  230. <i class="fa-fw fa-2x glyphicon glyphicon-<?php echo $icon ?>"></i>
  231. </button>
  232. <small><?php echo $icon ?></small>
  233. </div>
  234. <?php endforeach ?>
  235. </div>
  236. </div>
  237. <div id="tab-typicons" class="tab-pane fade">
  238. <div class="row tab-icons">
  239. <?php foreach($list_typicons as $icon): ?>
  240. <div class="col-sm-6">
  241. <button class="btn btn-default btn-xs btn-icon" title="<?php echo $icon ?>" data-icon-name="<?php echo $icon ?>">
  242. <i class="fa-fw fa-2x typcn typcn-<?php echo $icon ?>"></i>
  243. </button>
  244. <small><?php echo $icon ?></small>
  245. </div>
  246. <?php endforeach ?>
  247. </div>
  248. </div>
  249. <div id="tab-font-linux" class="tab-pane fade">
  250. <div class="row tab-icons">
  251. <?php foreach($list_font_linux as $icon): ?>
  252. <div class="col-sm-6">
  253. <button class="btn btn-default btn-xs btn-icon" title="<?php echo $icon ?>" data-icon-name="<?php echo $icon ?>">
  254. <i class="fa-fw fa-2x fl fl-<?php echo $icon ?>"></i>
  255. </button>
  256. <small><?php echo $icon ?></small>
  257. </div>
  258. <?php endforeach ?>
  259. </div>
  260. </div>
  261. <div class="preview-box hide">
  262. <hr/>
  263. <div class="row">
  264. <div class="box-alignment col-sm-6">
  265. <label>Alignment</label>
  266. <div class="btn-group btn-group-xs">
  267. <button class="button btn btn-default active" data-icon-align="" title="Use no align">
  268. <img src="../../../images/media_align_noalign.png" />
  269. </button><button class="button btn btn-default" data-icon-align="left" title="Align the icon on the left">
  270. <img src="../../../images/media_align_left.png" />
  271. </button><button class="button btn btn-default" data-icon-align="center" title="Align the icon in the center">
  272. <img src="../../../images/media_align_center.png" />
  273. </button><button class="button btn btn-default" data-icon-align="right" title="Align the icon on the right">
  274. <img src="../../../images/media_align_right.png" />
  275. </button>
  276. </div>
  277. </div>
  278. <div class="box-size col-sm-6">
  279. <label>Image size</label>
  280. <div class="btn-group btn-group-xs">
  281. <button class="button btn btn-default" data-icon-size="small" title="Small size">
  282. <img src="../../../images/media_size_small.png" />
  283. </button><button class="button btn btn-default" data-icon-size="medium" title="Medium size">
  284. <img src="../../../images/media_size_medium.png" />
  285. </button><button class="button btn btn-default" data-icon-size="large" title="Large size">
  286. <img src="../../../images/media_size_large.png" />
  287. </button><button class="button btn btn-default active" data-icon-size="original" title="Original size">
  288. <img src="../../../images/media_size_original.png" />
  289. </button>
  290. </div>
  291. </div>
  292. </div>
  293. <p>&nbsp;</p>
  294. <label>Preview</label>
  295. <pre id="preview"></pre>
  296. <input type="hidden" id="output" />
  297. <input type="hidden" id="icon_pack" />
  298. <input type="hidden" id="icon_name" />
  299. <input type="hidden" id="icon_size" />
  300. <input type="hidden" id="icon_align" />
  301. </div>
  302. </main>
  303. <footer>
  304. <nav class="navbar navbar-default navbar-fixed-bottom">
  305. <div class="container-fluid">
  306. <div class="navbar-text">
  307. <button type="button" id="btn-preview" class="hidden btn btn-default">Preview code</button>
  308. <button type="button" id="btn-insert" class="btn btn-success">Insert</button>
  309. <button type="button" id="btn-reset" class="btn btn-default">Reset</button>
  310. </div>
  311. </div>
  312. </nav>
  313. </footer>
  314. </body>
  315. </html>