ace-extra.min.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. if (!("ace" in window)) {
  2. window.ace = {}
  3. }
  4. ace.config = {
  5. cookie_expiry: 604800,
  6. storage_method: 2
  7. };
  8. ace.settings = {
  9. is: function(b, a) {
  10. return (ace.data.get("settings", b + "-" + a) == 1)
  11. },
  12. exists: function(b, a) {
  13. return (ace.data.get("settings", b + "-" + a) !== null)
  14. },
  15. set: function(b, a) {
  16. ace.data.set("settings", b + "-" + a, 1)
  17. },
  18. unset: function(b, a) {
  19. ace.data.set("settings", b + "-" + a, -1)
  20. },
  21. remove: function(b, a) {
  22. ace.data.remove("settings", b + "-" + a)
  23. },
  24. navbar_fixed: function(a) {
  25. a = a || false;
  26. if (!a && ace.settings.is("sidebar", "fixed")) {
  27. ace.settings.sidebar_fixed(false)
  28. }
  29. var b = document.getElementById("navbar");
  30. if (a) {
  31. if (!ace.hasClass(b, "navbar-fixed-top")) {
  32. ace.addClass(b, "navbar-fixed-top")
  33. }
  34. if (!ace.hasClass(document.body, "navbar-fixed")) {
  35. ace.addClass(document.body, "navbar-fixed")
  36. }
  37. ace.settings.set("navbar", "fixed")
  38. } else {
  39. ace.removeClass(b, "navbar-fixed-top");
  40. ace.removeClass(document.body, "navbar-fixed");
  41. ace.settings.unset("navbar", "fixed")
  42. }
  43. document.getElementById("ace-settings-navbar").checked = a
  44. },
  45. breadcrumbs_fixed: function(a) {
  46. a = a || false;
  47. if (a && !ace.settings.is("sidebar", "fixed")) {
  48. ace.settings.sidebar_fixed(true)
  49. }
  50. var b = document.getElementById("breadcrumbs");
  51. if (a) {
  52. if (!ace.hasClass(b, "breadcrumbs-fixed")) {
  53. ace.addClass(b, "breadcrumbs-fixed")
  54. }
  55. if (!ace.hasClass(document.body, "breadcrumbs-fixed")) {
  56. ace.addClass(document.body, "breadcrumbs-fixed")
  57. }
  58. ace.settings.set("breadcrumbs", "fixed")
  59. } else {
  60. ace.removeClass(b, "breadcrumbs-fixed");
  61. ace.removeClass(document.body, "breadcrumbs-fixed");
  62. ace.settings.unset("breadcrumbs", "fixed")
  63. }
  64. document.getElementById("ace-settings-breadcrumbs").checked = a
  65. },
  66. sidebar_fixed: function(a) {
  67. a = a || false;
  68. if (!a && ace.settings.is("breadcrumbs", "fixed")) {
  69. ace.settings.breadcrumbs_fixed(false)
  70. }
  71. if (a && !ace.settings.is("navbar", "fixed")) {
  72. ace.settings.navbar_fixed(true)
  73. }
  74. var b = document.getElementById("sidebar");
  75. if (a) {
  76. if (!ace.hasClass(b, "sidebar-fixed")) {
  77. ace.addClass(b, "sidebar-fixed")
  78. }
  79. ace.settings.set("sidebar", "fixed")
  80. } else {
  81. ace.removeClass(b, "sidebar-fixed");
  82. ace.settings.unset("sidebar", "fixed")
  83. }
  84. document.getElementById("ace-settings-sidebar").checked = a
  85. },
  86. main_container_fixed: function(a) {
  87. a = a || false;
  88. var c = document.getElementById("main-container");
  89. var b = document.getElementById("navbar-container");
  90. if (a) {
  91. if (!ace.hasClass(c, "container")) {
  92. ace.addClass(c, "container")
  93. }
  94. if (!ace.hasClass(b, "container")) {
  95. ace.addClass(b, "container")
  96. }
  97. ace.settings.set("main-container", "fixed")
  98. } else {
  99. ace.removeClass(c, "container");
  100. ace.removeClass(b, "container");
  101. ace.settings.unset("main-container", "fixed")
  102. }
  103. document.getElementById("ace-settings-add-container").checked = a;
  104. if (navigator.userAgent.match(/webkit/i)) {
  105. var d = document.getElementById("sidebar");
  106. ace.toggleClass(d, "menu-min");
  107. setTimeout(function() {
  108. ace.toggleClass(d, "menu-min")
  109. }, 0)
  110. }
  111. },
  112. sidebar_collapsed: function(c) {
  113. c = c || false;
  114. var e = document.getElementById("sidebar");
  115. var d = document.getElementById("sidebar-collapse").querySelector('[class*="icon-"]');
  116. var b = d.getAttribute("data-icon1");
  117. var a = d.getAttribute("data-icon2");
  118. if (c) {
  119. ace.addClass(e, "menu-min");
  120. ace.removeClass(d, b);
  121. ace.addClass(d, a);
  122. ace.settings.set("sidebar", "collapsed")
  123. } else {
  124. ace.removeClass(e, "menu-min");
  125. ace.removeClass(d, a);
  126. ace.addClass(d, b);
  127. ace.settings.unset("sidebar", "collapsed")
  128. }
  129. },
  130. };
  131. ace.settings.check = function(c, e) {
  132. if (!ace.settings.exists(c, e)) {
  133. return
  134. }
  135. var a = ace.settings.is(c, e);
  136. var b = {
  137. "navbar-fixed": "navbar-fixed-top",
  138. "sidebar-fixed": "sidebar-fixed",
  139. "breadcrumbs-fixed": "breadcrumbs-fixed",
  140. "sidebar-collapsed": "menu-min",
  141. "main-container-fixed": "container"
  142. };
  143. var d = document.getElementById(c);
  144. if (a != ace.hasClass(d, b[c + "-" + e])) {
  145. ace.settings[c.replace("-", "_") + "_" + e](a)
  146. }
  147. };
  148. ace.data_storage = function(e, c) {
  149. var b = "ace.";
  150. var d = null;
  151. var a = 0;
  152. if ((e == 1 || e === c) && "localStorage" in window && window.localStorage !== null) {
  153. d = ace.storage;
  154. a = 1
  155. } else {
  156. if (d == null && (e == 2 || e === c) && "cookie" in document && document.cookie !== null) {
  157. d = ace.cookie;
  158. a = 2
  159. }
  160. }
  161. this.set = function(h, g, i, k) {
  162. if (!d) {
  163. return
  164. }
  165. if (i === k) {
  166. i = g;
  167. g = h;
  168. if (i == null) {
  169. d.remove(b + g)
  170. } else {
  171. if (a == 1) {
  172. d.set(b + g, i)
  173. } else {
  174. if (a == 2) {
  175. d.set(b + g, i, ace.config.cookie_expiry)
  176. }
  177. }
  178. }
  179. } else {
  180. if (a == 1) {
  181. if (i == null) {
  182. d.remove(b + h + "." + g)
  183. } else {
  184. d.set(b + h + "." + g, i)
  185. }
  186. } else {
  187. if (a == 2) {
  188. var j = d.get(b + h);
  189. var f = j ? JSON.parse(j) : {};
  190. if (i == null) {
  191. delete f[g];
  192. if (ace.sizeof(f) == 0) {
  193. d.remove(b + h);
  194. return
  195. }
  196. } else {
  197. f[g] = i
  198. }
  199. d.set(b + h, JSON.stringify(f), ace.config.cookie_expiry)
  200. }
  201. }
  202. }
  203. };
  204. this.get = function(h, g, j) {
  205. if (!d) {
  206. return null
  207. }
  208. if (g === j) {
  209. g = h;
  210. return d.get(b + g)
  211. } else {
  212. if (a == 1) {
  213. return d.get(b + h + "." + g)
  214. } else {
  215. if (a == 2) {
  216. var i = d.get(b + h);
  217. var f = i ? JSON.parse(i) : {};
  218. return g in f ? f[g] : null
  219. }
  220. }
  221. }
  222. };
  223. this.remove = function(g, f, h) {
  224. if (!d) {
  225. return
  226. }
  227. if (f === h) {
  228. f = g;
  229. this.set(f, null)
  230. } else {
  231. this.set(g, f, null)
  232. }
  233. }
  234. };
  235. ace.cookie = {
  236. get: function(c) {
  237. var d = document.cookie,
  238. g, f = c + "=",
  239. a;
  240. if (!d) {
  241. return
  242. }
  243. a = d.indexOf("; " + f);
  244. if (a == -1) {
  245. a = d.indexOf(f);
  246. if (a != 0) {
  247. return null
  248. }
  249. } else {
  250. a += 2
  251. }
  252. g = d.indexOf(";", a);
  253. if (g == -1) {
  254. g = d.length
  255. }
  256. return decodeURIComponent(d.substring(a + f.length, g))
  257. },
  258. set: function(b, e, a, g, c, f) {
  259. var h = new Date();
  260. if (typeof(a) == "object" && a.toGMTString) {
  261. a = a.toGMTString()
  262. } else {
  263. if (parseInt(a, 10)) {
  264. h.setTime(h.getTime() + (parseInt(a, 10) * 1000));
  265. a = h.toGMTString()
  266. } else {
  267. a = ""
  268. }
  269. }
  270. document.cookie = b + "=" + encodeURIComponent(e) + ((a) ? "; expires=" + a : "") + ((g) ? "; path=" + g : "") + ((c) ? "; domain=" + c : "") + ((f) ? "; secure" : "")
  271. },
  272. remove: function(a, b) {
  273. this.set(a, "", -1000, b)
  274. }
  275. };
  276. ace.storage = {
  277. get: function(a) {
  278. return window.localStorage.getItem(a)
  279. },
  280. set: function(a, b) {
  281. window.localStorage.setItem(a, b)
  282. },
  283. remove: function(a) {
  284. window.localStorage.removeItem(a)
  285. }
  286. };
  287. ace.sizeof = function(c) {
  288. var b = 0;
  289. for (var a in c) {
  290. if (c.hasOwnProperty(a)) {
  291. b++
  292. }
  293. }
  294. return b
  295. };
  296. ace.hasClass = function(b, a) {
  297. return (" " + b.className + " ").indexOf(" " + a + " ") > -1
  298. };
  299. ace.addClass = function(c, b) {
  300. if (!ace.hasClass(c, b)) {
  301. var a = c.className;
  302. c.className = a + (a.length ? " " : "") + b
  303. }
  304. };
  305. ace.removeClass = function(b, a) {
  306. ace.replaceClass(b, a)
  307. };
  308. ace.replaceClass = function(c, b, d) {
  309. var a = new RegExp(("(^|\\s)" + b + "(\\s|$)"), "i");
  310. c.className = c.className.replace(a, function(e, g, f) {
  311. return d ? (g + d + f) : " "
  312. }).replace(/^\s+|\s+$/g, "")
  313. };
  314. ace.toggleClass = function(b, a) {
  315. if (ace.hasClass(b, a)) {
  316. ace.removeClass(b, a)
  317. } else {
  318. ace.addClass(b, a)
  319. }
  320. };
  321. ace.data = new ace.data_storage(ace.config.storage_method);