Professional Documents
Culture Documents
Drupal.theme.prototype.popupLoading = function() {
var loading = '<div id="popups-loading"><div>';
loading += Drupal.t('Loading...');
loading += '</div></div>';
return loading;
};
/**
* Similar to drupal_attributes
*
* @param object attrs
*/
Drupal.attributes =
Drupal.theme.prototype.attributes = function(attrs){
var ret = '';
$.each(attrs, function(k, v){
ret += ' ' + k + '="' + Drupal.checkPlain(v) +'"';
});
return $.trim(ret);
};
/**
* Similar to Drupal's l()
*
* @param string text
* @param string path
* @param object opts
*/
Drupal.l =
Drupal.theme.prototype.l = function(text, path, opts){
if(typeof opts == 'undefined'){
var opts = {};
}
var defaults = {
attributes: {},
html: false
};
opts = $.extend(defaults, opts);
/**
* Return a jquery object with the tipsy plugin bound.
*
* @param string content the content to show in the tipsy
* @param object opts
* string text the text to go inside the element that triggers the tipsy
* string gravity
* object attributes standard Drupal.attributes
*/
Drupal.theme.infotip = function(content, opts){
if(typeof opts == 'undefined'){
var opts = {};
}
var defaults = {
text: '',
gravity: 's',
attributes: {
'class': ''
}
};
opts = $.extend(defaults, opts);
return infotipObj;
};
/*
* Return Markup for action links
*/
Drupal.theme.sActionLinks = function(links, opts){
if(typeof opts == undefined){
var opts = {};
}
var defaults = {
wrapperId : '',
ulId : '',
btnId : '',
btnClass : '',
ulClass : '',
wrapperClass : '',
size : 'regular',
text : '',
isAngular : true
};
opts = $.extend(defaults, opts);
var output = '';
output += '<div class="' + (opts.isAngular ? 's-action-link' : '') + ' action-
links-wrapper action-links-wrapper-' + opts.size + ' ' + opts.wrapperClass + '">';
output += '<div tabindex="0" role="button" class="action-links-unfold" id="' +
opts.btnId + '">';
output += '<span class="action-links-unfold-text"><span class="visually-hidden">'
+ Drupal.t('Click to toggle options.') + '</span></span>';
output += '</div>';
output += '<ul class="action-links">';
$.each(links, function(k, v){
output += v;
});
output += '</ul>';
output += '</div>';
return output;
}
Drupal.theme.sCommonAngularDeletePopup = function(){
return {
title : Drupal.t('Delete'),
body : Drupal.t('Are you sure you want to delete this?'),
confirm : {
text : Drupal.t('Delete')
},
cancel : {
text : Drupal.t('Cancel')
}
};
}
/**
* Register an element for popups with the provided options.
*
* @param string/object el selector or jquery object
* @param object opts popups options
*/
Drupal.popup = function(el, opts){
var elObj = $(el)
elObj.not('.popups-processed').addClass('popups-processed').click(function(e){
e.preventDefault();
return Popups.clickPopupElement(this, opts);
});
return elObj;
};
Drupal.behaviors.schoologyTheme = function(context){
$('.popups-body textarea:not(.schoologyTheme-
processed)').addClass('schoologyTheme-processed').each(function(){
var ta = $(this);
ta.focus(function(){
ta.addClass('popups-textarea-focus');
popup = Popups.activePopup();
if(popup != null)
Popups.resizeAndCenter(popup);
});
});
};
Drupal.theme.sAjaxLoader = function(options){
var defaultOpts = {
asString : false,
imgId : false
};
var opts = $.extend( {}, $.fn.sActionLinks.defaults, options);
var ajaxLoader = $('<img
/>').attr('src','/sites/all/themes/schoology_theme/images/ajax-
loader.gif').addClass('ajax-loader');
if(opts.imgId){
ajaxLoader.attr('id', opts.imgId);
}
if(opts.asString){
return ajaxLoader[0].outerHTML;
}
return ajaxLoader;
}
return msg;
}
return output;
};
;// JavaScript Document
var wait_image = '/sites/all/themes/schoology_theme/images/ajax-loader.gif';
var wait_image_width = 43;
var wait_image_height = 11;
Drupal.behaviors.sGradeItem = function(context){
sGradeItemEnableCommentJump();
// cluetip
if($('#save-for-later-help', context).length){
$('#save-for-later-help', context).cluetip({splitTitle: '|', dropShadow:
false, showTitle: false, positionBy: 'auto'});
}
$('.grade-item-action-links:not(.sGradeItem-processed)',
context).addClass('sGradeItem-processed').each(function () {
$(this).sActionLinks({hidden: false, wrapper: '.action-links-
wrapper'});
});
$('.info-container .view-info:not(.sGradeItem-processed)',
context).addClass('sGradeItem-processed').each(function () {
var linkBtn = $(this);
linkBtn.bind('click', function(){
var wrapper = $(this).parent();
$('.grading-info', wrapper).toggle();
linkBtn.toggleClass('active');
return false;
}).tipsy({
'gravity': 'se'
});
});
$('body').unbind('click.sGradeViewInfo').bind('click.sGradeViewInfo',
function(e){
var linkBtn = $('.info-container .view-info', context);
var target = $(e.target);
if(linkBtn.hasClass('active') && target.not('.grading-info') &&
target.parents('.grading-info').length == 0){
linkBtn.click();
}
});
$('.info-container .link-btn:not(.sGradeItem-processed)',
context).addClass('sGradeItem-processed').each(function () {
$(this).tipsy({
'gravity': 'se'
});
});
$('.comment:not(.sGradeItem-processed)', context).addClass('sGradeItem-
processed').each(function () {
var comment = $(this);
comment.bind('mouseenter', function(){
$(".entry-links-view", comment).show();
}).bind('mouseleave', function(){
$(".entry-links-view", comment).hide();
});
});
$('#s-grade-item-add-attachment-form:not(.sGradeItem-processed)',
context).addClass('sGradeItem-processed').each(function() {
setTimeout(function(){
$('#file-selector').click();
},150);
});
if ($('body').hasClass('s-enable-mathml')) {
s_renderMath();
}
$('body:not(.sGradeItem-processed)', context).addClass('sGradeItem-
processed').each(function() {
var viewInfoClickHandlers;
var viewStatsClickHandlers;
$(this).on('grade-item-disable-top-controls', function() {
$('.grade-item-action-links .action-links-unfold',
context).addClass('disabled');
viewStatsLink.addClass('disabled');
viewStatsLink.tipsy('disable');
viewStatsLink.click(function(e) { e.preventDefault(); });
}
$('.assessment-status-wrapper', context).addClass('disabled');
});
$(this).on('grade-item-enable-top-controls', function() {
$('.grade-item-action-links .action-links-unfold',
context).removeClass('disabled');
$('.assessment-status-wrapper', context).removeClass('disabled');
});
});
};
function sGradeItemEnableCommentJump(){
$(".go-to-reply").click(function() {
var el = $(this).parent().parent().parent().parent();
if (location.pathname.replace(/^\//,'') ==
this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
$(target).effect("highlight", {color: "#f9b974"}, 3000);
target = target.length && target || $('[name=' + this.hash.slice(1) +']');
if (target.length) {
var targetOffset = target.offset().top-20;
$('html,body').animate({scrollTop: targetOffset}, 500);
return false;
}
}
});
}
/**
* Ajax plugins callback
*
* @param {String} hook
* @param {Object} args
* @return {Bool}
*/
if(formObj.length){
if(typeof args.redirect == 'string' && args.redirect.length > 0){
window.location.href = args.redirect;
}
else{
var validateOutput = args.ajax_validate_output;
var submitOutput = args.ajax_submit_output;
var id = 'comment-container';
var content = '';
// Display the submit output if set, otherwise display validate output
if(submitOutput != undefined)
content = submitOutput;
else if(validateOutput != undefined)
content = validateOutput;
/**
* Ajax plugins callback
*
* @param {String} hook
* @param {Object} args
* @return {Bool}
*/
Drupal.Ajax.plugins.s_comment = function(hook, args) {
switch( hook ) {
case 'submit':
var submitter = args.submitter,
formObj = submitter.closest('form'),
editorObj = formObj.find('.s-tinymce-load-editor');
if(formObj.hasClass('post-comment-form')){
submitter.attr('disabled', 'disabled').parent().addClass('disabled');
}
if(editorObj.length){
var ed = tinyMCE.get(editorObj.attr('id'));
if(ed){
ed.save();
}
}
break;
case 'message':
var submitter = args.local.submitter;
var commentForm = submitter.parents('form');
if(!submitter.parents('form').hasClass('post-comment-form')){
return;
}
if(isDiscussion) {
$(this).prepend(contentObj);
} else {
$(this).append(contentObj);
}
Drupal.attachBehaviors(contentObj);
// submission failed (ie, discussion is locked)
var is_locked = false;
for (i = 0; i < args.messages_error.length; ++i) {
if(args.messages_error[i].value == 'This discussion is locked') {
is_locked = true;
}
}
if(is_locked) {
footerComments.find("textarea")
.attr('defaulttext', footerComments.find("textarea").val())
.addClass('is-locked');
}
sCommentScrollToNewComment(contentObj, 750, ":has(.s-comments-post-form-
new)");
if(isDiscussion){
var colorString = "rgba(213,227, 241, 0.6)";
contentObj.effect("highlight", {color: colorString}, 3000);
}
});
}
else {
var contentObj = $('<div id="s_comments"><div class="discussion-
card">'+content+'</div></div>');
if(isDiscussion){
var colorString = "rgba(213,227, 241, 0.6)";
footerComments.find(".s-comments-post-form").after(contentObj);
contentObj.effect("highlight", {color: colorString}, 3000);
} else {
footerComments.find(".s-comments-post-form").before(contentObj);
}
Drupal.attachBehaviors(contentObj);
}
if(comments == 1)
suffix = splice[1]+"s";
++comments;
numCommentsLink.text(comments+ " "+suffix);
//resize textarea back to default size of 32 pixels
$('#edit-comment-wrapper #edit-comment', commentForm).css('height', '32px');
break;
case 'afterMessage':
// reset attachment form
if(!args.ajax_submit_output)
return;
if ($('li#file-selector').hasClass('active')){
$('li#file-selector').removeClass('active');
}
break;
}
}
/**
* Ajax plugins callback
*
* @param {String} hook
* @param {Object} args
* @return {Bool}
*/
Drupal.Ajax.plugins.s_comment_reply = function(hook, args) {
switch(hook){
case 'submit': // submitting the form
// disable the submit button
var submitter = args.submitter;
submitter.attr('disabled', 'disabled').parent().addClass('disabled');
break;
case 'message': // response received, return false to hide messages
var submitter = args.local.submitter;
var form = submitter.parents('form');
if(form.attr('id') == 's-comment-reply-form'){
if(typeof args.redirect == 'string' && args.redirect.length > 0){
window.location.href = args.redirect;
}
else{
// reenable the submit button
submitter.attr('disabled', false).parent().removeClass('disabled');
content = submitOutput;
Drupal.attachBehaviors(replyLevel);
} else if(validateOutput != undefined) {
content = validateOutput;
}
//increment the thread counter and show the hide link if exists
var threadRoot = submitter.closest('.thread-root');
var expanderBar = threadRoot.prev();
//ensure its not a pending comment
var contentObj = $(content);
var isPending = $('.pending-comment', contentObj).length > 0;
if(expanderBar.hasClass('expander-bar') && !isPending){
var numRepliesWrapper = $('.num-replies', expanderBar);
var numReplies = numRepliesWrapper.text();
var expandText = $('.expander-text', expanderBar);
var hideText = $('.expander-hide-text', expanderBar);
numReplies = parseInt(numReplies);
numReplies++;
numRepliesWrapper.html(numReplies);
expandText.html(Drupal.formatPlural(numReplies, '1 Reply', '@count
Replies'));
hideText.html(Drupal.formatPlural(numReplies, 'Hide 1 reply', 'Hide All
@count Replies'));
if (numReplies == 1) {
$('.expander-link-expanded', expanderBar).removeClass('hidden');
}
}
}
}
break;
}
}
;