Skip to content

Instantly share code, notes, and snippets.

@ryankshaw
Created January 25, 2012 06:24
Show Gist options
  • Select an option

  • Save ryankshaw/1675068 to your computer and use it in GitHub Desktop.

Select an option

Save ryankshaw/1675068 to your computer and use it in GitHub Desktop.
diff --git a/app/coffeescripts/gradebook2/Gradebook.coffee b/app/coffeescripts/gradebook2/Gradebook.coffee
index 1243233..156ce3a 100644
--- a/app/coffeescripts/gradebook2/Gradebook.coffee
+++ b/app/coffeescripts/gradebook2/Gradebook.coffee
@@ -12,7 +12,6 @@ define [
'str/htmlEscape'
'jst/gradebook_uploads_form'
'jst/gradebook2/section_to_show_menu'
- 'jst/gradebook2/column_header'
'jquery.ajaxJSON'
'jquery.instructure_date_and_time'
'jquery.instructure_jquery_patches'
@@ -24,7 +23,7 @@ define [
'jqueryui/position'
'jqueryui/sortable'
'compiled/jquery.kylemenu'
-], (I18n, $, GradeCalculator, Spinner, MultiGrid, SubmissionDetailsDialog, AssignmentGroupWeightsDialog, SubmissionCell, GradebookHeaderMenu, htmlEscape, gradebook_uploads_form, sectionToShowMenuTemplate, columnHeaderTemplate) ->
+], (I18n, $, GradeCalculator, Spinner, MultiGrid, SubmissionDetailsDialog, AssignmentGroupWeightsDialog, SubmissionCell, GradebookHeaderMenu, htmlEscape, gradebook_uploads_form, sectionToShowMenuTemplate) ->
class Gradebook
minimumAssignmentColumWidth = 10
diff --git a/public/javascripts/instructure-jquery.ui.draggable-patch.js b/public/javascripts/instructure-jquery.ui.draggable-patch.js
index e9ef3ed..78b8a62 100644
--- a/public/javascripts/instructure-jquery.ui.draggable-patch.js
+++ b/public/javascripts/instructure-jquery.ui.draggable-patch.js
@@ -1,13 +1,35 @@
-define(['jquery', 'jqueryui/draggable'], function ($) {
-
- var _mouseMove = $.ui.draggable.prototype._mouseMove;
- $.ui.draggable.prototype._mouseMove = function() {
- var ret = _mouseMove.apply(this, arguments);
- // Workaround-Instructure: this is a custom behavior added to jqueryUI draggable to make it work for resizing tiny.
- // look for instructureHackToNotAutoSizeTop in tinymce.editor_box.js to see where it is used.
- if (this.options.instructureHackToNotAutoSizeTop) this.helper[0].style.top = '';
- return ret;
- };
+define([
+ 'jquery',
+ 'jqueryui/draggable'
+], function (jQuery, _draggable) {
+
+jQuery.widget('instructure.draggable', jQuery.ui.draggable, {
+ _mouseDrag: function(event, noPropagation) {
+ // code is copy/pasted from jqueryui source except for commented workaround.
+
+ //Compute the helpers position
+ this.position = this._generatePosition(event);
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ //Call plugins and callbacks and use the resulting position if something is returned
+ if (!noPropagation) {
+ var ui = this._uiHash();
+ if(this._trigger('drag', event, ui) === false) {
+ this._mouseUp({});
+ return false;
+ }
+ this.position = ui.position;
+ }
+
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
+ // Workaround-Instructure: this is a custom behavior added to jqueryUI draggable to make it work for resizing tiny.
+ // look for instructureHackToNotAutoSizeTop in tinymce.editor_box.js to see where it is used.
+ if(!this.options.axis || this.options.axis != "x" && !this.options.instructureHackToNotAutoSizeTop) this.helper[0].style.top = this.position.top+'px';
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
+
+ return false;
+ }
+});
});
diff --git a/public/javascripts/rubric_assessment.js b/public/javascripts/rubric_assessment.js
index 230a209..92d3289 100644
--- a/public/javascripts/rubric_assessment.js
+++ b/public/javascripts/rubric_assessment.js
@@ -173,8 +173,8 @@ window.rubricAssessment = {
assessmentData: function($rubric) {
$rubric = rubricAssessment.findRubric($rubric);
var data = {};
- data['rubric_assessment[user_id]'] = rubricAssessment.assessment_user_id || $rubric.find(".user_id").text();
- data['rubric_assessment[assessment_type]'] = rubricAssessment.assessment_type || $rubric.find(".assessment_type").text();
+ data['rubric_assessment[user_id]'] = ENV.RUBRIC_ASSESSMENT.assessment_user_id || $rubric.find(".user_id").text();
+ data['rubric_assessment[assessment_type]'] = ENV.RUBRIC_ASSESSMENT.assessment_type || $rubric.find(".assessment_type").text();
$rubric.find(".criterion:not(.blank)").each(function() {
var id = $(this).attr('id');
var pre = "rubric_assessment[" + id + "]";
@@ -225,8 +225,8 @@ window.rubricAssessment = {
populateRubric: function($rubric, data) {
$rubric = rubricAssessment.findRubric($rubric);
var id = $rubric.attr('id').substring(7);
- $rubric.find(".user_id").text(rubricAssessment.assessment_user_id || data.user_id).end()
- .find(".assessment_type").text(rubricAssessment.assessment_type || data.assessment_type);
+ $rubric.find(".user_id").text(ENV.RUBRIC_ASSESSMENT.assessment_user_id || data.user_id).end()
+ .find(".assessment_type").text(ENV.RUBRIC_ASSESSMENT.assessment_type || data.assessment_type);
$rubric.find(".criterion_description").removeClass('completed').removeClass('original_completed').end()
.find(".rating").removeClass('selected').removeClass('original_selected').end()
@@ -302,10 +302,6 @@ window.rubricAssessment = {
}
};
-rubricAssessment.assessor_id = ENV.RUBRIC_ASSESSMENT.assessor_id;
-rubricAssessment.assessment_type = ENV.RUBRIC_ASSESSMENT.assessment_type;
-rubricAssessment.assessment_user_id = ENV.RUBRIC_ASSESSMENT.assessment_user_id;
-
$(rubricAssessment.init);
return rubricAssessment;
diff --git a/public/javascripts/speed_grader.js b/public/javascripts/speed_grader.js
index 02bb5cd..818fd9b 100644
--- a/public/javascripts/speed_grader.js
+++ b/public/javascripts/speed_grader.js
@@ -503,8 +503,8 @@ require([
function isAssessmentEditableByMe(assessment){
//if the assessment is mine or I can :manage_course then it is editable
- if (!assessment || assessment.assessor_id === rubricAssessment.assessor_id ||
- (rubricAssessment.assessment_type == 'grading' && assessment.assessment_type == 'grading')
+ if (!assessment || assessment.assessor_id === ENV.RUBRIC_ASSESSMENT.assessor_id ||
+ (ENV.RUBRIC_ASSESSMENT.assessment_type == 'grading' && assessment.assessment_type == 'grading')
){
return true;
}
@@ -1219,10 +1219,10 @@ require([
showRubric: function(){
//if this has some rubric_assessments
if (jsonData.rubric_association) {
- rubricAssessment.assessment_user_id = this.currentStudent.id;
+ ENV.RUBRIC_ASSESSMENT.assessment_user_id = this.currentStudent.id;
var assessmentsByMe = $.grep(EG.currentStudent.rubric_assessments, function(n,i){
- return n.assessor_id === rubricAssessment.assessor_id;
+ return n.assessor_id === ENV.RUBRIC_ASSESSMENT.assessor_id;
});
var gradingAssessments = $.grep(EG.currentStudent.rubric_assessments, function(n,i){
return n.assessment_type == 'grading';
@@ -1235,7 +1235,7 @@ require([
// show a new option if there is not an assessment by me
// or, if I can :manage_course, there is not an assessment already with assessment_type = 'grading'
- if( !assessmentsByMe.length || (rubricAssessment.assessment_type == 'grading' && !gradingAssessments.length) ) {
+ if( !assessmentsByMe.length || (ENV.RUBRIC_ASSESSMENT.assessment_type == 'grading' && !gradingAssessments.length) ) {
$rubric_assessments_select.append('<option value="new">' + I18n.t('new_assessment', '[New Assessment]') + '</option>');
}
@@ -1272,8 +1272,8 @@ require([
$comment.find('span.comment').html(htmlEscape(comment.comment).replace(/\n/g, "<br />"));
// this is really poorly decoupled but over in speed_grader.html.erb these rubricAssessment. variables are set.
// what this is saying is: if I am able to grade this assignment (I am administrator in the course) or if I wrote this comment...
- var commentIsDeleteableByMe = rubricAssessment.assessment_type === "grading" ||
- rubricAssessment.assessor_id === comment.author_id;
+ var commentIsDeleteableByMe = ENV.RUBRIC_ASSESSMENT.assessment_type === "grading" ||
+ ENV.RUBRIC_ASSESSMENT.assessor_id === comment.author_id;
$comment.find(".delete_comment_link").click(function(event) {
$(this).parents(".comment").confirmDelete({
diff --git a/spec/selenium/assignments_spec.rb b/spec/selenium/assignments_spec.rb
index c44f8b7..5c5770f 100644
--- a/spec/selenium/assignments_spec.rb
+++ b/spec/selenium/assignments_spec.rb
@@ -450,7 +450,8 @@ describe "assignments" do
get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}"
- keep_trying_until { driver.find_element(:css, '.toggle_full_rubric').click }
+ wait_for_ajaximations
+ driver.find_element(:css, '.toggle_full_rubric').click
find_with_jquery('#rubric_holder .criterion:visible .rating').click
driver.find_element(:css, '#rubric_holder .save_rubric_button').click
wait_for_ajaximations
diff --git a/spec/selenium/common.rb b/spec/selenium/common.rb
index e981a3c..05eed2a 100644
--- a/spec/selenium/common.rb
+++ b/spec/selenium/common.rb
@@ -291,10 +291,10 @@ shared_examples_for "all selenium tests" do
var pollForJqueryAndRequire = function(){
if (window.jQuery && window.require && window.require.resourcesDone) {
jQuery(function(){
- setTimeout(callback, 1);
+ setTimeout(callback, 0);
});
} else {
- setTimeout(pollForJqueryAndRequire, 1);
+ setTimeout(pollForJqueryAndRequire, 0);
}
}
pollForJqueryAndRequire();
diff --git a/spec/selenium/i18n_js_spec.rb b/spec/selenium/i18n_js_spec.rb
index fcd6323..1efb885 100644
--- a/spec/selenium/i18n_js_spec.rb
+++ b/spec/selenium/i18n_js_spec.rb
@@ -7,7 +7,7 @@ describe "i18n js" do
course_with_teacher_logged_in
get "/"
# get I18n global for all the tests
- driver.execute_script "require(['i18nObj'], function (I18n) { window.I18n = I18n });"
+ driver.execute_script "require(['i18n'], function (I18n) { window.I18n = I18n });"
end
context "html safety" do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment