From 472072028560aa178211ae248fc0dad4526533c7 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sun, 22 Jul 2007 16:47:22 +0000 Subject: corrected ajax but introduced with prototype, tweaked how ajax stuff is done, now uses ajax:: class also replaced player with a logout icon --- lib/class/ajax.class.php | 104 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 lib/class/ajax.class.php (limited to 'lib/class/ajax.class.php') diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php new file mode 100644 index 00000000..8f68da98 --- /dev/null +++ b/lib/class/ajax.class.php @@ -0,0 +1,104 @@ +\n"; + $observe .= "\tEvent.observe('$source','$method',function(){" . $action . ";});\n"; + $observe .= "\n"; + + return $observe; + + } // observe + + /** + * button + * This prints out an img of the specified icon with the specified alt text + * and then sets up the required ajax for it + */ + public static function button($action,$icon,$alt,$source='',$post='') { + + $url = Config::get('ajax_url') . $action; + + // Define the Action that is going to be performed + if ($post) { + $ajax_string = "ajaxPost('$url','$post','$source')"; + } + else { + $ajax_string = "ajaxPut('$url','$source')"; + } + + $string = get_user_icon($icon,$alt,$source); + + $string .= self::observe($source,'click',$ajax_string); + + return $string; + + } // button + + /** + * text + * This prints out the specified text as a link and setups the required + * ajax for the link so it works correctly + */ + public static function text($action,$text,$source,$post='') { + + $url = Config::get('ajax_url') . $action; + + if ($post) { + $ajax_string = "ajaxPost('$url','$post','$source')"; + } + else { + $ajax_string = "ajaxPut('$url','$post','$source')"; + } + + // If we pass a source put it in the ID + $string = "$text\n"; + + $string .= self::observe($source,'click',$ajax_string); + + return $string; + + } // text + +} // end Ajax class +?> -- cgit