Last active
January 11, 2016 07:26
-
-
Save d4rkm3z/7dc7e624d159615ef481 to your computer and use it in GitHub Desktop.
megagroup
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 massIncludingForms = [{ | |
id: '#formZamer', | |
path: '/zakazat-zamer' | |
}]; | |
var formInclude = { | |
/** | |
* @description Initialize forms from massIncludingForms for s3.includeForm script | |
* @author kirill.sadovnikov | |
* @date 2015-11-27 | |
* @anotherdate 2015-11-27T10:35:46+0300 | |
* @param {[string]} path [path to s3.includeForm.js] | |
* @param {[mass]} formMass [massIncludingForms] | |
*/ | |
load: function(path, formMass) { | |
var path = path || 'http://odissey.e2.4exc.ru/d/761879/t/v816/images/scripts/s3.includeform.js'; | |
function getForm(path) { | |
var defer = $.getScript(path) | |
.then( | |
function() { | |
if (!(formMass && formMass.length > 0)) { | |
throw new Error("formMass is null!"); | |
} | |
formMass.forEach(function(elem) { | |
doneForm(elem.path, elem.id, elem.upload); | |
}); | |
}, | |
function() { | |
throw new Error("Nothing path!"); | |
}); | |
}; | |
function doneForm(formPath, formId, upload) { | |
$(formId).s3IncludeForm(formPath, "", function() { | |
$(formId).find('input[name=_cn]').addClass('input input--large'); | |
if(formId == '#formOrderService'){ | |
$(formId).find('input[name="d[0]"]').val($('.service>.h3').text()); | |
} | |
/* if we have upload in our form*/ | |
if (upload) { | |
$(formId).find('.input-file--large').wrapAll("<div class='left remodal__files' />"); | |
$(formId).find('.remodal__files').after('<div class="left remodal__hint-file"> Формат: pdf, doc, jpg, gif, png<br> Размер: не более 5Mb </div>'); | |
var init = $(formId).find(".upload-init"); | |
if (init.length) { | |
init.each(function() { | |
if (!window.newSWFU) { | |
// | |
$.getScript("/d/26909/t/images/swfupload.upload.custom.js", function(data, textStatus, jqxhr) { | |
newSWFU($(this).data("dictionaty_position"), false, $(this).data("count"), $(this).data("upload_url"), $(this).data("upload_field"), "51 MB", $(this).data("filetypes1"), "", ""); | |
}); | |
} else { | |
newSWFU($(this).data("dictionaty_position"), false, $(this).data("count"), $(this).data("upload_url"), $(this).data("upload_field"), "51 MB", $(this).data("filetypes1"), "", ""); | |
} | |
}); | |
} | |
} | |
}); | |
} | |
getForm(path); | |
}, | |
/** | |
* @description Initialize upload from plupload.js | |
* @author kirill.sadovnikov | |
* @date 2015-11-27 | |
* @anotherdate 2015-11-27T11:41:59+0300 | |
* @param {string} idElement [id of main form block] | |
*/ | |
upload: function(idElement) { | |
var $init = $(idElement).find(".upload-init"); | |
newSWFU($init.data("dictionaty_position"), false, $init.data("count"), $init.data("upload_url"), $init.data("upload_field"), "5 MB", $init.data("filetypes1"), "", ""); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment