Re: mediaconfig.js

From disqus.com, 2 Months ago, written in JavaScript, viewed 3 times. This paste is a reply to Re: forum.js from disqus.com - view diff
URL https://pastebin.freepbx.org/view/ce001f85 Embed
Download Paste or View Raw
  1. define('core/mediaConfig',[
  2.     'underscore',
  3.     'backbone',
  4. ], function (
  5.     _,
  6.     Backbone
  7. ) {
  8.     'use strict';
  9.  
  10.     var MEDIA_PERSISTED_WIDTHS = [320, 480, 600, 800];
  11.  
  12.     // Calculates closest thumbnail width based on available
  13.     // width (document.body.offsetWidth) and caches this value
  14.     // for future use by PostView.
  15.     function findClosestThumbnailSize() {
  16.         var width = window.document.body.offsetWidth;
  17.  
  18.         // get closest image width we have to @width argument
  19.         var thumbnailsWidths = MEDIA_PERSISTED_WIDTHS;
  20.         var len = thumbnailsWidths.length;
  21.  
  22.         return _.find(thumbnailsWidths, function (__, i) {
  23.             return (i + 1 === len) ||
  24.                 (Math.abs(thumbnailsWidths[i + 1] - width) > Math.abs(thumbnailsWidths[i] - width));
  25.         });
  26.     }
  27.  
  28.     var config = new Backbone.Model({
  29.         collapsed: false,
  30.  
  31.         defaultIframeHeight: 300,
  32.         mediaPersistedWidths: MEDIA_PERSISTED_WIDTHS,
  33.  
  34.         loadedThumbnailWidth: findClosestThumbnailSize(),
  35.     });
  36.  
  37.     // for testing
  38.     config.findClosestThumbnailSize = findClosestThumbnailSize;
  39.  
  40.     return config;
  41. });
  42.  
  43. // https://c.disquscdn.com/next/next-core/core/mediaConfig.js

Replies to Re: mediaconfig.js rss

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

Reply to "Re: mediaconfig.js"

Here you can reply to the paste above