scope.paragraphs = _.map paragraphs, (lines) -> lines.split('\n') Also see simple_format helper for Javascript...

makandra dev
blog.getbootstrap.com

...even easier. If you need IE8 support, keep using Bootstrap 3. Rewrote all our JavaScript plugins. Every plugin has been rewritten in ES6 to take advantage of the newest JavaScript...

# when the browser has no focus. When /^I unfocus the "(.*?)" field to trigger javascript listeners$/ do |field_label| field = page.find_field(field_label) # Firing 'autocomplete:done' is a workaround...

field = $('#{field[:id]}') field.blur() field.fire('autocomplete:done') JS sleep 1 end In the javascript: /* * Listening on "blur" events does not work in tests because Firefox has a bug * deferring...

end Short explanation: asset_host is used for links to stylesheets and javascripts asset_host belongs to ActionController::Base -- changes are persistent and will not be reset after...

...because we cannot yield out of define_method module InstanceMethods private # Force URLs for JavaScript and Stylesheet links def assets_have_urls old_asset_host = asset_host self.asset_host = HOST...

You are not using javascript tests The file is served from a public folder (not via controller) Problem description If you deliver files from a public folder it might...

...response with content-type "..." Outline How to test file downloads with tests that need javascript. Public served Look at the link of the url and check if this file exists...

Old release code Old tmp folders with compiled view templates etc. Precompiled assets (Javascripts, images...) that no longer exist. When using the asset pipeline, Capistrano will symlink the public/assets...

...User-definable order of items Complicated item elements with super-custom CSS and other Javascript functionality Items that can be both leaves and containers of other items has_ancestry on...

...ended up using only draggable and reimplement something like droppable in ~120 lines of Javascript. There is some drag'n'drop support in Capybara/Selenium nodes, but again it's not...

makandra dev

...use Semantic Versioning's naming convention. If your library has both a Ruby and JavaScript component and you want to use the same version constant for both, you can use...

...some kind of pre-processing. You could probably also hack together a solution in JavaScript which downloads the background image file, rewrites the XML string and generates a data: URI...

...content of $('#id'). To do the same in Rails 3, include usual rails-ujs JavaScript, and put this into your application.js: $(function() { $('[data-remote][data-replace]') .data('type', 'html')

...replaced event on the link. .unobtrusive version In case you are using our unobtrusive JavaScript helper, use the following code instead: $.unobtrusive(function() { $('[data-remote][data-replace]') .data('type', 'html...

makandra dev

...position receives the click A step which finds and clicks the desired link via javascript may solve the problem: When(/^I search and click on "([^"]*)"$/) do |text| page.execute_script("$(\":contains...

...text}'):not(:has(:contains('#{text}')))\").click()") end Note: "Clicking" via JavaScript might click elements which are actually not clickable, e.g. because a modal overlay covers them. Use with caution.

...or close the dialog. The easiest way to interact with the editor is via javascript postMessages. To abort the dialog a post message on click with an event listener like...

...opacity': 1, 'margin-top': 0 }, { duration: 500 }); } The animation is implemented using setInterval and Javascript. This works great, but it's not as smooth as a CSS transition. Fortunately the...

...as a drop-in replacement for animate, but animate using CSS transitions instead of Javascript. This gives you a much higher framerate. If Transit has too many bells and whistles...

I had to deal with JavaScript Undefined Error while accessing a specific CKEditor instance to fill in text. Ensure everything is loaded with patiently do page.execute_script("return isCkeditorLoaded('#{selector...

...selector}');").should be_true end html.gsub!(/\n+/, "") # otherwise: unterminated string literal (Selenium::WebDriver::Error::JavascriptError) page.execute_script("CKEDITOR.instances['#{selector}'].setData('#{html}');") end The snippet for JavaScript: function isCkeditorLoaded(instance_selector...

...commit messages, add a new link "Commit" to your bookmarks and use the following Javascript as the link URL: javascript:(function() { let storyTitles = []; let stories = Array.from(document.querySelectorAll('.story[data-selected...

...page, and have Selenium click it: path = "/your/path/here" id = "helper_#{SecureRandom.hex(8)}" execute_script <<-JAVASCRIPT var $helper = $(' ').attr({ href: #{path.to_json}, id: #{id.to_json}, target: '_blank' }); $helper.prependTo('body').text('click...

...me').css({ zIndex: 9999, position: 'absolute' }); setTimeout(function() { $helper.remove() }, 1000); JAVASCRIPT find("##{id}").click Note that the link tag is removed after 1 second. You may or may not want...

Some modern Javascript APIs return iterators instead of arrays. In plain Javascript you can loop through an iterator using for...of: var iterator = ...; for (var value of iterator) { console.log(value...

...not it is hidden via CSS. In a Selenium scenario, visibility is detected via Javascript. This detection is very precise and should correctly determine visibility for the most fucked up...

makandra dev

...browsers that support a given declaration. There is CSS.supports() to do the equivalent in Javascript. backdrop-filter (Edge 17+, but not FF): Applying filters to what is visible through an...

...in your PT profile or in ~/.config/geordi/global.yml if you have ever used geordi commit javascript: (function() { var pt_project_id = 'XXX'; var pt_token='XXX'; var url = `https://www.pivotaltracker.com/services/v5/projects/$...

If you manipulate the DOM with JavaScript and your page contains nested elements with position: relative, chances are Internet Explorer 7 will not properly move to the right position.

...nest. This is often impossible, though. Force the correct redrawing of the elements using JavaScript. Adding a bogus class ($(element).addClass('touch')) seems to suffice. Try to give the offending...

makandra dev

In JavaScript we often use Immediately Invoked Function Expessions (or IIFEs) to prevent local variables from bleeding into an outside scope: (function() { var foo = "value"; // foo is scoped to this...

...many ways to achieve this, from SVGs inlined into the HTML, SVGs inlined in CSS, JavaScript-based solutions, to icon fonts. Out of all these options, the tried and true...

...most advantages, since icon fonts are supported everywhere they perform well and require no JavaScript at all their icons align nicely with text their icons automatically inherit color and size...

Cucumber scenarios that are tagged with @javascript so they run with Selenium are very slow. You might not want to run them every time. In order to skip all Selenium...

...scenarios, call Cucumber like this: cucumber --tags ~@javascript Note that you should still run all the scenarios, including the Selenium ones, before you push a change...