Professional Documents
Culture Documents
Jquery - Bootrap
Jquery - Bootrap
MC LC
Mt s thut ng ............................................................................................................ 3
Gii thiu ........................................................................................................................ 4
CHNG I - Gii thiu v jQuery ................................ Error! Bookmark not defined.
1.1 Nhng g jQuery c th lm ..................................................................................... 5
1.1.1 Hng ti cc thnh phn trong ti liu HTML. ............................................... 5
1.1.2 Thay i giao din ca mt trang web............................................................... 5
1.1.3 Tng tc vi ngi dng ................................................................................. 6
1.1.4 To hiu ng ng cho nhng thay i ca ti liu. .......................................... 6
1.1.5 Ly thng tin t server m khng cn ti li trang web ..................................... 6
1.2 Ti sao jQuery lm vic tt ...................................................................................... 6
1.3 To trang web u tin vi s h tr ca jQuery ..................................................... 7
1.3.1 T host jQuery ................................................................................................... 7
1.3.2 Dng phin bn c sn trn server ca Google ................................................. 8
1.3.3 Chun b ti liu HTML ..................................................................................... 8
1.3.4 Bt u code jQuery........................................................................................... 9
1.3.5 Thm vo mt class mi .................................................................................. 10
CHNG II - JQuery UI ............................................... Error! Bookmark not defined.
2.1 Cc tnh nng.......................................................................................................... 11
2.2 S dng JqueryUI trong ng dng ......................................................................... 11
2.2.1 Ti JqueryUI v t website .............................................................................. 12
2.2.2 Ty chn ti vi b xy dng ti v (download builder) ................................ 12
2.2.3 Ti v t th vin CDN ................................................................................... 14
2.3 S dng JqueryUI .................................................................................................. 16
2.4 Thay i kch thc i tng ............................................................................... 27
2.5 Tooltip .................................................................................................................... 27
2.6 Widget .................................................................................................................... 29
CHNG III - Bootstrap ............................................... Error! Bookmark not defined.
3.1 Ti v ...................................................................................................................... 34
3.2 Cu trc ca m ngun Bootstrap .......................................................................... 35
3.3 Giao din ................................................................................................................ 36
3.3.1 Giao din ban u ............................................................................................ 37
3.3.2 Jumbotron ........................................................................................................ 39
3.2.3 Carousel ........................................................................................................... 43
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
1
n tt nghip
n tt nghip
Mt s thut ng
Tn
ngha
Widget
Framework
web-based
jQuery
jQuery UI
CSS
Designer
Footer
n tt nghip
Gii thiu
Bootstrap l mt trong nhng d n ra mt nm 2011 v c s dng thng
xuyn lm c s cho chiu d n web-based. Tuy nhin, khi s dng thit k giao
din ngi dng cho cc d n c ny sinh mt s vn sau: Th nht, chng ta
khng ch mun s dng jQuery UI cho s pht trin cc Widget m cn mun s
dng n cng vi Bootstrap. Bootstrap c mt thit k trc quan tuyt vi cho tt c
mi th t cc nt bm ti cc tab v cung cp cho chng ta mt giao din c s tuyt
vi m chng ta c th lp li trn cc d n khc. Th hai, ta c th bit, khng c
mt ch bootstrap c sn cho jQuery UI nhng nu thm Bootstrap vo trong mt
trang, ta s nhanh chng thy rng mt s kiu CSS cho giao din ngi dng s b
ph v do xung t. y khng phi l li ca d n Bootstrap, Bootstrap khng c
to ra c s dng vi giao din ngi dng jQuery, tuy nhin, mt gii php
c a ra l th vin Jquery UI Bootstrap.
jQuery UI Bootstrap l g?
jQuery UI Bootstrap cung cp mt th vin ca thit k Twitter Bootstrap nh
mt ch cho jQuery UI c th c p dng cho cc widgets. N cng bao gm
mt phin bn mi (sch) ca Bootstrap m c th c s dng cng vi cc ch
c th ca jQuery UI m khng cn phi lo lng v cc xung t CSS.
Nh mt minh chng, ti sao khng c mt ci nhn ti trang ch ca d n? C
hai vng gii thiu v cc nt ti ang s dng Bootstrap lm giao din trong khi mi
th khc l s dng mt giao din jQuery UI. Li ch ca vic ny l ta ang c s
dng min ph tt c mi th t Bootstrap b tr trang web ca ta v cc giao din
jQuery UI cho cc widget tng tc. l mt gii php kh hu ch.
D nny vn cn kh mi, nhng ta c th s dng mt s thnh phn (cc
nt, tp nt, thanh trt ngang, cc tab, ca s modal, date-pickers) trong thit k vi
s t tin tt c chng lm vic cng nhau. Mt s tinh chnh vn ang c thc hin
cho nhng th nh nt lnh vi cc biu tng v cc widgetca bn th ba v s sm
c cc phin bn ci tin mi.
Framework ny hot ng tt trn cc trnh duyt: Chrome 15+ (supports 13/14
too), Opera (stable + next), Firefox 5+, Safari 5+, IE 8+.
n ny c trnh by trong 4 chng. Chng 1 gii thiu v
Jquery.Chng 2 trnh by v Jquery UI. Chng 3 em a ra cch thc s dng v
cc vn lin quan ti bootstrap CSS Framework. Chng 4 l mt s cc v d rt
c bn cho vic thc thi kt hp gia JqueryUI v Bootstraps css Framework v cui
cng l phn kt lun.
n tt nghip
n tt nghip
n tt nghip
n tt nghip
n tt nghip
<li><a
href="http://www.jquery.com">Tutorials</a></li>
<li><a href="#">Photoshop</a></li>
<li><a
href="mailto:email@yahoo.com">Email</a></li>
</ul>
</div><!--end#sidebar-->
<div id="primary">
<h3>Lorem ipsum dolor sit amet</h3>
<p
class="text">som
e text here
</p>
<div>
<h3>Lorem ipsum dolor sit amet</h3>
<p>some text here</p>
</div>
<h3>Lorem ipsum dolor sit amet</h3>
<p
class="text">some
text here
</p>
</div><!--end#primary-->
</div><!--end#mainContent-->
<div id="footer">
<p>©2010vanthanhloc@gmail.com</p>
</div><!--end#footer-->
</div><!-end#wrapper-->
</body>
</html>
on code trn bn d dng nhn thy rng th vin jQuery c t di
Stylesheet. y l mt im rt quan trng m bn cn lu l th t ca cc file khi
gi. Ban u phi l CSS load trc, khi trang web load xong phn CSS th chng
ta mi thm vo phn th vin jQuery cui cng mi l code jQuery chng ta t vit
ra. Nu khng khi code jQuery ca bn s khng lm vic ng nh mong i nu
th vin jQuery cha c load.
1.3.4 Bt u code jQuery
By gi bn m trnh son tho code ln v to mt file tn l first-jquery.js v
file ny c chng ta chn vo trong dng code:
n tt nghip
<script src=first-jquery.js
type=text/javascript></script>
Gvofilevato3dngcoden
hsau:
$(document).ready(
function() {
$('.text').addClass('i
mportant');
});
Thao tc c bn nht ca
jQuery l chn mt phn no
ca ti liu HTML. Bn tin hnh
n bng cch s dng hm $().
Thng th nm gia du ngoc ()
l mt chui di dng tham s, n
c th ln hng CSS Selectors. Trong v d ny chng ta mun tm tt c nhng
thnh phn no c class = text, cp hp ging nh khi bn vit code CSS vy.
Hm $() chnh l mt jQuery Object, y l nn mng cho tt c nhng g
chng ta s hc t by gi. Jquery Object bao gm khng hoc nhiu thnh phn
DOM v cho php chng ta tng tc vi chng bng nhiu cch. Trong trng hp
ny chng ta mun thay i cch hin th ca nhng phn ny trong trang, chng ta
thc hin n bng cch thay i classc a n.
1.3.5 Thm vo mt class mi
Phng php .addClass(), cng ging nh hu ht cc phng php jQuery
khc, c t tn theo chc nng ca n. Khi c gi, n s thm mt class vo
thnh phn chng ta chn. Tham s duy nht ca n l tn class s c thm
vo. Phng php ny v i ngc vi n l .removeClass(), s cho php chng ta
quan st jQuery hot ng nh th no khi chng ta khm ph nhng phng php
la chn c sn ca jQuery. Cn by gi, code jQuery ca chng ta ch n gin
thm mt class = important, v class ny c khai bo trong stylesheet vi cc
thuc tnh nh vin v nn hng nht.
border: 1px solid red; background: pink;
Bn cng nhn thy rng chng ta khng phi chy mt vng lp no thm
class vo cc on vn bn c cng chung class. y chnh l vng lp n ca cc
phng php jQuery, nh trong v d ny l .addClass(), cho nn bn ch phi gi
ng mt ln v ch c vy thay i nhng thnh phn bn mun trong ti liu.
By gi nu bn chy th trang web va to trn trnh duyt bn s thy 2 on vn
c cng class l .text s b t hng v c vin mu .
n tt nghip
CHNG II JQUERY UI
JQueryUI l mt frameworks cho vic thit k giao din trang ngoi thng dng
nht hin nay. N n gin nhng tin dng, hot ng n nh, ti nhanh v rt d s
dng cho cc nh pht trin web. N s dng HTML, CSS v Javascript.
JQueryUI l mt th vin Javascript mnh m c xy dng trn u trang
ca th vin jQuery JavaScript. UI l vit tt ca giao din ngi dng. N l mt tp
hp cc plug-in cho jQuery m thm chc nng mi cho th vin li jQuery. Tp hp
cc plug-in trong jQueryUI bao gm tng tc giao din, hiu ng, hnh nh ng ,
widgets, v ch c xy dng trn th vin jQuery JavaScript. JQueryUI c
pht hnh trong thng 9 nm 2007, cng b trong mt bi ng blog ca John Resig
trn jquery.com. Phin bn mi nht 1.10.4 yu cu jQuery 1.6 hoc phin bn sau
ny.
Chng ny s hng dn nhng iu c bn ca jQueryUI Framework m ta
c th s dng to ra cc ng dng phc tp giao din web mt cch d
dng.Hng dn ny c chia thnh cc phn c bn nh cu trc jQueryUI,
jQueryUI CSS, jQueryUI Giao din thnh phn v jQueryUI Plugins. Mi phn c ch
lin quan vi cc v d n gin v hu ch.
2.1 Cc tnh nng
JQueryUI c phn loi thnh bn nhm, tng tc (Interactions), Widget, hiu
ng (Effects), tin ch (Utilities). Cu trc ca th vin l nh th hin trong hnh di
y:
Interactions: y l nhng plugin tng tc nh ko, th, thay i kch thc
v nhiu hn na cung cp cho ngi dng kh nng tng tc vi cc yu
t DOM.
Widget: S dng vt dng trong l jQuery plugin, bn c th to ra cc yu
t giao din ngi dng nh accordian, datepicker,
Effects: Cc c xy dng trn cc hiu ng jQuery ni b. Chng cha mt
b y cc hnh nh ng ty chnh v chuyn tip cho cc phn t DOM.
Utilities: y l mt b cng c m-un th vin jQueryUI s dng ni b.
Li ch ca jQueryUI
API c kt v nht qun
H tr trnh duyt ton din
M ngun m v min ph s dng
Tt liu
C ch Theming mnh m
n nh v bo tr thn thin
2.2 S dng JQueryUI trong ng dng
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
11
n tt nghip
n tt nghip
n tt nghip
n tt nghip
<linkhref="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jqueryui.css"rel="stylesheet">
<scriptsrc="http://code.jquery.com/jquery-1.10.2.js"></script>
<scriptsrc="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
Chi tit ca m trn l:
Dng u tin, cho bit thm ch jQuery UI thng qua CSS. CSS ny
s lm phong cch (style) cho giao din ngi dng.
Dng th hai, thm cc th vin jQuery, nh jQuery UI c xy dng
trn u trang ca th vin jQuery.
Dng th ba, thm cc th vin jQuery UI. iu ny cho php s dng
jQuery UI trong trang ca bn.
By gi chng ta hy thm mt s ni dung vo th <head>:
<scripttype="text/javascript">
$(function(){
$('#dialogMsg').dialog();
});
</script>
Trong th <body>thm:
<body>
<formid="form1"runat="server">
<divid="dialogMsg"title="First JqueryUI Example">
Xin cho, y l v d u tin v jquery UI.
</div>
</form>
</body>
Lu file vi JUI-1.html
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
15
n tt nghip
M trang web ra v chng ta s nhn thy mt trang web trng v gia trang
c mt hp thoi nh hnh sau:
n tt nghip
n tt nghip
M ngun nh sau:
<script>$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp", "BASIC",
"C", "C++",
"Clojure",
"COBOL", "ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Java",
"JavaScript", "Lisp",
"Perl", "PHP",
"Python",
"Scala",
"Scheme"
"Haskell",
"Ruby",
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
<div class="demo-description">
n tt nghip
<p>The Autocomplete widgets provides suggestions while you type into the field.
Here the suggestions are tags for programming languages, give "ja" (for Java or
JavaScript) a try.</p>
<p>The datasource is a simple JavaScript array, provided to the widget using the
source-option.</p>
</div>
</body>
2.3.2 Hiu ng
Hiu ng cho php n, hin, chuyn ng cc thnh phn web, di y l mt v d
v cch s dng
.toggler { width: 500px; height: 200px; position: relative; }
#button { padding: .5em 1em; text-decoration: none; }
#effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
#effect h3 { margin: 0; padding: 0.4em; text-align: center; }
.ui-effects-transfer { border: 2px dotted gray; }
</style>
<script>
$(function() {
// run the currently selected effect
function runEffect() {
// get effect type from
var selectedEffect = $( "#effectTypes" ).val();
// most effect types need no options passed by default
var options = {};
// some effects have required parameters
if ( selectedEffect === "scale" ) {
options = { percent: 0 };
n tt nghip
n tt nghip
n tt nghip
n tt nghip
}
#positionable1 {
width: 75px;
height: 75px;
}
#positionable2 {
width: 120px;
height: 40px;
}
select, input {
margin-left: 15px;
}
</style>
<script>
$(function() {
function position() {
$( ".positionable" ).position({
of: $( "#parent" ),
my: $( "#my_horizontal" ).val() + " " + $( "#my_vertical" ).val(),
at: $( "#at_horizontal" ).val() + " " + $( "#at_vertical" ).val(),
collision: $( "#collision_horizontal" ).val() + " " + $( "#collision_vertical" ).val()
});
}
$( ".positionable" ).css( "opacity", 0.5 );
n tt nghip
n tt nghip
n tt nghip
<option value="center">center</option>
<option value="bottom">bottom</option>
</select>
</div>
<div style="padding-bottom: 20px;">
<b>collision:</b>
<select id="collision_horizontal">
<option value="flip">flip</option>
<option value="fit">fit</option>
<option value="flipfit">flipfit</option>
<option value="none">none</option>
</select>
<select id="collision_vertical">
<option value="flip">flip</option>
<option value="fit">fit</option>
<option value="flipfit">flipfit</option>
<option value="none">none</option>
</select>
</div>
</div>
<div class="demo-description">
<p>Use the form controls to configure the positioning, or drag the positioned element
to modify its offset.
<br>Drag around the parent element to see collision detection in action.</p>
</div>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
26
n tt nghip
</body>
2.4 Thay i kch thc i tng
Vic thay i ty chnh kch thc i tng tr ln n gin hn bao gi ht. Hy
xem v d sau.
<style>
#resizable { width: 150px; height: 150px; padding: 0.5em; }
#resizable h3 { text-align: center; margin: 0; }
</style>
<script>
$(function() {
$( "#resizable" ).resizable();
});
</script>
</head>
<body>
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Resizable</h3>
</div>
<div class="demo-description">
<p>Enable any DOM element to be resizable. With the cursor grab the right or
bottom border and drag to the desired width or height.</p>
</div>
</body>
</html>
2.5 Tooltip
Tooltips c th gn vo bt c phn t no.Khi bn di chut qua cc phn t, cc thuc
tnh tiu c hin th trong mt hp nh bn cnh cc phn t , ging nh mt
hng dn tr gip nh.
Tooltips cng rt hu ch cho vic vit cc hng dn cc thnh phn trong ng dng,
chng thng c dng hin th mt s thng tin b sung trong bi cnh ca tng
lnh vc.
<script>
$(function() {
n tt nghip
$( document ).tooltip();
});
</script>
<style>
label {
display: inline-block;
width: 5em;
}
</style>
</head>
<body>
<p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any
element. When you hover
the element with your mouse, the title attribute is displayed in a little box next to the
element, just like a native tooltip.</p>
<p>But as it's not a native tooltip, it can be styled. Any themes built with
<a href="http://themeroller.com" title="ThemeRoller: jQuery UI's theme builder
application">ThemeRoller</a>
will also style tooltips accordingly.</p>
<p>Tooltips are also useful for form elements, to show some additional information
in the context of each field.</p>
<p><label for="age">Your age:</label><input id="age" title="We ask for your age
only for statistical purposes."></p>
<p>Hover the field to see the tooltip.</p>
<div class="demo-description">
<p>Hover the links above or use the tab key to cycle the focus on each element.</p>
</div>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
28
n tt nghip
</body>
</html>
2.6 widget
Demo ny cho thy mt widget ty chnh n gin c xy dng bng cch s dng
th vin Widget (jquery.ui.widget.js).
Ba hp c khi to trong cch khc nhau.Nhp thay i mu nn ca chng.Xem
m ngun xem cch n hot ng, n rt nhiu bnh lun hay gip ngi dng c
th s dng c cho ng dng ring ca mnh.
<style>
.custom-colorize {
font-size: 20px;
position: relative;
width: 75px;
height: 75px;
}
.custom-colorize-changer {
font-size: 10px;
position: absolute;
right: 0;
bottom: 0;
}
</style>
<script>
$(function() {
// the widget definition, where "custom" is the namespace,
// "colorize" the widget name
$.widget( "custom.colorize", {
// default options
options: {
red: 255,
green: 0,
blue: 0,
// callbacks
change: null,
random: null
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
29
n tt nghip
},
// the constructor
_create: function() {
this.element
// add a class for theming
.addClass( "custom-colorize" )
// prevent double click to select text
.disableSelection();
this.changer = $( "<button>", {
text: "change",
"class": "custom-colorize-changer"
})
.appendTo( this.element )
.button();
// bind click events on the changer button to the random method
this._on( this.changer, {
// _on won't call random when widget is disabled
click: "random"
});
this._refresh();
},
// called when created, and later when changing options
_refresh: function() {
this.element.css( "background-color", "rgb(" +
this.options.red +"," +
this.options.green + "," +
this.options.blue + ")"
);
// trigger a callback/event
this._trigger( "change" );
},
// a public method to change the color to a random value
// can be called directly via .colorize( "random" )
random: function( event ) {
var colors = {
red: Math.floor( Math.random() * 256 ),
green: Math.floor( Math.random() * 256 ),
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
30
n tt nghip
n tt nghip
red: 60,
blue: 60
});
// initialize with custom green value
// and a random callback to allow only colors with enough green
$( "#my-widget3" ).colorize( {
green: 128,
random: function( event, ui ) {
return ui.green > 128;
}
});
// click to toggle enabled/disabled
$( "#disable" ).click(function() {
// use the custom selector created for each widget to find all instances
// all instances are toggled together, so we can check the state from the first
if ( $( ":custom-colorize" ).colorize( "option", "disabled" ) ) {
$( ":custom-colorize" ).colorize( "enable" );
} else {
$( ":custom-colorize" ).colorize( "disable" );
}
});
// click to set options after initialization
$( "#black" ).click( function() {
$( ":custom-colorize" ).colorize( "option", {
red: 0,
green: 0,
blue: 0
});
});
});
</script>
</head>
<body>
<div>
<div id="my-widget1">color me</div>
<div id="my-widget2">color me</div>
<div id="my-widget3">color me</div>
<button id="disable">Toggle disabled option</button>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
32
n tt nghip
2.7 Kt lun
JQuery UI c s dng rng ri trong cc ng dng web, n cho ngi dng
mt th vin cc thnh phn s dng, cc hiu ng, tin ch, widget da trn jquery
cho php linh hot trong thit k ng dng. Tuy nhin, n cn mt s hn ch trong
vic thit k cc thnh phn ng dng. b sung khim khuyt ny, cc nh pht
trin thng s dng mt Framework cho CSS l bootstrap vi a dng cc mu.
Chng sau y s gii thiu qua v CSS Framework ny.
n tt nghip
CHNG II - BOOTSTRAP
Chng ny s gii thiu tng quan v Bootstrap framework, cch ti v v s
dng, cc mu c bn v mt s v d c th.
3.1 Ti v
C mt s cch d dng v nhanh chng bt u vic s dng Bootstrap, mi cch
yu cu mt mc k nng khc nhau v cch s dng.C ba ty chn ti v,
ngi dng c th xem nhng g ph hp vi nhu cu c th ca mnh m ti v bn
ph hp. Phin bn hin ti l 3.1.1
Bootstrap CDN
Thay v download v dng, bootstrap cng cho php s dng trc tip trn host CDN
bng khai bo sau sau th <head>:
<!-- Latest compiled and minified CSS -->
<linkrel="stylesheet"href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.mi
n.css">
<!-- Optional theme -->
<linkrel="stylesheet"href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstraptheme.min.css">
<!-- Latest compiled and minified JavaScript -->
<scriptsrc="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
Ch rng tt c JavaScript plugins yu cu jQuery c include
n tt nghip
n tt nghip
n tt nghip
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed
-->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
3.3.1 Giao din ban u
n tt nghip
n tt nghip
3.3.2 Jumbotron
Xy dng xung quanh jumbotron vi mt thanh iu hng v mt s ct li
c bn. M ngun v d:
<title>Jumbotron Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="jumbotron.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy this line! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-filewarning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media
queries -->
<!--[if lt IE 9]>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
39
n tt nghip
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" datatarget=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Project name</a>
</div>
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="form">
<div class="form-group">
<input type="text" placeholder="Email" class="form-control">
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control">
</div>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
40
n tt nghip
n tt nghip
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus
commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details
»</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam.
Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus
commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet
risus.</p>
<p><a class="btn btn-default" href="#" role="button">View details
»</a></p>
</div>
</div>
<hr>
<footer>
<p>© Company 2014</p>
</footer>
</div><!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
42
n tt nghip
</body>
</html>
Hnh nh giao din nh sau:
3.2.3 Carousel
Ty chnh thanh iu hng v bng chuyn, sau thm mt s thnh phn mi.
M ngun:
<title>Carousel Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy this line! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-filewarning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media
queries -->
n tt nghip
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Custom styles for this template -->
<link href="carousel.css" rel="stylesheet">
</head>
<!-- NAVBAR
================================================== -->
<body>
<div class="navbar-wrapper">
<div class="container">
<div class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" datatarget=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Project name</a>
n tt nghip
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b
class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
n tt nghip
</div>
</div>
<!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img data-src="holder.js/900x500/auto/#777:#7a7a7a/text:First slide" alt="First
slide">
<div class="container">
<div class="carousel-caption">
<h1>Example headline.</h1>
<p>Note: If you're viewing this page via a <code>file://</code> URL, the "next" and
"previous" Glyphicon buttons on the left and right might not load/display properly
due to web browser security rules.</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Sign up today</a></p>
</div>
</div>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
46
n tt nghip
</div>
<div class="item">
<img data-src="holder.js/900x500/auto/#666:#6a6a6a/text:Second slide" alt="Second
slide">
<div class="container">
<div class="carousel-caption">
<h1>Another example headline.</h1>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi
porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Learn more</a></p>
</div>
</div>
</div>
<div class="item">
<img data-src="holder.js/900x500/auto/#555:#5a5a5a/text:Third slide" alt="Third
slide">
<div class="container">
<div class="carousel-caption">
<h1>One more for good measure.</h1>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi
porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Browse
gallery</a></p>
</div>
</div>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
47
n tt nghip
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev"><span
class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"><span
class="glyphicon glyphicon-chevron-right"></span></a>
</div><!-- /.carousel -->
<!-- Marketing messaging and featurettes
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->
<div class="container marketing">
<!-- Three columns of text below the carousel -->
<div class="row">
<div class="col-lg-4">
<img class="img-circle" data-src="holder.js/140x140" alt="Generic placeholder
image">
<h2>Heading</h2>
<p>Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam
id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac,
vestibulum at eros. Praesent commodo cursus magna.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div><!-- /.col-lg-4 -->
<div class="col-lg-4">
<img class="img-circle" data-src="holder.js/140x140" alt="Generic placeholder
image">
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
48
n tt nghip
<h2>Heading</h2>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio
sem nec elit. Cras mattis consectetur purus sit amet fermentum. Fusce dapibus, tellus
ac cursus commodo, tortor mauris condimentum nibh.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div><!-- /.col-lg-4 -->
<div class="col-lg-4">
<img class="img-circle" data-src="holder.js/140x140" alt="Generic placeholder
image">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam.
Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus
commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet
risus.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div><!-- /.col-lg-4 -->
</div><!-- /.row -->
<!-- START THE FEATURETTES -->
<hr class="featurette-divider">
<div class="row featurette">
<div class="col-md-7">
<h2 class="featurette-heading">First featurette heading. <span class="textmuted">It'll blow your mind.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id
ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque
nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
n tt nghip
</div>
<div class="col-md-5">
<img class="featurette-image img-responsive" data-src="holder.js/500x500/auto"
alt="Generic placeholder image">
</div>
</div>
<hr class="featurette-divider">
<div class="row featurette">
<div class="col-md-5">
<img class="featurette-image img-responsive" data-src="holder.js/500x500/auto"
alt="Generic placeholder image">
</div>
<div class="col-md-7">
<h2 class="featurette-heading">Oh yeah, it's that good. <span class="textmuted">See for yourself.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id
ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque
nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
</div>
<hr class="featurette-divider">
<div class="row featurette">
<div class="col-md-7">
<h2 class="featurette-heading">And lastly, this one. <span class="textmuted">Checkmate.</span></h2>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
50
n tt nghip
n tt nghip
<script src="../../assets/js/docs.min.js"></script>
</body>
</html>
Hnh nh giao din (trang bn)
n tt nghip
n tt nghip
n tt nghip
n tt nghip
n tt nghip
n tt nghip
n tt nghip
<td>consectetur</td>
<td>adipiscing</td>
<td>elit</td>
</tr>
<tr>
<td>1,003</td>
<td>Integer</td>
<td>nec</td>
<td>odio</td>
<td>Praesent</td>
</tr>
<tr>
<td>1,003</td>
<td>libero</td>
<td>Sed</td>
<td>cursus</td>
<td>ante</td>
</tr>
<tr>
<td>1,004</td>
<td>dapibus</td>
<td>diam</td>
<td>Sed</td>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
59
n tt nghip
<td>nisi</td>
</tr>
<tr>
<td>1,005</td>
<td>Nulla</td>
<td>quis</td>
<td>sem</td>
<td>at</td>
</tr>
<tr>
<td>1,006</td>
<td>nibh</td>
<td>elementum</td>
<td>imperdiet</td>
<td>Duis</td>
</tr>
<tr>
<td>1,007</td>
<td>sagittis</td>
<td>ipsum</td>
<td>Praesent</td>
<td>mauris</td>
</tr>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
60
n tt nghip
<tr>
<td>1,008</td>
<td>Fusce</td>
<td>nec</td>
<td>tellus</td>
<td>sed</td>
</tr>
<tr>
<td>1,009</td>
<td>augue</td>
<td>semper</td>
<td>porta</td>
<td>Mauris</td>
</tr>
<tr>
<td>1,010</td>
<td>massa</td>
<td>Vestibulum</td>
<td>lacinia</td>
<td>arcu</td>
</tr>
<tr>
<td>1,011</td>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
61
n tt nghip
<td>eget</td>
<td>nulla</td>
<td>Class</td>
<td>aptent</td>
</tr>
<tr>
<td>1,012</td>
<td>taciti</td>
<td>sociosqu</td>
<td>ad</td>
<td>litora</td>
</tr>
<tr>
<td>1,013</td>
<td>torquent</td>
<td>per</td>
<td>conubia</td>
<td>nostra</td>
</tr>
<tr>
<td>1,014</td>
<td>per</td>
<td>inceptos</td>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
62
n tt nghip
<td>himenaeos</td>
<td>Curabitur</td>
</tr>
<tr>
<td>1,015</td>
<td>sodales</td>
<td>ligula</td>
<td>in</td>
<td>libero</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<script src="../../assets/js/docs.min.js"></script>
n tt nghip
</body>
</html>
Hnh nh giao din:
n tt nghip
Sau khi ti v, chng ta gii nn ra v c th mc jquery-ui-bootstrapmasterbs3. Bn trong c cc th mc con: assets, css, less, theme, v mt s th mc
v tp tin khc. s dng, chng ta ch cn quan tm ti th mc css ni cha cc
file nh ngha cc style ca cc thnh phn web.
4.1.2 S dng
s dng, sau khi ti v file ngun, gii nn v tm ti th mc css/customtheme. Trong c th mc images v cc file: jquery.ui.1.10.3.ie.css, jquery-ui1.10.3.custom.css v jquery-ui-1.10.3.theme.css. Copy th mc css ny vo th mc
cha cc nh ngha style ca ng dng (thng thng cng l css). Cui cng, trong
mi ng dng th thm cc file css ny vo u file (th <head>) ca mi trang web.
Trong phn di y, em s gii thiu mt s thnh phn quan trng ca
jquery-ui-bootstrap framework.
4.2 Cc thnh phn c bn
4.2.1 Button
Trong jqueryUI bootstrap, cc button c khai bo n gin vi cc thuc tnh
thm vo to ra c nhiu kiu button khc nhau:
1.
// Button
n tt nghip
2.
3.
4.
$('button').button();
// Anchors, Submit
$('.button').button();
Ngoi ra cn rt nhiu kiu khc nh: Block level button, Thumbnails with buttons,
Button set, Simple toolbar, Split Button
Cc m ngun v button c tng hp trong on m di y, ta c th chn v s
dng button no cho hp l ty thuc ng dng trin khai v yu cu khch hng:
<div class="page-header">
<h1>Nt lnh</h1>
</div>
<!-- Buttons -->
<h3>Mu sc nt</h3>
<p>
<button>Kiu ngm nh</button>
<button class="ui-button-primary">Kiu chun</button>
<button class="ui-button-success">Kiu thnh cng</button>
<button class="ui-button-info">Kiu thng tin</button>
<button class="ui-button-warning">Kiu cnh bo</button>
<button class="ui-button-danger">Kiu nguy him</button>
<button class="ui-button-inverse">Kiu o chiu</button>
</p>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
66
n tt nghip
n tt nghip
M ngun s dng:
<section id="block-documentation">
<div class="page-header">
<h1>Hp thoi</h1>
</div>
<p class="dialog-button">
<a href="#" id="btn-dialog-simple" class="ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-newwin"></span>Hp thoi n gin
</a>
<a href="#" id="btn-dialog-message" class="ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-newwin"></span>
Hp thoi modal
</a>
<a href="#" id="btn-dialog-button" class="ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-newwin"></span>Hp thoi nhiu nt lnh
</a>
</p>
<!-- ui-dialog -->
<div id="modal-simple" title="Hp thoi n gin">
<p>Hp thoi n gin. n tt nghip CNTT nm 2014. JqueryUI Bootstrap
Dialog</p>
</div>
<!--static dialog-->
<div id="modal-message" title="Hp thoi Modal">
<p>
<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px
0;"></span>
Hp thoi Modal. n tt nghip CNTT nm 2014. JqueryUI Bootstrap Dialog.
</p>
<p>
Gio vin Hng dn: Vn Chiu - Khoa CNTT HPU
</p>
</div>
<!--end static dialog-->
<!-- Multi button dialog-->
<div id="modal-button" title="Hp thoi nhiu nt lnh">
<p>
<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px
0;"></span>
Hp thoi nhiu nt lnh. n tt nghip CNTT nm 2014. JqueryUI Bootstrap
Dialog.
</p>
<p>
Gio vin Hng dn: Vn Chiu - Khoa CNTT HPU
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
68
n tt nghip
</p>
</div>
</section>
4.2.3 Tabs
Thit k cc tab l mt phn khng th thiu trong hu ht cc ng dng web,
JqueryUI Bootstrap cho ta mt cch n gin lm iu ny.
M ngun:
<div class="page-header">
<h1>Tabs</h1>
</div>
<h2>Tab n gin</h2>
<!--Demo-->
<div id="tabs">
<ul>
<li><a href="#tabs-a">Tab 1</a></li>
<li><a href="#tabs-b">Tab 2</a></li>
<li><a href="#tabs-c">Tab 3</a></li>
</ul>
<div id="tabs-a">
<p>
<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px
0;"></span>
Hp thoi nhiu nt lnh. n tt nghip CNTT nm 2014. JqueryUI Bootstrap
Dialog.
</p>
<p>
Gio vin Hng dn: Vn Chiu - Khoa CNTT HPU
</p>
</div>
<div id="tabs-b">
<p>
<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
69
n tt nghip
0;"></span>
Hp thoi nhiu nt lnh. n tt nghip CNTT nm 2014. JqueryUI Bootstrap
Dialog.
</p>
<p>
Gio vin Hng dn: Vn Chiu - Khoa CNTT HPU
</p>
</div>
<div id="tabs-c">
<p>
<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px
0;"></span>
Hp thoi nhiu nt lnh. n tt nghip CNTT nm 2014. JqueryUI Bootstrap
Dialog.
</p>
<p>
Gio vin Hng dn: Vn Chiu - Khoa CNTT HPU
</p>
</div>
</div>
<h2>Thm bt tab</h2>
<!-- Demo -->
<div id="dialog2" title="Hp thoi thm Tab">
<form>
<fieldset class="ui-helper-reset">
<p>
<label for="tab_title">Tiu </label><br />
<input type="text" name="tab_title" id="tab_title" value="" class="ui-widget-content
ui-corner-all">
</p>
<p>
<label for="tab_content">Ni dung</label><br />
<textarea name="tab_content" id="tab_content" class="ui-widget-content ui-cornerall" cols="35"></textarea>
</p>
</fieldset>
</form>
</div>
<p>
<button id="add_tab" class="ui-button-primary">Thm Tab</button>
</p>
<div id="tabs2">
<ul>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
70
n tt nghip
M:
<div class="page-header">
<h1>nh du / Li</h1>
</div>
<!-- Highlight / Error -->
<h2>nh du</h2>
<div class="ui-widget">
n tt nghip
n tt nghip
4.2.5 Menu
JqueryUI Bootstrap cho php d dng to cc menu vi nhiu cp. V d
M:
<div class="page-header">
<h1>Menu</h1>
</div>
<div class="clearfix">
<ul id="menu">
<li><a href="#">Menu 1</a></li>
<li><a href="#">Menu 2</a></li>
<li><a href="#">Menu 3</a></li>
<li><a href="#">Menu 4</a></li>
<li>
<a href="#">Menu 5</a>
<ul>
<li><a href="#">Menu 5.1</a></li>
<li><a href="#">Menu 5.1</a></li>
<li><a href="#">Menu 5.1</a></li>
</ul>
</li>
<li><a href="#">Menu 6</a></li>
<li>
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
73
n tt nghip
</ul>
</li>
<li>
<a href="?Delphi">Menu 7.2</a>
<ul>
<li><a href="#">Menu 7.2.1</a></li>
<li><a href="#">Menu 7.2.2</a></li>
</ul>
</li>
<li><a href="#">Kt thc</a></li>
</ul>
</li>
</ul>
</div>
Ngoi ra cn rt nhiu cc thnh phn c h tr thit k m trong khun kh n
khng th gii thiu ht nh: Overlay and Shadow Classes, cc Slider, Autocomplete,
Spinner, Icons, Tooltip, Progress bar
4.3 V d th nghim 1 s thnh phn c bn ca jqueryUI bootstrap Framework
Trong phn ny, em xy dng mt v d (l mt trang html) c mt s cc
thnh phn c bn ca ca jqueryUI bootstrap, qua em mun ngi c c th vn
dng a cc giao din ca cc thnh phn web vo cc ng dng m khng cn
i hi nhiu v xy dng css.
Sinh vin: Vn Thnh Lc - Lp CTL601 - Ngnh: Cng ngh thng tin
74
n tt nghip
n tt nghip
n tt nghip
n tt nghip
KT LUN
n tm hiu c mt s k thut trong vic thit k cc giao din ca
ng dng web thng qua cc framework min ph v rt thng dng l Jquery,
JqueryUI, Bootstrap. Tuy nhin, khi kt hp gia Bootstrap v Jquery to ra nhng
b cc web sinh ng v p th xy ra mt s hin tng xung t, dn ti cc hiu
ng v phong cch khng nh mun. gii quyt iu ny, mt phng php
c a ra l xy dng li mt s thnh phn trong css v js ca bootstrap khng
b xung t vi jquery v l JqueryUI Bootstrap framework. n gii thiu
c mt s thnh phn trong ny v a ra v d s dng nhm mc ch h tr
ngi mi bt tay vo thit k c mt ci nhn n gin nht v c th ng dng nhanh
nht cc tin ch m JqueryUI Bootstrap framework mang li gip vic xy dng
chng trnh nhanh hn, d dng hn.
n tt nghip