3 /** This file is part of KCFinder project
5 * @desc Settings panel functionality
8 * @author Pavel Tzonkov <pavelc@users.sourceforge.net>
9 * @copyright 2010, 2011 KCFinder Project
10 * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11 * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12 * @link http://kcfinder.sunhater.com
15 browser.initSettings = function() {
17 if (!this.shows.length) {
18 var showInputs = $('#show input[type="checkbox"]').toArray();
19 $.each(showInputs, function (i, input) {
20 browser.shows[i] = input.name;
24 var shows = this.shows;
26 if (!_.kuki.isSet('showname')) {
27 _.kuki.set('showname', 'on');
28 $.each(shows, function (i, val) {
29 if (val != "name") _.kuki.set('show' + val, 'off');
33 $('#show input[type="checkbox"]').click(function() {
34 var kuki = $(this).get(0).checked ? 'on' : 'off';
35 _.kuki.set('show' + $(this).get(0).name, kuki)
36 if ($(this).get(0).checked)
37 $('#files .file div.' + $(this).get(0).name).css('display', 'block');
39 $('#files .file div.' + $(this).get(0).name).css('display', 'none');
42 $.each(shows, function(i, val) {
43 var checked = (_.kuki.get('show' + val) == 'on') ? 'checked' : '';
44 $('#show input[name="' + val + '"]').get(0).checked = checked;
47 if (!this.orders.length) {
48 var orderInputs = $('#order input[type="radio"]').toArray();
49 $.each(orderInputs, function (i, input) {
50 browser.orders[i] = input.value;
54 var orders = this.orders;
56 if (!_.kuki.isSet('order'))
57 _.kuki.set('order', 'name');
59 if (!_.kuki.isSet('orderDesc'))
60 _.kuki.set('orderDesc', 'off');
62 $('#order input[value="' + _.kuki.get('order') + '"]').get(0).checked = true;
63 $('#order input[name="desc"]').get(0).checked = (_.kuki.get('orderDesc') == 'on');
65 $('#order input[type="radio"]').click(function() {
66 _.kuki.set('order', $(this).get(0).value);
70 $('#order input[name="desc"]').click(function() {
71 _.kuki.set('orderDesc', $(this).get(0).checked ? 'on' : 'off');
75 if (!_.kuki.isSet('view'))
76 _.kuki.set('view', 'thumbs');
78 if (_.kuki.get('view') == 'list') {
79 $('#show input').each(function() { this.checked = true; });
80 $('#show input').each(function() { this.disabled = true; });
83 $('#view input[value="' + _.kuki.get('view') + '"]').get(0).checked = true;
85 $('#view input').click(function() {
86 var view = $(this).attr('value');
87 if (_.kuki.get('view') != view) {
88 _.kuki.set('view', view);
90 $('#show input').each(function() { this.checked = true; });
91 $('#show input').each(function() { this.disabled = true; });
93 $.each(browser.shows, function(i, val) {
94 $('#show input[name="' + val + '"]').get(0).checked =
95 (_.kuki.get('show' + val) == "on");
97 $('#show input').each(function() { this.disabled = false; });