css.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. /**
  2. * @license
  3. * Visual Blocks Editor
  4. *
  5. * Copyright 2013 Google Inc.
  6. * https://developers.google.com/blockly/
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. /**
  21. * @fileoverview Inject Blockly's CSS synchronously.
  22. * @author fraser@google.com (Neil Fraser)
  23. */
  24. 'use strict';
  25. goog.provide('Blockly.Css');
  26. /**
  27. * List of cursors.
  28. * @enum {string}
  29. */
  30. Blockly.Css.Cursor = {
  31. OPEN: 'handopen',
  32. CLOSED: 'handclosed',
  33. DELETE: 'handdelete'
  34. };
  35. /**
  36. * Current cursor (cached value).
  37. * @type {string}
  38. * @private
  39. */
  40. Blockly.Css.currentCursor_ = '';
  41. /**
  42. * Large stylesheet added by Blockly.Css.inject.
  43. * @type {Element}
  44. * @private
  45. */
  46. Blockly.Css.styleSheet_ = null;
  47. /**
  48. * Path to media directory, with any trailing slash removed.
  49. * @type {string}
  50. * @private
  51. */
  52. Blockly.Css.mediaPath_ = '';
  53. /**
  54. * Inject the CSS into the DOM. This is preferable over using a regular CSS
  55. * file since:
  56. * a) It loads synchronously and doesn't force a redraw later.
  57. * b) It speeds up loading by not blocking on a separate HTTP transfer.
  58. * c) The CSS content may be made dynamic depending on init options.
  59. * @param {boolean} hasCss If false, don't inject CSS
  60. * (providing CSS becomes the document's responsibility).
  61. * @param {string} pathToMedia Path from page to the Blockly media directory.
  62. */
  63. Blockly.Css.inject = function(hasCss, pathToMedia) {
  64. // Only inject the CSS once.
  65. if (Blockly.Css.styleSheet_) {
  66. return;
  67. }
  68. // Placeholder for cursor rule. Must be first rule (index 0).
  69. var text = '.blocklyDraggable {}\n';
  70. if (hasCss) {
  71. text += Blockly.Css.CONTENT.join('\n');
  72. if (Blockly.FieldDate) {
  73. text += Blockly.FieldDate.CSS.join('\n');
  74. }
  75. }
  76. // Strip off any trailing slash (either Unix or Windows).
  77. Blockly.Css.mediaPath_ = pathToMedia.replace(/[\\\/]$/, '');
  78. text = text.replace(/<<<PATH>>>/g, Blockly.Css.mediaPath_);
  79. // Inject CSS tag.
  80. var cssNode = document.createElement('style');
  81. document.head.appendChild(cssNode);
  82. var cssTextNode = document.createTextNode(text);
  83. cssNode.appendChild(cssTextNode);
  84. Blockly.Css.styleSheet_ = cssNode.sheet;
  85. Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);
  86. };
  87. /**
  88. * Set the cursor to be displayed when over something draggable.
  89. * @param {Blockly.Css.Cursor} cursor Enum.
  90. */
  91. Blockly.Css.setCursor = function(cursor) {
  92. if (Blockly.Css.currentCursor_ == cursor) {
  93. return;
  94. }
  95. Blockly.Css.currentCursor_ = cursor;
  96. var url = 'url(' + Blockly.Css.mediaPath_ + '/' + cursor + '.cur), auto';
  97. // There are potentially hundreds of draggable objects. Changing their style
  98. // properties individually is too slow, so change the CSS rule instead.
  99. var rule = '.blocklyDraggable {\n cursor: ' + url + ';\n}\n';
  100. Blockly.Css.styleSheet_.deleteRule(0);
  101. Blockly.Css.styleSheet_.insertRule(rule, 0);
  102. // There is probably only one toolbox, so just change its style property.
  103. var toolboxen = document.getElementsByClassName('blocklyToolboxDiv');
  104. for (var i = 0, toolbox; toolbox = toolboxen[i]; i++) {
  105. if (cursor == Blockly.Css.Cursor.DELETE) {
  106. toolbox.style.cursor = url;
  107. } else {
  108. toolbox.style.cursor = '';
  109. }
  110. }
  111. // Set cursor on the whole document, so that rapid movements
  112. // don't result in cursor changing to an arrow momentarily.
  113. var html = document.body.parentNode;
  114. if (cursor == Blockly.Css.Cursor.OPEN) {
  115. html.style.cursor = '';
  116. } else {
  117. html.style.cursor = url;
  118. }
  119. };
  120. /**
  121. * Array making up the CSS content for Blockly.
  122. */
  123. Blockly.Css.CONTENT = [
  124. '.blocklySvg {',
  125. 'background-color: #fff;',
  126. 'height: 481px;',
  127. 'outline: none;',
  128. 'overflow: hidden;', /* IE overflows by default. */
  129. '}',
  130. '.blocklyWidgetDiv {',
  131. 'display: none;',
  132. 'position: absolute;',
  133. 'z-index: 999;',
  134. '}',
  135. '.blocklyTooltipDiv {',
  136. 'background-color: #ffffc7;',
  137. 'border: 1px solid #ddc;',
  138. 'box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);',
  139. 'color: #000;',
  140. 'display: none;',
  141. 'font-family: sans-serif;',
  142. 'font-size: 9pt;',
  143. 'opacity: 0.94;',
  144. 'padding: 2px;',
  145. 'position: absolute;',
  146. 'z-index: 1000;',
  147. '}',
  148. '.blocklyResizeSE {',
  149. 'cursor: se-resize;',
  150. 'fill: #aaa;',
  151. '}',
  152. '.blocklyResizeSW {',
  153. 'cursor: sw-resize;',
  154. 'fill: #aaa;',
  155. '}',
  156. '.blocklyResizeLine {',
  157. 'stroke: #888;',
  158. 'stroke-width: 1;',
  159. '}',
  160. '.blocklyHighlightedConnectionPath {',
  161. ' fill: none;',
  162. ' stroke: #0f0;',
  163. ' stroke-width: 8px;',
  164. '}',
  165. '.blocklyHighlightedConnectionPathBad {', /* added for BlocksCAD */
  166. ' fill: none;',
  167. ' stroke: #f00;',
  168. ' stroke-width: 4px;',
  169. '}',
  170. '.blocklyPathLight {',
  171. ' fill: none;',
  172. ' stroke-linecap: round;',
  173. ' stroke-width: 2;',
  174. '}',
  175. '.blocklyBacklight>.blocklyPath {', /* added for BlocksCAD */
  176. ' stroke: #f00;',
  177. ' stroke-width: 4px;',
  178. '}',
  179. '.blocklyBacklight>.blocklyPathLight {', /* added for BlocksCAD */
  180. ' display: none;',
  181. '}',
  182. '.blocklySelected>.blocklyPath {',
  183. 'stroke: #fc3;',
  184. 'stroke-width: 3px;',
  185. '}',
  186. '.blocklySelected>.blocklyPathLight {',
  187. 'display: none;',
  188. '}',
  189. '.blocklyDragging>.blocklyPath,',
  190. '.blocklyDragging>.blocklyPathLight {',
  191. 'fill-opacity: .8;',
  192. 'stroke-opacity: .8;',
  193. '}',
  194. '.blocklyDragging>.blocklyPathDark {',
  195. 'display: none;',
  196. '}',
  197. '.blocklyDisabled>.blocklyPath {',
  198. 'fill-opacity: .5;',
  199. 'stroke-opacity: .5;',
  200. '}',
  201. '.blocklyDisabled>.blocklyPathLight,',
  202. '.blocklyDisabled>.blocklyPathDark {',
  203. 'display: none;',
  204. '}',
  205. '.blocklyText {',
  206. ' cursor: default;',
  207. ' fill: #fff;',
  208. ' font-family: sans-serif;',
  209. ' font-size: 11pt;',
  210. '}',
  211. '.blocklyButton {',
  212. ' cursor: default;',
  213. ' fill: #fff;',
  214. ' border: 1px solid #000;',
  215. ' font-size:12pt;',
  216. '}',
  217. '.blocklyNonEditableText>text {',
  218. 'pointer-events: none;',
  219. '}',
  220. '.blocklyNonEditableText>rect,',
  221. '.blocklyEditableText>rect {',
  222. 'fill: #fff;',
  223. 'fill-opacity: .6;',
  224. '}',
  225. '.blocklyNonEditableText>text,',
  226. '.blocklyEditableText>text {',
  227. 'fill: #000;',
  228. '}',
  229. '.blocklyEditableText:hover>rect {',
  230. 'stroke: #fff;',
  231. 'stroke-width: 2;',
  232. '}',
  233. '.blocklyBubbleText {',
  234. 'fill: #000;',
  235. '}',
  236. /*
  237. Don't allow users to select text. It gets annoying when trying to
  238. drag a block and selected text moves instead.
  239. */
  240. '.blocklySvg text {',
  241. 'user-select: none;',
  242. '-moz-user-select: none;',
  243. '-webkit-user-select: none;',
  244. 'cursor: inherit;',
  245. '}',
  246. '.blocklyHidden {',
  247. 'display: none;',
  248. '}',
  249. '.blocklyFieldDropdown:not(.blocklyHidden) {',
  250. 'display: block;',
  251. '}',
  252. '.blocklyIconGroup {',
  253. 'cursor: default;',
  254. '}',
  255. '.blocklyIconGroup:not(:hover),',
  256. '.blocklyIconGroupReadonly {',
  257. ' opacity: .6;',
  258. '}',
  259. '.blocklyIconShield {',
  260. ' cursor: default;',
  261. ' fill: #00c;',
  262. ' stroke: #ccc;',
  263. ' stroke-width: 1px;',
  264. '}',
  265. '.blocklyIconGroup:hover>.blocklyIconShield {',
  266. ' fill: #00f;',
  267. ' stroke: #fff;',
  268. '}',
  269. '.blocklyIconGroup:hover>.blocklyIconMark {',
  270. ' fill: #fff;',
  271. '}',
  272. '.blocklyIconMark {',
  273. ' cursor: default !important;',
  274. ' fill: #ccc;',
  275. ' font-family: sans-serif;',
  276. ' font-size: 9pt;',
  277. ' font-weight: bold;',
  278. ' text-anchor: middle;',
  279. '}',
  280. '.blocklyIconShape {',
  281. 'fill: #00f;',
  282. 'stroke: #fff;',
  283. 'stroke-width: 1px;',
  284. '}',
  285. '.blocklyIconSymbol {',
  286. 'fill: #fff;',
  287. '}',
  288. '.blocklyMinimalBody {',
  289. 'margin: 0;',
  290. 'padding: 0;',
  291. '}',
  292. '.blocklyCommentTextarea {',
  293. 'background-color: #ffc;',
  294. 'border: 0;',
  295. 'margin: 0;',
  296. 'padding: 2px;',
  297. 'resize: none;',
  298. '}',
  299. '.blocklyHtmlInput {',
  300. 'border: none;',
  301. 'border-radius: 4px;',
  302. 'font-family: sans-serif;',
  303. 'height: 100%;',
  304. 'margin: 0;',
  305. 'outline: none;',
  306. 'padding: 0 1px;',
  307. 'width: 100%',
  308. '}',
  309. '.blocklyMainBackground {',
  310. 'stroke-width: 1;',
  311. 'stroke: #c6c6c6;', /* Equates to #ddd due to border being off-pixel. */
  312. '}',
  313. '.blocklyMutatorBackground {',
  314. 'fill: #fff;',
  315. 'stroke: #ddd;',
  316. 'stroke-width: 1;',
  317. '}',
  318. '.blocklyFlyoutBackground {',
  319. ' fill: #ddd;',
  320. ' fill-opacity: .8;',
  321. '}',
  322. '.blocklyColourBackground {',
  323. ' fill: #666;',
  324. '}',
  325. '.blocklyScrollbarBackground {',
  326. 'opacity: 0;',
  327. '}',
  328. '.blocklyScrollbarHandle {',
  329. 'fill: #ccc;',
  330. '}',
  331. '.blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,',
  332. '.blocklyScrollbarHandle:hover {',
  333. 'fill: #bbb;',
  334. '}',
  335. '.blocklyZoom>image {',
  336. 'opacity: .4;',
  337. '}',
  338. '.blocklyZoom>image:hover {',
  339. 'opacity: .6;',
  340. '}',
  341. '.blocklyZoom>image:active {',
  342. 'opacity: .8;',
  343. '}',
  344. /* Darken flyout scrollbars due to being on a grey background. */
  345. /* By contrast, workspace scrollbars are on a white background. */
  346. '.blocklyFlyout .blocklyScrollbarHandle {',
  347. 'fill: #bbb;',
  348. '}',
  349. '.blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,',
  350. '.blocklyFlyout .blocklyScrollbarHandle:hover {',
  351. 'fill: #aaa;',
  352. '}',
  353. '.blocklyInvalidInput {',
  354. 'background: #faa;',
  355. '}',
  356. '.blocklyAngleCircle {',
  357. 'stroke: #444;',
  358. 'stroke-width: 1;',
  359. 'fill: #ddd;',
  360. 'fill-opacity: .8;',
  361. '}',
  362. '.blocklyAngleMarks {',
  363. 'stroke: #444;',
  364. 'stroke-width: 1;',
  365. '}',
  366. '.blocklyAngleGauge {',
  367. 'fill: #f88;',
  368. 'fill-opacity: .8;',
  369. '}',
  370. '.blocklyAngleLine {',
  371. 'stroke: #f00;',
  372. 'stroke-width: 2;',
  373. 'stroke-linecap: round;',
  374. '}',
  375. '.blocklyContextMenu {',
  376. 'border-radius: 4px;',
  377. '}',
  378. '.blocklyDropdownMenu {',
  379. 'padding: 0 !important;',
  380. '}',
  381. /* Override the default Closure URL. */
  382. '.blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,',
  383. '.blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {',
  384. 'background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px !important;',
  385. '}',
  386. /* Category tree in Toolbox. */
  387. '.blocklyToolboxDiv {',
  388. 'overflow-x: visible;',
  389. 'overflow-y: auto;',
  390. 'position: absolute;',
  391. '}',
  392. '.blocklyTreeRoot {',
  393. ' padding: 0;',
  394. ' margin-top: -2px;',
  395. '}',
  396. '.blocklyTreeRoot:focus {',
  397. 'outline: none;',
  398. '}',
  399. '.blocklyTreeRow {',
  400. ' line-height: 40px;',
  401. ' height: 40px;',
  402. ' padding-right: 1em;',
  403. ' white-space: nowrap;',
  404. ' margin-top: 3px;',
  405. '-webkit-touch-callout: none;',
  406. '-webkit-user-select: none;',
  407. '-khtml-user-select: none;',
  408. '-moz-user-select: none;',
  409. '-ms-user-select: none;',
  410. 'user-select: none;',
  411. '}',
  412. '.blocklyHorizontalTree {',
  413. 'float: left;',
  414. 'margin: 1px 5px 8px 0;',
  415. '}',
  416. '.blocklyHorizontalTreeRtl {',
  417. 'float: right;',
  418. 'margin: 1px 0 8px 5px;',
  419. '}',
  420. '.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {',
  421. ' padding-right: 0;',
  422. ' padding-left: 1em !important;',
  423. '}',
  424. '.blocklyTreeRow:hover {',
  425. '-webkit-box-shadow:inset 0px 0px 0px 1px #fff;',
  426. '-moz-box-shadow:inset 0px 0px 0px 1px #fff;',
  427. 'box-shadow:inset 0px 0px 0px 1px #fff;',
  428. '}',
  429. '.blocklyTreeSeparator {',
  430. 'border-bottom: solid #e5e5e5 1px;',
  431. 'height: 0;',
  432. 'margin: 5px 0;',
  433. '}',
  434. '.blocklyTreeSeparatorHorizontal {',
  435. 'border-right: solid #e5e5e5 1px;',
  436. 'width: 0;',
  437. 'padding: 5px 0;',
  438. 'margin: 0 5px;',
  439. '}',
  440. '.blocklyTreeIcon {',
  441. 'background-image: url(<<<PATH>>>/sprites.png);',
  442. 'height: 16px;',
  443. 'vertical-align: middle;',
  444. 'width: 16px;',
  445. '}',
  446. '.blocklyTreeIconClosedLtr {',
  447. 'background-position: -32px -1px;',
  448. '}',
  449. '.blocklyTreeIconClosedRtl {',
  450. 'background-position: 0px -1px;',
  451. '}',
  452. '.blocklyTreeIconOpen {',
  453. 'background-position: -16px -1px;',
  454. '}',
  455. '.blocklyTreeSelected>.blocklyTreeIconClosedLtr {',
  456. 'background-position: -32px -17px;',
  457. '}',
  458. '.blocklyTreeSelected>.blocklyTreeIconClosedRtl {',
  459. 'background-position: 0px -17px;',
  460. '}',
  461. '.blocklyTreeSelected>.blocklyTreeIconOpen {',
  462. 'background-position: -16px -17px;',
  463. '}',
  464. '.blocklyTreeIconNone,',
  465. '.blocklyTreeSelected>.blocklyTreeIconNone {',
  466. 'background-position: -48px -1px;',
  467. '}',
  468. '.blocklyTreeLabel {',
  469. 'cursor: default;',
  470. 'font-family: sans-serif;',
  471. 'font-size: 16px;',
  472. 'padding: 0 3px;',
  473. 'vertical-align: middle;',
  474. 'color: #fff',
  475. '}',
  476. '.blocklyTreeSelected .blocklyTreeLabel {',
  477. 'color: #fff;',
  478. '}',
  479. /* Copied from: goog/css/colorpicker-simplegrid.css */
  480. /*
  481. * Copyright 2007 The Closure Library Authors. All Rights Reserved.
  482. *
  483. * Use of this source code is governed by the Apache License, Version 2.0.
  484. * See the COPYING file for details.
  485. */
  486. /* Author: pupius@google.com (Daniel Pupius) */
  487. /*
  488. Styles to make the colorpicker look like the old gmail color picker
  489. NOTE: without CSS scoping this will override styles defined in palette.css
  490. */
  491. '.blocklyWidgetDiv .goog-palette {',
  492. 'outline: none;',
  493. 'cursor: default;',
  494. '}',
  495. '.blocklyWidgetDiv .goog-palette-table {',
  496. 'border: 1px solid #666;',
  497. 'border-collapse: collapse;',
  498. '}',
  499. '.blocklyWidgetDiv .goog-palette-cell {',
  500. 'height: 13px;',
  501. 'width: 15px;',
  502. 'margin: 0;',
  503. 'border: 0;',
  504. 'text-align: center;',
  505. 'vertical-align: middle;',
  506. 'border-right: 1px solid #666;',
  507. 'font-size: 1px;',
  508. '}',
  509. '.blocklyWidgetDiv .goog-palette-colorswatch {',
  510. 'position: relative;',
  511. 'height: 13px;',
  512. 'width: 15px;',
  513. 'border: 1px solid #666;',
  514. '}',
  515. '.blocklyWidgetDiv .goog-palette-cell-hover .goog-palette-colorswatch {',
  516. 'border: 1px solid #FFF;',
  517. '}',
  518. '.blocklyWidgetDiv .goog-palette-cell-selected .goog-palette-colorswatch {',
  519. 'border: 1px solid #000;',
  520. 'color: #fff;',
  521. '}',
  522. /* Copied from: goog/css/menu.css */
  523. /*
  524. * Copyright 2009 The Closure Library Authors. All Rights Reserved.
  525. *
  526. * Use of this source code is governed by the Apache License, Version 2.0.
  527. * See the COPYING file for details.
  528. */
  529. /**
  530. * Standard styling for menus created by goog.ui.MenuRenderer.
  531. *
  532. * @author attila@google.com (Attila Bodis)
  533. */
  534. '.blocklyWidgetDiv .goog-menu {',
  535. 'background: #fff;',
  536. 'border-color: #ccc #666 #666 #ccc;',
  537. 'border-style: solid;',
  538. 'border-width: 1px;',
  539. 'cursor: default;',
  540. 'font: normal 13px Arial, sans-serif;',
  541. 'margin: 0;',
  542. 'outline: none;',
  543. 'padding: 4px 0;',
  544. 'position: absolute;',
  545. 'overflow-y: auto;',
  546. 'overflow-x: hidden;',
  547. 'max-height: 100%;',
  548. 'z-index: 20000;', /* Arbitrary, but some apps depend on it... */
  549. '}',
  550. /* Copied from: goog/css/menuitem.css */
  551. /*
  552. * Copyright 2009 The Closure Library Authors. All Rights Reserved.
  553. *
  554. * Use of this source code is governed by the Apache License, Version 2.0.
  555. * See the COPYING file for details.
  556. */
  557. /**
  558. * Standard styling for menus created by goog.ui.MenuItemRenderer.
  559. *
  560. * @author attila@google.com (Attila Bodis)
  561. */
  562. /**
  563. * State: resting.
  564. *
  565. * NOTE(mleibman,chrishenry):
  566. * The RTL support in Closure is provided via two mechanisms -- "rtl" CSS
  567. * classes and BiDi flipping done by the CSS compiler. Closure supports RTL
  568. * with or without the use of the CSS compiler. In order for them not
  569. * to conflict with each other, the "rtl" CSS classes need to have the #noflip
  570. * annotation. The non-rtl counterparts should ideally have them as well, but,
  571. * since .goog-menuitem existed without .goog-menuitem-rtl for so long before
  572. * being added, there is a risk of people having templates where they are not
  573. * rendering the .goog-menuitem-rtl class when in RTL and instead rely solely
  574. * on the BiDi flipping by the CSS compiler. That's why we're not adding the
  575. * #noflip to .goog-menuitem.
  576. */
  577. '.blocklyWidgetDiv .goog-menuitem {',
  578. 'color: #000;',
  579. 'font: normal 13px Arial, sans-serif;',
  580. 'list-style: none;',
  581. 'margin: 0;',
  582. /* 28px on the left for icon or checkbox; 7em on the right for shortcut. */
  583. 'padding: 4px 7em 4px 28px;',
  584. 'white-space: nowrap;',
  585. '}',
  586. /* BiDi override for the resting state. */
  587. /* #noflip */
  588. '.blocklyWidgetDiv .goog-menuitem.goog-menuitem-rtl {',
  589. /* Flip left/right padding for BiDi. */
  590. 'padding-left: 7em;',
  591. 'padding-right: 28px;',
  592. '}',
  593. /* If a menu doesn't have checkable items or items with icons, remove padding. */
  594. '.blocklyWidgetDiv .goog-menu-nocheckbox .goog-menuitem,',
  595. '.blocklyWidgetDiv .goog-menu-noicon .goog-menuitem {',
  596. 'padding-left: 12px;',
  597. '}',
  598. /*
  599. * If a menu doesn't have items with shortcuts, leave just enough room for
  600. * submenu arrows, if they are rendered.
  601. */
  602. '.blocklyWidgetDiv .goog-menu-noaccel .goog-menuitem {',
  603. 'padding-right: 20px;',
  604. '}',
  605. '.blocklyWidgetDiv .goog-menuitem-content {',
  606. 'color: #000;',
  607. 'font: normal 13px Arial, sans-serif;',
  608. '}',
  609. /* State: disabled. */
  610. '.blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-accel,',
  611. '.blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-content {',
  612. 'color: #ccc !important;',
  613. '}',
  614. '.blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-icon {',
  615. 'opacity: 0.3;',
  616. '-moz-opacity: 0.3;',
  617. 'filter: alpha(opacity=30);',
  618. '}',
  619. /* State: hover. */
  620. '.blocklyWidgetDiv .goog-menuitem-highlight,',
  621. '.blocklyWidgetDiv .goog-menuitem-hover {',
  622. 'background-color: #d6e9f8;',
  623. /* Use an explicit top and bottom border so that the selection is visible',
  624. * in high contrast mode. */
  625. 'border-color: #d6e9f8;',
  626. 'border-style: dotted;',
  627. 'border-width: 1px 0;',
  628. 'padding-bottom: 3px;',
  629. 'padding-top: 3px;',
  630. '}',
  631. /* State: selected/checked. */
  632. '.blocklyWidgetDiv .goog-menuitem-checkbox,',
  633. '.blocklyWidgetDiv .goog-menuitem-icon {',
  634. 'background-repeat: no-repeat;',
  635. 'height: 16px;',
  636. 'left: 6px;',
  637. 'position: absolute;',
  638. 'right: auto;',
  639. 'vertical-align: middle;',
  640. 'width: 16px;',
  641. '}',
  642. /* BiDi override for the selected/checked state. */
  643. /* #noflip */
  644. '.blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-checkbox,',
  645. '.blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-icon {',
  646. /* Flip left/right positioning. */
  647. 'left: auto;',
  648. 'right: 6px;',
  649. '}',
  650. '.blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,',
  651. '.blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {',
  652. /* Client apps may override the URL at which they serve the sprite. */
  653. 'background: url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -512px 0;',
  654. '}',
  655. /* Keyboard shortcut ("accelerator") style. */
  656. '.blocklyWidgetDiv .goog-menuitem-accel {',
  657. 'color: #999;',
  658. /* Keyboard shortcuts are untranslated; always left-to-right. */
  659. /* #noflip */
  660. 'direction: ltr;',
  661. 'left: auto;',
  662. 'padding: 0 6px;',
  663. 'position: absolute;',
  664. 'right: 0;',
  665. 'text-align: right;',
  666. '}',
  667. /* BiDi override for shortcut style. */
  668. /* #noflip */
  669. '.blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-accel {',
  670. /* Flip left/right positioning and text alignment. */
  671. 'left: 0;',
  672. 'right: auto;',
  673. 'text-align: left;',
  674. '}',
  675. /* Mnemonic styles. */
  676. '.blocklyWidgetDiv .goog-menuitem-mnemonic-hint {',
  677. 'text-decoration: underline;',
  678. '}',
  679. '.blocklyWidgetDiv .goog-menuitem-mnemonic-separator {',
  680. 'color: #999;',
  681. 'font-size: 12px;',
  682. 'padding-left: 4px;',
  683. '}',
  684. /* Copied from: goog/css/menuseparator.css */
  685. /*
  686. * Copyright 2009 The Closure Library Authors. All Rights Reserved.
  687. *
  688. * Use of this source code is governed by the Apache License, Version 2.0.
  689. * See the COPYING file for details.
  690. */
  691. /**
  692. * Standard styling for menus created by goog.ui.MenuSeparatorRenderer.
  693. *
  694. * @author attila@google.com (Attila Bodis)
  695. */
  696. '.blocklyWidgetDiv .goog-menuseparator {',
  697. 'border-top: 1px solid #ccc;',
  698. 'margin: 4px 0;',
  699. 'padding: 0;',
  700. '}',
  701. ''
  702. ];