Add frontend assets and plugin bundles
Add the legacy frontend themes, scripts, and plugin assets required by the main SPOTA interfaces.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
jQuery Input Limiter plugin 1.3
|
||||
http://rustyjeans.com/jquery-plugins/input-limiter/
|
||||
|
||||
Copyright (c) 2009 Russel Fones <russel@rustyjeans.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,254 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Input Limiter Demo</title>
|
||||
<link rel="stylesheet" type="text/css" href="jquery.inputlimiter.1.0.css" />
|
||||
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
|
||||
<script type="text/javascript" src="jquery.inputlimiter.1.3.1.min.js"></script>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: verdana;
|
||||
}
|
||||
#limitingtext {
|
||||
color: #333;
|
||||
font-size: 90%;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
// Change default to count new lines as two characters
|
||||
$.fn.inputlimiter.defaults.lineReturnCount = 2;
|
||||
|
||||
// Default
|
||||
$('textarea').inputlimiter();
|
||||
|
||||
// Limit by Words
|
||||
$('#textarea3').inputlimiter({
|
||||
limit: 10,
|
||||
limitBy: 'words',
|
||||
remText: 'You only have %n word%s remaining...',
|
||||
limitText: 'Field limited to %n word%s.'
|
||||
});
|
||||
|
||||
// Make it more personal
|
||||
$('#text1').inputlimiter({
|
||||
limit: 50,
|
||||
remText: 'You only have %n character%s remaining...',
|
||||
remFullText: 'Stop typing! You\'re not allowed any more characters!',
|
||||
limitText: 'You\'re allowed to input %n character%s into this field.'
|
||||
|
||||
});
|
||||
|
||||
// The limiter will display the text in Spanish
|
||||
$('#text2').inputlimiter({
|
||||
limit: 50,
|
||||
remText: '%n caractere%s restantes.',
|
||||
limitText: 'Campo limitado a %n caractere%s.'
|
||||
});
|
||||
|
||||
// The limiter will display the text in French
|
||||
$('#text2_1').inputlimiter({
|
||||
limit: 50,
|
||||
remText: '%n caractère%s restants.',
|
||||
limitText: 'Champ limité à %n caractère%s.',
|
||||
zeroPlural: false
|
||||
});
|
||||
|
||||
// This input will display the limiter info in the existing span tag
|
||||
$('#text3').inputlimiter({
|
||||
limit: 30,
|
||||
boxId: 'limitingtext',
|
||||
boxAttach: false
|
||||
});
|
||||
|
||||
$('#text4').inputlimiter({
|
||||
limit: 40,
|
||||
remTextFilter: function (opts, charsRemaining) {
|
||||
var charsTyped = opts.limit - charsRemaining;
|
||||
return "You have typed " + charsTyped + " character" + ( charsTyped == 1?'':'s' ) + ".<br />" +
|
||||
"You have " + charsRemaining + " character" + ( charsRemaining == 1?'':'s' ) + " remaining.";
|
||||
},
|
||||
limitTextFilter: function (opts) {
|
||||
return "This field is limited to " + opts.limit + " character" + ( opts.limit == 1?'':'s' ) + ".";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// When your remaining characters drops below 13 the lyrics from The Twelve Days of Christmas will be displayed.
|
||||
$('#text5').inputlimiter({
|
||||
limit: 12,
|
||||
remTextFilter: function (opts, charsRemaining) {
|
||||
var remText = "The Twelve Days of Christmas";
|
||||
if ( charsRemaining == 12 ) {
|
||||
remText = "Twelve drummers druming.";
|
||||
} else if ( charsRemaining == 11 ) {
|
||||
remText = "Eleven pipers piping.";
|
||||
} else if ( charsRemaining == 10 ) {
|
||||
remText = "Ten lords a' leaping.";
|
||||
} else if ( charsRemaining == 9 ) {
|
||||
remText = "Nine ladies dancing.";
|
||||
} else if ( charsRemaining == 8 ) {
|
||||
remText = "Eight maids a' milking.";
|
||||
} else if ( charsRemaining == 7 ) {
|
||||
remText = "Seven swans a' swimming.";
|
||||
} else if ( charsRemaining == 6 ) {
|
||||
remText = "Six geese a' laying.";
|
||||
} else if ( charsRemaining == 5 ) {
|
||||
remText = "Five gold rings.";
|
||||
} else if ( charsRemaining == 4 ) {
|
||||
remText = "Four calling birds.";
|
||||
} else if ( charsRemaining == 3 ) {
|
||||
remText = "Three french hens.";
|
||||
} else if ( charsRemaining == 2 ) {
|
||||
remText = "Two turtle doves.";
|
||||
} else if ( charsRemaining == 1 ) {
|
||||
remText = "A partridge in a pear tree.";
|
||||
}
|
||||
return remText;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1><a href="http://rustyjeans.com/jquery-plugins/input-limiter/">jQuery Plugin: Input Limiter</a></h1>
|
||||
<form>
|
||||
<fieldset>
|
||||
<legend>Default Textareas</legend>
|
||||
<label>This textarea will show the limiter info on two lines<br />
|
||||
<textarea rows="3" cols="30" id="textarea1"></textarea></label><br />
|
||||
|
||||
<label>Since this text area is wider it will show the limiter info on one line<br />
|
||||
<textarea rows="5" cols="40" id="textarea2"></textarea></label><br />
|
||||
|
||||
<strong>Code:</strong><br />
|
||||
<pre>$('textarea').inputlimiter();</pre>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Limit by Words</legend>
|
||||
<label>This textarea only allows ten words<br />
|
||||
<textarea rows="3" cols="30" id="textarea3"></textarea></label><br />
|
||||
|
||||
<strong>Code:</strong><br />
|
||||
<pre>$('#textarea3').inputlimiter({
|
||||
limit: 10,
|
||||
limitBy: 'words',
|
||||
remText: 'You only have %n word%s remaining...',
|
||||
limitText: 'Field limited to %n word%s.'
|
||||
});</pre>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Custom limiter text</legend>
|
||||
<label>Make it more personal<br />
|
||||
<input type="text" id="text1" size="50" /></label><br />
|
||||
|
||||
<strong>Code:</strong><br />
|
||||
<pre>$('#text1').inputlimiter({
|
||||
limit: 50,
|
||||
remText: 'You only have %n character%s remaining...',
|
||||
remFullText: 'Stop typing! You\'re not allowed any more characters!',
|
||||
limitText: 'You\'re allowed to input %n character%s into this field.'
|
||||
});</pre>
|
||||
|
||||
<label>The limiter will display the text in Spanish<br />
|
||||
<input type="text" id="text2" size="50" /></label><br />
|
||||
|
||||
<strong>Code:</strong><br />
|
||||
<pre>$('#text2').inputlimiter({
|
||||
limit: 50,
|
||||
remText: '%n caractere%s restantes.',
|
||||
limitText: 'Campo limitado a %n caractere%s.'
|
||||
});</pre>
|
||||
|
||||
<label>The limiter will display the text in French<br />
|
||||
<input type="text" id="text2_1" size="50" /></label><br />
|
||||
|
||||
<strong>Code:</strong><br />
|
||||
<pre>$('#text2_1').inputlimiter({
|
||||
limit: 50,
|
||||
remText: '%n caractère%s restants.',
|
||||
limitText: 'Champ limité à %n caractère%s.',
|
||||
zeroPlural: false
|
||||
});</pre>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Alternate Box ID</legend>
|
||||
<label>This input will display the limiter info in the existing span tag<br />
|
||||
<input type="text" id="text3" size="30" /> <span id="limitingtext">Field limited to 30 characters.</span></label><br />
|
||||
|
||||
<strong>Code:</strong><br />
|
||||
<pre>$('#text3').inputlimiter({
|
||||
limit: 30,
|
||||
boxId: 'limitingtext',
|
||||
boxAttach: false
|
||||
});</pre>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Custom Text Filters</legend>
|
||||
<label>The remText and limitText have custom filters<br />
|
||||
<input type="text" id="text4" size="40" /></label><br />
|
||||
<strong>Code:</strong><br />
|
||||
<pre>$('#text4').inputlimiter({
|
||||
limit: 40,
|
||||
remTextFilter: function (opts, charsRemaining) {
|
||||
var charsTyped = opts.limit - charsRemaining;
|
||||
return "You have typed " + charsTyped + " character" + ( charsTyped == 1?'':'s' ) + ".<br />" +
|
||||
"You have " + charsRemaining + " character" + ( charsRemaining == 1?'':'s' ) + " remaining.";
|
||||
},
|
||||
limitTextFilter: function (opts) {
|
||||
return "This field is limited to " + opts.limit + " character" + ( opts.limit == 1?'':'s' ) + ".";
|
||||
}
|
||||
});</pre>
|
||||
<label>When your remaining characters drops below 13 the lyrics from The Twelve Days of Christmas will be displayed.<br />
|
||||
<input type="text" id="text5" size="30" /></label><br />
|
||||
|
||||
<strong>Code:</strong><br />
|
||||
<pre>$('#text5').inputlimiter({
|
||||
limit: 12,
|
||||
remTextFilter: function (opts, charsRemaining) {
|
||||
var remText = "The Twelve Days of Christmas";
|
||||
if ( charsRemaining == 12 ) {
|
||||
remText = "Twelve drummers druming.";
|
||||
} else if ( charsRemaining == 11 ) {
|
||||
remText = "Eleven pipers piping.";
|
||||
} else if ( charsRemaining == 10 ) {
|
||||
remText = "Ten lords a' leaping.";
|
||||
} else if ( charsRemaining == 9 ) {
|
||||
remText = "Nine ladies dancing.";
|
||||
} else if ( charsRemaining == 8 ) {
|
||||
remText = "Eight maids a' milking.";
|
||||
} else if ( charsRemaining == 7 ) {
|
||||
remText = "Seven swans a' swimming.";
|
||||
} else if ( charsRemaining == 6 ) {
|
||||
remText = "Six geese a' laying.";
|
||||
} else if ( charsRemaining == 5 ) {
|
||||
remText = "Five gold rings.";
|
||||
} else if ( charsRemaining == 4 ) {
|
||||
remText = "Four calling birds.";
|
||||
} else if ( charsRemaining == 3 ) {
|
||||
remText = "Three french hens.";
|
||||
} else if ( charsRemaining == 2 ) {
|
||||
remText = "Two turtle doves.";
|
||||
} else if ( charsRemaining == 1 ) {
|
||||
remText = "A partridge in a pear tree.";
|
||||
}
|
||||
return remText;
|
||||
}
|
||||
});</pre>
|
||||
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
.limiterBox {
|
||||
border: 1px solid #000;
|
||||
border-top: none;
|
||||
background-color: #ffc;
|
||||
padding: 3px 6px;
|
||||
font-size: 10px;
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* jQuery Input Limiter plugin 1.3.1
|
||||
* http://rustyjeans.com/jquery-plugins/input-limiter/
|
||||
*
|
||||
* Copyright (c) 2009 Russel Fones <russel@rustyjeans.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
$.fn.inputlimiter = function (options) {
|
||||
var opts = $.extend({}, $.fn.inputlimiter.defaults, options),
|
||||
$elements = $(this);
|
||||
if (opts.boxAttach && !$('#' + opts.boxId).length) {
|
||||
$('<div/>').appendTo("body").attr({id: opts.boxId, 'class': opts.boxClass}).css({'position': 'absolute'}).hide();
|
||||
// apply bgiframe if available
|
||||
if ($.fn.bgiframe) {
|
||||
$('#' + opts.boxId).bgiframe();
|
||||
}
|
||||
}
|
||||
|
||||
var inputlimiterKeyup = function (e) {
|
||||
var $this = $(this),
|
||||
count = counter($this.val());
|
||||
if (!opts.allowExceed && count > opts.limit) {
|
||||
$this.val(truncater($this.val()));
|
||||
}
|
||||
if (opts.boxAttach) {
|
||||
$('#' + opts.boxId).css({
|
||||
'width': $this.outerWidth() - ($('#' + opts.boxId).outerWidth() - $('#' + opts.boxId).width()) + 'px',
|
||||
'left': $this.offset().left + 'px',
|
||||
'top': ($this.offset().top + $this.outerHeight()) - 1 + 'px',
|
||||
'z-index': 2000
|
||||
});
|
||||
}
|
||||
var charsRemaining = (opts.limit - count > 0 ? opts.limit - count : 0),
|
||||
remText = opts.remTextFilter(opts, charsRemaining),
|
||||
limitText = opts.limitTextFilter(opts);
|
||||
|
||||
if (opts.limitTextShow) {
|
||||
$('#' + opts.boxId).html(remText + ' ' + limitText);
|
||||
// Check to see if the text is wrapping in the box
|
||||
// If it is lets break it between the remaining test and the limit test
|
||||
var textWidth = $("<span/>").appendTo("body").attr({id: '19cc9195583bfae1fad88e19d443be7a', 'class': opts.boxClass}).html(remText + ' ' + limitText).innerWidth();
|
||||
$("#19cc9195583bfae1fad88e19d443be7a").remove();
|
||||
if (textWidth > $('#' + opts.boxId).innerWidth()) {
|
||||
$('#' + opts.boxId).html(remText + '<br />' + limitText);
|
||||
}
|
||||
// Show the limiter box
|
||||
$('#' + opts.boxId).show();
|
||||
} else {
|
||||
$('#' + opts.boxId).html(remText).show();
|
||||
}
|
||||
},
|
||||
|
||||
inputlimiterKeypress = function (e) {
|
||||
var count = counter($(this).val());
|
||||
if (!opts.allowExceed && count > opts.limit) {
|
||||
var modifierKeyPressed = e.ctrlKey || e.altKey || e.metaKey;
|
||||
if (!modifierKeyPressed && (e.which >= 32 && e.which <= 122) && this.selectionStart === this.selectionEnd) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
inputlimiterBlur = function () {
|
||||
var $this = $(this);
|
||||
count = counter($this.val());
|
||||
if (!opts.allowExceed && count > opts.limit) {
|
||||
$this.val(truncater($this.val()));
|
||||
}
|
||||
if (opts.boxAttach) {
|
||||
$('#' + opts.boxId).fadeOut('fast');
|
||||
} else if (opts.remTextHideOnBlur) {
|
||||
var limitText = opts.limitText;
|
||||
limitText = limitText.replace(/\%n/g, opts.limit);
|
||||
limitText = limitText.replace(/\%s/g, (opts.limit === 1 ? '' : 's'));
|
||||
$('#' + opts.boxId).html(limitText);
|
||||
}
|
||||
},
|
||||
|
||||
counter = function (value) {
|
||||
if (opts.limitBy.toLowerCase() === "words") {
|
||||
return (value.length > 0 ? $.trim(value).replace(/\ +(?= )/g, '').split(' ').length : 0);
|
||||
}
|
||||
var count = value.length,
|
||||
newlines = value.match(/\n/g);
|
||||
if (newlines && opts.lineReturnCount > 1) {
|
||||
count += newlines.length * (opts.lineReturnCount - 1);
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
truncater = function (value) {
|
||||
if (opts.limitBy.toLowerCase() === "words") {
|
||||
return $.trim(value).replace(/\ +(?= )/g, '').split(' ').splice(0, opts.limit).join(' ') + ' ';
|
||||
}
|
||||
return value.substring(0, opts.limit);
|
||||
};
|
||||
|
||||
$(this).each(function (i) {
|
||||
var $this = $(this);
|
||||
if ((!options || !options.limit) && opts.useMaxlength && parseInt($this.attr('maxlength')) > 0 && parseInt($this.attr('maxlength')) != opts.limit) {
|
||||
$this.inputlimiter($.extend({}, opts, { limit: parseInt($this.attr('maxlength')) }));
|
||||
} else {
|
||||
if (!opts.allowExceed && opts.useMaxlength && opts.limitBy.toLowerCase() === "characters") {
|
||||
$this.attr('maxlength', opts.limit);
|
||||
}
|
||||
$this.unbind('.inputlimiter');
|
||||
$this.bind('keyup.inputlimiter', inputlimiterKeyup);
|
||||
$this.bind('keypress.inputlimiter', inputlimiterKeypress);
|
||||
$this.bind('blur.inputlimiter', inputlimiterBlur);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.inputlimiter.remtextfilter = function (opts, charsRemaining) {
|
||||
var remText = opts.remText;
|
||||
if (charsRemaining === 0 && opts.remFullText !== null) {
|
||||
remText = opts.remFullText;
|
||||
}
|
||||
remText = remText.replace(/\%n/g, charsRemaining);
|
||||
remText = remText.replace(/\%s/g, (opts.zeroPlural ? (charsRemaining === 1 ? '' : 's') : (charsRemaining <= 1 ? '' : 's')));
|
||||
return remText;
|
||||
};
|
||||
|
||||
$.fn.inputlimiter.limittextfilter = function (opts) {
|
||||
var limitText = opts.limitText;
|
||||
limitText = limitText.replace(/\%n/g, opts.limit);
|
||||
limitText = limitText.replace(/\%s/g, (opts.limit <= 1 ? '' : 's'));
|
||||
return limitText;
|
||||
};
|
||||
|
||||
$.fn.inputlimiter.defaults = {
|
||||
limit: 255,
|
||||
boxAttach: true,
|
||||
boxId: 'limiterBox',
|
||||
boxClass: 'limiterBox',
|
||||
remText: '%n character%s remaining.',
|
||||
remTextFilter: $.fn.inputlimiter.remtextfilter,
|
||||
remTextHideOnBlur: true,
|
||||
remFullText: null,
|
||||
limitTextShow: true,
|
||||
limitText: 'Field limited to %n character%s.',
|
||||
limitTextFilter: $.fn.inputlimiter.limittextfilter,
|
||||
zeroPlural: true,
|
||||
allowExceed: false,
|
||||
useMaxlength: true,
|
||||
limitBy: 'characters',
|
||||
lineReturnCount: 1
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,11 @@
|
||||
(function($){$.fn.inputlimiter=function(options){var opts=$.extend({},$.fn.inputlimiter.defaults,options),$elements=$(this);if(opts.boxAttach&&!$('#'+opts.boxId).length){$('<div/>').appendTo("body").attr({id:opts.boxId,'class':opts.boxClass}).css({'position':'absolute'}).hide();if($.fn.bgiframe){$('#'+opts.boxId).bgiframe();}}
|
||||
var inputlimiterKeyup=function(e){var $this=$(this),count=counter($this.val());if(!opts.allowExceed&&count>opts.limit){$this.val(truncater($this.val()));}
|
||||
if(opts.boxAttach){$('#'+opts.boxId).css({'width':$this.outerWidth()-($('#'+opts.boxId).outerWidth()-$('#'+opts.boxId).width())+'px','left':$this.offset().left+'px','top':($this.offset().top+$this.outerHeight())-1+'px','z-index':2000});}
|
||||
var charsRemaining=(opts.limit-count>0?opts.limit-count:0),remText=opts.remTextFilter(opts,charsRemaining),limitText=opts.limitTextFilter(opts);if(opts.limitTextShow){$('#'+opts.boxId).html(remText+' '+limitText);var textWidth=$("<span/>").appendTo("body").attr({id:'19cc9195583bfae1fad88e19d443be7a','class':opts.boxClass}).html(remText+' '+limitText).innerWidth();$("#19cc9195583bfae1fad88e19d443be7a").remove();if(textWidth>$('#'+opts.boxId).innerWidth()){$('#'+opts.boxId).html(remText+'<br />'+limitText);}
|
||||
$('#'+opts.boxId).show();}else{$('#'+opts.boxId).html(remText).show();}},inputlimiterKeypress=function(e){var count=counter($(this).val());if(!opts.allowExceed&&count>opts.limit){var modifierKeyPressed=e.ctrlKey||e.altKey||e.metaKey;if(!modifierKeyPressed&&(e.which>=32&&e.which<=122)&&this.selectionStart===this.selectionEnd){return false;}}},inputlimiterBlur=function(){var $this=$(this);count=counter($this.val());if(!opts.allowExceed&&count>opts.limit){$this.val(truncater($this.val()));}
|
||||
if(opts.boxAttach){$('#'+opts.boxId).fadeOut('fast');}else if(opts.remTextHideOnBlur){var limitText=opts.limitText;limitText=limitText.replace(/\%n/g,opts.limit);limitText=limitText.replace(/\%s/g,(opts.limit===1?'':'s'));$('#'+opts.boxId).html(limitText);}},counter=function(value){if(opts.limitBy.toLowerCase()==="words"){return(value.length>0?$.trim(value).replace(/\ +(?= )/g,'').split(' ').length:0);}
|
||||
var count=value.length,newlines=value.match(/\n/g);if(newlines&&opts.lineReturnCount>1){count+=newlines.length*(opts.lineReturnCount-1);}
|
||||
return count;},truncater=function(value){if(opts.limitBy.toLowerCase()==="words"){return $.trim(value).replace(/\ +(?= )/g,'').split(' ').splice(0,opts.limit).join(' ')+' ';}
|
||||
return value.substring(0,opts.limit);};$(this).each(function(i){var $this=$(this);if((!options||!options.limit)&&opts.useMaxlength&&parseInt($this.attr('maxlength'))>0&&parseInt($this.attr('maxlength'))!=opts.limit){$this.inputlimiter($.extend({},opts,{limit:parseInt($this.attr('maxlength'))}));}else{if(!opts.allowExceed&&opts.useMaxlength&&opts.limitBy.toLowerCase()==="characters"){$this.attr('maxlength',opts.limit);}
|
||||
$this.unbind('.inputlimiter');$this.bind('keyup.inputlimiter',inputlimiterKeyup);$this.bind('keypress.inputlimiter',inputlimiterKeypress);$this.bind('blur.inputlimiter',inputlimiterBlur);}});};$.fn.inputlimiter.remtextfilter=function(opts,charsRemaining){var remText=opts.remText;if(charsRemaining===0&&opts.remFullText!==null){remText=opts.remFullText;}
|
||||
remText=remText.replace(/\%n/g,charsRemaining);remText=remText.replace(/\%s/g,(opts.zeroPlural?(charsRemaining===1?'':'s'):(charsRemaining<=1?'':'s')));return remText;};$.fn.inputlimiter.limittextfilter=function(opts){var limitText=opts.limitText;limitText=limitText.replace(/\%n/g,opts.limit);limitText=limitText.replace(/\%s/g,(opts.limit<=1?'':'s'));return limitText;};$.fn.inputlimiter.defaults={limit:255,boxAttach:true,boxId:'limiterBox',boxClass:'limiterBox',remText:'%n character%s remaining.',remTextFilter:$.fn.inputlimiter.remtextfilter,remTextHideOnBlur:true,remFullText:null,limitTextShow:true,limitText:'Field limited to %n character%s.',limitTextFilter:$.fn.inputlimiter.limittextfilter,zeroPlural:true,allowExceed:false,useMaxlength:true,limitBy:'characters',lineReturnCount:1};})(jQuery);
|
||||
Reference in New Issue
Block a user