jQuery(document).ready(function() {
var conHeight = $('.end-content').height();
$('.end-content').mousemove(function(e){
e.pageY<=conHeight+ $('.post_title').height()+ 160&&e.pageY>$('.post_title').height()+ 300&&(
$('.btnPrev').css("top",e.pageY-(245+ $('.post_title').height())),
$('.btnNext').css("top",e.pageY-(245+ $('.post_title').height()))
)
});
});
$(function() {
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
function highlightText(text, $node) {
var searchText = $.trim(text).toLowerCase(), currentNode = $node.get(0).firstChild, matchIndex, newTextNode, newSpanNode;
while ((matchIndex = currentNode.data.toLowerCase().indexOf(searchText)) >= 0) {
newTextNode = currentNode.splitText(matchIndex);
currentNode = newTextNode.splitText(searchText.length);
newSpanNode = document.createElement("span");
newSpanNode.className = "highlight";
currentNode.parentNode.insertBefore(newSpanNode, currentNode);
newSpanNode.appendChild(newTextNode);
}
}
$( "#upload-tags" )
// don't navigate away from the field on tab when selecting an item
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).autocomplete( "instance" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
highlight: function(match, keywords) {
keywords = keywords.split(' ').join('|');
return match.replace(new RegExp("("+keywords+")", "gi"),'<b>$1</b>');
},
source: function( request, response ) {
$.getJSON( "/gold-app/gold-includes/GOLD.php?GOLD=autocomplete", {
term: extractLast( request.term )
}, response );
},
search: function() {
// custom minLength
var term = extractLast( this.value );
if ( term.length < 1 ) {
return false;
}
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
return false;
}
}).each(function(){
data("ui-autocomplete")._renderItem = function( ul, item ) {
var $a = $("<span></span>").text(item.label);
highlightText(this.term, $a);
return $("<li></li>").append($a).appendTo(ul);
};
});
});
$(function(){
$("#comment_value").keyup(function(){
$(".char_num").text($(this).val().length);
});
$('.add_comment').autosize();
$('#loginform').submit(function(e){
return false;
});
$('#open_modal').leanModal({ top: 110, overlay: 0.60, closeButton: ".hidemodal" });
});
// COMMENTS AND FACEBOOK COMMENTS
$('.comments-switch').click(function(){
var comment_type = $(this).data('comments');
$('#tab_comments, #tab_fb_comments').hide();
$(comment_type).show();
$('.comments-switch').removeClass('active');
$(this).addClass('active');
});
$("#cd-error-message").hide();
$(function(){
$("#drag_elements ul").sortable({ scroll: true, scrollSensitivity: 100, opacity: 0.6, cursor: "move", update: function() {
var order = "gold=admin_menu&"+$(this).sortable("serialize") + "&action=updateRecordsListings";
$.post("/gold-app/gold-includes/GOLD.php", order, function(theResponse){
});
} });
$("#main_sidebar_drag_elements ul").sortable({ scroll: true, scrollSensitivity: 100, opacity: 0.6, cursor: "move", update: function() {
var order = "gold=admin_menu&"+$(this).sortable("serialize") + "&action=main_sidebar_updateRecordsListings";
$.post("/gold-app/gold-includes/GOLD.php", order, function(theResponse){
});
} });
$("#profile_sidebar_drag_elements ul").sortable({ scroll: true, scrollSensitivity: 100, opacity: 0.6, cursor: "move", update: function() {
var order = "gold=admin_menu&"+$(this).sortable("serialize") + "&action=profile_sidebar_updateRecordsListings";
$.post("/gold-app/gold-includes/GOLD.php", order, function(theResponse){
});
} });
$("#post_sidebar_drag_elements ul").sortable({ scroll: true, scrollSensitivity: 100, opacity: 0.6, cursor: "move", update: function() {
var order = "gold=admin_menu&"+$(this).sortable("serialize") + "&action=post_sidebar_updateRecordsListings";
$.post("/gold-app/gold-includes/GOLD.php", order, function(theResponse){
});
} });
function ins2pos(str, id) {
var TextArea = document.getElementById(id);
var val = TextArea.value;
var before = val.substring(0, TextArea.selectionStart);
var after = val.substring(TextArea.selectionEnd, val.length);
TextArea.value = before + str + after;
}
$('#reply_emoticons a').live('click', function() {
GOLD_id = $(this).attr('data-id');
var smiley = $(this).attr('title');
ins2pos(smiley, 'reply_textarea'+GOLD_id);
});
$('#emoticons a').live('click', function() {
var smiley = $(this).attr('title');
ins2pos(smiley, 'comment_value');
});
$("#login_button").live('click', function(){
username=$("#signin-email").val();
password=$("#signin-password").val();
$.ajax({
type: "POST",
url: "/gold-app/gold-includes/GOLD.php",
data: "gold=login&name="+username+"&password="+password,
success: function(html){
if(html=='true') {
//$("#add_err").html("right username or password");
window.location="/";
} else {
$("#cd-error-message").css('display', 'inline', 'important');
$("#cd-error-message").html(html);
}
}
});
return false;
});
$(".social-share").click(function(event) {
var width = 575,
height = 400,
left = ($(window).width() - width) / 2,
top = ($(window).height() - height) / 2,
url = this.href,
opts = 'status=1' +
',width=' + width +
',height=' + height +
',top=' + top +
',left=' + left;
window.open(url, 'twitter', opts);
return false;
});
$("a.reply").live('click', function() {
GOLD_id = $(this).attr('id');
var toggled = $(this).data('toggled');
$(this).data('toggled', !toggled);
if (!toggled) {
$("#reply_comment"+GOLD_id).css('display', 'block');
$("#reply_textarea"+GOLD_id).css('height', '53px');
} else {
$("#reply_comment"+GOLD_id).css('display', 'none');
$("#reply_textarea"+GOLD_id).css('height', '53px');
}
});
$("a.flag").live('click', function(){
GOLD_id = $(this).attr('id');
jQuery("#flag_buttons"+GOLD_id).addClass("comments-div-flag");
$.ajax({
type: "POST",
data: "gold=flag&id="+$(this).attr("id")+"&user_id="+$(this).attr("user_id")+"&type="+$(this).attr("type"),
url: "/gold-app/gold-includes/GOLD.php",
success: function(msg) { }
});
});
$("a.btn-up").live('click', function(){
GOLD_id = $(this).attr('id');
jQuery("#vote_box_buttons"+GOLD_id).addClass('div-vote-up');
$.ajax({
type: "POST",
data: "gold=vote_up&id="+$(this).attr("id")+"&user_id="+$(this).attr("user_id"),
url: "/gold-app/gold-includes/GOLD.php",
success: function(msg)
{
$("#vote_box_num"+GOLD_id).html(msg);
$("#vote_box_num"+GOLD_id).fadeIn();
}
});
});
$("a.btn-down").live('click', function(){
//get the id
GOLD_id = $(this).attr('id');
jQuery("#vote_box_buttons"+GOLD_id).removeClass('div-vote-up');
//the main ajax request
$.ajax({
type: "POST",
data: "gold=vote_down&id="+$(this).attr("id")+"&user_id="+$(this).attr("user_id"),
url: "/gold-app/gold-includes/GOLD.php",
success: function(msg)
{
$("#vote_box_num"+GOLD_id).html(msg);
$("#vote_box_num"+GOLD_id).fadeIn();
}
});
});
$("a.comments-vote-up").live('click', function(){
GOLD_id = $(this).attr('id');
jQuery("#vote_buttons"+GOLD_id).addClass('comments-div-vote-up');
$("span#comment_votes"+GOLD_id).fadeOut("fast");
$.ajax({
type: "POST",
data: "gold=comments_vote_up&id="+$(this).attr("id")+"&user_id="+$(this).attr("user_id"),
url: "/gold-app/gold-includes/GOLD.php",
success: function(msg)
{
$("span#comment_votes"+GOLD_id).html(msg);
$("span#comment_votes"+GOLD_id).fadeIn();
}
});
});
$("a.comments-vote-down").live('click', function(){
//get the id
GOLD_id = $(this).attr('id');
jQuery("#vote_buttons"+GOLD_id).removeClass('up');
jQuery("#vote_buttons"+GOLD_id).removeClass('comments-div-vote-up');
//the main ajax request
$.ajax({
type: "POST",
data: "gold=comments_vote_down&id="+$(this).attr("id")+"&user_id="+$(this).attr("user_id"),
url: "/gold-app/gold-includes/GOLD.php",
success: function(msg)
{
$("span#comment_votes"+GOLD_id).fadeOut();
$("span#comment_votes"+GOLD_id).html(msg);
$("span#comment_votes"+GOLD_id).fadeIn();
}
});
});
$("#submit_reply_comment").live('click', function(){
GOLD_id = $(this).attr('data-id');
var comment = $("#reply_textarea"+GOLD_id).val();
var post_id = $("#post_id"+GOLD_id).val();
if(comment=='')
{
$("#gold_comments_error"+GOLD_id).show();
return false;
}
var GOLD_DATA = "gold=submit_reply_comments&post_id="+post_id+"&comment="+comment+"&reply_comment_id="+GOLD_id;
//alert(dataString);
$.ajax({
type: "POST",
url: "/gold-app/gold-includes/GOLD.php",
cache: false ,
data: GOLD_DATA,
beforeSend: function(){
$("#gold_comments_error"+GOLD_id).hide();
},
success: function(data)
{
$("#comment_children_tree"+GOLD_id).html(data);
$("#comment_children_tree"+GOLD_id).fadeIn();
$("#reply_comment"+GOLD_id).css("display", "none");
$("#gold_comments_error"+GOLD_id).hide();
$("#reply_textarea"+GOLD_id).val('');
return false;
}
});
return false;;
});
$("#submit_comment").live('click', function(){
var comment = $("#comment_value").val();
var post_id = $("#post_id").val();
if(comment=='')
{
$("#gold_comments_error").show();
return false;
}
var GOLD_DATA = "gold=comments&post_id="+post_id+"&comment="+comment;
//alert(dataString);
$.ajax({
type: "POST",
url: "/gold-app/gold-includes/GOLD.php",
cache: false ,
data: GOLD_DATA,
beforeSend: function(){
$("#gold_comments_error").hide();
$('#loading-indicator').show();
},
success: function(data)
{
$(".char_num").html('0');
$("#gold_comments_error").hide();
$(".responsive_no_comments").hide();
$('#loading-indicator').hide();
$('.responsive_comments_tree').html(data);
$("#comment_value").val('');
return false;
}
});
return false;;
});
});
jQuery(document).ready(function() {
var container = document.querySelector('#container');
var msnry;
// initialize Masonry after all images have loaded
imagesLoaded( container, function() {
msnry = new Masonry( container, {
itemSelector: '.box-object',
columnWidth: 285,
isFitWidth: true,
gutter: 10
});
$('#loading-indicator').hide();
});
var ias = $.ias({
container: "#container",
item: ".box-object",
pagination: "#page-nav",
next: "#page-nav a",
delay: 400,
negativeMargin: 200
});
ias.on('render', function(items) {
$(items).css({ opacity: 0 })
});
ias.on('rendered', function(items) {
imagesLoaded( items, function() {
msnry.appended(items);
});
});
ias.extension(new IASSpinnerExtension());
});
//<![CDATA[
$(window).load(function(){
$('#profile_box').hover(function() {
});
$("#main-nav-toggle").click(function(event)
{
$(".sidebar").animate({width: 'toggle'});
});
});//]]>
//<![CDATA[
window.onload = function(){
//Check File API support
if(window.File && window.FileList && window.FileReader)
{
var filesInput = document.getElementById("add-file");
filesInput.addEventListener("change", function(event){
var files = event.target.files; //FileList object
var output = document.getElementById("result");
for(var i = 0; i< files.length; i++)
{
var file = files[i];
//Only pics
if(!file.type.match('image'))
continue;
var picReader = new FileReader();
picReader.addEventListener("load",function(event){
$("#upload-data").css("clear", "both");
$("#add-seperator").hide();
$("#add-url-area").remove();
var picFile = event.target;
var div = document.createElement("div");
div.className = "preview_img";
div.innerHTML = "<img style='display: block; width: 280px; float: left;' src='" + picFile.result + "'" +
"title='" + picFile.name + "'/>";
output.insertBefore(div,null);
});
//Read the image
picReader.readAsDataURL(file);
}
});
}
else
{
console.log("Your browser does not support File API");
}
}
//]]>