/*! * jquery.sumoselect - v2.1.0 * http://hemantnegi.github.io/jquery.sumoselect * 2014-04-08 * * Copyright 2015 Hemant Negi * Email : hemant.frnz@gmail.com * Compressor http://refresh-sf.com/ */ (function ($) { 'namespace sumo'; $.fn.SumoSelect = function (options) { // var is_visible_default = false; //$(document).click(function () { is_visible_default = false; }); // This is the easiest way to have default options. var settings = $.extend({ placeholder: 'Select Here', // Dont change it here. csvDispCount: 3, // display no. of items in multiselect. 0 to display all. captionFormat:'{0} Selected', // format of caption text. you can set your locale. floatWidth: 400, // Screen width of device at which the list is rendered in floating popup fashion. forceCustomRendering: false, // force the custom modal on all devices below floatWidth resolution. nativeOnDevice: ['Android', 'BlackBerry', 'iPhone', 'iPad', 'iPod', 'Opera Mini', 'IEMobile', 'Silk'], // outputAsCSV: false, // true to POST data as csv ( false for Html control array ie. deafault select ) csvSepChar: ',', // seperation char in csv mode okCancelInMulti: false, //display ok cancel buttons in desktop mode multiselect also. triggerChangeCombined: true, // im multi select mode wether to trigger change event on individual selection or combined selection. selectAll: false, // to display select all button in multiselect mode.|| also select all will not be available on mobile devices. selectAlltext: 'Select All', // the text to display for select all. filter: false, // to display input for filtering content. selectAlltext will be input text placeholder filterText: 'Search...' // to display input for filtering content. selectAlltext will be input text placeholder }, options); var ret = this.each(function () { var selObj = this; // the original select object. if (this.sumo || !$(this).is('select')) return; //already initialized this.sumo = { E: $(selObj), //the jquery object of original select element. is_multi: $(selObj).attr('multiple'), //if its a mmultiple select select: '', caption: '', placeholder: '', optDiv: '', CaptionCont: '', is_floating: false, is_opened: false, //backdrop: '', mob:false, // if to open device default select Pstate: [], createElems: function () { var O = this; O.E.wrap('
'); O.select = O.E.parent(); O.caption = $(''); O.CaptionCont = $('

').addClass('SlectBox').attr('style', O.E.attr('style')).prepend(O.caption); O.select.append(O.CaptionCont); if(O.E.attr('disabled')) O.select.addClass('disabled').removeAttr('tabindex'); //if output as csv and is a multiselect. if (settings.outputAsCSV && O.is_multi && O.E.attr('name')) { //create a hidden field to store csv value. O.select.append($('').attr('name', O.E.attr('name')).val(O.getSelStr())); // so it can not post the original select. O.E.removeAttr('name'); } //break for mobile rendring.. if forceCustomRendering is false if (O.isMobile() && !settings.forceCustomRendering) { O.setNativeMobile(); return; } //hide original select O.E.hide(); //## Creating the list... O.optDiv = $('
'); //branch for floating list in low res devices. O.floatingList(); //Creating the markup for the available options ul = $('