- /**
- *
- * Function to show and hide the smiley-list in the hidden div
- *
- */
-
- $b .= "<script>\n";
- $b .= " smileybutton_show = 0;\n";
- $b .= " function toggle_smileybutton() {\n";
- $b .= " if (! smileybutton_show) {\n";
- $b .= " $(\"#smileybutton\").show();\n";
- $b .= " smileybutton_show = 1;\n";
- $b .= " } else {\n";
- $b .= " $(\"#smileybutton\").hide();\n";
- $b .= " smileybutton_show = 0;\n";
- $b .= " }}\n";
-
- /**
- *
- * Function to add the chosen smiley to the inputbox
- *
- */
-
- $b .= " function smileybutton_addsmiley(text) {\n";
- $b .= " v = $(\"#profile-jot-text\").val()\n";
- $b .= " v = v + text\n";
- $b .= " $(\"#profile-jot-text\").val(v)\n";
- $b .= " }\n";
- $b .= "</script>\n";
-}
-
-
-
-
-
-/**
- *
- * Set the configuration
- *
- */
-
-function smileybutton_settings_post($a,$post) {
- if(! local_user())
- return;
- if($_POST['smileybutton-submit'])
- set_pconfig(local_user(),'smileybutton','enable',intval($_POST['smileybutton']));
-}
-
-
-/**
- *
- * Add configuration-dialog to form
- *
- */
-
-
-function smileybutton_settings(&$a,&$s) {
-
- if(! local_user())
- return;
-
- /* Add our stylesheet to the page so we can make our settings look nice */
-
- $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/smileybutton/smileybutton.css' . '" media="all" />' . "\r\n";
-
- /* Get the current state of our config variable */
-
- $enabled = get_pconfig(local_user(),'smileybutton','enable');
-
- $checked = (($enabled) ? ' checked="checked" ' : '');
-
- /* Add some HTML to the existing form */
-
- $s .= '<div class="settings-block">';
- $s .= '<h3>Smileybutton settings</h3>';
- $s .= '<div id="smileybutton-enable-wrapper">';
- $s .= '<label id="smileybutton-enable-label" for="smileybutton-checkbox">Enable Smileybutton Plugin</label>';
- $s .= '<input id="smileybutton-checkbox" type="checkbox" name="smileybutton" value="1" ' . $checked . '/>';
- $s .= '</div><div class="clear"></div>';
-
- /* provide a submit button */
-
- $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="smileybutton-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
+
+ //Get the correct image for the theme
+ $image = 'addon/smileybutton/view/'.current_theme().'.png';
+ if (! file_exists($image))
+ $image = 'addon/smileybutton/view/default.png';
+ $image_url = $a->get_baseurl().'/'.$image;
+
+ //Add the hmtl and script to the page
+ $b = <<< EOT
+ <div id="profile-smiley-wrapper" style="display: block;" >
+ <img src="$image_url" class="smiley_button" onclick="toggle_smileybutton()" alt="smiley">
+ </div>
+
+ <div id="smileybutton" style="display:none;">
+ $s
+ </div>
+
+ <script>
+ var smileybutton_is_shown = 0;
+ function toggle_smileybutton() {
+ if (! smileybutton_is_shown) {
+ $("#smileybutton").show();
+ smileybutton_is_shown = 1;
+ } else {
+ $("#smileybutton").hide();
+ smileybutton_is_shown = 0;
+ }
+ }