Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

v1.5.3-beta. Response data for html ajaxy links now returns outerHTML…

… instead of innerHTML for head and body elements.
  • Loading branch information...
commit 0d6d61fe8522cd97091ed32781e16fb4db3802b9 1 parent 7154e68
@balupton authored
View
15 README.txt
@@ -19,7 +19,7 @@
* - A copy of our interpretation of the license used.
* If not, see <http://github.com/balupton/jquery-ajaxy/blob/master/COPYING.txt>.
*
- * @version 1.5.2-beta
+ * @version 1.5.3-beta
* @date August 07, 2010
* @since v0.1.0-dev, July 24, 2008
* @category jquery-plugin
@@ -47,6 +47,19 @@ Known Issues:
Changelog:
+v1.5.3-beta, August 07, 2010
+- The Response.data returned on normal html ajaxy links is now as follows:
+ {
+ "controller": controller,
+ "responseText": responseText, /* raw result */
+ "html": html, /* raw result put through Ajaxy.htmlCompat */
+ "title": title, /* the text of the title/#ajaxy-title element */
+ "head": head, /* the outerHTML of the head/#ajaxy-head element */
+ "body": body, /* the outerHTML of the body/#ajaxy-body element */
+ "content": content /* the innerHTML of the body/#ajaxy-body element or the html value */
+ }
+- Updated jQuery Sparkle dependencies to [v1.4.10-beta, August 07, 2010]
+
v1.5.2-beta, August 07, 2010
- Added the Ajaxy.htmlCompat function which will convert a html document into a jQuery compatible document.
This is based on old functionality and includes fixes.
View
9,565 scripts/closure.map
4,797 additions, 4,768 deletions not shown
View
26 scripts/jquery.ajaxy.js
@@ -946,6 +946,21 @@ String.prototype.queryStringToJSON = String.prototype.queryStringToJSON || funct
};
+ /**
+ * Get a elements html including it's own tag
+ * @version 1.0.1
+ * @date August 07, 2010
+ * @since 1.0.0, August 07, 2010
+ * @package jquery-sparkle {@link http://www.balupton/projects/jquery-sparkle}
+ * @author Benjamin "balupton" Lupton {@link http://www.balupton.com}
+ * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://www.balupton.com}
+ * @license GNU Affero General Public License version 3 {@link http://www.gnu.org/licenses/agpl-3.0.html}
+ */
+ $.fn.htmlAndSelf = $.fn.htmlAndSelf || function(){
+ // Get a elements html including it's own tag
+ return $(this).attr('outerHTML');
+ };
+
})(jQuery);/**
* @depends jquery
* @name jquery.utilities
@@ -1737,7 +1752,7 @@ String.prototype.queryStringToJSON = String.prototype.queryStringToJSON || funct
/**
* jQuery Ajaxy
- * @version 1.5.2
+ * @version 1.5.3
* @date August 07, 2010
* @since 0.1.0-dev, July 24, 2008
* @package jquery-ajaxy {@link http://www.balupton/projects/jquery-ajaxy}
@@ -3181,11 +3196,10 @@ String.prototype.queryStringToJSON = String.prototype.queryStringToJSON || funct
$title = $html.find('#ajaxy-title'),
$controller = $html.find('#ajaxy-controller'), /* special case support for controller in html pages */
title = ($title.length ? $title.text() : ''),
- head = ($head.length ? $head.html() : ''),
- body = ($body.length ? $body.html() : ''),
- content = (body || html),
- controller = ($controller.length ? $controller.text() : null);
- // ^ We do the above workaround with element types as jQuery does not support loadin in documents
+ head = ($head.length ? $head.htmlAndSelf() : ''),
+ body = ($body.length ? $body.htmlAndSelf() : ''),
+ content = ($body.length ? $body.html() : html),
+ controller = ($controller.length ? $controller.text().trim() : null);
// Create
responseData = {
View
9 scripts/jquery.ajaxy.min.js
@@ -35,6 +35,7 @@
GNU Affero General Public License version 3 {@link http://www.gnu.org/licenses/agpl-3.0.html}
GNU Affero General Public License version 3 {@link http://www.gnu.org/licenses/agpl-3.0.html}
GNU Affero General Public License version 3 {@link http://www.gnu.org/licenses/agpl-3.0.html}
+ GNU Affero General Public License version 3 {@link http://www.gnu.org/licenses/agpl-3.0.html}
*/
if(typeof window.console!=="object"||typeof window.console.emulated==="undefined"){if(typeof window.console!=="object"||typeof window.console.log!=="function"){window.console={};window.console.log=window.console.debug=window.console.warn=window.console.trace=function(){};window.console.error=function(){alert("An error has occured. Please use another browser to obtain more detailed information.")}}else{if(typeof window.console.debug==="undefined")window.console.debug=function(){for(var c=["console.debug:"],
a=0;a<arguments.length;a++)c.push(arguments[a]);window.console.log.apply(window.console,c)};if(typeof window.console.warn==="undefined")window.console.warn=function(){for(var c=["console.warn:"],a=0;a<arguments.length;a++)c.push(arguments[a]);window.console.log.apply(window.console,c)};if(typeof window.console.error==="undefined")window.console.error=function(){for(var c=["console.error"],a=0;a<arguments.length;a++)c.push(arguments[a]);window.console.log.apply(window.console,c)};if(typeof window.console.trace===
@@ -56,7 +57,7 @@ function(){return c(this).findAndSelf(":input").filter(":first")};c.fn.choose=c.
break;case a.is(":checkbox"):a.attr("checked",false);break;case a.is(":radio"):a.attr("checked",false);break;case a.is("select"):a.val(a.find("option:first").val());break;default:break}return this};c.fn.wouldSubmit=c.fn.wouldSubmit||function(){var a=c(this).findAndSelf(":input"),b=true;if(!a.length||!(a.attr("name")||0)||a.is(":radio,:checkbox")&&!a.is(":selected,:checked"))b=false;return b};c.fn.values=c.fn.values||function(){var a={};c(this).findAndSelf(":input").each(function(){var b=c(this),d=
b.attr("name")||null,e=b.val();if(!b.wouldSubmit())return true;if(d.indexOf("[]")!==-1){if(typeof a[d]==="undefined")a[d]=[];a[d].push(e)}else a[d]=e});return a};c.fn.submitForm=c.fn.submitForm||function(){var a=c(this);a.parentsAndSelf("form:first").trigger("submit");return a};c.fn.inDOM=c.fn.inDOM||function(){var a=c(this).parent().parent();return a.size()&&(a.height()||a.width())};c.fn.valWrap=c.fn.valWrap||function(a,b){var d=c(this);return d.val(d.val().wrap(a,b))};c.fn.valWrapSelection=c.fn.valWrapSelection||
function(a,b,d,e){var f=c(this),g=f.get(0);a=a||"";b=b||"";if(d||e)f.val(f.val().wrapSelection(a,b,d,e));else{d=g.selectionStart;e=g.selectionEnd;if(document.selection){g.focus();d=document.selection.createRange();d.text=a+d.text+b}else{var h=g.scrollTop;f.val(f.val().wrapSelection(a,b,d,e));g.focus();g.selectionStart=d+a.length;g.selectionEnd=e+a.length;g.scrollTop=h}}return f};c.fn.giveFocus=c.fn.giveFocus||function(){c(this).findAndSelf(":input:visible:first").focus();return this};c.fn.highlight=
-c.fn.highlight||function(a){return c(this).effect("highlight",{},a||3E3)}})(jQuery);
+c.fn.highlight||function(a){return c(this).effect("highlight",{},a||3E3)};c.fn.htmlAndSelf=c.fn.htmlAndSelf||function(){return c(this).attr("outerHTML")}})(jQuery);
(function(c){c.prepareObject=c.prepareObject||function(a,b){var d={};c.extend(d,a||{});c.intercept(true,d,b);var e=arguments;e[0]=e[1]="$.prepareObject.skipValue";c.each(e,function(f,g){if(g==="$.prepareObject.skipValue")return true;c.intercept(true,d,g)});return d};c.intercept=c.intercept||function(){var a=arguments,b,d=false,e=false;if(typeof a[0]==="boolean"){d=a[0];a[0]="$.intercept.skipValue";if(typeof a[1]==="boolean"){e=a[1];a[1]="$.intercept.skipValue";if(e)b={};else{b=a[2];a[2]="$.intercept.skipValue"}}else{b=
a[1];a[1]="$.intercept.skipValue"}}else{b=a[0];a[0]="$.intercept.skipValue"}var f={};c.each(b,function(g){f[g]=true});d?c.each(a,function(g,h){if(h==="$.intercept.skipValue")return true;c.each(h,function(j,i){if(typeof f[j]==="undefined")return true;if(typeof i==="object"&&!(i.test||0))c.extend(b[j],i||{});else b[j]=i})}):c.each(a,function(g,h){c.each(h,function(j,i){if(typeof f[j]==="undefined")return true;if(typeof i==="object"&&!(i.test||0))c.intercept(true,b[j],i);else b[j]=i})});return b}})(jQuery);
(function(c){function a(d){return typeof d=="object"?d:{top:d,left:d}}var b=c.scrollTo=function(d,e,f){c(window).scrollTo(d,e,f)};b.defaults={axis:"xy",duration:parseFloat(c.fn.jquery)>=1.3?0:1};b.window=function(){return c(window)._scrollable()};c.fn._scrollable=function(){return this.map(function(){if(!(!this.nodeName||c.inArray(this.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1))return this;var d=(this.contentWindow||this).document||this.ownerDocument||this;return c.browser.safari||
@@ -95,9 +96,9 @@ f.controller])}if(f.Error.callback)if(f.Error.callback.apply(f,arguments)||p==="
n=c('<input type="hidden" name="ajax" value="true"/>').appendTo(j),k=c('<input type="hidden" name="Ajaxy[form]" value="true"/>').appendTo(j);i.bind("load",function(){if((this.document||this.currentDocument||this.contentWindow.document).location.href==="about:blank")return true;var l=i.contents().find(".response").val(),m=false;try{m=c.parseJSON(l)}catch(r){window.console.error("Ajaxy.request.form: Invalid Response.",[this,arguments],[l])}m?request.success(m):request.error(m);j.removeAttr("target");
i.remove();n.remove();k.remove()});j.attr("target",e);j.submit();h=j.values();g.data=c.extend(true,g.data,h||{});e=true}else{h=j.values();g.data=c.extend(true,g.data,h||{})}}h=true;f.Request=g;e||(h=b.ajax(g));return h}},htmlCompat:function(a){return String(a).replace(/<\!DOCTYPE[^>]*>/i,"").replace(/<(html|head|body|title|meta)/gi,'<div id="ajaxy-$1"').replace(/<\/(html|head|body|title|meta)/gi,"</div")},ajax:function(a){var b=c.Ajaxy;b.options.debug&&window.console.debug("Ajaxy.ajax:",[this,arguments]);
var d={};d.success=a.success||function(){b.options.debug&&window.console.debug("Ajaxy.ajax.callbacks.success:",[this,arguments]);c(".error").empty()};d.error=a.error||function(f,g,h){b.options.debug&&window.console.debug("Ajaxy.ajax.callbacks.error:",[this,arguments]);c(".error").html(h)};d.complete=a.complete||function(){b.options.debug&&window.console.debug("Ajaxy.ajax.callbacks.complete:",[this,arguments])};delete a.success;delete a.error;delete a.complete;var e={type:"post",dataType:b.options.support_text?
-"text":"json"};c.extend(true,e,a);e.success=function(f,g){b.options.debug&&window.console.debug("Ajaxy.ajax.request.success:",[this,arguments]);var h={};if(typeof f!=="object"&&b.options.support_text&&f)try{h=c.parseJSON(f)}catch(j){h=b.htmlCompat(f);var i=c(h),n=i.find("#ajaxy-head"),k=i.find("#ajaxy-body"),l=i.find("#ajaxy-title");i=i.find("#ajaxy-controller");l=l.length?l.text():"";n=n.length?n.html():"";var m=(k=k.length?k.html():"")||h;h={controller:i.length?i.text():null,responseText:f,html:h,
-title:l,head:n,body:k,content:m}}else h=f;b.options.debug&&window.console.debug("Ajaxy.ajax.success:",[this,arguments]);if(typeof h.controller==="undefined"&&(typeof h.success!=="undefined"&&!h.success||typeof h.error!=="undefined"&&h.error))return d.error.apply(this,[null,g,h.error||true,h]);return d.success.apply(this,[h,g])};e.error=function(f,g,h){b.options.debug&&window.console.debug("Ajaxy.ajax.request.error:",[this,arguments]);var j=f.responseText||false;if(j)j=j.trim();j||(j=false);var i=
-{error:h||true,responseText:j};if(j)try{i=c.parseJSON(j)}catch(n){}finally{return this.success.apply(this,[i,g])}return d.error.apply(this,[f,g,h,i])};return c.ajax(e)},stateChange:function(a){c.Ajaxy.request(a)},configure:function(a){var b=c.Ajaxy,d=c.History;a=a||{};var e=a.Controllers||a.controllers||a;b.options=c.extend(true,b.options,a.options||a);b.bind(e);b.options.root_url=(b.options.root_url||document.location.protocol.toString()+"//"+document.location.hostname.toString()).replace(/\/+$/,
+"text":"json"};c.extend(true,e,a);e.success=function(f,g){b.options.debug&&window.console.debug("Ajaxy.ajax.request.success:",[this,arguments]);var h={};if(typeof f!=="object"&&b.options.support_text&&f)try{h=c.parseJSON(f)}catch(j){h=b.htmlCompat(f);var i=c(h),n=i.find("#ajaxy-head"),k=i.find("#ajaxy-body"),l=i.find("#ajaxy-title");i=i.find("#ajaxy-controller");l=l.length?l.text():"";n=n.length?n.htmlAndSelf():"";var m=k.length?k.htmlAndSelf():"";k=k.length?k.html():h;h={controller:i.length?i.text().trim():
+null,responseText:f,html:h,title:l,head:n,body:m,content:k}}else h=f;b.options.debug&&window.console.debug("Ajaxy.ajax.success:",[this,arguments]);if(typeof h.controller==="undefined"&&(typeof h.success!=="undefined"&&!h.success||typeof h.error!=="undefined"&&h.error))return d.error.apply(this,[null,g,h.error||true,h]);return d.success.apply(this,[h,g])};e.error=function(f,g,h){b.options.debug&&window.console.debug("Ajaxy.ajax.request.error:",[this,arguments]);var j=f.responseText||false;if(j)j=j.trim();
+j||(j=false);var i={error:h||true,responseText:j};if(j)try{i=c.parseJSON(j)}catch(n){}finally{return this.success.apply(this,[i,g])}return d.error.apply(this,[f,g,h,i])};return c.ajax(e)},stateChange:function(a){c.Ajaxy.request(a)},configure:function(a){var b=c.Ajaxy,d=c.History;a=a||{};var e=a.Controllers||a.controllers||a;b.options=c.extend(true,b.options,a.options||a);b.bind(e);b.options.root_url=(b.options.root_url||document.location.protocol.toString()+"//"+document.location.hostname.toString()).replace(/\/+$/,
"")+"/";b.options.base_url=b.options.base_url||"";b.options.relative_url=b.extractState(b.options.relative_url||document.location.pathname.toString());if(b.options.relative_as_base)if(b.options.base_url.length===0){b.options.base_url=b.options.relative_url;b.options.relative_url=""}b.options.root_url=b.options.root_url.replace(/\/+$/,"");b.options.base_url=b.options.base_url.replace(/\/+$/,"");b.options.relative_url=b.extractRelativeUrl(b.options.relative_url);if(b.options.root_url==="/")b.options.root_url=
"";if(b.options.base_url==="/")b.options.base_url="";if(b.options.relative_url==="/")b.options.relative_url="";b.options.debug&&window.console.debug("Ajaxy.configure:",[this,arguments]);if(b.options.redirect&&b.options.relative_url&&b.options.relative_url!==null){b=b.options.root_url+b.options.base_url+"#"+b.options.relative_url;if(d=d.getHash())b+="?anchor="+d;document.location=b}return true},construct:function(){var a=c.Ajaxy,b=c.History;if(!a.constructed){a.constructed=true;b.bind(function(d){return a.stateChange(d)});
c.fn.ajaxify=a.ajaxify;c.fn.ajaxy=a.ajaxify;c(function(){a.domReady();b.domReady()});return true}},domReady:function(){c.Sparkle&&c.Sparkle.addExtension("ajaxy",function(){c(this).ajaxify()});return true},ajaxify:function(){var a=c.Ajaxy,b=c(this);c.each(a.Controllers,function(d){a.ajaxifyController(d)});a.options.track_all_internal_links&&b.findAndSelf("a[href^=/],a[href^=./]").filter(":not(.ajaxy,.no-ajaxy)").addClass("ajaxy");a.options.track_all_anchors&&b.findAndSelf("a[href^=#]:not(.ajaxy,.no-ajaxy)").addClass("ajaxy");
View
11 scripts/resources/jquery.ajaxy.js
@@ -18,7 +18,7 @@
/**
* jQuery Ajaxy
- * @version 1.5.2
+ * @version 1.5.3
* @date August 07, 2010
* @since 0.1.0-dev, July 24, 2008
* @package jquery-ajaxy {@link http://www.balupton/projects/jquery-ajaxy}
@@ -1462,11 +1462,10 @@
$title = $html.find('#ajaxy-title'),
$controller = $html.find('#ajaxy-controller'), /* special case support for controller in html pages */
title = ($title.length ? $title.text() : ''),
- head = ($head.length ? $head.html() : ''),
- body = ($body.length ? $body.html() : ''),
- content = (body || html),
- controller = ($controller.length ? $controller.text() : null);
- // ^ We do the above workaround with element types as jQuery does not support loadin in documents
+ head = ($head.length ? $head.htmlAndSelf() : ''),
+ body = ($body.length ? $body.htmlAndSelf() : ''),
+ content = ($body.length ? $body.html() : html),
+ controller = ($controller.length ? $controller.text().trim() : null);
// Create
responseData = {
View
15 scripts/resources/jquery.extra.js
@@ -323,4 +323,19 @@
};
+ /**
+ * Get a elements html including it's own tag
+ * @version 1.0.1
+ * @date August 07, 2010
+ * @since 1.0.0, August 07, 2010
+ * @package jquery-sparkle {@link http://www.balupton/projects/jquery-sparkle}
+ * @author Benjamin "balupton" Lupton {@link http://www.balupton.com}
+ * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://www.balupton.com}
+ * @license GNU Affero General Public License version 3 {@link http://www.gnu.org/licenses/agpl-3.0.html}
+ */
+ $.fn.htmlAndSelf = $.fn.htmlAndSelf || function(){
+ // Get a elements html including it's own tag
+ return $(this).attr('outerHTML');
+ };
+
})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.