]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/ColorPalette.js.uncompressed.js
make precache_headlines_idle() start slower
[tt-rss.git] / lib / dijit / ColorPalette.js.uncompressed.js
1 require({cache:{
2 'url:dijit/templates/ColorPalette.html':"<div class=\"dijitInline dijitColorPalette\">\n\t<table dojoAttachPoint=\"paletteTableNode\" class=\"dijitPaletteTable\" cellSpacing=\"0\" cellPadding=\"0\" role=\"grid\">\n\t\t<tbody data-dojo-attach-point=\"gridNode\"></tbody>\n\t</table>\n</div>\n"}});
3 define("dijit/ColorPalette", [
4 "require", // require.toUrl
5 "dojo/text!./templates/ColorPalette.html",
6 "./_Widget",
7 "./_TemplatedMixin",
8 "./_PaletteMixin",
9 "dojo/i18n", // i18n.getLocalization
10 "dojo/_base/Color", // dojo.Color dojo.Color.named
11 "dojo/_base/declare", // declare
12 "dojo/dom-class", // domClass.contains
13 "dojo/dom-construct", // domConstruct.place
14 "dojo/_base/window", // win.body
15 "dojo/string", // string.substitute
16 "dojo/i18n!dojo/nls/colors", // translations
17 "dojo/colors" // extend dojo.Color w/names of other colors
18 ], function(require, template, _Widget, _TemplatedMixin, _PaletteMixin, i18n, Color,
19 declare, domClass, domConstruct, win, string){
20
21 /*=====
22 var _Widget = dijit._Widget;
23 var _TemplatedMixin = dijit._TemplatedMixin;
24 var _PaletteMixin = dijit._PaletteMixin;
25 =====*/
26
27 // module:
28 // dijit/ColorPalette
29 // summary:
30 // A keyboard accessible color-picking widget
31
32 var ColorPalette = declare("dijit.ColorPalette", [_Widget, _TemplatedMixin, _PaletteMixin], {
33 // summary:
34 // A keyboard accessible color-picking widget
35 // description:
36 // Grid showing various colors, so the user can pick a certain color.
37 // Can be used standalone, or as a popup.
38 //
39 // example:
40 // | <div data-dojo-type="dijit.ColorPalette"></div>
41 //
42 // example:
43 // | var picker = new dijit.ColorPalette({ },srcNode);
44 // | picker.startup();
45
46
47 // palette: [const] String
48 // Size of grid, either "7x10" or "3x4".
49 palette: "7x10",
50
51 // _palettes: [protected] Map
52 // This represents the value of the colors.
53 // The first level is a hashmap of the different palettes available.
54 // The next two dimensions represent the columns and rows of colors.
55 _palettes: {
56 "7x10": [["white", "seashell", "cornsilk", "lemonchiffon","lightyellow", "palegreen", "paleturquoise", "lightcyan", "lavender", "plum"],
57 ["lightgray", "pink", "bisque", "moccasin", "khaki", "lightgreen", "lightseagreen", "lightskyblue", "cornflowerblue", "violet"],
58 ["silver", "lightcoral", "sandybrown", "orange", "palegoldenrod", "chartreuse", "mediumturquoise", "skyblue", "mediumslateblue","orchid"],
59 ["gray", "red", "orangered", "darkorange", "yellow", "limegreen", "darkseagreen", "royalblue", "slateblue", "mediumorchid"],
60 ["dimgray", "crimson", "chocolate", "coral", "gold", "forestgreen", "seagreen", "blue", "blueviolet", "darkorchid"],
61 ["darkslategray","firebrick","saddlebrown", "sienna", "olive", "green", "darkcyan", "mediumblue","darkslateblue", "darkmagenta" ],
62 ["black", "darkred", "maroon", "brown", "darkolivegreen", "darkgreen", "midnightblue", "navy", "indigo", "purple"]],
63
64 "3x4": [["white", "lime", "green", "blue"],
65 ["silver", "yellow", "fuchsia", "navy"],
66 ["gray", "red", "purple", "black"]]
67 },
68
69 // templateString: String
70 // The template of this widget.
71 templateString: template,
72
73 baseClass: "dijitColorPalette",
74
75 _dyeFactory: function(value, row, col){
76 // Overrides _PaletteMixin._dyeFactory().
77 return new this._dyeClass(value, row, col);
78 },
79
80 buildRendering: function(){
81 // Instantiate the template, which makes a skeleton into which we'll insert a bunch of
82 // <img> nodes
83 this.inherited(arguments);
84
85 // Creates customized constructor for dye class (color of a single cell) for
86 // specified palette and high-contrast vs. normal mode. Used in _getDye().
87 this._dyeClass = declare(ColorPalette._Color, {
88 hc: domClass.contains(win.body(), "dijit_a11y"),
89 palette: this.palette
90 });
91
92 // Creates <img> nodes in each cell of the template.
93 this._preparePalette(
94 this._palettes[this.palette],
95 i18n.getLocalization("dojo", "colors", this.lang));
96 }
97 });
98
99 ColorPalette._Color = declare("dijit._Color", Color, {
100 // summary:
101 // Object associated with each cell in a ColorPalette palette.
102 // Implements dijit.Dye.
103
104 // Template for each cell in normal (non-high-contrast mode). Each cell contains a wrapper
105 // node for showing the border (called dijitPaletteImg for back-compat), and dijitColorPaletteSwatch
106 // for showing the color.
107 template:
108 "<span class='dijitInline dijitPaletteImg'>" +
109 "<img src='${blankGif}' alt='${alt}' class='dijitColorPaletteSwatch' style='background-color: ${color}'/>" +
110 "</span>",
111
112 // Template for each cell in high contrast mode. Each cell contains an image with the whole palette,
113 // but scrolled and clipped to show the correct color only
114 hcTemplate:
115 "<span class='dijitInline dijitPaletteImg' style='position: relative; overflow: hidden; height: 12px; width: 14px;'>" +
116 "<img src='${image}' alt='${alt}' style='position: absolute; left: ${left}px; top: ${top}px; ${size}'/>" +
117 "</span>",
118
119 // _imagePaths: [protected] Map
120 // This is stores the path to the palette images used for high-contrast mode display
121 _imagePaths: {
122 "7x10": require.toUrl("./themes/a11y/colors7x10.png"),
123 "3x4": require.toUrl("./themes/a11y/colors3x4.png")
124 },
125
126 constructor: function(/*String*/alias, /*Number*/ row, /*Number*/ col){
127 this._alias = alias;
128 this._row = row;
129 this._col = col;
130 this.setColor(Color.named[alias]);
131 },
132
133 getValue: function(){
134 // summary:
135 // Note that although dijit._Color is initialized with a value like "white" getValue() always
136 // returns a hex value
137 return this.toHex();
138 },
139
140 fillCell: function(/*DOMNode*/ cell, /*String*/ blankGif){
141 var html = string.substitute(this.hc ? this.hcTemplate : this.template, {
142 // substitution variables for normal mode
143 color: this.toHex(),
144 blankGif: blankGif,
145 alt: this._alias,
146
147 // variables used for high contrast mode
148 image: this._imagePaths[this.palette].toString(),
149 left: this._col * -20 - 5,
150 top: this._row * -20 - 5,
151 size: this.palette == "7x10" ? "height: 145px; width: 206px" : "height: 64px; width: 86px"
152 });
153
154 domConstruct.place(html, cell);
155 }
156 });
157
158
159 return ColorPalette;
160 });