1var Application= jQuery({}); 2var A = Application; 3 4A.log = function(str) { 5 if(window.console && console.log) 6 console.log(str); 7} 8 9A.enablePlaceholders = function() { 10 if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 10) { 11 jQuery('input[placeholder], textarea[placeholder]').each( function(){ 12 var input_with_default = jQuery(this); 13 14 if (jQuery.trim(input_with_default.val()) == "") { 15 input_with_default.val(input_with_default.attr('placeholder')); 16 } 17 18 input_with_default.focus(function() { 19 var input_with_default = jQuery(this) 20 if (input_with_default.val() == input_with_default.attr('placeholder')) { 21 input_with_default.val(""); 22 } 23 }); 24 25 input_with_default.blur(function() { 26 var input_with_default = jQuery(this) 27 if (jQuery.trim(input_with_default.val()) == "") { 28 input_with_default.val(input_with_default.attr('placeholder')); 29 } 30 }); 31 32 input_with_default.bind('updateplaceholder', function() { 33 var input_with_default = jQuery(this) 34 if (jQuery.trim(input_with_default.val()) == "") { 35 input_with_default.val(input_with_default.attr('placeholder')); 36 } 37 }); 38 39 }); 40 } 41} 42 43A.enableExpandoLists = function(selector) { 44 jQuery(selector).click(function() { 45 expander = jQuery(this); 46 expander.parent().siblings().show().end().hide(); 47 return false; 48 }) 49} 50 51// this is really really simple -- no intelligence at all -- just adds an 's' at the end of str if num != 1 52function pluralize(num, str) { 53 if (num == 1) 54 return num+' '+str; 55 else 56 return num+' '+str+'s'; 57} 58 59function detailURL(element) { 60 return permalinkURL()+'detail/'+$('document_id').innerHTML+'?element='+element 61} 62 63function summaryURL(element) { 64 return permalinkURL()+'summary/'+$('document_id').innerHTML+'?element='+element 65} 66 67function documentURL() { 68 return permalinkURL()+'show/'+$('document_id').innerHTML; 69} 70 71function permalinkURL() { 72 return '/courses/'+$('course_id').innerHTML+'/documents/'; 73} 74 75// // this turns off all jquery effects to stop the qtip opacity issue 76// jQuery.fx.off = true; 77 78// Make jQuery play nice with respond_to blocks 79jQuery.ajaxSetup({ 80 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} 81}) 82 83function highlight(object) { 84 object.effect("highlight", {}, 1500); 85} 86 87function activate_tooltips() { 88 // jQuery('.comment_box').each(function(){ 89 // var comment_box=jQuery(this); 90 // var counter = comment_box.children('.counter'); 91 // conversations = counter.attr('conversations'); 92 // comment_box.qtip({ 93 // content: "<p>This document has " + counter.text() + " comments in "+ conversations +" conversations</p>", 94 // position: { 95 // corner: { 96 // target: 'rightMiddle', 97 // tooltip: 'leftMiddle' 98 // } 99 // }, 100 // show: { 101 // solo: true 102 // }, 103 // style: { 104 // tip: 'leftMiddle', 105 // name: 'dark', 106 // color: 'white', 107 // background: '#0079B1', 108 // width: 280, 109 // border: { 110 // width: 2, 111 // radius: 4, 112 // color: '#0079B1' 113 // } 114 // } 115 // }) 116 // }); 117 118 jQuery('.processing.status').qtip({ 119 content: { 120 text: "processing..." 121 }, 122 position: { 123 corner: { 124 target: 'rightMiddle', 125 tooltip: 'leftMiddle' 126 } 127 }, 128 show: { 129 solo: true 130 }, 131 hide: { 132 delay: 1000, 133 fixed: true 134 }, 135 style: { 136 tip: 'leftMiddle', 137 button: { 138 'cursor': 'pointer' 139 }, 140 name: 'dark', 141 color: 'white', 142 "font-style": 'italic', 143 background: '#0079B1', 144 border: { 145 width: 2, 146 radius: 4, 147 color: '#0079B1' 148 } 149 } 150 }); 151 152 jQuery('.failure.status').qtip({ 153 content: { 154 text: "Failed to Upload" 155 }, 156 position: { 157 corner: { 158 target: 'rightMiddle', 159 tooltip: 'leftMiddle' 160 } 161 }, 162 show: { 163 solo: true 164 }, 165 hide: { 166 delay: 1000, 167 fixed: true 168 }, 169 style: { 170 tip: 'leftMiddle', 171 button: { 172 'cursor': 'pointer' 173 }, 174 name: 'dark', 175 color: 'white', 176 "font-style": 'italic', 177 background: '#0079B1', 178 border: { 179 width: 2, 180 radius: 4, 181 color: '#0079B1' 182 } 183 } 184 }); 185 186 jQuery('.flyout').each(function(){ 187 var bg_colour = '#0079B1'; 188 var width = 430; 189 var flyout_icon=jQuery(this); 190 if (flyout_icon.attr('right_align') == 'true') { 191 var target = 'rightMiddle'; 192 var tipstyle = 'leftMiddle'; 193 } else if (flyout_icon.attr('top_align') == 'true') { 194 var target = 'topMiddle'; 195 var tipstyle = 'bottomMiddle'; 196 } else if (flyout_icon.attr('bottom_align') == 'true') { 197 var target = 'bottomMiddle'; 198 var tipstyle = 'topMiddle'; 199 width = 330; 200 } else { 201 var target = 'leftMiddle'; 202 var tipstyle = 'rightMiddle'; 203 } 204 flyout_icon.qtip({ 205 content:{ 206 text: "Loading...", 207 url: flyout_icon.attr('rel')}, 208 position: { 209 corner: { 210 target: target, 211 tooltip: tipstyle 212 } 213 }, 214 show: { 215 solo: true 216 }, 217 hide: { 218 delay: 1000, 219 fixed: true 220 }, 221 style: { 222 tip: tipstyle, 223 button: { 224 'cursor': 'pointer' 225 }, 226 name: 'dark', 227 color: 'white', 228 background: bg_colour, 229 width: width, 230 border: { 231 width: 2, 232 radius: 4, 233 color: bg_colour 234 } 235 } 236 }) 237 }); 238 239 jQuery('.updates_toggle_button').qtip({ 240 content: { 241 text: "Email me about any comment on this document, either right away or in tomorrow\'s Daily Digest as controlled by my <a class=\"no_animation\" target=\"_blank\" href=\"/account/settings/notifications\">Notification Settings</a>" 242 }, 243 position: { 244 corner: { 245 target: 'bottomRight',
246 tooltip: 'topRight' 247 } 248 }, 249 hide: { 250 delay: 1000, 251 fixed: true 252 }, 253 style: { 254 tip: 'topRight', 255 name: 'dark', 256 color: 'white', 257 background: '#0079B1', 258 width: 330, 259 border: { 260 width: 2, 261 radius: 4, 262 color: '#0079B1' 263 }, 264 classes: { 265 tooltip: 'updates_toggle_tooltip' 266 } 267 } 268 }); 269 270 jQuery('.new_tooltip').qtip({ 271 position: { 272 corner: { 273 target: 'topMiddle', 274 tooltip: 'bottomMiddle' 275 } 276 }, 277 style: { 278 tip: 'bottomMiddle', 279 name: 'dark', 280 color: 'white', 281 background: '#0079B1', 282 width: 200, 283 border: { 284 width: 2, 285 radius: 4, 286 color: '#0079B1' 287 } 288 } 289 }); 290 291 jQuery('.tooltip_right').qtip({ 292 position: { 293 corner: { 294 target: 'rightMiddle', 295 tooltip: 'leftMiddle' 296 } 297 }, 298 style: { 299 tip: 'leftMiddle', 300 name: 'dark', 301 color: 'white', 302 background: '#0079B1', 303 width: 350, 304 border: { 305 width: 2, 306 radius: 4, 307 color: '#0079B1' 308 } 309 } 310 }); 311 312 jQuery('.create_new_btn').qtip({ 313 content: "<a href='/documents/new' class='qtip_links icon doc_icon'>Document</a><br /><a href='/folders/new' class='qtip_links icon folder_icon'>Folder</a><br /><a href='/groups/new' class='qtip_links icon group_icon'>Group</a>", 314 position: { 315 corner: { 316 target: 'bottomMiddle', 317 tooltip: 'topMiddle' 318 } 319 }, 320 show: { 321 when: 'click', 322 solo: true 323 }, 324 hide: { 325 fixed: true, 326 delay: 1000 327 }, 328 style: { 329 tip: 'topMiddle', 330 name: 'dark', 331 color: 'white', 332 background: '#0079B1', 333 width: 200, 334 border: { 335 width: 2, 336 radius: 4, 337 color: '#0079B1' 338 } 339 } 340 }); 341 342 jQuery('.modaltip').each(function(modalTip){ 343 jQuery(this).qtip({ 344 content: jQuery(this).next(), 345 position: { 346 corner: { 347 target: 'rightMiddle', 348 tooltip: 'leftMiddle' 349 } 350 }, 351 show: { 352 // when: 'click', 353 solo: true 354 }, 355 hide: { 356 fixed: true, 357 delay: 1000 358 }, 359 style: { 360 button: { 361 'cursor': 'pointer' 362 }, 363 tip: 'leftMiddle', 364 name: 'dark', 365 color: 'white', 366 background: '#3495cc', 367 border: { 368 width: 2, 369 radius: 4, 370 color: '#3495cc' 371 } 372 }, 373 api: { 374 onFocus: function(){ 375 var self = this; 376 377 jQuery(self.elements.tooltip).mouseleave(function(){ 378 jQuery(this).fadeOut('fast'); 379 }) 380 } 381 } 382 }); 383 384 385 }); 386} 387 388jQuery(function( $ ){ 389// var t = new Date; 390// var start = t.getTime(); 391// console.log('Misc setup'); 392 393 jQuery('#flash_close, #acknowledge_notification').click(function() { 394 jQuery('.flash').slideUp(); 395 jQuery.post('/users/acknowledge_notification'); 396 return false; 397 }); 398 399 jQuery('#announcement_close').click(function() { 400 jQuery('.system_announcement').slideUp(); 401 return false; 402 }); 403 404// jQuery('#doc_comment_header').click(function(e) { 405// if (e.target.tagName == 'IMG') { return } 406// doc_header = jQuery(this); 407// 408// if(doc_header.hasClass('open')) { 409// doc_header.removeClass('open'); 410// jQuery('#doc_comments').hide(); 411// } else { 412// doc_header.addClass('open'); 413// jQuery('#doc_comments').show(); 414// } 415// }); 416 417 jQuery(".course_listing caption").click(function() { 418 table = jQuery(this).parent(); 419 table.toggleClass('open'); 420 table.children('tbody').toggle(); 421 }); 422 423 if(navigator.userAgent.toLowerCase().indexOf('firefox') > 0){ 424 jQuery('.firefox_only').show(); 425 }; 426 427 jQuery("#signup_button a").click(function(){ 428 var link = jQuery(this); 429 link = link.attr('href'); 430 var e_input = jQuery("#user_session_email"); 431 email = e_input.val(); 432 var p_input = jQuery("#user_session_password"); 433 password = p_input.val(); 434 window.location = link + "?email=" + email; 435 return false 436 }); 437 438 jQuery(".draggable").draggable({cancel: ".cke, input, textarea, .button, select"}); 439 440 //load flash error at 0 opacity above page content 441 //animate flash error downwards 442 //pause for 10 seconds 443 //animate flash error upwards 444 jQuery('.flash').slideDown('fast',function (){ 445 jQuery(this).effect("highlight", {color: "#00F"}, 300); 446 }); 447 448 jQuery('table.sortable th').not('.select, .empty, .comments_header').click(function(){ 449 sort_docs_table(jQuery(this), false, false); 450 }); 451 452 jQuery('span.new_docs_count').click(function() { 453 if (jQuery('span.new_docs_count').text().match(/normal sort/)) { 454 sort_docs_table(jQuery('th[sort_field="last_activity"]'), false, true); 455 } else { 456 sort_docs_table(jQuery('th[sort_field="last_activity"]'), true, true); 457 } 458 }); 459 460 function sort_docs_table(header, new_first, force_asc) { 461 var sort_field = header.attr('sort_field'); 462 var show_toolbar = jQuery('.document_table').attr('data-show-toolbar'); 463 464 if (new_first || force_asc) { 465 sort_direction = 'ASC'; 466 jQuery('span.new_docs_count').text('please wait...'); 467 } else { 468 sort_direction = header.attr('sort_direction') || 'ASC'; 469 if (header.hasClass('active_sort')) { 470 if (sort_direction == 'ASC') { 471 sort_direction = 'DESC' 472 } else { 473 sort_direction = 'ASC'; 474 } 475 } 476 } 477 478 jQuery('.document_table thead th').removeClass('active_sort') 479 .removeClass('ASC') 480 .removeClass('DESC'); 481 482 header 483 .attr('sort_direction', sort_direction) 484 .addClass('active_sort') 485 .removeClass('ASC') 486 .removeClass('DESC') 487 .addClass(sort_direction) 488 .addClass('loading'); 489 490 window.location = window.location.pathname + '?show_toolbar=' + show_toolbar + '&sort_field=' + sort_field + '&sort_direction=' + sort_direction + '&new_first=' + new_first; 491 492 // We can no longer use this because we now reset to the first page of documents whenever we change the sort order and there's no easy way to update the pagination 493 // when we load the documents via javascript 494 // 495 //jQuery.get(window.location.pathname,{"show_toolbar":show_toolbar,"sort_field":sort_field, "sort_direction": sort_direction, "new_first": new_first}, function(data) { 496 // jQuery('tbody').remove(); 497 // jQuery('#document_table_head').after(data); 498 // activate_tooltips(); 499 // jQuery('.active_sort').removeClass('loading'); 500 // jQuery('span.new_docs_count').text(new_docs_count); 501 // jQuery(document).trigger('document_table/updated'); 502 //}, 'html'); 503 } 504 505 // Activate Tooltips 506 507 activate_tooltips(); 508 509 hovercardTooltips(); 510 511 A.enablePlaceholders(); 512 513 A.enableExpandoLists('.expand_list'); 514 515 // nav menu 516 $('#login_nav li').hover( 517 function () { 518 //show its submenu 519 $('ul', this).slideDown(100); 520 }, 521 function () { 522 //hide its submenu 523 $('ul', this).slideUp(100); 524 } 525 ); 526 $('li.help_dropdown').hover( 527 function () { 528 //show its submenu 529 $('ul', this).slideDown(100); 530 }, 531 function () { 532 //hide its submenu 533 $('ul', this).slideUp(100); 534 } 535 ); 536 $('li.safety_dropdown').hover( 537 function () { 538 //show its submenu 539 $('ul', this).slideDown(100); 540 }, 541 function () { 542 //hide its submenu 543 $('ul', this).slideUp(100); 544 } 545 ); 546 // documents table 547 $('table.document_table').on('mouseenter', 'ul.document_options', 548 function () { 549 //show its submenu 550 $('.document_options_menu', this).slideDown(100); 551 }); 552 553 $('table.document_table').on('mouseleave', 'ul.document_options', 554 function () { 555 //hide its submenu 556 $('.document_options_menu', this).slideUp(100); 557 } 558 ); 559// console.log('Finished misc setup'); 560// t = new Date; 561// var time = t.getTime() - start; 562// console.log("Took " + time + "ms"); 563}); 564 565function hovercardTooltips() { 566 // Hovercard JS 567 user_cards = jQuery('.user_card'); 568 if(user_cards.tooltip != undefined) 569 user_cards.tooltip({relative: true, predelay: 500, offset: [0, -57]}); 570 571 commenters = jQuery('.summary .commenter'); 572 if(commenters.tooltip != undefined) 573 commenters.tooltip({relative: true, predelay: 500, offset: [0, 50]}); 574 575 bots = jQuery('.fullcomment .bot_info'); 576 if(bots.tooltip != undefined) 577 bots.tooltip({relative: true, predelay: 500, offset: [15, 0]}); 578} 579 580function validateEmail(elementValue){ 581 var emailPattern = /^[a-zA-Z0-9+._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/; 582 return emailPattern.test(elementValue); 583} 584 585// highlight background of groups/documents when loading all folders page
586function highlightBackground(elements) { 587 jQuery(function(){ 588 jQuery(elements).addClass('highlighted'); 589 setTimeout(function() { 590 jQuery(elements).animate({color: '#0079B1'}, 3000); 591 }, 4000); 592 }); 593} 594 595jQuery(function() { 596 jQuery('a.load_quickref').click(function() { 597 jQuery("#reference_sheet").data("overlay").load(); 598 return false; 599 }); 600}); 601 602// For mobile devices 603jQuery(document).on('click', '.dropdown', function(event) { 604 jQuery(this).trigger('mouseenter'); 605}); 606 607jQuery(function() { 608 // dds layout 609 jQuery('#nowcomment').click(function() { 610 jQuery('.dropdown').trigger('mouseleave'); 611 }); 612 // application layout 613 jQuery('.container.main').click(function() { 614 jQuery('.dropdown').trigger('mouseleave'); 615 }); 616}); 617 618jQuery(function() { 619 jQuery('#new_owner_id').keyup(function(){ 620 jQuery.post('/users/find_name', {id: jQuery('#new_owner_id').val()}, function(data) { 621 jQuery('#new_owner_name').text(data); 622 }, 'text' 623 ); 624 }); 625}); 626 627function saveEditableDocument(element, async) { 628 var dom_obj = $(element); 629 var editor = CKEDITOR.instances[dom_obj.attr("id")]; 630 if (typeof(editor) != "undefined" && editor.checkDirty()) { // editor will be undefined if current user does not have permission to edit text 631 var data = {}; 632 data["document"] = {}; 633 data["document"]["fulltext"] = editor.getData(); 634 Debug.log("Saving data"); 635 if (async) { 636 $.ajax({"url": '/documents/' + dom_obj.data("id") + '/update_text', "data": data, "async": async, "type": "POST"}); 637 } else { 638 $.post('/documents/' + dom_obj.data("id") + '/update_text', data); 639 } 640 641 } 642} 643 644 645// Document upload page related scripts 646 647jQuery(function( $ ){ 648 if (jQuery('#doc_upload_form').length > 0) { 649 if (jQuery.cookie("upload_type") == "web") { 650 jQuery('#upload_web').click(); 651 } else if (jQuery.cookie("upload_type") == "word") { 652 jQuery('#upload_word_doc').click(); 653 } else if (jQuery.cookie("upload_type") == "pdf") { 654 jQuery('#upload_pdf').click(); 655 } else if (jQuery.cookie("upload_type") == "image") { 656 jQuery('#upload_image').click(); 657 } else if (jQuery.cookie("upload_type") == "c_and_p") { 658 jQuery('#upload_c_and_p').click(); 659 } 660 } 661 662 jQuery('#doc_upload_form').submit(function() { 663 jQuery('.doc_loading').show(); 664 jQuery('#doc_upload_form input[type="submit"]').val('Please wait...').attr('disabled', 'disabled'); 665 window.scrollTo(0,0); 666 }); 667 668 // Dan likes to use the back button to get back to this page - this will re-enable the button 669 jQuery('#doc_upload_form input[type="submit"]').removeAttr('disabled'); 670 671 if (jQuery('#document_fulltext').length > 0) { 672 var body_class = jQuery('body.documents-preview').length > 0 ? 'document_preview' : ''; 673 CKEDITOR.replace('document_fulltext', 674 { 675 toolbar: [['Maximize'], ['Bold', 'Italic'], ['RemoveFormat'], ['NumberedList', 'BulletedList'], ['Link', 'Unlink'], ['Source'], ['About']], 676 removePlugins: 'elementspath', 677 height : '250px', 678 width : '100%', 679 bodyClass: body_class 680 }); 681 } 682 683 if (jQuery('#editable_document_fulltext').length > 0) { 684 var editableArea = jQuery('#editable_document_fulltext'); 685 var height = editableArea.height(); 686 if (height < 250) { height = 250; } 687 var editor = CKEDITOR.inline('editable_document_fulltext', 688 { 689 toolbar: [ 690 { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] }, 691 { name: 'links', items: [ 'Link', 'Unlink' ] }, 692 { name: 'insert', items: [ 'Image', 'MediaEmbed', 'Table', 'HorizontalRule', 'SpecialChar' ] }, 693 { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source' ] }, 694 { name: 'others', items: [ '-' ] }, 695 '/', 696 { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] }, 697 { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote' ] }, 698 { name: 'styles', items: [ 'Styles', 'Format' ] }, 699 { name: 'about', items: [ 'About' ] } 700 ], 701 removePlugins: 'elementspath', 702 extraPlugins: 'mediaembed', 703 height : height, 704 width : '100%', 705 startupFocus: true, 706 filebrowserUploadUrl: '/uploaded_files' 707 }); 708 709 editor.on('blur', function() { 710 saveEditableDocument(editableArea, true); 711 }); 712 713 // see https://stackoverflow.com/questions/45551431/ckeditor-make-links-clickable-when-in-read-only-mode 714 editor.on( 'contentDom', function() { 715 var editable = editor.editable(); 716 editable.attachListener( editable, 'click', function( evt ) { 717 var link = new CKEDITOR.dom.elementPath( evt.data.getTarget(), this ).contains( 'a' ); 718 if ( link && evt.data.$.button != 2 ) { 719 window.open( link.getAttribute( 'href' ) ); 720 } 721 }, null, null, 15 ); 722 }); 723 724 editor.on( 'contentDom', function() { 725 var editable = editor.editable(); 726 editable.attachListener( editable, 'click', function( evt ) { 727 var button = new CKEDITOR.dom.elementPath( evt.data.getTarget(), this ).contains( 'button' ); 728 if ( button && button.$.className === 'toggle_prompt' ) { 729 togglePrompt('#' + button.$.id); 730 } 731 }, null, null, 15 ); 732 }); 733 } 734 735 $(document).on('visibilitychange', function(event) { 736 $('#editable_document_fulltext').each(function(index, element) { 737 saveEditableDocument(element, false); 738 }); 739 }); 740 741 if (jQuery('#sentence_text').length > 0) { 742 CKEDITOR.replace('sentence_text', 743 { 744 toolbarCanCollapse: true, 745 toolbarStartupExpanded: false, 746 toolbar: [['Bold', 'Italic'], ['RemoveFormat'], ['Link', 'Unlink'], ['About'], ['Source']], 747 removePlugins: 'elementspath', 748 height : '150px', 749 width : '285px' 750 }); 751 } 752 753 if (jQuery('#sentence_text_wording').length > 0) { 754 CKEDITOR.replace('sentence_text_wording', 755 { 756 toolbarCanCollapse: true, 757 toolbarStartupExpanded: false, 758 toolbar: [['Bold', 'Italic'], ['RemoveFormat'], ['Link', 'Unlink'], ['About'], ['Source']], 759 removePlugins: 'elementspath', 760 height : '150px', 761 width : '285px' 762 }); 763 } 764 765 if (jQuery('#blog_document_excerpt').length > 0) { 766 CKEDITOR.replace('blog_document_excerpt', 767 { 768 toolbar: [['Bold', 'Italic'], ['RemoveFormat'], ['NumberedList', 'BulletedList'], ['Link', 'Unlink'], ['About'], ['Source']], 769 removePlugins: 'elementspath', 770 height : '150px', 771 width : '100%' 772 }); 773 } 774 775 if (jQuery('#course_notes').length > 0) { 776 CKEDITOR.replace('course_notes', 777 { 778 toolbar: [['Bold', 'Italic'], ['RemoveFormat'], ['NumberedList', 'BulletedList'], ['Link', 'Unlink'], ['About'], ['Source']], 779 removePlugins: 'elementspath', 780 height : '150px', 781 width : '420px' 782 }); 783 } 784 785 if (jQuery('#blog_notes').length > 0) { 786 CKEDITOR.replace('blog_notes', 787 { 788 toolbar: [['Bold', 'Italic'], ['RemoveFormat'], ['NumberedList', 'BulletedList'], ['Link', 'Unlink'], ['About'], ['Source']], 789 removePlugins: 'elementspath', 790 height : '150px', 791 width : '100%' 792 }); 793 } 794 795 window.file_selector = jQuery('#document_uploaded_data'); 796 797 file_selector.change(function(){ 798 799 if(jQuery('#upload_type_field').val() != 'word' || validate_file_name(file_selector.val())) { 800 jQuery('.file_type_warning').hide(); 801 } else { 802 jQuery('.file_type_warning').show(); 803 804 } 805 806 file_name = file_selector.val().gsub(/C:\\.*\\/,'').split('.')[0]; 807 file_name = file_name.gsub(/_/, ' ') 808 jQuery('#document_title').val(file_name); 809 810 }); 811 812}); 813 814function validate_file_name(file_name) { 815 return file_name.match(/\.(doc|docx|rtf|odt|ods|xls|xlsx|txt)$/); 816} 817 818function wordButton(button_element) { 819 var doc_type = jQuery(button_element).data('type'); 820 if (doc_type == "image" || doc_type == "word") { 821 jQuery('.step2').show(); 822 jQuery('.upload_hints').show(); 823 } 824 jQuery("#new_document_options .button").addClass("blue"); 825 jQuery(button_element).removeClass("blue"); 826 jQuery(".step2").removeClass("inactive").effect("highlight", {color: "#bed6f3"}, 500); 827 jQuery("#rich_text").hide(); 828 jQuery(".cp_only").hide(); 829 jQuery(".file_type_warning").hide(); 830 jQuery("#upload,.access_area").fadeIn(400, function(){ 831 if ((doc_type == "image" || doc_type == "word") && jQuery(".flash p.error").length == 0) { 832 jQuery("#document_title").focus(); 833 } 834 }); 835 jQuery.cookie("upload_type", doc_type, {path: "/"}); 836 jQuery('#upload_type_field').val(doc_type); 837 if (doc_type == "pdf") { 838 jQuery('.upload_hints').hide(); 839 jQuery("#image_options").hide(); 840 jQuery("label[for*=\"uploaded_data\"]").text("PDF/Image to upload"); 841 } else if (doc_type == "image") { 842 jQuery("#image_options").show(); 843 jQuery("#pdf_options").hide(); 844 jQuery("label[for*=\"uploaded_data\"]").text("Image to upload"); 845 } else { 846 jQuery("#image_options").hide(); 847 jQuery("#pdf_options").hide(); 848 jQuery("label[for*=\"uploaded_data\"]").text("Word file to upload"); 849 } 850 if (!jQuery.browser['msie']) 851 jQuery('#document_uploaded_data').click(); 852 return false;
853} 854 855function pdfSelected() { 856 jQuery("#pdf_popup").data("overlay").close(); 857 jQuery("#document_title").focus(); 858 setTimeout(function() { 859 if (!jQuery.browser['msie']) 860 jQuery('#document_uploaded_data').click(); 861 }, 500); 862 return false; 863} 864 865function webButton(button_element) { 866 jQuery('.step2').show(); 867 jQuery('.upload_hints').show(); 868 jQuery("#new_document_options .button").addClass("blue"); 869 jQuery(button_element).removeClass("blue"); 870 jQuery(".step2").removeClass("inactive").effect("highlight", {color: "#bed6f3"}, 500); 871 jQuery("#upload").hide(); 872 jQuery(".cp_hint").show(); 873 jQuery(".cp_only").show(); 874 jQuery("#image_options").hide(); 875 jQuery("#pdf_options").hide(); 876 jQuery('#text_entry_label').text('Paste copied web content into window below'); 877 jQuery("#rich_text,.access_area").fadeIn(400, function() { 878 if (jQuery("p.error").length == 0) 879 jQuery("#document_title").focus(); 880 }); 881 jQuery.cookie("upload_type", "c_and_p", {path: "/"}); 882 jQuery('#upload_type_field').val('c_and_p'); 883 return false; 884} 885 886function writingPartnersUpload() { 887 jQuery('.step2').show(); 888 jQuery('.upload_hints').show(); 889 jQuery(".step2").removeClass("inactive").effect("highlight", {color: "#bed6f3"}, 500); 890 jQuery("#upload").hide(); 891 jQuery(".cp_hint").show(); 892 jQuery(".cp_only").show(); 893 jQuery("#image_options").hide(); 894 jQuery("#pdf_options").hide(); 895 jQuery('#text_entry_label').text('Write your text or paste copied content into the window below'); 896 jQuery("#rich_text,.access_area").fadeIn(400, function() { 897 if (jQuery("p.error").length == 0) 898 jQuery("#document_title").focus(); 899 }); 900 return false; 901} 902 903jQuery(function($) { 904 if ($('body.writing_partners').length > 0 && $('body.documents-new').length == 0 && $('#doc_upload_form').length > 0) { 905 writingPartnersUpload(); 906 } 907}); 908 909function writeNowButton(button_element) { 910 jQuery('.step2').show(); 911 jQuery('.upload_hints').show(); 912 jQuery("#new_document_options .button").addClass("blue"); 913 jQuery(button_element).removeClass("blue"); 914 jQuery(".step2").removeClass("inactive").effect("highlight", {color: "#bed6f3"}, 500); 915 jQuery(".cp_only").show(); 916 jQuery(".cp_hint").show(); 917 jQuery("#upload").hide(); 918 jQuery("#image_options").hide(); 919 jQuery("#pdf_options").hide(); 920 jQuery('#text_entry_label').text('Enter document text into window below'); 921 jQuery("#rich_text,.access_area").fadeIn(400, function() { 922 if (jQuery("p.error").length == 0) 923 jQuery("#document_title").focus(); 924 }); 925 jQuery.cookie("upload_type", "web", {path: "/"}); 926 jQuery('#upload_type_field').val('write_now'); 927 return false; 928} 929 930function edit_password(user_name, user_id) { 931 var new_pass = prompt('Please enter the new password for ' + user_name + ':'); 932 if (new_pass == null) { 933 // do nothing 934 } else if (new_pass.length < 4) { 935 alert('Sorry, the new password must be at least 4 characters long'); 936 } else { 937 jQuery.post('/users/' + user_id + '/change_password', {new_password: new_pass}, function(data) { 938 jQuery('#user' + user_id + ' .password').html(data); 939 }); 940 } 941 return false; 942} 943 944function edit_login(user_name, user_login, user_id) { 945 var new_login = prompt('Please enter the new username for ' + user_name + '.', user_login); 946 if (new_login == null) { 947 // do nothing 948 } else if (new_login.match(/@/)) { 949 alert('Sorry, the student\'s username cannot contain the @ symbol.') 950 } else if (new_login.length < 4) { 951 alert('Sorry, the new username must be at least 4 characters long'); 952 } else if (new_login.match(/user\d+/)) { 953 alert('Sorry, the new username cannot be in the form userXXX.'); 954 } else { 955 jQuery.ajax({ 956 url: '/users/' + user_id + '/change_login', 957 data: {new_login: new_login}, 958 success: function(data) { 959 console.log(data); 960 jQuery('#user' + user_id + ' .login').html(data); 961 }, 962 error: function(data) { 963 alert('Sorry, the username could not be changed. Most likely the requested username is already in use.') 964 }, 965 type: 'POST' 966 }); 967 } 968 return false; 969} 970 971// Add date when editing domain code notes field 972 973jQuery(function(){ 974 jQuery('form.domain_code #domain_code_notes, form #user_notes').focus(function(e) { 975 var today = new Date(); 976 var dd = today.getDate(); 977 var mm = today.getMonth()+1; //January is 0! 978 var yyyy = today.getFullYear(); 979 980 if(dd<10) { 981 dd='0'+dd 982 } 983 984 if(mm<10) { 985 mm='0'+mm 986 } 987
988 today = mm+'/'+dd+'/'+yyyy; 989 var notes_field = jQuery(e.target); 990 if (!notes_field.val().match(today)) { 991 var spacer = ""; 992 if (notes_field.val() != "") { 993 spacer = "\n"; 994 } 995 notes_field.val(notes_field.val() + spacer + today + ' - '); 996 } 997 }); 998}); 999 1000jQuery(function($) { 1001 $('.advanced_features_public_toggle, #document_public_true').on('change', function(event) { 1002 if ($(event.target).attr('checked') === 'checked') { 1003 $('.anti_spam').slideDown(); 1004 } else { 1005 $('.anti_spam').slideUp(); 1006 } 1007 }); 1008 1009 $('#document_public_false').on('change', function(event) { 1010 if ($(event.target).attr('checked') === 'checked') { 1011 $('.anti_spam').slideUp(); 1012 } else { 1013 $('.anti_spam').slideDown(); 1014 } 1015 }); 1016}); 1017 1018jQuery(function($) { 1019 $('.bot_advanced_settings input[type=range]').on('input', function(event) { 1020 var range_input = $(event.target); 1021 range_input.prevAll('.value_display').text(range_input.val()); 1022 }); 1023}); 1024 1025function toggle_bot_advanced_settings() { 1026 jQuery('.bot_advanced_settings').slideToggle(); 1027} 1028 1029jQuery(function($) { 1030 $('#bot_version').on('input', function(event) { 1031 var version = $(event.target).val(); 1032 $('.bot_version').hide(); 1033 $(`.bot_version[data-version=${version}]`).show(); 1034 }); 1035}); 1036 1037jQuery(function($) { 1038 $('#document_version').on('input', function(event) { 1039 var version = $(event.target).val(); 1040 $('.document_version').hide(); 1041 $(`.document_version[data-version=${version}]`).show(); 1042 }); 1043});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.