태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

롸이언의 인생이야기 @ Innovate yourself ™

'javascripit'에 해당되는 글 2건

  1. 2008/08/17 WinXP Progress Bar (version 1.2)
  2. 2008/06/18 Lightbox JS

WinXP Progress Bar (version 1.2)

Description: A great looking pure DHTML progress bar that resembles the one seen in Window XP's startup screen. All visual aspects of the bar can be customized, and the script can be invoked multiple times to display multiple bars on the same page. Script works in both IE5+ and NS6+.

Note that this script by default doesn't perform any action other than animating the progress bar. It's up to you to create helper functions to accomplish any relevant tasks.

Demo:


Directions: Developer's View

Step 1: Insert the following script in the HEAD section of your page

Select All

The above script references an external .js file, which you can download below:

xp_progress.js (download by right clicking, and selecting "Save As")

Be sure to upload this .js file to your web server.

Step 2: Within the BODY of your page where you wish the Progress Bar to appear, add the below script:

<script type="text/javascript">
var bar1= createBar(300,15,'white',1,'black','blue',85,7,3,"");
</script>

That's it! Read on for an explanation of each parameter within function createBar().

Explanation of parameters within createBar()

To customize the look of the progress bar, simply pass in different values into createBar():

var xyz = createBar(width, height, backgroundColor, borderWidth, borderColor, blockColor, scrollSpeed, blockCount, actionCount, actionString)

 They are:

  • xyz - An arbitrary variable name to store the bar reference and must be unique. This variable will have a few different methods (explained later) which can be used to control some of each bar's behavior. This variable IS REQUIRED if you wish to use these methods. However, if you do not plan to use the methods, then the variable assignment is not necessary, but it won't hurt to use it anyway.
  • width- Total width of the entire bar in pixels.
  • height- Total height of the entire bar in pixels.
  • backgroundColor- Background color of the bar. Use valid CSS color or HEX color code value.
  • borderWidth- The width of the border around the bar, in pixels.
  • borderColor- The color of the border around the bar. Use valid CSS color or HEX color code value.
  • blockColor- The darkest color of the individual blocks. The color will progressively become more transparent. Use valid CSS color or HEX color code value.
  • scrollSpeed- The delay, in milliseconds, between each scroll step. Use smaller values for faster scroll speeds.
  • blockCount- The total number of blocks to use.
  • actionCount - The number of times the bar is to scroll before actionString is performed.
  • actionString - The javascript function, in string form, to execute once the bar has scrolled actionCount times. Set this to an empty string to do nothing. If doing nothing, you can use any number as actionCount.

So for example, by changing the parameter settings, you can display a different looking Progress Bar, and one that executes a function after the Progress Bar has scrolled 3 cycles:

<script type="text/javascript">
var bar2= createBar(320,15,'white',1,'black','green',85,7,3,"alert('Hi there')");
</script>

(alert message disabled in actual demo).

Explanation of methods() to control the progress bar

Each bar, when assigned to a variable (ie: bar2) has several control methods you can call directly via javascript or in a link. These methods allow you to do things like pause the Progress Bar, hide or reveal it. Each of these is described below, along with an example which will control the bar above.

Method Example Description
var.toggleBar() toggle pause This method will toggle the pause status of the bar. If it is paused, it will un-pause it, and vice-versa. The code for the link at left is:
<a href="javascript:bar2.togglePause()">toggle pause</a>
var.hideBar() Hide Bar 2 This method will show the bar. If it is already visible, it will do nothing. The code for the link at left is:
<a href="javascript:bar2.hideBar()">Hide Bar 2</a>
var.showBar() Show Bar 2 This method will hide the bar. If it is already hidden, it will do nothing. The code for the link at left is:
<a href="javascript:bar2.showBar()">Show Bar 2</a>

Try clicking the links in the middle column to see how it affects the green Progress Bar.

Just in case you're confused how all this fits together, here's an example that scrolls a Progress Bar for 5 cycles before pausing and redirects to another page:

<script type="text/javascript">

function redirectpage(){
bar3.togglePause()
window.location="http://www.javascriptkit.com"
}

var bar3= createBar(320,15,'white',1,'black','red',85,7,5,"redirectpage()");
</script>
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 롸이언
공부 이야기/컴퓨터 몽땅 l 2008/08/17 16:51

Overview

Lightbox JS is a simple, unobtrusive script used to overlay images on the current page. It's a snap to setup and works on all modern browsers.

Note: An new version of this script is available: Lightbox JS v2.0

Example

To make sense of it all, check out these examples. Click on a thumbnail or text link below:

