/* jce - 2.6.14 | 2017-05-30 | http://www.joomlacontenteditor.net | Copyright (C) 2006 - 2017 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
WFAggregator.add("vimeo",{params:{width:480,height:480,embed:!0},props:{color:"",autoplay:0,loop:0,portrait:1,title:1,byline:1,fullscreen:1},setup:function(){$("#vimeo_embed").toggle(this.params.embed)},getTitle:function(){return this.title||this.name},getType:function(){return $("#vimeo_embed").is(":checked")?"flash":"iframe"},isSupported:function(v){return"object"==typeof v&&(v=v.src||v.data||""),!!/vimeo(.+)?\/(.+)/.test(v)&&(!/\/external\//.test(v)&&"vimeo")},getValues:function(src){var self=this,data={},args={},type=this.getType(),id="";if(src.indexOf("=")!==-1&&$.extend(args,Wf.String.query(src)),$("input, select","#vimeo_options").not("#vimeo_embed").each(function(){var k=$(this).attr("id"),v=$(this).val();if(k=k.substr(k.indexOf("_")+1),$(this).is(":checkbox")&&(v=$(this).is(":checked")?1:0),self.props[k]!==v&&""!==v){switch(k){case"color":"#"==v.charAt(0)&&(v=v.substr(1));break;case"portrait":case"title":case"byline":"flash"==type&&(k="show_"+k)}args[k]=v}}),args.clip_id)id=args.clip_id;else{var s=/vimeo\.com\/(\w+\/)?(\w+\/)?([0-9]+)/.exec(src);s&&"array"===$.type(s)&&(id=s.pop())}src="flash"==type?"http://vimeo.com/moogaloop.swf?clip_id="+id:"//player.vimeo.com/video/"+id;var query=$.param(args);return query&&(src=src+(/\?/.test(src)?"&":"?")+query),data.src=src,"iframe"==type?($.extend(data,{frameborder:0}),0!==args.fullscreen&&$.extend(data,{allowfullscreen:!0})):$.extend(!0,data,{param:{allowfullscreen:!0,wmode:"opaque"}}),data},setValues:function(data){var self=this,src=data.src||data.data||"",id="";if(!src)return data;var query=Wf.String.query(src);if($.extend(data,query),src=src.replace(/&amp;/g,"&"),/moogaloop.swf/.test(src))data.embed=!0,$.each(["portrait","title","byline"],function(i,s){var v=query["show_"+s];"undefined"!=typeof v&&(data[s]=v,delete data["show_"+s])}),id=query.clip_id,delete data.clip_id,delete query.clip_id;else{var s=/vimeo\.com\/(\w+\/)?(\w+\/)?([0-9]+)/.exec(src);s&&"array"===$.type(s)&&(id=s.pop())}return $.each(query,function(k,v){"undefined"==typeof self.props[k]&&$("#vimeo_options table").append('<tr><td><label for="vimeo_'+k+'">'+k+'</label><input type="text" id="vimeo_'+k+'" value="'+v+'" /></td></tr>')}),src="//vimeo.com/"+id,data.color&&"#"!=data.color.charAt(0)&&(data.color="#"+data.color),data.src=src,data},getAttributes:function(src){var args={},data=this.setValues({src:src})||{};return $.each(data,function(k,v){"src"!=k&&(args["vimeo_"+k]=v)}),$.extend(args,{src:data.src||src,width:this.params.width,height:this.params.height}),args},setAttributes:function(){},onSelectFile:function(){},onInsert:function(){}});