Created
May 11, 2015 13:50
-
-
Save victorpavlenko/a11c25f592e0da57a847 to your computer and use it in GitHub Desktop.
main
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var settingJson = '../settings.json'; | |
var settings = []; | |
var dataObject = {}; | |
var phpUrl = 'upload.php'; | |
$(function () { | |
/** Подключаем плагин Drag n Drop **/ | |
$('#fileupload').fileupload({ | |
url: phpUrl, | |
dataType: 'json', | |
autoUpload: true, | |
singleFileUploads: false | |
}) | |
/** Удачная загрузка документов **/ | |
.bind('fileuploaddone', function (e, data) { | |
$ajaxLoader.hide(); | |
$('.b-order').hide(); | |
$('.b-order-select').show(); | |
/** Подтаскиваем JSON **/ | |
$.ajax({ | |
url: settingJson, | |
async: false, | |
dataType: 'json', | |
success: function (json) { | |
settings = json.settings; | |
} | |
}); | |
/** Устанавливаем общую сумму **/ | |
dataObject.summary = 0; | |
/** Перебераем загруженнык элементы **/ | |
data.result.forEach(function (val, item) { | |
/** Отрисовываем общий шаблон **/ | |
var template = Handlebars.compile($("#li").html()); | |
var datas = { | |
itemNumber : item, | |
urls : val.url, | |
name : val.name, | |
size : val.size, | |
type : template | |
}; | |
datas.type = createView(settings, val.type); | |
template = template(datas); | |
/** В зависимости от типа создаем нужный экземпляр **/ | |
if (val.type == 'images') { | |
val.format = 0; | |
val.paperType = 0; | |
val.number = 0; | |
val.summ = 0; | |
val.count = 1; | |
dataObject[item] = val; | |
var co = new calculateImage(template, item, settings, dataObject); | |
co.init(); | |
} else if (val.type == 'documents') { | |
val.format = ''; | |
val.doublesidePrinting = false; | |
val.stiching = false; | |
val.colorPrint = false; | |
val.summ = 0; | |
val.count = 1; | |
dataObject[item] = val; | |
var cos = new calculateDocument(template, item, settings, dataObject); | |
cos.init(); | |
} else if (val.type == 'cards') { | |
val.count = 100; | |
val.paperType = 'melovka'; | |
val.doublePrint = false; | |
val.summ = 0; | |
dataObject[item] = val; | |
var cost = new calculateCard(template, item, settings, dataObject); | |
cost.init(); | |
} | |
}); | |
}) | |
/** Неудачная загрузка документов **/ | |
.bind('fileuploadfail', function (e, data) { | |
alert('Не удалось загрузить файлы'); | |
}) | |
/** Загрузка **/ | |
.bind('fileuploadsend', function (e, data) { | |
$ajaxLoader.show(); | |
}) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment