Skip to content

Commit

Permalink
0.0.8
Browse files Browse the repository at this point in the history
Add additional attributes to bottom of sticker. Add max-height for barcode (80px). Add two rows for top text.
  • Loading branch information
shoom3301 committed May 26, 2016
1 parent 0e75815 commit ff05dd5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 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.7",
"version": "0.0.8",
"main": [
"dist/barcode_editor.js",
"dist/css/style.scss"
Expand Down
17 changes: 13 additions & 4 deletions dist/barcode_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
if(imgsrc){
params.src = options.src || imgsrc;
}
params.attrs = options.attrs || [];
var item = new BarcodeItem(params);
item.render();
item.setStyle(_.extend(this.getItemStyle(), options));
Expand Down Expand Up @@ -258,7 +259,14 @@
'<div class="wrap">\
<div class="cell">\
<p></p>\
<img>\
<div class="img"><img src="<%= src %>"></div>\
<% if(attrs && attrs.length){ %>\
<div class="attrs">\
<% _.each(attrs, function(attr){ %>\
<div><label><%- attr.title %>: </label><span><%- attr.val %></span></div>\
<% }) %>\
</div>\
<% } %>\
</div>\
</div>',
initialize: function(options){
Expand All @@ -268,9 +276,9 @@
* Rendering barcode item
*/
render: function(){
this.$el.html(_.template(this.template)());
this.$el.html(_.template(this.template)(this.options));
var self = this;
this.$el.find('img').attr('src', (this.options.src || 'dist/barcode.png')).on('load', function(){
this.$el.find('img').on('load', function(){
self.trigger('imageLoaded');
});
},
Expand All @@ -280,6 +288,7 @@
* @see BarcodeEditor.getItemStyle
*/
setStyle: function(style){
var textRowsCount = 2;
var width = mm(style.width);
this.$el.css({
width: width,
Expand All @@ -288,7 +297,7 @@
this.$el.find('p').css({
fontSize: style.fontSize,
fontFamily: 'Courier, monospace'
}).text(this.strMax(style.text, width/(style.charWidth||10)));
}).text(this.strMax(style.text, width*textRowsCount/(style.charWidth||10)));
this.$el.find('img').css('width', mm(style.imageWidth));
},
strMax: function(str, len){
Expand Down
15 changes: 14 additions & 1 deletion dist/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions dist/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ body, html{
vertical-align: middle;
p{
margin: 5px 0;
max-height: 28px;
}
}
.img{
img{
max-height: 80px;
}
}
.attrs{
padding: 0 8px;
div{
font-size: 12px;
font-family: Courier, monospace;
font-weight: bold;
display: inline-block;
margin-right: 10px;
&:last-child{
margin-right: 0;
}
}
}
}
Expand Down

0 comments on commit ff05dd5

Please sign in to comment.