Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
2.5.0 release - General and error view changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jshah4517 committed Apr 24, 2019
1 parent 8aca65b commit 7f650b6
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 100 deletions.
33 changes: 12 additions & 21 deletions assets/general/js/done_typing.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,34 @@
// caused by blur.
// Requires jQuery 1.7+
//
;(function($){
;(function ($) {
$.fn.extend({
donetyping: function(callback,timeout){
donetyping: function (callback, timeout) {
timeout = timeout || 1e3; // 1 second default timeout
var timeoutReference,
doneTyping = function(el) {
if (!timeoutReference) return;
doneTyping = function (el) {
if (! timeoutReference) return;
timeoutReference = null;
if (callback) {
callback.call(el);
}
$(el).trigger('donetyping');
};
return this.each(function(i,el){
return this.each(function (i, el) {
var $el = $(el);
// Chrome Fix (Use keyup over keypress to detect backspace)
// thank you @palerdot
// Also added paste to catch when you copy and paste something without typing
$el.is(':input') && $el.on('paste keyup keypress',function(e){
// This catches the backspace button in chrome, but also prevents
// the event from triggering too premptively. Without this line,
// using tab/shift+tab will make the focused element fire the callback.
if (e.type=='keyup' && e.keyCode!=8) return;

// Check if timeout has been set. If it has, "reset" the clock and
// start over again.
// Check keyup event, also added paste to catch when you copy and paste something without typing
$el.is(':input') && $el.on('paste keyup', function () {
// Check if timeout has been set. If it has, "reset" the clock and start over again.
if (timeoutReference) clearTimeout(timeoutReference);
timeoutReference = setTimeout(function(){
// if we made it here, our timeout has elapsed. Fire the
// callback
timeoutReference = setTimeout(function () {
// if we made it here, our timeout has elapsed. Fire the callback
doneTyping(el);
}, timeout);
}).on('blur',function(){
}).on('blur', function () {
// If we can, fire the event since we're leaving the field
doneTyping(el);
});
});
}
});
})(jQuery);
})(jQuery);
16 changes: 8 additions & 8 deletions assets/general/js/fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ function FileUpload(parameters)
var $this = $(this),
that = $this.data('blueimp-fileupload') || $this.data('fileupload'),
options = that.options;

// Calculate cumulative size of attachments.
$.each(data.files, function (index, file) {
self.incrementTotalUploadedFileSize(file.size);
});

// Block upload that exceed the cumulative limit.
if (typeof options.cumulativeMaxFileSize !== 'undefined'
&& self.totalUploadedFileSize() > options.cumulativeMaxFileSize
Expand Down Expand Up @@ -159,7 +159,7 @@ function FileUpload(parameters)
// Re-enable the form submit button
$context.parents('form').find('input[type=submit]').removeAttr('disabled');
}

// Decrement cumulative file size count.
$.each(data.files, function (index, file) {
self.decrementTotalUploadedFileSize(file.size);
Expand Down Expand Up @@ -224,7 +224,7 @@ function FileUpload(parameters)
*/
this.decrementTotalUploadedFileSize = function (size)
{
cumulative_file_size -= size;
cumulative_file_size -= size;
};

/**
Expand All @@ -246,7 +246,7 @@ function FileUpload(parameters)
ul.find('li:last span.information span.filesize').text('(' + filesize.fileSize() + ')');
ul.find('li:last').removeClass('hide');
ul.find('li:last .deleteAttachment').attr('data-size', filesize).hide();

return ul.find('li:last');
};

Expand Down Expand Up @@ -337,7 +337,7 @@ function FileUpload(parameters)
if ( $message.find('div.attachments ul li').length == 1) {
$message.find('div.attachments').hide();
}

// Decrement cumulative file size.
self.decrementTotalUploadedFileSize($(context).data('size'));
},
Expand All @@ -356,7 +356,7 @@ function FileUpload(parameters)
* Show a drag and drop box when dragging a file over to give a visual guide. They can actually drop it anywhere
* in the browser.
*/
$(document).bind('dragover', function (e) {
$(document).on('dragover', function (e) {
var dragover = $('.attachment-dragover'),
timeout = window.dropZoneTimeout;

Expand All @@ -377,7 +377,7 @@ function FileUpload(parameters)
}, 500);
});

$(document).bind('drop', function (e) {
$(document).on('drop', function (e) {
$('.attachment-dragover').hide();
});
};
Expand Down
19 changes: 19 additions & 0 deletions assets/general/js/redactor_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@
pastePlainText: false,
linebreaks: true,
linkSize: 255,
linkTarget: '_blank',
linkifyCallback: function (elements) {
$.each(elements,function(i, s) {
if (s.tagName.toLowerCase() !== 'a' || s.target !== '') {
return;
}

s.target = $.Redactor.default_opts.linkTarget;
});

setTimeout($.proxy(function() {
this.code.sync();
}, this), 100);
},
modalOpenedCallback:function(name, modal) {
if (name === 'link' && ! this.observe.isCurrent('a') && $.Redactor.default_opts.linkTarget === '_blank') {
modal.find('#redactor-link-blank').prop('checked', 'checked');
}
},
imageUpload: laroute.route('core.embed.image'),
uploadImageFields: {
"_token": $('meta[name=csrf_token]').prop('content')
Expand Down
155 changes: 98 additions & 57 deletions assets/installer/js/database.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
var installer = function () {
/**
* Initialise an database migrations + seeds installer.
*
* @param parameters
*/
var installer = function (parameters) {
"use strict";

// Validate constructor arguments.
(function () {
if (typeof parameters.url !== 'string') {
throw new Error('Invalid argument "url", expecting string.');
}

if (typeof parameters.is_upgrade !== 'undefined' && typeof parameters.is_upgrade !== 'boolean') {
throw new Error('Invalid argument "is_upgrade", expecting boolean.');
}
})();

/**
* URL for AJAX to run.
*/
var url = parameters.url;

/**
* Whether this is a fresh install or an upgrade.
*/
var is_upgrade = parameters.is_upgrade || false;

/**
* jQuery #migration instance.
*/
var $preMigration, $migration;

/**
* Determine if a string is valid JSON.
Expand All @@ -22,73 +54,82 @@ var installer = function () {
* @param string
* @return void
*/
var errorHandler = function (string)
{
var errorHandler = function (string) {
alert('Something went wrong while contacting the server.');

// Add the error message to the log.
if (isValidJson(string)) {
var json = JSON.parse(string);

$('textarea').append($('<div>'+json.message+'</div>').text());
$migration.find('textarea').append($('<div>' + json.message + '</div>').text());
} else {
$('textarea').append($('<div>'+string+'</div>').text());
$migration.find('textarea').append($('<div>' + string + '</div>').text());
}
};

return {

/**
* Make new AJAX request. This will continuously process
* all migrations until complete.
*
* @param url
* @param is_upgrade
*/
makeRequest : function (url, is_upgrade)
{
if (!url) {
alert('Please specify a URL when making a request!');
return;
}

// Default AJAX parameters.
var params = { '_token': csrf_token };

// Determine if we're upgrading an existing install.
is_upgrade = is_upgrade || false;
if (is_upgrade) {
params = $.extend(params, { 'upgrade': true });
}

$.post(url, params, 'json')
.done(function( json, textStatus, jqXHR ) {
// Make sure we have valid json
if (isValidJson(jqXHR.responseText) == false) {
return errorHandler('<span>'+jqXHR.responseText+'</span>');
}

// Update the log.
$('textarea').append(json.data.verbose).scrollTop($('textarea')[0].scrollHeight);

// Fire the next request after 0.5 seconds
if (json.data.complete == true) {
$('textarea').append('Completed. Please click continue.\n').scrollTop($('textarea')[0].scrollHeight);
$('input[type=submit]').show().removeAttr('disabled');
} else {
window.setTimeout(function () {
installer.makeRequest(url, is_upgrade);
}, 500);
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
errorHandler(jqXHR.responseText);
})
.always(function() {
$('textarea').removeClass('loadinggif');
});
/**
* Make new AJAX request. This will continuously process all migrations until complete.
*/
var makeRequest = function () {
// Default AJAX parameters.
var params = { '_token': csrf_token },
$textarea = $migration.find('textarea');

// Determine if we're upgrading an existing install.
if (is_upgrade) {
params = $.extend(params, { 'upgrade': true });
}

$.post(url, params, 'json')
.done(function (json, textStatus, jqXHR) {
// Make sure we have valid json
if (isValidJson(jqXHR.responseText) == false) {
return errorHandler('<span>' + jqXHR.responseText + '</span>');
}

// Update the log.
$textarea.append(json.data.verbose).scrollTop($textarea[0].scrollHeight);

// Fire the next request after 0.5 seconds
if (json.data.complete == true) {
$textarea.scrollTop($textarea[0].scrollHeight);
$migration.find('input[type=submit]').show().removeAttr('disabled');

// Remove alert when clicking continue.
window.onbeforeunload = null;
} else {
window.setTimeout(function () {
makeRequest();
}, 500);
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
errorHandler(jqXHR.responseText);
})
.always(function () {
$textarea.removeClass('loadinggif');
});
};

}();
$(function () {
$preMigration = $('#pre-migration');
$migration = $('#migration');

// Prevent closing of the browser window.
window.onbeforeunload = function (e) {
return "Are you sure you want to close the browser window?";
};

// Register click event handler, we need page interaction in order for the onbeforeunload event to fire.
$preMigration.on('click', '#beginMigration', function (e) {
e.preventDefault();

// Hide pre-migration and show migration log.
$preMigration.toggle();
$migration.toggle();

// Start migration AJAX requests.
makeRequest();
});
});
};
8 changes: 1 addition & 7 deletions assets/installer/js/requirements.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function AllowedMethods(parameters)
{
"use strict";

// Validate parameters.
var sameStepRoute = parameters.sameStepRoute,
nextStepRoute = parameters.nextStepRoute,
Expand Down Expand Up @@ -99,9 +99,3 @@ function AllowedMethods(parameters)
});
}
}

$(document).ready(function() {
$('button').click(function () {
alert($("<div/>").html($(this).next('pre').html()).text());
});
});
14 changes: 7 additions & 7 deletions templates/vendor/jsvalidation/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
// Add the Bootstrap error class to the control group
$elm.addClass('has-error');
},

unhighlight: function(element, errorClass, validClass) {
// If there's multiple inputs in the row, add the class to the input instead of the row
// Excluding If it's redactor, codemirror, show/hide button, a checkbox or radio
Expand All @@ -94,18 +94,18 @@

// Remove the Bootstrap error class from the control group
$elm.removeClass('has-error');

// Hide error if it's "pending" (remote validation).
var describer = $(element).attr( "aria-describedby" );
if (describer) {
$row.find('#' + describer.replace(/\s+/g, ", #")).hide();
}
},

success: function (label, element) {
//
//
},

// Custom submit handler.
submitHandler: function (form) {
$(form).find('input[type="submit"], button[type="submit"]').prop('disabled', 'disabled');
Expand Down Expand Up @@ -150,7 +150,7 @@
var id = $(validator.errorList[0].element).parents('.tabContent').attr('id');
// Get name from ID and click on the tab
if (typeof id !== 'undefined' && id.substring(0, 3) == 'tab') {
$('.tabs li#' + id.substring(3)).click();
$('.tabs li#' + id.substring(3)).trigger('click');
}
}

Expand All @@ -163,7 +163,7 @@

rules: <?php echo json_encode($validator['rules']); ?>
});

// Element we want to validate might not actually exist.
if (typeof validator !== 'undefined') {
// Enable custom submit handler.
Expand Down

0 comments on commit 7f650b6

Please sign in to comment.