code-editor.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/pages/code-editor", ["jquery", "Site"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(require("jquery"), require("Site"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(global.jQuery, global.Site);
  11. global.pagesCodeEditor = mod.exports;
  12. }
  13. })(this, function (_jquery, _Site) {
  14. "use strict";
  15. _jquery = babelHelpers.interopRequireDefault(_jquery);
  16. var _items;
  17. (0, _jquery.default)(document).ready(function ($$$1) {
  18. (0, _Site.run)();
  19. }); // Treeview
  20. // ---------
  21. (function () {
  22. var data = [{
  23. text: 'assets',
  24. href: '#assets',
  25. state: {
  26. expanded: false
  27. },
  28. nodes: [{
  29. text: 'css',
  30. href: '#css',
  31. nodes: [{
  32. text: 'bootstrap.css',
  33. href: '#bootstrap.css',
  34. icon: 'fa fa-file-code-o'
  35. }, {
  36. text: 'site.css',
  37. href: '#site.css',
  38. icon: 'fa fa-file-code-o'
  39. }]
  40. }, {
  41. text: 'fonts',
  42. href: '#fonts',
  43. nodes: [{
  44. text: 'font-awesome',
  45. href: '#font-awesome'
  46. }, {
  47. text: 'web-icons',
  48. href: '#web-icons'
  49. }]
  50. }, {
  51. text: 'images',
  52. href: '#images',
  53. nodes: [{
  54. text: 'logo.png',
  55. href: '#logo.png',
  56. icon: 'fa fa-file-photo-o'
  57. }, {
  58. text: 'bg.png',
  59. href: '#bg.png',
  60. icon: 'fa fa-file-photo-o'
  61. }]
  62. }]
  63. }, {
  64. text: 'grunt',
  65. href: '#grunt',
  66. state: {
  67. expanded: false
  68. },
  69. nodes: [{
  70. text: 'autoprefixer.js',
  71. href: '#autoprefixer.js',
  72. icon: 'fa fa-file-code-o'
  73. }, {
  74. text: 'clean.js',
  75. href: '#clean.js',
  76. icon: 'fa fa-file-code-o'
  77. }, {
  78. text: 'concat.js',
  79. href: '#concat.js',
  80. icon: 'fa fa-file-code-o'
  81. }, {
  82. text: 'csscomb.js',
  83. href: '#csscomb.js',
  84. icon: 'fa fa-file-code-o'
  85. }, {
  86. text: 'cssmin.js',
  87. href: '#cssmin.js',
  88. icon: 'fa fa-file-code-o'
  89. }, {
  90. text: 'less.js',
  91. href: '#less.js',
  92. icon: 'fa fa-file-code-o'
  93. }, {
  94. text: 'uglify.js',
  95. href: '#uglify.js',
  96. icon: 'fa fa-file-code-o'
  97. }]
  98. }, {
  99. text: 'html',
  100. href: '#html',
  101. state: {
  102. expanded: true
  103. },
  104. nodes: [{
  105. text: 'blog.html',
  106. href: '#blog.html',
  107. icon: 'fa fa-file-code-o'
  108. }, {
  109. text: 'docs.html',
  110. href: '#docs.html',
  111. icon: 'fa fa-file-code-o'
  112. }, {
  113. text: 'index.html',
  114. href: '#index.html',
  115. state: {
  116. selected: true
  117. },
  118. icon: 'fa fa-file-code-o'
  119. }]
  120. }, {
  121. text: 'media',
  122. href: '#media',
  123. state: {
  124. expanded: false
  125. },
  126. nodes: [{
  127. text: 'audio.mp3',
  128. href: '#audio.mp3',
  129. icon: 'fa fa-file-audio-o'
  130. }, {
  131. text: 'video.mp4',
  132. href: '#video.mp4',
  133. icon: 'fa fa-file-video-o'
  134. }]
  135. }, {
  136. text: 'Gruntfile.js',
  137. href: '#Gruntfile.js',
  138. icon: 'fa fa-file-code-o'
  139. }, {
  140. text: 'bower.json',
  141. href: '#bower.json',
  142. icon: 'fa fa-file-code-o'
  143. }, {
  144. text: 'README.pdf',
  145. href: '#README.pdf',
  146. icon: 'fa fa-file-pdf-o'
  147. }, {
  148. text: 'package.json',
  149. href: '#package.json',
  150. icon: 'fa fa-file-code-o'
  151. }];
  152. var defaults = Plugin.getDefaults("treeview");
  153. var options = _jquery.default.extend({}, defaults, {
  154. levels: 1,
  155. color: false,
  156. backColor: false,
  157. borderColor: false,
  158. onhoverColor: false,
  159. selectedColor: false,
  160. selectedBackColor: false,
  161. searchResultColor: false,
  162. searchResultBackColor: false,
  163. data: data,
  164. highlightSelected: true
  165. });
  166. (0, _jquery.default)('#filesTree').treeview(options);
  167. })(); // Codemirror
  168. // ----------
  169. CodeMirror.fromTextArea(document.getElementById('code'), {
  170. lineNumbers: !0,
  171. theme: 'eclipse',
  172. mode: 'text/html',
  173. scrollbarStyle: "simple"
  174. }); // Contextmenu
  175. // -----------
  176. _jquery.default.contextMenu({
  177. selector: '#filesTree',
  178. // callback: function(key, options) {
  179. // var m = "clicked: " + key;
  180. // window.console && console.log(m) || alert(m);
  181. // },
  182. items: (_items = {
  183. "rename": {
  184. name: "Rename ...",
  185. icon: function icon() {
  186. return 'context-menu-icon context-menu-extend-icon wb-pencil';
  187. }
  188. },
  189. "search": {
  190. name: "Find in...",
  191. icon: function icon() {
  192. return 'context-menu-icon context-menu-extend-icon wb-search';
  193. }
  194. },
  195. "sep1": "---------",
  196. "new": {
  197. name: "New File",
  198. icon: function icon() {
  199. return 'context-menu-icon context-menu-extend-icon wb-file';
  200. }
  201. },
  202. "new-folder": {
  203. name: "New Folder",
  204. icon: function icon() {
  205. return 'context-menu-icon context-menu-extend-icon wb-folder';
  206. }
  207. }
  208. }, babelHelpers.defineProperty(_items, "sep1", "---------"), babelHelpers.defineProperty(_items, "delete", {
  209. name: "Delete",
  210. icon: function icon() {
  211. return 'context-menu-icon context-menu-extend-icon wb-close';
  212. }
  213. }), _items)
  214. });
  215. });