You are currently browsing the tag archive for the ‘Javascript’ tag.

Perfect for situations that have no clear timeout, but only happen once.

Usage

untilTimeout(function(){
  var elements = $('.foo select');
  if(elements.length > 1){
    doStuffWith(elements)
    return true;
  }
}, 100)

Code

function untilTimeout(callback, time){
  var timer = setInterval(function(){
    if(callback()){
      clearInterval(timer);
     }
   }, time)
}

The default jasmine page always jumped around, since the #jasmine_content area is above the results.
This css makes the page more stable with a 2-column layout, progress top, results left, content right.

# jasmine.yml
stylesheets:
  - spec/javascripts/support/jasmine.css
  ...
# spec/javascripts/support/jasmine.css

#HTMLReporter .results{
  position:absolute;
  top: 250px;
  width: 50%;
}

#jasmine_content {
  position:absolute;
  top: 250px;
  right: 0;
  width: 50%;
}

We had some weird issue where CKEDITOR always failed when you tried to open the link diaog, we traced it back to the filebrowser which for some reason always exploded…

CKEDITOR.config.removePlugins = 'filebrowser'
CKEDITOR._.events.dialogDefinition.listeners.shift();

Works for text input, checkboxes, radio, select, textarea

function isFilled(e){
  var type = e.getAttribute('type');
  if(type == 'radio' || type == 'checkbox'){
    return e.checked
  } else {
    return !e.value.empty()
  }
}

function anyFieldFilledIn(e){
  return e.select('input, select, textarea').map(function(e){return isFilled(e)}).any()
}

I recently set out to find a good slideshow for our homepage, but most of them are monsters, with 20kb code, no thanks…
The simples/best solution i found was the s3Slider somewhat simple and looks good.

But after it started behaving silly (sliding to fast/slow, hanging on mouseover) I decided to fix it and discovered a pile of spaghetti. So here is my s3_slider rewrite download that is smaller(now ~1kb) / simpler / maintainable and more easy to setup! Demo of the new version

Follow

Get every new post delivered to your Inbox.

Join 76 other followers