فهرست منبع

fix #1797 apply code formatter

Shinsuke Sugaya 7 سال پیش
والد
کامیت
c0c0dd00a8

+ 120 - 85
src/main/webapp/js/admin/admin.js

@@ -1,94 +1,129 @@
 $(function() {
 $(function() {
-	$('input[type="text"],select,textarea', '.login-box,section.content').first()
-			.focus();
-	$('.form-group .has-error').first().next('input,select,textarea').focus();
+  $('input[type="text"],select,textarea', ".login-box,section.content")
+    .first()
+    .focus();
+  $(".form-group .has-error")
+    .first()
+    .next("input,select,textarea")
+    .focus();
 
 
-	$("section.content input").keypress(function(e) {
-		if (e.which === 13) {
-			var $submitButton = $('input#submit, button#submit');
-			if ($submitButton.size() > 0) {
-				$submitButton[0].submit();
-			}
-			// ignore enter key down
-			return false;
-		}
-	});
+  $("section.content input").keypress(function(e) {
+    if (e.which === 13) {
+      var $submitButton = $("input#submit, button#submit");
+      if ($submitButton.size() > 0) {
+        $submitButton[0].submit();
+      }
+      // ignore enter key down
+      return false;
+    }
+  });
 
 
-	$('.table tr[data-href]').each(function() {
-		$(this).css('cursor', 'pointer').hover(function() {
-			$(this).addClass('active');
-		}, function() {
-			$(this).removeClass('active');
-		}).click(function() {
-			document.location = $(this).attr('data-href');
-		});
-	});
+  $(".table tr[data-href]").each(function() {
+    $(this)
+      .css("cursor", "pointer")
+      .hover(
+        function() {
+          $(this).addClass("active");
+        },
+        function() {
+          $(this).removeClass("active");
+        }
+      )
+      .click(function() {
+        document.location = $(this).attr("data-href");
+      });
+  });
 
 
-	$('#confirmToDelete').on('show.bs.modal', function(event) {
-		var button = $(event.relatedTarget);
-		var docId = button.data('docid');
-		var title = button.data('title');
-		var url = button.data('url');
+  $("#confirmToDelete").on("show.bs.modal", function(event) {
+    var button = $(event.relatedTarget);
+    var docId = button.data("docid");
+    var title = button.data("title");
+    var url = button.data("url");
 
 
-		$(this).find('.modal-body #delete-doc-title').text(title);
-		$(this).find('.modal-body #delete-doc-url').text(url);
-		$(this).find('.modal-footer input#docId').val(docId);
-	});
+    $(this)
+      .find(".modal-body #delete-doc-title")
+      .text(title);
+    $(this)
+      .find(".modal-body #delete-doc-url")
+      .text(url);
+    $(this)
+      .find(".modal-footer input#docId")
+      .val(docId);
+  });
 
 
-	// Date range picker
-	var lang = (window.navigator.userLanguage || window.navigator.language || window.navigator.browserLanguage)
-			.substr(0, 2);
-	moment.locale(lang);
-	$('input.form-control.date').daterangepicker({
-		autoUpdateInput : false,
-		timePicker : false,
-		singleDatePicker : true,
-		locale : {
-			format : 'YYYY-MM-DD'
-		}
-	}).on('apply.daterangepicker', function(ev, picker) {
-		$(this).val(picker.startDate.format('YYYY-MM-DD'));
-	});
-	$('input.form-control.daterange').daterangepicker({
-		autoUpdateInput : false,
-		timePicker : false,
-		singleDatePicker : false,
-		locale : {
-			format : 'YYYY-MM-DD'
-		}
-	}).on('apply.daterangepicker', function(ev, picker) {
-		$(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
-	});
-	$('input.form-control.datetime').daterangepicker({
-		autoUpdateInput : false,
-		timePicker : true,
-		timePickerIncrement : 10,
-		singleDatePicker : true,
-		locale : {
-			format : 'YYYY-MM-DD HH:mm'
-		}
-	}).on('apply.daterangepicker', function(ev, picker) {
-		$(this).val(picker.startDate.format('YYYY-MM-DD HH:mm'));
-	});
-	$('input.form-control.datetimerange').daterangepicker({
-		autoUpdateInput : false,
-		timePicker : true,
-		timePickerIncrement : 10,
-		singleDatePicker : false,
-		locale : {
-			format : 'YYYY-MM-DD HH:mm'
-		}
-	}).on('apply.daterangepicker', function(ev, picker) {
-		$(this).val(picker.startDate.format('YYYY-MM-DD HH:mm') + ' - ' + picker.endDate.format('YYYY-MM-DD HH:mm'));
-	});
+  // Date range picker
+  var lang = (
+    window.navigator.userLanguage ||
+    window.navigator.language ||
+    window.navigator.browserLanguage
+  ).substr(0, 2);
+  moment.locale(lang);
+  $("input.form-control.date")
+    .daterangepicker({
+      autoUpdateInput: false,
+      timePicker: false,
+      singleDatePicker: true,
+      locale: {
+        format: "YYYY-MM-DD"
+      }
+    })
+    .on("apply.daterangepicker", function(ev, picker) {
+      $(this).val(picker.startDate.format("YYYY-MM-DD"));
+    });
+  $("input.form-control.daterange")
+    .daterangepicker({
+      autoUpdateInput: false,
+      timePicker: false,
+      singleDatePicker: false,
+      locale: {
+        format: "YYYY-MM-DD"
+      }
+    })
+    .on("apply.daterangepicker", function(ev, picker) {
+      $(this).val(
+        picker.startDate.format("YYYY-MM-DD") +
+          " - " +
+          picker.endDate.format("YYYY-MM-DD")
+      );
+    });
+  $("input.form-control.datetime")
+    .daterangepicker({
+      autoUpdateInput: false,
+      timePicker: true,
+      timePickerIncrement: 10,
+      singleDatePicker: true,
+      locale: {
+        format: "YYYY-MM-DD HH:mm"
+      }
+    })
+    .on("apply.daterangepicker", function(ev, picker) {
+      $(this).val(picker.startDate.format("YYYY-MM-DD HH:mm"));
+    });
+  $("input.form-control.datetimerange")
+    .daterangepicker({
+      autoUpdateInput: false,
+      timePicker: true,
+      timePickerIncrement: 10,
+      singleDatePicker: false,
+      locale: {
+        format: "YYYY-MM-DD HH:mm"
+      }
+    })
+    .on("apply.daterangepicker", function(ev, picker) {
+      $(this).val(
+        picker.startDate.format("YYYY-MM-DD HH:mm") +
+          " - " +
+          picker.endDate.format("YYYY-MM-DD HH:mm")
+      );
+    });
 
 
-	// Time picker
-	$("input.form-control.time").timepicker({
-		showInputs : false
-	});
+  // Time picker
+  $("input.form-control.time").timepicker({
+    showInputs: false
+  });
 
 
-	// tooltips
-	$(function() {
-		$('[data-toggle="tooltip"]').tooltip()
-	})
+  // tooltips
+  $(function() {
+    $('[data-toggle="tooltip"]').tooltip();
+  });
 });
 });

+ 6 - 6
src/main/webapp/js/admin/dashboard.js

@@ -1,7 +1,7 @@
-$(function(){
-    var $content = $('#content');
-    var $contentFrame = $('#contentFrame');
-    $contentFrame.on('load', function(){
-        $(this).height($content.height());
-    });
+$(function() {
+  var $content = $("#content");
+  var $contentFrame = $("#contentFrame");
+  $contentFrame.on("load", function() {
+    $(this).height($content.height());
+  });
 });
 });

+ 17 - 16
src/main/webapp/js/admin/searchlist.js

@@ -1,19 +1,20 @@
 $(function() {
 $(function() {
-	var SEP_CHAR = '-'
-	var langCode;
-	var browserLang = (window.navigator.languages && window.navigator.languages[0])
-			|| window.navigator.language
-			|| window.navigator.userLanguage
-			|| window.navigator.browserLanguage;
+  var SEP_CHAR = "-";
+  var langCode;
+  var browserLang =
+    (window.navigator.languages && window.navigator.languages[0]) ||
+    window.navigator.language ||
+    window.navigator.userLanguage ||
+    window.navigator.browserLanguage;
 
 
-	if (browserLang) {
-		langCode = browserLang.split(SEP_CHAR)[0];
-	} else {
-		langCode = 'en';
-	}
+  if (browserLang) {
+    langCode = browserLang.split(SEP_CHAR)[0];
+  } else {
+    langCode = "en";
+  }
 
 
-	$.validate({
-		modules : 'html5',
-		lang : langCode,
-	});
-});
+  $.validate({
+    modules: "html5",
+    lang: langCode
+  });
+});

+ 39 - 38
src/main/webapp/js/advance.js

@@ -1,42 +1,43 @@
 $(function() {
 $(function() {
-	var $searchButton = $('#searchButton');
-	var contextPath = $('#contextPath').val();
+  var $searchButton = $("#searchButton");
+  var contextPath = $("#contextPath").val();
 
 
-	$('#searchForm').on('submit', function(e) {
-		$searchButton.attr('disabled', true);
-		setTimeout(function() {
-			$searchButton.attr('disabled', false);
-		}, 3000);
-		return true;
-	});
+  $("#searchForm").on("submit", function(e) {
+    $searchButton.attr("disabled", true);
+    setTimeout(function() {
+      $searchButton.attr("disabled", false);
+    }, 3000);
+    return true;
+  });
 
 
-	if (typeof $.fn.suggestor === 'function') {
-		$('#as_q')
-				.suggestor(
-						{
-							ajaxinfo : {
-								url : contextPath + '/suggest',
-								fn : '_default,content,title',
-								num : 10,
-								lang : $('#langSearchOption').val()
-							},
-							boxCssInfo : {
-								border : '1px solid rgba(82, 168, 236, 0.5)',
-								'-webkit-box-shadow' : '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-								'-moz-box-shadow' : '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-								'box-shadow' : '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-								'background-color' : '#fff',
-								'z-index' : '10000'
-							},
-							listSelectedCssInfo : {
-								'background-color' : 'rgba(82, 168, 236, 0.1)'
-							},
-							listDeselectedCssInfo : {
-								'background-color' : '#ffffff'
-							},
-							minterm : 1,
-							adjustWidthVal : 11,
-							searchForm : $('#searchForm')
-						});
-	}
+  if (typeof $.fn.suggestor === "function") {
+    $("#as_q").suggestor({
+      ajaxinfo: {
+        url: contextPath + "/suggest",
+        fn: "_default,content,title",
+        num: 10,
+        lang: $("#langSearchOption").val()
+      },
+      boxCssInfo: {
+        border: "1px solid rgba(82, 168, 236, 0.5)",
+        "-webkit-box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "-moz-box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "background-color": "#fff",
+        "z-index": "10000"
+      },
+      listSelectedCssInfo: {
+        "background-color": "rgba(82, 168, 236, 0.1)"
+      },
+      listDeselectedCssInfo: {
+        "background-color": "#ffffff"
+      },
+      minterm: 1,
+      adjustWidthVal: 11,
+      searchForm: $("#searchForm")
+    });
+  }
 });
 });

+ 54 - 51
src/main/webapp/js/help.js

@@ -1,56 +1,59 @@
-$(function(){
-	var $searchButton = $('#searchButton');
-	var contextPath = $('#contextPath').val();
+$(function() {
+  var $searchButton = $("#searchButton");
+  var contextPath = $("#contextPath").val();
 
 
-	$('#searchForm').on('submit', function(e) {
-		$searchButton.attr('disabled', true);
-		setTimeout(function() {
-			$searchButton.attr('disabled', false);
-		}, 3000);
-		return true;
-	});
+  $("#searchForm").on("submit", function(e) {
+    $searchButton.attr("disabled", true);
+    setTimeout(function() {
+      $searchButton.attr("disabled", false);
+    }, 3000);
+    return true;
+  });
 
 
-    $("[data-toggle='control-options']").click(function(e) {
-        e.preventDefault();
-        var target = $(this).attr('data-target') || $(this).attr('href');
-        if (target) {
-            $(target).toggleClass("active");
-        }
-    });
+  $("[data-toggle='control-options']").click(function(e) {
+    e.preventDefault();
+    var target = $(this).attr("data-target") || $(this).attr("href");
+    if (target) {
+      $(target).toggleClass("active");
+    }
+  });
 
 
-	$('#searchOptionsClearButton').on('click', function(e) {
-		$('#labelTypeSearchOption').prop('selectedIndex', -1);
-		$('#langSearchOption').prop('selectedIndex', 0);
-		$('#sortSearchOption').prop('selectedIndex', 0);
-		$('#numSearchOption').prop('selectedIndex', 0);
-		return false;
-	});
+  $("#searchOptionsClearButton").on("click", function(e) {
+    $("#labelTypeSearchOption").prop("selectedIndex", -1);
+    $("#langSearchOption").prop("selectedIndex", 0);
+    $("#sortSearchOption").prop("selectedIndex", 0);
+    $("#numSearchOption").prop("selectedIndex", 0);
+    return false;
+  });
 
 
-	if (typeof $.fn.suggestor === 'function') {
-	    $('#query').suggestor( {
-	        ajaxinfo: {
-	            url: contextPath + '/suggest',
-	            fn: '_default,content,title',
-	            num: 10,
-	            lang: $('#langSearchOption').val()
-	        },
-	        boxCssInfo: {
-	            border: '1px solid rgba(82, 168, 236, 0.5)',
-	            '-webkit-box-shadow': '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-	            '-moz-box-shadow': '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-	            'box-shadow': '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-	            'background-color': '#fff',
-	            'z-index': '10000'
-	        },
-	        listSelectedCssInfo: {
-	            'background-color': 'rgba(82, 168, 236, 0.1)'
-	        },
-	        listDeselectedCssInfo: {
-	            'background-color': '#ffffff'
-	        },
-	        minterm: 1,
-	        adjustWidthVal: 11,
-	        searchForm: $('#searchForm')
-	    });
-	}
+  if (typeof $.fn.suggestor === "function") {
+    $("#query").suggestor({
+      ajaxinfo: {
+        url: contextPath + "/suggest",
+        fn: "_default,content,title",
+        num: 10,
+        lang: $("#langSearchOption").val()
+      },
+      boxCssInfo: {
+        border: "1px solid rgba(82, 168, 236, 0.5)",
+        "-webkit-box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "-moz-box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "background-color": "#fff",
+        "z-index": "10000"
+      },
+      listSelectedCssInfo: {
+        "background-color": "rgba(82, 168, 236, 0.1)"
+      },
+      listDeselectedCssInfo: {
+        "background-color": "#ffffff"
+      },
+      minterm: 1,
+      adjustWidthVal: 11,
+      searchForm: $("#searchForm")
+    });
+  }
 });
 });

+ 59 - 58
src/main/webapp/js/index.js

@@ -1,66 +1,67 @@
 $(function() {
 $(function() {
-	$('#contentQuery').focus();
+  $("#contentQuery").focus();
 
 
-	var $searchButton = $('#searchButton');
-	var contextPath = $('#contextPath').val();
+  var $searchButton = $("#searchButton");
+  var contextPath = $("#contextPath").val();
 
 
-	$('#searchForm').on('submit', function(e) {
-		$searchButton.attr('disabled', true);
-		setTimeout(function() {
-			$searchButton.attr('disabled', false);
-		}, 3000);
-		return true;
-	});
+  $("#searchForm").on("submit", function(e) {
+    $searchButton.attr("disabled", true);
+    setTimeout(function() {
+      $searchButton.attr("disabled", false);
+    }, 3000);
+    return true;
+  });
 
 
-	$(document).on('click touchend', function(e) {
-		if (!$(e.target).closest('#searchOptions, #searchOptionsButton').length) {
-			$('#searchOptions').removeClass('active');
-		}
-	});
+  $(document).on("click touchend", function(e) {
+    if (!$(e.target).closest("#searchOptions, #searchOptionsButton").length) {
+      $("#searchOptions").removeClass("active");
+    }
+  });
 
 
-	$("[data-toggle='control-options']").click(function(e) {
-		e.preventDefault();
-		var target = $(this).attr('data-target') || $(this).attr('href');
-		if (target) {
-			$(target).toggleClass("active");
-		}
-	});
+  $("[data-toggle='control-options']").click(function(e) {
+    e.preventDefault();
+    var target = $(this).attr("data-target") || $(this).attr("href");
+    if (target) {
+      $(target).toggleClass("active");
+    }
+  });
 
 
-	$('#searchOptionsClearButton').on('click', function(e) {
-		$('#labelTypeSearchOption').prop('selectedIndex', -1);
-		$('#langSearchOption').prop('selectedIndex', 0);
-		$('#sortSearchOption').prop('selectedIndex', 0);
-		$('#numSearchOption').prop('selectedIndex', 0);
-		return false;
-	});
+  $("#searchOptionsClearButton").on("click", function(e) {
+    $("#labelTypeSearchOption").prop("selectedIndex", -1);
+    $("#langSearchOption").prop("selectedIndex", 0);
+    $("#sortSearchOption").prop("selectedIndex", 0);
+    $("#numSearchOption").prop("selectedIndex", 0);
+    return false;
+  });
 
 
-	if (typeof $.fn.suggestor === 'function') {
-		$('#contentQuery')
-				.suggestor(
-						{
-							ajaxinfo : {
-								url : contextPath + '/suggest',
-								fn : '_default,content,title',
-								num : 10,
-								lang : $('#langSearchOption').val()
-							},
-							boxCssInfo : {
-								border : '1px solid rgba(82, 168, 236, 0.5)',
-								'-webkit-box-shadow' : '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-								'-moz-box-shadow' : '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-								'box-shadow' : '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-								'background-color' : '#fff',
-								'z-index' : '10000'
-							},
-							listSelectedCssInfo : {
-								'background-color' : 'rgba(82, 168, 236, 0.1)'
-							},
-							listDeselectedCssInfo : {
-								'background-color' : '#ffffff'
-							},
-							minterm : 1,
-							adjustWidthVal : 11,
-							searchForm : $('#searchForm')
-						});
-	}
+  if (typeof $.fn.suggestor === "function") {
+    $("#contentQuery").suggestor({
+      ajaxinfo: {
+        url: contextPath + "/suggest",
+        fn: "_default,content,title",
+        num: 10,
+        lang: $("#langSearchOption").val()
+      },
+      boxCssInfo: {
+        border: "1px solid rgba(82, 168, 236, 0.5)",
+        "-webkit-box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "-moz-box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "background-color": "#fff",
+        "z-index": "10000"
+      },
+      listSelectedCssInfo: {
+        "background-color": "rgba(82, 168, 236, 0.1)"
+      },
+      listDeselectedCssInfo: {
+        "background-color": "#ffffff"
+      },
+      minterm: 1,
+      adjustWidthVal: 11,
+      searchForm: $("#searchForm")
+    });
+  }
 });
 });

+ 47 - 31
src/main/webapp/js/login.js

@@ -1,37 +1,53 @@
 $(function() {
 $(function() {
-	$('input[type="text"],select,textarea', '.login-box,section.content').first()
-			.focus();
-	$('.form-group .has-error').first().next('input,select,textarea').focus();
+  $('input[type="text"],select,textarea', ".login-box,section.content")
+    .first()
+    .focus();
+  $(".form-group .has-error")
+    .first()
+    .next("input,select,textarea")
+    .focus();
 
 
-	$("section.content input").keypress(function(e) {
-		if (e.which === 13) {
-			var $submitButton = $('input#submit, button#submit');
-			if ($submitButton.length > 0) {
-				$submitButton[0].submit();
-			}
-			// ignore enter key down
-			return false;
-		}
-	});
+  $("section.content input").keypress(function(e) {
+    if (e.which === 13) {
+      var $submitButton = $("input#submit, button#submit");
+      if ($submitButton.length > 0) {
+        $submitButton[0].submit();
+      }
+      // ignore enter key down
+      return false;
+    }
+  });
 
 
-	$('.table tr[data-href]').each(function() {
-		$(this).css('cursor', 'pointer').hover(function() {
-			$(this).addClass('active');
-		}, function() {
-			$(this).removeClass('active');
-		}).click(function() {
-			document.location = $(this).attr('data-href');
-		});
-	});
+  $(".table tr[data-href]").each(function() {
+    $(this)
+      .css("cursor", "pointer")
+      .hover(
+        function() {
+          $(this).addClass("active");
+        },
+        function() {
+          $(this).removeClass("active");
+        }
+      )
+      .click(function() {
+        document.location = $(this).attr("data-href");
+      });
+  });
 
 
-	$('#confirmToDelete').on('show.bs.modal', function(event) {
-		var button = $(event.relatedTarget);
-		var docId = button.data('docid');
-		var title = button.data('title');
-		var url = button.data('url');
+  $("#confirmToDelete").on("show.bs.modal", function(event) {
+    var button = $(event.relatedTarget);
+    var docId = button.data("docid");
+    var title = button.data("title");
+    var url = button.data("url");
 
 
-		$(this).find('.modal-body #delete-doc-title').text(title);
-		$(this).find('.modal-body #delete-doc-url').text(url);
-		$(this).find('.modal-footer input#docId').val(docId);
-	});
+    $(this)
+      .find(".modal-body #delete-doc-title")
+      .text(title);
+    $(this)
+      .find(".modal-body #delete-doc-url")
+      .text(url);
+    $(this)
+      .find(".modal-footer input#docId")
+      .val(docId);
+  });
 });
 });

+ 47 - 31
src/main/webapp/js/profile.js

@@ -1,37 +1,53 @@
 $(function() {
 $(function() {
-	$('input[type="text"],select,textarea', '.login-box,section.content').first()
-			.focus();
-	$('.form-group .has-error').first().next('input,select,textarea').focus();
+  $('input[type="text"],select,textarea', ".login-box,section.content")
+    .first()
+    .focus();
+  $(".form-group .has-error")
+    .first()
+    .next("input,select,textarea")
+    .focus();
 
 
-	$("section.content input").keypress(function(e) {
-		if (e.which === 13) {
-			var $submitButton = $('input#submit, button#submit');
-			if ($submitButton.length > 0) {
-				$submitButton[0].submit();
-			}
-			// ignore enter key down
-			return false;
-		}
-	});
+  $("section.content input").keypress(function(e) {
+    if (e.which === 13) {
+      var $submitButton = $("input#submit, button#submit");
+      if ($submitButton.length > 0) {
+        $submitButton[0].submit();
+      }
+      // ignore enter key down
+      return false;
+    }
+  });
 
 
-	$('.table tr[data-href]').each(function() {
-		$(this).css('cursor', 'pointer').hover(function() {
-			$(this).addClass('active');
-		}, function() {
-			$(this).removeClass('active');
-		}).click(function() {
-			document.location = $(this).attr('data-href');
-		});
-	});
+  $(".table tr[data-href]").each(function() {
+    $(this)
+      .css("cursor", "pointer")
+      .hover(
+        function() {
+          $(this).addClass("active");
+        },
+        function() {
+          $(this).removeClass("active");
+        }
+      )
+      .click(function() {
+        document.location = $(this).attr("data-href");
+      });
+  });
 
 
-	$('#confirmToDelete').on('show.bs.modal', function(event) {
-		var button = $(event.relatedTarget);
-		var docId = button.data('docid');
-		var title = button.data('title');
-		var url = button.data('url');
+  $("#confirmToDelete").on("show.bs.modal", function(event) {
+    var button = $(event.relatedTarget);
+    var docId = button.data("docid");
+    var title = button.data("title");
+    var url = button.data("url");
 
 
-		$(this).find('.modal-body #delete-doc-title').text(title);
-		$(this).find('.modal-body #delete-doc-url').text(url);
-		$(this).find('.modal-footer input#docId').val(docId);
-	});
+    $(this)
+      .find(".modal-body #delete-doc-title")
+      .text(title);
+    $(this)
+      .find(".modal-body #delete-doc-url")
+      .text(url);
+    $(this)
+      .find(".modal-footer input#docId")
+      .val(docId);
+  });
 });
 });

+ 250 - 232
src/main/webapp/js/search.js

@@ -1,234 +1,252 @@
 $(function() {
 $(function() {
-	var $result = $('#result');
-	var $queryId = $('#queryId');
-	var $favorites = $('.favorite', $result);
-	var $searchButton = $('#searchButton');
-	var contextPath = $('#contextPath').val();
-
-	$('#searchForm').on('submit', function(e) {
-		$searchButton.attr('disabled', true);
-		setTimeout(function() {
-			$searchButton.attr('disabled', false);
-		}, 3000);
-		return true;
-	});
-
-	$('#content').on('click touchend', function(e) {
-		if (!$(e.target).closest("#searchOptions, [data-toggle='control-options']").length) {
-			$('#searchOptions').removeClass('active');
-		}
-	});
-
-	$("[data-toggle='control-options']").click(function(e) {
-		e.preventDefault();
-		var target = $(this).attr('data-target') || $(this).attr('href');
-		if (target) {
-			$(target).toggleClass("active");
-		}
-	});
-
-	$('#searchOptionsClearButton').on('click', function(e) {
-		$('#labelTypeSearchOption').prop('selectedIndex', -1);
-		$('#langSearchOption').prop('selectedIndex', 0);
-		$('#sortSearchOption').prop('selectedIndex', 0);
-		$('#numSearchOption').prop('selectedIndex', 0);
-		return false;
-	});
-
-	$result.on('mousedown', 'a.link', function(e) {
-		var docId = $(this).attr('data-id'), rt = $('#rt').val(), queryId = $(
-				'#queryId').val(), order = $(this).attr('data-order'), url = $(
-				this).attr('href'), buf = [];
-		buf.push(contextPath);
-		buf.push('/go/?rt=');
-		buf.push(rt);
-		buf.push('&docId=');
-		buf.push(docId);
-		buf.push('&queryId=');
-		buf.push(queryId);
-		buf.push('&order=');
-		buf.push(order);
-
-		var hashIndex = url.indexOf('#');
-		if (hashIndex >= 0) {
-			var hashStr = url.substring(hashIndex);
-			buf.push('&hash=');
-			buf.push(encodeURIComponent(hashStr));
-		}
-
-		$(this).attr('href', buf.join(''));
-	});
-
-	$result.on('mouseover', 'a.link', function(e) {
-		var docId = $(this).attr('data-id'), rt = $('#rt').val(), url = $(
-				this).attr('href'), buf = [];
-		buf.push(contextPath);
-		buf.push('/go/?rt=');
-		buf.push(rt);
-		buf.push('&docId=');
-		buf.push(docId);
-
-		var hashIndex = url.indexOf('#');
-		if (hashIndex >= 0) {
-			var hashStr = url.substring(hashIndex);
-			buf.push('&hash=');
-			buf.push(encodeURIComponent(hashStr));
-			buf.push(hashStr);
-		}
-	});
-
-	$result.on('click', 'a.favorite', function(e) {
-		var $favorite = $(this);
-		var values = $favorite.attr('href').split('#');
-		if (values.length === 2 && $queryId.length > 0) {
-			var actionUrl = contextPath + '/json';
-			var docId = values[1];
-			$.ajax({
-				dataType : 'json',
-				cache : false,
-				type : 'post',
-				timeoutNumber : 10000,
-				url : actionUrl,
-				data : {
-					type : 'favorite',
-					docId : docId,
-					queryId : $queryId.val()
-				}
-			}).done(
-					function(data) {
-						if (data.response.status === 0
-								&& typeof data.response.result !== 'undefined'
-								&& data.response.result === 'ok') {
-							var $favorited = $favorite.siblings('.favorited');
-							var $favoritedCount = $('.favorited-count',
-									$favorited);
-							$favoritedCount.css('display', 'none');
-							$favorite.fadeOut(1000, function() {
-								$favorited.fadeIn(1000);
-							});
-						}
-					}).fail(function(data) {
-				$favorite.attr('href', '#' + docId);
-				// alert(JSON.stringify(data));
-			});
-		}
-		$(this).attr('href', '#');
-		return false;
-	});
-
-	if ($favorites.length > 0) {
-		$.ajax({
-			dataType : 'json',
-			cache : false,
-			type : 'post',
-			timeoutNumber : 10000,
-			url : contextPath + '/json',
-			data : {
-				type : 'favorites',
-				queryId : $queryId.val()
-			}
-		}).done(
-				function(data) {
-					if (data.response.status === 0
-							&& typeof data.response.num !== 'undefined'
-							&& data.response.num > 0) {
-						var docIds = data.response.doc_ids;
-						for (var i = 0; i < docIds.length; i++) {
-							docIds[i] = '#' + docIds[i];
-						}
-						$favorites.each(function(index) {
-							var $favorite = $(this);
-							var url = $favorite.attr('href');
-							var found = false;
-							for (var i = 0; i < docIds.length; i++) {
-								if (url === docIds[i]) {
-									found = true;
-									break;
-								}
-							}
-							if (found) {
-								var $favorited = $favorite
-										.siblings('.favorited');
-								$favorite.fadeOut(1000, function() {
-									$favorited.fadeIn(1000);
-								});
-							}
-						});
-					}
-				}).fail(function(data) {
-			// alert(JSON.stringify(data));
-		});
-	}
-
-	$result.on('click', '.more a', function(e) {
-		var $moreLink = $(this);
-		var value = $moreLink.attr('href');
-		if (value !== '') {
-			var $info = $(value + ' .info');
-			if ($info.length > 0) {
-				$moreLink.fadeOut(500, function() {
-					$info.slideDown("slow");
-				});
-			}
-		}
-		return false;
-	});
-
-	if (typeof $.fn.suggestor === 'function') {
-		$('#query')
-				.suggestor(
-						{
-							ajaxinfo : {
-								url : contextPath + '/suggest',
-								fn : '_default,content,title',
-								num : 10,
-								lang : $('#langSearchOption').val()
-							},
-							boxCssInfo : {
-								border : '1px solid rgba(82, 168, 236, 0.5)',
-								'-webkit-box-shadow' : '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-								'-moz-box-shadow' : '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-								'box-shadow' : '0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)',
-								'background-color' : '#fff',
-								'z-index' : '10000'
-							},
-							listSelectedCssInfo : {
-								'background-color' : 'rgba(82, 168, 236, 0.1)'
-							},
-							listDeselectedCssInfo : {
-								'background-color' : '#ffffff'
-							},
-							minterm : 1,
-							adjustWidthVal : 11,
-							searchForm : $('#searchForm')
-						});
-	}
-
-	IMG_LOADING_DELAY = 200;
-	IMG_LOADING_MAX = 0;
-	var loadImage = function(img, url, limit) {
-		var imgData = new Image();
-		$(imgData).on("load", function() {
-			$(img).css('background-image', '');
-			$(img).attr('src', url);
-		});
-		$(imgData).on('error', function() {
-			if (limit > 0) {
-				setTimeout(function() {
-					loadImage(img, url, --limit);
-				}, IMG_LOADING_DELAY);
-			} else {
-				// $(img).attr('src', contextPath + "/images/noimage.png");
-				$(img).parent().parent().css('display', 'none');
-			}
-			imgData = null;
-		});
-		imgData.src = url;
-	};
-
-	$('img.thumbnail').each(function() {
-		$(this).css('background-image', 'url("' + contextPath + '/images/loading.gif")');
-		loadImage(this, $(this).attr('data-src'), IMG_LOADING_MAX);
-	});
-
+  var $result = $("#result");
+  var $queryId = $("#queryId");
+  var $favorites = $(".favorite", $result);
+  var $searchButton = $("#searchButton");
+  var contextPath = $("#contextPath").val();
+
+  $("#searchForm").on("submit", function(e) {
+    $searchButton.attr("disabled", true);
+    setTimeout(function() {
+      $searchButton.attr("disabled", false);
+    }, 3000);
+    return true;
+  });
+
+  $("#content").on("click touchend", function(e) {
+    if (
+      !$(e.target).closest("#searchOptions, [data-toggle='control-options']")
+        .length
+    ) {
+      $("#searchOptions").removeClass("active");
+    }
+  });
+
+  $("[data-toggle='control-options']").click(function(e) {
+    e.preventDefault();
+    var target = $(this).attr("data-target") || $(this).attr("href");
+    if (target) {
+      $(target).toggleClass("active");
+    }
+  });
+
+  $("#searchOptionsClearButton").on("click", function(e) {
+    $("#labelTypeSearchOption").prop("selectedIndex", -1);
+    $("#langSearchOption").prop("selectedIndex", 0);
+    $("#sortSearchOption").prop("selectedIndex", 0);
+    $("#numSearchOption").prop("selectedIndex", 0);
+    return false;
+  });
+
+  $result.on("mousedown", "a.link", function(e) {
+    var docId = $(this).attr("data-id"),
+      rt = $("#rt").val(),
+      queryId = $("#queryId").val(),
+      order = $(this).attr("data-order"),
+      url = $(this).attr("href"),
+      buf = [];
+    buf.push(contextPath);
+    buf.push("/go/?rt=");
+    buf.push(rt);
+    buf.push("&docId=");
+    buf.push(docId);
+    buf.push("&queryId=");
+    buf.push(queryId);
+    buf.push("&order=");
+    buf.push(order);
+
+    var hashIndex = url.indexOf("#");
+    if (hashIndex >= 0) {
+      var hashStr = url.substring(hashIndex);
+      buf.push("&hash=");
+      buf.push(encodeURIComponent(hashStr));
+    }
+
+    $(this).attr("href", buf.join(""));
+  });
+
+  $result.on("mouseover", "a.link", function(e) {
+    var docId = $(this).attr("data-id"),
+      rt = $("#rt").val(),
+      url = $(this).attr("href"),
+      buf = [];
+    buf.push(contextPath);
+    buf.push("/go/?rt=");
+    buf.push(rt);
+    buf.push("&docId=");
+    buf.push(docId);
+
+    var hashIndex = url.indexOf("#");
+    if (hashIndex >= 0) {
+      var hashStr = url.substring(hashIndex);
+      buf.push("&hash=");
+      buf.push(encodeURIComponent(hashStr));
+      buf.push(hashStr);
+    }
+  });
+
+  $result.on("click", "a.favorite", function(e) {
+    var $favorite = $(this);
+    var values = $favorite.attr("href").split("#");
+    if (values.length === 2 && $queryId.length > 0) {
+      var actionUrl = contextPath + "/json";
+      var docId = values[1];
+      $.ajax({
+        dataType: "json",
+        cache: false,
+        type: "post",
+        timeoutNumber: 10000,
+        url: actionUrl,
+        data: {
+          type: "favorite",
+          docId: docId,
+          queryId: $queryId.val()
+        }
+      })
+        .done(function(data) {
+          if (
+            data.response.status === 0 &&
+            typeof data.response.result !== "undefined" &&
+            data.response.result === "ok"
+          ) {
+            var $favorited = $favorite.siblings(".favorited");
+            var $favoritedCount = $(".favorited-count", $favorited);
+            $favoritedCount.css("display", "none");
+            $favorite.fadeOut(1000, function() {
+              $favorited.fadeIn(1000);
+            });
+          }
+        })
+        .fail(function(data) {
+          $favorite.attr("href", "#" + docId);
+          // alert(JSON.stringify(data));
+        });
+    }
+    $(this).attr("href", "#");
+    return false;
+  });
+
+  if ($favorites.length > 0) {
+    $.ajax({
+      dataType: "json",
+      cache: false,
+      type: "post",
+      timeoutNumber: 10000,
+      url: contextPath + "/json",
+      data: {
+        type: "favorites",
+        queryId: $queryId.val()
+      }
+    })
+      .done(function(data) {
+        if (
+          data.response.status === 0 &&
+          typeof data.response.num !== "undefined" &&
+          data.response.num > 0
+        ) {
+          var docIds = data.response.doc_ids;
+          for (var i = 0; i < docIds.length; i++) {
+            docIds[i] = "#" + docIds[i];
+          }
+          $favorites.each(function(index) {
+            var $favorite = $(this);
+            var url = $favorite.attr("href");
+            var found = false;
+            for (var i = 0; i < docIds.length; i++) {
+              if (url === docIds[i]) {
+                found = true;
+                break;
+              }
+            }
+            if (found) {
+              var $favorited = $favorite.siblings(".favorited");
+              $favorite.fadeOut(1000, function() {
+                $favorited.fadeIn(1000);
+              });
+            }
+          });
+        }
+      })
+      .fail(function(data) {
+        // alert(JSON.stringify(data));
+      });
+  }
+
+  $result.on("click", ".more a", function(e) {
+    var $moreLink = $(this);
+    var value = $moreLink.attr("href");
+    if (value !== "") {
+      var $info = $(value + " .info");
+      if ($info.length > 0) {
+        $moreLink.fadeOut(500, function() {
+          $info.slideDown("slow");
+        });
+      }
+    }
+    return false;
+  });
+
+  if (typeof $.fn.suggestor === "function") {
+    $("#query").suggestor({
+      ajaxinfo: {
+        url: contextPath + "/suggest",
+        fn: "_default,content,title",
+        num: 10,
+        lang: $("#langSearchOption").val()
+      },
+      boxCssInfo: {
+        border: "1px solid rgba(82, 168, 236, 0.5)",
+        "-webkit-box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "-moz-box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "box-shadow":
+          "0 1px 1px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(82, 168, 236, 0.2)",
+        "background-color": "#fff",
+        "z-index": "10000"
+      },
+      listSelectedCssInfo: {
+        "background-color": "rgba(82, 168, 236, 0.1)"
+      },
+      listDeselectedCssInfo: {
+        "background-color": "#ffffff"
+      },
+      minterm: 1,
+      adjustWidthVal: 11,
+      searchForm: $("#searchForm")
+    });
+  }
+
+  IMG_LOADING_DELAY = 200;
+  IMG_LOADING_MAX = 0;
+  var loadImage = function(img, url, limit) {
+    var imgData = new Image();
+    $(imgData).on("load", function() {
+      $(img).css("background-image", "");
+      $(img).attr("src", url);
+    });
+    $(imgData).on("error", function() {
+      if (limit > 0) {
+        setTimeout(function() {
+          loadImage(img, url, --limit);
+        }, IMG_LOADING_DELAY);
+      } else {
+        // $(img).attr('src', contextPath + "/images/noimage.png");
+        $(img)
+          .parent()
+          .parent()
+          .css("display", "none");
+      }
+      imgData = null;
+    });
+    imgData.src = url;
+  };
+
+  $("img.thumbnail").each(function() {
+    $(this).css(
+      "background-image",
+      'url("' + contextPath + '/images/loading.gif")'
+    );
+    loadImage(this, $(this).attr("data-src"), IMG_LOADING_MAX);
+  });
 });
 });

+ 416 - 355
src/main/webapp/js/suggestor.js

@@ -1,355 +1,416 @@
-;(function($){
-
-$.fn.suggestor = function(setting) {
-
-	var $boxElement;
-	var $textArea;
-	var inputText = "";
-	var isFocusList = false;
-	var listNum = 0;
-	var listSelNum = 0;
-	var isMouseHover = false;
-	var started = false;
-	var interval = 5;
-
-	var settingMinTerm = 1;
-	var settingAjaxInfo;
-	var settingAdjustWidthVal;
-	var $settingSearchForm;
-	var listSelectedCssInfo;
-	var listDeselectedCssInfo;
-	var boxCssInfo;
-
-	var suggestingSts = false;
-
-	var suggestor = {
-		init: function($element, setting) {
-			suggestingSts = false;
-			$boxElement = $("<div/>");
-            $boxElement.addClass("suggestorBox");
-
-			//style sheet
-			$boxElement.css("display","none");
-			$boxElement.css("position","absolute");
-			$boxElement.css("text-align","left");
-			$boxElement.css("font-size",$element.css("font-size"));
-			if(typeof setting.boxCssInfo === "undefined") {
-				$boxElement.css("border","1px solid #cccccc");
-				$boxElement.css("-webkit-box-shadow","0 3px 2px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(236, 236, 236, 0.6)");
-				$boxElement.css("-moz-box-shadow","0 3px 2px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(236, 236, 236, 0.6)");
-				$boxElement.css("box-shadow","0 3px 2px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(236, 236, 236, 0.6)");
-				$boxElement.css("background-color","#fff");
-			} else {
-				$boxElement.css(setting.boxCssInfo);
-			}
-
-			$textArea = $element;
-			$textArea.attr("autocomplete","off");
-
-			isFocusList = false;
-			inputText = $textArea.val();
-
-
-			//settings
-			settingAjaxInfo = setting.ajaxinfo;
-			settingMinTerm = setting.minterm;
-			$settingSearchForm = setting.searchForm;
-			listSelectedCssInfo = setting.listSelectedCssInfo;
-			listDeselectedCssInfo = setting.listDeselectedCssInfo;
-			settingAdjustWidthVal = setting.adjustWidthVal;
-
-			boxCssInfo = setting.boxCssInfo;
-
-
-			$boxElement.hover(function() {
-				isMouseHover = true;
-			}, function() {
-				isMouseHover = false;
-			});
-
-
-			this.resize();
-			var suggestor = this;
-			$(window).resize(function() {
-				suggestor.resize();
-			});
-
-			$("body").append($boxElement);
-		},
-
-		suggest: function() {
-			suggestingSts = true;
-
-			this.resize();
-
-			var suggestor = this;
-			inputText = $textArea.val();
-
-			listNum = 0;
-			listSelNum = 0;
-
-			if(inputText.length < settingMinTerm) {
-				$boxElement.css("display","none");
-				suggestingSts = false;
-				return;
-			}
-
-
-			$.ajax({
-				url: settingAjaxInfo.url,
-				type:"get",
-				dataType: "jsonp",
-				cache : false,
-				data:{	query: $textArea.val(),
-						fields: settingAjaxInfo.fn,
-						num: settingAjaxInfo.num * 2,
-					    lang: settingAjaxInfo.lang
-				},
-				traditional: true
-			}).done(function(obj) { suggestor.createAutoCompleteList(obj); }).fail(function(a,obj,b) { suggestingSts=false; return; });
-
-		},
-
-
-		createAutoCompleteList: function(obj) {
-			if(obj.response.status !== 0) {
-				$boxElement.css("display","none");
-				return;
-			}
-
-			var hits = obj.response.result.hits;
-			var suggestor = this;
-
-
-			listNum = 0;
-			if(typeof hits !== "undefined") {
-				var reslist = [];
-				for(var i=0;i<hits.length;i++) {
-					reslist.push(hits[i].text);
-				}
-				var $olEle = $("<ol/>");
-				$olEle.css("list-style","none");
-				$olEle.css("padding","0");
-				$olEle.css("margin","2px");
-
-				for(var j=0;j<reslist.length && listNum < settingAjaxInfo.num;j++) {
-					var str = reslist[j];
-					var chkCorrectWord = true;
-
-					var $tmpli = $($olEle.children("li"));
-					for(var k=0;k<$tmpli.length;k++) {
-						if(str === $($tmpli.get(k)).html()) {
-							chkCorrectWord = false;
-						}
-					}
-
-					if(chkCorrectWord) {
-						var $liEle = $("<li/>");
-						$liEle.html(str);
-						$liEle.click(function() {
-							var str = $(this).html();
-							suggestor.fixList();
-							$textArea.val(str);
-							if(typeof $settingSearchForm !== "undefined") {
-								$settingSearchForm.submit();
-								//$settingSearchForm.trigger("submit");
-							}
-						});
-						$liEle.hover(function() {
-							listSelNum = $(this).closest("ol").children("li").index(this) + 1;
-							$(this).closest("ol").children("li").each(function(i){
-								if(i === (listSelNum-1)) {
-									if(typeof listSelectedCssInfo === 'undefined') {
-										$(this).css("background-color", "#e5e5e5");
-									} else {
-										$(this).css(listSelectedCssInfo);
-									}
-								} else {
-									if(typeof listDeselectedCssInfo !== 'undefined') {
-										$(this).css(listDeselectedCssInfo);
-									} else {
-										if(typeof boxCssInfo === 'undefined' || typeof boxCssInfo["background-color"] === 'undefined') {
-											$(this).css("background-color", "#ffffff");
-										} else {
-											$(this).css("background-color", boxCssInfo["background-color"]);
-										}
-									}
-								}
-							});
-						}, function() {
-							if( listSelNum === ($(this).closest("ol").children("li").index(this) + 1) ) {
-								if(typeof listDeselectedCssInfo !== 'undefined') {
-									$(this).css(listDeselectedCssInfo);
-								} else {
-									if(typeof boxCssInfo === 'undefined' || typeof boxCssInfo["background-color"] === 'undefined') {
-										$(this).css("background-color", "#ffffff");
-									} else {
-										$(this).css("background-color", boxCssInfo["background-color"]);
-									}
-								}
-								listSelNum = 0;
-							}
-						});
-
-						$liEle.css("padding","2px");
-
-						$olEle.append($liEle);
-						listNum++;
-					}
-				}
-
-				if(listNum>0 && $textArea.val().length >= settingMinTerm) {
-					$boxElement.html("");
-					$boxElement.append($olEle);
-					$boxElement.css("display","block");
-				} else {
-					$boxElement.css("display","none");
-				}
-			} else {
-				$boxElement.css("display","none");
-			}
-			this.resize();
-
-			suggestingSts = false;
-		},
-
-		selectlist: function(direction) {
-			if($boxElement.css("display") === "none") {
-				return;
-			}
-
-			if(direction === "down") {
-				listSelNum++;
-			} else if(direction === "up") {
-				listSelNum--;
-			} else {
-				return;
-			}
-
-			isFocusList = true;
-
-			if(listSelNum < 0){
-				listSelNum = listNum;
-			} else if(listSelNum > listNum) {
-				listSelNum = 0;
-			}
-
-			$boxElement.children("ol").children("li").each(function(i){
-				if(i === (listSelNum-1)) {
-					if(typeof listSelectedCssInfo === 'undefined') {
-						$(this).css("background-color", "#e5e5e5");
-					} else {
-						$(this).css(listSelectedCssInfo);
-					}
-					$textArea.val($(this).html());
-				} else {
-					if(typeof listDeselectedCssInfo !== 'undefined') {
-						$(this).css(listDeselectedCssInfo);
-					} else {
-						if(typeof boxCssInfo === 'undefined' || typeof boxCssInfo["background-color"] === 'undefined') {
-							$(this).css("background-color", "#ffffff");
-						} else {
-							$(this).css("background-color", boxCssInfo["background-color"]);
-						}
-					}
-				}
-			});
-			if(listSelNum === 0) {
-				$textArea.val(inputText);
-			}
-
-		},
-
-		fixList: function() {
-			if(listSelNum > 0) {
-				$textArea.val($($boxElement.children("ol").children("li").get(listSelNum-1)).html());
-			}
-			inputText = $textArea.val();
-
-			isFocusList = false;
-			$boxElement.css("display","none");
-			listNum = 0;
-		},
-
-		resize: function() {
-			$boxElement.css("top",$textArea.offset().top + $textArea.height() + 6);
-            $boxElement.css("left",$textArea.offset().left);
-			$boxElement.css("height","auto");
-			$boxElement.css("width","auto");
-			if($boxElement.width() < $textArea.width() + settingAdjustWidthVal) {
-				$boxElement.width($textArea.width() + settingAdjustWidthVal);
-			}
-		}
-	};
-
-	suggestor.init($(this), setting);
-
-	$(this).keydown( function(e){
-		if( ((e.keyCode >= 48) && (e.keyCode <= 90))
-			 || ((e.keyCode >= 96) && (e.keyCode <= 105))
-			 || ((e.keyCode >= 186) && (e.keyCode <= 226))
-			 || e.keyCode === 8
-			 || e.keyCode === 32
-			 || e.keyCode === 46
-			 ) {
-			started = true;
-			isFocusList = false;
-		} else if(e.keyCode === 38) {
-			if($boxElement.css("display") !== "none") {
-				e.preventDefault();
-			}
-			suggestor.selectlist("up");
-		} else if(e.keyCode === 40) {
-			if($boxElement.css("display") === "none") {
-				suggestor.suggest();
-			} else {
-				suggestor.selectlist("down");
-			}
-		} else if(e.keyCode === 13) {
-			if(isFocusList) {
-				suggestor.fixList();
-			}
-		}
-	});
-	$(this).keyup(  function(e){
-		if( ((e.keyCode >= 48) && (e.keyCode <= 90))
-			 || ((e.keyCode >= 96) && (e.keyCode <= 105))
-			 || ((e.keyCode >= 186) && (e.keyCode <= 226))
-			 || e.keyCode === 8
-			 || e.keyCode === 32
-			 || e.keyCode === 46
-			 ) {
-			started = true;
-			isFocusList = false;
-		} else if(e.keyCode === 38) {
-/*			if($boxElement.css("display") !== "none") {
-				var strTmp = $textArea.val();
-				$textArea.val("");
-				$textArea.focus();
-				$textArea.val(strTmp);
-			} */
-		}
-	});
-	$(this).blur(function(){
-		if(!isMouseHover) {
-			suggestor.fixList();
-		}
-	});
-
-	//monitoring input field
-	setInterval( function() {
-		if(interval < 5) {
-			interval = interval + 1;
-		} else {
-			if($textArea.val() !== inputText) {
-				if(!isFocusList && started && !suggestingSts) {
-					//update if not selecting item in list
-					suggestor.suggest();
-					interval = 0;
-				}
-			}
-		}
-	}, 100);
-
-}
-})(jQuery);
+(function($) {
+  $.fn.suggestor = function(setting) {
+    var $boxElement;
+    var $textArea;
+    var inputText = "";
+    var isFocusList = false;
+    var listNum = 0;
+    var listSelNum = 0;
+    var isMouseHover = false;
+    var started = false;
+    var interval = 5;
+
+    var settingMinTerm = 1;
+    var settingAjaxInfo;
+    var settingAdjustWidthVal;
+    var $settingSearchForm;
+    var listSelectedCssInfo;
+    var listDeselectedCssInfo;
+    var boxCssInfo;
+
+    var suggestingSts = false;
+
+    var suggestor = {
+      init: function($element, setting) {
+        suggestingSts = false;
+        $boxElement = $("<div/>");
+        $boxElement.addClass("suggestorBox");
+
+        //style sheet
+        $boxElement.css("display", "none");
+        $boxElement.css("position", "absolute");
+        $boxElement.css("text-align", "left");
+        $boxElement.css("font-size", $element.css("font-size"));
+        if (typeof setting.boxCssInfo === "undefined") {
+          $boxElement.css("border", "1px solid #cccccc");
+          $boxElement.css(
+            "-webkit-box-shadow",
+            "0 3px 2px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(236, 236, 236, 0.6)"
+          );
+          $boxElement.css(
+            "-moz-box-shadow",
+            "0 3px 2px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(236, 236, 236, 0.6)"
+          );
+          $boxElement.css(
+            "box-shadow",
+            "0 3px 2px 0px rgba(0, 0, 0, 0.1), 0 3px 2px 0px rgba(236, 236, 236, 0.6)"
+          );
+          $boxElement.css("background-color", "#fff");
+        } else {
+          $boxElement.css(setting.boxCssInfo);
+        }
+
+        $textArea = $element;
+        $textArea.attr("autocomplete", "off");
+
+        isFocusList = false;
+        inputText = $textArea.val();
+
+        //settings
+        settingAjaxInfo = setting.ajaxinfo;
+        settingMinTerm = setting.minterm;
+        $settingSearchForm = setting.searchForm;
+        listSelectedCssInfo = setting.listSelectedCssInfo;
+        listDeselectedCssInfo = setting.listDeselectedCssInfo;
+        settingAdjustWidthVal = setting.adjustWidthVal;
+
+        boxCssInfo = setting.boxCssInfo;
+
+        $boxElement.hover(
+          function() {
+            isMouseHover = true;
+          },
+          function() {
+            isMouseHover = false;
+          }
+        );
+
+        this.resize();
+        var suggestor = this;
+        $(window).resize(function() {
+          suggestor.resize();
+        });
+
+        $("body").append($boxElement);
+      },
+
+      suggest: function() {
+        suggestingSts = true;
+
+        this.resize();
+
+        var suggestor = this;
+        inputText = $textArea.val();
+
+        listNum = 0;
+        listSelNum = 0;
+
+        if (inputText.length < settingMinTerm) {
+          $boxElement.css("display", "none");
+          suggestingSts = false;
+          return;
+        }
+
+        $.ajax({
+          url: settingAjaxInfo.url,
+          type: "get",
+          dataType: "jsonp",
+          cache: false,
+          data: {
+            query: $textArea.val(),
+            fields: settingAjaxInfo.fn,
+            num: settingAjaxInfo.num * 2,
+            lang: settingAjaxInfo.lang
+          },
+          traditional: true
+        })
+          .done(function(obj) {
+            suggestor.createAutoCompleteList(obj);
+          })
+          .fail(function(a, obj, b) {
+            suggestingSts = false;
+            return;
+          });
+      },
+
+      createAutoCompleteList: function(obj) {
+        if (obj.response.status !== 0) {
+          $boxElement.css("display", "none");
+          return;
+        }
+
+        var hits = obj.response.result.hits;
+        var suggestor = this;
+
+        listNum = 0;
+        if (typeof hits !== "undefined") {
+          var reslist = [];
+          for (var i = 0; i < hits.length; i++) {
+            reslist.push(hits[i].text);
+          }
+          var $olEle = $("<ol/>");
+          $olEle.css("list-style", "none");
+          $olEle.css("padding", "0");
+          $olEle.css("margin", "2px");
+
+          for (
+            var j = 0;
+            j < reslist.length && listNum < settingAjaxInfo.num;
+            j++
+          ) {
+            var str = reslist[j];
+            var chkCorrectWord = true;
+
+            var $tmpli = $($olEle.children("li"));
+            for (var k = 0; k < $tmpli.length; k++) {
+              if (str === $($tmpli.get(k)).html()) {
+                chkCorrectWord = false;
+              }
+            }
+
+            if (chkCorrectWord) {
+              var $liEle = $("<li/>");
+              $liEle.html(str);
+              $liEle.click(function() {
+                var str = $(this).html();
+                suggestor.fixList();
+                $textArea.val(str);
+                if (typeof $settingSearchForm !== "undefined") {
+                  $settingSearchForm.submit();
+                  //$settingSearchForm.trigger("submit");
+                }
+              });
+              $liEle.hover(
+                function() {
+                  listSelNum =
+                    $(this)
+                      .closest("ol")
+                      .children("li")
+                      .index(this) + 1;
+                  $(this)
+                    .closest("ol")
+                    .children("li")
+                    .each(function(i) {
+                      if (i === listSelNum - 1) {
+                        if (typeof listSelectedCssInfo === "undefined") {
+                          $(this).css("background-color", "#e5e5e5");
+                        } else {
+                          $(this).css(listSelectedCssInfo);
+                        }
+                      } else {
+                        if (typeof listDeselectedCssInfo !== "undefined") {
+                          $(this).css(listDeselectedCssInfo);
+                        } else {
+                          if (
+                            typeof boxCssInfo === "undefined" ||
+                            typeof boxCssInfo["background-color"] ===
+                              "undefined"
+                          ) {
+                            $(this).css("background-color", "#ffffff");
+                          } else {
+                            $(this).css(
+                              "background-color",
+                              boxCssInfo["background-color"]
+                            );
+                          }
+                        }
+                      }
+                    });
+                },
+                function() {
+                  if (
+                    listSelNum ===
+                    $(this)
+                      .closest("ol")
+                      .children("li")
+                      .index(this) +
+                      1
+                  ) {
+                    if (typeof listDeselectedCssInfo !== "undefined") {
+                      $(this).css(listDeselectedCssInfo);
+                    } else {
+                      if (
+                        typeof boxCssInfo === "undefined" ||
+                        typeof boxCssInfo["background-color"] === "undefined"
+                      ) {
+                        $(this).css("background-color", "#ffffff");
+                      } else {
+                        $(this).css(
+                          "background-color",
+                          boxCssInfo["background-color"]
+                        );
+                      }
+                    }
+                    listSelNum = 0;
+                  }
+                }
+              );
+
+              $liEle.css("padding", "2px");
+
+              $olEle.append($liEle);
+              listNum++;
+            }
+          }
+
+          if (listNum > 0 && $textArea.val().length >= settingMinTerm) {
+            $boxElement.html("");
+            $boxElement.append($olEle);
+            $boxElement.css("display", "block");
+          } else {
+            $boxElement.css("display", "none");
+          }
+        } else {
+          $boxElement.css("display", "none");
+        }
+        this.resize();
+
+        suggestingSts = false;
+      },
+
+      selectlist: function(direction) {
+        if ($boxElement.css("display") === "none") {
+          return;
+        }
+
+        if (direction === "down") {
+          listSelNum++;
+        } else if (direction === "up") {
+          listSelNum--;
+        } else {
+          return;
+        }
+
+        isFocusList = true;
+
+        if (listSelNum < 0) {
+          listSelNum = listNum;
+        } else if (listSelNum > listNum) {
+          listSelNum = 0;
+        }
+
+        $boxElement
+          .children("ol")
+          .children("li")
+          .each(function(i) {
+            if (i === listSelNum - 1) {
+              if (typeof listSelectedCssInfo === "undefined") {
+                $(this).css("background-color", "#e5e5e5");
+              } else {
+                $(this).css(listSelectedCssInfo);
+              }
+              $textArea.val($(this).html());
+            } else {
+              if (typeof listDeselectedCssInfo !== "undefined") {
+                $(this).css(listDeselectedCssInfo);
+              } else {
+                if (
+                  typeof boxCssInfo === "undefined" ||
+                  typeof boxCssInfo["background-color"] === "undefined"
+                ) {
+                  $(this).css("background-color", "#ffffff");
+                } else {
+                  $(this).css(
+                    "background-color",
+                    boxCssInfo["background-color"]
+                  );
+                }
+              }
+            }
+          });
+        if (listSelNum === 0) {
+          $textArea.val(inputText);
+        }
+      },
+
+      fixList: function() {
+        if (listSelNum > 0) {
+          $textArea.val(
+            $(
+              $boxElement
+                .children("ol")
+                .children("li")
+                .get(listSelNum - 1)
+            ).html()
+          );
+        }
+        inputText = $textArea.val();
+
+        isFocusList = false;
+        $boxElement.css("display", "none");
+        listNum = 0;
+      },
+
+      resize: function() {
+        $boxElement.css("top", $textArea.offset().top + $textArea.height() + 6);
+        $boxElement.css("left", $textArea.offset().left);
+        $boxElement.css("height", "auto");
+        $boxElement.css("width", "auto");
+        if ($boxElement.width() < $textArea.width() + settingAdjustWidthVal) {
+          $boxElement.width($textArea.width() + settingAdjustWidthVal);
+        }
+      }
+    };
+
+    suggestor.init($(this), setting);
+
+    $(this).keydown(function(e) {
+      if (
+        (e.keyCode >= 48 && e.keyCode <= 90) ||
+        (e.keyCode >= 96 && e.keyCode <= 105) ||
+        (e.keyCode >= 186 && e.keyCode <= 226) ||
+        e.keyCode === 8 ||
+        e.keyCode === 32 ||
+        e.keyCode === 46
+      ) {
+        started = true;
+        isFocusList = false;
+      } else if (e.keyCode === 38) {
+        if ($boxElement.css("display") !== "none") {
+          e.preventDefault();
+        }
+        suggestor.selectlist("up");
+      } else if (e.keyCode === 40) {
+        if ($boxElement.css("display") === "none") {
+          suggestor.suggest();
+        } else {
+          suggestor.selectlist("down");
+        }
+      } else if (e.keyCode === 13) {
+        if (isFocusList) {
+          suggestor.fixList();
+        }
+      }
+    });
+    $(this).keyup(function(e) {
+      if (
+        (e.keyCode >= 48 && e.keyCode <= 90) ||
+        (e.keyCode >= 96 && e.keyCode <= 105) ||
+        (e.keyCode >= 186 && e.keyCode <= 226) ||
+        e.keyCode === 8 ||
+        e.keyCode === 32 ||
+        e.keyCode === 46
+      ) {
+        started = true;
+        isFocusList = false;
+      } else if (e.keyCode === 38) {
+        /*			if($boxElement.css("display") !== "none") {
+				var strTmp = $textArea.val();
+				$textArea.val("");
+				$textArea.focus();
+				$textArea.val(strTmp);
+			} */
+      }
+    });
+    $(this).blur(function() {
+      if (!isMouseHover) {
+        suggestor.fixList();
+      }
+    });
+
+    //monitoring input field
+    setInterval(function() {
+      if (interval < 5) {
+        interval = interval + 1;
+      } else {
+        if ($textArea.val() !== inputText) {
+          if (!isFocusList && started && !suggestingSts) {
+            //update if not selecting item in list
+            suggestor.suggest();
+            interval = 0;
+          }
+        }
+      }
+    }, 100);
+  };
+})(jQuery);