diff options
| author | Callum Macrae <callum@lynxphp.com> | 2011-07-14 13:33:42 +0100 |
|---|---|---|
| committer | Igor Wiedler <igor@wiedler.ch> | 2012-03-31 02:00:22 +0200 |
| commit | d420ceb9c717b83ba29dde3734b563881051e51a (patch) | |
| tree | 9edac83794c76485d758ce60ad5a5327096deee4 /phpBB/styles | |
| parent | 4f97cc12951b2be6fa8d7962beaf631f7c82fb43 (diff) | |
| download | forums-d420ceb9c717b83ba29dde3734b563881051e51a.tar forums-d420ceb9c717b83ba29dde3734b563881051e51a.tar.gz forums-d420ceb9c717b83ba29dde3734b563881051e51a.tar.bz2 forums-d420ceb9c717b83ba29dde3734b563881051e51a.tar.xz forums-d420ceb9c717b83ba29dde3734b563881051e51a.zip | |
[ticket/10270] Added JavaScript popups and basic AJAX functionality to PHP.
This commit adds the phpbb object (JavaScript), and alert and confirm box
methods. It also adds the first basic AJAX functionality, to deleting posts
in viewtopic.
PHPBB3-10270
Diffstat (limited to 'phpBB/styles')
| -rw-r--r-- | phpBB/styles/prosilver/template/overall_footer.html | 3 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/theme/common.css | 30 | ||||
| -rw-r--r-- | phpBB/styles/script.js | 80 |
3 files changed, 112 insertions, 1 deletions
diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 4456d6b37d..0d2fd4d27a 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -24,6 +24,9 @@ <!-- IF DEBUG_OUTPUT --><br />{DEBUG_OUTPUT}<!-- ENDIF --> <!-- IF U_ACP --><br /><strong><a href="{U_ACP}">{L_ACP}</a></strong><!-- ENDIF --> </div> + + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> + <script src="styles/script.js"></script> </div> </div> diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 27a55caf7a..5cf12be1ce 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -468,7 +468,7 @@ table.info tbody th { /* Misc layout styles ---------------------------------------- */ -/* column[1-2] styles are containers for two column layouts +/* column[1-2] styles are containers for two column layouts Also see tweaks.css */ .column1 { float: left; @@ -580,6 +580,34 @@ li.pagination { background: none 0 50% no-repeat; } +.row .pagination span a, li.pagination span a { + background-color: #FFFFFF; +} + +.row .pagination span a:hover, li.pagination span a:hover { + background-color: #d2d2d2; +} + +/* jQuery popups +---------------------------------------- */ +.jalert { + background-color: #FFFFFF; + border: 1px solid #999999; + display: none; + position: fixed; + top: 100px; + left: 35%; + width: 30%; + z-index: 50; + padding: 25px; + padding: 0 25px 20px 25px; +} + +.jalert p { + margin: 8px 0; + padding-bottom: 8px; +} + /* Miscellaneous styles ---------------------------------------- */ #forum-permissions { diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js new file mode 100644 index 0000000000..9be3efd4ce --- /dev/null +++ b/phpBB/styles/script.js @@ -0,0 +1,80 @@ +var phpbb = {}; + +/** + * Display a simple alert. + * + * @param string title Title of the message, eg "Information" + * @param string msg Message to display. Can be HTML. + */ +phpbb.alert = function(title, msg) { + var div = $('<div class="jalert"><h3>' + title + '</h3><p>' + msg + '</p></div>'); + + $(document).bind('click', function(e) { + if ($(e.target).parents('.jalert').length) + { + return true; + } + div.hide(300, function() { + div.remove(); + }); + return false; + }); + + $('body').append(div); + div.show(300); +} + +/** + * Display a simple yes / no box to the user. + * + * @param string msg Message to display. Can be HTML. + * @param function callback Callback. + */ +phpbb.confirm = function(msg, callback) { + var div = $('<div class="jalert"><p>' + msg + '</p>\ + <input type="button" class="jalertbut" value="Yes" /> \ + <input type="button" class="jalertbut" value="No" /></div>'); + + $('body').append(div); + + $('.jalertbut').bind('click', function(event) { + div.hide(300, function() { + div.remove(); + }); + callback(this.value === 'Yes'); + return false; + }); + div.show(300); +} + + + +$('.delete-icon a').click(function() +{ + var pid = this.href.split('&p=')[1]; + var __self = this; + $.get(this.href, function(res) { + res = JSON.parse(res); + phpbb.confirm(res.MESSAGE_TEXT, function(del) { + if (del) + { + var p = res.S_CONFIRM_ACTION.split('?'); + p[1] += '&confirm=Yes' + $.post(p[0], p[1], function(res) { + res = JSON.parse(res); + phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT) + $(__self).parents('div #p' + pid).remove(); + + //if there is a refresh, check that it isn't to the same place + if (res.REFRESH_DATA && res.REFRESH_DATA.url.indexOf('t=') === -1) + { + setTimeout(function() { + window.location = res.REFRESH_DATA.url; + }, res.REFRESH_DATA.time * 1000); + } + }); + } + }); + }); + return false; +}); |
