2011-02-01 09:57:29 +08:00
/ * *
* Copyright ( C ) 2011 Instructure , Inc .
*
* This file is part of Canvas .
*
* Canvas is free software : you can redistribute it and / or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation , version 3 of the License .
*
* Canvas is distributed in the hope that it will be useful , but WITHOUT ANY
* WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE . See the GNU Affero General Public License for more
* details .
*
* You should have received a copy of the GNU Affero General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
* /
2012-03-06 01:37:09 +08:00
define ( [
2011-11-11 00:31:45 +08:00
'i18n!course_settings' ,
'jquery' /* $ */ ,
2012-07-17 00:46:41 +08:00
'underscore' ,
2011-11-11 00:31:45 +08:00
'jquery.ajaxJSON' /* ajaxJSON */ ,
'jquery.instructure_date_and_time' /* parseFromISO, date_field */ ,
'jquery.instructure_forms' /* formSubmit, fillFormData, getFormData, formErrors */ ,
2012-04-07 01:02:00 +08:00
'jqueryui/dialog' ,
2012-09-25 02:51:47 +08:00
'compiled/jquery/fixDialogButtons' /* fix dialog formatting */ ,
2011-11-11 00:31:45 +08:00
'jquery.instructure_misc_helpers' /* scrollSidebar */ ,
'jquery.instructure_misc_plugins' /* confirmDelete, fragmentChange, showIf */ ,
'jquery.keycodes' /* keycodes */ ,
'jquery.loadingImg' /* loadingImage */ ,
2012-07-18 14:24:09 +08:00
'compiled/jquery.rails_flash_notifications' ,
2011-11-11 00:31:45 +08:00
'jquery.templateData' /* fillTemplateData, getTemplateData */ ,
'link_enrollment' /* link_enrollment */ ,
'vendor/jquery.ba-tinypubsub' /* /\.publish/ */ ,
'vendor/jquery.scrollTo' /* /\.scrollTo/ */ ,
'jqueryui/autocomplete' /* /\.autocomplete/ */ ,
'jqueryui/sortable' /* /\.sortable/ */ ,
'jqueryui/tabs' /* /\.tabs/ */
2012-07-17 00:46:41 +08:00
] , function ( I18n , $ , _ ) {
2011-10-04 02:18:07 +08:00
var GradePublishing = {
status : null ,
checkup : function ( ) {
$ . ajaxJSON ( $ ( "#publish_to_sis_form" ) . attr ( 'action' ) , 'GET' , { } , function ( data ) {
2011-11-30 05:59:40 +08:00
if ( ! data . hasOwnProperty ( "sis_publish_overall_status" ) ) return ;
GradePublishing . status = data . sis _publish _overall _status ;
GradePublishing . update ( data . hasOwnProperty ( "sis_publish_statuses" ) ? data . sis _publish _statuses : { } ) ;
2011-10-04 02:18:07 +08:00
} ) ;
} ,
update : function ( messages , requestInProgress ) {
var $publish _grades _link = $ ( "#publish_grades_link" ) ,
$publish _grades _error = $ ( "#publish_grades_error" ) ;
if ( GradePublishing . status == 'published' ) {
$publish _grades _error . hide ( ) ;
$publish _grades _link . html ( I18n . t ( 'links.republish' , "Republish grades to SIS" ) ) ;
$publish _grades _link . removeClass ( "disabled" ) ;
} else if ( GradePublishing . status == 'publishing' || GradePublishing . status == 'pending' ) {
$publish _grades _error . hide ( ) ;
$publish _grades _link . html ( I18n . t ( 'links.publishing' , "Publishing grades to SIS..." ) ) ;
if ( ! requestInProgress ) {
setTimeout ( GradePublishing . checkup , 5000 ) ;
}
$publish _grades _link . addClass ( "disabled" ) ;
} else if ( GradePublishing . status == 'unpublished' ) {
$publish _grades _error . hide ( ) ;
$publish _grades _link . html ( I18n . t ( 'links.publish' , "Publish grades to SIS" ) ) ;
$publish _grades _link . removeClass ( "disabled" ) ;
} else {
$publish _grades _error . show ( ) ;
$publish _grades _link . html ( I18n . t ( 'links.republish' , "Republish grades to SIS" ) ) ;
$publish _grades _link . removeClass ( "disabled" ) ;
}
$messages = $ ( "#publish_grades_messages" ) ;
$messages . empty ( ) ;
2011-11-30 05:59:40 +08:00
$ . each ( messages , function ( message , users ) {
2011-10-04 02:18:07 +08:00
var $message = $ ( "<span/>" ) ;
$message . text ( message ) ;
var $item = $ ( "<li/>" ) ;
$item . append ( $message ) ;
2011-11-30 05:59:40 +08:00
$item . append ( " - <b>" + users . length + "</b>" ) ;
2011-10-04 02:18:07 +08:00
$messages . append ( $item ) ;
} ) ;
} ,
publish : function ( ) {
if ( GradePublishing . status == 'publishing' || GradePublishing . status == 'pending' || GradePublishing . status == null ) {
2011-06-21 02:27:54 +08:00
return ;
}
2011-10-04 02:18:07 +08:00
if ( GradePublishing . status == 'published' ) {
if ( ! confirm ( I18n . t ( 'confirm.re_publish_grades' , "Are you sure you want to republish these grades to the student information system?" ) ) )
return ;
} else {
if ( ! confirm ( I18n . t ( 'confirm.publish_grades' , "Are you sure you want to publish these grades to the student information system? You should only do this if all your grades have been finalized." ) ) )
return ;
2011-06-21 02:27:54 +08:00
}
2011-10-04 02:18:07 +08:00
var $publish _to _sis _form = $ ( "#publish_to_sis_form" ) ;
GradePublishing . status = "publishing" ;
GradePublishing . update ( { } , true ) ;
var successful _statuses = { "published" : 1 , "publishing" : 1 , "pending" : 1 } ;
var error = function ( data , xhr , status , error ) {
GradePublishing . status = "unknown" ;
$ . flashError ( I18n . t ( 'errors.publish_grades' , "Something went wrong when trying to publish grades to the student information system. Please try again later." ) ) ;
GradePublishing . update ( { } ) ;
} ;
$ . ajaxJSON ( $publish _to _sis _form . attr ( 'action' ) , 'POST' , $publish _to _sis _form . getFormData ( ) , function ( data ) {
2011-11-30 05:59:40 +08:00
if ( ! data . hasOwnProperty ( "sis_publish_overall_status" ) || ! successful _statuses . hasOwnProperty ( data [ "sis_publish_overall_status" ] ) ) {
2011-10-04 02:18:07 +08:00
error ( null , null , I18n . t ( 'errors.invalid_sis_status' , "Invalid SIS publish status" ) , null ) ;
return ;
}
2011-11-30 05:59:40 +08:00
GradePublishing . status = data . sis _publish _overall _status ;
GradePublishing . update ( data . hasOwnProperty ( "sis_publish_statuses" ) ? data . sis _publish _statuses : { } ) ;
2011-10-04 02:18:07 +08:00
} , error ) ;
2011-04-15 07:49:30 +08:00
}
}
2011-06-21 02:27:54 +08:00
$ ( document ) . ready ( function ( ) {
var $add _section _form = $ ( "#add_section_form" ) ,
$edit _section _form = $ ( "#edit_section_form" ) ,
$course _form = $ ( "#course_form" ) ,
2012-07-17 00:46:41 +08:00
$enrollment _dialog = $ ( "#enrollment_dialog" ) ,
$tabBar = $ ( "#course_details_tabs" ) ,
// as of jqueryui 1.9, the cookie trumps the fragment :(. so we hack
// around that here
initialTab = _ . indexOf ( _ . pluck ( $tabBar . find ( '> ul a' ) , 'hash' ) , location . hash ) ;
2012-02-04 01:31:36 +08:00
2012-07-17 00:46:41 +08:00
$tabBar . tabs ( { cookie : { } , active : initialTab >= 0 ? initialTab : null } ) . show ( ) ;
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
$add _section _form . formSubmit ( {
required : [ 'course_section[name]' ] ,
beforeSubmit : function ( data ) {
$add _section _form . find ( "button" ) . attr ( 'disabled' , true ) . text ( I18n . t ( 'buttons.adding_section' , "Adding Section..." ) ) ;
} ,
2011-02-01 09:57:29 +08:00
success : function ( data ) {
2011-06-21 02:27:54 +08:00
var section = data . course _section ,
$section = $ ( ".section_blank:first" ) . clone ( true ) . attr ( 'class' , 'section' ) ,
$option = $ ( "<option/>" ) ;
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
$add _section _form . find ( "button" ) . attr ( 'disabled' , false ) . text ( I18n . t ( 'buttons.add_section' , "Add Section" ) ) ;
$section . fillTemplateData ( {
data : section ,
hrefValues : [ 'id' ]
2011-02-01 09:57:29 +08:00
} ) ;
2011-06-21 02:27:54 +08:00
$ ( "#course_section_id_holder" ) . show ( ) ;
$option . val ( section . id ) . text ( section . name ) . addClass ( 'option_for_section_' + section . id ) ;
$ ( "#sections .section_blank" ) . before ( $section ) ;
$section . slideDown ( ) ;
$ ( "#course_section_name" ) . val ( ) ;
} ,
error : function ( data ) {
$add _section _form
. formErrors ( data )
. find ( "button" ) . attr ( 'disabled' , false ) . text ( I18n . t ( 'errors.section' , "Add Section Failed, Please Try Again" ) ) ;
2011-02-01 09:57:29 +08:00
}
} ) ;
2011-06-21 02:27:54 +08:00
$ ( ".cant_delete_section_link" ) . click ( function ( event ) {
alert ( $ ( this ) . attr ( 'title' ) ) ;
return false ;
} ) ;
$edit _section _form . formSubmit ( {
beforeSubmit : function ( data ) {
$edit _section _form . hide ( ) ;
var $section = $edit _section _form . parents ( ".section" ) ;
$section . find ( ".name" ) . text ( data [ 'course_section[name]' ] ) . show ( ) ;
$section . loadingImage ( { image _size : "small" } ) ;
return $section ;
} ,
success : function ( data , $section ) {
var section = data . course _section ;
$section . loadingImage ( 'remove' ) ;
$ ( ".option_for_section_" + section . id ) . text ( section . name ) ;
} ,
error : function ( data , $section ) {
$section . loadingImage ( 'remove' ) . find ( ".edit_section_link" ) . click ( ) ;
$edit _section _form . formErrors ( data ) ;
}
} )
. find ( ":text" )
. bind ( 'blur' , function ( ) {
$edit _section _form . submit ( ) ;
} )
. keycodes ( 'return esc' , function ( event ) {
if ( event . keyString == 'return' ) {
$edit _section _form . submit ( ) ;
} else {
$ ( this ) . parents ( ".section" ) . find ( ".name" ) . show ( ) ;
$ ( "body" ) . append ( $edit _section _form . hide ( ) ) ;
}
} ) ;
$ ( ".edit_section_link" ) . click ( function ( ) {
var $this = $ ( this ) ,
$section = $this . parents ( ".section" ) ,
data = $section . getTemplateData ( { textValues : [ 'name' ] } ) ;
$edit _section _form . fillFormData ( data , { object _name : "course_section" } ) ;
$section . find ( ".name" ) . hide ( ) . after ( $edit _section _form . show ( ) ) ;
$edit _section _form . attr ( 'action' , $this . attr ( 'href' ) ) ;
$edit _section _form . find ( ":text:first" ) . focus ( ) . select ( ) ;
return false ;
} ) ;
$ ( ".delete_section_link" ) . click ( function ( ) {
$ ( this ) . parents ( ".section" ) . confirmDelete ( {
url : $ ( this ) . attr ( 'href' ) ,
message : I18n . t ( 'confirm.delete_section' , "Are you sure you want to delete this section?" ) ,
success : function ( data ) {
$ ( this ) . slideUp ( function ( ) {
$ ( this ) . remove ( ) ;
} ) ;
2011-02-01 09:57:29 +08:00
}
2011-06-21 02:27:54 +08:00
} ) ;
return false ;
} ) ;
$ ( "#nav_form" ) . submit ( function ( ) {
tab _id _regex = /(\d+)$/ ;
function tab _id _from _el ( el ) {
var tab _id _str = $ ( el ) . attr ( "id" ) ;
if ( tab _id _str ) {
basic lti navigation links
By properly configuring external tools (see
/spec/models/course_spec/rb:898 for examples) they can
be added as left-side navigation links to a course,
an account, or to the user profile section of Canvas.
testing notes:
- you have to manually set options on the external tool:
- for user navigation the tool needs to be created on the root account
with the following settings:
{:user_navigation => {:url => <url>, :text => <tab label>} }
(there are also some optional language options you can set using
the :labels attribute)
- for account navigation it's the same
- for course navigation it's the same, except with :course_navigation
there's also some additional options:
:visibility => <value> // public, members, admins
:default => <value> // disabled, enabled
test plan:
- configure a user navigation tool at the root account level,
make sure it shows up in the user's profile section
- configure a course navigation tool at the account level,
make sure it shows up in the course's navigation
- configure a course navigation tool at the course level,
make sure it shows up in the course's navigation
- make sure :default => 'disabled' course navigation tools don't
appear by default in the navigation, but can be enabled on
the course settings page
- make sure :visibility => 'members' only shows up for course members
- make sure :visibility => 'admins' only shows up for course admins
- configure an account navigation tool at the account level,
make sure it shows up in the account's navigation, and
any sub-account's navigation
Change-Id: I977da3c6b89a9e32b4cff4c2b6b221f8162782ff
Reviewed-on: https://gerrit.instructure.com/5427
Reviewed-by: Brian Whitmer <brian@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2011-08-18 13:49:01 +08:00
var tab _id = tab _id _str . replace ( /^nav_edit_tab_id_/ , '' ) ;
if ( tab _id . length > 0 ) {
if ( ! tab _id . match ( /context/ ) ) {
tab _id = parseInt ( tab _id , 10 ) ;
}
2011-06-21 02:27:54 +08:00
return tab _id ;
}
}
return null ;
2011-02-01 09:57:29 +08:00
}
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
var tabs = [ ] ;
$ ( "#nav_enabled_list li" ) . each ( function ( ) {
var tab _id = tab _id _from _el ( this ) ;
if ( tab _id !== null ) { tabs . push ( { id : tab _id } ) ; }
} ) ;
$ ( "#nav_disabled_list li" ) . each ( function ( ) {
var tab _id = tab _id _from _el ( this ) ;
if ( tab _id !== null ) { tabs . push ( { id : tab _id , hidden : true } ) ; }
} ) ;
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
$ ( "#tabs_json" ) . val ( JSON . stringify ( tabs ) ) ;
return true ;
2011-02-01 09:57:29 +08:00
} ) ;
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
$ ( ".edit_nav_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
2012-08-09 02:22:01 +08:00
$ ( "#nav_form" ) . dialog ( {
2011-06-21 02:27:54 +08:00
modal : true ,
resizable : false ,
width : 400
2012-08-09 02:22:01 +08:00
} ) ;
2011-02-01 09:57:29 +08:00
} ) ;
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
$ ( "#nav_enabled_list, #nav_disabled_list" ) . sortable ( {
items : 'li.enabled' ,
connectWith : '.connectedSortable' ,
axis : 'y'
} ) . disableSelection ( ) ;
2011-02-01 09:57:29 +08:00
2011-06-21 02:27:54 +08:00
$ ( document ) . fragmentChange ( function ( event , hash ) {
function handleFragmentType ( val ) {
$ ( "#tab-users-link" ) . click ( ) ;
$ ( ".add_users_link:visible" ) . click ( ) ;
$ ( "#enroll_users_form select[name='enrollment_type']" ) . val ( val ) ;
2011-02-01 09:57:29 +08:00
}
2011-06-21 02:27:54 +08:00
if ( hash == "#add_students" ) {
handleFragmentType ( "StudentEnrollment" ) ;
} else if ( hash == "#add_tas" ) {
handleFragmentType ( "TaEnrollment" ) ;
} else if ( hash == "#add_teacher" ) {
handleFragmentType ( "TeacherEnrollment" ) ;
}
} ) ;
$ ( ".edit_course_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
$ ( "#course_form" ) . addClass ( 'editing' ) . find ( ":text:first" ) . focus ( ) . select ( ) ;
2011-10-18 05:06:40 +08:00
$ ( "#course_account_id_lookup" ) . autocomplete ( {
source : $ ( "#course_account_id_url" ) . attr ( 'href' ) ,
select : function ( event , ui ) {
$ ( "#course_account_id" ) . val ( ui . item . id ) ;
}
} ) ;
2011-06-21 02:27:54 +08:00
} ) ;
$ ( ".move_course_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
2012-08-09 02:22:01 +08:00
$ ( "#move_course_dialog" ) . dialog ( {
2011-06-21 02:27:54 +08:00
title : I18n . t ( 'titles.move_course' , "Move Course" ) ,
width : 500
2012-09-25 02:51:47 +08:00
} ) . fixDialogButtons ( ) ;
2011-06-21 02:27:54 +08:00
} ) ;
$ ( "#move_course_dialog" ) . delegate ( '.cancel_button' , 'click' , function ( ) {
$ ( "#move_course_dialog" ) . dialog ( 'close' ) ;
} ) ;
$course _form . find ( ".grading_standard_checkbox" ) . change ( function ( ) {
$course _form . find ( ".grading_standard_link" ) . showIf ( $ ( this ) . attr ( 'checked' ) ) ;
} ) . change ( ) ;
$course _form . formSubmit ( {
processData : function ( data ) {
if ( data [ 'course[start_at]' ] ) {
data [ 'course[start_at]' ] += " 12:00am" ;
}
if ( data [ 'course[conclude_at]' ] ) {
data [ 'course[conclude_at]' ] += " 11:55pm" ;
}
return data ;
} ,
beforeSubmit : function ( data ) {
$ ( this ) . loadingImage ( ) . removeClass ( 'editing' ) ;
$ ( this ) . find ( ".readable_license,.account_name,.term_name,.grading_scheme_set" ) . text ( "..." ) ;
2011-07-12 05:36:55 +08:00
$ ( this ) . find ( ".storage_quota_mb" ) . text ( data [ 'course[storage_quota_mb]' ] ) ;
2011-06-21 02:27:54 +08:00
$ ( ".course_form_more_options" ) . hide ( ) ;
} ,
success : function ( data ) {
var course = data . course ;
course . start _at = $ . parseFromISO ( course . start _at ) . datetime _formatted ;
course . conclude _at = $ . parseFromISO ( course . conclude _at ) . datetime _formatted ;
course . is _public = course . is _public ? I18n . t ( 'public_course' , 'Public' ) : I18n . t ( 'private_course' , 'Private' ) ;
course . indexed = course . indexed ? I18n . t ( 'indexed_course' , "Included in public course index" ) : "" ;
course . grading _scheme _set = course . grading _standard _title || ( course . grading _standard _id ? I18n . t ( 'grading_standard_set' , "Currently Set" ) : I18n . t ( 'grading_standard_unset' , "Not Set" ) ) ;
2011-09-27 05:03:05 +08:00
course . restrict _dates = course . restrict _enrollments _to _course _dates ? I18n . t ( 'course_dates_enforced' , "Users can only participate in the course between these dates" ) : I18n . t ( 'course_dates_unenforced' , "These dates will not affect course availability" ) ;
2011-07-13 04:31:40 +08:00
course . locale = $ ( "#course_locale option[value='" + ( course . locale || '' ) + "']" ) . text ( ) ;
if ( course . locale != $course _form . find ( '.locale' ) . text ( ) ) {
location . reload ( ) ;
return ;
}
$ ( this ) . loadingImage ( 'remove' ) ;
2011-06-21 02:27:54 +08:00
$ ( "#course_form .public_options" ) . showIf ( course . is _public ) ;
$ ( "#course_form .self_enrollment_message" ) . css ( 'display' , course . self _enrollment ? '' : 'none' ) ;
$ ( "#course_form" ) . fillTemplateData ( { data : course } ) ;
2012-05-18 00:51:31 +08:00
if ( course . self _enrollment _code ) {
$ ( "#course_form .self_enrollment_message b" ) . each ( function ( ) {
$ ( this ) . text ( $ . replaceTags ( $ ( this ) . text ( ) , 'self_enrollment_code' , course . self _enrollment _code ) ) ;
} ) ;
}
2011-06-21 02:27:54 +08:00
} ,
error : function ( data ) {
$ ( this ) . loadingImage ( 'remove' ) ;
$ ( ".edit_course_link" ) . click ( ) ;
$ ( this ) . formErrors ( data ) ;
2011-02-01 09:57:29 +08:00
}
2011-06-21 02:27:54 +08:00
} )
. find ( ".cancel_button" )
. click ( function ( ) {
$course _form . removeClass ( 'editing' ) ;
$ ( ".course_form_more_options" ) . hide ( ) ;
} ) . end ( )
. find ( ":text:not(.date_entry)" ) . keycodes ( 'esc' , function ( ) {
$course _form . find ( ".cancel_button:first" ) . click ( ) ;
} ) ;
2012-02-04 01:31:36 +08:00
$ ( ".associated_user_link" ) . click ( function ( event ) {
2011-06-21 02:27:54 +08:00
event . preventDefault ( ) ;
var $user = $ ( this ) . parents ( ".user" ) ;
2012-02-04 01:31:36 +08:00
var $enrollment = $ ( this ) . parents ( ".enrollment_link" ) ;
var user _data = $user . getTemplateData ( { textValues : [ 'name' ] } ) ;
var enrollment _data = $enrollment . getTemplateData ( { textValues : [ 'enrollment_id' , 'associated_user_id' ] } ) ;
link _enrollment . choose ( user _data . name , enrollment _data . enrollment _id , enrollment _data . associated _user _id , function ( enrollment ) {
2011-06-21 02:27:54 +08:00
if ( enrollment ) {
2012-02-04 01:31:36 +08:00
var $user = $ ( ".observer_enrollments .user_" + enrollment . user _id )
var $enrollment _link = $user . find ( ".enrollment_link.enrollment_" + enrollment . id )
$enrollment _link . find ( ".associated_user.associated" ) . showIf ( enrollment . associated _user _id )
$enrollment _link . fillTemplateData ( { data : enrollment } ) ;
$enrollment _link . find ( ".associated_user.unassociated" ) . showIf ( ! enrollment . associated _user _id ) ;
2011-06-21 02:27:54 +08:00
}
} ) ;
} ) ;
2012-10-25 22:26:06 +08:00
$ ( ".course_info" ) . not ( '.uneditable' ) . attr ( 'title' , I18n . t ( 'titles.click_to_edit' , 'Click to Edit' ) ) . click ( function ( event ) {
2011-06-21 02:27:54 +08:00
if ( event . target . nodeName == "INPUT" ) {
return ;
}
$ ( ".edit_course_link:first" ) . click ( ) ;
var $obj = $ ( this ) . parents ( "td" ) . find ( ".course_form" ) ;
if ( $obj . length ) {
$obj . focus ( ) . select ( ) ;
}
} ) ;
$ ( ".course_form_more_options_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
2012-10-13 02:06:35 +08:00
var $moreOptions = $ ( ".course_form_more_options" ) ;
var optionText = $moreOptions . is ( ':visible' ) ? I18n . t ( 'links.more_options' , 'more options' ) : I18n . t ( 'links.less_options' , 'less options' ) ;
$ ( this ) . text ( optionText ) ;
$moreOptions . slideToggle ( ) ;
2011-06-21 02:27:54 +08:00
} ) ;
2012-04-16 23:27:28 +08:00
$enrollment _dialog . find ( ".cancel_button" ) . click ( function ( ) {
2011-06-21 02:27:54 +08:00
$enrollment _dialog . dialog ( 'close' ) ;
2011-02-11 06:38:47 +08:00
} ) ;
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
$enrollment _dialog . find ( ".re_send_invitation_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
var $link = $ ( this ) ;
$link . text ( I18n . t ( 'links.re_sending_invitation' , "Re-Sending Invitation..." ) ) ;
var url = $link . attr ( 'href' ) ;
$ . ajaxJSON ( url , 'POST' , { } , function ( data ) {
$enrollment _dialog . fillTemplateData ( { data : { invitation _sent _at : I18n . t ( 'invitation_sent_now' , "Just Now" ) } } ) ;
$link . text ( I18n . t ( 'invitation_sent' , "Invitation Sent!" ) ) ;
var $user = $enrollment _dialog . data ( 'user' ) ;
if ( $user ) {
$user . fillTemplateData ( { data : { invitation _sent _at : I18n . t ( 'invitation_sent_now' , "Just Now" ) } } ) ;
}
} , function ( data ) {
$link . text ( I18n . t ( 'errors.invitation' , "Invitation Failed. Please try again." ) ) ;
} ) ;
2011-05-24 03:57:32 +08:00
} ) ;
2011-06-21 02:27:54 +08:00
$ ( ".date_entry" ) . date _field ( ) ;
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
$ ( ) . data ( 'current_default_wiki_editing_roles' , $ ( "#course_default_wiki_editing_roles" ) . val ( ) ) ;
$ ( "#course_default_wiki_editing_roles" ) . change ( function ( ) {
var $this = $ ( this ) ;
$ ( ".changed_default_wiki_editing_roles" ) . showIf ( $this . val ( ) != $ ( ) . data ( 'current_default_wiki_editing_roles' ) ) ;
$ ( ".default_wiki_editing_roles_change" ) . text ( $this . find ( ":selected" ) . text ( ) ) ;
2011-02-01 09:57:29 +08:00
} ) ;
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
$ ( ".re_send_invitations_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
var $button = $ ( this ) ,
oldText = I18n . t ( 'links.re_send_all' , "Re-Send All Unaccepted Invitations" ) ;
2012-02-04 01:31:36 +08:00
2011-06-21 02:27:54 +08:00
$button . text ( I18n . t ( 'buttons.re_sending_all' , "Re-Sending Unaccepted Invitations..." ) ) . attr ( 'disabled' , true ) ;
$ . ajaxJSON ( $button . attr ( 'href' ) , 'POST' , { } , function ( data ) {
$button . text ( I18n . t ( 'buttons.re_sent_all' , "Re-Sent All Unaccepted Invitations!" ) ) . attr ( 'disabled' , false ) ;
$ ( ".user_list .user.pending" ) . each ( function ( ) {
var $user = $ ( this ) ;
$user . fillTemplateData ( { data : { invitation _sent _at : I18n . t ( 'invitation_sent_now' , "Just Now" ) } } ) ;
} ) ;
setTimeout ( function ( ) {
$button . text ( oldText ) ;
} , 2500 ) ;
} , function ( ) {
$button . text ( I18n . t ( 'errors.re_send_all' , "Send Failed, Please Try Again" ) ) . attr ( 'disabled' , false ) ;
2011-02-01 09:57:29 +08:00
} ) ;
} ) ;
2011-06-21 02:27:54 +08:00
$ ( "#enrollment_type" ) . change ( function ( ) {
$ ( ".teacherless_invite_message" ) . showIf ( $ ( this ) . find ( ":selected" ) . hasClass ( 'teacherless_invite' ) ) ;
} ) ;
$ ( ".is_public_checkbox" ) . change ( function ( ) {
$ ( ".public_options" ) . showIf ( $ ( this ) . attr ( 'checked' ) ) ;
2012-02-04 01:31:36 +08:00
} ) . change ( ) ;
2011-06-21 02:27:54 +08:00
$ ( ".self_enrollment_checkbox" ) . change ( function ( ) {
$ ( ".open_enrollment_holder" ) . showIf ( $ ( this ) . attr ( 'checked' ) ) ;
} ) . change ( ) ;
2011-04-15 07:49:30 +08:00
2011-06-21 02:27:54 +08:00
$ ( "#publish_grades_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
2011-10-04 02:18:07 +08:00
GradePublishing . publish ( ) ;
2011-06-21 02:27:54 +08:00
} ) ;
if ( typeof ( sisPublishEnabled ) != 'undefined' && sisPublishEnabled ) {
2011-10-04 02:18:07 +08:00
GradePublishing . checkup ( ) ;
2011-06-21 02:27:54 +08:00
}
2011-10-04 02:18:07 +08:00
2011-08-23 06:25:28 +08:00
$ ( ".reset_course_content_button" ) . click ( function ( event ) {
event . preventDefault ( ) ;
2012-08-09 02:22:01 +08:00
$ ( "#reset_course_content_dialog" ) . dialog ( {
2011-08-23 06:25:28 +08:00
title : I18n . t ( 'titles.reset_course_content_dialog_help' , "Reset Course Content" ) ,
width : 500
2012-08-09 02:22:01 +08:00
} ) ;
2012-10-25 22:26:06 +08:00
$ ( ".ui-dialog" ) . focus ( ) ;
2012-09-25 02:51:47 +08:00
} ) . fixDialogButtons ( ) ;
2011-08-23 06:25:28 +08:00
$ ( "#reset_course_content_dialog .cancel_button" ) . click ( function ( ) {
$ ( "#reset_course_content_dialog" ) . dialog ( 'close' ) ;
} ) ;
2011-04-15 07:49:30 +08:00
2011-06-21 02:27:54 +08:00
$ . scrollSidebar ( ) ;
} ) ;
2011-02-01 09:57:29 +08:00
} ) ;