Ext.define("Ext.ux.gallery.view.DropBox", {
	extend: "Ext.container.Container",
	alias: "widget.gallerydropbox",

	extensions: "*",

	layout: "absolute",

	requires: [
		"Ext.ux.plugin.UploadDD"
	],

	initComponent: function () {

		var i_cmp = this;

		i_cmp.initConfig(i_cmp.initialConfig);

		Ext.apply(i_cmp, {
			dropText: {
				en: "Drag-and-drop your file(s) here",
				da: "Træk-og-slip dine file(r) her"
			},
			html: i_cmp.createDropText(),
			plugins: [
				{
					ptype: "uploadDD",
					extensions: i_cmp.extensions
				}
			]
		});

		i_cmp.callParent(arguments);

		return i_cmp;
	},

	getDDPlugin: function () {

		var i_cmp = this;
		var s_key = "uploadDD";
		var i_found;

		Ext.Array.some(i_cmp.plugins, function (i_plugin) {
			if (i_plugin.pluginId == s_key) {
				i_found = i_plugin;
				return true;
			}
		});

		return i_found;
	},

	createDropText: function () {

		var i_cmp = this;

		return new Ext.XTemplate(
			"<div _type=\"dropbox\">",
				"<table style=\"height: 100%; width: 100%; padding: 2px;\">",
					"<tr style=\"vertical-align: middle;\">",
						"<td style=\"text-align: center; pointer-events:none;\">",
							ip2.i18n(i_cmp.dropText),
						"</td>",
					"</tr>",
				"</table>",
			"</div>"
		).html;
	}
});
