jquery.simplyCountable.js
(function($){
$.fn.simplyCountable = function(options){
options = $.extend({
counter: '#counter',
countType: 'characters',
wordSeparator: ' ',
maxCount: 256,
strictMax: false,
countDirection: 'down',
safeClass: 'safe',
overClass: 'over',
thousandSeparator: ',',
onOverCount: function(){},
onSafeCount: function(){},
onMaxCount: function(){}
}, options);
var countable = this;
var counter = $(options.counter);
if (!counter.length) { return false; }
var regex = new RegExp('['+options.wordSeparator+']+');
var countCheck = function(){
var count;
var revCount;
var reverseCount = function(ct){
return ct - (ct*2) + options.maxCount;
}
var countInt = function(){
var text = countable.val();
for (var i = 0; i < text.length; i++) {
var charCode = text.charCodeAt(i);
//utf-8 character count
if (charCode == 10 || charCode == 13) {
if ($.browser.msie) {
count -= 1;
}
}
else if (charCode > 127 && charCode < 2048) {
count -= 2;
} else if (charCode > 2047 && charCode < 65536) {
count -= 3;
} else if (charCode > 65535 && charCode < 1114112) {
count -= 4;
}
}
return (options.countDirection === 'up') ? revCount : count;
}
var numberFormat = function(ct){
if (options.thousandSeparator){
ct = ct.toString();
for (var i = ct.length-3; i > 0; i -= 3){
if((ct.length%4)==0 && ct.charAt(0)=='-'){
ct = ct;
} else {
ct = ct.substr(0,i) + options.thousandSeparator + ct.substr(i);
}
}
}
return ct;
}
/* Calculates count for either words or characters */
if (options.countType === 'words'){
count = options.maxCount - $.trim(countable.val()).split(regex).length;
if (countable.val() === ''){ count += 1; }
}
else { count = options.maxCount - countable.val().length; }
revCount = reverseCount(count);
/* If strictMax set restrict further characters */
if (options.strictMax && count <= 0){
var content = countable.val();
if (count < 0 || content.match(new RegExp('['+options.wordSeparator+']$'))) {
options.onMaxCount(countInt(), countable, counter);
}
if (options.countType === 'words'){
countable.val(content.split(regex).slice(0, options.maxCount).join(options.wordSeparator));
}
else { countable.val(content.substring(0, options.maxCount)); }
count = 0, revCount = options.maxCount;
}
counter.text(numberFormat(countInt()));
/* Set CSS class rules and API callbacks */
if (!counter.hasClass(options.safeClass) && !counter.hasClass(options.overClass)){
if (count < 0){ counter.addClass(options.overClass); }
else { counter.addClass(options.safeClass); }
}
else if (count < 0 && counter.hasClass(options.safeClass)){
counter.removeClass(options.safeClass).addClass(options.overClass);
options.onOverCount(countInt(), countable, counter);
}
else if (count >= 0 && counter.hasClass(options.overClass)){
counter.removeClass(options.overClass).addClass(options.safeClass);
options.onSafeCount(countInt(), countable, counter);
}
};
countCheck();
countable.keyup(countCheck);
countable.keypress(countCheck);
countable.click(countCheck);
countable.mouseover(countCheck);
};
})(jQuery);
main.gsp(for layout)
<g:javascript library="jquery" plugin="jquery"/>
<script type="text/javascript" src="${resource(dir: 'js', file: 'jquery.simplyCountable.js')}"></script>
<head>
…..............
…........
<style type="text/css" media="screen">
.safe {
color: green;
}
.over {
color: red;
}
</style>
<script>
jQuery.noConflict();
jQuery(document).ready(function () {
jQuery('textarea').map(function() {
if (jQuery(this).attr("floor") == 1) {
var id = jQuery(this).attr("id");
jQuery('#' + id).live('keydown',ND.utils.textCounter);
jQuery('#' + id).live('keyup',ND.utils.textCounter);
jQuery('#' + id).live('focus',ND.utils.textCounter);
}
});
});
</script>
….......
….........
</head>
For textarea in any .gsp
<g:countableTextArea name="medicalInfo" id="medicalInfo_countable" class="field" cols="25" rows="4" floor="1"
length="3000" value="${ifspTypeInfoInstance?.medicalInfo}"/>
NB:
1. floor means active for textarea countable...............
2. length means max length.
Taglib......
def countableTextArea = { attrs, body ->
def escapeHtml = true
if (attrs.escapeHtml) escapeHtml = Boolean.valueOf(attrs.remove('escapeHtml'))
// Pull out the value to use as content not attrib
def value = attrs.remove('value')
if (!value) {
value = body()
}
out << """<textarea """
attrs.each { k, v ->
out << "$k=\"${v.encodeAsHTML()}\" "
}
out << """ >""" <<"""${escapeHtml ? value.encodeAsHTML() :value}</textarea>"""
def check = Integer.valueOf(attrs.remove('floor'))
if (check == 1) {
out << """<p style="margin: 0;"> <span id="${attrs.id}-counter"> </span> </p>"""
}
}
বৃহস্পতিবার, ২১ এপ্রিল, ২০১১
বুধবার, ২০ এপ্রিল, ২০১১
two or three jquery in same page
if you have two or three jquery in same page, just put a different variable for different jquery..example :
<script type="text/javascript">
var $s = jQuery.noConflict();
$s(document).ready(function() {
$s('#news-container').vTicker({
speed: 500,
pause: 3000,
animation: 'fade',
mousePause: true,
showItems: 2
});
});
</script>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function() {
$j('.sf-menu ul').superfish({
delay: 1000,
animation: {opacity:'show',height:'show'},
speed: 'medium',
autoArrows: false,
dropShadows: 'medium'
});
});
</script>
courtesy.....
<script type="text/javascript">
var $s = jQuery.noConflict();
$s(document).ready(function() {
$s('#news-container').vTicker({
speed: 500,
pause: 3000,
animation: 'fade',
mousePause: true,
showItems: 2
});
});
</script>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function() {
$j('.sf-menu ul').superfish({
delay: 1000,
animation: {opacity:'show',height:'show'},
speed: 'medium',
autoArrows: false,
dropShadows: 'medium'
});
});
</script>
courtesy.....
বুধবার, ৬ এপ্রিল, ২০১১
মঙ্গলবার, ৫ এপ্রিল, ২০১১
grails important blog/link list
1. http://www.intelligrape.com/blog/category/grails/
2. For Symbole http://gavingrover.blogspot.com/2008/02/grerl-vys-and-groovys-symbols-part-2.html
3. Assert
4. Conditional validation in domain class ........details
5. Grails and the Pagination Bugaboo.......link
6. Dynamic jasper report in grails लिंक
7. export plugin problem solved by लिंक
8 . pdf css .....link
9. jquery-multiselect.js for multiple select combo box link-->
10. Grails AJAX Examples link
11. grails prevent multiple submition using useToken link
12. How to use onLoading event in grails remoteFunction link
13. Online Groovy Console link
14. http://csetyro.blogspot.com/2011/07/restfull-in-grails.html
15. Projection sum and group by link
2. For Symbole http://gavingrover.blogspot.com/2008/02/grerl-vys-and-groovys-symbols-part-2.html
3. Assert
4. Conditional validation in domain class ........details
5. Grails and the Pagination Bugaboo.......link
6. Dynamic jasper report in grails लिंक
7. export plugin problem solved by लिंक
8 . pdf css .....link
9. jquery-multiselect.js for multiple select combo box link-->
10. Grails AJAX Examples link
11. grails prevent multiple submition using useToken link
12. How to use onLoading event in grails remoteFunction link
13. Online Groovy Console link
14. http://csetyro.blogspot.com/2011/07/restfull-in-grails.html
15. Projection sum and group by link
মঙ্গলবার, ২৯ মার্চ, ২০১১
jQuery disable / enable SELECT options based on Radio selected
<!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" xml:lang="en" lang="en">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<title>Sandbox</title>
</head>
<body>
ABC: <input type="radio" name="abc123" id="abc"/>
123: <input type="radio" name="abc123" id="123"/>
<select id="theOptions">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
<script>
jQuery.fn.filterOn = function(radio, values) {
return this.each(function() {
var select = this;
var options = [];
$(select).find('option').each(function() {
options.push({value: $(this).val(), text: $(this).text()});
});
$(select).data('options', options);
$(radio).click(function() {
var options = $(select).empty().data('options');
var haystack = values[$(this).attr('id')];
$.each(options, function(i) {
var option = options[i];
if($.inArray(option.value, haystack) !== -1) {
$(select).append(
$('<option>').text(option.text).val(option.value)
);
}
});
});
});
};
$(function() {
$('#theOptions').filterOn('input:radio[name=abc123]', {
'abc': ['a','b','c'],
'123': ['1','2','3']
});
});
</script>
</body>
</html>
courtsey SandBox
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<title>Sandbox</title>
</head>
<body>
ABC: <input type="radio" name="abc123" id="abc"/>
123: <input type="radio" name="abc123" id="123"/>
<select id="theOptions">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
<script>
jQuery.fn.filterOn = function(radio, values) {
return this.each(function() {
var select = this;
var options = [];
$(select).find('option').each(function() {
options.push({value: $(this).val(), text: $(this).text()});
});
$(select).data('options', options);
$(radio).click(function() {
var options = $(select).empty().data('options');
var haystack = values[$(this).attr('id')];
$.each(options, function(i) {
var option = options[i];
if($.inArray(option.value, haystack) !== -1) {
$(select).append(
$('<option>').text(option.text).val(option.value)
);
}
});
});
});
};
$(function() {
$('#theOptions').filterOn('input:radio[name=abc123]', {
'abc': ['a','b','c'],
'123': ['1','2','3']
});
});
</script>
</body>
</html>
courtsey SandBox
সোমবার, ২৮ মার্চ, ২০১১
js confirm block
<script type="text/javascript"><br />function show_confirm()<br />{<br />var r=confirm("Press a button!");<br />return r;<br /><br />}<br /></script>
<a onclick="return show_confirm()" href="http://algobd.com/" value="nothing">click</a>
<a onclick="return show_confirm()" href="http://algobd.com/" value="nothing">click</a>
রবিবার, ২০ মার্চ, ২০১১
Ant as build file
To get up and running with the binary edition of Ant quickly, follow these steps:
- Make sure you have a Java environment installed, See System Requirements for details.
- Download Ant. See Binary Edition for details.
- Uncompress the downloaded file into a directory.
- Set environmental variables
JAVA_HOMEto your Java environment,ANT_HOMEto the directory you uncompressed Ant to, and add${ANT_HOME}/bin(Unix) or%ANT_HOME%/bin(Windows) to yourPATH. See Setup for details. - Optionally, from the
ANT_HOMEdirectory runant -f fetch.xml -Ddest=systemto get the library dependencies of most of the Ant tasks that require them. If you don't do this, many of the dependent Ant tasks will not be available. See Optional Tasks for details and other options for the -Ddest parameter. - Optionally, add any desired Antlibs. See Ant Libraries for a list.
Note that the links in the list above will give more details about each of the steps, should you need them. Or you can just continue reading the rest of this document.
The short story for working with the Ant source code (not needed if you are working with the binary edition) is:- Get the source code. See Source Edition for details.
- Build Ant. See Building Ant for details.
For the full story, continue reading. continue-->
এতে সদস্যতা:
পোস্টগুলি (Atom)