팝업 프린트 후 창 자동 닫기

Open API/그 외 |2018.09.14 11:05

modal 팝업 , 일반 팝업 , 레이어 팝업 등등..온갖 팝업이 난무하는데


프린트하기가 너무 힘든 상황 통합으로 사용하기 위해서 방법을 찾아봤습니다.


어떤 경우 어떤 브라우저 버전에서는 


window.print() 후 window.close() 하면 


프린트 창이 뜨기도 전에 창이 닫히는 상황이 발생하기도하고..


포인트는 출력 후 onfocus 되었을때 창을 닫는다는 것.


최종 적으로는 아래 글에서 내용을 찾아서 처리했습니다.


여러 상황에 히스토리를 갖고 수정방법이 나열되어있습니다.


https://code-examples.net/en/q/6294d6


var content = "Hello";


newWin= window.open();

newWin.document.open();

newWin.document.write(content);

newWin.document.close();

setTimeout(function(){

	newWin.print();

	newWin.onfocus=function(){ newWin.close();}

},500);




태그 : onfucus, 닫기, 팝업

댓글()

modal 팝업창에서 datepicker 사용 시 연도 월 Select box가 열리지 않는 문제 해결 방법

Open API/Jquery|2017.09.18 13:51


Bootstrap modal 팝업창에서 datepicker 사용 시 


changeMonth , changeYear 옵션을 true 로 사용할 경우 정상적으로 펼쳐지지 않고


바로 닫히는 버그가 있는데 꽤 오래된 상황임에도 업데이트가 되어지지 않고 있습니다.




하지만,  역시 스택오버플로우 


https://stackoverflow.com/questions/22050641/month-select-in-datepicker-inside-a-bootstrap-modal-wont-work-in-firefox


해결 방안을 제시해줍니다.


$('#modal').on('show', function () {
    $.fn.modal.Constructor.prototype.enforceFocus = function () { };
});




위와 같이 Show 혹은 modal 팝업 활성화 이후에

    $.fn.modal.Constructor.prototype.enforceFocus = function () { };

위와 같은 코딩을 실행해주면 정상적으로 연도 및 월 변경이 가능합니다.


댓글()

jQuery fancyBox - 레이어팝업

Open API/Jquery|2016.11.01 10:14




plugin Url & Download : http://fancybox.net/


샘플코드 다운로드 :   521.zip



라이센스.

http://fancyapps.com/fancybox/#license  2016.11.01 일 기준.


fancyBox licensed under Creative Commons Attribution-NonCommercial 3.0 license. 

You are free to use fancyBox for your personal or non-profit website projects. 

You can get the author's permission to use fancyBox for commercial websites by paying a fee.

----

개인 혹은 비영리사이트만 공짜...

이점 유의 (싱글 도메인 $19 / 멀티 도메인 $89)


