diff --git a/assets/general/js/done_typing.js b/assets/general/js/done_typing.js index 73db391..d51caa1 100644 --- a/assets/general/js/done_typing.js +++ b/assets/general/js/done_typing.js @@ -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); \ No newline at end of file +})(jQuery); diff --git a/assets/general/js/fileupload.js b/assets/general/js/fileupload.js index 9a7d8fa..22c45ce 100644 --- a/assets/general/js/fileupload.js +++ b/assets/general/js/fileupload.js @@ -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 @@ -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); @@ -224,7 +224,7 @@ function FileUpload(parameters) */ this.decrementTotalUploadedFileSize = function (size) { - cumulative_file_size -= size; + cumulative_file_size -= size; }; /** @@ -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'); }; @@ -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')); }, @@ -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; @@ -377,7 +377,7 @@ function FileUpload(parameters) }, 500); }); - $(document).bind('drop', function (e) { + $(document).on('drop', function (e) { $('.attachment-dragover').hide(); }); }; diff --git a/assets/general/js/redactor_config.js b/assets/general/js/redactor_config.js index 88fce62..a826db1 100644 --- a/assets/general/js/redactor_config.js +++ b/assets/general/js/redactor_config.js @@ -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') diff --git a/assets/installer/js/database.js b/assets/installer/js/database.js index 0183791..2dcda4c 100644 --- a/assets/installer/js/database.js +++ b/assets/installer/js/database.js @@ -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. @@ -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($('
'+json.message+'
').text()); + $migration.find('textarea').append($('
' + json.message + '
').text()); } else { - $('textarea').append($('
'+string+'
').text()); + $migration.find('textarea').append($('
' + string + '
').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(''+jqXHR.responseText+''); - } - - // 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('' + jqXHR.responseText + ''); + } + + // 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'); + }); }; -}(); \ No newline at end of file + $(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(); + }); + }); +}; diff --git a/assets/installer/js/requirements.js b/assets/installer/js/requirements.js index ca3351d..ff34cad 100644 --- a/assets/installer/js/requirements.js +++ b/assets/installer/js/requirements.js @@ -1,7 +1,7 @@ function AllowedMethods(parameters) { "use strict"; - + // Validate parameters. var sameStepRoute = parameters.sameStepRoute, nextStepRoute = parameters.nextStepRoute, @@ -99,9 +99,3 @@ function AllowedMethods(parameters) }); } } - -$(document).ready(function() { - $('button').click(function () { - alert($("
").html($(this).next('pre').html()).text()); - }); -}); \ No newline at end of file diff --git a/templates/vendor/jsvalidation/bootstrap.php b/templates/vendor/jsvalidation/bootstrap.php index b0c857e..99a7cad 100644 --- a/templates/vendor/jsvalidation/bootstrap.php +++ b/templates/vendor/jsvalidation/bootstrap.php @@ -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 @@ -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'); @@ -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'); } } @@ -163,7 +163,7 @@ rules: }); - + // Element we want to validate might not actually exist. if (typeof validator !== 'undefined') { // Enable custom submit handler.