mirror of
https://github.com/YunoHost-Apps/limesurvey_ynh.git
synced 2024-09-03 19:36:32 +02:00
14 lines
No EOL
3.8 KiB
JavaScript
14 lines
No EOL
3.8 KiB
JavaScript
/*
|
|
*
|
|
* Copyright (c) 2006-2008 Sam Collett (http://www.texotela.co.uk)
|
|
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
|
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
|
*
|
|
* Version 2.2.4
|
|
* Demo: http://www.texotela.co.uk/code/jquery/select/
|
|
*
|
|
* $LastChangedDate: 2008-06-17 17:27:25 +0100 (Tue, 17 Jun 2008) $
|
|
* $Rev: 5727 $
|
|
*
|
|
*/
|
|
(function(i){i.b.e=function(){function b(a,l,m,p,j){var n=document.createElement("option");n.value=l;n.text=m;m=a.options;var o=m.length;if(!a.c){a.c={};for(var k=0;k<o;k++)a.c[m[k].value]=k}if(j||j==0){k=n;for(j=j;j<=o;j++){var q=a.options[j];a.options[j]=k;m[j]=k;a.c[m[j].value]=j;k=q}}if(typeof a.c[l]=="undefined")a.c[l]=o;a.options[a.c[l]]=n;if(p)n.selected=true}var d=arguments;if(d.length==0)return this;var e=true,f=false,h,c,g;if(typeof d[0]=="object"){f=true;h=d[0]}if(d.length>=2){if(typeof d[1]== "boolean"){e=d[1];startindex=d[2]}else{if(typeof d[2]=="boolean")e=d[2];startindex=d[1]}if(!f){c=d[0];g=d[1]}}this.a(function(){if(this.nodeName.toLowerCase()=="select")if(f)for(var a in h){b(this,a,h[a],e,startindex);startindex+=1}else b(this,c,g,e,startindex)});return this};i.b.k=function(b,d,e,f,h){if(typeof b!="string")return this;if(typeof d!="object")d={};if(typeof e!="boolean")e=true;this.a(function(){var c=this;i.n(b,d,function(g){i(c).e(g,e);if(typeof f=="function")typeof h=="object"?f.apply(c, h):f.call(c)})});return this};i.b.h=function(){var b=arguments;if(b.length==0)return this;var d=typeof b[0],e,f;if(d=="string"||d=="object"||d=="function"){e=b[0];if(e.constructor==Array){d=e.length;for(var h=0;h<d;h++)this.h(e[h],b[1]);return this}}else if(d=="number")f=b[0];else return this;this.a(function(){if(this.nodeName.toLowerCase()=="select"){if(this.c)this.c=null;var c=false,g=this.options;if(e)for(var a=g.length-1;a>=0;a--){if(e.constructor==RegExp){if(g[a].value.match(e))c=true}else if(g[a].value== e)c=true;if(c&&b[1]===true)c=g[a].selected;if(c)g[a]=null;c=false}else(c=b[1]===true?g[f].selected:true)&&this.remove(f)}});return this};i.b.p=function(b){var d=i(this).i(),e=typeof b=="undefined"?true:!!b;this.a(function(){if(this.nodeName.toLowerCase()=="select"){for(var f=this.options,h=f.length,c=[],g=0;g<h;g++)c[g]={j:f[g].value,d:f[g].text};c.sort(function(a,l){o1t=a.d.toLowerCase();o2t=l.d.toLowerCase();if(o1t==o2t)return 0;return e?o1t<o2t?-1:1:o1t>o2t?-1:1});for(g=0;g<h;g++){f[g].text=c[g].d; f[g].value=c[g].j}}}).f(d,true);return this};i.b.f=function(b,d){var e=typeof b;if(e=="object"&&b.constructor==Array){var f=this;i.a(b,function(){f.f(this,d)})}var h=d||false;if(e!="string"&&e!="function"&&e!="object")return this;this.a(function(){if(this.nodeName.toLowerCase()!="select")return this;for(var c=this.options,g=c.length,a=0;a<g;a++)if(b.constructor==RegExp)if(c[a].value.match(b))c[a].selected=true;else{if(h)c[a].selected=false}else if(c[a].value==b)c[a].selected=true;else if(h)c[a].selected= false});return this};i.b.m=function(b,d){var e=d||"selected";if(i(b).size()==0)return this;this.a(function(){if(this.nodeName.toLowerCase()!="select")return this;for(var f=this.options,h=f.length,c=0;c<h;c++)if(e=="all"||e=="selected"&&f[c].selected)i(b).e(f[c].value,f[c].text)});return this};i.b.l=function(b,d){var e=false,f=typeof b,h=typeof d;if(f!="string"&&f!="function"&&f!="object")return h=="function"?this:e;this.a(function(){if(this.nodeName.toLowerCase()!="select")return this;if(e&&h!="function")return false; for(var c=this.options,g=c.length,a=0;a<g;a++)if(b.constructor==RegExp){if(c[a].value.match(b)){e=true;h=="function"&&d.call(c[a],a)}}else if(c[a].value==b){e=true;h=="function"&&d.call(c[a],a)}});return h=="function"?this:e};i.b.i=function(){var b=[];this.g().a(function(){b[b.length]=this.value});return b};i.b.o=function(){var b=[];this.g().a(function(){b[b.length]=this.text});return b};i.b.g=function(){return this.find("option:selected")}})(jQuery); |