[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-messages/js/autocomplete/ -> jquery.bgiframe.js (source)

   1  /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
   2   * Licensed under the MIT License (LICENSE.txt).
   3   *
   4   * Version 3.0.1
   5   *
   6   * Requires jQuery >= 1.2.6
   7   */
   8  
   9  (function (factory) {
  10      if (typeof define === 'function' && define.amd) {
  11          // AMD. Register as an anonymous module.
  12          define(['jquery'], factory);
  13      } else if (typeof exports === 'object') {
  14          // Node/CommonJS style for Browserify
  15          module.exports = factory;
  16      } else {
  17          // Browser globals
  18          factory(jQuery);
  19      }
  20  }(function ($) {
  21      $.fn.bgiframe = function(s) {
  22          s = $.extend({
  23              top         : 'auto', // auto == borderTopWidth
  24              left        : 'auto', // auto == borderLeftWidth
  25              width       : 'auto', // auto == offsetWidth
  26              height      : 'auto', // auto == offsetHeight
  27              opacity     : true,
  28              src         : 'javascript:false;',
  29              conditional : /MSIE 6\.0/.test(navigator.userAgent) // expresion or function. return false to prevent iframe insertion
  30          }, s);
  31  
  32          // wrap conditional in a function if it isn't already
  33          if (!$.isFunction(s.conditional)) {
  34              var condition = s.conditional;
  35              s.conditional = function() { return condition; };
  36          }
  37  
  38          var $iframe = $('<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
  39                             'style="display:block;position:absolute;z-index:-1;"/>');
  40  
  41          return this.each(function() {
  42              var $this = $(this);
  43              if ( s.conditional(this) === false ) { return; }
  44              var existing = $this.children('iframe.bgiframe');
  45              var $el = existing.length === 0 ? $iframe.clone() : existing;
  46              $el.css({
  47                  'top': s.top == 'auto' ?
  48                      ((parseInt($this.css('borderTopWidth'),10)||0)*-1)+'px' : prop(s.top),
  49                  'left': s.left == 'auto' ?
  50                      ((parseInt($this.css('borderLeftWidth'),10)||0)*-1)+'px' : prop(s.left),
  51                  'width': s.width == 'auto' ? (this.offsetWidth + 'px') : prop(s.width),
  52                  'height': s.height == 'auto' ? (this.offsetHeight + 'px') : prop(s.height),
  53                  'opacity': s.opacity === true ? 0 : undefined
  54              });
  55  
  56              if ( existing.length === 0 ) {
  57                  $this.prepend($el);
  58              }
  59          });
  60      };
  61  
  62      // old alias
  63      $.fn.bgIframe = $.fn.bgiframe;
  64  
  65      function prop(n) {
  66          return n && n.constructor === Number ? n + 'px' : n;
  67      }
  68  
  69  }));


Generated: Fri Apr 26 01:01:11 2024 Cross-referenced by PHPXref 0.7.1