module.exports = {




	/**
	 * 动态加载css
	 */
	addCSS: function (cssName) {
		var link = document.createElement('link');
		link.type = 'text/css';
		link.rel = 'stylesheet';
		link.href = cssName;
		document.getElementsByTagName("head")[0].appendChild(link);
	},

	/**
	 * 动态加载loadDhtmlxgantt
	 * @param {Object} success
	 */
	loadDhtmlxgantt: function (success) {
		if (jQuery().gantt) {
			success();
		} else {
			this.addCSS("../../static/dhtmlxgantt/dhtmlxgantt.css");
			$.getScript("../../static/dhtmlxgantt/dhtmlxgantt.js", function (data, textStatus, jqxhr) {
				$.getScript("../../static/dhtmlxgantt/locale/locale_cn.js", function (data, textStatus, jqxhr) {
					$.getScript("../../static/dhtmlxgantt/ext/dhtmlxgantt_auto_scheduling.js", function (data, textStatus, jaxhr) {
						$.getScript("../../static/dhtmlxgantt/ext/dhtmlxgantt_smart_rendering.js", function (data, textStatus, jaxhr) {
							$.getScript("../../static/dhtmlxgantt/ext/dhtmlxgantt_undo.js", function (data, textStatus, jaxhr) {
								$.getScript("../../static/dhtmlxgantt/ext/dhtmlxgantt_fullscreen.js", function (data, textStatus, jaxhr) {
									$.getScript("../../static/dhtmlxgantt/ext/api.js", function (data, textStatus, jaxhr) {
										success();
									});
								});
							});
						});
					});
				});
			});
		}
	},


	/**
	 * 动态加载summernote
	 * @param {Object} success
	 */
	 loadSummernote: function (success) {
		if (jQuery().summernote) {
			success();
		} else {
			this.addCSS("../../static/summernote-0.8.18/summernote.css");
			$.getScript("../../static/summernote-0.8.18/summernote.min.js", function (data, textStatus, jqxhr) {
				$.getScript("../../static/summernote-0.8.18/lang/summernote-zh-CN.min.js", function (data, textStatus, jaxhr) {
					success();
				})
			});
		}
	},
}
