source: trunk/admin/inc/ckeditor/filemanager/js/browser/init.js@ 239

Last change on this file since 239 was 239, checked in by luc, 9 years ago

Admin: correzione visulaizzazione immissione dati spoglio per Chrome e Safari - Aggiornamento dell'editor da FCKeditor a CKeditor , accessibili anche a Chrome e Safari.

  • Property svn:executable set to *
File size: 7.5 KB
Line 
1<?php
2
3/** This file is part of KCFinder project
4 *
5 * @desc Object initializations
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
15browser.init = function() {
16 if (!this.checkAgent()) return;
17
18 $('body').click(function() {
19 browser.hideDialog();
20 });
21 $('#shadow').click(function() {
22 return false;
23 });
24 $('#dialog').unbind();
25 $('#dialog').click(function() {
26 return false;
27 });
28 $('#alert').unbind();
29 $('#alert').click(function() {
30 return false;
31 });
32 this.initOpeners();
33 this.initSettings();
34 this.initContent();
35 this.initToolbar();
36 this.initResizer();
37 this.initDropUpload();
38};
39
40browser.checkAgent = function() {
41 if (!$.browser.version ||
42 ($.browser.msie && (parseInt($.browser.version) < 7) && !this.support.chromeFrame) ||
43 ($.browser.opera && (parseInt($.browser.version) < 10)) ||
44 ($.browser.mozilla && (parseFloat($.browser.version.replace(/^(\d+(\.\d+)?)([^\d].*)?$/, "$1")) < 1.8))
45 ) {
46 var html = '<div style="padding:10px">Your browser is not capable to display KCFinder. Please update your browser or install another one: <a href="http://www.mozilla.com/firefox/" target="_blank">Mozilla Firefox</a>, <a href="http://www.apple.com/safari" target="_blank">Apple Safari</a>, <a href="http://www.google.com/chrome" target="_blank">Google Chrome</a>, <a href="http://www.opera.com/browser" target="_blank">Opera</a>.';
47 if ($.browser.msie)
48 html += ' You may also install <a href="http://www.google.com/chromeframe" target="_blank">Google Chrome Frame ActiveX plugin</a> to get Internet Explorer 6 working.';
49 html += '</div>';
50 $('body').html(html);
51 return false;
52 }
53 return true;
54};
55
56browser.initOpeners = function() {
57 if (this.opener.TinyMCE && (typeof(tinyMCEPopup) == 'undefined'))
58 this.opener.TinyMCE = null;
59
60 if (this.opener.TinyMCE)
61 this.opener.callBack = true;
62
63 if ((!this.opener.name || (this.opener.name == 'fckeditor')) &&
64 window.opener && window.opener.SetUrl
65 ) {
66 this.opener.FCKeditor = true;
67 this.opener.callBack = true;
68 }
69
70 if (this.opener.CKEditor) {
71 if (window.parent && window.parent.CKEDITOR)
72 this.opener.CKEditor.object = window.parent.CKEDITOR;
73 else if (window.opener && window.opener.CKEDITOR) {
74 this.opener.CKEditor.object = window.opener.CKEDITOR;
75 this.opener.callBack = true;
76 } else
77 this.opener.CKEditor = null;
78 }
79
80 if (!this.opener.CKEditor && !this.opener.FCKEditor && !this.TinyMCE) {
81 if ((window.opener && window.opener.KCFinder && window.opener.KCFinder.callBack) ||
82 (window.parent && window.parent.KCFinder && window.parent.KCFinder.callBack)
83 )
84 this.opener.callBack = window.opener
85 ? window.opener.KCFinder.callBack
86 : window.parent.KCFinder.callBack;
87
88 if ((
89 window.opener &&
90 window.opener.KCFinder &&
91 window.opener.KCFinder.callBackMultiple
92 ) || (
93 window.parent &&
94 window.parent.KCFinder &&
95 window.parent.KCFinder.callBackMultiple
96 )
97 )
98 this.opener.callBackMultiple = window.opener
99 ? window.opener.KCFinder.callBackMultiple
100 : window.parent.KCFinder.callBackMultiple;
101 }
102};
103
104browser.initContent = function() {
105 $('div#folders').html(this.label("Loading folders..."));
106 $('div#files').html(this.label("Loading files..."));
107 $.ajax({
108 type: 'GET',
109 dataType: 'json',
110 url: browser.baseGetData('init'),
111 async: false,
112 success: function(data) {
113 if (browser.check4errors(data))
114 return;
115 browser.dirWritable = data.dirWritable;
116 $('#folders').html(browser.buildTree(data.tree));
117 browser.setTreeData(data.tree);
118 browser.initFolders();
119 browser.files = data.files ? data.files : [];
120 browser.orderFiles();
121 },
122 error: function() {
123 $('div#folders').html(browser.label("Unknown error."));
124 $('div#files').html(browser.label("Unknown error."));
125 }
126 });
127};
128
129browser.initResizer = function() {
130 var cursor = ($.browser.opera) ? 'move' : 'col-resize';
131 $('#resizer').css('cursor', cursor);
132 $('#resizer').drag('start', function() {
133 $(this).css({opacity:'0.4', filter:'alpha(opacity:40)'});
134 $('#all').css('cursor', cursor);
135 });
136 $('#resizer').drag(function(e) {
137 var left = e.pageX - parseInt(_.nopx($(this).css('width')) / 2);
138 left = (left >= 0) ? left : 0;
139 left = (left + _.nopx($(this).css('width')) < $(window).width())
140 ? left : $(window).width() - _.nopx($(this).css('width'));
141 $(this).css('left', left);
142 });
143 var end = function() {
144 $(this).css({opacity:'0', filter:'alpha(opacity:0)'});
145 $('#all').css('cursor', '');
146 var left = _.nopx($(this).css('left')) + _.nopx($(this).css('width'));
147 var right = $(window).width() - left;
148 $('#left').css('width', left + 'px');
149 $('#right').css('width', right + 'px');
150 _('files').style.width = $('#right').innerWidth() - _.outerHSpace('#files') + 'px';
151 _('resizer').style.left = $('#left').outerWidth() - _.outerRightSpace('#folders', 'm') + 'px';
152 _('resizer').style.width = _.outerRightSpace('#folders', 'm') + _.outerLeftSpace('#files', 'm') + 'px';
153 browser.fixFilesHeight();
154 };
155 $('#resizer').drag('end', end);
156 $('#resizer').mouseup(end);
157};
158
159browser.resize = function() {
160 _('left').style.width = '25%';
161 _('right').style.width = '75%';
162 _('toolbar').style.height = $('#toolbar a').outerHeight() + "px";
163 _('shadow').style.width = $(window).width() + 'px';
164 _('shadow').style.height = _('resizer').style.height = $(window).height() + 'px';
165 _('left').style.height = _('right').style.height =
166 $(window).height() - $('#status').outerHeight() + 'px';
167 _('folders').style.height =
168 $('#left').outerHeight() - _.outerVSpace('#folders') + 'px';
169 browser.fixFilesHeight();
170 var width = $('#left').outerWidth() + $('#right').outerWidth();
171 _('status').style.width = width + 'px';
172 while ($('#status').outerWidth() > width)
173 _('status').style.width = _.nopx(_('status').style.width) - 1 + 'px';
174 while ($('#status').outerWidth() < width)
175 _('status').style.width = _.nopx(_('status').style.width) + 1 + 'px';
176 if ($.browser.msie && ($.browser.version.substr(0, 1) < 8))
177 _('right').style.width = $(window).width() - $('#left').outerWidth() + 'px';
178 _('files').style.width = $('#right').innerWidth() - _.outerHSpace('#files') + 'px';
179 _('resizer').style.left = $('#left').outerWidth() - _.outerRightSpace('#folders', 'm') + 'px';
180 _('resizer').style.width = _.outerRightSpace('#folders', 'm') + _.outerLeftSpace('#files', 'm') + 'px';
181};
182
183browser.fixFilesHeight = function() {
184 _('files').style.height =
185 $('#left').outerHeight() - $('#toolbar').outerHeight() - _.outerVSpace('#files') -
186 (($('#settings').css('display') != "none") ? $('#settings').outerHeight() : 0) + 'px';
187};
Note: See TracBrowser for help on using the repository browser.