- swf , iframe , image , youtube , Googlemap 등 팝업 플러그인.


 
NameDescription
paddingSpace inside fancyBox around content. Can be set as array - [top, right, bottom, left].
Integer, Array; Default value: 15
marginMinimum space between viewport and fancyBox. Can be set as array - [top, right, bottom, left]. Right and bottom margins are ignored if content dimensions exceeds viewport
Integer, Array; Default value: 20
widthDefault width for 'iframe' and 'swf' content. Also for 'inline', 'ajax' and 'html' if 'autoSize' is set to 'false'. Can be numeric or 'auto'.
Number, String; Default value: 800
heightDefault height for 'iframe' and 'swf' content. Also for 'inline', 'ajax' and 'html' if 'autoSize' is set to 'false'. Can be numeric or 'auto'
Number, String; Default value: 600
minWidthMinimum width fancyBox should be allowed to resize to
Number; Default value: 100
minHeightMinimum height fancyBox should be allowed to resize to
Number; Default value: 100
maxWidthMaximum width fancyBox should be allowed to resize to
Number; Default value: 9999
maxHeightMaximum height fancyBox should be allowed to resize to
Number; Default value: 9999
autoSizeIf true, then sets both autoHeight and autoWidth to true
Boolean; Default value: true
autoHeightIf set to true, for 'inline', 'ajax' and 'html' type content width is auto determined. If no dimensions set this may give unexpected results
Boolean; Default value: false
autoWidthIf set to true, for 'inline', 'ajax' and 'html' type content height is auto determined. If no dimensions set this may give unexpected results
Boolean; Default value: false
autoResizeIf set to true, the content will be resized after window resize event
Boolean; Default value: !isTouch
autoCenterIf set to true, the content will always be centered
Boolean; Default value: !isTouch
fitToViewIf set to true, fancyBox is resized to fit inside viewport before opening
Boolean; Default value: true
aspectRatioIf set to true, resizing is constrained by the original aspect ratio (images always keep ratio)
Boolean; Default value: false
topRatioTop space ratio for vertical centering. If set to 0.5, then vertical and bottom space will be equal. If 0 - fancyBox will be at the viewport top
Number; Default value: 0.5
leftRatioLeft space ratio for horizontal centering. If set to 0.5, then left and right space will be equal. If 0 - fancyBox will be at the viewport left
Number; Default value: 0.5
scrollingSet the overflow CSS property to create or hide scrollbars. Can be set to 'auto', 'yes', 'no' or 'visible'
String; Default value: 'auto'
wrapCSSCustomizable CSS class for wrapping element (useful for custom styling)
string; Default value:
arrowsIf set to true, navigation arrows will be displayed
Boolean; Default value: true
closeBtnIf set to true, close button will be displayed
Boolean; Default value: true
closeClickIf set to true, fancyBox will be closed when user clicks the content
Boolean; Default value: false
nextClickIf set to true, will navigate to next gallery item when user clicks the content
Boolean; Default value: false
mouseWheelIf set to true, you will be able to navigate gallery using the mouse wheel
Boolean; Default value: true
autoPlayIf set to true, slideshow will start after opening the first gallery item
Boolean; Default value: false
playSpeedSlideshow speed in milliseconds
Integer; Default value: 3000
preloadNumber of gallery images to preload
Integer; Default value: 3
modalIf set to true, will disable navigation and closing
Boolean; Default value: false
loopIf set to true, enables cyclic navigation. This means, if you click "next" after you reach the last element, first element will be displayed (and vice versa).
Boolean; Default value: true
ajaxOptions for ajax request
Object; Default value:
{
	dataType : 'html',
	headers  : { 'X-fancyBox': true }
}
iframeOptions for content type "iframe"
Object; Default value:
{
	scrolling : 'auto',
	preload   : true
}
swfOptions for content type "swf"
Object; Default value:
{
	wmode: 'transparent',
	allowfullscreen   : 'true',
	allowscriptaccess : 'always'
}
keysDefine keyboard keys for gallery navigation, closing and slideshow
Object; Default value:
{
	next : {
		13 : 'left', // enter
		34 : 'up',   // page down
		39 : 'left', // right arrow
		40 : 'up'    // down arrow
	},
	prev : {
		8  : 'right',  // backspace
		33 : 'down',   // page up
		37 : 'right',  // left arrow
		38 : 'down'    // up arrow
	},
	close  : [27], // escape key
	play   : [32], // space - start/stop slideshow
	toggle : [70]  // letter "f" - toggle fullscreen
}
directionDefault navigation direction (for navigation arrows, too)
Object; Default value:
{
	{
		next : 'left',
		prev : 'right'
	}
}
scrollOutsideIf true, the script will try to avoid horizontal scrolling for iframes and html content
Boolean; Default value: true
indexOverrides group start index
Integer; Default value: 0
typeOverrides type for content. Supported types are 'image', 'inline', 'ajax', 'iframe', 'swf' and 'html'
String; Default value: null
hrefOverrides content source link
String; Default value: null
contentOverrides content to be displayed
String; Default value: null
titleOverrides title content, accepts any HTML
String; Default value: null
tplObject containing various templates
Object; Default value:
{
	wrap     : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
	image    : '<img class="fancybox-image" src="{href}" alt="" />',
	iframe   : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0"' + ($.browser.msie ? ' allowtransparency="true"' : '') + '></iframe>',
	error    : '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
	closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
	next     : '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
	prev     : '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
}
openEffect / closeEffect / nextEffect / prevEffectAnimation effect ('elastic', 'fade' or 'none') for each transition type
String; Default value: 'fade', 'fade', 'elastic', 'elastic'
openSpeed / closeSpeed / nextSpeed / prevSpeedThe time it takes (in ms, or "slow", "normal", "fast") to complete transition
Integer; Default value: 250
openEasing / closeEasing / nextEasing / prevEasingEasing method for each transition type. You have numerous choices if easing plugin is included
String; Default value: 'swing'
openOpacity / closeOpacityIf set to true, transparency is changed for elastic transitions
Boolean; Default value: true
openMethod / closeMethod / nextMethod / prevMethodMethod from $.fancybox.transitions() that handles transition (you can add custom effects there)
String; Default value: 'zoomIn' / 'zoomOut' / 'changeIn' / 'changeOut'
helpersObject containing enabled helpers and options for each of them
Object; Default value:
{
	overlay : {
		closeClick : true,  // if true, fancyBox will be closed when user clicks on the overlay
		speedOut   : 200,   // duration of fadeOut animation
		showEarly  : true,  // indicates if should be opened immediately or wait until the content is ready
		css        : {},    // custom CSS properties
		locked     : true   // if true, the content will be locked into overlay
	},
	title : {
		type : 'float' // 'float', 'inside', 'outside' or 'over'
	}
}
liveIf set to true, fancyBox uses "live" to assign click event. Set to "false", if you need to apply only to current collection, e.g., if using something like -
$("#page").children().filter('a').eq(0).fancybox();

