Feeds:
Posts
Comments

Posts Tagged ‘HTML’

Implementing Model popup Plug In

As shown in above screen, developing Model Popup will require 2 layers:

  1. Disabled Back ground
  2. Popup content Panel

We will implement a plug In and call it on Popup Panel element.

Somewhat like: $(“div.popupDiv”).ShowPopup();

ShowPopup();
Is a plug-In method which will initiate an instance of the plug-In which we going to implement as next step.

Prior to that a CSS for Disabled background needs to be developed

Which we can achieve as below:

.popupbackGround

{

position: absolute;

height: 100%;

width: 100%;

left: 0px;

top: 0px;

background-color: #000;

z-index: 1;

opacity: 0.5;

filter: alpha(opacity =50);

display: none;

}

We don’t have to assign this CSS class anywhere in HTML, but we will use this class while implementing Plug-In.

Next to this, we will implement Model Popup J-Query Plug-In.

Parameter to be passed to Plug-In: closeButtonCSS

The plug in will be called on the popup panel itself and take one parameter called CloseButtonCSS which will be used to close the Model popup.

We will create close event on the specified close button in parameter.

model-popup.js (Plug-In file)

jQuery.noConflict();

(

function($K){

$K.fn.ShowPopup=function(data)

{

/* Parameters: closeButtonCSS */

$K(this).each(function(i)

{

var dbBack,intTopAxis=0;

var objCloseButton= $K(“.” + data.closeButtonCSS);

var objPopup= $K(this);

var a;

objCloseButton.click(function(){ HidePopup(); });

$K(window).scroll(function(){

var xTop= parseInt($K(window).scrollTop()) + intTopAxis ;

objPopup.animate({top:xTop+ “px”},{queue: false, duration: 350});

});

initBackGround = function(){

dbBack = $K(“<div></div>”).attr(“class”,“popupbackGround”).css(“height”,$K(document).height()).hide();

$K(“body”).append(dbBack);

intTopAxis= parseInt(($K(window).height())/2)-(objPopup.height()/2); }

ShowPopup = function(){ initBackGround();

dbBack.fadeIn(function(){objPopup.show();

});

objPopup.css({“left”: (($K(window).width())/2)-(objPopup.width()/2),“top”: (($K(window).height())/2)-(objPopup.height()/2)+parseInt($K(window).scrollTop())});

}

HidePopup = function() {

objPopup.fadeOut(); dbBack.fadeOut();

}

ShowPopup();

});

}

})(jQuery);

How to call Model Popup

Popup Plug-In can be called on any Div object. And the DIV itself will get displayed as a popup like shown in the above screen.

For example:

Target popup DIV class is popupDiv.


<div class=”popupDiv”>

<div>Popup Content Goes Here.. </div>

<div class=”close”><class=”lnkClose”> <img src=”resource/small-closelabel.gif” /></a>

</div>

</div>

We can popup by placing the following javascript :

$k(“div.popupDiv”).ShowPopup(

{

closeButtonCSS:“lnkClose”

});

Here “closeButtonCSS:“lnkClose” is used to treat lnkClose as close button of popup.

Playing FLV

To play any FLV file in HTML will require a flash based FLV player. There are many FLV players available among of those we will use one, which is a flash file and we can play FVL using the flash FLV player.

Here we will require 2 flash (SWF) files:

  1. flvplayer.swf (download )
  2. SteelExternalAll.swf (needs to be placed on same path of container HTML page) (Download)

Below is how to embed object in HTML page to play FLV using above FLV player.

<object id=”Object1″ height=”380″ width=”400″ classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=”http://macromedia.com/cabs/swflash.cab#version=6,0,0,0″&gt;

<param name=”movie” value=”flash/flvplayer.swf” />

<param name=”FlashVars” value=”flvurl=../flash/test.flv” />

<param name=”quality” value=”high” />

<param value=”true” name=”autoplay” />

<embed height=”380″ width=”400″ src=”flash/flvplayer.swf” flashvars=”flvurl=../flash/test.flv” type=”application/x-shockwave-flash” />

