diff --git a/README.md b/README.md index ea89caa..9a0b0ff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -## YourCode 1.1.1 +## YourCode 2.0 +for MyBB 1.8.x *Forget MyCode. Take control of YourCode-- a much better way of handling BB Code for MyBB forums* diff --git a/Upload/admin/jscripts/yourcode/yourcode_inline.js b/Upload/admin/jscripts/yourcode/yourcode_inline.js index b664376..a9b2607 100644 --- a/Upload/admin/jscripts/yourcode/yourcode_inline.js +++ b/Upload/admin/jscripts/yourcode/yourcode_inline.js @@ -34,10 +34,10 @@ var YourCode = (function(yc) { */ function init() { initialCount(); - $('yc_select_all').observe('click', selectAll); - $$('.yc_check').invoke('observe', 'click', keepCount); - $('yc_inline_clear').observe('click', clearAll); - $('yc_inline_submit').observe('click', submitCheck); + $('#yc_select_all').click(selectAll); + $('.yc_check').click(keepCount); + $('#yc_inline_clear').click(clearAll); + $('#yc_inline_submit').click(submitCheck); } /** @@ -47,7 +47,7 @@ var YourCode = (function(yc) { * @return void */ function setup(language) { - Object.extend(lang, language || {}); + $.extend(lang, language || {}); } /** @@ -58,8 +58,8 @@ var YourCode = (function(yc) { */ function submitCheck(e) { if (!checkCount) { - Event.stop(e); - alert(lang.noSelection); + e.preventDefault(); + $.jGrowl(lang.noSelection); } } @@ -72,7 +72,7 @@ var YourCode = (function(yc) { function selectAll(e) { var onOff = false; - if(this.checked) { + if($(this).prop("checked")) { onOff = true; } setAllChecks(onOff); @@ -89,9 +89,9 @@ var YourCode = (function(yc) { onOff = false; } checkCount = 0; - $('yc_select_all').checked = onOff; - $$('.yc_check').each(function(check) { - check.checked = onOff; + $('#yc_select_all').prop("checked", onOff); + $('.yc_check').each(function(k, check) { + $(check).prop("checked", onOff); if (onOff) { ++checkCount; } @@ -106,7 +106,7 @@ var YourCode = (function(yc) { * @return void */ function keepCount(e) { - if(this.checked) { + if(this.prop("checked")) { ++checkCount; } else { --checkCount; @@ -120,7 +120,7 @@ var YourCode = (function(yc) { * @return void */ function updateCheckCount() { - $('yc_inline_submit').value = lang.go + ' (' + checkCount + ')'; + $('#yc_inline_submit').val(lang.go + ' (' + checkCount + ')'); } /** @@ -140,15 +140,15 @@ var YourCode = (function(yc) { */ function initialCount() { checkCount = 0; - $$('.yc_check').each(function(check) { - if (check.checked) { + $('.yc_check').each(function(k, check) { + if ($(check).prop("checked")) { ++checkCount; } }); updateCheckCount(); } - Event.observe(window, 'load', init); + $(document).ready(init); // the public method yc.inline = { diff --git a/Upload/admin/jscripts/yourcode/yourcode_sandbox.js b/Upload/admin/jscripts/yourcode/yourcode_sandbox.js index fed49a0..963de47 100644 --- a/Upload/admin/jscripts/yourcode/yourcode_sandbox.js +++ b/Upload/admin/jscripts/yourcode/yourcode_sandbox.js @@ -24,7 +24,7 @@ var YourCode = (function(yc) { function Sandbox(url, elements) { var allGood = true; - ['button', 'regexTextbox', 'replacementTextbox', 'testTextbox', 'htmlTextbox', 'actualDiv', 'nestableInput', 'caseSensitiveInput', 'singleLineInput', 'multiLineInput', 'evalInput'].each(function(key) { + $.each(['button', 'regexTextbox', 'replacementTextbox', 'testTextbox', 'htmlTextbox', 'actualDiv', 'nestableInput', 'caseSensitiveInput', 'singleLineInput', 'multiLineInput', 'evalInput'], function(k, key) { if (elements && elements[key]) { this[key] = elements[key]; } else { @@ -38,7 +38,7 @@ var YourCode = (function(yc) { } this.url = url; - this.button.observe('click', this.update.bindAsEventListener(this)); + this.button.click($.proxy(this.update, this)); } /** @@ -49,27 +49,26 @@ var YourCode = (function(yc) { */ function update(e) { var fn = encodeURIComponent; - Event.stop(e); + e.preventDefault(); // build the data - postData = "regex=" + fn(this.regexTextbox.value) + - "&replacement=" + fn(this.replacementTextbox.value) + - "&test_value=" + fn(this.testTextbox.value) + + postData = "regex=" + fn(this.regexTextbox.val()) + + "&replacement=" + fn(this.replacementTextbox.val()) + + "&test_value=" + fn(this.testTextbox.val()) + "&my_post_key=" + fn(my_post_key) + - (this.nestableInput.checked ? '&nestable=1' : '') + - (this.caseSensitiveInput.checked ? '&case_sensitive=1' : '') + - (this.singleLineInput.checked ? '&single_line=1' : '') + - (this.multiLineInput.checked ? '&multi_line=1' : '') + - (this.evalInput.checked ? '&eval=1' : ''); + (this.nestableInput.prop("checked") ? '&nestable=1' : '') + + (this.caseSensitiveInput.prop("checked") ? '&case_sensitive=1' : '') + + (this.singleLineInput.prop("checked") ? '&single_line=1' : '') + + (this.multiLineInput.prop("checked") ? '&multi_line=1' : '') + + (this.evalInput.prop("checked") ? '&eval=1' : ''); - this.spinner = new ActivityIndicator("body", { - image: this.spinnerImage - }); - - new Ajax.Request(this.url, { - method: 'post', - postBody: postData, - onComplete: this.onComplete.bind(this) + $.jGrowl("updating..."); + + $.ajax({ + type: 'post', + url: this.url, + data: postData, + complete: $.proxy(this.onComplete, this), }); } @@ -86,13 +85,11 @@ var YourCode = (function(yc) { if (!message[1]) { message[1] = "An unknown error occurred."; } - alert('There was an error fetching the test results.\n\n' + message[1]); + $.jGrowl('There was an error fetching the test results.\n\n' + message[1]); } else if(transport.responseText) { - this.actualDiv.innerHTML = transport.responseText; - this.htmlTextbox.value = transport.responseText; + this.actualDiv.html(transport.responseText); + this.htmlTextbox.val(transport.responseText); } - - this.spinner.destroy(); return true; } @@ -109,7 +106,6 @@ var YourCode = (function(yc) { singleLineInput: null, multiLineInput: null, evalInput: null, - spinnerImage: "../images/spinner_big.gif", update: update, onComplete: onComplete, } diff --git a/Upload/inc/plugins/yourcode/acp.php b/Upload/inc/plugins/yourcode/acp.php index 9ebc1f4..3a4c2fa 100644 --- a/Upload/inc/plugins/yourcode/acp.php +++ b/Upload/inc/plugins/yourcode/acp.php @@ -562,20 +562,20 @@ function yourcode_admin_edit() echo <<