!function(a,b){"use strict";var c,d,e,f,g;_.isUndefined(a.nineCodesSocialManagerAPI)||_.isUndefined(a.nineCodesSocialManagerAPI.id)||(c=document.getElementById("tmpl-buttons-content"),d=document.getElementById("tmpl-buttons-image"),(c||d)&&(a.nineCodesSocialManager=a.nineCodesSocialManagerAPI||{},nineCodesSocialManager.app=nineCodesSocialManager.app||{},nineCodesSocialManager.app.route=nineCodesSocialManager.root+nineCodesSocialManager.namespace,nineCodesSocialManager.app.sync=function(a,b,c){return _.extend(c,{url:nineCodesSocialManager.app.route+"/social-manager/buttons/"+(_.isFunction(b.url)?b.url():b.url)}),Backbone.sync(a,b,c)},nineCodesSocialManager.app.tmpl=_.memoize(function(a){var c,d={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(e){return(c=c||_.template(b("#tmpl-"+a).html(),null,d))(e)}}),nineCodesSocialManager.app.tmplString=_.memoize(function(a){var b,c={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(d){return(b=b||_.template(a,null,c))(d)}}),nineCodesSocialManager.Buttons=nineCodesSocialManager.Buttons||{},nineCodesSocialManager.Buttons={Collection:{},Model:{},View:{}},nineCodesSocialManager.Buttons.Model=Backbone.Model.extend({sync:nineCodesSocialManager.app.sync,defaults:{id:null,content:{},images:[]}}),nineCodesSocialManager.Buttons.View=Backbone.View.extend({el:"body",constructor:function(){this.template={buttonsContent:nineCodesSocialManager.app.tmpl("buttons-content"),buttonsImage:nineCodesSocialManager.app.tmpl("buttons-image"),imgWrapper:nineCodesSocialManager.app.tmplString('')},Backbone.View.apply(this,arguments)},initialize:function(){this.listenTo(this.model,"change:id",this.render)},buttonDialog:function(b){b.preventDefault(),b.stopImmediatePropagation();var c=b.currentTarget,d=c.getAttribute("href");return 0===d.indexOf("mailto:")?void(a.location.href=d):d&&""===d?void 0:void this.windowPopup(d)},windowPopup:function(b){var c=a,d=document,e=void 0!==c.screenLeft?c.screenLeft:screen.left,f=void 0!==c.screenTop?c.screenTop:screen.top,g=c.innerWidth?c.innerWidth:d.documentElement.clientWidth?d.documentElement.clientWidth:screen.width,h=c.innerHeight?c.innerHeight:d.documentElement.clientHeight?d.documentElement.clientHeight:screen.height,i=560,j=430,k=2,l=g/k-i/k+e,m=h/k-j/k+f,n=c.open(b,"","scrollbars=no,width="+i+",height="+j+",top="+m+",left="+l);n&&n.focus()}}),nineCodesSocialManager.Buttons.View.Content=nineCodesSocialManager.Buttons.View.extend({events:{'click [data-social-manager="ButtonsContent"] a':"buttonDialog"},render:function(a){var c=a.toJSON(),d=b("#"+nineCodesSocialManager.attrPrefix+"-buttons-"+c.id);try{d.append(this.template.buttonsContent(c.content))}catch(a){console.info(a.name,a.message)}return this}}),nineCodesSocialManager.Buttons.View.Images=nineCodesSocialManager.Buttons.View.extend({events:{'click [data-social-manager="ButtonsImage"] a':"buttonDialog"},render:function(a){var c=this,d=a.toJSON(),e=this.template.imgWrapper({id:d.id,prefix:nineCodesSocialManager.attrPrefix}),f=b('[data-social-manager="ContentImage-'+d.id+'"]');return f.each(function(a,f){try{var g=_.reduce(f.attributes,function(a,b){return a[b.name]=b.value,a},{}),h=d.images[a].src;_.contains(g,h)&&b(f).wrap(e).after(c.template.buttonsImage(d.images[a]))}catch(a){console.info(a.name,a.message)}}),this}}),g=new nineCodesSocialManager.Buttons.Model,g.url=nineCodesSocialManager.id,c&&(e=new nineCodesSocialManager.Buttons.View.Content({model:g})),d&&(f=new nineCodesSocialManager.Buttons.View.Images({model:g})),g.fetch()))}(window,jQuery);