From 80840a5f08c530d91f147c1bded1c316c2a73d0f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 20:51:03 +0100 Subject: [PATCH 001/175] [feature/event-dispatcher] Introduce a port of Symfony2 EventDispatcher PHPBB3-9550 --- phpBB/includes/event/dispatcher.php | 185 ++++++++++++++++++ phpBB/includes/event/dispatcher_interface.php | 96 +++++++++ phpBB/includes/event/event.php | 123 ++++++++++++ phpBB/includes/event/subscriber_interface.php | 50 +++++ 4 files changed, 454 insertions(+) create mode 100644 phpBB/includes/event/dispatcher.php create mode 100644 phpBB/includes/event/dispatcher_interface.php create mode 100644 phpBB/includes/event/event.php create mode 100644 phpBB/includes/event/subscriber_interface.php diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php new file mode 100644 index 0000000000..c3b8dc5790 --- /dev/null +++ b/phpBB/includes/event/dispatcher.php @@ -0,0 +1,185 @@ + + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + * @author Fabien Potencier + * @author Jordi Boggiano + * @author Jordan Alliot + */ +class phpbb_event_dispatcher +{ + private $listeners = array(); + private $sorted = array(); + + /** + * @see EventDispatcherInterface::dispatch + * + * @api + */ + public function dispatch($event_name, phpbb_event $event = null) + { + if (!isset($this->listeners[$event_name])) { + return; + } + + if (null === $event) { + $event = new phpbb_event(); + } + + $event->set_dispatcher($this); + $event->set_name($event_name); + + $this->do_dispatch($this->get_listeners($event_name), $event_name, $event); + } + + /** + * @see EventDispatcherInterface::get_listeners + */ + public function get_listeners($event_name = null) + { + if (null !== $event_name) { + if (!isset($this->sorted[$event_name])) { + $this->sort_listeners($event_name); + } + + return $this->sorted[$event_name]; + } + + foreach (array_keys($this->listeners) as $event_name) { + if (!isset($this->sorted[$event_name])) { + $this->sort_listeners($event_name); + } + } + + return $this->sorted; + } + + /** + * @see EventDispatcherInterface::has_listeners + */ + public function has_listeners($event_name = null) + { + return (Boolean) count($this->get_listeners($event_name)); + } + + /** + * @see EventDispatcherInterface::add_listener + * + * @api + */ + public function add_listener($event_name, $listener, $priority = 0) + { + $this->listeners[$event_name][$priority][] = $listener; + unset($this->sorted[$event_name]); + } + + /** + * @see EventDispatcherInterface::remove_listener + */ + public function remove_listener($event_name, $listener) + { + if (!isset($this->listeners[$event_name])) { + return; + } + + foreach ($this->listeners[$event_name] as $priority => $listeners) { + if (false !== ($key = array_search($listener, $listeners))) { + unset($this->listeners[$event_name][$priority][$key], $this->sorted[$event_name]); + } + } + } + + /** + * @see EventDispatcherInterface::add_subscriber + * + * @api + */ + public function add_subscriber(phpbb_event_subscriber_interface $subscriber) + { + foreach ($subscriber->get_subscribed_events() as $event_name => $params) { + if (is_string($params)) { + $this->add_listener($event_name, array($subscriber, $params)); + } elseif (is_string($params[0])) { + $this->add_listener($event_name, array($subscriber, $params[0]), $params[1]); + } else { + foreach ($params as $listener) { + $this->add_listener($event_name, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); + } + } + } + } + + /** + * @see EventDispatcherInterface::remove_subscriber + */ + public function remove_subscriber(phpbb_event_subscriber_interface $subscriber) + { + foreach ($subscriber->get_subscribed_events() as $event_name => $params) { + if (is_array($params) && is_array($params[0])) { + foreach ($params as $listener) { + $this->remove_listener($event_name, array($subscriber, $listener[0])); + } + } else { + $this->remove_listener($event_name, array($subscriber, is_string($params) ? $params : $params[0])); + } + } + } + + /** + * Triggers the listeners of an event. + * + * This method can be overridden to add functionality that is executed + * for each listener. + * + * @param array[callback] $listeners The event listeners. + * @param string $event_name The name of the event to dispatch. + * @param Event $event The event object to pass to the event handlers/listeners. + */ + protected function do_dispatch($listeners, $event_name, phpbb_event $event) + { + foreach ($listeners as $listener) { + call_user_func($listener, $event); + if ($event->is_propagation_stopped()) { + break; + } + } + } + + /** + * Sorts the internal list of listeners for the given event by priority. + * + * @param string $event_name The name of the event. + */ + private function sort_listeners($event_name) + { + $this->sorted[$event_name] = array(); + + if (isset($this->listeners[$event_name])) { + krsort($this->listeners[$event_name]); + $this->sorted[$event_name] = call_user_func_array('array_merge', $this->listeners[$event_name]); + } + } +} diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php new file mode 100644 index 0000000000..2564591ed7 --- /dev/null +++ b/phpBB/includes/event/dispatcher_interface.php @@ -0,0 +1,96 @@ + + */ +interface phpbb_event_dispatcher_interface +{ + /** + * Dispatches an event to all registered listeners. + * + * @param string $event_name The name of the event to dispatch. The name of + * the event is the name of the method that is + * invoked on listeners. + * @param Event $event The event to pass to the event handlers/listeners. + * If not supplied, an empty Event instance is created. + * + * @api + */ + function dispatch($event_name, Event $event = null); + + /** + * Adds an event listener that listens on the specified events. + * + * @param string $event_name The event to listen on + * @param callable $listener The listener + * @param integer $priority The higher this value, the earlier an event + * listener will be triggered in the chain (defaults to 0) + * + * @api + */ + function add_listener($event_name, $listener, $priority = 0); + + /** + * Adds an event subscriber. The subscriber is asked for all the events he is + * interested in and added as a listener for these events. + * + * @param EventSubscriberInterface $subscriber The subscriber. + * + * @api + */ + function add_subscriber(phpbb_event_subscriber_interface $subscriber); + + /** + * Removes an event listener from the specified events. + * + * @param string|array $event_name The event(s) to remove a listener from. + * @param object $listener The listener object to remove. + */ + function remove_listener($event_name, $listener); + + /** + * Removes an event subscriber. + * + * @param EventSubscriberInterface $subscriber The subscriber. + */ + function remove_subscriber(phpbb_event_subscriber_interface $subscriber); + + /** + * Gets the listeners of a specific event or all listeners. + * + * @param string $event_name The name of the event. + * + * @return array The event listeners for the specified event, or all event + * listeners by event name. + */ + function get_listeners($event_name = null); + + /** + * Checks whether an event has any registered listeners. + * + * @param string $event_name The name of the event. + * + * @return Boolean TRUE if the specified event has any listeners, FALSE + * otherwise. + */ + function has_listeners($event_name = null); +} diff --git a/phpBB/includes/event/event.php b/phpBB/includes/event/event.php new file mode 100644 index 0000000000..f74370618b --- /dev/null +++ b/phpBB/includes/event/event.php @@ -0,0 +1,123 @@ + + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + */ +class phpbb_event +{ + /** + * @var Boolean Whether no further event listeners should be triggered + */ + private $propagation_stopped = false; + + /** + * @var EventDispatcher Dispatcher that dispatched this event + */ + private $dispatcher; + + /** + * @var string This event's name + */ + private $name; + + /** + * Returns whether further event listeners should be triggered. + * + * @see Event::stop_propagation + * @return Boolean Whether propagation was already stopped for this event. + * + * @api + */ + public function is_propagation_stopped() + { + return $this->propagation_stopped; + } + + /** + * Stops the propagation of the event to further event listeners. + * + * If multiple event listeners are connected to the same event, no + * further event listener will be triggered once any trigger calls + * stop_propagation(). + * + * @api + */ + public function stop_propagation() + { + $this->propagation_stopped = true; + } + + /** + * Stores the EventDispatcher that dispatches this Event + * + * @param EventDispatcher $dispatcher + * + * @api + */ + public function set_dispatcher(phpbb_event_dispatcher $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + /** + * Returns the EventDispatcher that dispatches this Event + * + * @return EventDispatcher + * + * @api + */ + public function get_dispatcher() + { + return $this->dispatcher; + } + + /** + * Gets the event's name. + * + * @return string + * + * @api + */ + public function get_name() + { + return $this->name; + } + + /** + * Sets the event's name property. + * + * @param string $name The event name. + * + * @api + */ + public function set_name($name) + { + $this->name = $name; + } +} diff --git a/phpBB/includes/event/subscriber_interface.php b/phpBB/includes/event/subscriber_interface.php new file mode 100644 index 0000000000..4e7b23f596 --- /dev/null +++ b/phpBB/includes/event/subscriber_interface.php @@ -0,0 +1,50 @@ + + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + */ +interface phpbb_event_subscriber_interface +{ + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('event_name' => 'method_name') + * * array('event_name' => array('method_name', $priority)) + * * array('event_name' => array(array('method_name1', $priority), array('method_name2')) + * + * @return array The event names to listen to + */ + static function get_subscribed_events(); +} From 581b5624f7be3675a35fc61ca6b67b409ae6e8c6 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 20:53:04 +0100 Subject: [PATCH 002/175] [feature/event-dispatcher] Allow subscribers to be loaded from extensions PHPBB3-9550 --- phpBB/common.php | 4 ++ .../event/extension_subscriber_loader.php | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 phpBB/includes/event/extension_subscriber_loader.php diff --git a/phpBB/common.php b/phpBB/common.php index b308037a0e..44a0e7cec3 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -98,6 +98,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes +$phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new user(); $auth = new auth(); @@ -124,6 +125,9 @@ $phpbb_template_locator = new phpbb_template_locator(); $phpbb_template_path_provider = new phpbb_template_extension_path_provider($phpbb_extension_manager, new phpbb_template_path_provider()); $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_template_locator, $phpbb_template_path_provider); +$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); +$phpbb_subscriber_loader->load(); + // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php new file mode 100644 index 0000000000..2a53af1249 --- /dev/null +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -0,0 +1,43 @@ +dispatcher = $dispatcher; + $this->extension_manager = $extension_manager; + } + + public function load() + { + $finder = $this->extension_manager->get_finder(); + $subscriber_classes = $finder + ->extension_directory('/event') + ->suffix('subscriber') + ->core_path('event/') + ->get_classes(); + + foreach ($subscriber_classes as $class) { + $subscriber = new $class(); + $this->dispatcher->add_subscriber($subscriber); + } + } +} From 58a99c97cadd6a16b138e4de4f8fd1aa172e4eed Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 20:54:01 +0100 Subject: [PATCH 003/175] [feature/event-dispatcher] Add a sample hook in page_header PHPBB3-9550 --- phpBB/includes/functions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 753795b7cf..03376bf906 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4461,6 +4461,7 @@ function phpbb_http_login($param) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; + global $phpbb_dispatcher; if (defined('HEADER_INC')) { @@ -4744,6 +4745,9 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); + $event = new phpbb_event(); + $phpbb_dispatcher->dispatch('page_header', $event); + // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); From 03be9761375a082c2a43aceaa1b34661f87d702b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 21:42:19 +0100 Subject: [PATCH 004/175] [feature/event-dispatcher] Support setting data on an event PHPBB3-9550 --- phpBB/includes/event/data.php | 56 +++++++++++++++++++++++++++++++++++ phpBB/includes/functions.php | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 phpBB/includes/event/data.php diff --git a/phpBB/includes/event/data.php b/phpBB/includes/event/data.php new file mode 100644 index 0000000000..754876c119 --- /dev/null +++ b/phpBB/includes/event/data.php @@ -0,0 +1,56 @@ +set_data($data); + } + + public function set_data(array $data = array()) + { + $this->data = $data; + } + + public function get_data() + { + return $this->data; + } + + public function offsetExists($offset) + { + return isset($this->data[$offset]); + } + + public function offsetGet($offset) + { + return isset($this->data[$offset]) ? $this->data[$offset] : null; + } + + public function offsetSet($offset, $value) + { + $this->data[$offset] = $value; + } + + public function offsetUnset($offset) + { + unset($this->data[$offset]); + } +} diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 03376bf906..109f5b0366 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4745,7 +4745,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); - $event = new phpbb_event(); + $event = new phpbb_event_data(); + $event->set_data(compact('page_title', 'display_online_list', 'item_id', 'item')); $phpbb_dispatcher->dispatch('page_header', $event); // application/xhtml+xml not used because of IE From 80f6f2b96f1ef0c3a3bf5637cac85a3c1fa229db Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 21:50:16 +0100 Subject: [PATCH 005/175] [feature/event-dispatcher] Prefix event name with 'core.' PHPBB3-9550 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 109f5b0366..45958d1a0d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4747,7 +4747,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $event = new phpbb_event_data(); $event->set_data(compact('page_title', 'display_online_list', 'item_id', 'item')); - $phpbb_dispatcher->dispatch('page_header', $event); + $phpbb_dispatcher->dispatch('core.page_header', $event); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); From 82422968796188d4284d7cba0f837ee8f333bf11 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Jan 2012 00:48:21 +0100 Subject: [PATCH 006/175] [feature/event-dispatcher] Fix event class name in dispatcher interface PHPBB3-9550 --- phpBB/includes/event/dispatcher_interface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php index 2564591ed7..0a4881b3ba 100644 --- a/phpBB/includes/event/dispatcher_interface.php +++ b/phpBB/includes/event/dispatcher_interface.php @@ -35,7 +35,7 @@ interface phpbb_event_dispatcher_interface * * @api */ - function dispatch($event_name, Event $event = null); + function dispatch($event_name, phpbb_event $event = null); /** * Adds an event listener that listens on the specified events. From 71c5eddb7194f25711bc0733a54f09bf2f0c7c06 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Jan 2012 01:01:11 +0100 Subject: [PATCH 007/175] [feature/event-dispatcher] Add Symfony2 to AUTHORS PHPBB3-9550 --- phpBB/docs/AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS index 4fe0af6e28..8be261706e 100644 --- a/phpBB/docs/AUTHORS +++ b/phpBB/docs/AUTHORS @@ -79,3 +79,6 @@ Pear (c) 2001-2004 PHP Group, http://pear.php.net Text_Diff-0.2.1 http://pear.php.net/package/Text_Diff +MIT licenced: +Symfony2 (c) 2004-2011 Fabien Potencier, http://symfony.com/ + From 4c62dcd0ffc36a1c4bea203d7dcabbdd1f6143a3 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Jan 2012 13:20:44 +0100 Subject: [PATCH 008/175] [feature/event-dispatcher] Correct copyright statement for Symfony2 files Also add a notice to the files that were taken from Symfony2. PHPBB3-9550 --- phpBB/includes/event/dispatcher.php | 7 ++++++- phpBB/includes/event/dispatcher_interface.php | 7 ++++++- phpBB/includes/event/event.php | 7 ++++++- phpBB/includes/event/subscriber_interface.php | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php index c3b8dc5790..6f7d61c83b 100644 --- a/phpBB/includes/event/dispatcher.php +++ b/phpBB/includes/event/dispatcher.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * The EventDispatcherInterface is the central point of Symfony's event listener system. * diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php index 0a4881b3ba..37e6bd4cf1 100644 --- a/phpBB/includes/event/dispatcher_interface.php +++ b/phpBB/includes/event/dispatcher_interface.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * The EventDispatcherInterface is the central point of Symfony's event listener system. * Listeners are registered on the manager and events are dispatched through the diff --git a/phpBB/includes/event/event.php b/phpBB/includes/event/event.php index f74370618b..6ee144bc68 100644 --- a/phpBB/includes/event/event.php +++ b/phpBB/includes/event/event.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * Event is the base class for classes containing event data. * diff --git a/phpBB/includes/event/subscriber_interface.php b/phpBB/includes/event/subscriber_interface.php index 4e7b23f596..081d4f0210 100644 --- a/phpBB/includes/event/subscriber_interface.php +++ b/phpBB/includes/event/subscriber_interface.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * An EventSubscriber knows himself what events he is interested in. * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes From f17449e5ffb87c4a63e6c27c52036c5812f970d7 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 4 Feb 2012 11:11:48 +0200 Subject: [PATCH 009/175] [feature/prosilver-cleanup/duplicate-colors] Removing duplicate colors Removing color values from files other than colours.css PHPBB3-10619 --- phpBB/styles/prosilver/theme/colours.css | 14 ++- phpBB/styles/prosilver/theme/common.css | 100 +++--------------- phpBB/styles/prosilver/theme/content.css | 128 ++++------------------- phpBB/styles/prosilver/theme/cp.css | 100 +++--------------- phpBB/styles/prosilver/theme/forms.css | 48 ++------- phpBB/styles/prosilver/theme/links.css | 55 +++------- 6 files changed, 80 insertions(+), 365 deletions(-) diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 7bc66f4e7d..f6826f8056 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -26,10 +26,6 @@ hr { border-top-color: #CCCCCC; } -hr.dashed { - border-top-color: #CCCCCC; -} - /* Search box --------------------------------------------- */ @@ -452,6 +448,10 @@ dl.faq dt { color: #BC2A4D; } +.announce, .unreadpost { + /* Highlight the announcements & unread posts box */ +} + /* Post signature */ .signature { border-top-color: #CCCCCC; @@ -963,7 +963,7 @@ dl.mini dt { /* Avatar gallery */ #gallery label { - background-color: #FFFFFF; + background: #FFFFFF; border-color: #CCC; } @@ -998,6 +998,10 @@ dd label { color: #333; } +fieldset.fields1 { + background-color: transparent; +} + /* Hover effects */ fieldset dl:hover dt label { color: #000000; diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 8b5e09297e..f59728447f 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -16,8 +16,6 @@ html { body { /* Text-Sizing with ems: http://www.clagnut.com/blog/348/ */ font-family: Verdana, Helvetica, Arial, sans-serif; - color: #828282; - background-color: #FFFFFF; /*font-size: 62.5%; This sets the default font size to be equivalent to 10px */ font-size: 10px; margin: 0; @@ -28,7 +26,6 @@ h1 { /* Forum name */ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; margin-right: 200px; - color: #FFFFFF; margin-top: 15px; font-weight: bold; font-size: 2em; @@ -38,7 +35,6 @@ h2 { /* Forum header titles */ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-weight: normal; - color: #3f3f3f; font-size: 2em; margin: 0.8em 0 0.2em 0; } @@ -52,11 +48,10 @@ h3 { font-family: Arial, Helvetica, sans-serif; font-weight: bold; text-transform: uppercase; - border-bottom: 1px solid #CCCCCC; + border-bottom: 1px solid transparent; margin-bottom: 3px; padding-bottom: 2px; font-size: 1.05em; - color: #989898; margin-top: 20px; } @@ -78,8 +73,8 @@ img { hr { /* Also see tweaks.css */ - border: 0 none #FFFFFF; - border-top: 1px solid #CCCCCC; + border: 0 solid transparent; + border-top-width: 1px; height: 1px; margin: 5px 0; display: block; @@ -87,7 +82,7 @@ hr { } hr.dashed { - border-top: 1px dashed #CCCCCC; + border-top-style: dashed; margin: 10px 0; } @@ -136,7 +131,6 @@ a#logo:hover { /* Search box --------------------------------------------- */ #search-box { - color: #FFFFFF; position: relative; margin-top: 30px; margin-right: 5px; @@ -148,11 +142,10 @@ a#logo:hover { #search-box #keywords { width: 95px; - background-color: #FFF; } #search-box input { - border: 1px solid #b0b0b0; + border: 1px solid transparent; } /* .button1 style defined later, just a few tweaks for the search button version */ @@ -183,26 +176,24 @@ a#logo:hover { /* Round cornered boxes and backgrounds ---------------------------------------- */ .headerbar { - background: #ebebeb none repeat-x 0 0; - color: #FFFFFF; + background: transparent none repeat-x 0 0; margin-bottom: 4px; padding: 0 5px; } .navbar { - background-color: #ebebeb; padding: 0 10px; } .forabg { - background: #b1b1b1 none repeat-x 0 0; + background: transparent none repeat-x 0 0; margin-bottom: 4px; padding: 0 5px; clear: both; } .forumbg { - background: #ebebeb none repeat-x 0 0; + background: transparent none repeat-x 0 0; margin-bottom: 4px; padding: 0 5px; clear: both; @@ -211,8 +202,6 @@ a#logo:hover { .panel { margin-bottom: 4px; padding: 0 10px; - background-color: #f3f3f3; - color: #3f3f3f; } .post { @@ -222,31 +211,10 @@ a#logo:hover { background-position: 100% 0; } -.post:target .content { - color: #000000; -} - -.post:target h3 a { - color: #000000; -} - -.bg1 { background-color: #f7f7f7;} -.bg2 { background-color: #f2f2f2; } -.bg3 { background-color: #ebebeb; } - .rowbg { margin: 5px 5px 2px 5px; } -.ucprowbg { - background-color: #e2e2e2; -} - -.fieldsbg { - /*border: 1px #DBDEE2 solid;*/ - background-color: #eaeaea; -} - span.corners-top, span.corners-bottom, span.corners-top span, span.corners-bottom span { font-size: 1px; line-height: 1px; @@ -321,7 +289,7 @@ ul.linklist li.rightside, p.rightside { ul.navlinks { padding-bottom: 1px; margin-bottom: 1px; - border-bottom: 1px solid #FFFFFF; + border-bottom: 1px solid transparent; font-weight: bold; } @@ -352,7 +320,6 @@ table.table1 { table.table1 thead th { font-weight: normal; text-transform: uppercase; - color: #FFFFFF; line-height: 1.3em; font-size: 1em; padding: 0 0 4px 3px; @@ -363,30 +330,22 @@ table.table1 thead th span { } table.table1 tbody tr { - border: 1px solid #cfcfcf; -} - -table.table1 tbody tr:hover, table.table1 tbody tr.hover { - background-color: #f6f6f6; - color: #000; + border: 1px solid transparent; } table.table1 td { - color: #6a6a6a; font-size: 1.1em; } table.table1 tbody td { padding: 5px; - border-top: 1px solid #FAFAFA; + border-top: 1px solid transparent; } table.table1 tbody th { padding: 5px; - border-bottom: 1px solid #000000; + border-bottom: 1px solid transparent; text-align: left; - color: #333333; - background-color: #FFFFFF; } /* Specific column styles */ @@ -413,7 +372,6 @@ table.info tbody th { padding: 3px; text-align: right; vertical-align: top; - color: #000000; font-weight: normal; } @@ -460,7 +418,6 @@ dl.details dt { clear: left; width: 30%; text-align: right; - color: #000000; display: block; } @@ -468,7 +425,6 @@ dl.details dd { margin-left: 0; padding-left: 5px; margin-bottom: 5px; - color: #828282; float: left; width: 65%; } @@ -499,28 +455,21 @@ li.pagination { padding: 0 2px; margin: 0 2px; font-weight: normal; - color: #FFFFFF; - background-color: #bfbfbf; - border: 1px solid #bfbfbf; + border: 1px solid transparent; font-size: 0.9em; } .pagination span a, .pagination span a:link, .pagination span a:visited, .pagination span a:active { font-weight: normal; text-decoration: none; - color: #747474; margin: 0 2px; padding: 0 2px; - background-color: #eeeeee; - border: 1px solid #bababa; + border: 1px solid transparent; font-size: 0.9em; line-height: 1.5em; } .pagination span a:hover { - border-color: #d2d2d2; - background-color: #d2d2d2; - color: #FFF; text-decoration: none; } @@ -539,14 +488,6 @@ 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; -} - /* Miscellaneous styles ---------------------------------------- */ #forum-permissions { @@ -561,7 +502,6 @@ li.pagination { .copyright { padding: 5px; text-align: center; - color: #555555; } .small { @@ -577,22 +517,11 @@ li.pagination { } .error { - color: #bcbcbc; font-weight: bold; font-size: 1em; } -.reported { - background-color: #f7f7f7; -} - -li.reported:hover { - background-color: #ececec; -} - div.rules { - background-color: #ececec; - color: #bcbcbc; padding: 0 10px; margin: 10px 0; font-size: 1.1em; @@ -603,7 +532,6 @@ div.rules ul, div.rules ol { } p.rules { - background-color: #ececec; background-image: none; padding: 5px; } diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index adf5f2ca2a..b0872f78aa 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -8,13 +8,12 @@ ul.topiclist { } ul.forums { - background: #f9f9f9 none repeat-x 0 0; + background: transparent none repeat-x 0 0; } ul.topiclist li { display: block; list-style-type: none; - color: #777777; margin: 0; } @@ -38,7 +37,7 @@ ul.topiclist dt { ul.topiclist dd { display: block; float: left; - border-left: 1px solid #FFFFFF; + border-left: 1px solid transparent; padding: 4px 0; } @@ -65,28 +64,18 @@ ul.topiclist li.row dt a.subforum { } li.row { - border-top: 1px solid #FFFFFF; - border-bottom: 1px solid #8f8f8f; + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; } li.row strong { font-weight: normal; - color: #000000; -} - -li.row:hover { - background-color: #f6f6f6; -} - -li.row:hover dd { - border-left-color: #CCCCCC; } li.header dt, li.header dd { line-height: 1em; border-left-width: 0; margin: 2px 0 4px 0; - color: #FFFFFF; padding-top: 2px; padding-bottom: 2px; font-size: 1em; @@ -205,7 +194,6 @@ ul.topiclist dd.searchextra { margin-left: 5px; padding: 0.2em 0; font-size: 1.1em; - color: #333333; border-left: none; clear: both; width: 98%; @@ -228,7 +216,6 @@ div[class].topic-actions { .postbody { padding: 0; line-height: 1.48em; - color: #333333; width: 76%; float: left; clear: both; @@ -320,14 +307,12 @@ div[class].topic-actions { line-height: 1.4em; font-family: "Lucida Grande", "Trebuchet MS", Verdana, Helvetica, Arial, sans-serif; font-size: 1em; - color: #333333; padding-bottom: 1px; } .content h2, .panel h2 { font-weight: normal; - color: #989898; - border-bottom: 1px solid #CCCCCC; + border-bottom: 1px solid transparent; font-size: 1.6em; margin-top: 0.5em; margin-bottom: 0.5em; @@ -361,7 +346,6 @@ dl.faq { dl.faq dt { font-weight: bold; - color: #333333; } .content dl.faq { @@ -379,17 +363,9 @@ dl.faq dt { } .posthilit { - background-color: #f3f3f3; - color: #BCBCBC; padding: 0 2px 1px 2px; } -.announce, .unreadpost { - /* Highlight the announcements & unread posts box */ - border-left-color: #BCBCBC; - border-right-color: #BCBCBC; -} - /* Post author */ p.author { margin: 0 15em 0.6em 0; @@ -404,7 +380,7 @@ p.author { margin-top: 1.5em; padding-top: 0.2em; font-size: 1.1em; - border-top: 1px solid #CCCCCC; + border-top: 1px solid transparent; clear: left; line-height: 140%; overflow: hidden; @@ -434,7 +410,7 @@ dd .signature { margin-top: 1.5em; padding-top: 0.2em; font-size: 1em; - border-top: 1px dashed #CCCCCC; + border-top: 1px dashed transparent; clear: left; line-height: 130%; } @@ -450,8 +426,8 @@ ul.searchresults { ----------------------------------------*/ /* Quote block */ blockquote { - background: #ebebeb none 6px 8px no-repeat; - border: 1px solid #dbdbdb; + background: transparent none 6px 8px no-repeat; + border: 1px solid transparent; font-size: 0.95em; margin: 0.5em 1px 0 25px; overflow: hidden; @@ -460,16 +436,10 @@ blockquote { blockquote blockquote { /* Nested quotes */ - background-color: #bababa; font-size: 1em; margin: 0.5em 1px 0 15px; } -blockquote blockquote blockquote { - /* Nested quotes */ - background-color: #e4e4e4; -} - blockquote cite { /* Username/source of quoter */ font-style: normal; @@ -490,14 +460,13 @@ blockquote.uncited { /* Code block */ dl.codebox { padding: 3px; - background-color: #FFFFFF; - border: 1px solid #d8d8d8; + border: 1px solid transparent; font-size: 1em; } dl.codebox dt { text-transform: uppercase; - border-bottom: 1px solid #CCCCCC; + border-bottom: 1px solid transparent; margin-bottom: 3px; font-size: 0.8em; font-weight: bold; @@ -518,17 +487,9 @@ dl.codebox code { padding-top: 5px; font: 0.9em Monaco, "Andale Mono","Courier New", Courier, mono; line-height: 1.3em; - color: #8b8b8b; margin: 2px 0; } -.syntaxbg { color: #FFFFFF; } -.syntaxcomment { color: #000000; } -.syntaxdefault { color: #bcbcbc; } -.syntaxhtml { color: #000000; } -.syntaxkeyword { color: #585858; } -.syntaxstring { color: #a7a7a7; } - /* Attachments ----------------------------------------*/ .attachbox { @@ -536,15 +497,10 @@ dl.codebox code { width: auto; margin: 5px 5px 5px 0; padding: 6px; - background-color: #FFFFFF; - border: 1px dashed #d8d8d8; + border: 1px dashed transparent; clear: left; } -.pm-message .attachbox { - background-color: #f3f3f3; -} - .attachbox dt { font-family: Arial, Helvetica, sans-serif; text-transform: uppercase; @@ -554,7 +510,7 @@ dl.codebox code { margin-top: 4px; padding-top: 4px; clear: left; - border-top: 1px solid #d8d8d8; + border-top: 1px solid transparent; } .attachbox dd dd { @@ -563,7 +519,6 @@ dl.codebox code { .attachbox p { line-height: 110%; - color: #666666; font-weight: normal; clear: left; } @@ -571,7 +526,6 @@ dl.codebox code { .attachbox p.stats { line-height: 110%; - color: #666666; font-weight: normal; clear: left; } @@ -584,7 +538,7 @@ dl.codebox code { } .attach-image img { - border: 1px solid #999999; + border: 1px solid transparent; /* cursor: move; */ cursor: default; } @@ -613,19 +567,16 @@ dl.file dt { } dl.file dd { - color: #666666; margin: 0; padding: 0; } dl.thumbnail img { padding: 3px; - border: 1px solid #666666; - background-color: #FFF; + border: 1px solid transparent; } dl.thumbnail dd { - color: #666666; font-style: italic; font-family: Verdana, Arial, Helvetica, sans-serif; } @@ -634,12 +585,8 @@ dl.thumbnail dd { font-size: 100%; } -dl.thumbnail dt a:hover { - background-color: #EEEEEE; -} - dl.thumbnail dt a:hover img { - border: 1px solid #d2d2d2; + border: 1px solid transparent; } /* Post poll styles @@ -650,15 +597,13 @@ fieldset.polls { fieldset.polls dl { margin-top: 5px; - border-top: 1px solid #e2e2e2; + border-top: 1px solid transparent; padding: 5px 0 0 0; line-height: 120%; - color: #666666; } fieldset.polls dl.voted { font-weight: bold; - color: #000000; } fieldset.polls dt { @@ -692,41 +637,15 @@ fieldset.polls dd input { fieldset.polls dd div { text-align: right; font-family: Arial, Helvetica, sans-serif; - color: #FFFFFF; font-weight: bold; padding: 0 2px; overflow: visible; min-width: 2%; } -.pollbar1 { - background-color: #aaaaaa; - border-bottom: 1px solid #747474; - border-right: 1px solid #747474; -} - -.pollbar2 { - background-color: #bebebe; - border-bottom: 1px solid #8c8c8c; - border-right: 1px solid #8c8c8c; -} - -.pollbar3 { - background-color: #D1D1D1; - border-bottom: 1px solid #aaaaaa; - border-right: 1px solid #aaaaaa; -} - -.pollbar4 { - background-color: #e4e4e4; - border-bottom: 1px solid #bebebe; - border-right: 1px solid #bebebe; -} - -.pollbar5 { - background-color: #f8f8f8; - border-bottom: 1px solid #D1D1D1; - border-right: 1px solid #D1D1D1; +.pollbar1, .pollbar2, .pollbar3, .pollbar4, .pollbar5 { + border-bottom: 1px solid transparent; + border-right: 1px solid transparent; } /* Poster profile block @@ -735,15 +654,11 @@ fieldset.polls dd div { /* Also see tweaks.css */ margin: 5px 0 10px 0; min-height: 80px; - color: #666666; - border-left: 1px solid #FFFFFF; + border-left: 1px solid transparent; width: 22%; float: right; display: inline; } -.pm .postprofile { - border-left: 1px solid #DDDDDD; -} .postprofile dd, .postprofile dt { line-height: 1.2em; @@ -752,7 +667,6 @@ fieldset.polls dd div { .postprofile strong { font-weight: normal; - color: #000000; } .avatar { diff --git a/phpBB/styles/prosilver/theme/cp.css b/phpBB/styles/prosilver/theme/cp.css index 708bfbaf83..62e8513733 100644 --- a/phpBB/styles/prosilver/theme/cp.css +++ b/phpBB/styles/prosilver/theme/cp.css @@ -20,10 +20,6 @@ padding: 0; } -#cp-main h3, #cp-main hr, #cp-menu hr { - border-color: #bfbfbf; -} - #cp-main .panel p { font-size: 1.1em; } @@ -34,17 +30,16 @@ } #cp-main .panel li.row { - border-bottom: 1px solid #cbcbcb; - border-top: 1px solid #F9F9F9; + border-bottom: 1px solid transparent; + border-top: 1px solid transparent; } ul.cplist { margin-bottom: 5px; - border-top: 1px solid #cbcbcb; + border-top: 1px solid transparent; } #cp-main .panel li.header dd, #cp-main .panel li.header dt { - color: #000000; margin-bottom: 2px; } @@ -53,9 +48,8 @@ ul.cplist { } #cp-main table.table1 thead th { - color: #333333; font-weight: bold; - border-bottom: 1px solid #333333; + border-bottom: 1px solid transparent; padding: 5px; } @@ -76,9 +70,8 @@ ul.cplist { } #cp-main .pm-message { - border: 1px solid #e2e2e2; + border: 1px solid transparent; margin: 10px 0; - background-color: #FFFFFF; width: auto; float: none; } @@ -141,23 +134,17 @@ ul.cplist { display: block; background: none no-repeat 100% -35px; padding: 6px 10px 6px 5px; - color: #828282; white-space: nowrap; } -#tabs a:hover span { - color: #bcbcbc; -} - #tabs .activetab a { background-position: 0 0; - border-bottom: 1px solid #ebebeb; + border-bottom: 1px solid transparent; } #tabs .activetab a span { background-position: 100% 0; padding-bottom: 7px; - color: #333333; } #tabs a:hover { @@ -173,7 +160,6 @@ ul.cplist { } #tabs .activetab a:hover span { - color: #000000; background-position: 100% 0; } @@ -196,7 +182,6 @@ ul.cplist { padding: 0 10px 4px 10px; font-size: 1em; font-weight: bold; - background-color: #f2f2f2; margin-left: 2px; } @@ -207,14 +192,6 @@ ul.cplist { text-decoration: none; } -#minitabs li.activetab { - background-color: #F9F9F9; -} - -#minitabs li.activetab a, #minitabs li.activetab a:hover { - color: #333333; -} - /* UCP navigation menu ----------------------------------------*/ /* Container for sub-navigation list */ @@ -242,43 +219,25 @@ ul.cplist { margin: 1px 0; text-decoration: none; font-weight: bold; - color: #333; - background: #cfcfcf none repeat-y 100% 0; + background: transparent none repeat-y 100% 0; } #navigation a:hover { text-decoration: none; - background-color: #c6c6c6; - color: #bcbcbc; background-image: none; } #navigation #active-subsection a { display: block; - color: #d3d3d3; - background-color: #F9F9F9; background-image: none; } -#navigation #active-subsection a:hover { - color: #d3d3d3; -} - /* Preferences pane layout ----------------------------------------*/ #cp-main h2 { border-bottom: none; padding: 0; margin-left: 10px; - color: #333333; -} - -#cp-main .panel { - background-color: #F9F9F9; -} - -#cp-main .pm { - background-color: #FFFFFF; } #cp-main span.corners-top, #cp-menu span.corners-top { @@ -316,7 +275,6 @@ ul.cplist { /* Friends list */ .cp-mini { - background-color: #f9f9f9; padding: 0 5px; margin: 10px 15px 10px 5px; } @@ -327,7 +285,6 @@ ul.cplist { dl.mini dt { font-weight: bold; - color: #676767; } dl.mini dd { @@ -352,7 +309,7 @@ dl.mini dd { .pm-panel-header { margin: 0; padding-bottom: 10px; - border-bottom: 1px dashed #A4B3BF; + border-bottom: 1px dashed transparent; } .reply-all { @@ -373,12 +330,7 @@ dl.mini dd { #cp-main .pm-message-nav { margin: 0; padding: 2px 10px 5px 10px; - border-bottom: 1px dashed #A4B3BF; -} - -/* PM Message history */ -.current { - color: #999999; + border-bottom: 1px dashed transparent; } /* Defined rules list for PM options */ @@ -401,31 +353,16 @@ ol.def-rules li { } .pmlist li.pm_message_reported_colour, .pm_message_reported_colour { - border-left-color: #bcbcbc; - border-right-color: #bcbcbc; -} - -.pmlist li.pm_marked_colour, .pm_marked_colour { - padding: 0; - border: solid 3px #ffffff; - border-width: 0 3px; -} - -.pmlist li.pm_replied_colour, .pm_replied_colour { - padding: 0; - border: solid 3px #c2c2c2; - border-width: 0 3px; -} - -.pmlist li.pm_friend_colour, .pm_friend_colour { - padding: 0; - border: solid 3px #bdbdbd; - border-width: 0 3px; + border-left-color: transparent; + border-right-color: transparent; } +.pmlist li.pm_marked_colour, .pm_marked_colour, +.pmlist li.pm_replied_colour, .pm_replied_colour, +.pmlist li.pm_friend_colour, .pm_friend_colour, .pmlist li.pm_foe_colour, .pm_foe_colour { padding: 0; - border: solid 3px #000000; + border: solid 3px transparent; border-width: 0 3px; } @@ -444,11 +381,6 @@ ol.def-rules li { margin: 10px; padding: 5px; width: auto; - background: #FFFFFF; - border: 1px solid #CCC; + border: 1px solid transparent; text-align: center; } - -#gallery label:hover { - background-color: #EEE; -} diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css index 43888733cc..a381ecc04c 100644 --- a/phpBB/styles/prosilver/theme/forms.css +++ b/phpBB/styles/prosilver/theme/forms.css @@ -23,9 +23,8 @@ select { font-weight: normal; cursor: pointer; vertical-align: middle; - border: 1px solid #666666; + border: 1px solid transparent; padding: 1px; - background-color: #FAFAFA; font-size: 1em; } @@ -33,10 +32,6 @@ option { padding-right: 1em; } -option.disabled-option { - color: graytext; -} - textarea { font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; width: 60%; @@ -48,7 +43,6 @@ textarea { label { cursor: default; padding-right: 5px; - color: #676767; } label input { @@ -89,10 +83,6 @@ fieldset.fields1 dd { border-left-width: 0; } -fieldset.fields1 { - background-color: transparent; -} - fieldset.fields1 div { margin-bottom: 3px; } @@ -121,7 +111,6 @@ dt label { dd label { white-space: nowrap; - color: #333; } dd input, dd textarea { @@ -137,14 +126,6 @@ dd textarea { } /* Hover effects */ -fieldset dl:hover dt label { - color: #000000; -} - -fieldset.fields2 dl:hover dt label { - color: inherit; -} - #timezone { width: 95%; } @@ -166,7 +147,6 @@ fieldset.quick-login input.inputbox { width: 15%; vertical-align: middle; margin-right: 5px; - background-color: #f3f3f3; } fieldset.quick-login label { @@ -268,7 +248,6 @@ fieldset.submit-buttons input { min-width: 100%; max-width: 100%; font-size: 1.2em; - color: #333333; } /* Emoticons panel */ @@ -284,20 +263,13 @@ fieldset.submit-buttons input { /* Input field styles ---------------------------------------- */ .inputbox { - background-color: #FFFFFF; - border: 1px solid #c0c0c0; - color: #333333; + border: 1px solid transparent; padding: 2px; cursor: text; } -.inputbox:hover { - border: 1px solid #eaeaea; -} - -.inputbox:focus { - border: 1px solid #eaeaea; - color: #4b4b4b; +.inputbox:hover, .inputbox:focus { + border: 1px solid transparent; } input.inputbox { width: 85%; } @@ -324,13 +296,12 @@ a.button1, input.button1, input.button3, a.button2, input.button2 { padding-top: 1px; padding-bottom: 1px; font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - color: #000; - background: #FAFAFA none repeat-x top left; + background: transparent none repeat-x top left; } a.button1, input.button1 { font-weight: bold; - border: 1px solid #666666; + border: 1px solid transparent; } input.button3 { @@ -344,13 +315,12 @@ input.button3 { /* Alternative button */ a.button2, input.button2, input.button3 { - border: 1px solid #666666; + border: 1px solid transparent; } /* button in the style of the form buttons */ a.button1, a.button1:link, a.button1:visited, a.button1:active, a.button2, a.button2:link, a.button2:visited, a.button2:active { text-decoration: none; - color: #000000; padding: 2px 8px; line-height: 250%; vertical-align: text-bottom; @@ -359,14 +329,12 @@ a.button1, a.button1:link, a.button1:visited, a.button1:active, a.button2, a.but /* Hover states */ a.button1:hover, input.button1:hover, a.button2:hover, input.button2:hover, input.button3:hover { - border: 1px solid #BCBCBC; + border: 1px solid transparent; background-position: 0 100%; - color: #BCBCBC; } input.disabled { font-weight: normal; - color: #666666; } /* Topic and forum Search */ diff --git a/phpBB/styles/prosilver/theme/links.css b/phpBB/styles/prosilver/theme/links.css index c6a7cb4559..3cb6e928b5 100644 --- a/phpBB/styles/prosilver/theme/links.css +++ b/phpBB/styles/prosilver/theme/links.css @@ -7,10 +7,17 @@ a { unicode-bidi: embed; } -a:link { color: #898989; text-decoration: none; } -a:visited { color: #898989; text-decoration: none; } -a:hover { color: #d3d3d3; text-decoration: underline; } -a:active { color: #d2d2d2; text-decoration: none; } +a:link, a:visited { + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +a:active { + text-decoration: none; +} /* Coloured usernames */ .username-coloured { @@ -21,22 +28,18 @@ a:active { color: #d2d2d2; text-decoration: none; } /* Links on gradient backgrounds */ #search-box a:link, .navbg a:link, .forumbg .header a:link, .forabg .header a:link, th a:link { - color: #FFFFFF; text-decoration: none; } #search-box a:visited, .navbg a:visited, .forumbg .header a:visited, .forabg .header a:visited, th a:visited { - color: #FFFFFF; text-decoration: none; } #search-box a:hover, .navbg a:hover, .forumbg .header a:hover, .forabg .header a:hover, th a:hover { - color: #ffffff; text-decoration: underline; } #search-box a:active, .navbg a:active, .forumbg .header a:active, .forabg .header a:active, th a:active { - color: #ffffff; text-decoration: none; } @@ -45,96 +48,65 @@ a.forumtitle { font-family: "Trebuchet MS", Helvetica, Arial, Sans-serif; font-size: 1.2em; font-weight: bold; - color: #898989; text-decoration: none; } -/* a.forumtitle:visited { color: #898989; } */ - a.forumtitle:hover { - color: #bcbcbc; text-decoration: underline; } -a.forumtitle:active { - color: #898989; -} - a.topictitle { font-family: "Trebuchet MS", Helvetica, Arial, Sans-serif; font-size: 1.2em; font-weight: bold; - color: #898989; text-decoration: none; } -/* a.topictitle:visited { color: #d2d2d2; } */ - a.topictitle:hover { - color: #bcbcbc; text-decoration: underline; } -a.topictitle:active { - color: #898989; -} - /* Post body links */ .postlink { text-decoration: none; - color: #d2d2d2; - border-bottom: 1px solid #d2d2d2; + border-bottom: 1px solid transparent; padding-bottom: 0; } -/* .postlink:visited { color: #bdbdbd; } */ - -.postlink:active { - color: #d2d2d2; -} - .postlink:hover { - background-color: #f6f6f6; text-decoration: none; - color: #404040; } .signature a, .signature a:visited, .signature a:hover, .signature a:active { border: none; text-decoration: underline; - background-color: transparent; } /* Profile links */ .postprofile a:link, .postprofile a:visited, .postprofile dt.author a { font-weight: bold; - color: #898989; text-decoration: none; } .postprofile a:hover, .postprofile dt.author a:hover { text-decoration: underline; - color: #d3d3d3; } /* CSS spec requires a:link, a:visited, a:hover and a:active rules to be specified in this order. */ /* See http://www.phpbb.com/bugs/phpbb3/59685 */ .postprofile a:active { font-weight: bold; - color: #898989; text-decoration: none; } /* Profile searchresults */ .search .postprofile a { - color: #898989; text-decoration: none; font-weight: normal; } .search .postprofile a:hover { - color: #d3d3d3; text-decoration: underline; } @@ -177,7 +149,6 @@ a.up, a.up:link, a.up:active, a.up:visited { a.up:hover { background-position: left top; - background-color: transparent; } a.down, a.down:link, a.down:active, a.down:visited { @@ -194,7 +165,6 @@ a.left, a.left:active, a.left:visited { } a.left:hover { - color: #d2d2d2; text-decoration: none; background-position: 0 60%; } @@ -204,7 +174,6 @@ a.right, a.right:active, a.right:visited { } a.right:hover { - color: #d2d2d2; text-decoration: none; background-position: 100% 60%; } From 162f9b738aaa74684ea42e3ce4d6a911a183a996 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 18 Feb 2012 16:35:43 +0200 Subject: [PATCH 010/175] [feature/purge-cache] Allow all admins to purge cache Allow all administrators to purge cache PHPBB3-10659 --- phpBB/adm/style/acp_main.html | 3 ++- phpBB/includes/acp/acp_main.php | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/phpBB/adm/style/acp_main.html b/phpBB/adm/style/acp_main.html index 11f7fedd38..63ca3a1c79 100644 --- a/phpBB/adm/style/acp_main.html +++ b/phpBB/adm/style/acp_main.html @@ -194,13 +194,14 @@
+ +