Benefits

Places images above your current page, not within. This frees you from the constraints of the layout, particularly column widths.

Keeps users on the same page. Clicking to view an image and then having to click the back button to return to your site is bad for continuity (and no fun!).

How to Use:

  1. Include lightbox.js in your header.
    <script type="text/javascript" src="lightbox.js"></script>
    
  2. Add rel="lightbox" attribute to any link tag to activate the lightbox. For example:
    <a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
    
    Optional: Use the title attribute if you want to show a caption.

Customizing:

  1. You can use CSS to style the image container. Here is the code used in the examples above:
    #lightbox{
    	background-color:#eee;
    	padding: 10px;
    	border-bottom: 2px solid #666;
    	border-right: 2px solid #666;
    	}
    #lightboxDetails{
    	font-size: 0.8em;
    	padding-top: 0.4em;
    	}	
    #lightboxCaption{ float: left; }
    #keyboardMsg{ float: right; }
    
    #lightbox img{ border: none; } 
    #overlay img{ border: none; }
  2. To create the 'shadow' effect over the page, you'll need to use a PNG file and some extra CSS. The CSS is a bit messy thanks to IE's unorthodox support of PNG transparency:
    #overlay{ background-image: url(overlay.png); }
    
    * html #overlay{
    	background-color: #000;
    	back\ground-color: transparent;
    	background-image: url(blank.gif);
    	filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="overlay.png", sizingMethod="scale");
    	}
  3. If you would like to show the user a 'loading' graphic, like the animated progress bar in the examples above, specify its location at the top of the lightbox.js file.
    var loadingImage = 'loading.gif';
  4. In the same vein, if you would like to use a 'close button', like the 'X' graphic in the examples above, specify its location at the top of the lightbox.js file.
    var closeButton = 'close.gif';	

Download:

Changelog:

1/19/06 10:40PM EST - Added keypress activated closing.
1/15/06 12:50PM EST - Added optional 'close' button.
1/10/06 10:30PM EST - Added support for captions.
12/31/05 6:00PM EST - Fixed IE6 bugs.

Modifications:

Troubleshooting:

It doesn't work at all. The image opens up in a new window.
This is commonly caused by a conflict between JS scripts. Check your body tag and look for an onload attribute. Example:
<body onload="MM_preloadImages(‘/images/menu_on.gif’)…;">
A quick fix to this problem is to append the initLightbox() to the onload attribute as so:
<body onload="MM_preloadImages(‘/images/menu_on.gif’)…;initLightbox()">
It doesn't work if I click an image before the page has finished loading.
This is not a bug, but a side-effect of unobtrusive scripts of this kind.
Flash objects appear through overlay.
Refer to comment by netasceta.
Script doesn't work with imagemaps.
Refer to comment by Jason Buechler.
Can I call the script from within a frame/iframe and still have it display on top of the entire page?
Refer to comment by Sean K. Some people have noted trouble implementing this modification. Proceed with caution, and if you can clear up the instructions it would be appreciated.
The shadow overlay doesn't stretch to cover full browser window.
Remove the default margin and padding from the body tag. Add body{ margin: 0; padding: 0; } to your stylesheet.
The shadow overlay doesn't show up in IE.
Find the filter: progid:DXI… line that you added to your stylesheet. There is a reference to the overlay.png in this line. Make sure that it is set relative to the current webpage, not relative to the CSS file.

Contact:

For discussing bugs, asking questions, and troubleshooting the script use the messageboard. Before starting a new dicussion, please do a search to see if your question has been asked and maybe answered previously. Thank you very much.

크리에이티브 커먼즈 라이선스
Creative Commons License

'공부 이야기 > 컴퓨터 몽땅' 카테고리의 다른 글

Timezone on Linux  (2) 2008/07/21
NTPClient  (0) 2008/07/20
Lightbox JS  (0) 2008/06/18
epoll 서버 샘플 프로그래밍  (0) 2008/05/29
공유메모리 관련  (0) 2008/05/18
Embedded Linux Memory SWAP 사용법  (0) 2008/05/01
Posted by 롸이언
공부 이야기/컴퓨터 몽땅 l 2008/06/18 11:05
1 

카테고리

꼭대기 (82)
롸이언 이야기 (7)
가족 이야기 (0)
친구 이야기 (1)
공부 이야기 (51)
취미 이야기 (17)
노래 이야기 (1)

달력

«   2010/03   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Statistics Graph
tistory!get rss Tistory Tistory 가입하기! DNS Powered by DNSEver.com