This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'harmony' | |
| code = <<-eos | |
| javascript_object = { | |
| nombre: 'Jorge', | |
| say: function(){ | |
| return "Hi there!" | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- rails.js | |
| +++ (clipboard) | |
| @@ -40,10 +40,7 @@ | |
| el.trigger('ajax:loading', xhr); | |
| }, | |
| success: function (data, status, xhr) { | |
| - if (xhr.status) | |
| el.trigger('ajax:success', [data, status, xhr]); | |
| - else | |
| - el.trigger('ajax:failure', [xhr, "aborted", data]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ViewHelpers | |
| def render_javascript_template(data) | |
| render | |
| include_javascript_files | |
| yield do_render_javascript_template(data) | |
| end | |
| def include_javascript_files | |
| %w{jquery.js pure.js}.each {|file| js("load('public/javascripts/#{file}');")} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jasmine.create$SpyObj = function(name, listOfSpyMethods) { | |
| listOfSpyMethods = listOfSpyMethods || ['unbind', 'remove']; | |
| return jQuery.extend($('<div/>'), jasmine.createSpyObj(name, listOfSpyMethods)); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.expr[':'].focus = function(a){ | |
| return (a == document.activeElement); | |
| } | |
| $(".:focus"); // The currently focused element |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| toBeObjectWithProperties: function(expectedClass, expectedProperties) { | |
| var isObjectWithProperties = (this.actual instanceof expectedClass); | |
| for(var propertyName in expectedProperties){ | |
| var expectedPropertyValue = expectedProperties[propertyName]; | |
| isObjectWithProperties = isObjectWithProperties && (this.actual[propertyName] == expectedPropertyValue); | |
| } | |
| return isObjectWithProperties; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Methods like "put_raw" will put the raw content in the request | |
| [:put, :post].each do |verb| | |
| define_method "#{verb}_raw" do |method, content| | |
| request.stub!(:raw_post).and_return(content) | |
| put method | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var addBackboneSupportToJasminePrettyPrinter = function() { | |
| var oldPrettyPrinterFormat = jasmine.PrettyPrinter.prototype.format; | |
| jasmine.PrettyPrinter.prototype.format = function(value) { | |
| var self = this; | |
| if(value instanceof Backbone.Model){ | |
| this.emitObject(value.attributes); | |
| } | |
| else if(value instanceof Backbone.Collection){ | |
| value.each(function(model) { | |
| self.emitScalar(model.cid); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function( $ ){ | |
| $.fn.delayedKeyup = function(period, handler) { | |
| var delayedHandler = (function() { | |
| var timer = 0; | |
| return function(callback, miliSeconds) { | |
| clearTimeout(timer); | |
| timer = setTimeout(callback, miliSeconds); | |
| } | |
| })(); |
OlderNewer