checklist test

This commit is contained in:
vitalets
2012-11-25 13:22:27 +04:00
parent 0f795a3882
commit 0487380535
7 changed files with 138 additions and 39 deletions

@ -38,7 +38,7 @@
* for details see http://stackoverflow.com/questions/7410348/how-to-set-json-format-to-html5-data-attributes-in-the-jquery
*/
tryParseJson: function(s, safe) {
if (typeof s === 'string' && s.length && s.match(/^\{.*\}$/)) {
if (typeof s === 'string' && s.length && s.match(/^[\{\[].*[\}\]]$/)) {
if (safe) {
try {
/*jslint evil: true*/

@ -55,7 +55,7 @@ $(function(){
str2value: function(str) {
var reg, value = null;
if(typeof str === 'string' && str.length) {
reg = new RegExp('\s*'+$.trim(this.options.separator)+'\s*');
reg = new RegExp('\\s*'+$.trim(this.options.separator)+'\\s*');
value = str.split(reg);
} else if($.isArray(str)) {
value = str;
@ -86,9 +86,9 @@ $(function(){
//collect text of checked boxes
value2htmlFinal: function(value, element) {
var selected = [], html = '';
if($.isArray(value) && value.length <= this.options.limit) {
for(var i=0; i<value.length; i++){
var selected = [], item, i, html = '';
if($.isArray(value) && value.length <= this.options.limit) {
for(i=0; i<value.length; i++){
item = this.itemByVal(value[i]);
if(item) {
selected.push($('<div>').text(item.text).html());
@ -140,9 +140,9 @@ $(function(){
@property limitText
@type string
@default 'Checked {checked} options of {count}'
@default 'Selected {checked} of {count}'
**/
limitText: 'Checked {checked} options of {count}'
limitText: 'Selected {checked} of {count}'
});
$.fn.editableform.types.checklist = Checklist;

@ -209,7 +209,7 @@ List - abstract class for inputs that have source option loaded from js array or
//search for item by particular value
itemByVal: function(val) {
if($.isArray(this.sourceData)) {
for(i=0; i<this.sourceData.length; i++){
for(var i=0; i<this.sourceData.length; i++){
/*jshint eqeqeq: false*/
if(this.sourceData[i].value == val) {
/*jshint eqeqeq: true*/