Created
September 16, 2015 18:32
-
-
Save cacheleocode/482c3c6e1ffbbd5a4197 to your computer and use it in GitHub Desktop.
some popover garbage
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 status = ""; | |
// closed | |
$(".rating_badge.closed").popover({ | |
placement : 'right', | |
html: true, | |
title: 'Nima-kai Favorites<a class="close" href="#">×</a>', | |
content: $("#nima_stars p").html(), | |
trigger: "manual" | |
}) | |
.on("mouseenter", function() { | |
var _this = this; | |
$(this).popover("show"); | |
$(".popover").on("mouseleave", function() { | |
$(_this).popover('hide'); | |
}); | |
}).on("mouseleave", function() { | |
var _this = this; | |
setTimeout(function() { | |
if (!$(".popover:hover").length) { | |
$(_this).popover("hide"); | |
} | |
}, 300); | |
}); | |
$(".rating_badge.closed").click(function (e) { | |
e.stopPropagation(); | |
}); | |
$(document).click(function (e) { | |
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) { | |
$(".rating_badge.closed").popover('hide'); | |
} | |
}); | |
// disabled | |
$(".rating_badge.disabled").on('click', function(e) { | |
$('#choice_modal').modal(); | |
return false; | |
}); | |
$(".rating_badge.disabled").popover({ | |
placement : 'right', | |
html: true, | |
title: 'Nima-kai Favorites<a class="close" href="#">×</a>', | |
content: $("#nima_stars p").html(), | |
trigger: "manual" | |
}) | |
.on("mouseenter", function() { | |
var _this = this; | |
$(this).popover("show"); | |
$(".popover").on("mouseleave", function() { | |
$(_this).popover('hide'); | |
}); | |
}).on("mouseleave", function() { | |
var _this = this; | |
setTimeout(function() { | |
if (!$(".popover:hover").length) { | |
$(_this).popover("hide"); | |
} | |
}, 300); | |
}); | |
$(".rating_badge.disabled").click(function (e) { | |
e.stopPropagation(); | |
}); | |
$(document).click(function (e) { | |
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) { | |
$(".rating_badge.disabled").popover('hide'); | |
} | |
}); | |
/* | |
$(".rating_badge.disabled").on('show.bs.popover', function() { | |
$(".popover .close").on("click", function(e) { | |
e.preventDefault(); | |
return false; | |
}); | |
}); | |
*/ | |
// enabled | |
$(".rating_badge.enabled").popover({ | |
placement : 'right', | |
html: true, | |
title: 'Nima-kai Favorites<a class="close" href="#">×</a>', | |
content: $("#nima_stars p").html(), | |
trigger: "manual" | |
}) | |
.on("mouseenter", function() { | |
var _this = this; | |
$(this).popover("show"); | |
$(".popover").on("mouseleave", function() { | |
$(_this).popover('hide'); | |
}); | |
}).on("mouseleave", function() { | |
var _this = this; | |
setTimeout(function() { | |
if (!$(".popover:hover").length) { | |
$(_this).popover("hide"); | |
} | |
}, 300); | |
}); | |
$(".rating_badge.enabled").click(function (e) { | |
e.stopPropagation(); | |
}); | |
$(document).click(function (e) { | |
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) { | |
$(".rating_badge.enabled").popover('hide'); | |
} | |
}); | |
// voted | |
$(".rating_badge.voted").popover({ | |
html: true, | |
title: 'Nima-kai Favorites<a class="close" href="#">×</a>', | |
content: $("#nima_stars p").html() | |
}); | |
$(".rating_badge.voted").click(function (e) { | |
e.stopPropagation(); | |
}); | |
$(document).click(function (e) { | |
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) { | |
$(".rating_badge.voted").popover('hide'); | |
} | |
}); | |
$(".rating_badge.voted").popover("show"); | |
$('#choice_modal').on('show.bs.modal', function (event) { | |
var modal = $(this); | |
$.ajax({ | |
type: "GET", | |
url: "/en/login/form/", | |
data: "satus=" + status, | |
success: function(msg) { | |
modal.find('.login_form').html(msg); | |
} | |
}); | |
$(document).on('submit', '#login_form', function(e){ | |
$(this).find('input[type="submit"]').prop('disabled', true); | |
$.ajax({ | |
type: "POST", | |
url: "/en/login/form/", | |
data: $(this).serialize(), | |
success: function(msg) { | |
if ($(msg).find(".errorlist").length > 0) { | |
modal.find('.login_form').html(msg); | |
$(this).find('input[type="submit"]').prop('disabled', false); | |
} | |
else { | |
$.ajax({ | |
url: $("#secret_ballot").prop("href"), | |
success: function(msg){ | |
if (msg == "vote was forbidden") { | |
console.debug("forbidden!"); | |
} | |
else { | |
location.reload(); | |
} | |
}, // success | |
error: function(xhr, ajaxOptions, thrownError) { | |
if(xhr.status==403) { | |
console.debug("error, 403"); | |
location.reload(); | |
} | |
console.debug("error, not found?"); | |
location.reload(); | |
} // error | |
}); | |
} | |
} // success | |
}); // ajax | |
e.preventDefault(); | |
}); // submit | |
$.ajax({ | |
type: "GET", | |
url: "/en/users/register/", | |
data: "satus=" + status, | |
success: function(msg) { | |
modal.find('.register_form').html(msg); | |
} | |
}); | |
$(document).on('submit', '#register_form', function(e){ | |
$(this).find('input[type="submit"]').prop('disabled', true); | |
$.ajax({ | |
type: "POST", | |
url: "/en/users/register/", | |
data: $(this).serialize(), | |
success: function(msg){ | |
if ($(msg).find(".errorlist").length > 0) { | |
modal.find('.register_form').html(msg); | |
$(this).find('input[type="submit"]').prop('disabled', false); | |
} | |
else { | |
modal.find('.register_form').html(msg); | |
} | |
} // success | |
}); // ajax | |
e.preventDefault(); | |
}); // submit | |
}); // #choice_modal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment