text: "use strict";angular.module("adf",["adf.provider","ui.bootstrap"]).value("adfTemplatePath","../src/templates/").value("rowTemplate",'<adf-dashboard-row row="row" adf-model="adfModel" collapsible="collapsible" edit-mode="editMode" ng-repeat="row in column.rows" />').value("columnTemplate",'<adf-dashboard-column column="column" adf-model="adfModel" collapsible="collapsible" edit-mode="editMode" ng-repeat="column in row.columns" />').value("adfVersion","0.9.0-SNAPSHOT"),angular.module("adf").directive("adfDashboardColumn",["$log","$compile","adfTemplatePath","rowTemplate","dashboard",function(e,t,i,o,l){function a(e,t,i){var o=t.widgets;e.$apply(function(){o.splice(i.newIndex,0,o.splice(i.oldIndex,1)[0])})}function n(e,t){for(var i=null,o=0;o<e.widgets.length;o++){var l=e.widgets[o];if(l.wid===t){i=l;break}}return i}function d(e,t){for(var i=null,o=0;o<e.rows.length;o++){for(var l=e.rows[o],a=0;a<l.columns.length;a++){var n=l.columns[a];if(n.cid===t){i=n;break}n.rows&&(i=d(n,t))}if(i)break}return i}function r(e){var t=e.getAttribute("adf-id");return t?parseInt(t):-1}function s(t,i,o,l){var a=r(l.from),s=d(i,a);if(s){var c=r(l.item),u=n(s,c);u?t.$apply(function(){o.widgets.splice(l.newIndex,0,u)}):e.warn("could not find widget with id "+c)}else e.warn("could not find column with id "+a)}function c(e,t,i){e.$apply(function(){t.widgets.splice(i.oldIndex,1)})}function u(e,t,i,o){var l=t[0],n=Sortable.create(l,{group:"widgets",handle:".adf-move",ghostClass:"placeholder",animation:150,onAdd:function(t){s(e,i,o,t)},onRemove:function(t){c(e,o,t)},onUpdate:function(t){a(e,o,t)}});t.on("$destroy",function(){n.destroy()})}return{restrict:"E",replace:!0,scope:{column:"=",editMode:"=",adfModel:"=",collapsible:"="},templateUrl:i+"dashboard-column.html",link:function(e,i){var a=e.column;a.cid||(a.cid=l.id()),angular.isDefined(a.rows)&&angular.isArray(a.rows)?t(o)(e,function(e){i.append(e)}):u(e,i,e.adfModel,a)}}}]),angular.module("adf").directive("adfDashboard",["$rootScope","$log","$modal","dashboard","adfTemplatePath",function(e,t,i,o,l){function a(e,t){if(e.widgets&&e.widgets.length>0)for(var i=e.widgets.shift();i;)t.widgets.push(i),i=e.widgets.shift()}function n(e,t,i){return i=i||0,angular.isDefined(e.rows)&&angular.forEach(e.rows,function(e){angular.forEach(e.columns,function(e){e.widgets||(e.widgets=[]),angular.isDefined(t[i])&&(angular.isDefined(e.rows)||(a(t[i],e),i++)),i=n(e,t,i)})}),i}function d(e,t){return t=t||[],angular.isDefined(e.rows)&&angular.forEach(e.rows,function(e){angular.forEach(e.columns,function(e){t.push(e),d(e,t)})}),t}function r(e,t){var i=d(e),o=0;for(e.rows=angular.copy(t.rows);o<i.length;)o=n(e,i,o)}function s(e){var t={},i=o.widgets[e].config;return i&&(t=angular.copy(i)),t}function c(e){var i=null;if(!angular.isArray(e.rows))return t.error("model does not have any rows"),null;for(var o=0;o<e.rows.length;o++){var l=e.rows[o];if(angular.isArray(l.columns))for(var a=0;a<l.columns.length;a++){var n=l.columns[a];if(!n.rows){i=n;break}}if(i)break}return i}function u(e,i){if(e){var o=c(e);o?(o.widgets||(o.widgets=[]),o.widgets.unshift(i)):t.error("could not find first widget column")}else t.error("model is undefined")}return{replace:!0,restrict:"EA",transclude:!1,scope:{structure:"@",name:"@",collapsible:"@",editable:"@",adfModel:"=",adfWidgetFilter:"="},controller:["$scope",function(a){var n={},d={},c=null,g={},f=a.name;a.$watch("adfModel",function(e,i){(null!==i||null===e&&null===i)&&(n=a.adfModel,c=a.adfWidgetFilter,n&&n.rows||(g=a.structure,d=o.structures[g],d?(n?n.rows=angular.copy(d).rows:n=angular.copy(d),n.structure=g):t.error("could not find structure "+g)),n?(n.title||(n.title="Dashboard"),a.model=n):t.error("could not find or create model"))},!0),a.editMode=!1,a.editClass="",a.toggleEditMode=function(){a.editMode=!a.editMode,a.editMode&&(a.modelCopy=angular.copy(a.adfModel,{})),a.editMode||e.$broadcast("adfDashboardChanged",f,n)},a.cancelEditMode=function(){a.editMode=!1,angular.copy(a.modelCopy,a.adfModel),angular.copy(a.modelCopy,a.model)},a.editDashboardDialog=function(){var e=a.$new();e.copy={title:n.title},e.structures=o.structures;var d=i.open({scope:e,templateUrl:l+"dashboard-edit.html",backdrop:"static"});a.changeStructure=function(e,i){t.info("change structure to "+e),r(n,i)},e.closeDialog=function(){n.title=e.copy.title,d.close(),e.$destroy()}},a.addWidgetDialog=function(){var e,t=a.$new();angular.isFunction(c)?(e={},angular.forEach(o.widgets,function(t,i){c(t,i)&&(e[i]=t)})):e=o.widgets,t.widgets=e;var n={scope:t,templateUrl:l+"widget-add.html",backdrop:"static"},d=i.open(n);t.addWidget=function(e){var i={type:e,config:s(e)};u(t.model,i),d.close(),t.$destroy()},t.closeDialog=function(){d.close(),t.$destroy()}}}],compile:function(e,t){angular.isDefined(t.editable)||(t.editable=!0)},link:function(e,t,i){e.name=i.name,e.structure=i.structure,e.editable=i.editable},templateUrl:l+"dashboard.html"}}]),angular.module("adf.provider",[]).provider("dashboard",function(){var e={},t="",i={},o='<div class="alert alert-danger">{}</div>',l='      <div class="progress progress-striped active">\n        <div class="progress-bar" role="progressbar" style="width: 100%">\n          <span class="sr-only">loading ...</span>\n        </div>\n      </div>';this.widget=function(t,i){var o=angular.extend({reload:!1},i);if(o.edit){var l={reload:!0};angular.extend(l,o.edit),o.edit=l}return e[t]=o,this},this.widgetsPath=function(e){return t=e,this},this.structure=function(e,t){return i[e]=t,this},this.messageTemplate=function(e){return o=e,this},this.loadingTemplate=function(e){return l=e,this},this.$get=function(){var a=0;return{widgets:e,widgetsPath:t,structures:i,messageTemplate:o,loadingTemplate:l,id:function(){return++a}}}}),angular.module("adf").directive("adfDashboardRow",["$compile","adfTemplatePath","columnTemplate",function(e,t,i){return{restrict:"E",replace:!0,scope:{row:"=",adfModel:"=",editMode:"=",collapsible:"="},templateUrl:t+"dashboard-row.html",link:function(t,o){angular.isDefined(t.row.columns)&&angular.isArray(t.row.columns)&&e(i)(t,function(e){o.append(e)})}}}]),angular.module("adf").directive("adfWidgetContent",["$log","$q","$sce","$http","$templateCache","$compile","$controller","$injector","dashboard",function(e,t,i,o,l,a,n,d,r){function s(e){var t=e;return e.indexOf("{widgetsPath}")>=0&&(t=e.replace("{widgetsPath}",r.widgetsPath).replace("//","/"),0===t.indexOf("/")&&(t=t.substring(1))),t}function c(e){var a=t.defer();if(e.template)a.resolve(e.template);else if(e.templateUrl){var n=l.get(e.templateUrl);if(n)a.resolve(n);else{var d=i.getTrustedResourceUrl(s(e.templateUrl));o.get(d).success(function(t){l.put(e.templateUrl,t),a.resolve(t)}).error(function(){a.reject("could not load template")})}}return a.promise}function u(i,o,l){var s=i.model,u=i.content;o.html(r.loadingTemplate);var g=i.$new();s.config||(s.config={}),g.config=s.config;var f={$scope:g,widget:s,config:s.config},p={};return p.$tpl=c(u),u.resolve&&angular.forEach(u.resolve,function(e,t){p[t]=angular.isString(e)?d.get(e):d.invoke(e,e,f)}),t.all(p).then(function(e){angular.extend(e,f);var t=e.$tpl;if(o.html(t),u.controller){var i=n(u.controller,e);u.controllerAs&&(g[u.controllerAs]=i),o.children().data("$ngControllerController",i)}a(o.contents())(g)},function(t){var i="Could not resolve all promises";t&&(i+=": "+t),e.warn(i),o.html(r.messageTemplate.replace(/{}/g,i))}),l&&l.$destroy(),g}return{replace:!0,restrict:"EA",transclude:!1,scope:{model:"=",content:"="},link:function(e,t){var i=u(e,t,null);e.$on("widgetConfigChanged",function(){i=u(e,t,i)}),e.$on("widgetReload",function(){i=u(e,t,i)})}}}]),angular.module("adf").directive("adfWidget",["$log","$modal","dashboard","adfTemplatePath",function(e,t,i,o){function l(e){switch(angular.isDefined(e)?e.toLowerCase():null){case"true":case"yes":case"1":return!0;case"false":case"no":case"0":case null:return!1;default:return Boolean(e)}}function a(t){var o=t.definition;if(o){var a=i.widgets[o.type];if(a){o.title||(o.title=a.title),o.wid||(o.wid=i.id()),t.widget=angular.copy(a);var n=o.config;n?angular.isString(n)&&(n=angular.fromJson(n)):n={},t.config=n,t.collapsible=l(t.collapsible),t.isCollapsed=!1}else e.warn("could not find widget "+o.type)}else e.debug("definition not specified, widget was probably removed")}function n(i,l){var a=i.definition;a?(i.close=function(){var e=i.col;if(e){var t=e.widgets.indexOf(a);t>=0&&e.widgets.splice(t,1)}l.remove()},i.reload=function(){i.$broadcast("widgetReload")},i.edit=function(){var e=i.$new(),l={scope:e,templateUrl:o+"widget-edit.html",backdrop:"static"},a=t.open(l);e.closeDialog=function(){a.close(),e.$destroy();var t=i.widget;t.edit&&t.edit.reload&&i.$broadcast("widgetConfigChanged")}}):e.debug("widget not found")}return{replace:!0,restrict:"EA",transclude:!1,templateUrl:o+"widget.html",scope:{definition:"=",col:"=column",editMode:"=",collapsible:"="},compile:function(){return{pre:a,post:n}}}}]),angular.module("adf").run(["$templateCache",function(e){e.put("../src/templates/dashboard-column.html",'<div adf-id={{column.cid}} class=column ng-class=column.styleClass ng-model=column.widgets> <adf-widget ng-repeat="definition in column.widgets" definition=definition column=column edit-mode=editMode collapsible=collapsible>  </adf-widget></div> '),e.put("../src/templates/dashboard-edit.html",'<div class=modal-header> <button type=button class=close ng-click=closeDialog() aria-hidden=true>&times;</button> <h4 class=modal-title>Edit Dashboard</h4> </div> <div class=modal-body> <form role=form> <div class=form-group> <label for=dashboardTitle>Title</label> <input type=text class=form-control id=dashboardTitle ng-model=copy.title required> </div> <div class=form-group> <label>Structure</label> <div class=radio ng-repeat="(key, structure) in structures"> <label> <input type=radio value={{key}} ng-model=model.structure ng-change="changeStructure(key, structure)"> {{key}} </label> </div> </div> </form> </div> <div class=modal-footer> <button type=button class="btn btn-primary" ng-click=closeDialog()>Close</button> </div> '),e.put("../src/templates/dashboard-row.html","<div class=row ng-class=row.styleClass>  </div> "),e.put("../src/templates/dashboard.html",'<div class=dashboard-container> <h1> {{model.title}} <span style="font-size: 16px" class=pull-right> <a href ng-if=editMode title="add new widget" ng-click=addWidgetDialog()> <i class="glyphicon glyphicon-plus-sign"></i> </a> <a href ng-if=editMode title="edit dashboard" ng-click=editDashboardDialog()> <i class="glyphicon glyphicon-cog"></i> </a> <a href ng-if=editable title="{{editMode ? \'save changes\' : \'enable edit mode\'}}" ng-click=toggleEditMode()> <i class=glyphicon x-ng-class="{\'glyphicon-edit\' : !editMode, \'glyphicon-save\' : editMode}"></i> </a> <a href ng-if=editMode title="undo changes" ng-click=cancelEditMode()> <i class="glyphicon glyphicon-repeat adf-flip"></i> </a> </span> </h1> <div class=dashboard x-ng-class="{\'edit\' : editMode}"> <adf-dashboard-row row=row adf-model=model collapsible=collapsible ng-repeat="row in model.rows" edit-mode=editMode> </adf-dashboard-row></div> </div> '),e.put("../src/templates/widget-add.html",'<div class=modal-header> <button type=button class=close ng-click=closeDialog() aria-hidden=true>&times;</button> <h4 class=modal-title>Add new widget</h4> </div> <div class=modal-body> <div style="display: inline-block;"> <dl class=dl-horizontal> <dt ng-repeat-start="(key, widget) in widgets"> <a href ng-click=addWidget(key)> {{widget.title}} </a> </dt> <dd ng-repeat-end="" ng-if=widget.description> {{widget.description}} </dd> </dl> </div> </div> <div class=modal-footer> <button type=button class="btn btn-primary" ng-click=closeDialog()>Close</button> </div>'),e.put("../src/templates/widget-edit.html",'<div class=modal-header> <button type=button class=close ng-click=closeDialog() aria-hidden=true>&times;</button> <h4 class=modal-title>{{widget.title}}</h4> </div> <div class=modal-body> <form role=form> <div class=form-group> <label for=widgetTitle>Title</label> <input type=text class=form-control id=widgetTitle ng-model=definition.title placeholder="Enter title" required> </div> </form> <div ng-if=widget.edit> <adf-widget-content model=definition content=widget.edit> </adf-widget-content></div> </div> <div class=modal-footer> <button type=button class="btn btn-primary" ng-click=closeDialog()>Close</button> </div>'),e.put("../src/templates/widget.html",'<div adf-id={{definition.wid}} class="widget panel panel-default"> <div class="panel-heading clearfix"> <h3 class=panel-title> {{definition.title}} <span class=pull-right> <a href title="reload widget content" ng-if=widget.reload ng-click=reload()> <i class="glyphicon glyphicon-refresh"></i> </a>  <a href title="change widget location" class=adf-move ng-if=editMode> <i class="glyphicon glyphicon-move"></i> </a>  <a href title="collapse widget" ng-show="collapsible && !isCollapsed" ng-click="isCollapsed = !isCollapsed"> <i class="glyphicon glyphicon-minus"></i> </a>  <a href title="expand widget" ng-show="collapsible && isCollapsed" ng-click="isCollapsed = !isCollapsed"> <i class="glyphicon glyphicon-plus"></i> </a>  <a href title="edit widget configuration" ng-click=edit() ng-if=editMode> <i class="glyphicon glyphicon-cog"></i> </a>  <a href title="remove widget" ng-click=close() ng-if=editMode> <i class="glyphicon glyphicon-remove"></i> </a> </span> </h3> </div> <div class=panel-body collapse=isCollapsed> <adf-widget-content model=definition content=widget> </adf-widget-content></div> </div> ')}]);
  //# sourceMappingURL=angular-dashboard-framework.min.js.map