Skip to content

Instantly share code, notes, and snippets.

@victorpavlenko
Last active August 29, 2015 14:20
Show Gist options
  • Save victorpavlenko/5ce034a7d12e62f79490 to your computer and use it in GitHub Desktop.
Save victorpavlenko/5ce034a7d12e62f79490 to your computer and use it in GitHub Desktop.
view
var createView = function(settings, type){
var template,
context;
if(type == 'documents'){
/** Рисуем шаблон документов **/
var documentFormat = [];
for ( var k in settings.documents.format) {
documentFormat.push('<option value="' + settings.documents.format[k] + '">' + k + '</option>')
};
documentFormat = documentFormat.join(' ');
template = Handlebars.compile( $("#documents").html() );
context = {
format : documentFormat
};
return template(context);
} else if (type == 'images'){
/** Рисуем шаблон изображений **/
var imagepaperType = [];
var imageFormat = [];
$.each(settings.images.format, function(i, v) {
imageFormat.push( '<option value="' + v + '">Размеры ' + i + ' см</option>')
});
for(var key in settings.images.paperType ) {
imagepaperType.push( '<option value="' + key + '">'+ settings.images.paperType[key] + '</option>')
}
imageFormat = imageFormat.join(' ');
imagepaperType = imagepaperType.join(' ');
template = Handlebars.compile($("#images").html());
context = {
format : imageFormat,
type : imagepaperType
};
return template(context);
} else {
/** Рисуем шаблон визиток **/
var cardsCount = [];
var cardpaperType = [];
for(var keys in settings.cards.paperType){
cardpaperType.push( '<option value="' + keys + '">' + settings.cards.paperType[keys] + '</option>')
};
$.each(settings.cards.count, function(val, item){
cardsCount.push( '<option value="' + item + '">' + item + '</option>')
});
cardpaperType = cardpaperType.join('');
cardsCount = cardsCount.join('');
template = Handlebars.compile($("#cards").html());
context = {
count : cardsCount,
type : cardpaperType
};
return template(context);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment