1 | <?php
|
---|
2 |
|
---|
3 | /** This file is part of KCFinder project
|
---|
4 | *
|
---|
5 | * @desc Settings panel functionality
|
---|
6 | * @package KCFinder
|
---|
7 | * @version 2.51
|
---|
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
|
---|
13 | */?>
|
---|
14 |
|
---|
15 | browser.initSettings = function() {
|
---|
16 |
|
---|
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;
|
---|
21 | });
|
---|
22 | }
|
---|
23 |
|
---|
24 | var shows = this.shows;
|
---|
25 |
|
---|
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');
|
---|
30 | });
|
---|
31 | }
|
---|
32 |
|
---|
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');
|
---|
38 | else
|
---|
39 | $('#files .file div.' + $(this).get(0).name).css('display', 'none');
|
---|
40 | });
|
---|
41 |
|
---|
42 | $.each(shows, function(i, val) {
|
---|
43 | var checked = (_.kuki.get('show' + val) == 'on') ? 'checked' : '';
|
---|
44 | $('#show input[name="' + val + '"]').get(0).checked = checked;
|
---|
45 | });
|
---|
46 |
|
---|
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;
|
---|
51 | });
|
---|
52 | }
|
---|
53 |
|
---|
54 | var orders = this.orders;
|
---|
55 |
|
---|
56 | if (!_.kuki.isSet('order'))
|
---|
57 | _.kuki.set('order', 'name');
|
---|
58 |
|
---|
59 | if (!_.kuki.isSet('orderDesc'))
|
---|
60 | _.kuki.set('orderDesc', 'off');
|
---|
61 |
|
---|
62 | $('#order input[value="' + _.kuki.get('order') + '"]').get(0).checked = true;
|
---|
63 | $('#order input[name="desc"]').get(0).checked = (_.kuki.get('orderDesc') == 'on');
|
---|
64 |
|
---|
65 | $('#order input[type="radio"]').click(function() {
|
---|
66 | _.kuki.set('order', $(this).get(0).value);
|
---|
67 | browser.orderFiles();
|
---|
68 | });
|
---|
69 |
|
---|
70 | $('#order input[name="desc"]').click(function() {
|
---|
71 | _.kuki.set('orderDesc', $(this).get(0).checked ? 'on' : 'off');
|
---|
72 | browser.orderFiles();
|
---|
73 | });
|
---|
74 |
|
---|
75 | if (!_.kuki.isSet('view'))
|
---|
76 | _.kuki.set('view', 'thumbs');
|
---|
77 |
|
---|
78 | if (_.kuki.get('view') == 'list') {
|
---|
79 | $('#show input').each(function() { this.checked = true; });
|
---|
80 | $('#show input').each(function() { this.disabled = true; });
|
---|
81 | }
|
---|
82 |
|
---|
83 | $('#view input[value="' + _.kuki.get('view') + '"]').get(0).checked = true;
|
---|
84 |
|
---|
85 | $('#view input').click(function() {
|
---|
86 | var view = $(this).attr('value');
|
---|
87 | if (_.kuki.get('view') != view) {
|
---|
88 | _.kuki.set('view', view);
|
---|
89 | if (view == 'list') {
|
---|
90 | $('#show input').each(function() { this.checked = true; });
|
---|
91 | $('#show input').each(function() { this.disabled = true; });
|
---|
92 | } else {
|
---|
93 | $.each(browser.shows, function(i, val) {
|
---|
94 | $('#show input[name="' + val + '"]').get(0).checked =
|
---|
95 | (_.kuki.get('show' + val) == "on");
|
---|
96 | });
|
---|
97 | $('#show input').each(function() { this.disabled = false; });
|
---|
98 | }
|
---|
99 | }
|
---|
100 | browser.refresh();
|
---|
101 | });
|
---|
102 | };
|
---|