(function () {
	CKEDITOR.plugins.add("requirement", {
		init: function (editor) {
			if (editor.addMenuItems) {
				CKEDITOR.skin.addIcon("requirement", this.path + "icon/313.png");

				editor.addMenuGroup("requirement");
				editor.addMenuItems({
					requirement: {
						label: "신규 요구사항 등록",
						group: "requirement",
						icon: "requirement"
					}
				});

				editor.getMenuItem("requirement").onClick = function () {
					var selectedText = editor.getSelection().getSelectedText();
					editor.fire("createRequirement", { reqTitle: selectedText });
				};
			}

			if (editor.contextMenu) {
				editor.contextMenu.addListener(function () {
					var selectedText = editor.getSelection().getSelectedText();

					if (selectedText.trim() !== "") {
						return {
							requirement: CKEDITOR.TRISTATE_OFF
						};
					}
				});
			}
		}
	});
})();
