| 1 |
define([ |
| 2 |
"require", |
| 3 |
"dojo/text!./templates/ColorPalette.html", |
| 4 |
"./_Widget", |
| 5 |
"./_TemplatedMixin", |
| 6 |
"./_PaletteMixin", |
| 7 |
"./hccss", |
| 8 |
"dojo/i18n", |
| 9 |
"dojo/_base/Color", |
| 10 |
"dojo/_base/declare", |
| 11 |
"dojo/dom-construct", |
| 12 |
"dojo/string", |
| 13 |
"dojo/i18n!dojo/nls/colors", |
| 14 |
"dojo/colors" |
| 15 |
], function(require, template, _Widget, _TemplatedMixin, _PaletteMixin, has, i18n, Color, |
| 16 |
declare, domConstruct, string){ |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
var ColorPalette = declare("dijit.ColorPalette", [_Widget, _TemplatedMixin, _PaletteMixin], { |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
palette: "7x10", |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
_palettes: { |
| 45 |
"7x10": [ |
| 46 |
["white", "seashell", "cornsilk", "lemonchiffon", "lightyellow", "palegreen", "paleturquoise", "lightcyan", "lavender", "plum"], |
| 47 |
["lightgray", "pink", "bisque", "moccasin", "khaki", "lightgreen", "lightseagreen", "lightskyblue", "cornflowerblue", "violet"], |
| 48 |
["silver", "lightcoral", "sandybrown", "orange", "palegoldenrod", "chartreuse", "mediumturquoise", "skyblue", "mediumslateblue", "orchid"], |
| 49 |
["gray", "red", "orangered", "darkorange", "yellow", "limegreen", "darkseagreen", "royalblue", "slateblue", "mediumorchid"], |
| 50 |
["dimgray", "crimson", "chocolate", "coral", "gold", "forestgreen", "seagreen", "blue", "blueviolet", "darkorchid"], |
| 51 |
["darkslategray", "firebrick", "saddlebrown", "sienna", "olive", "green", "darkcyan", "mediumblue", "darkslateblue", "darkmagenta" ], |
| 52 |
["black", "darkred", "maroon", "brown", "darkolivegreen", "darkgreen", "midnightblue", "navy", "indigo", "purple"] |
| 53 |
], |
| 54 |
|
| 55 |
"3x4": [ |
| 56 |
["white", "lime", "green", "blue"], |
| 57 |
["silver", "yellow", "fuchsia", "navy"], |
| 58 |
["gray", "red", "purple", "black"] |
| 59 |
] |
| 60 |
}, |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
templateString: template, |
| 65 |
|
| 66 |
baseClass: "dijitColorPalette", |
| 67 |
|
| 68 |
_dyeFactory: function(value, row, col, title){ |
| 69 |
|
| 70 |
return new this._dyeClass(value, row, col, title); |
| 71 |
}, |
| 72 |
|
| 73 |
buildRendering: function(){ |
| 74 |
|
| 75 |
|
| 76 |
this.inherited(arguments); |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
this._dyeClass = declare(ColorPalette._Color, { |
| 81 |
palette: this.palette |
| 82 |
}); |
| 83 |
|
| 84 |
|
| 85 |
this._preparePalette( |
| 86 |
this._palettes[this.palette], |
| 87 |
i18n.getLocalization("dojo", "colors", this.lang)); |
| 88 |
} |
| 89 |
}); |
| 90 |
|
| 91 |
ColorPalette._Color = declare("dijit._Color", Color, { |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
template: "<span class='dijitInline dijitPaletteImg'>" + |
| 100 |
"<img src='${blankGif}' alt='${alt}' title='${title}' class='dijitColorPaletteSwatch' style='background-color: ${color}'/>" + |
| 101 |
"</span>", |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
hcTemplate: "<span class='dijitInline dijitPaletteImg' style='position: relative; overflow: hidden; height: 12px; width: 14px;'>" + |
| 106 |
"<img src='${image}' alt='${alt}' title='${title}' style='position: absolute; left: ${left}px; top: ${top}px; ${size}'/>" + |
| 107 |
"</span>", |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
_imagePaths: { |
| 112 |
"7x10": require.toUrl("./themes/a11y/colors7x10.png"), |
| 113 |
"3x4": require.toUrl("./themes/a11y/colors3x4.png") |
| 114 |
}, |
| 115 |
|
| 116 |
constructor: function(alias, row, col, title){ |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
this._title = title; |
| 128 |
this._row = row; |
| 129 |
this._col = col; |
| 130 |
this.setColor(Color.named[alias]); |
| 131 |
}, |
| 132 |
|
| 133 |
getValue: function(){ |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
return this.toHex(); |
| 138 |
}, |
| 139 |
|
| 140 |
fillCell: function( cell, blankGif){ |
| 141 |
var html = string.substitute(has("highcontrast") ? this.hcTemplate : this.template, { |
| 142 |
|
| 143 |
color: this.toHex(), |
| 144 |
blankGif: blankGif, |
| 145 |
alt: this._title, |
| 146 |
title: this._title, |
| 147 |
|
| 148 |
|
| 149 |
image: this._imagePaths[this.palette].toString(), |
| 150 |
left: this._col * -20 - 5, |
| 151 |
top: this._row * -20 - 5, |
| 152 |
size: this.palette == "7x10" ? "height: 145px; width: 206px" : "height: 64px; width: 86px" |
| 153 |
}); |
| 154 |
|
| 155 |
domConstruct.place(html, cell); |
| 156 |
} |
| 157 |
}); |
| 158 |
|
| 159 |
return ColorPalette; |
| 160 |
}); |