Commit 71a9a616 authored by jonnybradley's avatar jonnybradley

[FIX] jslint: Various: Added missing var declarations and semicolons, removed...

[FIX] jslint: Various: Added missing var declarations and semicolons, removed some redundant ones, replaced deprecated escape and unescape with tiki functions, some conditionals simplified, some JSDoc fixes and also some (unintentional) formatting improvements.
parent 1575f6ca
......@@ -150,7 +150,7 @@ CKEDITOR.on('dialogDefinition', function(ev) {
if (this.getContentElement('advanced','advCSSClasses').getValue() === 'wiki') {
this.getContentElement('info','linkType').setValue('tikilink');
var page = this.getContentElement('info','url').getValue(page);
var page = this.getContentElement('info','url').getValue();
if (!jqueryTiki.sefurl) {
page = page.replace('tiki-index.php?page=', '');
}
......
This diff is collapsed.
......@@ -41,7 +41,7 @@ CodeMirror.defineMode('tiki', function(config, parserConfig) {
stream.eatSpace();
var tagName = "";
var c;
while ((c = stream.eat(/[^\s\u00a0=\"\'\/?(}]/))) tagName += c;
while ((c = stream.eat(/[^\s\u00a0="'\/?(}]/))) tagName += c;
state.tokenize = inPlugin;
return "tag";
break;
......@@ -147,17 +147,17 @@ CodeMirror.defineMode('tiki', function(config, parserConfig) {
}
//here we detect values directly after equal character with no quotes
if (!/[\'\"]/.test(peek)) {
if (!/['"]/.test(peek)) {
state.tokenize = inAttributeNoQuote();
}
//end detect values
return "operator";
} else if (/[\'\"]/.test(ch)) {
} else if (/['"]/.test(ch)) {
state.tokenize = inAttribute(ch);
return state.tokenize(stream, state);
} else {
stream.eatWhile(/[^\s\u00a0=\"\'\/?]/);
stream.eatWhile(/[^\s\u00a0="'\/?]/);
return "keyword";
}
}
......
......@@ -82,13 +82,13 @@ function confirmAction(element, firstSvc) {
counter = data.FORWARD.ajaxtimer;
timer = setInterval(function() {
$('span#timer-seconds').html(--counter);
if (counter == 0 || counter < 0) { clearInterval(timer)};
if (counter == 0 || counter < 0) { clearInterval(timer)}
}, 1000);
}
});
if (typeof data.url !== 'undefined') {
setTimeout(function () {
location = data.url;
window.location.href = data.url;
return false;
}, (data.FORWARD.ajaxtimer + 1) * 1000);
}
......@@ -97,7 +97,7 @@ function confirmAction(element, firstSvc) {
}
},
error: function (jqxhr, status, errorObj) {
msgdiv = $('div#error_report');
var msgdiv = $('div#error_report');
$.closeModal();
if ($(document).scrollTop() > msgdiv.offset().top) {
$('html, body').animate({
......
......@@ -171,4 +171,4 @@ var connectVote = function(pref, vote, el) {
}).error(function (){
alert(tr("Tiki Connect is not set up properly. Please visit admin/connect/settings to configure the feature."))
});
}
};
......@@ -66,20 +66,21 @@ function hide(foo, f, section) {
// flip function... unfortunately didn't use show/hide (ay?)
function flip(foo, style) {
var $foo = $("#" + foo);
if (style && style !== 'block' || foo === 'help_sections' || foo === 'fgalexplorer' || typeof jqueryTiki === 'undefined') { // TODO find a better way?
$("#" + foo).toggle(); // inlines don't animate reliably (yet) (also help)
if ($("#" + foo).css('display') === 'none') {
setSessionVar('show_' + escape(foo), 'n');
$foo.toggle(); // inlines don't animate reliably (yet) (also help)
if ($foo.css('display') === 'none') {
setSessionVar('show_' + tiki_encodeURIComponent(foo), 'n');
} else {
setSessionVar('show_' + escape(foo), 'y');
setSessionVar('show_' + tiki_encodeURIComponent(foo), 'y');
}
} else {
if ($("#" + foo).css("display") === "none") {
setSessionVar('show_' + escape(foo), 'y');
if ($foo.css("display") === "none") {
setSessionVar('show_' + tiki_encodeURIComponent(foo), 'y');
show(foo);
}
else {
setSessionVar('show_' + escape(foo), 'n');
setSessionVar('show_' + tiki_encodeURIComponent(foo), 'n');
hide(foo);
}
}
......@@ -855,8 +856,7 @@ function popupPluginForm(area_id, type, index, pageName, pluginArgs, bodyContent
type: 'plugin_ready',
container: container,
arguments: arguments,
btns: btns,
type: type
btns: btns
});
}
......@@ -1995,7 +1995,7 @@ $.fn.tiki = function(func, type, options) {
}
if (confirm (message)) {
$this = $(this);
var $this = $(this);
$this.tikiModal(" ");
$.ajax($(this).attr('href'), {
......@@ -2152,14 +2152,14 @@ $.fn.tiki = function(func, type, options) {
.val(item)
.end()
.appendTo($results);
}
};
$.fn._object_selector_update_results = function (type, result, initial) {
var $container = this,
$results = $container.find('.results'),
$select = $container.find('select'),
$noresults = $('.no-result', this),
selection = []
selection = [];
this.find(':radio:checked, :checkbox:checked')
.not('.protected')
......@@ -2247,7 +2247,7 @@ $.fn.tiki = function(func, type, options) {
}
if (threshold !== -1) {
$spinner.tikiModal(" "),
$spinner.tikiModal(" ");
loadSelectorData(filter, {maxRecords: threshold, format: format}, function (data) {
$container._object_selector_update_results('radio', data.resultset.result, true);
......@@ -2375,7 +2375,7 @@ $.fn.tiki = function(func, type, options) {
$search.click(function (e) {
e.preventDefault();
$spinner = $filter.parent().tikiModal(" ");
var $spinner = $filter.parent().tikiModal(" ");
loadSelectorData($.extend(filter, {title: $filter.val()}), {format: format}, function (data) {
$container._object_selector_update_results('checkbox', data.resultset.result, false);
$spinner.tikiModal();
......@@ -2562,7 +2562,7 @@ $.fn.tiki = function(func, type, options) {
/**
* Show a loading spinner on top of a button (or whatever)
*
* @param empty or jq object $spinner if empty, spinner is added and returned and element "disabled"
* @param $spinner empty or jq object $spinner if empty, spinner is added and returned and element "disabled"
* if spinner then spinner is removed and element returned to normal
*
* @return jq object $spinner being shown or null when removing
......@@ -3195,7 +3195,7 @@ $.fn.moveToWithinWindow = function() {
$.fn.scaleImg = function (max) {
$(this).each(function() {
//Here we want to make sure that the displayed contents is the right size
var img = $(this),
var h, w, img = $(this),
actual = {
height: img.height(),
width: img.width()
......@@ -3228,11 +3228,11 @@ $.fn.scaleImg = function (max) {
} else {
//now we resize regular images
if (actual.height > actual.width) {
var h = max.height;
var w = Math.ceil(actual.width / actual.height * max.height);
h = max.height;
w = Math.ceil(actual.width / actual.height * max.height);
} else {
var w = max.width;
var h = Math.ceil(actual.height / actual.width * max.width);
w = max.width;
h = Math.ceil(actual.height / actual.width * max.width);
}
img.css({ height: h, width: w });
}
......@@ -3389,7 +3389,7 @@ $(document).on('shown.bs.modal', '.modal', function () {
});
$(document).on('tiki.modal.redraw', '.modal.fade', function () {
var modal = this;
var modal = this, $button;
// On Modal show, find all buttons part of a .submit block and create
// proxies of them in the modal footer
......@@ -3494,7 +3494,7 @@ $.closeModal = function (options) {
$('.modal.fade.in').last()
.one('hidden.bs.modal', done || function () {})
.modal('hide');
}
};
$.fn.clickModal = function (options) {
this.click($.clickModal(options));
......
......@@ -919,9 +919,9 @@
var pos = canvas.panorama.getPosition();
var base = currentProtocol + '//maps.googleapis.com/maps/api/streetview?'
+ 'size=' + width + 'x' + height + '&'
+ 'location=' + escape(pos.toUrlValue()) + '&'
+ 'heading=' + escape(pov.heading) + '&'
+ 'pitch=' + escape(pov.pitch) + '&'
+ 'location=' + tiki_encodeURIComponent(pos.toUrlValue()) + '&'
+ 'heading=' + tiki_encodeURIComponent(pov.heading) + '&'
+ 'pitch=' + tiki_encodeURIComponent(pov.pitch) + '&'
+ 'sensor=false'
;
......
......@@ -162,7 +162,7 @@ function dialogSharedClose( area_id, dialog ) {
// Internal Link
function dialogInternalLinkOpen( area_id ) {
var initial = $("#" + area_id).data('initial');
var initial = $("#" + area_id).data('initial'), options;
if (initial) {
options = { initial: initial };
} else {
......
......@@ -31,7 +31,7 @@ $(document).ready(function() {
$(window).bind("beforeunload", function( e ) {
if (modAdminDirty) {
var m = tr("You have unsaved changes to your modules, are you sure you want to leave the page without saving?");
var e = e || window.event;
e = e || window.event;
if (e && !($.browser.safari || $.browser.webkit)) {
e.returnValue = m;
}
......@@ -186,7 +186,7 @@ var showModuleEditForm = function(item, options) {
}
}
modStyle = $(item).attr("style");
if (modStyle && !modStyle.match("absolute")) {
if (modStyle && !modStyle.match(/absolute/)) {
modStyle = ""; // use style from object if draggable
}
}
......@@ -247,7 +247,7 @@ var showModuleEditForm = function(item, options) {
$('.pagename').tiki("autocomplete", "pagename", {multiple: true, multipleSeparator: ";"});
if (modStyle) {
// preload style field with style if position:absolute (unnecessary spaces removed)
$('input[name*=style]').val(modStyle.replace(/\:\s*/g, ":").replace(/\;\s*/g, ";"));
$('input[name*=style]').val(modStyle.replace(/:\s*/g, ":").replace(/;\s*/g, ";"));
}
$("#assign_name", "#module_edit_div").change( function () {
var formVals = {};
......@@ -299,7 +299,7 @@ var showModuleEditForm = function(item, options) {
width: 580,
height: 500,
modal: true,
title: tr("Edit module:") + " " + unescape(modName).replace("+"," "),
title: tr("Edit module:") + " " + tiki_decodeURIComponent(modName).replace("+"," "),
buttons: navbuttons,
close: function () {
$(this).find('input[type=text]').val('').removeClass('ui-state-error');
......
......@@ -9,7 +9,7 @@ $.fn.extend({
if (formParent.attr('satisfied')) return true;
formParent.addClass('hasMissingForm');
var formDialog = window.formDialog = $('<div id="formDialog" />').load('tiki-index_raw.php?page=' + escape(settings.informationForm), function(){
var formDialog = window.formDialog = $('<div id="formDialog" />').load('tiki-index_raw.php?page=' + tiki_encodeURIComponent(settings.informationForm), function(){
formDialog.dialog({
title: settings.informationForm,
modal: true,
......
......@@ -221,11 +221,7 @@ rangy.createModule("Phraser", ["WrappedSelection", "WrappedRange"], function(api
var indexes = this.phraseIndexes(parentWords, phraseWords, true);
if (indexes.length > 1) {
return false;
} else {
return true;
}
return indexes.length <= 1;
},
hasPhrase: function (parent, phrase) {
parent = this.sanitizeToWords(parent);
......@@ -234,7 +230,7 @@ rangy.createModule("Phraser", ["WrappedSelection", "WrappedRange"], function(api
parent = parent.join('|');
phrase = phrase.join('|');
return (parent.indexOf(phrase) > -1 ? true : false);
return (parent.indexOf(phrase) > -1);
},
sanitizeToWords: function (html) {
var sanitized = html.replace(/<(.|\n)*?>/g, ' ');
......
......@@ -25,9 +25,11 @@ var ttlTimelineReady = false, ttlInitCount = 0, ttlTimeline;
/***
* Set up Simile Timeline widget
*
* @param elementId id of div to contain timeline
* @param scale1 timescale of top band (hour, day, week, month, year, decade, century)
* @param scale2 optional lower band scale
* @param elementId id of div to contain timeline
* @param dataSource
* @param scale1 timescale of top band (hour, day, week, month, year, decade, century)
* @param scale2 optional lower band scale
* @param band2_height
*/
function ttlInit( elementId, dataSource, scale1, scale2, band2_height ) {
......
......@@ -91,7 +91,7 @@ $(document).ready(function() {
$(window).bind("beforeunload", function( e ) {
if (tocDirty) {
var m = tr("You have unsaved changes to your structure, are you sure you want to leave the page without saving?");
var e = e || window.event;
e = e || window.event;
if (e && !($.browser.safari || $.browser.webkit)) {
e.returnValue = m;
}
......
......@@ -26,7 +26,7 @@ $(document).ready(function() {
$(window).bind("beforeunload", function( e ) {
if (listDirty) {
var m = tr("You have unsaved changes to your survey, are you sure you want to leave the page without saving?");
var e = e || window.event;
e = e || window.event;
if (e && !($.browser.safari || $.browser.webkit)) {
e.returnValue = m;
}
......
......@@ -41,7 +41,7 @@ function browser() {
/* toggle CSS (tableless) layout columns */
function toggleCols(id, zeromargin, maincol, bidi) {
var showit = 'show_' + escape(id);
var showit = 'show_' + tiki_encodeURIComponent(id);
if (!zeromargin) { zeromargin = ''; }
if (!id) { id = ''; }
if (!maincol) { maincol = 'col1'; }
......@@ -783,7 +783,7 @@ function getHttpRequest( method, url, async )
//* an argument defaults when it is assigned null as a placeholder
//* a null placeholder is not required for trailing omitted arguments
function setSessionVar(name,value) {
var request = getHttpRequest( "GET", "tiki-cookie-jar.php?" + name + "=" + escape(value));
var request = getHttpRequest( "GET", "tiki-cookie-jar.php?" + name + "=" + tiki_encodeURIComponent(value));
request.send('');
if (tiki_cookie_jar) {
......@@ -1942,6 +1942,7 @@ Date.parseUnix = function(date) {
* Tracker rating field adjust after voing using ajax
* (when rendered in search results)
*
* @param element
* @param data array containing result
* 'my_rate',
* 'numvotes',
......
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