Skip to content

Instantly share code, notes, and snippets.

@kristianmandrup
Created January 30, 2010 13:12
Show Gist options
  • Save kristianmandrup/290545 to your computer and use it in GitHub Desktop.
Save kristianmandrup/290545 to your computer and use it in GitHub Desktop.
$(function() {
$(".sortable").sortable({cursor: 'pointer'});
$(".sortable").disableSelection();
});
$(function(){
//all hover and click logic for buttons
$(".fg-button:not(.ui-state-disabled)")
.hover(
function(){
$(this).addClass("ui-state-hover");
},
function(){
$(this).removeClass("ui-state-hover");
}
)
.mousedown(function(){
$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){ $(this).removeClass("ui-state-active"); }
else { $(this).addClass("ui-state-active"); }
})
.mouseup(function(){
if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button, .fg-buttonset-multi .fg-button') ){
$(this).removeClass("ui-state-active");
}
});
$("a.ajax_button").each(function(index, elem) {
e = $(this);
clazz = e.attr('class')
m = clazz.match(/h_(\d+)/);
options = {padding: 4, hideOnOverlayClick: false, hideOnContentClick: false, enableEscapeButton: true}
if (m) {
height = m[1];
options['frameHeight'] = parseInt(height);
}
e.fancybox(options);
});
$('a[type*=submit]').click(function(){
var me = this;
$.facebox(function(){
$.get(me.href,
null,
function(data){
$.facebox(data);
ajaxifyLoginForm(); // Here is the line we need to add
},
'html');
});
return false;
});
});
function ajaxifyForm() {
$('form.formtastic').submit(function(){
var me = $(this); // need access to this in our callbacks
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serialize(),
dataType: 'html',
success: function(data) {
window.location = '/albums';
},
error: function(xhr) {
if (xhr.status == '406') {
$('#errorExplanation').remove();
me.before('<div id="errorExplanation" class="errorExplanation">\
<h2>Dang you got errored!</h2>\
<p>'+ xhr.responseText + '</p>\
</div>');
}
}
});
return false;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment