rails-backbone-generator 0.0.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +15 -0
  2. data/README.md +18 -15
  3. data/lib/generators/backbone_generator.rb +1 -1
  4. data/lib/generators/{backbone → backbone_generator}/collection_generator.rb +9 -9
  5. data/lib/generators/{backbone → backbone_generator}/model_generator.rb +10 -10
  6. data/lib/generators/{backbone → backbone_generator}/namespace_generator.rb +18 -21
  7. data/lib/generators/{backbone → backbone_generator}/setup_generator.rb +25 -24
  8. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/Guardfile +4 -4
  9. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/app/assets/javascripts/application.js +7 -7
  10. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/app/assets/javascripts/shared/core_extentions/collections_extentions.coffee +8 -8
  11. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/app/assets/javascripts/shared/helpers/.gitkeep +0 -0
  12. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/app/assets/javascripts/shared/utils/.gitkeep +0 -0
  13. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/spec/javascripts/fixtures/.gitkeep +0 -0
  14. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/spec/javascripts/helpers/association_helpers.coffee +0 -0
  15. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/spec/javascripts/helpers/common_helpers.coffee +2 -2
  16. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/spec/javascripts/helpers/fake_host.coffee +3 -3
  17. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/spec/javascripts/helpers/headless_webkit_helper.coffee +0 -0
  18. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/spec/javascripts/support/jasmine.yml +0 -0
  19. data/lib/generators/backbone_generator/setup_generator/templates/vendor/assets/javascripts/backbone/backbone-1.1.0.js +1581 -0
  20. data/lib/generators/{backbone/setup_generator/templates/vendor/assets/javascripts/backbone/backbone-bind-to-1.0.0.coffee → backbone_generator/setup_generator/templates/vendor/assets/javascripts/backbone/backbone-bind-to-1.1.0.coffee} +23 -12
  21. data/lib/generators/backbone_generator/setup_generator/templates/vendor/assets/javascripts/backbone/backbone-handlebars-1.0.0.coffee +89 -0
  22. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/vendor/assets/javascripts/backbone/backbone-query-0.2.3.coffee +0 -0
  23. data/lib/generators/backbone_generator/setup_generator/templates/vendor/assets/javascripts/backbone/backbone-relational-0.8.6.js +1943 -0
  24. data/lib/generators/backbone_generator/setup_generator/templates/vendor/assets/javascripts/backbone/handlebars-1.1.2.js +2595 -0
  25. data/lib/generators/{backbone/setup_generator/templates/vendor/assets/javascripts/backbone/underscore-1.3.3.js → backbone_generator/setup_generator/templates/vendor/assets/javascripts/backbone/underscore-1.5.2.js} +529 -312
  26. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/vendor/assets/javascripts/browser_compatibility/json2.js +5 -6
  27. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/vendor/assets/javascripts/browser_compatibility/localstorage-polyfill.js +12 -12
  28. data/lib/generators/{backbone/setup_generator/templates/vendor/assets/javascripts/jquery/jquery-1.8.0.js → backbone_generator/setup_generator/templates/vendor/assets/javascripts/jquery/jquery-1.10.2.js} +4633 -4071
  29. data/lib/generators/backbone_generator/setup_generator/templates/vendor/assets/javascripts/jquery/jquery-ui-1.10.3.js +15003 -0
  30. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/vendor/assets/javascripts/jquery/jquery.easing-1.3.js +33 -33
  31. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/vendor/assets/javascripts/jquery/jquery_ujs.js +162 -136
  32. data/lib/generators/{backbone → backbone_generator}/setup_generator/templates/vendor/assets/javascripts/testing/backbone-factory.js +4 -4
  33. data/lib/generators/backbone_generator/setup_generator/templates/vendor/assets/javascripts/testing/jasmine-jquery-1.5.93.js +700 -0
  34. data/lib/generators/backbone_generator/setup_generator/templates/vendor/assets/javascripts/testing/jasmine-sinon-0.2.1.js +43 -0
  35. data/lib/generators/backbone_generator/setup_generator/templates/vendor/assets/javascripts/testing/mock-ajax-2.0.0.js +264 -0
  36. data/lib/generators/{backbone/setup_generator/templates/vendor/assets/javascripts/testing/sinon-1.4.2.js → backbone_generator/setup_generator/templates/vendor/assets/javascripts/testing/sinon-1.7.3.js} +686 -477
  37. data/lib/generators/{backbone → backbone_generator}/templates/app/assets/javascripts/%namespace%.coffee.tt +0 -1
  38. data/lib/generators/{backbone → backbone_generator}/templates/app/assets/javascripts/%namespace%/collections/%collection_name%.coffee.tt +0 -0
  39. data/lib/generators/{backbone → backbone_generator}/templates/app/assets/javascripts/%namespace%/collections/.gitkeep +0 -0
  40. data/lib/generators/{backbone → backbone_generator}/templates/app/assets/javascripts/%namespace%/models/%model_name%.coffee.tt +2 -2
  41. data/lib/generators/{backbone → backbone_generator}/templates/app/assets/javascripts/%namespace%/models/.gitkeep +0 -0
  42. data/lib/generators/{backbone → backbone_generator}/templates/app/assets/javascripts/%namespace%/routes/.gitkeep +0 -0
  43. data/lib/generators/{backbone → backbone_generator}/templates/app/assets/javascripts/%namespace%/templates/.gitkeep +0 -0
  44. data/lib/generators/{backbone → backbone_generator}/templates/app/assets/javascripts/%namespace%/views/.gitkeep +0 -0
  45. data/lib/generators/{backbone → backbone_generator}/templates/spec/javascripts/%namespace%/collections/%collection_name%_spec.coffee.tt +1 -1
  46. data/lib/generators/{backbone → backbone_generator}/templates/spec/javascripts/%namespace%/collections/.gitkeep +0 -0
  47. data/lib/generators/{backbone → backbone_generator}/templates/spec/javascripts/%namespace%/factories/%model_name%_factory.coffee.tt +1 -1
  48. data/lib/generators/{backbone → backbone_generator}/templates/spec/javascripts/%namespace%/factories/.gitkeep +0 -0
  49. data/lib/generators/{backbone → backbone_generator}/templates/spec/javascripts/%namespace%/models/%model_name%_spec.coffee.tt +3 -4
  50. data/lib/generators/{backbone → backbone_generator}/templates/spec/javascripts/%namespace%/models/.gitkeep +0 -0
  51. data/lib/generators/{backbone → backbone_generator}/templates/spec/javascripts/%namespace%/views/.gitkeep +0 -0
  52. data/lib/rails_backbone_generator/version.rb +1 -1
  53. metadata +53 -59
  54. data/lib/generators/backbone/setup_generator/templates/vendor/assets/javascripts/backbone/backbone-0.9.2.js +0 -1431
  55. data/lib/generators/backbone/setup_generator/templates/vendor/assets/javascripts/backbone/backbone-handlebars-1.0.0.js +0 -121
  56. data/lib/generators/backbone/setup_generator/templates/vendor/assets/javascripts/backbone/backbone-relational-0.6.0.js +0 -1687
  57. data/lib/generators/backbone/setup_generator/templates/vendor/assets/javascripts/backbone/handlebars-1.0.rc.1.js +0 -1920
  58. data/lib/generators/backbone/setup_generator/templates/vendor/assets/javascripts/jquery/jquery-ui.min.js +0 -17
  59. data/lib/generators/backbone/setup_generator/templates/vendor/assets/javascripts/testing/jasmine-jquery-1.3.1.js +0 -288
  60. data/lib/generators/backbone/setup_generator/templates/vendor/assets/javascripts/testing/jasmine-sinon.js +0 -43
  61. data/lib/generators/backbone/setup_generator/templates/vendor/assets/javascripts/testing/mock-ajax.js +0 -207
