/*! grafana - v3.1.0 - 2016-07-18
 * Copyright (c) 2016 Torkel Ödegaard; Licensed Apache-2.0 */

define(["angular","lodash","require","app/core/config"],function(a,b,c,d){"use strict";var e=a.module("grafana.controllers");e.controller("ShareModalCtrl",["$scope","$rootScope","$location","$timeout","timeSrv","$element","templateSrv","linkSrv",function(b,c,e,f,g,h,i,j){b.options={forCurrent:!0,includeTemplateVars:!0,theme:"current"},b.editor={index:b.tabIndex||0},b.init=function(){b.modeSharePanel=!!b.panel,b.tabs=[{title:"Link",src:"shareLink.html"}],b.modeSharePanel?(b.modalTitle="Share Panel",b.tabs.push({title:"Embed",src:"shareEmbed.html"})):b.modalTitle="Share",b.dashboard.meta.isSnapshot||b.tabs.push({title:"Snapshot",src:"shareSnapshot.html"}),b.dashboard.meta.isSnapshot||b.tabs.push({title:"Export",src:"shareExport.html"}),b.buildUrl()},b.buildUrl=function(){var c=e.absUrl(),f=c.indexOf("?");f!==-1&&(c=c.substring(0,f));var h=a.copy(e.search()),k=g.timeRange();h.from=k.from.valueOf(),h.to=k.to.valueOf(),b.options.includeTemplateVars&&i.fillVariableValuesForUrl(h),b.options.forCurrent||(delete h.from,delete h.to),"current"!==b.options.theme&&(h.theme=b.options.theme),b.modeSharePanel?(h.panelId=b.panel.id,h.fullscreen=!0):(delete h.panelId,delete h.fullscreen),b.shareUrl=j.addParamsToUrl(c,h);var l=b.shareUrl;l=l.replace(d.appSubUrl+"/dashboard/",d.appSubUrl+"/dashboard-solo/"),l=l.replace("&fullscreen","").replace("&edit",""),b.iframeHtml='<iframe src="'+l+'" width="450" height="200" frameborder="0"></iframe>',b.imageUrl=l.replace(d.appSubUrl+"/dashboard-solo/",d.appSubUrl+"/render/dashboard-solo/"),b.imageUrl+="&width=1000",b.imageUrl+="&height=500"}}]),e.directive("clipboardButton",function(){return function(a,b){c(["vendor/zero_clipboard"],function(a){a.config({swfPath:d.appSubUrl+"/public/vendor/zero_clipboard.swf"}),new a(b[0])})}})});