rails-backbone-generator 0.0.1 → 0.0.2

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 (57) hide show
  1. metadata +3 -59
  2. data/.gitignore +0 -19
  3. data/Gemfile +0 -4
  4. data/LICENSE +0 -22
  5. data/README.md +0 -135
  6. data/Rakefile +0 -2
  7. data/lib/generators/backbone/collection_generator.rb +0 -65
  8. data/lib/generators/backbone/model_generator.rb +0 -56
  9. data/lib/generators/backbone/namespace_generator.rb +0 -68
  10. data/lib/generators/backbone/templates/app/assets/javascripts/%namespace%/collections/%collection_name%.coffee.tt +0 -4
  11. data/lib/generators/backbone/templates/app/assets/javascripts/%namespace%/collections/.gitkeep +0 -0
  12. data/lib/generators/backbone/templates/app/assets/javascripts/%namespace%/models/%model_name%.coffee.tt +0 -15
  13. data/lib/generators/backbone/templates/app/assets/javascripts/%namespace%/models/.gitkeep +0 -0
  14. data/lib/generators/backbone/templates/app/assets/javascripts/%namespace%/routes/.gitkeep +0 -0
  15. data/lib/generators/backbone/templates/app/assets/javascripts/%namespace%/templates/.gitkeep +0 -0
  16. data/lib/generators/backbone/templates/app/assets/javascripts/%namespace%/views/.gitkeep +0 -0
  17. data/lib/generators/backbone/templates/app/assets/javascripts/%namespace%.coffee.tt +0 -16
  18. data/lib/generators/backbone/templates/app/assets/javascripts/shared/.gitkeep +0 -0
  19. data/lib/generators/backbone/templates/app/assets/javascripts/shared/core_extentions/collections_extentions.coffee +0 -30
  20. data/lib/generators/backbone/templates/app/assets/javascripts/shared/helpers/.gitkeep +0 -0
  21. data/lib/generators/backbone/templates/app/assets/javascripts/shared/utils/.gitkeep +0 -0
  22. data/lib/generators/backbone/templates/spec/javascripts/%namespace%/collections/%collection_name%_spec.coffee.tt +0 -8
  23. data/lib/generators/backbone/templates/spec/javascripts/%namespace%/collections/.gitkeep +0 -0
  24. data/lib/generators/backbone/templates/spec/javascripts/%namespace%/factories/%model_name%_factory.coffee.tt +0 -43
  25. data/lib/generators/backbone/templates/spec/javascripts/%namespace%/factories/.gitkeep +0 -0
  26. data/lib/generators/backbone/templates/spec/javascripts/%namespace%/models/%model_name%_spec.coffee.tt +0 -12
  27. data/lib/generators/backbone/templates/spec/javascripts/%namespace%/models/.gitkeep +0 -0
  28. data/lib/generators/backbone/templates/spec/javascripts/%namespace%/views/.gitkeep +0 -0
  29. data/lib/generators/backbone/templates/spec/javascripts/helpers/association_helpers.coffee +0 -3
  30. data/lib/generators/backbone/templates/spec/javascripts/helpers/common_helpers.coffee +0 -13
  31. data/lib/generators/backbone/templates/spec/javascripts/helpers/fake_host.coffee +0 -18
  32. data/lib/generators/backbone/templates/spec/javascripts/helpers/headless_webkit_helper.coffee +0 -9
  33. data/lib/generators/backbone/templates/spec/javascripts/helpers/state_helpers.coffee +0 -4
  34. data/lib/generators/backbone/templates/spec/javascripts/support/jasmine.yml +0 -81
  35. data/lib/generators/backbone/templates/vendor/javascripts/.gitkeep +0 -0
  36. data/lib/generators/backbone/templates/vendor/javascripts/backbone/backbone-0.9.2.js +0 -1431
  37. data/lib/generators/backbone/templates/vendor/javascripts/backbone/backbone-bind-to-1.0.0.coffee +0 -47
  38. data/lib/generators/backbone/templates/vendor/javascripts/backbone/backbone-handlebars-1.0.0.coffee +0 -1920
  39. data/lib/generators/backbone/templates/vendor/javascripts/backbone/backbone-query-0.1.2.js +0 -325
  40. data/lib/generators/backbone/templates/vendor/javascripts/backbone/backbone-relational-0.6.0.js +0 -1687
  41. data/lib/generators/backbone/templates/vendor/javascripts/backbone/handlebars-1.0.rc.1.js +0 -1920
  42. data/lib/generators/backbone/templates/vendor/javascripts/backbone/underscore-1.3.3.js +0 -1059
  43. data/lib/generators/backbone/templates/vendor/javascripts/browser_compatibility/json2.js +0 -487
  44. data/lib/generators/backbone/templates/vendor/javascripts/browser_compatibility/localstorage-polyfill.js +0 -92
  45. data/lib/generators/backbone/templates/vendor/javascripts/jquery/jquery-1.8.0.js +0 -9227
  46. data/lib/generators/backbone/templates/vendor/javascripts/jquery/jquery-ui.min.js +0 -17
  47. data/lib/generators/backbone/templates/vendor/javascripts/jquery/jquery.easing-1.3.js +0 -205
  48. data/lib/generators/backbone/templates/vendor/javascripts/jquery/jquery_ujs.js +0 -368
  49. data/lib/generators/backbone/templates/vendor/javascripts/testing/backbone-factory.js +0 -53
  50. data/lib/generators/backbone/templates/vendor/javascripts/testing/jasmine-jquery-1.3.1.js +0 -288
  51. data/lib/generators/backbone/templates/vendor/javascripts/testing/jasmine-sinon.js +0 -43
  52. data/lib/generators/backbone/templates/vendor/javascripts/testing/mock-ajax.js +0 -207
  53. data/lib/generators/backbone/templates/vendor/javascripts/testing/sinon-1.4.2.js +0 -4081
  54. data/lib/generators/backbone_generator.rb +0 -3
  55. data/lib/rails_backbone_generator/version.rb +0 -3
  56. data/lib/rails_backbone_generator.rb +0 -4
  57. data/rails_backbone_generator.gemspec +0 -20
