2013年5月23日 星期四

JQuery UI - ThemeRoller的使用

1.先架JSF2環境Java Web + Primefaces(JSF2) 

2.隨便用一個JQuery UI
使用colorpicker
參考http://jqueryui.com/slider/#colorpicker

ThemeRollerDemo.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">
<head>
<meta charset="utf-8" />
<title>jQuery UI Slider - Colorpicker</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<style>
#red, #green, #blue {
float: left;
clear: left;
width: 300px;
margin: 15px;
}
#swatch {
width: 120px;
height: 100px;
margin-top: 18px;
margin-left: 350px;
background-image: none;
}
#red .ui-slider-range { background: #ef2929; }
#red .ui-slider-handle { border-color: #ef2929; }
#green .ui-slider-range { background: #8ae234; }
#green .ui-slider-handle { border-color: #8ae234; }
#blue .ui-slider-range { background: #729fcf; }
#blue .ui-slider-handle { border-color: #729fcf; }
</style>
<script>
function hexFromRGB(r, g, b) {
var hex = [
r.toString( 16 ),
g.toString( 16 ),
b.toString( 16 )
];
$.each( hex, function( nr, val ) {
if ( val.length === 1 ) {
hex[ nr ] = "0" + val;
}
});
return hex.join( "" ).toUpperCase();
}
function refreshSwatch() {
var red = $( "#red" ).slider( "value" ),
green = $( "#green" ).slider( "value" ),
blue = $( "#blue" ).slider( "value" ),
hex = hexFromRGB( red, green, blue );
$( "#swatch" ).css( "background-color", "#" + hex );
}
$(function() {
$( "#red, #green, #blue" ).slider({
orientation: "horizontal",
range: "min",
max: 255,
value: 127,
slide: refreshSwatch,
change: refreshSwatch
});
$( "#red" ).slider( "value", 255 );
$( "#green" ).slider( "value", 140 );
$( "#blue" ).slider( "value", 60 );
});
</script>
</head>
<body class="ui-widget-content" style="border: 0;">
<p class="ui-state-default ui-corner-all ui-helper-clearfix" style="padding: 4px;">
<span class="ui-icon ui-icon-pencil" style="float: left; margin: -2px 5px 0 0;"></span>
Simple Colorpicker
</p>
<div id="red"></div>
<div id="green"></div>
<div id="blue"></div>
<div id="swatch" class="ui-widget-content ui-corner-all"></div>
</body>
</html> 
Demo頁面



3.使用ThemeRoller自建一組Theme
http://jqueryui.com/themeroller/  建立一組Theme




隨便拉個ugly red


4.下載設定完的Theme


取消JQuery的套件下載,只下載Theme



5.打開壓縮檔
在下面位置有Theme的css與image
jquery-ui-1.10.3.custom.zip\jquery-ui-1.10.3.custom\css\custom-theme\





6.把css檔images放到project裡
 


7.取消原本的css,加入剛才下載的css
(css檔的連結位置要與project中的配置相同)

 

8.重新Deploy後可以看到Theme已經改變為自定的ugly red

 

9. 完成

沒有留言:

張貼留言

Related Posts Plugin for WordPress, Blogger...