From b3e39df1a0f37ec3f31c097058c148da6d01facf Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Wed, 25 Jul 2012 09:54:49 -0600
Subject: [PATCH 001/152] All jQuerMX compatibility tests passing
---
class/class.js | 4 +-
controller/controller.html | 2 +-
controller/controller.js | 4 +-
.../view/test/qunit/controller_view_test.js | 7 +-
dom/animate/animate_test.js | 3 +-
dom/closest/closest.js | 2 +-
dom/compare/compare.js | 2 +-
dom/cookie/cookie.js | 2 +-
dom/dimensions/dimensions.js | 2 +-
dom/dimensions/dimensions_test.js | 3 -
dom/fixture/fixture.js | 4 +-
dom/form_params/form_params.js | 3 +-
dom/form_params/form_params_test.js | 6 +-
dom/range/range.js | 1559 ++++++++---------
dom/route/route.js | 3 +-
dom/selection/selection_test.js | 2 +-
dom/styles/styles.js | 5 +-
dom/styles/styles_test.js | 4 +-
dom/within/within.js | 4 +-
event/default/default.js | 6 +-
event/default/default_pause_test.js | 2 +-
event/destroyed/destroyed.js | 4 +-
event/destroyed/destroyed_test.js | 4 +-
event/drag/drag.js | 5 +-
event/drag/limit/limit.js | 3 +-
event/drag/scroll/scroll.js | 3 +-
event/drag/step/step.js | 3 +-
event/drop/drop.js | 6 +-
event/fastfix/fastfix.js | 4 +-
event/handle/handle.js | 4 +-
event/hashchange/hashchange.js | 4 +-
event/hover/hover.js | 4 +-
event/key/key.js | 4 +-
event/livehack/livehack.js | 2 +-
event/move/move.js | 2 +-
event/pause/pause.js | 3 +-
event/resize/resize.js | 4 +-
event/reverse/reverse.js | 4 +-
event/selection/selection.js | 5 +-
event/swipe/swipe.js | 3 +-
event/tap/tap.js | 3 +-
jquery.js | 1 -
lang/json/json.js | 2 +-
model/model.js | 4 +-
model/test/qunit/model_test.js | 23 +-
test/test.js | 42 +-
view/ejs/ejs.js | 2 +-
view/micro/micro.js | 84 +-
view/tmpl/tmpl.js | 108 +-
view/view.js | 3 +-
50 files changed, 950 insertions(+), 1022 deletions(-)
delete mode 100644 jquery.js
diff --git a/class/class.js b/class/class.js
index c404cab2..c6e68fa3 100644
--- a/class/class.js
+++ b/class/class.js
@@ -3,6 +3,6 @@
// http://ejohn.org/blog/simple-javascript-inheritance/
// It provides class level inheritance and callbacks.
//!steal-clean
-steal("can/construct/proxy","can/construct/super",function( $ ) {
- $.Class = can.Construct;
+steal("jquery", "can/construct", "can/construct/proxy","can/construct/super", function($, Construct) {
+ $.Class = Construct;
})();
diff --git a/controller/controller.html b/controller/controller.html
index a76e2ace..56458d75 100644
--- a/controller/controller.html
+++ b/controller/controller.html
@@ -75,7 +75,7 @@
// hides old active tab, shows new one
"li click" : function(el, ev){
ev.preventDefault();
- this.tab(this.find('.active').removeClass('active')).hide()
+ this.tab(this.element.find('.active').removeClass('active')).hide()
this.tab(el.addClass('active')).show();
}
})
diff --git a/controller/controller.js b/controller/controller.js
index 93b2c403..0b834de0 100644
--- a/controller/controller.js
+++ b/controller/controller.js
@@ -1,5 +1,5 @@
-steal('jquery/class','can/control/plugin',function( $ ) {
- $.Controller = can.Control;
+steal('jquery', 'can/control', 'jquery/class','can/control/plugin',function($, Control) {
+ $.Controller = Control;
$.fn.controller = $.fn.control;
$.fn.controllers = $.fn.controllers;
});
diff --git a/controller/view/test/qunit/controller_view_test.js b/controller/view/test/qunit/controller_view_test.js
index 506da897..1628f84d 100644
--- a/controller/view/test/qunit/controller_view_test.js
+++ b/controller/view/test/qunit/controller_view_test.js
@@ -1,5 +1,4 @@
-steal('jquery/controller/view','jquery/view/micro','funcunit/qunit') //load qunit
- .then(function(){
+steal('jquery', 'jquery/controller/view','jquery/view/micro','funcunit/qunit', function($) {
module("jquery/controller/view");
@@ -10,7 +9,7 @@ steal('jquery/controller/view','jquery/view/micro','funcunit/qunit') //load qun
this.element.html(this.view())
}
})
- jQuery.View.ext = ".micro";
+ $.View.ext = ".micro";
$("#qunit-test-area").append("");
new jquery.Controller.View.Test.Qunit( $('#cont_view') );
@@ -26,7 +25,7 @@ steal('jquery/controller/view','jquery/view/micro','funcunit/qunit') //load qun
}
})
- jQuery.View.ext = ".ejs"; // Reset view extension to default
+ $.View.ext = ".ejs"; // Reset view extension to default
equal(".ejs", jQuery.View.ext);
$("#qunit-test-area").append("");
diff --git a/dom/animate/animate_test.js b/dom/animate/animate_test.js
index 99c3253b..5f8009d1 100644
--- a/dom/animate/animate_test.js
+++ b/dom/animate/animate_test.js
@@ -1,5 +1,4 @@
-steal('jquery/dom/animate',
- 'funcunit/qunit').then('./qunit.css', function () {
+steal('jquery', 'jquery/dom/animate', 'funcunit/qunit', 'qunit.css', function ($) {
module("jquery/dom/animate");
diff --git a/dom/closest/closest.js b/dom/closest/closest.js
index 14ac24da..e6118da2 100644
--- a/dom/closest/closest.js
+++ b/dom/closest/closest.js
@@ -1,7 +1,7 @@
/**
* @add jQuery.fn
*/
-steal('jquery/dom').then(function(){
+steal('jquery', function($) {
/**
* @function closest
* @parent dom
diff --git a/dom/compare/compare.js b/dom/compare/compare.js
index 99dacf7b..a90596c8 100644
--- a/dom/compare/compare.js
+++ b/dom/compare/compare.js
@@ -1,4 +1,4 @@
-steal('jquery/dom').then(function($){
+steal('jquery', function($) {
/**
* @function jQuery.fn.compare
diff --git a/dom/cookie/cookie.js b/dom/cookie/cookie.js
index 003bd2f6..5c49ce03 100644
--- a/dom/cookie/cookie.js
+++ b/dom/cookie/cookie.js
@@ -1,4 +1,4 @@
-steal('jquery/lang/json',function() {
+steal('jquery', 'jquery/lang/json', function($) {
/**
* @function jQuery.cookie
* @parent jquerypp
diff --git a/dom/dimensions/dimensions.js b/dom/dimensions/dimensions.js
index 364e04c9..95f5c97f 100644
--- a/dom/dimensions/dimensions.js
+++ b/dom/dimensions/dimensions.js
@@ -1,5 +1,5 @@
-steal('jquery/dom/styles').then(function($) {
+steal('jquery', 'jquery/dom/styles', function($) {
var
//margin is inside border
diff --git a/dom/dimensions/dimensions_test.js b/dom/dimensions/dimensions_test.js
index 2b96bc68..15cb7f0e 100644
--- a/dom/dimensions/dimensions_test.js
+++ b/dom/dimensions/dimensions_test.js
@@ -4,9 +4,6 @@ steal("jquery/dom/dimensions",
module("jquery/dom/dimensions");
-
-
-
test("outerHeight and width",function(){
$("#qunit-test-area").html("//jquery/dom/dimensions/test/styles.micro",{})
})
diff --git a/dom/fixture/fixture.js b/dom/fixture/fixture.js
index 93c82a75..2e9b41a0 100644
--- a/dom/fixture/fixture.js
+++ b/dom/fixture/fixture.js
@@ -1,3 +1,3 @@
-steal('can/util/fixture',function($){
- $.fixture = can.fixture;
+steal('jquery', 'can/util/fixture', function($, fixture) {
+ $.fixture = fixture;
})
diff --git a/dom/form_params/form_params.js b/dom/form_params/form_params.js
index 45034c52..e3d102cb 100644
--- a/dom/form_params/form_params.js
+++ b/dom/form_params/form_params.js
@@ -1,4 +1,4 @@
-steal("jquery/dom").then(function( $ ) {
+steal("jquery", function( $ ) {
var
// use to parse bracket notation like my[name][attribute]
keyBreaker = /[^\[\]]+/g,
@@ -161,4 +161,5 @@ steal("jquery/dom").then(function( $ ) {
}
});
+ return $;
});
diff --git a/dom/form_params/form_params_test.js b/dom/form_params/form_params_test.js
index 4392b764..b515afd4 100644
--- a/dom/form_params/form_params_test.js
+++ b/dom/form_params/form_params_test.js
@@ -1,6 +1,5 @@
-steal("jquery/dom/form_params") //load your app
- .then('funcunit/qunit','jquery/view/micro') //load qunit
- .then(function(){
+steal("jquery", "jquery/dom/form_params", 'funcunit/qunit', 'jquery/view/micro',
+function($) {
$.ajaxSetup({
cache : false
@@ -11,7 +10,6 @@ test("with a form", function(){
$("#qunit-test-area").html("//jquery/dom/form_params/test/basics.micro",{})
-
var formParams = $("#qunit-test-area form").formParams() ;
ok(formParams.params.one === "1","one is right");
ok(formParams.params.two === "2","two is right");
diff --git a/dom/range/range.js b/dom/range/range.js
index 3b113357..ba96c298 100644
--- a/dom/range/range.js
+++ b/dom/range/range.js
@@ -1,856 +1,853 @@
-steal('jquery','jquery/dom/compare').then(function($){
+steal('jquery', 'jquery/dom/compare', function ($) {
$.fn.range =
-/**
- * @function jQuery.fn.range
- * @parent jQuery.Range
- *
- * `$.fn.range` returns a new [jQuery.Range] instance for the first selected element.
- *
- * $('#content').range() //-> range
- *
- * @return {$.Range} A $.Range instance for the selected element
- */
-function(){
- return $.Range(this[0])
-}
-
-var convertType = function(type){
- return type.replace(/([a-z])([a-z]+)/gi, function(all,first, next){
- return first+next.toLowerCase()
- }).replace(/_/g,"");
-},
-// reverses things like START_TO_END into END_TO_START
-reverse = function(type){
- return type.replace(/^([a-z]+)_TO_([a-z]+)/i, function(all, first, last){
- return last+"_TO_"+first;
- });
-},
-getWindow = function( element ) {
- return element ? element.ownerDocument.defaultView || element.ownerDocument.parentWindow : window
-},
-bisect = function(el, start, end){
- //split the start and end ... figure out who is touching ...
- if(end-start == 1){
- return
- }
-},
-support = {};
-/**
- * @Class jQuery.Range
- * @parent jQuery.Range
- *
- * Depending on the object passed, the selected text will be different.
- *
- * @param {TextRange|HTMLElement|Point} [range] An object specifiying a
- * range. Depending on the object, the selected text will be different. $.Range supports the
- * following types
- *
- * - __undefined or null__ - returns a range with nothing selected
- * - __HTMLElement__ - returns a range with the node's text selected
- * - __Point__ - returns a range at the point on the screen. The point can be specified like:
- *
- * //client coordinates
- * {clientX: 200, clientY: 300}
- *
- * //page coordinates
- * {pageX: 200, pageY: 300}
- * {top: 200, left: 300}
- *
- * - __TextRange__ a raw text range object.
- */
-$.Range = function(range){
- // If it's called w/o new, call it with new!
- if(this.constructor !== $.Range){
- return new $.Range(range);
- }
- // If we are passed a jQuery-wrapped element, get the raw element
- if(range && range.jquery){
- range = range[0];
- }
- // If we have an element, or nothing
- if(!range || range.nodeType){
- // create a range
- this.win = getWindow(range)
- if(this.win.document.createRange){
- this.range = this.win.document.createRange()
- }else{
- this.range = this.win.document.body.createTextRange()
- }
- // if we have an element, make the range select it
- if(range){
- this.select(range)
+ /**
+ * @function jQuery.fn.range
+ * @parent jQuery.Range
+ *
+ * `$.fn.range` returns a new [jQuery.Range] instance for the first selected element.
+ *
+ * $('#content').range() //-> range
+ *
+ * @return {$.Range} A $.Range instance for the selected element
+ */
+ function () {
+ return $.Range(this[0])
}
- }
- // if we are given a point
- else if (range.clientX != null || range.pageX != null || range.left != null) {
- this.moveToPoint(range);
- }
- // if we are given a touch event
- else if (range.originalEvent && range.originalEvent.touches && range.originalEvent.touches.length) {
- this.moveToPoint(range.originalEvent.touches[0])
-
- }
- // if we are a normal event
- else if (range.originalEvent && range.originalEvent.changedTouches && range.originalEvent.changedTouches.length) {
- this.moveToPoint(range.originalEvent.changedTouches[0])
- }
- // given a TextRange or something else?
- else {
- this.range = range;
- }
-};
-/**
- * @static
- */
-$.Range.
-/**
- * `$.Range.current([element])` returns the currently selected range
- * (using [window.getSelection](https://developer.mozilla.org/en/nsISelection)).
- *
- * var range = $.Range.current()
- * range.start().offset // -> selection start offset
- * range.end().offset // -> selection end offset
- *
- * @param {HTMLElement} [el] an optional element used to get selection for a given window.
- * @return {jQuery.Range} The range instance.
- */
-current = function(el){
- var win = getWindow(el),
- selection;
- if(win.getSelection){
- // If we can get the selection
- selection = win.getSelection()
- return new $.Range( selection.rangeCount ? selection.getRangeAt(0) : win.document.createRange())
- } else {
- // Otherwise use document.selection
- return new $.Range( win.document.selection.createRange() );
- }
-};
-
-
-
-
-$.extend($.Range.prototype,
-/** @prototype **/
-{
+
+ var convertType = function (type) {
+ return type.replace(/([a-z])([a-z]+)/gi,function (all, first, next) {
+ return first + next.toLowerCase()
+ }).replace(/_/g, "");
+ },
+// reverses things like START_TO_END into END_TO_START
+ reverse = function (type) {
+ return type.replace(/^([a-z]+)_TO_([a-z]+)/i, function (all, first, last) {
+ return last + "_TO_" + first;
+ });
+ },
+ getWindow = function (element) {
+ return element ? element.ownerDocument.defaultView || element.ownerDocument.parentWindow : window
+ },
+ bisect = function (el, start, end) {
+ //split the start and end ... figure out who is touching ...
+ if (end - start == 1) {
+ return
+ }
+ },
+ support = {};
/**
- * `range.moveToPoint(point)` moves the range end and start position to a specific point.
- * A point can be specified like:
+ * @Class jQuery.Range
+ * @parent jQuery.Range
+ *
+ * Depending on the object passed, the selected text will be different.
*
- * //client coordinates
- * {clientX: 200, clientY: 300}
+ * @param {TextRange|HTMLElement|Point} [range] An object specifiying a
+ * range. Depending on the object, the selected text will be different. $.Range supports the
+ * following types
*
- * //page coordinates
- * {pageX: 200, pageY: 300}
- * {top: 200, left: 300}
+ * - __undefined or null__ - returns a range with nothing selected
+ * - __HTMLElement__ - returns a range with the node's text selected
+ * - __Point__ - returns a range at the point on the screen. The point can be specified like:
*
- * @param point The point to move the range to
- * @return {$.Range}
+ * //client coordinates
+ * {clientX: 200, clientY: 300}
+ *
+ * //page coordinates
+ * {pageX: 200, pageY: 300}
+ * {top: 200, left: 300}
+ *
+ * - __TextRange__ a raw text range object.
*/
- moveToPoint : function(point){
- var clientX = point.clientX, clientY = point.clientY
- if(!clientX){
- var off = scrollOffset();
- clientX = (point.pageX || point.left || 0 ) - off.left;
- clientY = (point.pageY || point.top || 0 ) - off.top;
+ $.Range = function (range) {
+ // If it's called w/o new, call it with new!
+ if (this.constructor !== $.Range) {
+ return new $.Range(range);
}
- if(support.moveToPoint){
- this.range = $.Range().range
- this.range.moveToPoint(clientX, clientY);
- return this;
+ // If we are passed a jQuery-wrapped element, get the raw element
+ if (range && range.jquery) {
+ range = range[0];
}
-
-
- // it's some text node in this range ...
- var parent = document.elementFromPoint(clientX, clientY);
-
- //typically it will be 'on' text
- for(var n=0; n < parent.childNodes.length; n++){
- var node = parent.childNodes[n];
- if(node.nodeType === 3 || node.nodeType === 4){
- var range = $.Range(node),
- length = range.toString().length;
-
-
- // now lets start moving the end until the boundingRect is within our range
- for(var i = 1; i < length+1; i++){
- var rect = range.end(i).rect();
- if(rect.left <= clientX && rect.left+rect.width >= clientX &&
- rect.top <= clientY && rect.top+rect.height >= clientY ){
- range.start(i-1);
- this.range = range.range;
- return this;
- }
- }
+ // If we have an element, or nothing
+ if (!range || range.nodeType) {
+ // create a range
+ this.win = getWindow(range)
+ if (this.win.document.createRange) {
+ this.range = this.win.document.createRange()
+ } else {
+ this.range = this.win.document.body.createTextRange()
}
- }
-
- // if not 'on' text, recursively go through and find out when we shift to next
- // 'line'
- var previous;
- iterate(parent.childNodes, function(textNode){
- var range = $.Range(textNode);
- if(range.rect().top > point.clientY){
- return false;
- }else{
- previous = range;
+ // if we have an element, make the range select it
+ if (range) {
+ this.select(range)
}
- });
-
- if(previous){
- previous.start(previous.toString().length);
- this.range = previous.range;
- }else{
- this.range = $.Range(parent).range
}
- },
-
- window : function(){
- return this.win || window;
- },
- /**
- * `range.overlaps([elRange])` returns `true` if any portion of these two ranges overlap.
- *
- * var foo = document.getElementById('foo');
- *
- * $.Range(foo.childNodes[0]).overlaps(foo.childNodes[1]) //-> false
- *
- * @param {jQuery.Range} elRange The range to compare
- * @return {Boolean} true if part of the ranges overlap, false if otherwise.
- */
- overlaps : function(elRange){
- if(elRange.nodeType){
- elRange = $.Range(elRange).select(elRange);
+ // if we are given a point
+ else if (range.clientX != null || range.pageX != null || range.left != null) {
+ this.moveToPoint(range);
}
- //if the start is within the element ...
- var startToStart = this.compare("START_TO_START", elRange),
- endToEnd = this.compare("END_TO_END", elRange)
+ // if we are given a touch event
+ else if (range.originalEvent && range.originalEvent.touches && range.originalEvent.touches.length) {
+ this.moveToPoint(range.originalEvent.touches[0])
- // if we wrap elRange
- if(startToStart <=0 && endToEnd >=0){
- return true;
}
- // if our start is inside of it
- if( startToStart >= 0 &&
- this.compare("START_TO_END", elRange) <= 0 ) {
- return true;
+ // if we are a normal event
+ else if (range.originalEvent && range.originalEvent.changedTouches && range.originalEvent.changedTouches.length) {
+ this.moveToPoint(range.originalEvent.changedTouches[0])
}
- // if our end is inside of elRange
- if(this.compare("END_TO_START", elRange) >= 0 &&
- endToEnd <= 0 ) {
- return true;
+ // given a TextRange or something else?
+ else {
+ this.range = range;
}
- return false;
- },
- /**
- * `range.collapse([toStart])` collapses a range to one of its boundary points.
- * See [range.collapse](https://developer.mozilla.org/en/DOM/range.collapse).
- *
- * $('#foo').range().collapse()
- *
- * @param {Boolean} [toStart] true if to the start of the range, false if to the
- * end. Defaults to false.
- * @return {jQuery.Range} returns the range for chaining.
- */
- collapse : function(toStart){
- this.range.collapse(toStart === undefined ? true : toStart);
- return this;
- },
+ };
/**
- * `range.toString()` returns the text of the range.
- *
- * currentText = $.Range.current().toString()
- *
- * @return {String} The text content of this range
+ * @static
*/
- toString : function(){
- return typeof this.range.text == "string" ? this.range.text : this.range.toString();
- },
+ $.Range.
/**
- * `range.start([start])` gets or sets the start of the range.
- *
- * If a value is not provided, start returns the range's starting container and offset like:
- *
- * $('#foo').range().start()
- * //-> {container: fooElement, offset: 0 }
- *
- * If a set value is provided, it can set the range. The start of the range is set differently
- * depending on the type of set value:
+ * `$.Range.current([element])` returns the currently selected range
+ * (using [window.getSelection](https://developer.mozilla.org/en/nsISelection)).
*
- * - __Object__ - an object with the new starting container and offset like
+ * var range = $.Range.current()
+ * range.start().offset // -> selection start offset
+ * range.end().offset // -> selection end offset
*
- * $.Range().start({container: $('#foo')[0], offset: 20})
- *
- * - __Number__ - the new offset value. The container is kept the same.
- *
- * - __String__ - adjusts the offset by converting the string offset to a number and adding it to the current
- * offset. For example, the following moves the offset forward four characters:
- *
- * $('#foo').range().start("+4")
- *
- * Note that `start` can return a text node. To get the containing element use this:
- *
- * var startNode = range.start().container;
- * if( startNode.nodeType === Node.TEXT_NODE ||
- * startNode.nodeType === Node.CDATA_SECTION_NODE ) {
- * startNode = startNode.parentNode;
- * }
- * $(startNode).addClass('highlight');
- *
- * @param {Object|String|Number} [set] a set value if setting the start of the range or nothing if reading it.
- * @return {jQuery.Range|Object} if setting the start, the range is returned for chaining, otherwise, the
- * start offset and container are returned.
+ * @param {HTMLElement} [el] an optional element used to get selection for a given window.
+ * @return {jQuery.Range} The range instance.
*/
- start : function(set){
- // return start
- if(set === undefined){
- if(this.range.startContainer){
- return {
- container : this.range.startContainer,
- offset : this.range.startOffset
+ current = function (el) {
+ var win = getWindow(el),
+ selection;
+ if (win.getSelection) {
+ // If we can get the selection
+ selection = win.getSelection()
+ return new $.Range(selection.rangeCount ? selection.getRangeAt(0) : win.document.createRange())
+ } else {
+ // Otherwise use document.selection
+ return new $.Range(win.document.selection.createRange());
+ }
+ };
+
+
+ $.extend($.Range.prototype,
+ /** @prototype **/
+ {
+ /**
+ * `range.moveToPoint(point)` moves the range end and start position to a specific point.
+ * A point can be specified like:
+ *
+ * //client coordinates
+ * {clientX: 200, clientY: 300}
+ *
+ * //page coordinates
+ * {pageX: 200, pageY: 300}
+ * {top: 200, left: 300}
+ *
+ * @param point The point to move the range to
+ * @return {$.Range}
+ */
+ moveToPoint : function (point) {
+ var clientX = point.clientX, clientY = point.clientY
+ if (!clientX) {
+ var off = scrollOffset();
+ clientX = (point.pageX || point.left || 0 ) - off.left;
+ clientY = (point.pageY || point.top || 0 ) - off.top;
}
- }else{
- // Get the start parent element
- var start = this.clone().collapse().parent();
- // used to get the start element offset
- var startRange = $.Range(start).select(start).collapse();
- startRange.move("END_TO_START", this);
- return {
- container : start,
- offset : startRange.toString().length
+ if (support.moveToPoint) {
+ this.range = $.Range().range
+ this.range.moveToPoint(clientX, clientY);
+ return this;
}
- }
- } else {
- if (this.range.setStart) {
- // supports setStart
- if(typeof set == 'number'){
- this.range.setStart(this.range.startContainer, set)
- } else if(typeof set == 'string') {
- var res = callMove(this.range.startContainer, this.range.startOffset, parseInt(set,10))
- this.range.setStart(res.node, res.offset );
- } else {
- this.range.setStart(set.container, set.offset)
+
+
+ // it's some text node in this range ...
+ var parent = document.elementFromPoint(clientX, clientY);
+
+ //typically it will be 'on' text
+ for (var n = 0; n < parent.childNodes.length; n++) {
+ var node = parent.childNodes[n];
+ if (node.nodeType === 3 || node.nodeType === 4) {
+ var range = $.Range(node),
+ length = range.toString().length;
+
+
+ // now lets start moving the end until the boundingRect is within our range
+ for (var i = 1; i < length + 1; i++) {
+ var rect = range.end(i).rect();
+ if (rect.left <= clientX && rect.left + rect.width >= clientX &&
+ rect.top <= clientY && rect.top + rect.height >= clientY) {
+ range.start(i - 1);
+ this.range = range.range;
+ return this;
+ }
+ }
+ }
}
- } else {
- if(typeof set == "string"){
- this.range.moveStart('character', parseInt(set,10))
- } else {
- // get the current end container
- var container = this.start().container,
- offset
- if(typeof set == "number") {
- offset = set
+
+ // if not 'on' text, recursively go through and find out when we shift to next
+ // 'line'
+ var previous;
+ iterate(parent.childNodes, function (textNode) {
+ var range = $.Range(textNode);
+ if (range.rect().top > point.clientY) {
+ return false;
} else {
- container = set.container
- offset = set.offset
+ previous = range;
}
- var newPoint = $.Range(container).collapse();
- //move it over offset characters
- newPoint.range.move(offset);
- this.move("START_TO_START",newPoint);
- }
- }
- return this;
- }
+ });
+ if (previous) {
+ previous.start(previous.toString().length);
+ this.range = previous.range;
+ } else {
+ this.range = $.Range(parent).range
+ }
+ },
+
+ window : function () {
+ return this.win || window;
+ },
+ /**
+ * `range.overlaps([elRange])` returns `true` if any portion of these two ranges overlap.
+ *
+ * var foo = document.getElementById('foo');
+ *
+ * $.Range(foo.childNodes[0]).overlaps(foo.childNodes[1]) //-> false
+ *
+ * @param {jQuery.Range} elRange The range to compare
+ * @return {Boolean} true if part of the ranges overlap, false if otherwise.
+ */
+ overlaps : function (elRange) {
+ if (elRange.nodeType) {
+ elRange = $.Range(elRange).select(elRange);
+ }
+ //if the start is within the element ...
+ var startToStart = this.compare("START_TO_START", elRange),
+ endToEnd = this.compare("END_TO_END", elRange)
- },
- /**
- * `range.end([end])` gets or sets the end of the range.
- * It takes similar options as [jQuery.Range::start start]:
- *
- * - __Object__ - an object with the new end container and offset like
- *
- * $.Range().end({container: $('#foo')[0], offset: 20})
- *
- * - __Number__ - the new offset value. The container is kept the same.
- *
- * - __String__ - adjusts the offset by converting the string offset to a number and adding it to the current
- * offset. For example, the following moves the offset forward four characters:
- *
- * $('#foo').range().end("+4")
- *
- * Note that `end` can return a text node. To get the containing element use this:
- *
- * var startNode = range.end().container;
- * if( startNode.nodeType === Node.TEXT_NODE ||
- * startNode.nodeType === Node.CDATA_SECTION_NODE ) {
- * startNode = startNode.parentNode;
- * }
- * $(startNode).addClass('highlight');
- *
- * @param {Object|String|Number} [set] a set value if setting the end of the range or nothing if reading it.
- */
- end : function(set){
- // read end
- if (set === undefined) {
- if (this.range.startContainer) {
- return {
- container: this.range.endContainer,
- offset: this.range.endOffset
+ // if we wrap elRange
+ if (startToStart <= 0 && endToEnd >= 0) {
+ return true;
}
- }
- else {
- var
- // Get the end parent element
- end = this.clone().collapse(false).parent(),
- // used to get the end elements offset
- endRange = $.Range(end).select(end).collapse();
- endRange.move("END_TO_END", this);
- return {
- container: end,
- offset: endRange.toString().length
+ // if our start is inside of it
+ if (startToStart >= 0 &&
+ this.compare("START_TO_END", elRange) <= 0) {
+ return true;
}
- }
- } else {
- if (this.range.setEnd) {
- if(typeof set == 'number'){
- this.range.setEnd(this.range.endContainer, set)
- } else if(typeof set == 'string') {
- var res = callMove(this.range.endContainer, this.range.endOffset, parseInt(set,10))
- this.range.setEnd(res.node, res.offset );
+ // if our end is inside of elRange
+ if (this.compare("END_TO_START", elRange) >= 0 &&
+ endToEnd <= 0) {
+ return true;
+ }
+ return false;
+ },
+ /**
+ * `range.collapse([toStart])` collapses a range to one of its boundary points.
+ * See [range.collapse](https://developer.mozilla.org/en/DOM/range.collapse).
+ *
+ * $('#foo').range().collapse()
+ *
+ * @param {Boolean} [toStart] true if to the start of the range, false if to the
+ * end. Defaults to false.
+ * @return {jQuery.Range} returns the range for chaining.
+ */
+ collapse : function (toStart) {
+ this.range.collapse(toStart === undefined ? true : toStart);
+ return this;
+ },
+ /**
+ * `range.toString()` returns the text of the range.
+ *
+ * currentText = $.Range.current().toString()
+ *
+ * @return {String} The text content of this range
+ */
+ toString : function () {
+ return typeof this.range.text == "string" ? this.range.text : this.range.toString();
+ },
+ /**
+ * `range.start([start])` gets or sets the start of the range.
+ *
+ * If a value is not provided, start returns the range's starting container and offset like:
+ *
+ * $('#foo').range().start()
+ * //-> {container: fooElement, offset: 0 }
+ *
+ * If a set value is provided, it can set the range. The start of the range is set differently
+ * depending on the type of set value:
+ *
+ * - __Object__ - an object with the new starting container and offset like
+ *
+ * $.Range().start({container: $('#foo')[0], offset: 20})
+ *
+ * - __Number__ - the new offset value. The container is kept the same.
+ *
+ * - __String__ - adjusts the offset by converting the string offset to a number and adding it to the current
+ * offset. For example, the following moves the offset forward four characters:
+ *
+ * $('#foo').range().start("+4")
+ *
+ * Note that `start` can return a text node. To get the containing element use this:
+ *
+ * var startNode = range.start().container;
+ * if( startNode.nodeType === Node.TEXT_NODE ||
+ * startNode.nodeType === Node.CDATA_SECTION_NODE ) {
+ * startNode = startNode.parentNode;
+ * }
+ * $(startNode).addClass('highlight');
+ *
+ * @param {Object|String|Number} [set] a set value if setting the start of the range or nothing if reading it.
+ * @return {jQuery.Range|Object} if setting the start, the range is returned for chaining, otherwise, the
+ * start offset and container are returned.
+ */
+ start : function (set) {
+ // return start
+ if (set === undefined) {
+ if (this.range.startContainer) {
+ return {
+ container : this.range.startContainer,
+ offset : this.range.startOffset
+ }
+ } else {
+ // Get the start parent element
+ var start = this.clone().collapse().parent();
+ // used to get the start element offset
+ var startRange = $.Range(start).select(start).collapse();
+ startRange.move("END_TO_START", this);
+ return {
+ container : start,
+ offset : startRange.toString().length
+ }
+ }
} else {
- this.range.setEnd(set.container, set.offset)
+ if (this.range.setStart) {
+ // supports setStart
+ if (typeof set == 'number') {
+ this.range.setStart(this.range.startContainer, set)
+ } else if (typeof set == 'string') {
+ var res = callMove(this.range.startContainer, this.range.startOffset, parseInt(set, 10))
+ this.range.setStart(res.node, res.offset);
+ } else {
+ this.range.setStart(set.container, set.offset)
+ }
+ } else {
+ if (typeof set == "string") {
+ this.range.moveStart('character', parseInt(set, 10))
+ } else {
+ // get the current end container
+ var container = this.start().container,
+ offset
+ if (typeof set == "number") {
+ offset = set
+ } else {
+ container = set.container
+ offset = set.offset
+ }
+ var newPoint = $.Range(container).collapse();
+ //move it over offset characters
+ newPoint.range.move(offset);
+ this.move("START_TO_START", newPoint);
+ }
+ }
+ return this;
}
- } else {
- if(typeof set == "string"){
- this.range.moveEnd('character', parseInt(set,10));
+
+
+ },
+ /**
+ * `range.end([end])` gets or sets the end of the range.
+ * It takes similar options as [jQuery.Range::start start]:
+ *
+ * - __Object__ - an object with the new end container and offset like
+ *
+ * $.Range().end({container: $('#foo')[0], offset: 20})
+ *
+ * - __Number__ - the new offset value. The container is kept the same.
+ *
+ * - __String__ - adjusts the offset by converting the string offset to a number and adding it to the current
+ * offset. For example, the following moves the offset forward four characters:
+ *
+ * $('#foo').range().end("+4")
+ *
+ * Note that `end` can return a text node. To get the containing element use this:
+ *
+ * var startNode = range.end().container;
+ * if( startNode.nodeType === Node.TEXT_NODE ||
+ * startNode.nodeType === Node.CDATA_SECTION_NODE ) {
+ * startNode = startNode.parentNode;
+ * }
+ * $(startNode).addClass('highlight');
+ *
+ * @param {Object|String|Number} [set] a set value if setting the end of the range or nothing if reading it.
+ */
+ end : function (set) {
+ // read end
+ if (set === undefined) {
+ if (this.range.startContainer) {
+ return {
+ container : this.range.endContainer,
+ offset : this.range.endOffset
+ }
+ }
+ else {
+ var
+ // Get the end parent element
+ end = this.clone().collapse(false).parent(),
+ // used to get the end elements offset
+ endRange = $.Range(end).select(end).collapse();
+ endRange.move("END_TO_END", this);
+ return {
+ container : end,
+ offset : endRange.toString().length
+ }
+ }
} else {
- // get the current end container
- var container = this.end().container,
- offset
- if(typeof set == "number") {
- offset = set
+ if (this.range.setEnd) {
+ if (typeof set == 'number') {
+ this.range.setEnd(this.range.endContainer, set)
+ } else if (typeof set == 'string') {
+ var res = callMove(this.range.endContainer, this.range.endOffset, parseInt(set, 10))
+ this.range.setEnd(res.node, res.offset);
+ } else {
+ this.range.setEnd(set.container, set.offset)
+ }
} else {
- container = set.container
- offset = set.offset
+ if (typeof set == "string") {
+ this.range.moveEnd('character', parseInt(set, 10));
+ } else {
+ // get the current end container
+ var container = this.end().container,
+ offset
+ if (typeof set == "number") {
+ offset = set
+ } else {
+ container = set.container
+ offset = set.offset
+ }
+ var newPoint = $.Range(container).collapse();
+ //move it over offset characters
+ newPoint.range.move(offset);
+ this.move("END_TO_START", newPoint);
+ }
}
- var newPoint = $.Range(container).collapse();
- //move it over offset characters
- newPoint.range.move(offset);
- this.move("END_TO_START",newPoint);
+ return this;
}
- }
- return this;
- }
- },
- /**
- * `range.parent()` returns the most common ancestor element of
- * the endpoints in the range. This will return a text element if the range is
- * within a text element. In this case, to get the containing element use this:
- *
- * var parent = range.parent();
- * if( parent.nodeType === Node.TEXT_NODE ||
- * parent.nodeType === Node.CDATA_SECTION_NODE ) {
- * parent = startNode.parentNode;
- * }
- * $(parent).addClass('highlight');
- *
- * @return {HTMLNode} the TextNode or HTMLElement
- * that fully contains the range
- */
- parent : function(){
- if(this.range.commonAncestorContainer){
- return this.range.commonAncestorContainer;
- } else {
+ },
+ /**
+ * `range.parent()` returns the most common ancestor element of
+ * the endpoints in the range. This will return a text element if the range is
+ * within a text element. In this case, to get the containing element use this:
+ *
+ * var parent = range.parent();
+ * if( parent.nodeType === Node.TEXT_NODE ||
+ * parent.nodeType === Node.CDATA_SECTION_NODE ) {
+ * parent = startNode.parentNode;
+ * }
+ * $(parent).addClass('highlight');
+ *
+ * @return {HTMLNode} the TextNode or HTMLElement
+ * that fully contains the range
+ */
+ parent : function () {
+ if (this.range.commonAncestorContainer) {
+ return this.range.commonAncestorContainer;
+ } else {
+
+ var parentElement = this.range.parentElement(),
+ range = this.range;
- var parentElement = this.range.parentElement(),
- range = this.range;
+ // IE's parentElement will always give an element, we want text ranges
+ iterate(parentElement.childNodes, function (txtNode) {
+ if ($.Range(txtNode).range.inRange(range)) {
+ // swap out the parentElement
+ parentElement = txtNode;
+ return false;
+ }
+ });
- // IE's parentElement will always give an element, we want text ranges
- iterate(parentElement.childNodes, function(txtNode){
- if($.Range(txtNode).range.inRange( range ) ){
- // swap out the parentElement
- parentElement = txtNode;
- return false;
+ return parentElement;
}
- });
+ },
+ /**
+ * `range.rect([from])` returns the bounding rectangle of this range.
+ *
+ * @param {String} [from] - where the coordinates should be
+ * positioned from. By default, coordinates are given from the client viewport.
+ * But if 'page' is given, they are provided relative to the page.
+ *
+ * @return {TextRectangle} - The client rects.
+ */
+ rect : function (from) {
+ var rect = this.range.getBoundingClientRect();
+ // for some reason in webkit this gets a better value
+ if (!rect.height && !rect.width) {
+ rect = this.range.getClientRects()[0]
+ }
+ if (from === 'page') {
+ // Add the scroll offset
+ var off = scrollOffset();
+ rect = $.extend({}, rect);
+ rect.top += off.top;
+ rect.left += off.left;
+ }
+ return rect;
+ },
+ /**
+ * `range.rects(from)` returns the client rects.
+ *
+ * @param {String} [from] how the rects coordinates should be given (viewport or page). Provide 'page' for
+ * rect coordinates from the page.
+ * @return {Array} The client rects
+ */
+ rects : function (from) {
+ // order rects by size
+ var rects = $.map($.makeArray(this.range.getClientRects()).sort(function (rect1, rect2) {
+ return rect2.width * rect2.height - rect1.width * rect1.height;
+ }), function (rect) {
+ return $.extend({}, rect)
+ }),
+ i = 0, j,
+ len = rects.length;
+
+ // safari returns overlapping client rects
+ //
+ // - big rects can contain 2 smaller rects
+ // - some rects can contain 0 - width rects
+ // - we don't want these 0 width rects
+ while (i < rects.length) {
+ var cur = rects[i],
+ found = false;
+
+ j = i + 1;
+ while (j < rects.length) {
+ if (withinRect(cur, rects[j])) {
+ if (!rects[j].width) {
+ rects.splice(j, 1)
+ } else {
+ found = rects[j];
+ break;
+ }
+ } else {
+ j++;
+ }
+ }
- return parentElement;
- }
- },
- /**
- * `range.rect([from])` returns the bounding rectangle of this range.
- *
- * @param {String} [from] - where the coordinates should be
- * positioned from. By default, coordinates are given from the client viewport.
- * But if 'page' is given, they are provided relative to the page.
- *
- * @return {TextRectangle} - The client rects.
- */
- rect : function(from){
- var rect = this.range.getBoundingClientRect();
- // for some reason in webkit this gets a better value
- if(!rect.height && !rect.width){
- rect = this.range.getClientRects()[0]
- }
- if(from === 'page'){
- // Add the scroll offset
- var off = scrollOffset();
- rect = $.extend({}, rect);
- rect.top += off.top;
- rect.left += off.left;
- }
- return rect;
- },
- /**
- * `range.rects(from)` returns the client rects.
- *
- * @param {String} [from] how the rects coordinates should be given (viewport or page). Provide 'page' for
- * rect coordinates from the page.
- * @return {Array} The client rects
- */
- rects : function(from){
- // order rects by size
- var rects = $.map($.makeArray( this.range.getClientRects() ).sort(function(rect1, rect2){
- return rect2.width*rect2.height - rect1.width*rect1.height;
- }), function(rect){
- return $.extend({}, rect)
- }),
- i=0,j,
- len = rects.length;
-
- // safari returns overlapping client rects
- //
- // - big rects can contain 2 smaller rects
- // - some rects can contain 0 - width rects
- // - we don't want these 0 width rects
- while(i < rects.length){
- var cur = rects[i],
- found = false;
-
- j = i+1;
- while( j < rects.length ){
- if( withinRect( cur, rects[j] ) ) {
- if(!rects[j].width){
- rects.splice(j,1)
+
+ if (found) {
+ rects.splice(i, 1)
} else {
- found = rects[j];
- break;
+ i++;
}
- } else {
- j++;
+
+ }
+ // safari will be return overlapping ranges ...
+ if (from == 'page') {
+ var off = scrollOffset();
+ return $.each(rects, function (ith, item) {
+ item.top += off.top;
+ item.left += off.left;
+ })
}
- }
- if(found){
- rects.splice(i,1)
- }else{
- i++;
+ return rects;
}
- }
- // safari will be return overlapping ranges ...
- if(from == 'page'){
- var off = scrollOffset();
- return $.each(rects, function(ith, item){
- item.top += off.top;
- item.left += off.left;
- })
- }
-
-
- return rects;
- }
+ });
+ (function () {
+ //method branching ....
+ var fn = $.Range.prototype,
+ range = $.Range().range;
+
+ /**
+ * @function compare
+ *
+ * `range.compare(type, compareRange)` compares one range to another range.
+ *
+ * ## Example
+ *
+ * // compare the highlight element's start position
+ * // to the start of the current range
+ * $('#highlight')
+ * .range()
+ * .compare('START_TO_START', $.Range.current())
+ *
+ *
+ *
+ * @param {String} type Specifies the boundary of the
+ * range and the compareRange to compare.
+ *
+ * - `"START_TO_START"` - the start of the range and the start of compareRange
+ * - `"START_TO_END"` - the start of the range and the end of compareRange
+ * - `"END_TO_END"` - the end of the range and the end of compareRange
+ * - `"END_TO_START"` - the end of the range and the start of compareRange
+ *
+ * @param {$.Range} compareRange The other range
+ * to compare against.
+ * @return {Number} a number indicating if the range
+ * boundary is before,
+ * after, or equal to compareRange's
+ * boundary where:
+ *
+ * - -1 - the range boundary comes before the compareRange boundary
+ * - 0 - the boundaries are equal
+ * - 1 - the range boundary comes after the compareRange boundary
+ */
+ fn.compare = range.compareBoundaryPoints ?
+ function (type, range) {
+ return this.range.compareBoundaryPoints(this.window().Range[reverse(type)], range.range)
+ } :
+ function (type, range) {
+ return this.range.compareEndPoints(convertType(type), range.range)
+ }
-});
-(function(){
- //method branching ....
- var fn = $.Range.prototype,
- range = $.Range().range;
+ /**
+ * @function move
+ *
+ * `range.move([referenceRange])` moves the endpoints of a range relative to another range.
+ *
+ * // Move the current selection's end to the
+ * // end of the #highlight element
+ * $.Range.current().move('END_TO_END',
+ * $('#highlight').range() )
+ *
+ *
+ * @param {String} type a string indicating the ranges boundary point
+ * to move to which referenceRange boundary point where:
+ *
+ * - `"START_TO_START"` - the start of the range moves to the start of referenceRange
+ * - `"START\_TO\_END"` - the start of the range move to the end of referenceRange
+ * - `"END_TO_END"` - the end of the range moves to the end of referenceRange
+ * - `"END_TO_START"` - the end of the range moves to the start of referenceRange
+ *
+ * @param {jQuery.Range} referenceRange
+ * @return {jQuery.Range} the original range for chaining
+ */
+ fn.move = range.setStart ?
+ function (type, range) {
+
+ var rangesRange = range.range;
+ switch (type) {
+ case "START_TO_END" :
+ this.range.setStart(rangesRange.endContainer, rangesRange.endOffset)
+ break;
+ case "START_TO_START" :
+ this.range.setStart(rangesRange.startContainer, rangesRange.startOffset)
+ break;
+ case "END_TO_END" :
+ this.range.setEnd(rangesRange.endContainer, rangesRange.endOffset)
+ break;
+ case "END_TO_START" :
+ this.range.setEnd(rangesRange.startContainer, rangesRange.startOffset)
+ break;
+ }
- /**
- * @function compare
- *
- * `range.compare(type, compareRange)` compares one range to another range.
- *
- * ## Example
- *
- * // compare the highlight element's start position
- * // to the start of the current range
- * $('#highlight')
- * .range()
- * .compare('START_TO_START', $.Range.current())
- *
- *
- *
- * @param {String} type Specifies the boundary of the
- * range and the compareRange to compare.
- *
- * - `"START_TO_START"` - the start of the range and the start of compareRange
- * - `"START_TO_END"` - the start of the range and the end of compareRange
- * - `"END_TO_END"` - the end of the range and the end of compareRange
- * - `"END_TO_START"` - the end of the range and the start of compareRange
- *
- * @param {$.Range} compareRange The other range
- * to compare against.
- * @return {Number} a number indicating if the range
- * boundary is before,
- * after, or equal to compareRange's
- * boundary where:
- *
- * - -1 - the range boundary comes before the compareRange boundary
- * - 0 - the boundaries are equal
- * - 1 - the range boundary comes after the compareRange boundary
- */
- fn.compare = range.compareBoundaryPoints ?
- function(type, range){
- return this.range.compareBoundaryPoints(this.window().Range[reverse( type )], range.range)
- }:
- function(type, range){
- return this.range.compareEndPoints(convertType(type), range.range)
- }
+ return this;
+ } :
+ function (type, range) {
+ this.range.setEndPoint(convertType(type), range.range)
+ return this;
+ };
+ var cloneFunc = range.cloneRange ? "cloneRange" : "duplicate",
+ selectFunc = range.selectNodeContents ? "selectNodeContents" : "moveToElementText";
+
+ fn.
+ /**
+ * `range.clone()` clones the range and returns a new $.Range
+ * object:
+ *
+ * var range = new $.Range(document.getElementById('text'));
+ * var newRange = range.clone();
+ * range.start('+2');
+ * range.select();
+ *
+ * @return {jQuery.Range} returns the range as a $.Range.
+ */
+ clone = function () {
+ return $.Range(this.range[cloneFunc]());
+ };
- /**
- * @function move
- *
- * `range.move([referenceRange])` moves the endpoints of a range relative to another range.
- *
- * // Move the current selection's end to the
- * // end of the #highlight element
- * $.Range.current().move('END_TO_END',
- * $('#highlight').range() )
- *
- *
- * @param {String} type a string indicating the ranges boundary point
- * to move to which referenceRange boundary point where:
- *
- * - `"START_TO_START"` - the start of the range moves to the start of referenceRange
- * - `"START\_TO\_END"` - the start of the range move to the end of referenceRange
- * - `"END_TO_END"` - the end of the range moves to the end of referenceRange
- * - `"END_TO_START"` - the end of the range moves to the start of referenceRange
- *
- * @param {jQuery.Range} referenceRange
- * @return {jQuery.Range} the original range for chaining
- */
- fn.move = range.setStart ?
- function(type, range){
-
- var rangesRange = range.range;
- switch(type){
- case "START_TO_END" :
- this.range.setStart(rangesRange.endContainer, rangesRange.endOffset)
- break;
- case "START_TO_START" :
- this.range.setStart(rangesRange.startContainer, rangesRange.startOffset)
- break;
- case "END_TO_END" :
- this.range.setEnd(rangesRange.endContainer, rangesRange.endOffset)
- break;
- case "END_TO_START" :
- this.range.setEnd(rangesRange.startContainer, rangesRange.startOffset)
- break;
+ fn.
+ /**
+ * @function
+ *
+ * `range.select([el])` selects an element with this range. If nothing
+ * is provided, makes the current range appear as if the user has selected it.
+ *
+ * This works with text nodes. For example with:
+ *
+ *
This is a text
+ *
+ * $.Range can select `is a` like this:
+ *
+ * var range = new $.Range(document.getElementById('text'));
+ * range.start('+5');
+ * range.end('-5');
+ * range.select();
+ *
+ * @param {HTMLElement} [el] The element in which this range should be selected
+ * @return {jQuery.Range} the range for chaining.
+ */
+ select = range.selectNodeContents ? function (el) {
+ if (!el) {
+ var selection = this.window().getSelection();
+ selection.removeAllRanges();
+ selection.addRange(this.range);
+ } else {
+ this.range.selectNodeContents(el);
}
-
return this;
- }:
- function(type, range){
- this.range.setEndPoint(convertType(type), range.range)
+ } : function (el) {
+ if (!el) {
+ this.range.select()
+ } else if (el.nodeType === 3) {
+ //select this node in the element ...
+ var parent = el.parentNode,
+ start = 0,
+ end;
+ iterate(parent.childNodes, function (txtNode) {
+ if (txtNode === el) {
+ end = start + txtNode.nodeValue.length;
+ return false;
+ } else {
+ start = start + txtNode.nodeValue.length
+ }
+ })
+ this.range.moveToElementText(parent);
+
+ this.range.moveEnd('character', end - this.range.text.length)
+ this.range.moveStart('character', start);
+ } else {
+ this.range.moveToElementText(el);
+ }
return this;
};
- var cloneFunc = range.cloneRange ? "cloneRange" : "duplicate",
- selectFunc = range.selectNodeContents ? "selectNodeContents" : "moveToElementText";
- fn.
- /**
- * `range.clone()` clones the range and returns a new $.Range
- * object:
- *
- * var range = new $.Range(document.getElementById('text'));
- * var newRange = range.clone();
- * range.start('+2');
- * range.select();
- *
- * @return {jQuery.Range} returns the range as a $.Range.
- */
- clone = function(){
- return $.Range( this.range[cloneFunc]() );
- };
-
- fn.
- /**
- * @function
- *
- * `range.select([el])` selects an element with this range. If nothing
- * is provided, makes the current range appear as if the user has selected it.
- *
- * This works with text nodes. For example with:
- *
- *
This is a text
- *
- * $.Range can select `is a` like this:
- *
- * var range = new $.Range(document.getElementById('text'));
- * range.start('+5');
- * range.end('-5');
- * range.select();
- *
- * @param {HTMLElement} [el] The element in which this range should be selected
- * @return {jQuery.Range} the range for chaining.
- */
- select = range.selectNodeContents ? function(el){
- if(!el){
- var selection = this.window().getSelection();
- selection.removeAllRanges();
- selection.addRange(this.range);
- }else {
- this.range.selectNodeContents(el);
- }
- return this;
- } : function(el){
- if(!el){
- this.range.select()
- } else if(el.nodeType === 3){
- //select this node in the element ...
- var parent = el.parentNode,
- start = 0,
- end;
- iterate(parent.childNodes, function(txtNode){
- if(txtNode === el){
- end = start + txtNode.nodeValue.length;
- return false;
- } else {
- start = start + txtNode.nodeValue.length
- }
- })
- this.range.moveToElementText(parent);
-
- this.range.moveEnd('character', end - this.range.text.length)
- this.range.moveStart('character', start);
- } else {
- this.range.moveToElementText(el);
- }
- return this;
- };
-
-})();
+ })();
// helpers -----------------
// iterates through a list of elements, calls cb on every text node
// if cb returns false, exits the iteration
-var iterate = function(elems, cb){
- var elem, start;
- for (var i = 0; elems[i]; i++) {
- elem = elems[i];
- // Get the text from text nodes and CDATA nodes
- if (elem.nodeType === 3 || elem.nodeType === 4) {
- if (cb(elem) === false) {
- return false;
+ var iterate = function (elems, cb) {
+ var elem, start;
+ for (var i = 0; elems[i]; i++) {
+ elem = elems[i];
+ // Get the text from text nodes and CDATA nodes
+ if (elem.nodeType === 3 || elem.nodeType === 4) {
+ if (cb(elem) === false) {
+ return false;
+ }
+ // Traverse everything else, except comment nodes
+ }
+ else if (elem.nodeType !== 8) {
+ if (iterate(elem.childNodes, cb) === false) {
+ return false;
+ }
+ }
}
- // Traverse everything else, except comment nodes
- }
- else
- if (elem.nodeType !== 8) {
- if (iterate(elem.childNodes, cb) === false) {
- return false;
+
+ },
+ isText = function (node) {
+ return node.nodeType === 3 || node.nodeType === 4
+ },
+ iteratorMaker = function (toChildren, toNext) {
+ return function (node, mustMoveRight) {
+ // first try down
+ if (node[toChildren] && !mustMoveRight) {
+ return isText(node[toChildren]) ?
+ node[toChildren] :
+ arguments.callee(node[toChildren])
+ } else if (node[toNext]) {
+ return isText(node[toNext]) ?
+ node[toNext] :
+ arguments.callee(node[toNext])
+ } else if (node.parentNode) {
+ return arguments.callee(node.parentNode, true)
}
}
- }
-
-},
-isText = function(node){
- return node.nodeType === 3 || node.nodeType === 4
-},
-iteratorMaker = function(toChildren, toNext){
- return function( node, mustMoveRight ) {
- // first try down
- if(node[toChildren] && !mustMoveRight){
- return isText(node[toChildren]) ?
- node[toChildren] :
- arguments.callee(node[toChildren])
- } else if(node[toNext]) {
- return isText(node[toNext]) ?
- node[toNext] :
- arguments.callee(node[toNext])
- } else if(node.parentNode){
- return arguments.callee(node.parentNode, true)
- }
- }
-},
-getNextTextNode = iteratorMaker("firstChild","nextSibling"),
-getPrevTextNode = iteratorMaker("lastChild","previousSibling"),
-callMove = function(container, offset, howMany){
- if(isText(container)){
- return move(container, offset+howMany)
- } else {
- return container.childNodes[offset] ?
- move(container.childNodes[offset] , howMany) :
- move(container.lastChild, howMany , true)
- return
- }
-},
-move = function(from, howMany){
- var mover = howMany < 0 ?
- getPrevTextNode : getNextTextNode;
-
- howMany = Math.abs(howMany);
-
- if(!isText(from)){
- from = mover(from)
- }
- while(from && howMany >= from.nodeValue.length){
- hasMany = howMany- from.nodeValue.length;
- from = mover(from)
- }
- return {
- node: from,
- offset: mover === getNextTextNode ?
- howMany :
- from.nodeValue.length - howMany
- }
-},
-supportWhitespace,
-isWhitespace = function(el){
- if(supportWhitespace == null){
- supportWhitespace = 'isElementContentWhitespace' in el;
- }
- return (supportWhitespace? el.isElementContentWhitespace :
- (el.nodeType === 3 && '' == el.data.trim()));
-
-},
+ },
+ getNextTextNode = iteratorMaker("firstChild", "nextSibling"),
+ getPrevTextNode = iteratorMaker("lastChild", "previousSibling"),
+ callMove = function (container, offset, howMany) {
+ if (isText(container)) {
+ return move(container, offset + howMany)
+ } else {
+ return container.childNodes[offset] ?
+ move(container.childNodes[offset], howMany) :
+ move(container.lastChild, howMany, true)
+ return
+ }
+ },
+ move = function (from, howMany) {
+ var mover = howMany < 0 ?
+ getPrevTextNode : getNextTextNode;
+
+ howMany = Math.abs(howMany);
+
+ if (!isText(from)) {
+ from = mover(from)
+ }
+ while (from && howMany >= from.nodeValue.length) {
+ hasMany = howMany - from.nodeValue.length;
+ from = mover(from)
+ }
+ return {
+ node : from,
+ offset : mover === getNextTextNode ?
+ howMany :
+ from.nodeValue.length - howMany
+ }
+ },
+ supportWhitespace,
+ isWhitespace = function (el) {
+ if (supportWhitespace == null) {
+ supportWhitespace = 'isElementContentWhitespace' in el;
+ }
+ return (supportWhitespace ? el.isElementContentWhitespace :
+ (el.nodeType === 3 && '' == el.data.trim()));
+
+ },
// if a point is within a rectangle
-within = function(rect, point){
+ within = function (rect, point) {
- return rect.left <= point.clientX && rect.left + rect.width >= point.clientX &&
- rect.top <= point.clientY &&
- rect.top + rect.height >= point.clientY
-},
+ return rect.left <= point.clientX && rect.left + rect.width >= point.clientX &&
+ rect.top <= point.clientY &&
+ rect.top + rect.height >= point.clientY
+ },
// if a rectangle is within another rectangle
-withinRect = function(outer, inner){
- return within(outer, {
- clientX: inner.left,
- clientY: inner.top
- }) && //top left
- within(outer, {
- clientX: inner.left + inner.width,
- clientY: inner.top
- }) && //top right
- within(outer, {
- clientX: inner.left,
- clientY: inner.top + inner.height
- }) && //bottom left
- within(outer, {
- clientX: inner.left + inner.width,
- clientY: inner.top + inner.height
- }) //bottom right
-},
+ withinRect = function (outer, inner) {
+ return within(outer, {
+ clientX : inner.left,
+ clientY : inner.top
+ }) && //top left
+ within(outer, {
+ clientX : inner.left + inner.width,
+ clientY : inner.top
+ }) && //top right
+ within(outer, {
+ clientX : inner.left,
+ clientY : inner.top + inner.height
+ }) && //bottom left
+ within(outer, {
+ clientX : inner.left + inner.width,
+ clientY : inner.top + inner.height
+ }) //bottom right
+ },
// gets the scroll offset from a window
-scrollOffset = function( win){
- var win = win ||window;
- doc = win.document.documentElement, body = win.document.body;
-
- return {
- left: (doc && doc.scrollLeft || body && body.scrollLeft || 0) + (doc.clientLeft || 0),
- top: (doc && doc.scrollTop || body && body.scrollTop || 0) + (doc.clientTop || 0)
- };
-};
-
+ scrollOffset = function (win) {
+ var win = win || window;
+ doc = win.document.documentElement, body = win.document.body;
+
+ return {
+ left : (doc && doc.scrollLeft || body && body.scrollLeft || 0) + (doc.clientLeft || 0),
+ top : (doc && doc.scrollTop || body && body.scrollTop || 0) + (doc.clientTop || 0)
+ };
+ };
-support.moveToPoint = !!$.Range().range.moveToPoint
+ support.moveToPoint = !!$.Range().range.moveToPoint
+ return $;
});
\ No newline at end of file
diff --git a/dom/route/route.js b/dom/route/route.js
index 0b5bdc76..976435cd 100644
--- a/dom/route/route.js
+++ b/dom/route/route.js
@@ -1,4 +1,3 @@
-steal('can/route', 'jquery/event/hashchange',
-function( $ ) {
+steal('jquery', 'can/util', 'can/route', function($, can) {
$.route=can.route
})
\ No newline at end of file
diff --git a/dom/selection/selection_test.js b/dom/selection/selection_test.js
index 418e85c4..c32e66ad 100644
--- a/dom/selection/selection_test.js
+++ b/dom/selection/selection_test.js
@@ -1,4 +1,4 @@
-steal("funcunit/qunit", "jquery/dom/selection").then(function(){
+steal("jquery", "funcunit/qunit", "jquery/dom/selection").then(function($) {
module("jquery/dom/selection");
diff --git a/dom/styles/styles.js b/dom/styles/styles.js
index 797cece3..babfe151 100644
--- a/dom/styles/styles.js
+++ b/dom/styles/styles.js
@@ -1,5 +1,4 @@
-steal('jquery/dom').then(function( $ ) {
-
+steal('jquery', function( $ ) {
var getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
// The following variables are used to convert camelcased attribute names
// into dashed names, e.g. borderWidth to border-width
@@ -99,4 +98,6 @@ steal('jquery/dom').then(function( $ ) {
// Pass the arguments as an array to $.styles
return $.styles(this[0], $.makeArray(arguments));
};
+
+ return $;
});
\ No newline at end of file
diff --git a/dom/styles/styles_test.js b/dom/styles/styles_test.js
index 6dac5369..683f483c 100644
--- a/dom/styles/styles_test.js
+++ b/dom/styles/styles_test.js
@@ -1,9 +1,7 @@
-steal("jquery/dom/dimensions",'jquery/view/micro') //load your app
- .then('funcunit/qunit').then(function(){
+steal("jquery", "jquery/dom/dimensions",'jquery/view/micro', 'funcunit/qunit', function($) {
module("jquery/dom/styles");
-
test("reading", function(){
$("#qunit-test-area").html("//jquery/dom/styles/test/styles.micro",{})
diff --git a/dom/within/within.js b/dom/within/within.js
index b4858aa5..1440d17a 100644
--- a/dom/within/within.js
+++ b/dom/within/within.js
@@ -1,4 +1,4 @@
-steal('jquery/dom').then(function($){
+steal('jquery', function($) {
// Checks if x and y coordinates are within a box with left, top, width and height
var withinBox = function(x, y, left, top, width, height ){
return (y >= top &&
@@ -89,5 +89,5 @@ $.fn.withinBox = function(left, top, width, height, useOffsetCache){
});
return this.pushStack( jQuery.unique( ret ), "withinBox", jQuery.makeArray(arguments).join(",") );
}
-
+ return $;
})
diff --git a/event/default/default.js b/event/default/default.js
index 4caa9a91..9ba883df 100644
--- a/event/default/default.js
+++ b/event/default/default.js
@@ -1,5 +1,5 @@
-steal('jquery/event').then(function($){
+steal('jquery', function($){
/**
* @function jQuery.fn.triggerAsync
@@ -109,7 +109,5 @@ $event.trigger = function defaultTriggerer( event, data, elem, onlyHandlers){
return res;
};
-
-
-
+return $;
});
\ No newline at end of file
diff --git a/event/default/default_pause_test.js b/event/default/default_pause_test.js
index cb8a90f6..41cc79cf 100644
--- a/event/default/default_pause_test.js
+++ b/event/default/default_pause_test.js
@@ -1,4 +1,4 @@
-steal('funcunit/qunit','jquery/event/default','jquery/event/pause').then(function(){
+steal('jquery', 'funcunit/qunit','jquery/event/default','jquery/event/pause', function($) {
module("jquery/event/default_pause");
diff --git a/event/destroyed/destroyed.js b/event/destroyed/destroyed.js
index 6aab24ef..cb00616d 100644
--- a/event/destroyed/destroyed.js
+++ b/event/destroyed/destroyed.js
@@ -1,4 +1,4 @@
-steal('jquery/event').then(function( $ ) {
+steal('jquery', function( $ ) {
/**
* @attribute destroyed
* @download http://jmvcsite.heroku.com/pluginify?plugins[]=jquery/dom/destroyed/destroyed.js
@@ -18,5 +18,5 @@ steal('jquery/event').then(function( $ ) {
// Call the old jQuery.cleanData
oldClean(elems);
};
-
+return $;
});
\ No newline at end of file
diff --git a/event/destroyed/destroyed_test.js b/event/destroyed/destroyed_test.js
index 4fb19a96..c8bc43a0 100644
--- a/event/destroyed/destroyed_test.js
+++ b/event/destroyed/destroyed_test.js
@@ -1,6 +1,4 @@
-steal("jquery/event/destroyed") //load your app
- .then('funcunit/qunit')
- .then(function(){
+steal("jquery", "jquery/event/destroyed", 'funcunit/qunit', function($) {
module("jquery/event/destroyed")
test("removing an element", function(){
diff --git a/event/drag/drag.js b/event/drag/drag.js
index a9c61fc4..98a629f3 100644
--- a/event/drag/drag.js
+++ b/event/drag/drag.js
@@ -1,4 +1,5 @@
-steal('jquery/event', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/event/reverse', function( $ ) {
+steal('jquery', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/event/reverse', function( $ ) {
+
if(!$.event.special.move) {
$.event.reverse('move');
}
@@ -723,4 +724,6 @@ steal('jquery/event', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/eve
'dragend'], startEvent, function( e ) {
$.Drag.mousedown.call($.Drag, e, this);
});
+
+ return $;
});
diff --git a/event/drag/limit/limit.js b/event/drag/limit/limit.js
index 8b0abade..f788ee80 100644
--- a/event/drag/limit/limit.js
+++ b/event/drag/limit/limit.js
@@ -2,7 +2,7 @@
* @add jQuery.Drag.prototype
*/
-steal('jquery/event/drag', 'jquery/dom/styles').then(function( $ ) {
+steal('jquery', 'jquery/event/drag', 'jquery/dom/styles', function( $ ) {
$.Drag.prototype
@@ -75,4 +75,5 @@ steal('jquery/event/drag', 'jquery/dom/styles').then(function( $ ) {
oldPosition.call(this, offsetPositionv);
};
+ return $;
});
\ No newline at end of file
diff --git a/event/drag/scroll/scroll.js b/event/drag/scroll/scroll.js
index ecad5aa7..07250898 100644
--- a/event/drag/scroll/scroll.js
+++ b/event/drag/scroll/scroll.js
@@ -1,4 +1,4 @@
-steal("jquery/event/drop").then(function($){ //needs drop to determine if respondable
+steal("jquery", "jquery/event/drop", function($) { //needs drop to determine if respondable
/**
* @add jQuery.Drag.prototype
@@ -145,4 +145,5 @@ $.extend($.Scrollable.prototype,{
}
})
+return $;
})
\ No newline at end of file
diff --git a/event/drag/step/step.js b/event/drag/step/step.js
index a31d7e22..26b14cd9 100644
--- a/event/drag/step/step.js
+++ b/event/drag/step/step.js
@@ -2,7 +2,7 @@
* @add jQuery.Drag.prototype
*/
-steal('jquery/event/drag', 'jquery/dom/styles').then(function( $ ) {
+steal('jquery', 'jquery/event/drag', 'jquery/dom/styles', function( $ ) {
var round = function( x, m ) {
return Math.round(x / m) * m;
}
@@ -79,4 +79,5 @@ steal('jquery/event/drag', 'jquery/dom/styles').then(function( $ ) {
oldPosition.call(this, offsetPositionv)
}
+ return $;
})
\ No newline at end of file
diff --git a/event/drop/drop.js b/event/drop/drop.js
index 02c7ddac..6d831397 100644
--- a/event/drop/drop.js
+++ b/event/drop/drop.js
@@ -1,4 +1,4 @@
-steal('jquery/event/drag','jquery/dom/within','jquery/dom/compare',function($){
+steal('jquery', 'jquery/event/drag', 'jquery/dom/within', 'jquery/dom/compare', function($){
var event = $.event;
/**
* @add jQuery.event.special
@@ -444,5 +444,7 @@ steal('jquery/event/drag','jquery/dom/within','jquery/dom/compare',function($){
cancel: function() {
this._canceled = true;
}
- } )
+ });
+
+ return $;
});
\ No newline at end of file
diff --git a/event/fastfix/fastfix.js b/event/fastfix/fastfix.js
index d3ea7c7e..2f2703a5 100644
--- a/event/fastfix/fastfix.js
+++ b/event/fastfix/fastfix.js
@@ -1,4 +1,4 @@
-steal('jquery', function () {
+steal('jquery', function ($) {
// http://bitovi.com/blog/2012/04/faster-jquery-event-fix.html
// https://gist.github.com/2377196
@@ -91,4 +91,6 @@ steal('jquery', function () {
return event;
}
}
+
+ return $;
});
diff --git a/event/handle/handle.js b/event/handle/handle.js
index 49377f8e..42961301 100644
--- a/event/handle/handle.js
+++ b/event/handle/handle.js
@@ -1,4 +1,4 @@
-steal("jquery").then(function(){
+steal("jquery", function($) {
var $event = $.event,
oldTrigger = $event.trigger,
@@ -204,4 +204,6 @@ $.event.handle = function( event ) {
}
return event.result;
}
+
+ return $;
})
diff --git a/event/hashchange/hashchange.js b/event/hashchange/hashchange.js
index 2dcea54b..cda11d4b 100644
--- a/event/hashchange/hashchange.js
+++ b/event/hashchange/hashchange.js
@@ -92,7 +92,7 @@
* })
*
*/
-steal('jquery').then(function($){
+steal('jquery', function($){
'$:nomunge'; // Used by YUI compressor.
// Method / object references.
@@ -265,4 +265,6 @@ steal('jquery').then(function($){
return self;
})();
+
+ return $;
})
\ No newline at end of file
diff --git a/event/hover/hover.js b/event/hover/hover.js
index 784905a6..0f8ab54a 100644
--- a/event/hover/hover.js
+++ b/event/hover/hover.js
@@ -1,4 +1,4 @@
-steal('jquery/event','jquery/event/livehack').then(function($){
+steal('jquery', 'jquery/event/livehack', function($) {
/**
* @class jQuery.Hover
* @plugin jquery/event/hover
@@ -257,5 +257,5 @@ event.setupHelper( [
"hovermove"], "mouseenter", onmouseenter )
-
+return $;
})
\ No newline at end of file
diff --git a/event/key/key.js b/event/key/key.js
index 8e34034f..5432d1de 100644
--- a/event/key/key.js
+++ b/event/key/key.js
@@ -1,4 +1,4 @@
-steal('jquery/event').then(function($){
+steal('jquery', function($){
var keymap = {},
reverseKeyMap = {},
currentBrowser = jQuery.uaMatch(navigator.userAgent).browser;
@@ -151,5 +151,5 @@ steal('jquery/event').then(function($){
return reverseKeyMap[currentBrowser][event.keyCode+""]
}
-
+return $;
})
\ No newline at end of file
diff --git a/event/livehack/livehack.js b/event/livehack/livehack.js
index 774edf11..a873016c 100644
--- a/event/livehack/livehack.js
+++ b/event/livehack/livehack.js
@@ -1,4 +1,4 @@
-steal('jquery/event').then(function() {
+steal('jquery', function($) {
var event = jQuery.event,
diff --git a/event/move/move.js b/event/move/move.js
index 71e12beb..39db9214 100644
--- a/event/move/move.js
+++ b/event/move/move.js
@@ -1,3 +1,3 @@
-steal('jquery/event/reverse').then(function( $ ) {
+steal('jquery', 'jquery/event/reverse').then(function( $ ) {
$.event.reverse('move');
});
\ No newline at end of file
diff --git a/event/pause/pause.js b/event/pause/pause.js
index 458c5095..a8b87e7e 100644
--- a/event/pause/pause.js
+++ b/event/pause/pause.js
@@ -1,4 +1,4 @@
-steal('jquery/event/default').then(function($){
+steal('jquery', 'jquery/event/default', function($) {
var current,
@@ -84,4 +84,5 @@ $.Event.prototype.resume = function(){
};
+return $;
});
\ No newline at end of file
diff --git a/event/resize/resize.js b/event/resize/resize.js
index 2a3e54b6..86f61448 100644
--- a/event/resize/resize.js
+++ b/event/resize/resize.js
@@ -1,4 +1,4 @@
-steal('jquery/event/reverse').then(function( $ ) {
+steal('jquery', 'jquery/event/reverse').then(function( $ ) {
var
// bind on the window window resizes to happen
win = $(window),
@@ -39,4 +39,6 @@ steal('jquery/event/reverse').then(function( $ ) {
}
}
});
+
+ return $;
});
diff --git a/event/reverse/reverse.js b/event/reverse/reverse.js
index cd62965d..0f38a9b1 100644
--- a/event/reverse/reverse.js
+++ b/event/reverse/reverse.js
@@ -1,4 +1,4 @@
-steal('jquery/event').then(function( $ ) {
+steal('jquery', function( $ ) {
$.event.reverse = function(name, attributes) {
var bound = $(),
count = 0;
@@ -85,4 +85,6 @@ steal('jquery/event').then(function( $ ) {
return $.event.special[name];
}
+
+ return $;
})
\ No newline at end of file
diff --git a/event/selection/selection.js b/event/selection/selection.js
index 5f874867..b3cb8593 100644
--- a/event/selection/selection.js
+++ b/event/selection/selection.js
@@ -1,6 +1,6 @@
// a text selection event that is useful in mobile safari
-steal('jquery/dom/range', 'jquery/event/livehack').then(function($){
+steal('jquery', 'jquery/dom/range', 'jquery/event/livehack', function($){
var event = $.event;
@@ -92,5 +92,6 @@ steal('jquery/dom/range', 'jquery/event/livehack').then(function($){
$(delegate).bind('mousemove', mousemove)
.bind('mouseup',mouseup)
});
-
+
+ return $;
});
\ No newline at end of file
diff --git a/event/swipe/swipe.js b/event/swipe/swipe.js
index 256cf573..381f32a1 100644
--- a/event/swipe/swipe.js
+++ b/event/swipe/swipe.js
@@ -1,4 +1,4 @@
-steal('jquery/event/livehack').then(function($){
+steal('jquery', 'jquery/event/livehack', function($) {
var isPhantom = /Phantom/.test(navigator.userAgent),
supportTouch = !isPhantom && "ontouchend" in document,
scrollEvent = "touchmove scroll",
@@ -125,4 +125,5 @@ $.event.setupHelper( [
})
});
+return $;
});
diff --git a/event/tap/tap.js b/event/tap/tap.js
index 91228123..502ecc13 100644
--- a/event/tap/tap.js
+++ b/event/tap/tap.js
@@ -1,4 +1,4 @@
-steal('jquery/event/livehack').then(function($){
+steal('jquery', 'jquery/event/livehack', function($){
var supportTouch = "ontouchend" in document,
scrollEvent = "touchmove scroll",
touchStartEvent = supportTouch ? "touchstart" : "mousedown",
@@ -48,4 +48,5 @@ $.event.setupHelper( ["tap"], touchStartEvent, function(ev){
});
+ return $;
});
\ No newline at end of file
diff --git a/jquery.js b/jquery.js
deleted file mode 100644
index 4abd6777..00000000
--- a/jquery.js
+++ /dev/null
@@ -1 +0,0 @@
-steal('can/util/jquery/jquery.1.7.1.js')
diff --git a/lang/json/json.js b/lang/json/json.js
index 3c6457d8..8d74b29c 100644
--- a/lang/json/json.js
+++ b/lang/json/json.js
@@ -15,7 +15,7 @@
*/
//
- steal('jquery',function($){
+ steal('jquery', function($) {
/**
* @page jQuery.toJSON jQuery.toJSON
* @parent jquerymx.lang
diff --git a/model/model.js b/model/model.js
index 27182cfd..9c5efbbf 100644
--- a/model/model.js
+++ b/model/model.js
@@ -1,5 +1,5 @@
/*global OpenAjax: true */
-steal('jquery/class', 'can/model','can/observe/attributes','can/observe/setter','can/model/elements', function(){
- $.Model = can.Model
+steal('jquery', 'can/util', 'can/model','can/observe/attributes','can/observe/setter','can/model/elements', function($, can){
+ $.Model = can.Model;
});
diff --git a/model/test/qunit/model_test.js b/model/test/qunit/model_test.js
index cbb2a7b6..dc7c51d5 100644
--- a/model/test/qunit/model_test.js
+++ b/model/test/qunit/model_test.js
@@ -1,4 +1,5 @@
-module("jquery/model", {
+steal('can/util', 'jquery', 'jquery/model', function(can, $) {
+module("jquery/model", {
setup: function() {
var ids = 0;
$.Model("Person",{
@@ -98,7 +99,7 @@ test("save deferred", function(){
type : 'post',
dataType : "json",
fixture: function(){
- return [{id: 5}]
+ return {id: 5}
},
success : success
})
@@ -111,8 +112,8 @@ test("save deferred", function(){
stop();
personD.then(function(person){
start()
+ console.log(person)
equals(person.id, 5, "we got an id")
-
});
});
@@ -127,7 +128,7 @@ test("update deferred", function(){
type : 'post',
dataType : "json",
fixture: function(){
- return [{thing: "er"}]
+ return {thing: "er"}
},
success : success
})
@@ -155,7 +156,7 @@ test("destroy deferred", function(){
type : 'post',
dataType : "json",
fixture: function(){
- return [{thing: "er"}]
+ return {thing: "er"}
},
success : success
})
@@ -457,13 +458,13 @@ test("save error args", function(){
})
var st = '{type: "unauthorized"}';
- $.fixture("/testinmodelsfoos.json", function(){
- return [401,st]
+ $.fixture("/testinmodelsfoos.json", function(headers, respond) {
+ respond(401,st);
});
stop();
- var inst = new Foo({}).save(function(){
+ var inst = new Foo({}).save().done(function(){
ok(false, "success should not be called")
- }, function(jQXHR){
+ }).fail(function(jQXHR){
ok(true, "error called")
ok(jQXHR.getResponseHeader,"jQXHR object")
start()
@@ -571,6 +572,4 @@ test("object definitions", function(){
start();
})
})
-
-
-
+})
\ No newline at end of file
diff --git a/test/test.js b/test/test.js
index b09937ba..ece73b79 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,24 +1,24 @@
(function(){
-steal(
- // 'jquery/dom/animate/animate_test.js',
- 'jquery/dom/compare/compare_test.js',
- 'jquery/dom/dimensions/dimensions_test.js',
- 'jquery/dom/form_params/form_params_test.js',
- 'jquery/dom/styles/styles_test.js',
- // 'jquery/event/fastfix/fastfix_test.js',
- 'jquery/event/default/default_test.js',
- 'jquery/event/default/default_pause_test.js',
- 'jquery/event/destroyed/destroyed_test.js',
- 'jquery/event/drag/drag_test.js',
- 'jquery/event/drop/drop_test.js',
- 'jquery/event/hover/hover_test.js',
- 'jquery/event/key/key_test.js',
- 'jquery/event/pause/pause_test.js',
- 'jquery/event/reverse/reverse_test.js',
- 'jquery/event/resize/resize_test.js',
- 'jquery/event/swipe/swipe_test.js',
- 'jquery/lang/lang_test.js'
-)
-// .then('./qunit/jmvc.js');
+//steal(
+// // 'jquery/dom/animate/animate_test.js',
+// 'jquery/dom/compare/compare_test.js',
+// 'jquery/dom/dimensions/dimensions_test.js',
+// 'jquery/dom/form_params/form_params_test.js',
+// 'jquery/dom/styles/styles_test.js',
+// // 'jquery/event/fastfix/fastfix_test.js',
+// 'jquery/event/default/default_test.js',
+// 'jquery/event/default/default_pause_test.js',
+// 'jquery/event/destroyed/destroyed_test.js',
+// 'jquery/event/drag/drag_test.js',
+// 'jquery/event/drop/drop_test.js',
+// 'jquery/event/hover/hover_test.js',
+// 'jquery/event/key/key_test.js',
+// 'jquery/event/pause/pause_test.js',
+// 'jquery/event/reverse/reverse_test.js',
+// 'jquery/event/resize/resize_test.js',
+// 'jquery/event/swipe/swipe_test.js',
+// 'jquery/lang/lang_test.js'
+//)
+steal('./qunit/jmvc.js');
})();
diff --git a/view/ejs/ejs.js b/view/ejs/ejs.js
index d87fae52..81c131ce 100644
--- a/view/ejs/ejs.js
+++ b/view/ejs/ejs.js
@@ -1,4 +1,4 @@
/*jslint evil: true */
-steal('jquery/view', 'can/view/ejs', function($){
+steal('jquery', 'can/util', 'jquery/view', 'can/view/ejs', function($, can){
$.EJS = can.EJS;
});
\ No newline at end of file
diff --git a/view/micro/micro.js b/view/micro/micro.js
index 581c5ff0..c900bf5a 100644
--- a/view/micro/micro.js
+++ b/view/micro/micro.js
@@ -1,81 +1,3 @@
-steal('jquery/view').then(function(){
-// Simple JavaScript Templating
-// John Resig - http://ejohn.org/ - MIT Licensed
-
- var cache = {};
- /**
- * @function Micro
- * @parent jQuery.View
- * @plugin jquery/view/micro
- * A very lightweight template engine.
- * Magic tags look like:
- *
- * @codestart
- *
{%= message %}
- * @codeend
- *
- * Micro is integrated in JavaScriptMVC so
- * you can use it like:
- *
- * @codestart
- * $("#foo").html('//app/views/bar.micro',{});
- * @codeend
- *
- * ## Pros
- *
- * - Very Lightweight
- *
- * ## Cons
- *
- * - Doesn't handle nested tags.
- * - Doesn't handle {%= "%}" %}.
- * - More difficult to debug.
- * - Removes newlines and tabs.
- *
- * ## Use
- *
- * For more information on micro, see John Resig's
- * [http://ejohn.org/blog/javascript-micro-templating/ write up].
- *
- * @param {String} str template content.
- * @param {Object} data render's the template with this content.
- */
- function Micro(str, data){
- var body =
- "var p=[],print=function(){p.push.apply(p,arguments);};" +
-
- // Introduce the data as local variables using with(){}
- "with(obj){p.push('" +
-
- // Convert the template into pure JavaScript
- str.replace(/[\r\t\n]/g, " ")
- .replace(/'(?=[^%]*%})/g,"\t")
- .split("'").join("\\'")
- .split("\t").join("'")
- .replace(/{%=(.+?)%}/g, "',$1,'")
- .split("{%").join("');")
- .split("%}").join("p.push('")+ "');}return p.join('');"
-
- var fn = new Function("obj",body);
- fn.body = body;
-
- // Provide some basic currying to the user
- return data ? fn( data ) : fn;
- };
-
- $.View.register({
- suffix : "micro",
- renderer: function( id, text ) {
- var mt = Micro(text)
- return function(data){
- return mt(data)
- }
- },
- script: function( id, str ) {
- return "function(obj){"+Micro(str).body+"}";
- }
- })
- jQuery.View.ext = ".micro"
-
-
-});
\ No newline at end of file
+steal('jquery', 'jquery/view', 'can/view/micro', function($) {
+ return $;
+});
diff --git a/view/tmpl/tmpl.js b/view/tmpl/tmpl.js
index 377474df..393279ea 100644
--- a/view/tmpl/tmpl.js
+++ b/view/tmpl/tmpl.js
@@ -3,29 +3,29 @@
//
// Copyright Software Freedom Conservancy, Inc.
// Dual licensed under the MIT or GPL Version 2 licenses.
-// http://jquery.org/license
+// http://$.org/license
/**
- * @class jQuery.tmpl
- * @parent jQuery.View
+ * @class $.tmpl
+ * @parent $.View
* @plugin jquery/view/tmpl
* Provides basic templating with magic tags that look like:
* @codestart
* ${value}
* @codeend
- * [jQuery.View] integrates jQuery.tmpl templates into
- * your build process. You can use a jQuery.tmpl like:
+ * [$.View] integrates $.tmpl templates into
+ * your build process. You can use a $.tmpl like:
*
* @codestart
* $('#area').html('//path/to/template.tmpl',{ data });
* @codeend
*
- * For more information on jQuery.tmpl read
- * [http://api.jquery.com/category/plugins/templates/ it's documentation].
+ * For more information on $.tmpl read
+ * [http://api.$.com/category/plugins/templates/ it's documentation].
*/
-steal('jquery/view').then(function(){
+steal('jquery', 'can/util', 'jquery/view').then(function($, can){
// Override the DOM manipulation function
- var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
+ var oldManip = $.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
function newTmplItem( options, parentItem, fn, data ) {
@@ -45,7 +45,7 @@ steal('jquery/view').then(function(){
update: tiUpdate
};
if ( options ) {
- jQuery.extend( newItem, options, { nodes: [], parent: parentItem } );
+ $.extend( newItem, options, { nodes: [], parent: parentItem } );
}
if ( fn ) {
// Build the hierarchical content to be used during insertion into DOM
@@ -59,14 +59,14 @@ steal('jquery/view').then(function(){
}
// Override appendTo etc., in order to provide support for targeting multiple elements. (This code would disappear if integrated in jquery core).
- jQuery.each({
+ $.each({
appendTo: "append",
prependTo: "prepend",
insertBefore: "before",
insertAfter: "after",
replaceAll: "replaceWith"
}, function( name, original ) {
- jQuery.fn[ name ] = function( selector ) {
+ $.fn[ name ] = function( selector ) {
var ret = [], insert = jQuery( selector ), elems, i, l, tmplItems,
parent = this.length === 1 && this[0].parentNode;
@@ -78,7 +78,7 @@ steal('jquery/view').then(function(){
for ( i = 0, l = insert.length; i < l; i++ ) {
cloneIndex = i;
elems = (i > 0 ? this.clone(true) : this).get();
- jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
+ $.fn[ original ].apply( jQuery(insert[i]), elems );
ret = ret.concat( elems );
}
cloneIndex = 0;
@@ -86,41 +86,41 @@ steal('jquery/view').then(function(){
}
tmplItems = appendToTmplItems;
appendToTmplItems = null;
- jQuery.tmpl.complete( tmplItems );
+ $.tmpl.complete( tmplItems );
return ret;
};
});
- jQuery.fn.extend({
+ $.fn.extend({
// Use first wrapped element as template markup.
// Return wrapped set of template items, obtained by rendering template against data.
tmpl: function( data, options, parentItem ) {
- return jQuery.tmpl( this[0], data, options, parentItem );
+ return $.tmpl( this[0], data, options, parentItem );
},
// Find which rendered template item the first wrapped DOM element belongs to
tmplItem: function() {
- return jQuery.tmplItem( this[0] );
+ return $.tmplItem( this[0] );
},
// Consider the first wrapped element as a template declaration, and get the compiled template or store it as a named template.
template: function( name ) {
- return jQuery.template( name, this[0] );
+ return $.template( name, this[0] );
},
domManip: function( args, table, callback, options ) {
// This appears to be a bug in the appendTo, etc. implementation
// it should be doing .call() instead of .apply(). See #6227
if ( args[0] && args[0].nodeType ) {
- var dmArgs = jQuery.makeArray( arguments ), argsLength = args.length, i = 0, tmplItem;
- while ( i < argsLength && !(tmplItem = jQuery.data( args[i++], "tmplItem" ))) {}
+ var dmArgs = $.makeArray( arguments ), argsLength = args.length, i = 0, tmplItem;
+ while ( i < argsLength && !(tmplItem = $.data( args[i++], "tmplItem" ))) {}
if ( argsLength > 1 ) {
- dmArgs[0] = [jQuery.makeArray( args )];
+ dmArgs[0] = [$.makeArray( args )];
}
if ( tmplItem && cloneIndex ) {
dmArgs[2] = function( fragClone ) {
// Handler called by oldManip when rendered template has been inserted into DOM.
- jQuery.tmpl.afterManip( this, fragClone, callback );
+ $.tmpl.afterManip( this, fragClone, callback );
};
}
oldManip.apply( this, dmArgs );
@@ -129,20 +129,20 @@ steal('jquery/view').then(function(){
}
cloneIndex = 0;
if ( !appendToTmplItems ) {
- jQuery.tmpl.complete( newTmplItems );
+ $.tmpl.complete( newTmplItems );
}
return this;
}
});
- jQuery.extend({
+ $.extend({
// Return wrapped set of template items, obtained by rendering template against data.
tmpl: function( tmpl, data, options, parentItem ) {
var ret, topLevel = !parentItem;
if ( topLevel ) {
// This is a top-level tmpl call (not from a nested template using {{tmpl}})
parentItem = topTmplItem;
- tmpl = jQuery.template[tmpl] || jQuery.template( null, tmpl );
+ tmpl = $.template[tmpl] || $.template( null, tmpl );
wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level
} else if ( !tmpl ) {
// The template item is already associated with DOM - this is a refresh.
@@ -165,8 +165,8 @@ steal('jquery/view').then(function(){
if ( options && options.wrapped ) {
updateWrapped( options, options.wrapped );
}
- ret = jQuery.isArray( data ) ?
- jQuery.map( data, function( dataItem ) {
+ ret = $.isArray( data ) ?
+ $.map( data, function( dataItem ) {
return dataItem ? newTmplItem( options, parentItem, tmpl, dataItem ) : null;
}) :
[ newTmplItem( options, parentItem, tmpl, data ) ];
@@ -179,7 +179,7 @@ steal('jquery/view').then(function(){
if ( elem instanceof jQuery ) {
elem = elem[0];
}
- while ( elem && elem.nodeType === 1 && !(tmplItem = jQuery.data( elem, "tmplItem" )) && (elem = elem.parentNode) ) {}
+ while ( elem && elem.nodeType === 1 && !(tmplItem = $.data( elem, "tmplItem" )) && (elem = elem.parentNode) ) {}
return tmplItem || topTmplItem;
},
@@ -205,15 +205,15 @@ steal('jquery/view').then(function(){
}
if ( tmpl.nodeType ) {
// If this is a template block, use cached copy, or generate tmpl function and cache.
- tmpl = jQuery.data( tmpl, "tmpl" ) || jQuery.data( tmpl, "tmpl", buildTmplFn( tmpl.innerHTML ));
+ tmpl = $.data( tmpl, "tmpl" ) || $.data( tmpl, "tmpl", buildTmplFn( tmpl.innerHTML ));
}
- return typeof name === "string" ? (jQuery.template[name] = tmpl) : tmpl;
+ return typeof name === "string" ? ($.template[name] = tmpl) : tmpl;
}
// Return named compiled template
- return name ? (typeof name !== "string" ? jQuery.template( null, name ):
- (jQuery.template[name] ||
+ return name ? (typeof name !== "string" ? $.template( null, name ):
+ ($.template[name] ||
// If not in map, treat as a selector. (If integrated with core, use quickExpr.exec)
- jQuery.template( null, htmlExpr.test( name ) ? name : jQuery( name )))) : null;
+ $.template( null, htmlExpr.test( name ) ? name : jQuery( name )))) : null;
},
encode: function( text ) {
@@ -222,7 +222,7 @@ steal('jquery/view').then(function(){
}
});
- jQuery.extend( jQuery.tmpl, {
+ $.extend( $.tmpl, {
tag: {
"tmpl": {
_default: { $2: "null" },
@@ -264,7 +264,7 @@ steal('jquery/view').then(function(){
}
},
- // This stub can be overridden, e.g. in jquery.tmplPlus for providing rendered events
+ // This stub can be overridden, e.g. in $.tmplPlus for providing rendered events
complete: function( items ) {
newTmplItems = {};
},
@@ -274,13 +274,13 @@ steal('jquery/view').then(function(){
afterManip: function afterManip( elem, fragClone, callback ) {
// Provides cloned fragment ready for fixup prior to and after insertion into DOM
var content = fragClone.nodeType === 11 ?
- jQuery.makeArray(fragClone.childNodes) :
+ $.makeArray(fragClone.childNodes) :
fragClone.nodeType === 1 ? [fragClone] : [];
// Return fragment to original caller (e.g. append) for DOM insertion
callback.call( elem, fragClone );
- // Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by jQuery.data.
+ // Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by $.data.
storeTmplItems( content );
cloneIndex++;
}
@@ -291,9 +291,9 @@ steal('jquery/view').then(function(){
function build( tmplItem, nested, content ) {
// Convert hierarchical content into flat string array
// and finally return array of fragments ready for DOM insertion
- var frag, ret = content ? jQuery.map( content, function( item ) {
+ var frag, ret = content ? $.map( content, function( item ) {
return (typeof item === "string") ?
- // Insert template item annotations, to be converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
+ // Insert template item annotations, to be converted to $.data( "tmplItem" ) when elems are inserted into DOM.
(tmplItem.key ? item.replace( /(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" + tmplItem.key + "\" $2" ) : item) :
// This is a child template item. Build nested template.
build( item, tmplItem, item._ctnt );
@@ -327,7 +327,7 @@ steal('jquery/view').then(function(){
// Use createElement, since createTextNode will not render HTML entities correctly
var el = document.createElement( "div" );
el.innerHTML = text;
- return jQuery.makeArray(el.childNodes);
+ return $.makeArray(el.childNodes);
}
// Generate a reusable function that will serve to render a template against data
@@ -339,13 +339,13 @@ steal('jquery/view').then(function(){
"with($data){_.push('" +
// Convert the template into pure JavaScript
- jQuery.trim(markup)
+ $.trim(markup)
.replace( /([\\'])/g, "\\$1" )
.replace( /[\r\t\n]/g, " " )
.replace( /\$\{([^\}]*)\}/g, "{{= $1}}" )
.replace( /\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
function( all, slash, type, fnargs, target, parens, args ) {
- var tag = jQuery.tmpl.tag[ type ], def, expr, exprAutoFnDetect;
+ var tag = $.tmpl.tag[ type ], def, expr, exprAutoFnDetect;
if ( !tag ) {
throw "Template command not found: " + type;
}
@@ -386,7 +386,7 @@ steal('jquery/view').then(function(){
// Build the wrapped content.
options._wrap = build( options, true,
// Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.
- jQuery.isArray( wrapped ) ? wrapped : [htmlExpr.test( wrapped ) ? wrapped : jQuery( wrapped ).html()]
+ $.isArray( wrapped ) ? wrapped : [htmlExpr.test( wrapped ) ? wrapped : jQuery( wrapped ).html()]
).join("");
}
@@ -399,7 +399,7 @@ steal('jquery/view').then(function(){
return div.innerHTML;
}
- // Store template items in jQuery.data(), ensuring a unique tmplItem data data structure for each rendered template instance.
+ // Store template items in $.data(), ensuring a unique tmplItem data data structure for each rendered template instance.
function storeTmplItems( content ) {
var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
for ( i = 0, l = content.length; i < l; i++ ) {
@@ -434,12 +434,12 @@ steal('jquery/view').then(function(){
}
}
el.removeAttribute( tmplItmAtt );
- } else if ( cloneIndex && (tmplItem = jQuery.data( el, "tmplItem" )) ) {
+ } else if ( cloneIndex && (tmplItem = $.data( el, "tmplItem" )) ) {
// This was a rendered element, cloned during append or appendTo etc.
// TmplItem stored in jQuery data has already been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.
cloneTmplItem( tmplItem.key );
newTmplItems[tmplItem.key] = tmplItem;
- pntNode = jQuery.data( el.parentNode, "tmplItem" );
+ pntNode = $.data( el.parentNode, "tmplItem" );
pntNode = pntNode ? pntNode.key : 0;
}
if ( tmplItem ) {
@@ -456,7 +456,7 @@ steal('jquery/view').then(function(){
delete tmplItem._ctnt;
delete tmplItem._wrap;
// Store template item as jQuery data on the element
- jQuery.data( el, "tmplItem", tmplItem );
+ $.data( el, "tmplItem", tmplItem );
}
function cloneTmplItem( key ) {
key = key + keySuffix;
@@ -477,7 +477,7 @@ steal('jquery/view').then(function(){
function tiNest( tmpl, data, options ) {
// nested template, using {{tmpl}} tag
- return jQuery.tmpl( jQuery.template( tmpl ), data, options, this );
+ return $.tmpl( $.template( tmpl ), data, options, this );
}
function tiWrap( call, wrapped ) {
@@ -485,13 +485,13 @@ steal('jquery/view').then(function(){
var options = call.options || {};
options.wrapped = wrapped;
// Apply the template, which may incorporate wrapped content,
- return jQuery.tmpl( jQuery.template( call.tmpl ), call.data, options, call.item );
+ return $.tmpl( $.template( call.tmpl ), call.data, options, call.item );
}
function tiHtml( filter, textOnly ) {
var wrapped = this._wrap;
- return jQuery.map(
- jQuery( jQuery.isArray( wrapped ) ? wrapped.join("") : wrapped ).filter( filter || "*" ),
+ return $.map(
+ jQuery( $.isArray( wrapped ) ? wrapped.join("") : wrapped ).filter( filter || "*" ),
function(e) {
return textOnly ?
e.innerText || e.textContent :
@@ -501,7 +501,7 @@ steal('jquery/view').then(function(){
function tiUpdate() {
var coll = this.nodes;
- jQuery.tmpl( null, null, null, this).insertBefore( coll[0] );
+ $.tmpl( null, null, null, this).insertBefore( coll[0] );
jQuery( coll ).remove();
}
@@ -511,7 +511,7 @@ steal('jquery/view').then(function(){
var tmpl = $.template( null, text );
return function(data){
return tmpl.call($, $, {data: data}).join('');
- //$(text).tmpl(data);//jQuery.render( text, data );
+ //$(text).tmpl(data);//$.render( text, data );
};
},
script: function( id, str ) {
@@ -519,5 +519,5 @@ steal('jquery/view').then(function(){
return "function(data){return ("+tmpl+").call(jQuery, jQuery, {data: data}).join(''); }";
}
})
- jQuery.View.ext = ".tmpl"
+ $.View.ext = ".tmpl"
})
diff --git a/view/view.js b/view/view.js
index e748ab4b..5a27d973 100644
--- a/view/view.js
+++ b/view/view.js
@@ -1,3 +1,4 @@
-steal("can/view/modifiers",function(){
+steal("jquery", "can/util", "can/view", "can/view/modifiers",function($, can) {
$.View = can.view;
+ return $;
});
From 411273bcce6f57d50d543b4a4972bcd0dd929b5e Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Wed, 25 Jul 2012 10:32:46 -0600
Subject: [PATCH 002/152] All included tests passing with new Steal API
---
lang/observe/observe.js | 3 +--
test/qunit/jmvc.js | 14 +++++++-------
test/qunit/qunit.js | 39 -------------------------------------
test/test.js | 43 ++++++++++++++++++++---------------------
4 files changed, 29 insertions(+), 70 deletions(-)
delete mode 100644 test/qunit/qunit.js
diff --git a/lang/observe/observe.js b/lang/observe/observe.js
index 8073e2dc..c9028b62 100644
--- a/lang/observe/observe.js
+++ b/lang/observe/observe.js
@@ -1,4 +1,3 @@
-steal('jquery/class','can/observe').then(function() {
+steal('jquery', 'can/util','can/observe').then(function($, can) {
$.Observe = can.Observe;
-
});
diff --git a/test/qunit/jmvc.js b/test/qunit/jmvc.js
index c2c3417c..9c461107 100644
--- a/test/qunit/jmvc.js
+++ b/test/qunit/jmvc.js
@@ -1,8 +1,8 @@
// Tests for the JavaScriptMVC compatibility layer. Will be removed eventually
-steal('funcunit/qunit').then('jquery/controller/view/test/qunit')
- .then('jquery/class/class_test.js')
- .then('jquery/model/test/qunit')
- .then('jquery/controller/controller_test.js')
- .then('jquery/view/test/qunit')
- .then('jquery/dom/route/route_test.js')
- .then('./integration.js')
\ No newline at end of file
+steal('funcunit/qunit', 'jquery/controller/view/test/qunit'
+ , 'jquery/class/class_test.js'
+ , 'jquery/model/test/qunit'
+ , 'jquery/controller/controller_test.js'
+ , 'jquery/view/test/qunit'
+ , 'jquery/dom/route/route_test.js'
+ , './integration.js');
\ No newline at end of file
diff --git a/test/qunit/qunit.js b/test/qunit/qunit.js
deleted file mode 100644
index 15fc3338..00000000
--- a/test/qunit/qunit.js
+++ /dev/null
@@ -1,39 +0,0 @@
-(function(){
- var isReady,
- stateAfterScript;
-
-//we probably have to have this only describing where the tests are
-steal('jquery').then(function(){
- $(function(){
- isReady = true;
- })
-})
-.then('jquery/event/default/default_test.js',
- 'jquery/event/default/default_pause_test.js',
- 'jquery/dom/animate/animate_test.js',
- 'jquery/dom/compare/compare_test.js',
- 'jquery/dom/compare/compare_test.js',
- 'jquery/dom/dimensions/dimensions_test.js',
- 'jquery/dom/form_params/form_params_test.js',
- 'jquery/dom/styles/styles_test.js',
- 'jquery/event/destroyed/destroyed_test.js',
- 'jquery/event/drag/drag_test.js',
- 'jquery/event/drop/drop_test.js',
- 'jquery/event/hover/hover_test.js',
- 'jquery/event/fastfix/fastfix_test.js',
- 'jquery/event/key/key_test.js',
- 'jquery/event/pause/pause_test.js',
- 'jquery/event/resize/resize_test.js',
- 'jquery/event/swipe/swipe_test.js',
- 'jquery/lang/lang_test.js'
-)
-.then('./jmvc.js')
-.then(function(){
- stateAfterScript = isReady;
- module('jquery v steal');
- test("jquery isn't ready", function(){
- ok(!stateAfterScript, "jQuery isn't ready yet")
- });
-});
-
-})();
diff --git a/test/test.js b/test/test.js
index ece73b79..7808cb58 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,24 +1,23 @@
(function(){
-//steal(
-// // 'jquery/dom/animate/animate_test.js',
-// 'jquery/dom/compare/compare_test.js',
-// 'jquery/dom/dimensions/dimensions_test.js',
-// 'jquery/dom/form_params/form_params_test.js',
-// 'jquery/dom/styles/styles_test.js',
-// // 'jquery/event/fastfix/fastfix_test.js',
-// 'jquery/event/default/default_test.js',
-// 'jquery/event/default/default_pause_test.js',
-// 'jquery/event/destroyed/destroyed_test.js',
-// 'jquery/event/drag/drag_test.js',
-// 'jquery/event/drop/drop_test.js',
-// 'jquery/event/hover/hover_test.js',
-// 'jquery/event/key/key_test.js',
-// 'jquery/event/pause/pause_test.js',
-// 'jquery/event/reverse/reverse_test.js',
-// 'jquery/event/resize/resize_test.js',
-// 'jquery/event/swipe/swipe_test.js',
-// 'jquery/lang/lang_test.js'
-//)
-steal('./qunit/jmvc.js');
-
+steal(
+// 'jquery/dom/animate/animate_test.js'
+// , 'jquery/event/fastfix/fastfix_test.js'
+ 'jquery/dom/compare/compare_test.js'
+ , 'jquery/dom/dimensions/dimensions_test.js'
+ , 'jquery/dom/form_params/form_params_test.js'
+ , 'jquery/dom/styles/styles_test.js'
+ , 'jquery/event/default/default_test.js'
+ , 'jquery/event/default/default_pause_test.js'
+ , 'jquery/event/destroyed/destroyed_test.js'
+ , 'jquery/event/drag/drag_test.js'
+ , 'jquery/event/drop/drop_test.js'
+ , 'jquery/event/hover/hover_test.js'
+ , 'jquery/event/key/key_test.js'
+ , 'jquery/event/pause/pause_test.js'
+ , 'jquery/event/reverse/reverse_test.js'
+ , 'jquery/event/resize/resize_test.js'
+ , 'jquery/event/swipe/swipe_test.js'
+ , 'jquery/lang/lang_test.js'
+ , './qunit/jmvc.js'
+);
})();
From 4170a68f8e181bda1e2988df1ebbff64a6c7f163 Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Wed, 25 Jul 2012 15:01:43 -0600
Subject: [PATCH 003/152] Changing steal.root to steal.config().root
---
model/test/qunit/model_test.js | 10 +++++-----
view/helpers/helpers.js | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/model/test/qunit/model_test.js b/model/test/qunit/model_test.js
index dc7c51d5..152843ae 100644
--- a/model/test/qunit/model_test.js
+++ b/model/test/qunit/model_test.js
@@ -277,10 +277,10 @@ test("auto methods",function(){
//turn off fixtures
$.fixture.on = false;
var School = $.Model.extend("Jquery.Model.Models.School",{
- findAll : steal.root.join("jquery/model/test")+"/{type}.json",
- findOne : steal.root.join("jquery/model/test")+"/{id}.json",
- create : steal.root.join("jquery/model/test")+"/create.json",
- update : "POST "+steal.root.join("jquery/model/test")+"/update{id}.json"
+ findAll : steal.config().root.join("jquery/model/test")+"/{type}.json",
+ findOne : steal.config().root.join("jquery/model/test")+"/{id}.json",
+ create : steal.config().root.join("jquery/model/test")+"/create.json",
+ update : "POST "+steal.config().root.join("jquery/model/test")+"/update{id}.json"
},{})
stop();
School.findAll({type:"schools"}, function(schools){
@@ -318,7 +318,7 @@ test("isNew", function(){
test("findAll string", function(){
$.fixture.on = false;
$.Model("Test.Thing",{
- findAll : steal.root.join("jquery/model/test/qunit/findAll.json")+''
+ findAll : steal.config().root.join("jquery/model/test/qunit/findAll.json")+''
},{});
stop();
Test.Thing.findAll({},function(things){
diff --git a/view/helpers/helpers.js b/view/helpers/helpers.js
index 478046eb..93554d84 100644
--- a/view/helpers/helpers.js
+++ b/view/helpers/helpers.js
@@ -315,7 +315,7 @@ $.extend($.EJS.Helpers.prototype, {
*/
img_tag: function( image_location, options ) {
options = options || {};
- options.src = steal.root.join("resources/images/"+image_location)+'';
+ options.src = steal.config().root.join("resources/images/"+image_location)+'';
return this.single_tag_for('img', options);
}
From 84c2fa2c6310419c06781bdfc13a2dc4bdb47ade Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Thu, 26 Jul 2012 14:41:28 -0600
Subject: [PATCH 004/152] Working with update FuncUnit
---
event/drop/drop_test.js | 17 +++++++++--------
test/test.js | 2 +-
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/event/drop/drop_test.js b/event/drop/drop_test.js
index a894dd55..c055150c 100644
--- a/event/drop/drop_test.js
+++ b/event/drop/drop_test.js
@@ -1,4 +1,5 @@
-steal('funcunit','funcunit/syn').then(function(){
+steal("jquery/event/drop",'funcunit/syn') //load your app
+ .then('funcunit/qunit', function() {
module("jquery/event/drop");
@@ -8,7 +9,7 @@ test("new drop added",2, function(){
""+
""+
"");
-
+
div.appendTo($("#qunit-test-area"));
var basicCss = {
width: "20px",
@@ -19,12 +20,12 @@ test("new drop added",2, function(){
$("#drag").css(basicCss).css({top: "0px", left: "0px", zIndex: 1000, backgroundColor: "red"})
$("#midpoint").css(basicCss).css({top: "0px", left: "30px"})
$("#drop").css(basicCss).css({top: "0px", left: "60px"});
-
+
$('#drag').bind("draginit", function(){});
-
+
$("#midpoint").bind("dropover",function(){
ok(true, "midpoint called");
-
+
$("#drop").bind("dropover", function(){
ok(true, "drop called");
});
@@ -35,7 +36,7 @@ test("new drop added",2, function(){
start();
});
});
-
-
-
+
+
+
})
diff --git a/test/test.js b/test/test.js
index 7808cb58..b9881bae 100644
--- a/test/test.js
+++ b/test/test.js
@@ -10,7 +10,7 @@ steal(
, 'jquery/event/default/default_pause_test.js'
, 'jquery/event/destroyed/destroyed_test.js'
, 'jquery/event/drag/drag_test.js'
- , 'jquery/event/drop/drop_test.js'
+ ,'jquery/event/drop/drop_test.js'
, 'jquery/event/hover/hover_test.js'
, 'jquery/event/key/key_test.js'
, 'jquery/event/pause/pause_test.js'
From fc8f3b3c6ec941e5a50fda4c8c7f6d50d4abea9c Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Mon, 30 Jul 2012 09:23:17 -0600
Subject: [PATCH 005/152] All jQuery++ plugins return $, fix model_test
---
dom/animate/animate.js | 2 ++
dom/closest/closest.js | 2 ++
dom/compare/compare.js | 1 +
dom/cookie/cookie.js | 1 +
dom/dimensions/dimensions.js | 1 +
dom/selection/selection.js | 1 +
dom/within/within.js | 3 ++-
event/hashchange/hashchange.js | 2 +-
event/livehack/livehack.js | 2 ++
event/move/move.js | 1 +
event/tap/tap.js | 2 +-
model/test/qunit/model_test.js | 3 ++-
12 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/dom/animate/animate.js b/dom/animate/animate.js
index 282af608..dd1b2602 100644
--- a/dom/animate/animate.js
+++ b/dom/animate/animate.js
@@ -318,4 +318,6 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
return this;
};
+
+ return $;
});
diff --git a/dom/closest/closest.js b/dom/closest/closest.js
index e6118da2..4460647b 100644
--- a/dom/closest/closest.js
+++ b/dom/closest/closest.js
@@ -45,4 +45,6 @@ steal('jquery', function($) {
}
return res;
}
+
+ return $;
})
\ No newline at end of file
diff --git a/dom/compare/compare.js b/dom/compare/compare.js
index a90596c8..ee81f442 100644
--- a/dom/compare/compare.js
+++ b/dom/compare/compare.js
@@ -71,4 +71,5 @@ jQuery.fn.compare = function(element){ //usually
return number;
}
+return $;
});
\ No newline at end of file
diff --git a/dom/cookie/cookie.js b/dom/cookie/cookie.js
index 5c49ce03..c4b0035b 100644
--- a/dom/cookie/cookie.js
+++ b/dom/cookie/cookie.js
@@ -110,4 +110,5 @@ steal('jquery', 'jquery/lang/json', function($) {
}
};
+ return $;
});
diff --git a/dom/dimensions/dimensions.js b/dom/dimensions/dimensions.js
index 95f5c97f..a752bec6 100644
--- a/dom/dimensions/dimensions.js
+++ b/dom/dimensions/dimensions.js
@@ -184,4 +184,5 @@ height:
})
+return $;
})
diff --git a/dom/selection/selection.js b/dom/selection/selection.js
index ea24ec9c..3e5496f1 100644
--- a/dom/selection/selection.js
+++ b/dom/selection/selection.js
@@ -223,4 +223,5 @@ $.fn.selection = function(start, end){
// for testing
$.fn.selection.getCharElement = getCharElement;
+return $;
});
\ No newline at end of file
diff --git a/dom/within/within.js b/dom/within/within.js
index 1440d17a..22e39a11 100644
--- a/dom/within/within.js
+++ b/dom/within/within.js
@@ -89,5 +89,6 @@ $.fn.withinBox = function(left, top, width, height, useOffsetCache){
});
return this.pushStack( jQuery.unique( ret ), "withinBox", jQuery.makeArray(arguments).join(",") );
}
- return $;
+
+return $;
})
diff --git a/event/hashchange/hashchange.js b/event/hashchange/hashchange.js
index cda11d4b..25bf7a86 100644
--- a/event/hashchange/hashchange.js
+++ b/event/hashchange/hashchange.js
@@ -266,5 +266,5 @@ steal('jquery', function($){
return self;
})();
- return $;
+return $;
})
\ No newline at end of file
diff --git a/event/livehack/livehack.js b/event/livehack/livehack.js
index a873016c..ed3300d1 100644
--- a/event/livehack/livehack.js
+++ b/event/livehack/livehack.js
@@ -170,4 +170,6 @@ steal('jquery', function($) {
};
});
};
+
+ return $;
});
\ No newline at end of file
diff --git a/event/move/move.js b/event/move/move.js
index 39db9214..8fa9f2b6 100644
--- a/event/move/move.js
+++ b/event/move/move.js
@@ -1,3 +1,4 @@
steal('jquery', 'jquery/event/reverse').then(function( $ ) {
$.event.reverse('move');
+ return $;
});
\ No newline at end of file
diff --git a/event/tap/tap.js b/event/tap/tap.js
index 502ecc13..3b1d75f9 100644
--- a/event/tap/tap.js
+++ b/event/tap/tap.js
@@ -48,5 +48,5 @@ $.event.setupHelper( ["tap"], touchStartEvent, function(ev){
});
- return $;
+return $;
});
\ No newline at end of file
diff --git a/model/test/qunit/model_test.js b/model/test/qunit/model_test.js
index 152843ae..8c91f4aa 100644
--- a/model/test/qunit/model_test.js
+++ b/model/test/qunit/model_test.js
@@ -409,7 +409,8 @@ test("converters and serializes", function(){
}
},{});
var d = new Date();
- d.setMonth(1)
+ d.setDate(1);
+ d.setMonth(1);
var task1=new Task1({
createdAt: d,
name:"Task1"
From ba1d72a75195693676289fbb30612255d3f0d6a8 Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Wed, 1 Aug 2012 08:48:57 -0600
Subject: [PATCH 006/152] Fixing makefile for jQuery++
---
build/make.js | 157 +++++++++++++++++++++++++-------------------------
1 file changed, 79 insertions(+), 78 deletions(-)
diff --git a/build/make.js b/build/make.js
index fa0170ab..3a8c661b 100644
--- a/build/make.js
+++ b/build/make.js
@@ -1,12 +1,12 @@
load("steal/rhino/rhino.js");
-steal('steal/build/pluginify', 'jquery/build/stealify.js', 'jquery/build/amdify.js', 'jquery/build/extract.js',
+steal('steal/build/pluginify', // 'jquery/build/stealify.js', 'jquery/build/amdify.js', 'jquery/build/extract.js',
function() {
var out = "jquery/dist/",
- excludes = [ 'steal/dev',
- "can/util/jquery/jquery.1.7.1.js",
- "jquery/build/lib.js" ];
+ excludes = [ 'steal/dev/',
+ 'jquery',
+ 'jquery/build/lib.js' ];
steal.File(out).mkdirs();
@@ -14,88 +14,89 @@ function() {
steal.build.pluginify('jquery/build/lib.js', {
out: out + "jquerypp.js",
skipCallbacks: true,
+ shim : { 'jquery' : 'jQuery' },
exclude : excludes.concat([
'jquery/dom/dom.js', 'jquery/event/event.js', 'jquery/jquery.js'
])
});
// Create separate files
- steal.build.extract({
- "jquery/dom/animate/animate.js" : "jquery.animate.js",
- "jquery/dom/compare/compare.js" : "jquery.compare.js",
- "jquery/dom/cookie/cookie.js" : "jquery.cookie.js",
- "jquery/dom/dimensions/dimensions.js" : "jquery.dimensions.js",
- "jquery/dom/form_params/form_params.js" : "jquery.form_params.js",
- "jquery/dom/range/range.js" : "jquery.range.js",
- "jquery/dom/selection/selection.js" : "jquery.selection.js",
- "jquery/dom/styles/styles.js" : "jquery.styles.js",
- "jquery/dom/within/within.js" : "jquery.within.js",
- "jquery/event/default/default.js" : "jquery.event.default.js",
- "jquery/event/destroyed/destroyed.js" : "jquery.event.destroyed.js",
- "jquery/event/drag/drag.js" : "jquery.event.drag.js",
- "jquery/event/drop/drop.js" : "jquery.event.drop.js",
- "jquery/event/fastfix/fastfix.js" : "jquery.event.fastfix.js",
- "jquery/event/hover/hover.js" : "jquery.event.hover.js",
- "jquery/event/key/key.js" : "jquery.event.key.js",
- "jquery/event/pause/pause.js" : "jquery.event.pause.js",
- "jquery/event/resize/resize.js" : "jquery.event.resize.js",
- "jquery/event/swipe/swipe.js" : "jquery.event.swipe.js",
- "jquery/event/livehack/livehack.js" : "jquery.event.livehack.js",
- "jquery/lang/json/json.js" : "jquery.lang.json.js",
- "jquery/lang/vector/vector.js" : "jquery.lang.vector.js"
- }, {
- skipCallbacks: true,
- exclude : excludes.concat([
- 'jquery/dom/dom.js', 'jquery/event/event.js', 'jquery/jquery.js'
- ]),
- out : out + 'lib/'
- });
+// steal.build.extract({
+// "jquery/dom/animate/animate.js" : "jquery.animate.js",
+// "jquery/dom/compare/compare.js" : "jquery.compare.js",
+// "jquery/dom/cookie/cookie.js" : "jquery.cookie.js",
+// "jquery/dom/dimensions/dimensions.js" : "jquery.dimensions.js",
+// "jquery/dom/form_params/form_params.js" : "jquery.form_params.js",
+// "jquery/dom/range/range.js" : "jquery.range.js",
+// "jquery/dom/selection/selection.js" : "jquery.selection.js",
+// "jquery/dom/styles/styles.js" : "jquery.styles.js",
+// "jquery/dom/within/within.js" : "jquery.within.js",
+// "jquery/event/default/default.js" : "jquery.event.default.js",
+// "jquery/event/destroyed/destroyed.js" : "jquery.event.destroyed.js",
+// "jquery/event/drag/drag.js" : "jquery.event.drag.js",
+// "jquery/event/drop/drop.js" : "jquery.event.drop.js",
+// "jquery/event/fastfix/fastfix.js" : "jquery.event.fastfix.js",
+// "jquery/event/hover/hover.js" : "jquery.event.hover.js",
+// "jquery/event/key/key.js" : "jquery.event.key.js",
+// "jquery/event/pause/pause.js" : "jquery.event.pause.js",
+// "jquery/event/resize/resize.js" : "jquery.event.resize.js",
+// "jquery/event/swipe/swipe.js" : "jquery.event.swipe.js",
+// "jquery/event/livehack/livehack.js" : "jquery.event.livehack.js",
+// "jquery/lang/json/json.js" : "jquery.lang.json.js",
+// "jquery/lang/vector/vector.js" : "jquery.lang.vector.js"
+// }, {
+// skipCallbacks: true,
+// exclude : excludes.concat([
+// 'jquery/dom/dom.js', 'jquery/event/event.js', 'jquery/jquery.js'
+// ]),
+// out : out + 'lib/'
+// });
// Make Steal distributable
- steal.build.stealify('jquery/build/lib.js', {
- out : out + 'steal/',
- exclude : excludes
- });
+// steal.build.stealify('jquery/build/lib.js', {
+// out : out + 'steal/',
+// exclude : excludes
+// });
// Make AMD modules
- steal.build.amdify('jquery/build/lib.js', {
- out : out + 'amd/',
- exclude : excludes.concat([
- 'jquery/dom/dom.js', 'jquery/event/event.js'
- ]),
- map : { // steal file to CommonJS module name mappings
- "jquery/jquery.js" : "jquery",
- "jquery/build/lib.js" : "jquerypp/index",
- "jquery/lang/json/json.js" : "jquerypp/util/json",
- "jquery/lang/vector/vector.js" : "jquerypp/util/vector",
- "jquery/dom/animate/animate.js" : "jquerypp/animate",
- "jquery/dom/compare/compare.js" : "jquerypp/compare",
- "jquery/dom/cookie/cookie.js" : "jquerypp/cookie",
- "jquery/dom/dimensions/dimensions.js" : "jquerypp/dimensions",
- "jquery/dom/form_params/form_params.js" : "jquerypp/form_params",
- "jquery/dom/range/range.js" : "jquerypp/range",
- "jquery/dom/selection/selection.js" : "jquerypp/selection",
- "jquery/dom/styles/styles.js" : "jquerypp/styles",
- "jquery/dom/within/within.js" : "jquerypp/within",
- "jquery/event/default/default.js" : "jquerypp/event/default",
- "jquery/event/destroyed/destroyed.js" : "jquerypp/event/destroyed",
- "jquery/event/drag/drag.js" : "jquerypp/event/drag",
- "jquery/event/drag/limit/limit.js" : "jquerypp/event/drag.limit",
- "jquery/event/drag/scroll/scroll.js" : "jquerypp/event/drag.scroll",
- "jquery/event/drag/step/step.js" : "jquerypp/event/drag.step",
- "jquery/event/drop/drop.js" : "jquerypp/event/drop",
- "jquery/event/fastfix/fastfix.js" : "jquerypp/event/fastfix",
- "jquery/event/hover/hover.js" : "jquerypp/event/hover",
- "jquery/event/key/key.js" : "jquerypp/event/key",
- "jquery/event/reverse/reverse.js" : "jquerypp/event/reverse",
- "jquery/event/livehack/livehack.js" : "jquerypp/event/livehack",
- "jquery/event/pause/pause.js" : "jquerypp/event/pause",
- "jquery/event/resize/resize.js" : "jquerypp/event/resize",
- "jquery/event/swipe/swipe.js" : "jquerypp/event/swipe"
- },
- names : { // Module name to variable name mappings
- 'jquery' : 'jQuery'
- },
- global : 'jQuery'
- });
+// steal.build.amdify('jquery/build/lib.js', {
+// out : out + 'amd/',
+// exclude : excludes.concat([
+// 'jquery/dom/dom.js', 'jquery/event/event.js'
+// ]),
+// map : { // steal file to CommonJS module name mappings
+// "jquery/jquery.js" : "jquery",
+// "jquery/build/lib.js" : "jquerypp/index",
+// "jquery/lang/json/json.js" : "jquerypp/util/json",
+// "jquery/lang/vector/vector.js" : "jquerypp/util/vector",
+// "jquery/dom/animate/animate.js" : "jquerypp/animate",
+// "jquery/dom/compare/compare.js" : "jquerypp/compare",
+// "jquery/dom/cookie/cookie.js" : "jquerypp/cookie",
+// "jquery/dom/dimensions/dimensions.js" : "jquerypp/dimensions",
+// "jquery/dom/form_params/form_params.js" : "jquerypp/form_params",
+// "jquery/dom/range/range.js" : "jquerypp/range",
+// "jquery/dom/selection/selection.js" : "jquerypp/selection",
+// "jquery/dom/styles/styles.js" : "jquerypp/styles",
+// "jquery/dom/within/within.js" : "jquerypp/within",
+// "jquery/event/default/default.js" : "jquerypp/event/default",
+// "jquery/event/destroyed/destroyed.js" : "jquerypp/event/destroyed",
+// "jquery/event/drag/drag.js" : "jquerypp/event/drag",
+// "jquery/event/drag/limit/limit.js" : "jquerypp/event/drag.limit",
+// "jquery/event/drag/scroll/scroll.js" : "jquerypp/event/drag.scroll",
+// "jquery/event/drag/step/step.js" : "jquerypp/event/drag.step",
+// "jquery/event/drop/drop.js" : "jquerypp/event/drop",
+// "jquery/event/fastfix/fastfix.js" : "jquerypp/event/fastfix",
+// "jquery/event/hover/hover.js" : "jquerypp/event/hover",
+// "jquery/event/key/key.js" : "jquerypp/event/key",
+// "jquery/event/reverse/reverse.js" : "jquerypp/event/reverse",
+// "jquery/event/livehack/livehack.js" : "jquerypp/event/livehack",
+// "jquery/event/pause/pause.js" : "jquerypp/event/pause",
+// "jquery/event/resize/resize.js" : "jquerypp/event/resize",
+// "jquery/event/swipe/swipe.js" : "jquerypp/event/swipe"
+// },
+// names : { // Module name to variable name mappings
+// 'jquery' : 'jQuery'
+// },
+// global : 'jQuery'
+// });
});
From f95bb86d861008bae269efe614a5beb99c377008 Mon Sep 17 00:00:00 2001
From: Raymond May Jr
Date: Thu, 9 Aug 2012 15:45:52 +0200
Subject: [PATCH 007/152] add scrollTop and scrollLeft to animate pass through
as they do not work in $++ animate when passed with a timing value
---
dom/animate/animate.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dom/animate/animate.js b/dom/animate/animate.js
index dd1b2602..361918a4 100644
--- a/dom/animate/animate.js
+++ b/dom/animate/animate.js
@@ -57,7 +57,7 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
// Negative values not handled the same
|| props[name] < 0
// unit-less value
- || name == 'zIndex' || name == 'z-index'
+ || name == 'zIndex' || name == 'z-index' || name == 'scrollTop' || name == 'scrollLeft'
) {
return true;
}
From 6514e13ed498759d54c1f61b54ee2edc7efe5f73 Mon Sep 17 00:00:00 2001
From: Jason Brumwell
Date: Sun, 12 Aug 2012 10:02:28 -0400
Subject: [PATCH 008/152] Added ability to stop propagation of the dropon event
---
event/drop/drop.js | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/event/drop/drop.js b/event/drop/drop.js
index 6d831397..eaa0d9b7 100644
--- a/event/drop/drop.js
+++ b/event/drop/drop.js
@@ -374,17 +374,22 @@ steal('jquery', 'jquery/event/drag', 'jquery/dom/within', 'jquery/dom/compare',
}
},
end: function( event, moveable ) {
- var responder, la,
- endName = this.lowerName+'end',
- dropData;
+ var la,
+ endName = this.lowerName+'end',
+ onEvent = $.Event(this.endName, event),
+ dropData;
// call dropon
// go through the actives ... if you are over one, call dropped on it
for(var i = 0; i < this.last_active.length; i++){
la = this.last_active[i]
if( this.isAffected(event.vector(), moveable, la) && la[this.endName]){
- la.callHandlers(this.endName, null, event, moveable);
+ la.callHandlers(this.endName, null, onEvent, moveable);
}
+
+ if (onEvent.isPropagationStopped()) {
+ break;
+ }
}
// call dropend
for(var r =0; r
Date: Sun, 12 Aug 2012 10:23:24 -0400
Subject: [PATCH 009/152] Added dragcleanup event
---
event/drag/drag.js | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/event/drag/drag.js b/event/drag/drag.js
index 98a629f3..fca85d15 100644
--- a/event/drag/drag.js
+++ b/event/drag/drag.js
@@ -84,7 +84,8 @@ steal('jquery', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/event/rev
dragover: event.find(delegate, ["dragover"], selector),
dragmove: event.find(delegate, ["dragmove"], selector),
dragout: event.find(delegate, ["dragout"], selector),
- dragend: event.find(delegate, ["dragend"], selector)
+ dragend: event.find(delegate, ["dragend"], selector),
+ dragcleanup: event.find(delegate, ["dragcleanup"], selector),
},
destroyed: function() {
self.current = null;
@@ -404,7 +405,7 @@ steal('jquery', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/event/rev
});
}
else {
- this.cleanup();
+ this.cleanup(event);
}
this.event = null;
},
@@ -412,7 +413,7 @@ steal('jquery', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/event/rev
* Cleans up drag element after drag drop.
* @hide
*/
- cleanup: function() {
+ cleanup: function(event) {
this.movingElement.css({
zIndex: this.oldZIndex
});
@@ -427,6 +428,8 @@ steal('jquery', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/event/rev
// Remove the element when using drag.ghost()
this.movingElement.remove();
}
+
+ this.callEvents('cleanup', this.element, event);
this.movingElement = this.element = this.event = null;
},
@@ -713,17 +716,30 @@ steal('jquery', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/event/rev
* @attribute dragend
* @parent jQuery.event.drag
*
- * `dragend` is called when the drag motion is done.
+ * `dragend` is called when the drag operation is completed.
* The event handler gets an instance of [jQuery.Drag] passed as the second
* parameter.
*
* $('.draggable').on('dragend', function(ev, drag)
- * // Clean up when the drag motion is done
+ * // Calculation on whether revert should be invoked, alterations based on position of the end event
* });
*/
- 'dragend'], startEvent, function( e ) {
+ 'dragend',
+ /**
+ * @attribute dragcleanup
+ * @parent jQuery.event.drag
+ *
+ * `dragcleanup` is called after dragend and revert (if applied)
+ * The event handler gets an instance of [jQuery.Drag] passed as the second
+ * parameter.
+ *
+ * $('.draggable').on('dragcleanup', function(ev, drag)
+ * // cleanup
+ * });
+ */
+ 'dragcleanup'], startEvent, function( e ) {
$.Drag.mousedown.call($.Drag, e, this);
});
return $;
-});
+});
\ No newline at end of file
From f7b218172397b5ac8b0ed426df410b128522e374 Mon Sep 17 00:00:00 2001
From: Jason Brumwell
Date: Sun, 12 Aug 2012 14:07:24 -0400
Subject: [PATCH 010/152] namespace support for event.setuphelper
---
event/livehack/livehack.js | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/event/livehack/livehack.js b/event/livehack/livehack.js
index ed3300d1..d1397adc 100644
--- a/event/livehack/livehack.js
+++ b/event/livehack/livehack.js
@@ -124,18 +124,20 @@ steal('jquery', function($) {
startingEvent = null;
}
var add = function( handleObj ) {
-
- var bySelector, selector = handleObj.selector || "";
+ var bySelector,
+ selector = handleObj.selector || "",
+ namespace = handleObj.namespace ? '.'+handleObj.namespace : '';
+
if ( selector ) {
bySelector = event.find(this, types, selector);
if (!bySelector.length ) {
- $(this).delegate(selector, startingEvent, onFirst);
+ $(this).delegate(selector, startingEvent + namespace, onFirst);
}
}
else {
//var bySelector = event.find(this, types, selector);
if (!event.find(this, types, selector).length ) {
- event.add(this, startingEvent, onFirst, {
+ event.add(this, startingEvent + namespace, onFirst, {
selector: selector,
delegate: this
});
From aacda6840a2cf184705e852d6878843cc3c8c5d8 Mon Sep 17 00:00:00 2001
From: Austin McDaniel
Date: Mon, 13 Aug 2012 09:08:42 -0500
Subject: [PATCH 011/152] Reverse passes 'data' too.
Enhanced Reverse event to pass the data attribute like normal jQuery events do. Added tests for this enhancement too.
---
event/reverse/reverse.js | 4 ++--
event/reverse/reverse_test.js | 15 +++++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/event/reverse/reverse.js b/event/reverse/reverse.js
index 0f38a9b1..46713218 100644
--- a/event/reverse/reverse.js
+++ b/event/reverse/reverse.js
@@ -40,7 +40,7 @@ steal('jquery', function( $ ) {
var where = data === false ? ev.target : this
// trigger all this element's handlers
- $.event.handle.call(where, ev);
+ $.event.handle.call(where, ev, data);
if ( ev.isPropagationStopped() ) {
count--;
return;
@@ -56,7 +56,7 @@ steal('jquery', function( $ ) {
while (++index < length && (child = bound[index]) && (isWindow || $.contains(where, child)) ) {
// call the event
- $.event.handle.call(child, ev);
+ $.event.handle.call(child, ev, data);
if ( ev.isPropagationStopped() ) {
// move index until the item is not in the current child
diff --git a/event/reverse/reverse_test.js b/event/reverse/reverse_test.js
index dccd0c87..df976dbd 100644
--- a/event/reverse/reverse_test.js
+++ b/event/reverse/reverse_test.js
@@ -36,4 +36,19 @@ steal('funcunit/qunit', 'jquery/event/move').then(function() {
$('#outer').trigger('test');
$('body').trigger('test');
});
+
+ test('passing data', 1, function() {
+ $('#qunit-test-area').html('
' +
+ '
' +
+ '
Innermost div
' +
+ '
' +
+ '
');
+
+ $('#inner').on('test', function(ev, data) {
+ equals(data.data, true, 'data passed!');
+ });
+
+ $('#outer').trigger('test', { data: true });
+ //$('body').trigger('test');
+ });
});
\ No newline at end of file
From d9b8c3238ea81fc1bf33b3dd38d817521e11cdcf Mon Sep 17 00:00:00 2001
From: Austin McDaniel
Date: Tue, 14 Aug 2012 09:11:27 -0500
Subject: [PATCH 012/152] jQuery.Mousehold event addition
Mousehold is triggered when you hold down the mouse without releasing.
You can set delay and get the count of the current fire count.
---
event/mousehold/mousehold.js | 120 +++++++++++++++++++++++++++++++++++
1 file changed, 120 insertions(+)
create mode 100644 event/mousehold/mousehold.js
diff --git a/event/mousehold/mousehold.js b/event/mousehold/mousehold.js
new file mode 100644
index 00000000..326939b5
--- /dev/null
+++ b/event/mousehold/mousehold.js
@@ -0,0 +1,120 @@
+steal('jquery', 'jquery/event/livehack', function($) {
+
+/**
+ * @class jQuery.Mousehold
+ * @plugin jquery/event/mousehold
+ * @download http://jmvcsite.heroku.com/pluginify?plugins[]=jquery/event/mousehold/mousehold.js
+ * @parent jQuery.event.mousehold
+ *
+ * Creates a new mousehold. The constructor should not be called directly.
+ *
+ * An instance of `$.Mousehold` is passed as the second argument to each
+ * [jQuery.event.mousehold] event handler:
+ *
+ * $('#button').on("mousehold", function(ev, mousehold) {
+ * // Set the mousehold delay to 500ms
+ * mousehold.delay(500);
+ * });
+ */
+$.Mousehold = function(){
+ this._delay = $.Mousehold.delay;
+ this.fireCount = 0;
+};
+
+/**
+ * @Static
+ */
+$.extend($.Mousehold,{
+ /**
+ * @attribute delay
+ *
+ * `$.Mousehold.delay` is the delay (in milliseconds) after which the hold is
+ * activated by default.
+ *
+ * Set this value as a global default. The default is 100ms.
+ *
+ * // Set the global hover delay to 1 second
+ * $.Mousehold.delay = 1000;
+ */
+ delay: 500
+});
+
+/**
+ * @Prototype
+ */
+$.extend($.Mousehold.prototype,{
+ /**
+ * `mousehold.delay(time)` sets the delay (in ms) for this mousedown.
+ * This method should only be used in [jQuery.event.mousehold mousehold]:
+ *
+ * $('.holdable').on('mousehold', function(ev, mousehold) {
+ * // Set the delay to 500ms
+ * mousehold.delay(500);
+ * });
+ *
+ * @param {Number} delay the number of milliseconds used to determine a mousehold
+ * @return {$.Mousedown} The mousehold object
+ */
+ delay: function( delay ) {
+ this._delay = delay;
+ return this;
+ }
+});
+
+ var event = $.event,
+ onmousehold = function(ev) {
+
+ var mousehold = new $.Mousehold(),
+ fireStep = 0,
+ delegate = ev.delegateTarget || ev.currentTarget,
+ selector = ev.handleObj.selector,
+ downEl = this,
+ timeout;
+
+ var clearMousehold = function() {
+ clearInterval(timeout);
+
+ if (fireStep == 1) {
+ $.each(event.find(delegate, ["mousehold"], selector), function(){
+ mousehold.fireCount = 1;
+ this.call(downEl, ev, mousehold)
+ })
+ }
+
+ fireStep = 0;
+ $(downEl).unbind("mouseout", clearMousehold)
+ .unbind("mouseup", clearMousehold);
+ };
+
+ fireStep = 1;
+ timeout = setInterval(function() {
+ $.each(event.find(delegate, ["mousehold"], selector), function(){
+ mousehold.fireCount++;
+ this.call(downEl, ev, mousehold)
+ });
+
+ fireStep = 2;
+ }, mousehold.delay);
+
+ $(downEl).bind("mouseout", clearMousehold)
+ .bind("mouseup", clearMousehold);
+ };
+
+ /**
+ * @add jQuery.event.special
+ */
+// Attach events
+event.setupHelper([
+/**
+ * @attribute mousehold
+ * @parent jQuery.event.mousehold
+ *
+ * `mousehold` is called while the mouse is being held down.
+ *
+ * Additionally, the function, when executed, is passed a single
+ * argument representing the count of times the event has been fired during
+ * this session of the mouse hold.
+ */
+"mousehold" ], "mousedown", onmousehold );
+
+});
\ No newline at end of file
From c095cddc0d2ee6463c669ba0ad55d72530435b9a Mon Sep 17 00:00:00 2001
From: Austin McDaniel
Date: Tue, 14 Aug 2012 09:20:42 -0500
Subject: [PATCH 013/152] few doc updates for mousehold
---
event/mousehold/mousehold.js | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/event/mousehold/mousehold.js b/event/mousehold/mousehold.js
index 326939b5..5346fc1b 100644
--- a/event/mousehold/mousehold.js
+++ b/event/mousehold/mousehold.js
@@ -31,7 +31,7 @@ $.extend($.Mousehold,{
* `$.Mousehold.delay` is the delay (in milliseconds) after which the hold is
* activated by default.
*
- * Set this value as a global default. The default is 100ms.
+ * Set this value as a global default. The default is 500ms.
*
* // Set the global hover delay to 1 second
* $.Mousehold.delay = 1000;
@@ -48,8 +48,8 @@ $.extend($.Mousehold.prototype,{
* This method should only be used in [jQuery.event.mousehold mousehold]:
*
* $('.holdable').on('mousehold', function(ev, mousehold) {
- * // Set the delay to 500ms
- * mousehold.delay(500);
+ * // Set the delay to 100ms
+ * mousehold.delay(100);
* });
*
* @param {Number} delay the number of milliseconds used to determine a mousehold
@@ -108,12 +108,7 @@ event.setupHelper([
/**
* @attribute mousehold
* @parent jQuery.event.mousehold
- *
* `mousehold` is called while the mouse is being held down.
- *
- * Additionally, the function, when executed, is passed a single
- * argument representing the count of times the event has been fired during
- * this session of the mouse hold.
*/
"mousehold" ], "mousedown", onmousehold );
From 538c41ac6fa235208e99833fd7e4133444c9e5a0 Mon Sep 17 00:00:00 2001
From: Austin McDaniel
Date: Tue, 14 Aug 2012 10:58:27 -0500
Subject: [PATCH 014/152] Changed 'mouseout' to 'mouseleave'. Changed
'setInterval' to 'setTimeout'.
---
event/mousehold/mousehold.js | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/event/mousehold/mousehold.js b/event/mousehold/mousehold.js
index 5346fc1b..e45ae935 100644
--- a/event/mousehold/mousehold.js
+++ b/event/mousehold/mousehold.js
@@ -12,8 +12,8 @@ steal('jquery', 'jquery/event/livehack', function($) {
* [jQuery.event.mousehold] event handler:
*
* $('#button').on("mousehold", function(ev, mousehold) {
- * // Set the mousehold delay to 500ms
- * mousehold.delay(500);
+ * // Set the mousehold delay to 100ms
+ * mousehold.delay(100);
* });
*/
$.Mousehold = function(){
@@ -82,21 +82,22 @@ $.extend($.Mousehold.prototype,{
}
fireStep = 0;
- $(downEl).unbind("mouseout", clearMousehold)
+ $(downEl).unbind("mouseleave", clearMousehold)
.unbind("mouseup", clearMousehold);
};
fireStep = 1;
- timeout = setInterval(function() {
+ timeout = setTimeout(function() {
$.each(event.find(delegate, ["mousehold"], selector), function(){
mousehold.fireCount++;
this.call(downEl, ev, mousehold)
});
fireStep = 2;
+ timeout = setTimeout(arguments.callee, mousehold.delay)
}, mousehold.delay);
- $(downEl).bind("mouseout", clearMousehold)
+ $(downEl).bind("mouseleave", clearMousehold)
.bind("mouseup", clearMousehold);
};
From bf6e971e4068cdfe85562e3c9189da048857b20c Mon Sep 17 00:00:00 2001
From: Austin McDaniel
Date: Mon, 20 Aug 2012 15:10:18 -0500
Subject: [PATCH 015/152] Added more docs and updating of offset to
jquery/event/mousehold
---
event/mousehold/mousehold.js | 45 ++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 9 deletions(-)
diff --git a/event/mousehold/mousehold.js b/event/mousehold/mousehold.js
index e45ae935..f47de750 100644
--- a/event/mousehold/mousehold.js
+++ b/event/mousehold/mousehold.js
@@ -36,7 +36,7 @@ $.extend($.Mousehold,{
* // Set the global hover delay to 1 second
* $.Mousehold.delay = 1000;
*/
- delay: 500
+ delay: 100
});
/**
@@ -68,10 +68,15 @@ $.extend($.Mousehold.prototype,{
fireStep = 0,
delegate = ev.delegateTarget || ev.currentTarget,
selector = ev.handleObj.selector,
- downEl = this,
+ downEl = $(this),
+ offsetY = 0,
+ offsetX = 0,
timeout;
- var clearMousehold = function() {
+ var updateCoordinates = function(ev){
+ offsetX = ev.offsetX;
+ offsetY = ev.offsetY;
+ }, clearMousehold = function() {
clearInterval(timeout);
if (fireStep == 1) {
@@ -82,23 +87,29 @@ $.extend($.Mousehold.prototype,{
}
fireStep = 0;
- $(downEl).unbind("mouseleave", clearMousehold)
- .unbind("mouseup", clearMousehold);
+ downEl.unbind("mouseleave", clearMousehold)
+ .unbind("mouseup", clearMousehold)
+ .unbind("mousemove", updateCoordinates);
};
fireStep = 1;
timeout = setTimeout(function() {
$.each(event.find(delegate, ["mousehold"], selector), function(){
mousehold.fireCount++;
+
+ ev.offsetX = offsetX || ev.offsetX;
+ ev.offsetY = offsetY || ev.offsetY;
+
this.call(downEl, ev, mousehold)
});
fireStep = 2;
- timeout = setTimeout(arguments.callee, mousehold.delay)
- }, mousehold.delay);
+ timeout = setTimeout(arguments.callee, mousehold._delay)
+ }, mousehold._delay);
- $(downEl).bind("mouseleave", clearMousehold)
- .bind("mouseup", clearMousehold);
+ downEl.bind("mouseleave", clearMousehold)
+ .bind("mouseup", clearMousehold)
+ .bind('mousemove', updateCoordinates)
};
/**
@@ -109,7 +120,23 @@ event.setupHelper([
/**
* @attribute mousehold
* @parent jQuery.event.mousehold
+ *
* `mousehold` is called while the mouse is being held down.
+ *
+ * This is different from `mousedown` in the fact that `mousedown`
+ * will only fire once no matter how long you hold down the mouse.
+ *
+ * For example, if you were to create a 'button' and hold
+ * down the button, 'mousehold' would fire until you release
+ * your cursor.
+ *
+ * Optionally, can set the delay between the event triggering.
+ * The `mousehold` class will contain the current delay and
+ * the number of times the event has fired.
+ *
+ * The `mousehold` event also updates the `offsetX` and `offsetY`
+ * of the event since this would be for the original event mouse offset.
+ *
*/
"mousehold" ], "mousedown", onmousehold );
From 248d74d0d7cef64b33d06c9d40039f3f78450489 Mon Sep 17 00:00:00 2001
From: Austin McDaniel
Date: Mon, 20 Aug 2012 16:22:56 -0500
Subject: [PATCH 016/152] A little bit of cleanup and setting target too in
mousehold
---
event/mousehold/mousehold.js | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/event/mousehold/mousehold.js b/event/mousehold/mousehold.js
index f47de750..d5df9de6 100644
--- a/event/mousehold/mousehold.js
+++ b/event/mousehold/mousehold.js
@@ -69,13 +69,12 @@ $.extend($.Mousehold.prototype,{
delegate = ev.delegateTarget || ev.currentTarget,
selector = ev.handleObj.selector,
downEl = $(this),
- offsetY = 0,
- offsetX = 0,
timeout;
- var updateCoordinates = function(ev){
- offsetX = ev.offsetX;
- offsetY = ev.offsetY;
+ var updateCoordinates = function(event){
+ ev.offsetX = event.offsetX;
+ ev.offsetY = event.offsetY;
+ ev.target = event.target;
}, clearMousehold = function() {
clearInterval(timeout);
@@ -96,10 +95,6 @@ $.extend($.Mousehold.prototype,{
timeout = setTimeout(function() {
$.each(event.find(delegate, ["mousehold"], selector), function(){
mousehold.fireCount++;
-
- ev.offsetX = offsetX || ev.offsetX;
- ev.offsetY = offsetY || ev.offsetY;
-
this.call(downEl, ev, mousehold)
});
From 16655c6e5252d8c0020731b796499a04cdbeafca Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Mon, 27 Aug 2012 12:58:52 -0600
Subject: [PATCH 017/152] JQuery++ tests with latest Steal
---
.../view/test/qunit/controller_view_test.js | 2 +-
dom/animate/animate.js | 15 ++++++++-------
dom/form_params/form_params_test.js | 4 ++--
dom/styles/styles_test.js | 2 +-
event/default/default_pause_test.js | 2 +-
event/destroyed/destroyed_test.js | 2 +-
6 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/controller/view/test/qunit/controller_view_test.js b/controller/view/test/qunit/controller_view_test.js
index 1628f84d..15b04274 100644
--- a/controller/view/test/qunit/controller_view_test.js
+++ b/controller/view/test/qunit/controller_view_test.js
@@ -1,4 +1,4 @@
-steal('jquery', 'jquery/controller/view','jquery/view/micro','funcunit/qunit', function($) {
+steal('jquery/controller/view','jquery/view/micro','funcunit/qunit', function() {
module("jquery/controller/view");
diff --git a/dom/animate/animate.js b/dom/animate/animate.js
index dd1b2602..d0500a6b 100644
--- a/dom/animate/animate.js
+++ b/dom/animate/animate.js
@@ -250,7 +250,12 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
}
$.removeData(self, dataKey, true);
- }
+ },
+ finisAnimation = function() {
+ // Call animationEnd using the passed properties
+ animationEnd(props, true);
+ done();
+ };
for(prop in props) {
properties.push(prop);
@@ -288,7 +293,7 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
'animation-play-state' : 'paused'
}));
// Unbind the animation end handler
- self.off(getBrowser().transitionEnd, animationEnd);
+ self.off(getBrowser().transitionEnd, finisAnimation());
if(!gotoEnd) {
// We were told not to finish the animation
// Call animationEnd but set the CSS to the current computed style
@@ -308,11 +313,7 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
}));
// Attach the transition end event handler to run only once
- self.one(getBrowser().transitionEnd, function() {
- // Call animationEnd using the passed properties
- animationEnd(props, true);
- done();
- });
+ self.one(getBrowser().transitionEnd, finishAnimation);
});
diff --git a/dom/form_params/form_params_test.js b/dom/form_params/form_params_test.js
index b515afd4..03e5340f 100644
--- a/dom/form_params/form_params_test.js
+++ b/dom/form_params/form_params_test.js
@@ -1,5 +1,5 @@
-steal("jquery", "jquery/dom/form_params", 'funcunit/qunit', 'jquery/view/micro',
-function($) {
+steal("jquery/dom/form_params", 'funcunit/qunit', 'jquery/view/micro',
+function() {
$.ajaxSetup({
cache : false
diff --git a/dom/styles/styles_test.js b/dom/styles/styles_test.js
index 683f483c..77bb27cc 100644
--- a/dom/styles/styles_test.js
+++ b/dom/styles/styles_test.js
@@ -1,4 +1,4 @@
-steal("jquery", "jquery/dom/dimensions",'jquery/view/micro', 'funcunit/qunit', function($) {
+steal("jquery/dom/dimensions",'jquery/view/micro', 'funcunit/qunit', function() {
module("jquery/dom/styles");
diff --git a/event/default/default_pause_test.js b/event/default/default_pause_test.js
index 41cc79cf..1cd6d94d 100644
--- a/event/default/default_pause_test.js
+++ b/event/default/default_pause_test.js
@@ -1,4 +1,4 @@
-steal('jquery', 'funcunit/qunit','jquery/event/default','jquery/event/pause', function($) {
+steal('funcunit/qunit','jquery/event/default','jquery/event/pause', function() {
module("jquery/event/default_pause");
diff --git a/event/destroyed/destroyed_test.js b/event/destroyed/destroyed_test.js
index c8bc43a0..4dd264a4 100644
--- a/event/destroyed/destroyed_test.js
+++ b/event/destroyed/destroyed_test.js
@@ -1,4 +1,4 @@
-steal("jquery", "jquery/event/destroyed", 'funcunit/qunit', function($) {
+steal("jquery/event/destroyed", 'funcunit/qunit', function() {
module("jquery/event/destroyed")
test("removing an element", function(){
From 11630bb25c4d2b8e9e47605ef1e73b4f3c99171d Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Mon, 27 Aug 2012 13:41:44 -0600
Subject: [PATCH 018/152] Changelog
---
changelog.md | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 changelog.md
diff --git a/changelog.md b/changelog.md
new file mode 100644
index 00000000..ad0d4173
--- /dev/null
+++ b/changelog.md
@@ -0,0 +1,24 @@
+### Change Log
+
+__1.0.0__
+
+- fix: [pass through scrollTop in animate](https://github.com/jupiterjs/jquerypp/pull/40)
+
+__1.0 Beta 2__
+
+- feature: [Key mapping tool for jQuery.event.key for international characters](https://github.com/jupiterjs/jquerypp/issues/16)
+- fix: [jQuery.formParams converts disabled fields](https://github.com/jupiterjs/jquerypp/issues/24)
+- fix: [jQuery.animate supports all parameters](https://github.com/jupiterjs/jquerypp/issues/22)
+- change: [jQuery.event.drag supports touch events](https://github.com/jupiterjs/jquerypp/issues/23)
+- fix: [jQuery.animate .stop() doesn't work](https://github.com/jupiterjs/jquerypp/issues/19)
+- fix: [Bug with duplicate sub keys](https://github.com/jupiterjs/jquerypp/issues/17)
+- change: [Added width property to jQuery.selection](https://github.com/jupiterjs/jquerypp/pull/11)
+- fix: [Security error in jQuery.animate](https://github.com/jupiterjs/jquerypp/issues/5)
+- *jquerypp.com*
+ - jsFiddle examples for [cookie](#cookie), [compare](#compare), [range](#range), [styles](#styles) and [key](#key)
+ - Links to annotated sources ([e.g. jQuery.animate](http://donejs.com/jquery/docs/jquery.animate.html))
+ - Changelog and list of heroes section
+
+__1.0 Beta__ (June 1st 2012)
+
+- Released!
\ No newline at end of file
From c94b4aaef2f1a0338cdff2e697af6ea769bb3316 Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Mon, 27 Aug 2012 13:42:24 -0600
Subject: [PATCH 019/152] dragcleanup event tests and tweaks
---
event/drag/drag.js | 8 +++++---
event/drag/drag_test.js | 8 +++++++-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/event/drag/drag.js b/event/drag/drag.js
index fca85d15..771a17aa 100644
--- a/event/drag/drag.js
+++ b/event/drag/drag.js
@@ -85,7 +85,7 @@ steal('jquery', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/event/rev
dragmove: event.find(delegate, ["dragmove"], selector),
dragout: event.find(delegate, ["dragout"], selector),
dragend: event.find(delegate, ["dragend"], selector),
- dragcleanup: event.find(delegate, ["dragcleanup"], selector),
+ dragcleanup: event.find(delegate, ["dragcleanup"], selector)
},
destroyed: function() {
self.current = null;
@@ -428,8 +428,10 @@ steal('jquery', 'jquery/lang/vector', 'jquery/event/livehack', 'jquery/event/rev
// Remove the element when using drag.ghost()
this.movingElement.remove();
}
-
- this.callEvents('cleanup', this.element, event);
+
+ if(event) {
+ this.callEvents('cleanup', this.element, event);
+ }
this.movingElement = this.element = this.event = null;
},
diff --git a/event/drag/drag_test.js b/event/drag/drag_test.js
index a2545f1f..a622d42b 100644
--- a/event/drag/drag_test.js
+++ b/event/drag/drag_test.js
@@ -62,6 +62,10 @@ test("dragging an element", function(){
.live("dragout", function(){
drags.dragout = true;
})
+ .live("dragcleanup", function() {
+ drags.dragcleanup = true;
+ })
+
$('#drop')
.live("dropinit", function(){
drops.dropinit = true;
@@ -89,6 +93,7 @@ test("dragging an element", function(){
ok(drags.draginit, "draginit fired correctly")
ok(drags.dragmove, "dragmove fired correctly")
ok(drags.dragend, "dragend fired correctly")
+ ok(drags.dragcleanup, "dragcleanup fired correctly")
ok(!drags.dragover,"dragover not fired yet")
ok(!drags.dragout, "dragout not fired yet")
//console.log(drags, drags.dragout)
@@ -104,7 +109,8 @@ test("dragging an element", function(){
ok(drops.dropmove, "dropmove fired correctly")
ok(drops.dropon, "dropon fired correctly")
}).drag({to: "#midpoint"}, function(){
- ok(drags.dragout, "dragout fired correctly")
+ ok(drags.dragout, "dragout fired correctly")
+ ok(drags.dragcleanup, "dragcleanup fired correctly")
ok(drops.dropout, "dropout fired correctly")
//div.remove();
From 41b66d2c615749e7aaed14117764087bfd175246 Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Mon, 27 Aug 2012 14:18:32 -0600
Subject: [PATCH 020/152] Changelog update, animate bugfix
---
changelog.md | 1 +
dom/animate/animate.js | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/changelog.md b/changelog.md
index ad0d4173..ff64bfb8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -3,6 +3,7 @@
__1.0.0__
- fix: [pass through scrollTop in animate](https://github.com/jupiterjs/jquerypp/pull/40)
+- feature: [dragcleanup event](https://github.com/jupiterjs/jquerypp/pull/43)
__1.0 Beta 2__
diff --git a/dom/animate/animate.js b/dom/animate/animate.js
index bd584781..a1505ed5 100644
--- a/dom/animate/animate.js
+++ b/dom/animate/animate.js
@@ -251,7 +251,7 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
$.removeData(self, dataKey, true);
},
- finisAnimation = function() {
+ finishAnimation = function() {
// Call animationEnd using the passed properties
animationEnd(props, true);
done();
@@ -293,7 +293,7 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
'animation-play-state' : 'paused'
}));
// Unbind the animation end handler
- self.off(getBrowser().transitionEnd, finisAnimation());
+ self.off(getBrowser().transitionEnd, finishAnimation);
if(!gotoEnd) {
// We were told not to finish the animation
// Call animationEnd but set the CSS to the current computed style
From 34f1c67b5da9586765b8f2935e9ab0463b393696 Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Tue, 28 Aug 2012 16:01:58 -0600
Subject: [PATCH 021/152] Always return when original event is undefined.
Closes #45
---
event/fastfix/fastfix.js | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/event/fastfix/fastfix.js b/event/fastfix/fastfix.js
index 2f2703a5..3707b497 100644
--- a/event/fastfix/fastfix.js
+++ b/event/fastfix/fastfix.js
@@ -19,12 +19,20 @@ steal('jquery', function ($) {
// special converters
special = {
pageX : function (original) {
+ if(!original) {
+ return;
+ }
+
var eventDoc = this.target.ownerDocument || document;
doc = eventDoc.documentElement;
body = eventDoc.body;
return original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
},
pageY : function (original) {
+ if(!original) {
+ return;
+ }
+
var eventDoc = this.target.ownerDocument || document;
doc = eventDoc.documentElement;
body = eventDoc.body;
@@ -34,12 +42,20 @@ steal('jquery', function ($) {
if(!original) {
return;
}
+
return original.fromElement === this.target ? original.toElement : original.fromElement;
},
metaKey : function (originalEvent) {
+ if(!originalEvent) {
+ return;
+ }
return originalEvent.ctrlKey;
},
which : function (original) {
+ if(!original) {
+ return;
+ }
+
return original.charCode != null ? original.charCode : original.keyCode;
}
};
From cf3ea630aed4607c9cdd6284ca4c3808c4259e39 Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Wed, 29 Aug 2012 09:12:37 -0600
Subject: [PATCH 022/152] Animate test, close #28
---
dom/animate/animate.html | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/dom/animate/animate.html b/dom/animate/animate.html
index e3af0314..27655466 100644
--- a/dom/animate/animate.html
+++ b/dom/animate/animate.html
@@ -22,19 +22,13 @@
From ac3be904e7f0b5d1f7e344a97f5fc0661abbf548 Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Wed, 29 Aug 2012 10:26:36 -0600
Subject: [PATCH 023/152] Updating changelog, fix IE range error, closes #39
---
changelog.md | 12 +++++++++---
dom/range/range.js | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/changelog.md b/changelog.md
index ff64bfb8..40e47d6e 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,19 +2,25 @@
__1.0.0__
-- fix: [pass through scrollTop in animate](https://github.com/jupiterjs/jquerypp/pull/40)
- feature: [dragcleanup event](https://github.com/jupiterjs/jquerypp/pull/43)
+- feature: [Reverse and move event](https://github.com/jupiterjs/jquerypp/issues/25)
+- fix: [pass through scrollTop in animate](https://github.com/jupiterjs/jquerypp/pull/40)
+- fix: [Fastfix: Original can be undefined](https://github.com/jupiterjs/jquerypp/pull/45)
+- fix: [Animate Scroll not working](https://github.com/jupiterjs/jquerypp/issues/35)
+- fix: [.stop() does not stop callbacks from being executed](https://github.com/jupiterjs/jquerypp/issues/28)
+- fix: [jQuery.event.swipe.max isn't actually being used](https://github.com/jupiterjs/jquerypp/issues/33)
+- fix: [Range triggers error on IE8](https://github.com/jupiterjs/jquerypp/issues/39)
__1.0 Beta 2__
- feature: [Key mapping tool for jQuery.event.key for international characters](https://github.com/jupiterjs/jquerypp/issues/16)
- fix: [jQuery.formParams converts disabled fields](https://github.com/jupiterjs/jquerypp/issues/24)
- fix: [jQuery.animate supports all parameters](https://github.com/jupiterjs/jquerypp/issues/22)
-- change: [jQuery.event.drag supports touch events](https://github.com/jupiterjs/jquerypp/issues/23)
- fix: [jQuery.animate .stop() doesn't work](https://github.com/jupiterjs/jquerypp/issues/19)
- fix: [Bug with duplicate sub keys](https://github.com/jupiterjs/jquerypp/issues/17)
-- change: [Added width property to jQuery.selection](https://github.com/jupiterjs/jquerypp/pull/11)
- fix: [Security error in jQuery.animate](https://github.com/jupiterjs/jquerypp/issues/5)
+- change: [jQuery.event.drag supports touch events](https://github.com/jupiterjs/jquerypp/issues/23)
+- change: [Added width property to jQuery.selection](https://github.com/jupiterjs/jquerypp/pull/11)
- *jquerypp.com*
- jsFiddle examples for [cookie](#cookie), [compare](#compare), [range](#range), [styles](#styles) and [key](#key)
- Links to annotated sources ([e.g. jQuery.animate](http://donejs.com/jquery/docs/jquery.animate.html))
diff --git a/dom/range/range.js b/dom/range/range.js
index ba96c298..b888946e 100644
--- a/dom/range/range.js
+++ b/dom/range/range.js
@@ -74,7 +74,7 @@ steal('jquery', 'jquery/dom/compare', function ($) {
this.win = getWindow(range)
if (this.win.document.createRange) {
this.range = this.win.document.createRange()
- } else {
+ } else if(this.win && this.win.document.body && this.win.document.body.createTextRange) {
this.range = this.win.document.body.createTextRange()
}
// if we have an element, make the range select it
From 4aba7e974c2175cece9fae3a9740d657bb919f70 Mon Sep 17 00:00:00 2001
From: Noah Sloan
Date: Fri, 31 Aug 2012 22:47:14 -0500
Subject: [PATCH 024/152] controls not controllers
---
controller/controller.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/controller/controller.js b/controller/controller.js
index 0b834de0..1eec010a 100644
--- a/controller/controller.js
+++ b/controller/controller.js
@@ -1,5 +1,5 @@
steal('jquery', 'can/control', 'jquery/class','can/control/plugin',function($, Control) {
$.Controller = Control;
$.fn.controller = $.fn.control;
- $.fn.controllers = $.fn.controllers;
+ $.fn.controllers = $.fn.controls;
});
From fabf75cbc958a464ae9898d32544eaedbac830bf Mon Sep 17 00:00:00 2001
From: Noah Sloan
Date: Fri, 31 Aug 2012 22:50:37 -0500
Subject: [PATCH 025/152] restore model getters
---
model/model.js | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/model/model.js b/model/model.js
index 9c5efbbf..d62481d0 100644
--- a/model/model.js
+++ b/model/model.js
@@ -2,4 +2,9 @@
steal('jquery', 'can/util', 'can/model','can/observe/attributes','can/observe/setter','can/model/elements', function($, can){
$.Model = can.Model;
+ var get = $.Model.prototype.__get;
+ $.Model.prototype.__get = function(attr) {
+ var getter = attr && ("get" + can.classize(attr));
+ return typeof this[getter] === 'function' ? this[getter]() : get.apply(this,arguments);
+ };
});
From e5d311c15c9dd0f94430dac6daad669e21887236 Mon Sep 17 00:00:00 2001
From: Noah Sloan
Date: Fri, 31 Aug 2012 22:51:02 -0500
Subject: [PATCH 026/152] restore list.get(model(s))
---
model/model.js | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/model/model.js b/model/model.js
index d62481d0..0dbe746a 100644
--- a/model/model.js
+++ b/model/model.js
@@ -7,4 +7,19 @@ steal('jquery', 'can/util', 'can/model','can/observe/attributes','can/observe/se
var getter = attr && ("get" + can.classize(attr));
return typeof this[getter] === 'function' ? this[getter]() : get.apply(this,arguments);
};
+ // List.get used to take a model or list of models
+ var getList = $.Model.List.prototype.get;
+ $.Model.List.prototype.get = function(arg) {
+ var ids;
+ if(arg instanceof $.Model.List) {
+ ids = [];
+ $.each(arg,function() {
+ ids.push(this.attr('id'));
+ });
+ arg = ids;
+ } else if(arg.attr && arg.attr('id')) {
+ arg = arg.attr('id');
+ }
+ return getList.apply(this,arguments);
+ };
});
From d1a065b31f77375c64f199e6b130ae11ec85bd51 Mon Sep 17 00:00:00 2001
From: Noah Sloan
Date: Fri, 31 Aug 2012 22:51:45 -0500
Subject: [PATCH 027/152] restore list.push(anotherList)
---
model/model.js | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/model/model.js b/model/model.js
index 0dbe746a..94f8fc7c 100644
--- a/model/model.js
+++ b/model/model.js
@@ -22,4 +22,12 @@ steal('jquery', 'can/util', 'can/model','can/observe/attributes','can/observe/se
}
return getList.apply(this,arguments);
};
+ // restore the ability to push a list!arg
+ var push = $.Model.List.prototype.push;
+ $.Model.List.prototype.push = function(arg) {
+ if(arg instanceof $.Model.List) {
+ arg = can.makeArray(arg);
+ }
+ return push.apply(this,arguments);
+ };
});
From 3ffb54f6f45e6a7ba4d7e5a8fccc4f6e68bc17de Mon Sep 17 00:00:00 2001
From: Noah Sloan
Date: Fri, 31 Aug 2012 22:47:46 -0500
Subject: [PATCH 028/152] restore $.Controller.find
---
controller/controller.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/controller/controller.js b/controller/controller.js
index 1eec010a..e46dc12a 100644
--- a/controller/controller.js
+++ b/controller/controller.js
@@ -2,4 +2,7 @@ steal('jquery', 'can/control', 'jquery/class','can/control/plugin',function($, C
$.Controller = Control;
$.fn.controller = $.fn.control;
$.fn.controllers = $.fn.controls;
+ can.Control.prototype.find = can.Control.prototype.find || function(s) {
+ return this.element.find(s);
+ };
});
From 5b242064db933be13aa79d832cf9e08a6b283a85 Mon Sep 17 00:00:00 2001
From: Noah Sloan
Date: Fri, 31 Aug 2012 22:48:08 -0500
Subject: [PATCH 029/152] restore Controller.bind and delegate
---
controller/controller.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/controller/controller.js b/controller/controller.js
index e46dc12a..cd0e96b7 100644
--- a/controller/controller.js
+++ b/controller/controller.js
@@ -5,4 +5,6 @@ steal('jquery', 'can/control', 'jquery/class','can/control/plugin',function($, C
can.Control.prototype.find = can.Control.prototype.find || function(s) {
return this.element.find(s);
};
+ $.Controller.prototype.bind = $.Controller.prototype.on;
+ $.Controller.prototype.delegate = $.Controller.prototype.on;
});
From f53a1069e458a669f89112164d16f0de6cb74155 Mon Sep 17 00:00:00 2001
From: Noah Sloan
Date: Fri, 31 Aug 2012 22:52:01 -0500
Subject: [PATCH 030/152] restore model.update
---
model/model.js | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/model/model.js b/model/model.js
index 94f8fc7c..e57626d7 100644
--- a/model/model.js
+++ b/model/model.js
@@ -30,4 +30,10 @@ steal('jquery', 'can/util', 'can/model','can/observe/attributes','can/observe/se
}
return push.apply(this,arguments);
};
+
+ $.Model.prototype.update = function( attrs, success, error ) {
+ steal.dev.log('$.Model.update is deprecated. You can use attr + save instead.');
+ this.attr(attrs);
+ return this.save(success, error);
+ };
});
From d3e5148ab6e3b8e52dbc5b76216631bf9d5f2aa6 Mon Sep 17 00:00:00 2001
From: Justin Meyer
Date: Tue, 4 Sep 2012 15:35:34 -0500
Subject: [PATCH 031/152] doesn't break jQuery 1.8's dimensions. related to #50
---
dom/dimensions/dimensions.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dom/dimensions/dimensions.js b/dom/dimensions/dimensions.js
index a752bec6..ad2db757 100644
--- a/dom/dimensions/dimensions.js
+++ b/dom/dimensions/dimensions.js
@@ -153,7 +153,7 @@ height:
return this;
} else {
// Return the old value
- return first ? checks["oldOuter" + Upper].call(this, v) : null;
+ return first ? checks["oldOuter" + Upper].apply(this, arguments) : null;
}
}
$.fn["inner" + Upper] = function(v) {
From 0c9ecd0a09045632d3741d7b578a8e272447ec2b Mon Sep 17 00:00:00 2001
From: Austin McDaniel
Date: Wed, 5 Sep 2012 08:57:10 -0500
Subject: [PATCH 032/152] Fix for jQuery 1.8.1 data updates
---
model/list/list_test.js | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/model/list/list_test.js b/model/list/list_test.js
index 15a29800..9391f0a3 100644
--- a/model/list/list_test.js
+++ b/model/list/list_test.js
@@ -173,11 +173,15 @@ test("events - add", 4, function(){
// check that we are listening to updates on person ...
- ok( $(person).data("events"), "person has events" );
+ // events are hooked internally now
+ // ok( $(person).data("events"), "person has events" );
+ ok(jQuery._data(person, 'events'), "person has events" );
list.pop()
- ok( !$(person).data("events"), "person has no events" );
+ // events are hooked internally now
+ // ok( !$(person).data("events"), "person has no events" );
+ ok( !jQuery._data(person, 'events'), "person has no events" );
});
From c883b95b4ed214c00d5794ed55801a445554b6e1 Mon Sep 17 00:00:00 2001
From: Noah Sloan
Date: Wed, 5 Sep 2012 11:31:34 -0500
Subject: [PATCH 033/152] move $.Model.List fixes ion the right plugin
---
model/list/list.js | 26 +++++++++++++++++++++++++-
model/model.js | 23 -----------------------
2 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/model/list/list.js b/model/list/list.js
index 8a634b44..7aa4be5d 100644
--- a/model/list/list.js
+++ b/model/list/list.js
@@ -1 +1,25 @@
-steal('can/model/list','jquery/model');
\ No newline at end of file
+steal('can/model/list','jquery/model').then(function() {
+ // List.get used to take a model or list of models
+ var getList = $.Model.List.prototype.get;
+ $.Model.List.prototype.get = function(arg) {
+ var ids;
+ if(arg instanceof $.Model.List) {
+ ids = [];
+ $.each(arg,function() {
+ ids.push(this.attr('id'));
+ });
+ arg = ids;
+ } else if(arg.attr && arg.attr('id')) {
+ arg = arg.attr('id');
+ }
+ return getList.apply(this,arguments);
+ };
+ // restore the ability to push a list!arg
+ var push = $.Model.List.prototype.push;
+ $.Model.List.prototype.push = function(arg) {
+ if(arg instanceof $.Model.List) {
+ arg = can.makeArray(arg);
+ }
+ return push.apply(this,arguments);
+ };
+});
diff --git a/model/model.js b/model/model.js
index e57626d7..72e2dc70 100644
--- a/model/model.js
+++ b/model/model.js
@@ -7,29 +7,6 @@ steal('jquery', 'can/util', 'can/model','can/observe/attributes','can/observe/se
var getter = attr && ("get" + can.classize(attr));
return typeof this[getter] === 'function' ? this[getter]() : get.apply(this,arguments);
};
- // List.get used to take a model or list of models
- var getList = $.Model.List.prototype.get;
- $.Model.List.prototype.get = function(arg) {
- var ids;
- if(arg instanceof $.Model.List) {
- ids = [];
- $.each(arg,function() {
- ids.push(this.attr('id'));
- });
- arg = ids;
- } else if(arg.attr && arg.attr('id')) {
- arg = arg.attr('id');
- }
- return getList.apply(this,arguments);
- };
- // restore the ability to push a list!arg
- var push = $.Model.List.prototype.push;
- $.Model.List.prototype.push = function(arg) {
- if(arg instanceof $.Model.List) {
- arg = can.makeArray(arg);
- }
- return push.apply(this,arguments);
- };
$.Model.prototype.update = function( attrs, success, error ) {
steal.dev.log('$.Model.update is deprecated. You can use attr + save instead.');
From 001d1f491a789278132055db39281d2024b584af Mon Sep 17 00:00:00 2001
From: Noah Sloan
Date: Fri, 7 Sep 2012 09:33:48 -0500
Subject: [PATCH 034/152] use the configured id of a model - fixes
list.get(model)
---
model/list/list.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/model/list/list.js b/model/list/list.js
index 7aa4be5d..8a3ed8c2 100644
--- a/model/list/list.js
+++ b/model/list/list.js
@@ -2,15 +2,15 @@ steal('can/model/list','jquery/model').then(function() {
// List.get used to take a model or list of models
var getList = $.Model.List.prototype.get;
$.Model.List.prototype.get = function(arg) {
- var ids;
+ var ids, id;
if(arg instanceof $.Model.List) {
ids = [];
$.each(arg,function() {
ids.push(this.attr('id'));
});
arg = ids;
- } else if(arg.attr && arg.attr('id')) {
- arg = arg.attr('id');
+ } else if(arg.attr && arg.constructor && (id = arg.attr(arg.constructor.id))) {
+ arg = id;
}
return getList.apply(this,arguments);
};
From d1bb1de19ae0f20506046cd4b029af74f908fd12 Mon Sep 17 00:00:00 2001
From: Austin McDaniel
Date: Tue, 11 Sep 2012 13:43:37 -0500
Subject: [PATCH 035/152] all .then(function must be removed if getting args
---
lang/vector/vector.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lang/vector/vector.js b/lang/vector/vector.js
index 441556af..1e6165f4 100644
--- a/lang/vector/vector.js
+++ b/lang/vector/vector.js
@@ -1,4 +1,4 @@
-steal('jquery').then(function($){
+steal('jquery', function($){
var getSetZero = function(v){ return v !== undefined ? (this.array[0] = v) : this.array[0] },
getSetOne = function(v){ return v !== undefined ? (this.array[1] = v) : this.array[1]};
From 1b5c8c25bfcf89f4a305a5238421e8329ee4877e Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Tue, 11 Sep 2012 13:02:07 -0600
Subject: [PATCH 036/152] Removing more .then
---
event/move/move.js | 2 +-
event/resize/resize.js | 2 +-
event/reverse/reverse.js | 4 ++--
lang/observe/observe.js | 2 +-
lang/string/string.js | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/event/move/move.js b/event/move/move.js
index 8fa9f2b6..2e14113b 100644
--- a/event/move/move.js
+++ b/event/move/move.js
@@ -1,4 +1,4 @@
-steal('jquery', 'jquery/event/reverse').then(function( $ ) {
+steal('jquery', 'jquery/event/reverse').then(function() {
$.event.reverse('move');
return $;
});
\ No newline at end of file
diff --git a/event/resize/resize.js b/event/resize/resize.js
index 86f61448..2e486ed3 100644
--- a/event/resize/resize.js
+++ b/event/resize/resize.js
@@ -1,4 +1,4 @@
-steal('jquery', 'jquery/event/reverse').then(function( $ ) {
+steal('jquery/event/reverse', function() {
var
// bind on the window window resizes to happen
win = $(window),
diff --git a/event/reverse/reverse.js b/event/reverse/reverse.js
index 46713218..3cc800fd 100644
--- a/event/reverse/reverse.js
+++ b/event/reverse/reverse.js
@@ -1,4 +1,4 @@
-steal('jquery', function( $ ) {
+steal('jquery', function() {
$.event.reverse = function(name, attributes) {
var bound = $(),
count = 0;
@@ -87,4 +87,4 @@ steal('jquery', function( $ ) {
}
return $;
-})
\ No newline at end of file
+})
diff --git a/lang/observe/observe.js b/lang/observe/observe.js
index c9028b62..36b79355 100644
--- a/lang/observe/observe.js
+++ b/lang/observe/observe.js
@@ -1,3 +1,3 @@
-steal('jquery', 'can/util','can/observe').then(function($, can) {
+steal('can/util', 'jquery', 'can/observe', function(can) {
$.Observe = can.Observe;
});
diff --git a/lang/string/string.js b/lang/string/string.js
index e29fb807..4cdda42b 100644
--- a/lang/string/string.js
+++ b/lang/string/string.js
@@ -36,7 +36,7 @@
* Used for vector math.
*/
//string helpers
-steal('jquery').then(function( $ ) {
+steal('jquery').then(function() {
// Several of the methods in this plugin use code adapated from Prototype
// Prototype JavaScript framework, version 1.6.0.1
// (c) 2005-2007 Sam Stephenson
From 414383d2b2cd7af1074951d220c519f0f0ed43ef Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Wed, 12 Sep 2012 08:51:42 -0600
Subject: [PATCH 037/152] Dimensions feature detection and tests, closes #50
---
dom/dimensions/dimensions.js | 54 +++++++++++++++++--------------
dom/dimensions/dimensions_test.js | 29 +++++++++++++----
dom/dimensions/styles.micro | 3 ++
3 files changed, 55 insertions(+), 31 deletions(-)
create mode 100644 dom/dimensions/styles.micro
diff --git a/dom/dimensions/dimensions.js b/dom/dimensions/dimensions.js
index ad2db757..c793af57 100644
--- a/dom/dimensions/dimensions.js
+++ b/dom/dimensions/dimensions.js
@@ -1,5 +1,5 @@
-steal('jquery', 'jquery/dom/styles', function($) {
+steal('jquery', 'jquery/dom/styles', function() {
var
//margin is inside border
@@ -12,7 +12,8 @@ var
oldOuterWidth: $.fn.outerWidth,
oldInnerWidth: $.fn.innerWidth,
oldInnerHeight: $.fn.innerHeight
- };
+ },
+ supportsSetter = $.fn.jquery >= '1.8.0';
$.each({
@@ -145,33 +146,36 @@ height:
}
//getter / setter
- $.fn["outer" + Upper] = function(v, margin) {
- var first = this[0];
- if (typeof v == 'number') {
- // Setting the value
- first && this[lower](v - getBoxes[lower](first, {padding: true, border: true, margin: margin}))
- return this;
- } else {
- // Return the old value
- return first ? checks["oldOuter" + Upper].apply(this, arguments) : null;
- }
- }
- $.fn["inner" + Upper] = function(v) {
- var first = this[0];
- if (typeof v == 'number') {
- // Setting the value
- first&& this[lower](v - getBoxes[lower](first, { padding: true }))
- return this;
- } else {
- // Return the old value
- return first ? checks["oldInner" + Upper].call(this, v) : null;
- }
- }
+ if(!supportsSetter) {
+ $.fn["outer" + Upper] = function(v, margin) {
+ var first = this[0];
+ if (typeof v == 'number') {
+ // Setting the value
+ first && this[lower](v - getBoxes[lower](first, {padding: true, border: true, margin: margin}))
+ return this;
+ } else {
+ // Return the old value
+ return first ? checks["oldOuter" + Upper].apply(this, arguments) : null;
+ }
+ }
+ $.fn["inner" + Upper] = function(v) {
+ var first = this[0];
+ if (typeof v == 'number') {
+ // Setting the value
+ first&& this[lower](v - getBoxes[lower](first, { padding: true }))
+ return this;
+ } else {
+ // Return the old value
+ return first ? checks["oldInner" + Upper].apply(this, arguments) : null;
+ }
+ }
+ }
+
//provides animations
var animate = function(boxes){
// Return the animation function
return function(fx){
- if (fx.state == 0) {
+ if (fx[supportsSetter ? 'pos' : 'state'] == 0) {
fx.start = $(fx.elem)[lower]();
fx.end = fx.end - getBoxes[lower](fx.elem,boxes);
}
diff --git a/dom/dimensions/dimensions_test.js b/dom/dimensions/dimensions_test.js
index 15cb7f0e..41db0fcd 100644
--- a/dom/dimensions/dimensions_test.js
+++ b/dom/dimensions/dimensions_test.js
@@ -1,11 +1,28 @@
steal("jquery/dom/dimensions",
- 'jquery/view/micro',
- 'funcunit/qunit').then(function(){
+ 'jquery/view/micro',
+ 'funcunit/qunit').then(function () {
-module("jquery/dom/dimensions");
+ module("jquery/dom/dimensions");
-test("outerHeight and width",function(){
- $("#qunit-test-area").html("//jquery/dom/dimensions/test/styles.micro",{})
-})
+ test("outerHeight and width", function () {
+ $("#qunit-test-area").html("//jquery/dom/dimensions/styles.micro", {});
+ var div = $("#qunit-test-area div"),
+ baseHeight = div.height();
+ equals(div.outerHeight(), baseHeight + 4, 'outerHeight() is adding border width');
+ equals(div.outerHeight(true), baseHeight + 4 + 10, 'outerHeight(true) is adding border width and margins');
+ div.outerHeight(50, true);
+ equals(div.height(), 50 - 4 - 10, 'Div height set as expected');
+ });
+
+ test("animate", function () {
+ $("#qunit-test-area").html("//jquery/dom/dimensions/styles.micro", {});
+ var div = $("#qunit-test-area div");
+ stop();
+ div.animate({ outerHeight : 50 }, 100, function() {
+ div.outerHeight(50, true);
+ equals(div.height(), 50 - 4 - 10, 'Div height animated as expected');
+ start();
+ });
+ });
});
\ No newline at end of file
diff --git a/dom/dimensions/styles.micro b/dom/dimensions/styles.micro
new file mode 100644
index 00000000..7c7503ca
--- /dev/null
+++ b/dom/dimensions/styles.micro
@@ -0,0 +1,3 @@
+
+Here is some content;
+
\ No newline at end of file
From d2acb77484f312b5b92c3ee01f8e080bf69fb092 Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Wed, 12 Sep 2012 10:00:15 -0600
Subject: [PATCH 038/152] Removing more steal.then, updating changelog, tests
passing with jQuery 1.8.1
---
changelog.md | 1 +
dom/dimensions/test/outer.micro | 0
dom/dimensions/test/styles.micro | 3 ---
event/move/move.js | 2 +-
lang/string/deparam/deparam.js | 2 +-
lang/string/rsplit/rsplit.js | 2 +-
lang/string/string.js | 2 +-
7 files changed, 5 insertions(+), 7 deletions(-)
delete mode 100644 dom/dimensions/test/outer.micro
delete mode 100644 dom/dimensions/test/styles.micro
diff --git a/changelog.md b/changelog.md
index 40e47d6e..d4bb21c8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -4,6 +4,7 @@ __1.0.0__
- feature: [dragcleanup event](https://github.com/jupiterjs/jquerypp/pull/43)
- feature: [Reverse and move event](https://github.com/jupiterjs/jquerypp/issues/25)
+- feature: jQuery 1.8.0 compatibility
- fix: [pass through scrollTop in animate](https://github.com/jupiterjs/jquerypp/pull/40)
- fix: [Fastfix: Original can be undefined](https://github.com/jupiterjs/jquerypp/pull/45)
- fix: [Animate Scroll not working](https://github.com/jupiterjs/jquerypp/issues/35)
diff --git a/dom/dimensions/test/outer.micro b/dom/dimensions/test/outer.micro
deleted file mode 100644
index e69de29b..00000000
diff --git a/dom/dimensions/test/styles.micro b/dom/dimensions/test/styles.micro
deleted file mode 100644
index 7c7503ca..00000000
--- a/dom/dimensions/test/styles.micro
+++ /dev/null
@@ -1,3 +0,0 @@
-
-Here is some content;
-
\ No newline at end of file
diff --git a/event/move/move.js b/event/move/move.js
index 2e14113b..f85e7136 100644
--- a/event/move/move.js
+++ b/event/move/move.js
@@ -1,4 +1,4 @@
-steal('jquery', 'jquery/event/reverse').then(function() {
+steal('jquery', 'jquery/event/reverse', function() {
$.event.reverse('move');
return $;
});
\ No newline at end of file
diff --git a/lang/string/deparam/deparam.js b/lang/string/deparam/deparam.js
index 0f9dd0bd..e490730c 100644
--- a/lang/string/deparam/deparam.js
+++ b/lang/string/deparam/deparam.js
@@ -1,4 +1,4 @@
-steal('jquery', function($){
+steal('jquery', function() {
var digitTest = /^\d+$/,
keyBreaker = /([^\[\]]+)|(\[\])/g,
diff --git a/lang/string/rsplit/rsplit.js b/lang/string/rsplit/rsplit.js
index 8b60bc7c..865a8b56 100644
--- a/lang/string/rsplit/rsplit.js
+++ b/lang/string/rsplit/rsplit.js
@@ -1,4 +1,4 @@
-steal('jquery/lang/string',function( $ ) {
+steal('jquery/lang/string', function() {
/**
* @add jQuery.String
*/
diff --git a/lang/string/string.js b/lang/string/string.js
index 4cdda42b..35dd2ab4 100644
--- a/lang/string/string.js
+++ b/lang/string/string.js
@@ -36,7 +36,7 @@
* Used for vector math.
*/
//string helpers
-steal('jquery').then(function() {
+steal('jquery', function() {
// Several of the methods in this plugin use code adapated from Prototype
// Prototype JavaScript framework, version 1.6.0.1
// (c) 2005-2007 Sam Stephenson
From 4aad411e3095951d2550d417e506e3d2067ac196 Mon Sep 17 00:00:00 2001
From: David Luecke
Date: Fri, 14 Sep 2012 09:34:54 -0600
Subject: [PATCH 039/152] Animation chaining with easing works, closes #37
---
dom/animate/animate.html | 33 +-
dom/animate/animate.js | 4 +-
dom/animate/animate_test.js | 2621 +++++++++++++++++++++--------------
dom/animate/qunit.html | 387 +++---
4 files changed, 1818 insertions(+), 1227 deletions(-)
diff --git a/dom/animate/animate.html b/dom/animate/animate.html
index 27655466..d6d2e460 100644
--- a/dom/animate/animate.html
+++ b/dom/animate/animate.html
@@ -1,16 +1,16 @@
-
- Animate Demo
-
-
-
+
+ Animate Demo
+
+
+
@@ -21,16 +21,11 @@
src='../../../steal/steal.js'>
\ No newline at end of file
diff --git a/dom/animate/animate.js b/dom/animate/animate.js
index a1505ed5..e33d26c1 100644
--- a/dom/animate/animate.js
+++ b/dom/animate/animate.js
@@ -1,4 +1,4 @@
-steal('jquery', 'jquery/dom/styles').then(function ($) {
+steal('jquery', 'jquery/dom/styles', function () {
// Overwrites `jQuery.fn.animate` to use CSS 3 animations if possible
@@ -244,7 +244,7 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
}));
// Call the original callback
- if (optall.old && exec) {
+ if ($.isFunction(optall.old) && exec) {
// Call success, pass the DOM element as the this reference
optall.old.call(self[0], true)
}
diff --git a/dom/animate/animate_test.js b/dom/animate/animate_test.js
index 5f8009d1..c8294360 100644
--- a/dom/animate/animate_test.js
+++ b/dom/animate/animate_test.js
@@ -2,1250 +2,1833 @@ steal('jquery', 'jquery/dom/animate', 'funcunit/qunit', 'qunit.css', function ($
module("jquery/dom/animate");
- test("sanity check", function () {
- expect(1);
- ok(jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects");
- });
+ if ( jQuery.fx ) {
+ test("sanity check", function() {
+ expect(1);
+ ok( jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" );
+ });
- test("show()", function () {
- expect(28);
+ test("show()", function() {
+ expect(26);
- var hiddendiv = jQuery("div.hidden");
+ var hiddendiv = jQuery("div.hidden");
- hiddendiv.hide().show();
+ hiddendiv.hide().show();
- equal(hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible.");
+ equal( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." );
- var div = jQuery("
").hide().appendTo("#qunit-fixture").show();
+ var div = jQuery("
");
-
- var old = jQuery("#test-table").show().css("display") !== "table";
- jQuery("#test-table").remove();
-
- var test = {
- "div" : "block",
- "p" : "block",
- "a" : "inline",
- "code" : "inline",
- "pre" : "block",
- "span" : "inline",
- "table" : old ? "block" : "table",
- "thead" : old ? "block" : "table-header-group",
- "tbody" : old ? "block" : "table-row-group",
- "tr" : old ? "block" : "table-row",
- "th" : old ? "block" : "table-cell",
- "td" : old ? "block" : "table-cell",
- "ul" : "block",
- "li" : old ? "block" : "list-item"
- };
- jQuery.each(test, function (selector, expected) {
- var elem = jQuery(selector, "#show-tests").show();
- equal(elem.css("display"), expected, "Show using correct display type for " + selector);
- });
-
- // Make sure that showing or hiding a text node doesn't cause an error
- jQuery("
test
text test").show().remove();
- jQuery("
test
text test").hide().remove();
- });
-
- test("show(Number) - other displays", function () {
- expect(15);
- QUnit.reset();
- stop();
-
- // #show-tests * is set display: none in CSS
- jQuery("#qunit-fixture").append("
");
-
- var old = jQuery("#test-table").show().css("display") !== "table",
- num = 0;
- jQuery("#test-table").remove();
-
- var test = {
- "div" : "block",
- "p" : "block",
- "a" : "inline",
- "code" : "inline",
- "pre" : "block",
- "span" : "inline",
- "table" : old ? "block" : "table",
- "thead" : old ? "block" : "table-header-group",
- "tbody" : old ? "block" : "table-row-group",
- "tr" : old ? "block" : "table-row",
- "th" : old ? "block" : "table-cell",
- "td" : old ? "block" : "table-cell",
- "ul" : "block",
- "li" : old ? "block" : "list-item"
- };
+ // #show-tests * is set display: none in CSS
+ jQuery("#qunit-fixture").append("
");
+
+ var old = jQuery("#test-table").show().css("display") !== "table";
+ jQuery("#test-table").remove();
+
+ var test = {
+ "div" : "block",
+ "p" : "block",
+ "a" : "inline",
+ "code" : "inline",
+ "pre" : "block",
+ "span" : "inline",
+ "table" : old ? "block" : "table",
+ "thead" : old ? "block" : "table-header-group",
+ "tbody" : old ? "block" : "table-row-group",
+ "tr" : old ? "block" : "table-row",
+ "th" : old ? "block" : "table-cell",
+ "td" : old ? "block" : "table-cell",
+ "ul" : "block",
+ "li" : old ? "block" : "list-item"
+ };
- jQuery.each(test, function (selector, expected) {
- var elem = jQuery(selector, "#show-tests").show(1, function () {
- equal(elem.css("display"), expected, "Show using correct display type for " + selector);
- if (++num === 15) {
- start();
- }
+ jQuery.each(test, function(selector, expected) {
+ var elem = jQuery(selector, "#show-tests").show();
+ equal( elem.css("display"), expected, "Show using correct display type for " + selector );
});
- });
- });
+ jQuery("#show-tests").remove();
-// Supports #7397
- test("Persist correct display value", function () {
- expect(3);
- QUnit.reset();
- stop();
-
- // #show-tests * is set display: none in CSS
- jQuery("#qunit-fixture").append("
foo
");
-
- var $span = jQuery("#show-tests span"),
- displayNone = $span.css("display"),
- display = "", num = 0;
-
- $span.show();
+ // Make sure that showing or hiding a text node doesn't cause an error
+ jQuery("
test
text test").show().remove();
+ jQuery("
test
text test").hide().remove();
+ });
- display = $span.css("display");
+ test("show(Number) - other displays", function() {
+ expect(15);
+ QUnit.reset();
+ stop();
- $span.hide();
+ // #show-tests * is set display: none in CSS
+ jQuery("#qunit-fixture").append("
");
+
+ var old = jQuery("#test-table").show().css("display") !== "table",
+ num = 0;
+ jQuery("#test-table").remove();
+
+ var test = {
+ "div" : "block",
+ "p" : "block",
+ "a" : "inline",
+ "code" : "inline",
+ "pre" : "block",
+ "span" : "inline",
+ "table" : old ? "block" : "table",
+ "thead" : old ? "block" : "table-header-group",
+ "tbody" : old ? "block" : "table-row-group",
+ "tr" : old ? "block" : "table-row",
+ "th" : old ? "block" : "table-cell",
+ "td" : old ? "block" : "table-cell",
+ "ul" : "block",
+ "li" : old ? "block" : "list-item"
+ };
- $span.fadeIn(100, function () {
- equal($span.css("display"), display, "Expecting display: " + display);
- $span.fadeOut(100, function () {
- equal($span.css("display"), displayNone, "Expecting display: " + displayNone);
- $span.fadeIn(100, function () {
- equal($span.css("display"), display, "Expecting display: " + display);
- start();
+ jQuery.each(test, function(selector, expected) {
+ var elem = jQuery(selector, "#show-tests").show(1, function() {
+ equal( elem.css("display"), expected, "Show using correct display type for " + selector );
+ if ( ++num === 15 ) {
+ start();
+ }
});
});
+
+ jQuery("#show-tests").remove();
});
- });
- test("show() resolves correct default display #8099", function () {
- expect(7);
- var tt8099 = jQuery("").appendTo("body"),
- dfn8099 = jQuery("", { html : "foo"}).appendTo("body");
- equal(tt8099.css("display"), "none", "default display override for all tt");
- equal(tt8099.show().css("display"), "inline", "Correctly resolves display:inline");
- equal(jQuery("#foo").hide().show().css("display"), "block", "Correctly resolves display:block after hide/show");
+// Supports #7397
+ test("Persist correct display value", function() {
+ expect(3);
+ QUnit.reset();
+ stop();
- equal(tt8099.hide().css("display"), "none", "default display override for all tt");
- equal(tt8099.show().css("display"), "inline", "Correctly resolves display:inline");
+ // #show-tests * is set display: none in CSS
+ jQuery("#qunit-fixture").append("