070.settings.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /** This file is part of KCFinder project
  2. *
  3. * @desc Settings panel functionality
  4. * @package KCFinder
  5. * @version 3.12
  6. * @author Pavel Tzonkov <sunhater@sunhater.com>
  7. * @copyright 2010-2014 KCFinder Project
  8. * @license http://opensource.org/licenses/GPL-3.0 GPLv3
  9. * @license http://opensource.org/licenses/LGPL-3.0 LGPLv3
  10. * @link http://kcfinder.sunhater.com
  11. */
  12. _.initSettings = function() {
  13. $('#settings').disableTextSelect();
  14. $('#settings fieldset, #settings input, #settings label').uniform();
  15. if (!_.shows.length)
  16. $('#show input[type="checkbox"]').each(function(i) {
  17. _.shows[i] = this.name;
  18. });
  19. var shows = _.shows;
  20. if (!$.$.kuki.isSet('showname')) {
  21. $.$.kuki.set('showname', "on");
  22. $.each(shows, function (i, val) {
  23. if (val != "name") $.$.kuki.set('show' + val, "off");
  24. });
  25. }
  26. $('#show input[type="checkbox"]').click(function() {
  27. $.$.kuki.set('show' + this.name, this.checked ? "on" : "off")
  28. $('#files .file div.' + this.name).css('display', this.checked ? "block" : "none");
  29. });
  30. $.each(shows, function(i, val) {
  31. $('#show input[name="' + val + '"]').get(0).checked = ($.$.kuki.get('show' + val) == "on") ? "checked" : "";
  32. });
  33. if (!_.orders.length)
  34. $('#order input[type="radio"]').each(function(i) {
  35. _.orders[i] = this.value;
  36. })
  37. var orders = _.orders;
  38. if (!$.$.kuki.isSet('order'))
  39. $.$.kuki.set('order', "name");
  40. if (!$.$.kuki.isSet('orderDesc'))
  41. $.$.kuki.set('orderDesc', "off");
  42. $('#order input[value="' + $.$.kuki.get('order') + '"]').get(0).checked = true;
  43. $('#order input[name="desc"]').get(0).checked = ($.$.kuki.get('orderDesc') == "on");
  44. $('#order input[type="radio"]').click(function() {
  45. $.$.kuki.set('order', this.value);
  46. _.orderFiles();
  47. });
  48. $('#order input[name="desc"]').click(function() {
  49. $.$.kuki.set('orderDesc', this.checked ? 'on' : "off");
  50. _.orderFiles();
  51. });
  52. if (!$.$.kuki.isSet('view'))
  53. $.$.kuki.set('view', "thumbs");
  54. if ($.$.kuki.get('view') == "list")
  55. $('#show').parent().hide();
  56. $('#view input[value="' + $.$.kuki.get('view') + '"]').get(0).checked = true;
  57. $('#view input').click(function() {
  58. var view = this.value;
  59. if ($.$.kuki.get('view') != view) {
  60. $.$.kuki.set('view', view);
  61. if (view == "list")
  62. $('#show').parent().hide();
  63. else
  64. $('#show').parent().show();
  65. }
  66. _.fixFilesHeight();
  67. _.refresh();
  68. });
  69. };