vendor/assets/javascripts/bhf/application.js in bhf-0.6.14 vs vendor/assets/javascripts/bhf/application.js in bhf-0.6.15

- old
+ new

@@ -1,23 +1,23 @@ //= require turbolinks //= require ./mootools-core-1.4.5-full-compat.js //= require ./mootools-more-1.4.0.1.js //= require ./mootools_ujs_ap //= require_tree ./classes/ +var lang = document.html.get('lang'); +if (lang === 'en') { + lang = 'en-US'; +} +else { + lang = lang+'-'+lang.toUpperCase(); +} +Locale.use(lang); var ajaxNote = new Ajaxify(); var bhfInit = function(){ var quickEdit = new AjaxEdit(); ajaxNote.setup(); - var lang = document.html.get('lang'); - if (lang === 'en') { - lang = 'en-US'; - } - else { - lang = lang+'-'+lang.toUpperCase(); - } - Locale.use(lang); var wysiwyg = []; var setupJsForm = function(scope){ scope.getElements('.wysiwyg').each(function(elem){ wysiwyg.push(elem.mooEditable()); }); @@ -139,10 +139,13 @@ if (platforms.length) { var setupSortables = function(scope){ scope.getElements('.sortable').each(function(sortableElems){ new Sortables(sortableElems, { handle: '.handle', + onFailure: function(invalidForm){ + ajaxNote.failure(); + }, onStart: function(element, clone){ element.addClass('dragged'); }, onComplete: function(element){ element.removeClass('dragged'); @@ -157,10 +160,13 @@ var updatePlatform = function(href, platform, callback){ ajaxNote.loading(); new Request.HTML({ method: 'get', url: href, + onFailure: function(invalidForm){ + ajaxNote.failure(); + }, onSuccess: function(a, b, html, js){ platform.innerHTML = html; if (callback) { callback.call(); } @@ -188,10 +194,13 @@ } new Request.HTML({ method: 'get', url: this.get('action'), + onFailure: function(invalidForm){ + ajaxNote.failure(); + }, onSuccess: function(a, b, html){ parent.innerHTML = html; setupSortables(parent); ajaxNote.success(); window.fireEvent('platformUpdate', [parent]); @@ -219,10 +228,13 @@ }); } }); quickEdit.addEvents({ + onFailure: function(invalidForm){ + ajaxNote.failure(); + }, successAndChange: function(json){ var tr = this.wrapElement; tr.getElements('td').each(function(td){ var name = td.get('data-column-name'); if ( ! name) { return; } @@ -286,9 +298,12 @@ }); } }); quickEdit.addEvents({ + onFailure: function(invalidForm){ + ajaxNote.failure(); + }, successAndAdd: function(json){ var relation = this.wrapElement.getPrevious('.relation'); relation.getPrevious('.empty').addClass('hide'); if (relation.hasClass('has_one') || relation.hasClass('embeds_one')) { relation.getNext('.add_field').addClass('hide'); \ No newline at end of file