Skip to content

Commit

Permalink
0.0.6
Browse files Browse the repository at this point in the history
Substr barcode title
  • Loading branch information
shoom3301 committed Jan 18, 2016
1 parent 1810fca commit 5a456f8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "barcodeEditor",
"description": "Editor for print barcode",
"version": "0.0.5",
"version": "0.0.6",
"main": [
"dist/barcode_editor.js",
"dist/css/style.scss"
Expand Down
23 changes: 21 additions & 2 deletions dist/barcode_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@
this.view.setParam('itemsCount', value);
});

this.on('change:fontSize', function(_self, value){
var $span = $('<span>').html('1').css({
fontSize: value,
fontFamily: 'Courier, monospace'
});
$('body').append($span);
this.set('charWidth', $span.width());
$span.remove();
});

this.on('destroy', function(){
this.view.remove();
});
Expand Down Expand Up @@ -189,6 +199,7 @@
width: this.get('itemWidth'),
height: this.get('itemHeight'),
imageWidth: this.get('imageWidth'),
charWidth: this.get('charWidth'),
text: this.get('text')
};
},
Expand Down Expand Up @@ -260,12 +271,20 @@
* @see BarcodeEditor.getItemStyle
*/
setStyle: function(style){
var width = mm(style.width);
this.$el.css({
width: mm(style.width),
width: width,
height: mm(style.height)
});
this.$el.find('p').css('fontSize', style.fontSize).text(style.text);
this.$el.find('p').css({
fontSize: style.fontSize,
fontFamily: 'Courier, monospace'
}).text(this.strMax(style.text, width/(style.charWidth||10)));
this.$el.find('img').css('width', mm(style.imageWidth));
},
strMax: function(str, len){
if(!str || !str.length) return '';
return (str.length > len)?(str.substr(0, len-2)+'..'):str;
}
});

Expand Down

0 comments on commit 5a456f8

Please sign in to comment.