{L_PURGE_CACHE_EXPLAIN}
- diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index b30c294ce2..7cdf734973 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -330,11 +330,6 @@ class acp_main break; case 'purge_cache': - if ((int) $user->data['user_type'] !== USER_FOUNDER) - { - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - global $cache; $cache->purge(); From c5de658c7f15a6ab0028353684323c3ef21521c9 Mon Sep 17 00:00:00 2001 From: callumacrae Date: Fri, 2 Dec 2011 17:26:39 +0000 Subject: [PATCH 011/175] [ticket/10510] Moved quick-mod tools markup to template. PHPBB3-10510 --- .../prosilver/template/viewtopic_body.html | 20 +++++++++++-- .../subsilver2/template/viewtopic_body.html | 24 +++++++++++++++- phpBB/viewtopic.php | 28 +++++++++---------- 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 952b986d9f..674f8b1ff4 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -254,10 +254,26 @@ - +
- {S_TOPIC_MOD} + + + {S_FORM_TOKEN}
diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index b8387482bf..f9526b9b28 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -347,7 +347,29 @@ - +
{L_QUICK_MOD}: {S_TOPIC_MOD}
+ +
+ {L_QUICK_MOD}: + + +
+ +
{rules.RULE}
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 7cb6df3660..450ebfeda8 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -517,20 +517,6 @@ gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']); // Quick mod tools $allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false; -$topic_mod = ''; -$topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? '' : '') : ''; -$topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '' : ''; -$topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '' : ''; -$topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '' : ''; -$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '' : ''; -$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '' : ''; - // If we've got a hightlight set pass it on to pagination. $pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start); @@ -617,7 +603,19 @@ $template->assign_vars(array( 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true, 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")), - 'S_TOPIC_MOD' => ($topic_mod != '') ? '' : '', + 'S_TOPIC_MOD_LOCK' => ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'lock' : 'unlock') : '', + 'S_TOPIC_MOD_DELETE' => ($auth->acl_get('m_delete', $forum_id)) ? true : false, + 'S_TOPIC_MOD_MOVE' => ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? true : false, + 'S_TOPIC_MOD_SPLIT' => ($auth->acl_get('m_split', $forum_id)) ? true : false, + 'S_TOPIC_MOD_MERGE' => ($auth->acl_get('m_merge', $forum_id)) ? true : false, + 'S_TOPIC_MOD_MERGE_TOPIC' => ($auth->acl_get('m_merge', $forum_id)) ? true : false, + 'S_TOPIC_MOD_FORK' => ($auth->acl_get('m_move', $forum_id)) ? true : false, + 'S_TOPIC_MOD_MAKE_NORMAL' => ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? true : false, + 'S_TOPIC_MOD_MAKE_STICKY' => ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? true : false, + 'S_TOPIC_MOD_MAKE_ANNOUNCE' => ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? true : false, + 'S_TOPIC_MOD_MAKE_GLOBAL' => ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? true : false, + 'S_TOPIC_MOD_TOPIC_LOGS' => ($auth->acl_get('m_', $forum_id)), + 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . "&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id), 'S_VIEWTOPIC' => true, From 2b0282cba73c8649b1649444a23c3913cc652de2 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 20 Dec 2011 09:27:56 +0000 Subject: [PATCH 012/175] [ticket/10510] Updated quick-mod conditional in subsilver2. It was still trying to use the old conditional, which was referring to a variable which had been removed. PHPBB3-10510 --- phpBB/styles/subsilver2/template/viewtopic_body.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index f9526b9b28..a431d51c79 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -348,7 +348,7 @@
- +
{L_QUICK_MOD}: - - - - - - - - - - - - - + + + {S_FORM_TOKEN} diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index a431d51c79..f696254249 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -352,19 +352,9 @@ {L_QUICK_MOD}:
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 450ebfeda8..12a611ce6f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -517,6 +517,99 @@ gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']); // Quick mod tools $allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false; +if ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => (($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'lock' : 'unlock'), + 'TITLE' => $user->lang[(($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'LOCK' : 'UNLOCK') . '_TOPIC'] + )); +} + +if ($auth->acl_get('m_delete', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'delete_topic', + 'TITLE' => $user->lang['DELETE_TOPIC'] + )); +} + +if ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'move', + 'TITLE' => $user->lang['MOVE_TOPIC'] + )); +} + +if ($auth->acl_get('m_split', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'split', + 'TITLE' => $user->lang['SPLIT_TOPIC'] + )); +} + +if ($auth->acl_get('m_merge', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'merge', + 'TITLE' => $user->lang['MERGE_POSTS'] + )); + + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'merge_topic', + 'TITLE' => $user->lang['MERGE_TOPIC'] + )); +} + +if ($auth->acl_get('m_move', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'fork', + 'TITLE' => $user->lang['FORK_TOPIC'] + )); +} + +if ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'make_normal', + 'TITLE' => $user->lang['MAKE_NORMAL'] + )); +} + +if ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'make_sticky', + 'TITLE' => $user->lang['MAKE_STICKY'] + )); +} + +if ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'make_announce', + 'TITLE' => $user->lang['MAKE_ANNOUNCE'] + )); +} + +if ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'make_global', + 'TITLE' => $user->lang['MAKE_GLOBAL'] + )); +} + +if ($auth->acl_get('m_', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'topic_logs', + 'TITLE' => $user->lang['VIEW_TOPIC_LOGS'] + )); +} + // If we've got a hightlight set pass it on to pagination. $pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start); @@ -603,19 +696,6 @@ $template->assign_vars(array( 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true, 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")), - 'S_TOPIC_MOD_LOCK' => ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'lock' : 'unlock') : '', - 'S_TOPIC_MOD_DELETE' => ($auth->acl_get('m_delete', $forum_id)) ? true : false, - 'S_TOPIC_MOD_MOVE' => ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? true : false, - 'S_TOPIC_MOD_SPLIT' => ($auth->acl_get('m_split', $forum_id)) ? true : false, - 'S_TOPIC_MOD_MERGE' => ($auth->acl_get('m_merge', $forum_id)) ? true : false, - 'S_TOPIC_MOD_MERGE_TOPIC' => ($auth->acl_get('m_merge', $forum_id)) ? true : false, - 'S_TOPIC_MOD_FORK' => ($auth->acl_get('m_move', $forum_id)) ? true : false, - 'S_TOPIC_MOD_MAKE_NORMAL' => ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? true : false, - 'S_TOPIC_MOD_MAKE_STICKY' => ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? true : false, - 'S_TOPIC_MOD_MAKE_ANNOUNCE' => ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? true : false, - 'S_TOPIC_MOD_MAKE_GLOBAL' => ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? true : false, - 'S_TOPIC_MOD_TOPIC_LOGS' => ($auth->acl_get('m_', $forum_id)), - 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . "&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id), 'S_VIEWTOPIC' => true, From c52e99fdbb4854f57ab8e4c6ad1fe06c4944a492 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 8 Mar 2012 18:41:22 +0000 Subject: [PATCH 020/175] [ticket/10510] Fixed a bug where quickmod tools weren't being displayed. It was referring to some template variables that were removed in a previous commit. Changed! PHPBB3-10510 --- phpBB/styles/prosilver/template/viewtopic_body.html | 2 +- phpBB/styles/subsilver2/template/viewtopic_body.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 320d6cb97d..59e464d22e 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -254,7 +254,7 @@ - +
diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index f696254249..2c5351b926 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -348,7 +348,7 @@ - + - + diff --git a/phpBB/adm/style/acp_bbcodes.html b/phpBB/adm/style/acp_bbcodes.html index b85e8eca81..5939af24ae 100644 --- a/phpBB/adm/style/acp_bbcodes.html +++ b/phpBB/adm/style/acp_bbcodes.html @@ -101,7 +101,7 @@ - + diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index 158751623a..ed94fa985e 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -350,7 +350,7 @@ - + diff --git a/phpBB/adm/style/acp_icons.html b/phpBB/adm/style/acp_icons.html index 85b5343666..a8864d42f7 100644 --- a/phpBB/adm/style/acp_icons.html +++ b/phpBB/adm/style/acp_icons.html @@ -245,7 +245,7 @@ diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index 3f1c0bf50b..6c4645e80c 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -164,7 +164,7 @@ {ICON_MOVE_DOWN_DISABLED} {ICON_EDIT} - {ICON_DELETE} + {ICON_DELETE} diff --git a/phpBB/adm/style/acp_permission_roles.html b/phpBB/adm/style/acp_permission_roles.html index 658d8dd0c8..2ac77af25d 100644 --- a/phpBB/adm/style/acp_permission_roles.html +++ b/phpBB/adm/style/acp_permission_roles.html @@ -174,7 +174,7 @@ {ICON_MOVE_DOWN_DISABLED} {ICON_EDIT} - {ICON_DELETE} + {ICON_DELETE} diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index 0ac0d78a64..7804533d1a 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -195,7 +195,7 @@ - + diff --git a/phpBB/adm/style/acp_ranks.html b/phpBB/adm/style/acp_ranks.html index 2f77a256b1..7fb7da7095 100644 --- a/phpBB/adm/style/acp_ranks.html +++ b/phpBB/adm/style/acp_ranks.html @@ -80,7 +80,7 @@ - + diff --git a/phpBB/adm/style/acp_reasons.html b/phpBB/adm/style/acp_reasons.html index 522aec5930..7cf2cce4c9 100644 --- a/phpBB/adm/style/acp_reasons.html +++ b/phpBB/adm/style/acp_reasons.html @@ -99,7 +99,7 @@ {ICON_EDIT} - {ICON_DELETE} + {ICON_DELETE} {ICON_DELETE_DISABLED} diff --git a/phpBB/adm/style/acp_words.html b/phpBB/adm/style/acp_words.html index 113f58ef92..4acd75f933 100644 --- a/phpBB/adm/style/acp_words.html +++ b/phpBB/adm/style/acp_words.html @@ -60,7 +60,7 @@ - + diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php index a3822a982a..e537d7a8b9 100644 --- a/phpBB/includes/acp/acp_bbcodes.php +++ b/phpBB/includes/acp/acp_bbcodes.php @@ -24,7 +24,7 @@ class acp_bbcodes function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/posting'); @@ -272,6 +272,18 @@ class acp_bbcodes $db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id"); $cache->destroy('sql', BBCODES_TABLE); add_log('admin', 'LOG_BBCODE_DELETE', $row['bbcode_tag']); + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['BBCODE_DELETED'], + 'REFRESH_DATA' => array( + 'time' => 3 + ) + )); + } } else { diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 49a092f16b..bfe17c5007 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -782,6 +782,18 @@ class acp_icons $cache->destroy('_icons'); $cache->destroy('sql', $table); + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $notice, + 'REFRESH_DATA' => array( + 'time' => 3 + ) + )); + } } else { diff --git a/phpBB/includes/acp/acp_ranks.php b/phpBB/includes/acp/acp_ranks.php index ec5a76df87..d9ed5b17f1 100644 --- a/phpBB/includes/acp/acp_ranks.php +++ b/phpBB/includes/acp/acp_ranks.php @@ -24,7 +24,7 @@ class acp_ranks function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/posting'); @@ -122,6 +122,18 @@ class acp_ranks $cache->destroy('_ranks'); add_log('admin', 'LOG_RANK_REMOVED', $rank_title); + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['RANK_REMOVED'], + 'REFRESH_DATA' => array( + 'time' => 3 + ) + )); + } } else { diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php index 84cf640d1f..76d4869990 100644 --- a/phpBB/language/en/acp/posting.php +++ b/phpBB/language/en/acp/posting.php @@ -45,6 +45,7 @@ $lang = array_merge($lang, array( 'BBCODE_ADDED' => 'BBCode added successfully.', 'BBCODE_EDITED' => 'BBCode edited successfully.', + 'BBCODE_DELETED' => 'The BBCode has been removed successfully.', 'BBCODE_NOT_EXIST' => 'The BBCode you selected does not exist.', 'BBCODE_HELPLINE' => 'Help line', 'BBCODE_HELPLINE_EXPLAIN' => 'This field contains the mouse over text of the BBCode.', diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 8814d105e1..85dcdb25f5 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -363,6 +363,9 @@ phpbb.add_ajax_callback('post_delete', function(el) { tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } +}).add_ajax_callback('row_delete', function(el) { + var tr = $(el).parents('tr'); + tr.remove(); }).add_ajax_callback('zebra', function(el, res) { if (res.success) { $('.zebra').html(res.MESSAGE_TEXT); From 1cb3b595ec70730429a9c8654b248fc6d50cf1b3 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 15:45:51 +0100 Subject: [PATCH 088/175] [ticket/10271] AJAXified the styles tab in the ACP. PHPBB3-10271 --- phpBB/adm/style/acp_styles.html | 2 +- phpBB/includes/acp/acp_styles.php | 17 +++++++++++++++-- phpBB/language/en/acp/styles.php | 2 ++ phpBB/styles/script.js | 22 ++++++++++++++++------ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index dc89aa247a..dfc8def646 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -288,7 +288,7 @@ - + - + diff --git a/phpBB/includes/acp/acp_bots.php b/phpBB/includes/acp/acp_bots.php index f080b3c9fb..b9dd6664f4 100644 --- a/phpBB/includes/acp/acp_bots.php +++ b/phpBB/includes/acp/acp_bots.php @@ -24,7 +24,7 @@ class acp_bots function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template, $cache, $request; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; $action = request_var('action', ''); @@ -352,6 +352,14 @@ class acp_bots break; } + + if ($request->is_ajax() && ($action == 'activate' || $action == 'deactivate')) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'text' => $user->lang['BOT_' . (($action == 'activate') ? 'DE' : '') . 'ACTIVATE'], + )); + } $s_options = ''; $_options = array('activate' => 'BOT_ACTIVATE', 'deactivate' => 'BOT_DEACTIVATE', 'delete' => 'DELETE'); diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 16d64319d9..59fe7cf8e2 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -228,6 +228,10 @@ phpbb.ajaxify = function(options, refresh, callback) { { var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); } + else + { + dark.fadeOut(); + } if (typeof phpbb.ajax_callbacks[callback] === 'function') { @@ -249,6 +253,10 @@ phpbb.ajaxify = function(options, refresh, callback) { { var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); } + else + { + dark.fadeOut(); + } if (typeof phpbb.ajax_callbacks[callback] === 'function') { From bcb824a9f2407523c84501ac1d4260bb27661ff1 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 16:59:05 +0100 Subject: [PATCH 092/175] [ticket/10272] Renamed AJAX callback "style_act_deact" to "act_deact". PHPBB3-10272 --- phpBB/adm/style/acp_bots.html | 2 +- phpBB/adm/style/acp_modules.html | 2 +- phpBB/adm/style/acp_profile.html | 2 +- phpBB/adm/style/acp_styles.html | 2 +- phpBB/styles/script.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/adm/style/acp_bots.html b/phpBB/adm/style/acp_bots.html index e0e9588364..3a5ef72acd 100644 --- a/phpBB/adm/style/acp_bots.html +++ b/phpBB/adm/style/acp_bots.html @@ -76,7 +76,7 @@ - + diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index 6c4645e80c..380a037977 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -148,7 +148,7 @@ - + - + - + diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index d0920774f1..4a6df768a8 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -195,7 +195,7 @@ - + - +
- + {L_QUICK_MOD}: - -
- -
- -
- {S_FORM_TOKEN} - {QR_HIDDEN_FIELDS} -   -   -
- - - -
-
+ + + 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 = $('

' + title + '

' + msg + '

'); + + $(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 = $('

' + msg + '

\ +  \ +
'); + + $('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; +}); From e6401c081e2e7543db020d16271792d715571249 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 14 Jul 2011 14:41:24 +0100 Subject: [PATCH 057/175] [ticket/10271] Added phpbb.confirm_box (JavaScript). As well as adding the method, this commit also changes the previous commit so that deleting a post from viewtopic uses this method, too. This commit has also made some improvements to phpbb.alert and phpbb.confirm. PHPBB3-10271 --- phpBB/styles/script.js | 97 ++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 9be3efd4ce..ed10375cf1 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -5,11 +5,13 @@ var phpbb = {}; * * @param string title Title of the message, eg "Information" * @param string msg Message to display. Can be HTML. + * + * @return Returns the div created. */ phpbb.alert = function(title, msg) { var div = $('

' + title + '

' + msg + '

'); - $(document).bind('click', function(e) { + $(document).one('click', function(e) { if ($(e.target).parents('.jalert').length) { return true; @@ -22,6 +24,7 @@ phpbb.alert = function(title, msg) { $('body').append(div); div.show(300); + return div; } /** @@ -29,6 +32,8 @@ phpbb.alert = function(title, msg) { * * @param string msg Message to display. Can be HTML. * @param function callback Callback. + * + * @return Returns the div created. */ phpbb.confirm = function(msg, callback) { var div = $('

' + msg + '

\ @@ -45,36 +50,74 @@ phpbb.confirm = function(msg, callback) { return false; }); div.show(300); + return div; } - -$('.delete-icon a').click(function() +/** + * This function interacts via AJAX with phpBBs confirm_box function. + * + * @param string condition The element to capture. + * @param bool/function refresh If we are sent back a refresh, should it be + * acted upon? This can either be true / false / a function. + * @param function callback Callback. + */ +phpbb.confirm_box = function(condition, refresh, callback) { - 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(); + __self = this; + $(condition).click(function() { + 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); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + callback(__self); - //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); - } - }); - } + if (res.REFRESH_DATA) + { + if (typeof refresh === 'function') + { + refresh = refresh(res.REFRESH_DATA.url) + } + else if (typeof refresh !== 'boolean') + { + refresh = false; + } + + if (refresh) + { + setTimeout(function() { + window.location = res.REFRESH_DATA.url; + }, res.REFRESH_DATA.time * 1000); + } + else + { + setTimeout(function() { + div.hide(300, function() { + div.remove(); + }); + }, res.REFRESH_DATA.time * 1000); + } + } + }); + } + }); }); + return false; }); - return false; -}); +} + +var refresh = function(url) { + return (url.indexOf('t=') === -1); +} +var callback = function(el) { + var pid = el.href.split('&p=')[1]; + $(el).parents('div #p' + pid).remove(); +} +phpbb.confirm_box('.delete-icon a', refresh, callback); From 2556f5fcc2df1dc51ddd5a97859a7325809b7837 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 14 Jul 2011 14:57:45 +0100 Subject: [PATCH 058/175] [ticket/10272] AJAXified most links. This commit makes some significant changes to the phpbb.confirm_box function (namely, removing some duplicate code), and also manually adds most link to the phpBB AJAX functions. PHPBB3-10272 --- phpBB/styles/script.js | 101 +++++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 25 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index ed10375cf1..ee67768469 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -53,6 +53,39 @@ phpbb.confirm = function(msg, callback) { return div; } +/** + * Clearing up some duplicate code - don't use this. + */ +function handle_refresh(data, refresh, div) +{ + if (data) + { + if (typeof refresh === 'function') + { + refresh = refresh(data.url) + } + else if (typeof refresh !== 'boolean') + { + refresh = false; + } + + if (refresh) + { + setTimeout(function() { + window.location = data.url; + }, data.time * 1000); + } + else + { + setTimeout(function() { + div.hide(300, function() { + div.remove(); + }); + }, data.time * 1000); + } + } +} + /** * This function interacts via AJAX with phpBBs confirm_box function. @@ -77,34 +110,13 @@ phpbb.confirm_box = function(condition, refresh, callback) $.post(p[0], p[1], function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - callback(__self); - if (res.REFRESH_DATA) + if (typeof callback !== 'undefined') { - if (typeof refresh === 'function') - { - refresh = refresh(res.REFRESH_DATA.url) - } - else if (typeof refresh !== 'boolean') - { - refresh = false; - } - - if (refresh) - { - setTimeout(function() { - window.location = res.REFRESH_DATA.url; - }, res.REFRESH_DATA.time * 1000); - } - else - { - setTimeout(function() { - div.hide(300, function() { - div.remove(); - }); - }, res.REFRESH_DATA.time * 1000); - } + callback(__self); } + + handle_refresh(res.REFRESH_DATA, refresh, alert); }); } }); @@ -113,6 +125,26 @@ phpbb.confirm_box = function(condition, refresh, callback) }); } +/** + * Makes a link use AJAX instead of loading an entire page. + */ +phpbb.ajaxify = function(selector, refresh, callback) { + $(selector).click(function() { + var __self = this; + $.get(this.href, function(res) { + res = JSON.parse(res); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof callback !== 'undefined') + { + callback(__self, res); + } + + handle_refresh(res.REFRESH_DATA, refresh, alert); + }); + return false; + }); +} + var refresh = function(url) { return (url.indexOf('t=') === -1); } @@ -121,3 +153,22 @@ var callback = function(el) { $(el).parents('div #p' + pid).remove(); } phpbb.confirm_box('.delete-icon a', refresh, callback); +phpbb.confirm_box('a[href$="ucp.php?mode=delete_cookies"]', true); + +phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { + var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); + text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; + $(el).text(el.title = text); +}); +phpbb.ajaxify('a[href*="&watch=topic"]', false, function(el, res) { + var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); + text = (text) ? 'Unsubscribe topic' : 'Subscribe topic'; + $(el).text(el.title = text); +}); +phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { + var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); + text = (text) ? 'Unsubscribe forum' : 'Subscribe forum'; + $(el).text(el.title = text); +}); +phpbb.ajaxify('a[href*="mode=bump"]'); +phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums From c4aaf3ae5a2b0a720227a0eadcb62bea5671056a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 14 Jul 2011 17:49:17 +0100 Subject: [PATCH 059/175] [feature/ajax] Cleaned up AJAX-related JavaScript. Mostly just added comments, but has cleaned up some actual code too. PHPBB3-10270 --- phpBB/styles/script.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index ee67768469..4e0566a9a5 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,7 +1,7 @@ var phpbb = {}; /** - * Display a simple alert. + * Display a simple alert similar to JSs native alert(). * * @param string title Title of the message, eg "Information" * @param string msg Message to display. Can be HTML. @@ -54,7 +54,7 @@ phpbb.confirm = function(msg, callback) { } /** - * Clearing up some duplicate code - don't use this. + * Works out what to do with the refresh. Don't use this. */ function handle_refresh(data, refresh, div) { @@ -97,7 +97,6 @@ function handle_refresh(data, refresh, div) */ phpbb.confirm_box = function(condition, refresh, callback) { - __self = this; $(condition).click(function() { var __self = this; $.get(this.href, function(res) { @@ -106,16 +105,13 @@ phpbb.confirm_box = function(condition, refresh, callback) if (del) { var p = res.S_CONFIRM_ACTION.split('?'); - p[1] += '&confirm=Yes'; - $.post(p[0], p[1], function(res) { + $.post(p[0], p[1] + '&confirm=Yes', function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - if (typeof callback !== 'undefined') { callback(__self); } - handle_refresh(res.REFRESH_DATA, refresh, alert); }); } @@ -127,6 +123,11 @@ phpbb.confirm_box = function(condition, refresh, callback) /** * Makes a link use AJAX instead of loading an entire page. + * + * @param string condition The element to capture. + * @param bool/function refresh If we are sent back a refresh, should it be + * acted upon? This can either be true / false / a function. + * @param function callback Callback. */ phpbb.ajaxify = function(selector, refresh, callback) { $(selector).click(function() { @@ -138,23 +139,25 @@ phpbb.ajaxify = function(selector, refresh, callback) { { callback(__self, res); } - handle_refresh(res.REFRESH_DATA, refresh, alert); }); return false; }); } + +//bind the confirm_boxes var refresh = function(url) { return (url.indexOf('t=') === -1); } -var callback = function(el) { +phpbb.confirm_box('.delete-icon a', refresh, function(el) { var pid = el.href.split('&p=')[1]; $(el).parents('div #p' + pid).remove(); -} -phpbb.confirm_box('.delete-icon a', refresh, callback); +}); phpbb.confirm_box('a[href$="ucp.php?mode=delete_cookies"]', true); + +//AJAXify some links phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; From 8a28456f759747fc34aaf9a6589102fcace3acb6 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 16 Jul 2011 17:53:22 +0100 Subject: [PATCH 060/175] [ticket/10273] AJAXified approve / disapprove posts (in viewtopic). This commit AJAXifies the moderator approval functionality, and adds it to viewtopic instead of the MCP. This commit has involved some language changes, which may affect fallbacks. PHPBB3-10273 --- phpBB/language/en/common.php | 2 +- phpBB/language/en/viewtopic.php | 2 + .../prosilver/template/viewtopic_body.html | 10 +++- phpBB/styles/prosilver/theme/common.css | 4 ++ phpBB/styles/script.js | 51 +++++++++++++++++++ phpBB/viewtopic.php | 1 + 6 files changed, 68 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 94edddc6f5..19b801e585 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -476,7 +476,7 @@ $lang = array_merge($lang, array( 'POST_SUBJECT' => 'Post subject', 'POST_TIME' => 'Post time', 'POST_TOPIC' => 'Post a new topic', - 'POST_UNAPPROVED' => 'This post is waiting for approval', + 'POST_UNAPPROVED' => 'Post awaiting approval:', 'PREVIEW' => 'Preview', 'PREVIOUS' => 'Previous', // Used in pagination 'PREVIOUS_STEP' => 'Previous', diff --git a/phpBB/language/en/viewtopic.php b/phpBB/language/en/viewtopic.php index f47f8a076b..1460490672 100644 --- a/phpBB/language/en/viewtopic.php +++ b/phpBB/language/en/viewtopic.php @@ -35,6 +35,7 @@ if (empty($lang) || !is_array($lang)) // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine $lang = array_merge($lang, array( + 'APPROVE' => 'Approve', 'ATTACHMENT' => 'Attachment', 'ATTACHMENT_FUNCTIONALITY_DISABLED' => 'The attachments feature has been disabled.', @@ -49,6 +50,7 @@ $lang = array_merge($lang, array( 'CODE' => 'Code', 'DELETE_TOPIC' => 'Delete topic', + 'DISAPPROVE' => 'Disapprove', 'DOWNLOAD_NOTICE' => 'You do not have the required permissions to view the files attached to this post.', 'EDITED_TIMES_TOTAL' => array( diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 59e464d22e..5571ce07c4 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -135,10 +135,18 @@

{postrow.MINI_POST_IMG}{postrow.MINI_POST_IMG}{L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » {postrow.POST_DATE}

+

- {UNAPPROVED_IMG} {L_POST_UNAPPROVED}
+ + {UNAPPROVED_IMG} {L_POST_UNAPPROVED}   +   + + + {S_FORM_TOKEN} +
{REPORTED_IMG} {L_POST_REPORTED}

+
{postrow.MESSAGE}
diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 5cf12be1ce..6b34bb1c3d 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -658,6 +658,10 @@ p.rules { p.rules img { vertical-align: middle; +} + +p.rules strong { + vertical-align: middle; padding-top: 5px; } diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 4e0566a9a5..b5dec2ca0a 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -86,6 +86,18 @@ function handle_refresh(data, refresh, div) } } +function parse_hidden(inputs) +{ + var end = []; + $(inputs).each(function() { + if (this.type === 'hidden') + { + end.push(this.name + '=' + this.value); + } + }); + return end.join('&'); +} + /** * This function interacts via AJAX with phpBBs confirm_box function. @@ -175,3 +187,42 @@ phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { }); phpbb.ajaxify('a[href*="mode=bump"]'); phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums + + + +/** + * Forms have to be captured manually, as they're all different. + */ +$('input[name^="action"]').click(function(e) { + var __self = this; + var path = $(this).parents('form')[0].action.replace('&', '&'); + var action = (this.name === 'action[approve]') ? 'approve' : 'disapprove'; + var data = { + action: action, + post_id_list: [$(this).siblings('input[name="post_id_list[]"]')[0].value] + }; + $.post(path, data, function(res) { + res = JSON.parse(res); + phpbb.confirm(res.MESSAGE_TEXT, function(del) { + if (del) + { + path = res.S_CONFIRM_ACTION; + data = parse_hidden(res.S_HIDDEN_FIELDS); + $.post(path, data + '&confirm=Yes', function(res) { + console.log(res); + res = JSON.parse(res); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + + $(__self).parents((action === 'approve') ? '.rules' : '.post').remove(); + + setTimeout(function() { + alert.hide(300, function() { + alert.remove(); + }); + }, 5000); + }); + } + }); + }); + return false; +}); diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 8a95851b7e..1ce80568b6 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1534,6 +1534,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_YIM' => $user_cache[$poster_id]['yim'], 'U_JABBER' => $user_cache[$poster_id]['jabber'], + 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f=$forum_id"), 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', From 456e56144256f3d14d78b02b397d5f3838f0cfea Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 16 Jul 2011 18:20:04 +0100 Subject: [PATCH 061/175] [ticket/10270] Cleaned up code and made popups fade. This commit cleans up some code - mostly, replacing all instances of __self with "that", and also replacing the parse_hidden function with jQuerys built in .serialize. It also adds animations to the popups. PHPBB3-10270 --- phpBB/styles/script.js | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index b5dec2ca0a..17934ed6ae 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -16,14 +16,14 @@ phpbb.alert = function(title, msg) { { return true; } - div.hide(300, function() { + div.animate({opacity: 0}, 300, function() { div.remove(); }); return false; }); $('body').append(div); - div.show(300); + div.css('opacity', 0).show().animate({opacity: 1}, 300); return div; } @@ -43,13 +43,13 @@ phpbb.confirm = function(msg, callback) { $('body').append(div); $('.jalertbut').bind('click', function(event) { - div.hide(300, function() { + div.animate({opacity: 0}, 300, function() { div.remove(); }); callback(this.value === 'Yes'); return false; }); - div.show(300); + div.css('opacity', 0).show().animate({opacity: 1}, 300); return div; } @@ -78,7 +78,7 @@ function handle_refresh(data, refresh, div) else { setTimeout(function() { - div.hide(300, function() { + div.animate({opacity: 0}, 300, function() { div.remove(); }); }, data.time * 1000); @@ -86,18 +86,6 @@ function handle_refresh(data, refresh, div) } } -function parse_hidden(inputs) -{ - var end = []; - $(inputs).each(function() { - if (this.type === 'hidden') - { - end.push(this.name + '=' + this.value); - } - }); - return end.join('&'); -} - /** * This function interacts via AJAX with phpBBs confirm_box function. @@ -110,19 +98,20 @@ function parse_hidden(inputs) phpbb.confirm_box = function(condition, refresh, callback) { $(condition).click(function() { - var __self = this; + var that = 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('?'); - $.post(p[0], p[1] + '&confirm=Yes', function(res) { + var path = res.S_CONFIRM_ACTION; + var data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); + $.post(path, data + '&confirm=Yes', function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') { - callback(__self); + callback(that); } handle_refresh(res.REFRESH_DATA, refresh, alert); }); @@ -143,13 +132,13 @@ phpbb.confirm_box = function(condition, refresh, callback) */ phpbb.ajaxify = function(selector, refresh, callback) { $(selector).click(function() { - var __self = this; + var that = this; $.get(this.href, function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') { - callback(__self, res); + callback(that, res); } handle_refresh(res.REFRESH_DATA, refresh, alert); }); @@ -194,7 +183,7 @@ phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums * Forms have to be captured manually, as they're all different. */ $('input[name^="action"]').click(function(e) { - var __self = this; + var that = this; var path = $(this).parents('form')[0].action.replace('&', '&'); var action = (this.name === 'action[approve]') ? 'approve' : 'disapprove'; var data = { @@ -207,13 +196,12 @@ $('input[name^="action"]').click(function(e) { if (del) { path = res.S_CONFIRM_ACTION; - data = parse_hidden(res.S_HIDDEN_FIELDS); + data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); $.post(path, data + '&confirm=Yes', function(res) { - console.log(res); res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - $(__self).parents((action === 'approve') ? '.rules' : '.post').remove(); + $(that).parents((action === 'approve') ? '.rules' : '.post').remove(); setTimeout(function() { alert.hide(300, function() { From f42f6f19028fab5b047baae0df5004a43e946a30 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 17 Jul 2011 14:57:13 +0100 Subject: [PATCH 062/175] [ticket/10273] Added phpbb.ajaxify_form and converted accept / deny to it. Also made a few minor improvements to other JavaScript. PHPBB3-10273 --- .../prosilver/template/viewtopic_body.html | 4 +- phpBB/styles/script.js | 125 +++++++++++------- 2 files changed, 80 insertions(+), 49 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 5571ce07c4..856ee6962c 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -139,8 +139,8 @@

{UNAPPROVED_IMG} {L_POST_UNAPPROVED}   -   - +   + {S_FORM_TOKEN}
diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 17934ed6ae..5d9b89e386 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,3 +1,26 @@ +/** + * Make some changes to the jQuery core. + */ +$.fn.hide = function() { + this.animate({opacity: 0}, 300, function() { + $(this).css('display', 'none') + .css('opacity', 1); + }); +} +$.fn.show = function() { + this.css('opacity', 0) + .css('display', 'block') + .animate({opacity: 1}, 300); +} + +$.fn.remove_old = $.fn.remove; +$.fn.remove = function() { + this.animate({opacity: 0}, 300, function() { + $(this).remove_old(); + }); +} + + var phpbb = {}; /** @@ -16,14 +39,12 @@ phpbb.alert = function(title, msg) { { return true; } - div.animate({opacity: 0}, 300, function() { - div.remove(); - }); + div.remove(); return false; }); $('body').append(div); - div.css('opacity', 0).show().animate({opacity: 1}, 300); + div.show(); return div; } @@ -37,19 +58,17 @@ phpbb.alert = function(title, msg) { */ phpbb.confirm = function(msg, callback) { var div = $('

' + msg + '

\ -  \ -
'); +  \ +
'); $('body').append(div); $('.jalertbut').bind('click', function(event) { - div.animate({opacity: 0}, 300, function() { - div.remove(); - }); + div.remove(); callback(this.value === 'Yes'); return false; }); - div.css('opacity', 0).show().animate({opacity: 1}, 300); + div.show(); return div; } @@ -101,12 +120,13 @@ phpbb.confirm_box = function(condition, refresh, callback) var that = this; $.get(this.href, function(res) { res = JSON.parse(res); + console.log(res); phpbb.confirm(res.MESSAGE_TEXT, function(del) { if (del) { var path = res.S_CONFIRM_ACTION; var data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(path, data + '&confirm=Yes', function(res) { + $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') @@ -135,6 +155,7 @@ phpbb.ajaxify = function(selector, refresh, callback) { var that = this; $.get(this.href, function(res) { res = JSON.parse(res); + console.log(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') { @@ -146,6 +167,50 @@ phpbb.ajaxify = function(selector, refresh, callback) { }); } +/** + * AJAXifies a form. This will automatically get the action from the submit. + * + * @param string condition The element to capture. + * @param bool/function refresh If we are sent back a refresh, should it be + * acted upon? This can either be true / false / a function. + * @param function callback Callback. + */ +phpbb.ajaxify_form = function(selector, refresh, callback) +{ + $(selector + ' input:submit').click(function(e) { + var act = /action\[([a-z]+)\]/.exec(this.name), + data = decodeURI($(this).closest('form').serialize()), + path = $(this).closest('form').attr('action').replace('&', '&'), + that = this; + + if (act) + { + data += '&action=' + act[1]; + } + + $.post(path, data, function(res) { + res = JSON.parse(res); + phpbb.confirm(res.MESSAGE_TEXT, function(del) { + if (del) + { + path = res.S_CONFIRM_ACTION; + data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); + $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { + res = JSON.parse(res); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof callback !== 'undefined') + { + callback(that, act[1]); + } + handle_refresh(res.REFRESH_DATA, refresh, alert); + }); + } + }); + }); + return false; + }); +} + //bind the confirm_boxes var refresh = function(url) { @@ -177,40 +242,6 @@ phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { phpbb.ajaxify('a[href*="mode=bump"]'); phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums - - -/** - * Forms have to be captured manually, as they're all different. - */ -$('input[name^="action"]').click(function(e) { - var that = this; - var path = $(this).parents('form')[0].action.replace('&', '&'); - var action = (this.name === 'action[approve]') ? 'approve' : 'disapprove'; - var data = { - action: action, - post_id_list: [$(this).siblings('input[name="post_id_list[]"]')[0].value] - }; - $.post(path, data, function(res) { - res = JSON.parse(res); - phpbb.confirm(res.MESSAGE_TEXT, function(del) { - if (del) - { - path = res.S_CONFIRM_ACTION; - data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(path, data + '&confirm=Yes', function(res) { - res = JSON.parse(res); - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - - $(that).parents((action === 'approve') ? '.rules' : '.post').remove(); - - setTimeout(function() { - alert.hide(300, function() { - alert.remove(); - }); - }, 5000); - }); - } - }); - }); - return false; +phpbb.ajaxify_form('.mcp_approve', false, function(el, act) { + $(el).parents((act === 'approve') ? '.rules' : '.post').remove(); }); From fbad17f91202236d3b4ed5c1dacb844aaf2ddbff Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 17 Jul 2011 15:27:58 +0100 Subject: [PATCH 063/175] [feature/ajax] Reduced duplicate code by merging all AJAX function into one. This commit merges phpbb.confirm_box, phpbb.ajaxify and phpbb.ajaxify_form into one function which automatically detects what is happening and calls the correct code accordingly. This has removed a lot of duplicate code and generally made the code cleaner. PHPBB3-10270 --- phpBB/styles/script.js | 202 +++++++++++++++++------------------------ 1 file changed, 84 insertions(+), 118 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 5d9b89e386..e893b84bf8 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -75,72 +75,7 @@ phpbb.confirm = function(msg, callback) { /** * Works out what to do with the refresh. Don't use this. */ -function handle_refresh(data, refresh, div) -{ - if (data) - { - if (typeof refresh === 'function') - { - refresh = refresh(data.url) - } - else if (typeof refresh !== 'boolean') - { - refresh = false; - } - if (refresh) - { - setTimeout(function() { - window.location = data.url; - }, data.time * 1000); - } - else - { - setTimeout(function() { - div.animate({opacity: 0}, 300, function() { - div.remove(); - }); - }, data.time * 1000); - } - } -} - - -/** - * This function interacts via AJAX with phpBBs confirm_box function. - * - * @param string condition The element to capture. - * @param bool/function refresh If we are sent back a refresh, should it be - * acted upon? This can either be true / false / a function. - * @param function callback Callback. - */ -phpbb.confirm_box = function(condition, refresh, callback) -{ - $(condition).click(function() { - var that = this; - $.get(this.href, function(res) { - res = JSON.parse(res); - console.log(res); - phpbb.confirm(res.MESSAGE_TEXT, function(del) { - if (del) - { - var path = res.S_CONFIRM_ACTION; - var data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { - res = JSON.parse(res); - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - if (typeof callback !== 'undefined') - { - callback(that); - } - handle_refresh(res.REFRESH_DATA, refresh, alert); - }); - } - }); - }); - return false; - }); -} /** * Makes a link use AJAX instead of loading an entire page. @@ -151,62 +86,92 @@ phpbb.confirm_box = function(condition, refresh, callback) * @param function callback Callback. */ phpbb.ajaxify = function(selector, refresh, callback) { - $(selector).click(function() { - var that = this; - $.get(this.href, function(res) { - res = JSON.parse(res); - console.log(res); - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - if (typeof callback !== 'undefined') - { - callback(that, res); - } - handle_refresh(res.REFRESH_DATA, refresh, alert); - }); - return false; - }); -} -/** - * AJAXifies a form. This will automatically get the action from the submit. - * - * @param string condition The element to capture. - * @param bool/function refresh If we are sent back a refresh, should it be - * acted upon? This can either be true / false / a function. - * @param function callback Callback. - */ -phpbb.ajaxify_form = function(selector, refresh, callback) -{ - $(selector + ' input:submit').click(function(e) { - var act = /action\[([a-z]+)\]/.exec(this.name), - data = decodeURI($(this).closest('form').serialize()), - path = $(this).closest('form').attr('action').replace('&', '&'), - that = this; - - if (act) + //private function to handle refreshes + function handle_refresh(data, refresh, div) + { + if (!data) { - data += '&action=' + act[1]; + return; } - $.post(path, data, function(res) { + refresh = ((typeof refresh === 'function') ? refresh(data.url) : + (typeof refresh === 'boolean') && refresh); + + setTimeout(function() { + if (refresh) + { + window.location = data.url; + } + else + { + div.remove(); + } + }, data.time * 1000); + } + + var is_form = $(selector).is('form'); + $(selector + ((is_form) ? ' input:submit' : '')).click(function() { + var act, data, path, that = this; + function return_handler(res) + { res = JSON.parse(res); - phpbb.confirm(res.MESSAGE_TEXT, function(del) { - if (del) + + if (typeof res.S_CONFIRM_ACTION === 'undefined') + { + /** + * It is a standard link, no confirm_box required. + */ + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof callback !== 'undefined') { - path = res.S_CONFIRM_ACTION; - data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { - res = JSON.parse(res); - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - if (typeof callback !== 'undefined') - { - callback(that, act[1]); - } - handle_refresh(res.REFRESH_DATA, refresh, alert); - }); + callback(that, res); } - }); - }); + handle_refresh(res.REFRESH_DATA, refresh, alert); + } + else + { + /** + * confirm_box - confirm with the user and send back + */ + phpbb.confirm(res.MESSAGE_TEXT, function(del) { + if (del) + { + data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); + path = res.S_CONFIRM_ACTION; + $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { + res = JSON.parse(res); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof callback !== 'undefined') + { + callback(that, (is_form) ? act : null); + } + handle_refresh(res.REFRESH_DATA, refresh, alert); + }); + } + }); + } + } + + if (is_form) + { + act = /action\[([a-z]+)\]/.exec(this.name); + data = decodeURI($(this).closest('form').serialize()); + path = $(this).closest('form').attr('action').replace('&', '&'); + + if (act) + { + act = act[1] + data += '&action=' + act; + } + + $.post(path, data, return_handler); + } + else + { + $.get(this.href, return_handler); + } + return false; }); } @@ -216,20 +181,21 @@ phpbb.ajaxify_form = function(selector, refresh, callback) var refresh = function(url) { return (url.indexOf('t=') === -1); } -phpbb.confirm_box('.delete-icon a', refresh, function(el) { +phpbb.ajaxify('.delete-icon a', refresh, function(el) { var pid = el.href.split('&p=')[1]; $(el).parents('div #p' + pid).remove(); }); -phpbb.confirm_box('a[href$="ucp.php?mode=delete_cookies"]', true); +phpbb.ajaxify('a[href$="ucp.php?mode=delete_cookies"]', true); //AJAXify some links phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { + console.log(res); var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; $(el).text(el.title = text); }); -phpbb.ajaxify('a[href*="&watch=topic"]', false, function(el, res) { +phpbb.ajaxify('a[href*="watch=topic"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); text = (text) ? 'Unsubscribe topic' : 'Subscribe topic'; $(el).text(el.title = text); @@ -242,6 +208,6 @@ phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { phpbb.ajaxify('a[href*="mode=bump"]'); phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums -phpbb.ajaxify_form('.mcp_approve', false, function(el, act) { +phpbb.ajaxify('.mcp_approve', false, function(el, act) { $(el).parents((act === 'approve') ? '.rules' : '.post').remove(); }); From ac1b32c30772cd722c77694af83cb14b4581675f Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 17 Jul 2011 15:36:54 +0100 Subject: [PATCH 064/175] [ticket/10270] Changed function names of jQuery modifications. The code was modifying the jQuery code before, now the functions have been renamed to unused function names. PHPBB3-10270 --- phpBB/styles/script.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index e893b84bf8..959a41a643 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,22 +1,21 @@ /** * Make some changes to the jQuery core. */ -$.fn.hide = function() { +$.fn.hide_anim = function() { this.animate({opacity: 0}, 300, function() { $(this).css('display', 'none') .css('opacity', 1); }); } -$.fn.show = function() { +$.fn.show_anim = function() { this.css('opacity', 0) .css('display', 'block') .animate({opacity: 1}, 300); } -$.fn.remove_old = $.fn.remove; -$.fn.remove = function() { +$.fn.remove_anim = function() { this.animate({opacity: 0}, 300, function() { - $(this).remove_old(); + $(this).remove(); }); } @@ -39,12 +38,12 @@ phpbb.alert = function(title, msg) { { return true; } - div.remove(); + div.remove_anim(); return false; }); $('body').append(div); - div.show(); + div.show_anim(); return div; } @@ -64,11 +63,11 @@ phpbb.confirm = function(msg, callback) { $('body').append(div); $('.jalertbut').bind('click', function(event) { - div.remove(); + div.remove_anim(); callback(this.value === 'Yes'); return false; }); - div.show(); + div.show_anim(); return div; } @@ -105,7 +104,7 @@ phpbb.ajaxify = function(selector, refresh, callback) { } else { - div.remove(); + div.remove_anim(); } }, data.time * 1000); } @@ -183,14 +182,13 @@ var refresh = function(url) { } phpbb.ajaxify('.delete-icon a', refresh, function(el) { var pid = el.href.split('&p=')[1]; - $(el).parents('div #p' + pid).remove(); + $(el).parents('div #p' + pid).remove_anim(); }); phpbb.ajaxify('a[href$="ucp.php?mode=delete_cookies"]', true); //AJAXify some links phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { - console.log(res); var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; $(el).text(el.title = text); @@ -209,5 +207,5 @@ phpbb.ajaxify('a[href*="mode=bump"]'); phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums phpbb.ajaxify('.mcp_approve', false, function(el, act) { - $(el).parents((act === 'approve') ? '.rules' : '.post').remove(); + $(el).parents((act === 'approve') ? '.rules' : '.post').remove_anim(); }); From 2f2ec1096b6288c032e276c75c849bb1cc820674 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 17 Jul 2011 15:56:27 +0100 Subject: [PATCH 065/175] [ticket/10272] Made some jQuery selectors more specific to avoid conflicts. Before, a link to any URL with, say, "mode=bump" in the title would have been prevented from acting normally. PHPBB3-10272 --- phpBB/styles/script.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 959a41a643..32b12bdd34 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -184,27 +184,27 @@ phpbb.ajaxify('.delete-icon a', refresh, function(el) { var pid = el.href.split('&p=')[1]; $(el).parents('div #p' + pid).remove_anim(); }); -phpbb.ajaxify('a[href$="ucp.php?mode=delete_cookies"]', true); +phpbb.ajaxify('#page-footer a[href$="ucp.php?mode=delete_cookies"]', true); //AJAXify some links -phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { +phpbb.ajaxify('#page-footer a[href*="&bookmark=1"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; $(el).text(el.title = text); }); -phpbb.ajaxify('a[href*="watch=topic"]', false, function(el, res) { +phpbb.ajaxify('#page-footer a[href*="watch=topic"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); text = (text) ? 'Unsubscribe topic' : 'Subscribe topic'; $(el).text(el.title = text); }); -phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { +phpbb.ajaxify('#page-footer a[href*="watch=forum"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); text = (text) ? 'Unsubscribe forum' : 'Subscribe forum'; $(el).text(el.title = text); }); -phpbb.ajaxify('a[href*="mode=bump"]'); -phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums +phpbb.ajaxify('#page-footer a[href*="mode=bump"]'); +phpbb.ajaxify('.rightside a[href*="mark="]'); //captures topics and forums phpbb.ajaxify('.mcp_approve', false, function(el, act) { $(el).parents((act === 'approve') ? '.rules' : '.post').remove_anim(); From 8fd86717e1320cb3160515fe786869c80e6771f9 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 20 Jul 2011 18:28:14 +0100 Subject: [PATCH 066/175] [ticket/10271] Added ability for exceptions to phpbb.ajaxify. Also made it easy for additional options to be added in the future. PHPBB3-10271 --- .../prosilver/template/viewtopic_body.html | 2 +- phpBB/styles/script.js | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 856ee6962c..9e333cf5ec 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -263,7 +263,7 @@ -
+
  -   +  
diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index b73c392312..889db70f98 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -103,6 +103,11 @@ phpbb.ajaxify = function(options, refresh, callback) { $(selector).click(function() { var act, data, path, that = this; + if ($(this).data('ajax') == false) + { + return true; + } + function return_handler(res) { res = JSON.parse(res); @@ -157,7 +162,11 @@ phpbb.ajaxify = function(options, refresh, callback) { act = act[1] data += '&action=' + act; } - + else + { + data += '&' + this.name + '=' + this.value; + } + if (run_exception && options.exception($(this).parents('form'), act, data)) { return true; @@ -213,6 +222,10 @@ phpbb.add_ajax_callback('post_delete', function(el) { $(el).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { $(this).remove(); }); +}).add_ajax_callback('qr-submit', function(el) { + $(el).parents('form').fadeOut(function() { + $(this).remove(); + }); }); From 7ccc18297af17dbc66fc5a28710af6970a17fb6e Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Mon, 25 Jul 2011 20:42:29 +0100 Subject: [PATCH 071/175] [ticket/10270] Makes page fade to dark on popup, and added $.querystring. PHPBB3-10270 --- phpBB/styles/prosilver/theme/common.css | 16 ++- phpBB/styles/script.js | 139 ++++++++++++++++++++---- 2 files changed, 133 insertions(+), 22 deletions(-) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 6b34bb1c3d..a3d2c5660e 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -593,8 +593,8 @@ li.pagination { .jalert { background-color: #FFFFFF; border: 1px solid #999999; - display: none; position: fixed; + display: none; top: 100px; left: 35%; width: 30%; @@ -608,6 +608,20 @@ li.pagination { padding-bottom: 8px; } +#darkenwrapper { + display: none; +} + +#darken { + position: fixed; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: #000000; + opacity: 0.5; +} + /* Miscellaneous styles ---------------------------------------- */ #forum-permissions { diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 889db70f98..0b2d372db7 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,5 +1,47 @@ +$.querystring = function(string) { + var end = {}, i; + + string = string.split('&'); + for (i = 0; i < string.length; i++) + { + end[string[i].split('=')[0]] = decodeURIComponent(string[i].split('=')[1]); + } + return end; +} + + var phpbb = {}; +var dark = $('
 
'); +$('body').append(dark); + +var loading_alert = $('

Loading

Please wait.

'); +$(dark).append(loading_alert); + + +/** + * Display a loading screen. + */ +phpbb.loading_alert = function() { + if (dark.is(':visible')) + { + loading_alert.fadeIn(); + } + else + { + loading_alert.show(); + dark.fadeIn(); + } + + setTimeout(function() { + if (loading_alert.is(':visible')) + { + phpbb.alert('Error', 'Error processing your request. Please try again.'); + } + }, 3000); + return loading_alert; +} + /** * Display a simple alert similar to JSs native alert(). * @@ -8,22 +50,48 @@ var phpbb = {}; * * @return Returns the div created. */ -phpbb.alert = function(title, msg) { +phpbb.alert = function(title, msg, fadedark) { var div = $('

' + title + '

' + msg + '

'); - $(document).one('click', function(e) { - if ($(e.target).parents('.jalert').length) + $(div).bind('click', function(e) { + e.stopPropagation(); + return true; + }); + $(dark).one('click', function(e) { + if (typeof fadedark === 'undefined' || fadedark) { - return true; + dark.fadeOut(function() { + div.remove(); + }); + } + else + { + div.fadeOut(function() { + div.remove(); + }); } - div.fadeOut(function() { - div.remove(); - }); return false; }); - $('body').append(div); - div.fadeIn(); + if (loading_alert.is(':visible')) + { + loading_alert.fadeOut(function() { + $(dark).append(div); + div.fadeIn(); + }); + } + else if (dark.is(':visible')) + { + $(dark).append(div); + div.fadeIn(); + } + else + { + $(dark).append(div); + div.show(); + dark.fadeIn(); + } + return div; } @@ -35,21 +103,47 @@ phpbb.alert = function(title, msg) { * * @return Returns the div created. */ -phpbb.confirm = function(msg, callback) { +phpbb.confirm = function(msg, callback, fadedark) { var div = $('

' + msg + '

\  \
'); - - $('body').append(div); - - $('.jalertbut').bind('click', function(event) { - div.fadeOut(function() { - div.remove(); - }); + + div.find('.jalertbut').bind('click', function() { + if (typeof fadedark === 'undefined' || fadedark) + { + dark.fadeOut(function() { + div.remove(); + }); + } + else + { + div.fadeOut(function() { + div.remove(); + }); + } callback(this.value === 'Yes'); return false; }); - div.fadeIn(); + + if (loading_alert.is(':visible')) + { + loading_alert.fadeOut(function() { + $(dark).append(div); + div.fadeIn(); + }); + } + else if (dark.is(':visible')) + { + $(dark).append(div); + div.fadeIn(); + } + else + { + $(dark).append(div); + div.show(); + dark.fadeIn(); + } + return div; } @@ -82,7 +176,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } else { - div.fadeOut(function() { + dark.fadeOut(function() { div.remove(); }); } @@ -135,6 +229,7 @@ phpbb.ajaxify = function(options, refresh, callback) { { data = $('' + res.S_HIDDEN_FIELDS + '').serialize(); path = res.S_CONFIRM_ACTION; + phpbb.loading_alert(); $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); @@ -146,7 +241,7 @@ phpbb.ajaxify = function(options, refresh, callback) { handle_refresh(res.REFRESH_DATA, refresh, alert); }); } - }); + }, false); } } @@ -171,6 +266,7 @@ phpbb.ajaxify = function(options, refresh, callback) { { return true; } + phpbb.loading_alert(); $.post(path, data, return_handler); } else @@ -179,6 +275,7 @@ phpbb.ajaxify = function(options, refresh, callback) { { return true; } + phpbb.loading_alert(); $.get(this.href, return_handler); } @@ -240,7 +337,7 @@ $('[data-ajax]').each(function() { phpbb.ajaxify({ selector: '#quickmodform', exception: function(el, act, data) { - var d = data.split('=')[1]; + var d = $.querystring(data).action; if (d == 'make_normal') { return !(el.find('select option[value="make_global"]').length); From 149daa0e4fbe5bf59a613caf850ecda083cc772a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 26 Jul 2011 11:46:49 +0100 Subject: [PATCH 072/175] [feature/ajax] Added code to avoid conflicts with other libraries using $ PHPBB3-10270 --- phpBB/styles/script.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 0b2d372db7..66e99a6a63 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,3 +1,6 @@ +;(function($) { //avoid conflicts with other libraries + + $.querystring = function(string) { var end = {}, i; @@ -345,3 +348,6 @@ phpbb.ajaxify({ return !(d == 'lock' || d == 'unlock' || d == 'delete_topic' || d.slice(0, 5) == 'make_'); } }, true); + + +})(jQuery); //avoid conflicts with other libraries From e4ea4d1c579477389349a06190643391ea8740fc Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 26 Jul 2011 12:13:09 +0100 Subject: [PATCH 073/175] [ticket/10270] Fixed a bug where fadedark wouldn't go. If the confirm box was submitted as yes, then the fadedark would stay until it was clicked. This commit fixes that. PHPBB3-10270 --- phpBB/styles/script.js | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 66e99a6a63..8c7324e39a 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -50,6 +50,8 @@ phpbb.loading_alert = function() { * * @param string title Title of the message, eg "Information" * @param string msg Message to display. Can be HTML. + * @param bool fadedark Remove the dark background when done? Defaults + * to yes. * * @return Returns the div created. */ @@ -61,18 +63,10 @@ phpbb.alert = function(title, msg, fadedark) { return true; }); $(dark).one('click', function(e) { - if (typeof fadedark === 'undefined' || fadedark) - { - dark.fadeOut(function() { - div.remove(); - }); - } - else - { - div.fadeOut(function() { - div.remove(); - }); - } + var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; + fade.fadeOut(function() { + div.remove(); + }); return false; }); @@ -102,7 +96,10 @@ phpbb.alert = function(title, msg, fadedark) { * Display a simple yes / no box to the user. * * @param string msg Message to display. Can be HTML. - * @param function callback Callback. + * @param function callback Callback. Bool param, whether the user pressed + * yes or no (or whatever their language is). + * @param bool fadedark Remove the dark background when done? Defaults + * to yes. * * @return Returns the div created. */ @@ -112,19 +109,12 @@ phpbb.confirm = function(msg, callback, fadedark) { '); div.find('.jalertbut').bind('click', function() { - if (typeof fadedark === 'undefined' || fadedark) - { - dark.fadeOut(function() { - div.remove(); - }); - } - else - { - div.fadeOut(function() { - div.remove(); - }); - } - callback(this.value === 'Yes'); + var res = this.value === 'Yes'; + var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; + fade.fadeOut(function() { + div.remove(); + }); + callback(res); return false; }); From 22c6953c116e24cbe278f0fe63aabaf950c843e3 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 26 Jul 2011 16:25:04 +0100 Subject: [PATCH 074/175] [feature/ajax] Fixed a small bug in the JavaScript. The bug meant that code outside of the function that ran on document ready would not be able to access the phpbb object. PHPBB3-10270 --- phpBB/styles/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 8c7324e39a..72e3c59e75 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,4 +1,6 @@ -;(function($) { //avoid conflicts with other libraries +var phpbb = {}; + +(function($) { //avoid conflicts with other libraries $.querystring = function(string) { @@ -13,8 +15,6 @@ $.querystring = function(string) { } -var phpbb = {}; - var dark = $('
 
'); $('body').append(dark); From bb7a03f738c97dc225873691c459f2bf9e612ef6 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 27 Jul 2011 12:57:58 +0100 Subject: [PATCH 075/175] [ticket/10281] AJAXified reordering forums in the ACP. PHPBB3-10281 --- phpBB/adm/style/acp_forums.html | 18 ++++++++--------- phpBB/adm/style/overall_footer.html | 4 ++++ phpBB/includes/acp/acp_forums.php | 6 ++++++ phpBB/styles/script.js | 30 +++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/phpBB/adm/style/acp_forums.html b/phpBB/adm/style/acp_forums.html index 447c0ce466..b2b3ad6d40 100644 --- a/phpBB/adm/style/acp_forums.html +++ b/phpBB/adm/style/acp_forums.html @@ -443,7 +443,7 @@
{forums.FOLDER_IMAGE}
{forums.FORUM_IMAGE}
@@ -453,17 +453,17 @@
- {ICON_MOVE_UP_DISABLED} - {ICON_MOVE_DOWN} + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN} - {ICON_MOVE_UP} - {ICON_MOVE_DOWN} + {ICON_MOVE_UP} + {ICON_MOVE_DOWN} - {ICON_MOVE_UP} - {ICON_MOVE_DOWN_DISABLED} + {ICON_MOVE_UP} + {ICON_MOVE_DOWN_DISABLED} - {ICON_MOVE_UP_DISABLED} - {ICON_MOVE_DOWN_DISABLED} + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN_DISABLED} {ICON_EDIT} diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index f05e9c56c5..3740122d9b 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -17,6 +17,10 @@
{DEBUG_OUTPUT} + + + + diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index fad22fc285..d3e2dbd904 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -255,6 +255,12 @@ class acp_forums add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); $cache->destroy('sql', FORUMS_TABLE); } + + if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + { + echo json_encode(array('success' => ($move_forum_name !== false))); + exit; + } break; diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 72e3c59e75..35c99464bd 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -316,6 +316,36 @@ phpbb.add_ajax_callback('post_delete', function(el) { $(el).parents('form').fadeOut(function() { $(this).remove(); }); +}).add_ajax_callback('forum_down', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':first-child')) + { + $(el).parents('span').siblings('.up').html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.up').children('a')}, false, 'forum_up'); + } + tr.insertAfter(tr.next()); + if (tr.is(':last-child')) + { + $(el).html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); + } +}).add_ajax_callback('forum_up', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':last-child')) + { + $(el).parents('span').siblings('.down').html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.down').children('a')}, false, 'forum_down'); + } + tr.insertBefore(tr.prev()); + if (tr.is(':first-child')) + { + $(el).html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); + } }); From 59031fdc735a80502ea2cda3683a9276da5649cd Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 18 Aug 2011 18:34:09 +0100 Subject: [PATCH 076/175] [ticket/10272] AJAXified the add / remove friend / foe links. PHPBB3-10272 --- phpBB/styles/prosilver/template/memberlist_view.html | 8 ++++---- phpBB/styles/script.js | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index f10ec64975..d8bb92a731 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -35,15 +35,15 @@
{custom_fields.PROFILE_FIELD_NAME}:
{custom_fields.PROFILE_FIELD_VALUE}
-
 
{L_REMOVE_FRIEND}
+
 
{L_REMOVE_FRIEND}
-
 
{L_REMOVE_FOE}
+
 
{L_REMOVE_FOE}
-
 
{L_ADD_FRIEND}
+
 
{L_ADD_FRIEND}
-
 
{L_ADD_FOE}
+
 
{L_ADD_FOE}
diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 35c99464bd..d17a2cdc10 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -346,7 +346,12 @@ phpbb.add_ajax_callback('post_delete', function(el) { tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } -}); +}).add_ajax_callback('zebra', function(el, res) { + if (res.MESSAGE_TEXT.indexOf('successfully') !== -1) { + $('.zebra').html(res.MESSAGE_TEXT.split(' Date: Thu, 18 Aug 2011 19:02:18 +0100 Subject: [PATCH 077/175] [ticket/10270] Added keyboard shortcuts to confirm and alert boxes. PHPBB3-10270 --- phpBB/styles/script.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index d17a2cdc10..54248cc31c 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -69,6 +69,14 @@ phpbb.alert = function(title, msg, fadedark) { }); return false; }); + + $(document).bind('keydown', function(e) { + if (e.keyCode === 13 || e.keyCode === 27) { + $(dark).trigger('click'); + return false; + } + return true; + }); if (loading_alert.is(':visible')) { @@ -118,6 +126,17 @@ phpbb.confirm = function(msg, callback, fadedark) { return false; }); + $(document).bind('keydown', function(e) { + if (e.keyCode === 13) { + $('.jalertbut.button1').trigger('click'); + return false; + } else if (e.keyCode === 27) { + $('.jalertbut.button2').trigger('click'); + return false; + } + return true; + }); + if (loading_alert.is(':visible')) { loading_alert.fadeOut(function() { From 94172b54dd09b28e19b4b12933b3f96e498d264a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 19 Aug 2011 09:38:57 +0100 Subject: [PATCH 078/175] [ticket/10271] Changed AJAX functions to $request->is_ajax(). PHPBB3-10271 --- phpBB/includes/acp/acp_forums.php | 4 ++-- phpBB/includes/functions.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index d3e2dbd904..cb410e361a 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -25,7 +25,7 @@ class acp_forums function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx; $user->add_lang('acp/forums'); @@ -256,7 +256,7 @@ class acp_forums $cache->destroy('sql', FORUMS_TABLE); } - if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + if ($request->is_ajax()) { echo json_encode(array('success' => ($move_forum_name !== false))); exit; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 572986bb4b..b126fcc709 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2448,9 +2448,9 @@ function build_url($strip_vars = false) */ function meta_refresh($time, $url, $disable_cd_check = false) { - global $template, $refresh_data; + global $template, $refresh_data, $request; - if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + if ($request->is_ajax()) { $refresh_data = array( 'time' => $time, @@ -2629,7 +2629,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg */ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '') { - global $user, $template, $db; + global $user, $template, $db, $request; global $phpEx, $phpbb_root_path, $request; if (isset($_POST['cancel'])) @@ -2710,7 +2710,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo $db->sql_query($sql); - if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + if ($request->is_ajax()) { $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; echo json_encode(array( @@ -3748,7 +3748,7 @@ function phpbb_checkdnsrr($host, $type = 'MX') */ function msg_handler($errno, $msg_text, $errfile, $errline) { - global $cache, $db, $auth, $template, $config, $user; + global $cache, $db, $auth, $template, $config, $user, $request; global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text; // Do not display notices if we suppress them via @ @@ -3947,7 +3947,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false) ); - if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + if ($request->is_ajax()) { global $refresh_data; From dce38f44de04bd7a1f91f8e57f6d266bd5e1af86 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 19 Aug 2011 10:45:03 +0100 Subject: [PATCH 079/175] [ticket/10328] Added a JSON class. The JSON class adds a consistent way to send JSON to the client, making it perfect for AJAX (jQuery automatically parses it). PHPBB3-10328 --- phpBB/common.php | 1 + phpBB/includes/acp/acp_forums.php | 3 +- phpBB/includes/functions.php | 6 ++-- phpBB/includes/json.php | 59 +++++++++++++++++++++++++++++++ phpBB/styles/script.js | 3 -- 5 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 phpBB/includes/json.php diff --git a/phpBB/common.php b/phpBB/common.php index 129f7e4881..2c90ccf76c 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -74,6 +74,7 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +require($phpbb_root_path . 'includes/json.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index cb410e361a..6c05b1e108 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -258,8 +258,7 @@ class acp_forums if ($request->is_ajax()) { - echo json_encode(array('success' => ($move_forum_name !== false))); - exit; + JSON::send(array('success' => ($move_forum_name !== false))); } break; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b126fcc709..b9ca30279f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2713,7 +2713,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo if ($request->is_ajax()) { $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; - echo json_encode(array( + JSON::send(array( 'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title], 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'], @@ -2721,7 +2721,6 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo 'S_CONFIRM_ACTION' => str_replace('&', '&', $u_action), //inefficient, rewrite whole function 'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields )); - exit; } if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) @@ -3951,14 +3950,13 @@ function msg_handler($errno, $msg_text, $errfile, $errline) { global $refresh_data; - echo json_encode(array( + JSON::send(array( 'MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text, 'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false, 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false, 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null )); - exit; } // We do not want the cron script to be called on error messages diff --git a/phpBB/includes/json.php b/phpBB/includes/json.php new file mode 100644 index 0000000000..04472080d9 --- /dev/null +++ b/phpBB/includes/json.php @@ -0,0 +1,59 @@ + Date: Fri, 19 Aug 2011 17:39:35 +0100 Subject: [PATCH 080/175] [ticket/10270] Lengthened the timeout on the AJAX request error. It was at 3 seconds before, now it is at 5 seconds from when the popup has faded in. PHPBB3-10270 --- phpBB/styles/script.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 3ed12bfee8..04e768e21e 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -33,15 +33,16 @@ phpbb.loading_alert = function() { else { loading_alert.show(); - dark.fadeIn(); + dark.fadeIn(function() { + setTimeout(function() { + if (loading_alert.is(':visible')) + { + phpbb.alert('Error', 'Error processing your request. Please try again.'); + } + }, 5000); + }); } - - setTimeout(function() { - if (loading_alert.is(':visible')) - { - phpbb.alert('Error', 'Error processing your request. Please try again.'); - } - }, 3000); + return loading_alert; } From 082c5c5b328e10e3fa99beaff31c4bc28f73bbd0 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 19 Aug 2011 18:11:58 +0100 Subject: [PATCH 081/175] [ticket/10272] Zebra operations using AJAX are now less hacky. Before, they were splitting stuff by the
, and now JSON::add() is being used. PHPBB3-10272 --- phpBB/includes/ucp/ucp_zebra.php | 4 ++++ phpBB/styles/script.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index 004f3b80aa..3f0e97b48a 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -201,6 +201,10 @@ class ucp_zebra if ($updated) { + JSON::add(array( + 'message' => $user->lang[$l_mode . '_UPDATED'], + 'success' => true + )); meta_refresh(3, $this->u_action); $message = $user->lang[$l_mode . '_UPDATED'] . '
' . implode('
', $error) . ((sizeof($error)) ? '
' : '') . '
' . sprintf($user->lang['RETURN_UCP'], '', ''); trigger_error($message); diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 04e768e21e..f1fe2b9a10 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -364,8 +364,8 @@ phpbb.add_ajax_callback('post_delete', function(el) { phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } }).add_ajax_callback('zebra', function(el, res) { - if (res.MESSAGE_TEXT.indexOf('successfully') !== -1) { - $('.zebra').html(res.MESSAGE_TEXT.split(' Date: Wed, 24 Aug 2011 11:31:17 +0100 Subject: [PATCH 082/175] [ticket/10271] Moved $.querystring to phpbb.parse_querystring. PHPBB3-10271 --- phpBB/styles/script.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index f1fe2b9a10..ceaf92672c 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -3,18 +3,6 @@ var phpbb = {}; (function($) { //avoid conflicts with other libraries -$.querystring = function(string) { - var end = {}, i; - - string = string.split('&'); - for (i = 0; i < string.length; i++) - { - end[string[i].split('=')[0]] = decodeURIComponent(string[i].split('=')[1]); - } - return end; -} - - var dark = $('
 
'); $('body').append(dark); @@ -160,6 +148,23 @@ phpbb.confirm = function(msg, callback, fadedark) { return div; } +/** + * Turn a querystring into an array. + * + * @argument string string The querystring to parse. + * @returns array The array created. + */ +phpbb.parse_querystring = function(string) { + var end = {}, i; + + string = string.split('&'); + for (i = 0; i < string.length; i++) + { + end[string[i].split('=')[0]] = decodeURIComponent(string[i].split('=')[1]); + } + return end; +} + /** * Makes a link use AJAX instead of loading an entire page. @@ -382,7 +387,7 @@ $('[data-ajax]').each(function() { phpbb.ajaxify({ selector: '#quickmodform', exception: function(el, act, data) { - var d = $.querystring(data).action; + var d = phpbb.parse_querystring(data).action; if (d == 'make_normal') { return !(el.find('select option[value="make_global"]').length); From 6efb9dd0b6e0119009d5b10d198722ba2b19f0e2 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 11:34:41 +0100 Subject: [PATCH 083/175] [ticket/10270] Added jQuery popup CSS to the ACP. It was missing previously, meaning that it displayed wrong and in the footer. PHPBB3-10270 --- phpBB/adm/style/admin.css | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index ceda824e5a..70c06f2d62 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -1070,6 +1070,40 @@ input.disabled { color: #666666; } +/* jQuery popups +---------------------------------------- */ +.jalert { + background-color: #FFFFFF; + border: 1px solid #999999; + position: fixed; + display: none; + top: 100px; + left: 35%; + width: 30%; + z-index: 50; + padding: 25px; + padding: 0 25px 20px 25px; +} + +.jalert p { + margin: 8px 0; + padding-bottom: 8px; +} + +#darkenwrapper { + display: none; +} + +#darken { + position: fixed; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: #000000; + opacity: 0.5; +} + /* Pagination ---------------------------------------- */ .pagination { From 420de9c9a0a638135da147a498436dbe7abfd4bd Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 11:42:39 +0100 Subject: [PATCH 084/175] [ticket/10270] Moved some HTML from the JavaScript to overall_footer. PHPBB3-10270 --- phpBB/adm/style/overall_footer.html | 5 +++++ phpBB/language/en/common.php | 2 ++ phpBB/styles/prosilver/template/overall_footer.html | 5 +++++ phpBB/styles/script.js | 7 ++----- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 3740122d9b..625121f1bd 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -18,6 +18,11 @@ {DEBUG_OUTPUT} +
+
 
+

{L_LOADING}

{L_PLEASE_WAIT}

+
+ diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 19b801e585..e8fff96e5a 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -314,6 +314,7 @@ $lang = array_merge($lang, array( 'LDAP_NO_SERVER_CONNECTION' => 'Could not connect to LDAP server.', 'LDAP_SEARCH_FAILED' => 'An error occured while searching the LDAP directory.', 'LEGEND' => 'Legend', + 'LOADING' => 'Loading', 'LOCATION' => 'Location', 'LOCK_POST' => 'Lock post', 'LOCK_POST_EXPLAIN' => 'Prevent editing', @@ -451,6 +452,7 @@ $lang = array_merge($lang, array( 2 => '%d pixels', ), 'PLAY_QUICKTIME_FILE' => 'Play Quicktime file', + 'PLEASE_WAIT' => 'Please wait.', 'PM' => 'PM', 'PM_REPORTED' => 'Click to view report', 'POSTING_MESSAGE' => 'Posting message in %s', diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index ffdb27be98..37caaf7cca 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -24,6 +24,11 @@
{DEBUG_OUTPUT}
{L_ACP} + +
+
 
+

{L_LOADING}

{L_PLEASE_WAIT}

+
diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index ceaf92672c..bf8c548df0 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -3,11 +3,8 @@ var phpbb = {}; (function($) { //avoid conflicts with other libraries -var dark = $('
 
'); -$('body').append(dark); - -var loading_alert = $('

Loading

Please wait.

'); -$(dark).append(loading_alert); +var dark = $('#darkenwrapper'), + loading_alert = $('#loadingalert'); /** From c92b30d66cbb2839369c04172eb5ae9bacd27a16 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 11:44:28 +0100 Subject: [PATCH 085/175] [feature/ajax] Changed JavaScript comments to follow coding guidelines. Also replaced a couple instances of "@return" with "@returns". PHPBB3-10270 --- phpBB/styles/script.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index bf8c548df0..1b9262f585 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,6 +1,6 @@ var phpbb = {}; -(function($) { //avoid conflicts with other libraries +(function($) { // Avoid conflicts with other libraries var dark = $('#darkenwrapper'), @@ -9,6 +9,8 @@ var dark = $('#darkenwrapper'), /** * Display a loading screen. + * + * @returns object Returns loading_alert. */ phpbb.loading_alert = function() { if (dark.is(':visible')) @@ -39,7 +41,7 @@ phpbb.loading_alert = function() { * @param bool fadedark Remove the dark background when done? Defaults * to yes. * - * @return Returns the div created. + * @returns object Returns the div created. */ phpbb.alert = function(title, msg, fadedark) { var div = $('

' + title + '

' + msg + '

'); @@ -95,7 +97,7 @@ phpbb.alert = function(title, msg, fadedark) { * @param bool fadedark Remove the dark background when done? Defaults * to yes. * - * @return Returns the div created. + * @returns object Returns the div created. */ phpbb.confirm = function(msg, callback, fadedark) { var div = $('

' + msg + '

\ @@ -173,7 +175,7 @@ phpbb.parse_querystring = function(string) { */ phpbb.ajaxify = function(options, refresh, callback) { - //private function to handle refreshes + // Private function to handle refreshes function handle_refresh(data, refresh, div) { if (!data) @@ -221,9 +223,7 @@ phpbb.ajaxify = function(options, refresh, callback) { { if (typeof res.S_CONFIRM_ACTION === 'undefined') { - /** - * It is a standard link, no confirm_box required. - */ + // It is a standard link, no confirm_box required. var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); callback = phpbb.ajax_callbacks[callback]; if (typeof callback === 'function') @@ -234,9 +234,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } else { - /** - * confirm_box - confirm with the user and send back - */ + // confirm_box - confirm with the user and send back phpbb.confirm(res.MESSAGE_TEXT, function(del) { if (del) { @@ -394,4 +392,4 @@ phpbb.ajaxify({ }, true); -})(jQuery); //avoid conflicts with other libraries +})(jQuery); // Avoid conflicts with other libraries From 7a933bdb5ad4a9bc4877a7d4d516fa0b21d9e4c0 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 12:25:54 +0100 Subject: [PATCH 086/175] [ticket/10328] Renamed the JSON class, also now using autoloading. It is no longer static, and uses autoloading. It has also been renamed from JSON to phpbb_json_response. PHPBB3-10328 --- phpBB/common.php | 1 - phpBB/includes/acp/acp_forums.php | 3 ++- phpBB/includes/functions.php | 6 +++-- .../includes/{json.php => json_response.php} | 23 +++--------------- phpBB/includes/ucp/ucp_zebra.php | 24 ++++++++++++++----- phpBB/styles/script.js | 2 +- 6 files changed, 28 insertions(+), 31 deletions(-) rename phpBB/includes/{json.php => json_response.php} (58%) diff --git a/phpBB/common.php b/phpBB/common.php index 2c90ccf76c..129f7e4881 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -74,7 +74,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/json.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 6c05b1e108..3a3b2021eb 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -258,7 +258,8 @@ class acp_forums if ($request->is_ajax()) { - JSON::send(array('success' => ($move_forum_name !== false))); + $json_response = new phpbb_json_response; + $json_response->send(array('success' => ($move_forum_name !== false))); } break; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b9ca30279f..afd901a296 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2713,7 +2713,8 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo if ($request->is_ajax()) { $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; - JSON::send(array( + $json_response = new phpbb_json_response; + $json_response->send(array( 'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title], 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'], @@ -3950,7 +3951,8 @@ function msg_handler($errno, $msg_text, $errfile, $errline) { global $refresh_data; - JSON::send(array( + $json_response = new phpbb_json_response; + $json_response->send(array( 'MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text, 'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false, diff --git a/phpBB/includes/json.php b/phpBB/includes/json_response.php similarity index 58% rename from phpBB/includes/json.php rename to phpBB/includes/json_response.php index 04472080d9..95d02e3c0e 100644 --- a/phpBB/includes/json.php +++ b/phpBB/includes/json_response.php @@ -20,25 +20,18 @@ if (!defined('IN_PHPBB')) * JSON class * @package phpBB3 */ -class JSON +class phpbb_json_response { - private static $data = array(); - /** * Send the data to the client and exit the script. * * @param array $data Any additional data to send. * @param bool $exit Will exit the script if true. */ - public static function send($data = false, $exit = true) + public function send($data, $exit = true) { - if ($data) - { - self::add($data); - } - header('Content-type: application/json'); - echo json_encode(self::$data); + echo json_encode($data); if ($exit) { @@ -46,14 +39,4 @@ class JSON exit_handler(); } } - - /** - * Saves some data to be written when JSON::send() is called. - * - * @param array $data Data to save to be sent. - */ - public static function add($data) - { - self::$data = array_merge(self::$data, $data); - } } diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index 3f0e97b48a..efe928b387 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -25,7 +25,7 @@ class ucp_zebra function main($id, $mode) { - global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; + global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $request; $submit = (isset($_POST['submit']) || isset($_GET['add']) || isset($_GET['remove'])) ? true : false; $s_hidden_fields = ''; @@ -198,13 +198,25 @@ class ucp_zebra } } } - - if ($updated) + + if ($request->is_ajax()) { - JSON::add(array( - 'message' => $user->lang[$l_mode . '_UPDATED'], - 'success' => true + $message = ($updated) ? $user->lang[$l_mode . '_UPDATED'] : implode('
', $error); + + $json_response = new phpbb_json_response; + $json_response->send(array( + 'success' => $updated, + + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => array( + 'time' => 3, + 'url' => $this->u_action + ) )); + } + else if ($updated) + { meta_refresh(3, $this->u_action); $message = $user->lang[$l_mode . '_UPDATED'] . '
' . implode('
', $error) . ((sizeof($error)) ? '
' : '') . '
' . sprintf($user->lang['RETURN_UCP'], '', ''); trigger_error($message); diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 1b9262f585..8814d105e1 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -365,7 +365,7 @@ phpbb.add_ajax_callback('post_delete', function(el) { } }).add_ajax_callback('zebra', function(el, res) { if (res.success) { - $('.zebra').html(res.message); + $('.zebra').html(res.MESSAGE_TEXT); $($('.zebra').get(1)).remove(); } });; From 11112314f757f4a6c65852817fba0f1a2f4526d2 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 12:46:33 +0100 Subject: [PATCH 087/175] [ticket/10271] AJAXified various deletions in the ACP. The following places have had deletion AJAXified: * Smilies and icons * Word censors * BBCodes * Attachment groups * Groups * Admin / User / Moderator / Forum roles * Report / denial reasons * Module management * Custom profile fields PHPBB3-10271 --- phpBB/adm/style/acp_attachments.html | 2 +- phpBB/adm/style/acp_bbcodes.html | 2 +- phpBB/adm/style/acp_groups.html | 2 +- phpBB/adm/style/acp_icons.html | 2 +- phpBB/adm/style/acp_modules.html | 2 +- phpBB/adm/style/acp_permission_roles.html | 2 +- phpBB/adm/style/acp_profile.html | 4 ++-- phpBB/adm/style/acp_ranks.html | 2 +- phpBB/adm/style/acp_reasons.html | 2 +- phpBB/adm/style/acp_words.html | 2 +- phpBB/includes/acp/acp_bbcodes.php | 14 +++++++++++++- phpBB/includes/acp/acp_icons.php | 12 ++++++++++++ phpBB/includes/acp/acp_ranks.php | 14 +++++++++++++- phpBB/language/en/acp/posting.php | 1 + phpBB/styles/script.js | 3 +++ 15 files changed, 53 insertions(+), 13 deletions(-) diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index 33ef8062a6..c2f8b34792 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -248,7 +248,7 @@
» {L_ALLOWED_IN_PM_POST}
{groups.CATEGORY} {ICON_EDIT}  {ICON_DELETE}  {ICON_EDIT}  {ICON_DELETE} 
{bbcodes.BBCODE_TAG}{ICON_EDIT} {ICON_DELETE}{ICON_EDIT} {ICON_DELETE}
{groups.TOTAL_MEMBERS} {L_SETTINGS} {L_MEMBERS}{L_DELETE}{L_DELETE}{L_DELETE}{L_DELETE}
{ICON_MOVE_UP_DISABLED}{ICON_MOVE_UP}  {ICON_MOVE_DOWN_DISABLED}{ICON_MOVE_DOWN} -  {ICON_EDIT} {ICON_DELETE} +  {ICON_EDIT} {ICON_DELETE}
{fields.FIELD_IDENT} {fields.FIELD_TYPE}{fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE}{fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE} @@ -213,7 +213,7 @@ {ICON_EDIT_DISABLED} - {ICON_DELETE} + {ICON_DELETE}
{ranks.RANK_TITLE}  -   {ranks.RANK_TITLE}   -  {ranks.MIN_POSTS}{ICON_EDIT} {ICON_DELETE}{ICON_EDIT} {ICON_DELETE}
{words.WORD} {words.REPLACEMENT} {ICON_EDIT}  {ICON_DELETE}  {ICON_EDIT}  {ICON_DELETE} 
- {installed.L_STYLE_ACT_DEACT} | + {installed.L_STYLE_ACT_DEACT} | {installed.S_ACTIONS} diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 7b449d3b35..a241dd3d10 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -28,7 +28,7 @@ class acp_styles function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; // Hardcoded template bitfield to add for new templates @@ -185,6 +185,18 @@ inherit_from = {INHERIT_FROM} WHERE forum_style = ' . $style_id; $db->sql_query($sql); } + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'text' => $user->lang['STYLE_' . (($action == 'activate') ? 'DE' : '') . 'ACTIVATE'], + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['STYLE_' . strtoupper($action) . 'D'], + 'REFRESH_DATA' => array( + 'time' => 3 + ) + )); + } } else if ($action == 'deactivate') { @@ -335,7 +347,8 @@ inherit_from = {INHERIT_FROM} $s_actions = array(); foreach ($actions as $option) { - $s_actions[] = '' . $user->lang[strtoupper($option)] . ''; + $data_ajax = ($option == 'refresh') ? ' data-ajax="true"' : ''; + $s_actions[] = '' . $user->lang[strtoupper($option)] . ''; } $template->assign_block_vars('installed', array( diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index 59df82477e..3a96100947 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -295,9 +295,11 @@ $lang = array_merge($lang, array( 'SELECTED_THEME_FILE' => 'Selected theme file', 'STORE_FILESYSTEM' => 'Filesystem', 'STYLE_ACTIVATE' => 'Activate', + 'STYLE_ACTIVATED' => 'Style activated successfully', 'STYLE_ACTIVE' => 'Active', 'STYLE_ADDED' => 'Style added successfully.', 'STYLE_DEACTIVATE' => 'Deactivate', + 'STYLE_DEACTIVATED' => 'Style deactivated successfully', 'STYLE_DEFAULT' => 'Make default style', 'STYLE_DELETED' => 'Style deleted successfully.', 'STYLE_DETAILS_UPDATED' => 'Style edited successfully.', diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 85dcdb25f5..44b21906cc 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -225,10 +225,9 @@ phpbb.ajaxify = function(options, refresh, callback) { { // It is a standard link, no confirm_box required. var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - callback = phpbb.ajax_callbacks[callback]; - if (typeof callback === 'function') + if (typeof phpbb.ajax_callbacks[callback] === 'function') { - callback(that, (is_form) ? act : null); + phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); } handle_refresh(res.REFRESH_DATA, refresh, alert); } @@ -243,10 +242,9 @@ phpbb.ajaxify = function(options, refresh, callback) { phpbb.loading_alert(); $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - callback = phpbb.ajax_callbacks[callback]; - if (typeof callback === 'function') + if (typeof phpbb.ajax_callbacks[callback] === 'function') { - callback(that, res, (is_form) ? act : null); + phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); } handle_refresh(res.REFRESH_DATA, refresh, alert); }); @@ -363,6 +361,18 @@ phpbb.add_ajax_callback('post_delete', function(el) { tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } +}).add_ajax_callback('style_act_deact', function(el, res) { + $(el).text(res.text); + var new_href = $(el).attr('href'); + if (new_href.indexOf('deactivate') !== -1) + { + new_href = new_href.replace('deactivate', 'activate') + } + else + { + new_href = new_href.replace('activate', 'deactivate') + } + $(el).attr('href', new_href); }).add_ajax_callback('row_delete', function(el) { var tr = $(el).parents('tr'); tr.remove(); From 4ae74cd4b450ae4cca956f6f3e2371429f67deec Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 16:06:06 +0100 Subject: [PATCH 089/175] [ticket/10271] AJAXified buttons on acp_main. PHPBB3-10271 --- phpBB/adm/style/acp_main.html | 14 ++++++------ phpBB/includes/acp/acp_main.php | 38 ++++++++++++++++++++++++++++++-- phpBB/language/en/acp/common.php | 7 ++++++ 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/phpBB/adm/style/acp_main.html b/phpBB/adm/style/acp_main.html index 63ca3a1c79..d9f833d878 100644 --- a/phpBB/adm/style/acp_main.html +++ b/phpBB/adm/style/acp_main.html @@ -152,35 +152,35 @@
{L_STATISTIC_RESYNC_OPTIONS} -
+

 
-
+

 
-
+

{L_RESYNC_STATS_EXPLAIN}
-
+

{L_RESYNC_POSTCOUNTS_EXPLAIN}
-
+

{L_RESYNC_POST_MARKING_EXPLAIN}
@@ -188,7 +188,7 @@ -
+

{L_PURGE_SESSIONS_EXPLAIN}
@@ -196,7 +196,7 @@ -
+

{L_PURGE_CACHE_EXPLAIN}
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 4c9ee85982..144b225766 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -24,7 +24,7 @@ class acp_main function main($id, $mode) { - global $config, $db, $user, $auth, $template; + global $config, $db, $user, $auth, $template, $request; global $phpbb_root_path, $phpbb_admin_path, $phpEx; // Show restore permissions notice @@ -129,6 +129,11 @@ class acp_main set_config('record_online_users', 1, true); set_config('record_online_date', time(), true); add_log('admin', 'LOG_RESET_ONLINE'); + + if ($request->is_ajax()) + { + trigger_error('RESET_ONLINE_SUCCESS'); + } break; case 'stats': @@ -179,6 +184,11 @@ class acp_main update_last_username(); add_log('admin', 'LOG_RESYNC_STATS'); + + if ($request->is_ajax()) + { + trigger_error('RESYNC_STATS_SUCCESS'); + } break; case 'user': @@ -241,7 +251,11 @@ class acp_main } add_log('admin', 'LOG_RESYNC_POSTCOUNTS'); - + + if ($request->is_ajax()) + { + trigger_error('RESYNC_POSTCOUNTS_SUCCESS'); + } break; case 'date': @@ -252,6 +266,11 @@ class acp_main set_config('board_startdate', time() - 1); add_log('admin', 'LOG_RESET_DATE'); + + if ($request->is_ajax()) + { + trigger_error('RESET_DATE_SUCCESS'); + } break; case 'db_track': @@ -327,6 +346,11 @@ class acp_main } add_log('admin', 'LOG_RESYNC_POST_MARKING'); + + if ($request->is_ajax()) + { + trigger_error('RESYNC_POST_MARKING_SUCCESS'); + } break; case 'purge_cache': @@ -338,6 +362,11 @@ class acp_main cache_moderators(); add_log('admin', 'LOG_PURGE_CACHE'); + + if ($request->is_ajax()) + { + trigger_error('PURGE_CACHE_SUCCESS'); + } break; case 'purge_sessions': @@ -384,6 +413,11 @@ class acp_main $db->sql_query($sql); add_log('admin', 'LOG_PURGE_SESSIONS'); + + if ($request->is_ajax()) + { + trigger_error('PURGE_SESSIONS_SUCCESS'); + } break; } } diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 242329a041..f96947b580 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -368,25 +368,32 @@ $lang = array_merge($lang, array( 'PURGE_CACHE' => 'Purge the cache', 'PURGE_CACHE_CONFIRM' => 'Are you sure you wish to purge the cache?', 'PURGE_CACHE_EXPLAIN' => 'Purge all cache related items, this includes any cached template files or queries.', + 'PURGE_CACHE_SUCCESS' => 'Cache successfully purged.', 'PURGE_SESSIONS' => 'Purge all sessions', 'PURGE_SESSIONS_CONFIRM' => 'Are you sure you wish to purge all sessions? This will log out all users.', 'PURGE_SESSIONS_EXPLAIN' => 'Purge all sessions. This will log out all users by truncating the session table.', + 'PURGE_SESSIONS_SUCCESS' => 'Sessions successfully purged.', 'RESET_DATE' => 'Reset board’s start date', 'RESET_DATE_CONFIRM' => 'Are you sure you wish to reset the board’s start date?', + 'RESET_DATE_SUCCESS' => 'Board’s start date reset', 'RESET_ONLINE' => 'Reset most users ever online', 'RESET_ONLINE_CONFIRM' => 'Are you sure you wish to reset the most users ever online counter?', + 'RESET_ONLINE_SUCCESS' => 'Most users ever online reset', 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise files statistics?', 'RESYNC_POSTCOUNTS' => 'Resynchronise post counts', 'RESYNC_POSTCOUNTS_EXPLAIN' => 'Only existing posts will be taken into consideration. Pruned posts will not be counted.', 'RESYNC_POSTCOUNTS_CONFIRM' => 'Are you sure you wish to resynchronise post counts?', + 'RESYNC_POSTCOUNTS_SUCCESS' => 'Resynchronised post counts', 'RESYNC_POST_MARKING' => 'Resynchronise dotted topics', 'RESYNC_POST_MARKING_CONFIRM' => 'Are you sure you wish to resynchronise dotted topics?', 'RESYNC_POST_MARKING_EXPLAIN' => 'First unmarks all topics and then correctly marks topics that have seen any activity during the past six months.', + 'RESYNC_POST_MARKING_SUCCESS' => 'Resynchronised dotted topics', 'RESYNC_STATS' => 'Resynchronise statistics', 'RESYNC_STATS_CONFIRM' => 'Are you sure you wish to resynchronise statistics?', 'RESYNC_STATS_EXPLAIN' => 'Recalculates the total number of posts, topics, users and files.', + 'RESYNC_STATS_SUCCESS' => 'Resynchronised statistics', 'RUN' => 'Run now', 'STATISTIC' => 'Statistic', From fc7cb6a70b9e0422bf5658bb9f49de831be08718 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 16:25:54 +0100 Subject: [PATCH 090/175] [ticket/10270] Made the alert after an AJAX operation optional. PHPBB3-10270 --- phpBB/styles/script.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 44b21906cc..16d64319d9 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -224,7 +224,11 @@ phpbb.ajaxify = function(options, refresh, callback) { if (typeof res.S_CONFIRM_ACTION === 'undefined') { // It is a standard link, no confirm_box required. - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof res.MESSAGE_TITLE !== 'undefined') + { + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + } + if (typeof phpbb.ajax_callbacks[callback] === 'function') { phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); @@ -241,7 +245,11 @@ phpbb.ajaxify = function(options, refresh, callback) { path = res.S_CONFIRM_ACTION; phpbb.loading_alert(); $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof res.MESSAGE_TITLE !== 'undefined') + { + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + } + if (typeof phpbb.ajax_callbacks[callback] === 'function') { phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); From e7e09f8da26abf0d4e625653d14d68774050a244 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 16:39:25 +0100 Subject: [PATCH 091/175] [ticket/10272] AJAXified the bots page in the ACP. PHPBB3-10272 --- phpBB/adm/style/acp_bots.html | 4 ++-- phpBB/includes/acp/acp_bots.php | 10 +++++++++- phpBB/styles/script.js | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/phpBB/adm/style/acp_bots.html b/phpBB/adm/style/acp_bots.html index 886005caa3..e0e9588364 100644 --- a/phpBB/adm/style/acp_bots.html +++ b/phpBB/adm/style/acp_bots.html @@ -76,9 +76,9 @@
{bots.BOT_NAME}  {bots.LAST_VISIT}  {bots.L_ACTIVATE_DEACTIVATE}  {bots.L_ACTIVATE_DEACTIVATE}   {L_EDIT}  {L_DELETE}  {L_DELETE} 
{bots.BOT_NAME}  {bots.LAST_VISIT}  {bots.L_ACTIVATE_DEACTIVATE}  {bots.L_ACTIVATE_DEACTIVATE}   {L_EDIT}   {L_DELETE} 
{modules.MODULE_IMAGE} {modules.MODULE_TITLE} [{L_HIDDEN_MODULE}] {L_DISABLE}{L_ENABLE}  {L_DISABLE}{L_ENABLE}  {ICON_MOVE_UP_DISABLED} diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index 7804533d1a..d0920774f1 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -195,7 +195,7 @@ {fields.FIELD_IDENT} {fields.FIELD_TYPE}{fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE}{fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE} diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index dfc8def646..0b98dea603 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -288,7 +288,7 @@ - {installed.L_STYLE_ACT_DEACT} | + {installed.L_STYLE_ACT_DEACT} | {installed.S_ACTIONS} diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 59fe7cf8e2..4630c4fed1 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -377,7 +377,7 @@ phpbb.add_ajax_callback('post_delete', function(el) { tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } -}).add_ajax_callback('style_act_deact', function(el, res) { +}).add_ajax_callback('act_deact', function(el, res) { $(el).text(res.text); var new_href = $(el).attr('href'); if (new_href.indexOf('deactivate') !== -1) From f85faf435da19f877b7633e208ae103a3d954355 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 22:29:52 +0100 Subject: [PATCH 093/175] [ticket/10271] Cleaned up phpbb.ajaxify. Reduced a lot of duplicate code and made it more efficient. PHPBB3-10271 --- phpBB/styles/script.js | 70 +++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 4630c4fed1..4d7d6e1425 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -174,32 +174,6 @@ phpbb.parse_querystring = function(string) { * @param function callback Callback. */ phpbb.ajaxify = function(options, refresh, callback) { - - // Private function to handle refreshes - function handle_refresh(data, refresh, div) - { - if (!data) - { - return; - } - - refresh = ((typeof refresh === 'function') ? refresh(data.url) : - (typeof refresh === 'boolean') && refresh); - - setTimeout(function() { - if (refresh) - { - window.location = data.url; - } - else - { - dark.fadeOut(function() { - div.remove(); - }); - } - }, data.time * 1000); - } - var selector = (typeof options === 'string') ? options : options.selector; var is_form = $(selector).is('form'); if (is_form && typeof selector === 'object') @@ -237,7 +211,29 @@ phpbb.ajaxify = function(options, refresh, callback) { { phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); } - handle_refresh(res.REFRESH_DATA, refresh, alert); + + if (res.REFRESH_DATA) + { + if (typeof refresh === 'function') + { + refresh = refresh(res.REFRESH_DATA.url); + } + else if (typeof refresh !== 'boolean') + { + refresh = false; + } + + setTimeout(function() { + if (refresh) + { + window.location = res.REFRESH_DATA.url; + } + + dark.fadeOut(function() { + alert.remove(); + }); + }, res.REFRESH_DATA.time * 1000); + } } else { @@ -245,25 +241,9 @@ phpbb.ajaxify = function(options, refresh, callback) { phpbb.confirm(res.MESSAGE_TEXT, function(del) { if (del) { - data = $('' + res.S_HIDDEN_FIELDS + '').serialize(); - path = res.S_CONFIRM_ACTION; phpbb.loading_alert(); - $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { - if (typeof res.MESSAGE_TITLE !== 'undefined') - { - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - } - else - { - dark.fadeOut(); - } - - if (typeof phpbb.ajax_callbacks[callback] === 'function') - { - phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); - } - handle_refresh(res.REFRESH_DATA, refresh, alert); - }); + data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); + $.post(res.S_CONFIRM_ACTION, data + '&confirm=' + res.YES_VALUE, return_handler); } }, false); } From 53201da98c7b9ca88d1b43f1b59b8d17208c2025 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 22:53:26 +0100 Subject: [PATCH 094/175] [ticket/10270] Increased the speed of the animations. PHPBB3-10270 --- phpBB/styles/script.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 4d7d6e1425..0e885bceed 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -15,12 +15,12 @@ var dark = $('#darkenwrapper'), phpbb.loading_alert = function() { if (dark.is(':visible')) { - loading_alert.fadeIn(); + loading_alert.fadeIn(200); } else { loading_alert.show(); - dark.fadeIn(function() { + dark.fadeIn(200, function() { setTimeout(function() { if (loading_alert.is(':visible')) { @@ -52,7 +52,7 @@ phpbb.alert = function(title, msg, fadedark) { }); $(dark).one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; - fade.fadeOut(function() { + fade.fadeOut(200, function() { div.remove(); }); return false; @@ -68,21 +68,21 @@ phpbb.alert = function(title, msg, fadedark) { if (loading_alert.is(':visible')) { - loading_alert.fadeOut(function() { + loading_alert.fadeOut(200, function() { $(dark).append(div); - div.fadeIn(); + div.fadeIn(200); }); } else if (dark.is(':visible')) { $(dark).append(div); - div.fadeIn(); + div.fadeIn(200); } else { $(dark).append(div); div.show(); - dark.fadeIn(); + dark.fadeIn(200); } return div; @@ -107,7 +107,7 @@ phpbb.confirm = function(msg, callback, fadedark) { div.find('.jalertbut').bind('click', function() { var res = this.value === 'Yes'; var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; - fade.fadeOut(function() { + fade.fadeOut(200, function() { div.remove(); }); callback(res); @@ -127,21 +127,21 @@ phpbb.confirm = function(msg, callback, fadedark) { if (loading_alert.is(':visible')) { - loading_alert.fadeOut(function() { + loading_alert.fadeOut(200, function() { $(dark).append(div); - div.fadeIn(); + div.fadeIn(200); }); } else if (dark.is(':visible')) { $(dark).append(div); - div.fadeIn(); + div.fadeIn(200); } else { $(dark).append(div); div.show(); - dark.fadeIn(); + dark.fadeIn(200); } return div; @@ -204,7 +204,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } else { - dark.fadeOut(); + dark.fadeOut(200); } if (typeof phpbb.ajax_callbacks[callback] === 'function') @@ -229,7 +229,7 @@ phpbb.ajaxify = function(options, refresh, callback) { window.location = res.REFRESH_DATA.url; } - dark.fadeOut(function() { + dark.fadeOut(200, function() { alert.remove(); }); }, res.REFRESH_DATA.time * 1000); @@ -249,7 +249,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } } - var run_exception = typeof options.exception === 'function'; + var run_exception = (typeof options.exception === 'function'); if (is_form) { act = /action\[([a-z]+)\]/.exec(this.name); From 431a78f34696707973f1c67f4417d6ee85713ee6 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 11 Sep 2011 15:42:00 +0100 Subject: [PATCH 095/175] [ticket/10270] Got rid of the temporary jQuery for the AJAX changes. The jQuery library wasn't included before, so a temporary one was included. Now that igorws jQuery patch has been merged, the temporary library can be removed. PHPBB3-10270 --- phpBB/adm/style/overall_footer.html | 5 +---- phpBB/styles/prosilver/template/overall_footer.html | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 625121f1bd..ec3e6a30d3 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -22,15 +22,12 @@
 

{L_LOADING}

{L_PLEASE_WAIT}

- - - - + diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 37caaf7cca..20f6ee1f91 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -29,9 +29,6 @@
 

{L_LOADING}

{L_PLEASE_WAIT}

- - - @@ -43,6 +40,7 @@ + From 8c0e72cd9e52c754bd6a851de73862b3c6485840 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 11 Sep 2011 15:54:03 +0100 Subject: [PATCH 096/175] [ticket/10270] Sped up animations of popups. They were too slow and were hampering the user experience on boards with a fast connection such as local boards. PHPBB3-10270 --- phpBB/styles/script.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 0e885bceed..cafb11c9e4 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -15,12 +15,12 @@ var dark = $('#darkenwrapper'), phpbb.loading_alert = function() { if (dark.is(':visible')) { - loading_alert.fadeIn(200); + loading_alert.fadeIn(100); } else { loading_alert.show(); - dark.fadeIn(200, function() { + dark.fadeIn(100, function() { setTimeout(function() { if (loading_alert.is(':visible')) { @@ -52,7 +52,7 @@ phpbb.alert = function(title, msg, fadedark) { }); $(dark).one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; - fade.fadeOut(200, function() { + fade.fadeOut(100, function() { div.remove(); }); return false; @@ -68,21 +68,21 @@ phpbb.alert = function(title, msg, fadedark) { if (loading_alert.is(':visible')) { - loading_alert.fadeOut(200, function() { + loading_alert.fadeOut(100, function() { $(dark).append(div); - div.fadeIn(200); + div.fadeIn(100); }); } else if (dark.is(':visible')) { $(dark).append(div); - div.fadeIn(200); + div.fadeIn(100); } else { $(dark).append(div); div.show(); - dark.fadeIn(200); + dark.fadeIn(100); } return div; @@ -107,7 +107,7 @@ phpbb.confirm = function(msg, callback, fadedark) { div.find('.jalertbut').bind('click', function() { var res = this.value === 'Yes'; var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; - fade.fadeOut(200, function() { + fade.fadeOut(100, function() { div.remove(); }); callback(res); @@ -127,21 +127,21 @@ phpbb.confirm = function(msg, callback, fadedark) { if (loading_alert.is(':visible')) { - loading_alert.fadeOut(200, function() { + loading_alert.fadeOut(100, function() { $(dark).append(div); - div.fadeIn(200); + div.fadeIn(100); }); } else if (dark.is(':visible')) { $(dark).append(div); - div.fadeIn(200); + div.fadeIn(100); } else { $(dark).append(div); div.show(); - dark.fadeIn(200); + dark.fadeIn(100); } return div; @@ -204,7 +204,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } else { - dark.fadeOut(200); + dark.fadeOut(100); } if (typeof phpbb.ajax_callbacks[callback] === 'function') @@ -229,7 +229,7 @@ phpbb.ajaxify = function(options, refresh, callback) { window.location = res.REFRESH_DATA.url; } - dark.fadeOut(200, function() { + dark.fadeOut(100, function() { alert.remove(); }); }, res.REFRESH_DATA.time * 1000); From dbb81fbd2bfadf52502f2200b0420953d98ffb56 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 24 Sep 2011 16:35:46 +0100 Subject: [PATCH 097/175] [ticket/10328] Added capital to "Content-type" in phpbb_json_response. It was originally Content-type, but has been replaced with Content-Type, which is correct. PHPBB3-10328 --- phpBB/includes/json_response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/json_response.php b/phpBB/includes/json_response.php index 95d02e3c0e..dfddea98f2 100644 --- a/phpBB/includes/json_response.php +++ b/phpBB/includes/json_response.php @@ -30,7 +30,7 @@ class phpbb_json_response */ public function send($data, $exit = true) { - header('Content-type: application/json'); + header('Content-Type: application/json'); echo json_encode($data); if ($exit) From 233c2d51cfc1ffc33b03f1ab73c016d07828bab4 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 24 Sep 2011 16:42:22 +0100 Subject: [PATCH 098/175] [ticket/10270] Removed some unnecessary calls to $() in script.js. Sometimes, jQuery objects were being sent through the jQuery function again, wasting resources. PHPBB3-10270 --- phpBB/styles/script.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index cafb11c9e4..dd9d2532cc 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -46,11 +46,11 @@ phpbb.loading_alert = function() { phpbb.alert = function(title, msg, fadedark) { var div = $('

' + title + '

' + msg + '

'); - $(div).bind('click', function(e) { + div.bind('click', function(e) { e.stopPropagation(); return true; }); - $(dark).one('click', function(e) { + dark.one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; fade.fadeOut(100, function() { div.remove(); @@ -60,7 +60,7 @@ phpbb.alert = function(title, msg, fadedark) { $(document).bind('keydown', function(e) { if (e.keyCode === 13 || e.keyCode === 27) { - $(dark).trigger('click'); + dark.trigger('click'); return false; } return true; @@ -69,18 +69,18 @@ phpbb.alert = function(title, msg, fadedark) { if (loading_alert.is(':visible')) { loading_alert.fadeOut(100, function() { - $(dark).append(div); + dark.append(div); div.fadeIn(100); }); } else if (dark.is(':visible')) { - $(dark).append(div); + dark.append(div); div.fadeIn(100); } else { - $(dark).append(div); + dark.append(div); div.show(); dark.fadeIn(100); } @@ -128,18 +128,18 @@ phpbb.confirm = function(msg, callback, fadedark) { if (loading_alert.is(':visible')) { loading_alert.fadeOut(100, function() { - $(dark).append(div); + dark.append(div); div.fadeIn(100); }); } else if (dark.is(':visible')) { - $(dark).append(div); + dark.append(div); div.fadeIn(100); } else { - $(dark).append(div); + dark.append(div); div.show(); dark.fadeIn(100); } @@ -174,18 +174,14 @@ phpbb.parse_querystring = function(string) { * @param function callback Callback. */ phpbb.ajaxify = function(options, refresh, callback) { - var selector = (typeof options === 'string') ? options : options.selector; - var is_form = $(selector).is('form'); - if (is_form && typeof selector === 'object') + var selector = $((typeof options === 'string') ? options : options.selector); + var is_form = selector.is('form'); + if (is_form) { - selector = $(selector).find('input:submit'); - } - else if (is_form) - { - selector += ' input:submit'; + selector = selector.find('input:submit'); } - $(selector).click(function() { + selector.click(function() { var act, data, path, that = this; if ($(this).data('ajax') == false) From 818d98916873945d7e0e7bf2855e982496c7fe35 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 24 Sep 2011 17:41:58 +0100 Subject: [PATCH 099/175] [feature/ajax] Moved script.js into a few different files. Seperated it into: assets/javascript/core.js, styles/prosilver/template/ajax.js and adm/style/ajax.js. PHPBB3-10270 --- phpBB/adm/style/ajax.js | 61 ++++++++++ phpBB/adm/style/overall_footer.html | 3 +- .../script.js => assets/javascript/core.js} | 104 +----------------- phpBB/styles/prosilver/template/ajax.js | 66 +++++++++++ .../prosilver/template/overall_footer.html | 3 +- 5 files changed, 133 insertions(+), 104 deletions(-) create mode 100644 phpBB/adm/style/ajax.js rename phpBB/{styles/script.js => assets/javascript/core.js} (61%) create mode 100644 phpBB/styles/prosilver/template/ajax.js diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js new file mode 100644 index 0000000000..407ef92110 --- /dev/null +++ b/phpBB/adm/style/ajax.js @@ -0,0 +1,61 @@ +(function($) { // Avoid conflicts with other libraries + + + +phpbb.add_ajax_callback('forum_down', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':first-child')) + { + $(el).parents('span').siblings('.up').html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.up').children('a')}, false, 'forum_up'); + } + tr.insertAfter(tr.next()); + if (tr.is(':last-child')) + { + $(el).html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); + } +}).add_ajax_callback('forum_up', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':last-child')) + { + $(el).parents('span').siblings('.down').html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.down').children('a')}, false, 'forum_down'); + } + tr.insertBefore(tr.prev()); + if (tr.is(':first-child')) + { + $(el).html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); + } +}).add_ajax_callback('act_deact', function(el, res) { + $(el).text(res.text); + var new_href = $(el).attr('href'); + if (new_href.indexOf('deactivate') !== -1) + { + new_href = new_href.replace('deactivate', 'activate') + } + else + { + new_href = new_href.replace('activate', 'deactivate') + } + $(el).attr('href', new_href); +}).add_ajax_callback('row_delete', function(el) { + var tr = $(el).parents('tr'); + tr.remove(); +}); + + + +$('[data-ajax]').each(function() { + var fn = ($(this).data('ajax') !== 'true') ? $(this).data('ajax') : null; + phpbb.ajaxify({selector: this}, $(this).data('refresh') !== undefined, fn); +}); + + + +})(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index ec3e6a30d3..b57f8261a3 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -27,7 +27,8 @@ - + + diff --git a/phpBB/styles/script.js b/phpBB/assets/javascript/core.js similarity index 61% rename from phpBB/styles/script.js rename to phpBB/assets/javascript/core.js index dd9d2532cc..7337a7fbc0 100644 --- a/phpBB/styles/script.js +++ b/phpBB/assets/javascript/core.js @@ -3,6 +3,7 @@ var phpbb = {}; (function($) { // Avoid conflicts with other libraries + var dark = $('#darkenwrapper'), loading_alert = $('#loadingalert'); @@ -295,106 +296,5 @@ phpbb.add_ajax_callback = function(id, callback) } -phpbb.add_ajax_callback('post_delete', function(el) { - if ($(this).data('refresh') === undefined) - { - var pid = el.href.split('&p=')[1]; - $(el).parents('div #p' + pid).fadeOut(function() { - $(this).remove(); - }); - } -}).add_ajax_callback('bookmark', function(el, res) { - var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); - text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; - $(el).text(el.title = text); -}).add_ajax_callback('topic_subscribe', function(el) { - $(el).text(el.title = 'Unsubscribe topic'); -}).add_ajax_callback('topic_unsubscribe', function(el) { - $(el).text(el.title = 'Subscribe forum'); -}).add_ajax_callback('forum_subscribe', function(el) { - $(el).text(el.title = 'Unsubscribe topic'); -}).add_ajax_callback('forum_unsubscribe', function(el) { - $(el).text(el.title = 'Subscribe forum'); -}).add_ajax_callback('post_approve', function(el, res, act) { - $(el).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { - $(this).remove(); - }); -}).add_ajax_callback('qr-submit', function(el) { - $(el).parents('form').fadeOut(function() { - $(this).remove(); - }); -}).add_ajax_callback('forum_down', function(el) { - var tr = $(el).parents('tr'); - if (tr.is(':first-child')) - { - $(el).parents('span').siblings('.up').html('Move up'); - tr.next().find('.up').html('Move up'); - phpbb.ajaxify({selector: $(el).parents('span').siblings('.up').children('a')}, false, 'forum_up'); - } - tr.insertAfter(tr.next()); - if (tr.is(':last-child')) - { - $(el).html('Move down'); - tr.prev().find('.down').html('Move down'); - phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); - } -}).add_ajax_callback('forum_up', function(el) { - var tr = $(el).parents('tr'); - if (tr.is(':last-child')) - { - $(el).parents('span').siblings('.down').html('Move down'); - tr.prev().find('.down').html('Move down'); - phpbb.ajaxify({selector: $(el).parents('span').siblings('.down').children('a')}, false, 'forum_down'); - } - tr.insertBefore(tr.prev()); - if (tr.is(':first-child')) - { - $(el).html('Move up'); - tr.next().find('.up').html('Move up'); - phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); - } -}).add_ajax_callback('act_deact', function(el, res) { - $(el).text(res.text); - var new_href = $(el).attr('href'); - if (new_href.indexOf('deactivate') !== -1) - { - new_href = new_href.replace('deactivate', 'activate') - } - else - { - new_href = new_href.replace('activate', 'deactivate') - } - $(el).attr('href', new_href); -}).add_ajax_callback('row_delete', function(el) { - var tr = $(el).parents('tr'); - tr.remove(); -}).add_ajax_callback('zebra', function(el, res) { - if (res.success) { - $('.zebra').html(res.MESSAGE_TEXT); - $($('.zebra').get(1)).remove(); - } -});; - - -$('[data-ajax]').each(function() { - var fn = ($(this).data('ajax') !== 'true') ? $(this).data('ajax') : null; - phpbb.ajaxify({selector: this}, $(this).data('refresh') !== undefined, fn); -}); - - - -phpbb.ajaxify({ - selector: '#quickmodform', - exception: function(el, act, data) { - var d = phpbb.parse_querystring(data).action; - if (d == 'make_normal') - { - return !(el.find('select option[value="make_global"]').length); - } - return !(d == 'lock' || d == 'unlock' || d == 'delete_topic' || d.slice(0, 5) == 'make_'); - } -}, true); - - -})(jQuery); // Avoid conflicts with other libraries +})(jQuery); // Avoid conflicts with other libraries \ No newline at end of file diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js new file mode 100644 index 0000000000..38233ad0e0 --- /dev/null +++ b/phpBB/styles/prosilver/template/ajax.js @@ -0,0 +1,66 @@ +(function($) { // Avoid conflicts with other libraries + + + +phpbb.add_ajax_callback('post_delete', function(el) { + if ($(this).data('refresh') === undefined) + { + var pid = el.href.split('&p=')[1]; + $(el).parents('div #p' + pid).fadeOut(function() { + $(this).remove(); + }); + } +}).add_ajax_callback('bookmark', function(el, res) { + var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); + text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; + $(el).text(el.title = text); +}).add_ajax_callback('topic_subscribe', function(el) { + $(el).text(el.title = 'Unsubscribe topic'); +}).add_ajax_callback('topic_unsubscribe', function(el) { + $(el).text(el.title = 'Subscribe forum'); +}).add_ajax_callback('forum_subscribe', function(el) { + $(el).text(el.title = 'Unsubscribe topic'); +}).add_ajax_callback('forum_unsubscribe', function(el) { + $(el).text(el.title = 'Subscribe forum'); +}).add_ajax_callback('post_approve', function(el, res, act) { + $(el).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { + $(this).remove(); + }); +}).add_ajax_callback('qr-submit', function(el) { + $(el).parents('form').fadeOut(function() { + $(this).remove(); + }); +}).add_ajax_callback('row_delete', function(el) { + var tr = $(el).parents('tr'); + tr.remove(); +}).add_ajax_callback('zebra', function(el, res) { + if (res.success) { + $('.zebra').html(res.MESSAGE_TEXT); + $($('.zebra').get(1)).remove(); + } +});; + + + +$('[data-ajax]').each(function() { + var fn = ($(this).data('ajax') !== 'true') ? $(this).data('ajax') : null; + phpbb.ajaxify({selector: this}, $(this).data('refresh') !== undefined, fn); +}); + + + +phpbb.ajaxify({ + selector: '#quickmodform', + exception: function(el, act, data) { + var d = phpbb.parse_querystring(data).action; + if (d == 'make_normal') + { + return !(el.find('select option[value="make_global"]').length); + } + return !(d == 'lock' || d == 'unlock' || d == 'delete_topic' || d.slice(0, 5) == 'make_'); + } +}, true); + + + +})(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 20f6ee1f91..a89cd7f04e 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -40,7 +40,8 @@ - + + From 0e55b2393dffa269a724f3090469dad563217dff Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 25 Sep 2011 16:02:26 +0100 Subject: [PATCH 100/175] [ticket/10270] Removed all the inline language and HTML from the JS. PHPBB3-10270 --- phpBB/assets/javascript/core.js | 23 ++++++++++++------- phpBB/language/en/common.php | 2 ++ phpBB/styles/prosilver/template/ajax.js | 12 ---------- .../prosilver/template/overall_footer.html | 13 ++++++++--- .../prosilver/template/overall_header.html | 2 +- phpBB/viewtopic.php | 2 ++ 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 7337a7fbc0..d685d28c81 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -25,7 +25,7 @@ phpbb.loading_alert = function() { setTimeout(function() { if (loading_alert.is(':visible')) { - phpbb.alert('Error', 'Error processing your request. Please try again.'); + phpbb.alert($('body').data('l-err'), $('body').data('l-err-processing-req')); } }, 5000); }); @@ -45,7 +45,9 @@ phpbb.loading_alert = function() { * @returns object Returns the div created. */ phpbb.alert = function(title, msg, fadedark) { - var div = $('

' + title + '

' + msg + '

'); + var div = $('#jalert_alert'); + div.find('h3').html(title); + div.find('p').html(msg); div.bind('click', function(e) { e.stopPropagation(); @@ -54,7 +56,7 @@ phpbb.alert = function(title, msg, fadedark) { dark.one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; fade.fadeOut(100, function() { - div.remove(); + div.hide(); }); return false; }); @@ -101,15 +103,14 @@ phpbb.alert = function(title, msg, fadedark) { * @returns object Returns the div created. */ phpbb.confirm = function(msg, callback, fadedark) { - var div = $('

' + msg + '

\ -  \ -
'); + var div = $('#jalert_confirm'); + div.find('p').html(msg); div.find('.jalertbut').bind('click', function() { var res = this.value === 'Yes'; var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; fade.fadeOut(100, function() { - div.remove(); + div.hide(); }); callback(res); return false; @@ -227,7 +228,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } dark.fadeOut(100, function() { - alert.remove(); + alert.hide(); }); }, res.REFRESH_DATA.time * 1000); } @@ -296,5 +297,11 @@ phpbb.add_ajax_callback = function(id, callback) } +phpbb.add_ajax_callback('alt_text', function(el) { + var alt_text = $(el).data('alt-text'); + $(el).data('alt-text', $(el).text()); + $(el).text(el.title = alt_text); +}); + })(jQuery); // Avoid conflicts with other libraries \ No newline at end of file diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index e8fff96e5a..ff3d229915 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -179,10 +179,12 @@ $lang = array_merge($lang, array( 'ERR_CONNECTING_SERVER' => 'Error connecting to the server.', 'ERR_JAB_AUTH' => 'Could not authorise on Jabber server.', 'ERR_JAB_CONNECT' => 'Could not connect to Jabber server.', + 'ERR_PROCESSING_REQ' => 'There was an error processing your request. Please try again.', 'ERR_UNABLE_TO_LOGIN' => 'The specified username or password is incorrect.', 'ERR_UNWATCHING' => 'An error occured while trying to unsubscribe.', 'ERR_WATCHING' => 'An error occured while trying to subscribe.', 'ERR_WRONG_PATH_TO_PHPBB' => 'The phpBB path specified appears to be invalid.', + 'ERROR' => 'Error', 'EXPAND_VIEW' => 'Expand view', 'EXTENSION' => 'Extension', 'EXTENSION_CONTROLLER_MISSING' => 'The extension %s is missing a controller class and cannot be accessed through the front-end.', diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 38233ad0e0..58b765779e 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -10,18 +10,6 @@ phpbb.add_ajax_callback('post_delete', function(el) { $(this).remove(); }); } -}).add_ajax_callback('bookmark', function(el, res) { - var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); - text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; - $(el).text(el.title = text); -}).add_ajax_callback('topic_subscribe', function(el) { - $(el).text(el.title = 'Unsubscribe topic'); -}).add_ajax_callback('topic_unsubscribe', function(el) { - $(el).text(el.title = 'Subscribe forum'); -}).add_ajax_callback('forum_subscribe', function(el) { - $(el).text(el.title = 'Unsubscribe topic'); -}).add_ajax_callback('forum_unsubscribe', function(el) { - $(el).text(el.title = 'Subscribe forum'); }).add_ajax_callback('post_approve', function(el, res, act) { $(el).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { $(this).remove(); diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index a89cd7f04e..362f8bc1cc 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -8,9 +8,9 @@
{bots.BOT_NAME}  {bots.LAST_VISIT}  {bots.L_ACTIVATE_DEACTIVATE}  {bots.L_ACTIVATE_DEACTIVATE}   {L_EDIT}   {L_DELETE}  {fields.FIELD_IDENT} {fields.FIELD_TYPE}{fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE}{fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE} diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index 0b98dea603..a166623f89 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -288,7 +288,7 @@ - {installed.L_STYLE_ACT_DEACT} | + {installed.L_STYLE_ACT_DEACT} | {installed.S_ACTIONS} diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 869126ab76..88c28fe071 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -46,7 +46,7 @@ phpbb.add_ajax_callback('forum_down', function() { * It does this by replacing the text, and replacing all instances of "activate" * in the href with "deactivate", and vice versa. */ -phpbb.add_ajax_callback('act_deact', function(res) { +phpbb.add_ajax_callback('activate_deactivate', function(res) { el = $(this); el.text(res.text); var new_href = el.attr('href'); From 0d83e8725bfa51427a629fb540daf16035492a97 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 17 Nov 2011 17:45:31 +0000 Subject: [PATCH 134/175] [ticket/10272] Made a JS selector less specific. Now, style authors can change the posts to not be divs without the code breaking! PHPBB3-10272 --- phpBB/styles/prosilver/template/ajax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index efa1feb9cc..722295c65d 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -7,7 +7,7 @@ phpbb.add_ajax_callback('post_delete', function() { if (el.data('refresh') === undefined) { var post_id = el[0].href.split('&p=')[1]; - el.parents('div #p' + post_id).fadeOut(function() { + el.parents('#p' + post_id).fadeOut(function() { $(this).remove(); }); } From 2189efadc624deb515df1ba04c232724a2f8eae3 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 18 Nov 2011 17:31:10 +0000 Subject: [PATCH 135/175] [ticket/10270] Moved the AJAX error langyage entries to the footer. PHPBB3-10270 --- phpBB/adm/style/overall_footer.html | 2 +- phpBB/assets/javascript/core.js | 10 +++++----- phpBB/styles/prosilver/template/overall_footer.html | 2 +- phpBB/styles/prosilver/template/overall_header.html | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 5daaa4c6db..549b6995af 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -23,7 +23,7 @@

{L_LOADING}

{L_PLEASE_WAIT}

-
+

diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 067676348b..b25e75e979 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -4,12 +4,12 @@ phpbb.alert_time = 100; (function($) { // Avoid conflicts with other libraries // define a couple constants for keydown functions. -var ENTER = 13, - ESC = 27; +var ENTER = 13; +var ESC = 27; -var dark = $('#darkenwrapper'), - loading_alert = $('#loadingalert'); +var dark = $('#darkenwrapper'); +var loading_alert = $('#loadingalert'); /** @@ -30,7 +30,7 @@ phpbb.loading_alert = function() { setTimeout(function() { if (loading_alert.is(':visible')) { - phpbb.alert($('body').data('l-err'), $('body').data('l-timeout-processing-req')); + phpbb.alert($('#phpbb_alert').data('l-err'), $('#phpbb_alert').data('l-timeout-processing-req')); } }, 5000); }); diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 542bdf45f1..00de9029ec 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -30,7 +30,7 @@

{L_LOADING}

{L_PLEASE_WAIT}

-
+

diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index b5bbdf4f3e..5e095d0a0d 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -90,7 +90,7 @@ - +
From 81e357beef9e1e82607e59d59deba1cf54af4257 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 18 Nov 2011 17:33:22 +0000 Subject: [PATCH 136/175] [ticket/10272] Removed some duplication calls to $.fn.data. PHPBB3-10272 --- phpBB/adm/style/ajax.js | 6 +++--- phpBB/styles/prosilver/template/ajax.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 88c28fe071..902e072dda 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -72,10 +72,10 @@ phpbb.add_ajax_callback('row_delete', function() { $('[data-ajax]').each(function() { - var $this = $(this); - if ($this.data('ajax') !== 'false') + var $this = $(this), ajax = $this.data('ajax'); + if (ajax !== 'false') { - var fn = ($this.data('ajax') !== 'true') ? $this.data('ajax') : null; + var fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn); } }); diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 722295c65d..afbf27a20d 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -44,10 +44,10 @@ phpbb.add_ajax_callback('zebra', function(res) { $('[data-ajax]').each(function() { - var $this = $(this); - if ($this.data('ajax') !== 'false') + var $this = $(this), ajax = $this.data('ajax'); + if (ajax !== 'false') { - var fn = ($this.data('ajax') !== 'true') ? $this.data('ajax') : null; + var fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn); } }); From d1134f9a90ce3002068a28d196f7fd024381270a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 18 Nov 2011 17:50:34 +0000 Subject: [PATCH 137/175] [ticket/10271] Improved the AJAXification of the quick-mod tools. Instead of passing the querystring, now gets the value properly. PHPBB3-10271 --- phpBB/styles/prosilver/template/ajax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index afbf27a20d..117a392dc6 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -62,7 +62,7 @@ $('[data-ajax]').each(function() { phpbb.ajaxify({ selector: '#quickmodform', exception: function(act, data) { - var action = phpbb.parse_querystring(data).action; + var action = $('#quick-mod-select').val() if (action === 'make_normal') { return !($(this).find('select option[value="make_global"]').length); From eee0624a69389a10d3dcb97a5587fa6007be90f8 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 30 Nov 2011 16:48:38 +0000 Subject: [PATCH 138/175] [ticket/10271] Renamed an unhelpful variable name in core.js. PHPBB3-10271 --- phpBB/assets/javascript/core.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index b25e75e979..235fa41a1a 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -225,14 +225,14 @@ phpbb.parse_querystring = function(string) { * that was returned and (if it is a form) the form action. */ phpbb.ajaxify = function(options, refresh, callback) { - var selector = $((typeof options === 'string') ? options : options.selector); - var is_form = selector.is('form'); + var elements = $((typeof options === 'string') ? options : options.selector); + var is_form = elements.is('form'); if (is_form) { - selector = selector.find('input:submit'); + elements = elements.find('input:submit'); } - selector.click(function() { + elements.click(function() { var action, data, path, that = this, $this = $(this); if ($this.data('ajax') == false) From 3e53dff95c0957cd26d0256f40b5288094550f90 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 30 Nov 2011 16:58:17 +0000 Subject: [PATCH 139/175] [ticket/10271] Added some documentation to phpbb.ajaxify. PHPBB3-10271 --- phpBB/assets/javascript/core.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 235fa41a1a..d32bb2d1c2 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -252,9 +252,11 @@ phpbb.ajaxify = function(options, refresh, callback) { */ function return_handler(res) { + // Is a confirmation required? if (typeof res.S_CONFIRM_ACTION === 'undefined') { - // It is a standard link, no confirm_box required. + // If a confirmation is not required, display an alert and call the + // callbacks. if (typeof res.MESSAGE_TITLE !== 'undefined') { var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); @@ -269,6 +271,8 @@ phpbb.ajaxify = function(options, refresh, callback) { phpbb.ajax_callbacks[callback].call(that, res, (is_form) ? act : null); } + // If the server says to refresh the page, check whether the page should + // be refreshed and refresh page after specified time if required. if (res.REFRESH_DATA) { if (typeof refresh === 'function') @@ -286,15 +290,17 @@ phpbb.ajaxify = function(options, refresh, callback) { window.location = res.REFRESH_DATA.url; } + // Hide the alert even if we refresh the page, in case the user + // presses the back button. dark.fadeOut(phpbb.alert_time, function() { alert.hide(); }); - }, res.REFRESH_DATA.time * 1000); + }, res.REFRESH_DATA.time * 1000); // Server specifies time in seconds } } else { - // confirm_box - confirm with the user and send back + // If confirmation is required, display a diologue to the user. phpbb.confirm(res.MESSAGE_TEXT, function(del) { if (del) { @@ -306,6 +312,8 @@ phpbb.ajaxify = function(options, refresh, callback) { } } + // If the element is a form, POST must be used and some extra data must + // be taken from the form. var run_exception = (typeof options.exception === 'function'); if (is_form) { @@ -323,6 +331,8 @@ phpbb.ajaxify = function(options, refresh, callback) { data += '&' + this.name + '=' + this.value; } + // If exception function returns true, cancel the AJAX functionality, + // and return true (meaning that the HTTP request will be sent normally). if (run_exception && options.exception.call($this.parents('form')[0], action, data)) { return true; @@ -332,6 +342,8 @@ phpbb.ajaxify = function(options, refresh, callback) { } else { + // If exception function returns true, cancel the AJAX functionality, + // and return true (meaning that the HTTP request will be sent normally). if (run_exception && options.exception.call(this)) { return true; From 265907b1150303ca141be0f09de4093cbfb6d9f5 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 18:40:08 +0100 Subject: [PATCH 140/175] [feature/ajax] Replace keyboard vars with a keymap PHPBB3-10270 --- phpBB/assets/javascript/core.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index d32bb2d1c2..7b6bc4304a 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -4,9 +4,10 @@ phpbb.alert_time = 100; (function($) { // Avoid conflicts with other libraries // define a couple constants for keydown functions. -var ENTER = 13; -var ESC = 27; - +var keymap = { + ENTER: 13, + ESC: 27 +}; var dark = $('#darkenwrapper'); var loading_alert = $('#loadingalert'); @@ -70,7 +71,7 @@ phpbb.alert = function(title, msg, fadedark) { }); $(document).bind('keydown', function(e) { - if (e.keyCode === ENTER || e.keyCode === ESC) { + if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) { dark.trigger('click'); return false; } @@ -147,10 +148,10 @@ phpbb.confirm = function(msg, callback, fadedark) { }); $(document).bind('keydown', function(e) { - if (e.keyCode === ENTER) { + if (e.keyCode === keymap.ENTER) { $('input[type="button"].button1').trigger('click'); return false; - } else if (e.keyCode === ESC) { + } else if (e.keyCode === keymap.ESC) { $('input[type="button"].button2').trigger('click'); return false; } From 30888ff2a009fe5a001046484d5df4b6e2c67ac8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 18:42:21 +0100 Subject: [PATCH 141/175] [feature/ajax] Use attr('data-foo') instead of data('foo') data() is slower and does additional unwanted things like caching and type conversion. Just reading the value is safer. PHPBB3-10270 --- phpBB/adm/style/ajax.js | 12 ++++++------ phpBB/assets/javascript/core.js | 10 +++++----- phpBB/styles/prosilver/template/ajax.js | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 902e072dda..50477eef90 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -12,7 +12,7 @@ phpbb.add_ajax_callback('forum_down', function() { var tr = el.parents('tr'); if (tr.is(':first-child')) { - el.parents('span').siblings('.up').html('Move up'); + el.parents('span').siblings('.up').html('Move up'); tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: el.parents('span').siblings('.up').children('a')}, false, 'forum_up'); } @@ -20,7 +20,7 @@ phpbb.add_ajax_callback('forum_down', function() { if (tr.is(':last-child')) { el.html('Move down'); - tr.prev().find('.down').html('Move down'); + tr.prev().find('.down').html('Move down'); phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); } }).add_ajax_callback('forum_up', function() { @@ -28,7 +28,7 @@ phpbb.add_ajax_callback('forum_down', function() { var tr = el.parents('tr'); if (tr.is(':last-child')) { - el.parents('span').siblings('.down').html('Move down'); + el.parents('span').siblings('.down').html('Move down'); tr.prev().find('.down').html('Move down'); phpbb.ajaxify({selector: el.parents('span').siblings('.down').children('a')}, false, 'forum_down'); } @@ -36,7 +36,7 @@ phpbb.add_ajax_callback('forum_down', function() { if (tr.is(':first-child')) { el.html('Move up'); - tr.next().find('.up').html('Move up'); + tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } }); @@ -72,11 +72,11 @@ phpbb.add_ajax_callback('row_delete', function() { $('[data-ajax]').each(function() { - var $this = $(this), ajax = $this.data('ajax'); + var $this = $(this), ajax = $this.attr('data-ajax'); if (ajax !== 'false') { var fn = (ajax !== 'true') ? ajax : null; - phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn); + phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); } }); diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 7b6bc4304a..4e0ed11a8e 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -31,7 +31,7 @@ phpbb.loading_alert = function() { setTimeout(function() { if (loading_alert.is(':visible')) { - phpbb.alert($('#phpbb_alert').data('l-err'), $('#phpbb_alert').data('l-timeout-processing-req')); + phpbb.alert($('#phpbb_alert').attr('data-l-err'), $('#phpbb_alert').attr('data-l-timeout-processing-req')); } }, 5000); }); @@ -125,7 +125,7 @@ phpbb.confirm = function(msg, callback, fadedark) { e.stopPropagation(); return true; }); - + var click_handler = function() { var res = this.className === 'button1'; var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; @@ -236,7 +236,7 @@ phpbb.ajaxify = function(options, refresh, callback) { elements.click(function() { var action, data, path, that = this, $this = $(this); - if ($this.data('ajax') == false) + if ($this.attr('data-ajax') == false) { return true; } @@ -385,8 +385,8 @@ phpbb.add_ajax_callback = function(id, callback) */ phpbb.add_ajax_callback('alt_text', function(el) { el = $(el); - var alt_text = el.data('alt-text'); - el.data('alt-text', el.text()); + var alt_text = el.attr('data-alt-text'); + el.attr('data-alt-text', el.text()); el.text(el[0].title = alt_text); }); diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 117a392dc6..a0f0c820ba 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -4,7 +4,7 @@ // This callback finds the post from the delete link, and removes it. phpbb.add_ajax_callback('post_delete', function() { var el = $(this); - if (el.data('refresh') === undefined) + if (el.attr('data-refresh') === undefined) { var post_id = el[0].href.split('&p=')[1]; el.parents('#p' + post_id).fadeOut(function() { @@ -44,11 +44,11 @@ phpbb.add_ajax_callback('zebra', function(res) { $('[data-ajax]').each(function() { - var $this = $(this), ajax = $this.data('ajax'); + var $this = $(this), ajax = $this.attr('data-ajax'); if (ajax !== 'false') { var fn = (ajax !== 'true') ? ajax : null; - phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn); + phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); } }); From b100bb9a69982221e7244ac74dd1de421b6344bc Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 18:58:23 +0100 Subject: [PATCH 142/175] [feature/ajax] Replace return false with explicit preventDefault() PHPBB3-10270 --- phpBB/assets/javascript/core.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 4e0ed11a8e..68f7cf4ed8 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -59,7 +59,6 @@ phpbb.alert = function(title, msg, fadedark) { div.bind('click', function(e) { e.stopPropagation(); - return true; }); dark.one('click', function(e) { div.find('.alert_close').unbind('click'); @@ -67,15 +66,18 @@ phpbb.alert = function(title, msg, fadedark) { fade.fadeOut(phpbb.alert_time, function() { div.hide(); }); - return false; + + e.preventDefault(); + e.stopPropagation(); }); $(document).bind('keydown', function(e) { if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) { dark.trigger('click'); - return false; + + e.preventDefault(); + e.stopPropagation(); } - return true; }); div.find('.alert_close').one('click', function() { @@ -123,10 +125,9 @@ phpbb.confirm = function(msg, callback, fadedark) { div.bind('click', function(e) { e.stopPropagation(); - return true; }); - var click_handler = function() { + var click_handler = function(e) { var res = this.className === 'button1'; var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; fade.fadeOut(phpbb.alert_time, function() { @@ -134,7 +135,11 @@ phpbb.confirm = function(msg, callback, fadedark) { }); div.find('input[type="button"]').unbind('click', click_handler); callback(res); - return false; + + if (e) { + e.preventDefault(); + e.stopPropagation(); + } }; div.find('input[type="button"]').one('click', click_handler); @@ -144,18 +149,21 @@ phpbb.confirm = function(msg, callback, fadedark) { div.hide(); }); callback(false); - return false; + + e.preventDefault(); + e.stopPropagation(); }); $(document).bind('keydown', function(e) { if (e.keyCode === keymap.ENTER) { $('input[type="button"].button1').trigger('click'); - return false; + e.preventDefault(); + e.stopPropagation(); } else if (e.keyCode === keymap.ESC) { $('input[type="button"].button2').trigger('click'); - return false; + e.preventDefault(); + e.stopPropagation(); } - return true; }); div.find('.alert_close').one('click', function() { @@ -238,7 +246,7 @@ phpbb.ajaxify = function(options, refresh, callback) { if ($this.attr('data-ajax') == false) { - return true; + return; } /** From 628074bf7057ad5f9aff929d7c8cd85171ce60b8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 19:02:16 +0100 Subject: [PATCH 143/175] [feature/ajax] Stylistic JavaScript adjustments PHPBB3-10270 --- phpBB/adm/style/ajax.js | 25 ++++++++++++++++--------- phpBB/assets/javascript/core.js | 8 ++++++-- phpBB/styles/prosilver/template/ajax.js | 19 +++++++++++++------ 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 50477eef90..2725d9fa0a 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -8,8 +8,9 @@ * activates any up / down icons that require it (the ones at the top or bottom). */ phpbb.add_ajax_callback('forum_down', function() { - el = $(this); - var tr = el.parents('tr'); + var el = $(this), + tr = el.parents('tr'); + if (tr.is(':first-child')) { el.parents('span').siblings('.up').html('Move up'); @@ -23,9 +24,12 @@ phpbb.add_ajax_callback('forum_down', function() { tr.prev().find('.down').html('Move down'); phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); } -}).add_ajax_callback('forum_up', function() { - el = $(this); - var tr = el.parents('tr'); +}); + +phpbb.add_ajax_callback('forum_up', function() { + var el = $(this), + tr = el.parents('tr'); + if (tr.is(':last-child')) { el.parents('span').siblings('.down').html('Move down'); @@ -47,9 +51,9 @@ phpbb.add_ajax_callback('forum_down', function() { * in the href with "deactivate", and vice versa. */ phpbb.add_ajax_callback('activate_deactivate', function(res) { - el = $(this); + var el = $(this), + new_href = el.attr('href'); el.text(res.text); - var new_href = el.attr('href'); if (new_href.indexOf('deactivate') !== -1) { new_href = new_href.replace('deactivate', 'activate') @@ -72,10 +76,13 @@ phpbb.add_ajax_callback('row_delete', function() { $('[data-ajax]').each(function() { - var $this = $(this), ajax = $this.attr('data-ajax'); + var $this = $(this), + ajax = $this.attr('data-ajax'), + fn; + if (ajax !== 'false') { - var fn = (ajax !== 'true') ? ajax : null; + fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); } }); diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 68f7cf4ed8..9c5f507bb8 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -61,8 +61,10 @@ phpbb.alert = function(title, msg, fadedark) { e.stopPropagation(); }); dark.one('click', function(e) { + var fade; + div.find('.alert_close').unbind('click'); - var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; + fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; fade.fadeOut(phpbb.alert_time, function() { div.hide(); }); @@ -261,6 +263,8 @@ phpbb.ajaxify = function(options, refresh, callback) { */ function return_handler(res) { + var alert; + // Is a confirmation required? if (typeof res.S_CONFIRM_ACTION === 'undefined') { @@ -268,7 +272,7 @@ phpbb.ajaxify = function(options, refresh, callback) { // callbacks. if (typeof res.MESSAGE_TITLE !== 'undefined') { - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); } else { diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index a0f0c820ba..bf7551b8b8 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -3,10 +3,12 @@ // This callback finds the post from the delete link, and removes it. phpbb.add_ajax_callback('post_delete', function() { - var el = $(this); + var el = $(this), + post_id; + if (el.attr('data-refresh') === undefined) { - var post_id = el[0].href.split('&p=')[1]; + post_id = el[0].href.split('&p=')[1]; el.parents('#p' + post_id).fadeOut(function() { $(this).remove(); }); @@ -34,20 +36,25 @@ phpbb.add_ajax_callback('row_delete', function() { // This handles friend / foe additions removals. phpbb.add_ajax_callback('zebra', function(res) { + var zebra; + if (res.success) { - var zebra = $('.zebra'); + zebra = $('.zebra'); zebra.html(res.MESSAGE_TEXT); $(zebra.get(1)).remove(); } -});; +}); $('[data-ajax]').each(function() { - var $this = $(this), ajax = $this.attr('data-ajax'); + var $this = $(this), + ajax = $this.attr('data-ajax'), + fn; + if (ajax !== 'false') { - var fn = (ajax !== 'true') ? ajax : null; + fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); } }); From d53c36684db5ee592b871f518364ae9de03d3e8b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 19:03:30 +0100 Subject: [PATCH 144/175] [feature/ajax] JavaScript strict mode PHPBB3-10270 --- phpBB/adm/style/ajax.js | 1 + phpBB/assets/javascript/core.js | 2 ++ phpBB/styles/prosilver/template/ajax.js | 1 + 3 files changed, 4 insertions(+) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 2725d9fa0a..9b73b618d6 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -1,5 +1,6 @@ (function($) { // Avoid conflicts with other libraries +"use strict"; /** * The following callbacks are for reording forums in acp_forums. forum_down diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 9c5f507bb8..742aa05115 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -3,6 +3,8 @@ phpbb.alert_time = 100; (function($) { // Avoid conflicts with other libraries +"use strict"; + // define a couple constants for keydown functions. var keymap = { ENTER: 13, diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index bf7551b8b8..3e431a0c6e 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -1,5 +1,6 @@ (function($) { // Avoid conflicts with other libraries +"use strict"; // This callback finds the post from the delete link, and removes it. phpbb.add_ajax_callback('post_delete', function() { From a12b7a5c64ba68bf98a161c41520546abce9fc81 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 19:38:21 +0100 Subject: [PATCH 145/175] [feature/ajax] Fix alt_text and overlay closing PHPBB3-10270 --- phpBB/assets/javascript/core.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 742aa05115..5088da65db 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -84,8 +84,10 @@ phpbb.alert = function(title, msg, fadedark) { } }); - div.find('.alert_close').one('click', function() { + div.find('.alert_close').one('click', function(e) { dark.trigger('click'); + + e.preventDefault(); }); if (loading_alert.is(':visible')) @@ -170,12 +172,14 @@ phpbb.confirm = function(msg, callback, fadedark) { } }); - div.find('.alert_close').one('click', function() { + div.find('.alert_close').one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && fadedark) ? div : dark; fade.fadeOut(phpbb.alert_time, function() { div.hide(); }); callback(false); + + e.preventDefault(); }); if (loading_alert.is(':visible')) @@ -397,9 +401,12 @@ phpbb.add_ajax_callback = function(id, callback) * the alt-text data attribute, and replaces the text in the attribute with the * current text so that the process can be repeated. */ -phpbb.add_ajax_callback('alt_text', function(el) { - el = $(el); - var alt_text = el.attr('data-alt-text'); +phpbb.add_ajax_callback('alt_text', function(data) { + var el = $(this), + alt_text; + + alt_text = el.attr('data-alt-text'); + el.text(); el.attr('data-alt-text', el.text()); el.text(el[0].title = alt_text); }); From d96b07a745f8bebce55a93bbeaa61c07f7c5332a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 19:46:36 +0100 Subject: [PATCH 146/175] [feature/ajax] Only allow object argument for phpbb.ajaxify PHPBB3-10270 --- phpBB/assets/javascript/core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 5088da65db..6318fa2f17 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -234,7 +234,7 @@ phpbb.parse_querystring = function(string) { * For more info, view the following page on the phpBB wiki: * http://wiki.phpbb.com/JavaScript_Function.phpbb.ajaxify * - * @param object options Options, if a string will be the selector. + * @param object options Options. * @param bool/function refresh If we are sent back a refresh, should it be * acted upon? This can either be true / false / a function. * @param function callback Callback to call on completion of event. Has @@ -242,7 +242,7 @@ phpbb.parse_querystring = function(string) { * that was returned and (if it is a form) the form action. */ phpbb.ajaxify = function(options, refresh, callback) { - var elements = $((typeof options === 'string') ? options : options.selector); + var elements = $(options.selector); var is_form = elements.is('form'); if (is_form) { From 1fc26eb1d57ab2e6d49c5121414090b596ba2f8d Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 19:52:04 +0100 Subject: [PATCH 147/175] [feature/ajax] Make quick-mod tools "exception" handling more explicit PHPBB3-10270 --- phpBB/styles/prosilver/template/ajax.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 3e431a0c6e..53dc8e1124 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -70,18 +70,22 @@ $('[data-ajax]').each(function() { phpbb.ajaxify({ selector: '#quickmodform', exception: function(act, data) { - var action = $('#quick-mod-select').val() + var action = $('#quick-mod-select').val(); + if (action === 'make_normal') { return !($(this).find('select option[value="make_global"]').length); } - else if (action.slice(-4) === 'lock') + else if (action === 'lock' || action === 'unlock') { - // Return false for both lock and unlock return false; } - // make_sticky, make_announce and make_global all use AJAX. - return !(action === 'delete_topic' || action.slice(0, 5) === 'make_'); + + if (action === 'delete_topic' || action === 'make_sticky' || action === 'make_announce' || action === 'make_global') { + return false; + } + + return true; } }, true); From 7ed2cbef75e2e3e561dec00cad26870684968a3a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 19:56:25 +0100 Subject: [PATCH 148/175] [feature/ajax] Make phpbb.ajaxify signature use single object (more explicit) PHPBB3-10270 --- phpBB/adm/style/ajax.js | 26 ++++++++++++++++++++----- phpBB/assets/javascript/core.js | 9 ++++++--- phpBB/styles/prosilver/template/ajax.js | 11 ++++++++--- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 9b73b618d6..b4385b2740 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -16,14 +16,20 @@ phpbb.add_ajax_callback('forum_down', function() { { el.parents('span').siblings('.up').html('Move up'); tr.next().find('.up').html('Move up'); - phpbb.ajaxify({selector: el.parents('span').siblings('.up').children('a')}, false, 'forum_up'); + phpbb.ajaxify({ + selector: el.parents('span').siblings('.up').children('a'), + callback: 'forum_up' + }); } tr.insertAfter(tr.next()); if (tr.is(':last-child')) { el.html('Move down'); tr.prev().find('.down').html('Move down'); - phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); + phpbb.ajaxify({ + selector: tr.prev().find('.down').children('a'), + callback: 'forum_down' + }); } }); @@ -35,14 +41,20 @@ phpbb.add_ajax_callback('forum_up', function() { { el.parents('span').siblings('.down').html('Move down'); tr.prev().find('.down').html('Move down'); - phpbb.ajaxify({selector: el.parents('span').siblings('.down').children('a')}, false, 'forum_down'); + phpbb.ajaxify({ + selector: el.parents('span').siblings('.down').children('a'), + callback: 'forum_down' + }); } tr.insertBefore(tr.prev()); if (tr.is(':first-child')) { el.html('Move up'); tr.next().find('.up').html('Move up'); - phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); + phpbb.ajaxify({ + selector: tr.next().find('.up').children('a'), + callback: 'forum_up' + }); } }); @@ -84,7 +96,11 @@ $('[data-ajax]').each(function() { if (ajax !== 'false') { fn = (ajax !== 'true') ? ajax : null; - phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); + phpbb.ajaxify({ + selector: this, + refresh: $this.attr('data-refresh') !== undefined, + callback: fn + }); } }); diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 6318fa2f17..22865e744d 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -241,9 +241,12 @@ phpbb.parse_querystring = function(string) { * three parameters: the element that the event was evoked from, the JSON * that was returned and (if it is a form) the form action. */ -phpbb.ajaxify = function(options, refresh, callback) { - var elements = $(options.selector); - var is_form = elements.is('form'); +phpbb.ajaxify = function(options) { + var elements = $(options.selector), + refresh = options.refresh, + callback = options.callback, + is_form = elements.is('form'); + if (is_form) { elements = elements.find('input:submit'); diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 53dc8e1124..739648200b 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -56,7 +56,11 @@ $('[data-ajax]').each(function() { if (ajax !== 'false') { fn = (ajax !== 'true') ? ajax : null; - phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); + phpbb.ajaxify({ + selector: this, + refresh: $this.attr('data-refresh') !== undefined, + callback: fn + }); } }); @@ -86,8 +90,9 @@ phpbb.ajaxify({ } return true; - } -}, true); + }, + refresh: true +}); From 8a0d8c0a84e119121bc9bd69c757aa4776d42acb Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 20:38:23 +0100 Subject: [PATCH 149/175] [feature/ajax] Do not hard-code sorting images of acp_forums ordering PHPBB3-10270 --- phpBB/adm/style/acp_forums.html | 8 +++++ phpBB/adm/style/admin.css | 4 +++ phpBB/adm/style/ajax.js | 39 ++++++++++++++++++++----- phpBB/styles/prosilver/theme/common.css | 4 +++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/phpBB/adm/style/acp_forums.html b/phpBB/adm/style/acp_forums.html index b2b3ad6d40..048a24a328 100644 --- a/phpBB/adm/style/acp_forums.html +++ b/phpBB/adm/style/acp_forums.html @@ -500,6 +500,14 @@ + + diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index 01af071766..a162d44f9d 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -101,6 +101,10 @@ hr { font-size: 0.85em; } +.hidden { + display: none; +} + /* General links */ a:link, a:visited { color: #105289; diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index b4385b2740..0c00efee1b 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -2,6 +2,13 @@ "use strict"; +var img_templates = { + up: $('.template-up-img'), + up_disabled: $('.template-up-img-disabled'), + down: $('.template-down-img'), + down_disabled: $('.template-down-img-disabled') +}; + /** * The following callbacks are for reording forums in acp_forums. forum_down * is triggered when a forum is moved down, and forum_up is triggered when @@ -14,18 +21,26 @@ phpbb.add_ajax_callback('forum_down', function() { if (tr.is(':first-child')) { - el.parents('span').siblings('.up').html('Move up'); - tr.next().find('.up').html('Move up'); + var up_img = img_templates.up.clone().attr('href', tr.attr('data-up')); + el.parents('span').siblings('.up').html(up_img); + + tr.next().find('.up').html(img_templates.up_disabled); + phpbb.ajaxify({ selector: el.parents('span').siblings('.up').children('a'), callback: 'forum_up' }); } + tr.insertAfter(tr.next()); + if (tr.is(':last-child')) { - el.html('Move down'); - tr.prev().find('.down').html('Move down'); + el.replaceWith(img_templates.down_disabled); + + var down_img = img_templates.down.clone().attr('href', tr.attr('data-down')); + tr.prev().find('.down').html(down_img); + phpbb.ajaxify({ selector: tr.prev().find('.down').children('a'), callback: 'forum_down' @@ -39,18 +54,26 @@ phpbb.add_ajax_callback('forum_up', function() { if (tr.is(':last-child')) { - el.parents('span').siblings('.down').html('Move down'); - tr.prev().find('.down').html('Move down'); + var down_img = img_templates.down.clone().attr('href', tr.attr('data-down')); + el.parents('span').siblings('.down').html(down_img); + + tr.prev().find('.down').html(img_templates.down_disabled); + phpbb.ajaxify({ selector: el.parents('span').siblings('.down').children('a'), callback: 'forum_down' }); } + tr.insertBefore(tr.prev()); + if (tr.is(':first-child')) { - el.html('Move up'); - tr.next().find('.up').html('Move up'); + el.replaceWith(img_templates.up_disabled); + + var up_img = img_templates.up.clone().attr('href', tr.attr('data-up')); + tr.next().find('.up').html(up_img); + phpbb.ajaxify({ selector: tr.next().find('.up').children('a'), callback: 'forum_up' diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index d1fc1fa3e3..3b0e7899cb 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -702,3 +702,7 @@ p.rules a { line-height: 1px; background: transparent; } + +.hidden { + display: none; +} From 2ede0b1c811657827c388c4a0559063f4f02f025 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 9 Feb 2012 17:10:16 +0200 Subject: [PATCH 150/175] [feature/ajax] Better handling for zebra Better handling for zebra: message is displayed instead of first .zebra. Other .zebra entries are emptied, but not completely removed to avoid changing layout. PHPBB3-10272 --- phpBB/styles/prosilver/template/ajax.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 739648200b..35e8d6c0b4 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -41,8 +41,8 @@ phpbb.add_ajax_callback('zebra', function(res) { if (res.success) { zebra = $('.zebra'); - zebra.html(res.MESSAGE_TEXT); - $(zebra.get(1)).remove(); + zebra.first().html(res.MESSAGE_TEXT); + zebra.not(':first').html(' ').prev().html(' '); } }); From fc0d2425dcc7fe63cd9ff027a555fe14671d7393 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 9 Feb 2012 22:13:34 +0100 Subject: [PATCH 151/175] [feature/ajax] Fix the alt_text ajax callback PHPBB3-10270 --- phpBB/assets/javascript/core.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 22865e744d..973d57c6ac 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -409,9 +409,8 @@ phpbb.add_ajax_callback('alt_text', function(data) { alt_text; alt_text = el.attr('data-alt-text'); - el.text(); - el.attr('data-alt-text', el.text()); - el.text(el[0].title = alt_text); + el.attr('title', alt_text); + el.text(alt_text); }); From 6ad4015a37c6bba8e3b2a8cddc816f1ba7780dfa Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 11 Feb 2012 20:13:28 +0100 Subject: [PATCH 152/175] [feature/ajax] Add a missing semicolon PHPBB3-10270 --- phpBB/assets/javascript/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 973d57c6ac..0ff7436ca5 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -345,7 +345,7 @@ phpbb.ajaxify = function(options) { if (action) { - action = action[1] + action = action[1]; data += '&action=' + action; } else From b8a6a50f5c6a1f1f2ebcf9650e3f026561e2b060 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 11 Feb 2012 20:32:44 +0100 Subject: [PATCH 153/175] [feature/ajax] Rename exception to filter PHPBB3-10270 --- phpBB/assets/javascript/core.js | 10 +++++----- phpBB/styles/prosilver/template/ajax.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 0ff7436ca5..2f1a19c682 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -336,7 +336,7 @@ phpbb.ajaxify = function(options) { // If the element is a form, POST must be used and some extra data must // be taken from the form. - var run_exception = (typeof options.exception === 'function'); + var run_filter = (typeof options.filter === 'function'); if (is_form) { action = /action\[([a-z]+)\]/.exec(this.name); @@ -353,9 +353,9 @@ phpbb.ajaxify = function(options) { data += '&' + this.name + '=' + this.value; } - // If exception function returns true, cancel the AJAX functionality, + // If filter function returns true, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). - if (run_exception && options.exception.call($this.parents('form')[0], action, data)) + if (run_filter && options.filter.call($this.parents('form')[0], action, data)) { return true; } @@ -364,9 +364,9 @@ phpbb.ajaxify = function(options) { } else { - // If exception function returns true, cancel the AJAX functionality, + // If filter function returns true, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). - if (run_exception && options.exception.call(this)) + if (run_filter && options.filter.call(this)) { return true; } diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 35e8d6c0b4..f49b0af9c6 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -68,12 +68,12 @@ $('[data-ajax]').each(function() { /** * This AJAXifies the quick-mod tools. The reason it cannot be a standard - * callback / data attribute is that it requires exceptions - some of the options + * callback / data attribute is that it requires filtering - some of the options * can be ajaxified, while others cannot. */ phpbb.ajaxify({ selector: '#quickmodform', - exception: function(act, data) { + filter: function(act, data) { var action = $('#quick-mod-select').val(); if (action === 'make_normal') From 4848d6c9e839c287de736cf3badac42e859eaa69 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 14 Feb 2012 16:51:26 +0100 Subject: [PATCH 154/175] [feature/ajax] Bind to form.submit instead of form input.click PHPBB3-10270 --- phpBB/assets/javascript/core.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 2f1a19c682..4300e7056f 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -245,17 +245,13 @@ phpbb.ajaxify = function(options) { var elements = $(options.selector), refresh = options.refresh, callback = options.callback, - is_form = elements.is('form'); + is_form = elements.is('form'), + event_name = is_form ? 'submit' : 'click'; - if (is_form) - { - elements = elements.find('input:submit'); - } - - elements.click(function() { + elements.bind(event_name, function() { var action, data, path, that = this, $this = $(this); - if ($this.attr('data-ajax') == false) + if (!$this.attr('data-ajax')) { return; } @@ -290,7 +286,7 @@ phpbb.ajaxify = function(options) { if (typeof phpbb.ajax_callbacks[callback] === 'function') { - phpbb.ajax_callbacks[callback].call(that, res, (is_form) ? act : null); + phpbb.ajax_callbacks[callback].call(that, res); } // If the server says to refresh the page, check whether the page should From de82608e6ffa5e2bc12654197b7d7bd580563ddc Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 19:32:53 +0100 Subject: [PATCH 155/175] [feature/ajax] Refactor phpbb.ajaxify event callback PHPBB3-10270 --- phpBB/assets/javascript/core.js | 56 +++++++++++-------------- phpBB/styles/prosilver/template/ajax.js | 2 +- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 4300e7056f..b42870f466 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -249,7 +249,7 @@ phpbb.ajaxify = function(options) { event_name = is_form ? 'submit' : 'click'; elements.bind(event_name, function() { - var action, data, path, that = this, $this = $(this); + var action, method, data, that = this, $this = $(this); if (!$this.attr('data-ajax')) { @@ -333,45 +333,39 @@ phpbb.ajaxify = function(options) { // If the element is a form, POST must be used and some extra data must // be taken from the form. var run_filter = (typeof options.filter === 'function'); + if (is_form) { - action = /action\[([a-z]+)\]/.exec(this.name); - data = decodeURI($this.closest('form').serialize()); - path = $this.closest('form').attr('action').replace('&', '&'); - - if (action) - { - action = action[1]; - data += '&action=' + action; - } - else - { - data += '&' + this.name + '=' + this.value; - } - - // If filter function returns true, cancel the AJAX functionality, - // and return true (meaning that the HTTP request will be sent normally). - if (run_filter && options.filter.call($this.parents('form')[0], action, data)) - { - return true; - } - phpbb.loading_alert(); - $.post(path, data, return_handler); + action = $this.attr('action').replace('&', '&'); + data = $this.serializeArray(); + method = $this.attr('method'); } else { - // If filter function returns true, cancel the AJAX functionality, - // and return true (meaning that the HTTP request will be sent normally). - if (run_filter && options.filter.call(this)) - { - return true; - } - phpbb.loading_alert(); - $.get(this.href, return_handler); + action = this.href; + data = null; + method = 'GET'; } + // If filter function returns true, cancel the AJAX functionality, + // and return true (meaning that the HTTP request will be sent normally). + if (run_filter && options.filter.call(this, data)) + { + return true; + } + + phpbb.loading_alert(); + + $.ajax({ + url: action, + type: method, + data: data, + success: return_handler + }); + return false; }); + return this; } diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index f49b0af9c6..4360dc645f 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -73,7 +73,7 @@ $('[data-ajax]').each(function() { */ phpbb.ajaxify({ selector: '#quickmodform', - filter: function(act, data) { + filter: function(data) { var action = $('#quick-mod-select').val(); if (action === 'make_normal') From 2f25173d931d00b31087913b1772b51f12623690 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 19:38:55 +0100 Subject: [PATCH 156/175] [feature/ajax] Change filter semantics, some minor adjustments PHPBB3-10270 --- phpBB/assets/javascript/core.js | 4 ++-- phpBB/styles/prosilver/template/ajax.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index b42870f466..488b095b47 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -338,7 +338,7 @@ phpbb.ajaxify = function(options) { { action = $this.attr('action').replace('&', '&'); data = $this.serializeArray(); - method = $this.attr('method'); + method = $this.attr('method') || 'GET'; } else { @@ -347,7 +347,7 @@ phpbb.ajaxify = function(options) { method = 'GET'; } - // If filter function returns true, cancel the AJAX functionality, + // If filter function returns false, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). if (run_filter && options.filter.call(this, data)) { diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 4360dc645f..f82da9f70e 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -73,25 +73,25 @@ $('[data-ajax]').each(function() { */ phpbb.ajaxify({ selector: '#quickmodform', - filter: function(data) { + refresh: true, + filter: function (data) { var action = $('#quick-mod-select').val(); if (action === 'make_normal') { - return !($(this).find('select option[value="make_global"]').length); + return $(this).find('select option[value="make_global"]').length > 0; } else if (action === 'lock' || action === 'unlock') { - return false; + return true; } if (action === 'delete_topic' || action === 'make_sticky' || action === 'make_announce' || action === 'make_global') { - return false; + return true; } - return true; - }, - refresh: true + return false; + } }); From 27199bb50954e22416e64154032e08801d0fbb6d Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 20:58:00 +0100 Subject: [PATCH 157/175] [feature/ajax] Generic error handling with a phpbb.alert box PHPBB3-10270 --- phpBB/adm/style/overall_footer.html | 2 +- phpBB/assets/javascript/core.js | 18 +++++++++++++++++- phpBB/language/en/common.php | 2 ++ .../prosilver/template/overall_footer.html | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 549b6995af..dfe161fd76 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -18,7 +18,7 @@ {DEBUG_OUTPUT} -
+
 

{L_LOADING}

{L_PLEASE_WAIT}

diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 488b095b47..1faec27316 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -324,12 +324,28 @@ phpbb.ajaxify = function(options) { { phpbb.loading_alert(); data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(res.S_CONFIRM_ACTION, data + '&confirm=' + res.YES_VALUE, return_handler); + $.ajax({ + url: res.S_CONFIRM_ACTION, + type: 'POST', + data: data + '&confirm=' + res.YES_VALUE, + success: return_handler + }); } }, false); } } + function error_handler() + { + var alert; + + alert = phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text')); + + dark.fadeOut(phpbb.alert_time, function() { + alert.hide(); + }); + } + // If the element is a form, POST must be used and some extra data must // be taken from the form. var run_filter = (typeof options.filter === 'function'); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 4983aaca69..b92b915623 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -67,6 +67,8 @@ $lang = array_merge($lang, array( 'ADMINISTRATORS' => 'Administrators', 'AGE' => 'Age', 'AIM' => 'AIM', + 'AJAX_ERROR_TITLE' => 'AJAX error', + 'AJAX_ERROR_TEXT' => 'Something went wrong when processing your request.', 'ALLOWED' => 'Allowed', 'ALL_FILES' => 'All files', 'ALL_FORUMS' => 'All forums', diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 00de9029ec..ccc5b8b5de 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -25,7 +25,7 @@
{L_ACP}
-
+
 

{L_LOADING}

{L_PLEASE_WAIT}

From ea4362fc4cc89c4371d3eaadb1326676c6d2793e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 21:04:19 +0100 Subject: [PATCH 158/175] [feature/ajax] Use the error handler PHPBB3-10270 --- phpBB/assets/javascript/core.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 1faec27316..764bc74bce 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -328,7 +328,8 @@ phpbb.ajaxify = function(options) { url: res.S_CONFIRM_ACTION, type: 'POST', data: data + '&confirm=' + res.YES_VALUE, - success: return_handler + success: return_handler, + error: error_handler }); } }, false); @@ -341,9 +342,11 @@ phpbb.ajaxify = function(options) { alert = phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text')); - dark.fadeOut(phpbb.alert_time, function() { - alert.hide(); - }); + setTimeout(function () { + dark.fadeOut(phpbb.alert_time, function() { + alert.hide(); + }); + }, 5000); } // If the element is a form, POST must be used and some extra data must @@ -376,7 +379,8 @@ phpbb.ajaxify = function(options) { url: action, type: method, data: data, - success: return_handler + success: return_handler, + error: error_handler }); return false; From 2f44850a28fa9121052b9db57370d8e20ec5a0aa Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 21:16:16 +0100 Subject: [PATCH 159/175] [feature/ajax] Fix filter check, quick mod tools data-attribute PHPBB3-10270 --- phpBB/assets/javascript/core.js | 2 +- phpBB/styles/prosilver/template/viewtopic_body.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 764bc74bce..eb9798331e 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -368,7 +368,7 @@ phpbb.ajaxify = function(options) { // If filter function returns false, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). - if (run_filter && options.filter.call(this, data)) + if (run_filter && !options.filter.call(this, data)) { return true; } diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 8559b6fd9e..1c450b0500 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -263,7 +263,7 @@ -
+
  diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index ccc5b8b5de..1561bae26a 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -31,11 +31,11 @@
- +

- +

  diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 42f6efc5b1..855febf4aa 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -1074,3 +1074,17 @@ input.search { input.disabled { color: #666666; } + +/* jQuery popups +---------------------------------------- */ +.phpbb_alert { + background-color: #FFFFFF; + border-color: #999999; +} +.phpbb_alert .alert_close { + background-image: url("./images/alert_close.png"); +} +#darken { + background-color: #000000; +} + diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 3b0e7899cb..31015b28f9 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -591,8 +591,7 @@ li.pagination { /* jQuery popups ---------------------------------------- */ .phpbb_alert { - background-color: #FFFFFF; - border: 1px solid #999999; + border: 1px solid transparent; position: fixed; display: none; top: 100px; @@ -603,10 +602,19 @@ li.pagination { padding: 0 25px 20px 25px; } -.phpbb_alert img.alert_close { +.phpbb_alert .alert_close { + display: block; float: right; + width: 16px; + height: 16px; + overflow: hidden; + text-decoration: none !important; + background: transparent none 0 0 no-repeat; margin-top: -7px; - margin-right: -30px; + margin-right: -31px; +} +.phpbb_alert .alert_close:hover { + background-position: 0 -16px; } .phpbb_alert p { @@ -624,7 +632,6 @@ li.pagination { top: 0; width: 100%; height: 100%; - background-color: #000000; opacity: 0.5; } diff --git a/phpBB/styles/prosilver/theme/images/alert_close.png b/phpBB/styles/prosilver/theme/images/alert_close.png index 123ac4ac901f817080d565efbf952886f2177b5e..79750a013c5db627a14bf3d57edc8f8e3a477046 100644 GIT binary patch literal 2097 zcmaJ?YgAKL7LJ0*E65`_OVRcktP$(m;m=}RWa0BUlnFI$KFgT?|u4kiA3~!|za!^XLV766|9vif#KejaL{7)!6A}_|31pm15rZevXf%TciR7k7xWS211XQ|7 zVaFu}76kJZVmTs~Ndbc*7%e-9FtPed|G0ug{y|m>zi*SiVR$7d#}jb`!`M;+DD?ERrEISR|7J zeqkN}7vzhjhWH(x%cXOqFak>X5QoLY>J@Nev4GC@B#`|*{mC94R5FpsCi<{wRDTMY z!ydg(~-9>ey7ZS}zi<3m!t+ZB3SKgt9WQ7Gdw4$Ft9d~}4j zFW?e{Nv?m9pHdj_97b)G@1|0l9`^7s(F1|DU%OVV^zp?&GlP5Zhxvso<-*BtV`j90+^+Kq+rZ^rVgVBNYDp_VD1tDjYM!MYi*vF#7t(PL0l z)DyZYi6cAnqoAfJ+sj$iJv7vitlLk2akMevXSk}Y?AyJOkta(^u++rfgKD3$rw7cKB`MuM-owP8{DYdB?iOn(y5+F}JX2vgz#XG`}8n#b{t^MpOj~ zg+kWF*_X97H56K5&}Lh+f9sl>d^#RHFta*$?i_(mKY8nxM|XGkwh+v4o5;OgTKnnc z(t&~Y_IBgXf1jGN&Iw?#NDM}n-5HHWV`FJ@v3LC2uj}dxI1;{9<)g_%Ez!i`;!Br| znM`Ij^a@jO_Uv(;ZhyqJ-C%Rg;?5DqCY$?$XqHO_x$=jU7ObcxOv{#IgZ&VT-z={VJW37mK0GC+~Yb-~OSGgC|l zZr!!dj?z>Fuz&h~MEzxs&zgQg<3&zW3AgzLh1+4IKqzYtm@Vp3jR!(7oD}PFIVLjH zzWr@oYYbJz;Z3@9K1=N#x1V{!$2%>0ev*Z*jE<<-YCWq=PgvMqn?3dB6pvt;H{Up{ zd7_DioBR6uGJWm)QpUF(*kVuz0!+ph1Beywao>^UFx1wac`1|_6gs6iqg>D5F;_n_sqUFU+rFJp-wFwhQkVD7JgIw13D@SeKaZ>)ZJd4< z+yAO-gF4Z=JHFzfN8W7Hfby#=Ocj}k59M^l>lQ38kK?L8?&YOrwf8gR`5pnzrJk07 z9h>HqX7}&L$Wx~68AZB`wWs)RGd{E4H?(8tzjDos27za(tedB`w-v2!Ti0L7i8%Kg z{pab)fVr32!GH^D*`%P6vmxhA_uiJxkAp>NlObLf(dO&-mrdKxoIaINP)J#o)3)m4 zP&-o_>eMz2#Z3YgxgTUO}hquind8 z6ZFON6Q7E3^pnjtJ7$l0Z`TYmj0WTG-oDUjK}#HF0P-Ihb32c&Kw&oWB|A*ZcNl)+ N9Ci?^(l_eZe*jUwWY7Qr delta 658 zcmV;D0&V@V5S;~(7k>~41^@s6AM^iV00004b3#c}2nYxWddbVG7wVRUJ4ZXi@?ZDjy5H7_|YF)`g4T#x_&0338hSaefw zW^{L9a%BKPWN%_+AVz6&Wp{6KYjYq&Q#En5<2C>Q0rp8mL4Q;@jeV25Ym-qJ#(&37 zf)M#!98zOSz%;#BX>^rtb*W8B92y%db#bbsi+@171grt4L>-G+B7|77hgqmX^LNaE}%5M5AMc z{ixMyGVS%&6kH!Ddo2*qB-^&dw(SAo+1Z)iTb3o0PN%620;{V(du7|UEs>2439qkf zlYBle*9=2)xtun65{Xy}?xA4f;mV2*G#U+=@%co7gnxoTDHIBF)!`5Yl1L;puUIUK zf>$WGG2Hv{@v%1Pt#~{>G7kkQ6wK}J?v4aa)70V_pHJHD_BexsOTh2blaqlPsZ=UF z4u=6S41-ds#G_D%PN$vg%aupkQL>E@=+ zp2=kL3V;4Ts@wDP2c~K2U@R7sXIonXgMF~PES6>IvnjVbryrC8W7_MjwOXx_KF1-M zOny}GX82Rw_b)E~Xf~S{iqq+INx01E&B07*qoM6N<$f_tGUn*aa+ From 07826d6679d7edb738024c2e759247e82574a8a3 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 00:13:08 +0200 Subject: [PATCH 167/175] [feature/ajax] Remove quick-reply AJAX handling until we have something good The current implementation is not very user friendly, lots of things flashing in the user's face. We can re-consider AJAX when we have a decent solution. PHPBB3-10270 --- phpBB/styles/prosilver/template/ajax.js | 7 ------- phpBB/styles/prosilver/template/quickreply_editor.html | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 9ae7679e3e..3ad03f1539 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -24,13 +24,6 @@ phpbb.add_ajax_callback('post_approve', function(res) { }); }); -// This callback handles the removal of the quick reply form. -phpbb.add_ajax_callback('qr-submit', function() { - $(this).css('pointer-events', 'none').fadeOut(function() { - $(this).remove(); - }); -}); - // This removes the parent row of the link or form that fired the callback. phpbb.add_ajax_callback('row_delete', function() { $(this).parents('tr').remove(); diff --git a/phpBB/styles/prosilver/template/quickreply_editor.html b/phpBB/styles/prosilver/template/quickreply_editor.html index 3eff2a2bd6..4cd5eedd3e 100644 --- a/phpBB/styles/prosilver/template/quickreply_editor.html +++ b/phpBB/styles/prosilver/template/quickreply_editor.html @@ -1,4 +1,4 @@ - +

{L_QUICKREPLY}

From 9b971c9fb17f284cda413eacc6665f5cdf837cbd Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 00:59:27 +0200 Subject: [PATCH 168/175] [feature/ajax] Replace static call to phpbb_request with OO PHPBB3-10270 --- phpBB/includes/acp/acp_modules.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 427a3e1e71..e7cd057361 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -375,7 +375,8 @@ class acp_modules { if ($request->is_ajax()) { - phpbb_json_response::send(array( + $json_response = new phpbb_json_response(); + $json_response->send(array( 'MESSAGE_TITLE' => $user->lang('ERROR'), 'MESSAGE_TEXT' => implode('
', $errors), )); From d3e7744dd6968b941fb3216ee2a989ed6a0c2ba1 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 00:59:49 +0200 Subject: [PATCH 169/175] [feature/ajax] Remove not working module enable/disable ajax code PHPBB3-10270 --- phpBB/adm/style/acp_modules.html | 2 +- phpBB/adm/style/ajax.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index 380a037977..6c4645e80c 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -148,7 +148,7 @@
{modules.MODULE_IMAGE} {modules.MODULE_TITLE} [{L_HIDDEN_MODULE}] {L_DISABLE}{L_ENABLE}  {L_DISABLE}{L_ENABLE}  {ICON_MOVE_UP_DISABLED} diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 0c00efee1b..fd2f7a2122 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -89,7 +89,9 @@ phpbb.add_ajax_callback('forum_up', function() { phpbb.add_ajax_callback('activate_deactivate', function(res) { var el = $(this), new_href = el.attr('href'); + el.text(res.text); + if (new_href.indexOf('deactivate') !== -1) { new_href = new_href.replace('deactivate', 'activate') @@ -98,6 +100,7 @@ phpbb.add_ajax_callback('activate_deactivate', function(res) { { new_href = new_href.replace('activate', 'deactivate') } + el.attr('href', new_href); }); From ac320fad0599184f458786455cc441010d6f6d35 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 01:57:10 +0300 Subject: [PATCH 170/175] [ticket/10270] Alter background colors for posts Change background colors for posts after deleted post PHPBB3-10270 --- phpBB/styles/prosilver/template/ajax.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 3ad03f1539..cc886c42b1 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -10,7 +10,14 @@ phpbb.add_ajax_callback('post_delete', function() { if (el.attr('data-refresh') === undefined) { post_id = el[0].href.split('&p=')[1]; - el.parents('#p' + post_id).css('pointer-events', 'none').fadeOut(function() { + var post = el.parents('#p' + post_id).css('pointer-events', 'none'); + if (post.hasClass('bg1') || post.hasClass('bg2')) + { + var posts1 = post.nextAll('.bg1'); + post.nextAll('.bg2').removeClass('bg2').addClass('bg1'); + posts1.removeClass('bg1').addClass('bg2'); + } + post.fadeOut(function() { $(this).remove(); }); } From 8138103c6b5695b07c2f98d7ff9942e22903591a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:09:41 +0200 Subject: [PATCH 171/175] [feature/ajax] Send correct activate/deactivate JSON response in acp_profile PHPBB3-10270 --- phpBB/includes/acp/acp_profile.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 511148baf9..3ffffd3047 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -242,6 +242,15 @@ class acp_profile $db->sql_freeresult($result); add_log('admin', 'LOG_PROFILE_FIELD_ACTIVATE', $field_ident); + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response(); + $json_response->send(array( + 'text' => $user->lang('DEACTIVATE'), + )); + } + trigger_error($user->lang['PROFILE_FIELD_ACTIVATED'] . adm_back_link($this->u_action)); break; @@ -266,7 +275,16 @@ class acp_profile $field_ident = (string) $db->sql_fetchfield('field_ident'); $db->sql_freeresult($result); + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response(); + $json_response->send(array( + 'text' => $user->lang('ACTIVATE'), + )); + } + add_log('admin', 'LOG_PROFILE_FIELD_DEACTIVATE', $field_ident); + trigger_error($user->lang['PROFILE_FIELD_DEACTIVATED'] . adm_back_link($this->u_action)); break; From ef03f8d0536033d1ef4739c5884d1a1f919618bd Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:15:13 +0200 Subject: [PATCH 172/175] [feature/ajax] Fix acp_styles activate_deactivate ajax callback name PHPBB3-10270 --- phpBB/adm/style/acp_styles.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index a166623f89..3532e8c7d9 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -288,7 +288,7 @@ - {installed.L_STYLE_ACT_DEACT} | + {installed.L_STYLE_ACT_DEACT} | {installed.S_ACTIONS} From 4a5172c9f74047c5917a0356f8537da2fe1550f4 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:17:35 +0200 Subject: [PATCH 173/175] [feature/ajax] Unify phpbb_json_response instantiation PHPBB3-10270 --- phpBB/includes/acp/acp_modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index e7cd057361..8528dc91c4 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -375,7 +375,7 @@ class acp_modules { if ($request->is_ajax()) { - $json_response = new phpbb_json_response(); + $json_response = new phpbb_json_response; $json_response->send(array( 'MESSAGE_TITLE' => $user->lang('ERROR'), 'MESSAGE_TEXT' => implode('
', $errors), From 41d8a777dc73350a2f3bba6aaae2686921110d08 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:26:04 +0200 Subject: [PATCH 174/175] [feature/ajax] Add entirely unrelated but nice newlines PHPBB3-10270 --- phpBB/includes/acp/acp_styles.php | 1 + phpBB/includes/functions_display.php | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index a241dd3d10..26939080bc 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -185,6 +185,7 @@ inherit_from = {INHERIT_FROM} WHERE forum_style = ' . $style_id; $db->sql_query($sql); } + if ($request->is_ajax()) { $json_response = new phpbb_json_response; diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 9335cabc15..18db64cc68 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -273,6 +273,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod markread('topics', $forum_ids); $message = sprintf($user->lang['RETURN_FORUM'], '', ''); meta_refresh(3, $redirect); + trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); } else From b42e10df28742ba5a68d15e740e33aa7f8260f40 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:35:28 +0200 Subject: [PATCH 175/175] [feature/ajax] Remove strange non-breaking spaces from approve button The viewtopic inline approve/disapprove buttons for posts had spaces. PHPBB3-10270 --- phpBB/styles/prosilver/template/viewtopic_body.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 1c450b0500..3c551b3d52 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -138,8 +138,8 @@

- {UNAPPROVED_IMG} {L_POST_UNAPPROVED}   -   + {UNAPPROVED_IMG} {L_POST_UNAPPROVED} + {S_FORM_TOKEN}