In this regard, the jquery.boxy plug-in has been made very powerful. Commonly used prompts, confirmations, dragging, changing sizes, and asynchronous loading are all very practical, resulting in larger files (negligible), and many functions are not needed. For this reason , with the attitude and idea of learning and practicing at the same time, I made a lightweight pop-up layer plug-in suitable for this project. This is the first time I write a jqeury plug-in, and I am also preparing to encapsulate common operations into jquery plug-ins in the future. Bar.
First of all, let’s give the plug-in a name so that it can fool people. Let’s call it jquey.cvbox.min.js. cv is the abbreviation of the website domain name ChinaValue. The compressed capacity is controlled below 6K. Since it's not finished yet, I'll write down my thoughts first.
1. Add container elements to the page to display content, as well as the background of the pop-up layer. It only needs to be there. As for where you were born (that is, where it is displayed on the page) and what you will grow into. The appearance will be cultivated (set up) later, and the appearance will naturally be dressed up by the art director.
2. According to our needs, we define some commonly used objects in advance, such as the background of the mask, the container of the pop-up layer, the title bar of the pop-up layer, the content area of the pop-up layer, and the height of the current browser window. Kuan, etc., with these, it will be much more convenient to use later.
3. Start stuffing content into the container. The content can be a prompt (corresponding to the prompt function), a question (corresponding to the confirmation box), a picture (for example, for enlarging a small picture), or It is a piece of HTML code (replacing the inconvenience of writing HTML directly in JS).
4. Define the event that the user clicks to close, that is, hiding or removing the background layer and pop-up layer, leaving it to be called when the operation is completed.
5. Set the background layer transparency and scroll height, set the position of the pop-up layer, center it with scrolling or be fixed.
6. Finally, in order to facilitate use in multiple situations, extract variable parameters. The parameters must have default values, and use $.extend to complete it.
The beta version is expected to be released after the holidays, and it will be unabridged.
Online demo: http://demo.jb51.net/js/jquery_cvbox/index.htm
Package download: http://xiazai.jb51.net/201010/ yuanma/jquery_cvbox.rar
jquery.cvbox.min.js code
$(this).cvbox({ <br>titleBarText: "弹出提示框", <br>alertText: "世界上最远的距离不是生与死的距离<br />而是我在你面前<br />你却不知道我爸爸是李刚" <br>}); <br>
$("# A2").click(function() { <BR>$(this).cvbox({ <BR>titleBarText: "팝업 프롬프트 상자는 1초 후에 자동으로 닫힙니다.", <BR>alertText: "가장 먼 거리 세상에는 삶과 죽음의 거리가 없습니다<br /> ;하지만 나는 당신 앞에 있습니다<br />당신은 내 아버지가 리강이라는 것을 모르고 있습니다", <BR>delayClose:1000 <BR> }); <BR>
$("#A3"). click(function() { <BR>$(this).cvbox({ <BR>titleBarText: "팝업 대화 상자", <BR>confirmText: "세상에서 가장 먼 거리는 삶과 죽음의 거리가 아닙니다< ;br /> 근데 나야 너 앞에서는<br />그런데 내 아버지가 리강이라는 걸 모르시나봐요<br <BR>/><br />네 아버지가 리강인 게 확실해? Gang? ", <BR>submitAfter:HelloLiGang <BR>}); <BR>}); <BR><BR>function HelloLiGang(){ <BR>alert("아버지에 대한 존경심은 끝없는 강과 같습니다! "); <br>} <br>< ;/pre> <BR></div> <BR><div> <BR><a id="A4" href="javascript:void(0) ;">4. HTML 콘텐츠를 로드하고 클릭하여 효과를 확인하세요. </a> <BR><div class="A4Demo" style="display: none; width: 550px; padding: 10px;"> <BR><div> <BR>이 콘텐츠의 일반적인 표시 이는 HTML 콘텐츠가 동적으로 작성되지 않고 현재 페이지에 있음을 보여주기 위한 것입니다. <BR>. <BR><br /> <BR>콘텐츠는 iframe을 포함한 모든 요소일 수 있습니다. <BR></div> <BR><div> <BR></div> <BR><script type="text/javascript"< ![CDATA[ <BR>$("#A4").click(function() { <BR>$(".A4Demo").cvbox({ <BR>titleBarText: "HTML 콘텐츠 로드" <BR> }); <BR>// ]]</script> <BR></div><BR><BR>< pre class="brush:html"><div class="A4Demo" style="display:none; width:550px; padding:10px; "> <BR><div> 표시가 숨겨짐으로 설정되어 있습니다. 이는 HTML 콘텐츠가 동적으로 작성되지 않고 현재 페이지에 있음을 보여주기 위한 것입니다. <BR><br /> <BR>콘텐츠는 iframe을 포함한 모든 요소일 수 있습니다. <BR></div> <BR><div> <BR><iframe width="100%"frameborder="0" src="http://a.cvimg.cn/UploadFile/MiniBlog/2010 /10-20/7a09cf13-eeb6-491b-aa63- <BR>18dd67bde0a1_Big.jpg"></iframe> <BR></div> <BR></div> <BR></pre> ; <BR></div> <BR><br /> <BR><div class="jb51_Highlighter"><BR><pre class="brush:javascript">$("# A4").click(function() { <BR>$(".A4Demo").cvbox({ <BR>titleBarText: "HTML 콘텐츠 로드 중" <BR>}); <BR>}); <BR>