IconPanel reimplemented

This commit is contained in:
Ezequiel Bergamaschi 2014-03-16 21:33:56 -03:00
parent 43898f6878
commit bd70f3b609

View File

@ -19,8 +19,7 @@
mindplot.widget.IconPanel = new Class({ mindplot.widget.IconPanel = new Class({
Extends:mindplot.widget.ToolbarPaneItem, Extends:mindplot.widget.ToolbarPaneItem,
initialize:function (buttonId, model) { initialize:function (buttonId, model) {
console.error("mindplot.widget.IconPanel"); this.parent(buttonId, model);
// this.parent(buttonId, model);
}, },
_updateSelectedItem:function () { _updateSelectedItem:function () {
@ -29,9 +28,8 @@ mindplot.widget.IconPanel = new Class({
}, },
buildPanel:function () { buildPanel:function () {
var content = new Element('div', {'class':'toolbarPanel', 'id':'IconsPanel'}); var content = $('<div class="toolbarPanel" id="IconsPanel"></div>').css({width: 253, height: 230, padding: 5});
content.setStyles({width:253, height:230, padding:5}); content.on('click', function (event) {
content.addEvent("click", function (event) {
event.stopPropagation() event.stopPropagation()
}); });
@ -42,23 +40,25 @@ mindplot.widget.IconPanel = new Class({
// Separate icons by line ... // Separate icons by line ...
var familyContent; var familyContent;
if ((count % 12) == 0) { if ((count % 12) == 0) {
familyContent = new Element('div').inject(content); familyContent = $('<div></div>');
content.append(familyContent);
} }
var iconId = familyIcons[j]; var iconId = familyIcons[j];
var img = new Element('img', { var img = $('<img>')
id:iconId, .attr('id', iconId)
src:mindplot.ImageIcon.prototype._getImageUrl(iconId) .attr('src', mindplot.ImageIcon.prototype._getImageUrl(iconId))
}); .css({
img.setStyles({width:16, width:16,
height:16, height:16,
padding:"0px 2px", padding:"0px 2px",
cursor:'pointer' cursor:'pointer'
}).inject(familyContent); });
familyContent.append(img);
var panel = this; var panel = this;
var model = this.getModel(); var model = this.getModel();
img.addEvent('click', function (event) { img.on('click', function (event) {
model.setValue(this.id); model.setValue(this.id);
panel.hide(); panel.hide();
}.bind(img)); }.bind(img));