| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- // Effect drag category
- $( function() {
- $( ".library-header-menu-cover" ).draggable({
- refreshPositions: true,
- drag: function( event, ui ) {
- var right = $(ui.helper[0]).parent().width() - $(ui.helper[0]).width();
- ui.position.left = Math.max( right , ui.position.left );
- ui.position.left = Math.min( 0, ui.position.left );
-
- ui.position.top = 0;
- }
- });
- } );
- $(document).ready(function(){
- // Effect show search
- $("#library-search-input").click(function(event) {
- //$(".library-search-result").fadeIn();
- $(".library-search-container .shadow-overlap").fadeIn();
- $(".library-search-icon").addClass('flipper-icon');
- });
- $(".library-search-container .shadow-overlap").click(function(event) {
- $(".library-search-result").fadeOut();
- $(".library-search-container .shadow-overlap").fadeOut();
- $(".library-search-icon").removeClass('flipper-icon');
- });
- $(".library-search-icon").click(function(event) {
- if( $(this).hasClass('flipper-icon') ){
- $(".library-search-container .shadow-overlap").trigger('click');
- }else{
- $("#library-search-input").trigger('click');
- }
- });
- // Start Search
- var timeSearch;
- $("#library-search-input").keyup(function(event) {
- var keyWord = $(this).val();
-
- if(event.keyCode == 13){
- if(keyWord.trim() != ""){
- window.location.href = urlConfig('Common/Course?searchname='+keyWord);
- }else{
- return false;
- }
- }else{
-
- clearTimeout(timeSearch);
- timeSearch = setTimeout(function(){
- // Show result
- if(keyWord != "" && keyWord != undefined){
- $.ajax({
- url: urlConfig("library-search"),
- data: {
- key_word : keyWord
- },
-
- type:"POST"
-
- }).success(function(data) {
- $(".library-search-result").fadeIn();
- $('.library-search-result').html(data);
- $(".library-search-result .result-product").fadeIn(200);
-
- });
-
-
- }
- }, 300);
- }
-
-
- });
- $(document).on('click','.btn-suggest-vocabulary',function(){
- if(checkSuggestProduct()){
- var vocabularyName = $('#suggest-product-name').val();
- var idea = $('#suggest-product-description').val();
- var source = $('#suggest-product-document').val();
- var token = $('input[name="suggest_token"]').val();
-
- if(vocabularyName.trim() != "" && idea.trim() != ""){
- $('#modal-suggest-product').modal('hide');
- $(".library-search-container .shadow-overlap").trigger('click');
- $.ajax({
- url: urlConfig("suggest-vocabulary"),
- data: {
- vocabulary_name : vocabularyName,
- vocabulary_idea : idea,
- vocabulary_document : source,
- suggest_token : token,
- },
-
- type:"POST"
-
- }).success(function(data) {
-
- $("body").append('<span class="toast-msg">'+data[1]+'</span>');
- $(".toast-msg").fadeIn(400,function(){
- setTimeout(function(){
- $(".toast-msg").fadeOut(function(){
- $(".toast-msg").remove();
- });
- }, 2000);
- });
- });
- }
- }
- });
-
-
- });
- // Check sugget product
- $(document).on('change keyup', ".suggest-product-input", function(){
- if(checkSuggestProduct()){
- $('.suggest-product-bottom button').addClass('button-active');
- }else{
- $('.suggest-product-bottom button').removeClass('button-active');
- }
- });
- function checkSuggestProduct(){
- var productName = $("#suggest-product-name").val();
- var productDes = $("#suggest-product-description").val();
- if(productName != "" && productDes != ""){
- return true;
- }
- return false;
- }
- var tUser;
- var isStoped = false;
- function stopGetUserProduct() {
- isStoped = true;
- clearTimeout(tUser);
- }
- function getUserProduct(){
- if(!isStoped){
- tUser = setTimeout(function(){
- var link = $('.product-user').attr('link')
- $.ajax({
- url: link,
- data: {
- },
- type: "POST"
- }).success(function(data) {
- if(data != ''){
- $('.product-user').css({'bottom':'-200px','opacity':0});
- $('.product-user').html(data);
- $('.product-user').animate({'bottom':'15px','opacity':0.9}, 1300);
- setTimeout(function(){
- $('.product-user').animate({'bottom':'-200px','opacity':0}, 1300);
- getUserProduct();
- },15000)
- }
-
- });
- },15000);
- }
-
- }
|