IconPanel reimplemented

This commit is contained in:
Ezequiel Bergamaschi 2014-03-16 21:33:56 -03:00
parent 6edaf3f30a
commit c1c022c96b

View File

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