Boolean; Default value: true
parentParent element of the container. This is useful for ASP.NET where the top element is "form" -
$(".fancybox").fancybox({
    parent: "form:first" // jQuery selector
});

String; Default value: body

 
NameDescription
open

$.fancybox.open( [group], [options] )

Launch fancyBox, the same as $.fancybox([group], [options]) 
First parameter can be in various types, examples: 
$.fancybox([ {href : 'img1.jpg', title : 'Title'}, {href : 'img2.jpg', title : 'Title'} ]); - array containing objects 
$.fancybox( {href : 'image.jpg', title : 'Lorem lipsum'} ); - single object 
$.fancybox( ['image.jpg', 'image.jpg'] ); - array containing links as strings
$.fancybox( 'image.jpg' ); - string as source link 
$.fancybox( [jQuery object] ); 
$.fancybox( '<h1>Lorem lipsum</h1>' );
cancel

$.fancybox.cancel()

Cancel loading image or abort ajax request
close

$.fancybox.close( [force] )

If fancyBox is fully opened (open animation has ended) then start closing animation. If not or closing is forced (e.g. called like $.fancybox.close( true )) than fancyBox is removed immediatly
play

$.fancybox.play()

Start or stop (if already running) slideshow
next

$.fancybox.next()

Navigate to next gallery item
prev

$.fancybox.prev()

Navigate to previous gallery item
jumpto

$.fancybox.jumpto( [index] )

Navigate to gallery item by index. Item counting starts from 0, e.g. $.fancybox.jumpto( 0 ); will open the first, e.g. $.fancybox.jumpto( 1 ); will second, etc
reposition

$.fancybox.reposition()

Will center fancyBox inside viewport and toggle position type to fixed or absolute if needed
update

$.fancybox.update()

Auto-sizes fancyBox height to match height of content
toggle

$.fancybox.toggle()

If content is resized to fit inside viewport than it will be expanded to full size (and vice verse)
showLoading

$.fancybox.showLoading()

Shows loading animation
hideLoading

$.fancybox.hideLoading()

Hides loading animation


 
NameDescription
onCancelCalled after user triggers canceling. 
Note: If false is returned by the callback, the canceling will be halted
beforeLoadCalled before starting to load content. 
Note: If false is returned by the callback, the loading will be halted
afterLoadCalled after content is loaded. Receives two arguments - upcoming and current object - http://jsfiddle.net/xW5gs/ 
Note: If false is returned by the callback, the content will not be shown.
beforeShowCalled right before open animations has started
afterShowCalled after open animations has ended
beforeCloseCalled right after closing has been triggered but not yet started 
Note: If false is returned by the callback, the closing will be halted.
afterCloseCalled after closing animation has ended
onUpdateCalled after window resize, scroll or orientation change events are triggered
onPlayStartCalled after slideshdow has started
onPlayEndCalled after slideshdow has stoped




 


 







댓글()