| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO: RE: implements RequestAnimationFrameCallback. File bug | 5 // TODO: RE: implements RequestAnimationFrameCallback. File bug |
| 6 // against dom libs because it should be possible to pass a function | 6 // against dom libs because it should be possible to pass a function |
| 7 // to webkitRequestAnimationFrame just like addEventListener. | 7 // to webkitRequestAnimationFrame just like addEventListener. |
| 8 class InnerMenuView { | 8 class InnerMenuView { |
| 9 static final List<String> _textAlignmentClassNames = const <String>[ "l", "c",
"r" ]; | 9 static final List<String> _textAlignmentClassNames = const <String>[ "l", "c",
"r" ]; |
| 10 static final List<int> _textAlignmentValues = const <int>[ | 10 static final List<int> _textAlignmentValues = const <int>[ |
| 11 Style.LEFT, Style.CENTER, Style.RIGHT | 11 Style.LEFT, Style.CENTER, Style.RIGHT |
| 12 ]; | 12 ]; |
| 13 static final List<String> _textStyleClassNames = const <String>[ "b", "i", "u"
, "s" ]; | 13 static final List<String> _textStyleClassNames = const <String>[ "b", "i", "u"
, "s" ]; |
| 14 static final List<int> _textStyleValues = const <int>[ | 14 static final List<int> _textStyleValues = const <int>[ |
| 15 Style.BOLD, Style.ITALIC, Style.UNDERLINE, Style.STRIKETHROUGH | 15 Style.BOLD, Style.ITALIC, Style.UNDERLINE, Style.STRIKETHROUGH |
| 16 ]; | 16 ]; |
| 17 | 17 |
| 18 // Return the height of the menu | 18 // Return the height of the menu |
| 19 static int getInnerMenuHeight() => CssStyles.INNER_MENU_HEIGHT; | 19 static int getInnerMenuHeight() => CssStyles.INNER_MENU_HEIGHT; |
| 20 | 20 |
| 21 static DivElement _addButton(Element parent, | 21 static DivElement _addButton(Element parent, |
| 22 String classOfButton, | 22 String classOfButton, |
| 23 String classOfDiv, | 23 String classOfDiv, |
| 24 void clickedFunc(DivElement div)) { | 24 void clickedFunc(DivElement div)) { |
| 25 Document document = parent.document; | 25 Document document = parent.document; |
| 26 ButtonElement button = document.createElement("button"); | 26 ButtonElement button = new Element.tag("button"); |
| 27 button.attributes["class"] = classOfButton; | 27 button.attributes["class"] = classOfButton; |
| 28 Element div = document.createElement("div"); | 28 Element div = new Element.tag("div"); |
| 29 div.attributes["class"] = classOfDiv; | 29 div.attributes["class"] = classOfDiv; |
| 30 button.nodes.add(div); | 30 button.nodes.add(div); |
| 31 parent.nodes.add(button); | 31 parent.nodes.add(button); |
| 32 | 32 |
| 33 // Don't allow click to bubble to the button container | 33 // Don't allow click to bubble to the button container |
| 34 button.on.click.add((Event e) { | 34 button.on.click.add((Event e) { |
| 35 e.cancelBubble = true; | 35 e.cancelBubble = true; |
| 36 clickedFunc(div); | 36 clickedFunc(div); |
| 37 }); | 37 }); |
| 38 return div; | 38 return div; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 */ | 97 */ |
| 98 InnerMenuView(this._window, this._row, this._selectionManager, Style style, in
t initialHeight, | 98 InnerMenuView(this._window, this._row, this._selectionManager, Style style, in
t initialHeight, |
| 99 this._innerMenuMoved, this._callToHide) { | 99 this._innerMenuMoved, this._callToHide) { |
| 100 // Ensure statics are initialized | 100 // Ensure statics are initialized |
| 101 Formats formats = new Formats(); | 101 Formats formats = new Formats(); |
| 102 | 102 |
| 103 _row.classes.add('with-inner-menu'); | 103 _row.classes.add('with-inner-menu'); |
| 104 _pinHeight(_window, _row); | 104 _pinHeight(_window, _row); |
| 105 | 105 |
| 106 Document document = _row.document; | 106 Document document = _row.document; |
| 107 _bar = document.createElement("div"); | 107 _bar = new Element.tag("div"); |
| 108 _bar.classes.add("inner-menu"); | 108 _bar.classes.add("inner-menu"); |
| 109 | 109 |
| 110 // Close the menu when the non-button area is clicked | 110 // Close the menu when the non-button area is clicked |
| 111 // We use the supplied _callToHide function to initiate the hiding | 111 // We use the supplied _callToHide function to initiate the hiding |
| 112 Element buttons = document.createElement("div"); | 112 Element buttons = new Element.tag("div"); |
| 113 buttons.classes.add("inner-menu-buttons"); | 113 buttons.classes.add("inner-menu-buttons"); |
| 114 buttons.on.click.add((Event e) { _callToHide(); }); | 114 buttons.on.click.add((Event e) { _callToHide(); }); |
| 115 | 115 |
| 116 _textStyleButtons = new List<Element>(4); | 116 _textStyleButtons = new List<Element>(4); |
| 117 _textStyleButtons[0] = _addButton(buttons, "inner-menu-button", "b", _textSt
yle); | 117 _textStyleButtons[0] = _addButton(buttons, "inner-menu-button", "b", _textSt
yle); |
| 118 _textStyleButtons[1] = _addButton(buttons, "inner-menu-button", "i", _textSt
yle); | 118 _textStyleButtons[1] = _addButton(buttons, "inner-menu-button", "i", _textSt
yle); |
| 119 _textStyleButtons[2] = _addButton(buttons, "inner-menu-button", "u", _textSt
yle); | 119 _textStyleButtons[2] = _addButton(buttons, "inner-menu-button", "u", _textSt
yle); |
| 120 _textStyleButtons[3] = _addButton(buttons, "inner-menu-button", "s", _textSt
yle); | 120 _textStyleButtons[3] = _addButton(buttons, "inner-menu-button", "s", _textSt
yle); |
| 121 | 121 |
| 122 _textAlignmentButtons = new List<Element>(3); | 122 _textAlignmentButtons = new List<Element>(3); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 252 } |
| 253 } | 253 } |
| 254 | 254 |
| 255 _textColorPicker.selectedIndex = style.textColor; | 255 _textColorPicker.selectedIndex = style.textColor; |
| 256 _backgroundColorPicker.selectedIndex = style.backgroundColor; | 256 _backgroundColorPicker.selectedIndex = style.backgroundColor; |
| 257 _numericFormatPicker.selectedIndex = style.numericFormatIndex; | 257 _numericFormatPicker.selectedIndex = style.numericFormatIndex; |
| 258 } | 258 } |
| 259 | 259 |
| 260 ColorPicker _createColorPicker(Element buttons, String name, String className, | 260 ColorPicker _createColorPicker(Element buttons, String name, String className, |
| 261 SetStyleFunction action) { | 261 SetStyleFunction action) { |
| 262 DivElement div = buttons.document.createElement("div"); | 262 DivElement div = new Element.tag("div"); |
| 263 div.id = "${name}Div"; | 263 div.id = "${name}Div"; |
| 264 | 264 |
| 265 ColorPicker picker = new ColorPicker(div, Formats.htmlColors, 8, 6, 18, 3); | 265 ColorPicker picker = new ColorPicker(div, Formats.htmlColors, 8, 6, 18, 3); |
| 266 picker.addListener((int index) { | 266 picker.addListener((int index) { |
| 267 _showHide(div, false); | 267 _showHide(div, false); |
| 268 _execute(action, index); | 268 _execute(action, index); |
| 269 }); | 269 }); |
| 270 | 270 |
| 271 DivElement button = _addButton(buttons, "inner-menu-button", className, | 271 DivElement button = _addButton(buttons, "inner-menu-button", className, |
| 272 (DivElement elt) { | 272 (DivElement elt) { |
| 273 bool show = div.classes.contains("fadeOut"); | 273 bool show = div.classes.contains("fadeOut"); |
| 274 _showHide(div, show); | 274 _showHide(div, show); |
| 275 }); | 275 }); |
| 276 button.nodes.add(div); | 276 button.nodes.add(div); |
| 277 | 277 |
| 278 if (_pickerElts == null) { | 278 if (_pickerElts == null) { |
| 279 _pickerElts = new List<Element>(); | 279 _pickerElts = new List<Element>(); |
| 280 } | 280 } |
| 281 _pickerElts.add(div); | 281 _pickerElts.add(div); |
| 282 | 282 |
| 283 return picker; | 283 return picker; |
| 284 } | 284 } |
| 285 | 285 |
| 286 ValuePicker _createValuePicker(Element buttons, String name, String className, | 286 ValuePicker _createValuePicker(Element buttons, String name, String className, |
| 287 List<String> values, SetStyleFunction action) { | 287 List<String> values, SetStyleFunction action) { |
| 288 DivElement div = buttons.document.createElement("div"); | 288 DivElement div = new Element.tag("div"); |
| 289 div.id = "${name}Div"; | 289 div.id = "${name}Div"; |
| 290 | 290 |
| 291 DivElement button = _addButton(buttons, "inner-menu-button", "n", | 291 DivElement button = _addButton(buttons, "inner-menu-button", "n", |
| 292 (DivElement elt) { | 292 (DivElement elt) { |
| 293 bool show = div.classes.contains("fadeOut"); | 293 bool show = div.classes.contains("fadeOut"); |
| 294 _showHide(div, show); | 294 _showHide(div, show); |
| 295 }); | 295 }); |
| 296 button.nodes.add(div); | 296 button.nodes.add(div); |
| 297 | 297 |
| 298 ValuePicker picker = new ValuePicker(div, values); | 298 ValuePicker picker = new ValuePicker(div, values); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 for (int i = 0; i < 4; i++) { | 416 for (int i = 0; i < 4; i++) { |
| 417 if (_textStyleButtons[i].attributes["class"].length > 1) { | 417 if (_textStyleButtons[i].attributes["class"].length > 1) { |
| 418 textStyle += _textStyleValues[i]; | 418 textStyle += _textStyleValues[i]; |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 | 421 |
| 422 _execute(Style _(Style s, int selectedIndex) | 422 _execute(Style _(Style s, int selectedIndex) |
| 423 => s.setTextFormatByIndex(selectedIndex), textStyle); | 423 => s.setTextFormatByIndex(selectedIndex), textStyle); |
| 424 } | 424 } |
| 425 } | 425 } |
| OLD | NEW |