src/cm/media/js/site/f_text_view_frame.js
changeset 59 8a2d933209aa
parent 0 40c8f766c9b8
child 103 61fd17f9ab78
equal deleted inserted replaced
58:a480a91d63ca 59:8a2d933209aa
   302 		}
   302 		}
   303 	});
   303 	});
   304 	
   304 	
   305 	if (frames['text_view_comments'].gLayout.isInComentSite()) {
   305 	if (frames['text_view_comments'].gLayout.isInComentSite()) {
   306 		$("#c_fullscreen_btn").click( function() {
   306 		$("#c_fullscreen_btn").click( function() {
   307 				top.v_toggleFrameSize();
   307 				toggleFrameSize();
   308 		});
   308 		});
   309 	} ;	
   309 	} ;	
   310 	
   310 	
   311 	$("#c_advanced_btn").click( function() {
   311 	$("#c_advanced_btn").click( function() {
   312 		$('.ui-layout-toggler').click() ; // calling the layout method did not work well edo that instead		
   312 		$('.ui-layout-toggler').click() ; // calling the layout method did not work well edo that instead		
   735 }
   735 }
   736 
   736 
   737 f_setCookie = function(name, value) {
   737 f_setCookie = function(name, value) {
   738 	_setCookie(name, value) ;
   738 	_setCookie(name, value) ;
   739 }
   739 }
       
   740 
       
   741 
       
   742 
       
   743 /*****************************************************************************/
       
   744 
       
   745 
       
   746 gInFullScreen = false;
       
   747 
       
   748 _setFrameSize = function() {
       
   749 	if (gInFullScreen) {
       
   750 		var headerHeight = parent.$("#header").height();
       
   751 		var windowHeight = parent.$(parent).height();
       
   752 		var frameHeight = (windowHeight - headerHeight - 2) + 'px'; // - 2 to prevent scrollbars ? --> TODO test it without -2
       
   753 
       
   754 		var windowWidth = parent.$(parent).width();
       
   755 		var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ?// --> TODO test it without -2
       
   756 
       
   757 		// TODO we should be embeded ! shouldn't work otherwise anyway (frame security concerns)
       
   758 		parent.$("#text_view_frame").css( {
       
   759 			'position' :'absolute',
       
   760 			'left' :'0px',
       
   761 			'top' :headerHeight,
       
   762 			'width' :frameWidth,
       
   763 			'height' :frameHeight
       
   764 		});
       
   765 	}
       
   766 	else {
       
   767 		var frameTop = Math.ceil(parent.$("#autoexpand_text_view_frame_container").position()["top"]);
       
   768 
       
   769 		var windowHeight = parent.$(parent).height();
       
   770 		var frameHeight = (windowHeight - frameTop - 2) + 'px'; // - 2 to prevent scrollbars // ? --> TODO test it without -2
       
   771 		
       
   772 		var windowWidth = parent.$(parent).width();
       
   773 		var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ? // --> TODO test it without -2
       
   774 
       
   775 		// TODO test if we're embeded ! wont work otherwise anyway (frame security)
       
   776 		parent.$("#text_view_frame").css( {
       
   777 			'position' :'relative',
       
   778 			'width' :'99.9%',
       
   779 			'height' :frameHeight,
       
   780 			'top' :'0px'
       
   781 		});
       
   782 	}
       
   783 }
       
   784 _toFullScreenSize = function() {
       
   785 	gInFullScreen = true;
       
   786 	_setFrameSize() ;
       
   787 
       
   788 	$("#c_fullscreen_btn").attr('src', sv_media_url + '/img/arrow_in.png');
       
   789 
       
   790 	f_setCookie('fullscreen', '1') ;
       
   791 };
       
   792 
       
   793 _toNormalSize = function() {
       
   794 	gInFullScreen = false;
       
   795 	_setFrameSize() ;
       
   796 
       
   797 	$("#c_fullscreen_btn").attr('src', sv_media_url + 'img/arrow_out.png');
       
   798 	
       
   799 	f_setCookie('fullscreen', '0') ;
       
   800 };
       
   801 
       
   802 _toInitialSize = function() {
       
   803 	//console.info('_toInitialSize') ; 
       
   804 	var fullscreen = ($.cookie('fullscreen') == '1');
       
   805 	if (fullscreen)
       
   806 		_toFullScreenSize() ;
       
   807 	else 
       
   808 		_toNormalSize() ;
       
   809 };
       
   810 
       
   811 toInitialSize = function() {
       
   812 	_toInitialSize() ;
       
   813 	parent.$(parent).resize(function(){
       
   814 //		console.log('before setFramesize in top resize winwidth' + 	frames['text_view_comments'].CY.DOM.winWidth()) ;
       
   815 		_setFrameSize();
       
   816 //		console.log('after setFramesize in top resize winwidth' + 	frames['text_view_frame'].frames['text_view_comments'].CY.DOM.winWidth()) ;
       
   817 	});
       
   818 }
       
   819 
       
   820 toggleFrameSize = function() {
       
   821 	if (gInFullScreen)
       
   822 		_toNormalSize() ;
       
   823 	else 
       
   824 		_toFullScreenSize() ;
       
   825 }
       
   826