From d68292d8cb1afd62b8181152d2cf2aab38e3ca3d Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Wed, 3 Apr 2013 10:14:43 +0200 Subject: [PATCH] Fixed issue #07725: jquery.selectboxes is missing --- application/config/third_party.php | 9 + .../controllers/admin/globalsettings.php | 1 - .../views/admin/globalSettings_view.php | 4 + third_party/jquery-selectboxes/README | 13 + .../selectboxes/ChangeLog.txt | 49 ++ .../selectboxes/jquery.selectboxes.js | 553 ++++++++++++++++++ .../selectboxes/jquery.selectboxes.min.js | 14 + .../selectboxes/jquery.selectboxes.pack.js | 14 + 8 files changed, 656 insertions(+), 1 deletion(-) create mode 100644 third_party/jquery-selectboxes/README create mode 100644 third_party/jquery-selectboxes/selectboxes/ChangeLog.txt create mode 100644 third_party/jquery-selectboxes/selectboxes/jquery.selectboxes.js create mode 100644 third_party/jquery-selectboxes/selectboxes/jquery.selectboxes.min.js create mode 100644 third_party/jquery-selectboxes/selectboxes/jquery.selectboxes.pack.js diff --git a/application/config/third_party.php b/application/config/third_party.php index 025951534bc..cee58b1fafd 100644 --- a/application/config/third_party.php +++ b/application/config/third_party.php @@ -137,6 +137,15 @@ 'depends' => array( 'jquery', ) + ), + 'jquery-selectboxes' => array( + 'baseUrl' => 'third_party/jquery-selectboxes/selectboxes', + 'js' => array( + 'jquery.selectboxes.js' + ), + 'depends' => array( + 'jquery' + ) ) diff --git a/application/controllers/admin/globalsettings.php b/application/controllers/admin/globalsettings.php index fc5c42fa088..c99ba45a426 100644 --- a/application/controllers/admin/globalsettings.php +++ b/application/controllers/admin/globalsettings.php @@ -263,7 +263,6 @@ private function _checkSettings() */ protected function _renderWrappedTemplate($sAction = '', $aViewUrls = array(), $aData = array()) { - App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "jquery/jquery.selectboxes.min.js"); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . "globalsettings.js"); parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData); diff --git a/application/views/admin/globalSettings_view.php b/application/views/admin/globalSettings_view.php index 88d21546cd1..68f9b0c2f5a 100644 --- a/application/views/admin/globalSettings_view.php +++ b/application/views/admin/globalSettings_view.php @@ -1,3 +1,7 @@ +getClientScript()->registerPackage('jquery-selectboxes'); + +?> diff --git a/third_party/jquery-selectboxes/README b/third_party/jquery-selectboxes/README new file mode 100644 index 00000000000..48a3c3928c7 --- /dev/null +++ b/third_party/jquery-selectboxes/README @@ -0,0 +1,13 @@ +Plugins for jQuery: + +checkbox manipulation - working with checkboxes +dialogIframe - Opens links in an iframe in a jQuery UI Dialog box +dialogImage - Opens images in a jQuery UI Dialog box +fix Q tags - wrap q tags with proper quotes in Internet Explorer +focus fields - add an outline and background to text inputs when they are given focus +jQIR - replace text with images +newsticker - a news ticker for sequentially showing each item in a list +numeric - allow only numbers to be typed into a text box +preload images - preload any images that you may use in the future (e.g. for image rollovers) +select box manipulation - add/remove options in select boxes as well as sort them +time picker - display a list of times when you click on an input diff --git a/third_party/jquery-selectboxes/selectboxes/ChangeLog.txt b/third_party/jquery-selectboxes/selectboxes/ChangeLog.txt new file mode 100644 index 00000000000..f13b74d3ad3 --- /dev/null +++ b/third_party/jquery-selectboxes/selectboxes/ChangeLog.txt @@ -0,0 +1,49 @@ +Select box manipulation ChangeLog + +8 February 2009 + Sorting no longer has the wrong options selected. selectOptions now takes an array. New selectedTexts (like selectedValues) + +6 October 2008 + ajaxAddOption documentation (in source) update. removeOption can take an array. new selectedOptions + minified version + +17 June 2008 + available under a MIT/GPL dual license. Callback function for containsOption is passed on the index of the found option + +14 December 2007 + removing options by index now works again + +12 September 2007 + new selectedValues plugin - returns values of selected options as an array + +27 July 2007 + cache (created when adding an option) is removed when removing options + if you supply a second parameter to removeOption and it is true, then the option will only be removed + if it is selected as well + +15 June 2007 + addOption is now much faster when adding many options (no longer causing an 'unresponsive script' dialog box) + +22 May 2007 + Packed version available using Dean Edwards' Packer: http://dean.edwards.name/packer/ + +5 April 2007 + ajaxAddOption takes two additional arguments - fn (function to call when after the options have been added) + and args (arguments to pass on to the function) + New containsOption plugin, for checking if an option is within the select list + +20 February 2007 + removeOption can now take a regular expression + (useful if you want to remove multiple options in one go) + +13 February 2007 + addOption can also replace options that already exist with the same value + selectOptions can clear previously selected options + new copyOptions now allows you to copy options from one select to another + +2 February 2007 + Fix for Safari 2.0 - couldn't add option + +5 December 2006 + Select option(s) by value with 'selectOptions' + Based on code by Mathias Bank (http://www.mathias-bank.de) \ No newline at end of file diff --git a/third_party/jquery-selectboxes/selectboxes/jquery.selectboxes.js b/third_party/jquery-selectboxes/selectboxes/jquery.selectboxes.js new file mode 100644 index 00000000000..d98f01e7999 --- /dev/null +++ b/third_party/jquery-selectboxes/selectboxes/jquery.selectboxes.js @@ -0,0 +1,553 @@ +/* + * + * Copyright (c) 2006-2010 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.6 + * Demo: http://www.texotela.co.uk/code/jquery/select/ + * + * + */ + +;(function($) { + +/** + * Adds (single/multiple) options to a select box (or series of select boxes) + * + * @name addOption + * @author Sam Collett (http://www.texotela.co.uk) + * @type jQuery + * @example $("#myselect").addOption("Value", "Text"); // add single value (will be selected) + * @example $("#myselect").addOption("Value 2", "Text 2", false); // add single value (won't be selected) + * @example $("#myselect").addOption({"foo":"bar","bar":"baz"}, false); // add multiple values, but don't select + * + */ +$.fn.addOption = function() +{ + var add = function(el, v, t, sO, index) + { + var option = document.createElement("option"); + option.value = v, option.text = t; + // get options + var o = el.options; + // get number of options + var oL = o.length; + if(!el.cache) + { + el.cache = {}; + // loop through existing options, adding to cache + for(var i = 0; i < oL; i++) + { + el.cache[o[i].value] = i; + } + } + if (index || index == 0) + { + // we're going to insert these starting at a specific index... + // this has the side effect of el.cache[v] being the + // correct value for the typeof check below + var ti = option; + for(var ii =index; ii <= oL; ii++) + { + var tmp = el.options[ii]; + el.options[ii] = ti; + o[ii] = ti; + el.cache[o[ii].value] = ii; + ti = tmp; + } + } + + // add to cache if it isn't already + if(typeof el.cache[v] == "undefined") el.cache[v] = oL; + el.options[el.cache[v]] = option; + if(sO) + { + option.selected = true; + } + }; + + var a = arguments; + if(a.length == 0) return this; + // select option when added? default is true + var sO = true; + // multiple items + var m = false; + // other variables + var items, v, t, startindex = 0; + if(typeof(a[0]) == "object") + { + m = true; + items = a[0]; + } + if(a.length >= 2) + { + if(typeof(a[1]) == "boolean") + { + sO = a[1]; + startindex = a[2]; + } + else if(typeof(a[2]) == "boolean") + { + sO = a[2]; + startindex = a[1]; + } + else + { + startindex = a[1]; + } + if(!m) + { + v = a[0]; + t = a[1]; + } + } + this.each( + function() + { + if(this.nodeName.toLowerCase() != "select") return; + if(m) + { + for(var item in items) + { + add(this, item, items[item], sO, startindex); + startindex += 1; + } + } + else + { + add(this, v, t, sO, startindex); + } + } + ); + return this; +}; + +/** + * Add options via ajax + * + * @name ajaxAddOption + * @author Sam Collett (http://www.texotela.co.uk) + * @type jQuery + * @param String url Page to get options from (must be valid JSON) + * @param Object params (optional) Any parameters to send with the request + * @param Boolean select (optional) Select the added options, default true + * @param Function fn (optional) Call this function with the select object as param after completion + * @param Array args (optional) Array with params to pass to the function afterwards + * @example $("#myselect").ajaxAddOption("myoptions.php"); + * @example $("#myselect").ajaxAddOption("myoptions.php", {"code" : "007"}); + * @example $("#myselect").ajaxAddOption("myoptions.php", {"code" : "007"}, false, sortoptions, [{"dir": "desc"}]); + * + */ +$.fn.ajaxAddOption = function(url, params, select, fn, args) +{ + if(typeof(url) != "string") return this; + if(typeof(params) != "object") params = {}; + if(typeof(select) != "boolean") select = true; + this.each( + function() + { + var el = this; + $.getJSON(url, + params, + function(r) + { + $(el).addOption(r, select); + if(typeof fn == "function") + { + if(typeof args == "object") + { + fn.apply(el, args); + } + else + { + fn.call(el); + } + } + } + ); + } + ); + return this; +}; + +/** + * Removes an option (by value or index) from a select box (or series of select boxes) + * + * @name removeOption + * @author Sam Collett (http://www.texotela.co.uk) + * @type jQuery + * @param String|RegExp|Number what Option to remove + * @param Boolean selectedOnly (optional) Remove only if it has been selected (default false) + * @example $("#myselect").removeOption("Value"); // remove by value + * @example $("#myselect").removeOption(/^val/i); // remove options with a value starting with 'val' + * @example $("#myselect").removeOption(/./); // remove all options + * @example $("#myselect").removeOption(/./, true); // remove all options that have been selected + * @example $("#myselect").removeOption(0); // remove by index + * @example $("#myselect").removeOption(["myselect_1","myselect_2"]); // values contained in passed array + * + */ +$.fn.removeOption = function() +{ + var a = arguments; + if(a.length == 0) return this; + var ta = typeof(a[0]); + var v, index; + // has to be a string or regular expression (object in IE, function in Firefox) + if(ta == "string" || ta == "object" || ta == "function" ) + { + v = a[0]; + // if an array, remove items + if(v.constructor == Array) + { + var l = v.length; + for(var i = 0; i=0; i--) + { + if(v.constructor == RegExp) + { + if(o[i].value.match(v)) + { + remove = true; + } + } + else if(o[i].value == v) + { + remove = true; + } + // if the option is only to be removed if selected + if(remove && a[1] === true) remove = o[i].selected; + if(remove) + { + o[i] = null; + } + remove = false; + } + } + else + { + // only remove if selected? + if(a[1] === true) + { + remove = o[index].selected; + } + else + { + remove = true; + } + if(remove) + { + this.remove(index); + } + } + } + ); + return this; +}; + +/** + * Sort options (ascending or descending) in a select box (or series of select boxes) + * + * @name sortOptions + * @author Sam Collett (http://www.texotela.co.uk) + * @type jQuery + * @param Boolean ascending (optional) Sort ascending (true/undefined), or descending (false) + * @example // ascending + * $("#myselect").sortOptions(); // or $("#myselect").sortOptions(true); + * @example // descending + * $("#myselect").sortOptions(false); + * + */ +$.fn.sortOptions = function(ascending) +{ + // get selected values first + var sel = $(this).selectedValues(); + var a = typeof(ascending) == "undefined" ? true : !!ascending; + this.each( + function() + { + if(this.nodeName.toLowerCase() != "select") return; + // get options + var o = this.options; + // get number of options + var oL = o.length; + // create an array for sorting + var sA = []; + // loop through options, adding to sort array + for(var i = 0; i o2t ? -1 : 1; + } + } + ); + // change the options to match the sort array + for(var i = 0; i=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=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;go2t?-1:1});for(g=0;g35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(6($){$.u.N=6(){5 j=6(a,v,t,b,c){5 d=11.12("U");d.p=v,d.H=t;5 o=a.z;5 e=o.q;3(!a.A){a.A={};x(5 i=0;i=2){3(9(a[1])=="O"){k=a[1];E=a[2]}n 3(9(a[2])=="O"){k=a[2];E=a[1]}n{E=a[1]}3(!m){v=a[0];t=a[1]}}4.y(6(){3(4.F.C()!="G")7;3(m){x(5 a 13 l){j(4,a,l[a],k,E);E+=1}}n{j(4,v,t,k,E)}});7 4};$.u.14=6(b,c,d,e,f){3(9(b)!="J")7 4;3(9(c)!="D")c={};3(9(d)!="O")d=8;4.y(6(){5 a=4;$.15(b,c,6(r){$(a).N(r,d);3(9 e=="6"){3(9 f=="D"){e.16(a,f)}n{e.P(a)}}})});7 4};$.u.X=6(){5 a=W;3(a.q==0)7 4;5 d=9(a[0]);5 v,K;3(d=="J"||d=="D"||d=="6"){v=a[0];3(v.I==Y){5 l=v.q;x(5 i=0;i=0;i--){3(v.I==Q){3(o[i].p.R(v)){b=8}}n 3(o[i].p==v){b=8}3(b&&a[1]===8)b=o[i].s;3(b){o[i]=Z}b=B}}n{3(a[1]===8){b=o[K].s}n{b=8}3(b){4.18(K)}}});7 4};$.u.19=6(f){5 g=$(4).10();5 a=9(f)=="V"?8:!!f;4.y(6(){3(4.F.C()!="G")7;5 o=4.z;5 d=o.q;5 e=[];x(5 i=0;iM?-1:1}});x(5 i=0;i