' + error + '
'); } else { $('.error', popup).removeClass('hide'); } } } }); } }); $(window).resize(function() { var popup = $('#notice-popup'); if (!popup.hasClass('hide')) { $('.con', popup).css({'max-height':$(window).height() - $('#header').outerHeight() - $('#notice-popup .hd').outerHeight() - 3}); } }); $('#notice-popup .close').click(function() { $('#notice-popup').addClass('hide'); if ($('#notice-list .unread').length > 0) { // set all unread notice to be read var url = $(this).data('url'); $.ajax({ url: url, dataType: 'json', success: function() { $('.num', msg_ct).html(0).addClass('hide'); document.title = orig_doc_title; } }); } }); $('#my-info').click(function() { var popup = $('#user-info-popup'); popup.toggleClass('hide'); if (!popup.hasClass('hide')) { var loading_tip = $('.loading-tip', popup), space_traffic = $('#space-traffic'); loading_tip.show(); space_traffic.addClass('hide'); $('.error', popup).addClass('hide'); $.ajax({ url: space_traffic.data('url'), dataType: 'json', cache: false, success: function(data) { loading_tip.hide(); space_traffic.html(data['html']).removeClass('hide'); }, error: function (xhr, textStatus, errorThrown) { if (xhr.responseText) { var error = $.parseJSON(xhr.responseText).error; loading_tip.hide(); if ($('.error', popup).length == 0) { loading_tip.after('' + error + '
'); } else { $('.error', popup).removeClass('hide'); } } } }); } }); }); $(document).click(function(e) { var target = e.target || event.srcElement; var closePopup = function(popup, popup_switch) { if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target) && !popup_switch.find('*').is(target) ) { popup.addClass('hide'); } }; closePopup($('#user-info-popup'), $('#my-info')); closePopup($('#top-nav-grp-info'), $('#top-nav-grp')); closePopup($('#notice-popup'), $('#notice-icon')); }); // search: disable submit when input nothing $('.search-form').submit(function() { if (!$.trim($(this).find('.search-input').val())) { return false; } }); $(".checkbox-label").hover( function() { $(this).addClass('hl'); }, function() { $(this).removeClass('hl'); } ); $("tr:gt(0)", $('table')).hover( function() { $(this).addClass('hl'); $(this).find('.op-icon, .op').removeClass('vh'); }, function() { $(this).find('.op-icon, .op').addClass('vh'); $(this).removeClass('hl'); } ); $('input, textarea').placeholder(); // clear repo enc info when log out $('#logout').click(function() { if ('localStorage' in window && window['localStorage'] !== null) { if (localStorage.length > 0) { for (var key in localStorage) { if (key.lastIndexOf('_decrypt_t') == 36 || key.lastIndexOf('_enc_key') == 36 || key.lastIndexOf('_enc_iv') == 36) { // key: {{repo_id}}_xx localStorage.removeItem(key); } } } } }); if ($.browser.mozilla || $.browser.msie) { $('a').focus(function() { $(this).blur(); }); } if ($.browser.msie) { $('button, input[type="checkbox"], input[type="radio"], input[type="submit"]').focus(function() { $(this).blur(); }); $('.search-input').css({'line-height':$('.search-input').css('height')}); } /* * add op confirm popup * e.g: * e.g: addConfirmTo($('.user-del'), {'title': 'Delete user', 'con':'Really del user %s ?'}); */ function addConfirmTo(op_ele, popup) { op_ele.click(function() { var con = ''; if ($(this).data('target') && popup['con'].indexOf('%s') != -1) { con = popup['con'].replace('%s', '' + HTMLescape($(this).data('target')) + ''); } else { con = popup['con']; } $('#confirm-con').html('' + con + '
'); $('#confirm-popup').modal({appendTo:'#main'}); $('#simplemodal-container').css({'height':'auto'}); $('#confirm-yes').data('url', $(this).data('url')).click(function() { location.href = $(this).data('url'); }); return false;//in case op_ele is '' }); } // Similar to ``addConfirmto``, instead using form post when user confirms. function addConfirmTo_POST(op_ele, popup) { op_ele.click(function() { var con = ''; if ($(this).data('target') && popup['con'].indexOf('%s') != -1) { con = popup['con'].replace('%s', '' + HTMLescape($(this).data('target')) + ''); } else { con = popup['con']; } $('#confirm-con').html('' + con + '
'); $('#confirm-popup').modal({appendTo:'#main'}); $('#simplemodal-container').css({'height':'auto'}); $('#confirm-yes').data('url', $(this).data('url')).click(function() { $('