Re: Re: Iframe.js.js

From disqus.com, 2 Months ago, written in JavaScript, viewed 3 times. This paste is a reply to Re: exploreModuleConstants.js.js from disqus.com - view diff
URL https://pastebin.freepbx.org/view/5c76839f Embed
Download Paste or View Raw
  1. define('core/common/kernel/Iframe',['require','core/utils/html/setInlineStyle','core/utils/object/extend','core/common/kernel/WindowBase','core/common/kernel/utils'],function (require) {
  2.     'use strict';
  3.  
  4.     var setInlineStyle = require('core/utils/html/setInlineStyle');
  5.     var extend = require('core/utils/object/extend');
  6.  
  7.     var WindowBase = require('core/common/kernel/WindowBase');
  8.     var utils = require('core/common/kernel/utils');
  9.  
  10.     var document = window.document;
  11.  
  12.     //
  13.     // Iframe
  14.     //
  15.     // Base iframe wrapper class. Inherited by Channel and Sandbox.
  16.     //
  17.  
  18.     var Iframe = function (opts) {
  19.         WindowBase.call(this, opts);
  20.  
  21.         this.styles = opts.styles || {};
  22.         this.tabIndex = opts.tabIndex || 0;
  23.         this.title = opts.title || 'Disqus';
  24.         this.sandbox = opts.sandbox;
  25.  
  26.         // The element that contains this iframe
  27.         this.container = opts.container;
  28.         this.elem = null;  // The iframe element
  29.     };
  30.  
  31.     extend(Iframe.prototype, WindowBase.prototype);
  32.  
  33.     Iframe.prototype.load = function () {
  34.         var elem = this.elem = document.createElement('iframe');
  35.  
  36.         elem.setAttribute('id', this.uid);
  37.         elem.setAttribute('name', this.uid);
  38.         elem.setAttribute('allowTransparency', 'true'); // < IE8 iframe transparency
  39.         elem.setAttribute('frameBorder', '0');
  40.         elem.setAttribute('scrolling', 'no');
  41.  
  42.         // This part is for accessibility
  43.         if (this.role)
  44.             elem.setAttribute('role', this.role);
  45.         elem.setAttribute('tabindex', this.tabIndex);
  46.         elem.setAttribute('title', this.title);
  47.  
  48.         // An empty string is valid for the `sandbox` attribute
  49.         if (typeof this.sandbox === 'string')
  50.             elem.setAttribute('sandbox', this.sandbox);
  51.  
  52.         this.setInlineStyle(this.styles);
  53.     };
  54.  
  55.     Iframe.prototype.getOffset = function (container) {
  56.         return utils.getOffset(this.elem, container);
  57.     };
  58.  
  59.     // Utility method for setting an inline style on the frame.
  60.     // Automatically gives all styles '!important' precedence,
  61.     // in order to reduce CSS conflicts with the parent page.
  62.     //
  63.     // Translation: if you don't use this function to set inline
  64.     // styles, you WILL get hosed by publisher styles. Use it!
  65.     //
  66.     // Usage:
  67.     //    frame.setInlineStyle('height', '500px');
  68.     //    frame.setInlineStyle({ height: '500px', display: 'block' });
  69.     //
  70.     // WARNING:
  71.     // DOM-modifying function
  72.     // Does NOT escape inputs
  73.     // XSS hazard
  74.     //
  75.     // This function does not escape inputs; therefore if you pass outside
  76.     // inputs into this function, you open up the code to an XSS attack
  77.     // via CSS.
  78.     //
  79.     // Do NOT pass unknown values into this function!
  80.     Iframe.prototype.setInlineStyle = function (prop, value) {
  81.         return setInlineStyle(this.elem, prop, value);
  82.     };
  83.  
  84.     Iframe.prototype.removeInlineStyle = function (prop) {
  85.         var style = this.elem.style;
  86.         if ('removeProperty' in style)
  87.             return void style.removeProperty(prop);
  88.  
  89.         style[prop] = '';
  90.     };
  91.  
  92.     Iframe.prototype.hide = function () {
  93.         this.setInlineStyle('display', 'none');
  94.     };
  95.  
  96.     Iframe.prototype.show = function () {
  97.         this.removeInlineStyle('display');
  98.     };
  99.  
  100.     Iframe.prototype.destroy = function () {
  101.         if (this.elem && this.elem.parentNode) {
  102.             this.elem.parentNode.removeChild(this.elem);
  103.             this.elem = null;
  104.         }
  105.  
  106.         return WindowBase.prototype.destroy.call(this);
  107.     };
  108.  
  109.     return Iframe;
  110. });
  111.  
  112. // https://c.disquscdn.com/next/next-core/core/common/kernel/Iframe.js

Replies to Re: Re: Iframe.js.js rss

Title Name Language When
Re: Re: Iframe.js disqus.com javascript 2 Months ago.

Reply to "Re: Re: Iframe.js.js"

Here you can reply to the paste above