Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

version 1.1

some bad code removed
  • Loading branch information...
commit b962061442f04f7a5bf813598fc480d1419446f1 1 parent 1e1e595
Maxim authored

Showing 2 changed files with 4 additions and 7 deletions. Show diff stats Hide diff stats

  1. +3 6 fcbklistselection.js
  2. +1 1  fcbklistselection.min.js
9 fcbklistselection.js
@@ -164,8 +164,7 @@ jQuery.fcbkListSelection = function(elem, width, height, row){
164 164 }
165 165 });
166 166 }
167   - catch (e) {
168   - //console.log(e);
  167 + catch (e) {
169 168 }
170 169 //remove last ,
171 170 string = string.substr(0, (string.length - 1));
@@ -177,8 +176,7 @@ jQuery.fcbkListSelection = function(elem, width, height, row){
177 176 try {
178 177 eval("this." + id + " = value;");
179 178 }
180   - catch (e) {
181   - //console.log(e);
  179 + catch (e) {
182 180 }
183 181 }
184 182
@@ -204,8 +202,7 @@ jQuery.fcbkListSelection = function(elem, width, height, row){
204 202 }
205 203 $("#" + inputid).val(string);
206 204 }
207   - catch (e) {
208   - //console.log(e);
  205 + catch (e) {
209 206 }
210 207 }
211 208 }
2  fcbklistselection.min.js
@@ -14,4 +14,4 @@
14 14 * height - height of each element
15 15 * row - number of items in row
16 16 */
17   -jQuery.fcbkListSelection=function(elem,width,height,row){var getContent=function(elem,tab){switch(tab){case"all":elem.children("li").show();break;case"selected":elem.children("li:not([addedid])").hide();elem.children("li[addedid]").show();break;case"unselected":elem.children("li[addedid]").hide();elem.children("li:not([addedid])").show();break;}}var hiddenCheck=function(obj){switch(curTab()){case"all":elem.children("li").show();break;case"selected":elem.children("li:not([addedid])").hide();elem.children("li[addedid]").show();break;case"unselected":elem.children("li[addedid]").hide();elem.children("li:not([addedid])").show();break;}}var addToSelected=function(obj){if(obj.hasClass("itemselected")){$("#view_selected_count").text(parseInt($("#view_selected_count").text(),10)-1);obj.parents("li").removeAttr("addedid");removeValue(obj);}else{$("#view_selected_count").text(parseInt($("#view_selected_count").text(),10)+1);obj.parents("li").attr("addedid","tester");addValue(obj);}hiddenCheck(obj);}var bindEventsOnItems=function(elem){$.each(elem.children("li").children(".fcbklist_item"),function(i,obj){obj=$(obj);if(obj.children("input[checked]").length!=0){addToSelected(obj);obj.toggleClass("itemselected");obj.parents("li").toggleClass("liselected");}obj.click(function(){addToSelected(obj);obj.toggleClass("itemselected");obj.parents("li").toggleClass("liselected");});obj.mouseover(function(){obj.addClass("itemover");});obj.mouseout(function(){$(".itemover").removeClass("itemover");});});}var bindEventsOnTabs=function(elem){$.each($("#selections li"),function(i,obj){obj=$(obj);obj.click(function(){$(".view_on").removeClass("view_on");obj.addClass("view_on");getContent(elem,obj.attr("id").replace("view_",""));});});}var createTabs=function(elem,width){var html='<div id="filters" style="width:'+(parseInt(width,10)+2)+'px;">'+'<ul class="selections" id="selections"><li id="view_all" class="view_on">'+'<a onclick="return false;" href="#">View All</a></li><li id="view_selected" class="">'+'<a onclick="return false;" href="#">Selected (<strong id="view_selected_count">0</strong>)</a></li>'+'<li id="view_unselected" class=""><a onclick="return false;" href="#">Unselected</a></li></ul>'+'<div class="clearer"></div></div>';elem.before(html);}var wrapElements=function(elem,width,height,row){elem.children("li").wrapInner('<div class="fcbklist_item"></div>');$(".fcbklist_item").css("height",height+"px");var newwidth=Math.ceil((parseInt(width,10))/parseInt(row,10))-11;$(".fcbklist_item").css("width",newwidth+"px");}var addValue=function(obj,value){var inputid=elem.attr('id')+"_values";if($("#"+inputid).length==0){var input=document.createElement('input');$(input).attr({'type':'hidden','name':inputid,'id':inputid,'value':""});elem.after(input);}else{var input=$("#"+inputid);}var randid="rand_"+randomId();if(!value){value=obj.find("[type=hidden]").val();obj.find("[type=hidden]").attr("randid",randid);}var jsdata=new data(randid,value);var stored=jsToString(jsdata,$(input).val());$(input).val(stored);return input;}var jsToString=function(jsdata,json){var string="{";$.each(jsdata,function(i,item){if(i){string+="\""+i+"\":\""+item+"\",";}});try{eval("json = "+json+";");$.each(json,function(i,item){if(i&&item){string+="\""+i+"\":\""+item+"\",";}});}catch(e){}string=string.substr(0,(string.length-1));string+="}"return string;}var data=function(id,value){try{eval("this."+id+" = value;");}catch(e){}}var removeValue=function(obj){var randid=obj.find("[type=hidden]").attr("randid");var inputid=elem.attr('id')+"_values";if($("#"+inputid).length!=0){try{eval("json = "+$("#"+inputid).val()+";");var string="{";$.each(json,function(i,item){if(i&&item&&i!=randid){string+="\""+i+"\":\""+item+"\",";}});if(string.length>2){string=string.substr(0,(string.length-1));string+="}"}else{string="";}$("#"+inputid).val(string);}catch(e){}}}var randomId=function(){var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";var string_length=32;var randomstring='';for(var i=0;i<string_length;i++){var rnum=Math.floor(Math.random()*chars.length);randomstring+=chars.substring(rnum,rnum+1);}return randomstring;}var curTab=function(){return $(".view_on").attr("id").replace("view_","");}if(typeof(elem)!='object')elem=$(elem);elem.css("width",width+"px");createTabs(elem,width);wrapElements(elem,width,height,row);bindEventsOnTabs(elem);bindEventsOnItems(elem);}
  17 +jQuery.fcbkListSelection=function(d,h,j,k){var l=function(b,c){switch(c){case "all":b.children("li").show();break;case "selected":b.children("li:not([addedid])").hide();b.children("li[addedid]").show();break;case "unselected":b.children("li[addedid]").hide();b.children("li:not([addedid])").show();break}},n=function(){switch(m()){case "all":d.children("li").show();break;case "selected":d.children("li:not([addedid])").hide();d.children("li[addedid]").show();break;case "unselected":d.children("li[addedid]").hide(); d.children("li:not([addedid])").show();break}},i=function(b){if(b.hasClass("itemselected")){$("#view_selected_count").text(parseInt($("#view_selected_count").text(),10)-1);b.parents("li").removeAttr("addedid");o(b)}else{$("#view_selected_count").text(parseInt($("#view_selected_count").text(),10)+1);b.parents("li").attr("addedid","tester");p(b)}n(b)},p=function(b,c){var a=d.attr("id")+"_values";if($("#"+a).length==0){var e=document.createElement("input");$(e).attr({type:"hidden",name:a,id:a,value:""}); d.after(e)}else e=$("#"+a);a="rand_"+q();if(!c){c=b.find("[type=hidden]").val();b.find("[type=hidden]").attr("randid",a)}b=new r(a,c);b=s(b,$(e).val());$(e).val(b);return e},s=function(b,c){var a="{";$.each(b,function(f,g){if(f)a+='"'+f+'":"'+g+'",'});try{eval("json = "+c+";");$.each(c,function(f,g){if(f&&g)a+='"'+f+'":"'+g+'",'})}catch(e){}a=a.substr(0,a.length-1);a+="}";return a},r=function(b){try{eval("this."+b+" = value;")}catch(c){}},o=function(b){var c=b.find("[type=hidden]").attr("randid"); b=d.attr("id")+"_values";if($("#"+b).length!=0)try{eval("json = "+$("#"+b).val()+";");var a="{";$.each(json,function(f,g){if(f&&g&&f!=c)a+='"'+f+'":"'+g+'",'});if(a.length>2){a=a.substr(0,a.length-1);a+="}"}else a="";$("#"+b).val(a)}catch(e){}},q=function(){for(var b="",c=0;c<32;c++){var a=Math.floor(Math.random()*61);b+="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".substring(a,a+1)}return b},m=function(){return $(".view_on").attr("id").replace("view_","")};if(typeof d!="object")d= $(d);d.css("width",h+"px");(function(b,c){c='<div id="filters" style="width:'+(parseInt(c,10)+2)+'px;"><ul class="selections" id="selections"><li id="view_all" class="view_on"><a onclick="return false;" href="#">View All</a></li><li id="view_selected" class=""><a onclick="return false;" href="#">Selected (<strong id="view_selected_count">0</strong>)</a></li><li id="view_unselected" class=""><a onclick="return false;" href="#">Unselected</a></li></ul><div class="clearer"></div></div>';b.before(c)})(d, h);(function(b,c,a,e){b.children("li").wrapInner('<div class="fcbklist_item"></div>');$(".fcbklist_item").css("height",a+"px");b=Math.ceil(parseInt(c,10)/parseInt(e,10))-11;$(".fcbklist_item").css("width",b+"px")})(d,h,j,k);(function(b){$.each($("#selections li"),function(c,a){a=$(a);a.click(function(){$(".view_on").removeClass("view_on");a.addClass("view_on");l(b,a.attr("id").replace("view_",""))})})})(d);(function(b){$.each(b.children("li").children(".fcbklist_item"),function(c,a){a=$(a);if(a.children("input[checked]").length!= 0){i(a);a.toggleClass("itemselected");a.parents("li").toggleClass("liselected")}a.click(function(){i(a);a.toggleClass("itemselected");a.parents("li").toggleClass("liselected")});a.mouseover(function(){a.addClass("itemover")});a.mouseout(function(){$(".itemover").removeClass("itemover")})})})(d)};

0 comments on commit b962061

Please sign in to comment.
Something went wrong with that request. Please try again.