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($('