o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1373188285.7630644: @value"&#{I" class:EFI"ProcessedAsset;FI"logical_path;F"2jquery/fcbkListSelection/fcbklistselection.jsI" pathname;F"t/home/bigxiang/RubyMineWorkspace/bs-helper/app/assets/javascripts/jquery/fcbkListSelection/fcbklistselection.jsI"content_type;FI"application/javascript;FI" mtime;FI"2013-06-18T17:30:50+08:00;FI" length;Fi§I" digest;F"%08aab4fc5589972ff5f9370a46cd5994I" source;FI"§/* fcbkListSelection 1.10 - Jquery version required: 1.2.x, 1.3.x, 1.4.x Changelog: - 1.1: added preselected items - 1.0: project started */ /* Coded by: emposha */ /* Copyright: Emposha.com - Distributed under MIT - Keep this message! */ /* * elem - ul element id or object * width - width of ul * height - height of each element * row - number of items in row */ jQuery.fcbkListSelection = function(elem, width, height, row){ //get content of tabs 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; } } //add to selected items function var addToSelected = function(obj){ var count = parseInt(obj.parents('.fcbklist').prev('#filters').find('#view_selected_count').text(), 10); if (obj.hasClass("itemselected")) { obj.parents('.fcbklist').prev('#filters').find('#view_selected_count').text(count - 1); obj.parents("li").removeAttr("addedid"); removeValue(obj); } else { obj.parents('.fcbklist').prev('#filters').find('#view_selected_count').text(count + 1); obj.parents("li").attr("addedid", "tester"); addValue(obj); } hiddenCheck(obj); } //bind onmouseover && click event on item 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"); }); }); } //bind onclick event on filters 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_", "")); }); }); } //create control tabs var createTabs = function(elem, width){ var html = ''; elem.before(html); } //wrap elements with div var wrapElements = function(elem, width, height, row){ elem.children("li").wrapInner('
'); $(".fcbklist_item").css("height", height + "px"); var newwidth = Math.ceil((parseInt(width, 10) - 40) / parseInt(row, 10)) - 11; $(".fcbklist_item").css("width", newwidth + "px"); } var addValue = function(obj, value){ var input = $(obj).children('input[type=checkbox]').attr('checked', 'checked'); // //create input // 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) { } //remove last , 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){ $(obj).children('input[type=checkbox]').removeAttr('checked'); // 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 + "\","; // } // }); // //remove last , // 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_", ""); } //main if (typeof(elem) != 'object') elem = $(elem); elem.css("width", width + "px"); createTabs(elem, width); wrapElements(elem, width, height, row); bindEventsOnTabs(elem); bindEventsOnItems(elem); } ; ;TI"dependency_digest;F"%5730953f1759635f6f41d989943fe0a2I"required_paths;F["t/home/bigxiang/RubyMineWorkspace/bs-helper/app/assets/javascripts/jquery/fcbkListSelection/fcbklistselection.jsI"dependency_paths;F[{I" path;F"t/home/bigxiang/RubyMineWorkspace/bs-helper/app/assets/javascripts/jquery/fcbkListSelection/fcbklistselection.jsI" mtime;FI"2013-06-18T17:30:50+08:00;FI" digest;F"%3e17bca3151a5e299bdff6be1d563f1dI" _version;F"%6776f581a4329e299531e1d52aa59832