diff options
author | prashant | 2015-01-29 15:36:45 +0530 |
---|---|---|
committer | prashant | 2015-01-29 15:36:45 +0530 |
commit | 4d55002e7acd845fdf2ed3d5577751e3dedf574d (patch) | |
tree | 0b483379812f3a5c1fea902536115ae274670ef6 /js/tbc_comment_ajax.txt | |
download | tbc_comments-4d55002e7acd845fdf2ed3d5577751e3dedf574d.tar.gz tbc_comments-4d55002e7acd845fdf2ed3d5577751e3dedf574d.tar.bz2 tbc_comments-4d55002e7acd845fdf2ed3d5577751e3dedf574d.zip |
first commit added all the files
Diffstat (limited to 'js/tbc_comment_ajax.txt')
-rw-r--r-- | js/tbc_comment_ajax.txt | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/js/tbc_comment_ajax.txt b/js/tbc_comment_ajax.txt new file mode 100644 index 0000000..9108ebd --- /dev/null +++ b/js/tbc_comment_ajax.txt @@ -0,0 +1,151 @@ + $(document).ready(function(){ + + var basePath = Drupal.settings.basePath; + var modPath = basePath + "comments/"; + var modPath1 = basePath + "comments/books"; + var modPath2 = basePath + "comments/books/all"; +//function changeLikeDislike(type,id){ + +$(".likebt").click(function(){ + console.log("Like"); + +var type = $(this).attr('data-name'); +var id = $(this).attr('data-bid'); + console.log("###"); + var dataString = 'id='+ id + '&type=' + type; + $("#product_flash_"+id).show(); + $("#product_flash_"+id).fadeIn(400).html('<img src="' +basePath+'sites/all/modules/tbc_comments/image/loading.gif" />'); + + console.log(dataString); + $.ajax({ + type: "POST", + url: modPath + "ajax/", + data: dataString, + cache: false, + success: function(result){ + console.log("Like"); + console.log(result); + $('#product_like_'+ id).html(result); + + } + }); +}); + +$(".dislikebt").click(function(){ +var type = $(this).attr('data-name'); +var id = $(this).attr('data-bid'); + console.log("###"); + var dataString = 'id='+ id + '&type=' + type; + $("#product_flash_"+id).show(); + $("#product_flash_"+id).fadeIn(400).html('<img src="' +basePath+'sites/all/modules/tbc_comments/image/loading.gif" />'); + + console.log(dataString); + $.ajax({ + type: "POST", + url: modPath + "ajax/", + data: dataString, + cache: false, + success: function(result){ + console.log("disLike"); + console.log(result); + + $('#product_dislike_'+ id).html(result); + + } + }); + + +}); + + +$(".popup_comment_box").hide(); +$(".comment_click").click(function() { + +var cid = $(this).attr('data-bookid'); + $('#popup_box_'+ cid).fadeIn("slow"); + $("#container").css({ // this is just for style + "opacity": "0.3" + }); + +}); + $('.close_button').click( function() { + unloadPopupBox(); + }); + + + $('#container').click( function() { + unloadPopupBox(); + }); + + function unloadPopupBox() { // TO Unload the Popupbox + $('.popup_comment_box').fadeOut("slow"); + $("#container").css({ // this is just for style + "opacity": "1" + }); + } + + function loadPopupBox() { // To Load the Popupbox + $('.popup_comment_box').fadeIn("slow"); + $("#container").css({ // this is just for style + "opacity": "0.3" + }); + } +// + + + + + + + var submit = $('.submit_form'); + var form = $('.form_comments'); + console.log(form); + + + form.on('submit', function(e) { + // prevent default action + e.preventDefault(); + // send ajax request + $.ajax({ + url: modPath1 + '/ajax/', + type: 'POST', + //cache: false, + data: form.serialize(), //form serizlize data + beforeSend: function(){ + console.log('###'); + // change submit button value text and disabled it + console.log(form.serialize()); + submit.val('Submitting...').attr('disabled', 'disabled'); + }, + success: function(data){ + + var item = $(data).hide().fadeIn(800); + console.log('sssss'); + console.log(item); + $('#comment-block').prepend(item); + + + // reset form and button + form.trigger('reset'); + submit.val('Submit Comment').removeAttr('disabled'); + }, + error: function(e){ + alert(e); + } + }); + }); +// + +$("#testform").click(function() { + +$("#share").append('<form action="" method="POST">'); + $("#share form").append('<div class="appm">Save this</div>'); + $("#share form").append('<input type="text" placeholder="Name" name="routename" id="rname"/>'); + $("#share form").append('<input type="text" placeholder="description" id="rdescription" name="routedescription" class="address"/>'); + $("#share form").append('<input type="text" placeholder="tags" id="tags" name="routetags"/>'); + $("#share form").append('<br><input type="submit" id="savebutton" value="Save" />'); +}); +}); + + + |