Support » Plugin: Stratus » Stratus dynamic iframe option idea

  • Resolved Deryll

    (@padreed123)


    I have recently been using the stratus player for some projects. It work great but if you don’t have an ajax site it won’t continuously play. I’ve been adding to the stratus script to make it dynamically replace the page content with iframes so that the player will keep playing while you browse the site(almost like smc player). The stratus script I’ve added to works but it wont follow links. I am having a hard time figuring it out so I thought you would be interested in helping finishing it and adding it as an option to your script. I think people would enjoy this option a lot.

    Heres what I’ve added:

    (function() {
      var $;
      $ = jQuery;
      (function($){var g,d,j=1,a,b=this,f=!1,h="postMessage",e="addEventListener",c,i=b[h]&&!$.browser.opera;$[h]=function(k,l,m){if(!l){return}k=typeof k==="string"?k:$.param(k);m=m||parent;if(i){m[h](k,l.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))}else{if(l){m.location=l.replace(/#.*$/,"")+"#"+(+new Date)+(j++)+"&"+k}}};$.receiveMessage=c=function(l,m,k){if(i){if(l){a&&c();a=function(n){if((typeof m==="string"&&n.origin!==m)||($.isFunction(m)&&m(n.origin)===f)){return f}l(n)}}if(b[e]){b[l?e:"removeEventListener"]("message",a,f)}else{b[l?"attachEvent":"detachEvent"]("onmessage",a)}}else{g&&clearInterval(g);g=null;if(l){k=typeof m==="number"?m:typeof k==="number"?k:100;g=setInterval(function(){var o=document.location.hash,n=/^#?\d+&/;if(o!==d&&n.test(o)){d=o;l({data:o.replace(n,"")})}},k)}}}})(jQuery);;
      $.fn.stratus = function(settings) {
        return $.stratus(settings);
      };
      $.stratus = function(settings) {
        var root_url, src;
        root_url = settings.env === 'development' ? 'http://example.com:3000' : 'http://stratus.sc';
        $('head').append("<link rel='stylesheet' href='" + root_url + "/stratus.css' type='text/css'/>");
        if (settings.align === 'top') {
          $('head').append("<style>#stratus{ top: 0; }</style>");
        }
        if (settings.position === 'absolute') {
          $('head').append("<style>#stratus{ position: absolute; }</style>");
        }
        if (settings.offset) {
          $('head').append("<style>#stratus{ " + settings.align + ": " + settings.offset + "px !important; }</style>");
        }
    
    		// create raw frame
    		var frame = $('<iframe id="contentframe" style="height: 100%;width: 100%;bottom: 0;left: 0;position: absolute;right: 0;top: 0;z-index: 1;" allowtransparency="true" frameborder="0" scrolling="0"><html></html></iframe>');
    
    		// store a copy of current document contents
    		var copiedHead = $('head').clone();
    		var copiedBody = $('body').clone();
    
    		// empty the current document
    		$(':not(iframe) head *').remove();
    		$(':not(iframe) body *').remove();
    
    		// load the copy into the frame;
    		// it's not possible to replace the whole HTML element;
    		// using plain JS DOM function here, since jQuery would strip out any SCRIPT and STYLE tags
    		frame.load(function(){
    			$(this).contents().find('html')[0].replaceChild(copiedHead[0] , $(this).contents().find('head')[0]);
    			$(this).contents().find('html')[0].replaceChild(copiedBody[0] , $(this).contents().find('body')[0]);
    		}).appendTo('body');
    
    		$('body').append("<iframe id='stratus' style='height: 50px;width: 100%;bottom: 0;left: 0;position: absolute;right: 0;z-index: 99;' allowtransparency='true' frameborder='0' scrolling='0'>");
    
    		src = root_url + '/player?' + $.param(settings, true) + '&link=' + encodeURIComponent(document.location.href);
    	$('iframe#stratus').attr({
    	  src: src
    	});
    	$('a#contentframe').click(function() {
          $.postMessage($(this).attr('href'), src, $('iframe#contentframe')[0].contentWindow);
          return false;
        });
    
        $('iframe#stratus').load(function() {
          return $(this).css({
            visibility: 'visible'
          });
        });
        $('#stratus').show();
        $('a#stratus').click(function() {
          $.postMessage($(this).attr('href'), src, $('iframe#stratus')[0].contentWindow);
          return false;
        });
        return $.receiveMessage(function(e) {
          return $('#stratus').toggleClass('open');
        }, root_url);
      };
    }).call(this);b

    http://wordpress.org/extend/plugins/stratus/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Stratus dynamic iframe option idea’ is closed to new replies.