Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 KB | None | 0 0
  1. <style class="cp-pen-styles">@import url(http://fonts.googleapis.com/css?family=Lato:300,400,700|PT+Mono);
  2. body {
  3. background: LightBlue;
  4. font-family: Lato, sans-serif;
  5. font-size: 15px;
  6. margin: 0;
  7. }
  8. *,
  9. *:before,
  10. *:after {
  11. box-sizing: border-box;
  12. }
  13. *:focus {
  14. outline: none;
  15. }
  16. a {
  17. text-decoration: none;
  18. color: inherit;
  19. }
  20. main {
  21. min-height: 100vh;
  22. display: flex;
  23. display: -webkit-flex;
  24. -webkit-align-items: center;
  25. align-items: center;
  26. -webkit-flex-direction: column;
  27. flex-direction: column;
  28. }
  29. .title {
  30. color: #fff;
  31. text-align: center;
  32. font-weight: 300;
  33. text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  34. font-size: 2.8em;
  35. margin-top: 1.5em;
  36. }
  37. .title small {
  38. display: block;
  39. font-size: 0.6em;
  40. margin-top: 0.4em;
  41. }
  42. .credits {
  43. color: #fff;
  44. text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  45. margin-top: 2em;
  46. font-size: 0.8em;
  47. opacity: 0.5;
  48. }
  49. .window {
  50. width: 547px;
  51. background: GhostWhite;
  52. border-radius: 0.3rem;
  53. box-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
  54. overflow: hidden;
  55. }
  56. .window .window-header {
  57. height: 37px;
  58. background: Gainsboro;
  59. position: relative;
  60. }
  61. .window .window-header .action-buttons {
  62. position: absolute;
  63. top: 50%;
  64. left: 10px;
  65. margin-top: -5px;
  66. width: 10px;
  67. height: 10px;
  68. background: Crimson;
  69. border-radius: 50%;
  70. box-shadow: 15px 0 0 Orange,
  71. 30px 0 0 LimeGreen;
  72. }
  73. .window .window-header .language {
  74. display: inline-block;
  75. position: absolute;
  76. right: 10px;
  77. top: 50%;
  78. margin-top: -10px;
  79. height: 21px;
  80. padding: 0 1em;
  81. text-align: right;
  82. -webkit-appearance: none;
  83. appearance: none;
  84. border: none;
  85. background: transparent;
  86. font-family: Lato, sans-serif;
  87. color: DimGrey;
  88. }
  89. .window .window-header .language:before {
  90. content: 'asd';
  91. }
  92. .window .window-header .language:hover {
  93. background: rgba(0, 0, 0, 0.1);
  94. }
  95. .window .window-body {
  96. position: relative;
  97. height: 300px;
  98. }
  99. .window .window-body .code-input,
  100. .window .window-body .code-output {
  101. position: absolute;
  102. top: 0;
  103. left: 0;
  104. width: 100%;
  105. height: 100%;
  106. padding: 1rem;
  107. border: none;
  108. font-family: 'PT Mono', monospace;
  109. font-size: 0.8rem;
  110. background: transparent;
  111. white-space: pre-wrap;
  112. line-height: 1.5em;
  113. word-wrap: break-word;
  114. }
  115. .window .window-body .code-input {
  116. opacity: 0.7;
  117. margin: 0;
  118. color: #999;
  119. resize: none;
  120. }
  121. .window .window-body .code-output {
  122. pointer-events: none;
  123. z-index: 3;
  124. margin: 0;
  125. overflow-y: auto;
  126. }
  127. .window .window-body .code-output code {
  128. position: absolute;
  129. top: 0;
  130. left: 0;
  131. margin: 0;
  132. padding: 1rem;
  133. display: block;
  134. color: #666;
  135. font-size: 0.8rem;
  136. font-family: 'PT Mono', monospace;
  137. }
  138. a.token {
  139. text-decoration: none;
  140. }
  141. .token.selector,
  142. .token.punctuation,
  143. .token.keyword {
  144. color: PaleVioletRed;
  145. }
  146. .token.property,
  147. .token.number,
  148. .token.string,
  149. .token.punctuation,
  150. .token.tag-id {
  151. color: DodgerBlue;
  152. }
  153. .token.function,
  154. .token.attr-name {
  155. color: CadetBlue;
  156. }
  157. .token.atrule .atrule-id {
  158. color: BlueViolet;
  159. }
  160. .token.boolean {
  161. color: LightSlateGray;
  162. }
  163. .token.comment {
  164. color: DarkGrey;
  165. }
  166. .language-php .variable {
  167. color: CadetBlue;
  168. }
  169. </style></head><body>
  170. <main class="view">
  171. <h1 class="title">
  172. iCode
  173. <small>The editor of the future!</small>
  174. </h1>
  175.  
  176. <div class="window">
  177. <div class="window-header">
  178. <div class="action-buttons"></div>
  179. <select class="language">
  180. <option value="javascript">Javascript</option>
  181. <option value="php">PHP</option>
  182. <option value="markup" selected>HTML</option>
  183. </select>
  184. </div>
  185. <div class="window-body">
  186. <textarea class="code-input">
  187. //Code Editor by InfiniCode
  188. </textarea>
  189. <pre class="code-output">
  190. <code class="language-javascript">
  191.  
  192. </code>
  193. </pre>
  194. </div>
  195. </div>
  196. <div class="credits">
  197. Copyright &copy InfiniCode
  198. </div>
  199. </main>
  200. <script src='//assets.codepen.io/assets/common/stopExecutionOnTimeout.js?t=1'></script><script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/prism/0.0.1/prism.min.js'></script>
  201. <script>
  202. ;
  203. var MicroCode = function () {
  204. return {
  205. init: function (inputSel, outputSel, languageSel) {
  206. this.focusInput(inputSel);
  207. this.listenForInput(inputSel);
  208. this.listenForLanguage(languageSel, '.code-output', inputSel);
  209. this.renderOutput(outputSel, $(inputSel)[0].value);
  210. this.listenerForScroll(inputSel, outputSel);
  211. },
  212. listenForInput: function (inputSel) {
  213. var self = this;
  214. $(inputSel).on('input keydown', function (key) {
  215. var input = this, selStartPos = input.selectionStart, inputVal = input.value;
  216. if (key.keyCode === 9) {
  217. input.value = inputVal.substring(0, selStartPos) + ' ' + inputVal.substring(selStartPos, input.value.length);
  218. input.selectionStart = selStartPos + 4;
  219. input.selectionEnd = selStartPos + 4;
  220. key.preventDefault();
  221. }
  222. self.renderOutput('.code-output', this.value);
  223. });
  224. Prism.highlightAll();
  225. },
  226. listenForLanguage: function (languageSel, outputSel, inputSel) {
  227. var self = this;
  228. $(languageSel).on('change', function () {
  229. $('code', outputSel).removeClass().addClass('language-' + this.value).removeAttr('data-language');
  230. $(outputSel).removeClass().addClass('code-output language-' + this.value);
  231. $(inputSel).val('');
  232. $('code', outputSel).html('');
  233. self.focusInput(inputSel);
  234. });
  235. },
  236. listenerForScroll: function (inputSel, outputSel) {
  237. $(inputSel).on('scroll', function () {
  238. console.log(this.scrollTop);
  239. $(outputSel)[0].scrollTop = this.scrollTop;
  240. });
  241. },
  242. renderOutput: function (outputSel, value) {
  243. $('code', outputSel).html(value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') + '\n');
  244. Prism.highlightAll();
  245. },
  246. focusInput: function (inputSel) {
  247. var input = $(inputSel);
  248. input.focus();
  249. input[0].selectionStart = input[0].value.length;
  250. input[0].selectionEnd = input[0].value.length;
  251. }
  252. };
  253. }();
  254. MicroCode.init('.code-input', '.code-output', '.language');
  255. //@ sourceURL=pen.js
  256. </script>
  257. <script src='//codepen.io/assets/editor/live/css_live_reload_init.js'></script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement