diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index e8916ec304..e2e7b87a7e 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -93,7 +93,7 @@ angular.module('ansible', [ 'SchedulesHelper' ]) - .constant('AngularScheduler.partial', $basePath + 'lib/angular-scheduler/lib/angular-scheduler.html') + .constant('AngularScheduler.partials', $basePath + 'lib/angular-scheduler/lib/') .constant('AngularScheduler.useTimezone', false) .constant('AngularScheduler.showUTCField', false) .constant('$timezones.definitions.location', $basePath + 'lib/angular-tz-extensions/tz/data') diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 5007a0a07f..9964e8f223 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -705,7 +705,6 @@ function(SchedulerInit, Rest, Wait) { }]) - .factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm', 'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate', 'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find','WatchInventoryWindowResize', diff --git a/awx/ui/static/js/helpers/Schedules.js b/awx/ui/static/js/helpers/Schedules.js index f77cc19b57..65c05c17d2 100644 --- a/awx/ui/static/js/helpers/Schedules.js +++ b/awx/ui/static/js/helpers/Schedules.js @@ -76,9 +76,6 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) } }); $('#scheduler-tabs a:first').tab('show'); - $('#rrule_nlp_description').dblclick(function() { - setTimeout(function() { scope.$apply(function() { scope.showRRuleDetail = (scope.showRRuleDetail) ? false : true; }); }, 100); - }); }, resizeStop: function () { // for some reason, after resizing dialog the form and fields (the content) doesn't expand to 100% @@ -102,12 +99,16 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) open: function () { Wait('stop'); $('#schedulerName').focus(); + $('#rrule_nlp_description').dblclick(function() { + console.log('here!'); + setTimeout(function() { scope.$apply(function() { scope.showRRule = (scope.showRRule) ? false : true; }); }, 100); + }); } }); }; }]) - .factory('ShowDetails', [ function() { + /*.factory('ShowDetails', [ function() { return function(params) { var scope = params.scope, @@ -137,10 +138,10 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) } } }; - }]) + }])*/ - .factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'ShowDetails', 'Wait', 'Rest', - function(SchedulerInit, ShowSchedulerModal, ShowDetails, Wait, Rest) { + .factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', + function(SchedulerInit, ShowSchedulerModal, Wait, Rest) { return function(params) { var scope = params.scope, schedule = params.schedule, @@ -149,8 +150,10 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) Wait('start'); $('#form-container').empty(); - scheduler = SchedulerInit({ scope: scope }); + scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false }); scheduler.inject('form-container', false); + scheduler.injectDetail('occurrences', false); + ShowSchedulerModal({ scope: scope }); scope.showRRuleDetail = false; @@ -167,7 +170,6 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) var newSchedule; $('#scheduler-tabs a:first').tab('show'); if (scheduler.isValid()) { - scope.schedulerIsValid = true; Wait('start'); newSchedule = scheduler.getValue(); schedule.name = newSchedule.name; @@ -183,19 +185,20 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) $('#scheduler-modal-dialog').dialog('close'); }); } - else { - scope.schedulerIsValid = false; - } }; $('#scheduler-tabs li a').on('shown.bs.tab', function(e) { - ShowDetails({ e: e, scope: scope, scheduler: scheduler }); + if ($(e.target).text() === 'Details') { + if (!scheduler.isValid()) { + $('#scheduler-tabs a:first').tab('show'); + } + } }); }; }]) - .factory('AddSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'ShowDetails', 'Wait', 'Rest', - function(SchedulerInit, ShowSchedulerModal, ShowDetails, Wait, Rest) { + .factory('AddSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', + function(SchedulerInit, ShowSchedulerModal, Wait, Rest) { return function(params) { var scope = params.scope, url = params.url, @@ -204,8 +207,9 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) Wait('start'); $('#form-container').empty(); - scheduler = SchedulerInit({ scope: scope }); + scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false }); scheduler.inject('form-container', false); + scheduler.injectDetail('occurrences', false); scheduler.clear(); ShowSchedulerModal({ scope: scope }); scope.showRRuleDetail = false; @@ -218,7 +222,6 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) var newSchedule; $('#scheduler-tabs a:first').tab('show'); if (scheduler.isValid()) { - scope.schedulerIsValid = true; Wait('start'); newSchedule = scheduler.getValue(); schedule.name = newSchedule.name; @@ -234,13 +237,14 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) $('#scheduler-modal-dialog').dialog('close'); }); } - else { - scope.schedulerIsValid = false; - } }; $('#scheduler-tabs li a').on('shown.bs.tab', function(e) { - ShowDetails({ e: e, scope: scope, scheduler: scheduler }); + if ($(e.target).text() === 'Details') { + if (!scheduler.isValid()) { + $('#scheduler-tabs a:first').tab('show'); + } + } }); }; }]); \ No newline at end of file diff --git a/awx/ui/static/less/angular-scheduler.less b/awx/ui/static/less/angular-scheduler.less index 4d3e41da1e..bb943f3c4a 100644 --- a/awx/ui/static/less/angular-scheduler.less +++ b/awx/ui/static/less/angular-scheduler.less @@ -37,6 +37,10 @@ text-align: right; } +#schedules-detail { + display:none; +} + #scheduler-modal-dialog, #schedules-form-container { display: none; overflow-x: hidden; @@ -55,6 +59,15 @@ display: inline-block; } + .occurrence-list { + border: 1px solid @well-border; + padding: 8px 10px; + border-radius: 4px; + background-color: @well; + list-style: none; + margin-bottom: 5px; + } + #date-choice { display: inline-block; margin-left: 15px; diff --git a/awx/ui/static/lib/angular-scheduler/.gitignore b/awx/ui/static/lib/angular-scheduler/.gitignore new file mode 100644 index 0000000000..7bf6eb18f7 --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/.gitignore @@ -0,0 +1,2 @@ +bower_components +node_modules diff --git a/awx/ui/static/lib/angular-scheduler/.jshintrc b/awx/ui/static/lib/angular-scheduler/.jshintrc new file mode 100644 index 0000000000..ae5c719d7f --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/.jshintrc @@ -0,0 +1,21 @@ +{ + // Details: https://github.com/victorporof/Sublime-JSHint#using-your-own-jshintrc-options + // Example: https://github.com/jshint/jshint/blob/master/examples/.jshintrc + // Documentation: http://www.jshint.com/docs/ + + "browser": true, + "jquery": true, + "esnext": true, + "globalstrict": true, + "globals": { "angular":false, "alert":true }, + "strict": false, + "quotmark": false, + "smarttabs": true, + "trailing": true, + "undef": true, + "unused": true, + "eqeqeq": true, + "indent": 4, + "onevar": true, + "newcap": false +} diff --git a/awx/ui/static/lib/angular-scheduler/README.md b/awx/ui/static/lib/angular-scheduler/README.md index 7be076cbbf..f9bf9d58d9 100644 --- a/awx/ui/static/lib/angular-scheduler/README.md +++ b/awx/ui/static/lib/angular-scheduler/README.md @@ -15,13 +15,60 @@ Using Coming soon... -Examples --------- +Sample App +---------- -An example site is included along with a simple node based web server. With [node](http://nodejs.org) installed, run the following: +An example application is included along with a simple node based web server. With [node](http://nodejs.org) installed, run the following to start the server: - node scripts/web-server.js + node ./scripts/web-server.js 8000 -Once that's running, point you browser to http://localhost:8000/app/index.html +Visit the sample by pointing your browser to http://localhost:8000/app/index.html + + +Contributing +------------ +After cloning the repo, install the the bower packages listed in bower.json: + + bower install + +Install the npm packages listed in package.json: + + node install + +Install [Grunt](http://www.gruntjs.com) command line: + + npm install -g grunt-cli + +From the project root run the grunt command. This will execute the default steps found in Gruntfile.js, which will lint and minify the javascript and css files: + + grunt + +You should see output similar to the following: + + Running "jshint:uses_defaults" (jshint) task + >> 2 files lint free. + + Running "uglify:my_target" (uglify) task + File "lib/angular-scheduler.min.js" created. + + Running "less:production" (less) task + File lib/angular-scheduler.min.css created. + +Run tests found in the ./tests directory. GetRRule.js provides a set of unit tests. Install [Karma](http://karma-runner.github.io/0.12/index.html), and launch with the folllowing: + + cd test + karma start + +SetRRule.js provides end-to-end tests that run with [Protractor](https://github.com/angular/protractor). Follow the instructions to install protractor and a local selenium server (assuming you don't have access to an existing selenium server). Launch the provided sample app (as described above) in a terminal session. In a separate terminal session launch a local selenium server. The test configuration file expects the web server to run at localhost:8000 and the selenium server to run at localhost:4444. In a third session luanch the tests: + +Session 1: + node ./scripts/web-server.js 8000 + +Session 2: + webdriver-manager start + +Session 3: + cd tests + protractor protractorConf.js diff --git a/awx/ui/static/lib/angular-scheduler/app/css/sampleApp.less b/awx/ui/static/lib/angular-scheduler/app/css/sampleApp.less index 371dd50cd0..37a55845c4 100644 --- a/awx/ui/static/lib/angular-scheduler/app/css/sampleApp.less +++ b/awx/ui/static/lib/angular-scheduler/app/css/sampleApp.less @@ -43,6 +43,10 @@ body { font-weight: bold; } +#scope-variables { + margin-top: 65px; +} + hr { margin-top: 40px; margin-bottom: 40px; @@ -196,4 +200,18 @@ a:hover { } .ui-front { z-index: 1050; +} + +#message { + padding-top: 20px; +} + +.tab-pane { + margin-top: 20px; +} + +@media (min-width: 1200px) { + #scope-variables { + margin-left: 25px; + } } \ No newline at end of file diff --git a/awx/ui/static/lib/angular-scheduler/app/js/sampleApp.js b/awx/ui/static/lib/angular-scheduler/app/js/sampleApp.js index 43d217d049..2040f3d0f7 100644 --- a/awx/ui/static/lib/angular-scheduler/app/js/sampleApp.js +++ b/awx/ui/static/lib/angular-scheduler/app/js/sampleApp.js @@ -20,16 +20,33 @@ angular.module('sampleApp', ['ngRoute', 'AngularScheduler', 'Timezones']) }); }]) - .constant('AngularScheduler.partial', '/lib/angular-scheduler.html') + .run(['$rootScope', function($rootScope) { + $rootScope.toggleTab = function(e, tab, tabs) { + e.preventDefault(); + $('#' + tabs + ' #' + tab).tab('show'); + }; + }]) + + .constant('AngularScheduler.partial', '/lib/') .constant('AngularScheduler.useTimezone', false) .constant('AngularScheduler.showUTCField', false) .constant('$timezones.definitions.location', '/bower_components/angular-tz-extensions/tz/data') .controller('sampleController', ['$scope', '$filter', 'SchedulerInit', function($scope, $filter, SchedulerInit) { - var scheduler = SchedulerInit({ scope: $scope }); + var scheduler = SchedulerInit({ scope: $scope, requireFutureStartTime: false }); scheduler.inject('form-container', true); + scheduler.injectDetail('details-tab', true); + + $('#scheduler-tabs a[data-toggle="tab"]').on('shown.bs.tab', function(e) { + // Only show detail tab if schedule is valid + if ($(e.target).text() === 'Details') { + if (!scheduler.isValid()) { + $('#scheduler-link').tab('show'); + } + } + }); $scope.setRRule = function() { $scope.inputRRuleMsg = ''; @@ -41,62 +58,32 @@ angular.module('sampleApp', ['ngRoute', 'AngularScheduler', 'Timezones']) $scope.saveForm = function() { if (scheduler.isValid()) { var schedule = scheduler.getValue(), - rrule = scheduler.getRRule(), - html, wheight = $(window).height(), wwidth = $(window).width(), - w, h, occurrences; + w, h; - occurrences = []; - rrule.all(function(date, i) { - if (i < 10) { - occurrences.push(date); - return true; - } - else { - return false; - } - }); - - html = "
\n" + - "
\n" + - "\n" + - "\n" + - "
" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n"; + $('#message').empty(); + scheduler.injectDetail('message', true); w = (600 > wwidth) ? wwidth : 600; - h = (600 > wheight) ? wheight : 600; + h = (635 > wheight) ? wheight : 635; - $('#message').html(html) - .dialog({ - title: schedule.name, - modal: true, - width: w, - height: h, - position: 'center', - buttons: { OK: function() { $(this).dialog('close');} }, - open: function () { - // fix the close button - $('.ui-dialog[aria-describedby="message"]').find('.ui-dialog-titlebar button') - .empty().attr({ 'class': 'close' }).text('x'); - // fix the OK button - $('.ui-dialog[aria-describedby="message"]').find('.ui-dialog-buttonset button:first') - .attr({ 'class': 'btn btn-primary', 'id': 'modal-ok-button' }); - } - }); + $('#message').dialog({ + title: schedule.name, + modal: true, + width: w, + height: h, + position: 'center', + buttons: { OK: function() { $(this).dialog('close');} }, + open: function () { + // fix the close button + $('.ui-dialog[aria-describedby="message"]').find('.ui-dialog-titlebar button') + .empty().attr({ 'class': 'close' }).text('x'); + // fix the OK button + $('.ui-dialog[aria-describedby="message"]').find('.ui-dialog-buttonset button:first') + .attr({ 'class': 'btn btn-primary', 'id': 'modal-ok-button' }); + } + }); } }; diff --git a/awx/ui/static/lib/angular-scheduler/app/partials/main.html b/awx/ui/static/lib/angular-scheduler/app/partials/main.html index cf41b55a07..19b24a787a 100644 --- a/awx/ui/static/lib/angular-scheduler/app/partials/main.html +++ b/awx/ui/static/lib/angular-scheduler/app/partials/main.html @@ -1,14 +1,24 @@
-
-
+ + + +
+
+
+
+
-
- +
diff --git a/awx/ui/static/lib/angular-scheduler/bower.json b/awx/ui/static/lib/angular-scheduler/bower.json index e7e6738491..665ea99ac9 100644 --- a/awx/ui/static/lib/angular-scheduler/bower.json +++ b/awx/ui/static/lib/angular-scheduler/bower.json @@ -1,6 +1,6 @@ { "name": "angular-scheduler", - "version": "0.0.2", + "version": "0.0.3", "authors": [ "Chris Houseknecht " ], @@ -24,10 +24,10 @@ "dependencies": { "angular": "~1.2.14", "underscore": "*", - "twitter": "*", + "bootstrap": "~3.1.1", "rrule": "*", "timezone-js": "*", - "angular-tz-extensions":"*" + "angular-tz-extensions": "*" }, "homepage": "https://github.com/chouseknecht/angular-scheduler", "main": "git@github.com:chouseknecht/angular-scheduler.git", diff --git a/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler-detail.html b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler-detail.html new file mode 100644 index 0000000000..267dc118a9 --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler-detail.html @@ -0,0 +1,43 @@ + +
+
+

The scheduler options are invalid or incomplete. Make the needed changes on the options tab, then come back here to see details.

+
+
+
+ + +
+
+ + +
+
+ +
+
Date format
+ +
UTC
+ +
Local time
+
+
    +
  • {{ occurrence.utc }}
  • +
+
    +
  • {{ occurrence.local }}
  • +
+
+
+
\ No newline at end of file diff --git a/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.css b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.css index a5c4bd53fc..b87a1e1550 100644 --- a/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.css +++ b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.css @@ -91,4 +91,46 @@ input.ng-dirty.ng-invalid, select.ng-dirty.ng-invalid, textarea.ng-dirty.ng-inva } select { width: 100%; +} + +/* Details page */ + +#occurrence-label { + display: inline-block; +} + +.occurrence-list { + border: 1px solid #ccc; + padding: 8px 10px; + border-radius: 4px; + background-color: #eee; + list-style: none; + margin-bottom: 5px; + min-height: 220px; +} + +#date-choice { + display: inline-block; + margin-left: 15px; + font-size: 12px; +} + +#date-choice .label-inline { + display: inline-block; + vertical-align: middle; +} + +#date-choice input { + margin-bottom: 2px; + height: 11px; + width: 10px; +} + +#date-choice .label-inline:first-child { + padding-bottom: 2px; + margin-right: 10px; +} + +#date-choice .label-inline:nth-child(3) { + margin-right: 10px; } \ No newline at end of file diff --git a/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.js b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.js index abe6291803..6684f7eaf0 100644 --- a/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.js +++ b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.js @@ -24,7 +24,7 @@ angular.module('underscore',[]) angular.module('AngularScheduler', ['underscore']) - .constant('AngularScheduler.partial', '/lib/angular-scheduler.html') + .constant('AngularScheduler.partials', '/lib/') .constant('AngularScheduler.useTimezone', false) .constant('AngularScheduler.showUTCField', false) @@ -178,8 +178,8 @@ angular.module('AngularScheduler', ['underscore']) user input is valid, reset the form, etc. All the things we need to access and manipulate the scheduler widget */ - .factory('CreateObject', ['AngularScheduler.useTimezone', '$filter', 'GetRule', 'Inject', 'SetDefaults', '$timezones', 'SetRule', - function(useTimezone, $filter, GetRule, Inject, SetDefaults, $timezones, SetRule) { + .factory('CreateObject', ['AngularScheduler.useTimezone', '$filter', 'GetRule', 'Inject', 'InjectDetail', 'SetDefaults', '$timezones', 'SetRule', + function(useTimezone, $filter, GetRule, Inject, InjectDetail, SetDefaults, $timezones, SetRule) { return function(scope, requireFutureST) { var fn = function() { @@ -238,6 +238,25 @@ angular.module('AngularScheduler', ['underscore']) } }; + // Set values for detail page + this.setDetails = function() { + var rrule = this.getRRule(); + if (rrule) { + scope.rrule_nlp_description = rrule.toText(); + scope.dateChoice = 'utc'; + scope.occurrence_list = []; + rrule.all(function(date, i){ + if (i < 10) { + scope.occurrence_list.push({ utc: date.toUTCString(), local: date.toString() }); + return true; + } + return false; + }); + scope.rrule_nlp_description = rrule.toText().replace(/^RRule error.*$/,'Natural language description not available'); + scope.rrule = rrule.toString(); + } + }; + // Check the input form for errors this.isValid = function() { var startDt, now, dateStr, adjNow, timeNow, timeFuture, validity = true; @@ -301,6 +320,12 @@ angular.module('AngularScheduler', ['underscore']) this.scope.startDateError("Provide a start time"); validity = false; } + + scope.schedulerIsValid = validity; + if (validity) { + this.setDetails(); + } + return validity; }; @@ -338,6 +363,10 @@ angular.module('AngularScheduler', ['underscore']) return Inject({ scope: this.scope, target: element, buttons: showButtons }); }; + this.injectDetail = function(element, showRRule) { + return InjectDetail({ scope: this.scope, target: element, showRRule: showRRule }); + }; + // Clear the form, returning all elements to a default state this.clear = function() { this.clearErrors(); @@ -360,12 +389,16 @@ angular.module('AngularScheduler', ['underscore']) this.getRequireFutureStartTime = function() { return this.requireFutureStartTime; }; + + this.setShowRRule = function(opt) { + scope.showRRule = opt; + }; }; return new fn(); }; }]) - .factory('Inject', ['AngularScheduler.partial', '$compile', '$http', '$log', function(scheduler_partial, $compile, $http) { + .factory('Inject', ['AngularScheduler.partials', '$compile', '$http', '$log', function(scheduler_partial, $compile, $http) { return function(params) { var scope = params.scope, @@ -384,12 +417,41 @@ angular.module('AngularScheduler', ['underscore']) } }); - $http({ method: 'GET', url: scheduler_partial }) + $http({ method: 'GET', url: scheduler_partial + 'angular-scheduler.html' }) .success( function(data) { scope.$emit('htmlReady', data); }) .error( function(data, status) { - throw('Error reading ' + scheduler_partial + '. ' + status); + throw('Error reading ' + scheduler_partial + 'angular-scheduler.html. ' + status); + //$log.error('Error calling ' + scheduler_partial + '. ' + status); + }); + }; + }]) + + .factory('InjectDetail', ['AngularScheduler.partials', '$compile', '$http', '$log', function(scheduler_partial, $compile, $http) { + return function(params) { + + var scope = params.scope, + target = params.target, + showRRule = params.showRRule; + + scope.showRRule = showRRule || false; + + if (scope.removeHtmlDetailReady) { + scope.removeHtmlDetailReady(); + } + scope.removeHtmlDetailReady = scope.$on('htmlDetailReady', function(e, data) { + var element = (angular.isObject(target)) ? target : angular.element(document.getElementById(target)); + element.html(data); + $compile(element)(scope); + }); + + $http({ method: 'GET', url: scheduler_partial + 'angular-scheduler-detail.html' }) + .success( function(data) { + scope.$emit('htmlDetailReady', data); + }) + .error( function(data, status) { + throw('Error reading ' + scheduler_partial + 'angular-scheduler-detail.html. ' + status); //$log.error('Error calling ' + scheduler_partial + '. ' + status); }); }; @@ -756,6 +818,13 @@ angular.module('AngularScheduler', ['underscore']) scope.weekDayFRClass = ''; scope.weekDaySAClass = ''; scope.weekDaySUClass = ''; + + //Detail view + scope.schedulerIsValid = false; + scope.rrule_nlp_description = ''; + scope.rrule = ''; + scope.dateChoice = 'utc'; + scope.occurrence_list = []; }; }]) diff --git a/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.min.css b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.min.css index 8f38cffc2f..e95591b0ee 100644 --- a/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.min.css +++ b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.min.css @@ -1 +1 @@ -.ui-widget input{font-size:12px;font-weight:400;text-align:center}.ui-spinner.ui-widget-content{border-bottom-color:#ccc;border-top-color:#ccc;border-left-color:#ccc;border-right-color:#ccc}.ui-spinner-button{border-left-color:#ccc;border-left-style:solid;border-left-width:1px}.scheduler-time-spinner{width:40px;height:24px}.scheduler-spinner{width:50px;height:24px}.fmt-help{font-size:12px;font-weight:400;color:#999;padding-left:10px}.error{color:#dd1b16;font-size:12px;margin-bottom:0;margin-top:0;padding-top:3px}.error-pull-up{position:relative;top:-15px;margin-bottom:15px}.red-text{color:#dd1b16}input.ng-dirty.ng-invalid,select.ng-dirty.ng-invalid,textarea.ng-dirty.ng-invalid{border:1px solid red;outline:0}.help-text{font-size:12px;font-weight:400;color:#999;margin-top:5px}.inline-label{margin-left:10px}#scheduler-buttons{margin-top:20px}.no-label{padding-top:25px}.padding-top-slim{padding-top:5px}.option-pad-left{padding-left:15px}.option-pad-top{padding-top:15px}.option-pad-bottom{padding-bottom:15px}#monthlyOccurrence,#monthlyWeekDay{margin-top:5px}select{width:100%} \ No newline at end of file +.ui-widget input{font-size:12px;font-weight:400;text-align:center}.ui-spinner.ui-widget-content{border-bottom-color:#ccc;border-top-color:#ccc;border-left-color:#ccc;border-right-color:#ccc}.ui-spinner-button{border-left-color:#ccc;border-left-style:solid;border-left-width:1px}.scheduler-time-spinner{width:40px;height:24px}.scheduler-spinner{width:50px;height:24px}.fmt-help{font-size:12px;font-weight:400;color:#999;padding-left:10px}.error{color:#dd1b16;font-size:12px;margin-bottom:0;margin-top:0;padding-top:3px}.error-pull-up{position:relative;top:-15px;margin-bottom:15px}.red-text{color:#dd1b16}input.ng-dirty.ng-invalid,select.ng-dirty.ng-invalid,textarea.ng-dirty.ng-invalid{border:1px solid red;outline:0}.help-text{font-size:12px;font-weight:400;color:#999;margin-top:5px}.inline-label{margin-left:10px}#scheduler-buttons{margin-top:20px}.no-label{padding-top:25px}.padding-top-slim{padding-top:5px}.option-pad-left{padding-left:15px}.option-pad-top{padding-top:15px}.option-pad-bottom{padding-bottom:15px}#monthlyOccurrence,#monthlyWeekDay{margin-top:5px}select{width:100%}#occurrence-label{display:inline-block}.occurrence-list{border:1px solid #ccc;padding:8px 10px;border-radius:4px;background-color:#eee;list-style:none;margin-bottom:5px;min-height:220px}#date-choice{display:inline-block;margin-left:15px;font-size:12px}#date-choice .label-inline{display:inline-block;vertical-align:middle}#date-choice input{margin-bottom:2px;height:11px;width:10px}#date-choice .label-inline:first-child{padding-bottom:2px;margin-right:10px}#date-choice .label-inline:nth-child(3){margin-right:10px} \ No newline at end of file diff --git a/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.min.js b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.min.js index 967c23c774..63bb5233f1 100644 --- a/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.min.js +++ b/awx/ui/static/lib/angular-scheduler/lib/angular-scheduler.min.js @@ -1 +1 @@ -/*! angular-scheduler - v0.0.1 - 2014-03-11 */"use strict";angular.module("underscore",[]).factory("_",[function(){return window._}]),angular.module("AngularScheduler",["underscore"]).constant("AngularScheduler.partial","/lib/angular-scheduler.html").constant("AngularScheduler.useTimezone",!1).constant("AngularScheduler.showUTCField",!1).factory("SchedulerInit",["$log","$filter","$timezones","LoadLookupValues","SetDefaults","CreateObject","_","AngularScheduler.useTimezone","AngularScheduler.showUTCField",function(a,b,c,d,e,f,g,h,i){return function(b){var j=b.scope;return j.schedulerShowTimeZone=h,j.schedulerShowUTCStartTime=i,j.setDefaults=function(){h&&(j.current_timezone=c.getLocal(),($.isEmptyObject(j.current_timezone)||!j.current_timezone.name)&&(a.error("Failed to find local timezone. Defaulting to America/New_York."),j.current_timezone={name:"America/New_York"}),j.schedulerTimeZone=g.find(j.timeZones,function(a){return a.name===j.current_timezone.name})),d(j),e(j),j.scheduleTimeChange(),j.scheduleRepeatChange()},j.scheduleTimeChange=function(){if(j.schedulerStartDt)if(h){j.resetStartDate();try{var a=j.schedulerStartDt+"T"+j.schedulerStartHour+":"+j.schedulerStartMinute+":"+j.schedulerStartSecond+".000Z";j.schedulerUTCTime=c.toUTC(a,j.schedulerTimeZone.name).toISOString()}catch(b){j.startDateError("Provide a valid start date and time")}}else j.schedulerUTCTime=j.schedulerStartDt+"T"+j.schedulerStartHour+":"+j.schedulerStartMinute+":"+j.schedulerStartSecond+".000Z";else j.schedulerUTCTime=""},j.scheduleRepeatChange=function(){j.schedulerFrequency&&""!==j.schedulerFrequency.value&&"none"!==j.schedulerFrequency.value?(j.schedulerInterval=1,j.schedulerShowInterval=!0,j.schedulerIntervalLabel=j.schedulerFrequency.intervalLabel):(j.schedulerShowInterval=!1,j.schedulerEnd=j.endOptions[0])},j.showCalendar=function(a){$("#"+a).focus()},j.monthlyRepeatChange=function(){$("#monthDay").spinner("day"!==j.monthlyRepeatOption?"disable":"enable")},j.yearlyRepeatChange=function(){$("#yearlyRepeatDay").spinner("month"!==j.yearlyRepeatOption?"disable":"enable")},j.setWeekday=function(a){var b=j.weekDays.indexOf(a);b>=0?j.weekDays.splice(a,1):j.weekDays.push(a)},j.startDateError=function(a){j.scheduler_form&&(j.scheduler_form_schedulerStartDt_error=a,j.scheduler_form.schedulerStartDt.$pristine=!1,j.scheduler_form.schedulerStartDt.$dirty=!0,$("#schedulerStartDt").removeClass("ng-pristine").removeClass("ng-valid").removeClass("ng-valid-custom-error").addClass("ng-dirty").addClass("ng-invalid").addClass("ng-invalid-custom-error"))},j.resetStartDate=function(){j.scheduler_form&&(j.scheduler_form_schedulerStartDt_error="",j.scheduler_form.schedulerStartDt.$setValidity("custom-error",!0),j.scheduler_form.schedulerStartDt.$setPristine())},j.removeZonesReady&&j.removeZonesReady(),j.removeZonesReady=j.$on("zonesReady",function(){j.timeZones=JSON.parse(localStorage.zones),j.setDefaults()}),h?c.getZoneList(j):j.setDefaults(),f(j)}}]).factory("CreateObject",["AngularScheduler.useTimezone","$filter","GetRule","Inject","SetDefaults","$timezones","SetRule",function(a,b,c,d,e,f,g){return function(e){var h=function(){this.scope=e,this.useTimezone=a,this.getOptions=function(){var a={};return a.startDate=this.scope.schedulerUTCTime,a.frequency=this.scope.schedulerFrequency.value,a.interval=this.scope.schedulerInterval,"after"===this.scope.schedulerEnd.value&&(a.occurrenceCount=this.scope.schedulerOccurrenceCount),"on"===this.scope.schedulerEnd.value&&(a.endDate=e.schedulerEndDt+this.scope.schedulerUTCTime.replace(/^\d{4}-\d{2}-\d{2}/,"")),"weekly"===this.scope.schedulerFrequency.value?a.weekDays=this.scope.weekDays:"yearly"===this.scope.schedulerFrequency.value?"month"===this.scope.yearlyRepeatOption?(a.month=this.scope.yearlyMonth.value,a.monthDay=this.scope.yearlyMonthDay):(a.setOccurrence=this.scope.yearlyOccurrence.value,a.weekDays=this.scope.yearlyWeekDay.value,a.month=this.scope.yearlyOtherMonth.value):"monthly"===this.scope.schedulerFrequency.value&&("day"===this.scope.monthlyRepeatOption?a.monthDay=this.scope.monthDay:(a.setOccurrence=this.scope.monthlyOccurrence.value,a.weekDays=this.scope.monthlyWeekDay.value)),a},this.clearErrors=function(){this.scope.scheduler_weekDays_error=!1,this.scope.scheduler_endDt_error=!1,this.scope.resetStartDate(),this.scope.scheduler_endDt_error=!1,this.scope.scheduler_form.schedulerEndDt.$setValidity("custom-error",!0),this.scope.scheduler_form.schedulerEndDt.$setPristine(),this.scope.scheduler_form.$setPristine()},this.isValid=function(){var a,c,d,g,h,i,j=!0;if(this.clearErrors(),"weekly"===this.scope.schedulerFrequency.value&&0===e.weekDays.length&&(this.scope.scheduler_weekDays_error=!0,j=!1),this.scope.scheduler_form.schedulerName.$valid||(this.scope.scheduler_form.schedulerName.$dirty=!0,$("#schedulerName").addClass("ng-dirty"),j=!1),"on"===this.scope.schedulerEnd.value&&(/^\d{4}-\d{2}-\d{2}$/.test(this.scope.schedulerEndDt)||(this.scope.scheduler_form.schedulerEndDt.$pristine=!1,this.scope.scheduler_form.schedulerEndDt.$dirty=!0,$("#schedulerEndDt").removeClass("ng-pristine").removeClass("ng-valid").removeClass("ng-valid-custom-error").addClass("ng-dirty").addClass("ng-invalid").addClass("ng-invalid-custom-error"),this.scope.scheduler_endDt_error=!0,j=!1)),this.scope.schedulerUTCTime)try{a=new Date(this.scope.schedulerUTCTime),isNaN(a)?(this.scope.startDateError("Invalid start date and time"),j=!1):(i=a.getTime(),c=new Date,this.useTimezone?(d=c.getFullYear()+"-"+b("schZeroPad")(c.getMonth()+1,2)+"-"+b("schZeroPad")(c.getDate(),2)+"T"+b("schZeroPad")(c.getHours(),2)+":"+b("schZeroPad")(c.getMinutes(),2)+":"+b("schZeroPad")(c.getSeconds(),2)+".000Z",g=f.toUTC(d,this.scope.schedulerTimeZone.name),h=g.getTime()):h=c.getTime(),h>=i&&(this.scope.startDateError("Start date and time must be in the future"),j=!1))}catch(k){this.scope.startDateError("Invalid start date and time"),j=!1}else this.scope.startDateError("Provide a valid start date and time"),j=!1;return j},this.getRRule=function(){var a=this.getOptions();return c(a)},this.getValue=function(){var a=this.getRRule(),b=this.getOptions();return{name:e.schedulerName,rrule:a.toString(),options:b}},this.setRRule=function(a){return this.clear(),g(a,this.scope)},this.setName=function(a){this.scope.schedulerName=a},this.inject=function(a,b){return d({scope:this.scope,target:a,buttons:b})},this.clear=function(){this.clearErrors(),this.scope.scheduler_form.schedulerName.$setPristine(),this.scope.setDefaults()},this.getUserTimezone=function(){return f.getLocal()}};return new h}}]).factory("Inject",["AngularScheduler.partial","$compile","$http","$log",function(a,b,c){return function(d){var e=d.scope,f=d.target,g=d.buttons;e.removeHtmlReady&&e.removeHtmlReady(),e.removeHtmlReady=e.$on("htmlReady",function(a,c){var d=angular.isObject(f)?f:angular.element(document.getElementById(f));d.html(c),b(d)(e),g&&$("#scheduler-buttons").show()}),c({method:"GET",url:a}).success(function(a){e.$emit("htmlReady",a)}).error(function(b,c){throw"Error reading "+a+". "+c})}}]).factory("GetRule",["$log",function(a){return function(b){var c,d=b.startDate,e=b.frequency,f=b.interval,g=b.occurrenceCount,h=b.endDate,i=b.month,j=b.monthDay,k=b.weekDays,l=b.setOccurrence,m={};if(angular.isDate(d))m.dtstart=d;else try{m.dtstart=new Date(d)}catch(n){a.error("Date conversion failed. Attempted to convert "+d+" to Date. "+n.message)}if(e&&"none"!==e){if(m.freq=RRule[e.toUpperCase()],m.interval=f,k&&"string"==typeof k&&(m.byweekday=RRule[k.toUpperCase()]),k&&angular.isArray(k))for(m.byweekday=[],c=0;c 0"),"BYDAY"===r)if("WEEKLY"===g(d,"FREQ"))for(i=s.split(/,/),f.weekDays=[],k=0;k0&&parseInt(s,10)<32?(f.monthDay=parseInt(s,10),f.monhthlyRepeatOption="day"):m="BYMONTHDAY must contain an integer between 1 and 31"),"DTSTART"===r&&(n=!0,/\d{8}T\d{6}Z/.test(s)&&(s=s.replace(/(\d{4})(\d{2})(\d{2}T)(\d{2})(\d{2})(\d{2}Z)/,function(a,b,c,d,e,f,g){return b+"-"+c+"-"+d+e+":"+f+":"+g})),a?(l=new Date(s),o=e("schZeroPad")(l.getMonth()+1,2),p=e("schZeroPad")(l.getDate(),2),f.schedulerStartDt=l.getFullYear()+"-"+o+"-"+p,f.schedulerStartHour=e("schZeroPad")(l.getHours(),2),f.schedulerStartMinute=e("schZeroPad")(l.getMinutes(),2),f.schedulerStartSecond=e("schZeroPad")(l.getSeconds(),2),f.scheduleTimeChange()):(q=s.replace(/^.*T/,""),f.schedulerStartDt=s.replace(/T.*$/,""),f.schedulerStartHour=q.substr(0,2),f.schedulerStartMinute=q.substr(3,2),f.schedulerStartMinute=q.substr(6,2)),f.scheduleTimeChange()),"BYSETPOS"===r&&("YEARLY"===g(d,"FREQ")?(f.yearlRepeatOption="other",f.yearlyOccurrence=b.find(f.occurrences,function(a){return a.value===parseInt(s,10)}),f.yearlyOccurrence&&f.yearlyOccurrence.name||(m="BYSETPOS was not in the set of 1,2,3,4,-1")):(f.monthlyOccurrence=b.find(f.occurrences,function(a){return a.value===parseInt(s,10)}),f.monthlyOccurrence&&f.monthlyOccurrence.name||(m="BYSETPOS was not in the set of 1,2,3,4,-1"))),"COUNT"===r&&(parseInt(s,10)?(f.schedulerEnd=f.endOptions[1],f.schedulerOccurrenceCount=parseInt(s,10)):m="COUNT must be a valid integer > 0"),"UNTIL"===r&&(/\d{8}T\d{6}Z/.test(s)&&(s=s.replace(/(\d{4})(\d{2})(\d{2}T)(\d{2})(\d{2})(\d{2}Z)/,function(a,b,c,d,e,f,g){return b+"-"+c+"-"+d+e+":"+f+":"+g})),f.schedulerEnd=f.endOptions[2],a?(l=new Date(s),o=e("schZeroPad")(l.getMonth()+1,2),p=e("schZeroPad")(l.getDate(),2),f.schedulerEndDt=l.getFullYear()+"-"+o+"-"+p):f.schedulerEndDt=s.replace(/T.*$/,"")),"BYMONTH"===r&&("YEARLY"===g(d,"FREQ")&&g(d,"BYDAY")?(f.yearlRepeatOption="other",f.yearlyOtherMonth=b.find(f.months,function(a){return a.value===parseInt(s,10)}),f.yearlyOtherMonth&&f.yearlyOtherMonth.name||(m="BYMONTH must be an integer between 1 and 12")):(f.yearlyOption="month",f.yearlyMonth=b.find(f.months,function(a){return a.value===parseInt(s,10)}),f.yearlyMonth&&f.yearlyMonth.name||(m="BYMONTH must be an integer between 1 and 12"))),"BYMONTHDAY"===r&&(parseInt(s,10)?f.yearlyMonthDay=parseInt(s,10):m="BYMONTHDAY must be an integer between 1 and 31")}function j(){"weekly"===f.schedulerFrequency.name&&0===f.weekDays.length&&(m="Frequency is weekly, but BYDAYS value is missing."),n||(m="Warning: start date was not provided")}var k,l,m="",n=!1;if(d)if(k=d.split(/;/),angular.isArray(k)){for(l=0;l=0?j.weekDays.splice(a,1):j.weekDays.push(a)},j.startDateError=function(a){j.scheduler_form&&(j.scheduler_form.schedulerStartDt&&(j.scheduler_form_schedulerStartDt_error=a,j.scheduler_form.schedulerStartDt.$pristine=!1,j.scheduler_form.schedulerStartDt.$dirty=!0),$("#schedulerStartDt").removeClass("ng-pristine").removeClass("ng-valid").removeClass("ng-valid-custom-error").addClass("ng-dirty").addClass("ng-invalid").addClass("ng-invalid-custom-error"))},j.resetStartDate=function(){j.scheduler_form&&(j.scheduler_form_schedulerStartDt_error="",j.scheduler_form.schedulerStartDt&&(j.scheduler_form.schedulerStartDt.$setValidity("custom-error",!0),j.scheduler_form.schedulerStartDt.$setPristine()))},j.removeZonesReady&&j.removeZonesReady(),j.removeZonesReady=j.$on("zonesReady",function(){j.timeZones=JSON.parse(localStorage.zones),j.setDefaults()}),h?c.getZoneList(j):j.setDefaults(),f(j,k)}}]).factory("CreateObject",["AngularScheduler.useTimezone","$filter","GetRule","Inject","InjectDetail","SetDefaults","$timezones","SetRule",function(a,b,c,d,e,f,g,h){return function(f,i){var j=function(){this.scope=f,this.useTimezone=a,this.requireFutureStartTime=i,this.getOptions=function(){var a={};return a.startDate=this.scope.schedulerUTCTime,a.frequency=this.scope.schedulerFrequency.value,a.interval=this.scope.schedulerInterval,"after"===this.scope.schedulerEnd.value&&(a.occurrenceCount=this.scope.schedulerOccurrenceCount),"on"===this.scope.schedulerEnd.value&&(a.endDate=f.schedulerEndDt+this.scope.schedulerUTCTime.replace(/^\d{4}-\d{2}-\d{2}/,"")),"weekly"===this.scope.schedulerFrequency.value?a.weekDays=this.scope.weekDays:"yearly"===this.scope.schedulerFrequency.value?"month"===this.scope.yearlyRepeatOption?(a.month=this.scope.yearlyMonth.value,a.monthDay=this.scope.yearlyMonthDay):(a.setOccurrence=this.scope.yearlyOccurrence.value,a.weekDays=this.scope.yearlyWeekDay.value,a.month=this.scope.yearlyOtherMonth.value):"monthly"===this.scope.schedulerFrequency.value&&("day"===this.scope.monthlyRepeatOption?a.monthDay=this.scope.monthDay:(a.setOccurrence=this.scope.monthlyOccurrence.value,a.weekDays=this.scope.monthlyWeekDay.value)),a},this.clearErrors=function(){this.scope.scheduler_weekDays_error=!1,this.scope.scheduler_endDt_error=!1,this.scope.resetStartDate(),this.scope.scheduler_endDt_error=!1,this.scope.scheduler_form&&this.scope.scheduler_form.schedulerEndDt&&(this.scope.scheduler_form.schedulerEndDt.$setValidity("custom-error",!0),this.scope.scheduler_form.schedulerEndDt.$setPristine(),this.scope.scheduler_form.$setPristine())},this.setDetails=function(){var a=this.getRRule();a&&(f.rrule_nlp_description=a.toText(),f.dateChoice="utc",f.occurrence_list=[],a.all(function(a,b){return 10>b?(f.occurrence_list.push({utc:a.toUTCString(),local:a.toString()}),!0):!1}),f.rrule_nlp_description=a.toText().replace(/^RRule error.*$/,"Natural language description not available"),f.rrule=a.toString())},this.isValid=function(){var a,c,d,e,h,i,j=!0;if(this.clearErrors(),"weekly"===this.scope.schedulerFrequency.value&&0===f.weekDays.length&&(this.scope.scheduler_weekDays_error=!0,j=!1),this.scope.scheduler_form.schedulerName.$valid||(this.scope.scheduler_form.schedulerName.$dirty=!0,$("#schedulerName").addClass("ng-dirty"),j=!1),"on"===this.scope.schedulerEnd.value&&(/^\d{4}-\d{2}-\d{2}$/.test(this.scope.schedulerEndDt)||(this.scope.scheduler_form.schedulerEndDt.$pristine=!1,this.scope.scheduler_form.schedulerEndDt.$dirty=!0,$("#schedulerEndDt").removeClass("ng-pristine").removeClass("ng-valid").removeClass("ng-valid-custom-error").addClass("ng-dirty").addClass("ng-invalid").addClass("ng-invalid-custom-error"),this.scope.scheduler_endDt_error=!0,j=!1)),this.scope.schedulerUTCTime)try{a=new Date(this.scope.schedulerUTCTime),isNaN(a)?(this.scope.startDateError("Invalid start time"),j=!1):(i=a.getTime(),c=new Date,this.useTimezone?(d=c.getFullYear()+"-"+b("schZeroPad")(c.getMonth()+1,2)+"-"+b("schZeroPad")(c.getDate(),2)+"T"+b("schZeroPad")(c.getHours(),2)+":"+b("schZeroPad")(c.getMinutes(),2)+":"+b("schZeroPad")(c.getSeconds(),2)+".000Z",e=g.toUTC(d,this.scope.schedulerTimeZone.name),h=e.getTime()):h=c.getTime(),this.requireFutureStartTime&&h>=i&&(this.scope.startDateError("Start time must be in the future"),j=!1))}catch(k){this.scope.startDateError("Invalid start time"),j=!1}else this.scope.startDateError("Provide a start time"),j=!1;return f.schedulerIsValid=j,j&&this.setDetails(),j},this.getRRule=function(){var a=this.getOptions();return c(a)},this.getValue=function(){var a=this.getRRule(),b=this.getOptions();return{name:f.schedulerName,rrule:a.toString(),options:b}},this.setRRule=function(a){return this.clear(),h(a,this.scope)},this.setName=function(a){this.scope.schedulerName=a},this.inject=function(a,b){return d({scope:this.scope,target:a,buttons:b})},this.injectDetail=function(a,b){return e({scope:this.scope,target:a,showRRule:b})},this.clear=function(){this.clearErrors(),this.scope.scheduler_form&&this.scope.scheduler_form.schedulerName&&this.scope.scheduler_form.schedulerName.$setPristine(),this.scope.setDefaults()},this.getUserTimezone=function(){return g.getLocal()},this.setRequireFutureStartTime=function(a){this.requireFutureStartTime=a},this.getRequireFutureStartTime=function(){return this.requireFutureStartTime},this.setShowRRule=function(a){f.showRRule=a}};return new j}}]).factory("Inject",["AngularScheduler.partials","$compile","$http","$log",function(a,b,c){return function(d){var e=d.scope,f=d.target,g=d.buttons;e.removeHtmlReady&&e.removeHtmlReady(),e.removeHtmlReady=e.$on("htmlReady",function(a,c){var d=angular.isObject(f)?f:angular.element(document.getElementById(f));d.html(c),b(d)(e),g&&$("#scheduler-buttons").show()}),c({method:"GET",url:a+"angular-scheduler.html"}).success(function(a){e.$emit("htmlReady",a)}).error(function(b,c){throw"Error reading "+a+"angular-scheduler.html. "+c})}}]).factory("InjectDetail",["AngularScheduler.partials","$compile","$http","$log",function(a,b,c){return function(d){var e=d.scope,f=d.target,g=d.showRRule;e.showRRule=g||!1,e.removeHtmlDetailReady&&e.removeHtmlDetailReady(),e.removeHtmlDetailReady=e.$on("htmlDetailReady",function(a,c){var d=angular.isObject(f)?f:angular.element(document.getElementById(f));d.html(c),b(d)(e)}),c({method:"GET",url:a+"angular-scheduler-detail.html"}).success(function(a){e.$emit("htmlDetailReady",a)}).error(function(b,c){throw"Error reading "+a+"angular-scheduler-detail.html. "+c})}}]).factory("GetRule",["$log",function(a){return function(b){var c,d=b.startDate,e=b.frequency,f=b.interval,g=b.occurrenceCount,h=b.endDate,i=b.month,j=b.monthDay,k=b.weekDays,l=b.setOccurrence,m={};if(angular.isDate(d))m.dtstart=d;else try{m.dtstart=new Date(d)}catch(n){a.error("Date conversion failed. Attempted to convert "+d+" to Date. "+n.message)}if(e&&"none"!==e){if(m.freq=RRule[e.toUpperCase()],m.interval=f,k&&"string"==typeof k&&(m.byweekday=RRule[k.toUpperCase()]),k&&angular.isArray(k))for(m.byweekday=[],c=0;c 0"),"BYDAY"===r)if("WEEKLY"===g(d,"FREQ"))for(i=s.split(/,/),f.weekDays=[],k=0;k0&&parseInt(s,10)<32?(f.monthDay=parseInt(s,10),f.monhthlyRepeatOption="day"):m="BYMONTHDAY must contain an integer between 1 and 31"),"DTSTART"===r&&(n=!0,/\d{8}T\d{6}Z/.test(s)&&(s=s.replace(/(\d{4})(\d{2})(\d{2}T)(\d{2})(\d{2})(\d{2}Z)/,function(a,b,c,d,e,f,g){return b+"-"+c+"-"+d+e+":"+f+":"+g})),a?(l=new Date(s),o=e("schZeroPad")(l.getMonth()+1,2),p=e("schZeroPad")(l.getDate(),2),f.schedulerStartDt=l.getFullYear()+"-"+o+"-"+p,f.schedulerStartHour=e("schZeroPad")(l.getHours(),2),f.schedulerStartMinute=e("schZeroPad")(l.getMinutes(),2),f.schedulerStartSecond=e("schZeroPad")(l.getSeconds(),2),f.scheduleTimeChange()):(q=s.replace(/^.*T/,""),f.schedulerStartDt=s.replace(/T.*$/,""),f.schedulerStartHour=q.substr(0,2),f.schedulerStartMinute=q.substr(3,2),f.schedulerStartMinute=q.substr(6,2)),f.scheduleTimeChange()),"BYSETPOS"===r&&("YEARLY"===g(d,"FREQ")?(f.yearlRepeatOption="other",f.yearlyOccurrence=b.find(f.occurrences,function(a){return a.value===parseInt(s,10)}),f.yearlyOccurrence&&f.yearlyOccurrence.name||(m="BYSETPOS was not in the set of 1,2,3,4,-1")):(f.monthlyOccurrence=b.find(f.occurrences,function(a){return a.value===parseInt(s,10)}),f.monthlyOccurrence&&f.monthlyOccurrence.name||(m="BYSETPOS was not in the set of 1,2,3,4,-1"))),"COUNT"===r&&(parseInt(s,10)?(f.schedulerEnd=f.endOptions[1],f.schedulerOccurrenceCount=parseInt(s,10)):m="COUNT must be a valid integer > 0"),"UNTIL"===r&&(/\d{8}T\d{6}Z/.test(s)&&(s=s.replace(/(\d{4})(\d{2})(\d{2}T)(\d{2})(\d{2})(\d{2}Z)/,function(a,b,c,d,e,f,g){return b+"-"+c+"-"+d+e+":"+f+":"+g})),f.schedulerEnd=f.endOptions[2],a?(l=new Date(s),o=e("schZeroPad")(l.getMonth()+1,2),p=e("schZeroPad")(l.getDate(),2),f.schedulerEndDt=l.getFullYear()+"-"+o+"-"+p):f.schedulerEndDt=s.replace(/T.*$/,"")),"BYMONTH"===r&&("YEARLY"===g(d,"FREQ")&&g(d,"BYDAY")?(f.yearlRepeatOption="other",f.yearlyOtherMonth=b.find(f.months,function(a){return a.value===parseInt(s,10)}),f.yearlyOtherMonth&&f.yearlyOtherMonth.name||(m="BYMONTH must be an integer between 1 and 12")):(f.yearlyOption="month",f.yearlyMonth=b.find(f.months,function(a){return a.value===parseInt(s,10)}),f.yearlyMonth&&f.yearlyMonth.name||(m="BYMONTH must be an integer between 1 and 12"))),"BYMONTHDAY"===r&&(parseInt(s,10)?f.yearlyMonthDay=parseInt(s,10):m="BYMONTHDAY must be an integer between 1 and 31")}function j(){"weekly"===f.schedulerFrequency.name&&0===f.weekDays.length&&(m="Frequency is weekly, but BYDAYS value is missing."),n||(m="Warning: start date was not provided")}var k,l,m="",n=!1;if(d)if(k=d.split(/;/),angular.isArray(k)){for(l=0;l + + + + Jasmine Spec Runner v2.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/awx/ui/static/lib/angular-scheduler/tests/karma.conf.js b/awx/ui/static/lib/angular-scheduler/tests/karma.conf.js new file mode 100644 index 0000000000..6760301faf --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/tests/karma.conf.js @@ -0,0 +1,82 @@ +// Karma configuration +// Generated on Thu Feb 27 2014 22:39:50 GMT-0500 (EST) + +module.exports = function(config) { + config.set({ + + // base path, that will be used to resolve files and exclude + basePath: '../', + + + // frameworks to use + frameworks: ['jasmine'], + + // list of files / patterns to load in the browser + files: [ + 'bower_components/jquery/dist/jquery.min.js', + 'bower_components/jqueryui/ui/minified/jquery-ui.min.js', + 'bower_components/twitter/dist/js/bootstrap.min.js', + 'bower_components/timezone-js/src/date.js', + 'bower_components/angular-tz-extensions/packages/jstimezonedetect/jstz.min.js', + 'bower_components/underscore/underscore.js', + 'bower_components/rrule/lib/rrule.js', + 'bower_components/angular/angular.min.js', + 'bower_components/angular-mocks/angular-mocks.js', + 'bower_components/angular-route/angular-route.min.js', + 'bower_components/angular-tz-extensions/lib/angular-tz-extensions.js', + 'lib/angular-scheduler.js', + 'tests/GetRRule.js', + + // fixtures + { pattern: 'bower_components/angular-tz-extensions/tz/data/*', watched: false, served: true, included: false } + ], + + + // list of files to exclude + exclude: [ + + ], + + + // test results reporter to use + // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_DEBUG, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // Start these browsers, currently available: + // - Chrome + // - ChromeCanary + // - Firefox + // - Opera (has to be installed with `npm install karma-opera-launcher`) + // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`) + // - PhantomJS + // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`) + browsers: ['Firefox','Chrome'], + + + // If browser does not capture in given timeout [ms], kill it + captureTimeout: 60000, + + + // Continuous Integration mode + // if true, it capture browsers, run tests and exit + singleRun: false + }); +}; diff --git a/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/boot.js b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/boot.js new file mode 100644 index 0000000000..ec8baa0aa5 --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/boot.js @@ -0,0 +1,181 @@ +/** + Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project. + + If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms. + + The location of `boot.js` can be specified and/or overridden in `jasmine.yml`. + + [jasmine-gem]: http://github.com/pivotal/jasmine-gem + */ + +(function() { + + /** + * ## Require & Instantiate + * + * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. + */ + window.jasmine = jasmineRequire.core(jasmineRequire); + + /** + * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference. + */ + jasmineRequire.html(jasmine); + + /** + * Create the Jasmine environment. This is used to run all specs in a project. + */ + var env = jasmine.getEnv(); + + /** + * ## The Global Interface + * + * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged. + */ + var jasmineInterface = { + describe: function(description, specDefinitions) { + return env.describe(description, specDefinitions); + }, + + xdescribe: function(description, specDefinitions) { + return env.xdescribe(description, specDefinitions); + }, + + it: function(desc, func) { + return env.it(desc, func); + }, + + xit: function(desc, func) { + return env.xit(desc, func); + }, + + beforeEach: function(beforeEachFunction) { + return env.beforeEach(beforeEachFunction); + }, + + afterEach: function(afterEachFunction) { + return env.afterEach(afterEachFunction); + }, + + expect: function(actual) { + return env.expect(actual); + }, + + pending: function() { + return env.pending(); + }, + + spyOn: function(obj, methodName) { + return env.spyOn(obj, methodName); + }, + + jsApiReporter: new jasmine.JsApiReporter({ + timer: new jasmine.Timer() + }) + }; + + /** + * Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`. + */ + if (typeof window == "undefined" && typeof exports == "object") { + extend(exports, jasmineInterface); + } else { + extend(window, jasmineInterface); + } + + /** + * Expose the interface for adding custom equality testers. + */ + jasmine.addCustomEqualityTester = function(tester) { + env.addCustomEqualityTester(tester); + }; + + /** + * Expose the interface for adding custom expectation matchers + */ + jasmine.addMatchers = function(matchers) { + return env.addMatchers(matchers); + }; + + /** + * Expose the mock interface for the JavaScript timeout functions + */ + jasmine.clock = function() { + return env.clock; + }; + + /** + * ## Runner Parameters + * + * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface. + */ + + var queryString = new jasmine.QueryString({ + getWindowLocation: function() { return window.location; } + }); + + var catchingExceptions = queryString.getParam("catch"); + env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions); + + /** + * ## Reporters + * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any). + */ + var htmlReporter = new jasmine.HtmlReporter({ + env: env, + onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); }, + getContainer: function() { return document.body; }, + createElement: function() { return document.createElement.apply(document, arguments); }, + createTextNode: function() { return document.createTextNode.apply(document, arguments); }, + timer: new jasmine.Timer() + }); + + /** + * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript. + */ + env.addReporter(jasmineInterface.jsApiReporter); + env.addReporter(htmlReporter); + + /** + * Filter which specs will be run by matching the start of the full name against the `spec` query param. + */ + var specFilter = new jasmine.HtmlSpecFilter({ + filterString: function() { return queryString.getParam("spec"); } + }); + + env.specFilter = function(spec) { + return specFilter.matches(spec.getFullName()); + }; + + /** + * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack. + */ + window.setTimeout = window.setTimeout; + window.setInterval = window.setInterval; + window.clearTimeout = window.clearTimeout; + window.clearInterval = window.clearInterval; + + /** + * ## Execution + * + * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded. + */ + var currentWindowOnload = window.onload; + + window.onload = function() { + if (currentWindowOnload) { + currentWindowOnload(); + } + htmlReporter.initialize(); + env.execute(); + }; + + /** + * Helper function for readability above. + */ + function extend(destination, source) { + for (var property in source) destination[property] = source[property]; + return destination; + } + +}()); diff --git a/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/console.js b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/console.js new file mode 100644 index 0000000000..33c1698cf1 --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/console.js @@ -0,0 +1,160 @@ +/* +Copyright (c) 2008-2013 Pivotal Labs + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +function getJasmineRequireObj() { + if (typeof module !== "undefined" && module.exports) { + return exports; + } else { + window.jasmineRequire = window.jasmineRequire || {}; + return window.jasmineRequire; + } +} + +getJasmineRequireObj().console = function(jRequire, j$) { + j$.ConsoleReporter = jRequire.ConsoleReporter(); +}; + +getJasmineRequireObj().ConsoleReporter = function() { + + var noopTimer = { + start: function(){}, + elapsed: function(){ return 0; } + }; + + function ConsoleReporter(options) { + var print = options.print, + showColors = options.showColors || false, + onComplete = options.onComplete || function() {}, + timer = options.timer || noopTimer, + specCount, + failureCount, + failedSpecs = [], + pendingCount, + ansi = { + green: '\x1B[32m', + red: '\x1B[31m', + yellow: '\x1B[33m', + none: '\x1B[0m' + }; + + this.jasmineStarted = function() { + specCount = 0; + failureCount = 0; + pendingCount = 0; + print("Started"); + printNewline(); + timer.start(); + }; + + this.jasmineDone = function() { + printNewline(); + for (var i = 0; i < failedSpecs.length; i++) { + specFailureDetails(failedSpecs[i]); + } + + printNewline(); + var specCounts = specCount + " " + plural("spec", specCount) + ", " + + failureCount + " " + plural("failure", failureCount); + + if (pendingCount) { + specCounts += ", " + pendingCount + " pending " + plural("spec", pendingCount); + } + + print(specCounts); + + printNewline(); + var seconds = timer.elapsed() / 1000; + print("Finished in " + seconds + " " + plural("second", seconds)); + + printNewline(); + + onComplete(failureCount === 0); + }; + + this.specDone = function(result) { + specCount++; + + if (result.status == "pending") { + pendingCount++; + print(colored("yellow", "*")); + return; + } + + if (result.status == "passed") { + print(colored("green", '.')); + return; + } + + if (result.status == "failed") { + failureCount++; + failedSpecs.push(result); + print(colored("red", 'F')); + } + }; + + return this; + + function printNewline() { + print("\n"); + } + + function colored(color, str) { + return showColors ? (ansi[color] + str + ansi.none) : str; + } + + function plural(str, count) { + return count == 1 ? str : str + "s"; + } + + function repeat(thing, times) { + var arr = []; + for (var i = 0; i < times; i++) { + arr.push(thing); + } + return arr; + } + + function indent(str, spaces) { + var lines = (str || '').split("\n"); + var newArr = []; + for (var i = 0; i < lines.length; i++) { + newArr.push(repeat(" ", spaces).join("") + lines[i]); + } + return newArr.join("\n"); + } + + function specFailureDetails(result) { + printNewline(); + print(result.fullName); + + for (var i = 0; i < result.failedExpectations.length; i++) { + var failedExpectation = result.failedExpectations[i]; + printNewline(); + print(indent(failedExpectation.stack, 2)); + } + + printNewline(); + } + } + + return ConsoleReporter; +}; diff --git a/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine-html.js b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine-html.js new file mode 100644 index 0000000000..985d0d1a0a --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine-html.js @@ -0,0 +1,359 @@ +/* +Copyright (c) 2008-2013 Pivotal Labs + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +jasmineRequire.html = function(j$) { + j$.ResultsNode = jasmineRequire.ResultsNode(); + j$.HtmlReporter = jasmineRequire.HtmlReporter(j$); + j$.QueryString = jasmineRequire.QueryString(); + j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); +}; + +jasmineRequire.HtmlReporter = function(j$) { + + var noopTimer = { + start: function() {}, + elapsed: function() { return 0; } + }; + + function HtmlReporter(options) { + var env = options.env || {}, + getContainer = options.getContainer, + createElement = options.createElement, + createTextNode = options.createTextNode, + onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {}, + timer = options.timer || noopTimer, + results = [], + specsExecuted = 0, + failureCount = 0, + pendingSpecCount = 0, + htmlReporterMain, + symbols; + + this.initialize = function() { + htmlReporterMain = createDom("div", {className: "html-reporter"}, + createDom("div", {className: "banner"}, + createDom("span", {className: "title"}, "Jasmine"), + createDom("span", {className: "version"}, j$.version) + ), + createDom("ul", {className: "symbol-summary"}), + createDom("div", {className: "alert"}), + createDom("div", {className: "results"}, + createDom("div", {className: "failures"}) + ) + ); + getContainer().appendChild(htmlReporterMain); + + symbols = find(".symbol-summary"); + }; + + var totalSpecsDefined; + this.jasmineStarted = function(options) { + totalSpecsDefined = options.totalSpecsDefined || 0; + timer.start(); + }; + + var summary = createDom("div", {className: "summary"}); + + var topResults = new j$.ResultsNode({}, "", null), + currentParent = topResults; + + this.suiteStarted = function(result) { + currentParent.addChild(result, "suite"); + currentParent = currentParent.last(); + }; + + this.suiteDone = function(result) { + if (currentParent == topResults) { + return; + } + + currentParent = currentParent.parent; + }; + + this.specStarted = function(result) { + currentParent.addChild(result, "spec"); + }; + + var failures = []; + this.specDone = function(result) { + if (result.status != "disabled") { + specsExecuted++; + } + + symbols.appendChild(createDom("li", { + className: result.status, + id: "spec_" + result.id, + title: result.fullName + } + )); + + if (result.status == "failed") { + failureCount++; + + var failure = + createDom("div", {className: "spec-detail failed"}, + createDom("div", {className: "description"}, + createDom("a", {title: result.fullName, href: specHref(result)}, result.fullName) + ), + createDom("div", {className: "messages"}) + ); + var messages = failure.childNodes[1]; + + for (var i = 0; i < result.failedExpectations.length; i++) { + var expectation = result.failedExpectations[i]; + messages.appendChild(createDom("div", {className: "result-message"}, expectation.message)); + messages.appendChild(createDom("div", {className: "stack-trace"}, expectation.stack)); + } + + failures.push(failure); + } + + if (result.status == "pending") { + pendingSpecCount++; + } + }; + + this.jasmineDone = function() { + var banner = find(".banner"); + banner.appendChild(createDom("span", {className: "duration"}, "finished in " + timer.elapsed() / 1000 + "s")); + + var alert = find(".alert"); + + alert.appendChild(createDom("span", { className: "exceptions" }, + createDom("label", { className: "label", 'for': "raise-exceptions" }, "raise exceptions"), + createDom("input", { + className: "raise", + id: "raise-exceptions", + type: "checkbox" + }) + )); + var checkbox = find("input"); + + checkbox.checked = !env.catchingExceptions(); + checkbox.onclick = onRaiseExceptionsClick; + + if (specsExecuted < totalSpecsDefined) { + var skippedMessage = "Ran " + specsExecuted + " of " + totalSpecsDefined + " specs - run all"; + alert.appendChild( + createDom("span", {className: "bar skipped"}, + createDom("a", {href: "?", title: "Run all specs"}, skippedMessage) + ) + ); + } + var statusBarMessage = "" + pluralize("spec", specsExecuted) + ", " + pluralize("failure", failureCount); + if (pendingSpecCount) { statusBarMessage += ", " + pluralize("pending spec", pendingSpecCount); } + + var statusBarClassName = "bar " + ((failureCount > 0) ? "failed" : "passed"); + alert.appendChild(createDom("span", {className: statusBarClassName}, statusBarMessage)); + + var results = find(".results"); + results.appendChild(summary); + + summaryList(topResults, summary); + + function summaryList(resultsTree, domParent) { + var specListNode; + for (var i = 0; i < resultsTree.children.length; i++) { + var resultNode = resultsTree.children[i]; + if (resultNode.type == "suite") { + var suiteListNode = createDom("ul", {className: "suite", id: "suite-" + resultNode.result.id}, + createDom("li", {className: "suite-detail"}, + createDom("a", {href: specHref(resultNode.result)}, resultNode.result.description) + ) + ); + + summaryList(resultNode, suiteListNode); + domParent.appendChild(suiteListNode); + } + if (resultNode.type == "spec") { + if (domParent.getAttribute("class") != "specs") { + specListNode = createDom("ul", {className: "specs"}); + domParent.appendChild(specListNode); + } + specListNode.appendChild( + createDom("li", { + className: resultNode.result.status, + id: "spec-" + resultNode.result.id + }, + createDom("a", {href: specHref(resultNode.result)}, resultNode.result.description) + ) + ); + } + } + } + + if (failures.length) { + alert.appendChild( + createDom('span', {className: "menu bar spec-list"}, + createDom("span", {}, "Spec List | "), + createDom('a', {className: "failures-menu", href: "#"}, "Failures"))); + alert.appendChild( + createDom('span', {className: "menu bar failure-list"}, + createDom('a', {className: "spec-list-menu", href: "#"}, "Spec List"), + createDom("span", {}, " | Failures "))); + + find(".failures-menu").onclick = function() { + setMenuModeTo('failure-list'); + }; + find(".spec-list-menu").onclick = function() { + setMenuModeTo('spec-list'); + }; + + setMenuModeTo('failure-list'); + + var failureNode = find(".failures"); + for (var i = 0; i < failures.length; i++) { + failureNode.appendChild(failures[i]); + } + } + }; + + return this; + + function find(selector) { + return getContainer().querySelector(selector); + } + + function createDom(type, attrs, childrenVarArgs) { + var el = createElement(type); + + for (var i = 2; i < arguments.length; i++) { + var child = arguments[i]; + + if (typeof child === 'string') { + el.appendChild(createTextNode(child)); + } else { + if (child) { + el.appendChild(child); + } + } + } + + for (var attr in attrs) { + if (attr == "className") { + el[attr] = attrs[attr]; + } else { + el.setAttribute(attr, attrs[attr]); + } + } + + return el; + } + + function pluralize(singular, count) { + var word = (count == 1 ? singular : singular + "s"); + + return "" + count + " " + word; + } + + function specHref(result) { + return "?spec=" + encodeURIComponent(result.fullName); + } + + function setMenuModeTo(mode) { + htmlReporterMain.setAttribute("class", "html-reporter " + mode); + } + } + + return HtmlReporter; +}; + +jasmineRequire.HtmlSpecFilter = function() { + function HtmlSpecFilter(options) { + var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); + var filterPattern = new RegExp(filterString); + + this.matches = function(specName) { + return filterPattern.test(specName); + }; + } + + return HtmlSpecFilter; +}; + +jasmineRequire.ResultsNode = function() { + function ResultsNode(result, type, parent) { + this.result = result; + this.type = type; + this.parent = parent; + + this.children = []; + + this.addChild = function(result, type) { + this.children.push(new ResultsNode(result, type, this)); + }; + + this.last = function() { + return this.children[this.children.length - 1]; + }; + } + + return ResultsNode; +}; + +jasmineRequire.QueryString = function() { + function QueryString(options) { + + this.setParam = function(key, value) { + var paramMap = queryStringToParamMap(); + paramMap[key] = value; + options.getWindowLocation().search = toQueryString(paramMap); + }; + + this.getParam = function(key) { + return queryStringToParamMap()[key]; + }; + + return this; + + function toQueryString(paramMap) { + var qStrPairs = []; + for (var prop in paramMap) { + qStrPairs.push(encodeURIComponent(prop) + "=" + encodeURIComponent(paramMap[prop])); + } + return "?" + qStrPairs.join('&'); + } + + function queryStringToParamMap() { + var paramStr = options.getWindowLocation().search.substring(1), + params = [], + paramMap = {}; + + if (paramStr.length > 0) { + params = paramStr.split('&'); + for (var i = 0; i < params.length; i++) { + var p = params[i].split('='); + var value = decodeURIComponent(p[1]); + if (value === "true" || value === "false") { + value = JSON.parse(value); + } + paramMap[decodeURIComponent(p[0])] = value; + } + } + + return paramMap; + } + + } + + return QueryString; +}; diff --git a/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine.css b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine.css new file mode 100644 index 0000000000..f4d35b6e78 --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine.css @@ -0,0 +1,55 @@ +body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; } + +.html-reporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; } +.html-reporter a { text-decoration: none; } +.html-reporter a:hover { text-decoration: underline; } +.html-reporter p, .html-reporter h1, .html-reporter h2, .html-reporter h3, .html-reporter h4, .html-reporter h5, .html-reporter h6 { margin: 0; line-height: 14px; } +.html-reporter .banner, .html-reporter .symbol-summary, .html-reporter .summary, .html-reporter .result-message, .html-reporter .spec .description, .html-reporter .spec-detail .description, .html-reporter .alert .bar, .html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; } +.html-reporter .banner .version { margin-left: 14px; } +.html-reporter #jasmine_content { position: fixed; right: 100%; } +.html-reporter .version { color: #aaaaaa; } +.html-reporter .banner { margin-top: 14px; } +.html-reporter .duration { color: #aaaaaa; float: right; } +.html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; } +.html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; } +.html-reporter .symbol-summary li.passed { font-size: 14px; } +.html-reporter .symbol-summary li.passed:before { color: #5e7d00; content: "\02022"; } +.html-reporter .symbol-summary li.failed { line-height: 9px; } +.html-reporter .symbol-summary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; } +.html-reporter .symbol-summary li.disabled { font-size: 14px; } +.html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; } +.html-reporter .symbol-summary li.pending { line-height: 17px; } +.html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; } +.html-reporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; } +.html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; } +.html-reporter .bar.failed { background-color: #b03911; } +.html-reporter .bar.passed { background-color: #a6b779; } +.html-reporter .bar.skipped { background-color: #bababa; } +.html-reporter .bar.menu { background-color: #fff; color: #aaaaaa; } +.html-reporter .bar.menu a { color: #333333; } +.html-reporter .bar a { color: white; } +.html-reporter.spec-list .bar.menu.failure-list, .html-reporter.spec-list .results .failures { display: none; } +.html-reporter.failure-list .bar.menu.spec-list, .html-reporter.failure-list .summary { display: none; } +.html-reporter .running-alert { background-color: #666666; } +.html-reporter .results { margin-top: 14px; } +.html-reporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; } +.html-reporter.showDetails .summaryMenuItem:hover { text-decoration: underline; } +.html-reporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; } +.html-reporter.showDetails .summary { display: none; } +.html-reporter.showDetails #details { display: block; } +.html-reporter .summaryMenuItem { font-weight: bold; text-decoration: underline; } +.html-reporter .summary { margin-top: 14px; } +.html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; } +.html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; } +.html-reporter .summary li.passed a { color: #5e7d00; } +.html-reporter .summary li.failed a { color: #b03911; } +.html-reporter .summary li.pending a { color: #ba9d37; } +.html-reporter .description + .suite { margin-top: 0; } +.html-reporter .suite { margin-top: 14px; } +.html-reporter .suite a { color: #333333; } +.html-reporter .failures .spec-detail { margin-bottom: 28px; } +.html-reporter .failures .spec-detail .description { background-color: #b03911; } +.html-reporter .failures .spec-detail .description a { color: white; } +.html-reporter .result-message { padding-top: 14px; color: #333333; white-space: pre; } +.html-reporter .result-message span.result { display: block; } +.html-reporter .stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; } diff --git a/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine.js b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine.js new file mode 100644 index 0000000000..24463ecb83 --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine.js @@ -0,0 +1,2402 @@ +/* +Copyright (c) 2008-2013 Pivotal Labs + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +function getJasmineRequireObj() { + if (typeof module !== "undefined" && module.exports) { + return exports; + } else { + window.jasmineRequire = window.jasmineRequire || {}; + return window.jasmineRequire; + } +} + +getJasmineRequireObj().core = function(jRequire) { + var j$ = {}; + + jRequire.base(j$); + j$.util = jRequire.util(); + j$.Any = jRequire.Any(); + j$.CallTracker = jRequire.CallTracker(); + j$.Clock = jRequire.Clock(); + j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(); + j$.Env = jRequire.Env(j$); + j$.ExceptionFormatter = jRequire.ExceptionFormatter(); + j$.Expectation = jRequire.Expectation(); + j$.buildExpectationResult = jRequire.buildExpectationResult(); + j$.JsApiReporter = jRequire.JsApiReporter(); + j$.matchersUtil = jRequire.matchersUtil(j$); + j$.ObjectContaining = jRequire.ObjectContaining(j$); + j$.pp = jRequire.pp(j$); + j$.QueueRunner = jRequire.QueueRunner(); + j$.ReportDispatcher = jRequire.ReportDispatcher(); + j$.Spec = jRequire.Spec(j$); + j$.SpyStrategy = jRequire.SpyStrategy(); + j$.Suite = jRequire.Suite(); + j$.Timer = jRequire.Timer(); + j$.version = jRequire.version(); + + j$.matchers = jRequire.requireMatchers(jRequire, j$); + + return j$; +}; + +getJasmineRequireObj().requireMatchers = function(jRequire, j$) { + var availableMatchers = [ + "toBe", + "toBeCloseTo", + "toBeDefined", + "toBeFalsy", + "toBeGreaterThan", + "toBeLessThan", + "toBeNaN", + "toBeNull", + "toBeTruthy", + "toBeUndefined", + "toContain", + "toEqual", + "toHaveBeenCalled", + "toHaveBeenCalledWith", + "toMatch", + "toThrow", + "toThrowError" + ], + matchers = {}; + + for (var i = 0; i < availableMatchers.length; i++) { + var name = availableMatchers[i]; + matchers[name] = jRequire[name](j$); + } + + return matchers; +}; + +getJasmineRequireObj().base = function(j$) { + j$.unimplementedMethod_ = function() { + throw new Error("unimplemented method"); + }; + + j$.MAX_PRETTY_PRINT_DEPTH = 40; + j$.DEFAULT_TIMEOUT_INTERVAL = 5000; + + j$.getGlobal = (function() { + var jasmineGlobal = eval.call(null, "this"); + return function() { + return jasmineGlobal; + }; + })(); + + j$.getEnv = function(options) { + var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options); + //jasmine. singletons in here (setTimeout blah blah). + return env; + }; + + j$.isArray_ = function(value) { + return j$.isA_("Array", value); + }; + + j$.isString_ = function(value) { + return j$.isA_("String", value); + }; + + j$.isNumber_ = function(value) { + return j$.isA_("Number", value); + }; + + j$.isA_ = function(typeName, value) { + return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; + }; + + j$.isDomNode = function(obj) { + return obj.nodeType > 0; + }; + + j$.any = function(clazz) { + return new j$.Any(clazz); + }; + + j$.objectContaining = function(sample) { + return new j$.ObjectContaining(sample); + }; + + j$.createSpy = function(name, originalFn) { + + var spyStrategy = new j$.SpyStrategy({ + name: name, + fn: originalFn, + getSpy: function() { return spy; } + }), + callTracker = new j$.CallTracker(), + spy = function() { + callTracker.track({ + object: this, + args: Array.prototype.slice.apply(arguments) + }); + return spyStrategy.exec.apply(this, arguments); + }; + + for (var prop in originalFn) { + if (prop === 'and' || prop === 'calls') { + throw new Error("Jasmine spies would overwrite the 'and' and 'calls' properties on the object being spied upon"); + } + + spy[prop] = originalFn[prop]; + } + + spy.and = spyStrategy; + spy.calls = callTracker; + + return spy; + }; + + j$.isSpy = function(putativeSpy) { + if (!putativeSpy) { + return false; + } + return putativeSpy.and instanceof j$.SpyStrategy && + putativeSpy.calls instanceof j$.CallTracker; + }; + + j$.createSpyObj = function(baseName, methodNames) { + if (!j$.isArray_(methodNames) || methodNames.length === 0) { + throw "createSpyObj requires a non-empty array of method names to create spies for"; + } + var obj = {}; + for (var i = 0; i < methodNames.length; i++) { + obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]); + } + return obj; + }; +}; + +getJasmineRequireObj().util = function() { + + var util = {}; + + util.inherit = function(childClass, parentClass) { + var Subclass = function() { + }; + Subclass.prototype = parentClass.prototype; + childClass.prototype = new Subclass(); + }; + + util.htmlEscape = function(str) { + if (!str) { + return str; + } + return str.replace(/&/g, '&') + .replace(//g, '>'); + }; + + util.argsToArray = function(args) { + var arrayOfArgs = []; + for (var i = 0; i < args.length; i++) { + arrayOfArgs.push(args[i]); + } + return arrayOfArgs; + }; + + util.isUndefined = function(obj) { + return obj === void 0; + }; + + return util; +}; + +getJasmineRequireObj().Spec = function(j$) { + function Spec(attrs) { + this.expectationFactory = attrs.expectationFactory; + this.resultCallback = attrs.resultCallback || function() {}; + this.id = attrs.id; + this.description = attrs.description || ''; + this.fn = attrs.fn; + this.beforeFns = attrs.beforeFns || function() { return []; }; + this.afterFns = attrs.afterFns || function() { return []; }; + this.onStart = attrs.onStart || function() {}; + this.exceptionFormatter = attrs.exceptionFormatter || function() {}; + this.getSpecName = attrs.getSpecName || function() { return ''; }; + this.expectationResultFactory = attrs.expectationResultFactory || function() { }; + this.queueRunnerFactory = attrs.queueRunnerFactory || function() {}; + this.catchingExceptions = attrs.catchingExceptions || function() { return true; }; + + this.timer = attrs.timer || {setTimeout: setTimeout, clearTimeout: clearTimeout}; + + if (!this.fn) { + this.pend(); + } + + this.result = { + id: this.id, + description: this.description, + fullName: this.getFullName(), + failedExpectations: [] + }; + } + + Spec.prototype.addExpectationResult = function(passed, data) { + if (passed) { + return; + } + this.result.failedExpectations.push(this.expectationResultFactory(data)); + }; + + Spec.prototype.expect = function(actual) { + return this.expectationFactory(actual, this); + }; + + Spec.prototype.execute = function(onComplete) { + var self = this, + timeout; + + this.onStart(this); + + if (this.markedPending || this.disabled) { + complete(); + return; + } + + function timeoutable(fn) { + return function(done) { + timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() { + onException(new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.')); + done(); + }, j$.DEFAULT_TIMEOUT_INTERVAL]]); + + var callDone = function() { + clearTimeoutable(); + done(); + }; + + fn.call(this, callDone); //TODO: do we care about more than 1 arg? + }; + } + + function clearTimeoutable() { + Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeout]]); + timeout = void 0; + } + + var allFns = this.beforeFns().concat(this.fn).concat(this.afterFns()), + allTimeoutableFns = []; + for (var i = 0; i < allFns.length; i++) { + var fn = allFns[i]; + allTimeoutableFns.push(fn.length > 0 ? timeoutable(fn) : fn); + } + + this.queueRunnerFactory({ + fns: allTimeoutableFns, + onException: onException, + onComplete: complete + }); + + function onException(e) { + clearTimeoutable(); + if (Spec.isPendingSpecException(e)) { + self.pend(); + return; + } + + self.addExpectationResult(false, { + matcherName: "", + passed: false, + expected: "", + actual: "", + error: e + }); + } + + function complete() { + self.result.status = self.status(); + self.resultCallback(self.result); + + if (onComplete) { + onComplete(); + } + } + }; + + Spec.prototype.disable = function() { + this.disabled = true; + }; + + Spec.prototype.pend = function() { + this.markedPending = true; + }; + + Spec.prototype.status = function() { + if (this.disabled) { + return 'disabled'; + } + + if (this.markedPending) { + return 'pending'; + } + + if (this.result.failedExpectations.length > 0) { + return 'failed'; + } else { + return 'passed'; + } + }; + + Spec.prototype.getFullName = function() { + return this.getSpecName(this); + }; + + Spec.pendingSpecExceptionMessage = "=> marked Pending"; + + Spec.isPendingSpecException = function(e) { + return e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1; + }; + + return Spec; +}; + +if (typeof window == void 0 && typeof exports == "object") { + exports.Spec = jasmineRequire.Spec; +} + +getJasmineRequireObj().Env = function(j$) { + function Env(options) { + options = options || {}; + + var self = this; + var global = options.global || j$.getGlobal(); + + var totalSpecsDefined = 0; + + var catchExceptions = true; + + var realSetTimeout = j$.getGlobal().setTimeout; + var realClearTimeout = j$.getGlobal().clearTimeout; + this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler()); + + var runnableLookupTable = {}; + + var spies = []; + + var currentSpec = null; + var currentSuite = null; + + var reporter = new j$.ReportDispatcher([ + "jasmineStarted", + "jasmineDone", + "suiteStarted", + "suiteDone", + "specStarted", + "specDone" + ]); + + this.specFilter = function() { + return true; + }; + + var equalityTesters = []; + + var customEqualityTesters = []; + this.addCustomEqualityTester = function(tester) { + customEqualityTesters.push(tester); + }; + + j$.Expectation.addCoreMatchers(j$.matchers); + + var nextSpecId = 0; + var getNextSpecId = function() { + return 'spec' + nextSpecId++; + }; + + var nextSuiteId = 0; + var getNextSuiteId = function() { + return 'suite' + nextSuiteId++; + }; + + var expectationFactory = function(actual, spec) { + return j$.Expectation.Factory({ + util: j$.matchersUtil, + customEqualityTesters: customEqualityTesters, + actual: actual, + addExpectationResult: addExpectationResult + }); + + function addExpectationResult(passed, result) { + return spec.addExpectationResult(passed, result); + } + }; + + var specStarted = function(spec) { + currentSpec = spec; + reporter.specStarted(spec.result); + }; + + var beforeFns = function(suite) { + return function() { + var befores = []; + while(suite) { + befores = befores.concat(suite.beforeFns); + suite = suite.parentSuite; + } + return befores.reverse(); + }; + }; + + var afterFns = function(suite) { + return function() { + var afters = []; + while(suite) { + afters = afters.concat(suite.afterFns); + suite = suite.parentSuite; + } + return afters; + }; + }; + + var getSpecName = function(spec, suite) { + return suite.getFullName() + ' ' + spec.description; + }; + + // TODO: we may just be able to pass in the fn instead of wrapping here + var buildExpectationResult = j$.buildExpectationResult, + exceptionFormatter = new j$.ExceptionFormatter(), + expectationResultFactory = function(attrs) { + attrs.messageFormatter = exceptionFormatter.message; + attrs.stackFormatter = exceptionFormatter.stack; + + return buildExpectationResult(attrs); + }; + + // TODO: fix this naming, and here's where the value comes in + this.catchExceptions = function(value) { + catchExceptions = !!value; + return catchExceptions; + }; + + this.catchingExceptions = function() { + return catchExceptions; + }; + + var maximumSpecCallbackDepth = 20; + var currentSpecCallbackDepth = 0; + + function clearStack(fn) { + currentSpecCallbackDepth++; + if (currentSpecCallbackDepth >= maximumSpecCallbackDepth) { + currentSpecCallbackDepth = 0; + realSetTimeout(fn, 0); + } else { + fn(); + } + } + + var catchException = function(e) { + return j$.Spec.isPendingSpecException(e) || catchExceptions; + }; + + var queueRunnerFactory = function(options) { + options.catchException = catchException; + options.clearStack = options.clearStack || clearStack; + + new j$.QueueRunner(options).execute(); + }; + + var topSuite = new j$.Suite({ + env: this, + id: getNextSuiteId(), + description: 'Jasmine__TopLevel__Suite', + queueRunner: queueRunnerFactory, + resultCallback: function() {} // TODO - hook this up + }); + runnableLookupTable[topSuite.id] = topSuite; + currentSuite = topSuite; + + this.topSuite = function() { + return topSuite; + }; + + this.execute = function(runnablesToRun) { + runnablesToRun = runnablesToRun || [topSuite.id]; + + var allFns = []; + for(var i = 0; i < runnablesToRun.length; i++) { + var runnable = runnableLookupTable[runnablesToRun[i]]; + allFns.push((function(runnable) { return function(done) { runnable.execute(done); }; })(runnable)); + } + + reporter.jasmineStarted({ + totalSpecsDefined: totalSpecsDefined + }); + + queueRunnerFactory({fns: allFns, onComplete: reporter.jasmineDone}); + }; + + this.addReporter = function(reporterToAdd) { + reporter.addReporter(reporterToAdd); + }; + + this.addMatchers = function(matchersToAdd) { + j$.Expectation.addMatchers(matchersToAdd); + }; + + this.spyOn = function(obj, methodName) { + if (j$.util.isUndefined(obj)) { + throw new Error("spyOn could not find an object to spy upon for " + methodName + "()"); + } + + if (j$.util.isUndefined(obj[methodName])) { + throw new Error(methodName + '() method does not exist'); + } + + if (obj[methodName] && j$.isSpy(obj[methodName])) { + //TODO?: should this return the current spy? Downside: may cause user confusion about spy state + throw new Error(methodName + ' has already been spied upon'); + } + + var spy = j$.createSpy(methodName, obj[methodName]); + + spies.push({ + spy: spy, + baseObj: obj, + methodName: methodName, + originalValue: obj[methodName] + }); + + obj[methodName] = spy; + + return spy; + }; + + var suiteFactory = function(description) { + var suite = new j$.Suite({ + env: self, + id: getNextSuiteId(), + description: description, + parentSuite: currentSuite, + queueRunner: queueRunnerFactory, + onStart: suiteStarted, + resultCallback: function(attrs) { + reporter.suiteDone(attrs); + } + }); + + runnableLookupTable[suite.id] = suite; + return suite; + }; + + this.describe = function(description, specDefinitions) { + var suite = suiteFactory(description); + + var parentSuite = currentSuite; + parentSuite.addChild(suite); + currentSuite = suite; + + var declarationError = null; + try { + specDefinitions.call(suite); + } catch (e) { + declarationError = e; + } + + if (declarationError) { + this.it("encountered a declaration exception", function() { + throw declarationError; + }); + } + + currentSuite = parentSuite; + + return suite; + }; + + this.xdescribe = function(description, specDefinitions) { + var suite = this.describe(description, specDefinitions); + suite.disable(); + return suite; + }; + + var specFactory = function(description, fn, suite) { + totalSpecsDefined++; + + var spec = new j$.Spec({ + id: getNextSpecId(), + beforeFns: beforeFns(suite), + afterFns: afterFns(suite), + expectationFactory: expectationFactory, + exceptionFormatter: exceptionFormatter, + resultCallback: specResultCallback, + getSpecName: function(spec) { + return getSpecName(spec, suite); + }, + onStart: specStarted, + description: description, + expectationResultFactory: expectationResultFactory, + queueRunnerFactory: queueRunnerFactory, + fn: fn, + timer: {setTimeout: realSetTimeout, clearTimeout: realClearTimeout} + }); + + runnableLookupTable[spec.id] = spec; + + if (!self.specFilter(spec)) { + spec.disable(); + } + + return spec; + + function removeAllSpies() { + for (var i = 0; i < spies.length; i++) { + var spyEntry = spies[i]; + spyEntry.baseObj[spyEntry.methodName] = spyEntry.originalValue; + } + spies = []; + } + + function specResultCallback(result) { + removeAllSpies(); + j$.Expectation.resetMatchers(); + customEqualityTesters = []; + currentSpec = null; + reporter.specDone(result); + } + }; + + var suiteStarted = function(suite) { + reporter.suiteStarted(suite.result); + }; + + this.it = function(description, fn) { + var spec = specFactory(description, fn, currentSuite); + currentSuite.addChild(spec); + return spec; + }; + + this.xit = function(description, fn) { + var spec = this.it(description, fn); + spec.pend(); + return spec; + }; + + this.expect = function(actual) { + return currentSpec.expect(actual); + }; + + this.beforeEach = function(beforeEachFunction) { + currentSuite.beforeEach(beforeEachFunction); + }; + + this.afterEach = function(afterEachFunction) { + currentSuite.afterEach(afterEachFunction); + }; + + this.pending = function() { + throw j$.Spec.pendingSpecExceptionMessage; + }; + } + + return Env; +}; + +getJasmineRequireObj().JsApiReporter = function() { + + var noopTimer = { + start: function(){}, + elapsed: function(){ return 0; } + }; + + function JsApiReporter(options) { + var timer = options.timer || noopTimer, + status = "loaded"; + + this.started = false; + this.finished = false; + + this.jasmineStarted = function() { + this.started = true; + status = 'started'; + timer.start(); + }; + + var executionTime; + + this.jasmineDone = function() { + this.finished = true; + executionTime = timer.elapsed(); + status = 'done'; + }; + + this.status = function() { + return status; + }; + + var suites = {}; + + this.suiteStarted = function(result) { + storeSuite(result); + }; + + this.suiteDone = function(result) { + storeSuite(result); + }; + + function storeSuite(result) { + suites[result.id] = result; + } + + this.suites = function() { + return suites; + }; + + var specs = []; + this.specStarted = function(result) { }; + + this.specDone = function(result) { + specs.push(result); + }; + + this.specResults = function(index, length) { + return specs.slice(index, index + length); + }; + + this.specs = function() { + return specs; + }; + + this.executionTime = function() { + return executionTime; + }; + + } + + return JsApiReporter; +}; + +getJasmineRequireObj().Any = function() { + + function Any(expectedObject) { + this.expectedObject = expectedObject; + } + + Any.prototype.jasmineMatches = function(other) { + if (this.expectedObject == String) { + return typeof other == 'string' || other instanceof String; + } + + if (this.expectedObject == Number) { + return typeof other == 'number' || other instanceof Number; + } + + if (this.expectedObject == Function) { + return typeof other == 'function' || other instanceof Function; + } + + if (this.expectedObject == Object) { + return typeof other == 'object'; + } + + if (this.expectedObject == Boolean) { + return typeof other == 'boolean'; + } + + return other instanceof this.expectedObject; + }; + + Any.prototype.jasmineToString = function() { + return ''; + }; + + return Any; +}; + +getJasmineRequireObj().CallTracker = function() { + + function CallTracker() { + var calls = []; + + this.track = function(context) { + calls.push(context); + }; + + this.any = function() { + return !!calls.length; + }; + + this.count = function() { + return calls.length; + }; + + this.argsFor = function(index) { + var call = calls[index]; + return call ? call.args : []; + }; + + this.all = function() { + return calls; + }; + + this.allArgs = function() { + var callArgs = []; + for(var i = 0; i < calls.length; i++){ + callArgs.push(calls[i].args); + } + + return callArgs; + }; + + this.first = function() { + return calls[0]; + }; + + this.mostRecent = function() { + return calls[calls.length - 1]; + }; + + this.reset = function() { + calls = []; + }; + } + + return CallTracker; +}; + +getJasmineRequireObj().Clock = function() { + function Clock(global, delayedFunctionScheduler) { + var self = this, + realTimingFunctions = { + setTimeout: global.setTimeout, + clearTimeout: global.clearTimeout, + setInterval: global.setInterval, + clearInterval: global.clearInterval + }, + fakeTimingFunctions = { + setTimeout: setTimeout, + clearTimeout: clearTimeout, + setInterval: setInterval, + clearInterval: clearInterval + }, + installed = false, + timer; + + self.install = function() { + replace(global, fakeTimingFunctions); + timer = fakeTimingFunctions; + installed = true; + }; + + self.uninstall = function() { + delayedFunctionScheduler.reset(); + replace(global, realTimingFunctions); + timer = realTimingFunctions; + installed = false; + }; + + self.setTimeout = function(fn, delay, params) { + if (legacyIE()) { + if (arguments.length > 2) { + throw new Error("IE < 9 cannot support extra params to setTimeout without a polyfill"); + } + return timer.setTimeout(fn, delay); + } + return Function.prototype.apply.apply(timer.setTimeout, [global, arguments]); + }; + + self.setInterval = function(fn, delay, params) { + if (legacyIE()) { + if (arguments.length > 2) { + throw new Error("IE < 9 cannot support extra params to setInterval without a polyfill"); + } + return timer.setInterval(fn, delay); + } + return Function.prototype.apply.apply(timer.setInterval, [global, arguments]); + }; + + self.clearTimeout = function(id) { + return Function.prototype.call.apply(timer.clearTimeout, [global, id]); + }; + + self.clearInterval = function(id) { + return Function.prototype.call.apply(timer.clearInterval, [global, id]); + }; + + self.tick = function(millis) { + if (installed) { + delayedFunctionScheduler.tick(millis); + } else { + throw new Error("Mock clock is not installed, use jasmine.clock().install()"); + } + }; + + return self; + + function legacyIE() { + //if these methods are polyfilled, apply will be present + return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply; + } + + function replace(dest, source) { + for (var prop in source) { + dest[prop] = source[prop]; + } + } + + function setTimeout(fn, delay) { + return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2)); + } + + function clearTimeout(id) { + return delayedFunctionScheduler.removeFunctionWithId(id); + } + + function setInterval(fn, interval) { + return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true); + } + + function clearInterval(id) { + return delayedFunctionScheduler.removeFunctionWithId(id); + } + + function argSlice(argsObj, n) { + return Array.prototype.slice.call(argsObj, 2); + } + } + + return Clock; +}; + +getJasmineRequireObj().DelayedFunctionScheduler = function() { + function DelayedFunctionScheduler() { + var self = this; + var scheduledLookup = []; + var scheduledFunctions = {}; + var currentTime = 0; + var delayedFnCount = 0; + + self.tick = function(millis) { + millis = millis || 0; + var endTime = currentTime + millis; + + runScheduledFunctions(endTime); + currentTime = endTime; + }; + + self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) { + var f; + if (typeof(funcToCall) === 'string') { + /* jshint evil: true */ + f = function() { return eval(funcToCall); }; + /* jshint evil: false */ + } else { + f = funcToCall; + } + + millis = millis || 0; + timeoutKey = timeoutKey || ++delayedFnCount; + runAtMillis = runAtMillis || (currentTime + millis); + + var funcToSchedule = { + runAtMillis: runAtMillis, + funcToCall: f, + recurring: recurring, + params: params, + timeoutKey: timeoutKey, + millis: millis + }; + + if (runAtMillis in scheduledFunctions) { + scheduledFunctions[runAtMillis].push(funcToSchedule); + } else { + scheduledFunctions[runAtMillis] = [funcToSchedule]; + scheduledLookup.push(runAtMillis); + scheduledLookup.sort(function (a, b) { + return a - b; + }); + } + + return timeoutKey; + }; + + self.removeFunctionWithId = function(timeoutKey) { + for (var runAtMillis in scheduledFunctions) { + var funcs = scheduledFunctions[runAtMillis]; + var i = indexOfFirstToPass(funcs, function (func) { + return func.timeoutKey === timeoutKey; + }); + + if (i > -1) { + if (funcs.length === 1) { + delete scheduledFunctions[runAtMillis]; + deleteFromLookup(runAtMillis); + } else { + funcs.splice(i, 1); + } + + // intervals get rescheduled when executed, so there's never more + // than a single scheduled function with a given timeoutKey + break; + } + } + }; + + self.reset = function() { + currentTime = 0; + scheduledLookup = []; + scheduledFunctions = {}; + delayedFnCount = 0; + }; + + return self; + + function indexOfFirstToPass(array, testFn) { + var index = -1; + + for (var i = 0; i < array.length; ++i) { + if (testFn(array[i])) { + index = i; + break; + } + } + + return index; + } + + function deleteFromLookup(key) { + var value = Number(key); + var i = indexOfFirstToPass(scheduledLookup, function (millis) { + return millis === value; + }); + + if (i > -1) { + scheduledLookup.splice(i, 1); + } + } + + function reschedule(scheduledFn) { + self.scheduleFunction(scheduledFn.funcToCall, + scheduledFn.millis, + scheduledFn.params, + true, + scheduledFn.timeoutKey, + scheduledFn.runAtMillis + scheduledFn.millis); + } + + function runScheduledFunctions(endTime) { + if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) { + return; + } + + do { + currentTime = scheduledLookup.shift(); + + var funcsToRun = scheduledFunctions[currentTime]; + delete scheduledFunctions[currentTime]; + + for (var i = 0; i < funcsToRun.length; ++i) { + var funcToRun = funcsToRun[i]; + funcToRun.funcToCall.apply(null, funcToRun.params || []); + + if (funcToRun.recurring) { + reschedule(funcToRun); + } + } + } while (scheduledLookup.length > 0 && + // checking first if we're out of time prevents setTimeout(0) + // scheduled in a funcToRun from forcing an extra iteration + currentTime !== endTime && + scheduledLookup[0] <= endTime); + } + } + + return DelayedFunctionScheduler; +}; + +getJasmineRequireObj().ExceptionFormatter = function() { + function ExceptionFormatter() { + this.message = function(error) { + var message = error.name + + ': ' + + error.message; + + if (error.fileName || error.sourceURL) { + message += " in " + (error.fileName || error.sourceURL); + } + + if (error.line || error.lineNumber) { + message += " (line " + (error.line || error.lineNumber) + ")"; + } + + return message; + }; + + this.stack = function(error) { + return error ? error.stack : null; + }; + } + + return ExceptionFormatter; +}; + +getJasmineRequireObj().Expectation = function() { + + var matchers = {}; + + function Expectation(options) { + this.util = options.util || { buildFailureMessage: function() {} }; + this.customEqualityTesters = options.customEqualityTesters || []; + this.actual = options.actual; + this.addExpectationResult = options.addExpectationResult || function(){}; + this.isNot = options.isNot; + + for (var matcherName in matchers) { + this[matcherName] = matchers[matcherName]; + } + } + + Expectation.prototype.wrapCompare = function(name, matcherFactory) { + return function() { + var args = Array.prototype.slice.call(arguments, 0), + expected = args.slice(0), + message = ""; + + args.unshift(this.actual); + + var matcher = matcherFactory(this.util, this.customEqualityTesters), + matcherCompare = matcher.compare; + + function defaultNegativeCompare() { + var result = matcher.compare.apply(null, args); + result.pass = !result.pass; + return result; + } + + if (this.isNot) { + matcherCompare = matcher.negativeCompare || defaultNegativeCompare; + } + + var result = matcherCompare.apply(null, args); + + if (!result.pass) { + if (!result.message) { + args.unshift(this.isNot); + args.unshift(name); + message = this.util.buildFailureMessage.apply(null, args); + } else { + message = result.message; + } + } + + if (expected.length == 1) { + expected = expected[0]; + } + + // TODO: how many of these params are needed? + this.addExpectationResult( + result.pass, + { + matcherName: name, + passed: result.pass, + message: message, + actual: this.actual, + expected: expected // TODO: this may need to be arrayified/sliced + } + ); + }; + }; + + Expectation.addCoreMatchers = function(matchers) { + var prototype = Expectation.prototype; + for (var matcherName in matchers) { + var matcher = matchers[matcherName]; + prototype[matcherName] = prototype.wrapCompare(matcherName, matcher); + } + }; + + Expectation.addMatchers = function(matchersToAdd) { + for (var name in matchersToAdd) { + var matcher = matchersToAdd[name]; + matchers[name] = Expectation.prototype.wrapCompare(name, matcher); + } + }; + + Expectation.resetMatchers = function() { + for (var name in matchers) { + delete matchers[name]; + } + }; + + Expectation.Factory = function(options) { + options = options || {}; + + var expect = new Expectation(options); + + // TODO: this would be nice as its own Object - NegativeExpectation + // TODO: copy instead of mutate options + options.isNot = true; + expect.not = new Expectation(options); + + return expect; + }; + + return Expectation; +}; + +//TODO: expectation result may make more sense as a presentation of an expectation. +getJasmineRequireObj().buildExpectationResult = function() { + function buildExpectationResult(options) { + var messageFormatter = options.messageFormatter || function() {}, + stackFormatter = options.stackFormatter || function() {}; + + return { + matcherName: options.matcherName, + expected: options.expected, + actual: options.actual, + message: message(), + stack: stack(), + passed: options.passed + }; + + function message() { + if (options.passed) { + return "Passed."; + } else if (options.message) { + return options.message; + } else if (options.error) { + return messageFormatter(options.error); + } + return ""; + } + + function stack() { + if (options.passed) { + return ""; + } + + var error = options.error; + if (!error) { + try { + throw new Error(message()); + } catch (e) { + error = e; + } + } + return stackFormatter(error); + } + } + + return buildExpectationResult; +}; + +getJasmineRequireObj().ObjectContaining = function(j$) { + + function ObjectContaining(sample) { + this.sample = sample; + } + + ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) { + if (typeof(this.sample) !== "object") { throw new Error("You must provide an object to objectContaining, not '"+this.sample+"'."); } + + mismatchKeys = mismatchKeys || []; + mismatchValues = mismatchValues || []; + + var hasKey = function(obj, keyName) { + return obj !== null && !j$.util.isUndefined(obj[keyName]); + }; + + for (var property in this.sample) { + if (!hasKey(other, property) && hasKey(this.sample, property)) { + mismatchKeys.push("expected has key '" + property + "', but missing from actual."); + } + else if (!j$.matchersUtil.equals(this.sample[property], other[property])) { + mismatchValues.push("'" + property + "' was '" + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + "' in actual, but was '" + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in expected."); + } + } + + return (mismatchKeys.length === 0 && mismatchValues.length === 0); + }; + + ObjectContaining.prototype.jasmineToString = function() { + return ""; + }; + + return ObjectContaining; +}; + +getJasmineRequireObj().pp = function(j$) { + + function PrettyPrinter() { + this.ppNestLevel_ = 0; + } + + PrettyPrinter.prototype.format = function(value) { + this.ppNestLevel_++; + try { + if (j$.util.isUndefined(value)) { + this.emitScalar('undefined'); + } else if (value === null) { + this.emitScalar('null'); + } else if (value === j$.getGlobal()) { + this.emitScalar(''); + } else if (value.jasmineToString) { + this.emitScalar(value.jasmineToString()); + } else if (typeof value === 'string') { + this.emitString(value); + } else if (j$.isSpy(value)) { + this.emitScalar("spy on " + value.and.identity()); + } else if (value instanceof RegExp) { + this.emitScalar(value.toString()); + } else if (typeof value === 'function') { + this.emitScalar('Function'); + } else if (typeof value.nodeType === 'number') { + this.emitScalar('HTMLNode'); + } else if (value instanceof Date) { + this.emitScalar('Date(' + value + ')'); + } else if (value.__Jasmine_been_here_before__) { + this.emitScalar(''); + } else if (j$.isArray_(value) || j$.isA_('Object', value)) { + value.__Jasmine_been_here_before__ = true; + if (j$.isArray_(value)) { + this.emitArray(value); + } else { + this.emitObject(value); + } + delete value.__Jasmine_been_here_before__; + } else { + this.emitScalar(value.toString()); + } + } finally { + this.ppNestLevel_--; + } + }; + + PrettyPrinter.prototype.iterateObject = function(obj, fn) { + for (var property in obj) { + if (!obj.hasOwnProperty(property)) { continue; } + if (property == '__Jasmine_been_here_before__') { continue; } + fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) && + obj.__lookupGetter__(property) !== null) : false); + } + }; + + PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_; + PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_; + PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_; + PrettyPrinter.prototype.emitString = j$.unimplementedMethod_; + + function StringPrettyPrinter() { + PrettyPrinter.call(this); + + this.string = ''; + } + + j$.util.inherit(StringPrettyPrinter, PrettyPrinter); + + StringPrettyPrinter.prototype.emitScalar = function(value) { + this.append(value); + }; + + StringPrettyPrinter.prototype.emitString = function(value) { + this.append("'" + value + "'"); + }; + + StringPrettyPrinter.prototype.emitArray = function(array) { + if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) { + this.append("Array"); + return; + } + + this.append('[ '); + for (var i = 0; i < array.length; i++) { + if (i > 0) { + this.append(', '); + } + this.format(array[i]); + } + this.append(' ]'); + }; + + StringPrettyPrinter.prototype.emitObject = function(obj) { + if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) { + this.append("Object"); + return; + } + + var self = this; + this.append('{ '); + var first = true; + + this.iterateObject(obj, function(property, isGetter) { + if (first) { + first = false; + } else { + self.append(', '); + } + + self.append(property); + self.append(' : '); + if (isGetter) { + self.append(''); + } else { + self.format(obj[property]); + } + }); + + this.append(' }'); + }; + + StringPrettyPrinter.prototype.append = function(value) { + this.string += value; + }; + + return function(value) { + var stringPrettyPrinter = new StringPrettyPrinter(); + stringPrettyPrinter.format(value); + return stringPrettyPrinter.string; + }; +}; + +getJasmineRequireObj().QueueRunner = function() { + + function QueueRunner(attrs) { + this.fns = attrs.fns || []; + this.onComplete = attrs.onComplete || function() {}; + this.clearStack = attrs.clearStack || function(fn) {fn();}; + this.onException = attrs.onException || function() {}; + this.catchException = attrs.catchException || function() { return true; }; + this.userContext = {}; + } + + QueueRunner.prototype.execute = function() { + this.run(this.fns, 0); + }; + + QueueRunner.prototype.run = function(fns, recursiveIndex) { + var length = fns.length, + self = this, + iterativeIndex; + + for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) { + var fn = fns[iterativeIndex]; + if (fn.length > 0) { + return attemptAsync(fn); + } else { + attemptSync(fn); + } + } + + var runnerDone = iterativeIndex >= length; + + if (runnerDone) { + this.clearStack(this.onComplete); + } + + function attemptSync(fn) { + try { + fn.call(self.userContext); + } catch (e) { + handleException(e); + } + } + + function attemptAsync(fn) { + var next = function () { self.run(fns, iterativeIndex + 1); }; + + try { + fn.call(self.userContext, next); + } catch (e) { + handleException(e); + next(); + } + } + + function handleException(e) { + self.onException(e); + if (!self.catchException(e)) { + //TODO: set a var when we catch an exception and + //use a finally block to close the loop in a nice way.. + throw e; + } + } + }; + + return QueueRunner; +}; + +getJasmineRequireObj().ReportDispatcher = function() { + function ReportDispatcher(methods) { + + var dispatchedMethods = methods || []; + + for (var i = 0; i < dispatchedMethods.length; i++) { + var method = dispatchedMethods[i]; + this[method] = (function(m) { + return function() { + dispatch(m, arguments); + }; + }(method)); + } + + var reporters = []; + + this.addReporter = function(reporter) { + reporters.push(reporter); + }; + + return this; + + function dispatch(method, args) { + for (var i = 0; i < reporters.length; i++) { + var reporter = reporters[i]; + if (reporter[method]) { + reporter[method].apply(reporter, args); + } + } + } + } + + return ReportDispatcher; +}; + + +getJasmineRequireObj().SpyStrategy = function() { + + function SpyStrategy(options) { + options = options || {}; + + var identity = options.name || "unknown", + originalFn = options.fn || function() {}, + getSpy = options.getSpy || function() {}, + plan = function() {}; + + this.identity = function() { + return identity; + }; + + this.exec = function() { + return plan.apply(this, arguments); + }; + + this.callThrough = function() { + plan = originalFn; + return getSpy(); + }; + + this.returnValue = function(value) { + plan = function() { + return value; + }; + return getSpy(); + }; + + this.throwError = function(something) { + var error = (something instanceof Error) ? something : new Error(something); + plan = function() { + throw error; + }; + return getSpy(); + }; + + this.callFake = function(fn) { + plan = fn; + return getSpy(); + }; + + this.stub = function(fn) { + plan = function() {}; + return getSpy(); + }; + } + + return SpyStrategy; +}; + +getJasmineRequireObj().Suite = function() { + function Suite(attrs) { + this.env = attrs.env; + this.id = attrs.id; + this.parentSuite = attrs.parentSuite; + this.description = attrs.description; + this.onStart = attrs.onStart || function() {}; + this.resultCallback = attrs.resultCallback || function() {}; + this.clearStack = attrs.clearStack || function(fn) {fn();}; + + this.beforeFns = []; + this.afterFns = []; + this.queueRunner = attrs.queueRunner || function() {}; + this.disabled = false; + + this.children = []; + + this.result = { + id: this.id, + status: this.disabled ? 'disabled' : '', + description: this.description, + fullName: this.getFullName() + }; + } + + Suite.prototype.getFullName = function() { + var fullName = this.description; + for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { + if (parentSuite.parentSuite) { + fullName = parentSuite.description + ' ' + fullName; + } + } + return fullName; + }; + + Suite.prototype.disable = function() { + this.disabled = true; + }; + + Suite.prototype.beforeEach = function(fn) { + this.beforeFns.unshift(fn); + }; + + Suite.prototype.afterEach = function(fn) { + this.afterFns.unshift(fn); + }; + + Suite.prototype.addChild = function(child) { + this.children.push(child); + }; + + Suite.prototype.execute = function(onComplete) { + var self = this; + if (this.disabled) { + complete(); + return; + } + + var allFns = []; + + for (var i = 0; i < this.children.length; i++) { + allFns.push(wrapChildAsAsync(this.children[i])); + } + + this.onStart(this); + + this.queueRunner({ + fns: allFns, + onComplete: complete + }); + + function complete() { + self.resultCallback(self.result); + + if (onComplete) { + onComplete(); + } + } + + function wrapChildAsAsync(child) { + return function(done) { child.execute(done); }; + } + }; + + return Suite; +}; + +if (typeof window == void 0 && typeof exports == "object") { + exports.Suite = jasmineRequire.Suite; +} + +getJasmineRequireObj().Timer = function() { + function Timer(options) { + options = options || {}; + + var now = options.now || function() { return new Date().getTime(); }, + startTime; + + this.start = function() { + startTime = now(); + }; + + this.elapsed = function() { + return now() - startTime; + }; + } + + return Timer; +}; + +getJasmineRequireObj().matchersUtil = function(j$) { + // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter? + + return { + equals: function(a, b, customTesters) { + customTesters = customTesters || []; + + return eq(a, b, [], [], customTesters); + }, + + contains: function(haystack, needle, customTesters) { + customTesters = customTesters || []; + + if (Object.prototype.toString.apply(haystack) === "[object Array]") { + for (var i = 0; i < haystack.length; i++) { + if (eq(haystack[i], needle, [], [], customTesters)) { + return true; + } + } + return false; + } + return haystack.indexOf(needle) >= 0; + }, + + buildFailureMessage: function() { + var args = Array.prototype.slice.call(arguments, 0), + matcherName = args[0], + isNot = args[1], + actual = args[2], + expected = args.slice(3), + englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); + + var message = "Expected " + + j$.pp(actual) + + (isNot ? " not " : " ") + + englishyPredicate; + + if (expected.length > 0) { + for (var i = 0; i < expected.length; i++) { + if (i > 0) { + message += ","; + } + message += " " + j$.pp(expected[i]); + } + } + + return message + "."; + } + }; + + // Equality function lovingly adapted from isEqual in + // [Underscore](http://underscorejs.org) + function eq(a, b, aStack, bStack, customTesters) { + var result = true; + + for (var i = 0; i < customTesters.length; i++) { + var customTesterResult = customTesters[i](a, b); + if (!j$.util.isUndefined(customTesterResult)) { + return customTesterResult; + } + } + + if (a instanceof j$.Any) { + result = a.jasmineMatches(b); + if (result) { + return true; + } + } + + if (b instanceof j$.Any) { + result = b.jasmineMatches(a); + if (result) { + return true; + } + } + + if (b instanceof j$.ObjectContaining) { + result = b.jasmineMatches(a); + if (result) { + return true; + } + } + + if (a instanceof Error && b instanceof Error) { + return a.message == b.message; + } + + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) { return a !== 0 || 1 / a == 1 / b; } + // A strict comparison is necessary because `null == undefined`. + if (a === null || b === null) { return a === b; } + var className = Object.prototype.toString.call(a); + if (className != Object.prototype.toString.call(b)) { return false; } + switch (className) { + // Strings, numbers, dates, and booleans are compared by value. + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return a == String(b); + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for + // other numeric values. + return a != +a ? b != +b : (a === 0 ? 1 / a == 1 / b : a == +b); + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a == +b; + // RegExps are compared by their source patterns and flags. + case '[object RegExp]': + return a.source == b.source && + a.global == b.global && + a.multiline == b.multiline && + a.ignoreCase == b.ignoreCase; + } + if (typeof a != 'object' || typeof b != 'object') { return false; } + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] == a) { return bStack[length] == b; } + } + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); + var size = 0; + // Recursively compare objects and arrays. + if (className == '[object Array]') { + // Compare array lengths to determine if a deep comparison is necessary. + size = a.length; + result = size == b.length; + if (result) { + // Deep compare the contents, ignoring non-numeric properties. + while (size--) { + if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) { break; } + } + } + } else { + // Objects with different constructors are not equivalent, but `Object`s + // from different frames are. + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(isFunction(aCtor) && (aCtor instanceof aCtor) && + isFunction(bCtor) && (bCtor instanceof bCtor))) { + return false; + } + // Deep compare objects. + for (var key in a) { + if (has(a, key)) { + // Count the expected number of properties. + size++; + // Deep compare each member. + if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; } + } + } + // Ensure that both objects contain the same number of properties. + if (result) { + for (key in b) { + if (has(b, key) && !(size--)) { break; } + } + result = !size; + } + } + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + + return result; + + function has(obj, key) { + return obj.hasOwnProperty(key); + } + + function isFunction(obj) { + return typeof obj === 'function'; + } + } +}; + +getJasmineRequireObj().toBe = function() { + function toBe() { + return { + compare: function(actual, expected) { + return { + pass: actual === expected + }; + } + }; + } + + return toBe; +}; + +getJasmineRequireObj().toBeCloseTo = function() { + + function toBeCloseTo() { + return { + compare: function(actual, expected, precision) { + if (precision !== 0) { + precision = precision || 2; + } + + return { + pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2) + }; + } + }; + } + + return toBeCloseTo; +}; + +getJasmineRequireObj().toBeDefined = function() { + function toBeDefined() { + return { + compare: function(actual) { + return { + pass: (void 0 !== actual) + }; + } + }; + } + + return toBeDefined; +}; + +getJasmineRequireObj().toBeFalsy = function() { + function toBeFalsy() { + return { + compare: function(actual) { + return { + pass: !!!actual + }; + } + }; + } + + return toBeFalsy; +}; + +getJasmineRequireObj().toBeGreaterThan = function() { + + function toBeGreaterThan() { + return { + compare: function(actual, expected) { + return { + pass: actual > expected + }; + } + }; + } + + return toBeGreaterThan; +}; + + +getJasmineRequireObj().toBeLessThan = function() { + function toBeLessThan() { + return { + + compare: function(actual, expected) { + return { + pass: actual < expected + }; + } + }; + } + + return toBeLessThan; +}; +getJasmineRequireObj().toBeNaN = function(j$) { + + function toBeNaN() { + return { + compare: function(actual) { + var result = { + pass: (actual !== actual) + }; + + if (result.pass) { + result.message = "Expected actual not to be NaN."; + } else { + result.message = "Expected " + j$.pp(actual) + " to be NaN."; + } + + return result; + } + }; + } + + return toBeNaN; +}; + +getJasmineRequireObj().toBeNull = function() { + + function toBeNull() { + return { + compare: function(actual) { + return { + pass: actual === null + }; + } + }; + } + + return toBeNull; +}; + +getJasmineRequireObj().toBeTruthy = function() { + + function toBeTruthy() { + return { + compare: function(actual) { + return { + pass: !!actual + }; + } + }; + } + + return toBeTruthy; +}; + +getJasmineRequireObj().toBeUndefined = function() { + + function toBeUndefined() { + return { + compare: function(actual) { + return { + pass: void 0 === actual + }; + } + }; + } + + return toBeUndefined; +}; + +getJasmineRequireObj().toContain = function() { + function toContain(util, customEqualityTesters) { + customEqualityTesters = customEqualityTesters || []; + + return { + compare: function(actual, expected) { + + return { + pass: util.contains(actual, expected, customEqualityTesters) + }; + } + }; + } + + return toContain; +}; + +getJasmineRequireObj().toEqual = function() { + + function toEqual(util, customEqualityTesters) { + customEqualityTesters = customEqualityTesters || []; + + return { + compare: function(actual, expected) { + var result = { + pass: false + }; + + result.pass = util.equals(actual, expected, customEqualityTesters); + + return result; + } + }; + } + + return toEqual; +}; + +getJasmineRequireObj().toHaveBeenCalled = function(j$) { + + function toHaveBeenCalled() { + return { + compare: function(actual) { + var result = {}; + + if (!j$.isSpy(actual)) { + throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); + } + + if (arguments.length > 1) { + throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); + } + + result.pass = actual.calls.any(); + + result.message = result.pass ? + "Expected spy " + actual.and.identity() + " not to have been called." : + "Expected spy " + actual.and.identity() + " to have been called."; + + return result; + } + }; + } + + return toHaveBeenCalled; +}; + +getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { + + function toHaveBeenCalledWith(util) { + return { + compare: function() { + var args = Array.prototype.slice.call(arguments, 0), + actual = args[0], + expectedArgs = args.slice(1), + result = { pass: false }; + + if (!j$.isSpy(actual)) { + throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); + } + + if (!actual.calls.any()) { + result.message = "Expected spy " + actual.and.identity() + " to have been called with " + j$.pp(expectedArgs) + " but it was never called."; + return result; + } + + if (util.contains(actual.calls.allArgs(), expectedArgs)) { + result.pass = true; + result.message = "Expected spy " + actual.and.identity() + " not to have been called with " + j$.pp(expectedArgs) + " but it was."; + } else { + result.message = "Expected spy " + actual.and.identity() + " to have been called with " + j$.pp(expectedArgs) + " but actual calls were " + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + "."; + } + + return result; + } + }; + } + + return toHaveBeenCalledWith; +}; + +getJasmineRequireObj().toMatch = function() { + + function toMatch() { + return { + compare: function(actual, expected) { + var regexp = new RegExp(expected); + + return { + pass: regexp.test(actual) + }; + } + }; + } + + return toMatch; +}; + +getJasmineRequireObj().toThrow = function(j$) { + + function toThrow(util) { + return { + compare: function(actual, expected) { + var result = { pass: false }, + threw = false, + thrown; + + if (typeof actual != "function") { + throw new Error("Actual is not a Function"); + } + + try { + actual(); + } catch (e) { + threw = true; + thrown = e; + } + + if (!threw) { + result.message = "Expected function to throw an exception."; + return result; + } + + if (arguments.length == 1) { + result.pass = true; + result.message = "Expected function not to throw, but it threw " + j$.pp(thrown) + "."; + + return result; + } + + if (util.equals(thrown, expected)) { + result.pass = true; + result.message = "Expected function not to throw " + j$.pp(expected) + "."; + } else { + result.message = "Expected function to throw " + j$.pp(expected) + ", but it threw " + j$.pp(thrown) + "."; + } + + return result; + } + }; + } + + return toThrow; +}; + +getJasmineRequireObj().toThrowError = function(j$) { + function toThrowError (util) { + return { + compare: function(actual) { + var threw = false, + thrown, + errorType, + message, + regexp, + name, + constructorName; + + if (typeof actual != "function") { + throw new Error("Actual is not a Function"); + } + + extractExpectedParams.apply(null, arguments); + + try { + actual(); + } catch (e) { + threw = true; + thrown = e; + } + + if (!threw) { + return fail("Expected function to throw an Error."); + } + + if (!(thrown instanceof Error)) { + return fail("Expected function to throw an Error, but it threw " + thrown + "."); + } + + if (arguments.length == 1) { + return pass("Expected function not to throw an Error, but it threw " + fnNameFor(thrown) + "."); + } + + if (errorType) { + name = fnNameFor(errorType); + constructorName = fnNameFor(thrown.constructor); + } + + if (errorType && message) { + if (thrown.constructor == errorType && util.equals(thrown.message, message)) { + return pass("Expected function not to throw " + name + " with message \"" + message + "\"."); + } else { + return fail("Expected function to throw " + name + " with message \"" + message + + "\", but it threw " + constructorName + " with message \"" + thrown.message + "\"."); + } + } + + if (errorType && regexp) { + if (thrown.constructor == errorType && regexp.test(thrown.message)) { + return pass("Expected function not to throw " + name + " with message matching " + regexp + "."); + } else { + return fail("Expected function to throw " + name + " with message matching " + regexp + + ", but it threw " + constructorName + " with message \"" + thrown.message + "\"."); + } + } + + if (errorType) { + if (thrown.constructor == errorType) { + return pass("Expected function not to throw " + name + "."); + } else { + return fail("Expected function to throw " + name + ", but it threw " + constructorName + "."); + } + } + + if (message) { + if (thrown.message == message) { + return pass("Expected function not to throw an exception with message " + j$.pp(message) + "."); + } else { + return fail("Expected function to throw an exception with message " + j$.pp(message) + + ", but it threw an exception with message " + j$.pp(thrown.message) + "."); + } + } + + if (regexp) { + if (regexp.test(thrown.message)) { + return pass("Expected function not to throw an exception with a message matching " + j$.pp(regexp) + "."); + } else { + return fail("Expected function to throw an exception with a message matching " + j$.pp(regexp) + + ", but it threw an exception with message " + j$.pp(thrown.message) + "."); + } + } + + function fnNameFor(func) { + return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1]; + } + + function pass(notMessage) { + return { + pass: true, + message: notMessage + }; + } + + function fail(message) { + return { + pass: false, + message: message + }; + } + + function extractExpectedParams() { + if (arguments.length == 1) { + return; + } + + if (arguments.length == 2) { + var expected = arguments[1]; + + if (expected instanceof RegExp) { + regexp = expected; + } else if (typeof expected == "string") { + message = expected; + } else if (checkForAnErrorType(expected)) { + errorType = expected; + } + + if (!(errorType || message || regexp)) { + throw new Error("Expected is not an Error, string, or RegExp."); + } + } else { + if (checkForAnErrorType(arguments[1])) { + errorType = arguments[1]; + } else { + throw new Error("Expected error type is not an Error."); + } + + if (arguments[2] instanceof RegExp) { + regexp = arguments[2]; + } else if (typeof arguments[2] == "string") { + message = arguments[2]; + } else { + throw new Error("Expected error message is not a string or RegExp."); + } + } + } + + function checkForAnErrorType(type) { + if (typeof type !== "function") { + return false; + } + + var Surrogate = function() {}; + Surrogate.prototype = type.prototype; + return (new Surrogate()) instanceof Error; + } + } + }; + } + + return toThrowError; +}; + +getJasmineRequireObj().version = function() { + return "2.0.0"; +}; diff --git a/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine_favicon.png b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine_favicon.png new file mode 100644 index 0000000000..3562e278f1 Binary files /dev/null and b/awx/ui/static/lib/angular-scheduler/tests/lib/jasmine-2.0.0/jasmine_favicon.png differ diff --git a/awx/ui/static/lib/angular-scheduler/tests/protractorConf.js b/awx/ui/static/lib/angular-scheduler/tests/protractorConf.js new file mode 100644 index 0000000000..b26982713c --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/tests/protractorConf.js @@ -0,0 +1,117 @@ +// A reference configuration file. +exports.config = { + // The address of a running selenium server. If specified, Protractor will + // connect to an already running instance of selenium. This usually looks like + // seleniumAddress: 'http://localhost:4444/wd/hub' + seleniumAddress: 'http://localhost:4444/wd/hub', + + // The timeout for each script run on the browser. This should be longer + // than the maximum time your application needs to stabilize between tasks. + allScriptsTimeout: 11000, + + // ----- What tests to run ----- + // + // Spec patterns are relative to the location of this config. + specs: [ + 'SetRRule.js', + ], + + // Patterns to exclude. + exclude: [], + + // ----- Capabilities to be passed to the webdriver instance ---- + // + // For a full list of available capabilities, see + // https://code.google.com/p/selenium/wiki/DesiredCapabilities + // and + // https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js + capabilities: { + 'browserName': 'chrome' + }, + + // If you would like to run more than one instance of webdriver on the same + // tests, use multiCapabilities, which takes an array of capabilities. + // If this is specified, capabilities will be ignored. + multiCapabilities: [], + + // ----- More information for your tests ---- + // + // A base URL for your application under test. Calls to protractor.get() + // with relative paths will be prepended with this. + baseUrl: 'http://localhost:8000', + + // Selector for the element housing the angular app - this defaults to + // body, but is necessary if ng-app is on a descendant of + rootElement: 'html', + + // A callback function called once protractor is ready and available, and + // before the specs are executed + // You can specify a file containing code to run by setting onPrepare to + // the filename string. + onPrepare: function() { + // At this point, global 'protractor' object will be set up, and jasmine + // will be available. For example, you can add a Jasmine reporter with: + // jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter( + // 'outputdir/', true, true)); + }, + + // The params object will be passed directly to the protractor instance, + // and can be accessed from your test. It is an arbitrary object and can + // contain anything you may need in your test. + // This can be changed via the command line as: + // --params.login.user 'Joe' + params: { + login: { + user: 'Jane', + password: '1234' + } + }, + + // ----- The test framework ----- + // + // Jasmine and Cucumber are fully supported as a test and assertion framework. + // Mocha has limited beta support. You will need to include your own + // assertion framework if working with mocha. + framework: 'jasmine', + + // ----- Options to be passed to minijasminenode ----- + // + // See the full list at https://github.com/juliemr/minijasminenode + jasmineNodeOpts: { + // onComplete will be called just before the driver quits. + onComplete: null, + // If true, display spec names. + isVerbose: false, + // If true, print colors to the terminal. + showColors: true, + // If true, include stack traces in failures. + includeStackTrace: true, + // Default time to wait in ms before a test fails. + defaultTimeoutInterval: 30000 + }, + + // ----- Options to be passed to mocha ----- + // + // See the full list at http://visionmedia.github.io/mocha/ + mochaOpts: { + ui: 'bdd', + reporter: 'list' + }, + + // ----- Options to be passed to cucumber ----- + cucumberOpts: { + // Require files before executing the features. + require: 'cucumber/stepDefinitions.js', + // Only execute the features or scenarios with tags matching @dev. + tags: '@dev', + // How to format features (default: progress) + format: 'summary' + }, + + // ----- The cleanup step ----- + // + // A callback function called once the tests have finished running and + // the webdriver instance has been shut down. It is passed the exit code + // (0 if the tests passed or 1 if not). + onCleanUp: function() {} +}; diff --git a/awx/ui/static/lib/angular-scheduler/tests/spec/PlayerSpec.js b/awx/ui/static/lib/angular-scheduler/tests/spec/PlayerSpec.js new file mode 100644 index 0000000000..f17521fde3 --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/tests/spec/PlayerSpec.js @@ -0,0 +1,58 @@ +describe("Player", function() { + var player; + var song; + + beforeEach(function() { + player = new Player(); + song = new Song(); + }); + + it("should be able to play a Song", function() { + player.play(song); + expect(player.currentlyPlayingSong).toEqual(song); + + //demonstrates use of custom matcher + expect(player).toBePlaying(song); + }); + + describe("when song has been paused", function() { + beforeEach(function() { + player.play(song); + player.pause(); + }); + + it("should indicate that the song is currently paused", function() { + expect(player.isPlaying).toBeFalsy(); + + // demonstrates use of 'not' with a custom matcher + expect(player).not.toBePlaying(song); + }); + + it("should be possible to resume", function() { + player.resume(); + expect(player.isPlaying).toBeTruthy(); + expect(player.currentlyPlayingSong).toEqual(song); + }); + }); + + // demonstrates use of spies to intercept and test method calls + it("tells the current song if the user has made it a favorite", function() { + spyOn(song, 'persistFavoriteStatus'); + + player.play(song); + player.makeFavorite(); + + expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true); + }); + + //demonstrates use of expected exceptions + describe("#resume", function() { + it("should throw an exception if song is already playing", function() { + player.play(song); + + expect(function() { + player.resume(); + }).toThrowError("song is already playing"); + }); + }); +}); diff --git a/awx/ui/static/lib/angular-scheduler/tests/spec/SpecHelper.js b/awx/ui/static/lib/angular-scheduler/tests/spec/SpecHelper.js new file mode 100644 index 0000000000..578b3e8626 --- /dev/null +++ b/awx/ui/static/lib/angular-scheduler/tests/spec/SpecHelper.js @@ -0,0 +1,15 @@ +beforeEach(function () { + jasmine.addMatchers({ + toBePlaying: function () { + return { + compare: function (actual, expected) { + var player = actual; + + return { + pass: player.currentlyPlayingSong === expected && player.isPlaying + } + } + }; + } + }); +}); diff --git a/awx/ui/static/partials/inventory-edit.html b/awx/ui/static/partials/inventory-edit.html index 9d61b35c39..92be70ee30 100644 --- a/awx/ui/static/partials/inventory-edit.html +++ b/awx/ui/static/partials/inventory-edit.html @@ -32,15 +32,16 @@

-
+
+
+
+
+ Show Details
-
- -
diff --git a/awx/ui/static/partials/schedule_detail.html b/awx/ui/static/partials/schedule_detail.html index 1a2f673409..103ac7207a 100644 --- a/awx/ui/static/partials/schedule_detail.html +++ b/awx/ui/static/partials/schedule_detail.html @@ -18,35 +18,6 @@
-
-

The scheduler options are invalid or incomplete. Make the needed changes on the options tab, then come back here to see details.

-
-
-
- - -
-
- - -
-
- -
-
Date format
- -
UTC
- -
Local time
-
-
    -
  • {{ occurrence.utc }}
  • -
-
    -
  • {{ occurrence.local }}
  • -
-
-
\ No newline at end of file diff --git a/bower.json b/bower.json index aa5a5dc661..9fd2a8b4af 100644 --- a/bower.json +++ b/bower.json @@ -15,7 +15,7 @@ "angular-md5": "~0.1.7", "angular-resource": "~1.2.12", "angular-sanitize": "~1.2.12", - "angular-scheduler": "*", + "angular-scheduler": "~0.0.3", "bootstrap": "~3.1.1", "components-font-awesome": "~4.0.3", "less.js": "~1.6.3",
Scope Variable