Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MINOR Moved jquery-changetracker from 'cms' to 'sapphire'

  • Loading branch information...
commit c2457c845b11356f9c29a749aa8b1faa0a534ef3 1 parent 89055ee
@chillu chillu authored
View
17 javascript/jquery-changetracker/README.md
@@ -1,17 +0,0 @@
-# jquery.changetracker - Change tracking for forms #
-
-## Setup ##
-
- jQuery('<my-form>).changetracker();
-
-## Usage ##
-
-Finding out if the form has changed:
- jQuery('<my-form>).is('.changed');
-
-## Options ##
-
-* fieldSelector: jQuery selector string for tracked fields
- (Default: ':input:not(:submit),:select:not(:submit)')
-* ignoreFieldSelector: jQuery selector string for specifically excluded fields
-* changedCssClass: CSS class attribute which is appended to all changed fields and the form itself
View
103 javascript/jquery-changetracker/lib/jquery.changetracker.js
@@ -1,103 +0,0 @@
-(function($){
- // Copyright (c) 2009, SilverStripe Ltd.
- // All rights reserved.
- //
- // Redistribution and use in source and binary forms, with or without
- // modification, are permitted provided that the following conditions are met:
- // * Redistributions of source code must retain the above copyright
- // notice, this list of conditions and the following disclaimer.
- // * Redistributions in binary form must reproduce the above copyright
- // notice, this list of conditions and the following disclaimer in the
- // documentation and/or other materials provided with the distribution.
- // * Neither the name of the <organization> nor the
- // names of its contributors may be used to endorse or promote products
- // derived from this software without specific prior written permission.
- //
- // THIS SOFTWARE IS PROVIDED BY SilverStripe Ltd. ''AS IS'' AND ANY
- // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- // DISCLAIMED. IN NO EVENT SHALL SilverStripe Ltd. BE LIABLE FOR ANY
- // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- /**
- * @class Tracks onchange events on all form fields.
- *
- * @todo Implement form reset handling
- *
- * @name jQuery.changetracker
- * @author Ingo Schommer, SilverStripe Ltd.
- * @license BSD License
- */
- $.fn.changetracker = function(_options) {
- var self = this;
-
- if(this.length > 1){
- this.each(function(i, item) {
- this.changetracker(_options);
- });
- return this;
- }
-
- this.defaults = {
- fieldSelector: ':input:not(:submit)',
- ignoreFieldSelector: "",
- changedCssClass: 'changed'
- };
-
- var options = $.extend({}, this.defaults, _options);
-
- this.initialize = function() {
- // optional metadata plugin support
- if ($.meta) options = $.extend({}, options, this.data());
-
- // setup original values
- this.getFields()
- .bind('change', function(e) {
- var $field = $(e.target);
- var origVal = $field.data('changetracker.origVal');
- if(origVal === null || $field.val() != origVal) {
- $field.addClass(options.changedCssClass);
- self.addClass(options.changedCssClass);
- }
- })
- .each(function() {
- $(this).data('changetracker.origVal', $(this).val());
- });
- };
-
- /**
- * Reset change state of all form fields and the form itself.
- */
- this.reset = function() {
- this.getFields().each(function() {
- self.resetField(this);
- });
-
- this.removeClass(options.changedCssClass);
- };
-
- /**
- * Reset the change single form field.
- * Does not reset to the original value.
- *
- * @param DOMElement field
- */
- this.resetField = function(field) {
- return $(field).removeData('changetracker.origVal');
- };
-
- /**
- * @return jQuery Collection of fields
- */
- this.getFields = function() {
- return this.find(options.fieldSelector).not(options.ignoreFieldSelector);
- };
-
- return this.initialize();
- };
-}(jQuery));
View
31 javascript/jquery-changetracker/spec/.tmp_spec.html.49538~
@@ -1,31 +0,0 @@
-<html>
- <head>
- <link type="text/css" rel="stylesheet" href="../vendor/jspec/lib/jspec.css" />
- <script src="../vendor/jquery-1.3.2.js"></script>
- <script src="../vendor/jquery.livequery-1.0.3.js"></script>
- <script src="../vendor/jspec/lib/jspec.js"></script>
- <script src="../vendor/jspec/lib/jspec.jquery.js"></script>
-
- <script src="../src/jquery.dat.js"></script>
- <script src="../src/jquery.specifity.js"></script>
- <script src="../src/jquery.concrete.js"></script>
- <script src="../src/jquery.fastis.js"></script>
- <script>
- function runSuites() {
- JSpec
- .exec('spec.concrete.basics.js')
- .exec('spec.concrete.selectors.js')
- .exec('spec.concrete.events.js')
- .exec('spec.concrete.has.js')
- .exec('spec.concrete.properties.js')
- .run()
- .report()
- }
- </script>
- </head>
- <body class="jspec" onLoad="runSuites();">
- <div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div>
- <div id="jspec"><div class="loading"></div></div>
- <div id="jspec-bottom"></div>
- </body>
-</html>
View
34 javascript/jquery-changetracker/spec/.tmp_spec.html.8678~
@@ -1,34 +0,0 @@
-<html>
- <head>
- <link type="text/css" rel="stylesheet" href="../vendor/jspec/lib/jspec.css" />
- <script src="../vendor/jquery-1.3.2.js"></script>
- <script src="../vendor/jspec/lib/jspec.js"></script>
- <script src="../vendor/jspec/lib/jspec.jquery.js"></script>
-
- <script src="../../jquery.selector/src/jquery.class.js"></script>
- <script src="../../jquery.selector/src/jquery.selector.js"></script>
- <script src="../../jquery.selector/src/jquery.selector.specifity.js"></script>
- <script src="../../jquery.selector/src/jquery.selector.matches.js"></script>
- <script src="../src/jquery.dat.js"></script>
- <script src="../src/jquery.concrete.js"></script>
- <script>
- function runSuites() {
- JSpec
- .exec('spec.concrete.basics.js')
- .exec('spec.concrete.super.js')
- //.exec('spec.concrete.selectors.js')
- .exec('spec.concrete.events.js')
- .exec('spec.concrete.ctors.js')
- //.exec('spec.concrete.has.js')
- //.exec('spec.concrete.properties.js')
- .run()
- .report()
- }
- </script>
- </head>
- <body class="jspec" onLoad="runSuites();">
- <div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div>
- <div id="jspec"><div class="loading"></div></div>
- <div id="jspec-bottom"></div>
- </body>
-</html>
View
32 javascript/jquery-changetracker/spec/.tmp_spec.html.970~
@@ -1,32 +0,0 @@
-<html>
- <head>
- <link type="text/css" rel="stylesheet" href="../vendor/jspec/lib/jspec.css" />
- <script src="../vendor/jquery-1.3.2.js"></script>
- <script src="../vendor/jspec/lib/jspec.js"></script>
- <script src="../vendor/jspec/lib/jspec.jquery.js"></script>
-
- <script src="../../jquery.selector/src/jquery.class.js"></script>
- <script src="../../jquery.selector/src/jquery.selector.js"></script>
- <script src="../../jquery.selector/src/jquery.selector.specifity.js"></script>
- <script src="../../jquery.selector/src/jquery.selector.matches.js"></script>
- <script src="../src/jquery.dat.js"></script>
- <script src="../src/jquery.concrete.js"></script>
- <script>
- function runSuites() {
- JSpec
- .exec('spec.concrete.basics.js')
- //.exec('spec.concrete.selectors.js')
- .exec('spec.concrete.events.js')
- //.exec('spec.concrete.has.js')
- //.exec('spec.concrete.properties.js')
- .run()
- .report()
- }
- </script>
- </head>
- <body class="jspec" onLoad="runSuites();">
- <div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div>
- <div id="jspec"><div class="loading"></div></div>
- <div id="jspec-bottom"></div>
- </body>
-</html>
View
31 javascript/jquery-changetracker/spec/.tmp_spec_selectors.html.13329~
@@ -1,31 +0,0 @@
-<html>
- <head>
- <link type="text/css" rel="stylesheet" href="../vendor/jspec/lib/jspec.css" />
- <script src="../vendor/jquery-1.3.2.js"></script>
- <script src="../vendor/jquery.livequery-1.0.3.js"></script>
- <script src="../vendor/jspec/lib/jspec.js"></script>
- <script src="../vendor/jspec/lib/jspec.jquery.js"></script>
-
- <script src="../src/jquery.dat.js"></script>
- <script src="../src/jquery.specifity.js"></script>
- <script src="../src/jquery.concrete.js"></script>
- <script src="../src/jquery.fastis.js"></script>
- <script>
- function runSuites() {
- JSpec
- .exec('spec.concrete.basics.js')
- .exec('spec.concrete.selectors.js')
- .exec('spec.concrete.events.js')
- .exec('spec.concrete.has.js')
- .exec('spec.concrete.properties.js')
- .run()
- .report()
- }
- </script>
- </head>
- <body class="jspec" onLoad="runSuites();">
- <div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div>
- <div id="jspec"><div class="loading"></div></div>
- <div id="jspec-bottom"></div>
- </body>
-</html>
View
105 javascript/jquery-changetracker/spec/.tmp_speed.html.70283~
@@ -1,105 +0,0 @@
-<html>
- <head>
- <link type="text/css" rel="stylesheet" href="../vendor/jspec/lib/jspec.css" />
- <script src="../vendor/jquery-1.3.2.js"></script>
- <script src="../vendor/jquery.livequery-1.0.3.js"></script>
- <script src="../vendor/jspec/lib/jspec.js"></script>
- <script src="../vendor/jspec/lib/jspec.jquery.js"></script>
-
- <script src="../src/jquery.dat.js"></script>
- <script src="../src/jquery.specifity.js"></script>
- <script src="../src/jquery.concrete.js"></script>
- <script src="../src/jquery.fastis.js"></script>
- <script>
- function run() {
- var selectors = [
- '#a',
- '.b',
- '.b.c',
- '#d > #a',
- '#e #a',
- '#e > #d > #a',
- '#base #d #a',
- '#a ~ #c',
- '#a + #b',
- '#a:not(#b)',
- '.b:not(.d)',
- '#e:not(#f) #a:not(#f)'
- ];
-
- var is = 0, isc = 0, fast = 0, fastc = 0;
- var x = 0, y = 0;
- function test() {
- var selector = selectors[x];
-
- if (y == 0) {
- var el = $(selector);
- var start = (new Date).getTime()
- for (var j = 0; j < 10000; j++) {
- if (!el.is(selector)) { $('#out').append('<li>'+selector+':good is:ERROR</li>'); return; }
- }
- var time = (new Date).getTime() - start;
- $('#out').append('<li>'+selector+':good is:'+time+'</li>');
- is += time; isc += 1; $('#isg').css('width', is/isc + 'px');
- y=1;
- }
-
- else if (y == 1) {
- var el = $(selector);
- var start = (new Date).getTime()
- for (var j = 0; j < 10000; j++) {
- if (!el.fastis(selector)) { $('#out').append('<li>'+selector+':good fastis:ERROR</li>'); return; };
- }
- var time = (new Date).getTime() - start;
- $('#out').append('<li>'+selector+':good fastis:'+time+'</li>');
- fast += time; fastc += 1; $('#fastg').css('width', fast/fastc + 'px');
- y=2;
- }
-
- else if (y==2) {
- var el = $('#base');
- var start = (new Date).getTime()
- for (var j = 0; j < 10000; j++) {
- if (el.is(selector)) { $('#out').append('<li>'+selector+':bad is:ERROR</li>'); return; };
- }
- var time = (new Date).getTime() - start;
- $('#out').append('<li>'+selector+':bad is:'+time+'</li>');
- is += time; isc += 1; $('#isg').css('width', is/isc + 'px');
- y=3;
- }
-
- else if (y==3) {
- var el = $('#base');
- var start = (new Date).getTime()
- for (var j = 0; j < 10000; j++) {
- if (el.fastis(selector)) { $('#out').append('<li>'+selector+':bad fastis:ERROR</li>'); return; };
- }
- var time = (new Date).getTime() - start;
- $('#out').append('<li>'+selector+':bad fastis:'+time+'</li>');
- fast += time; fastc += 1; $('#fastg').css('width', fast/fastc + 'px');
- y=0; x += 1;
- }
-
- if (x < selectors.length) setTimeout(test,20);
- }
-
- test();
- }
- </script>
- </head>
- <body class="jspec" onLoad="run();">
- <div id='isg' style='height:20px;float:left;clear:left;background:blue;'>Regular is</div>
- <div id='fastg' style='height:20px;float:left;clear:left;background:green;'>Fast is</div>
- <ul id='out' style='clear:left;'>
- </ul>
- <div id='base'>
- <div id='e'>
- <div id='d'>
- <div id='a' class='b c'></div>
- <div id='b'></div>
- <div id='c'></div>
- </div>
- </div>
- </div>
- </body>
-</html>
View
128 javascript/jquery-changetracker/spec/spec.changetracker.basics.js
@@ -1,128 +0,0 @@
-describe 'ChangeTracker'
- describe 'Basics'
- before_each
- $('body').append(
- '<form method="GET" id="form_test" action="#"></form>'
- );
- end
- after_each
- $('#form_test').remove()
- end
-
- it 'doesnt mark unaltered forms as changed'
- $('#form_test').append(
- '<input type="text" name="field_text" value="origval" />'
- );
-
- $('#form_test').changetracker();
-
- $('#form_test').is('.changed').should.be_false
- end
-
- it 'can track changes on input type=text fields with existing values'
- $('#form_test').append(
- '<input type="text" name="field_text" value="origval" />'
- );
-
- $('#form_test').changetracker();
-
- $(':input[name=field_text]').val('newval').trigger('change');
- $('#form_test').is('.changed').should.be_true
- $(':input[name=field_text]').is('.changed').should.be_true
- end
-
- it 'can track changes on input type=radio fields with existing values'
- $('#form_test').append(
- '<input type="radio" name="field_radio" value="1" />'
- + '<input type="radio" name="field_radio" value="2" />'
- );
-
- $('#form_test').changetracker();
-
- $(':input[name=field_radio]').val(1).trigger('change');
- $('#form_test').is('.changed').should.be_true
- $(':input[name=field_radio]').is('.changed').should.be_true
- end
-
- it 'can track changes on select fields with existing values'
- $('#form_test').append(
- '<select name="field_select">'
- + '<option value="1" selected="selected" />'
- + '<option value="2" />'
- + '</select>'
- );
-
- $('#form_test').changetracker();
-
- $(':input[name=field_select]').val(2).trigger('change');
- $('#form_test').is('.changed').should.be_true
- $(':input[name=field_select]').is('.changed').should.be_true
- end
-
- it 'can exclude certain fields via an optional selector'
- $('#form_test').append(
- '<input type="text" name="field_text" value="origval" />'
- + '<input type="text" name="field_text_ignored" value="origval" />'
- );
-
- $('#form_test').changetracker({
- ignoreFieldSelector: ':input[name=field_text_ignored]'
- });
-
- $(':input[name=field_text_ignored]').val('newval').trigger('change');
- $('#form_test').is('.changed').should.be_false
- $(':input[name=field_text_ignored]').is('.changed').should.be_false
-
- $(':input[name=field_text]').val('newval').trigger('change');
- $('#form_test').is('.changed').should.be_true
- $(':input[name=field_text]').is('.changed').should.be_true
- end
-
- it 'can attach custom CSS classes for tracking changed state'
- $('#form_test').append(
- '<input type="text" name="field_text" value="origval" />'
- );
-
- $('#form_test').changetracker({
- changedCssClass: 'customchanged'
- });
-
- $(':input[name=field_text]').val('newval').trigger('change');
- $('#form_test').hasClass('changed').should.be_false
- $('#form_test').hasClass('customchanged').should.be_true
- $(':input[name=field_text]').hasClass('changed').should.be_false
- $(':input[name=field_text]').hasClass('customchanged').should.be_true
- end
-
- it 'can reset changed state of individual fields'
- $('#form_test').append(
- '<input type="text" name="field_text1" value="origval" />'
- + '<input type="text" name="field_text2" value="origval" />'
- );
- $('#form_test').changetracker();
-
- $(':input[name=field_text1]').val('newval').trigger('change');
- $(':input[name=field_text2]').val('newval').trigger('change');
- $('#form_test').changetracker('resetfield', $(':input[name=field_text1]'));
- $(':input[name=field_text1]').is('.changed').should.be_false
- $(':input[name=field_text2]').is('.changed').should.be_true
- $('#form_test').is('.changed').should.be_true
- end
-
- it 'can reset all fields in the form'
- $('#form_test').append(
- '<input type="text" name="field_text1" value="origval" />'
- + '<input type="text" name="field_text2" value="origval" />'
- );
- $('#form_test').changetracker();
-
- $(':input[name=field_text1]').val('newval').trigger('change');
- $(':input[name=field_text2]').val('newval').trigger('change');
- $('#form_test').changetracker('reset');
- $(':input[name=field_text1]').is('.changed').should.be_false
- $(':input[name=field_text2]').is('.changed').should.be_false
- $('#form_test').is('.changed').should.be_false
- end
-
- end
-end
View
8 javascript/jquery-changetracker/spec/spec.core.js
@@ -1,8 +0,0 @@
-
-describe 'YourLib'
- describe '.someMethod()'
- it 'should do something'
- true.should.be true
- end
- end
-end
View
24 javascript/jquery-changetracker/spec/spec.dom.html
@@ -1,24 +0,0 @@
-<html>
- <head>
- <link type="text/css" rel="stylesheet" href="../vendor/jspec/lib/jspec.css" />
-
- <script src="../vendor/jquery-1.3.2.js"></script>
- <script src="../vendor/jspec/lib/jspec.js"></script>
- <script src="../vendor/jspec/lib/jspec.jquery.js"></script>
-
- <script src="../lib/jquery.changetracker.js"></script>
- <script>
- function runSuites() {
- JSpec
- .exec('spec.changetracker.basics.js')
- .run()
- .report()
- }
- </script>
- </head>
- <body class="jspec" onLoad="runSuites();">
- <div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div>
- <div id="jspec"></div>
- <div id="jspec-bottom"></div>
- </body>
-</html>
View
9 javascript/jquery-changetracker/spec/spec.rhino.js
@@ -1,9 +0,0 @@
-load('vendor/jquery-1.3.2.js')
-load('vendor/jspec/lib/jspec.js')
-load('vendor/jspec/lib/jspec.jquery.js')
-load('lib/jquery.changetracker.js')
-
-JSpec
-.exec('spec/spec.changetracker.basics.js')
-.run({ formatter : JSpec.formatters.Terminal })
-.report()
View
61 javascript/jquery-changetracker/vendor/TrivialReporter.js
@@ -1,61 +0,0 @@
-jasmine.TrivialReporter = function() {
-};
-
-jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
- var el = document.createElement(type);
-
- for (var i = 2; i < arguments.length; i++) {
- var child = arguments[i];
-
- if (typeof child === 'string') {
- el.appendChild(document.createTextNode(child));
- } else {
- el.appendChild(child);
- }
- }
-
- for (var attr in attrs) {
- if (attr == 'className') {
- el.setAttribute('class', attrs[attr]);
- } else {
- if (attr.indexOf('x-') == 0) {
- el.setAttribute(attr, attrs[attr]);
- } else {
- el[attr] = attrs[attr];
- }
- }
- }
-
- return el;
-};
-
-jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
- console.log(runner);
-};
-
-jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
- console.log(suite);
-};
-
-jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
- var specDiv = this.createDom('div', {
- className: spec.getResults().passed() ? 'spec passed' : 'spec failed'
- }, spec.getFullName());
-
- var resultItems = spec.getResults().getItems();
- for (var i = 0; i < resultItems.length; i++) {
- var result = resultItems[i];
- if (!result.passed) {
- var resultMessageDiv = this.createDom('div', {className: 'resultMessage'});
- resultMessageDiv.innerHTML = result.message; // todo: lame; mend
- specDiv.appendChild(resultMessageDiv);
- specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
- }
- }
-
- document.body.appendChild(specDiv);
-};
-
-jasmine.TrivialReporter.prototype.log = function() {
- console.log.apply(console, arguments);
-};
View
24 javascript/jquery-changetracker/vendor/jasmine.css
@@ -1,24 +0,0 @@
-body {
- font: 14px "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
- padding-left: 40px;
-}
-
-h1 {
- padding-top: 20px;
- font-weight: bold;
- font: 24px; /* "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; */
-}
-
-p {
- margin-top: 5px;
- padding-left: 20px;
-}
-
-p.fail {
- background: url( ../images/fail-16.png ) no-repeat;
- color: red;
-}
-
-p.fail_in_summary {
- color: red;
-}
View
900 javascript/jquery-changetracker/vendor/jasmine.js
@@ -1,900 +0,0 @@
-/*
- * Jasmine internal classes & objects
- */
-
-var Jasmine = {};
-
-Jasmine.util = {};
-
-/** @deprecated Use Jasmine.util instead */
-Jasmine.Util = Jasmine.util;
-
-Jasmine.util.inherit = function(childClass, parentClass) {
- var subclass = function() { };
- subclass.prototype = parentClass.prototype;
- childClass.prototype = new subclass;
-};
-
-/*
- * Holds results; allows for the results array to hold another Jasmine.NestedResults
- */
-Jasmine.NestedResults = function() {
- this.totalCount = 0;
- this.passedCount = 0;
- this.failedCount = 0;
- this.results = [];
-};
-
-Jasmine.NestedResults.prototype.rollupCounts = function(result) {
- this.totalCount += result.totalCount;
- this.passedCount += result.passedCount;
- this.failedCount += result.failedCount;
-};
-
-Jasmine.NestedResults.prototype.push = function(result) {
- if (result.results) {
- this.rollupCounts(result);
- } else {
- this.totalCount++;
- if (result.passed) {
- this.passedCount++;
- } else {
- this.failedCount++;
- }
- }
- this.results.push(result);
-};
-
-Jasmine.NestedResults.prototype.passed = function() {
- return this.passedCount === this.totalCount;
-};
-
-
-/*
- * base for Runner & Suite: allows for a queue of functions to get executed, allowing for
- * any one action to complete, including asynchronous calls, before going to the next
- * action.
- *
- **/
-Jasmine.ActionCollection = function() {
- this.actions = [];
- this.index = 0;
- this.finished = false;
- this.results = new Jasmine.NestedResults();
-};
-
-Jasmine.ActionCollection.prototype.finish = function() {
- if (this.finishCallback) {
- this.finishCallback();
- }
- this.finished = true;
-};
-
-Jasmine.ActionCollection.prototype.report = function(result) {
- this.results.push(result);
-};
-
-Jasmine.ActionCollection.prototype.execute = function() {
- if (this.actions.length > 0) {
- this.next();
- }
-};
-
-Jasmine.ActionCollection.prototype.getCurrentAction = function() {
- return this.actions[this.index];
-};
-
-Jasmine.ActionCollection.prototype.next = function() {
- if (this.index >= this.actions.length) {
- this.finish();
- return;
- }
-
- var currentAction = this.getCurrentAction();
-
- currentAction.execute(this);
-
- if (currentAction.afterCallbacks) {
- for (var i = 0; i < currentAction.afterCallbacks.length; i++) {
- try {
- currentAction.afterCallbacks[i]();
- } catch (e) {
- alert(e);
- }
- }
- }
-
- this.waitForDone(currentAction);
-};
-
-Jasmine.ActionCollection.prototype.waitForDone = function(action) {
- var self = this;
- var afterExecute = function() {
- self.report(action.results);
- self.index++;
- self.next();
- };
-
- if (action.finished) {
- afterExecute();
- return;
- }
-
- var id = setInterval(function() {
- if (action.finished) {
- clearInterval(id);
- afterExecute();
- }
- }, 150);
-};
-
-Jasmine.safeExecuteBeforeOrAfter = function(spec, func) {
- try {
- func.apply(spec);
- } catch (e) {
- var fail = {passed: false, message: func.typeName + '() fail: ' + Jasmine.util.formatException(e)};
- spec.results.push(fail);
- }
-};
-
-/*
- * QueuedFunction is how ActionCollections' actions are implemented
- */
-Jasmine.QueuedFunction = function(func, timeout, latchFunction, spec) {
- this.func = func;
- this.timeout = timeout;
- this.latchFunction = latchFunction;
- this.spec = spec;
-
- this.totalTimeSpentWaitingForLatch = 0;
- this.latchTimeoutIncrement = 100;
-};
-
-Jasmine.QueuedFunction.prototype.next = function() {
- this.spec.finish(); // default value is to be done after one function
-};
-
-Jasmine.QueuedFunction.prototype.safeExecute = function() {
- if (console) {
- console.log('>> Jasmine Running ' + this.spec.suite.description + ' ' + this.spec.description + '...');
- }
-
- try {
- this.func.apply(this.spec);
- } catch (e) {
- this.fail(e);
- }
-};
-
-Jasmine.QueuedFunction.prototype.execute = function() {
- var self = this;
- var executeNow = function() {
- self.safeExecute();
- self.next();
- };
-
- var executeLater = function() {
- setTimeout(executeNow, self.timeout);
- };
-
- var executeNowOrLater = function() {
- var latchFunctionResult;
-
- try {
- latchFunctionResult = self.latchFunction.apply(self.spec);
- } catch (e) {
- self.fail(e);
- self.next();
- return;
- }
-
- if (latchFunctionResult) {
- executeNow();
- } else if (self.totalTimeSpentWaitingForLatch >= self.timeout) {
- var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.latchFunction.description || 'something to happen');
- self.fail({ name: 'timeout', message: message });
- self.next();
- } else {
- self.totalTimeSpentWaitingForLatch += self.latchTimeoutIncrement;
- setTimeout(executeNowOrLater, self.latchTimeoutIncrement);
- }
- };
-
- if (this.latchFunction !== undefined) {
- executeNowOrLater();
- } else if (this.timeout > 0) {
- executeLater();
- } else {
- executeNow();
- }
-};
-
-Jasmine.QueuedFunction.prototype.fail = function(e) {
- this.spec.results.push({passed:false, message: Jasmine.util.formatException(e)});
-};
-
-/******************************************************************************
- * Jasmine
- ******************************************************************************/
-
-Jasmine.Env = function() {
- this.currentSpec = null;
- this.currentSuite = null;
- this.currentRunner = null;
-};
-
-Jasmine.Env.prototype.execute = function() {
- this.currentRunner.execute();
-};
-
-Jasmine.currentEnv_ = new Jasmine.Env();
-
-/** @deprecated use Jasmine.getEnv() instead */
-var jasmine = Jasmine.currentEnv_;
-
-Jasmine.getEnv = function() {
- return Jasmine.currentEnv_;
-};
-
-Jasmine.isArray_ = function(value) {
- return value &&
- typeof value === 'object' &&
- typeof value.length === 'number' &&
- typeof value.splice === 'function' &&
- !(value.propertyIsEnumerable('length'));
-};
-
-Jasmine.arrayToString_ = function(array) {
- var formatted_value = '';
- for (var i = 0; i < array.length; i++) {
- if (i > 0) {
- formatted_value += ', ';
- }
- ;
- formatted_value += Jasmine.pp(array[i]);
- }
- return '[ ' + formatted_value + ' ]';
-};
-
-Jasmine.objectToString_ = function(obj) {
- var formatted_value = '';
- var first = true;
- for (var property in obj) {
- if (property == '__Jasmine_pp_has_traversed__') continue;
-
- if (first) {
- first = false;
- } else {
- formatted_value += ', ';
- }
- formatted_value += property;
- formatted_value += ' : ';
- formatted_value += Jasmine.pp(obj[property]);
- }
-
- return '{ ' + formatted_value + ' }';
-};
-
-Jasmine.ppNestLevel_ = 0;
-
-Jasmine.pp = function(value) {
- if (Jasmine.ppNestLevel_ > 40) {
-// return '(Jasmine.pp nested too deeply!)';
- throw new Error('Jasmine.pp nested too deeply!');
- }
-
- Jasmine.ppNestLevel_++;
- try {
- return Jasmine.pp_(value);
- } finally {
- Jasmine.ppNestLevel_--;
- }
-};
-
-Jasmine.pp_ = function(value) {
- if (value === undefined) {
- return 'undefined';
- }
- if (value === null) {
- return 'null';
- }
-
- if (value.navigator && value.frames && value.setTimeout) {
- return '<window>';
- }
-
- if (value instanceof Jasmine.Any) return value.toString();
-
- if (typeof value === 'string') {
- return "'" + Jasmine.util.htmlEscape(value) + "'";
- }
- if (typeof value === 'function') {
- return 'Function';
- }
- if (typeof value.nodeType === 'number') {
- return 'HTMLNode';
- }
-
- if (value.__Jasmine_pp_has_traversed__) {
- return '<circular reference: ' + (Jasmine.isArray_(value) ? 'Array' : 'Object') + '>';
- }
-
- if (Jasmine.isArray_(value) || typeof value == 'object') {
- value.__Jasmine_pp_has_traversed__ = true;
- var stringified = Jasmine.isArray_(value) ? Jasmine.arrayToString_(value) : Jasmine.objectToString_(value);
- delete value.__Jasmine_pp_has_traversed__;
- return stringified;
- }
-
- return Jasmine.util.htmlEscape(value.toString());
-};
-
-/*
- * Jasmine.Matchers methods; add your own by extending Jasmine.Matchers.prototype - don't forget to write a test
- *
- */
-
-Jasmine.Matchers = function(actual, results) {
- this.actual = actual;
- this.passing_message = 'Passed.';
- this.results = results || new Jasmine.NestedResults();
-};
-
-Jasmine.Matchers.prototype.report = function(result, failing_message) {
-
- this.results.push({
- passed: result,
- message: result ? this.passing_message : failing_message
- });
-
- return result;
-};
-
-Jasmine.isDomNode = function(obj) {
- return obj['nodeType'] > 0;
-};
-
-Jasmine.Any = function(expectedClass) {
- this.expectedClass = expectedClass;
-};
-
-Jasmine.Any.prototype.matches = function(other) {
- if (this.expectedClass == String) {
- return typeof other == 'string' || other instanceof String;
- }
-
- if (this.expectedClass == Number) {
- return typeof other == 'number' || other instanceof Number;
- }
-
- return other instanceof this.expectedClass;
-};
-
-Jasmine.Any.prototype.toString = function() {
- return '<Jasmine.any(' + this.expectedClass + ')>';
-};
-
-Jasmine.any = function(clazz) {
- return new Jasmine.Any(clazz);
-};
-
-Jasmine.Matchers.prototype.toEqual = function(expected) {
- var mismatchKeys = [];
- var mismatchValues = [];
-
- var hasKey = function(obj, keyName) {
- return obj!=null && obj[keyName] !== undefined;
- };
-
- var equal = function(a, b) {
- if (a == undefined || a == null) {
- return (a == undefined && b == undefined);
- }
-
- if (Jasmine.isDomNode(a) && Jasmine.isDomNode(b)) {
- return a === b;
- }
-
- if (typeof a === "object" && typeof b === "object") {
- for (var property in b) {
- if (!hasKey(a, property) && hasKey(b, property)) {
- mismatchKeys.push("expected has key '" + property + "', but missing from <b>actual</b>.");
- }
- }
- for (property in a) {
- if (!hasKey(b, property) && hasKey(a, property)) {
- mismatchKeys.push("<b>expected</b> missing key '" + property + "', but present in actual.");
- }
- }
- for (property in b) {
- if (!equal(a[property], b[property])) {
- mismatchValues.push("'" + property + "' was<br /><br />'" + (b[property] ? Jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "'<br /><br />in expected, but was<br /><br />'" + (a[property] ? Jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "'<br /><br />in actual.<br />");
- }
- }
-
-
- return (mismatchKeys.length == 0 && mismatchValues.length == 0);
- }
-
- if (b instanceof Jasmine.Any) {
- return b.matches(a);
- }
-
- // functions are considered equivalent if their bodies are equal // todo: remove this
- if (typeof a === "function" && typeof b === "function") {
- return a.toString() == b.toString();
- }
-
- //Straight check
- return (a === b);
- };
-
- var formatMismatches = function(name, array) {
- if (array.length == 0) return '';
- var errorOutput = '<br /><br />Different ' + name + ':<br />';
- for (var i = 0; i < array.length; i++) {
- errorOutput += array[i] + '<br />';
- }
- return errorOutput;
-
- };
-
- return this.report(equal(this.actual, expected),
- 'Expected<br /><br />' + Jasmine.pp(expected)
- + '<br /><br />but got<br /><br />' + Jasmine.pp(this.actual)
- + '<br />'
- + formatMismatches('Keys', mismatchKeys)
- + formatMismatches('Values', mismatchValues));
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.should_equal = Jasmine.Matchers.prototype.toEqual;
-
-Jasmine.Matchers.prototype.toNotEqual = function(expected) {
- return this.report((this.actual !== expected),
- 'Expected ' + Jasmine.pp(expected) + ' to not equal ' + Jasmine.pp(this.actual) + ', but it does.');
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.should_not_equal = Jasmine.Matchers.prototype.toNotEqual;
-
-Jasmine.Matchers.prototype.toMatch = function(reg_exp) {
- return this.report((new RegExp(reg_exp).test(this.actual)),
- 'Expected ' + this.actual + ' to match ' + reg_exp + '.');
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.should_match = Jasmine.Matchers.prototype.toMatch;
-
-Jasmine.Matchers.prototype.toNotMatch = function(reg_exp) {
- return this.report((!new RegExp(reg_exp).test(this.actual)),
- 'Expected ' + this.actual + ' to not match ' + reg_exp + '.');
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.should_not_match = Jasmine.Matchers.prototype.toNotMatch;
-
-Jasmine.Matchers.prototype.toBeDefined = function() {
- return this.report((this.actual !== undefined),
- 'Expected a value to be defined but it was undefined.');
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.should_be_defined = Jasmine.Matchers.prototype.toBeDefined;
-
-Jasmine.Matchers.prototype.toBeNull = function() {
- return this.report((this.actual === null),
- 'Expected a value to be null but it was not.');
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.should_be_null = Jasmine.Matchers.prototype.toBeNull;
-
-Jasmine.Matchers.prototype.toBeTruthy = function() {
- return this.report((this.actual),
- 'Expected a value to be truthy but it was not.');
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.should_be_truthy = Jasmine.Matchers.prototype.toBeTruthy;
-
-Jasmine.Matchers.prototype.toBeFalsy = function() {
- return this.report((!this.actual),
- 'Expected a value to be falsy but it was not.');
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.should_be_falsy = Jasmine.Matchers.prototype.toBeFalsy;
-
-Jasmine.Matchers.prototype.wasCalled = function() {
- if (!this.actual.isSpy) {
- return this.report(false, 'Expected value to be a spy, but it was not.');
- }
- return this.report((this.actual.wasCalled),
- 'Expected spy to have been called, but it was not.');
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.was_called = Jasmine.Matchers.prototype.wasCalled;
-
-Jasmine.Matchers.prototype.wasNotCalled = function() {
- if (!this.actual.isSpy) {
- return this.report(false, 'Expected value to be a spy, but it was not.');
- }
- return this.report((!this.actual.wasCalled),
- 'Expected spy to not have been called, but it was.');
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.was_not_called = Jasmine.Matchers.prototype.wasNotCalled;
-
-Jasmine.Matchers.prototype.wasCalledWith = function() {
- if (!this.wasCalled()) return false;
- var argMatcher = new Jasmine.Matchers(this.actual.mostRecentCall.args, this.results);
- return argMatcher.toEqual(Jasmine.util.argsToArray(arguments));
-};
-/** @deprecated */
-Jasmine.Matchers.prototype.was_called = Jasmine.Matchers.prototype.wasCalled;
-
-Jasmine.Matchers.prototype.toContain = function(item) {
- return this.report((this.actual.indexOf(item) >= 0),
- 'Expected ' + Jasmine.pp(this.actual) + ' to contain ' + Jasmine.pp(item) + ', but it does not.');
-};
-
-Jasmine.Matchers.prototype.toNotContain = function(item) {
- return this.report((this.actual.indexOf(item) < 0),
- 'Expected ' + Jasmine.pp(this.actual) + ' not to contain ' + Jasmine.pp(item) + ', but it does.');
-};
-
-Jasmine.createSpy = function() {
- var spyObj = function() {
- spyObj.wasCalled = true;
- spyObj.callCount++;
- var args = Jasmine.util.argsToArray(arguments);
- spyObj.mostRecentCall = {
- object: this,
- args: args
- };
- spyObj.argsForCall.push(args);
- return spyObj.plan.apply(this, arguments);
- };
-
- spyObj.isSpy = true;
-
- spyObj.plan = function() {
- };
-
- spyObj.andCallThrough = function() {
- spyObj.plan = spyObj.originalValue;
- return spyObj;
- };
- spyObj.andReturn = function(value) {
- spyObj.plan = function() {
- return value;
- };
- return spyObj;
- };
- spyObj.andThrow = function(exceptionMsg) {
- spyObj.plan = function() {
- throw exceptionMsg;
- };
- return spyObj;
- };
- spyObj.andCallFake = function(fakeFunc) {
- spyObj.plan = fakeFunc;
- return spyObj;
- };
- spyObj.reset = function() {
- spyObj.wasCalled = false;
- spyObj.callCount = 0;
- spyObj.argsForCall = [];
- spyObj.mostRecentCall = {};
- };
- spyObj.reset();
-
- return spyObj;
-};
-
-Jasmine.spyOn = function(obj, methodName) {
- var spec = Jasmine.getEnv().currentSpec;
- spec.after(function() {
- spec.removeAllSpies();
- });
-
- if (obj == undefined) {
- throw "spyOn could not find an object to spy upon";
- }
-
- if (obj[methodName] === undefined) {
- throw methodName + '() method does not exist';
- }
-
- if (obj[methodName].isSpy) {
- throw new Error(methodName + ' has already been spied upon');
- }
-
- var spyObj = Jasmine.createSpy();
-
- spec.spies_.push(spyObj);
- spyObj.baseObj = obj;
- spyObj.methodName = methodName;
- spyObj.originalValue = obj[methodName];
-
- obj[methodName] = spyObj;
-
- return spyObj;
-};
-
-var spyOn = Jasmine.spyOn;
-
-/*
- * Jasmine spec constructor
- */
-
-Jasmine.Spec = function(description) {
- this.suite = null;
- this.description = description;
- this.queue = [];
- this.currentTimeout = 0;
- this.currentLatchFunction = undefined;
- this.finished = false;
- this.afterCallbacks = [];
- this.spies_ = [];
-
- this.results = new Jasmine.NestedResults();
-};
-
-Jasmine.Spec.prototype.freezeSuite = function(suite) {
- this.suite = suite;
-};
-
-/** @deprecated */
-Jasmine.Spec.prototype.expects_that = function(actual) {
- return new Jasmine.Matchers(actual, this.results);
-};
-
-Jasmine.Spec.prototype.waits = function(timeout) {
- this.currentTimeout = timeout;
- this.currentLatchFunction = undefined;
- return this;
-};
-
-Jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, message) {
- this.currentTimeout = timeout;
- this.currentLatchFunction = latchFunction;
- this.currentLatchFunction.description = message;
- return this;
-};
-
-Jasmine.Spec.prototype.resetTimeout = function() {
- this.currentTimeout = 0;
- this.currentLatchFunction = undefined;
-};
-
-Jasmine.Spec.prototype.finishCallback = function() {
- if (Jasmine.getEnv().reporter) {
- Jasmine.getEnv().reporter.reportSpecResults(this.results);
- }
-};
-
-Jasmine.Spec.prototype.finish = function() {
- if (this.suite.afterEach) {
- Jasmine.safeExecuteBeforeOrAfter(this, this.suite.afterEach);
- }
- this.finishCallback();
- this.finished = true;
-};
-
-Jasmine.Spec.prototype.after = function(doAfter) {
- this.afterCallbacks.push(doAfter);
-};
-
-Jasmine.Spec.prototype.execute = function() {
- Jasmine.getEnv().currentSpec = this;
- if (this.suite.beforeEach) {
- Jasmine.safeExecuteBeforeOrAfter(this, this.suite.beforeEach);
- }
- if (this.queue[0]) {
- this.queue[0].execute();
- } else {
- this.finish();
- }
-};
-
-Jasmine.Spec.prototype.explodes = function() {
- throw 'explodes function should not have been called';
-};
-
-Jasmine.Spec.prototype.spyOn = Jasmine.spyOn;
-
-Jasmine.Spec.prototype.removeAllSpies = function() {
- for (var i = 0; i < this.spies_.length; i++) {
- var spy = this.spies_[i];
- spy.baseObj[spy.methodName] = spy.originalValue;
- }
- this.spies_ = [];
-};
-
-var it = function(description, func) {
- var that = new Jasmine.Spec(description);
-
- var addToQueue = function(func) {
- var currentFunction = new Jasmine.QueuedFunction(func, that.currentTimeout, that.currentLatchFunction, that);
- that.queue.push(currentFunction);
-
- if (that.queue.length > 1) {
- var previousFunction = that.queue[that.queue.length - 2];
- previousFunction.next = function() {
- currentFunction.execute();
- };
- }
-
- that.resetTimeout();
- return that;
- };
-
- that.expectationResults = that.results.results;
- that.runs = addToQueue;
- that.freezeSuite(Jasmine.getEnv().currentSuite);
-
- Jasmine.getEnv().currentSuite.specs.push(that);
-
- Jasmine.getEnv().currentSpec = that;
-
- if (func) {
- addToQueue(func);
- }
-
- that.results.description = description;
- return that;
-};
-
-//this mirrors the spec syntax so you can define a spec description that will not run.
-var xit = function() {
- return {runs: function() {
- } };
-};
-
-var expect = function() {
- return Jasmine.getEnv().currentSpec.expects_that.apply(Jasmine.getEnv().currentSpec, arguments);
-};
-
-var runs = function(func) {
- Jasmine.getEnv().currentSpec.runs(func);
-};
-
-var waits = function(timeout) {
- Jasmine.getEnv().currentSpec.waits(timeout);
-};
-
-var waitsFor = function(timeout, latchFunction, message) {
- Jasmine.getEnv().currentSpec.waitsFor(timeout, latchFunction, message);
-};
-
-var beforeEach = function(beforeEach) {
- beforeEach.typeName = 'beforeEach';
- Jasmine.getEnv().currentSuite.beforeEach = beforeEach;
-};
-
-var afterEach = function(afterEach) {
- afterEach.typeName = 'afterEach';
- Jasmine.getEnv().currentSuite.afterEach = afterEach;
-};
-
-Jasmine.Description = function(description, specDefinitions) {
- Jasmine.ActionCollection.call(this);
-
- this.description = description;
- this.specs = this.actions;
-};
-Jasmine.util.inherit(Jasmine.Description, Jasmine.ActionCollection);
-
-var describe = function(description, spec_definitions) {
- var that = new Jasmine.Description(description, spec_definitions);
-
- Jasmine.getEnv().currentSuite = that;
- Jasmine.getEnv().currentRunner.suites.push(that);
-
- spec_definitions();
-
- that.results.description = description;
- that.specResults = that.results.results;
-
- that.finishCallback = function() {
- if (Jasmine.getEnv().reporter) {
- Jasmine.getEnv().reporter.reportSuiteResults(that.results);
- }
- };
-
- return that;
-};
-
-var xdescribe = function() {
- return {execute: function() {
- }};
-};
-
-Jasmine.Runner = function() {
- Jasmine.ActionCollection.call(this);
-
- this.suites = this.actions;
- this.results.description = 'All Jasmine Suites';
-};
-Jasmine.util.inherit(Jasmine.Runner, Jasmine.ActionCollection);
-
-var Runner = function() {
- var that = new Jasmine.Runner();
-
- that.finishCallback = function() {
- if (Jasmine.getEnv().reporter) {
- Jasmine.getEnv().reporter.reportRunnerResults(that.results);
- }
- };
-
- that.suiteResults = that.results.results;
-
- Jasmine.getEnv().currentRunner = that;
- return that;
-};
-
-Jasmine.getEnv().currentRunner = Runner();
-
-/* JasmineReporters.reporter
- * Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to
- * descendants of this object to do something with the results (see json_reporter.js)
- */
-Jasmine.Reporters = {};
-
-Jasmine.Reporters.reporter = function(callbacks) {
- var that = {
- callbacks: callbacks || {},
-
- doCallback: function(callback, results) {
- if (callback) {
- callback(results);
- }
- },
-
- reportRunnerResults: function(results) {
- that.doCallback(that.callbacks.runnerCallback, results);
- },
- reportSuiteResults: function(results) {
- that.doCallback(that.callbacks.suiteCallback, results);
- },
- reportSpecResults: function(results) {
- that.doCallback(that.callbacks.specCallback, results);
- }
- };
-
- return that;
-};
-
-Jasmine.util.formatException = function(e) {
- var lineNumber;
- if (e.line) {
- lineNumber = e.line;
- }
- else if (e.lineNumber) {
- lineNumber = e.lineNumber;
- }
-
- var file;
-
- if (e.sourceURL) {
- file = e.sourceURL;
- }
- else if (e.fileName) {
- file = e.fileName;
- }
-
- var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
-
- if (file && lineNumber) {
- message += ' in ' + file + ' (line ' + lineNumber + ')';
- }
-
- return message;
-};
-
-Jasmine.util.htmlEscape = function(str) {
- if (!str) return str;
- return str.replace(/&/g, '&amp;')
- .replace(/</g, '&lt;')
- .replace(/>/g, '&gt;');
-};
-
-Jasmine.util.argsToArray = function(args) {
- var arrayOfArgs = [];
- for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
- return arrayOfArgs;
-};
View
4,376 javascript/jquery-changetracker/vendor/jquery-1.3.2.js
0 additions, 4,376 deletions not shown
Please sign in to comment.
Something went wrong with that request. Please try again.