franck@0: 'Popup Test',
franck@0: 'page callback' => '_popups_test_popups',
franck@0: 'type' => MENU_CALLBACK,
franck@0: 'access callback' => TRUE,
franck@0: );
franck@0: $items['popups/test/response'] = array(
franck@0: 'page callback' => '_popups_test_response',
franck@0: 'type' => MENU_CALLBACK,
franck@0: 'access callback' => TRUE,
franck@0: );
franck@0: $items['popups/test/namechange'] = array(
franck@0: 'page callback' => 'drupal_get_form',
franck@0: 'page arguments' => array('_popups_test_namechange'),
franck@0: 'type' => MENU_CALLBACK,
franck@0: 'access callback' => TRUE,
franck@0: );
franck@0: $items['popups/test/old'] = array(
franck@0: 'title' => 'Popup Test',
franck@0: 'page callback' => '_popups_test_popups_old',
franck@0: 'type' => MENU_CALLBACK,
franck@0: 'access callback' => TRUE,
franck@1: );
franck@0: return $items;
franck@0: }
franck@0:
franck@0: /**
franck@0: * Implementation of hook_popups().
franck@1: *
franck@0: * This implements hook_popups, defined in popups_get_popups.
franck@0: * See the comments in popups_add_popups for explination of the options.
franck@0: * Adding popup behavior to the core admin pages has been moved to popups_admin.
franck@0: *
franck@0: * @return: Array of link selectors to apply popup behavior to.
franck@0: * Keyed by path or form_id.
franck@0: */
franck@1: function popups_test_popups() {
franck@0: return array(
franck@0: 'popups/test' => array( // test page.
franck@0: // '*' => array( // test page.
franck@1: '#test-popup' => array(
franck@0: // 'additionalJavascript' => array('misc/collapse.js'),
franck@0: // 'forceReturn' => 'node/add/story',
franck@0: ),
franck@1: ),
franck@0: );
franck@0: }
franck@0:
franck@0: // **************************************************************************
franck@0: // TESTING ****************************************************************
franck@0: // **************************************************************************
franck@0:
franck@0: function _popups_test_popups() {
franck@0: popups_add_popups();
franck@0: $output = '
';
franck@1: $output .= '- '. l("Pop up entire local page.", 'popups/test/response',
franck@0: array('attributes' => array('class' => 'popups')));
franck@1: $output .= "
- ". l("Pop with options (href override).", 'popups/test/',
franck@0: array('attributes' => array('class' => 'popups', 'on-popups-options' => '{href: "test/response"}')));
franck@1: $output .= "
- ". l("Pop with options (width=200px).", 'popups/test/response',
franck@0: array('attributes' => array('class' => 'popups', 'on-popups-options' => '{width: "200px"}')));
franck@0: $output .= "
";
franck@0: $output .= '- '. l("Add Story (hook)", 'node/add/story',
franck@0: array( 'attributes' => array('id' => 'test-popup')));
franck@0: $output .= '
- '. l("Add Story (attribute).", 'node/add/story',
franck@0: array( 'attributes' => array('class' => 'popups-form')));
franck@1:
franck@1: $output .= '
- '. l("Change Settings and ajax update entire content area: ",
franck@0: 'admin/settings/popups',
franck@0: array( 'attributes' => array('class' => 'popups-form'),
franck@0: ));
franck@0: $output .= " (Auto Fade checkbox is: " . (variable_get('popups_autoclose_final_message', 1) ? 'on' : 'off') . ')';
franck@0:
franck@0: $output .= '
- '. l("Change Settings and ajax update only single target.", 'admin/settings/popups',
franck@1: array( 'attributes' => array('id' => 'reload-target'),
franck@0: ));
franck@0: $output .= " (Auto Fade checkbox is: " . (variable_get('popups_autoclose_final_message', 1) ? 'on' : 'off') . ')';
franck@1: popups_add_popups(array('#reload-target'=>array('targetSelectors'=>array('#response2'))));
franck@1:
franck@0: $output .= '
- '. l("Change Settings and ajax update multiple targets with data from other page (tricky!).", 'admin/settings/popups',
franck@0: array( 'attributes' => array(
franck@0: 'id' => 'foo',
franck@0: 'class' => 'popups-form',
franck@0: 'on-popups-options' => '{targetSelectors: {"#edit-popups-always-scan-wrapper": "#foo", "#edit-popups-popup-final-message-wrapper": "#test-list li:first"}, forceReturn: "admin/settings/popups"}')));
franck@0:
franck@1: $output .= '
- '. l("Change Settings and reload entire page.",
franck@0: 'admin/settings/popups',
franck@0: array( 'attributes' => array('class' => 'popups-form-reload'),
franck@0: ));
franck@1:
franck@1: $output .= '
- '. l("Pop up defined by popups_add_popups rule.", 'popups/test/response',
franck@0: array('attributes' => array('id' => 'rule-test')));
franck@1: popups_add_popups(array('#rule-test'=>array('width'=>'300px')));
franck@1: $output .= '
- '. l('Ajax update just Page Title (only works if you theme uses id="page-title")', 'popups/test/namechange',
franck@0: array('attributes' => array('id' => 'title-test')));
franck@1: popups_add_popups(array('#title-test'=>array('titleSelectors'=>array('#page-title'), 'noUpdate'=> TRUE, 'forceReturn'=>'popups/test/namechange')));
franck@0:
franck@0: global $user;
franck@0: $output .= "
- You are user number $user->uid
";
franck@0: if ($user->uid == 0) {
franck@1: $output .= '- '. l("Login and ajax refresh content area.", 'user',
franck@0: array('attributes' => array('class' => 'popups-form')));
franck@1: $output .= '
- '. l("Login and reload entire page.", 'user',
franck@1: array('attributes' => array('class' => 'popups-form-reload')));
franck@1: $output .= '
- '. l("Login and do not reload anything.", 'user',
franck@1: array('attributes' => array('class' => 'popups-form-noupdate')));
franck@0: }
franck@0: else {
franck@1: $output .= '
- '. l("Logout (need to surpress warning b/c session is dumped)", 'logout',
franck@0: array('attributes' => array('id' => 'logout')));
franck@0: }
franck@0: // Need to have the rule outside the else, or it won't get loaded on ajax reload.
franck@1: popups_add_popups(array('#logout'=>array('noUpdate'=>TRUE, 'reloadOnError'=>TRUE)));
franck@0:
franck@1: $output .= '
- '. l("Add Poll (test inline)", 'node/add/poll',
franck@0: array('attributes' => array('class' => 'popups-form')));
franck@1:
franck@1: $output .= "
";
franck@0: return $output;
franck@0: }
franck@0:
franck@0: function _popups_test_popups_old() {
franck@0: // drupal_set_message('Popup Test Page: If you edit your page.tpl.php to wrap the print $messages in a div with id="popit", this message will popup on page load');
franck@0: popups_add_popups();
franck@0: $output = '';
franck@1: $output .= '- '. l("Pop up entire local page.", 'popups/test/response',
franck@0: array('attributes' => array('class' => 'popups')));
franck@1: $output .= "
- ". l("Pop with options (href override).", 'popups/test/',
franck@0: array('attributes' => array('class' => 'popups', 'on-popups-options' => '{href: "test/response"}')));
franck@1: $output .= "
- ". l("Pop with options (width=200px).", 'popups/test/response',
franck@0: array('attributes' => array('class' => 'popups', 'on-popups-options' => '{width: "200px"}')));
franck@0: $output .= "
";
franck@0: $output .= '- '. l("Add Story (hook)", 'node/add/story',
franck@0: array( 'attributes' => array('id' => 'test-popup')));
franck@0: $output .= '
- '. l("Add Story (attribute).", 'node/add/story',
franck@0: array( 'attributes' => array('class' => 'popups-form')));
franck@1:
franck@1: $output .= '
- '. l("Change Settings and ajax update entire content area: ",
franck@0: 'admin/settings/popups',
franck@0: array( 'attributes' => array('class' => 'popups-form'),
franck@0: ));
franck@0: $output .= " (Auto Fade checkbox is: " . (variable_get('popups_popup_final_message', 1) ? 'on' : 'off') . ')';
franck@0:
franck@0: $output .= '
- '. l("Change Settings and ajax update only single target.", 'admin/settings/popups',
franck@1: array( 'attributes' => array('id' => 'reload-target'),
franck@0: ));
franck@0: $output .= " (Auto Fade checkbox is: " . (variable_get('popups_popup_final_message', 1) ? 'on' : 'off') . ')';
franck@1: popups_add_popups(array('#reload-target'=>array('targetSelectors'=>array('#response2'))));
franck@1:
franck@0: $output .= '
- '. l("Change Settings and ajax update multiple targets with data from other page (tricky!).", 'admin/settings/popups',
franck@0: array( 'attributes' => array(
franck@0: 'id' => 'foo',
franck@0: 'class' => 'popups-form',
franck@0: 'on-popups-options' => '{targetSelectors: {"#edit-popups-always-scan-wrapper": "#foo", "#edit-popups-popup-final-message-wrapper": "#test-list li:first"}, forceReturn: "admin/settings/popups"}')));
franck@0:
franck@1: $output .= '
- '. l("Change Settings and reload entire page.",
franck@0: 'admin/settings/popups',
franck@0: array( 'attributes' => array('class' => 'popups-form-reload'),
franck@0: ));
franck@1:
franck@1: $output .= '
- '. l("Pop up defined by popups_add_popups rule.", 'popups/test/response',
franck@0: array('attributes' => array('id' => 'rule-test')));
franck@1: popups_add_popups(array('#rule-test'=>array('width'=>'300px')));
franck@1: $output .= '
- '. l('Ajax update just Page Title (only works if you theme uses id="page-title")', 'popups/test/namechange',
franck@0: array('attributes' => array('id' => 'title-test')));
franck@1: popups_add_popups(array('#title-test'=>array('titleSelectors'=>array('#page-title'), 'noUpdate'=> TRUE, 'forceReturn'=>'popups/test/namechange')));
franck@0:
franck@0: global $user;
franck@0: $output .= "
- You are user number $user->uid
";
franck@0: if ($user->uid == 0) {
franck@1: $output .= '- '. l("Login and ajax refresh content area.", 'user',
franck@0: array('attributes' => array('class' => 'popups-form')));
franck@1: $output .= '
- '. l("Login and reload entire page.", 'user',
franck@1: array('attributes' => array('class' => 'popups-form-reload')));
franck@1: $output .= '
- '. l("Login and do not reload anything.", 'user',
franck@1: array('attributes' => array('class' => 'popups-form-noupdate')));
franck@0: }
franck@0: else {
franck@1: $output .= '
- '. l("Logout (need to surpress warning b/c session is dumped)", 'logout',
franck@0: array('attributes' => array('id' => 'logout')));
franck@0: }
franck@0: // Need to have the rule outside the else, or it won't get loaded on ajax reload.
franck@1: popups_add_popups(array('#logout'=>array('noUpdate'=>TRUE, 'reloadOnError'=>TRUE)));
franck@0:
franck@1: $output .= '
- '. l("Add Poll (test inline)", 'node/add/poll',
franck@0: array('attributes' => array('class' => 'popups-form')));
franck@1:
franck@1: $output .= "
";
franck@0: return $output;
franck@0: }
franck@0:
franck@0: function _popups_test_response() {
franck@0: drupal_set_title("Popup Test Two");
franck@0: return 'Hello World
';
franck@0: }
franck@0:
franck@0: function _popups_test_namechange() {
franck@0: drupal_set_title("New Name for Test Page");
franck@0: $form = array();
franck@0:
franck@0: $form['popups_popup_final_message'] = array(
franck@0: '#type' => 'submit',
franck@0: '#value' => t('Test Name Change'),
franck@0: );
franck@1:
franck@0: return $form;
franck@0: }