Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay
Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay
Peer-Review Article Analysis
The peer-reviewed article selected and which concerns my area of practice as a Family Nurse Practitioner is;
Smith, J. D., Fu, E., & Kobayashi, M. (2020). Prevention and management of childhood obesity and its psychological and health comorbidities. Annual review of clinical psychology, 16, 351. doi: 10.1146/annurev-clinpsy-100219-060201
The main reason for selecting the article concerns the increased rates of childhood obesity; where, as of 2020, the world statistics show that children below five years and with obesity were approximately 39 million (World Health Organization, 2021).
I retrieved Smith et al. (2020) article from PubMed Central, one of the nursing and medical databases that provides authentic, credible, and reliable articles and journals on life and biomedical sciences. The main problem I encountered searching for the article is that most researchers merged their research on children with obesity with that of young adults, making me spend a lot of time looking for an article that solely focused on obesity in children Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay .
PLACE YOUR ORDER HERE
I am confident that my colleagues would find the PubMed Central database essential in their nursing research since it provides full-text articles making it cost-effective for a student compared to other databases that require one to pay for full articles. Also, considering that the database was initiated in 2000, it has a variety of research articles on nursing practice that can help advance their knowledge of different nursing areas (PubMed Central, n.d).
The main reason why I would recommend the use of PubMed Central is based on the fact it has a large data volume on medical and nursing articles. As a result, it will facilitate carrying out evidence-based research since all its articles and journals are available in full-text. In conclusion, PubMed Central is a nursing student-friendly research database.
References
Pubmed Central (n.d). About PMC. National Library of Medicine. https://www.ncbi.nlm.nih.gov/pmc/about/intro/
Smith, J. D., Fu, E., & Kobayashi, M. (2020). Prevention and management of childhood obesity and its psychological and health comorbidities. Annual review of clinical psychology, 16, 351. doi: 10.1146/annurev-clinpsy-100219-060201
World Health Organization (June 9, 2021). Obesity and Overweight. https://www.who.int/news-room/fact-sheets/detail/obesity-and-overweight
{};
var toggleHighlights = false;
origReport.toggleHighlightButton = function () {
var titleContent, liveText;
$(this).toggleClass(‘disabled’);
if ($(this).hasClass(‘disabled’)) {
titleContent = origReport.translations.showHighlightTitle;
liveText = origReport.translations.citationNotHighlightedMsg;
} else {
titleContent = origReport.translations.removeHighlightTitle;
liveText = origReport.translations.citationHighlightedMsg;
}
$(this).attr(‘title’, titleContent);
$(this).children(‘span.hideoff’).text(liveText);
};
origReport.pageInit = function () {
// rotate and reposition the dock/undock button depending on the width
var windowWidth = $(window).width();
if (windowWidth < 992) {
$(‘#expandCollapse-panel’).find(‘span’).addClass(‘rotated’);
$(‘#expandCollapse-panel’).addClass(‘centered’);
} else {
$(‘#expandCollapse-panel’).find(‘span’).removeClass(‘rotated’);
$(‘#expandCollapse-panel’).removeClass(‘centered’);
}
};
$(function () {
$(‘#expColToggle’).on(“click”, function () {
// toggle docking and undocking
$(‘#expColToggle’).toggleClass(‘docked’);
$(‘#expColToggle’).find(‘span’)
.toggleClass(‘glyphicon-chevron-right’)
.toggleClass(‘glyphicon-chevron-left’);
$(‘#previewer’).toggleClass(‘col-lg-11 col-md-11 col-sm-12’)
.toggleClass(‘col-lg-8 col-md-8 col-sm-12’);
$(‘#report-panel-inner’).toggleClass(‘hide’);
$(‘.report-panel’).toggleClass(‘col-lg-1 col-md-1 col-sm-12’)
.toggleClass(‘col-lg-4 col-md-4 col-sm-12 whiteBG’);
$(‘#expandCollapse-panel’)
.toggleClass(‘col-lg-12 col-md-12 col-sm-12’)
.toggleClass(‘col-lg-2 col-md-2’);
var titleContent;
if ($(this).hasClass(‘docked’)) {
titleContent = origReport.translations.expandReportPanelTitle;
} else {/* Prototype JavaScript framework, version 1.7 * (c) 2005-2010 Sam Stephenson * * Prototype is freely distributable under the terms of an MIT-style license. * For details, see the Prototype web site: http://www.prototypejs.org/ * *————————————————————————–*/ var Prototype = { Version: ‘1.7’, Browser: (function(){ var ua = navigator.userAgent; var isOpera = Object.prototype.toString.call(window.opera) == ‘[object Opera]’; var isIE = !!window.attachEvent && !isOpera; return { IE: isIE, Opera: isOpera, WebKit: ua.indexOf(‘AppleWebKit/’) > -1, Gecko: ua.indexOf(‘Gecko’) > -1 && ua.indexOf(‘KHTML’) === -1, MobileSafari: /Apple.*Mobile/.test(ua), Edge: !isIE && !!window.StyleMedia } })(), BrowserFeatures: { XPath: !!document.evaluate, SelectorsAPI: !!document.querySelector, ElementExtensions: (function() { var constructor = window.Element || window.HTMLElement; return !!(constructor && constructor.prototype); })(), SpecificElementExtensions: (function() { if (typeof window.HTMLDivElement !== ‘undefined’) return true; var div = document.createElement(‘div’), form = document.createElement(‘form’), Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay isSupported = false; if (div[‘__proto__’] && (div[‘__proto__’] !== form[‘__proto__’])) { isSupported = true; } div = form = null; return isSupported; })() }, ScriptFragment: ‘]*>([\\S\\s]*?)’, JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, emptyFunction: function() { }, K: function(x) { return x } }; if (Prototype.Browser.MobileSafari) Prototype.BrowserFeatures.SpecificElementExtensions = false; var Abstract = { }; var Try = { these: function() { var returnValue; for (var i = 0, length = arguments.length; i < length; i++) { var lambda = arguments[i]; try { returnValue = lambda(); break; } catch (e) { } } return returnValue; } }; /* Based on Alex Arnell’s inheritance implementation. */ var Class = (function() { var IS_DONTENUM_BUGGY = (function(){ for (var p in { toString: 1 }) { if (p === ‘toString’) return false; } return true; })(); function subclass() {}; function create() { var parent = null, properties = $A(arguments); if (Object.isFunction(properties[0])) parent = properties.shift(); function klass() { this.initialize.apply(this, arguments); } Object.extend(klass, Class.Methods); klass.superclass = parent; klass.subclasses = []; if (parent) { subclass.prototype = parent.prototype; klass.prototype = new subclass; parent.subclasses.push(klass); } for (var i = 0, length = properties.length; i < length; i++) klass.addMethods(properties[i]); if (!klass.prototype.initialize) klass.prototype.initialize = Prototype.emptyFunction; klass.prototype.constructor = klass; return klass; } function addMethods(source) { var ancestor = this.superclass && this.superclass.prototype, properties = Object.keys(source); if (IS_DONTENUM_BUGGY) { if (source.toString != Object.prototype.toString) properties.push(“toString”); if (source.valueOf != Object.prototype.valueOf) properties.push(“valueOf”); } for (var i = 0, length = properties.length; i < length; i++) { var property = properties[i], value = source[property]; if (ancestor && Object.isFunction(value) && value.argumentNames()[0] == “$super”) { var method = value; value = (function(m) { return function() { return ancestor[m].apply(this, arguments); }; })(property).wrap(method); value.valueOf = method.valueOf.bind(method); value.toString = method.toString.bind(method); } this.prototype[property] = value; } return this; } return { create: create, Methods: { addMethods: addMethods } }; })(); (function() { var _toString = Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay Object.prototype.toString, NULL_TYPE = ‘Null’, UNDEFINED_TYPE = ‘Undefined’, BOOLEAN_TYPE = ‘Boolean’, NUMBER_TYPE = ‘Number’, STRING_TYPE = ‘String’, OBJECT_TYPE = ‘Object’, FUNCTION_CLASS = ‘[object Function]’, BOOLEAN_CLASS = ‘[object Boolean]’, NUMBER_CLASS = ‘[object Number]’, STRING_CLASS = ‘[object String]’, ARRAY_CLASS = ‘[object Array]’, DATE_CLASS = ‘[object Date]’, NATIVE_JSON_STRINGIFY_SUPPORT = window.JSON && typeof JSON.stringify === ‘function’ && JSON.stringify(0) === ‘0’ && typeof JSON.stringify(Prototype.K) === ‘undefined’; function Type(o) { switch(o) { case null: return NULL_TYPE; case (void 0): return UNDEFINED_TYPE; } var type = typeof o; switch(type) { case ‘boolean’: return BOOLEAN_TYPE; case ‘number’: return NUMBER_TYPE; case ‘string’: return STRING_TYPE; } return OBJECT_TYPE; } function extend(destination, source) { for (var property in source) destination[property] = source[property]; return destination; } function inspect(object) { try { if (isUndefined(object)) return ‘undefined’; if (object === null) return ‘null’; return object.inspect ? object.inspect() : String(object); } catch (e) { if (e instanceof RangeError) return ‘…’; throw e; } } function toJSON(value) { return Str(”, { ”: value }, []); } function Str(key, holder, stack) { var value = holder[key], type = typeof value; if (Type(value) === OBJECT_TYPE && typeof value.toJSON === ‘function’) { value = value.toJSON(key); } var _class = _toString.call(value); switch (_class) { case NUMBER_CLASS: case BOOLEAN_CLASS: case STRING_CLASS: value = value.valueOf(); } switch (value) { case null: return ‘null’; case true: return ‘true’; case false: return ‘false’; } type = typeof value; switch (type) { case ‘string’: return value.inspect(true); case ‘number’: return isFinite(value) ? String(value) : ‘null’; case ‘object’: for (var i = 0, length = stack.length; i < length; i++) { if (stack[i] === value) { throw new TypeError(); } } stack.push(value); var partial = []; if (_class === ARRAY_CLASS) { for (var i = 0, length = value.length; i < length; i++) { var str = Str(i, value, stack); partial.push(typeof str === ‘undefined’ ? ‘null’ : str); } partial = ‘[‘ + partial.join(‘,’) + ‘]’; } else { var keys = Object.keys(value); for (var i = 0, length = keys.length; i < length; i++) { var key = keys[i], str = Str(key, value, stack); if (typeof str !== “undefined”) { partial.push(key.inspect(true)+ ‘:’ + str); } } partial = ‘{‘ + partial.join(‘,’) + ‘}’; } stack.pop(); return partial; } } function stringify(object) { return JSON.stringify(object); } function toQueryString(object) { return $H(object).toQueryString(); } function toHTML(object) { return object && object.toHTML ? object.toHTML() : String.interpret(object); } function keys(object) { if (Type(object) !== OBJECT_TYPE) { throw new TypeError(); } var results = []; for (var property in object) { if (object.hasOwnProperty(property)) { results.push(property); } } return results; } function values(object) { var results = []; for (var property in object) results.push(object[property]); return results; } function clone(object) { return extend({ }, object); } function isElement(object) { return !!(object && object.nodeType == 1); } function isArray(object)
{ return _toString.call(object) === ARRAY_CLASS; } var hasNativeIsArray = (typeof Array.isArray == ‘function’) && Array.isArray([]) && !Array.isArray({}); if (hasNativeIsArray) { isArray = Array.isArray; } function isHash(object) { return object instanceof Hash; } function isFunction(object) { return _toString.call(object) === FUNCTION_CLASS; } function isString(object) { return _toString.call(object) === STRING_CLASS; } function isNumber(object) { return _toString.call(object) === NUMBER_CLASS; } function isDate(object) { return _toString.call(object) === DATE_CLASS; } function isUndefined(object) { return typeof object === “undefined”; } extend(Object, { extend: extend, inspect: inspect, toJSON: NATIVE_JSON_STRINGIFY_SUPPORT ? stringify : toJSON, toJSONEx: toJSON, // Leaving this in here to assist in debugging odd stringify issues in IE if we see them again in other contexts. toQueryString: toQueryString, toHTML: toHTML, keys: Object.keys || keys, values: values, clone: clone, isElement: isElement, isArray: isArray, isHash: isHash, isFunction: isFunction, isString: isString, isNumber: isNumber, isDate: isDate, isUndefined: isUndefined }); })(); Object.extend(Function.prototype, (function() { var slice = Array.prototype.slice; function update(array, args) { var arrayLength = array.length, length = args.length; while (length–) array[arrayLength + length] = args[length]; return array; } function merge(array, args) { array = slice.call(array, 0); return update(array, args); } function argumentNames() { var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1] .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, ”) .replace(/\s+/g, ”).split(‘,’); return names.length == 1 && !names[0] ? [] : names; } function bind(context) { if (arguments Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay .
length < 2 && Object.isUndefined(arguments[0])) return this; var __method = this, args = slice.call(arguments, 1); return function() { var a = merge(args, arguments); return __method.apply(context, a); } } function bindAsEventListener(context) { var __method = this, args = slice.call(arguments, 1); return function(event) { var a = update([event || window.event], args); return __method.apply(context, a); } } function curry() { if (!arguments.length) return this; var __method = this, args = slice.call(arguments, 0); return function() { var a = merge(args, arguments); return __method.apply(this, a); } } function delay(timeout) { var __method = this, args = slice.call(arguments, 1); timeout = timeout * 1000; return window.setTimeout(function() { return __method.apply(__method, args); }, timeout); } function defer() { var args = update([0.01], arguments); return this.delay.apply(this, args); } function wrap(wrapper) { var __method = this; return function() { var a = update([__method.bind(this)], arguments); return wrapper.apply(this, a); } } function methodize() { if (this._methodized) return this._methodized; var __method = this; return this._methodized = function() { var a = update([this], arguments); return __method.apply(null, a); }; } return { argumentNames: argumentNames, bind: bind, bindAsEventListener: bindAsEventListener, curry: curry, delay: delay, defer: defer, wrap: wrap, methodize: methodize } })()); (function(proto) { function toISOString() { return this.getUTCFullYear() + ‘-‘ + (this.getUTCMonth() + 1).toPaddedString(2) + ‘-‘ + this.getUTCDate().toPaddedString(2) + ‘T’ + this.getUTCHours().toPaddedString(2) + ‘:’ + this.getUTCMinutes().toPaddedString(2) + ‘:’ + this.getUTCSeconds().toPaddedString(2) + ‘Z’; } function toJSON() { return this.toISOString(); } if (!proto.toISOString) proto.toISOString = toISOString; if (!proto.toJSON) proto.toJSON = toJSON; })(Date.prototype); RegExp.prototype.match = RegExp.prototype.test; RegExp.escape = function(str) { return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, ‘\\$1’); }; var PeriodicalExecuter = Class.create({ initialize: function(callback, frequency) { this.callback = callback; this.frequency = frequency; this.currentlyExecuting = false; this.registerCallback(); }, registerCallback: function() { this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); }, execute: function() { this.callback(this); }, stop: function() { if (!this.timer) return; clearInterval(this.timer); this.timer = null; }, onTimerEvent: function() { if (!this.currentlyExecuting) { try { this.currentlyExecuting = true; this.execute(); this.currentlyExecuting = false; } catch(e) { this.currentlyExecuting = false; throw e; } } } }); Object.extend(String, { interpret: function(value) { return value == null ? ” : String(value); }, specialChar: { ‘\b’: ‘\\b’, ‘\t’: ‘\\t’, ‘\n’: ‘\\n’, ‘\f’: ‘\\f’, ‘\r’: ‘\\r’, ‘\\’: ‘\\\\’ } }); Object.extend(String.prototype, (function() { var NATIVE_JSON_PARSE_SUPPORT = window.JSON && typeof JSON.parse === ‘function’ && JSON.parse(‘{“test”: true}’).test; function prepareReplacement(replacement) { if (Object.isFunction(replacement)) return replacement; var template = new Template(replacement); return function(match) { return template.evaluate(match) }; } function gsub(pattern, replacement) { var result = ”, source = this, match; replacement = prepareReplacement(replacement); if (Object.isString(pattern)) pattern = RegExp.escape(pattern); if (!(pattern.length || pattern.source)) { replacement = replacement(”); return replacement + source.split(”).join(replacement) + replacement; } while (source.length > 0) { if (match = source.match(pattern)) { result += source.slice(0, match.index); result += String.interpret(replacement(match)); source = source.slice(match.index + match[0].length); } else { result += source, source = ”; } } return result; } function sub(pattern, replacement, count) { replacement = prepareReplacement(replacement); count = Object.isUndefined(count) ? 1 : count; return this.gsub(pattern, function(match) { if (–count < 0) return match[0]; return replacement(match); }); } function scan(pattern, iterator) { this.gsub(pattern, iterator); return String(this); } function truncate(length, truncation) { length = length || 30; truncation = Object.isUndefined(truncation) ? ‘…’ : truncation; return this.length > length ? this.slice(0, length – truncation.length) + truncation : String(this); } function strip() { return this.replace(/^\s+/, ”).replace(/\s+$/, ”); } function stripTags() { return this.replace(/])+)?>|/gi, ”); } function stripScripts() { return this.replace(new RegExp(Prototype.ScriptFragment, ‘img’), ”); } function extractScripts() { //
NOTE: The original code here extracted scripts with a regex – that worked well-enough except it included scripts inside // comments. An attempt was made to remove comments via a regex but (a) that caused chrome to churn 100% cpu and effectively crash sometimes // and (b) extract html comments via a regex is not actually possible to do 100% safely. // Instead, let the browser do the work for us- create an element out of this html but DO NOT ADD IT to the dom so it is never actually rendered. // Then just find all the scripts in that element. If any were inside comments then they will already be properly excluded. var temp = document.createElement(‘div’); temp.innerHTML = this; var scripts = temp.getElementsByTagName(‘script’); if (scripts.length > 0) { var rawScripts = []; for (var i=0;i</g,'<‘).replace(/>/g,’>’); } function unescapeHTML() { return this.stripTags().replace(/</g,'<‘).replace(/>/g,’>’).replace(/&/g,’&’); } function toQueryParams(separator) { var match = this.strip().match(/([^?#]*)(#.*)?$/); if (!match) return { }; return match[1].split(separator || ‘&’).inject({ }, function(hash, pair) { if ((pair = pair.split(‘=’))[0]) { var key = decodeURIComponent(pair.shift()), value = pair.length > 1 ? pair.join(‘=’) : pair[0]; if (value != undefined) value = decodeURIComponent(value); if (key in hash) { if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; hash[key].push(value); } else hash[key] = value; } return hash; }); } function toArray() { return this.split(”); } function succ() { return this.slice(0, this.length – 1) + String.fromCharCode(this.charCodeAt(this.length – 1) + 1); } function times(count) { return count < 1 ? ” : new Array(count + 1).join(this); } function camelize() { return this.replace(/-+(.)?/g, function(match, chr) { return chr ? chr.toUpperCase() : ”; }); } function capitalize() { return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); } function underscore() { return this.replace(/::/g, ‘/’) .replace(/([A-Z]+)([A-Z][a-z])/g, ‘$1_$2’) .replace(/([a-z\d])([A-Z])/g, ‘$1_$2’) .replace(/-/g, ‘_’) .toLowerCase(); } function dasherize() { return this.replace(/_/g, ‘-‘); } function inspect(useDoubleQuotes) { var escapedString = this.replace(/[\x00-\x1f\\]/g, function(character) { if (character in String.specialChar) { return String.specialChar[character]; } return ‘\\u00’ + character.charCodeAt().toPaddedString(2, 16); }); if (useDoubleQuotes) return ‘”‘ + escapedString.replace(/”/g, ‘\\”‘) + ‘”‘; return “‘” + escapedString.replace(/’/g, ‘\\\”) + “‘”; } function unfilterJSON(filter) { return this.replace(filter || Prototype.JSONFilter, ‘$1’); } function isJSON() { var str = this; if (str.blank()) return false; str = str.replace(/\\(?:[“\\\/bfnrt]|u[0-9a-fA-F]{4})/g, ‘@’); str = str.replace(/”[^”\\\n\r]*”|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ‘]’); str = str.replace(/(?:^|:|,)(?:\s*\[)+/g, ”); return (/^[\],:{}\s]*$/).test(str); } function evalJSON(sanitize) { var json = this.unfilterJSON(), cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; if (cx.test(json)) { json = json.replace(cx, function (a) { return ‘\\u’ + (‘0000’ + a.charCodeAt(0).toString(16)).slice(-4); }); } try { if (!sanitize || json.isJSON()) return eval(‘(‘ + json + ‘)’); } catch (e) { } throw new SyntaxError(‘Badly formed JSON string: ‘ + this.inspect()); } function parseJSON() { var json = this.unfilterJSON(); return JSON.parse(json); } function include(pattern) { return this.indexOf(pattern) > -1; } function startsWith(pattern) { return this.lastIndexOf(pattern, 0) === 0; } function endsWith(pattern) { var d = this.length – pattern.length; return d >= 0 && this.indexOf(pattern, d) === d; } function empty() { return this == ”; } function blank() { return /^\s*$/.test(this); } function interpolate(object, pattern) Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay
{ return new Template(this, pattern).evaluate(object); } return { gsub: gsub, sub: sub, scan: scan, truncate: truncate, strip: String.prototype.trim || strip, stripTags: stripTags, stripScripts: stripScripts, extractScripts: extractScripts, evalScripts: evalScripts, escapeHTML: escapeHTML, unescapeHTML: unescapeHTML, toQueryParams: toQueryParams, parseQuery: toQueryParams, toArray: toArray, succ: succ, times: times, camelize: camelize, capitalize: capitalize, underscore: underscore, dasherize: dasherize, inspect: inspect, unfilterJSON: unfilterJSON, isJSON: isJSON, evalJSON: NATIVE_JSON_PARSE_SUPPORT ? parseJSON : evalJSON, include: include, startsWith: startsWith, endsWith: endsWith, empty: empty, blank: blank, interpolate: interpolate }; })()); var Template = Class.create({ initialize: function(template, pattern) { this.template = template.toString(); this.pattern = pattern || Template.Pattern; }, evaluate: function(object) { if (object && Object.isFunction(object.toTemplateReplacements)) object = object.toTemplateReplacements(); return this.template.gsub(this.pattern, function(match) { if (object == null) return (match[1] + ”); var before = match[1] || ”; if (before == ‘\\’) return match[2]; var ctx = object, expr = match[3], pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; match = pattern.exec(expr); if (match == null) return before; while (match != null) { var comp = match[1].startsWith(‘[‘) ? match[2].replace(/\\\\]/g, ‘]’) : match[1]; ctx = ctx[comp]; if (null == ctx || ” == match[3]) break; expr = expr.substring(‘[‘ == match[3] ? match[1].length : match[0].length); match = pattern.exec(expr); } return before + String.interpret(ctx); }); } }); Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; var $break = { }; var Enumerable = (function() { function each(iterator, context) { var index = 0; try { this._each(function(value) { iterator.call(context, value, index++); }); } catch (e) { if (e != $break) throw e; } return this; } function eachSlice(number, iterator, context) { var index = -number, slices = [], array = this.toArray(); if (number < 1) return array; while ((index += number) < array.length) slices.push(array.slice(index, index+number)); return slices.collect(iterator, context); } function all(iterator, context) { iterator = iterator || Prototype.K; var result = true; this.each(function(value, index) { result = result && !!iterator.call(context, value, index); if (!result) throw $break; }); return result; } function any(iterator, context) { iterator = iterator || Prototype.K; var result = false; this.each(function(value, index) { if (result = !!iterator.call(context, value, index)) throw $break; }); return result; } function collect(iterator, context) { iterator = iterator || Prototype.K; var results = []; this.each(function(value, index) { results.push(iterator.call(context, value, index)); }); return results; } function detect(iterator, context) { var result; this.each(function(value, index) { if (iterator.call(context, value, index)) { result = value; throw $break; } }); return result; } function findAll(iterator, context) { var results = []; this.each(function(value, index) { if (iterator.call(context, value, index)) results.push(value); }); return results; } function grep(filter, iterator, context) { iterator = iterator || Prototype.K; var results = []; if (Object.isString(filter)) filter = new RegExp(RegExp.escape(filter)); this.each(function(value, index) { if (filter.match(value)) results.push(iterator.call(context, value, index)); }); return results; } function include(object) { if (Object.isFunction(this.indexOf)) if (this.indexOf(object) != -1) return true; var found = false; this.each(function(value) { if (value == object) { found = true; throw $break; } }); return found; } function inGroupsOf(number, fillWith) { fillWith = Object.isUndefined(fillWith) ? null : fillWith; return this.eachSlice(number, function(slice) { while(slice.length < number) slice.push(fillWith); return slice; }); } function inject(memo, iterator, context) { this.each(function(value, index) { memo = iterator.call(context, memo, value, index); }); return memo; } function invoke(method) { var args = $A(arguments).slice(1); return this.map(function(value) { return value[method].apply(value, args); }); } function max(iterator, context) { iterator = iterator || Prototype.K; var result; this.each(function(value, index) { value = iterator.call(context, value, index); if (result == null || value >= result) result = value; }); return result; } function min(iterator, context) { iterator = iterator || Prototype.K; var result; this.each(function(value, index) { value = iterator.call(context, value, index); if (result == null || value < result) result = value; }); return result; } function partition(iterator, context) { iterator = iterator || Prototype.K; var trues = [], falses = []; this.each(function(value, index) { (iterator.call(context, value, index) ? trues : falses).push(value); }); return [trues, falses]; } function pluck(property) { var results = []; this.each(function(value) { results.push(value[property]); }); return results; } function reject(iterator, context) { var results = []; this.each(function(value, index) { if (!iterator.call(context, value, index)) results.push(value); }); return results; } function sortBy(iterator, context) { return this.map(function(value, index) { return { value: value, criteria: iterator.call(context, value, index) }; }).sort(function(left, right) { var a = left.criteria, b = right.criteria; return a < b ? -1 : a > b ? 1 : 0; }).pluck(‘value’); } function toArray() { return this.map(); } function zip() { var iterator = Prototype.K, args = $A(arguments); if (Object.isFunction(args.last())) iterator = args.pop(); var collections = [this].concat(args).map($A); return this.map(function(value, index) { return iterator(collections.pluck(index)); }); } function size() { return this.toArray().length; } function inspect() { return ‘#’; } return { each: each, eachSlice: eachSlice, all: all, every: all, any: any, some: any, collect: collect, map: collect, detect: detect, findAll: findAll, select: findAll, filter: findAll, grep: grep, include: include, member: include, inGroupsOf: inGroupsOf, inject: inject, invoke: invoke, max: max, min: min, partition: partition, pluck: pluck, reject: reject, sortBy: sortBy, toArray: toArray, entries: toArray, zip: zip, size: size, inspect: inspect, find: detect }; })(); function $A(iterable) { if (!iterable) return []; if (‘toArray’ in Object(iterable)) return iterable.toArray(); var length = iterable.length || 0, results = new Array(length); while (length–) results[length] = iterable[length]; return results; } function $w(string) { if (!Object.isString(string)) return []; string = string.strip(); return string ? string.split(/\s+/) : []; } Array.from = $A; (function() { var arrayProto = Array.prototype, slice = arrayProto.slice, _each = arrayProto.forEach; // use native browser JS 1.6 implementation if available function each(iterator, context) { for (var i = 0, length = this.length >>> 0; i < length; i++) { if (i in this) iterator.call(context, this[i], i, this); } } if (!_each) _each = each; function clear() { this.length = 0; return this; } function first() { return this[0]; } function last() { return this[this.length – 1]; } function compact() { return this.select(function(value) { return value != null; }); } function flatten() { return this.inject([], function(array, value) { if (Object.isArray(value)) return array.concat(value.flatten()); array.push(value); return array; }); } function without() { var values = slice.call(arguments, 0); return this.select(function(value) { return !values.include(value); }); } function reverse(inline) { return (inline === false ? this.toArray() : this)._reverse(); } function uniq(sorted) { return this.inject([], function(array, value, index) { if (0 == index || (sorted ? array.last() != value : !array.include(value))) array.push(value); return array; }); } function intersect(array) { return this.uniq().findAll(function(item) { return array.detect(function(value) { return item === value }); }); } function clone() { return slice.call(this, 0); } function size() { return this.length; } function inspect() { return ‘[‘ + this.map(Object.inspect).join(‘, ‘) + ‘]’; } function indexOf(item, i) { i || (i = 0); var length = this.length; if (i < 0) i = length + i; for (; i < length; i++) if (this[i] === item) return i; return -1; } function lastIndexOf(item, i) { i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; var n = this.slice(0, i).reverse().indexOf(item); return (n < 0) ? n : i – n – 1; } function concat() { var array = slice.call(this, 0), item; for (var i = 0, length = arguments.length; i < length; i++) { item = arguments[i]; if (Object.isArray(item) && !(‘callee’ in item)) { for (var j = 0, arrayLength = item.length; j < arrayLength; j++) array.push(item[j]); } else { array.push(item); } } return array; } Object.extend(arrayProto, Enumerable); if (!arrayProto._reverse) arrayProto._reverse = arrayProto.reverse; Object.extend(arrayProto, { _each: _each, clear: clear, first: first, last: last, compact: compact, flatten: flatten, without: without, reverse: reverse, uniq: uniq, intersect: intersect, clone: clone, toArray: clone, size: size, inspect: inspect }); var CONCAT_ARGUMENTS_BUGGY = (function() { return [].concat(arguments)[0][0] !== 1; })(1,2) if (CONCAT_ARGUMENTS_BUGGY) arrayProto.concat = concat; if (!arrayProto.indexOf) arrayProto.indexOf = indexOf; if (!arrayProto.lastIndexOf) arrayProto.lastIndexOf = lastIndexOf; })(); function $H(object) { return new Hash(object); }; var Hash = Class.create(Enumerable, (function() { function initialize(object) { this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); } function _each(iterator) { for (var key in this._object) { var value = this._object[key], pair = [key, value]; pair.key = key; pair.value = value; iterator(pair); } } function set(key, value) { return this._object[key] = value; } function get(key) { if (this._object[key] !== Object.prototype[key]) return this._object[key]; } function unset(key) { var value = this._object[key]; delete this._object[key]; return value; } function toObject() { return Object.clone(this._object); } function keys() { return this.pluck(‘key’); } function values() { return this.pluck(‘value’); } function index(value) { var match = this.detect(function(pair) { return pair.value === value; }); return match && match.key; } function merge(object) { return this.clone().update(object); } function update(object) { return new Hash(object).inject(this, function(result, pair) { result.set(pair.key, pair.value); return result; }); } function toQueryPair(key, value) { if (Object.isUndefined(value)) return key; return key + ‘=’ + encodeURIComponent(String.interpret(value)); } function toQueryString() { return this.inject([], function(results, pair) { var key = encodeURIComponent(pair.key), values = pair.value; if (values && typeof values == ‘object’) { if (Object.isArray(values)) { var queryValues = []; for (var i = 0, len = values.length, value; i < len; i++) { value = values[i]; queryValues.push(toQueryPair(key, value)); } return results.concat(queryValues); } } else results.push(toQueryPair(key, values)); return results; }).join(‘&’); } function inspect() { return ‘#’; } function clone() { return new Hash(this); } return { initialize: initialize, _each: _each, set: set, get: get, unset: unset, toObject: toObject, toTemplateReplacements: toObject, keys: keys, values: values, index: index, merge: merge, update: update, toQueryString: toQueryString, inspect: inspect, toJSON: toObject, clone: clone }; })()); Hash.from = $H; Object.extend(Number.prototype, (function() { function toColorPart() { return this.toPaddedString(2, 16); } function succ() { return this + 1; } function times(iterator, context) { $R(0, this, true).each(iterator, context); return this; } function toPaddedString(length, radix) { var string = this.toString(radix || 10); return ‘0’.times(length – string.length) + string; } function abs() { return Math.abs(this); } function round() { return Math.round(this); } function ceil() { return Math.ceil(this); } function floor() { return Math.floor(this); } return { toColorPart: toColorPart, succ: succ, times: times, toPaddedString: toPaddedString, abs: abs, round: round, ceil: ceil, floor: floor }; })()); function $R(start, end, exclusive) { return new ObjectRange(start, end, exclusive); } var ObjectRange = Class.create(Enumerable, (function() { function initialize(start, end, exclusive) { this.start = start; this.end = end; this.exclusive = exclusive; } function _each(iterator) { var value = this.start; while (this.include(value)) { iterator(value); value = value.succ(); } } function include(value) { if (value < this.start) return false; if (this.exclusive) return value < this.end; return value <= this.end; } return { initialize: initialize, _each: _each, include: include }; })()); var Ajax = { getTransport: function() { return Try.these( function() {return new XMLHttpRequest()}, function() {return new ActiveXObject(‘Msxml2.XMLHTTP’)}, function() {return new ActiveXObject(‘Microsoft.XMLHTTP’)} ) || false; }, activeRequestCount: 0 }; Ajax.Responders = { responders: [], _each: function(iterator) { this.responders._each(iterator); }, register: function(responder) { if (!this.include(responder)) this.responders.push(responder); }, unregister: function(responder) { this.responders = this.responders.without(responder); }, dispatch: function(callback, request, transport, json Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay
{ this.each(function(responder) { if (Object.isFunction(responder[callback])) { try { responder[callback].apply(responder, [request, transport, json]); } catch (e) { } } }); }, hasResponder: function( callback ) { this.each(function(responder) { if (Object.isFunction(responder[callback])) { return true; } }); return false; } }; Object.extend(Ajax.Responders, Enumerable); Ajax.Responders.register({ onCreate: function() { Ajax.activeRequestCount++ }, onComplete: function() { Ajax.activeRequestCount– } }); Ajax.Base = Class.create({ initialize: function(options) { this.options = { method: ‘post’, asynchronous: true, contentType: ‘application/x-www-form-urlencoded’, encoding: ‘UTF-8’, parameters: ”, evalJSON: true, evalJS: true }; Object.extend(this.options, options || { }); this.options.method = this.options.method.toLowerCase(); if (Object.isHash(this.options.parameters)) this.options.parameters = this.options.parameters.toObject(); } }); Ajax.Request = Class.create(Ajax.Base, { _complete: false, initialize: function($super, url, options) { $super(options); this.transport = Ajax.getTransport(); this.request(url); }, request: function(url) { this.url = url; this.method = this.options.method; var params = Object.isString(this.options.parameters) ? this.options.parameters : Object.toQueryString(this.options.parameters); if (![‘get’, ‘post’].include(this.method)) { params += (params ? ‘&’ : ”) + “_method=” + this.method; this.method = ‘post’; } if (params && this.method === ‘get’) { this.url += (this.url.include(‘?’) ? ‘&’ : ‘?’) + params; } this.parameters = params.toQueryParams(); try { var response = new Ajax.Response(this); if (this.options.onCreate) this.options.onCreate(response); Ajax.Responders.dispatch(‘onCreate’, this, response); this.transport.open(this.method.toUpperCase(), this.url, this.options.asynchronous); if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); this.transport.onreadystatechange = this.onStateChange.bind(this); this.setRequestHeaders(); this.body = this.method == ‘post’ ? (this.options.postBody || params) : null; this.transport.send(this.body); /* Force Firefox to handle ready state 4 for synchronous requests */ if (!this.options.asynchronous && this.transport.overrideMimeType) this.onStateChange(); } catch (e) { this.dispatchException(e); } }, onStateChange: function() { var readyState = this.transport.readyState; if (readyState > 1 && !((readyState == 4) && this._complete)) this.respondToReadyState(this.transport.readyState); }, setRequestHeaders: function() { var headers = { ‘X-Requested-With’: ‘XMLHttpRequest’, ‘X-Prototype-Version’: Prototype.Version, ‘Accept’: ‘text/javascript, text/html, application/xml, text/xml, */*’ }; if (this.method == ‘post’) { headers[‘Content-type’] = this.options.contentType + (this.options.encoding ? ‘; charset=’ + this.options.encoding : ”); /* Force “Connection: close” for older Mozilla browsers to work * around a bug where XMLHttpRequest sends an incorrect * Content-length header. See Mozilla Bugzilla #246651. */ if (this.transport.overrideMimeType && (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) headers[‘Connection’] = ‘close’; } if (typeof this.options.requestHeaders == ‘object’) { var extras = this.options.requestHeaders; if (Object.isFunction(extras.push)) for (var i = 0, length = extras.length; i < length; i += 2) headers[extras[i]] = extras[i+1]; else $H(extras).each(function(pair) { headers[pair.key] = pair.value }); } for (var name in headers) this.transport.setRequestHeader(name, headers[name]); }, success: function() { var status = this.getStatus(); return !status || (status >= 200 && status < 300) || status == 304; }, getStatus: function() { try { if (this.transport.status === 1223) return 204; return this.transport.status || 0; } catch (e) { return 0 } }, respondToReadyState: function(readyState) { var state = Ajax.Request.Events[readyState]; // quite a high number of Interactive events can be generated on some browsers // triggering a memory issue in FF3 when building the response object. So if there is no // registered listener, quick return // see https://bugzilla.mozilla.org/show_bug.cgi?id=453709 if ( state == ‘Interactive’ ) { if ( this.notListeningToInteractive ) { if ( this.notListeningToInteractive.value ) return; } else { this.notListeningToInteractive = new Object(); this.notListeningToInteractive.value = ( !this.options[‘onInteractive’] && !Ajax.Responders.hasResponder( state ) ); if ( this.notListeningToInteractive.value ) return; } } var response = new Ajax.Response(this); if (state == ‘Complete’) { try { this._complete = true; (this.options[‘on’ + response.status] || this.options[‘on’ + (this.success() ? ‘Success’ : ‘Failure’)] || Prototype.emptyFunction)(response, response.headerJSON); } catch (e) { this.dispatchException(e); } var contentType = response.getHeader(‘Content-type’); if (this.options.evalJS == ‘force’ || (this.options.evalJS && this.isSameOrigin() && contentType && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) this.evalResponse(); } try { (this.options[‘on’ + state] || Prototype.emptyFunction)(response, response.headerJSON); Ajax.Responders.dispatch(‘on’ + state, this, response, response.headerJSON); } catch (e) { this.dispatchException(e); } if (state == ‘Complete’) { this.transport.onreadystatechange = Prototype.emptyFunction; } }, isSameOrigin: function() { var m = this.url.match(/^\s*https?:\/\/[^\/]*/); return !m || (m[0] == ‘#{protocol}//#{domain}#{port}’.interpolate({ protocol: location.protocol, domain: document.domain, port: location.port ? ‘:’ + location.port : ” })); }, getHeader: function(name) { try { return this.transport.getResponseHeader(name) || null; } catch (e) { return null; } }, evalResponse: function() { try { return eval((this.transport.responseText || ”).unfilterJSON()); } catch (e) { this.dispatchException(e); } }, dispatchException: function(exception) { (this.options.onException || Prototype.emptyFunction)(this, exception); Ajax.Responders.dispatch(‘onException’, this, exception); } }); Ajax.Request.Events = [‘Uninitialized’, ‘Loading’, ‘Loaded’, ‘Interactive’, ‘Complete’]; Ajax.Response = Class.create({ initialize: function(request){ this.request = request; var transport = this.transport = request.transport, readyState = this.readyState = transport.readyState; if ((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { this.status = this.getStatus(); this.statusText = this.getStatusText(); this.responseText = String.interpret(transport.responseText); this.headerJSON = this._getHeaderJSON(); } if (readyState == 4) { var xml = transport.responseXML; this.responseXML = Object.isUndefined(xml) ? null : xml; this.responseJSON = this._getResponseJSON(); } }, status: 0, statusText: ”, getStatus: Ajax.Request.prototype.getStatus, getStatusText: function() { try { return this.transport.statusText || ”; } catch (e) { return ” } }, getHeader: Ajax.Request.prototype.getHeader, getAllHeaders: function() { try { return this.getAllResponseHeaders(); } catch (e) { return null } }, getResponseHeader: function(name) { return this.transport.getResponseHeader(name); }, getAllResponseHeaders: function() { return this.transport.getAllResponseHeaders(); }, _getHeaderJSON: function() { var json = this.getHeader(‘X-JSON’); if (!json) return null; json = decodeURIComponent(escape(json)); try { return json.evalJSON(this.request.options.sanitizeJSON || !this.request.isSameOrigin()); } catch (e) { this.request.dispatchException(e); } }, _getResponseJSON: function() { var options = this.request.options; if (!options.evalJSON || (options.evalJSON != ‘force’ && !(this.getHeader(‘Content-type’) || ”).include(‘application/json’)) || this.responseText.blank()) return null; try { return this.responseText.evalJSON(options.sanitizeJSON || !this.request.isSameOrigin()); } catch (e) { this.request.dispatchException(e); } } }); Ajax.Updater = Class.create(Ajax.Request, { initialize: function($super, container, url, options) { this.container = { success: (container.success || container), failure: (container.failure || (container.success ? null : container)) }; options = Object.clone(options); var onComplete = options.onComplete; options.onComplete = (function(response, json) { this.updateContent(response.responseText); if (Object.isFunction(onComplete)) onComplete(response, json); }).bind(this); $super(url, options); }, updateContent: function(responseText) { var receiver = this.container[this.success() ? ‘success’ : ‘failure’], options = this.options; if (!options.evalScripts) responseText = responseText.stripScripts(); if (receiver = $(receiver)) { if (options.insertion) { if (Object.isString(options.insertion)) { var insertion = { }; insertion[options.insertion] = responseText; receiver.insert(insertion); } else options.insertion(receiver, responseText); } else receiver.update(responseText); } } }); Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { initialize: function($super, container, url, options) { $super(options); this.onComplete = this.options.onComplete; this.frequency = (this.options.frequency || 2); this.decay = (this.options.decay || 1); this.updater = { }; this.container = container; this.url = url; this.start(); }, start: function() { this.options.onComplete = this.updateComplete.bind(this); this.onTimerEvent(); }, stop: function() { this.updater.options.onComplete = undefined; clearTimeout(this.timer); (this.onComplete || Prototype.emptyFunction).apply(this, arguments); }, updateComplete: function(response) { if (this.options.decay) { this.decay = (response.responseText == this.lastText ? this.decay * this.options.decay : 1); this.lastText = response.responseText; } this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); }, onTimerEvent: function() { this.updater = new Ajax.Updater(this.container, this.url, this.options); } }); function $s(element) { if (Object.isString(element)) { return document.getElementById(element); } return element; } function $(element) { if (arguments.length > 1) { for (var i = 0, elements = [], length = arguments.length; i < length; i++) elements.push($(arguments[i])); return elements; } if (Object.isString(element)) element = document.getElementById(element); return Element.extend(element); } if (Prototype.BrowserFeatures.XPath) { document._getElementsByXPath = function(expression, parentElement) { var results = []; var query = document.evaluate(expression, $(parentElement) || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0, length = query.snapshotLength; i < length; i++) results.push(Element.extend(query.snapshotItem(i))); return results; }; } /*————————————————————————–*/ if (!Node) var Node = { }; if (!Node.ELEMENT_NODE) { Object.extend(Node, { ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5, ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12 }); } (function(global) { function shouldUseCache(tagName, attributes) { if (tagName === ‘select’) return false; if (‘type’ in attributes) return false; return true; } var HAS_EXTENDED_CREATE_ELEMENT_SYNTAX = (function(){ try { var el = document.createElement(‘ ‘); return el.tagName.toLowerCase() === ‘input’ && el.name === ‘x’; } catch(err) { return false; } })(); var element = global.Element; global.Element = function(tagName, attributes) { attributes = attributes || { }; tagName = tagName.toLowerCase(); var cache = Element.cache; if (HAS_EXTENDED_CREATE_ELEMENT_SYNTAX && attributes.name) { tagName = ‘<‘ + tagName + ‘ name=”‘ + attributes.name + ‘”>’; delete attributes.name; return Element.writeAttribute(document.createElement(tagName), attributes); } if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName)); var node = shouldUseCache(tagName, attributes) ? cache[tagName].cloneNode(false) : document.createElement(tagName); return Element.writeAttribute(node, attributes); }; Object.extend(global.Element, element || { }); if (element) global.Element.prototype = element.prototype; })(this); Element.idCounter = 1; Element.cache = { }; Element._purgeElement = function(element) { var uid = element._prototypeUID; if (uid) { Element.stopObserving(element); element._prototypeUID = void 0; delete Element.Storage[uid]; } } Element.Methods = { visible: function(element) { return $(element).style.display != ‘none’; }, toggle: function(element) { element = $(element); Element[Element.visible(element) ? ‘hide’ : ‘show’](element); return element; }, hide: function(element) { element = $(element); element.style.display = ‘none’; return element; }, show: function(element) { element = $(element); element.style.display = ”; return element; }, // only extend the element if it is a string – otherwise we don’t need to extend the element remove: function(element) { if (Object.isString(element)) { element = $(element); } if (element.parentNode) { element.parentNode.removeChild(element); } return element; }, update: (function(){ var SELECT_ELEMENT_INNERHTML_BUGGY = (function(){ var el = document.createElement(“select”), isBuggy = true; el.innerHTML = “test”; if (el.options && el.options[0]) { isBuggy = el.options[0].nodeName.toUpperCase() !== “OPTION”; } el = null; return isBuggy; })(); var TABLE_ELEMENT_INNERHTML_BUGGY = (function(){ try { var el = document.createElement(“table”); if (el && el.tBodies) { el.innerHTML = “test”; var isBuggy = typeof el.tBodies[0] == “undefined”; el = null; return isBuggy; } } catch (e) { return true; } })(); var LINK_ELEMENT_INNERHTML_BUGGY = (function() { try { var el = document.createElement(‘div’); el.innerHTML = “”; var isBuggy = (el.childNodes.length === 0); el = null; return isBuggy; } catch(e) { return true; } })(); var ANY_INNERHTML_BUGGY = SELECT_ELEMENT_INNERHTML_BUGGY || TABLE_ELEMENT_INNERHTML_BUGGY || LINK_ELEMENT_INNERHTML_BUGGY; var SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING = (function () { var s = document.createElement(“script”), isBuggy = false; try { s.appendChild(document.createTextNode(“”)); isBuggy = !s.firstChild || s.firstChild && s.firstChild.nodeType !== 3; } catch (e) { isBuggy = true; } s = null; return isBuggy; })(); function update(element, content) { element = $(element); var purgeElement = Element._purgeElement; var descendants = element.getElementsByTagName(‘*’), i = descendants.length; while (i–) purgeElement(descendants[i]); if (content && content.toElement) content = content.toElement(); if (Object.isElement(content)) return element.update().insert(content); content = Object.toHTML(content); var tagName = element.tagName.toUpperCase(); if (tagName === ‘SCRIPT’ && SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING) { element.text = content; return element; } if (ANY_INNERHTML_BUGGY) { if (tagName in Element._insertionTranslations.tags) { while (element.firstChild) { element.removeChild(element.firstChild); } Element._getContentFromAnonymousElement(tagName, content.stripScripts()) .each(function(node) { element.appendChild(node) }); } else if (LINK_ELEMENT_INNERHTML_BUGGY && Object.isString(content) && content.indexOf(‘ -1) { while (element.firstChild) { element.removeChild(element.firstChild); } var nodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts(), true); nodes.each(function(node) { element.appendChild(node) }); } else { element.innerHTML = content.stripScripts(); } } else { element.innerHTML = content.stripScripts(); } content.evalScripts.bind(content).defer(); return element; } return update; })(), replace: function(element, content) { element = $(element); if (content && content.toElement) content = content.toElement(); else if (!Object.isElement(content)) { content = Object.toHTML(content); var range = element.ownerDocument.createRange(); range.selectNode(element); content.evalScripts.bind(content).defer(); content = range.createContextualFragment(content.stripScripts()); } element.parentNode.replaceChild(content, element); return element; }, insert: function(element, insertions) { element = $(element); if (Object.isString(insertions) || Object.isNumber(insertions) || Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) insertions = {bottom:insertions}; var content, insert, tagName, childNodes; for (var position in insertions) { content = insertions[position]; position = position.toLowerCase(); insert = Element._insertionTranslations[position]; if (content && content.toElement) content = content.toElement(); if (Object.isElement(content)) { insert(element, content); continue; } content = Object.toHTML(content); tagName = ((position == ‘before’ || position == ‘after’) ? element.parentNode : element).tagName.toUpperCase(); childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); if (position == ‘top’ || position == ‘after’) childNodes.reverse(); childNodes.each(insert.curry(element)); content.evalScripts.bind(content).defer(); } return element; }, wrap: function(element, wrapper, attributes) { element = $(element); if (Object.isElement(wrapper)) $(wrapper).writeAttribute(attributes || { }); else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes); else wrapper = new Element(‘div’, wrapper); if (element.parentNode) element.parentNode.replaceChild(wrapper, element); wrapper.appendChild(element); return wrapper; }, inspect: function(element) { element = $(element); var result = ‘<‘ + element.tagName.toLowerCase(); $H({‘id’: ‘id’, ‘className’: ‘class’}).each(function(pair) { var property = pair.first(), attribute = pair.last(), value = (element[property] || ”).toString(); if (value) result += ‘ ‘ + attribute + ‘=’ + value.inspect(true); }); return result + ‘>’; }, recursivelyCollect: function(element, property, maximumLength) { element = $(element); maximumLength = maximumLength || -1; var elements = []; while (element = element[property]) { if (element.nodeType == 1) elements.push(Element.extend(element)); if (elements.length == maximumLength) break; } return elements; }, // Collect items without extending them all: rawRecursivelyCollect: function(element, property) { element = $(element); var elements = []; while (element = element[property]) if (element.nodeType == 1) { elements.push(element); } return elements; }, ancestors: function(element) { return Element.recursivelyCollect(element, ‘parentNode’); }, descendants: function(element) { return Element.select(element, “*”); }, firstDescendant: function(element) { element = $(element).firstChild; while (element && element.nodeType != 1) element = element.nextSibling; return $(element); }, immediateDescendants: function(element) { var results = [], child = $(element).firstChild; while (child) { if (child.nodeType === 1) { results.push(Element.extend(child)); } child = child.nextSibling; } return results; }, // Find the immediate descendents of the given element without extending them all rawImmediateDescendants: function(element) { if (!(element = $(element).firstChild)) return []; while (element && element.nodeType != 1) element = element.nextSibling; if (element) return [element].concat($(element).rawNextSiblings()); return []; }, previousSiblings: function(element, maximumLength) { return Element.recursivelyCollect(element, ‘previousSibling’); }, nextSiblings: function(element) { return Element.recursivelyCollect(element, ‘nextSibling’); }, // Find the next siblings without actually extending them all rawNextSiblings: function(element) { return $(element).rawRecursivelyCollect(‘nextSibling’); }, siblings: function(element) { element = $(element); return Element.previousSiblings(element).reverse() .concat(Element.nextSiblings(element)); }, match: function(element, selector) { element = $(element); if (Object.isString(selector)) return Prototype.Selector.match(element, selector); return selector.match(element); }, up: function(element, expression, index) { element = $(element); if (arguments.length == 1) return $(element.parentNode); var ancestors = Element.ancestors(element); return Object.isNumber(expression) ? ancestors[expression] : Prototype.Selector.find(ancestors, expression, index); }, down: function(element, expression, index) { element = $(element); if (arguments.length == 1) return Element.firstDescendant(element); return Object.isNumber(expression) ? Element.descendants(element)[expression] : Element.select(element, expression)[index || 0]; }, previous: function(element, expression, index) { element = $(element); if (Object.isNumber(expression)) index = expression, expression = false; if (!Object.isNumber(index)) index = 0; if (expression) { return Prototype.Selector.find(element.previousSiblings(), expression, index); } else { return element.recursivelyCollect(“previousSibling”, index + 1)[index]; } }, next: function(element, expression, index) { element = $(element); if (Object.isNumber(expression)) index = expression, expression = false; if (!Object.isNumber(index)) index = 0; if (expression) { return Prototype.Selector.find(element.nextSiblings(), expression, index); } else { var maximumLength = Object.isNumber(index) ? index + 1 : 1; return element.recursivelyCollect(“nextSibling”, index + 1)[index]; } }, select: function(element) { element = $(element); var expressions = Array.prototype.slice.call(arguments, 1).join(‘, ‘); return Prototype.Selector.select(expressions, element); }, adjacent: function(element) { element = $(element); var expressions = Array.prototype.slice.call(arguments, 1).join(‘, ‘); return Prototype.Selector.select(expressions, element.parentNode).without(element); }, identify: function(element) { element = $(element); var id = Element.readAttribute(element, ‘id’); if (id) return id; do { id = ‘anonymous_element_’ + Element.idCounter++ } while ($(id)); Element.writeAttribute(element, ‘id’, id); return id; }, readAttribute: function(element, name) { element = $(element); if (Prototype.Browser.IE) { var t = Element._attributeTranslations.read; if (t.values[name]) return t.values[name](element, name); if (t.names[name]) name = t.names[name]; if (name.include(‘:’)) { return (!element.attributes || !element.attributes[name]) ? null : element.attributes[name].value; } } return element.getAttribute(name); }, writeAttribute: function(element, name, value) { element = $(element); var attributes = { }, t = Element._attributeTranslations.write; if (typeof name == ‘object’) attributes = name; else attributes[name] = Object.isUndefined(value) ? true : value; for (var attr in attributes) { name = t.names[attr] || attr; value = attributes[attr]; if (t.values[attr]) name = t.values[attr](element, value); if (value === false || value === null) element.removeAttribute(name); else if (value === true) element.setAttribute(name, name); else element.setAttribute(name, value); } return element; }, getHeight: function(element) { return Element.getDimensions(element).height; }, getWidth: function(element) { return Element.getDimensions(element).width; }, classNames: function(element) { return new Element.ClassNames(element); }, hasClassName: function(element, className) { if (!(element = $(element))) return; var elementClassName = element.className; return (elementClassName.length > 0 && (elementClassName == className || new RegExp(“(^|\\s)” + className + “(\\s|$)”).test(elementClassName))); }, addClassName: function(element, className) { if (!(element = $(element))) return; if (!Element.hasClassName(element, className)) element.className += (element.className ? ‘ ‘ : ”) + className; return element; }, removeClassName: function(element, className) { if (!(element = $(element))) return; element.className = element.className.replace( new RegExp(“(^|\\s+)” + className + “(\\s+|$)”), ‘ ‘).strip(); return element; }, toggleClassName: function(element, className) { if (!(element = $(element))) return; return Element[Element.hasClassName(element, className) ? ‘removeClassName’ : ‘addClassName’](element, className); }, cleanWhitespace: function(element) { element = $s(element); var node = element.firstChild; while (node) { var nextNode = node.nextSibling; if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) element.removeChild(node); node = nextNode; } return element; }, empty: function(element) { return $(element).innerHTML.blank(); }, descendantOf: function(element, ancestor) { element = $(element), ancestor = $(ancestor); if (element.compareDocumentPosition) return (element.compareDocumentPosition(ancestor) & 8) === 8; if (ancestor.contains) return ancestor.contains(element) && ancestor !== element; while (element = element.parentNode) if (element == ancestor) return true; return false; }, scrollTo: function(element) { element = $(element); var pos = Element.cumulativeOffset(element); window.scrollTo(pos[0], pos[1]); return element; }, getStyle: function(element, style) { element = $(element); style = style == ‘float’ ? ‘cssFloat’ : style.camelize(); var value = element.style[style]; if (!value || value == ‘auto’) { var css = document.defaultView.getComputedStyle(element, null); value = css ? css[style] : null; } if (style == ‘opacity’) return value ? parseFloat(value) : 1.0; return value == ‘auto’ ? null : value; }, getOpacity: function(element) { return $(element).getStyle(‘opacity’); }, setStyle: function(element, styles) { element = $(element); var elementStyle = element.style, match; if (Object.isString(styles)) { element.style.cssText += ‘;’ + styles; return styles.include(‘opacity’) ? element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element; } for (var property in styles) if (property == ‘opacity’) element.setOpacity(styles[property]); else elementStyle[(property == ‘float’ || property == ‘cssFloat’) ? (Object.isUndefined(elementStyle.styleFloat) ? ‘cssFloat’ : ‘styleFloat’) : property] = styles[property]; return element; }, setOpacity: function(element, value) { element = $(element); element.style.opacity = (value == 1 || value === ”) ? ” : (value < 0.00001) ? 0 : value; return element; }, makePositioned: function(element) { element = $s(element); var pos = Element.getStyle(element, ‘position’); if (pos == ‘static’ || !pos) { element._madePositioned = true; element.style.position = ‘relative’; if (Prototype.Browser.Opera) { element.style.top = 0; element.style.left = 0; } } return element; }, undoPositioned: function(element) { element = $(element); if (element._madePositioned) { element._madePositioned = undefined; element.style.position = element.style.top = element.style.left = element.style.bottom = element.style.right = ”; } return element; }, makeClipping: function(element) { element = $(element); if (element._overflow) return element; element._overflow = Element.getStyle(element, ‘overflow’) || ‘auto’; if (element._overflow !== ‘hidden’) element.style.overflow = ‘hidden’; return element; }, undoClipping: function(element) { element = $(element); if (!element._overflow) return element; element.style.overflow = element._overflow == ‘auto’ ? ” : element._overflow; element._overflow = null; return element; }, clonePosition: function(element, source) { var options = Object.extend({ setLeft: true, setTop: true, setWidth: true, setHeight: true, offsetTop: 0, offsetLeft: 0 }, arguments[2] || { }); source = $(source); var p = Element.viewportOffset(source), delta = [0, 0], parent = null; element = $(element); if (Element.getStyle(element, ‘position’) == ‘absolute’) { parent = Element.getOffsetParent(element); delta = Element.viewportOffset(parent); } if (parent == document.body) { delta[0] -= document.body.offsetLeft; delta[1] -= document.body.offsetTop; } if (options.setLeft) element.style.left = (p[0] – delta[0] + options.offsetLeft) + ‘px’; if (options.setTop) element.style.top = (p[1] – delta[1] + options.offsetTop) + ‘px’; if (options.setWidth) element.style.width = source.offsetWidth + ‘px’; if (options.setHeight) element.style.height = source.offsetHeight + ‘px’; return element; } }; Object.extend(Element.Methods, { getElementsBySelector: Element.Methods.select, childElements: Element.Methods.immediateDescendants }); Element._attributeTranslations = { write: { names: { className: ‘class’, htmlFor: ‘for’ }, values: { } } }; if (Prototype.Browser.Opera) { Element.Methods.getStyle = Element.Methods.getStyle.wrap( function(proceed, element, style) { switch (style) { case ‘height’: case ‘width’: if (!Element.visible(element)) return null; var dim = parseInt(proceed(element, style), 10); if (dim !== element[‘offset’ + style.capitalize()]) return dim + ‘px’; var properties; if (style === ‘height’) { properties = [‘border-top-width’, ‘padding-top’, ‘padding-bottom’, ‘border-bottom-width’]; } else { properties = [‘border-left-width’, ‘padding-left’, ‘padding-right’, ‘border-right-width’]; } return properties.inject(dim, function(memo, property) { var val = proceed(element, property); return val === null ? memo : memo – parseInt(val, 10); }) + ‘px’; default: return proceed(element, style); } } ); Element.Methods.readAttribute = Element.Methods.readAttribute.wrap( function(proceed, element, attribute) { if (attribute === ‘title’) return element.title; return proceed(element, attribute); } ); } else if (Prototype.Browser.IE) { Element.Methods.getStyle = function(element, style) { element = $(element); style = (style == ‘float’ || style == ‘cssFloat’) ? ‘styleFloat’ : style.camelize(); var value = element.style[style]; if (!value && element.currentStyle) value = element.currentStyle[style]; if (style == ‘opacity’) { if (value = (element.getStyle(‘filter’) || ”).match(/alpha\(opacity=(.*)\)/)) if (value[1]) return parseFloat(value[1]) / 100; return 1.0; } if (value == ‘auto’) { if ((style == ‘width’ || style == ‘height’) && (element.getStyle(‘display’) != ‘none’)) return element[‘offset’ + style.capitalize()] + ‘px’; return null; } return value; }; Element.Methods.setOpacity = function(element, value) { function stripAlpha(filter){ return filter.replace(/alpha\([^\)]*\)/gi,”); } element = $(element); var currentStyle = element.currentStyle; if ((currentStyle && !currentStyle.hasLayout) || (!currentStyle && element.style.zoom == ‘normal’)) element.style.zoom = 1; var filter = element.getStyle(‘filter’), style = element.style; if (value == 1 || value === ”) { (filter = stripAlpha(filter)) ? style.filter = filter : style.removeAttribute(‘filter’); return element; } else if (value < 0.00001) value = 0; style.filter = stripAlpha(filter) + ‘alpha(opacity=’ + (value * 100) + ‘)’; return element; }; Element._attributeTranslations = (function(){ var classProp = ‘className’, forProp = ‘for’, el = document.createElement(‘div’); el.setAttribute(classProp, ‘x’); if (el.className !== ‘x’) { el.setAttribute(‘class’, ‘x’); if (el.className === ‘x’) { classProp = ‘class’; } } el = null; el = document.createElement(‘label’); el.setAttribute(forProp, ‘x’); if (el.htmlFor !== ‘x’) { el.setAttribute(‘htmlFor’, ‘x’); if (el.htmlFor === ‘x’) { forProp = ‘htmlFor’; } } el = null; return { read: { names: { ‘class’: classProp, ‘className’: classProp, ‘for’: forProp, ‘htmlFor’: forProp }, values: { _getAttr: function(element, attribute) { return element.getAttribute(attribute); }, _getAttr2: function(element, attribute) { return element.getAttribute(attribute, 2); }, _getAttrNode: function(element, attribute) { var node = element.getAttributeNode(attribute); return node ? node.value : “”; }, _getEv: (function(){ var el = document.createElement(‘div’), f; el.onclick = Prototype.emptyFunction; var value = el.getAttribute(‘onclick’); if (String(value).indexOf(‘{‘) > -1) { f = function(element, attribute) { attribute = element.getAttribute(attribute); if (!attribute) return null; attribute = attribute.toString(); attribute = attribute.split(‘{‘)[1]; attribute = attribute.split(‘}’)[0]; return attribute.strip(); }; } else if (value === ”) { f = function(element, attribute) { attribute = element.getAttribute(attribute); if (!attribute) return null; return attribute.strip(); }; } el = null; return f; })(), _flag: function(element, attribute) { return $(element).hasAttribute(attribute) ? attribute : null; }, style: function(element) { return element.style.cssText.toLowerCase(); }, title: function(element) { return element.title; } } } } })(); Element._attributeTranslations.write = { names: Object.extend({ cellpadding: ‘cellPadding’, cellspacing: ‘cellSpacing’ }, Element._attributeTranslations.read.names), values: { checked: function(element, value) { element.checked = !!value; }, style: function(element, value) { element.style.cssText = value ? value : ”; } } }; Element._attributeTranslations.has = {}; $w(‘colSpan rowSpan vAlign dateTime accessKey tabIndex ‘ + ‘encType maxLength readOnly longDesc frameBorder’).each(function(attr) { Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; Element._attributeTranslations.has[attr.toLowerCase()] = attr; }); (function(v) { Object.extend(v, { href: v._getAttr2, src: v._getAttr2, type: v._getAttr, action: v._getAttrNode, disabled: v._flag, checked: v._flag, readonly: v._flag, multiple: v._flag, onload: v._getEv, onunload: v._getEv, onclick: v._getEv, ondblclick: v._getEv, onmousedown: v._getEv, onmouseup: v._getEv, onmouseover: v._getEv, onmousemove: v._getEv, onmouseout: v._getEv, onfocus: v._getEv, onblur: v._getEv, onkeypress: v._getEv, onkeydown: v._getEv, onkeyup: v._getEv, onsubmit: v._getEv, onreset: v._getEv, onselect: v._getEv, onchange: v._getEv }); })(Element._attributeTranslations.read.values); if (Prototype.BrowserFeatures.ElementExtensions) { (function() { function _descendants(element) { var nodes = element.getElementsByTagName(‘*’), results = []; for (var i = 0, node; node = nodes[i]; i++) if (node.tagName !== “!”) // Filter out comment nodes. results.push(node); return results; } Element.Methods.down = function(element, expression, index) { element = $(element); if (arguments.length == 1) return element.firstDescendant(); return Object.isNumber(expression) ? _descendants(element)[expression] : Element.select(element, expression)[index || 0]; } })(); } } else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) { Element.Methods.setOpacity = function(element, value) { element = $(element); element.style.opacity = (value == 1) ? 0.999999 : (value === ”) ? ” : (value < 0.00001) ? 0 : value; return element; }; } else if (Prototype.Browser.WebKit) { Element.Methods.setOpacity = function(element, value) { element = $(element); element.style.opacity = (value == 1 || value === ”) ? ” : (value < 0.00001) ? 0 : value; if (value == 1) if (element.tagName.toUpperCase() == ‘IMG’ && element.width) { element.width++; element.width–; } else try { var n = document.createTextNode(‘ ‘); element.appendChild(n); element.removeChild(n); } catch (e) { } return element; }; } if (‘outerHTML’ in document.documentElement) { Element.Methods.replace = function(element, content) { element = $(element); if (content && content.toElement) content = content.toElement(); if (Object.isElement(content)) { element.parentNode.replaceChild(content, element); return element; } content = Object.toHTML(content); var parent = element.parentNode, tagName = parent.tagName.toUpperCase(); if (Element._insertionTranslations.tags[tagName]) { var nextSibling = element.next(), fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); parent.removeChild(element); if (nextSibling) fragments.each(function(node) { parent.insertBefore(node, nextSibling) }); else fragments.each(function(node) { parent.appendChild(node) }); } else element.outerHTML = content.stripScripts(); content.evalScripts.bind(content).defer(); return element; }; } Element._returnOffset = function(l, t) { var result = [l, t]; result.left = l; result.top = t; return result; }; Element._getContentFromAnonymousElement = function(tagName, html, force) { var div = new Element(‘div’), t = Element._insertionTranslations.tags[tagName]; var workaround = false; if (t) workaround = true; else if (force) { workaround = true; t = [”, ”, 0]; } if (workaround) { div.innerHTML = ‘ ‘ + t[0] + html + t[1]; div.removeChild(div.firstChild); for (var i = t[2]; i–; ) { div = div.firstChild; } } else { div.innerHTML = html; } return $A(div.childNodes); }; Element._insertionTranslations = { before: function(element, node) { element.parentNode.insertBefore(node, element); }, top: function(element, node) { element.insertBefore(node, element.firstChild); }, bottom: function(element, node) { element.appendChild(node); }, after: function(element, node) { element.parentNode.insertBefore(node, element.nextSibling); }, tags: { TABLE: [‘
‘, ‘
‘, 1], TBODY: [‘
‘, ‘
‘, 2], TR: [‘
‘, ‘
‘, 3], TD: [‘
‘, ‘
‘, 4], SELECT: [‘ ‘, 1] } }; (function() { var tags = Element._insertionTranslations.tags; Object.extend(tags, { THEAD: tags.TBODY, TFOOT: tags.TBODY, TH: tags.TD }); })(); Element.Methods.Simulated = { hasAttribute: function(element, attribute) { attribute = Element._attributeTranslations.has[attribute] || attribute; var node = $(element).getAttributeNode(attribute); return !!(node && node.specified); } }; Element.Methods.ByTag = { }; Object.extend(Element, Element.Methods); (function(div) { if (!Prototype.BrowserFeatures.ElementExtensions && div[‘__proto__’]) { window.HTMLElement = { }; window.HTMLElement.prototype = div[‘__proto__’]; Prototype.BrowserFeatures.ElementExtensions = true; } div = null; })(document.createElement(‘div’)); Element.extend = (function() { function checkDeficiency(tagName) { if (typeof window.Element != ‘undefined’) { var proto = window.Element.prototype; if (proto) { var id = ‘_’ + (Math.random()+”).slice(2), el = document.createElement(tagName); proto[id] = ‘x’; var isBuggy = (el[id] !== ‘x’); delete proto[id]; el = null; return isBuggy; } } return false; } function extendElementWith(element, methods) { for (var property in methods) { var value = methods[property]; if (Object.isFunction(value) && !(property in element)) element[property] = value.methodize(); } } var HTMLOBJECTELEMENT_PROTOTYPE_BUGGY = checkDeficiency(‘object’); if (Prototype.BrowserFeatures.SpecificElementExtensions) { if (HTMLOBJECTELEMENT_PROTOTYPE_BUGGY) { return function(element) { if (element && typeof element._extendedByPrototype == ‘undefined’) { var t = element.tagName; if (t && (/^(?:object|applet|embed)$/i.test(t))) { extendElementWith(element, Element.Methods); extendElementWith(element, Element.Methods.Simulated); extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]); } } return element; } } return Prototype.K; } var Methods = { }, ByTag = Element.Methods.ByTag; var extend = Object.extend(function(element) { if (!element || typeof element._extendedByPrototype != ‘undefined’ || element.nodeType != 1 || element == window) return element; var methods = Object.clone(Methods), tagName = element.tagName.toUpperCase(); if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); extendElementWith(element, methods); element._extendedByPrototype = Prototype.emptyFunction; return element; }, { refresh: function() { if (!Prototype.BrowserFeatures.ElementExtensions) { Object.extend(Methods, Element.Methods); Object.extend(Methods, Element.Methods.Simulated); } } }); extend.refresh(); return extend; })(); if (document.documentElement.hasAttribute) { Element.hasAttribute = function(element, attribute) { return element.hasAttribute(attribute); }; } else { Element.hasAttribute = Element.Methods.Simulated.hasAttribute; } Element.addMethods = function(methods) { var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; if (!methods) { Object.extend(Form, Form.Methods); Object.extend(Form.Element, Form.Element.Methods); Object.extend(Element.Methods.ByTag, { “FORM”: Object.clone(Form.Methods), “INPUT”: Object.clone(Form.Element.Methods), “SELECT”: Object.clone(Form.Element.Methods), “TEXTAREA”: Object.clone(Form.Element.Methods), “BUTTON”: Object.clone(Form.Element.Methods) }); } if (arguments.length == 2) { var tagName = methods; methods = arguments[1]; } if (!tagName) Object.extend(Element.Methods, methods || { }); else { if (Object.isArray(tagName)) tagName.each(extend); else extend(tagName); } function extend(tagName) { tagName = tagName.toUpperCase(); if (!Element.Methods.ByTag[tagName]) Element.Methods.ByTag[tagName] = { }; Object.extend(Element.Methods.ByTag[tagName], methods); } function copy(methods, destination, onlyIfAbsent) { onlyIfAbsent = onlyIfAbsent || false; for (var property in methods) { var value = methods[property]; if (!Object.isFunction(value)) continue; if (!onlyIfAbsent || !(property in destination)) destination[property] = value.methodize(); } } function findDOMClass(tagName) { var klass; var trans = { “OPTGROUP”: “OptGroup”, “TEXTAREA”: “TextArea”, “P”: “Paragraph”, “FIELDSET”: “FieldSet”, “UL”: “UList”, “OL”: “OList”, “DL”: “DList”, “DIR”: “Directory”, “H1”: “Heading”, “H2”: “Heading”, “H3”: “Heading”, “H4”: “Heading”, “H5”: “Heading”, “H6”: “Heading”, “Q”: “Quote”, “INS”: “Mod”, “DEL”: “Mod”, “A”: “Anchor”, “IMG”: “Image”, “CAPTION”: “TableCaption”, “COL”: “TableCol”, “COLGROUP”: “TableCol”, “THEAD”: “TableSection”, “TFOOT”: “TableSection”, “TBODY”: “TableSection”, “TR”: “TableRow”, “TH”: “TableCell”, “TD”: “TableCell”, “FRAMESET”: “FrameSet”, “IFRAME”: “IFrame” }; if (trans[tagName]) klass = ‘HTML’ + trans[tagName] + ‘Element’; if (window[klass]) return window[klass]; klass = ‘HTML’ + tagName + ‘Element’; if (window[klass]) return window[klass]; klass = ‘HTML’ + tagName.capitalize() + ‘Element’; if (window[klass]) return window[klass]; var element = document.createElement(tagName), proto = element[‘__proto__’] || element.constructor.prototype; element = null; return proto; } var elementPrototype = window.HTMLElement ? HTMLElement.prototype : Element.prototype; if (F.ElementExtensions) { copy(Element.Methods, elementPrototype); copy(Element.Methods.Simulated, elementPrototype, true); } if (F.SpecificElementExtensions) { for (var tag in Element.Methods.ByTag) { var klass = findDOMClass(tag); if (Object.isUndefined(klass)) continue; copy(T[tag], klass.prototype); } } Object.extend(Element, Element.Methods); delete Element.ByTag; if (Element.extend.refresh) Element.extend.refresh(); Element.cache = { }; }; document.viewport = { getDimensions: function() { return { width: this.getWidth(), height: this.getHeight() }; }, getScrollOffsets: function() { return Element._returnOffset( window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); } }; (function(viewport) { var B = Prototype.Browser, doc = document, element, property = {}; function getRootElement() { if (B.WebKit && !doc.evaluate) return document; if (B.Opera && window.parseFloat(window.opera.version()) < 9.5) return document.body; return document.documentElement; } function define(D) { if (!element) element = getRootElement(); property[D] = ‘client’ + D; viewport[‘get’ + D] = function() { return element[property[D]] }; return viewport[‘get’ + D](); } viewport.getWidth = define.curry(‘Width’); viewport.getHeight = define.curry(‘Height’); })(document.viewport); Element.Storage = { UID: 1 }; Element.addMethods({ getStorage: function(element) { if (!(element = $(element))) return; var uid; if (element === window) { uid = 0; } else { if (typeof element._prototypeUID === “undefined”) element._prototypeUID = Element.Storage.UID++; uid = element._prototypeUID; } if (!Element.Storage[uid]) Element.Storage[uid] = $H(); return Element.Storage[uid]; }, store: function(element, key, value) { if (!(element = $(element))) return; if (arguments.length === 2) { Element.getStorage(element).update(key); } else { Element.getStorage(element).set(key, value); } return element; }, retrieve: function(element, key, defaultValue) { if (!(element = $(element))) return; var hash = Element.getStorage(element), value = hash.get(key); if (Object.isUndefined(value)) { hash.set(key, defaultValue); value = defaultValue; } return value; }, clone: function(element, deep) { if (!(element = $(element))) return; var clone = element.cloneNode(deep); clone._prototypeUID = void 0; if (deep) { var descendants = Element.select(clone, ‘*’), i = descendants.length; while (i–) { descendants[i]._prototypeUID = void 0; } } return Element.extend(clone); }, purge: function(element) { if (!(element = $(element))) return; var purgeElement = Element._purgeElement; purgeElement(element); var descendants = element.getElementsByTagName(‘*’), i = descendants.length; while (i–) purgeElement(descendants[i]); return null; } }); (function() { function toDecimal(pctString) { var match = pctString.match(/^(\d+)%?$/i); if (!match) return null; return (Number(match[1]) / 100); } function getPixelValue(value, property, context) { var element = null; if (Object.isElement(value)) { element = value; value = element.getStyle(property); } if (value === null) { return null; } if ((/^(?:-)?\d+(\.\d+)?(px)?$/i).test(value)) { return window.parseFloat(value); } var isPercentage = value.include(‘%’), isViewport = (context === document.viewport); if (/\d/.test(value) && element && element.runtimeStyle && !(isPercentage && isViewport)) { var style = element.style.left, rStyle = element.runtimeStyle.left; element.runtimeStyle.left = element.currentStyle.left; element.style.left = value || 0; value = element.style.pixelLeft; element.style.left = style; element.runtimeStyle.left = rStyle; return value; } if (element && isPercentage) { context = context || element.parentNode; var decimal = toDecimal(value); var whole = null; var position = element.getStyle(‘position’); var isHorizontal = property.include(‘left’) || property.include(‘right’) || property.include(‘width’); var isVertical = property.include(‘top’) || property.include(‘bottom’) || property.include(‘height’); if (context === document.viewport) { if (isHorizontal) { whole = document.viewport.getWidth(); } else if (isVertical) { whole = document.viewport.getHeight(); } } else { if (isHorizontal) { whole = $(context).measure(‘width’); } else if (isVertical) { whole = $(context).measure(‘height’); } } return (whole === null) ? 0 : whole * decimal; } return 0; } function toCSSPixels(number) { if (Object.isString(number) && number.endsWith(‘px’)) { return number; } return number + ‘px’; } function isDisplayed(element) { var originalElement = element; while (element && element.parentNode) { var display = element.getStyle(‘display’); if (display === ‘none’) { return false; } element = $(element.parentNode); } return true; } var hasLayout = Prototype.K; if (‘currentStyle’ in document.documentElement) { hasLayout = function(element) { if (!element.currentStyle.hasLayout) { element.style.zoom = 1; } return element; }; } function cssNameFor(key) { if (key.include(‘border’)) key = key + ‘-width’; return key.camelize(); } Element.Layout = Class.create(Hash, { initialize: function($super, element, preCompute) { $super(); this.element = $(element); Element.Layout.PROPERTIES.each( function(property) { this._set(property, null); }, this); if (preCompute) { this._preComputing = true; this._begin(); Element.Layout.PROPERTIES.each( this._compute, this ); this._end(); this._preComputing = false; } }, _set: function(property, value) { return Hash.prototype.set.call(this, property, value); }, set: function(property, value) { throw “Properties of Element.Layout are read-only.”; }, get: function($super, property) { var value = $super(property); return value === null ? this._compute(property) : value; }, _begin: function() { if (this._prepared) return; var element = this.element; if (isDisplayed(element)) { this._prepared = true; return; } var originalStyles = { position: element.style.position || ”, width: element.style.width || ”, visibility: element.style.visibility || ”, display: element.style.display || ” }; element.store(‘prototype_original_styles’, originalStyles); var position = element.getStyle(‘position’), width = element.getStyle(‘width’); if (width === “0px” || width === null) { element.style.display = ‘block’; width = element.getStyle(‘width’); } var context = (position === ‘fixed’) ? document.viewport : element.parentNode; element.setStyle({ position: ‘absolute’, visibility: ‘hidden’, display: ‘block’ }); var positionedWidth = element.getStyle(‘width’); var newWidth; if (width && (positionedWidth === width)) { newWidth = getPixelValue(element, ‘width’, context); } else if (position === ‘absolute’ || position === ‘fixed’) { newWidth = getPixelValue(element, ‘width’, context); } else { var parent = element.parentNode, pLayout = $(parent).getLayout(); newWidth = pLayout.get(‘width’) – this.get(‘margin-left’) – this.get(‘border-left’) – this.get(‘padding-left’) – this.get(‘padding-right’) – this.get(‘border-right’) – this.get(‘margin-right’); } element.setStyle({ width: newWidth + ‘px’ }); this._prepared = true; }, _end: function() { var element = this.element; var originalStyles = element.retrieve(‘prototype_original_styles’); element.store(‘prototype_original_styles’, null); element.setStyle(originalStyles); this._prepared = false; }, _compute: function(property) { var COMPUTATIONS = Element.Layout.COMPUTATIONS; if (!(property in COMPUTATIONS)) { throw “Property not found.”; } return this._set(property, COMPUTATIONS[property].call(this, this.element)); }, toObject: function() { var args = $A(arguments); var keys = (args.length === 0) ? Element.Layout.PROPERTIES : args.join(‘ ‘).split(‘ ‘); var obj = {}; keys.each( function(key) { if (!Element.Layout.PROPERTIES.include(key)) return; var value = this.get(key); if (value != null) obj[key] = value; }, this); return obj; }, toHash: function() { var obj = this.toObject.apply(this, arguments); return new Hash(obj); }, toCSS: function() { var args = $A(arguments); var keys = (args.length === 0) ? Element.Layout.PROPERTIES : args.join(‘ ‘).split(‘ ‘); var css = {}; keys.each( function(key) { if (!Element.Layout.PROPERTIES.include(key)) return; if (Element.Layout.COMPOSITE_PROPERTIES.include(key)) return; var value = this.get(key); if (value != null) css[cssNameFor(key)] = value + ‘px’; }, this); return css; }, inspect: function() { return “#”; } }); Object.extend(Element.Layout, { PROPERTIES: $w(‘height width top left right bottom border-left border-right border-top border-bottom padding-left padding-right padding-top padding-bottom margin-top margin-bottom margin-left margin-right padding-box-width padding-box-height border-box-width border-box-height margin-box-width margin-box-height’), COMPOSITE_PROPERTIES: $w(‘padding-box-width padding-box-height margin-box-width margin-box-height border-box-width border-box-height’), COMPUTATIONS: { ‘height’: function(element) { if (!this._preComputing) this._begin(); var bHeight = this.get(‘border-box-height’); if (bHeight <= 0) { if (!this._preComputing) this._end(); return 0; } var bTop = this.get(‘border-top’), bBottom = this.get(‘border-bottom’); var pTop = this.get(‘padding-top’), pBottom = this.get(‘padding-bottom’); if (!this._preComputing) this._end(); return bHeight – bTop – bBottom – pTop – pBottom; }, ‘width’: function(element) { if (!this._preComputing) this._begin(); var bWidth = this.get(‘border-box-width’); if (bWidth <= 0) { if (!this._preComputing) this._end(); return 0; } var bLeft = this.get(‘border-left’), bRight = this.get(‘border-right’); var pLeft = this.get(‘padding-left’), pRight = this.get(‘padding-right’); if (!this._preComputing) this._end(); return bWidth – bLeft – bRight – pLeft – pRight; }, ‘padding-box-height’: function(element) { var height = this.get(‘height’), pTop = this.get(‘padding-top’), pBottom = this.get(‘padding-bottom’); return height + pTop + pBottom; }, ‘padding-box-width’: function(element) { var width = this.get(‘width’), pLeft = this.get(‘padding-left’), pRight = this.get(‘padding-right’); return width + pLeft + pRight; }, ‘border-box-height’: function(element) { if (!this._preComputing) this._begin(); var height = element.offsetHeight; if (!this._preComputing) this._end(); return height; }, ‘border-box-width’: function(element) { if (!this._preComputing) this._begin(); var width = element.offsetWidth; if (!this._preComputing) this._end(); return width; }, ‘margin-box-height’: function(element) { var bHeight = this.get(‘border-box-height’), mTop = this.get(‘margin-top’), mBottom = this.get(‘margin-bottom’); if (bHeight <= 0) return 0; return bHeight + mTop + mBottom; }, ‘margin-box-width’: function(element) { var bWidth = this.get(‘border-box-width’), mLeft = this.get(‘margin-left’), mRight = this.get(‘margin-right’); if (bWidth <= 0) return 0; return bWidth + mLeft + mRight; }, ‘top’: function(element) { var offset = element.positionedOffset(); return offset.top; }, ‘bottom’: function(element) { var offset = element.positionedOffset(), parent = element.getOffsetParent(), pHeight = parent.measure(‘height’); var mHeight = this.get(‘border-box-height’); return pHeight – mHeight – offset.top; }, ‘left’: function(element) { var offset = element.positionedOffset(); return offset.left; }, ‘right’: function(element) { var offset = element.positionedOffset(), parent = element.getOffsetParent(), pWidth = parent.measure(‘width’); var mWidth = this.get(‘border-box-width’); return pWidth – mWidth – offset.left; }, ‘padding-top’: function(element) { return getPixelValue(element, ‘paddingTop’); }, ‘padding-bottom’: function(element) { return getPixelValue(element, ‘paddingBottom’); }, ‘padding-left’: function(element) { return getPixelValue(element, ‘paddingLeft’); }, ‘padding-right’: function(element) { return getPixelValue(element, ‘paddingRight’); }, ‘border-top’: function(element) { return getPixelValue(element, ‘borderTopWidth’); }, ‘border-bottom’: function(element) { return getPixelValue(element, ‘borderBottomWidth’); }, ‘border-left’: function(element) { return getPixelValue(element, ‘borderLeftWidth’); }, ‘border-right’: function(element) { return getPixelValue(element, ‘borderRightWidth’); }, ‘margin-top’: function(element) { return getPixelValue(element, ‘marginTop’); }, ‘margin-bottom’: function(element) { return getPixelValue(element, ‘marginBottom’); }, ‘margin-left’: function(element) { return getPixelValue(element, ‘marginLeft’); }, ‘margin-right’: function(element) { return getPixelValue(element, ‘marginRight’); } } }); if (‘getBoundingClientRect’ in document.documentElement) { Object.extend(Element.Layout.COMPUTATIONS, { ‘right’: function(element) { var parent = hasLayout(element.getOffsetParent()); var rect = element.getBoundingClientRect(), pRect = parent.getBoundingClientRect(); return (pRect.right – rect.right).round(); }, ‘bottom’: function(element) { var parent = hasLayout(element.getOffsetParent()); var rect = element.getBoundingClientRect(), pRect = parent.getBoundingClientRect(); return (pRect.bottom – rect.bottom).round(); } }); } Element.Offset = Class.create({ initialize: function(left, top) { this.left = left.round(); this.top = top.round(); this[0] = this.left; this[1] = this.top; }, relativeTo: function(offset) { return new Element.Offset( this.left – offset.left, this.top – offset.top ); }, inspect: function() { return “#”.interpolate(this); }, toString: function() { return “[#{left}, #{top}]”.interpolate(this); }, toArray: function() { return [this.left, this.top]; } }); function getLayout(element, preCompute) { return new Element.Layout(element, preCompute); } function measure(element, property) { return
ORDER A PLAGIARISM FREE PAPER NOW
$(element).getLayout().get(property); } function getDimensions(element) { element = $(element); var display = Element.getStyle(element, ‘display’); if (display && display !== ‘none’) { return { width: element.offsetWidth, height: element.offsetHeight }; } var style = element.style; var originalStyles = { visibility: style.visibility, position: style.position, display: style.display }; var newStyles = { visibility: ‘hidden’, display: ‘block’ }; if (originalStyles.position !== ‘fixed’) newStyles.position = ‘absolute’; Element.setStyle(element, newStyles); var dimensions = { width: element.offsetWidth, height: element.offsetHeight }; Element.setStyle(element, originalStyles); return dimensions; } // Implementing a new method to avoid retesting the entire application with clientHeight function getDimensionsEx(element) { element = $(element); var display = Element.getStyle(element, ‘display’); if (display && display != ‘none’) { // Safari bug return {width: element.clientWidth, height: element.clientHeight}; } return getDimensions(element); } function getOffsetParent(element) { element = $(element); if (isDocument(element) || isDetached(element) || isBody(element) || isHtml(element)) return $(document.body); var isInline = (Element.getStyle(element, ‘display’) === ‘inline’); if (!isInline && element.offsetParent) return $(element.offsetParent); while ((element = element.parentNode) && element !== document.body) { if (Element.getStyle(element, ‘position’) !== ‘static’) { return isHtml(element) ? $(document.body) : $(element); } } return $(document.body); } function cumulativeOffset(element) { element = $(element); var valueT = 0, valueL = 0; if (element.parentNode) { do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; element = element.offsetParent; } while (element); } return new Element.Offset(valueL, valueT); } function positionedOffset(element) { element = $(element); var layout = element.getLayout(); var valueT = 0, valueL = 0; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; element = element.offsetParent; if (element) { if (isBody(element)) break; var p = Element.getStyle(element, ‘position’); if (p !== ‘static’) break; } } while (element); valueL -= layout.get(‘margin-top’); valueT -= layout.get(‘margin-left’); return new Element.Offset(valueL, valueT); } function cumulativeScrollOffset(element) { var valueT = 0, valueL = 0; do { valueT += element.scrollTop || 0; valueL += element.scrollLeft || 0; element = element.parentNode; } while (element); return new Element.Offset(valueL, valueT); } function viewportOffset(forElement) { element = $(element); var valueT = 0, valueL = 0, docBody = document.body; var element = forElement; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; if (element.offsetParent == docBody && Element.getStyle(element, ‘position’) == ‘absolute’) break; } while (element = element.offsetParent); element = forElement; do { if (element != docBody) { valueT -= element.scrollTop || 0; valueL -= element.scrollLeft || 0; } } while (element = element.parentNode); return new Element.Offset(valueL, valueT); } function absolutize(element) { element = $(element); if (Element.getStyle(element, ‘position’) === ‘absolute’) { return element; } var offsetParent = getOffsetParent(element); var eOffset = element.viewportOffset(), pOffset = offsetParent.viewportOffset(); var offset = eOffset.relativeTo(pOffset); var layout = element.getLayout(); element.store(‘prototype_absolutize_original_styles’, { left: element.getStyle(‘left’), top: element.getStyle(‘top’), width: element.getStyle(‘width’), height: element.getStyle(‘height’) }); element.setStyle({ position: ‘absolute’, top: offset.top + ‘px’, left: offset.left + ‘px’, width: layout.get(‘width’) + ‘px’, height: layout.get(‘height’) + ‘px’ }); return element; } function relativize(element) { element = $(element); if (Element.getStyle(element, ‘position’) === ‘relative’) { return element; } var originalStyles = element.retrieve(‘prototype_absolutize_original_styles’); if (originalStyles) element.setStyle(originalStyles); return element; } if (Prototype.Browser.IE) { getOffsetParent = getOffsetParent.wrap( function(proceed, element) { element = $(element); if (isDocument(element) || isDetached(element) || isBody(element) || isHtml(element)) return $(document.body); var position = element.getStyle(‘position’); if (position !== ‘static’) return proceed(element); element.setStyle({ position: ‘relative’ }); var value = proceed(element); element.setStyle({ position: position }); return value; } ); positionedOffset = positionedOffset.wrap(function(proceed, element) { element = $(element); if (!element.parentNode) return new Element.Offset(0, 0); var position = element.getStyle(‘position’); if (position !== ‘static’) return proceed(element); var offsetParent = element.getOffsetParent(); if (offsetParent && offsetParent.getStyle(‘position’) === ‘fixed’) hasLayout(offsetParent); element.setStyle({ position: ‘relative’ }); var value = proceed(element); element.setStyle({ position: position }); return value; }); } else if (Prototype.Browser.Webkit) { cumulativeOffset = function(element) { element = $(element); var valueT = 0, valueL = 0; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; if (element.offsetParent == document.body) if (Element.getStyle(element, ‘position’) == ‘absolute’) break; element = element.offsetParent; } while (element); return new Element.Offset(valueL, valueT); }; } Element.addMethods({ getLayout: getLayout, measure: measure, getDimensions: getDimensions, getDimensionsEx: getDimensionsEx, getOffsetParent: getOffsetParent, cumulativeOffset: cumulativeOffset, positionedOffset: positionedOffset, cumulativeScrollOffset: cumulativeScrollOffset, viewportOffset: viewportOffset, absolutize: absolutize, relativize: relativize }); function isBody(element) { return element.nodeName.toUpperCase() === ‘BODY’; } function isHtml(element) { return element.nodeName.toUpperCase() === ‘HTML’; } function isDocument(element) { return element.nodeType === Node.DOCUMENT_NODE; } function isDetached(element) { return element !== document.body && !Element.descendantOf(element, document.body); } if (‘getBoundingClientRect’ in document.documentElement) { Element.addMethods({ viewportOffset: function(element) { element = $(element); if (isDetached(element)) return new Element.Offset(0, 0); var rect = element.getBoundingClientRect(), docEl = document.documentElement; return new Element.Offset(rect.left – docEl.clientLeft, rect.top – docEl.clientTop); } }); } })(); window.$$ = function() { var expression = $A(arguments).join(‘, ‘); return Prototype.Selector.select(expression, document); }; Prototype.Selector = (function() { function select() { throw new Error(‘Method “Prototype.Selector.select” must be defined.’); } function match() { throw new Error(‘Method “Prototype.Selector.match” must be defined.’); } function find(elements, expression, index) { index = index || 0; var match = Prototype.Selector.match, length = elements.length, matchIndex = 0, i; for (i = 0; i < length; i++) { if (match(elements[i], expression) && index == matchIndex++) { return Element.extend(elements[i]); } } } function extendElements(elements) { for (var i = 0, length = elements.length; i < length; i++) { Element.extend(elements[i]); } return elements; } var K = Prototype.K; return { select: select, match: match, find: find, extendElements: (Element.extend === K) ? K : extendElements, extendElement: Element.extend }; })(); Prototype._original_property = window.Sizzle; /*! * Sizzle CSS Selector Engine – v1.0 * Copyright 2009, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * More information: http://sizzlejs.com/ */ (function(){ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|[‘”][^'”]*[‘”]|[^[\]'”]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, done = 0, toString = Object.prototype.toString, hasDuplicate = false, baseHasDuplicate = true; [0, 0].sort(function(){ baseHasDuplicate = false; return 0; }); var Sizzle = function(selector, context, results, seed) { results = results || []; var origContext = context = context || document; if ( context.nodeType !== 1 && context.nodeType !== 9 ) { return []; } if ( !selector || typeof selector !== “string” ) { return results; } var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context), soFar = selector; while ( (chunker.exec(“”), m = chunker.exec(soFar)) !== null ) { soFar = m[3]; parts.push( m[1] ); if ( m[2] ) { extra = m[3]; break; } } if ( parts.length > 1 && origPOS.exec( selector ) ) { if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { set = posProcess( parts[0] + parts[1], context ); } else { set = Expr.relative[ parts[0] ] ? [ context ] : Sizzle( parts.shift(), context ); while ( parts.length ) { selector = parts.shift(); if ( Expr.relative[ selector ] ) selector += parts.shift(); set = posProcess( selector, set ); } } } else { if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length – 1]) ) { var ret = Sizzle.find( parts.shift(), context, contextXML ); context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; } if ( context ) { var ret = seed ? { expr: parts.pop(), set: makeArray(seed) } : Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === “~” || parts[0] === “+”) && context.parentNode ? context.parentNode : context, contextXML ); set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; if ( parts.length > 0 ) { checkSet = makeArray(set); } else { prune = false; } while ( parts.length ) { var cur = parts.pop(), pop = cur; if ( !Expr.relative[ cur ] ) { cur = “”; } else { pop = parts.pop(); } if ( pop == null ) { pop = context; } Expr.relative[ cur ]( checkSet, pop, contextXML ); } } else { checkSet = parts = []; } } if ( !checkSet ) { checkSet = set; } if ( !checkSet ) { throw “Syntax error, unrecognized expression: ” + (cur || selector); } if ( toString.call(checkSet) === “[object Array]” ) { if ( !prune ) { results.push.apply( results, checkSet ); } else if ( context && context.nodeType === 1 ) { for ( var i = 0; checkSet[i] != null; i++ ) { if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { results.push( set[i] ); } } } else { for ( var i = 0; checkSet[i] != null; i++ ) { if ( checkSet[i] && checkSet[i].nodeType === 1 ) { results.push( set[i] ); } } } } else { makeArray( checkSet, results ); } if ( extra ) { Sizzle( extra, origContext, results, seed ); Sizzle.uniqueSort( results ); } return results; }; Sizzle.uniqueSort = function(results){ if ( sortOrder ) { hasDuplicate = baseHasDuplicate; results.sort(sortOrder); if ( hasDuplicate ) { for ( var i = 1; i < results.length; i++ ) { if ( results[i] === results[i-1] ) { results.splice(i–, 1); } } } } return results; }; Sizzle.matches = function(expr, set){ return Sizzle(expr, null, null, set); }; Sizzle.find = function(expr, context, isXML){ var set, match; if ( !expr ) { return []; } for ( var i = 0, l = Expr.order.length; i < l; i++ ) { var type = Expr.order[i], match; if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { var left = match[1]; match.splice(1,1); if ( left.substr( left.length – 1 ) !== “\\” ) { match[1] = (match[1] || “”).replace(/\\/g, “”); set = Expr.find[ type ]( match, context, isXML ); if ( set != null ) { expr = expr.replace( Expr.match[ type ], “” ); break; } } } } if ( !set ) { set = context.getElementsByTagName(“*”); } return {set: set, expr: expr}; }; Sizzle.filter = function(expr, set, inplace, not){ var old = expr, result = [], curLoop = set, match, anyFound, isXMLFilter = set && set[0] && isXML(set[0]); while ( expr && set.length ) { for ( var type in Expr.filter ) { if ( (match = Expr.match[ type ].exec( expr )) != null ) { var filter = Expr.filter[ type ], found, item; anyFound = false; if ( curLoop == result ) { result = []; } if ( Expr.preFilter[ type ] ) { match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); if ( !match ) { anyFound = found = true; } else if ( match === true ) { continue; } } if ( match ) { for ( var i = 0; (item = curLoop[i]) != null; i++ ) { if ( item ) { found = filter( item, match, i, curLoop ); var pass = not ^ !!found; if ( inplace && found != null ) { if ( pass ) { anyFound = true; } else { curLoop[i] = false; } } else if ( pass ) { result.push( item ); anyFound = true; } } } } if ( found !== undefined ) { if ( !inplace ) { curLoop = result; } expr = expr.replace( Expr.match[ type ], “” ); if ( !anyFound ) { return []; } break; } } } if ( expr == old ) { if ( anyFound == null ) { throw “Syntax error, unrecognized expression: ” + expr; } else { break; } } old = expr; } return curLoop; }; var Expr = Sizzle.selectors = { order: [ “ID”, “NAME”, “TAG” ], match: { ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/, CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/, NAME: /\[name=[‘”]*((?:[\w\u00c0-\uFFFF-]|\\.)+)[‘”]*\]/, ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*([‘”]*)(.*?)\3|)\s*\]/, TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/, CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\(([‘”]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ }, leftMatch: {}, attrMap: { “class”: “className”, “for”: “htmlFor” }, attrHandle: { href: function(elem){ return elem.getAttribute(“href”); } }, relative: { “+”: function(checkSet, part, isXML){ var isPartStr = typeof part === “string”, isTag = isPartStr && !/\W/.test(part), isPartStrNotTag = isPartStr && !isTag; if ( isTag && !isXML ) { part = part.toUpperCase(); } for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { if ( (elem = checkSet[i]) ) { while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ? elem || false : elem === part; } } if ( isPartStrNotTag ) { Sizzle.filter( part, checkSet, true ); } }, “>”: function(checkSet, part, isXML){ var isPartStr = typeof part === “string”; if ( isPartStr && !/\W/.test(part) ) { part = isXML ? part : part.toUpperCase(); for ( var i = 0, l = checkSet.length; i < l; i++ ) { var elem = checkSet[i]; if ( elem ) { var parent = elem.parentNode; checkSet[i] = parent.nodeName === part ? parent : false; } } } else { for ( var i = 0, l = checkSet.length; i < l; i++ ) { var elem = checkSet[i]; if ( elem ) { checkSet[i] = isPartStr ? elem.parentNode : elem.parentNode === part; } } if ( isPartStr ) { Sizzle.filter( part, checkSet, true ); } } }, “”: function(checkSet, part, isXML){ var doneName = done++, checkFn = dirCheck; if ( !/\W/.test(part) ) { var nodeCheck = part = isXML ? part : part.toUpperCase(); checkFn = dirNodeCheck; } checkFn(“parentNode”, part, doneName, checkSet, nodeCheck, isXML); }, “~”: function(checkSet, part, isXML){ var doneName = done++, checkFn = dirCheck; if ( typeof part === “string” && !/\W/.test(part) ) { var nodeCheck = part = isXML ? part : part.toUpperCase(); checkFn = dirNodeCheck; } checkFn(“previousSibling”, part, doneName, checkSet, nodeCheck, isXML); } }, find: { ID: function(match, context, isXML){ if ( typeof context.getElementById !== “undefined” && !isXML ) { var m = context.getElementById(match[1]); return m ? [m] : []; } }, NAME: function(match, context, isXML){ if ( typeof context.getElementsByName !== “undefined” ) { var ret = [], results = context.getElementsByName(match[1]); for ( var i = 0, l = results.length; i < l; i++ ) { if ( results[i].getAttribute(“name”) === match[1] ) { ret.push( results[i] ); } } return ret.length === 0 ? null : ret; } }, TAG: function(match, context){ return context.getElementsByTagName(match[1]); } }, preFilter: { CLASS: function(match, curLoop, inplace, result, not, isXML){ match = ” ” + match[1].replace(/\\/g, “”) + ” “; if ( isXML ) { return match; } for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { if ( elem ) { if ( not ^ (elem.className && (” ” + elem.className + ” “).indexOf(match) >= 0) ) { if ( !inplace ) result.push( elem ); } else if ( inplace ) { curLoop[i] = false; } } } return false; }, ID: function(match){ return match[1].replace(/\\/g, “”); }, TAG: function(match, curLoop){ for ( var i = 0; curLoop[i] === false; i++ ){} return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase(); }, CHILD: function(match){ if ( match[1] == “nth” ) { var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( match[2] == “even” && “2n” || match[2] == “odd” && “2n+1” || !/\D/.test( match[2] ) && “0n+” + match[2] || match[2]); match[2] = (test[1] + (test[2] || 1)) – 0; match[3] = test[3] – 0; } match[0] = done++; return match; }, ATTR: function(match, curLoop, inplace, result, not, isXML){ var name = match[1].replace(/\\/g, “”); if ( !isXML && Expr.attrMap[name] ) { match[1] = Expr.attrMap[name]; } if ( match[2] === “~=” ) { match[4] = ” ” + match[4] + ” “; } return match; }, PSEUDO: function(match, curLoop, inplace, result, not){ if ( match[1] === “not” ) { if ( ( chunker.exec(match[3]) || “” ).length > 1 || /^\w/.test(match[3]) ) { match[3] = Sizzle(match[3], null, null, curLoop); } else { var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); if ( !inplace ) { result.push.apply( result, ret ); } return false; } } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { return true; } return match; }, POS: function(match){ match.unshift( true ); return match; } }, filters: { enabled: function(elem){ return elem.disabled === false && elem.type !== “hidden”; }, disabled: function(elem){ return elem.disabled === true; }, checked: function(elem){ return elem.checked === true; }, selected: function(elem){ elem.parentNode.selectedIndex; return elem.selected === true; }, parent: function(elem){ return !!elem.firstChild; }, empty: function(elem){ return !elem.firstChild; }, has: function(elem, i, match){ return !!Sizzle( match[3], elem ).length; }, header: function(elem){ return /h\d/i.test( elem.nodeName ); }, text: function(elem){ return “text” === elem.type; }, radio: function(elem){ return “radio” === elem.type; }, checkbox: function(elem){ return “checkbox” === elem.type; }, file: function(elem){ return “file” === elem.type; }, password: function(elem){ return “password” === elem.type; }, submit: function(elem){ return “submit” === elem.type; }, image: function(elem){ return “image” === elem.type; }, reset: function(elem){ return “reset” === elem.type; }, button: function(elem){ return “button” === elem.type || elem.nodeName.toUpperCase() === “BUTTON”; }, input: function(elem){ return /input|select|textarea|button/i.test(elem.nodeName); } }, setFilters: { first: function(elem, i){ return i === 0; }, last: function(elem, i, match, array){ return i === array.length – 1; }, even: function(elem, i){ return i % 2 === 0; }, odd: function(elem, i){ return i % 2 === 1; }, lt: function(elem, i, match){ return i < match[3] – 0; }, gt: function(elem, i, match){ return i > match[3] – 0; }, nth: function(elem, i, match){ return match[3] – 0 == i; }, eq: function(elem, i, match){ return match[3] – 0 == i; } }, filter: { PSEUDO: function(elem, match, i, array){ var name = match[1], filter = Expr.filters[ name ]; if ( filter ) { return filter( elem, i, match, array ); } else if ( name === “contains” ) { return (elem.textContent || elem.innerText || “”).indexOf(match[3]) >= 0; } else if ( name === “not” ) { var not = match[3]; for ( var i = 0, l = not.length; i < l; i++ ) { if ( not[i] === elem ) { return false; } } return true; } }, CHILD: function(elem, match){ var type = match[1], node = elem; switch (type) { case ‘only’: case ‘first’: while ( (node = node.previousSibling) ) { if ( node.nodeType === 1 ) return false; } if ( type == ‘first’) return true; node = elem; case ‘last’: while ( (node = node.nextSibling) ) { if ( node.nodeType === 1 ) return false; } return true; case ‘nth’: var first = match[2], last = match[3]; if ( first == 1 && last == 0 ) { return true; } var doneName = match[0], parent = elem.parentNode; if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { var count = 0; for ( node = parent.firstChild; node; node = node.nextSibling ) { if ( node.nodeType === 1 ) { node.nodeIndex = ++count; } } parent.sizcache = doneName; } var diff = elem.nodeIndex – last; if ( first == 0 ) { return diff == 0; } else { return ( diff % first == 0 && diff / first >= 0 ); } } }, ID: function(elem, match){ return elem.nodeType === 1 && elem.getAttribute(“id”) === match; }, TAG: function(elem, match){ return (match === “*” && elem.nodeType === 1) || elem.nodeName === match; }, CLASS: function(elem, match){ return (” ” + (elem.className || elem.getAttribute(“class”)) + ” “) .indexOf( match ) > -1; }, ATTR: function(elem, match){ var name = match[1], result = Expr.attrHandle[ name ] ? Expr.attrHandle[ name ]( elem ) : elem[ name ] != null ? elem[ name ] : elem.getAttribute( name ), value = result + “”, type = match[2], check = match[4]; return result == null ? type === “!=” : type === “=” ? value === check : type === “*=” ? value.indexOf(check) >= 0 : type === “~=” ? (” ” + value + ” “).indexOf(check) >= 0 : !check ? value && result !== false : type === “!=” ? value != check : type === “^=” ? value.indexOf(check) === 0 : type === “$=” ? value.substr(value.length – check.length) === check : type === “|=” ? value === check || value.substr(0, check.length + 1) === check + “-” : false; }, POS: function(elem, match, i, array){ var name = match[2], filter = Expr.setFilters[ name ]; if ( filter ) { return filter( elem, i, match, array ); } } } }; var origPOS = Expr.match.POS; for ( var type in Expr.match ) { Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source ); } var makeArray = function(array, results) { array = Array.prototype.slice.call( array, 0 ); if ( results ) { results.push.apply( results, array ); return results; } return array; }; try { Array.prototype.slice.call( document.documentElement.childNodes, 0 ); } catch(e){ makeArray = function(array, results) { var ret = results || []; if ( toString.call(array) === “[object Array]” ) { Array.prototype.push.apply( ret, array ); } else { if ( typeof array.length === “number” ) { for ( var i = 0, l = array.length; i < l; i++ ) { ret.push( array[i] ); } } else { for ( var i = 0; array[i]; i++ ) { ret.push( array[i] ); } } } return ret; }; } var sortOrder; if ( document.documentElement.compareDocumentPosition ) { sortOrder = function( a, b ) { if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { if ( a == b ) { hasDuplicate = true; } return 0; } var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; if ( ret === 0 ) { hasDuplicate = true; } return ret; }; } else if ( “sourceIndex” in document.documentElement ) { sortOrder = function( a, b ) { if ( !a.sourceIndex || !b.sourceIndex ) { if ( a == b ) { hasDuplicate = true; } return 0; } var ret = a.sourceIndex – b.sourceIndex; if ( ret === 0 ) { hasDuplicate = true; } return ret; }; } else if ( document.createRange ) { sortOrder = function( a, b ) { if ( !a.ownerDocument || !b.ownerDocument ) { if ( a == b ) { hasDuplicate = true; } return 0; } var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); aRange.setStart(a, 0); aRange.setEnd(a, 0); bRange.setStart(b, 0); bRange.setEnd(b, 0); var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); if ( ret === 0 ) { hasDuplicate = true; } return ret; }; } (function(){ var form = document.createElement(“div”), id = “script” + (new Date).getTime(); form.innerHTML = “”; var root = document.documentElement; root.insertBefore( form, root.firstChild ); if ( !!document.getElementById( id ) ) { Expr.find.ID = function(match, context, isXML){ if ( typeof context.getElementById !== “undefined” && !isXML ) { var m = context.getElementById(match[1]); return m ? m.id === match[1] || typeof m.getAttributeNode !== “undefined” && m.getAttributeNode(“id”).nodeValue === match[1] ? [m] : undefined : []; } }; Expr.filter.ID = function(elem, match){ var node = typeof elem.getAttributeNode !== “undefined” && elem.getAttributeNode(“id”); return elem.nodeType === 1 && node && node.nodeValue === match; }; } root.removeChild( form ); root = form = null; // release memory in IE })(); (function(){ var div = document.createElement(“div”); div.appendChild( document.createComment(“”) ); if ( div.getElementsByTagName(“*”).length > 0 ) { Expr.find.TAG = function(match, context){ var results = context.getElementsByTagName(match[1]); if ( match[1] === “*” ) { var tmp = []; for ( var i = 0; results[i]; i++ ) { if ( results[i].nodeType === 1 ) { tmp.push( results[i] ); } } results = tmp; } return results; }; } div.innerHTML = “”; if ( div.firstChild && typeof div.firstChild.getAttribute !== “undefined” && div.firstChild.getAttribute(“href”) !== “#” ) { Expr.attrHandle.href = function(elem){ return elem.getAttribute(“href”, 2); }; } div = null; // release memory in IE })(); if ( document.querySelectorAll ) (function(){ var oldSizzle = Sizzle, div = document.createElement(“div”); div.innerHTML = ”
“; if ( div.querySelectorAll && div.querySelectorAll(“.TEST”).length === 0 ) { return; } Sizzle = function(query, context, extra, seed){ context = context || document; if ( !seed && context.nodeType === 9 && !isXML(context) ) { try { return makeArray( context.querySelectorAll(query), extra ); } catch(e){} } return oldSizzle(query, context, extra, seed); }; for ( var prop in oldSizzle ) { Sizzle[ prop ] = oldSizzle[ prop ]; } div = null; // release memory in IE })(); if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ var div = document.createElement(“div”); div.innerHTML = ”
“; if ( div.getElementsByClassName(“e”).length === 0 ) return; div.lastChild.className = “e”; if ( div.getElementsByClassName(“e”).length === 1 ) return; Expr.order.splice(1, 0, “CLASS”); Expr.find.CLASS = function(match, context, isXML) { if ( typeof context.getElementsByClassName !== “undefined” && !isXML ) { return context.getElementsByClassName(match[1]); } }; div = null; // release memory in IE })(); function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { var sibDir = dir == “previousSibling” && !isXML; for ( var i = 0, l = checkSet.length; i < l; i++ ) { var elem = checkSet[i]; if ( elem ) { if ( sibDir && elem.nodeType === 1 ){ elem.sizcache = doneName; elem.sizset = i; } elem = elem[dir]; var match = false; while ( elem ) { if ( elem.sizcache === doneName ) { match = checkSet[elem.sizset]; break; } if ( elem.nodeType === 1 && !isXML ){ elem.sizcache = doneName; elem.sizset = i; } if ( elem.nodeName === cur ) { match = elem; break; } elem = elem[dir]; } checkSet[i] = match; } } } function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { var sibDir = dir == “previousSibling” && !isXML; for ( var i = 0, l = checkSet.length; i < l; i++ ) { var elem = checkSet[i]; if ( elem ) { if ( sibDir && elem.nodeType === 1 ) { elem.sizcache = doneName; elem.sizset = i; } elem = elem[dir]; var match = false; while ( elem ) { if ( elem.sizcache === doneName ) { match = checkSet[elem.sizset]; break; } if ( elem.nodeType === 1 ) { if ( !isXML ) { elem.sizcache = doneName; elem.sizset = i; } if ( typeof cur !== “string” ) { if ( elem === cur ) { match = true; break; } } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { match = elem; break; } } elem = elem[dir]; } checkSet[i] = match; } } } var contains = document.compareDocumentPosition ? function(a, b){ return a.compareDocumentPosition(b) & 16; } : function(a, b){ return a !== b && (a.contains ? a.contains(b) : true); }; var isXML = function(elem){ return elem.nodeType === 9 && elem.documentElement.nodeName !== “HTML” || !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== “HTML”; }; var posProcess = function(selector, context){ var tmpSet = [], later = “”, match, root = context.nodeType ? [context] : context; while ( (match = Expr.match.PSEUDO.exec( selector )) ) { later += match[0]; selector = selector.replace( Expr.match.PSEUDO, “” ); } selector = Expr.relative[selector] ? selector + “*” : selector; for ( var i = 0, l = root.length; i < l; i++ ) { Sizzle( selector, root[i], tmpSet ); } return Sizzle.filter( later, tmpSet ); }; window.Sizzle = Sizzle; })(); ;(function(engine) { var extendElements = Prototype.Selector.extendElements; function select(selector, scope) { return extendElements(engine(selector, scope || document)); } function match(element, selector) { return engine.matches(selector, [element]).length == 1; } Prototype.Selector.engine = engine; Prototype.Selector.select = select; Prototype.Selector.match = match; })(Sizzle); window.Sizzle = Prototype._original_property; delete Prototype._original_property; var Form = { reset: function(form) { form = $(form); form.reset(); return form; }, serializeElements: function(elements, options) { if (typeof options != ‘object’) options = { hash: !!options }; else if (Object.isUndefined(options.hash)) options.hash = true; var key, value, submitted = false, submit = options.submit, accumulator, initial; if (options.hash) { initial = {}; accumulator = function(result, key, value) { if (key in result) { if (!Object.isArray(result[key])) result[key] = [result[key]]; result[key].push(value); } else result[key] = value; return result; }; } else { initial = ”; accumulator = function(result, key, value) { return result + (result ? ‘&’ : ”) + encodeURIComponent(key) + ‘=’ + encodeURIComponent(value); } } return elements.inject(initial, function(result, element) { if (!element.disabled && element.name) { key = element.name; value = $(element).getValue(); if (value != null && element.type != ‘file’ && (element.type != ‘submit’ || (!submitted && submit !== false && (!submit || key == submit) && (submitted = true)))) { result = accumulator(result, key, value); } } return result; }); } }; Form.Methods = { serialize: function(form, options) { return Form.serializeElements(Form.getElements(form), options); }, getElements: function(form) { var elements = $(form).getElementsByTagName(‘*’), element, arr = [ ], serializers = Form.Element.Serializers; for (var i = 0; element = elements[i]; i++) { arr.push(element); } return arr.inject([], function(elements, child) { if (serializers[child.tagName.toLowerCase()]) elements.push(Element.extend(child)); return elements; }) }, getInputs: function(form, typeName, name) { form = $(form); var inputs = form.getElementsByTagName(‘input’); if (!typeName && !name) return $A(inputs).map(Element.extend); for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { var input = inputs[i]; if ((typeName && input.type != typeName) || (name && input.name != name)) continue; matchingInputs.push(Element.extend(input)); } return matchingInputs; }, disable: function(form) { form = $(form); Form.getElements(form).invoke(‘disable’); return form; }, enable: function(form) { form = $(form); Form.getElements(form).invoke(‘enable’); return form; }, findFirstElement: function(form) { var elements = $(form).getElements().findAll(function(element) { return ‘hidden’ != element.type && !element.disabled; }); var firstByIndex = elements.findAll(function(element) { return element.hasAttribute(‘tabIndex’) && element.tabIndex >= 0; }).sortBy(function(element) { return element.tabIndex }).first(); return firstByIndex ? firstByIndex : elements.find(function(element) { return /^(?:input|select|textarea)$/i.test(element.tagName); }); }, focusFirstElement: function(form) { form = $(form); var element = form.findFirstElement(); if (element) element.activate(); return form; }, request: function(form, options) { form = $(form), options = Object.clone(options || { }); var params = options.parameters, action = form.readAttribute(‘action’) || ”; if (action.blank()) action = window.location.href; options.parameters = form.serialize(true); if (params) { if (Object.isString(params)) params = params.toQueryParams(); Object.extend(options.parameters, params); } if (form.hasAttribute(‘method’) && !options.method) options.method = form.getAttribute(‘method’); return new Ajax.Request(action, options); } }; /*————————————————————————–*/ Form.Element = { focus: function(element) { $(element).focus(); return element; }, select: function(element) { $(element).select(); return element; } }; Form.Element.Methods = { serialize: function(element) { element = $(element); if (!element.disabled && element.name) { var value = element.getValue(); if (value != undefined) { var pair = { }; pair[element.name] = value; return Object.toQueryString(pair); } } return ”; }, getValue: function(element) { element = $(element); var method = element.tagName.toLowerCase(); return Form.Element.Serializers[method](element); }, setValue: function(element, value) { element = $(element); var method = element.tagName.toLowerCase(); Form.Element.Serializers[method](element, value); return element; }, clear: function(element) { $(element).value = ”; return element; }, present: function(element) { return $(element).value != ”; }, activate: function(element) { element = $(element); try { element.focus(); if (element.select && (element.tagName.toLowerCase() != ‘input’ || !(/^(?:button|reset|submit)$/i.test(element.type)))) element.select(); } catch (e) { } return element; }, disable: function(element) { element = $(element); element.disabled = true; return element; }, enable: function(element) { element = $(element); element.disabled = false; return element; } }; /*————————————————————————–*/ var Field = Form.Element; var $F = Form.Element.Methods.getValue; /*————————————————————————–*/ Form.Element.Serializers = (function() { function input(element, value) { switch (element.type.toLowerCase()) { case ‘checkbox’: case ‘radio’: return inputSelector(element, value); default: return valueSelector(element, value); } } function inputSelector(element, value) { if (Object.isUndefined(value)) return element.checked ? element.value : null; else element.checked = !!value; } function valueSelector(element, value) { if (Object.isUndefined(value)) return element.value; else element.value = value; } function select(element, value) { if (Object.isUndefined(value)) return (element.type === ‘select-one’ ? selectOne : selectMany)(element); var opt, currentValue, single = !Object.isArray(value); for (var i = 0, length = element.length; i < length; i++) { opt = element.options[i]; currentValue = this.optionValue(opt); if (single) { if (currentValue == value) { opt.selected = true; return; } } else opt.selected = value.include(currentValue); } } function selectOne(element) { var index = element.selectedIndex; return index >= 0 ? optionValue(element.options[index]) : null; } function selectMany(element) { var values, length = element.length; if (!length) return null; for (var i = 0, values = []; i < length; i++) { var opt = element.options[i]; if (opt.selected) values.push(optionValue(opt)); } return values; } function optionValue(opt) { return Element.hasAttribute(opt, ‘value’) ? opt.value : opt.text; } return { input: input, inputSelector: inputSelector, textarea: valueSelector, select: select, selectOne: selectOne, selectMany: selectMany, optionValue: optionValue, button: valueSelector }; })(); /*————————————————————————–*/ Abstract.TimedObserver = Class.create(PeriodicalExecuter, { initialize: function($super, element, frequency, callback) { $super(callback, frequency); this.element = $(element); this.lastValue = this.getValue(); }, execute: function() { var value = this.getValue(); if (Object.isString(this.lastValue) && Object.isString(value) ? this.lastValue != value : String(this.lastValue) != String(value)) { this.callback(this.element, value); this.lastValue = value; } } }); Form.Element.Observer = Class.create(Abstract.TimedObserver, { getValue: function() { return Form.Element.getValue(this.element); } }); Form.Observer = Class.create(Abstract.TimedObserver, { getValue: function() { return Form.serialize(this.element); } }); /*————————————————————————–*/ Abstract.EventObserver = Class.create({ initialize: function(element, callback) { this.element = $(element); this.callback = callback; this.lastValue = this.getValue(); if (this.element.tagName.toLowerCase() == ‘form’) this.registerFormCallbacks(); else this.registerCallback(this.element); }, onElementEvent: function() { var value = this.getValue(); if (this.lastValue != value) { this.callback(this.element, value); this.lastValue = value; } }, registerFormCallbacks: function() { Form.getElements(this.element).each(this.registerCallback, this); }, registerCallback: function(element) { if (element.type) { switch (element.type.toLowerCase()) { case ‘checkbox’: case ‘radio’: Event.observe(element, ‘click’, this.onElementEvent.bind(this)); break; default: Event.observe(element, ‘change’, this.onElementEvent.bind(this)); break; } } } }); Form.Element.EventObserver = Class.create(Abstract.EventObserver, { getValue: function() { return Form.Element.getValue(this.element); } }); Form.EventObserver = Class.create(Abstract.EventObserver, { getValue: function() { return Form.serialize(this.element); } }); (function() { var Event = { KEY_BACKSPACE: 8, KEY_TAB: 9, KEY_RETURN: 13, KEY_ESC: 27, KEY_SPACE: 32, KEY_LEFT: 37, KEY_UP: 38, KEY_RIGHT: 39, KEY_DOWN: 40, KEY_DELETE: 46, KEY_HOME: 36, KEY_END: 35, KEY_PAGEUP: 33, KEY_PAGEDOWN: 34, KEY_INSERT: 45, cache: {} }; var docEl = document.documentElement; var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = ‘onmouseenter’ in docEl && ‘onmouseleave’ in docEl; var isIELegacyEvent = function(event) { return false; }; if (window.attachEvent) { if (window.addEventListener) { isIELegacyEvent = function(event) { return !(event instanceof window.Event); }; } else { isIELegacyEvent = function(event) { return true; }; } } var _isButton; function _isButtonForDOMEvents(event, code) { return event.which ? (event.which === code + 1) : (event.button === code); } var legacyButtonMap = { 0: 1, 1: 4, 2: 2 }; function _isButtonForLegacyEvents(event, code) { return event.button === legacyButtonMap[code]; } function _isButtonForWebKit(event, code) { switch (code) { case 0: return event.which == 1 && !event.metaKey; case 1: return event.which == 2 || (event.which == 1 && event.metaKey); case 2: return event.which == 3; default: return false; } } if (window.attachEvent) { if (!window.addEventListener) { _isButton = _isButtonForLegacyEvents; } else { _isButton = function(event, code) { return isIELegacyEvent(event) ? _isButtonForLegacyEvents(event, code) : _isButtonForDOMEvents(event, code); } } } else if (Prototype.Browser.WebKit) { _isButton = _isButtonForWebKit; } else { _isButton = _isButtonForDOMEvents; } function isLeftClick(event) { return _isButton(event, 0) } function isMiddleClick(event) { return _isButton(event, 1) } function isRightClick(event) { return _isButton(event, 2) } function element(event) { event = Event.extend(event); var node = event.target, type = event.type, currentTarget = event.currentTarget; if (currentTarget && currentTarget.tagName) { if (type === ‘load’ || type === ‘error’ || (type === ‘click’ && currentTarget.tagName.toLowerCase() === ‘input’ && currentTarget.type === ‘radio’)) node = currentTarget; } if (node.nodeType == Node.TEXT_NODE) node = node.parentNode; return Element.extend(node); } function findElement(event, expression) { var element = Event.element(event); if (!expression) return element; while (element) { if (Object.isElement(element) && Prototype.Selector.match(element, expression)) { return Element.extend(element); } element = element.parentNode; } } function pointer(event) { return { x: pointerX(event), y: pointerY(event) }; } function pointerX(event) { var docElement = document.documentElement, body = document.body || { scrollLeft: 0 }; return event.pageX || (event.clientX + (docElement.scrollLeft || body.scrollLeft) – (docElement.clientLeft || 0)); } function pointerY(event) { var docElement = document.documentElement, body = document.body || { scrollTop: 0 }; return event.pageY || (event.clientY + (docElement.scrollTop || body.scrollTop) – (docElement.clientTop || 0)); } function stop(event) { Event.extend(event); event.preventDefault(); event.stopPropagation(); event.stopped = true; } Event.Methods = { isLeftClick: isLeftClick, isMiddleClick: isMiddleClick, isRightClick: isRightClick, element: element, findElement: findElement, pointer: pointer, pointerX: pointerX, pointerY: pointerY, stop: stop }; var methods = Object.keys(Event.Methods).inject({ }, function(m, name) { m[name] = Event.Methods[name].methodize(); return m; }); if (window.attachEvent) { function _relatedTarget(event) { var element; switch (event.type) { case ‘mouseover’: case ‘mouseenter’: element = event.fromElement; break; case ‘mouseout’: case ‘mouseleave’: element = event.toElement; break; default: return null; } return Element.extend(element); } var additionalMethods = { stopPropagation: function() { this.cancelBubble = true }, preventDefault: function() { this.returnValue = false }, inspect: function() { return ‘[object Event]’ } }; Event.extend = function(event, element) { if (!event) return false; if (!isIELegacyEvent(event)) return event; if (event._extendedByPrototype) return event; event._extendedByPrototype = Prototype.emptyFunction; var pointer = Event.pointer(event); Object.extend(event, { target: event.srcElement || element, relatedTarget: _relatedTarget(event), pageX: pointer.x, pageY: pointer.y }); Object.extend(event, methods); Object.extend(event, additionalMethods); return event; }; } else { Event.extend = Prototype.K; } if (window.addEventListener) { Event.prototype = window.Event.prototype || document.createEvent(‘HTMLEvents’).__proto__; Object.extend(Event.prototype, methods); } function _createResponder(element, eventName, handler) { var registry = Element.retrieve(element, ‘prototype_event_registry’); if (Object.isUndefined(registry)) { CACHE.push(element); registry = Element.retrieve(element, ‘prototype_event_registry’, $H()); } var respondersForEvent = registry.get(eventName); if (Object.isUndefined(respondersForEvent)) { respondersForEvent = []; registry.set(eventName, respondersForEvent); } if (respondersForEvent.pluck(‘handler’).include(handler)) return false; var responder; if (eventName.include(“:”)) { responder = function(event) { if (Object.isUndefined(event.eventName)) return false; if (event.eventName !== eventName) return false; Event.extend(event, element); handler.call(element, event); }; } else { if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED && (eventName === “mouseenter” || eventName === “mouseleave”)) { if (eventName === “mouseenter” || eventName === “mouseleave”) { responder = function(event) { Event.extend(event, element); var parent = event.relatedTarget; while (parent && parent !== element) { try { parent = parent.parentNode; } catch(e) { parent = element; } } if (parent === element) return; handler.call(element, event); }; } } else { if (eventName === “beforeunload”) { responder = function(event) { Event.extend(event, element); return handler.call(element, event); }; } else { responder = function(event) { Event.extend(event, element); handler.call(element, event); }; } } } responder.handler = handler; respondersForEvent.push(responder); return responder; } function _destroyCache() { for (var i = 0, length = CACHE.length; i < length; i++) { Event.stopObserving(CACHE[i]); CACHE[i] = null; } } var CACHE = []; if (Prototype.Browser.IE) window.attachEvent(‘onunload’, _destroyCache); if (Prototype.Browser.WebKit) window.addEventListener(‘unload’, Prototype.emptyFunction, false); var _getDOMEventName = Prototype.K, translations = { mouseenter: “mouseover”, mouseleave: “mouseout” }; if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) { _getDOMEventName = function(eventName) { return (translations[eventName] || eventName); }; } function observe(element, eventName, handler) { element = $(element); var responder = _createResponder(element, eventName, handler); if (!responder) return element; if (eventName.include(‘:’)) { if (element.addEventListener) element.addEventListener(“dataavailable”, responder, false); else { element.attachEvent(“ondataavailable”, responder); element.attachEvent(“onlosecapture”, responder); } } else { var actualEventName = _getDOMEventName(eventName); if (element.addEventListener) element.addEventListener(actualEventName, responder, false); else element.attachEvent(“on” + actualEventName, responder); } return element; } function stopObserving(element, eventName, handler) { element = $(element); var registry = Element.retrieve(element, ‘prototype_event_registry’); if (!registry) return element; if (!eventName) { registry.each( function(pair) { var eventName = pair.key; stopObserving(element, eventName); }); return element; } var responders = registry.get(eventName); if (!responders) return element; if (!handler) { responders.each(function(r) { stopObserving(element, eventName, r.handler); }); return element; } var i = responders.length, responder; while (i–) { if (responders[i].handler === handler) { responder = responders[i]; break; } } if (!responder) return element; if (eventName.include(‘:’)) { if (element.removeEventListener) element.removeEventListener(“dataavailable”, responder, false); else { element.detachEvent(“ondataavailable”, responder); element.detachEvent(“onlosecapture”, responder); } } else { var actualEventName = _getDOMEventName(eventName); if (element.removeEventListener) element.removeEventListener(actualEventName, responder, false); else element.detachEvent(‘on’ + actualEventName, responder); } registry.set(eventName, responders.without(responder)); return element; } function fire(element, eventName, memo, bubble) { element = $(element); if (Object.isUndefined(bubble)) bubble = true; if (element == document && document.createEvent && !element.dispatchEvent) element = document.documentElement; var event; if (document.createEvent) { event = document.createEvent(‘HTMLEvents’); event.initEvent(‘dataavailable’, bubble, true); } else { event = document.createEventObject(); event.eventType = bubble ? ‘ondataavailable’ : ‘onlosecapture’; } event.eventName = eventName; event.memo = memo || { }; if (document.createEvent) element.dispatchEvent(event); else element.fireEvent(event.eventType, event); return Event.extend(event); } Event.Handler = Class.create({ initialize: function(element, eventName, selector, callback) { this.element = $(element); this.eventName = eventName; this.selector = selector; this.callback = callback; this.handler = this.handleEvent.bind(this); }, start: function() { Event.observe(this.element, this.eventName, this.handler); return this; }, stop: function() { Event.stopObserving(this.element, this.eventName, this.handler); return this; }, handleEvent: function(event) { var element = Event.findElement(event, this.selector); if (element) this.callback.call(this.element, event, element); } }); function on(element, eventName, selector, callback) { element = $(element); if (Object.isFunction(selector) && Object.isUndefined(callback)) { callback = selector, selector = null; } return new Event.Handler(element, eventName, selector, callback).start(); } Object.extend(Event, Event.Methods); Object.extend(Event, { fire: fire, observe: observe, stopObserving: stopObserving, on: on }); Element.addMethods({ fire: fire, observe: observe, stopObserving: stopObserving, on: on }); Object.extend(document, { fire: fire.methodize(), observe: observe.methodize(), stopObserving: stopObserving.methodize(), on: on.methodize(), loaded: false }); if (window.Event) Object.extend(window.Event, Event); else window.Event = Event; })(); (function() { /* Support for the DOMContentLoaded event is based on work by Dan Webb, Matthias Miller, Dean Edwards, John Resig, and Diego Perini. */ var timer; function fireContentLoadedEvent() { if (document.loaded) return; if (timer) window.clearTimeout(timer); document.loaded = true; document.fire(‘dom:loaded’); } function checkReadyState() { if (document.readyState === ‘complete’) { document.stopObserving(‘readystatechange’, checkReadyState); fireContentLoadedEvent(); } } function pollDoScroll() { try { document.documentElement.doScroll(‘left’); } catch(e) { timer = pollDoScroll.defer(); return; } fireContentLoadedEvent(); } if (document.addEventListener) { document.addEventListener(‘DOMContentLoaded’, fireContentLoadedEvent, false); } else { document.observe(‘readystatechange’, checkReadyState); if (window == top) timer = pollDoScroll.defer(); } Event.observe(window, ‘load’, fireContentLoadedEvent); })(); Element.addMethods(); /*——————————- DEPRECATED ——————————-*/ Hash.toQueryString = Object.toQueryString; var Toggle = { display: Element.toggle }; Element.Methods.childOf = Element.Methods.descendantOf; var Insertion = { Before: function(element, content) { return Element.insert(element, {before:content}); }, Top: function(element, content) { return Element.insert(element, {top:content}); }, Bottom: function(element, content) { return Element.insert(element, {bottom:content}); }, After: function(element, content) { return Element.insert(element, {after:content}); } }; var $continue = new Error(‘”throw $continue” is deprecated, use “return” instead’); var Position = { includeScrollOffsets: false, prepare: function() { this.deltaX = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0; this.deltaY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; }, within: function(element, x, y) { if (this.includeScrollOffsets) return this.withinIncludingScrolloffsets(element, x, y); this.xcomp = x; this.ycomp = y; this.offset = Element.cumulativeOffset(element); return (y >= this.offset[1] && y < this.offset[1] + element.offsetHeight && x >= this.offset[0] && x < this.offset[0] + element.offsetWidth); }, Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay withinIncludingScrolloffsets: function(element, x, y) { var offsetcache = Element.cumulativeScrollOffset(element); this.xcomp = x + offsetcache[0] – this.deltaX; this.ycomp = y + offsetcache[1] – this.deltaY; this.offset = Element.cumulativeOffset(element); return (this.ycomp >= this.offset[1] && this.ycomp < this.offset[1] + element.offsetHeight && this.xcomp >= this.offset[0] && this.xcomp < this.offset[0] + element.offsetWidth); }, overlap: function(mode, element) { if (!mode) return 0; if (mode == ‘vertical’) return ((this.offset[1] + element.offsetHeight) – this.ycomp) / element.offsetHeight; if (mode == ‘horizontal’) return ((this.offset[0] + element.offsetWidth) – this.xcomp) / element.offsetWidth; }, cumulativeOffset: Element.Methods.cumulativeOffset, positionedOffset: Element.Methods.positionedOffset, absolutize: function(element) { Position.prepare(); return Element.absolutize(element); }, relativize: function(element) { Position.prepare(); return Element.relativize(element); }, realOffset: Element.Methods.cumulativeScrollOffset, offsetParent: Element.Methods.getOffsetParent, page: Element.Methods.viewportOffset, clone: function(source, target, options) { options = options || { }; return Element.clonePosition(target, source, options); } }; /*————————————————————————–*/ if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){ function iter(name) { return name.blank() ? null : “[contains(concat(‘ ‘, @class, ‘ ‘), ‘ ” + name + ” ‘)]”; } var _getElementsByClassName = instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ? function(element, className) { className = className.toString().strip(); var cond = /\s/.test(className) ? $w(className).map(iter).join(”) : iter(className); return cond ? document._getElementsByXPath(‘.//*’ + cond, element) : []; } : function(element, className) { className = className.toString().strip(); var elements = [], classNames = (/\s/.test(className) ? $w(className) : null); if (!classNames && !className) return elements; var nodes = $(element).getElementsByTagName(‘*’); className = ‘ ‘ + className + ‘ ‘; for (var i = 0, child, cn; child = nodes[i]; i++) { if (child.className && (cn = ‘ ‘ + child.className + ‘ ‘) && (cn.include(className) || (classNames && classNames.all(function(name) { return !name.toString().blank() && cn.include(‘ ‘ + name + ‘ ‘); })))) elements.push(Element.extend(child)); } return elements; }; return function(className, parentElement) { return _getElementsByClassName( parentElement || document.body, className ); }; }(Element.Methods); /*————————————————————————–*/ Element.ClassNames = Class.create(); Element.ClassNames.prototype = { initialize: function(element) { this.element = $(element); }, _each: function(iterator) { this.element.className.split(/\s+/).select(function(name) { return name.length > 0; })._each(iterator); }, set: function(className) { this.element.className = className; }, add: function(classNameToAdd) { if (this.include(classNameToAdd)) return; this.set($A(this).concat(classNameToAdd).join(‘ ‘)); }, remove: function(classNameToRemove) { if (!this.include(classNameToRemove)) return; this.set($A(this).without(classNameToRemove).join(‘ ‘)); }, toString: function() { return $A(this).join(‘ ‘); } }; Object.extend(Element.ClassNames.prototype, Enumerable); /*————————————————————————–*/ (function() { window.Selector = Class.create({ initialize: function(expression) { this.expression = expression.strip(); }, findElements: function(rootElement) { return Prototype.Selector.select(this.expression, rootElement); }, match: function(element) { return Prototype.Selector.match(element, this.expression); }, toString: function() { return this.expression; }, inspect: function() { return “#”; } }); Object.extend(Selector, { matchElements: function(elements, expression) { var match = Prototype.Selector.match, results = []; for (var i = 0, length = elements.length; i < length; i++) { var element = elements[i]; if (match(element, expression)) { results.push(Element.extend(element)); } } return results; }, findElement: function(elements, expression, index) { index = index || 0; var matchIndex = 0, element; for (var i = 0, length = elements.length; i < length; i++) { element = elements[i]; if (Prototype.Selector.match(element, expression) && index === matchIndex++) { return Element.extend(element); } } }, findChildElements: function(element, expressions) { var selector = expressions.toArray().join(‘, ‘); return Prototype.Selector.select(selector, element || document); } }); })(); /*! jQuery v3.5.1 | (c) JS Foundation and other contributors | jquery.org/license */ !function(e,t){“use strict”;”object”==typeof module&&”object”==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error(“jQuery requires a window with a document”);return t(e)}:t(e)}(“undefined”!=typeof window?window:this,function(C,e){“use strict”;var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return”function”==typeof e&&”number”!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement(“script”);if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+””:”object”==typeof e||”function”==typeof e?n[o.call(e)]||”object”:typeof e}var f=”3.5.1″,S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&”length”in e&&e.length,n=w(e);return!m(e)&&!x(e)&&(“array”===n||0===t||”number”==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e< al; x++) { if(typeof a[x] === ‘function’) { if (FastInit.done ) { a[x](); } else { FastInit.f.push(a[x]); } } } }, listen : function() { if (/WebKit|khtml/i.test(navigator.userAgent)) { FastInit.timer = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { clearInterval(FastInit.timer); delete FastInit.timer; FastInit.onload(); }}, 10); } else if (document.addEventListener) { document.addEventListener(‘DOMContentLoaded’, FastInit.onload, false); } else if(!FastInit.iew32) { if(window.addEventListener) { window.addEventListener(‘load’, FastInit.onload, false); } else if (window.attachEvent) { return window.attachEvent(‘onload’, FastInit.onload); } } }, f:[],done:false,timer:null,iew32:false }; /*@cc_on @*/ /*@if (@_win32) FastInit.iew32 = true; document.write(‘–> = ” //So,that extractScripts won’t find commented scripts to extract //str =str.replace(new RegExp(‘\’, ‘img’), ”); page.delayAddExtractedScripts(str.extractScripts(), waitForVars, signalObject); }; // Evaluate any inline script – delay a bit to give the scripts above time to load // NOTE that this is not guaranteed to work – if there are delays loading and initializing // the scripts required then code in these scripts might fail to find the required variables // If it is for our code then updating waitForVars appropriately per script will work page.delayAddExtractedScripts = function (scripts, waitForVars, signalObject) { var count = 0; if (waitForVars.length === 0) { page.actuallyAddExtractedScripts(scripts, signalObject); } else { new PeriodicalExecuter( function( pe ) { if ( count < 100 ) { count++; if ( page.allVariablesDefined(waitForVars) ) { page.actuallyAddExtractedScripts(scripts, signalObject); pe.stop(); } } else // give up if it takes longer than 5s to load { page.actuallyAddExtractedScripts(scripts, signalObject); pe.stop(); } }.bind(this), 0.05 ); } }; page.variableDefined = function (avar) { if ( !window[avar] ) { if (avar.indexOf(‘.’) > 0) { var parts = avar.split(‘.’); var obj = window[parts[0]]; for (var partNum = 1; obj && partNum < parts.length; partNum++) { obj = obj[parts[partNum]]; } if (obj) { return true; } } return false; } return true; }; page.allVariablesDefined = function(vars) { var result = true; for ( var i = 0; i < vars.length; i++ ) { if ( !page.variableDefined(vars[i]) ) { result = false; break; } } return result; }; page.actuallyAddExtractedScripts = function (scripts, signalObject) { var scriptExecutionDelay = 0; if( signalObject ) { scriptExecutionDelay = signalObject.delayScriptExecution; if (scriptExecutionDelay === undefined) { scriptExecutionDelay = 0; } } if (FastInit !== undefined && typeof(FastInit.onload) === “function”) { FastInit.onload(); } scripts.each(function(script) { if ( script != ” ) { if ( Prototype.Browser.IE && window.execScript ) { ( function() { window.execScript( script ); }.delay( scriptExecutionDelay ) ); } else { ( function() { var scriptElem = new Element( ‘script’, { type : ‘text/javascript’ } ); var head = $$( ‘head’ )[ 0 ]; script = document.createTextNode( script ); scriptElem.appendChild( script ); head.appendChild( scriptElem ); head.removeChild( scriptElem ); }.delay( scriptExecutionDelay ) ); } } } ); if (signalObject) { if ( typeof( signalObject.evaluatingScripts ) === “function” ) { ( function() { signalObject.evaluatingScripts(); signalObject.evaluatingScripts = false; //reset function so another call will not unintentionally call this callback function. }.defer() ); } else { signalObject.evaluatingScripts = false; } } }; //When the browser page is resized, we use page.onResizeCleanSlateIframe( widthRate ) to determine the new width for the iframe. page.onResizeCleanSlateIframe = function( widthRatio ) { var iframeElement = $$(‘iframe.cleanSlate’)[0]; var iframeParentWidth = iframeElement.parentElement.scrollWidth; //We resize the iframe width according its parent element width(container width) and the ratio ( the ratio of iframe width to it’s parent width). iframeElement.style.width = parseInt( iframeParentWidth * widthRatio) + ‘px’; } //Set iframe height and width for fitting the size of embedded content. //This function is only called in method renderFileContentBody(…) in ContentRendererUtil.java when the iframe has been loaded. page.setIframeHeightAndWidth = function () { try { var iframeElement = $$(‘iframe.cleanSlate’)[0]; // Set default height and width for the iframe so that if any un-handled situation happens in this function, // the iframe still can be showed properly. var defaultHeight = 400; iframeElement.style.height = defaultHeight + ‘px’; iframeElement.style.width = ‘100%’; // If the current url of iframe is not file content url, we don’t set the height and width. if ( iframeElement.contentDocument.URL.indexOf(“/bbcswebdav”) === -1 ) { return; } // Start to handle the situation which the embedded file content contains multiple iframes/frames. var iframeHeight = iframeElement.contentDocument.body.scrollHeight; var iframeWidth = iframeElement.contentDocument.body.scrollWidth var containedFrames = [iframeElement.contentDocument.getElementsByTagName(“frame”) , iframeElement.contentDocument.getElementsByTagName(“iframe”)]; var isContainsMultiFrames = ( containedFrames[0].length === 0 && containedFrames[1].length === 0 ) ? false : true; if ( isContainsMultiFrames === true ) { var maxSizeArray = getMaxIframeContentSize(); iframeHeight = maxSizeArray.height; iframeWidth = maxSizeArray.width; } iframeElement.style.height = (iframeHeight > defaultHeight ? iframeHeight: defaultHeight) + ‘px’; iframeElement.style.width = iframeWidth + ‘px’; // As the iframe width is specified in ‘px’ above, causes the width would stay same when the browser page is resized, // so we attach ‘onresize’ listener here and then use page.onResizeCleanSlateIframe( widthRate ) to determine the new width for the iframe. var widthRatio = iframeWidth/iframeElement.parentElement.scrollWidth; // record the ratio of iframe width to its parent element width (container width) for caculating the new width. Event.observe( window, ‘resize’, page.onResizeCleanSlateIframe( widthRatio ) ); } catch(e){} // Go through all contained frames/Iframes for getting the max height and width. // TODO: Should handle iframeset in this function. function getMaxIframeContentSize() { var i = 0; var maxHeight = iframeHeight; var maxWidth = iframeWidth; try { for( i = 0; i < containedFrames.length; i++ ) { var j = 0; for( j = 0; j < containedFrames[i].length; j++ ) { var h = containedFrames[i][j].contentWindow.document.body.scrollHeight; var w = containedFrames[i][j].contentWindow.document.body.scrollWidth; maxHeight = ( maxHeight > h ) ? maxHeight : h; maxWidth = ( maxWidth > w ) ? maxWidth : w; } } } catch (e){} return {height:maxHeight , width:maxWidth}; } }; page.onResizeChannelIframe = function( channelExtRef ) { var frameId = ‘iframe’ + channelExtRef; var listId = ‘list_channel’ + channelExtRef; var f = $( frameId ); var fli = f.contentWindow.document.getElementById( listId ); if (fli) { f.style.height = fli.scrollHeight + 15 + “px”; } }; /** * Contains page-wide utility methods */ page.util = {}; /** * Returns whether the specific element has the specified class name. * Same as prototype’s Element.hasClassName, except it doesn’t extend the element (which is faster in IE). */ page.util.hasClassName = function ( element, className ) { var elementClassName = element.className; if ((typeof elementClassName == “undefined”) || elementClassName.length === 0) { return false; } if (elementClassName == className || elementClassName.match(new RegExp(“(^|\\s)” + className + “(\\s|$)”))) { return true; } return false; }; page.util.fireClick = function ( elem ) { if (Prototype.Browser.IE) { elem.fireEvent(“onclick”); } else { var evt = document.createEvent(“HTMLEvents”); evt.initEvent(“click”, true, true); elem.dispatchEvent(evt); } }; // Find an element with the given className, starting with the element passed in page.util.upToClass = function ( element, className ) { while (element && !page.util.hasClassName(element, className)) { element = element.parentNode; } return $(element); }; page.util.isRTL = function () { var els = document.getElementsByTagName(“html”); var is_rtl = (typeof(els) != ‘undefined’ && els && els.length == 1 && els[0].dir == ‘rtl’ ); return is_rtl ; }; page.util.allImagesLoaded = function (imgList) { var allDone = true; if (imgList) { for ( var i = 0, c = imgList.length; i < c; i++ ) { var animg = imgList[i]; // TODO – this doesn’t appear to work on IE. if ( !animg.complete ) { allDone = false; break; } } } return allDone; }; // Exposes (display but keep invisible) an invisible element for measurement // recursively traverses up the DOM looking for // a parent node of element whose display == ‘none’ // If found, sets its style to: display:block, position:absolute, and visibility:hidden // and saves it as element.hiddenNode so it can be easily unexposed page.util.exposeElementForMeasurement = function ( element ) { element = $(element); var e = element; var hiddenNode; // find parent node that is hidden while ( !hiddenNode && e && e.parentNode) { if ( $(e).getStyle(‘display’) === ‘none’) { hiddenNode = $(e); } e = $(e.parentNode); } if ( hiddenNode ) { // save original style attributes: visibility, position, & display element.hiddenNode = hiddenNode; var style = hiddenNode.style; var originalStyles = { visibility: style.visibility, position: style.position, display: style.display }; var newStyles = { visibility: ‘hidden’, display: ‘block’ }; if (originalStyles.position !== ‘fixed’) { newStyles.position = ‘absolute’; } hiddenNode.originalStyles = originalStyles; // set new style for: visibility, position, & display hiddenNode.setStyle( newStyles ); } }; // undo previous call to exposeElementForMeasurement page.util.unExposeElementForMeasurement = function ( element ) { element = $(element); if ( element && element.hiddenNode && element.hiddenNode.originalStyles ) { Element.setStyle( element.hiddenNode, element.hiddenNode.originalStyles ); element.hiddenNode.originalStyles = null; element.hiddenNode = null; } }; /** * Returns whether any part of the two elements overlap each other. */ page.util.elementsOverlap = function ( e1, e2 ) { var pos1 = $(e1).cumulativeOffset(); var a = { x1: pos1.left, y1: pos1.top, x2: pos1.left + e1.getWidth(), y2: pos1.top + e1.getHeight() }; var pos2 = $(e2).cumulativeOffset(); var b = { x1: pos2.left, y1: pos2.top, x2: pos2.left + e2.getWidth(), y2: pos2.top + e2.getHeight() }; return a.x1 < b.x2 && a.x2 > b.x1 && a.y1 < b.y2 && a.y2 > b.y1; }; /** * To handle the case where the focus is visible but too close to the bottom of the page, scroll the page up a bit. Note: when using scrollbar.js, use scrollBar.scrollTo() rather than focusAndScroll */ page.util.focusAndScroll= function(elem) { elem.focus(); return page.util.ensureVisible(elem); }; page.util.ensureVisible= function(elem) { var scrolltop = document.viewport.getScrollOffsets().top; var mytop = elem.cumulativeOffset()[1]; var height = document.viewport.getDimensions().height; var realtop = mytop – scrolltop; var thirty = height * 0.3; if (realtop > (height-thirty)) { var scrollDistance = realtop – thirty; window.scrollBy(0,scrollDistance); } return false; }; page.util.processJSProtoString = function (string, checkToken) { // This value must match the value passed as the 2nd parameter to this string. // The goal is to pass a known value, as a constant, through the javascript: pseudo-protocol // handler. We can then examine the result to determine the decoding method used by the current // browser. var sniffToken = ‘%C3%A9’; // There are three known decoding cases, non-translated, UTF8, and unescape if (checkToken === unescape(sniffToken)) { // Unescape decoded return decodeURIComponent(escape(string)); } else if (checkToken === sniffToken) { // Non-translated return decodeURIComponent(string); } else { // UTF8 Decoded/Unknown return string; } }; /** * Find the first action bar that precedes sourceElement * Returns the action bar div element if found, null otherwise * * @param sourceElement */ page.util.findPrecedingActionBar = function( sourceElement ) { var actionBar = null; // Loop through each ancestor of sourceElement, // starting with parent, until an action bar is found sourceElement.ancestors().each( function( item ) { actionBar = item.previous(‘div.tabActionBar’) || item.previous(‘div.actionBarMicro’) || item.previous(‘div.actionBar’); if (actionBar) { throw $break; } }); return actionBar; }; page.util.getLargestDimensions = function (element) { var width = 0; var height = 0; var dim; while (element != document) { dim = $(element).getDimensions(); if (dim.width > width) { width = dim.width; } if (dim.height > height) { height = dim.height; } element = element.up(); } return { width: width, height: height }; }; /* * Resize the current window so that it will fit the largest dimensions found for the given element. * Will also reposition on the screen if required to fit. Will not size larger than the screen. * NOTE that this will only work for popup windows – main windows are typically in a tabset in * the browser and they don’t allow resizing like this. That’s OK because the main use case * for this method is to make sure popup windows are resized appropriately for their content. */ page.util.resizeToContent = function (startElement) { var dim = page.util.getLargestDimensions(startElement); var newWidth = dim.width; newWidth += 25; // TODO: Haven’t figured out why I need this extra space yet… if (window.innerWidth > newWidth) { newWidth = window.innerWidth; } if (newWidth > screen.width) { newWidth = screen.width; } var newHeight = dim.height; newHeight += 100; // TODO: Haven’t figured out why I need this extra space yet if (window.innerHeight > newHeight) { newHeight = window.innerHeight; } if (newHeight > screen.height) { newHeight = screen.height; } var left = 0; var top = 0; if ( window.screenLeft ) { left = window.screenLeft; top = window.screenTop; } else if ( window.screenX ) { left = window.screenX; top = window.screenY; } if (left + newWidth > screen.width) { left = screen.width – newWidth; if (left < 0) { left = 0; } } if (top + newHeight > screen.height) { top = screen.height – newHeight; if (top < 0) { top = 0; } } window.moveTo(left,top); window.resizeTo(newWidth,newHeight); }; /** * Sets the css position of all li elements that are contained in action bars on the page. * Since z-index only works on positioned elements, this function can be used to ensure that * divs with a higher z-index will always appear on top of any action bars on the page. * * @param cssPosition */ page.util.setActionBarPosition = function( cssPosition ) { $$( ‘div.actionBar’, ‘div.tabActionBar’, ‘div.actionBarMicro’ ).each( function( actionbar ) { actionbar.select( ‘li’ ).each( function( li ) { li.setStyle( {position: cssPosition} ); }); }); }; /** * Returns true if we are currently running inside Ultra, false otherwise. * @returns {Boolean} */ page.util.insideUltra = function() { if ( top.__isUltraApp ) { return true; } return false; }; /** * Returns true if the current window’s parent is the Ultra app, false otherwise. * @returns {Boolean} */ page.util.parentWindowIsUltraApp = function() { if ( parent.__isUltraApp ) { //adding class to body to isolate spoecific css styles for classic views served in Ultra, primarily for mobile breakpoints document.body.addClassName(‘isUltra’); return true; } return false; }; /** * Utility method to broadcast event to angular realm * @param {string} name Event name to broadcast. * @param {…*} args Optional one or more arguments which will be passed onto the event listeners. * @returns {boolean} True if angular is available, false otherwise. */ page.util.broadcastToUltra = function( name, args ) { if ( page.util.insideUltra() ) { // Method upgraded to broadcast event from innermost window to top most window. // This will make sure it will check every window object until it has the event to broadcast. var currentWindow = window; var topWindow = window.top; var isTopWindow = false; while( currentWindow && !isTopWindow ) { isTopWindow = topWindow === window; if( currentWindow.angular ) { // Angular is available, so broadcast the event to Ultra var scope = currentWindow.angular.element( currentWindow.document ).injector().get( ‘$rootScope’ ); var broadcast = scope.$broadcast.apply( scope, arguments ); // Once broadcasted successfully boradcasted will get currentScope property if( ( broadcast && broadcast.hasOwnProperty( ‘currentScope’ ) ) || topWindow === currentWindow ) { currentWindow = null; } else { currentWindow = currentWindow.parent; } } else { currentWindow = currentWindow.parent; } } // If the event is from the Administration Panel then returning anything (true, false, null) will cause Firefox // to display the value returned (even null) overwriting the Administration Panel. Then when the peek is closed // the Administration Panel is no longer displayed. if ( name.endsWith( “admin-panel-open” ) ) { return; } return true; } return false; }; /** * Utility methods to pin the bottom Submit step at the bottom of window or * container whichever is applicable. * This function is invoked on all the pages which have the submit button being rendered either via stepSubmit tag or directly. * The pages including, but not limited to, * Course Item create/edit page * Course Video create/edit page * Edit/reply discussion message(s) on Course discussion thread page * Institution Domain create/edit page * Institution Brand customize page * The classic edit page of Configure Collaborate Web Conference in light box (See LRN-112422) * * Any time this function is being updated, the pages above or any page has the Submit button need be manually tested. The test should be performed on * the emulated mobile devices in addition to the desktop. Also, the test needs cover the two supported themes, as_2012 and as_2015. */ page.util.pinBottomSubmitStep = function( bottomSubmit, lightboxDiv ) { var placeHolderDividerName = ‘bottomSubmitPlaceHolder’; var submitStepFixedStyle = ‘submitStepFixed’; var spaceUnderLightbox = 0; var isSubmitOutOfLightbox = false; var isContainerOutOfLightbox = false; var container = bottomSubmit.parentElement; var viewPortHeight = document.viewport.getDimensions().height; var isPinned = page.util.hasClassName(bottomSubmit, submitStepFixedStyle); // bottomSubmitPlaceHolder holds the place of submit step within the // container when the step is pinned to bottom of window to make sure the // container doesn’t shrink. // It also be used to keep the original attributes for the submit step div, i.e. the width. var bottomSubmitPlaceHolder = document.getElementById(placeHolderDividerName); var bottomOfSubmit = parseInt(bottomSubmit.getBoundingClientRect().bottom, 10); if ( lightboxDiv && lightboxDiv.contains( container ) ) { var bottomOfLightbox = parseInt(lightboxDiv.getBoundingClientRect().bottom, 10); spaceUnderLightbox = viewPortHeight – bottomOfLightbox; isContainerOutOfLightbox = (parseInt(container.getBoundingClientRect().bottom, 10) > bottomOfLightbox); isSubmitOutOfLightbox = (bottomOfSubmit > bottomOfLightbox); } // In case the bottom of submit button is below then the bottom of window, or the container/submit button is out of available light box, // pin the submit step to the bottom of browser by adding the css class ‘submitStepFixed’. if (!isPinned && (( viewPortHeight – bottomOfSubmit ) < 0 || isContainerOutOfLightbox || isSubmitOutOfLightbox)) { bottomSubmit.addClassName(submitStepFixedStyle); if ( spaceUnderLightbox >0 ) { bottomSubmit.style.marginBottom = spaceUnderLightbox+’px’; } page.util.setPinnedBottomSubmitStepWidth( bottomSubmit, container ); if ( !bottomSubmitPlaceHolder ) { bottomSubmitPlaceHolder = document.createElement(‘div’); bottomSubmitPlaceHolder.id = placeHolderDividerName; container.insertBefore(bottomSubmitPlaceHolder,bottomSubmit); } bottomSubmitPlaceHolder.style.height = bottomSubmit.getDimensions().height + ‘px’; } else if ( isPinned ) { //The width of the pinned submit button div might need be updated upon the event of resizing. page.util.setPinnedBottomSubmitStepWidth( bottomSubmit, container ); // The submit button div should be set back to the container by removing the class ‘submitStepFixed’ // if the top of submit button is higher than the place holder. if ( !bottomSubmitPlaceHolder || (bottomSubmit.getBoundingClientRect().top > bottomSubmitPlaceHolder.getBoundingClientRect().top) ) { if ( bottomSubmitPlaceHolder ) { bottomSubmit.style.width = bottomSubmitPlaceHolder.style.width; bottomSubmitPlaceHolder.remove(); } bottomSubmit.style.marginBottom = ‘auto’; bottomSubmit.removeClassName( submitStepFixedStyle ); } } }; /** * Refresh pinning the bottom buttons. */ page.util.refreshPinBottomSubmitStep = function( ) { var bottomSubmitToBePinned = page.util.getBottomSubmitStep(); var lightboxDiv = page.util.upToClass( bottomSubmitToBePinned, “lb-content” ); if ( lightboxDiv && bottomSubmitToBePinned ) { page.util.pinBottomSubmitStep(bottomSubmitToBePinned, lightboxDiv); } }; /** * Sets the width for the pinned bottom submit div. */ page.util.setPinnedBottomSubmitStepWidth = function( pinnedBottomSubmit, container ) { var computedStyle; if (document.defaultView && document.defaultView.getComputedStyle) { computedStyle = document.defaultView.getComputedStyle(pinnedBottomSubmit, null); }; var pinnedButtonWidth = container.offsetWidth; if( pinnedButtonWidth == 0 ) { //Generally, the ‘container’ comes from ‘dataCollectionContainer’, which contains the appropriate width //for the offset. Sometimes, the container fetches the wrong parent (nested
• tags in the menu and stick them in a map/object of id to the li object $A(this.contextMenuDiv.getElementsByTagName(“li”)).each( function( listItem ) { if (listItem.hasClassName(“contextmenubar_top”)) { closeItem = listItem; } else { if (this.menuOrder.indexOf(listItem.id) > -1) { orderMap[listItem.id] = listItem; // add item to map } else { extraItems.push(listItem); // listItem id not specified in menuOrder, so add listItem to extraItems } } }.bind(this) ); // Remove all the content from the context menu div $A(this.contextMenuDiv.getElementsByTagName(“ul”)).each( function( list ) { Element.remove(list); }.bind(this) ); // Re-add the special “close” item as the first item. var ulElement = $(document.createElement(“ul”)); ulElement.setAttribute(‘role’,’presentation’); this.contextMenuDiv.insert({bottom:ulElement}); ulElement.insert({bottom:closeItem}); // Loop through the order, adding a
at the start, and starting a new
whenever a “*separator*” // is encountered, and adding the corresponding
o for each of the ids in the order using the map/object this.menuOrder.each( function( id ) { if (id == “*separator*”) { ulElement = $(document.createElement(“ul”)); ulElement.setAttribute(‘role’,’presentation’); this.contextMenuDiv.insert({bottom:ulElement}); } else { ulElement.insert({bottom:orderMap[id]}); } }.bind(this) ); // Add any extraItems to thier own ul if (extraItems.length > 0) { ulElement = $(document.createElement(“ul”)); ulElement.setAttribute(‘role’,’presentation’); this.contextMenuDiv.insert({bottom:ulElement}); extraItems.each( function( lineItem ) { ulElement.insert({bottom:lineItem}); }.bind(this) ); } // Remove any empty ULs and ensure that the added
s have id of form “cmul${num}_${uniqueId}” $A(this.contextMenuDiv.getElementsByTagName(“ul”)).findAll( function( list ) { if ( list.childElements().length === 0 ) { list.remove(); return false; } else { return true; } }).each( function( list, index ) { list.id = ‘cmul’+index+’_’+this.uniqueId; }.bind(this) ); }, processDynamicMenu : function() { if (this.dynamicMenu) { page.ContextMenu.closeAllContextMenus(); this.generateDynamicMenuHelper(this.afterMenuGeneration, false); } }, showContextMenuLink : function() { page.ContextMenu.showContextMenuLink(this.displayContextMenuLink); }, hideContextMenuLink : function() { page.ContextMenu.hideContextMenuLink(this.displayContextMenuLink); }, generateDynamicMenu : function(event) { page.ContextMenu.closeAllContextMenus(); if (this.dynamicMenu) { this.generateDynamicMenuHelper(this.afterMenuGeneration, true); } else { this.afterMenuGeneration.call(this, null, true); } $(event).preventDefault(); }, generateDynamicMenuHelper : function(callBackOnSuccess, showMenu) { var context_parameters = this.contextParameters; var menu_generator_url = this.menuGeneratorURL; var nav = this.nav; var overwriteNavItems = this.overwriteNavItems; if ( context_parameters ) { context_parameters = context_parameters.toQueryParams(); } else { context_parameters = {}; } var params = Object.extend({nav_item: nav }, context_parameters ); params = Object.extend( params, { overwriteNavItems : overwriteNavItems } ); var dynamicMenusCacheKey = menu_generator_url + JSON.stringify( params ); if ( undefined !== page.ContextMenu.dynamicMenus.get(dynamicMenusCacheKey) ) { this.afterMenuGeneration.call(this, dynamicMenusCacheKey, showMenu); } else { // on mobile the onClick and onFocus/onMouseOver events happen at the same time. To prevent two ajax calls to the // menu_generator_url add an empty string to the dynamicMenu cache. Upstream methods close open menus, so this // will be ‘rendered’ by the afterMenuGeneration call but not won’t change anything because its an empty string page.ContextMenu.dynamicMenus.set(dynamicMenusCacheKey, “”); new Ajax.Request(menu_generator_url, { method: ‘post’, parameters: params, onSuccess: callBackOnSuccess.bind( this, dynamicMenusCacheKey, showMenu ), onFailure: function(e) { page.ContextMenu.dynamicMenus.set( undefined ); } // reset in case of error }); } }, onDisplayLinkClick: function( event ) { page.ContextMenu.closeAllContextMenus(); if (this.dynamicMenu) { this.generateDynamicMenu(event); } else { this.showMenu(); //focus on the first menu item (function() { if (this.contextMenuDiv.style.display != ‘none’) { this.contextMenuDiv.down(“a”).focus(); } }.bind(this).defer()); $(event).preventDefault(); } }, onCloseLinkClick: function( event, doNotSetFocusOnClick ) { this.close(); var setFocusOnDisplayContextMenuLink = true; // grade center (in non-accessible mode) hides displayContextMenuLink onMouseOut, so we need to make sure it’s doNotSetFocusOnClose flag is not set // before setting focus. if ( this.displayContextMenuLink.doNotSetFocusOnClose !== undefined && this.displayContextMenuLink.doNotSetFocusOnClose ) { setFocusOnDisplayContextMenuLink = false; } // We may not want to set focus on displayContextMenuLink when one of the menu items (other than Close Menu) is clicked. // Initially this behavior was required for Grade Center Quick Comment of a grade in the grid (see getGradeContextMenuItems function in gradebookgrid_cellctrl.js) if ( doNotSetFocusOnClick !== undefined && doNotSetFocusOnClick ) { setFocusOnDisplayContextMenuLink = false; } if ( setFocusOnDisplayContextMenuLink ) { this.displayContextMenuLink.focus(); } if (event) { Event.stop( event ); } }, close: function() { // Delay the removal of the element from the page so firefox will continue to process // the click on the menu item chosen (otherwise it stops processing as soon as we remove the // element resulting in the menu not actually working) (function() { this.closeNow(); }.bind(this).delay(0.1)); }, closeNow: function() { if (this.contextMenuDiv.style.display != “none”) { var links = this.contextMenuDiv.getElementsBySelector(“li > a”); links.each(function(link) { link.blur(); }); this.contextMenuDiv.style.display = “none”; Element.remove( this.contextMenuDiv ); if ( this.shim ) { this.shim.close(); } } } }; /** * Function called to change the ‘arrow’ of a breadcrumb to face downward when they are clicked for the * contextual menu. * @param uniqId – unique number which identifies the crumb which was clicked * @param size – the size of the breadcrumb * @return */ page.ContextMenu.changeArrowInBreadcrumb = function (uniqId, event) { page.ContextMenu.alignArrowsInBreadcrumb(event);
ORDER A PLAGIARISM FREE PAPER NOW
$(‘arrowContext_’+uniqId).addClassName(‘contextArrowDown’).removeClassName(‘contextArrow’); //Stop the click event to propagate anymore -else all arrows will be aligned again Event.stop( event ); return false; }; //To align all breadcrumb arrows in one direction page.ContextMenu.alignArrowsInBreadcrumb = function (event) { if ($(‘breadcrumbs’) !== null){ var bList = $($(‘breadcrumbs’).getElementsByTagName(‘ol’)[0]); var bs = bList.immediateDescendants(); if (bs.length !== null && bs.length >1){ for (var i = 2; i <= bs.length; i++) { var arrowSpan = $(‘arrowContext_’+i); if (arrowSpan !== null ){ $(‘arrowContext_’+i).addClassName(‘contextArrow’).removeClassName(‘contextArrowDown’); } } } } return false; }; // “static” methods page.ContextMenu.LI = function(event, divId, forceMenuRefresh) { page.LazyInit(event,[‘focus’,’mouseover’],’new page.ContextMenu(page.util.upToClass(target,\’contextMenuContainer\’), \” + divId + ‘\’,’ + forceMenuRefresh + ‘);’); }; page.ContextMenu.dynamicMenus = $H() page.ContextMenu.contextMenus = []; // _Open_ context menus page.ContextMenu.registerContextMenu = function( menu ) { page.ContextMenu.contextMenus.push( menu ); }; page.ContextMenu.hiddenDivs = $H(); // All the menu divs on the page – only needed for cases such as view_spreadsheet2.js where we try to modify the menus outside this framework page.ContextMenu.hideMenuDiv = function( uniqueId, firstInsideInventoryCard) { var linkId = ‘cmlink_’ + uniqueId; var link = document.getElementById(linkId); if (link && !link.savedDiv ) { element = page.ContextMenu.locateMenuDiv( link, uniqueId ); if (element) { link.savedDiv = element; page.ContextMenu.hiddenDivs.set(uniqueId,element); Element.remove( element ); if (firstInsideInventoryCard) { var theCard = page.util.upToClass(link, ‘block’); if (theCard) { var menuSpanToMove = page.util.upToClass(link,’contextMenuContainer inlineMenuItems’); if (menuSpanToMove) { menuSpanToMove.style.display=’inline’; theCard.insert({bottom:menuSpanToMove}); } } } } } }; /* * This takes in contextMenuDiv or any element inside contextMenuDiv (div element with ‘cmdiv_{uniqueId}’ as its id) and * make necessary changes to show the element in DOM including its container(s) and the link to the context menu. */ page.ContextMenu.showContextMenuAndLink = function(elem) { var menuItem; var menuGroup; var menuDiv; if(elem.hasClassName(‘cmdiv’)) { menuDiv = elem; Array.prototype.slice.call(menuDiv.getElementsByTagName(‘ul’)).each(function(menuGroup) { menuGroup.removeClassName(‘cmul-hide’); Array.prototype.slice.call(menuGroup.getElementsByTagName(‘li’)).each(function(menuItem) { $j(menuItem).removeClass(‘cmli-hide cmitem-hide’); Array.prototype.slice.call(menuItem.getElementsByTagName(‘a’)).each(function(menuItemLink) { menuItemLink.removeClassName(‘cmitem-hide’); }); }); }); } else { var elemTagNameUpperCase = elem.tagName.toUpperCase() if(“UL” === elemTagNameUpperCase) { menuGroup = elem; Array.prototype.slice.call(menuGroup.getElementsByTagName(‘li’)).each(function(menuItem) { $j(menuItem).removeClass(‘cmli-hide cmitem-hide’); Array.prototype.slice.call(menuItem.getElementsByTagName(‘a’)).each(function(menuItemLink) { menuItemLink.removeClassName(‘cmitem-hide’); }); }); } else { if(“A” === elemTagNameUpperCase) { menuItem = elem.up(‘li’); elem.removeClassName(‘cmitem-hide’); } else if(“SPAN” === elemTagNameUpperCase) { menuItem = elem.up(‘li’); } else if(“LI” === elemTagNameUpperCase) { menuItem = elem; Array.prototype.slice.call(menuItem.getElementsByTagName(‘a’)).each(function(menuItemLink) { menuItemLink.removeClassName(‘cmitem-hide’); }); } else { return; } $j(menuItem).removeClass(‘cmli-hide cmitem-hide’); menuGroup = menuItem.up(‘ul’); } menuGroup.removeClassName(‘cmul-hide’); menuDiv = page.util.upToClass(menuGroup,’cmdiv’); } var emptyMenuItem = menuDiv.down(“.contextmenu_empty”); if(emptyMenuItem) { emptyMenuItem.up(‘ul’).remove(); } page.ContextMenu.updateContextMenuLinkVisibility(menuDiv, true) }; /* * This takes in contextMenuDiv or any element inside contextMenuDiv (div element with ‘cmdiv_{uniqueId}’ as its id) and * update the visibility of the (context menu) link that’s for the menu */ page.ContextMenu.updateContextMenuLinkVisibility = function(elem, isShow) { var ctxMenuLink = page.ContextMenu.locateMenuLink(elem); if(ctxMenuLink) { if(isShow) { page.ContextMenu.showContextMenuLink(ctxMenuLink); } else { page.ContextMenu.hideContextMenuLink(ctxMenuLink); } } }; /* * This takes in contextMenuDiv or any element inside contextMenuDiv (div element with ‘cmdiv_{uniqueId}’ as its id) and * locate its corresponding context menu link in DOM */ page.ContextMenu.locateMenuLink = function(elem) { var ctxMenuDiv; if(elem.hasClassName(‘cmdiv’)) { ctxMenuDiv = elem; } else { ctxMenuDiv = page.util.upToClass(elem,’cmdiv’); } var uniqueId = ctxMenuDiv.id.split(‘_’)[1]; return $(‘cmlink_’+uniqueId); }; page.ContextMenu.hideContextMenuLink = function(link) { if( link && page.util.hasClassName(link, ‘cmimg’) ) { link.addClassName(‘cmimg-hide’); } }; page.ContextMenu.showContextMenuLink = function(link) { if( link && page.util.hasClassName(link, ‘cmimg’) ) { link.removeClassName(‘cmimg-hide’); } }; page.ContextMenu.locateMenuDiv = function( link, uniqueId ) { var elementId = ‘cmdiv_’ + uniqueId; var element = link.nextSibling; // Should be the text between the link and div but check anyways if ( !element || element.id != elementId ) { element = element.nextSibling; if ( !element || element.id != elementId) { element = document.getElementById(elementId); } } return element; }; page.ContextMenu.addDivs = function() { $H(page.ContextMenu.hiddenDivs).values().each(function(ele) { document.body.appendChild(ele); }); }; page.ContextMenu.removeDivs = function() { $H(page.ContextMenu.hiddenDivs).values().each(function(ele) { Element.remove(ele); }); }; page.ContextMenu.closeAllContextMenus = function( event ) { var deferClose = false; if ( event ) { var e = Event.findElement( event, ‘a’ ); if ( e && e.href.indexOf(“#contextMenu”) >= 0 ) { Event.stop( event ); return; } deferClose = true; } page.ContextMenu.contextMenus.each( function( menu ) { if ( menu != this ) { if (deferClose) { menu.close(); } else { menu.closeNow(); } } }); page.ContextMenu.contextMenus = []; }; /** * Enables flyout menus to be opened using a keyboard or mouse. Enables * them to be viewed properly in IE as well. */ page.FlyoutMenu = Class.create(); page.FlyoutMenu.prototype = { initialize: function( subMenuListItem ) { if ( !Event.KEY_SPACE ) { Event.KEY_SPACE = 32; } this.subMenuListItem = $(subMenuListItem); // LRN-149616 Menus should use button instead of anchor tag to open the menu. // If a button is not found, fall back to searching for an anchor tag. this.menuLink = $(subMenuListItem.getElementsBySelector(‘> button’)[0]); if (!this.menuLink) { this.menuLink = $(subMenuListItem.getElementsByTagName(‘a’)[0]); } //special case to render iframe shim under new course content build menu if (this.subMenuListItem.hasClassName(‘bcContent’)) { var buildContentDiv = this.subMenuListItem.down(“div.flyout”); if ( !buildContentDiv ) { this.subMenu = $(subMenuListItem.getElementsByTagName(‘ul’)[0]); } else { this.subMenu = buildContentDiv; } } else { this.subMenu = $(subMenuListItem.getElementsByTagName(‘ul’)[0]); } this.menuLink.flyoutMenu = this; // calculate the next/previous tab stops this.previousSibling = this.subMenuListItem.previous(); while ( this.previousSibling && (!this.previousSibling.down(‘a’) || !this.previousSibling.visible()) ) { this.previousSibling = this.previousSibling.previous(); } this.nextSibling = this.subMenuListItem.next(); while ( this.nextSibling && (!this.nextSibling.down(‘a’) || !this.nextSibling.visible()) ) { this.nextSibling = this.nextSibling.next(); } var rumble = $(this.subMenuListItem.parentNode.parentNode); this.inListActionBar = rumble && ( rumble.hasClassName(“rumble_top”) || rumble.hasClassName(“rumble”) ); Event.observe( this.menuLink, ‘mouseover’, this.onOpen.bindAsEventListener( this ) ); Event.observe( subMenuListItem, ‘mouseout’, this.onClose.bindAsEventListener( this ) ); Event.observe( this.menuLink, ‘click’, this.onLinkOpen.bindAsEventListener( this ) ); Event.observe( this.subMenuListItem, ‘keydown’, this.onKeyPress.bindAsEventListener( this ) ); $A( this.subMenu.getElementsByTagName(‘li’) ).each ( function( li ) { $A(li.getElementsByTagName(‘a’)).each( function( link ) { Event.observe( link, ‘focus’, this.onAnchorFocus.bindAsEventListener( this ) ); Event.observe( link, ‘blur’, this.onAnchorBlur.bindAsEventListener( this ) ); Event.observe( link, ‘click’, this.onLinkClick.bindAsEventListener( this, link ) ); }.bind( this ) ); }.bind( this ) ); this.initARIA(); this.enabled = true; }, initARIA: function() { var inListActionBar = this.inListActionBar; if ( inListActionBar ) { this.subMenuListItem.up(‘ul’).setAttribute( “role”, “menubar” ); } this.subMenuListItem.setAttribute( “role”, “presentation” ); this.subMenu.setAttribute( “role”, “menu” ); this.subMenu.setAttribute( “aria-hidden”, “true” ); if ( !this.menuLink.hasClassName(“notMenuLabel”) ) { this.menuLink.setAttribute( “aria-expanded”, “false” ); this.menuLink.setAttribute( “aria-haspopup”, “true” ); this.menuLink.setAttribute( “aria-controls”, this.subMenu.id ); this.menuLink.setAttribute( “role”, “button” ); this.subMenu.setAttribute( “aria-labelledby”, this.menuLink.id ); } $A( this.subMenu.getElementsByTagName(‘a’) ).each ( function( link ) { link.setAttribute( “role”, “menuitem” ); link.parentNode.setAttribute( “role”, “presentation” ); if ( !link.parentNode.hasClassName(“current”) ) { link.setAttribute( “tabindex”, “-1” ); } else { link.setAttribute( “tabindex”, “0” ); } // List action bars have onclick handlers that prevent submission of the page // if no items are selected, so we can’t register new onclicks here because // otherwise we can’t stop them from executing. if ( !inListActionBar ) { if ( !link.href.include(“#”) ) { Event.observe( link, ‘click’, function() { if ( this.ohref.toLowerCase().startsWith(“javascript”) ) { eval(decodeURIComponent(this.ohref) ); } else { if ( this.target ) { window.open( this.ohref, this.target ); } else { window.location = this.ohref; } } } ); link.ohref = link.href; link.removeAttribute( “href” ); link.tabIndex = “-1″; link.style.cursor = ‘pointer’; // make it look like a link. } } }); }, setEnabled: function( enabled ) { this.enabled = enabled; if ( !enabled ) { this.subMenu.setStyle({ display: ” }); } }, onKeyPress: function( event ) { if (!this.enabled) { return; } var key = event.keyCode || event.which; var elem = Event.element ( event ); var children, index, link; if ( key == Event.KEY_UP ) { children = this.subMenu.getElementsBySelector(“li > a”); index = children.indexOf( elem ); if ( index > 0 ) { children[index – 1].focus(); } else if ( index === 0 ) { children[children.length – 1].focus(); // wrap to bottom } Event.stop( event ); } else if ( key == Event.KEY_DOWN ) { children = this.subMenu.getElementsBySelector(“li > a”); index = children.indexOf( elem ); if ( index == -1 ) { this.open(); (function() { this.subMenu.down(“li > a”).focus(); }.bind(this).defer()); } else if ( index < ( children.length – 1 ) ) { children[index + 1].focus(); } else if ( index == ( children.length – 1 ) ) { children[0].focus(); // wrap to top } Event.stop( event ); } else if ( key == Event.KEY_LEFT ) { if ( !this.previousSibling || ( this.previousSibling.hasClassName(“mainButton”) || this.previousSibling.hasClassName(“mainButtonType”) ) ) { this.executeTab( event, true, true ); } else if ( this.previousSibling ) { link = this.previousSibling.getElementsByTagName(‘a’)[0]; if ( !link || !this.previousSibling.hasClassName(“sub”) ) { return; } this.close(); page.util.fireClick( link ); Event.stop( event ); } } else if ( key == Event.KEY_RIGHT ) { if ( !this.nextSibling || ( this.nextSibling.hasClassName(“mainButton”) || this.nextSibling.hasClassName(“mainButtonType”) ) ) { this.executeTab( event, true, false ); } else if ( this.nextSibling ) { link = this.nextSibling.getElementsByTagName(‘a’)[0]; if ( !link || !this.nextSibling.hasClassName(“sub”) ) { return; } this.close(); page.util.fireClick( link ); Event.stop( event ); } } else if ( key == Event.KEY_ESC ) { this.close(); this.menuLink.focus(); Event.stop( event ); } else if ( (key == Event.KEY_RETURN || key == Event.KEY_SPACE) && !this.inListActionBar ) { page.util.fireClick( elem ); Event.stop( event ); } else if ( key == Event.KEY_TAB ) { this.executeTab( event, false, event.shiftKey ); } }, executeTab: function( event, forceMenuLinkTab, shift ) { var elem = Event.element ( event ); var link; if ( ( elem != this.menuLink ) || forceMenuLinkTab ) { if ( shift ) { // Go to previous menu if ( this.previousSibling ) { link = this.previousSibling.getElementsByTagName(‘a’)[0]; if ( link ) { link.focus(); } else { this.menuLink.focus(); } } else { this.menuLink.focus(); } } else { // Go to next menu if ( this.nextSibling ) { link = this.nextSibling.getElementsByTagName(‘a’)[0]; if ( link ) { link.focus(); } else { this.menuLink.focus(); } } else { this.menuLink.focus(); } } this.close(); Event.stop( event ); } }, onOpen: function( event ) { if (!this.enabled) { return; } this.open(); }, onClose: function( event ) { var to = $(event.relatedTarget || event.toElement); if ( !to || to.up(‘li.sub’) != this.subMenuListItem ) { this.close(); } }, onLinkOpen: function( event ) { if (!this.enabled) { return; } this.open(); (function() { this.subMenu.down(“li > a”).focus(); }.bind(this).defer()); Event.stop( event ); }, onToggle: function( event ) { if (!this.enabled) { return; } var alreadyShown = this.subMenu.getStyle(‘display’) === ‘block’; if ( alreadyShown ) { this.close(); } else { this.open(); } Event.stop( event ); }, resizeAfterShowHide: function() { // TODO – ideally this would just resize the outer div, but closing and opening ‘works’ this.close(); this.open(); }, open: function() { var alreadyShown = this.subMenu.getStyle(‘display’) === ‘block’; // If the menu is already showing (i.e. as_ce4 theme, we don’t need to position it) if ( !alreadyShown ) { // Set position of action bar elements to static to enable z-index stack order page.util.setActionBarPosition( ‘static’ ); var menuTop = this.subMenuListItem.getHeight(); if ( this.subMenu.hasClassName( ‘narrow’ ) ) { menuTop = 0; } this.subMenuListItem.setStyle( {position: ‘relative’} ); this.subMenu.setAttribute( “aria-hidden”, “false” ); this.menuLink.setAttribute( “aria-expanded”, “true” ); this.subMenu.setStyle( { display: ‘block’, zIndex: ‘999999’, top: menuTop+’px’, left: ‘0px’, width: ”, height: ”, overflowY: ” }); var offset = Position.cumulativeOffset( this.subMenuListItem ); var menuDims = this.subMenu.getDimensionsEx(); var menuHeight = menuDims.height; var popupWidth = this.subMenu.getWidth(); var subListItemDims = this.subMenuListItem.getDimensions(); var menuWidth = subListItemDims.width; var viewportDimensions = document.viewport.getDimensions(); var scrollOffsets = document.viewport.getScrollOffsets(); var gnav = $(‘globalNavPageNavArea’); var gnavHeight = 0; if (window.self === window.top) { if (gnav) { var gdim = gnav.getDimensions() gnavHeight = gdim.height; } viewportDimensions.height -= gnavHeight; var gnavContent = $(‘globalNavPageContentArea’); var gnavScroll = 0; if (gnavContent) { gnavScroll = gnavContent.scrollTop; } scrollOffsets.top += gnavScroll; var offsetTop = offset[1] – scrollOffsets.top – gnavHeight; } this.subMenu.flyoutMenu = this; if ( (offsetTop + menuHeight + subListItemDims.height) > viewportDimensions.height) { if ( (offsetTop – menuHeight) > 0 ) { // if menu goes below viewport but still fits on-page, show it above button this.subMenu.setStyle({ top: ‘-‘+menuHeight+’px’ }); } else { // we need to create scrollbars var newWidth = this.subMenu.getWidth() + 15; popupWidth = newWidth + 5; var newMenuHeight = viewportDimensions.height – (offsetTop + subListItemDims.height) – 20; var newMenuTop = menuTop; if (newMenuHeight < offsetTop) { // More space above than below newMenuHeight = offsetTop; newMenuTop = -offsetTop; } this.subMenu.setStyle( { display: ‘block’, zIndex: ‘999999’, top: newMenuTop+’px’, left: ‘0px’, width: newWidth + ‘px’, height: newMenuHeight + ‘px’, overflowY: ‘auto’ }); } } var offsetLeft = offset[0] – scrollOffsets.left; if ( (offsetLeft + popupWidth) > viewportDimensions.width ) { var subMenuWidth = this.subMenuListItem.getWidth(); var newLeft = popupWidth – (viewportDimensions.width-offsetLeft); if ((newLeft > 0) && (newLeft < offsetLeft)) { newLeft = -newLeft; } else { newLeft = -offsetLeft; } this.subMenu.setStyle({ left: newLeft+’px’ }); } if ( page.util.isRTL() ) { var newRight = 0; if ( (offsetLeft + menuWidth) – popupWidth < 0 ) { newRight = (offsetLeft + menuWidth) – popupWidth; } this.subMenu.setStyle({ left: ”, right: newRight+’px’}); } if (!this.shim) { this.shim = new page.popupShim( this.subMenu); } this.shim.open(); } }, close: function() { // Reset position of action bar elements to relative page.util.setActionBarPosition( ‘relative’ ); this.menuLink.blur(); this.subMenuListItem.setStyle({position: ”}); this.subMenu.setAttribute( “aria-hidden”, “true” ); this.menuLink.setAttribute( “aria-expanded”, “false” ); this.subMenu.setStyle({ display: ”, top: ”, left: ”, width: ”, height: ”, overflowY: ” }); if ( this.shim ) { this.shim.close(); } }, onLinkClick: function( event, link ) { if (!this.enabled) { return; } setTimeout( this.blurLink.bind( this, link), 100); }, blurLink: function( link ) { link.blur(); if (page.util.hasClassName( link, “donotclose” )) { link.focus(); } else { this.close(); } }, onAnchorFocus: function ( event ) { if (!this.enabled) { return; } var link = Event.element( event ); link.setStyle({ backgroundColor: ‘#FFFFFF’ }); }, onAnchorBlur: function( event ) { var link = Event.element( event ); link.setStyle({ backgroundColor: ” }); } }; /** * Class for providing functionality to menu palettes */ page.PaletteController = Class.create(); page.PaletteController.prototype = { /** * Constructor * * @param paletteIdStr Unique string identifier for a palette * @param expandCollapseIdStr Id value of anchor tag to be assigned * the palette expand/collapse functionality * @param closeOtherPalettesWhenOpen Whether to close all other palettes when this one is open */ initialize: function( paletteIdStr, expandCollapseIdStr, closeOtherPalettesWhenOpen, collapsed ) { // palette id string this.paletteItemStr = paletteIdStr; // palette element this.paletteItem = $(this.paletteItemStr); // default id string to palette contents container element this.defaultContentsContainerId = page.PaletteController.getDefaultContentsContainerId(this.paletteItemStr); // the currently active palette contents container element this.activeContentsContainer = $(this.defaultContentsContainerId); // expand/collapse palette toggle element this.paletteToggle = $(expandCollapseIdStr); if (this.paletteToggle) { Event.observe(this.paletteToggle, ‘click’, this.toggleExpandCollapsePalette.bindAsEventListener(this)); } this.closeOtherPalettesWhenOpen = closeOtherPalettesWhenOpen; page.PaletteController.registerPaletteBox(this); if (collapsed) { this.collapsePalette(true); } }, /** * Set the currently active palette contents container element * * @param container palette contents container element */ setActiveContentsContainer: function ( container ) { this.activeContentsContainer = container; }, /** * Get the currently active palette contents container element * * @return palette contents container element */ getActiveContentsContainer: function () { return this.activeContentsContainer; }, /** * Expands the palette if it’s not already expanded. * * @return palette contents container element */ expandPalette: function ( doNotPersist ) { var itemPalClass = []; itemPalClass = this.paletteItem.className.split(” “); var h2 = $(this.paletteItemStr+”_paletteTitleHeading”); var expandCollapseLink = h2.getElementsByTagName(‘a’)[0]; if ( !this.useFirstTagForExpandCollapse( h2 ) ) { expandCollapseLink = h2.getElementsByTagName(‘a’)[1]; } var itemList = this.activeContentsContainer; if ( itemList.style.display == “none” ) { itemList.style.display = “block”; itemPalClass.length = itemPalClass.length – 1; this.paletteItem.className = itemPalClass.join(” “); h2.className = “”; var itemTitle = expandCollapseLink.innerHTML.stripTags().trim(); if ( !this.useFirstTagForExpandCollapse( h2 ) ) { itemTitle = h2.getElementsByTagName(‘a’)[0].innerHTML.stripTags(); } expandCollapseLink.title = page.bundle.getString(‘expandCollapse.collapse.section.param’, itemTitle); expandCollapseLink.setAttribute(“aria-expanded”, “true”); } if ( doNotPersist ) { return; } this.saveSessionStickyInfo( itemList.id, itemList.style.display ); }, /** * Collapses the palette if it’s not already collapsed. * * @return palette contents container element */ collapsePalette: function ( doNotPersist ) { var itemPalClass = []; itemPalClass = this.paletteItem.className.split(” “); // Note – h2 is actually a div, not an h2 🙂 var h2 = $(this.paletteItemStr+”_paletteTitleHeading”); var expandCollapseLink = h2.getElementsByTagName(‘a’)[0]; if ( !this.useFirstTagForExpandCollapse( h2 ) ) { expandCollapseLink = h2.getElementsByTagName(‘a’)[1]; } var itemList = this.activeContentsContainer; if ( itemList.style.display != “none” ) { itemList.style.display = “none”; itemPalClass[itemPalClass.length] = ‘navPaletteCol’; this.paletteItem.className = itemPalClass.join(” “); if (itemPalClass.indexOf(‘controlpanel’) != -1) { } if (itemPalClass.indexOf(‘listCm’)!=-1) { h2.className = “listCmCol”; // colors h2 background (removes background image) } if (itemPalClass.indexOf(‘tools’) != -1) { h2.className = “toolsCol”; } var itemTitle = expandCollapseLink.innerHTML.stripTags(); if ( !this.useFirstTagForExpandCollapse( h2 ) ) { itemTitle = h2.getElementsByTagName(‘a’)[0].innerHTML.stripTags().trim(); } expandCollapseLink.title = page.bundle.getString(‘expandCollapse.expand.section.param’, itemTitle); expandCollapseLink.setAttribute(“aria-expanded”, “false”); } if (doNotPersist) { return; } this.saveSessionStickyInfo( itemList.id, itemList.style.display ); }, /** * Takes in a key value pair to save to the session as sticky data. * * @param key The key that will have the current course id appended to it to be saved to the session. * @param value The value to the key. */ saveSessionStickyInfo: function( key, value ) { /* Get the course id off of the global variable if exists, so that data is saved per * user session per course. If course doesn’t exist, use empty string. */ var current_course_id = window.course_id ? window.course_id : “”; ClientCache.setItem( key + current_course_id, value ); }, /** * Whether the first tag has js onclick event binding on it for palette collapse/expand * * @param h2 */ useFirstTagForExpandCollapse: function ( h2 ) { return h2.getElementsByTagName(‘a’)[0].id.indexOf( “noneExpandCollapseTag” ) > -1 ? false : true; }, /** * Toggles a palette from expand to collapse and vice versa. * * @param event Optional event object if this method was bound to event. */ toggleExpandCollapsePalette: function ( event, doNotPersist ) { // To prevent default event behavior if ( event ) { Event.stop( event ); } if ( this.activeContentsContainer.style.display == “none” ) { // palette is currently closed, so we will be expanding it if ( this.closeOtherPalettesWhenOpen ) { // if closeOtherPalettesWhenOpen is set to true for this palette, close all other palettes page.PaletteController.closeAllOtherPalettes(this.paletteItemStr, doNotPersist); } this.expandPalette( doNotPersist ); } else { // palette is currently expanded, so we will be collapsing it this.collapsePalette( doNotPersist ); } } }; // “static” methods page.PaletteController.paletteBoxes = []; page.PaletteController.registerPaletteBox = function( paletteBox ) { page.PaletteController.paletteBoxes.push( paletteBox ); }; /** * Get the palette controller js object by palette id * * @param paletteId */ page.PaletteController.getPaletteControllerObjById = function( paletteId ) { return page.PaletteController.paletteBoxes.find( function( pb ) { return ( pb.paletteItemStr == paletteId ); } ); }; /** * Closes all palettes except the specified one * * @param paletteToKeepOpen */ page.PaletteController.closeAllOtherPalettes = function( paletteToKeepOpen, doNotPersist ) { for(var i = 0; i < page.PaletteController.paletteBoxes.length; i++) { var paletteItem = page.PaletteController.paletteBoxes[i]; if (paletteToKeepOpen !== paletteItem.paletteItemStr) { paletteItem.collapsePalette( doNotPersist ); } } }; /** * Toggles (expand/collapse) the contents of a nav palette by palette id * * @param paletteId * @param doNotPersist – optional param to suppress persisting state, default is to persist */ page.PaletteController.toggleExpandCollapsePalette = function( paletteId, doNotPersist ) { var paletteObj = page.PaletteController.getPaletteControllerObjById( paletteId ); paletteObj.toggleExpandCollapsePalette( null, doNotPersist); }; /** * Collapses the contents of a nav palette by palette id * * @param paletteId * @param doNotPersist – optional param to suppress persisting state, default is to persist */ page.PaletteController.collapsePalette = function( paletteId, doNotPersist ) { var paletteObj = page.PaletteController.getPaletteControllerObjById( paletteId ); paletteObj.collapsePalette( doNotPersist); }; /** * Expand the contents of a nav palette by palette id * * @param paletteId * @param doNotPersist – optional param to suppress persisting state, default is to persist */ page.PaletteController.expandPalette = function( paletteId, doNotPersist ) { var paletteObj = page.PaletteController.getPaletteControllerObjById( paletteId ); paletteObj.expandPalette( doNotPersist); }; /** * Set the active palette contents container (element containing the body * contents of a palette). The active contents container is used to toggle * visibility when expanding and collapsing menu palettes. * * @param paletteId * @param paletteContentsContainer Optional container to set. * If not given, the palette’s active * container will not be changed. * @return The new active palette contents container element. * If no paletteContentsContainer element was passed, * The current active palette contents container element * will be returned. */ page.PaletteController.setActivePaletteContentsContainer = function( paletteId, paletteContentsContainer ) { var paletteObj = page.PaletteController.getPaletteControllerObjById( paletteId ); if ( paletteContentsContainer ) { paletteObj.setActiveContentsContainer( paletteContentsContainer ); } return paletteObj.getActiveContentsContainer(); }; /* * Get the default palette contents container id string * * @param paletteId */ page.PaletteController.getDefaultContentsContainerId = function( paletteId ) { return paletteId + “_contents”; }; /** * Class for providing expand/collapse functionality (with dynamic loading) */ page.ItemExpander = Class.create(); page.ItemExpander.prototype = { /** * Constructor * – expandLink – the link that when clicked will expand/collapse the item * – expandArea – the actual area that will get expanded/collapsed (if the item is dynamically loaded, this area will be populated dynamically) * – expandText – the text to show as a tooltip on the link for expanding * – collapseText – the text to show as a tooltip on the link for collapsing * – expandTitleText – the customized text for link title afer expanding the item; if null/undefined, use expandText * – collapseTitleText – the customized text for link title after collapsing the item;if null/undefined, use collapseText * – dynamic – whether the contents are dynamically loaded * – dynamicUrl – the URL to get the contents of the item from * – contextParameters – additional URL parameters to add when calling the dynamicUrl * – sticky – load/save expand state from UserData; true if null/undefined * – expanded – initially expanded; false if null/undefined * – useClientCache – if true, lookup the state from ClientCache instead of userdatadwrfacade */ initialize: function( expandLink, expandArea, expandText, collapseText, dynamic, dynamicUrl, contextParameters, expandTitleText, collapseTitleText, sticky, expanded, useClientCache ) { this.expandLink = $(expandLink); this.expandArea = $s(expandArea); // Register the expander so it can be found page.ItemExpander.itemExpanderMap[this.expandLink.id] = this; this.expandText = expandText.unescapeHTML(); this.collapseText = collapseText.unescapeHTML(); if ( expandTitleText !== null && expandTitleText !== undefined ) { this.expandTitleText = expandTitleText.unescapeHTML(); } else { this.expandTitleText = this.expandText; } if ( collapseTitleText !== null && collapseTitleText !== undefined ) { this.collapseTitleText = collapseTitleText.unescapeHTML(); } else { this.collapseTitleText = this.collapseText; } this.dynamic = dynamic; this.dynamicUrl = dynamicUrl; if ( contextParameters !== null && contextParameters !== undefined ) { this.contextParameters = contextParameters.toQueryParams(); } else { this.contextParameters = {}; } this.sticky = ( sticky !== null && sticky !== undefined ) ? sticky : true; this.expanded = ( expanded !== null && expanded !== undefined ) ? expanded : false; this.useClientCache = ( useClientCache !== null && useClientCache !== undefined ) ? useClientCache : false; this.hasContents = !this.dynamic; if ( this.sticky ) { // get the course id off of the global variable if exists, because data is saved per user session per course var current_course_id = ( ( typeof course_id != “undefined” ) && course_id !== null ) ? course_id : “”; if ( this.useClientCache ) { this.getAvailableResponse( ClientCache.getItem( this.expandLink.id + current_course_id ) ); } else { UserDataDWRFacade.getStringTempScope( this.expandLink.id + current_course_id, this.getAvailableResponse.bind( this ) ); } } this.expandCollapse( !this.expanded ); Event.observe( this.expandLink, “click”, this.onToggleClick.bindAsEventListener( this ) ); }, getAvailableResponse : function ( response ) { var originalExpanded = this.expanded ; var cachedExpanded = false; if ( response && response.length > 0 ) { if ( response == ‘true’ ) { cachedExpanded = true; } else { cachedExpanded = false; } } if ( originalExpanded != cachedExpanded ) { //because we want the menu to be in the cached state, //we pass in the opposite so that expandCollapse changes the menu state. this.expandCollapse(originalExpanded); } }, onToggleClick: function( event ) { if ( event ) { Event.stop( event ); } this.expandCollapse(this.expanded); if ( this.sticky ) { // get the course id off of the global variable if exists, so that data is saved per user session per course var current_course_id = ( (typeof course_id != “undefined”) && course_id !== null ) ? course_id : “”; if ( this.useClientCache ) { ClientCache.setItem( this.expandLink.id + current_course_id, this.expanded ); } else { UserDataDWRFacade.setStringTempScope( this.expandLink.id + current_course_id, this.expanded ); } } }, expandCollapse: function(shouldCollapse) { var combo; if ( shouldCollapse ) //Collapse the item { $(this.expandArea).hide(); this.expandLink.title = this.expandTitleText; this.expandLink.setAttribute(“aria-expanded”, “false”); if ( this.expandLink.hasClassName(“comboLink_active”) ) { combo = this.expandLink.up(“li”).down(“.submenuLink_active”); this.expandLink.removeClassName(“comboLink_active”); this.expandLink.addClassName(“comboLink”); if ( combo ) { combo.removeClassName(“submenuLink_active”); combo.addClassName(“submenuLink”); } } else { this.expandLink.removeClassName(“open”); } this.expanded = false; } else //Expand the item { if ( this.hasContents ) { $(this.expandArea).setStyle({ zoom: 1 }); this.expandArea.show(); this.expandLink.title = this.collapseTitleText; this.expandLink.setAttribute(“aria-expanded”, “true”); if ( this.expandLink.hasClassName(“comboLink”) ) { combo = this.expandLink.up(“li”).down(“.submenuLink”); this.expandLink.removeClassName(“comboLink”); this.expandLink.addClassName(“comboLink_active”); if ( combo ) { combo.removeClassName(“submenuLink”); combo.addClassName(“submenuLink_active”); } } else { this.expandLink.addClassName(“open”); } } else if ( this.dynamic ) { this.loadData(); } this.expanded = true; } }, loadData: function() { new Ajax.Request( this.dynamicUrl, { method: “post”, parameters: this.contextParameters, onSuccess: this.afterLoadData.bind( this ) }); }, afterLoadData: function( req ) { try { var result = req.responseText.evalJSON( true ); if ( result.success != “true” ) { new page.InlineConfirmation(“error”, result.errorMessage, false ); } else { this.hasContents = true; this.expandArea.innerHTML = result.itemContents; $(this.expandArea).setStyle({ zoom: 1 }); this.expandArea.show(); this.expandLink.title = this.collapseTitleText; this.expandLink.setAttribute(“aria-expanded”, “true”); if ( this.expandLink.hasClassName(“comboLink”) ) { var combo = this.expandLink.up(“li”).down(“.submenuLink”); this.expandLink.removeClassName(“comboLink”); this.expandLink.addClassName(“comboLink_active”); if ( combo ) { combo.removeClassName(“submenuLink”); combo.addClassName(“submenuLink_active”); } } else { this.expandLink.addClassName(“open”); } this.expanded = true; } } catch ( e ) { //Invalid response } } }; page.ItemExpander.itemExpanderMap = {}; /** * Class for controlling the “breadcrumb expansion” (i.e. the “…” hiding the inner * breadcrumbs) */ page.BreadcrumbExpander = Class.create(); page.BreadcrumbExpander.prototype = { initialize: function( breadcrumbBar ) { var breadcrumbListElement = $(breadcrumbBar.getElementsByTagName(‘ol’)[0]); var breadcrumbs = breadcrumbListElement.immediateDescendants(); if ( breadcrumbs.length > 4 ) { this.ellipsis = document.createElement(“li”); var ellipsisLink = document.createElement(“a”); ellipsisLink.setAttribute(“href”, “#”); ellipsisLink.setAttribute(“title”, page.bundle.getString(‘breadcrumbs.expand’) ); ellipsisLink.innerHTML = “…”; this.ellipsis.appendChild( ellipsisLink ); this.ellipsis = Element.extend( this.ellipsis ); Event.observe( ellipsisLink, “click”, this.onEllipsisClick.bindAsEventListener( this ) ); this.hiddenItems = $A(breadcrumbs.slice(2,breadcrumbs.length – 2)); breadcrumbListElement.insertBefore( this.ellipsis, this.hiddenItems[0] ); this.hiddenItems.invoke( “hide” ); } // Make sure the breadcrumbs don’t run into the mode switcher var breadcrumbContainer = $(breadcrumbListElement.parentNode); var modeSwitcher = breadcrumbBar.down(‘.modeSwitchWrap’); if ( modeSwitcher ) { var containerWidth = breadcrumbContainer.getWidth(); var containerOffset = breadcrumbContainer.cumulativeOffset(); var modeSwitcherOffset = modeSwitcher.cumulativeOffset(); var modeSwitcherWidth = modeSwitcher.getWidth(); if ( page.util.isRTL() ) { if ( modeSwitcherOffset[0] + modeSwitcherWidth > containerOffset[0] ) { breadcrumbContainer.setStyle({ paddingLeft: ( modeSwitcherOffset[0] + modeSwitcherWidth ) + ‘px’} ); } } // else //{ // breadcrumbContainer.setStyle({ paddingRight: ( containerWidth – ( modeSwitcherOffset[0] – containerOffset[0] ) ) + ‘px’} ); //} } }, onEllipsisClick: function( event ) { this.hiddenItems.invoke( “show” ); this.ellipsis.hide(); Event.stop( event ); } }; page.getCssClassByType = function ( type ) { var cssClass = “bad”; if ( type === “success” ) { cssClass = “good”; } else if ( type === “warning” ) { cssClass = “warningReceipt”; } else if ( type === “adding” ) { cssClass = “adding”; } else if ( type === “removing” ) { cssClass = “removing”; } return cssClass; } /** * Dynamically creates an inline confirmation. * * refreshMessage – if we allow only one receipt on the page, refresh the message; even if we display only one instance * of message on the page, we can change the content of the message */ page.InlineConfirmation = Class.create(); page.InlineConfirmation.prototype = { initialize: function( type, message, showRefreshLink, oneReceiptPerPage, refreshMessage, focusOnRender ) { if ( Object.isUndefined( focusOnRender ) ) { focusOnRender = true; } var receiptId = $s(‘receipt_id’); // do not insert a duplicate receipt, if one already exists if( receiptId && oneReceiptPerPage ) { if( !refreshMessage ) { return; } else { var receiptDivElement = $( receiptId ); receiptDivElement.parentNode.removeChild( receiptDivElement ); } } var cssClass = page.getCssClassByType(type); var contentPane = $(‘contentPanel’) || $(‘portalPane’); var receiptHtml = ‘
‘+ ”+message+”; if ( showRefreshLink ) { receiptHtml += ‘ ‘ + page.bundle.getString(“inlineconfirmation.refresh”) + ”; } receiptHtml += ‘
‘; contentPane.insert({top:receiptHtml}); // use aria live region to announce this confirmation message rather than setting focus to it. (Too many things are fighting over setting focus) // Note: if this confirmation is invoked from a menu handler, it may not announce if focus is lost when the menu closes. See how courseTheme.js sets focus before invoking. var insertedA = contentPane.down(‘span.inlineReceiptSpan’); insertedA.setAttribute(“aria-live”,”assertive”); insertedA.parentNode.setAttribute(“role”,”application”); (function() { insertedA.update( insertedA.innerHTML ); }.defer(2)); // update live region so it is announced if( focusOnRender ) { page.util.focusAndScroll( insertedA ); } } }; page.NestedInlineConfirmationIdCounter = 0; page.NestedInlineConfirmation = Class.create(); page.NestedInlineConfirmation.prototype = { initialize: function( type, message, showRefreshLink, previousElement,showCloseLink, extracss, insertBefore, oneReceiptPerPage, fadeAway, focusDiv, fadingTime, insertTop, receiptDivId, focusOnRender, additionalArrowCss ) { new page.NestedInlineConfirmationEx({ type : type, message : message, showRefreshLink : showRefreshLink, previousElement : previousElement, showCloseLink : showCloseLink, extracss : (extracss) ? extracss : “”, insertBefore : insertBefore, oneReceiptPerPage : oneReceiptPerPage, fadeAway : fadeAway, focusDiv : focusDiv, fadingTime : fadingTime, insertTop : insertTop, receiptDivId : receiptDivId, focusOnRender : focusOnRender, additionalArrowCss : additionalArrowCss}); } }; page.NestedInlineConfirmationEx = Class.create(); page.NestedInlineConfirmationEx.prototype = { initialize: function( options ) { this.options = Object.extend( { type : null, message : null, showRefreshLink : null, previousElement: null, showCloseLink : null, extracss: “”, insertBefore: null, oneReceiptPerPage: null, fadeAway : null, focusDiv : null, fadingTime: null, insertTop: null, receiptDivId : null, focusOnRender : true, axOnly : false, additionalArrowCss: “” }, options ); var receiptId = $s(‘receipt_nested_id’); // do not insert a duplicate receipt, if one already exists var newDivId = ‘receipt_nested_id’; if(receiptId) { if (this.options.oneReceiptPerPage) { return; } newDivId = newDivId + (page.NestedInlineConfirmationIdCounter++); } // if receiptDivId is provided, we are explicitly using it as the id for the new receipt replacing the existing receipt with the same id if (this.options.receiptDivId) { // Remove the old message with the same receiptDivId if there is one before adding a new one if ( $( this.options.receiptDivId ) != null ) { $( this.options.receiptDivId ).remove(); } newDivId = this.options.receiptDivId; } var cssClass = page.getCssClassByType(this.options.type); if ( this.options.axOnly ) { cssClass = cssClass + ‘ hideoff’; //overrides a few options explicitly for our purpose of using the receipt only for AX this.options.fadeAway = true; this.options.showCloseLink = false; } var arrowSpan = ”; if (this.options.extracss.indexOf( “point”, 0 ) != -1) { if ( this.options.additionalArrowCss ) { arrowSpan = ”; } else { arrowSpan = ”; } } var contentPane = $(this.options.previousElement); if (!contentPane) { // TODO – if we can’t find the element we wanted to insert before, is it OK to just drop the notification? return; } var receiptHtml = ‘
‘; } if ( this.options.insertBefore ) { contentPane.insert({before:receiptHtml}); } else if (this.options.insertTop) { contentPane.insert({top:receiptHtml}); } else { contentPane.insert({after:receiptHtml}); } this.insertedDiv = this.options.insertBefore?contentPane.previousSibling:(this.options.insertTop?contentPane.firstChild:contentPane.nextSibling); $(this.insertedDiv).show(); var insertedA = $(this.insertedDiv).down(‘span.inlineReceiptSpan’); var fadingDuration = this.options.fadingTime ? this.options.fadingTime : 5000; // For all cases (focus or not), set the aria assertive attribute to make sure this is announced by the screen reader insertedA.setAttribute(“aria-live”,”assertive”); this.insertedDiv.setAttribute(“role”,”application”); (function() { insertedA.update( insertedA.innerHTML ); }.defer(2)); // update live region so it is announced (needed for jaws 12) if ( this.options.focusOnRender ) { try { ( function() { try { if ( this.options.focusDiv ) { page.util.focusAndScroll( $( this.options.focusDiv ) ); } else { page.util.focusAndScroll( insertedA ); } } catch ( focusError ) { // Ignore focus errors. These can happens sometimes on IE if focus is set on an element that is located // inside another element that has recently been switched from a hidden state to a visible one. } }.defer() ); } catch ( focusError ) { // Ignore focus errors. These can happens sometimes on IE if focus is set on an element that is located // inside another element that has recently been switched from a hidden state to a visible one. } } else { // not setting focus to this confirmation – but still make sure it is visible. if ( this.options.focusDiv ) { page.util.ensureVisible( $( this.options.focusDiv ) ); } else { page.util.ensureVisible( insertedA ); } } if ( this.options.fadeAway ) { setTimeout( function() { Element.fade( $(this.insertedDiv), { duration : 0.3 } ); }.bind(this), fadingDuration ); } }, close: function() { if ( this.insertedDiv ) { this.insertedDiv.remove(); } } }; /** * Dynamically creates a Floating confirmation. * This floating confirmation is a control that its position depends of the referenced element, * Its width depends of the message, and its attached directly to the body of the page. * * type – It defines the css class to be used, that is determined by getCssClassByType. * message – the text to display * referencedElementId – the id of the element that this confirmation will take as reference to be showed. * verticalPosition – Vertically the confirmation could be displayed on: top, bottom, middle, top-inside and bottom-inside, of the referenced element. * horizontalPosition – Horizontally the confirmation could be displayed on: left, right, center, left-inside and right-inside, of the referenced element. * focusBackElementId – after close the confirmation where the focus should be redirected. */ page.FloatingConfirmation = Class.create(); page.FloatingConfirmation.prototype = { initialize: function ( type, message, referencedElementId, verticalPosition, horizontalPosition, focusBackElementId ) { page.removeFloatingConfirmation(); let divContainer = document.createElement( ‘div’ ); divContainer.setAttribute( “id”, ‘floating_receipt’ ); divContainer.className = “miniReceipt ” + page.getCssClassByType( type ); divContainer.style.position = “absolute”; divContainer.style.whiteSpace = “nowrap”; divContainer.style.padding = “1px”; divContainer.setAttribute( “aria-describedby”, ‘floating_receipt_description’ ); divContainer.setAttribute( “aria-modal”, ‘true’ ); divContainer.setAttribute( “role”, ‘alertdialog’ ); let spanMessage = document.createElement( ‘span’ ); spanMessage.innerText = message; spanMessage.tabIndex = -1; spanMessage.className = “inlineReceiptSpan”; spanMessage.setAttribute( “id”, ‘floating_receipt_description’ ); let closeButton = document.createElement( ‘button’ ); closeButton.className = “btn-with-img”; closeButton.title = page.bundle.getString(“inlineconfirmation.close”); closeButton.setAttribute( “arial-label”, page.bundle.getString(“inlineconfirmation.close”)); closeButton.addEventListener( “click”, function () { page.removeFloatingConfirmation(); if ( focusBackElementId ) { page.util.focusAndScroll( $( focusBackElementId ) ); } }, false ); let closeImage = document.createElement( ‘img’ ); closeImage.alt = page.bundle.getString(“inlineconfirmation.close”); closeImage.src = getCdnURL( “/images/ci/ng/close_mini.gif” ); closeImage.style.width = “13px”; closeButton.appendChild( closeImage ); divContainer.appendChild( spanMessage ); divContainer.appendChild( closeButton ); document.body.appendChild( divContainer ); let referencedElement = $( referencedElementId ); if ( referencedElement ) { this.setConfirmationPosition( divContainer, referencedElement, verticalPosition, horizontalPosition ); } page.util.focusAndScroll( spanMessage ); }, setConfirmationPosition: function ( divContainer, referencedElement, verticalPosition, horizontalPosition ) { let referenceOffSet = Element.viewportOffset(referencedElement); referenceOffSet.top = referenceOffSet.top + document.viewport.getScrollOffsets().top; referenceOffSet.left = referenceOffSet.left + document.viewport.getScrollOffsets().left; divContainer.style.top = ( referenceOffSet.top- divContainer.offsetHeight ) + “px”; if ( verticalPosition && verticalPosition === “bottom” ) { divContainer.style.top = ( referenceOffSet.top+ referencedElement.offsetHeight ) + “px”; } else if ( verticalPosition && referencedElement === “middle” ) { divContainer.style.top = ( referenceOffSet.top+ ( referencedElement.offsetHeight / 2 ) – ( divContainer.offsetHeight / 2 ) ) + “px”; } else if ( verticalPosition && verticalPosition === “top-inside” ) { divContainer.style.top = referenceOffSet.top+ “px”; } else if ( verticalPosition && verticalPosition === “bottom-inside” ) { divContainer.style.top = ( referenceOffSet.top+ referencedElement.offsetHeight – divContainer.offsetHeight ) + “px”; } if ( page.util.isRTL() ) { if ( horizontalPosition === “left” ) { horizontalPosition = “right”; } else if ( horizontalPosition === “right” ) { horizontalPosition = “left”; } else if ( horizontalPosition === “left-inside” ) { horizontalPosition = “right-inside”; } else if ( horizontalPosition === “right-inside” ) { horizontalPosition = “left-inside”; } } divContainer.style.left = ( referenceOffSet.left – divContainer.offsetWidth ) + “px”; if ( horizontalPosition && horizontalPosition === “right” ) { divContainer.style.left = ( referenceOffSet.left + referencedElement.offsetWidth ) + “px”; } else if ( horizontalPosition && horizontalPosition === “center” ) { divContainer.style.left = ( referenceOffSet.left + ( referencedElement.offsetWidth / 2 ) – ( divContainer.offsetWidth / 2 ) ) + “px”; } else if ( horizontalPosition && horizontalPosition === “left-inside” ) { divContainer.style.left = referenceOffSet.left + “px”; } else if ( horizontalPosition && horizontalPosition === “right-inside” ) { divContainer.style.left = ( referenceOffSet.left + referencedElement.offsetWidth – divContainer.offsetWidth ) + “px”; } } }; page.removeFloatingConfirmation = function () { var oldFloatingConfirmation = $( “floating_receipt” ); if ( oldFloatingConfirmation ) { Element.remove( oldFloatingConfirmation ); } } page.NestedInlineFadeAwayConfirmation = Class.create(); page.NestedInlineFadeAwayConfirmation.prototype = { initialize: function( type, message, showRefreshLink, element,showCloseLink, insertBefore, time ) { var fadingDuration = time ? time : 2000; new page.NestedInlineConfirmation(type, message, showRefreshLink, element,showCloseLink, “”, insertBefore, null, true, null, fadingDuration ); } }; page.NestedInlineFadeAwaySingleConfirmation = Class.create(); page.NestedInlineFadeAwaySingleConfirmation.prototype = { initialize: function( type, message, showRefreshLink, element,showCloseLink, insertBefore, time, newDivId, insertTop ) { var fadingDuration = time ? time : 2000; new page.NestedInlineConfirmation(type, message, showRefreshLink, element,showCloseLink, “”, insertBefore, false /*only one instance*/, true, null, fadingDuration, insertTop, newDivId ); } }; /** * Make sure the container as position: relative so that the offset can work */ page.MiniReceipt = Class.create(); page.MiniReceipt.prototype = { initialize: function( message, containerElement, top, left, time ) { var visibleDuration = time ? time : 2000; var top = top?top:-22; // usually show receipt above var left = left?left:0; var alreadyExistingReceipt = $( containerElement ).down( “div.miniReceipt” ); if ( alreadyExistingReceipt ) { alreadyExistingReceipt.hide( ); } var receiptHtml = ‘
‘; var receiptElement = $( containerElement ).insert( { top:receiptHtml } ).firstDescendant( ); $( containerElement ).select(); receiptElement.show( ); setTimeout( function() { Element.fade( receiptElement, {duration:0.3, afterFinish: function() { receiptElement.remove(); } } ); }, visibleDuration ); } }; page.extendedHelp = function( helpattributes, windowName ) { window.helpwin = window.open(‘/webapps/blackboard/execute/viewExtendedHelp?’ + helpattributes,windowName,’menubar=1,resizable=1,scrollbars=1,status=1,width=480,height=600′); window.helpwin.focus(); }; page.decoratePageBanner = function() { var bannerDiv = $(‘pageBanner’); // TODO: review this logic – we used to actually add a style to containerDiv but // we do not need it anymore – does the pagetitlediv hiding depend on containerdiv existing? probably, so leaving var containerDiv = $(‘contentPanel’) || $(‘contentPane’); if ( bannerDiv && containerDiv ) { // hide empty title bar if ( !$(‘pageTitleText’) && $(‘pageTitleDiv’) ) { $(‘pageTitleDiv’).hide(); } } }; page.initializeSinglePopupPage = function( pageId ) { // Initialize the single popup page, make sure the window will be closed by clicking submit or cancel, and the parent // window will be refreshed after submit. var items = document.forms; for ( var i = 0; i < items.length; i++ ) { var formItem = items[ i ]; formItem.observe( ‘submit’, function() { (function() { window.close(); if( window.opener.refreshConfirm ) { window.opener.refreshConfirm(pageId); } }.defer()); } ); //TODO: Delete the reference to top_Cancel after floating bottom submit proven works. if ( formItem.top_Cancel ) { Event.observe( formItem.top_Cancel, ‘click’, function( event ) { Event.stop( event ); window.close(); } ); } if ( formItem.bottom_Cancel ) { Event.observe( formItem.bottom_Cancel, ‘click’, function( event ) { Event.stop( event ); window.close(); } ); } } }; page.openLightbox = function( link, title, url, width, height ) { var lightboxParam = { defaultDimensions : { w : width ? width : 1100, h : height ? height : 800 }, contents : ”, title : title, closeOnBodyClick : false, showCloseLink : true, useDefaultDimensionsAsMinimumSize : true }; var lightboxInstance = new lightbox.Lightbox( lightboxParam ); lightboxInstance.open(); }; page.printAndClose = function() { (function() { window.print(); window.close(); }.defer()); }; /** * Utility for data collection step manipulation */ page.steps = {}; page.steps.HIDE = “hide”; page.steps.SHOW = “show”; /** * Hide or show an array of steps given the step ids and * renumber all visible steps on the page. * * @param action – either page.steps.HIDE or page.steps.SHOW * @param stepIdArr – string array of step ids */ page.steps.hideShowAndRenumber = function ( action, stepIdArr ) { // hide or show each of the step ids given ($A(stepIdArr)).each( function( stepId ) { page.steps.hideShow( action, stepId ); }); // get all H3 elements that contain css class of “steptitle” var stepTitleTags = []; $A(document.getElementsByTagName(‘h3’)).each( function( tag ) { if ( page.util.hasClassName( tag, ‘steptitle’ ) ) { stepTitleTags.push( $(tag) ); } }); // starting at number 1, renumber all of the visible steps var number = 1; stepTitleTags.each(function( stepTitleTag ) { if ( stepTitleTag.up(‘div’).visible() ) { stepTitleTag.down(‘span’).update(number); number++; } }); }; /** * Hide or show a single step given the step id. * * @param action – either page.steps.HIDE or page.steps.SHOW * @param stepId – string identifier to a single step */ page.steps.hideShow = function ( action, stepId ) { if ( action == page.steps.SHOW ) { $(stepId).show(); } else if ( action == page.steps.HIDE ) { $(stepId).hide(); } }; /** * Initializing the Expand/Collapse of the Step */ page.steps.initCollapsibleStep = function ( ) { $A( document.getElementsByClassName( “collapsibleStepTitle” ) ).each( function( stepTitle ) { Event.observe( $( stepTitle ), “click”, this.page.steps.collapsibleStep.bindAsEventListener( this, stepTitle ) ); Event.observe( $( stepTitle ), “keydown”, function( event ) { var key = event.keyCode || event.which; if ( key == Event.KEY_RETURN || key == 32 ) { page.steps.collapsibleStep( event, stepTitle ); } } ); }); }; page.steps.collapsibleStep = function( event, stepTitle ) { var content = $( stepTitle ).up().down(“div”); if ( content.visible() ) { stepTitle.removeClassName( “collapsibleStepExpanded” ); content.removeClassName( “collapsibleStepContentExpanded” ); Effect.toggle(content.id, “slide”, { duration: 0.5 }); content.setAttribute(“aria-hidden”, “true”); stepTitle.setAttribute(“aria-expanded”, “false”); } else { stepTitle.addClassName( “collapsibleStepExpanded” ); content.addClassName( “collapsibleStepContentExpanded” ); Effect.toggle(content.id, “slide”, { duration: 0.5 } ); content.setAttribute(“aria-hidden”, “false”); stepTitle.setAttribute(“aria-expanded”, “true”); } Event.stop( event ); }; page.showChangeTextSizeHelp = function() { page.extendedHelp(‘internalhandle=change_text_size&helpkey=change_text_size’,’change_text_size’ ); return false; }; page.showAccessibilityOptions = function() { var win = window.open(‘/webapps/portal/execute/changePersonalStyle?cmd=showAccessibilityOptions’, ‘accessibilityOptions’,’menubar=1,resizable=1,scrollbars=1,status=1,width=768,height=600′); win.focus(); }; page.toggleContrast = function( ) { new Ajax.Request(‘/webapps/portal/execute/changePersonalStyle?cmd=toggleContrast’, { onSuccess: function(transport, json) { var fsWin; if (window.top.nav) { fsWin = window.top; } else if (window.opener && window.opener.top.nav) { fsWin = window.opener.top; window.close(); } if (fsWin) { fsWin.nav.location.reload(); fsWin.content.location.reload(); } else { window.top.location.reload(); } } }); return false; }; page.showPrivacyPolicy = function(cookieNonce, isFramesetSupported) { cookieConsent = new CookieConsent(‘/webapps/privacy-disclosure/’); cookieConsent.showPolicy( cookieNonce, isFramesetSupported ); }; /** * IFrame-based shim used with popups so they render on top of all other page elements (including applets) */ page.popupShim = Class.create(); page.popupShim.prototype = { initialize: function( popup ) { this.popup = popup; }, close: function( ) { this.toggleOverlappingEmbeds( false ); }, open: function( ) { this.toggleOverlappingEmbeds( true ); }, toggleOverlappingEmbeds: function( turnOff ) { [’embed’,’object’,’applet’,’select’].each( function( tag ) { var elems = document.getElementsByTagName( tag ); for ( var i = 0, l = elems.length; i < l; i++ ) { var e = $(elems[i]); /* Only show/hide overlapping object if the element is visible in the first place, otherwise there is no point. * Note that visible() checks the display property, and behaves differently from the visibility property being * set below, so we’re safe when this method is being called with turn off|on. */ if( e.visible() ) { if ( !turnOff || ( page.util.elementsOverlap( this.popup, e ) && !e.descendantOf( this.popup ) ) ) { elems[i].style.visibility = ( turnOff ? ‘hidden’ : ” ); } } } }.bind( this ) ); } }; /** * Looks through the children of the specified element for links with the specified * class name, and if it finds any, autowires lightboxes to them. If lightbox.js/effects.js * hasn’t already been loaded, load it. */ page.LightboxInitializer = Class.create( { initialize: function( className, parentElement, justThisParent ) { this.className = className; if (justThisParent) { this.parentElement = parentElement; } var links = parentElement.getElementsByTagName(‘a’); for ( var i = 0, l = links.length; i < l; i++ ) { if ( page.util.hasClassName( links[i], className ) ) { if ( window.lightbox && window.Effect) { this._autowire(); } else { this._load(); } break; } } }, _autowire: function() { lightbox.autowireLightboxes( this.className, this.parentElement ); }, _load: function() { var h = $$(‘head’)[0]; // TODO: This code does not take version into account (so immediately after an upgrade this won’t get the new file)… var scs = ( !window.lightbox ? [getCdnURL(‘/javascript/ngui/lightbox.js’)] : []).concat( !window.Effect ? [‘/javascript/scriptaculous/effects.js’] : [] ); scs.each( function( sc ) { var s = new Element(‘script’, { type: ‘text/javascript’, src: getCdnURL(sc) } ); h.appendChild( s ); }); this._wait(); }, _wait: function() { var count = 0; new PeriodicalExecuter( function( pe ) { if ( count < 100 ) { count++; if ( window.lightbox && window.Effect ) { pe.stop(); this._autowire(); } } else // give up if it takes longer than 5s to load lightbox.js/effects.js { pe.stop(); } }.bind(this), 0.05 ); } }); page.util.flyoutMenuMainButtonKeyboardHandler = function( event ) { var key = event.keyCode || event.which; if (key == Event.KEY_LEFT || key == Event.KEY_RIGHT) { var elem = Event.element( event ); var target = elem.up( ‘li’ ); while ( true ) { if ( key == Event.KEY_LEFT ) { target = target.previous(); } else if ( key == Event.KEY_RIGHT ) { target = target.next(); } if ( !target || page.util.hasClassName( target, ‘sub’ ) || page.util.hasClassName( target, ‘mainButton’ ) || page.util.hasClassName( target, ‘mainButtonType’ ) ) { break; } } if ( target ) { var menuLinks = $A( target.getElementsByTagName( ‘a’ ) ); if ( menuLinks && menuLinks.length > 0 ) { menuLinks[ 0 ].focus(); Event.stop( event ); } } } }; page.util.initFlyoutMenuBehaviourForListActionMenuItems = function( container ) { //Initialize accessible flyout menu behavior if ( !container ) { container = document; } var uls = document.getElementsByTagName(‘ul’); if (uls) { var numUls = uls.length; for (var i = 0; i < numUls; i++) { var ul = uls[i]; if (page.util.hasClassName(ul, ‘nav’)) { var lis = ul.getElementsByTagName(‘li’); if (lis) { var numLis = lis.length; for (var j = 0; j < numLis; j++) { var li = lis[j]; if (page.util.hasClassName(li, ‘switch’)) { var menu = new page.FlyoutMenu($(li)); var menuLink = $($(li).getElementsByTagName(‘a’)[0]); Event.stopObserving( menuLink, ‘mouseover’ ); Event.stopObserving( menuLink, ‘click’ ); Event.observe( menuLink, ‘click’, menu.onToggle.bindAsEventListener( menu )); } else if (page.util.hasClassName(li, ‘sub’)) { new page.FlyoutMenu($(li)); } else if (page.util.hasClassName(li, ‘mainButton’) || page.util.hasClassName(li, ‘mainButtonType’)) { var menuLinks = $A($(li).getElementsByTagName(‘a’)); if (menuLinks && menuLinks.length > 0) { Event.observe(menuLinks[0], ‘keydown’, page.util.flyoutMenuMainButtonKeyboardHandler.bindAsEventListener(menuLinks[0])); } } } } } } } }; //LRN-67276 because of the ‘same-origin’ policy, the browser cannot inspect the DOM of embedded frames/iframes where the //source is on a different ‘origin’. if that happens, catch the exception and make sure we return a valid value for maxHeight page.util.getMaxContentHeight = function( iframeElement ) { var maxHeight = iframeElement.contentWindow.document.body.scrollHeight; var frameElements; var iframeElements; if ( iframeElement.contentDocument ) { // getElementsByTagName() returns a NodeList object, which is immutable and cannot easily be converted to an array frameElements = iframeElement.contentDocument.getElementsByTagName(“frame”); iframeElements = iframeElement.contentDocument.getElementsByTagName(“iframe”); } var i = 0; var frameHeight; var frameElement; try { for( i = 0; i < frameElements.length; i++ ) { frameElement = frameElements[i]; if( frameElement.contentWindow && frameElement.contentWindow.document && frameElement.contentWindow.document.body ) { frameHeight = frameElement.contentWindow.document.body.scrollHeight; } if( frameHeight > maxHeight ) { maxHeight = frameHeight; } } } catch (e) { // ignore – see same-origin comment at the top of this function } try { for( i = 0; i < iframeElements.length; i++ ) { frameElement = iframeElements[i]; if( frameElement.contentWindow && frameElement.contentWindow.document && frameElement.contentWindow.document.body ) { frameHeight = frameElement.contentWindow.document.body.scrollHeight; } if( frameHeight > maxHeight ) { maxHeight = frameHeight; } } } catch (e) { // ignore – see same-origin comment at the top of this function } return maxHeight; }; //LRN-67276 because of the ‘same-origin’ policy, the browser cannot inspect the DOM of embedded frames/iframes where the //source is on a different ‘origin’. if that happens, catch the exception and make sure we return a valid value for maxWidth page.util.getMaxContentWidth = function( iframeElement ) { var maxWidth = iframeElement.contentWindow.document.body.scrollWidth; var frameElements; var iframeElements; if ( iframeElement.contentDocument ) { // getElementsByTagName() returns a NodeList object, which is immutable and cannot easily be converted to an array frameElements = iframeElement.contentDocument.getElementsByTagName(“frame”); iframeElements = iframeElement.contentDocument.getElementsByTagName(“iframe”); } var i = 0; var frameWidth; var frameElement; try { for( i = 0; i < frameElements.length; i++ ) { frameElement = frameElements[i]; if( frameElement.contentWindow && frameElement.contentWindow.document && frameElement.contentWindow.document.body ) { frameWidth = frameElement.contentWindow.document.body.scrollWidth; } if( frameWidth > maxWidth ) { maxWidth = frameWidth; } } } catch (e) { // ignore – see same-origin comment at the top of this function } try { for( i = 0; i < iframeElements.length; i++ ) { frameElement = iframeElements[i]; if( frameElement.contentWindow && frameElement.contentWindow.document && frameElement.contentWindow.document.body ) { frameWidth = frameElement.contentWindow.document.body.scrollWidth; } if( frameWidth > maxWidth ) { maxWidth = frameWidth; } } } catch (e) { // ignore – see same-origin comment at the top of this function } return maxWidth; }; page.subheaderCleaner = { init : function( entityKind, divId ) { var allHidden = true; var firstUl = null; var className = ‘portletList-img courseListing ‘ + entityKind; var parentElement = $( divId ) || document; $A( parentElement.getElementsByClassName( className ) ).each( function( ul ) { if ( !ul.down() ) { var prev = ul.previous( ‘h3’ ) || ul.previous( ‘h4’ ); prev.hide(); ul.hide(); if ( !firstUl ) { firstUl = ul; } } else { allHidden = false; } } ); // if term grouping, hide term headings without courses/orgs className = ‘termHeading-‘ + entityKind; $A( parentElement.getElementsByClassName( className ) ).each( function( termHeading ) { var hasVisibleBlocks = $A( termHeading.next( ‘div’ ).select( ‘ul’ ) ).any( function( block ) { return block.visible(); } ); if ( !hasVisibleBlocks ) { termHeading.hide(); } } ); if ( allHidden && firstUl ) { firstUl.up( ‘div’ ).previous( ‘div’ ).show(); } } }; /** * Set up any JavaScript that will always be run on load (that doesn’t depend on * any application logic / localization) here. * * Please leave this at the bottom of the file so it’s easy to find. * */ FastInit.addOnLoad( function() { Event.observe( document.body, “click”, page.ContextMenu.closeAllContextMenus.bindAsEventListener( window ) ); Event.observe( document.body, “click”, page.ContextMenu.alignArrowsInBreadcrumb.bindAsEventListener( window ) ); Event.observe( document.body, ‘keydown’, function(event) { var key = event.keyCode || event.which; if ( key == 116 ) // reload current page on F5 key press { Event.stop( event ); // prevent browser from reloading complete frameset if ( Prototype.Browser.IE ) { event.keyCode = 0; } (function() { window.location.reload( true ); }.defer()); return false; } }); page.util.initFlyoutMenuBehaviourForListActionMenuItems(); if ( $(‘breadcrumbs’) ) { new page.BreadcrumbExpander($(‘breadcrumbs’)); // If we’re in the content wrapper, hide the content wrapper breadcrumb frame // so that we don’t get stacked breadcrumbs. if ( window.name === ‘contentFrame’ ) { var parent = window.parent; if ( parent ) { var frameset = parent.document.getElementById( ‘contentFrameset’ ); if ( frameset ) { frameset.rows = “*,100%”; } } } } var contentPane = $(‘contentPanel’) || $(‘portalPane’); if ( contentPane ) { new page.LightboxInitializer( ‘lb’, contentPane ); } // add a label for inventory table checkboxes, if needed $A(document.getElementsByTagName(“table”)).each( function( table ) { if ( !page.util.hasClassName( table, ‘inventory’ ) ) { return; } var rows = table.rows; if ( rows.length < 2 ) { return; } for (var r = 0, rlen = rows.length – 1; r < rlen; r++) { var cells = rows[r+1].cells; // skip header row for (var c = 0, clen = cells.length; c < clen; c++) { var cell = $(cells[c]); var inp = cell.down(‘input’); if ( !inp || ( inp.type != ‘checkbox’ && inp.type != ‘radio’ ) ) { // We’re only looking for checkbox/radio cells to label, so move on continue; } var lbl = cell.down(‘label’); if (lbl && !lbl.innerHTML.blank()) { break; // skip cells that already have a non-blank label } if ( !lbl ) { // add new label to checkbox lbl = new Element(‘label’, {htmlFor: inp.id} ); lbl.addClassName(‘hideoff’); cell.insert({bottom:lbl}); } var headerCell = $(cell.parentNode).down(‘th’); if ( !headerCell ) { break; // skip rows without header cell } // create a temporary clone of the header cell and remove any hidden divs I.e. context menus var tempCell = $(headerCell.cloneNode(true)); var tempCellDivs = tempCell.getElementsByTagName(“div”); for ( var i = 0; i < tempCellDivs.length; i++ ) { var d = tempCellDivs[i]; if ( d && !$(d).visible() ) { d.remove(); } } var lblBody = tempCell.innerHTML.replace( /]*>/g, ” ); // strip html tags from header lblBody = page.bundle.getString(‘inventoryList.select.item’, lblBody); lbl.update( lblBody ); // set label to header contents (minus tags) break; } } }); //set default font sizes to display text. hack to fix IE7 default font size issue. var sizes = {1:’xx-small’, 2:’x-small’, 3:’small’, 4:’medium’, 5:’large’, 6:’x-large’, 7:’xx-large’}; var fonts = document.getElementsByTagName(‘font’); for ( var i = 0; i < fonts.length; i++ ) { var font = fonts[i]; if ( font.size ) { // Since some font elements may be manually created by end users we have to handle random // values in here. if (!font.size.startsWith(“+”) && !font.size.startsWith(“-“)) { var fsize = parseInt(font.size, 10); if (fsize > 0 && fsize < 8) { font.style.fontSize = sizes[fsize]; } } } } page.scrollToEnsureVisibleElement(); page.isLoaded = true; }); /** * Class for adding an insertion marker within a list */ page.ListInsertionMarker = Class.create(); page.ListInsertionMarker.prototype = { initialize: function( listId, position, key, text ) { var list = $(listId); var listElements = list.childElements(); // create a marker list item var marker = new Element(‘li’,{‘id’:listId+’:’+key, ‘class’:’clearfix separator’ }); marker.update(‘
‘+text+’
‘); //marker.setStyle({ position: ‘relative’, minHeight: ’10px’, padding: ‘0px’, background: ‘#CCCCCC’ }); position = ( position > listElements.length ) ? listElements.length : position; // add marker to list if (listElements.length === 0) { list.insert({top:marker}); // add marker to top of empty list } else if (listElements.length == position) { list.insert({bottom:marker}); // add marker after last element } else { listElements[position].insert({before:marker}); // add marker before element at position } var select = $(‘reorderControls’+listId).down(‘select’); // add a option for the marker to the keyboard repostioning select, if any if (select) { var option = new Element(‘option’,{‘value’:key}).update( ‘– ‘+text+’ –‘ ); if (listElements.length === 0) { select.insert({top:option}); } else if (listElements.length == position) { select.insert({bottom:option}); } else { $(select.options[position]).insert({before:option}); } } } }; page.scrollToEnsureVisibleElement = function() { var params = window.location.search.parseQuery(); var ensureVisibleId = params.ensureVisibleId; if (!ensureVisibleId) { return; } var ensureVisibleElement = $(ensureVisibleId); if (!ensureVisibleElement) { return; } var pos = ensureVisibleElement.cumulativeOffset(); var scrollY = pos.top; var bodyHeight = $(document.body).getHeight(); if (scrollY + ensureVisibleElement.getHeight() < bodyHeight) { return; // element is already visible } var receipt = $(“inlineReceipt_good”); if (receipt && receipt.visible()) { // pin receipt to top var offset = receipt.cumulativeOffset(); offset.top = globalNavigation.getNavDivHeight(); var w = parseInt(receipt.getStyle(“width”), 10); if (Prototype.Browser.IE) { // width in IE includes border & padding, need to remove it var bw = parseInt(receipt.getStyle(‘borderLeftWidth’), 10) + parseInt(receipt.getStyle(‘borderRightWidth’), 10); var pw = parseInt(receipt.getStyle(‘paddingLeft’), 10) + parseInt(receipt.getStyle(‘paddingRight’), 10); w = w – bw – pw; } // scroll window to show ensureVisibleElement window.location = “#” + ensureVisibleId; //pin reciept top of screen if scroll does not equal zero. If scroll is 0 it will be pinned directly under the main navigation. if (document.viewport.getScrollOffsets()[“top”] < offset.top) { topPosition = offset.top + “px”; } else { topPosition = 0; } receipt.setStyle({ position: “fixed”, zIndex: “1000”, left: offset.left + “px”, top: topPosition, width: w + “px” }); scrollY = scrollY – 2 * receipt.getHeight(); } //on scroll keep reciept pinned to top of screen. If scroll is 0, it will be pinned directly under the main navigation. if (receipt && receipt.visible()) { Event.observe(window, “scroll”, function() { if (document.viewport.getScrollOffsets()[“top”] < offset.top) { receipt.setStyle({ top: offset.top + “px” }); } else { receipt.setStyle({ top: 0 }); } }); } }; /** * Recursively walks up the frameset stack asking each window to change their * document.domain attribute in anticipation of making a cross-site scripting * call to an LMS integration. * *
This should only be called from popup windows, as changing the document.domain * value of a window that is going to be reused later could do surprising things. * * @param domain Domain name shared by the Learn and LMS servers. */ page.setLmsIntegrationDomain = function( domain ) { if ( ” == domain ) { return; } try { if ( parent.page.setLmsIntegrationDomain ) { parent.page.setLmsIntegrationDomain( domain ); } } catch ( err ) { /* Ignore */ } document.domain = domain; }; page.refreshTopFrame = function() { if ( window.top.nav ) { window.top.nav.location.reload(); } }; // See BreadcrumbBarRenderer.java for code that calls this method. page.rewriteTaskStatusUntilDone = function( spanId, taskId, courseId ) { var theSpan = $(spanId); if (theSpan) { new Ajax.Request(“/webapps/blackboard/execute/getSystemTaskStatus?taskId=” + taskId + “&course_id=” + courseId , { method: ‘post’, onSuccess: function(transport, json) { var result = transport.responseText.evalJSON( true ); theSpan = $(spanId); // reload it just in case it was removed between the request and response if (theSpan) { theSpan.update(result.text); if (result.complete == “false”) { setTimeout(function() {page.rewriteTaskStatusUntilDone(spanId, taskId, courseId);}, 3000); } } }, onFailure: function(transport, json) { theSpan = $(spanId); //reload the span as above if (theSpan) { theSpan.hide(); $(spanId+’error’).show(); } } }); } }; /* * Clean up the task id which associated with the specified course, so that the inline warning does not show up again */ page.cleanTaskId = function( courseId, nonce ) { // we don’t care about the result, at worse it will display again on the next page var url = “/webapps/blackboard/execute/courseMain?action=cleanTaskId&course_id=” + courseId + “&blackboard.platform.security.NonceUtil.nonce.ajax=” + nonce; new Ajax.Request( url, { method: ‘post’ } ); }; //that doesn’t then any code utilizing these methods will not work ‘as expected’. Current usage //as/of the writing of this code is “ok” with that – the user won’t get the perfect experience but it won’t completely fail either. page.putInSessionStorage = function( key, value ) { if ( typeof sessionStorage !== ‘undefined’ ) { sessionStorage[ getCookie( ‘JSESSIONID’ ) + key ] = value; } }; // any code utilizing these methods must have separately included cookie.js // since we don’t always include cookie.js page.getFromSessionStorage = function( key ) { if ( typeof sessionStorage !== ‘undefined’ ) { return sessionStorage[ getCookie( ‘JSESSIONID’ ) + key ]; } return undefined; }; page.aria = {}; page.aria.show = function ( element, button ) { $(element).show(); if ( !!button ) { button.setAttribute(“aria-expanded”, “true”); } }; page.aria.hide = function ( element, button ) { $(element).hide(); if ( !!button ) { button.setAttribute(“aria-expanded”, “false”); } }; page.aria.toggle = function ( element, button ) { if (Element.visible($(element))) { page.aria.hide(element, button); } else { page.aria.show(element, button); } }; page.util.isIE = function () { return ( navigator.userAgent.toLowerCase().indexOf( “msie” ) != -1 ); }; page.util.isFirefox = function() { return ( navigator.userAgent.toLowerCase().indexOf( “firefox” ) != -1 ); }; /* * We’d probably never want to set an empty title on an html element but unfortunately * due to a browser rendering issue(FF 20), there currently is a practical reason to do * so. By setting a title to a ‘blank space'(!), we can prevent the title from the parent * element to show up when the user is interacting with a child {code}element{code}. * Currently this is necessary only for FF, and it can be changed as a need arise but you * MUST NOT set an empty space title in IE/Chrome because they will render it as an empty * title tooltip, which we don’t want. * NOTE : An empty space title will be set only if a title is not already set to something * other than an empty String. * Bug Ref. : LRN-67140 */ page.util.setEmptyTitle = function( element ) { if( page.util.isFirefox() ) { if ( element.title.blank() ) { page.util.setTitle( element, ‘ ‘ ); } } }; page.util.setTitle = function( element, title ) { element.setAttribute( ‘title’, title ); }; page.FocusTrap = Class.create(); page.FocusTrap.prototype = { /** * this method injects 2 invisible spans used to trap the focus inside this given div. Once you tab into the div you * stay inside the div – should only be used on pages where you’ve dynamically loaded the div and placed the user into it * to start (otherwise on a full page reload this could be confusing) * * @param options.mainDiv – the id of the div where we want the focus to be trapped for Accessibility * @param options.initialSelector – selector to find the first element to focus on at the top of the div * @param options.finalSelector – optional selector to find the last element to focus on (if known) */ initialize : function( options ) { this.options = Object.extend( { mainDiv : null, initialSelector : null, finalSelector : null }, options); var mainDiv = $( this.options.mainDiv ); // insert span at the end of the div this.endOfDivIndicator = this.getIndicatorSpan(‘Bot’); mainDiv.insertBefore( this.endOfDivIndicator, null ); this.startOfDivIndicator = this.getIndicatorSpan(‘Top’); mainDiv.insertBefore( this.startOfDivIndicator, mainDiv.childNodes[0] ); this.initialSelector = mainDiv.down( this.options.initialSelector ); if ( this.options.finalSelector ) { this.finalSelector = mainDiv.down( this.options.finalSelector ); } // Note: Going on both keydown and keyup so that you can hold down the TAB key and have it work properly. Event.observe( mainDiv, ‘keydown’, this.handleKeyDown.bind(this) ); Event.observe( mainDiv, ‘keyup’, this.handleKeyDown.bind(this) ); }, getIndicatorSpan : function (loc) { var span = new Element( “span” ).addClassName( “focustrap” ); span.setAttribute( “tabIndex”, “0” ); span.id = ‘focusTrap_’ + loc + this.options.mainDiv; return span }, handleKeyDown : function( event ) { var code = event.keyCode || event.which; var elem = event.element(); if ( code == Event.KEY_TAB) { // Note that while this logic does “work” it seems to have an issue we might be able to live with: // 1) Going backwards this has an explicit ‘blank’ item that you tab to which will be confusing (i.e. focusing on the end-of-div indicator // doesn’t help unless we shift-tab again). We might be able to make this work better by simulating another copy of event… another day though. if (event.shiftKey && this.startOfDivIndicator == elem) { // Going backwards if ( this.finalSelector ) { page.util.focusAndScroll( this.finalSelector ); } else { page.util.focusAndScroll( this.endOfDivIndicator ); /* Tried a few things – leaving them here as work-in-progress… it doesn’t work. var evt = document.createEvent( “KeyboardEvent” ); if ( evt.initKeyEvent ) { evt.initKeyEvent( “keyup”, true, true, null, 0, 0, true, 0, Event.KEY_TAB, Event.KEY_TAB ); } else { evt.initKeyboardEvent( “keyup”, true, true, null, 0, 0, true, 0, Event.KEY_TAB, Event.KEY_TAB ); } this.endOfDivIndicator.dispatchEvent( evt ); */ } } else if (!event.shiftKey && this.endOfDivIndicator == elem) { // going forwards. page.util.focusAndScroll(this.initialSelector); } } } }; page.treatEnterAsClickOnElement = function( buttonElementId ) { Event.observe( $(buttonElementId), ‘keypress’, function(evt) { if ( evt.keyCode == Event.KEY_RETURN ) { page.util.fireClick(this); } }); }; } /* ================================================================== *The JavaScript Validation objects to be used in form validation. * Copyright (c) 2001 by Blackboard, Inc., * 1899 L Street, NW, 5th Floor * Washington, DC, 20036, U.S.A. * All rights reserved. * Submit RFC & bugs report to: [email protected] * This software is the confidential and proprietary information * of Blackboard, Inc. (“Confidential Information”). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with Blackboard. * ==================================================================*/ /** * General purpose DOM utility methods. There’s probably a better place for this. * Private methods and properties have names prefixed with “_”. */ var bbDomUtil = { _inputTypes: [ ‘input’, ‘textarea’, ‘select’, ‘button’ ], _maxRecursion: 500, /** * @param elName name of the form input element (the request parameter name). * @return an array of two or more elements, a single element, or null. */ getInputElementByName: function( elName ) { var elArray = this._getInputElementsByNameInSection( ‘dataCollectionContainer’, elName ); if ( elArray.length === 0 ) { elArray = this._getInputElementsByName( elName ); } return ( elArray.length === 0 ) ? null : ( elArray.length == 1 ? elArray[ 0 ] : elArray ); }, /* * @param sectionId the ID of any element inside a form * @return the enclosing form element or null */ getEnclosingForm: function( sectionId ) { var form = null; if ( sectionId ) { var count; var section = document.getElementById( sectionId ); while ( section ) { ++count; if ( count > this._maxRecursion ) { break; } if ( section.tagName && section.tagName.toLowerCase() == “form” ) { form = section; break; } section = section.parentNode; } } return ( !form ) ? ( document.forms.length === 0 ? null : document.forms[ 0 ] ) : form; }, /** * Adds some additional processing to account for an IE bug * @param id the ID of an element */ getElementById: function( id ) { var el = $( id ); try { if ( el && /msie|internet explorer/i.test( navigator.userAgent ) && el.attributes.id && el.attributes.id.value != id && document.all ) { // IE usually returns item at 0 for ( var i = 0; i < document.all[ id ].length; ++i ) { if ( document.all[ id ][ i ].attributes.id && document.all[ id ][ i ].attributes.id.value == id ) { return $( document.all[ id ][ i ] ); } } } } catch ( e ) { // Ignore all exceptions } return el; }, syncCheckboxToInput: function( checkboxElement, inputElement ) { var checkbox = $( checkboxElement ); var input = $( inputElement ); if ( checkbox && input ) { var checkIfNotEmpty = function( ) { checkbox.checked = ( input.value.strip?input.value.strip( ):input.value )?true:false; }; input.observe( ‘change’, checkIfNotEmpty ); input.observe( ‘blur’, checkIfNotEmpty ); } }, /** * @param sectionId the ID of an element that restricts the scope of elements. Cannot be null. * @param elName name of the form input element (the request parameter name). Cannot be null. * @return an array of zero or more elements with the specified name in the scope of the specified parent element. */ _getInputElementsByNameInSection: function( sectionId, elName ) { var result = []; if ( sectionId ) { var section = document.getElementById( sectionId ); if ( section ) { for ( var i = 0; i < this._inputTypes.length; ++i ) { var elements = section.getElementsByTagName( this._inputTypes[ i ] ); for ( var j = 0; j < elements.length; ++j ) { if ( elements[ j ].name == elName ) { result.push( elements[ j ] ); } } } } } return result; }, /** * @param elName name of the form input element (the request parameter name). Cannot be null. * @return an array of zero or more elements with the specified name. */ _getInputElementsByName: function( elName ) { var result = []; var elArray = document.getElementsByName( elName ); var formName = null; for ( var i = 0; i < elArray.length; ++i ) { if ( elArray[ i ].tagName.match( /^(input|select|textarea|button)$/i ) ) { if ( elArray[ i ].form !== null ) { if ( !formName ) { formName = elArray[ i ].form.name; } else if ( formName != elArray[ i ] .form.name ) { // Ignore elements that don’t belong to the same form as the first one found. continue; } result.push( elArray[ i ] ); } } } return result; } }; /************************************************************ * Object formCheckList. Use this object to hold form objects * to be validated and perform form validation ************************************************************/ var addElement, removeElement, removeAllElements, getElement, checkForm, CheckGroup; var formCheckList = new formCheckList(); var skipValidation=false; function formCheckList() { this.checkList = []; this.addElement = addElement; this.removeElement = removeElement; this.removeAllElements = removeAllElements; this.getElement = getElement; this.check = checkForm; } function addElement(element) { if ( typeof element.group != ‘undefined’ ) { for ( var i=0; i < this.checkList.length;i++ ) { if ( this.checkList[i].name == element.group ) { this.checkList[i].addElement(element); return; } } var grp = new CheckGroup(element); grp.addElement(element); this.checkList[this.checkList.length] = grp; return; } this.checkList[this.checkList.length] = element; } function removeElement(name) { for (var i = 0; i < this.checkList.length; ++i) { if ( this.checkList[i].fieldName == name ) { this.checkList.splice(i, 1); } } } function getElement(name) { for (var i = 0; i < this.checkList.length; ++i) { if ( this.checkList[i].fieldName == name ) { return this.checkList[i]; } } } function removeAllElements() { var valSize = this.checkList.length; this.checkList.splice(0, valSize); } function checkForm() { if ( typeof(window.invalidAnswersTmp)!=’undefined’ ) { window.invalidAnswersTmp=[]; } var valid =true; for ( var i=0;i<>=+,]/g this.cmp_element = ‘bbDomUtil.getInputElementByName(“‘+h.cmp_field+'”)’; this.cmp_ref_label = h.cmp_ref_label; this.xor = h.xor; this.cmp_required = h.cmp_required; this.activeX = h.activeX; // synch activeX to hidden field before submission this.isHtmlDoc = h.isHtmlDoc; // is portfolio with body and html this.img_check = h.img_check; this.empty_value_warn = h.empty_value_warn; this.valid_system_role_id = h.valid_system_role_id; this.required = h.required; this.canValidate = h.canValidate; // callback function to determine whether the inputtext should be validated if (h.ref_and_regex === undefined) { this.ref_and_regex = true; } else { this.ref_and_regex = h.ref_and_regex; } if ( document.all && document.getElementById(h.name+’_ax’) ) { this.axobj = document.getElementById(h.name+’_ax’); } // Add here anything you need to validate } function isAnEmptyVtbe(val) { // Different browsers populate an ’empty’ VTBE with a different blank line – look for any of the known combinations and ignore them. // NOTE: Changes to this method need to be reflected in AssessmentDisplayControl.isAnEmptyVtbe return ( !val || !val.replace(/
/gi,”).trim() || !val.replace(/
/gi,”).trim() || !val.replace(/ /gi,”).trim()); } // Do actual check here function inputTextCheck() { if ( this.shouldFocus === undefined ) { this.shouldFocus = true; } var element = eval(this.element); var cmp_element = eval(this.cmp_element); if ( element ) { // don’t validate disabled elements if (element.disabled) { return true; } var focusElement = element; if ( this.axobj ) { focusElement = this.axobj; } this.custom_alert = (typeof this.custom_alert != ‘undefined’) ? this.custom_alert : ”; this.custom_alert_cmp = (typeof this.custom_alert_cmp != ‘undefined’) ? this.custom_alert_cmp : ”; this.ref_label = (typeof this.ref_label != ‘undefined’) ? this.ref_label : JS_RESOURCES.getFormattedString(‘field_name.substitute’, [element.name]); var val = element.value; if ( isAnEmptyVtbe(val) ) { val=”; } var trimmedVal, numVal, isValidNum, re; if ( this.activeX && isEmptyWysiwyg(element) ) { element.value = ”; val = ”; } if ( typeof eval(this.formatElement) != “undefined” && eval(this.formatElement) !== null ) { //Check if it is a mathml where; if ( / Prevention And Management Of Childhood Obesity And Its Psychological And Health Comorbidities Essay