{I" class:ETI"BundledAsset;FI"logical_path;TI"init-bootbox.js;FI" pathname;TI"V/home/bigxiang/RubyMineWorkspace/bs-helper/app/assets/javascripts/init-bootbox.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+ŇORI" length;Ti…!I" digest;TI"%37dfee72f230fbae163bcca8fcfc015c;FI" source;TI"…!$(function(){ //=================================================== // Replace alert and confirm with bootbox //=================================================== var _alert = window.alert; window.alert = function (message) { bootbox.alert(message); } $.rails.newLinkClickSelector = $.rails.linkClickSelector + ', a[data-js]'; $.rails.newButtonClickSelector = $.rails.buttonClickSelector + ', button[data-js], button[href]'; $.rails.confirm = function (message, callback) { bootbox.confirm(message, callback); } $.rails.processLink = function (element) { if (element.data('js') !== undefined) { eval(element.data('js')); return false; } else if (element.attr('href') !== undefined) { if (element.attr('target') !== undefined) { switch (element.attr('target')) { case '_blank': window.open(element.attr('href')); break; case '_self': window.location = element.attr('href'); break; case '_parent': window.parent.location = element.attr('href'); break; case '_top': window.top.location = element.attr('href'); break; default: window.top.frames[element.attr('target')].location = element.attr('href'); } } else window.location = element.attr('href'); return false; } } $.rails.allowAction = function (element, callback, directCall) { var message = element.data('confirm'); if (!message) { return directCall($(element)); } if ($.rails.fire(element, 'confirm')) { $.rails.confirm(message, function (result) { callback(result); $.rails.fire(element, 'confirm:complete', [result]); }); } } //--------------------------------------------------- // link //--------------------------------------------------- $.rails.linkClick = function (link) { var method = link.data('method'), data = link.data('params'); if (link.is($.rails.linkDisableSelector)) $.rails.disableElement(link); if (link.data('remote') !== undefined) { if ((e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data) { return true; } var handleRemote = $.rails.handleRemote(link); // response from rails.handleRemote() will either be false or a deferred object promise. if (handleRemote === false) { $.rails.enableElement(link); } else { handleRemote.error(function () { $.rails.enableElement(link); }); } return false; } else if (link.data('method')) { $.rails.handleMethod(link); return false; } return $.rails.processLink(link); } $(document).off('click.rails', $.rails.linkClickSelector); $(document).on('click.rails', $.rails.newLinkClickSelector, function (e) { e.preventDefault(); var link = $(this); $.rails.allowAction(link, function (result) { if (result) { return $.rails.linkClick(link); } else return $.rails.stopEverything(e); }, $.rails.linkClick); }); //--------------------------------------------------- // button //--------------------------------------------------- $.rails.buttonClick = function (button) { if (button.data('remote') !== undefined) { $.rails.handleRemote(button); return false; } return $.rails.processLink(button); } $(document).off('click.rails', $.rails.buttonClickSelector); $(document).on('click.rails', $.rails.newButtonClickSelector, function (e) { e.preventDefault(); var button = $(this); $.rails.allowAction(button, function (result) { if (result) { return $.rails.buttonClick(button); } else return $.rails.stopEverything(e); }, $.rails.buttonClick); }); //--------------------------------------------------- // change event //--------------------------------------------------- $.rails.inputChange = function (input) { $.rails.handleRemote(input); return false; } $(document).off('change.rails', $.rails.inputChangeSelector); $(document).on('change.rails', $.rails.inputChangeSelector, function (e) { e.preventDefault(); var link = $(this); $.rails.allowAction(link, function (result) { if (result) { return $.rails.inputChange(link); } else return $.rails.stopEverything(e); }, $.rails.inputChange); }); //--------------------------------------------------- // form //--------------------------------------------------- $.rails.formSubmit = function (form) { var remote = form.data('remote') !== undefined, blankRequiredInputs = $.rails.blankInputs(form, $.rails.requiredInputSelector), nonBlankFileInputs = $.rails.nonBlankInputs(form, $.rails.fileInputSelector); // skip other logic when required values are missing or file upload is present if (blankRequiredInputs && form.attr("novalidate") == undefined && $.rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) { return $.rails.stopEverything(e); } if (remote) { if (nonBlankFileInputs) { // slight timeout so that the submit button gets properly serialized // (make it easy for event handler to serialize form without disabled values) setTimeout(function () { $.rails.disableFormElements(form); }, 13); var aborted = $.rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]); // re-enable form elements if event bindings return false (canceling normal form submission) if (!aborted) { setTimeout(function () { $.rails.enableFormElements(form); }, 13); } return aborted; } $.rails.handleRemote(form); return false; } else { // slight timeout so that the submit button gets properly serialized setTimeout(function () { $.rails.disableFormElements(form); }, 13); form[0].submit(); } } $(document).off('submit.rails', $.rails.formSubmitSelector); $(document).on('submit.rails', $.rails.formSubmitSelector, function (e) { e.preventDefault(); var form = $(this); $.rails.allowAction(form, function (result) { if (result) { return $.rails.formSubmit(form); } else return $.rails.stopEverything(e); }, $.rails.formSubmit); }); //--------------------------------------------------- // submit //--------------------------------------------------- $.rails.formInputClick = function (button) { // register the pressed submit button var name = button.attr('name'), data = name ? {name: name, value: button.val()} : null; button.closest('form').data('ujs:submit-button', data); var submitButton = $('', {type: 'hidden', name: name, value: button.val()}); var form = button.closest('form'); form.append(submitButton); form[0].submit(); submitButton.remove(); } $(document).off('click.rails', $.rails.formInputClickSelector); $(document).on('click.rails', $.rails.formInputClickSelector, function (e) { e.preventDefault(); var button = $(this); $.rails.allowAction(button, function (result) { if (result) { return $.rails.formInputClick(button); } else return $.rails.stopEverything(e); }, $.rails.formInputClick); }); }); ;TI"required_assets_digest;TI"%a1d581b917dc48ca21ef2d5f40e74f96;FI" _version;TI"%2cf3622cbba861b85d33ffabfa420c13;F