Commit 16039897 authored by Pat Kira's avatar Pat Kira Committed by Aaron Wells

FIX: To allow the use jQuery within function(s) (bootstrap)

Bug 1465107: Use Bootstrap CSS Framework
Change-Id: I3b56a1e1d2b7993d4848f1d65e7f87736167a312
parent 0cb71655
......@@ -246,10 +246,10 @@ function process_allowed_iframe_url($url) {
}
$js = <<<EOF
\$j(function() {
\$j('.url-open-editform').click(function(e) {
jQuery(function($) {
$('.url-open-editform').click(function(e) {
e.preventDefault();
\$j('#' + this.id + '-form').toggleClass('js-hidden');
$('#' + this.id + '-form').toggleClass('js-hidden');
});
});
EOF;
......
......@@ -142,15 +142,15 @@ $form = pieform(array(
$inlinejs = <<<EOF
\$j(function() {
\$j('#addfontform_fontfileZip').change(function() {
jQuery(function($) {
$('#addfontform_fontfileZip').change(function() {
// need to hide the 'font files' fieldset
\$j('fieldset.individualfiles').hide(500);
$('fieldset.individualfiles').hide(500);
});
\$j('fieldset.individualfiles input').each(function() {
\$j(this).change(function() {
$('fieldset.individualfiles input').each(function() {
$(this).change(function() {
// need to hide the 'zip archive' fieldset
\$j('fieldset.zipfile').hide(500);
$('fieldset.zipfile').hide(500);
});
});
});
......
......@@ -1110,24 +1110,24 @@ function search_submit(Pieform $form, $values) {
// Hide/disable options based on theme selected
$themeoptionsjs = '
$j(function() {
if ($j("#institution_theme").val() == "sitedefault") {
$j("#institution_dropdownmenu").attr("disabled", true);
$j("#institution_dropdownmenu").attr("checked", false);
jQuery(function($) {
if ($("#institution_theme").val() == "sitedefault") {
$("#institution_dropdownmenu").attr("disabled", true);
$("#institution_dropdownmenu").attr("checked", false);
}
$j("#institution_theme").change(function() {
$("#institution_theme").change(function() {
if ($(this).value == "custom") {
$j(".customtheme").removeClass("js-hidden");
$(".customtheme").removeClass("js-hidden");
}
else {
$j(".customtheme").addClass("js-hidden");
$(".customtheme").addClass("js-hidden");
}
if ($(this).value == "sitedefault") {
$j("#institution_dropdownmenu").attr("disabled", true);
$j("#institution_dropdownmenu").attr("checked", false);
$("#institution_dropdownmenu").attr("disabled", true);
$("#institution_dropdownmenu").attr("checked", false);
}
else {
$j("#institution_dropdownmenu").removeAttr("disabled");
$("#institution_dropdownmenu").removeAttr("disabled");
}
});
});
......
......@@ -189,10 +189,10 @@ $pagination = build_pagination(array(
));
$js = '
$j(function() {
$j("a.notetitle").click(function(e) {
jQuery(function($) {
$("a.notetitle").click(function(e) {
e.preventDefault();
$j("#" + this.id + "_desc").toggleClass("hidden");
$("#" + this.id + "_desc").toggleClass("hidden");
});
});';
......
......@@ -27,14 +27,14 @@ $goals = ArtefactTypeResumeGoalAndSkill::get_goals_and_skills('goals');
$skills = ArtefactTypeResumeGoalAndSkill::get_goals_and_skills('skills');
$js = '
$j(function() {
$j("a.goaltitle").click(function(e) {
jQuery(function($) {
$("a.goaltitle").click(function(e) {
e.preventDefault();
$j("#" + this.id + "_desc").toggleClass("hidden");
});
$j("a.skilltitle").click(function(e) {
$("a.skilltitle").click(function(e) {
e.preventDefault();
$j("#" + this.id + "_desc").toggleClass("hidden");
$("#" + this.id + "_desc").toggleClass("hidden");
});
});';
......
......@@ -118,10 +118,11 @@ $personalinformationform = pieform(array(
),
));
$smarty = smarty(array('artefact/resume/js/simpleresumefield.js'));
$smarty->assign('coverletterform', $coverletterform);
$smarty->assign('personalinformationform',$personalinformationform);
$smarty->assign('INLINEJAVASCRIPT', '$j(simple_resumefield_init);');
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('SUBPAGENAV', PluginArtefactResume::submenu_items());
$smarty->display('artefact:resume:index.tpl');
......
......@@ -35,9 +35,9 @@ $form = pieform(simple_resumefield_form($defaults, 'artefact/resume/interests.ph
'editortitle' => get_string('interests', 'artefact.resume')
)));
$smarty = smarty(array('artefact/resume/js/simpleresumefield.js'));
$smarty->assign('interestsform', $form);
$smarty->assign('INLINEJAVASCRIPT', '$j(simple_resumefield_init);');
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('subsectionheading', get_string('interests', 'artefact.resume'));
$smarty->assign('SUBPAGENAV', PluginArtefactResume::submenu_items());
......
/*jslint browser: true, nomen: true, white: true */
/* global jQuery, $ */
var simpleresume = {};
jQuery(function($) {
"use strict";
simpleresume.connect_editbuttons = function() {
$("#resumefieldform input.openedit").click(function() {
//takes id and removes the word 'edit' from the end...
var t = this.id.substr(0, this.id.length - 4),
container = $("#" + t + "_container"),
submitcontainer = $("#" + t + "submit_container"),
submit = $("#" + t + "submit"),
cancel = $("#cancel_" + t + "submit"),
displaycontainer = $("#" + t + "display_container"),
editcontainer = $("#" + t + "edit_container");
container.removeClass("js-hidden");
submitcontainer.removeClass("js-hidden");
submit.removeClass("js-hidden");
cancel.removeClass("js-hidden");
displaycontainer.addClass("hidden").removeClass("nojs-hidden-block");
editcontainer.addClass("hidden").removeClass("nojs-hidden-block");
if (typeof tinyMCE != 'undefined') {
var editor = tinyMCE.get(t),
formTop = container.closest('#main-column-container').attr('id');;
editor.show();
editor.focus();
document.location.href = "#" + formTop;
}
else {
$("#" + t).removeClass("js-hidden").focus();
}
});
}
simpleresume.connect_cancelbuttons = function() {
$("#resumefieldform input.submitcancel.cancel").click(function(e) {
e.preventDefault();
//takes id and removes the word 'cancel' from the end...
var t = this.id.substr(7, this.id.length - 7 - 6),
container = $("#" + t + "_container"),
submitcontainer = $("#" + t + "submit_container"),
submit = $("#" + t + "submit"),
cancel = $("#cancel_" + t + "submit"),
displaycontainer = $("#" + t + "display_container"),
editcontainer = $("#" + t + "edit_container");
container.addClass("js-hidden");
submitcontainer.addClass("js-hidden");
submit.addClass("js-hidden");
cancel.addClass("js-hidden");
displaycontainer.removeClass("hidden");
editcontainer.removeClass("hidden");
if (typeof tinyMCE != 'undefined') {
tinyMCE.get(t).hide();
}
else {
$("#" + t).addClass("js-hidden");
}
$("#" + t + "edit_container").find('input.openedit').focus();
});
}
simpleresume.simple_resumefield_init = function() {
this.connect_editbuttons();
this.connect_cancelbuttons();
var ids = [];
$("#resumefieldform input.submitcancel.cancel").each(function() {
var prefix = 'cancel_';
var suffix = 'submit';
ids.push(this.id.substr(prefix.length, this.id.length - prefix.length - suffix.length));
});
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.EditorManager.on('SetupEditor', function(editor) {
if (ids.indexOf(editor.id) >= 0) {
editor.on('init', function() {
editor.hide();
});
}
});
}
}
simpleresume.simple_resumefield_init();
});
function simple_resumefield_success(form, data) {
var displaynode = $j("#resumefieldform_" + data.update + "display_container td");
var displaynode = jQuery("#resumefieldform_" + data.update + "display_container td");
displaynode.html(data.content);
simple_resumefield_init();
simpleresume.simple_resumefield_init();
formSuccess(form, data);
}
function simple_resumefield_error(form, data) {
simple_resumefield_init();
var errornodeid = $j("#resumefieldform textarea.error.wysiwyg").attr("id");
simpleresume.simple_resumefield_init();
var errornodeid = jQuery("#resumefieldform textarea.error.wysiwyg").attr("id");
if (errornodeid) {
var editbutton = $j("input#" + errornodeid + "edit");
var editbutton = jQuery("input#" + errornodeid + "edit");
if (editbutton) {
editbutton.click();
}
}
}
function connect_editbuttons() {
$j("#resumefieldform input.openedit").click(function() {
var t = this.id.substr(0, this.id.length - 4);
$j("#" + t + "_container").removeClass("js-hidden");
$j("#" + t + "submit_container").removeClass("js-hidden");
$j("#" + t + "submit").removeClass("js-hidden");
$j("#cancel_" + t + "submit").removeClass("js-hidden");
$j("#" + t + "display_container").addClass("hidden");
$j("#" + t + "display_container").removeClass("nojs-hidden-block");
$j("#" + t + "edit_container").addClass("hidden");
$j("#" + t + "edit_container").removeClass("nojs-hidden-block");
if (typeof tinyMCE != 'undefined') {
var editor = tinyMCE.get(t);
editor.show();
editor.focus();
}
else {
$j("#" + t).removeClass("js-hidden").focus();
}
});
}
function connect_cancelbuttons() {
$j("#resumefieldform input.submitcancel.cancel").click(function(e) {
e.preventDefault();
var t = this.id.substr(7, this.id.length - 7 - 6);
$j("#" + t + "_container").addClass("js-hidden");
$j("#" + t + "submit_container").addClass("js-hidden");
$j("#" + t + "submit").addClass("js-hidden");
$j("#cancel_" + t + "submit").addClass("js-hidden");
$j("#" + t + "display_container").removeClass("hidden");
$j("#" + t + "edit_container").removeClass("hidden");
if (typeof tinyMCE != 'undefined') {
tinyMCE.get(t).hide();
}
else {
$j("#" + t).addClass("js-hidden");
}
$j("#" + t + "edit_container").find('input.openedit').focus();
});
}
function simple_resumefield_init() {
connect_editbuttons();
connect_cancelbuttons();
var ids = [];
$j("#resumefieldform input.submitcancel.cancel").each(function() {
var prefix = 'cancel_';
var suffix = 'submit';
ids.push(this.id.substr(prefix.length, this.id.length - prefix.length - suffix.length));
});
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.EditorManager.on('SetupEditor', function(editor) {
if (ids.indexOf(editor.id) >= 0) {
editor.on('init', function() {
editor.hide();
});
}
});
}
}
}
\ No newline at end of file
......@@ -1138,7 +1138,7 @@ function formatSize(size) {
}
function listAttachments(attachments) {
if (attachments.length > 0) {
var togglelink = P({$attachmentsstr});
var togglelink = SPAN({$attachmentsstr});
var thead = THEAD({}, TR(null, TH(null, togglelink)));
var tbody = TBODY({});
for (var i=0; i < attachments.length; i++) {
......@@ -2061,11 +2061,11 @@ function simple_resumefield_form($defaults, $goto, $options = array()) {
'elements' => array(
$t => array(
'type' => 'wysiwyg',
'class' => 'js-hidden',
'class' => 'js-hidden tinymce-large',
'title' => $editortitle,
'hiddenlabel' => true,
'rows' => 20,
'cols' => 65,
'rows' => 100,
'cols' => 365,
'defaultvalue' => $content,
'rules' => array('maxlength' => 65536),
),
......
......@@ -79,7 +79,6 @@ function resumelicense_submit(Pieform $form, $values) {
$smarty = smarty(array('artefact/resume/js/simpleresumefield.js'));
$smarty->assign('licensesform', $form);
$smarty->assign('INLINEJAVASCRIPT', '$j(simple_resumefield_init);');
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('SUBPAGENAV', PluginArtefactResume::submenu_items());
$smarty->display('artefact:resume:licenses.tpl');
......@@ -2214,10 +2214,10 @@ function auth_generate_registration_form_js($aform, $registerconfirm) {
if (count($registerconfirm) == 1) {
$js = '
$j(function() {
$j("#' . $reasonid . '_container").removeClass("js-hidden");
$j("#' . $reasonid . '_container textarea").removeClass("js-hidden");
$j("#' . $reasonid . '_container").next("tr.textarea").removeClass("js-hidden");
jQuery(function($) {
$("#' . $reasonid . '_container").removeClass("js-hidden");
$("#' . $reasonid . '_container textarea").removeClass("js-hidden");
$("#' . $reasonid . '_container").next("tr.textarea").removeClass("js-hidden");
});
';
}
......@@ -2225,21 +2225,21 @@ function auth_generate_registration_form_js($aform, $registerconfirm) {
$url = get_config('wwwroot') . 'json/termsandconditions.php';
$js = '
var registerconfirm = ' . json_encode($registerconfirm) . ';
$j(function() {
$j("#' . $institutionid . '").change(function() {
jQuery(function($) {
$("#' . $institutionid . '").change(function() {
if (this.value && registerconfirm[this.value] == 1) {
$j("#' . $reasonid . '_container").removeClass("js-hidden");
$j("#' . $reasonid . '_container textarea").removeClass("js-hidden");
$j("#' . $reasonid . '_container").next("tr.textarea").removeClass("js-hidden");
$("#' . $reasonid . '_container").removeClass("js-hidden");
$("#' . $reasonid . '_container textarea").removeClass("js-hidden");
$("#' . $reasonid . '_container").next("tr.textarea").removeClass("js-hidden");
}
else {
$j("#' . $reasonid . '_container").addClass("js-hidden");
$j("#' . $reasonid . '_container textarea").addClass("js-hidden");
$j("#' . $reasonid . '_container").next("tr.textarea").addClass("js-hidden");
$("#' . $reasonid . '_container").addClass("js-hidden");
$("#' . $reasonid . '_container textarea").addClass("js-hidden");
$("#' . $reasonid . '_container").next("tr.textarea").addClass("js-hidden");
}
// need to fetch the correct terms and conditions for the institution
if (this.value) {
$j.ajax({
$.ajax({
type: "POST",
dataType: "json",
url: "' . $url . '",
......@@ -2248,7 +2248,7 @@ function auth_generate_registration_form_js($aform, $registerconfirm) {
}
}).done(function (data) {
if (data.content) {
$j("#termscontainer").html(data.content);
$("#termscontainer").html(data.content);
}
});
}
......
......@@ -42,7 +42,7 @@ if ($accesschanged = $SESSION->get('pageaccesschanged')) {
$alertstr = get_string('viewsaddedtocollection1', 'collection', $SESSION->get('pagesadded')) . ' ' . $alertstr;
$inlinejs = <<<EOF
jQuery(function($) {
var message = $('<div id="changestatusline" class="alert alert-warning alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><p>$alertstr</p></div>');
var message = $('<div id="changestatusline" class="warning"><div>$alertstr</div></div>');
$('#messages').append(message);
});
EOF;
......@@ -185,10 +185,14 @@ jQuery(function($) {
}
}
if (data.message.message) {
<<<<<<< HEAD
var warningClass = data.message.messagestatus === 'ok' ? 'success' : 'warning';
var warnmessage = $('<div id="changestatusline" class="alert alert-dismissible alert-' + warningClass + '" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><p>' + data.message.message + '</p></div>');
=======
var warnmessage = $('<div id="changestatusline" class="' + data.message.messagestatus + '"><div>' + data.message.message + '</div></div>');
>>>>>>> 8d8cc48... FIX: To allow the use jQuery within function(s) (bootstrap)
$('#messages').empty().append(warnmessage);
}
wiresortables();
......
......@@ -27,8 +27,8 @@
min-height: 500px;
}
label.sr-only + div.mce-tinymce {
max-width: 100%;
width: 99%;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -30,14 +30,14 @@
<button id="query-button" class="btn-search" type="submit">{str tag="go"}</button>
</div>
<script type="application/javascript">
$j(function() {
jQuery(function($) {
var csvlink = '{$WWWROOT}admin/groups/archivescsvdownload.php';
$j('#institution').on('change', function() {
if ($j(this).val() != 'all') {
$j('#csvlink').attr('href', csvlink + '?institution=' + $j(this).val());
$('#institution').on('change', function() {
if ($(this).val() != 'all') {
$('#csvlink').attr('href', csvlink + '?institution=' + $j(this).val());
}
else {
$j('#csvlink').attr('href', csvlink);
$('#csvlink').attr('href', csvlink);
}
});
});
......
......@@ -149,20 +149,22 @@ for ($i = 0; $i < count($records); $i++) {
$count = count($records);
if ($count) {
$js = <<<EOF
\$j(document).ready(function() {
for (i = 0; i < {$count}; i++) {
var element = document.getElementById("copytoclipboard-" + i);
try {
var client = new ZeroClipboard(element);
client.on("error", function(e) {
var element = document.getElementById("copytoclipboard-" + e.client.id);
\$j(element).hide();
});
jQuery(function($) {
$(document).ready(function() {
for (i = 0; i < {$count}; i++) {
var element = document.getElementById("copytoclipboard-" + i);
try {
var client = new ZeroClipboard(element);
client.on("error", function(e) {
var element = document.getElementById("copytoclipboard-" + e.client.id);
$(element).hide();
});
}
catch(err) {
$(element).hide();
}
}
catch(err) {
\$j(element).hide();
}
}
});
});
EOF;
......@@ -273,10 +275,10 @@ else {
$newform = $allownew ? pieform($newform) : null;
$js .= <<<EOF
\$j(function() {
\$j('.url-open-editform').click(function(e) {
jQuery(function($) {
$('.url-open-editform').click(function(e) {
e.preventDefault();
\$j('#' + this.id + '-form').toggleClass('js-hidden');
$('#' + this.id + '-form').toggleClass('js-hidden');
});
});
EOF;
......
......@@ -286,17 +286,17 @@ addLoadEvent(function () {
paginator = {$feedback->pagination_js}
});
\$j(function() {
\$j('#column-container .blockinstance-content .commentlink').each(function() {
var blockid = \$j(this).attr('id').match(/\d+/);
jQuery(function($) {
$('#column-container .blockinstance-content .commentlink').each(function() {
var blockid = $(this).attr('id').match(/\d+/);
// only use comments expander if there are comments on the artefact
\$j(this).on('click', function(e) {
var commentlink = \$j(this);
$(this).on('click', function(e) {
var commentlink = $(this);
var chtml = commentlink.parent().parent().find('#feedbacktable_' + blockid).parent();
// add a 'close' link at the bottom of the list for convenience
if (\$j('#closer_' + blockid).length == 0) {
var closer = \$j('<a id="closer_' + blockid + '" href="#" class="close-link">Close</a>').click(function(e) {
\$j(this).parent().toggle(400, function() {
if ($('#closer_' + blockid).length == 0) {
var closer = $('<a id="closer_' + blockid + '" href="#" class="close-link">Close</a>').click(function(e) {
$(this).parent().toggle(400, function() {
commentlink.focus();
});
e.preventDefault();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment