UNPKG

cssobj-plugin-localize

Version:
1 lines 1.2 kB
var cssobj_plugin_localize=function(){"use strict";function r(r){return"string"==typeof r}function n(r,n,t){if(r.indexOf(n)<0)return[r];for(var e,a=0,u=0,o="",c=0,s=[];e=r.charAt(a);a++)o?e==o&&"\\"!=r.charAt(a-1)&&(o=""):(('"'==e||"'"==e)&&(o=e),t||(("("==e||"["==e)&&u++,(")"==e||"]"==e)&&u--),u||e!=n||(s.push(r.substring(c,a)),c=a+1));return s.concat(r.substring(c))}function t(t){t=t||{};var u=t.space="string"!=typeof t.space?"function"==typeof t.random?t.random():e():t.space,o=t.localNames=t.localNames||{},c=function(r){return"!"==r[0]?r.substr(1):r in o?o[r]:r+u},s=function(t){if(!r(t))return t;for(var e,u,o=n(t,".",!0),s=o[0],i=1,f=o.length;f>i;i++)e=o[i],e?(u=e.search(a),s+="."+(0>u?c(e):c(e.substr(0,u))+e.substr(u))):s+=".";return s},i=function(n){return r(n)?s(n.replace(/\s+\.?/g,".").replace(/^([^:\s.])/i,".$1")).replace(/\./g," ").trim():n},f=function(r){return r.space=u,r.localNames=o,r.mapSel=s,r.mapClass=i,r};return{selector:function(r,n,t){return n.at?r:(t.mapSel||f(t),s(r))},post:f}}var e=function(){var r=0;return function(n){return r++,"_"+(n||"")+Math.floor(Math.random()*Math.pow(2,32)).toString(36)+r+"_"}}(),a=/[ \~\\@$%^&\*\(\)\+\=,\/';\:"?><[\]\\{}|`]/;return t}();