database.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
  2. var Controller = {
  3. index: function () {
  4. //禁止在操作select元素时关闭dropdown的关闭事件
  5. $("#database").on('click', '.dropdown-menu input, .dropdown-menu label, .dropdown-menu select', function (e) {
  6. e.stopPropagation();
  7. });
  8. //提交时检查是否有删除或清空操作
  9. $("#database").on("submit", "#sqlexecute", function () {
  10. var v = $("#sqlquery").val().toLowerCase();
  11. if ((v.indexOf("delete ") >= 0 || v.indexOf("truncate ") >= 0) && !confirm(__('Are you sure you want to delete or turncate?'))) {
  12. return false;
  13. }
  14. });
  15. //事件按钮操作
  16. $("#database").on("click", "ul#subaction li input", function () {
  17. $("#topaction").val($(this).attr("rel"));
  18. return true;
  19. });
  20. //窗口变更的时候重设结果栏高度
  21. $(window).on("resize", function () {
  22. $("#database .well").height($(window).height() - $("#database #sqlexecute").height() - $("#ribbon").outerHeight() - $(".panel-heading").outerHeight() - 130);
  23. });
  24. //修复iOS下iframe无法滚动的BUG
  25. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  26. $("#resultparent").css({"-webkit-overflow-scrolling": "touch", "overflow": "auto"});
  27. }
  28. $(window).resize();
  29. }
  30. };
  31. return Controller;
  32. });