[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/kcfinder/js/browser/ -> init.js (source)

   1  <?php
   2  
   3  /** This file is part of KCFinder project
   4    *
   5    *      @desc Object initializations
   6    *   @package KCFinder
   7    *   @version 2.21
   8    *    @author Pavel Tzonkov <[email protected]>
   9    * @copyright 2010 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.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      this.initOpeners();
  29      this.initSettings();
  30      this.initContent();
  31      this.initToolbar();
  32      this.initResizer();
  33  };
  34  
  35  browser.checkAgent = function() {
  36      if (!$.browser.version ||
  37          ($.browser.msie && (parseInt($.browser.version) < 7) && !this.support.chromeFrame) ||
  38          ($.browser.opera && (parseInt($.browser.version) < 10)) ||
  39          ($.browser.mozilla && (parseFloat($.browser.version.replace(/^(\d+(\.\d+)?)([^\d].*)?$/, "$1")) < 1.8))
  40      ) {
  41          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>.';
  42          if ($.browser.msie)
  43              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.';
  44          html += '</div>';
  45          $('body').html(html);
  46          return false;
  47      }
  48      return true;
  49  };
  50  
  51  browser.initOpeners = function() {
  52      if (this.opener.TinyMCE && (typeof(tinyMCEPopup) == 'undefined'))
  53          this.opener.TinyMCE = null;
  54  
  55      if (this.opener.TinyMCE)
  56          this.opener.callBack = true;
  57  
  58      if ((!this.opener.name || (this.opener.name == 'fckeditor')) &&
  59          window.opener && window.opener.SetUrl
  60      ) {
  61          this.opener.FCKeditor = true;
  62          this.opener.callBack = true;
  63      }
  64  
  65      if (this.opener.CKEditor) {
  66          if (window.parent && window.parent.CKEDITOR)
  67              this.opener.CKEditor.object = window.parent.CKEDITOR;
  68          else if (window.opener && window.opener.CKEDITOR) {
  69              this.opener.CKEditor.object = window.opener.CKEDITOR;
  70              this.opener.callBack = true;
  71          } else
  72              this.opener.CKEditor = null;
  73      }
  74  
  75      if (!this.opener.CKFinder && !this.opener.FCKEditor && !this.TinyMCE) {
  76          if ((window.opener && window.opener.KCFinder && window.opener.KCFinder.callBack) ||
  77              (window.parent && window.parent.KCFinder && window.parent.KCFinder.callBack)
  78          )
  79              this.opener.callBack = window.opener
  80                  ? window.opener.KCFinder.callBack
  81                  : window.parent.KCFinder.callBack;
  82  
  83          if ((
  84                  window.opener &&
  85                  window.opener.KCFinder &&
  86                  window.opener.KCFinder.callBackMultiple
  87              ) || (
  88                  window.parent &&
  89                  window.parent.KCFinder &&
  90                  window.parent.KCFinder.callBackMultiple
  91              )
  92          )
  93              this.opener.callBackMultiple = window.opener
  94                  ? window.opener.KCFinder.callBackMultiple
  95                  : window.parent.KCFinder.callBackMultiple;
  96      }
  97  };
  98  
  99  browser.initContent = function() {
 100      $('div#folders').html(this.label("Loading folders..."));
 101      $('div#files').html(this.label("Loading files..."));
 102      $.ajax({
 103          type: 'GET',
 104          url: browser.baseGetData('init'),
 105          async: false,
 106          success: function(xml) {
 107              if (browser.errors(xml)) return;
 108              var dirWritable = xml.getElementsByTagName('files')[0].getAttribute('dirWritable');
 109              browser.dirWritable = (dirWritable == 'yes');
 110              var tree = xml.getElementsByTagName('tree')[0].getElementsByTagName('dir')[0];
 111              $('#folders').html(browser.buildTree(tree));
 112              browser.setTreeData(tree);
 113              browser.initFolders();
 114              var files = xml.getElementsByTagName('files')[0].getElementsByTagName('file');
 115              browser.loadFiles(files);
 116              browser.orderFiles();
 117          },
 118          error: function(request, error) {
 119              $('div#folders').html(browser.label("Unknown error."));
 120              $('div#files').html(browser.label("Unknown error."));
 121          }
 122      });
 123  };
 124  
 125  browser.initResizer = function() {
 126      var cursor = ($.browser.opera) ? 'move' : 'col-resize';
 127      $('#resizer').css('cursor', cursor);
 128      $('#resizer').drag('start', function() {
 129          $(this).css({opacity:'0.4', filter:'alpha(opacity:40)'});
 130          $('#all').css('cursor', cursor);
 131      });
 132      $('#resizer').drag(function(e) {
 133          var left = e.pageX - parseInt(_.nopx($(this).css('width')) / 2);
 134          left = (left >= 0) ? left : 0;
 135          left = (left + _.nopx($(this).css('width')) < $(window).width())
 136              ? left : $(window).width() - _.nopx($(this).css('width'));
 137          $(this).css('left', left);
 138      });
 139      var end = function() {
 140          $(this).css({opacity:'0', filter:'alpha(opacity:0)'});
 141          $('#all').css('cursor', '');
 142          var left = _.nopx($(this).css('left')) + _.nopx($(this).css('width'));
 143          var right = $(window).width() - left;
 144          $('#left').css('width', left + 'px');
 145          $('#right').css('width', right + 'px');
 146          _('files').style.width = $('#right').innerWidth() - _.outerHSpace('#files') + 'px';
 147          _('resizer').style.left = $('#left').outerWidth() - _.outerRightSpace('#folders', 'm') + 'px';
 148          _('resizer').style.width = _.outerRightSpace('#folders', 'm') + _.outerLeftSpace('#files', 'm') + 'px';
 149          browser.fixFilesHeight();
 150      };
 151      $('#resizer').drag('end', end);
 152      $('#resizer').mouseup(end);
 153  };
 154  
 155  browser.resize = function() {
 156      _('left').style.width = '25%';
 157      _('right').style.width = '75%';
 158      _('toolbar').style.height = $('#toolbar a').outerHeight() + "px";
 159      _('shadow').style.width = $(window).width() + 'px';
 160      _('shadow').style.height = _('resizer').style.height = $(window).height() + 'px';
 161      _('left').style.height = _('right').style.height =
 162          $(window).height() - $('#status').outerHeight() + 'px';
 163      _('folders').style.height =
 164          $('#left').outerHeight() - _.outerVSpace('#folders') + 'px';
 165      browser.fixFilesHeight();
 166      var width = $('#left').outerWidth() + $('#right').outerWidth();
 167      _('status').style.width = width + 'px';
 168      while ($('#status').outerWidth() > width)
 169          _('status').style.width = _.nopx(_('status').style.width) - 1 + 'px';
 170      while ($('#status').outerWidth() < width)
 171          _('status').style.width = _.nopx(_('status').style.width) + 1 + 'px';
 172      if ($.browser.msie && ($.browser.version.substr(0, 1) < 8))
 173          _('right').style.width = $(window).width() - $('#left').outerWidth() + 'px';
 174      _('files').style.width = $('#right').innerWidth() - _.outerHSpace('#files') + 'px';
 175      _('resizer').style.left = $('#left').outerWidth() - _.outerRightSpace('#folders', 'm') + 'px';
 176      _('resizer').style.width = _.outerRightSpace('#folders', 'm') + _.outerLeftSpace('#files', 'm') + 'px';
 177  };
 178  
 179  browser.fixFilesHeight = function() {
 180      _('files').style.height =
 181          $('#left').outerHeight() - $('#toolbar').outerHeight() - _.outerVSpace('#files') -
 182          (($('#settings').css('display') != "none") ? $('#settings').outerHeight() : 0) + 'px';
 183  };


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1