Exemplo n.º 1
0
      success: function(data) {
        $(this).loadingImage('remove');

        // message is the message div containing this form, and conversation the
        // owning conversation. we make a copy of this div before filling it out
        // so that we can use it for the next message (if any)
        var $message = $(this).parents(".communication_sub_message")
        var $conversation = $message.parents(".communication_message");

        // fill out this message, display the new info, and remove the form
        var message_data = data.messages[0];
        $message.fillTemplateData({
          data: {
            post_date: $.datetimeString(message_data.created_at),
            message: message_data.body
          },
          htmlValues: ['message']
        });
        $message.find(".message").show();
        $(this).remove();

        // turn the "add message" button back on
        $conversation.find(".reply_message").show();

        // notify the user and any other watchers in the document
        $.flashMessage('Message Sent!');
        $(document).triggerHandler('user_content_change');
        if(location.pathname === '/') {
          $.trackEvent('dashboard_comment', 'create');
        }
      },
Exemplo n.º 2
0
 $.ajaxJSON($link.attr('href').replace(/\/download/, ""), 'GET', {}, function(data) {
   var attachment = data && data.attachment;
   $link.loadingImage('remove');
   if (attachment &&
         ($.isPreviewable(attachment.content_type, 'google') ||
          attachment.canvadoc_session_url)) {
     var $div = $("<div>")
       .insertAfter($link.parents(".link_holder:last"))
       .loadDocPreview({
         canvadoc_session_url: attachment.canvadoc_session_url,
         mimeType: attachment.content_type,
         public_url: attachment.public_url,
         attachment_preview_processing: attachment.workflow_state == 'pending_upload' || attachment.workflow_state == 'processing'
       })
       .prepend(
         $('<a href="#" style="font-size: 0.8em;" class="hide_file_preview_link">' + htmlEscape(I18n.t('links.minimize_file_preview', 'Minimize File Preview')) + '</a>')
         .click(function(event) {
           event.preventDefault();
           $link.show();
           $div.remove();
           $.trackEvent('hide_embedded_content', 'hide_file_preview');
         })
       );
     $.trackEvent('show_embedded_content', 'show_file_preview');
   }
 }, function() {
$(document).on('click', 'a.instructure_inline_media_comment', preventDefault(function () {
  if (!INST.kalturaSettings) {
    alert(I18n.t('alerts.kaltura_disabled', 'Kaltura has been disabled for this Canvas site'))
    return
  }

  const $link = $(this)

  let mediaType = 'video'
  const id = inlineMediaComment.getMediaCommentId($link)
  const $holder = inlineMediaComment.buildCommentHolder($link)
  $link.after($holder)
  $link.hide()

  if ($link.data('media_comment_type') === 'audio' || $link.is('.audio_playback, .audio_comment, .instructure_audio_link')) {
    mediaType = 'audio'
  }

  $holder.children('div').mediaComment('show_inline', id, mediaType, $link.data('download') || $link.attr('href'))

  const $minimizer = inlineMediaComment.buildMinimizerLink()

  $minimizer.appendTo($holder).click(preventDefault(() => {
    $link.show().focus()
    inlineMediaComment.collapseComment($holder)
  }))

  $.trackEvent('show_embedded_content', 'show_media')
}))
Exemplo n.º 4
0
function handleYoutubeLink () {
  const $link = $(this)
  const href = $link.attr('href')
  const id = $.youTubeID(href || "")

  if (id && !$link.hasClass('inline_disabled')) {
    const $after = $(`
      <a
        href="${ htmlEscape(href) }"
        class="youtubed"
      >
        <img src="/images/play_overlay.png"
          class="media_comment_thumbnail"
          style="background-image: url(//img.youtube.com/vi/${ htmlEscape(id) }/2.jpg)"
          alt="${ htmlEscape($link.data('preview-alt') || '') }"
        />
      </a>
    `)
    $after.click(preventDefault(function() {
      const $video = $(`
        <span class='youtube_holder' style='display: block;'>
          <iframe
            src='//www.youtube.com/embed/${  htmlEscape(id)  }?autoplay=1&rel=0&hl=en_US&fs=1'
            frameborder='0'
            width='425'
            height='344'
            allowfullscreen
          ></iframe>
          <br/>
          <a
            href='#'
            style='font-size: 0.8em;'
            class='hide_youtube_embed_link'
          >
            ${  htmlEscape(I18n.t('links.minimize_youtube_video', "Minimize Video"))  }
          </a>
        </span>
      `)
      $video.find(".hide_youtube_embed_link").click(preventDefault(() => {
        $video.remove()
        $after.show()
        $.trackEvent('hide_embedded_content', 'hide_you_tube')
      }))
      $(this).after($video).hide()
    }))
    $.trackEvent('show_embedded_content', 'show_you_tube')
    $link.addClass('youtubed').after($after)
  }
}
Exemplo n.º 5
0
 success: function(data) {
   $(this).loadingImage('remove');
   var $message = $(this).parents(".communication_sub_message");
   if($(this).hasClass('submission_comment_form')) {
     var user_id = $(this).getTemplateData({textValues: ['submission_user_id']}).submission_user_id;
     var submission = null;
     for(var idx in data) {
       var s = data[idx].submission;
       if(s.user_id == user_id) {
         submission = s;
       }
     }
     if(submission) {
       var comment = submission.submission_comments[submission.submission_comments.length - 1].submission_comment;
       comment.post_date = $.datetimeString(comment.created_at);
       comment.message = comment.formatted_body || comment.comment;
       $message.fillTemplateData({
         data: comment,
         htmlValues: ['message']
       });
     }
   } else {
     var entry = data.discussion_entry;
     entry.post_date = $.datetimeString(entry.created_at);
     $message.find(".content > .message_html").val(entry.message);
     $message.fillTemplateData({
       data: entry,
       htmlValues: ['message']
     });
   }
   $message.find(".message").show();
   $message.find(".user_content").removeClass('enhanced');
   $message.parents(".communication_message").find(".reply_message").removeClass('lonely_behavior_message').show();
   $(document).triggerHandler('richTextEnd', $(this).find("textarea.rich_text"));
   $(document).triggerHandler('user_content_change');
   $(this).remove();
   if(location.href.match(/dashboard/)) {
     $.trackEvent('dashboard_comment', 'create');
   }
 },
Exemplo n.º 6
0
 $video.find(".hide_youtube_embed_link").click(preventDefault(() => {
   $video.remove()
   $after.show()
   $.trackEvent('hide_embedded_content', 'hide_you_tube')
 }))
Exemplo n.º 7
0
 .click(function(event) {
   event.preventDefault();
   $link.show();
   $div.remove();
   $.trackEvent('hide_embedded_content', 'hide_file_preview');
 })
Exemplo n.º 8
0
          </a>
        </span>
      `)
      $video.find(".hide_youtube_embed_link").click(preventDefault(() => {
        $video.remove()
        $after.show()
        $.trackEvent('hide_embedded_content', 'hide_you_tube')
      }))
      $(this).after($video).hide()
    }))
    $.trackEvent('show_embedded_content', 'show_you_tube')
    $link.addClass('youtubed').after($after)
  }
}

  $.trackEvent('Route', location.pathname.replace(/\/$/, '').replace(/\d+/g, '--') || '/');


  var JQUERY_UI_WIDGETS_WE_TRY_TO_ENHANCE = '.dialog, .draggable, .resizable, .sortable, .tabs';
  export function enhanceUserContent() {
    var $content = $("#content");
    $(".user_content:not(.enhanced):visible").addClass('unenhanced');
    $(".user_content.unenhanced:visible")
      .each(function() {
        var $this = $(this);
        $this.find("img").css('maxWidth', Math.min($content.width(), $this.width()));
        $this.data('unenhanced_content_html', $this.html());
      })
      .find(".enhanceable_content").show()
        .filter(JQUERY_UI_WIDGETS_WE_TRY_TO_ENHANCE).ifExists(function($elements){
          var msg =
Exemplo n.º 9
0
      }
    });
    setTimeout(function(){
      if($('#insecure_content_msg').is(":visible")){
        $('#load_failure').show()
        launchToolInNewTab();
      }
    }, 3 * 1000);
    break;
}

//Google analytics tracking code
var toolName = $toolForm.data('tool-id') || "unknown";
var toolPath = $toolForm.data('tool-path');
var messageType = $toolForm.data('message-type') || 'tool_launch';
$.trackEvent(messageType, toolName, toolPath);

//Iframe resize handler
var $tool_content_wrapper;
var min_tool_height, canvas_chrome_height;

$(function() {
  var $window = $(window);
  $tool_content_wrapper = $('.tool_content_wrapper');
  const toolResizer = new ToolLaunchResizer(min_tool_height);
  const $tool_content = $('iframe#tool_content')

  const $external_content_info_alerts = $tool_content_wrapper
    .find('.before_external_content_info_alert, .after_external_content_info_alert');

  $external_content_info_alerts.on('focus', function(e) {
Exemplo n.º 10
0
  $.fn.validateForm = function(options) {
    if (this.length === 0) {
      return false;
    }
    var options = $.extend({}, $.fn.validateForm.defaults, options),
        $form = this,
        errors = {},
        data = options.data || $form.getFormData(options);

    if (options.object_name) {
      options.required = $._addObjectName(options.required, options.object_name);
      options.date_fields = $._addObjectName(options.date_fields, options.object_name);
      options.dates = $._addObjectName(options.dates, options.object_name);
      options.times = $._addObjectName(options.times, options.object_name);
      options.numbers = $._addObjectName(options.numbers, options.object_name);
      options.property_validations = $._addObjectName(options.property_validations, options.object_name);
    }
    if (options.required) {
      var required = _.result(options, 'required')
      $.each(required, function(i, name) {
        if (!data[name]) {
          if (!errors[name]) {
            errors[name] = [];
          }
          var fieldPrompt = $form.getFieldLabelString(name);
          errors[name].push(I18n.t('errors.required', "Required field")+(fieldPrompt ? ': '+fieldPrompt : ''));
        }
      });
    }
    if(options.date_fields) {
      $.each(options.date_fields, function(i, name) {
        var $item = $form.find("input[name='" + name + "']").filter(".datetime_field_enabled");
        if ($item.length && $item.data('invalid')) {
          if (!errors[name]) {
            errors[name] = [];
          }
          errors[name].push(I18n.t('errors.invalid_datetime', "Invalid date/time value"));
        }
      });
    }
    if (options.numbers) {
      $.each(options.numbers, function(i, name){
        var val = parseFloat(data[name]);
        if(isNaN(val)) {
          if(!errors[name]) {
            errors[name] = [];
          }
          errors[name].push(I18n.t('errors.invalid_number', "This should be a number."));
        }
      });
    }
    if(options.property_validations) {
      $.each(options.property_validations, function(name, validation) {
        if($.isFunction(validation)) {
          var result = validation.call($form, data[name], data);
          if(result) {
            if(typeof(result) != "string") {
              result = I18n.t('errors.invalid_entry_for_field', "Invalid entry: %{field}", {field: name});
            }
            if(!errors[name]) { errors[name] = []; }
            errors[name].push(result);
          }
        }
      });
    }
    var hasErrors = false;
    for(var err in errors) {
      hasErrors = true;
      break;
    }
    if(hasErrors) {
      $form.formErrors(errors, options);
      $.trackEvent("Form Errors", this.attr('id') || this.attr('class') || document.title, JSON.stringify(errors));
      return false;
    }
    return true;
  };
  ),

  buildCommentHolder: ($link) => $('<div><div class="innerholder" tabindex="-1" style="margin-bottom: 15px;"></div></div>'),

  getMediaCommentId ($link) {
    let idAttr
    let id = $link.data('media_comment_id') || $link.find('.media_comment_id:first').text()
    if (!id) idAttr = $link.attr('id')
    if (idAttr && idAttr.match(/^media_comment_/)) id = idAttr.substring(14)
    return id
  },

  collapseComment ($holder) {
    __guard__($holder.find('video,audio').data('mediaelementplayer'), x => x.pause())
    $holder.remove()
    $.trackEvent('hide_embedded_content', 'hide_media')
  },
}

const initialFocusInnerhold = (e) => {
  $(e.target).find('div.mejs-audio').focus()
}

const minTdWidth = 300

const isVideoInTd = ($link) => {
  const $closestTd = $link.closest('td')
  return $closestTd.length > 0
}

const isContainingTdSmall = ($link) => {