Browse files

Updated to jQuery 1.8 widget factory

  • Loading branch information...
1 parent f1b6058 commit d78ebd2a85eb3cfd337e3108baf3b65df3879f9d @jzaefferer committed Apr 20, 2010
Showing with 48 additions and 46 deletions.
  1. +48 −46 jquery.nmk.colorswatch.js
View
94 jquery.nmk.colorswatch.js
@@ -1,9 +1,53 @@
(function($) {
$.widget('nmk.colorswatch', {
+
+ options: {
+ colors: [
+ '#000000',
+ '#993300',
+ '#333300',
+ '#000080',
+ '#333399',
+ '#333333',
+ '#800000',
+ '#FF6600',
+ '#808000',
+ '#008000',
+ '#008080',
+ '#0000FF',
+ '#666699',
+ '#808080',
+ '#FF0000',
+ '#FF9900',
+ '#99CC00',
+ '#339966',
+ '#33CCCC',
+ '#3366FF',
+ '#800080',
+ '#999999',
+ '#FF00FF',
+ '#FFCC00',
+ '#FFFF00',
+ '#00FF00',
+ '#00FFFF',
+ '#00CCFF',
+ '#993366',
+ '#C0C0C0',
+ '#FF99CC',
+ '#FFCC99',
+ '#FFFF99',
+ '#CCFFFF',
+ '#99CCFF',
+ '#FFFFFF'
+ ],
+ rowSize: 6,
+ value: null
+ },
+
isInput: false,
- _init: function() {
+ _create: function() {
this.swatch = (this.element.is(':input') ? this._initFromInput() : this.element)
.addClass('nmk-colorswatch');
@@ -36,7 +80,7 @@ $.widget('nmk.colorswatch', {
rowSize = this.options.rowSize,
swatch = this.swatch.empty(),
self = this;
-
+
$.each(this.options.colors, function(i, color) {
if (!(i % rowSize)) {
row = $('<div></div>')
@@ -94,54 +138,12 @@ $.widget('nmk.colorswatch', {
this.swatch.empty();
}
- $.widget.prototype.destroy.apply(this, arguments);
+ $.Widget.prototype.destroy.apply(this, arguments);
}
});
$.extend($.nmk.colorswatch, {
- version: '1.0pre',
- defaults: {
- colors: [
- '#000000',
- '#993300',
- '#333300',
- '#000080',
- '#333399',
- '#333333',
- '#800000',
- '#FF6600',
- '#808000',
- '#008000',
- '#008080',
- '#0000FF',
- '#666699',
- '#808080',
- '#FF0000',
- '#FF9900',
- '#99CC00',
- '#339966',
- '#33CCCC',
- '#3366FF',
- '#800080',
- '#999999',
- '#FF00FF',
- '#FFCC00',
- '#FFFF00',
- '#00FF00',
- '#00FFFF',
- '#00CCFF',
- '#993366',
- '#C0C0C0',
- '#FF99CC',
- '#FFCC99',
- '#FFFF99',
- '#CCFFFF',
- '#99CCFF',
- '#FFFFFF'
- ],
- rowSize: 6,
- value: null
- }
+ version: '1.0pre'
});
})(jQuery);

0 comments on commit d78ebd2

Please sign in to comment.