@@ -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,205 +0,0 @@
1
- /*
2
- * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
3
- *
4
- * Uses the built in easing capabilities added In jQuery 1.1
5
- * to offer multiple easing options
6
- *
7
- * TERMS OF USE - jQuery Easing
8
- *
9
- * Open source under the BSD License.
10
- *
11
- * Copyright © 2008 George McGinley Smith
12
- * All rights reserved.
13
- *
14
- * Redistribution and use in source and binary forms, with or without modification,
15
- * are permitted provided that the following conditions are met:
16
- *
17
- * Redistributions of source code must retain the above copyright notice, this list of
18
- * conditions and the following disclaimer.
19
- * Redistributions in binary form must reproduce the above copyright notice, this list
20
- * of conditions and the following disclaimer in the documentation and/or other materials
21
- * provided with the distribution.
22
- *
23
- * Neither the name of the author nor the names of contributors may be used to endorse
24
- * or promote products derived from this software without specific prior written permission.
25
- *
26
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
27
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
31
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
32
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34
- * OF THE POSSIBILITY OF SUCH DAMAGE.
35
- *
36
- */
37
-
38
- // t: current time, b: begInnIng value, c: change In value, d: duration
39
- jQuery.easing['jswing'] = jQuery.easing['swing'];
40
-
41
- jQuery.extend( jQuery.easing,
42
- {
43
- def: 'easeOutQuad',
44
- swing: function (x, t, b, c, d) {
45
- //alert(jQuery.easing.default);
46
- return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
47
- },
48
- easeInQuad: function (x, t, b, c, d) {
49
- return c*(t/=d)*t + b;
50
- },
51
- easeOutQuad: function (x, t, b, c, d) {
52
- return -c *(t/=d)*(t-2) + b;
53
- },
54
- easeInOutQuad: function (x, t, b, c, d) {
55
- if ((t/=d/2) < 1) return c/2*t*t + b;
56
- return -c/2 * ((--t)*(t-2) - 1) + b;
57
- },
58
- easeInCubic: function (x, t, b, c, d) {
59
- return c*(t/=d)*t*t + b;
60
- },
61
- easeOutCubic: function (x, t, b, c, d) {
62
- return c*((t=t/d-1)*t*t + 1) + b;
63
- },
64
- easeInOutCubic: function (x, t, b, c, d) {
65
- if ((t/=d/2) < 1) return c/2*t*t*t + b;
66
- return c/2*((t-=2)*t*t + 2) + b;
67
- },
68
- easeInQuart: function (x, t, b, c, d) {
69
- return c*(t/=d)*t*t*t + b;
70
- },
71
- easeOutQuart: function (x, t, b, c, d) {
72
- return -c * ((t=t/d-1)*t*t*t - 1) + b;
73
- },
74
- easeInOutQuart: function (x, t, b, c, d) {
75
- if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
76
- return -c/2 * ((t-=2)*t*t*t - 2) + b;
77
- },
78
- easeInQuint: function (x, t, b, c, d) {
79
- return c*(t/=d)*t*t*t*t + b;
80
- },
81
- easeOutQuint: function (x, t, b, c, d) {
82
- return c*((t=t/d-1)*t*t*t*t + 1) + b;
83
- },
84
- easeInOutQuint: function (x, t, b, c, d) {
85
- if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
86
- return c/2*((t-=2)*t*t*t*t + 2) + b;
87
- },
88
- easeInSine: function (x, t, b, c, d) {
89
- return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
90
- },
91
- easeOutSine: function (x, t, b, c, d) {
92
- return c * Math.sin(t/d * (Math.PI/2)) + b;
93
- },
94
- easeInOutSine: function (x, t, b, c, d) {
95
- return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
96
- },
97
- easeInExpo: function (x, t, b, c, d) {
98
- return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
99
- },
100
- easeOutExpo: function (x, t, b, c, d) {
101
- return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
102
- },
103
- easeInOutExpo: function (x, t, b, c, d) {
104
- if (t==0) return b;
105
- if (t==d) return b+c;
106
- if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
107
- return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
108
- },
109
- easeInCirc: function (x, t, b, c, d) {
110
- return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
111
- },
112
- easeOutCirc: function (x, t, b, c, d) {
113
- return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
114
- },
115
- easeInOutCirc: function (x, t, b, c, d) {
116
- if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
117
- return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
118
- },
119
- easeInElastic: function (x, t, b, c, d) {
120
- var s=1.70158;var p=0;var a=c;
121
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
122
- if (a < Math.abs(c)) { a=c; var s=p/4; }
123
- else var s = p/(2*Math.PI) * Math.asin (c/a);
124
- return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
125
- },
126
- easeOutElastic: function (x, t, b, c, d) {
127
- var s=1.70158;var p=0;var a=c;
128
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
129
- if (a < Math.abs(c)) { a=c; var s=p/4; }
130
- else var s = p/(2*Math.PI) * Math.asin (c/a);
131
- return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
132
- },
133
- easeInOutElastic: function (x, t, b, c, d) {
134
- var s=1.70158;var p=0;var a=c;
135
- if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
136
- if (a < Math.abs(c)) { a=c; var s=p/4; }
137
- else var s = p/(2*Math.PI) * Math.asin (c/a);
138
- if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
139
- return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
140
- },
141
- easeInBack: function (x, t, b, c, d, s) {
142
- if (s == undefined) s = 1.70158;
143
- return c*(t/=d)*t*((s+1)*t - s) + b;
144
- },
145
- easeOutBack: function (x, t, b, c, d, s) {
146
- if (s == undefined) s = 1.70158;
147
- return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
148
- },
149
- easeInOutBack: function (x, t, b, c, d, s) {
150
- if (s == undefined) s = 1.70158;
151
- if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
152
- return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
153
- },
154
- easeInBounce: function (x, t, b, c, d) {
155
- return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
156
- },
157
- easeOutBounce: function (x, t, b, c, d) {
158
- if ((t/=d) < (1/2.75)) {
159
- return c*(7.5625*t*t) + b;
160
- } else if (t < (2/2.75)) {
161
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
162
- } else if (t < (2.5/2.75)) {
163
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
164
- } else {
165
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
166
- }
167
- },
168
- easeInOutBounce: function (x, t, b, c, d) {
169
- if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
170
- return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
171
- }
172
- });
173
-
174
- /*
175
- *
176
- * TERMS OF USE - EASING EQUATIONS
177
- *
178
- * Open source under the BSD License.
179
- *
180
- * Copyright © 2001 Robert Penner
181
- * All rights reserved.
182
- *
183
- * Redistribution and use in source and binary forms, with or without modification,
184
- * are permitted provided that the following conditions are met:
185
- *
186
- * Redistributions of source code must retain the above copyright notice, this list of
187
- * conditions and the following disclaimer.
188
- * Redistributions in binary form must reproduce the above copyright notice, this list
189
- * of conditions and the following disclaimer in the documentation and/or other materials
190
- * provided with the distribution.
191
- *
192
- * Neither the name of the author nor the names of contributors may be used to endorse
193
- * or promote products derived from this software without specific prior written permission.
194
- *
195
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
196
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
197
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
198
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
199
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
200
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
201
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
202
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
203
- * OF THE POSSIBILITY OF SUCH DAMAGE.
204
- *
205
- */
@@ -1,368 +0,0 @@
1
- (function($, undefined) {
2
-
3
- /**
4
- * Unobtrusive scripting adapter for jQuery
5
- *
6
- * Requires jQuery 1.6.0 or later.
7
- * https://github.com/rails/jquery-ujs
8
-
9
- * Uploading file using rails.js
10
- * =============================
11
- *
12
- * By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
13
- * in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
14
- *
15
- * The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
16
- *
17
- * Ex:
18
- * $('form').live('ajax:aborted:file', function(event, elements){
19
- * // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
20
- * // Returning false in this handler tells rails.js to disallow standard form submission
21
- * return false;
22
- * });
23
- *
24
- * The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
25
- *
26
- * Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
27
- * techniques like the iframe method to upload the file instead.
28
- *
29
- * Required fields in rails.js
30
- * ===========================
31
- *
32
- * If any blank required inputs (required="required") are detected in the remote form, the whole form submission
33
- * is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
34
- *
35
- * The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
36
- *
37
- * !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
38
- * get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
39
- *
40
- * Ex:
41
- * $('form').live('ajax:aborted:required', function(event, elements){
42
- * // Returning false in this handler tells rails.js to submit the form anyway.
43
- * // The blank required inputs are passed to this function in `elements`.
44
- * return ! confirm("Would you like to submit the form with missing info?");
45
- * });
46
- */
47
-
48
- // Shorthand to make it a little easier to call public rails functions from within rails.js
49
- var rails;
50
-
51
- $.rails = rails = {
52
- // Link elements bound by jquery-ujs
53
- linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
54
-
55
- // Select elements bound by jquery-ujs
56
- inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
57
-
58
- // Form elements bound by jquery-ujs
59
- formSubmitSelector: 'form',
60
-
61
- // Form input elements bound by jquery-ujs
62
- formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])',
63
-
64
- // Form input elements disabled during form submission
65
- disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
66
-
67
- // Form input elements re-enabled after form submission
68
- enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
69
-
70
- // Form required input elements
71
- requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
72
-
73
- // Form file input elements
74
- fileInputSelector: 'input:file',
75
-
76
- // Link onClick disable selector with possible reenable after remote submission
77
- linkDisableSelector: 'a[data-disable-with]',
78
-
79
- // Make sure that every Ajax request sends the CSRF token
80
- CSRFProtection: function(xhr) {
81
- var token = $('meta[name="csrf-token"]').attr('content');
82
- if (token) xhr.setRequestHeader('X-CSRF-Token', token);
83
- },
84
-
85
- // Triggers an event on an element and returns false if the event result is false
86
- fire: function(obj, name, data) {
87
- var event = $.Event(name);
88
- obj.trigger(event, data);
89
- return event.result !== false;
90
- },
91
-
92
- // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
93
- confirm: function(message) {
94
- return confirm(message);
95
- },
96
-
97
- // Default ajax function, may be overridden with custom function in $.rails.ajax
98
- ajax: function(options) {
99
- return $.ajax(options);
100
- },
101
-
102
- // Submits "remote" forms and links with ajax
103
- handleRemote: function(element) {
104
- var method, url, data,
105
- crossDomain = element.data('cross-domain') || null,
106
- dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType),
107
- options;
108
-
109
- if (rails.fire(element, 'ajax:before')) {
110
-
111
- if (element.is('form')) {
112
- method = element.attr('method');
113
- url = element.attr('action');
114
- data = element.serializeArray();
115
- // memoized value from clicked submit button
116
- var button = element.data('ujs:submit-button');
117
- if (button) {
118
- data.push(button);
119
- element.data('ujs:submit-button', null);
120
- }
121
- } else if (element.is(rails.inputChangeSelector)) {
122
- method = element.data('method');
123
- url = element.data('url');
124
- data = element.serialize();
125
- if (element.data('params')) data = data + "&" + element.data('params');
126
- } else {
127
- method = element.data('method');
128
- url = element.attr('href');
129
- data = element.data('params') || null;
130
- }
131
-
132
- options = {
133
- type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
134
- // stopping the "ajax:beforeSend" event will cancel the ajax request
135
- beforeSend: function(xhr, settings) {
136
- if (settings.dataType === undefined) {
137
- xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
138
- }
139
- return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
140
- },
141
- success: function(data, status, xhr) {
142
- element.trigger('ajax:success', [data, status, xhr]);
143
- },
144
- complete: function(xhr, status) {
145
- element.trigger('ajax:complete', [xhr, status]);
146
- },
147
- error: function(xhr, status, error) {
148
- element.trigger('ajax:error', [xhr, status, error]);
149
- }
150
- };
151
- // Only pass url to `ajax` options if not blank
152
- if (url) { options.url = url; }
153
-
154
- rails.ajax(options);
155
- }
156
- },
157
-
158
- // Handles "data-method" on links such as:
159
- // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
160
- handleMethod: function(link) {
161
- var href = link.attr('href'),
162
- method = link.data('method'),
163
- target = link.attr('target'),
164
- csrf_token = $('meta[name=csrf-token]').attr('content'),
165
- csrf_param = $('meta[name=csrf-param]').attr('content'),
166
- form = $('<form method="post" action="' + href + '"></form>'),
167
- metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
168
-
169
- if (csrf_param !== undefined && csrf_token !== undefined) {
170
- metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
171
- }
172
-
173
- if (target) { form.attr('target', target); }
174
-
175
- form.hide().append(metadata_input).appendTo('body');
176
- form.submit();
177
- },
178
-
179
- /* Disables form elements:
180
- - Caches element value in 'ujs:enable-with' data store
181
- - Replaces element text with value of 'data-disable-with' attribute
182
- - Sets disabled property to true
183
- */
184
- disableFormElements: function(form) {
185
- form.find(rails.disableSelector).each(function() {
186
- var element = $(this), method = element.is('button') ? 'html' : 'val';
187
- element.data('ujs:enable-with', element[method]());
188
- element[method](element.data('disable-with'));
189
- element.prop('disabled', true);
190
- });
191
- },
192
-
193
- /* Re-enables disabled form elements:
194
- - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
195
- - Sets disabled property to false
196
- */
197
- enableFormElements: function(form) {
198
- form.find(rails.enableSelector).each(function() {
199
- var element = $(this), method = element.is('button') ? 'html' : 'val';
200
- if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
201
- element.prop('disabled', false);
202
- });
203
- },
204
-
205
- /* For 'data-confirm' attribute:
206
- - Fires `confirm` event
207
- - Shows the confirmation dialog
208
- - Fires the `confirm:complete` event
209
-
210
- Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
211
- Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
212
- Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
213
- return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
214
- */
215
- allowAction: function(element) {
216
- var message = element.data('confirm'),
217
- answer = false, callback;
218
- if (!message) { return true; }
219
-
220
- if (rails.fire(element, 'confirm')) {
221
- answer = rails.confirm(message);
222
- callback = rails.fire(element, 'confirm:complete', [answer]);
223
- }
224
- return answer && callback;
225
- },
226
-
227
- // Helper function which checks for blank inputs in a form that match the specified CSS selector
228
- blankInputs: function(form, specifiedSelector, nonBlank) {
229
- var inputs = $(), input,
230
- selector = specifiedSelector || 'input,textarea';
231
- form.find(selector).each(function() {
232
- input = $(this);
233
- // Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
234
- if (nonBlank ? input.val() : !input.val()) {
235
- inputs = inputs.add(input);
236
- }
237
- });
238
- return inputs.length ? inputs : false;
239
- },
240
-
241
- // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
242
- nonBlankInputs: function(form, specifiedSelector) {
243
- return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
244
- },
245
-
246
- // Helper function, needed to provide consistent behavior in IE
247
- stopEverything: function(e) {
248
- $(e.target).trigger('ujs:everythingStopped');
249
- e.stopImmediatePropagation();
250
- return false;
251
- },
252
-
253
- // find all the submit events directly bound to the form and
254
- // manually invoke them. If anyone returns false then stop the loop
255
- callFormSubmitBindings: function(form) {
256
- var events = form.data('events'), continuePropagation = true;
257
- if (events !== undefined && events['submit'] !== undefined) {
258
- $.each(events['submit'], function(i, obj){
259
- if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data);
260
- });
261
- }
262
- return continuePropagation;
263
- },
264
-
265
- // replace element's html with the 'data-disable-with' after storing original html
266
- // and prevent clicking on it
267
- disableElement: function(element) {
268
- element.data('ujs:enable-with', element.html()); // store enabled state
269
- element.html(element.data('disable-with')); // set to disabled state
270
- element.bind('click.railsDisable', function(e) { // prevent further clicking
271
- return rails.stopEverything(e)
272
- });
273
- },
274
-
275
- // restore element to its original state which was disabled by 'disableElement' above
276
- enableElement: function(element) {
277
- if (element.data('ujs:enable-with') !== undefined) {
278
- element.html(element.data('ujs:enable-with')); // set to old enabled state
279
- // this should be element.removeData('ujs:enable-with')
280
- // but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
281
- element.data('ujs:enable-with', false); // clean up cache
282
- }
283
- element.unbind('click.railsDisable'); // enable element
284
- }
285
-
286
- };
287
-
288
- $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
289
-
290
- $(rails.linkDisableSelector).live('ajax:complete', function() {
291
- rails.enableElement($(this));
292
- });
293
-
294
- $(rails.linkClickSelector).live('click.rails', function(e) {
295
- var link = $(this), method = link.data('method'), data = link.data('params');
296
- if (!rails.allowAction(link)) return rails.stopEverything(e);
297
-
298
- if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
299
-
300
- if (link.data('remote') !== undefined) {
301
- if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
302
- rails.handleRemote(link);
303
- return false;
304
- } else if (link.data('method')) {
305
- rails.handleMethod(link);
306
- return false;
307
- }
308
- });
309
-
310
- $(rails.inputChangeSelector).live('change.rails', function(e) {
311
- var link = $(this);
312
- if (!rails.allowAction(link)) return rails.stopEverything(e);
313
-
314
- rails.handleRemote(link);
315
- return false;
316
- });
317
-
318
- $(rails.formSubmitSelector).live('submit.rails', function(e) {
319
- var form = $(this),
320
- remote = form.data('remote') !== undefined,
321
- blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
322
- nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
323
-
324
- if (!rails.allowAction(form)) return rails.stopEverything(e);
325
-
326
- // skip other logic when required values are missing or file upload is present
327
- if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
328
- return rails.stopEverything(e);
329
- }
330
-
331
- if (remote) {
332
- if (nonBlankFileInputs) {
333
- return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
334
- }
335
-
336
- // If browser does not support submit bubbling, then this live-binding will be called before direct
337
- // bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
338
- if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
339
-
340
- rails.handleRemote(form);
341
- return false;
342
- } else {
343
- // slight timeout so that the submit button gets properly serialized
344
- setTimeout(function(){ rails.disableFormElements(form); }, 13);
345
- }
346
- });
347
-
348
- $(rails.formInputClickSelector).live('click.rails', function(event) {
349
- var button = $(this);
350
-
351
- if (!rails.allowAction(button)) return rails.stopEverything(event);
352
-
353
- // register the pressed submit button
354
- var name = button.attr('name'),
355
- data = name ? {name:name, value:button.val()} : null;
356
-
357
- button.closest('form').data('ujs:submit-button', data);
358
- });
359
-
360
- $(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) {
361
- if (this == event.target) rails.disableFormElements($(this));
362
- });
363
-
364
- $(rails.formSubmitSelector).live('ajax:complete.rails', function(event) {
365
- if (this == event.target) rails.enableFormElements($(this));
366
- });
367
-
368
- })( jQuery );