@@ -1,17 +0,0 @@
1
- /*! jQuery UI - v1.8.23 - 2012-08-15
2
- * https://github.com/jquery/jquery-ui
3
- * Includes: jquery.ui.core.js
4
- * Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
5
- (function(a,b){function c(b,c){var e=b.nodeName.toLowerCase();if("area"===e){var f=b.parentNode,g=f.name,h;return!b.href||!g||f.nodeName.toLowerCase()!=="map"?!1:(h=a("img[usemap=#"+g+"]")[0],!!h&&d(h))}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};if(a.ui.version)return;a.extend(a.ui,{version:"1.8.23",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(b,c){return typeof b=="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;return a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0),/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){var d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return f}d=d.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a("<a>").outerWidth(1).jquery||a.each(["Width","Height"],function(c,d){function h(b,c,d,f){return a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)}),c}var e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){return c===b?g["inner"+d].call(this):this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){return typeof b!="number"?g["outer"+d].call(this,b):this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:a.expr.createPseudo?a.expr.createPseudo(function(b){return function(c){return!!a.data(c,b)}}):function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));c.offsetHeight,a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in c,b.removeChild(c).style.display="none"}),a.curCSS||(a.curCSS=a.css),a.extend(a.ui,{plugin:{add:function(b,c,d){var e=a.ui[b].prototype;for(var f in d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var d=a.plugins[b];if(!d||!a.element[0].parentNode)return;for(var e=0;e<d.length;e++)a.options[d[e][0]]&&d[e][1].apply(a.element,c)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(b,c){if(a(b).css("overflow")==="hidden")return!1;var d=c&&c==="left"?"scrollLeft":"scrollTop",e=!1;return b[d]>0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)},isOverAxis:function(a,b,c){return a>b&&a<b+c},isOver:function(b,c,d,e,f,g){return a.ui.isOverAxis(b,d,f)&&a.ui.isOverAxis(c,e,g)}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
6
- * https://github.com/jquery/jquery-ui
7
- * Includes: jquery.ui.widget.js
8
- * Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
9
- (function(a,b){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b){for(var d=0,e;(e=b[d])!=null;d++)try{a(e).triggerHandler("remove")}catch(f){}c(b)}}else{var d=a.fn.remove;a.fn.remove=function(b,c){return this.each(function(){return c||(!b||a.filter(b,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(b){}}),d.call(a(this),b,c)})}}a.widget=function(b,c,d){var e=b.split(".")[0],f;b=b.split(".")[1],f=e+"-"+b,d||(d=c,c=a.Widget),a.expr[":"][f]=function(c){return!!a.data(c,b)},a[e]=a[e]||{},a[e][b]=function(a,b){arguments.length&&this._createWidget(a,b)};var g=new c;g.options=a.extend(!0,{},g.options),a[e][b].prototype=a.extend(!0,g,{namespace:e,widgetName:b,widgetEventPrefix:a[e][b].prototype.widgetEventPrefix||b,widgetBaseClass:f},d),a.widget.bridge(b,a[e][b])},a.widget.bridge=function(c,d){a.fn[c]=function(e){var f=typeof e=="string",g=Array.prototype.slice.call(arguments,1),h=this;return e=!f&&g.length?a.extend.apply(null,[!0,e].concat(g)):e,f&&e.charAt(0)==="_"?h:(f?this.each(function(){var d=a.data(this,c),f=d&&a.isFunction(d[e])?d[e].apply(d,g):d;if(f!==d&&f!==b)return h=f,!1}):this.each(function(){var b=a.data(this,c);b?b.option(e||{})._init():a.data(this,c,new d(e,this))}),h)}},a.Widget=function(a,b){arguments.length&&this._createWidget(a,b)},a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(b,c){a.data(c,this.widgetName,this),this.element=a(c),this.options=a.extend(!0,{},this.options,this._getCreateOptions(),b);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()}),this._create(),this._trigger("create"),this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName),this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+"ui-state-disabled")},widget:function(){return this.element},option:function(c,d){var e=c;if(arguments.length===0)return a.extend({},this.options);if(typeof c=="string"){if(d===b)return this.options[c];e={},e[c]=d}return this._setOptions(e),this},_setOptions:function(b){var c=this;return a.each(b,function(a,b){c._setOption(a,b)}),this},_setOption:function(a,b){return this.options[a]=b,a==="disabled"&&this.widget()[b?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+" "+"ui-state-disabled").attr("aria-disabled",b),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_trigger:function(b,c,d){var e,f,g=this.options[b];d=d||{},c=a.Event(c),c.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase(),c.target=this.element[0],f=c.originalEvent;if(f)for(e in f)e in c||(c[e]=f[e]);return this.element.trigger(c,d),!(a.isFunction(g)&&g.call(this.element[0],c,d)===!1||c.isDefaultPrevented())}}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
10
- * https://github.com/jquery/jquery-ui
11
- * Includes: jquery.ui.position.js
12
- * Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
13
- (function(a,b){a.ui=a.ui||{};var c=/left|center|right/,d=/top|center|bottom/,e="center",f={},g=a.fn.position,h=a.fn.offset;a.fn.position=function(b){if(!b||!b.of)return g.apply(this,arguments);b=a.extend({},b);var h=a(b.of),i=h[0],j=(b.collision||"flip").split(" "),k=b.offset?b.offset.split(" "):[0,0],l,m,n;return i.nodeType===9?(l=h.width(),m=h.height(),n={top:0,left:0}):i.setTimeout?(l=h.width(),m=h.height(),n={top:h.scrollTop(),left:h.scrollLeft()}):i.preventDefault?(b.at="left top",l=m=0,n={top:b.of.pageY,left:b.of.pageX}):(l=h.outerWidth(),m=h.outerHeight(),n=h.offset()),a.each(["my","at"],function(){var a=(b[this]||"").split(" ");a.length===1&&(a=c.test(a[0])?a.concat([e]):d.test(a[0])?[e].concat(a):[e,e]),a[0]=c.test(a[0])?a[0]:e,a[1]=d.test(a[1])?a[1]:e,b[this]=a}),j.length===1&&(j[1]=j[0]),k[0]=parseInt(k[0],10)||0,k.length===1&&(k[1]=k[0]),k[1]=parseInt(k[1],10)||0,b.at[0]==="right"?n.left+=l:b.at[0]===e&&(n.left+=l/2),b.at[1]==="bottom"?n.top+=m:b.at[1]===e&&(n.top+=m/2),n.left+=k[0],n.top+=k[1],this.each(function(){var c=a(this),d=c.outerWidth(),g=c.outerHeight(),h=parseInt(a.curCSS(this,"marginLeft",!0))||0,i=parseInt(a.curCSS(this,"marginTop",!0))||0,o=d+h+(parseInt(a.curCSS(this,"marginRight",!0))||0),p=g+i+(parseInt(a.curCSS(this,"marginBottom",!0))||0),q=a.extend({},n),r;b.my[0]==="right"?q.left-=d:b.my[0]===e&&(q.left-=d/2),b.my[1]==="bottom"?q.top-=g:b.my[1]===e&&(q.top-=g/2),f.fractions||(q.left=Math.round(q.left),q.top=Math.round(q.top)),r={left:q.left-h,top:q.top-i},a.each(["left","top"],function(c,e){a.ui.position[j[c]]&&a.ui.position[j[c]][e](q,{targetWidth:l,targetHeight:m,elemWidth:d,elemHeight:g,collisionPosition:r,collisionWidth:o,collisionHeight:p,offset:k,my:b.my,at:b.at})}),a.fn.bgiframe&&c.bgiframe(),c.offset(a.extend(q,{using:b.using}))})},a.ui.position={fit:{left:function(b,c){var d=a(window),e=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();b.left=e>0?b.left-e:Math.max(b.left-c.collisionPosition.left,b.left)},top:function(b,c){var d=a(window),e=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();b.top=e>0?b.top-e:Math.max(b.top-c.collisionPosition.top,b.top)}},flip:{left:function(b,c){if(c.at[0]===e)return;var d=a(window),f=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft(),g=c.my[0]==="left"?-c.elemWidth:c.my[0]==="right"?c.elemWidth:0,h=c.at[0]==="left"?c.targetWidth:-c.targetWidth,i=-2*c.offset[0];b.left+=c.collisionPosition.left<0?g+h+i:f>0?g+h+i:0},top:function(b,c){if(c.at[1]===e)return;var d=a(window),f=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop(),g=c.my[1]==="top"?-c.elemHeight:c.my[1]==="bottom"?c.elemHeight:0,h=c.at[1]==="top"?c.targetHeight:-c.targetHeight,i=-2*c.offset[1];b.top+=c.collisionPosition.top<0?g+h+i:f>0?g+h+i:0}}},a.offset.setOffset||(a.offset.setOffset=function(b,c){/static/.test(a.curCSS(b,"position"))&&(b.style.position="relative");var d=a(b),e=d.offset(),f=parseInt(a.curCSS(b,"top",!0),10)||0,g=parseInt(a.curCSS(b,"left",!0),10)||0,h={top:c.top-e.top+f,left:c.left-e.left+g};"using"in c?c.using.call(b,h):d.css(h)},a.fn.offset=function(b){var c=this[0];return!c||!c.ownerDocument?null:b?a.isFunction(b)?this.each(function(c){a(this).offset(b.call(this,c,a(this).offset()))}):this.each(function(){a.offset.setOffset(this,b)}):h.call(this)}),a.curCSS||(a.curCSS=a.css),function(){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d,e,g,h,i;d=document.createElement(b?"div":"body"),g={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},b&&a.extend(g,{position:"absolute",left:"-1000px",top:"-1000px"});for(var j in g)d.style[j]=g[j];d.appendChild(c),e=b||document.documentElement,e.insertBefore(d,e.firstChild),c.style.cssText="position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;",h=a(c).offset(function(a,b){return b}).offset(),d.innerHTML="",e.removeChild(d),i=h.top+h.left+(b?2e3:0),f.fractions=i>21&&i<22}()})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
14
- * https://github.com/jquery/jquery-ui
15
- * Includes: jquery.ui.autocomplete.js
16
- * Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
17
- (function(a,b){var c=0;a.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var b=this,c=this.element[0].ownerDocument,d;this.isMultiLine=this.element.is("textarea"),this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(b.options.disabled||b.element.propAttr("readOnly"))return;d=!1;var e=a.ui.keyCode;switch(c.keyCode){case e.PAGE_UP:b._move("previousPage",c);break;case e.PAGE_DOWN:b._move("nextPage",c);break;case e.UP:b._keyEvent("previous",c);break;case e.DOWN:b._keyEvent("next",c);break;case e.ENTER:case e.NUMPAD_ENTER:b.menu.active&&(d=!0,c.preventDefault());case e.TAB:if(!b.menu.active)return;b.menu.select(c);break;case e.ESCAPE:b.element.val(b.term),b.close(c);break;default:clearTimeout(b.searching),b.searching=setTimeout(function(){b.term!=b.element.val()&&(b.selectedItem=null,b.search(null,c))},b.options.delay)}}).bind("keypress.autocomplete",function(a){d&&(d=!1,a.preventDefault())}).bind("focus.autocomplete",function(){if(b.options.disabled)return;b.selectedItem=null,b.previous=b.element.val()}).bind("blur.autocomplete",function(a){if(b.options.disabled)return;clearTimeout(b.searching),b.closing=setTimeout(function(){b.close(a),b._change(a)},150)}),this._initSource(),this.menu=a("<ul></ul>").addClass("ui-autocomplete").appendTo(a(this.options.appendTo||"body",c)[0]).mousedown(function(c){var d=b.menu.element[0];a(c.target).closest(".ui-menu-item").length||setTimeout(function(){a(document).one("mousedown",function(c){c.target!==b.element[0]&&c.target!==d&&!a.ui.contains(d,c.target)&&b.close()})},1),setTimeout(function(){clearTimeout(b.closing)},13)}).menu({focus:function(a,c){var d=c.item.data("item.autocomplete");!1!==b._trigger("focus",a,{item:d})&&/^key/.test(a.originalEvent.type)&&b.element.val(d.value)},selected:function(a,d){var e=d.item.data("item.autocomplete"),f=b.previous;b.element[0]!==c.activeElement&&(b.element.focus(),b.previous=f,setTimeout(function(){b.previous=f,b.selectedItem=e},1)),!1!==b._trigger("select",a,{item:e})&&b.element.val(e.value),b.term=b.element.val(),b.close(a),b.selectedItem=e},blur:function(a,c){b.menu.element.is(":visible")&&b.element.val()!==b.term&&b.element.val(b.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu"),a.fn.bgiframe&&this.menu.element.bgiframe(),b.beforeunloadHandler=function(){b.element.removeAttr("autocomplete")},a(window).bind("beforeunload",b.beforeunloadHandler)},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup"),this.menu.element.remove(),a(window).unbind("beforeunload",this.beforeunloadHandler),a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments),b==="source"&&this._initSource(),b==="appendTo"&&this.menu.element.appendTo(a(c||"body",this.element[0].ownerDocument)[0]),b==="disabled"&&c&&this.xhr&&this.xhr.abort()},_initSource:function(){var b=this,c,d;a.isArray(this.options.source)?(c=this.options.source,this.source=function(b,d){d(a.ui.autocomplete.filter(c,b.term))}):typeof this.options.source=="string"?(d=this.options.source,this.source=function(c,e){b.xhr&&b.xhr.abort(),b.xhr=a.ajax({url:d,data:c,dataType:"json",success:function(a,b){e(a)},error:function(){e([])}})}):this.source=this.options.source},search:function(a,b){a=a!=null?a:this.element.val(),this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(this._trigger("search",b)===!1)return;return this._search(a)},_search:function(a){this.pending++,this.element.addClass("ui-autocomplete-loading"),this.source({term:a},this._response())},_response:function(){var a=this,b=++c;return function(d){b===c&&a.__response(d),a.pending--,a.pending||a.element.removeClass("ui-autocomplete-loading")}},__response:function(a){!this.options.disabled&&a&&a.length?(a=this._normalize(a),this._suggest(a),this._trigger("open")):this.close()},close:function(a){clearTimeout(this.closing),this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.deactivate(),this._trigger("close",a))},_change:function(a){this.previous!==this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(b){return b.length&&b[0].label&&b[0].value?b:a.map(b,function(b){return typeof b=="string"?{label:b,value:b}:a.extend({label:b.label||b.value,value:b.value||b.label},b)})},_suggest:function(b){var c=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(c,b),this.menu.deactivate(),this.menu.refresh(),c.show(),this._resizeMenu(),c.position(a.extend({of:this.element},this.options.position)),this.options.autoFocus&&this.menu.next(new a.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(b,c){var d=this;a.each(c,function(a,c){d._renderItem(b,c)})},_renderItem:function(b,c){return a("<li></li>").data("item.autocomplete",c).append(a("<a></a>").text(c.label)).appendTo(b)},_move:function(a,b){if(!this.menu.element.is(":visible")){this.search(null,b);return}if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term),this.menu.deactivate();return}this.menu[a](b)},widget:function(){return this.menu.element},_keyEvent:function(a,b){if(!this.isMultiLine||this.menu.element.is(":visible"))this._move(a,b),b.preventDefault()}}),a.extend(a.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(b,c){var d=new RegExp(a.ui.autocomplete.escapeRegex(c),"i");return a.grep(b,function(a){return d.test(a.label||a.value||a)})}})})(jQuery),function(a){a.widget("ui.menu",{_create:function(){var b=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(c){if(!a(c.target).closest(".ui-menu-item a").length)return;c.preventDefault(),b.select(c)}),this.refresh()},refresh:function(){var b=this,c=this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem");c.children("a").addClass("ui-corner-all").attr("tabindex",-1).mouseenter(function(c){b.activate(c,a(this).parent())}).mouseleave(function(){b.deactivate()})},activate:function(a,b){this.deactivate();if(this.hasScroll()){var c=b.offset().top-this.element.offset().top,d=this.element.scrollTop(),e=this.element.height();c<0?this.element.scrollTop(d+c):c>=e&&this.element.scrollTop(d+c-e+b.height())}this.active=b.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end(),this._trigger("focus",a,{item:b})},deactivate:function(){if(!this.active)return;this.active.children("a").removeClass("ui-state-hover").removeAttr("id"),this._trigger("blur"),this.active=null},next:function(a){this.move("next",".ui-menu-item:first",a)},previous:function(a){this.move("prev",".ui-menu-item:last",a)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(a,b,c){if(!this.active){this.activate(c,this.element.children(b));return}var d=this.active[a+"All"](".ui-menu-item").eq(0);d.length?this.activate(c,d):this.activate(c,this.element.children(b))},nextPage:function(b){if(this.hasScroll()){if(!this.active||this.last()){this.activate(b,this.element.children(".ui-menu-item:first"));return}var c=this.active.offset().top,d=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c-d+a(this).height();return b<10&&b>-10});e.length||(e=this.element.children(".ui-menu-item:last")),this.activate(b,e)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))},previousPage:function(b){if(this.hasScroll()){if(!this.active||this.first()){this.activate(b,this.element.children(".ui-menu-item:last"));return}var c=this.active.offset().top,d=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c+d-a(this).height();return b<10&&b>-10});e.length||(e=this.element.children(".ui-menu-item:first")),this.activate(b,e)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[a.fn.prop?"prop":"attr"]("scrollHeight")},select:function(a){this._trigger("selected",a,{item:this.active})}})}(jQuery);;
@@ -1,288 +0,0 @@
1
- var readFixtures = function() {
2
- return jasmine.getFixtures().proxyCallTo_('read', arguments);
3
- };
4
-
5
- var preloadFixtures = function() {
6
- jasmine.getFixtures().proxyCallTo_('preload', arguments);
7
- };
8
-
9
- var loadFixtures = function() {
10
- jasmine.getFixtures().proxyCallTo_('load', arguments);
11
- };
12
-
13
- var setFixtures = function(html) {
14
- jasmine.getFixtures().set(html);
15
- };
16
-
17
- var sandbox = function(attributes) {
18
- return jasmine.getFixtures().sandbox(attributes);
19
- };
20
-
21
- var spyOnEvent = function(selector, eventName) {
22
- jasmine.JQuery.events.spyOn(selector, eventName);
23
- }
24
-
25
- jasmine.getFixtures = function() {
26
- return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures();
27
- };
28
-
29
- jasmine.Fixtures = function() {
30
- this.containerId = 'jasmine-fixtures';
31
- this.fixturesCache_ = {};
32
- this.fixturesPath = 'spec/javascripts/fixtures';
33
- };
34
-
35
- jasmine.Fixtures.prototype.set = function(html) {
36
- this.cleanUp();
37
- this.createContainer_(html);
38
- };
39
-
40
- jasmine.Fixtures.prototype.preload = function() {
41
- this.read.apply(this, arguments);
42
- };
43
-
44
- jasmine.Fixtures.prototype.load = function() {
45
- this.cleanUp();
46
- this.createContainer_(this.read.apply(this, arguments));
47
- };
48
-
49
- jasmine.Fixtures.prototype.read = function() {
50
- var htmlChunks = [];
51
-
52
- var fixtureUrls = arguments;
53
- for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
54
- htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]));
55
- }
56
-
57
- return htmlChunks.join('');
58
- };
59
-
60
- jasmine.Fixtures.prototype.clearCache = function() {
61
- this.fixturesCache_ = {};
62
- };
63
-
64
- jasmine.Fixtures.prototype.cleanUp = function() {
65
- jQuery('#' + this.containerId).remove();
66
- };
67
-
68
- jasmine.Fixtures.prototype.sandbox = function(attributes) {
69
- var attributesToSet = attributes || {};
70
- return jQuery('<div id="sandbox" />').attr(attributesToSet);
71
- };
72
-
73
- jasmine.Fixtures.prototype.createContainer_ = function(html) {
74
- var container;
75
- if(html instanceof jQuery) {
76
- container = jQuery('<div id="' + this.containerId + '" />');
77
- container.html(html);
78
- } else {
79
- container = '<div id="' + this.containerId + '">' + html + '</div>'
80
- }
81
- jQuery('body').append(container);
82
- };
83
-
84
- jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
85
- if (typeof this.fixturesCache_[url] == 'undefined') {
86
- this.loadFixtureIntoCache_(url);
87
- }
88
- return this.fixturesCache_[url];
89
- };
90
-
91
- jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
92
- var self = this;
93
- var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl;
94
- jQuery.ajax({
95
- async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
96
- cache: false,
97
- dataType: 'html',
98
- url: url,
99
- success: function(data) {
100
- self.fixturesCache_[relativeUrl] = data;
101
- },
102
- error: function(jqXHR, status, errorThrown) {
103
- throw Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')');
104
- }
105
- });
106
- };
107
-
108
- jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
109
- return this[methodName].apply(this, passedArguments);
110
- };
111
-
112
-
113
- jasmine.JQuery = function() {};
114
-
115
- jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
116
- return jQuery('<div/>').append(html).html();
117
- };
118
-
119
- jasmine.JQuery.elementToString = function(element) {
120
- return jQuery('<div />').append(element.clone()).html();
121
- };
122
-
123
- jasmine.JQuery.matchersClass = {};
124
-
125
- (function(namespace) {
126
- var data = {
127
- spiedEvents: {},
128
- handlers: []
129
- };
130
-
131
- namespace.events = {
132
- spyOn: function(selector, eventName) {
133
- var handler = function(e) {
134
- data.spiedEvents[[selector, eventName]] = e;
135
- };
136
- jQuery(selector).bind(eventName, handler);
137
- data.handlers.push(handler);
138
- },
139
-
140
- wasTriggered: function(selector, eventName) {
141
- return !!(data.spiedEvents[[selector, eventName]]);
142
- },
143
-
144
- cleanUp: function() {
145
- data.spiedEvents = {};
146
- data.handlers = [];
147
- }
148
- }
149
- })(jasmine.JQuery);
150
-
151
- (function(){
152
- var jQueryMatchers = {
153
- toHaveClass: function(className) {
154
- return this.actual.hasClass(className);
155
- },
156
-
157
- toBeVisible: function() {
158
- return this.actual.is(':visible');
159
- },
160
-
161
- toBeHidden: function() {
162
- return this.actual.is(':hidden');
163
- },
164
-
165
- toBeSelected: function() {
166
- return this.actual.is(':selected');
167
- },
168
-
169
- toBeChecked: function() {
170
- return this.actual.is(':checked');
171
- },
172
-
173
- toBeEmpty: function() {
174
- return this.actual.is(':empty');
175
- },
176
-
177
- toExist: function() {
178
- return this.actual.size() > 0;
179
- },
180
-
181
- toHaveAttr: function(attributeName, expectedAttributeValue) {
182
- return hasProperty(this.actual.attr(attributeName), expectedAttributeValue);
183
- },
184
-
185
- toHaveId: function(id) {
186
- return this.actual.attr('id') == id;
187
- },
188
-
189
- toHaveHtml: function(html) {
190
- return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html);
191
- },
192
-
193
- toHaveText: function(text) {
194
- if (text && jQuery.isFunction(text.test)) {
195
- return text.test(this.actual.text());
196
- } else {
197
- return this.actual.text() == text;
198
- }
199
- },
200
-
201
- toHaveValue: function(value) {
202
- return this.actual.val() == value;
203
- },
204
-
205
- toHaveData: function(key, expectedValue) {
206
- return hasProperty(this.actual.data(key), expectedValue);
207
- },
208
-
209
- toBe: function(selector) {
210
- return this.actual.is(selector);
211
- },
212
-
213
- toContain: function(selector) {
214
- return this.actual.find(selector).size() > 0;
215
- },
216
-
217
- toBeDisabled: function(selector){
218
- return this.actual.is(':disabled');
219
- },
220
-
221
- // tests the existence of a specific event binding
222
- toHandle: function(eventName) {
223
- var events = this.actual.data("events");
224
- return events && events[eventName].length > 0;
225
- },
226
-
227
- // tests the existence of a specific event binding + handler
228
- toHandleWith: function(eventName, eventHandler) {
229
- var stack = this.actual.data("events")[eventName];
230
- var i;
231
- for (i = 0; i < stack.length; i++) {
232
- if (stack[i].handler == eventHandler) {
233
- return true;
234
- }
235
- }
236
- return false;
237
- }
238
- };
239
-
240
- var hasProperty = function(actualValue, expectedValue) {
241
- if (expectedValue === undefined) {
242
- return actualValue !== undefined;
243
- }
244
- return actualValue == expectedValue;
245
- };
246
-
247
- var bindMatcher = function(methodName) {
248
- var builtInMatcher = jasmine.Matchers.prototype[methodName];
249
-
250
- jasmine.JQuery.matchersClass[methodName] = function() {
251
- if (this.actual instanceof jQuery) {
252
- var result = jQueryMatchers[methodName].apply(this, arguments);
253
- this.actual = jasmine.JQuery.elementToString(this.actual);
254
- return result;
255
- }
256
-
257
- if (builtInMatcher) {
258
- return builtInMatcher.apply(this, arguments);
259
- }
260
-
261
- return false;
262
- };
263
- };
264
-
265
- for(var methodName in jQueryMatchers) {
266
- bindMatcher(methodName);
267
- }
268
- })();
269
-
270
- beforeEach(function() {
271
- this.addMatchers(jasmine.JQuery.matchersClass);
272
- this.addMatchers({
273
- toHaveBeenTriggeredOn: function(selector) {
274
- this.message = function() {
275
- return [
276
- "Expected event " + this.actual + " to have been triggered on" + selector,
277
- "Expected event " + this.actual + " not to have been triggered on" + selector
278
- ];
279
- };
280
- return jasmine.JQuery.events.wasTriggered(selector, this.actual);
281
- }
282
- })
283
- });
284
-
285
- afterEach(function() {
286
- jasmine.getFixtures().cleanUp();
287
- jasmine.JQuery.events.cleanUp();
288
- });
@@ -1,43 +0,0 @@
1
- (function(global) {
2
-
3
- var spyMatchers = "called calledOnce calledTwice calledThrice calledBefore calledAfter calledOn alwaysCalledOn calledWith alwaysCalledWith calledWithExactly alwaysCalledWithExactly".split(" "),
4
- i = spyMatchers.length,
5
- spyMatcherHash = {},
6
- unusualMatchers = {
7
- "returned": "toHaveReturned",
8
- "alwaysReturned": "toHaveAlwaysReturned",
9
- "threw": "toHaveThrown",
10
- "alwaysThrew": "toHaveAlwaysThrown"
11
- },
12
-
13
- getMatcherFunction = function(sinonName) {
14
- return function() {
15
- var sinonProperty = this.actual[sinonName];
16
- return (typeof sinonProperty === 'function') ? sinonProperty.apply(this.actual, arguments) : sinonProperty;
17
- };
18
- };
19
-
20
- while(i--) {
21
- var sinonName = spyMatchers[i],
22
- matcherName = "toHaveBeen" + sinonName.charAt(0).toUpperCase() + sinonName.slice(1);
23
-
24
- spyMatcherHash[matcherName] = getMatcherFunction(sinonName);
25
- };
26
-
27
- for (var j in unusualMatchers) {
28
- spyMatcherHash[unusualMatchers[j]] = getMatcherFunction(j);
29
- }
30
-
31
- global.sinonJasmine = {
32
- getMatchers: function() {
33
- return spyMatcherHash;
34
- }
35
- };
36
-
37
- })(window);
38
-
39
- beforeEach(function() {
40
-
41
- this.addMatchers(sinonJasmine.getMatchers());
42
-
43
- });
@@ -1,207 +0,0 @@
1
- /*
2
- Jasmine-Ajax : a set of helpers for testing AJAX requests under the Jasmine
3
- BDD framework for JavaScript.
4
-
5
- Supports both Prototype.js and jQuery.
6
-
7
- http://github.com/pivotal/jasmine-ajax
8
-
9
- Jasmine Home page: http://pivotal.github.com/jasmine
10
-
11
- Copyright (c) 2008-2010 Pivotal Labs
12
-
13
- Permission is hereby granted, free of charge, to any person obtaining
14
- a copy of this software and associated documentation files (the
15
- "Software"), to deal in the Software without restriction, including
16
- without limitation the rights to use, copy, modify, merge, publish,
17
- distribute, sublicense, and/or sell copies of the Software, and to
18
- permit persons to whom the Software is furnished to do so, subject to
19
- the following conditions:
20
-
21
- The above copyright notice and this permission notice shall be
22
- included in all copies or substantial portions of the Software.
23
-
24
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
-
32
- */
33
-
34
- // Jasmine-Ajax interface
35
- var ajaxRequests = [];
36
-
37
- function mostRecentAjaxRequest() {
38
- if (ajaxRequests.length > 0) {
39
- return ajaxRequests[ajaxRequests.length - 1];
40
- } else {
41
- return null;
42
- }
43
- }
44
-
45
- function clearAjaxRequests() {
46
- ajaxRequests = [];
47
- }
48
-
49
- // Fake XHR for mocking Ajax Requests & Responses
50
- function FakeXMLHttpRequest() {
51
- var extend = Object.extend || $.extend;
52
- extend(this, {
53
- requestHeaders: {},
54
-
55
- open: function() {
56
- this.method = arguments[0];
57
- this.url = arguments[1];
58
- this.readyState = 1;
59
- },
60
-
61
- setRequestHeader: function(header, value) {
62
- this.requestHeaders[header] = value;
63
- },
64
-
65
- abort: function() {
66
- this.readyState = 0;
67
- },
68
-
69
- readyState: 0,
70
-
71
- onreadystatechange: function(isTimeout) {
72
- },
73
-
74
- status: null,
75
-
76
- send: function(data) {
77
- this.params = data;
78
- this.readyState = 2;
79
- },
80
-
81
- getResponseHeader: function(name) {
82
- return this.responseHeaders[name];
83
- },
84
-
85
- getAllResponseHeaders: function() {
86
- var responseHeaders = [];
87
- for (var i in this.responseHeaders) {
88
- if (this.responseHeaders.hasOwnProperty(i)) {
89
- responseHeaders.push(i + ': ' + this.responseHeaders[i]);
90
- }
91
- }
92
- return responseHeaders.join('\r\n');
93
- },
94
-
95
- responseText: null,
96
-
97
- response: function(response) {
98
- this.status = response.status;
99
- this.responseText = response.responseText || "";
100
- this.readyState = 4;
101
- this.responseHeaders = response.responseHeaders ||
102
- {"Content-type": response.contentType || "application/json" };
103
- // uncomment for jquery 1.3.x support
104
- // jasmine.Clock.tick(20);
105
-
106
- this.onreadystatechange();
107
- },
108
- responseTimeout: function() {
109
- this.readyState = 4;
110
- jasmine.Clock.tick(jQuery.ajaxSettings.timeout || 30000);
111
- this.onreadystatechange('timeout');
112
- }
113
- });
114
-
115
- return this;
116
- }
117
-
118
-
119
- jasmine.Ajax = {
120
-
121
- isInstalled: function() {
122
- return jasmine.Ajax.installed == true;
123
- },
124
-
125
- assertInstalled: function() {
126
- if (!jasmine.Ajax.isInstalled()) {
127
- throw new Error("Mock ajax is not installed, use jasmine.Ajax.useMock()")
128
- }
129
- },
130
-
131
- useMock: function() {
132
- if (!jasmine.Ajax.isInstalled()) {
133
- var spec = jasmine.getEnv().currentSpec;
134
- spec.after(jasmine.Ajax.uninstallMock);
135
-
136
- jasmine.Ajax.installMock();
137
- }
138
- },
139
-
140
- installMock: function() {
141
- if (typeof jQuery != 'undefined') {
142
- jasmine.Ajax.installJquery();
143
- } else if (typeof Prototype != 'undefined') {
144
- jasmine.Ajax.installPrototype();
145
- } else {
146
- throw new Error("jasmine.Ajax currently only supports jQuery and Prototype");
147
- }
148
- jasmine.Ajax.installed = true;
149
- },
150
-
151
- installJquery: function() {
152
- jasmine.Ajax.mode = 'jQuery';
153
- jasmine.Ajax.real = jQuery.ajaxSettings.xhr;
154
- jQuery.ajaxSettings.xhr = jasmine.Ajax.jQueryMock;
155
-
156
- },
157
-
158
- installPrototype: function() {
159
- jasmine.Ajax.mode = 'Prototype';
160
- jasmine.Ajax.real = Ajax.getTransport;
161
-
162
- Ajax.getTransport = jasmine.Ajax.prototypeMock;
163
- },
164
-
165
- uninstallMock: function() {
166
- jasmine.Ajax.assertInstalled();
167
- if (jasmine.Ajax.mode == 'jQuery') {
168
- jQuery.ajaxSettings.xhr = jasmine.Ajax.real;
169
- } else if (jasmine.Ajax.mode == 'Prototype') {
170
- Ajax.getTransport = jasmine.Ajax.real;
171
- }
172
- jasmine.Ajax.reset();
173
- },
174
-
175
- reset: function() {
176
- jasmine.Ajax.installed = false;
177
- jasmine.Ajax.mode = null;
178
- jasmine.Ajax.real = null;
179
- },
180
-
181
- jQueryMock: function() {
182
- var newXhr = new FakeXMLHttpRequest();
183
- ajaxRequests.push(newXhr);
184
- return newXhr;
185
- },
186
-
187
- prototypeMock: function() {
188
- return new FakeXMLHttpRequest();
189
- },
190
-
191
- installed: false,
192
- mode: null
193
- }
194
-
195
-
196
- // Jasmine-Ajax Glue code for Prototype.js
197
- if (typeof Prototype != 'undefined' && Ajax && Ajax.Request) {
198
- Ajax.Request.prototype.originalRequest = Ajax.Request.prototype.request;
199
- Ajax.Request.prototype.request = function(url) {
200
- this.originalRequest(url);
201
- ajaxRequests.push(this);
202
- };
203
-
204
- Ajax.Request.prototype.response = function(responseOptions) {
205
- return this.transport.response(responseOptions);
206
- };
207
- }