1
+ var LSNGRD = LSNGRD || { } ;
2
+
3
+ LSNGRD . childClass = ".uuidBox" ;
4
+ LSNGRD . type = "comment" ;
5
+
1
6
// CommentsGradingPane is called by ajax from a URL like
2
7
// /lessonbuilder-tool/faces/CommentsGradingPane
3
8
// however URLs we generate need to be the usual
@@ -22,11 +27,7 @@ function fixurls() {
22
27
}
23
28
24
29
$ ( function ( ) {
25
- makeButtons ( ) ;
26
-
27
- $ . ajaxSetup ( {
28
- cache : false
29
- } ) ;
30
+ LSNGRD . initButtonsAndPointBoxes ( ) ;
30
31
31
32
$ ( ".gradingTable" ) . find ( ".details-row" ) . hide ( ) ;
32
33
@@ -50,7 +51,7 @@ $(function() {
50
51
var current = $ ( value ) ;
51
52
var next = $ ( value ) . next ( ) . next ( ) ;
52
53
53
- makeButtons ( ) ;
54
+ LSNGRD . makeButtons ( ) ;
54
55
55
56
$ ( current ) . show ( ) ;
56
57
@@ -76,78 +77,14 @@ $(function() {
76
77
77
78
return false ;
78
79
} ) ;
79
-
80
- $ ( ".pointsBox" ) . each ( function ( index , value ) {
81
- $ ( value ) . parent ( ) . children ( "img" ) . attr ( "id" , "statusImg" + index ) ;
82
- $ ( value ) . val ( $ ( value ) . parent ( ) . children ( ".pointsSpan" ) . text ( ) ) ;
83
- } ) ;
84
-
85
- $ ( ".pointsBox" ) . on ( 'change' , function ( ) {
86
- var img = $ ( this ) . parent ( ) . children ( "img" ) ;
87
- img . attr ( "src" , getStrippedImgSrc ( img . attr ( "id" ) ) + "no-status.png" ) ;
88
- $ ( this ) . addClass ( "unsubmitted" ) ;
89
- } ) ;
90
-
91
- // cr on individual box, update that box
92
- $ ( ".pointsBox" ) . keyup ( function ( event ) {
93
- if ( event . keyCode === 13 )
94
- updateGrade ( $ ( this ) ) ;
95
- } ) ;
96
-
97
- // update points button, do all the need it
98
- $ ( "#clickToSubmit" ) . click ( function ( event ) {
99
- updateGrades ( ) ;
100
- } ) ;
101
-
102
- $ ( "#zeroMissing" ) . click ( function ( event ) {
103
- event . preventDefault ( ) ;
104
- $ ( "#zero" ) . click ( ) ;
105
- } ) ;
106
-
107
-
108
80
} ) ;
109
81
110
- function updateGrades ( ) {
111
- var unsubs = $ ( ".unsubmitted" ) ;
112
- if ( unsubs . length > 0 ) {
113
- // call back when finished submitted this one
114
- if ( unsubs . length > 1 )
115
- setGradingDoneHook ( updateGrades ) ;
116
- else
117
- setGradingDoneHook ( null ) ;
118
- updateGrade ( unsubs . first ( ) ) ;
119
- }
120
- }
121
-
122
-
123
- function updateGrade ( item ) {
124
- var img = item . parent ( ) . children ( "img" ) ;
125
- item . removeClass ( "unsubmitted" ) ;
126
- img . attr ( "src" , getStrippedImgSrc ( img . attr ( "id" ) ) + "loading.gif" ) ;
127
-
128
- $ ( ".idField" ) . val ( item . parent ( ) . children ( ".uuidBox" ) . text ( ) ) . change ( ) ;
129
- $ ( ".jsIdField" ) . val ( img . attr ( "id" ) ) . change ( ) ;
130
- $ ( ".typeField" ) . val ( "comment" ) ;
131
-
132
- // This one triggers the update
133
- $ ( ".pointsField" ) . val ( item . val ( ) ) . change ( ) ;
134
- }
135
-
136
82
function prefetchComments ( value ) {
137
83
// Prefetch the next one as well, so that it's ready when they need it.
138
84
if ( $ ( value ) . length > 0 && $ ( value ) . find ( ".replaceWithComments" ) . children ( ) . length === 0 ) {
139
85
var href = $ ( value ) . find ( ".commentsLink" ) . attr ( "href" ) ;
140
86
var ci = href . indexOf ( "Comment" ) ;
141
87
href = "/lessonbuilder-tool/faces/" + href . substring ( ci ) ;
142
- $ ( value ) . find ( ".replaceWithComments" ) . load ( href , makeButtons ) ;
88
+ $ ( value ) . find ( ".replaceWithComments" ) . load ( href , LSNGRD . makeButtons ) ;
143
89
}
144
90
}
145
-
146
- function makeButtons ( ) {
147
- if ( ! ( navigator . userAgent . indexOf ( "Firefox/2." ) > 0 ) ) {
148
- $ ( '.usebutton' ) . button ( { text :true } ) ;
149
- } else {
150
- // fake it; can't seem to get rid of underline though
151
- $ ( '.usebutton' ) . css ( 'border' , '1px solid black' ) . css ( 'padding' , '1px 4px' ) . css ( 'color' , 'black' ) ;
152
- }
153
- }
0 commit comments