/** * Define the angular app */ 'use strict'; var app = (function () { Helpers.validateSaveVersion(); var app = angular.module('scienceAlchemy', ['ngDragDrop', 'ui.grid','ngAnimate']); // directives /** * Provides an easy way to toggle a checkboxes indeterminate property * * @example */ // app.directive('uiIndeterminate', [ // function () { // // return { // compile: function (tElm, tAttrs) { // if (!tAttrs.type || tAttrs.type.toLowerCase() !== 'checkbox') { // return angular.noop; // } // // return function ($scope, elm, attrs) { // $scope.$watch(attrs.uiIndeterminate, function (newVal) { // elm[0].indeterminate = !!newVal; // }); // }; // } // }; // } // ]); /** * Directive to render a rule and bind it's option with select boxes * This expects ng-model="rule" as an attribute */ function cfsRule($compile) { return { link: function (scope, element, attrs) { scope.$eval("$index"); var rule = scope.$eval(attrs.ngModel); // first generate a select box for each option (using lodash templating) _.templateSettings.interpolate = /<%=([\s\S]+?)%>/g; var optionTmpl = '' + '\n'; var tmplParams = _.defaults({},rule.options,rule.otherOptions); for (var option in rule.optionDesc) { if (rule.optionDesc.hasOwnProperty(option)) { var vals = rule.optionDesc[option].possibleVals; if (vals) { tmplParams[option] = _.template(optionTmpl)({ option: option }); } else { // if there are no options replace '{{color}}' with 'color' tmplParams[option] = option; } } } // now put each select box into description // replace '{{color}}' with '