Sha256: aa374af2a1c483571820e6584e955b5bf193339c96f1d4b22dabdf77791676f3

Contents?: true

Size: 1 KB

Versions: 21

Compression:

Stored size: 1 KB

Contents

jQuery(function($) {
  var RE = /^data-stanza-(.+)/

  $('[data-stanza]').each(function(index) {
    var $this  = $(this),
        data   = $this.data(),
        params = {};

    $.each(this.attributes, function(i, attr) {
      var key = (RE.exec(attr.name) || [])[1]

      if (key) {
        params[key.replace('-', '_')] = attr.value;
      }
    });

    var src = data.stanza + '?' + $.param(params);


    setTimeout(function(){
      $("<iframe></iframe>")
        .addClass('unload')
        .attr({src: src, frameborder: 0, id: 'stanza-frame-' + index, name: 'stanza-frame-' + index})
        .width(data.stanzaWidth || '100%')
        .height(data.stanzaHeight)
        .appendTo($this)
        .load(function(){
          $(this).removeClass("unload");
        });
      }, index * 500);
  });

  window.onmessage = function(e) {
    var message = JSON.parse(e.data),
        iframe  = $('#' + message.id);

    if (iframe.attr('style').search(/height/) === -1) {
      iframe.height(message.height);
    }
  };
});

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
togostanza-1.0.5 assets/stanza.js