]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/shortcode.min.js
WordPress 3.8-scripts
[autoinstalls/wordpress.git] / wp-includes / js / shortcode.min.js
index a3d967194344c85d6e5724feae84341d588ee941..0323a993f0134b96352845dae16df6ee11675663 100644 (file)
@@ -1 +1 @@
-window.wp=window.wp||{};(function(){wp.shortcode={next:function(b,f,d){var e=wp.shortcode.regexp(b),c,a;e.lastIndex=d||0;c=e.exec(f);if(!c){return}if(c[1]==="["&&c[7]==="]"){return wp.shortcode.next(b,f,e.lastIndex)}a={index:c.index,content:c[0],shortcode:wp.shortcode.fromMatch(c)};if(c[1]){a.match=a.match.slice(1);a.index++}if(c[7]){a.match=a.match.slice(0,-1)}return a},replace:function(a,b,c){return b.replace(wp.shortcode.regexp(a),function(h,d,m,k,g,i,e,j,f){if(d==="["&&j==="]"){return h}var l=c(wp.shortcode.fromMatch(arguments));return l?d+l+j:h})},string:function(a){return new wp.shortcode(a).string()},regexp:_.memoize(function(a){return new RegExp("\\[(\\[?)("+a+")(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)","g")}),attrs:_.memoize(function(e){var a={},c=[],d,b;d=/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/g;e=e.replace(/[\u00a0\u200b]/g," ");while((b=d.exec(e))){if(b[1]){a[b[1].toLowerCase()]=b[2]}else{if(b[3]){a[b[3].toLowerCase()]=b[4]}else{if(b[5]){a[b[5].toLowerCase()]=b[6]}else{if(b[7]){c.push(b[7])}else{if(b[8]){c.push(b[8])}}}}}}return{named:a,numeric:c}}),fromMatch:function(a){var b;if(a[4]){b="self-closing"}else{if(a[6]){b="closed"}else{b="single"}}return new wp.shortcode({tag:a[2],attrs:a[3],type:b,content:a[5]})}};wp.shortcode=_.extend(function(b){_.extend(this,_.pick(b||{},"tag","attrs","type","content"));var a=this.attrs;this.attrs={named:{},numeric:[]};if(!a){return}if(_.isString(a)){this.attrs=wp.shortcode.attrs(a)}else{if(_.isEqual(_.keys(a),["named","numeric"])){this.attrs=a}else{_.each(b.attrs,function(d,c){this.set(c,d)},this)}}},wp.shortcode);_.extend(wp.shortcode.prototype,{get:function(a){return this.attrs[_.isNumber(a)?"numeric":"named"][a]},set:function(a,b){this.attrs[_.isNumber(a)?"numeric":"named"][a]=b;return this},string:function(){var a="["+this.tag;_.each(this.attrs.numeric,function(b){if(/\s/.test(b)){a+=' "'+b+'"'}else{a+=" "+b}});_.each(this.attrs.named,function(c,b){a+=" "+b+'="'+c+'"'});if("single"===this.type){return a+"]"}else{if("self-closing"===this.type){return a+" /]"}}a+="]";if(this.content){a+=this.content}return a+"[/"+this.tag+"]"}})}());(function(){wp.html=_.extend(wp.html||{},{attrs:function(c){var a,b;if("/"===c[c.length-1]){c=c.slice(0,-1)}a=wp.shortcode.attrs(c);b=a.named;_.each(a.numeric,function(d){if(/\s/.test(d)){return}b[d]=""});return b},string:function(a){var c="<"+a.tag,b=a.content||"";_.each(a.attrs,function(e,d){c+=" "+d;if(""===e){return}if(_.isBoolean(e)){e=e?"true":"false"}c+='="'+e+'"'});if(a.single){return c+" />"}c+=">";c+=_.isObject(b)?wp.html.string(b):b;return c+"</"+a.tag+">"}})}());
\ No newline at end of file
+window.wp=window.wp||{},function(){wp.shortcode={next:function(a,b,c){var d,e,f=wp.shortcode.regexp(a);return f.lastIndex=c||0,(d=f.exec(b))?"["===d[1]&&"]"===d[7]?wp.shortcode.next(a,b,f.lastIndex):(e={index:d.index,content:d[0],shortcode:wp.shortcode.fromMatch(d)},d[1]&&(e.match=e.match.slice(1),e.index++),d[7]&&(e.match=e.match.slice(0,-1)),e):void 0},replace:function(a,b,c){return b.replace(wp.shortcode.regexp(a),function(a,b,d,e,f,g,h,i){if("["===b&&"]"===i)return a;var j=c(wp.shortcode.fromMatch(arguments));return j?b+j+i:a})},string:function(a){return new wp.shortcode(a).string()},regexp:_.memoize(function(a){return new RegExp("\\[(\\[?)("+a+")(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)","g")}),attrs:_.memoize(function(a){var b,c,d={},e=[];for(b=/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/g,a=a.replace(/[\u00a0\u200b]/g," ");c=b.exec(a);)c[1]?d[c[1].toLowerCase()]=c[2]:c[3]?d[c[3].toLowerCase()]=c[4]:c[5]?d[c[5].toLowerCase()]=c[6]:c[7]?e.push(c[7]):c[8]&&e.push(c[8]);return{named:d,numeric:e}}),fromMatch:function(a){var b;return b=a[4]?"self-closing":a[6]?"closed":"single",new wp.shortcode({tag:a[2],attrs:a[3],type:b,content:a[5]})}},wp.shortcode=_.extend(function(a){_.extend(this,_.pick(a||{},"tag","attrs","type","content"));var b=this.attrs;this.attrs={named:{},numeric:[]},b&&(_.isString(b)?this.attrs=wp.shortcode.attrs(b):_.isEqual(_.keys(b),["named","numeric"])?this.attrs=b:_.each(a.attrs,function(a,b){this.set(b,a)},this))},wp.shortcode),_.extend(wp.shortcode.prototype,{get:function(a){return this.attrs[_.isNumber(a)?"numeric":"named"][a]},set:function(a,b){return this.attrs[_.isNumber(a)?"numeric":"named"][a]=b,this},string:function(){var a="["+this.tag;return _.each(this.attrs.numeric,function(b){a+=/\s/.test(b)?' "'+b+'"':" "+b}),_.each(this.attrs.named,function(b,c){a+=" "+c+'="'+b+'"'}),"single"===this.type?a+"]":"self-closing"===this.type?a+" /]":(a+="]",this.content&&(a+=this.content),a+"[/"+this.tag+"]")}})}(),function(){wp.html=_.extend(wp.html||{},{attrs:function(a){var b,c;return"/"===a[a.length-1]&&(a=a.slice(0,-1)),b=wp.shortcode.attrs(a),c=b.named,_.each(b.numeric,function(a){/\s/.test(a)||(c[a]="")}),c},string:function(a){var b="<"+a.tag,c=a.content||"";return _.each(a.attrs,function(a,c){b+=" "+c,""!==a&&(_.isBoolean(a)&&(a=a?"true":"false"),b+='="'+a+'"')}),a.single?b+" />":(b+=">",b+=_.isObject(c)?wp.html.string(c):c,b+"</"+a.tag+">")}})}();
\ No newline at end of file