</object>

Above code will take FLV file path as a parameter, that is been specified at 2 places.

  1. flashvars=”flvurl=../flash/test.flv”
  2. <param name=”movie” value=”flash/flvplayer.swf” />

Your FLV file path will go here.

Putting all together

Now we got both things ready with us.

  1. Implemented J-Query plug-In for model popup
  2. FLV player

Simply placing the <object> tag inside the Popup Div will result in our targeted output.

In addition to that we will require a Button to be clicked to show model popup. Like shown below

<a class=”lnkPopup”>Play FLV in Popup</a>

Let’s create a simple J-Query click event of the above link and call popup plug-In inside click event, like shown below.

<script type=”text/javascript” language=”javascript”>

var $k=jQuery.noConflict();

$k(document).ready(function(){

$k(“a.lnkPopup”).click(function()

{

$k(“div.popupDiv”).ShowPopup(

{

closeButtonCSS:“lnkClose”

});

});

});

</script>

You can also download full source code ZIP file by clicking here .

Advertisements

Read Full Post »

CSS3 gives a great flexibility to designers to create optimized HTML by utilizing CSS3 features.

CSS3 selectors gives rich amount of DOM element filtering, which will let designers to minimize inline attributes and inline styles in HTML code.

Here I am giving an overview of how to utilize CSS3 to develop an HTML form as shown below.

We will try to optimize HTML as much as possible by giving all styles and attributes through CSS3 in css file itself.

Form Concept:

As shown in below screen, we will be dividing form into 4 pieces,

  1. Header part (<th> )
  2. Left side labels (<td>)
  3. Right side textbox area (<td> & <input type=”text” /> )
  4. Bottom Buttons ( <input type=”submit”/> )

Generating Simple HTML form:

As shown in below HTML, we will not give any attributes to TABLE or TD.

Just a simple Table with only one class which is assigned to TABLE, like class=”tblform”. Very neat HTML without any kind of attributes assigned.

HTML file code

<table class=”tblform”>

<tr>

<th colspan=”2″>Please enter your details below.</th>

</tr>

<tr>

<td>Name</td>

<td><input type=”text”/></td>

</tr>

<tr>

<td>Email</td>

<td><input type=”text”/></td>

</tr>

<tr>

<td>Mobile</td>

<td><input type=”text”/></td>

</tr>

<tr>

<td>

</td>

<td><input type=”submit” value=”Submit”/> <input type=”submit” value=”Cancel”/></td>

</tr>

</table>

Developing CSS file:

Once we got the above HTML ready, our all focus will be now on CSS to make it look like as shown in above screen shot,

In HTML there is only 1 CSS class assigned to TABLE which is tblform.

Further will be doing all stuffs in the CSS as given below,

CSS file code

.tblform

{

border-collapse: collapse;

width: 100%;

font-family: Calibri;

font-size: 11pt;

}

.tblform td

{

padding: 5px;

border: solid 1px #E1E1E1;

}

.tblform th

{

padding: 5px;

border: solid 1px #E1E1E1;

font-weight: normal;

text-align: left;

background-color: #E1E1E1;

font-weight: bold;

}

.tblform td input[type=text]

{

border: 1px solid #CCCCCC;

width: 180px;

height: 20px;

padding-left: 5px;

}

.tblform td:first-child

{

padding: 5px;

border: solid 1px #E1E1E1;

background-color: #F2F2F2;

}

.tblform td input[type=submit], .tblform td input[type=submit]:hover

{

background-image: url(button-bg.gif);

background-repeat: repeat-x;

line-height: 22px;

height: 25px;

font-family: Verdana, Arial,Helvetica,sans-serif;

font-weight: bold;

font-size: 11px;

color: #333333;

padding: 0px 10px 0px 10px;

border: 1px solid #999999;

cursor: pointer !important;

}

That’s it, it will result in a nice form with all CSS applied and HTML will remain neat as it is.

Read Full Post »

%d bloggers like this: