PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/wp-ui/js/select/init.js

https://gitlab.com/Blueprint-Marketing/interoccupy.net
JavaScript | 274 lines | 171 code | 23 blank | 80 comment | 15 complexity | a8c85d82304af69e4e39750962441324 MD5 | raw file
  1. /**
  2. * The included files and init below.
  3. */
  4. if(typeof String.prototype.trim !== 'function') {
  5. String.prototype.trim = function() {
  6. return this.replace(/^\s+|\s+$/g, '');
  7. }
  8. }
  9. if(!Array.indexOf){
  10. Array.prototype.indexOf = function(obj){
  11. for(var i=0; i<this.length; i++){
  12. if(this[i]==obj){
  13. return i;
  14. }
  15. }
  16. }
  17. }
  18. /**
  19. * jQuery Cookie plugin
  20. *
  21. * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
  22. * Dual licensed under the MIT and GPL licenses:
  23. * http://www.opensource.org/licenses/mit-license.php
  24. * http://www.gnu.org/licenses/gpl.html
  25. *
  26. */
  27. // TODO JsDoc
  28. /**
  29. * Create a cookie with the given key and value and other optional parameters.
  30. *
  31. * @example $.cookie('the_cookie', 'the_value');
  32. * @desc Set the value of a cookie.
  33. * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
  34. * @desc Create a cookie with all available options.
  35. * @example $.cookie('the_cookie', 'the_value');
  36. * @desc Create a session cookie.
  37. * @example $.cookie('the_cookie', null);
  38. * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
  39. * used when the cookie was set.
  40. *
  41. * @param String key The key of the cookie.
  42. * @param String value The value of the cookie.
  43. * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
  44. * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
  45. * If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
  46. * If set to null or omitted, the cookie will be a session cookie and will not be retained
  47. * when the the browser exits.
  48. * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
  49. * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
  50. * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
  51. * require a secure protocol (like HTTPS).
  52. * @type undefined
  53. *
  54. * @name $.cookie
  55. * @cat Plugins/Cookie
  56. * @author Klaus Hartl/klaus.hartl@stilbuero.de
  57. */
  58. /**
  59. * Get the value of a cookie with the given key.
  60. *
  61. * @example $.cookie('the_cookie');
  62. * @desc Get the value of a cookie.
  63. *
  64. * @param String key The key of the cookie.
  65. * @return The value of the cookie.
  66. * @type String
  67. *
  68. * @name $.cookie
  69. * @cat Plugins/Cookie
  70. * @author Klaus Hartl/klaus.hartl@stilbuero.de
  71. */
  72. jQuery.cookie = function (key, value, options) {
  73. // key and value given, set cookie...
  74. if (arguments.length > 1 && (value === null || typeof value !== "object")) {
  75. options = jQuery.extend({}, options);
  76. if (value === null) {
  77. options.expires = -1;
  78. }
  79. if (typeof options.expires === 'number') {
  80. var days = options.expires, t = options.expires = new Date();
  81. t.setDate(t.getDate() + days);
  82. }
  83. return (document.cookie = [
  84. encodeURIComponent(key), '=',
  85. options.raw ? String(value) : encodeURIComponent(String(value)),
  86. options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  87. options.path ? '; path=' + options.path : '',
  88. options.domain ? '; domain=' + options.domain : '',
  89. options.secure ? '; secure' : ''
  90. ].join(''));
  91. }
  92. // key and possibly options given, get cookie...
  93. options = value || {};
  94. var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
  95. return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
  96. };
  97. if ( typeof wpUIOpts == 'object' && wpUIOpts.docWriteFix == 'on' ) {
  98. var docWriteTxt = "";
  99. jQuery(function() {
  100. document.write = function( dWT ) {
  101. docWriteTxt += dWT;
  102. }
  103. // document.write("");
  104. jQuery( docWriteTxt ).appendTo( 'body' );
  105. });
  106. } // END doc write fix.
  107. /*
  108. * jQuery BBQ: Back Button & Query Library - v1.3pre - 8/26/2010
  109. * http://benalman.com/projects/jquery-bbq-plugin/
  110. *
  111. * Copyright (c) 2010 "Cowboy" Ben Alman
  112. * Dual licensed under the MIT and GPL licenses.
  113. * http://benalman.com/about/license/
  114. */
  115. (function($,r){var h,n=Array.prototype.slice,t=decodeURIComponent,a=$.param,j,c,m,y,b=$.bbq=$.bbq||{},s,x,k,e=$.event.special,d="hashchange",B="querystring",F="fragment",z="elemUrlAttr",l="href",w="src",p=/^.*\?|#.*$/g,u,H,g,i,C,E={};function G(I){return typeof I==="string"}function D(J){var I=n.call(arguments,1);return function(){return J.apply(this,I.concat(n.call(arguments)))}}function o(I){return I.replace(H,"$2")}function q(I){return I.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(K,P,I,L,J){var R,O,N,Q,M;if(L!==h){N=I.match(K?H:/^([^#?]*)\??([^#]*)(#?.*)/);M=N[3]||"";if(J===2&&G(L)){O=L.replace(K?u:p,"")}else{Q=m(N[2]);L=G(L)?m[K?F:B](L):L;O=J===2?L:J===1?$.extend({},L,Q):$.extend({},Q,L);O=j(O);if(K){O=O.replace(g,t)}}R=N[1]+(K?C:O||!N[1]?"?":"")+O+M}else{R=P(I!==h?I:location.href)}return R}a[B]=D(f,0,q);a[F]=c=D(f,1,o);a.sorted=j=function(J,K){var I=[],L={};$.each(a(J,K).split("&"),function(P,M){var O=M.replace(/(?:%5B|=).*$/,""),N=L[O];if(!N){N=L[O]=[];I.push(O)}N.push(M)});return $.map(I.sort(),function(M){return L[M]}).join("&")};c.noEscape=function(J){J=J||"";var I=$.map(J.split(""),encodeURIComponent);g=new RegExp(I.join("|"),"g")};c.noEscape(",/");c.ajaxCrawlable=function(I){if(I!==h){if(I){u=/^.*(?:#!|#)/;H=/^([^#]*)(?:#!|#)?(.*)$/;C="#!"}else{u=/^.*#/;H=/^([^#]*)#?(.*)$/;C="#"}i=!!I}return i};c.ajaxCrawlable(0);$.deparam=m=function(L,I){var K={},J={"true":!0,"false":!1,"null":null};$.each(L.replace(/\+/g," ").split("&"),function(O,T){var N=T.split("="),S=t(N[0]),M,R=K,P=0,U=S.split("]["),Q=U.length-1;if(/\[/.test(U[0])&&/\]$/.test(U[Q])){U[Q]=U[Q].replace(/\]$/,"");U=U.shift().split("[").concat(U);Q=U.length-1}else{Q=0}if(N.length===2){M=t(N[1]);if(I){M=M&&!isNaN(M)?+M:M==="undefined"?h:J[M]!==h?J[M]:M}if(Q){for(;P<=Q;P++){S=U[P]===""?R.length:U[P];R=R[S]=P<Q?R[S]||(U[P+1]&&isNaN(U[P+1])?{}:[]):M}}else{if($.isArray(K[S])){K[S].push(M)}else{if(K[S]!==h){K[S]=[K[S],M]}else{K[S]=M}}}}else{if(S){K[S]=I?h:""}}});return K};function A(K,I,J){if(I===h||typeof I==="boolean"){J=I;I=a[K?F:B]()}else{I=G(I)?I.replace(K?u:p,""):I}return m(I,J)}m[B]=D(A,0);m[F]=y=D(A,1);$[z]||($[z]=function(I){return $.extend(E,I)})({a:l,base:l,iframe:w,img:w,input:w,form:"action",link:l,script:w});k=$[z];function v(L,J,K,I){if(!G(K)&&typeof K!=="object"){I=K;K=J;J=h}return this.each(function(){var O=$(this),M=J||k()[(this.nodeName||"").toLowerCase()]||"",N=M&&O.attr(M)||"";O.attr(M,a[L](N,K,I))})}$.fn[B]=D(v,B);$.fn[F]=D(v,F);b.pushState=s=function(L,I){if(G(L)&&/^#/.test(L)&&I===h){I=2}var K=L!==h,J=c(location.href,K?L:{},K?I:2);location.href=J};b.getState=x=function(I,J){return I===h||typeof I==="boolean"?y(I):y(J)[I]};b.removeState=function(I){var J={};if(I!==h){J=x();$.each($.isArray(I)?I:arguments,function(L,K){delete J[K]})}s(J,2)};e[d]=$.extend(e[d],{add:function(I){var K;function J(M){var L=M[F]=c();M.getState=function(N,O){return N===h||typeof N==="boolean"?m(L,N):m(L,O)[N]};K.apply(this,arguments)}if($.isFunction(I)){K=I;return J}else{K=I.handler;I.handler=J}}})})(jQuery,this);
  116. /*
  117. * jQuery hashchange event - v1.3 - 7/21/2010
  118. * http://benalman.com/projects/jquery-hashchange-plugin/
  119. *
  120. * Copyright (c) 2010 "Cowboy" Ben Alman
  121. * Dual licensed under the MIT and GPL licenses.
  122. * http://benalman.com/about/license/
  123. */
  124. (function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this);
  125. jQuery.fn.extend({
  126. hashchange : function(fn) {
  127. return fn ? this.bind("hashchange", fn) : this.trigger("hashchange");
  128. }
  129. });
  130. /*
  131. * JSON Library
  132. * https://github.com/douglascrockford/JSON-js/blob/master/json2.js
  133. */
  134. var JSON;if(!JSON){JSON={};}
  135. (function(){"use strict";function f(n){return n<10?'0'+n:n;}
  136. if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
  137. f(this.getUTCMonth()+1)+'-'+
  138. f(this.getUTCDate())+'T'+
  139. f(this.getUTCHours())+':'+
  140. f(this.getUTCMinutes())+':'+
  141. f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
  142. var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
  143. function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
  144. if(typeof rep==='function'){value=rep.call(holder,key,value);}
  145. switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
  146. gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
  147. v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}
  148. if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==='string'){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
  149. v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
  150. if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
  151. rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
  152. return str('',{'':value});};}
  153. if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
  154. return reviver.call(holder,key,value);}
  155. text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
  156. ('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
  157. if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
  158. throw new SyntaxError('JSON.parse');};}}());
  159. /* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
  160. * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
  161. * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
  162. * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
  163. * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
  164. *
  165. * Version: 3.0.2
  166. *
  167. * Requires: 1.2.2+
  168. */
  169. (function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);
  170. /**
  171. * Init the scripts.
  172. */
  173. jQuery(document).ready(function( $ ) {
  174. if ( typeof wpUIOpts == 'object' ) {
  175. if ( wpUIOpts.enablePagination == 'on' &&
  176. typeof jQuery.fn.wpuiPager == 'function' )
  177. jQuery( 'div.wpui-pages-holder' ).wpuiPager();
  178. if ( wpUIOpts.enableTabs == 'on' &&
  179. typeof jQuery.fn.wptabs == 'function')
  180. jQuery('div.wp-tabs').wptabs();
  181. if ( wpUIOpts.enableSpoilers == 'on' &&
  182. typeof jQuery.fn.wpspoiler == 'function')
  183. jQuery('.wp-spoiler').wpspoiler();
  184. if ( wpUIOpts.enableAccordion == 'on' &&
  185. typeof jQuery.fn.wpaccord == 'function')
  186. jQuery('.wp-accordion').wpaccord();
  187. }
  188. });
  189. (function( $ ) {
  190. if ( ! $.wpui ) $.wpui = {};
  191. if ( ! $.wpui.ids ) $.wpui.ids = {};
  192. if ( ! $.wpui.tabsNo ) $.wpui.tabsNo = 0;
  193. var wpUIOpts = window.wpUIOpts || {}, console = window.console;
  194. /// Enable Misc options.
  195. if ( typeof( wpUIOpts.misc_options ) != 'undefined' ) {
  196. var misc_opts = wpUIOpts.misc_options.split( "\n" ), misc_opts1={};
  197. for ( var i=0; i<misc_opts.length; i++ ) {
  198. doo = misc_opts[ i ].split('=');
  199. misc_opts1[ doo[ 0 ] ] = doo[ 1 ];
  200. }
  201. wpUIOpts.misc_opts = misc_opts1;
  202. }
  203. // Return treated ID strings.
  204. if ( typeof( $.wpui.getIds ) == 'undefined' ) {
  205. $.wpui.getIds = function( str, par ) {
  206. var num = $.wpui.tabsNo, dup;
  207. if ( typeof($.wpui.ids[ par ] ) == 'undefined' )
  208. $.wpui.ids[ par ] = [];
  209. str = $.trim(str).replace(/\s{1,}/gm, '_')
  210. .replace( /[^\-A-Za-z0-9\s_]/mg, '')
  211. .toLowerCase();
  212. for ( dup in $.wpui.ids ) {
  213. if ( $.inArray( str, $.wpui.ids[ dup ] ) != '-1' || $( '#' + str ).length ) {
  214. str = str + '-' + num;
  215. }
  216. }
  217. // characters.
  218. if ( str.match( /[^\x00-\x80]+/ ) ) {
  219. str = 'tabs-' + num;
  220. }
  221. $.wpui.ids[ par ].push( str );
  222. $.wpui.tabsNo++;
  223. return str;
  224. };
  225. }
  226. })( jQuery );