Download:
child 4:88f00d65652c
parent 2:612d0821dd74
3:cd531665699b
Anton Shestakov <engored@ya.ru>, Thu, 09 May 2013 00:42:25 +0900
itemFn and widgetItemFn take now text as a second argument.

4 файлов изменено, 24 вставок(+), 17 удалений(-) [+]
demo-bootstrap.html file | annotate | diff | comparison | revisions
demo-foundation4.html file | annotate | diff | comparison | revisions
demo.html file | annotate | diff | comparison | revisions
jquery.lensy.js file | annotate | diff | comparison | revisions
--- a/demo-bootstrap.html Sun May 05 22:15:37 2013 +0900
+++ b/demo-bootstrap.html Thu May 09 00:42:25 2013 +0900
@@ -99,10 +99,10 @@
widgetClass: 'lensy-widget inline well well-small',
closeButtonClass: 'btn',
itemActiveClass: 'thumbnail',
- itemFn: function(value) {
- var colorbox = $('<div>').css({width: '64px', height: '64px', background: value});
+ itemFn: function(value, text) {
+ var colorbox = $('<div>').css({width: '64px', height: '64px', background: text});
return $('<div>')
- .text(value)
+ .text(text)
.prepend(colorbox);
}
});
--- a/demo-foundation4.html Sun May 05 22:15:37 2013 +0900
+++ b/demo-foundation4.html Thu May 09 00:42:25 2013 +0900
@@ -91,10 +91,10 @@
widgetClass: 'lensy-widget inline-list',
closeButtonClass: 'button',
itemActiveClass: 'th',
- itemFn: function(value) {
- var colorbox = $('<div>').css({width: '64px', height: '64px', background: value});
+ itemFn: function(value, text) {
+ var colorbox = $('<div>').css({width: '64px', height: '64px', background: text});
return $('<div>')
- .text(value)
+ .text(text)
.prepend(colorbox);
}
});
--- a/demo.html Sun May 05 22:15:37 2013 +0900
+++ b/demo.html Thu May 09 00:42:25 2013 +0900
@@ -172,17 +172,17 @@
<script id="lensy-js">
$(function() {
$('select').lensy({
- itemFn: function(value) {
- var colorbox = $('<div>').css({width: '64px', height: '64px', background: value});
+ itemFn: function(value, text) {
+ var colorbox = $('<div>').css({width: '64px', height: '64px', background: text});
return $('<div>')
- .text(value)
+ .text(text)
.prepend(colorbox);
},
- widgetItemFn: function(value) {
+ widgetItemFn: function(value, text) {
// If you don't define this function,
// itemFn will be used for widget items.
return $('<span>')
- .css({background: value})
+ .css({background: text})
.text(value);
}
});
--- a/jquery.lensy.js Sun May 05 22:15:37 2013 +0900
+++ b/jquery.lensy.js Thu May 09 00:42:25 2013 +0900
@@ -46,17 +46,24 @@
this.$modal.hide();
},
- createItem: function(value) {
+ createItem: function($option) {
+ var value = $option.val();
+ var text = $option.text();
+
return $('<li>')
.addClass(this.settings.itemClass)
.attr('data-original-value', value)
- .html(this.settings.itemFn(value));
+ .attr('data-original-text', text)
+ .html(this.settings.itemFn(value, text));
},
- createWidgetItem: function(value) {
+ createWidgetItem: function($item) {
+ var value = $item.attr('data-original-value');
+ var text = $item.attr('data-original-text');
+
return $('<li>')
.addClass(this.settings.itemClass)
- .html((this.settings.widgetItemFn || this.settings.itemFn)(value));
+ .html((this.settings.widgetItemFn || this.settings.itemFn)(value, text));
},
filter: function() {
@@ -87,7 +94,7 @@
} else {
$item.addClass(self.settings.itemActiveClass);
- var $widgetItem = self.createWidgetItem(value);
+ var $widgetItem = self.createWidgetItem($item);
self.$widget.append($widgetItem);
}
});
@@ -118,7 +125,7 @@
// $container is populated with $items
this.$select.find('option').each(function() {
var $option = $(this);
- var $item = self.createItem($option.val());
+ var $item = self.createItem($option);
$item.on('click', itemSelected);
self.$container.append($item);
});