diff --git a/blog/wp-content/plugins/front-end-editor/admin.php b/blog/wp-content/plugins/front-end-editor/admin.php new file mode 100755 index 0000000..7009bcd --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/admin.php @@ -0,0 +1,147 @@ +textdomain = 'front-end-editor'; + + $this->args = array('page_title' => __('Front-end Editor', $this->textdomain)); + + $this->boxes = array( + array('fields', __('Fields', $this->textdomain), 'normal'), + array('settings', __('Settings', $this->textdomain), 'side'), + ); + } + + function page_head() { +?> + +options->disabled = $disabled; + + $this->admin_msg(); + } + + function fields_box() { + // Separate fields + $post_fields = $other_fields = array(); + foreach ( FEE_Core::get_fields() as $field => $args ) + if ( 'post' == call_user_func(array($args['class'], 'get_object_type') ) ) + $post_fields[$field] = $args; + else + $other_fields[$field] = $args; + + echo html('p', __('Enable or disable editable fields', $this->textdomain)); + + $tables = self::fields_table(__('Post fields', $this->textdomain), $post_fields); + $tables .= self::fields_table(__('Other fields', $this->textdomain), $other_fields); + + echo $this->form_wrap($tables, '', 'manage_fields'); + } + + private function fields_table($title, $fields) { + $thead = + html('thead', + html('tr', + html('th scope="col" class="check-column"', '') + .html('th scope="col"', $title) + ) + ); + + $tbody = ''; + foreach ( $fields as $field => $args ) + $tbody .= + html('tr', + html('th scope="row" class="check-column"', + $this->input(array( + 'type' => 'checkbox', + 'name' => $field, + 'checked' => ! @in_array($field, $this->options->disabled) + )) + ) + .html('td', $args['title']) + ); + + return html('table class="widefat"', $thead . $tbody); + } + + function settings_handler() { + if ( !isset($_POST['save_settings']) ) + return; + + foreach ( array('rich', 'chunks', 'reset_date', 'highlight', 'tooltip') as $key ) + $this->options->$key = (bool) @$_POST[$key]; + + $this->admin_msg(); + } + + function settings_box() { + $rows = array( + array( + 'desc' => __('Enable the WYSIWYG editor', $this->textdomain), + 'type' => 'checkbox', + 'name' => 'rich', + ), + + array( + 'desc' => __('Edit one paragraph at a time, instead of an entire post', $this->textdomain), + 'type' => 'checkbox', + 'name' => 'chunks', + ), + + array( + 'desc' => __('Reset the post date on each edit', $this->textdomain), + 'type' => 'checkbox', + 'name' => 'reset_date', + ), + + array( + 'desc' => __('Highlight editable elements', $this->textdomain), + 'type' => 'checkbox', + 'name' => 'highlight', + ), + array( + 'desc' => __('Display a tooltip above editable elements', $this->textdomain), + 'type' => 'checkbox', + 'name' => 'tooltip', + ), + ); + + $out = ''; + foreach ( $rows as $row ) + $out .= html('p', $this->input($row)); + + echo $this->form_wrap($out, '', 'save_settings'); + } +} + diff --git a/blog/wp-content/plugins/front-end-editor/core.php b/blog/wp-content/plugins/front-end-editor/core.php new file mode 100644 index 0000000..3cd0fe8 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/core.php @@ -0,0 +1,240 @@ +highlight ) + add_action('wp_head', array(__CLASS__, 'highlight')); + } + + static function highlight() { +?> + + $args ) + $field_types[$name] = $args['type']; + + $data = array( + 'save_text' => __('Save', 'front-end-editor'), + 'cancel_text' => __('Cancel', 'front-end-editor'), + 'fields' => $field_types, + 'ajax_url' => admin_url('admin-ajax.php'), + 'spinner' => admin_url('images/loading.gif'), + 'nonce' => wp_create_nonce(self::$nonce), + ); + + $css_dependencies = array(); + $js_dependencies = array('jquery'); + + // qTip + if ( self::$options->tooltip ) { + $data['tooltip'] = array( + 'icon' => $url . 'editor.png', + 'text' => __('Double-click to edit', 'front-end-editor') + ); + + wp_register_script('jquery-qtip', $url . "jquery.qtip$js_dev.js", array(), '1.0-rc3', true); + $js_dependencies[] = 'jquery-qtip'; + } + + // Autosuggest + if ( array_key_exists('terminput', $wrapped) ) { + $js_dependencies[] = 'suggest'; + } + + // Rich Editor + if ( array_key_exists('rich', $wrapped) ) { + $data['nicedit'] = apply_filters('front_end_editor_nicedit', array( + 'iconsPath' => $url . 'nicedit/nicEditorIcons.gif', + 'buttonList' => array( + 'bold', 'italic', 'strikethrough', + 'left','center', 'right', + 'fontFormat', 'fontFamily', 'forecolor', + 'removeformat', + 'ul', 'ol', + 'link', 'image', + 'xhtml' + ) + )); + + wp_register_script('nicedit', $url . "nicedit/nicEdit$js_dev.js", array(), '0.9r23', true); + $js_dependencies[] = 'nicedit'; + } + + // Thickbox + if ( array_key_exists('image', $wrapped) || array_key_exists('thumbnail', $wrapped) ) { + $data['admin_url'] = admin_url(); + + $data['image'] = array( + 'change' => __('Change Image', 'front-end-editor'), + 'revert' => '(' . __('Clear', 'front-end-editor') . ')', + 'tb_close' => get_bloginfo('wpurl') . '/wp-includes/js/thickbox/tb-close.png', + ); + + $css_dependencies[] = 'thickbox'; + $js_dependencies[] = 'thickbox'; + + wp_register_script('livequery', $url . 'livequery.js', array('jquery'), '1.1.0-pre', true); + $js_dependencies[] = 'livequery'; + } + + // Core script + wp_register_style('front-end-editor', $url . "editor$css_dev.css", $css_dependencies, self::$version); + wp_register_script('front-end-editor', $url . "editor$js_dev.js", $js_dependencies, self::$version, true); + +?> + + ucfirst(str_replace('_', ' ', $filter)), + 'type' => 'input', + 'priority' => 11, + 'argc' => 1 + )); + + self::$fields[$filter] = $args; + + return true; + } + + static function make_instances() { + self::$active_fields = self::get_fields(); + foreach ( (array) self::$options->disabled as $name ) + unset(self::$active_fields[$name]); + + foreach ( self::$active_fields as $name => $args ) { + extract($args); + + self::$instances[$name] = new $class($name, $type); + } + } + + static function add_filters() { + foreach ( self::$active_fields as $name => $args ) { + extract($args); + + $instance = self::$instances[$name]; + + add_filter($name, array($instance, 'wrap'), $priority, $argc); + } + } + + static function get_fields() { + return self::$fields; + } + + static function get_args($filter) { + return self::$fields[$filter]; + } + + static function ajax_response() { + // Is user trusted? + check_ajax_referer(self::$nonce, 'nonce'); + + $id = $_POST['item_id']; + $name = $_POST['name']; + $type = $_POST['type']; + $action = $_POST['callback']; + + // Is the current field defined? + if ( ! $instance = self::$instances[$name] ) + die(-1); + + // Does the user have the right to do this? + if ( ! $instance->check($id) || ! $instance->allow($id) ) + die(-1); + + $args = self::get_args($name); + + if ( $action == 'save' ) { + $content = stripslashes_deep($_POST['content']); + $result = $instance->save($id, $content); + $result = @apply_filters($name, $result); + } + elseif ( $action == 'get' ) { + $result = $instance->get($id); + + if ( $type == 'rich' ) + $result = wpautop($result); + } + + die($result); + } +} + +/* +Registers a new editable field + +@param string $filter +@param array $args( + 'class' => string The name of the field handler class (mandatory) + 'title' => string The user-friendly title (optional) + 'type' => string: 'input' | 'textarea' | 'rich' | 'image' (default: input) + 'priority' => integer (default: 11) + 'argc' => integer (default: 1) +) +*/ +function register_fronted_field() { + return FEE_Core::register(func_get_args()); +} + diff --git a/blog/wp-content/plugins/front-end-editor/editor/editor.css b/blog/wp-content/plugins/front-end-editor/editor/editor.css new file mode 100644 index 0000000..780d3de --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/editor.css @@ -0,0 +1 @@ +.fee-field,.fee-form{margin:0!important;padding:0!important;border-width:0!important;}div.fee-form,textarea.fee-form-content{clear:both!important;width:100%!important;}.fee-form-spinner{border:0!important;width:16px!important;height:16px!important;}div.fee-form button{margin-top:5px;}span.fee-form input{margin-right:5px;}.fee-form button+button{margin-left:5px;}.fee-form button{text-decoration:none!important;line-height:14px!important;font-size:11px!important;vertical-align:middle!important;padding:2px 8px!important;cursor:pointer!important;-moz-border-radius:11px;-khtml-border-radius:11px;-webkit-border-radius:11px;border-radius:11px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;-khtml-box-sizing:content-box;box-sizing:content-box;}button.fee-form-save{background-color:#23779f;color:#fff;border:1px solid #1c5e7f;font-weight:bold;}.fee-form-save:hover{border:1px solid #000!important;}button.fee-form-cancel{background-color:#fcfcfc;color:#808080;border:1px solid #ddd;}.fee-form-cancel:hover{border:1px solid #666!important;}.nicEdit-selected:focus{outline:none;}.fee-suggest-results{padding:0;margin:0;list-style:none;position:absolute;display:none;z-index:10000;border-width:1px;border-style:solid;}.fee-suggest-results li{padding:2px 5px;white-space:nowrap;text-align:left;}.fee-suggest-match{text-decoration:underline;}.fee-suggest-over{cursor:pointer;}.fee-suggest-results{background-color:#fff;border-color:#808080;}.fee-suggest-results li{color:#101010;}.fee-suggest-match{color:#000;}.fee-suggest-over{background-color:#f0f0b8;}#TB_window #TB_title{background-color:#222;color:#CFCFCF;height:27px;}#fee-img-revert{display:block;float:left;padding:6px 10px 0;}#fee-img-revert:link,#fee-img-revert:active,#fee-img-revert:visited{color:#21759B!important;}#fee-img-revert:hover{color:#D54E21!important;} \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/editor.dev.css b/blog/wp-content/plugins/front-end-editor/editor/editor.dev.css new file mode 100644 index 0000000..1cc9024 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/editor.dev.css @@ -0,0 +1,104 @@ +/* Main */ +.fee-field, .fee-form { + margin: 0 !important; + padding: 0 !important; + border-width: 0 !important; +} +div.fee-form, textarea.fee-form-content { + clear: both !important; + width: 100% !important; +} +.fee-form-spinner { + border: 0 !important; + width: 16px !important; + height: 16px !important; +} + +/* Buttons */ +div.fee-form button {margin-top: 5px} +span.fee-form input {margin-right: 5px} +.fee-form button + button {margin-left: 5px} + +.fee-form button { + text-decoration: none !important; + line-height: 14px !important; + font-size: 11px !important; + vertical-align: middle !important; + padding: 2px 8px !important; + cursor: pointer !important; + -moz-border-radius: 11px; + -khtml-border-radius: 11px; + -webkit-border-radius: 11px; + border-radius: 11px; + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + -khtml-box-sizing: content-box; + box-sizing: content-box; +} + +button.fee-form-save { + background-color: #23779f; + color: #fff; + border: 1px solid #1c5e7f; + font-weight: bold; +} + +.fee-form-save:hover { + border: 1px solid #000 !important; +} + +button.fee-form-cancel { + background-color: #fcfcfc; + color: #808080; + border: 1px solid #ddd; +} + +.fee-form-cancel:hover { + border: 1px solid #666 !important; +} + +/* Rich Editor */ +.nicEdit-selected:focus { + outline: none; +} + +/* Suggest */ +.fee-suggest-results { + padding: 0; + margin: 0; + list-style: none; + position: absolute; + display: none; + z-index: 10000; + border-width: 1px; + border-style: solid; +} +.fee-suggest-results li {padding: 2px 5px; white-space: nowrap; text-align: left} +.fee-suggest-match {text-decoration: underline} +.fee-suggest-over {cursor: pointer} + +/* Suggest colors */ +.fee-suggest-results {background-color: #fff; border-color: #808080} +.fee-suggest-results li {color: #101010} +.fee-suggest-match {color: #000} +.fee-suggest-over {background-color: #f0f0b8} + +/* Image */ +#TB_window #TB_title { + background-color: #222; + color: #CFCFCF; + height: 27px; +} + +#fee-img-revert { + display: block; + float: left; + padding: 6px 10px 0; +} +#fee-img-revert:link, #fee-img-revert:active, #fee-img-revert:visited { + color: #21759B !important; +} +#fee-img-revert:hover { + color: #D54E21 !important; +} + diff --git a/blog/wp-content/plugins/front-end-editor/editor/editor.dev.js b/blog/wp-content/plugins/front-end-editor/editor/editor.dev.js new file mode 100644 index 0000000..8778e32 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/editor.dev.js @@ -0,0 +1,669 @@ +(function($){ + + if ( FrontEndEditor._loaded ) + return; + FrontEndEditor._loaded = true; + + // http://ejohn.org/blog/simple-javascript-inheritance/ + // Inspired by base2 and Prototype + (function(){ + var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; + + // The base Class implementation (does nothing) + this.Class = function(){}; + + // Create a new Class that inherits from this class + Class.extend = function(prop) { + var _super = this.prototype; + + // Instantiate a base class (but only create the instance, + // don't run the init constructor) + initializing = true; + var prototype = new this(); + initializing = false; + + // Copy the properties over onto the new prototype + for (var name in prop) { + // Check if we're overwriting an existing function + prototype[name] = ( typeof prop[name] == "function" && + typeof _super[name] == "function" && fnTest.test(prop[name]) ) ? + (function(name, fn){ + return function() { + var tmp = this._super; + + // Add a new ._super() method that is the same method + // but on the super-class + this._super = _super[name]; + + // The method only need to be bound temporarily, so we + // remove it when we're done executing + var ret = fn.apply(this, arguments); + this._super = tmp; + + return ret; + }; + })(name, prop[name]) : + prop[name]; + } + + // The dummy class constructor + function Class() { + // All construction is actually done in the init method + if ( !initializing && this.init ) + this.init.apply(this, arguments); + } + + // Populate our constructed prototype object + Class.prototype = prototype; + + // Enforce the constructor to be what we expect + Class.constructor = Class; + + // And make this class extendable + Class.extend = arguments.callee; + + return Class; + }; + })(); + + +// _____Actual code starts here_____ + + + var spinner = $('').attr({ + 'src': FrontEndEditor.data.spinner, + 'class': 'front-editor-spinner' + }); + + var is_overlay = function($el) { + var attr = [$el.attr('id'), $el.attr("class"), $el.attr("rel")]; + + var tokens = ['lightbox', 'thickbox', 'shutter', 'awppost_link']; + + for ( var i in tokens ) + for ( var j in attr ) + if ( attr[j].indexOf(tokens[i]) != -1 ) + return true; + + return false; + }; + + var resume = function() { + if ( FrontEndEditor._trap ) + return; + + var $link = FrontEndEditor._to_click; + + if ( typeof $link == 'undefined' ) + return; + +/* + var ev_reference; + var ev_capture = function(ev) { ev_reference = ev; } + + var onClick = $link.attr('onclick'); + + $link.bind('click', ev_capture); + + if ( typeof onClick == 'function' ) + $link.bind('click', onClick); + + $link.click(); + + $link.unbind('click', ev_capture); + + if ( typeof onClick == 'function' ) + $link.unbind('click', onClick); + + if ( ev_reference.isDefaultPrevented() ) + return; +*/ + + if ( typeof $link.attr('href') != 'undefined' && $link.attr('href') != '#' ) { + if ( $link.attr('target') == '_blank' ) + window.open($link.attr('href')); + else + window.location.href = $link.attr('href'); + } + + delete FrontEndEditor._to_click; + }; + + var fieldTypes = {}; + + fieldTypes['base'] = Class.extend({ + + init: function($el, type, name, id) { + var self = this; + + self.set_el($el); + self.type = type; + self.name = name; + self.id = id; + + self.bind(self.el, 'click', self.click); + self.bind(self.el, 'dblclick', self.dblclick); + }, + + set_el: function($el) { + var self = this; + + self.el = $el; + + // From a > .front-ed > content + // To .front-ed > a > content + var $parent = self.el.parents('a'); + + if ( ! $parent.length ) + return; + + var $link = $parent.clone(true) + .html(self.el.html()); + + var $wrap = self.el.clone(true) + .html($link); + + $parent.replaceWith($wrap); + + self.el = $wrap; + self.switched = true; + }, + + click: function(ev) { +// if ( typeof FrontEndEditor._to_click != 'undefined' ) +// return; + + var $el = $(ev.target).closest('a'); + + if ( ! $el.length ) + return; + + if ( is_overlay($el) ) + return; + + ev.stopImmediatePropagation(); + ev.preventDefault(); + + FrontEndEditor._to_click = $el; + + setTimeout(resume, 300); + }, + + dblclick: function(ev) { + var self = this; + + ev.stopPropagation(); + ev.preventDefault(); + + FrontEndEditor._trap = true; + }, + + get_content: null /* function() */, + set_content: null /* function(content) */, + + ajax_get_handler: null /* function(content) */, + ajax_set_handler: null /* function(content) */, + + ajax_get: function() { + var self = this; + + var data = { + 'nonce': FrontEndEditor.data.nonce, + 'action': 'front-editor', + 'callback': 'get', + 'name': self.name, + 'type': self.type, + 'item_id': self.id + }; + + $.post(FrontEndEditor.data.ajax_url, data, function(response){ + self.ajax_get_handler(response); + }); + }, + + ajax_set: function(content) { + var self = this; + + content = content || self.get_content(); + + var data = { + 'nonce': FrontEndEditor.data.nonce, + 'action': 'front-editor', + 'callback': 'save', + 'name': self.name, + 'type': self.type, + 'item_id': self.id, + 'content': content + }; + + $.post(FrontEndEditor.data.ajax_url, data, function(response){ + self.ajax_set_handler(response); + }); + }, + + // Event utility: this = self + bind: function(element, event, callback) { + var self = this; + + element.bind(event, function(ev) { + callback.call(self, ev); + }); + } + }); + + fieldTypes['image'] = fieldTypes['base'].extend({ + + dblclick: function(ev) { + var self = this; + + self._super(ev); + + self.open_box(); + }, + + open_box: function() { + var self = this; + + tb_show(FrontEndEditor.data.image.change, FrontEndEditor.data.admin_url + + '/media-upload.php?post_id=0&type=image&TB_iframe=true&width=640&editable_image=1'); + + var $revert = $('').text(FrontEndEditor.data.image.revert); + + $revert.click(function(ev){ + self.ajax_set(-1); + }); + + $('#TB_ajaxWindowTitle').after($revert); + $('#TB_closeWindowButton img').attr('src', FrontEndEditor.data.image.tb_close); + + self.bind($('#TB_iframeContent'), 'load', self.replace_button); + }, + + replace_button: function(ev) { + var self = this; + + var $frame = $(ev.target).contents(); + + $('.media-item', $frame).livequery(function(){ + var $item = $(this); + var $button = $('').text(FrontEndEditor.data.image.change); + + $button.click(function(ev){ + self.ajax_set(self.get_content($item)); + }); + + $(this).find(':submit, #go_button').replaceWith($button); + }); + }, + + get_content: function($item) { + var $field; + + // Media library + $field = $item.find('.urlfile'); + if ( $field.length ) + return $field.attr('title'); + + // From URL (embed) + $field = $item.find('#embed-src'); + if ( $field.length ) + return $field.val(); + + // From URL + $field = $item.find('#src'); + if ( $field.length ) + return $field.val(); + + return false; + }, + + ajax_set_handler: function(url) { + var self = this; + + if ( url == -1 ) { + window.location.reload(true); + } else { + self.el.find('img').attr('src', url); + tb_remove(); + } + } + }); + + fieldTypes['thumbnail'] = fieldTypes['image'].extend({ + + replace_button: function(ev) { + var self = this; + + var $frame = $(ev.target).contents(); + + $frame.find('#tab-type_url').remove(); + + self._super(ev); + }, + + get_content: function($item) { + return $item.attr('id').replace('media-item-', ''); + } + }); + + fieldTypes['input'] = fieldTypes['base'].extend({ + + init: function($el, type, name, id) { + var self = this; + + self.spinner = spinner.clone(); + + self._super($el, type, name, id); + }, + + input_tag: '', + + create_input: function() { + var self = this; + + self.input = $(self.input_tag); + + self.input.attr({ + 'id': 'edit_' + self.el.attr('id'), + 'class': 'fee-form-content' + }).prependTo(self.form); + }, + + set_input: function(content) { + var self = this; + + self.input.val(content); + }, + + get_content: function() { + var self = this; + return self.input.val(); + }, + + set_content: function(content) { + var self = this; + + if ( self.switched ) + self.el.find('a').html(content); + else + self.el.html(content); + }, + + ajax_get: function() { + var self = this; + + self.el.hide().after(self.spinner.show()); + + self.create_input(); + + self._super(); + }, + + ajax_set: function() { + var self = this; + + self.el.before(self.spinner.show()); + + self._super(); + }, + + ajax_get_handler: function(content) { + var self = this; + + self.spinner.hide().replaceWith(self.form); + + self.set_input(content); + + self.input.focus(); + }, + + ajax_set_handler: function(content) { + var self = this; + + self.set_content(content); + + self.spinner.hide(); + self.el.show(); + }, + + dblclick: function(ev) { + var self = this; + + self._super(ev); + + self.form_handler(); + }, + + form_handler: function() { + var self = this; + + // Button actions + var form_remove = function(with_spinner) { + FrontEndEditor._trap = false; + + self.form.remove(); + + if ( with_spinner === true ) + self.el.before(self.spinner.show()); + else + self.el.show(); + + self.el.trigger('fee_remove_form'); + }; + + var form_submit = function() { + self.ajax_set(); + form_remove(true); + }; + + // Button markup + self.save_button = $('').addClass('fee-form-save').text(FrontEndEditor.data.save_text).click(form_submit); + self.cancel_button = $('').addClass('fee-form-cancel').text(FrontEndEditor.data.cancel_text).click(form_remove); + + // Create form + var inline = self.type == 'input' || self.type == 'terminput'; + + self.form = inline ? $('') : $(''); + + self.form + .addClass('fee-form') + .addClass('fee-type-' + self.type) + .addClass('fee-filter-' + self.name) + .append(self.save_button) + .append(self.cancel_button); + + self.bind(self.form, 'keypress', self.keypress); + + self.ajax_get(); + }, + + keypress: function(ev) { + var self = this; + + var keys = {ENTER: 13, ESCAPE: 27}; + var code = (ev.keyCode || ev.which || ev.charCode || 0); + + if ( code == keys.ENTER && self.type == 'input' ) + self.save_button.click(); + + if ( code == keys.ESCAPE ) + self.cancel_button.click(); + } + }); + + fieldTypes['terminput'] = fieldTypes['input'].extend({ + + set_input: function(content) { + var self = this; + + self._super(content); + + self.input.suggest(FrontEndEditor.data.ajax_url + '?action=ajax-tag-search&tax=' + self.id.split('#')[1], { + multiple: true, + resultsClass: 'fee-suggest-results', + selectClass: 'fee-suggest-over', + matchClass: 'fee-suggest-match' + }); + } + }); + + fieldTypes['textarea'] = fieldTypes['input'].extend({ + input_tag: '' + }); + + fieldTypes['rich'] = fieldTypes['textarea'].extend({ + + set_input: function(content) { + var self = this; + + self._super(content); + + self.editor = new nicEditor(FrontEndEditor.data.nicedit).panelInstance(self.input.attr('id')); + + self.form.find('.nicEdit-main').focus(); + }, + + get_content: function() { + var self = this; + return self.pre_wpautop(self.input.val()); + }, + + // Copied from wp-admin/js/editor.dev.js + pre_wpautop: function(content) { + var blocklist1, blocklist2; + + // Protect pre|script tags + content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { + a = a.replace(/[\r\n]*/g, ''); + return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, ''); + }); + + // Pretty it up for the source editor + blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset'; + content = content.replace(new RegExp('\\s*('+blocklist1+')>\\s*', 'g'), '$1>\n'); + content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'g'), '\n<$1>'); + + // Mark if it has any attributes. + content = content.replace(/(]+>.*?)<\/p>/g, '$1'); + + // Sepatate containing + content = content.replace(/]*)>\s*/gi, '\n\n'); + + // Remove and + content = content.replace(/\s*/gi, ''); + content = content.replace(/\s*<\/p>\s*/gi, '\n\n'); + content = content.replace(/\n[\s\u00a0]+\n/g, '\n\n'); + content = content.replace(/\s*\s*/gi, '\n'); + + // Fix some block element newline issues + content = content.replace(/\s*\s*/g, '\n'); + content = content.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n'); + content = content.replace(/caption\]\n\n+\[caption/g, 'caption]\n\n[caption'); + + blocklist2 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset'; + content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'g'), '\n<$1>'); + content = content.replace(new RegExp('\\s*('+blocklist2+')>\\s*', 'g'), '$1>\n'); + content = content.replace(/]*)>/g, '\t'); + + if ( content.indexOf('/g, function(a){ + return a.replace(/[\r\n]+/g, ''); + }); + } + + // Unmark special paragraph closing tags + content = content.replace(/<\/p#>/g, '\n'); + content = content.replace(/\s*(]+>[\s\S]*?<\/p>)/g, '\n$1'); + + // Trim whitespace + content = content.replace(/^\s+/, ''); + content = content.replace(/[\s\u00a0]+$/, ''); + + // put back the line breaks in pre|script + content = content.replace(//g, '\n'); + + return content; + }, + + ajax_set: function() { + var self = this; + + self.editor.nicInstances[0].saveContent(); + + self._super(); + } + }); + + // export + FrontEndEditor.fieldTypes = fieldTypes; + +$(document).ready(function($) { + // Widget fields hack: Add data-fee attr to each element + $('.fee-filter-widget_title, .fee-filter-widget_text').each(function() { + var $el = $(this); + var id = $el.parents('.widget').attr('id'); + + if ( id ) + $el.attr('data-fee', id); + else + // undo wrap; can't find widget id + $el.replaceWith($el.html()); + }); + + // Create field instances + $.each(FrontEndEditor.data.fields, function(name, type) { + $('.fee-filter-' + name).each(function() { + var $el = $(this); + + var id = $el.attr('data-fee'); + + var parts = id.split('#'); + + switch (name) { + case 'post_meta': type = parts[2]; break; + case 'editable_option': type = parts[1]; break; + } + + new fieldTypes[type]($el, type, name, id); + }); + }); + + // Tooltip init + if ( FrontEndEditor.data.tooltip ) { + $.fn.qtip.styles.fee = { + height: 10, + paddingTop: '4px', + paddingRight: '5px', + paddingBottom: '6px', + paddingLeft: '25px', + background: '#bbbebf url(' + FrontEndEditor.data.tooltip.icon + ') top left no-repeat', + color: '#ffffff', + textAlign: 'left', + lineHeight: '100%', + fontFamily: 'sans-serif', + fontSize: '14px', + opacity: '0.75', + border: { + width: 0, + radius: 5, + color: '#bbbebf' + }, + tip: 'bottomLeft', + name: 'dark' + }; + + $('.fee-field').qtip({ + content: FrontEndEditor.data.tooltip.text, + position: { corner: { target: 'topMiddle' }, adjust: { x: 0, y: -40 } }, + show: { + effect: 'fade' + }, + + style: { + name: 'fee' + } + }); + } +}); +})(jQuery); diff --git a/blog/wp-content/plugins/front-end-editor/editor/editor.js b/blog/wp-content/plugins/front-end-editor/editor/editor.js new file mode 100644 index 0000000..83ff808 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/editor.js @@ -0,0 +1 @@ +(function($){if(FrontEndEditor._loaded){return}FrontEndEditor._loaded=true;(function(){var initializing=false,fnTest=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(prop){var _super=this.prototype;initializing=true;var prototype=new this();initializing=false;for(var name in prop){prototype[name]=(typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name]))?(function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);this._super=tmp;return ret}})(name,prop[name]):prop[name]}function Class(){if(!initializing&&this.init){this.init.apply(this,arguments)}}Class.prototype=prototype;Class.constructor=Class;Class.extend=arguments.callee;return Class}})();var spinner=$("").attr({src:FrontEndEditor.data.spinner,"class":"front-editor-spinner"});var is_overlay=function($el){var attr=[$el.attr("id"),$el.attr("class"),$el.attr("rel")];var tokens=["lightbox","thickbox","shutter","awppost_link"];for(var i in tokens){for(var j in attr){if(attr[j].indexOf(tokens[i])!=-1){return true}}}return false};var resume=function(){if(FrontEndEditor._trap){return}var $link=FrontEndEditor._to_click;if(typeof $link=="undefined"){return}if(typeof $link.attr("href")!="undefined"&&$link.attr("href")!="#"){if($link.attr("target")=="_blank"){window.open($link.attr("href"))}else{window.location.href=$link.attr("href")}}delete FrontEndEditor._to_click};var fieldTypes={};fieldTypes.base=Class.extend({init:function($el,type,name,id){var self=this;self.set_el($el);self.type=type;self.name=name;self.id=id;self.bind(self.el,"click",self.click);self.bind(self.el,"dblclick",self.dblclick)},set_el:function($el){var self=this;self.el=$el;var $parent=self.el.parents("a");if(!$parent.length){return}var $link=$parent.clone(true).html(self.el.html());var $wrap=self.el.clone(true).html($link);$parent.replaceWith($wrap);self.el=$wrap;self.switched=true},click:function(ev){var $el=$(ev.target).closest("a");if(!$el.length){return}if(is_overlay($el)){return}ev.stopImmediatePropagation();ev.preventDefault();FrontEndEditor._to_click=$el;setTimeout(resume,300)},dblclick:function(ev){var self=this;ev.stopPropagation();ev.preventDefault();FrontEndEditor._trap=true},get_content:null,set_content:null,ajax_get_handler:null,ajax_set_handler:null,ajax_get:function(){var self=this;var data={nonce:FrontEndEditor.data.nonce,action:"front-editor",callback:"get",name:self.name,type:self.type,item_id:self.id};$.post(FrontEndEditor.data.ajax_url,data,function(response){self.ajax_get_handler(response)})},ajax_set:function(content){var self=this;content=content||self.get_content();var data={nonce:FrontEndEditor.data.nonce,action:"front-editor",callback:"save",name:self.name,type:self.type,item_id:self.id,content:content};$.post(FrontEndEditor.data.ajax_url,data,function(response){self.ajax_set_handler(response)})},bind:function(element,event,callback){var self=this;element.bind(event,function(ev){callback.call(self,ev)})}});fieldTypes.image=fieldTypes.base.extend({dblclick:function(ev){var self=this;self._super(ev);self.open_box()},open_box:function(){var self=this;tb_show(FrontEndEditor.data.image.change,FrontEndEditor.data.admin_url+"/media-upload.php?post_id=0&type=image&TB_iframe=true&width=640&editable_image=1");var $revert=$('').text(FrontEndEditor.data.image.revert);$revert.click(function(ev){self.ajax_set(-1)});$("#TB_ajaxWindowTitle").after($revert);$("#TB_closeWindowButton img").attr("src",FrontEndEditor.data.image.tb_close);self.bind($("#TB_iframeContent"),"load",self.replace_button)},replace_button:function(ev){var self=this;var $frame=$(ev.target).contents();$(".media-item",$frame).livequery(function(){var $item=$(this);var $button=$('').text(FrontEndEditor.data.image.change);$button.click(function(ev){self.ajax_set(self.get_content($item))});$(this).find(":submit, #go_button").replaceWith($button)})},get_content:function($item){var $field;$field=$item.find(".urlfile");if($field.length){return $field.attr("title")}$field=$item.find("#embed-src");if($field.length){return $field.val()}$field=$item.find("#src");if($field.length){return $field.val()}return false},ajax_set_handler:function(url){var self=this;if(url==-1){window.location.reload(true)}else{self.el.find("img").attr("src",url);tb_remove()}}});fieldTypes.thumbnail=fieldTypes.image.extend({replace_button:function(ev){var self=this;var $frame=$(ev.target).contents();$frame.find("#tab-type_url").remove();self._super(ev)},get_content:function($item){return $item.attr("id").replace("media-item-","")}});fieldTypes.input=fieldTypes.base.extend({init:function($el,type,name,id){var self=this;self.spinner=spinner.clone();self._super($el,type,name,id)},input_tag:'',create_input:function(){var self=this;self.input=$(self.input_tag);self.input.attr({id:"edit_"+self.el.attr("id"),"class":"fee-form-content"}).prependTo(self.form)},set_input:function(content){var self=this;self.input.val(content)},get_content:function(){var self=this;return self.input.val()},set_content:function(content){var self=this;if(self.switched){self.el.find("a").html(content)}else{self.el.html(content)}},ajax_get:function(){var self=this;self.el.hide().after(self.spinner.show());self.create_input();self._super()},ajax_set:function(){var self=this;self.el.before(self.spinner.show());self._super()},ajax_get_handler:function(content){var self=this;self.spinner.hide().replaceWith(self.form);self.set_input(content);self.input.focus()},ajax_set_handler:function(content){var self=this;self.set_content(content);self.spinner.hide();self.el.show()},dblclick:function(ev){var self=this;self._super(ev);self.form_handler()},form_handler:function(){var self=this;var form_remove=function(with_spinner){FrontEndEditor._trap=false;self.form.remove();if(with_spinner===true){self.el.before(self.spinner.show())}else{self.el.show()}self.el.trigger("fee_remove_form")};var form_submit=function(){self.ajax_set();form_remove(true)};self.save_button=$("").addClass("fee-form-save").text(FrontEndEditor.data.save_text).click(form_submit);self.cancel_button=$("").addClass("fee-form-cancel").text(FrontEndEditor.data.cancel_text).click(form_remove);var inline=self.type=="input"||self.type=="terminput";self.form=inline?$(""):$("");self.form.addClass("fee-form").addClass("fee-type-"+self.type).addClass("fee-filter-"+self.name).append(self.save_button).append(self.cancel_button);self.bind(self.form,"keypress",self.keypress);self.ajax_get()},keypress:function(ev){var self=this;var keys={ENTER:13,ESCAPE:27};var code=(ev.keyCode||ev.which||ev.charCode||0);if(code==keys.ENTER&&self.type=="input"){self.save_button.click()}if(code==keys.ESCAPE){self.cancel_button.click()}}});fieldTypes.terminput=fieldTypes.input.extend({set_input:function(content){var self=this;self._super(content);self.input.suggest(FrontEndEditor.data.ajax_url+"?action=ajax-tag-search&tax="+self.id.split("#")[1],{multiple:true,resultsClass:"fee-suggest-results",selectClass:"fee-suggest-over",matchClass:"fee-suggest-match"})}});fieldTypes.textarea=fieldTypes.input.extend({input_tag:''});fieldTypes.rich=fieldTypes.textarea.extend({set_input:function(content){var self=this;self._super(content);self.editor=new nicEditor(FrontEndEditor.data.nicedit).panelInstance(self.input.attr("id"));self.form.find(".nicEdit-main").focus()},get_content:function(){var self=this;return self.pre_wpautop(self.input.val())},pre_wpautop:function(content){var blocklist1,blocklist2;content=content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(a){a=a.replace(/[\r\n]*/g,"");return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"")});blocklist1="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset";content=content.replace(new RegExp("\\s*("+blocklist1+")>\\s*","g"),"$1>\n");content=content.replace(new RegExp("\\s*<(("+blocklist1+")[^>]*)>","g"),"\n<$1>");content=content.replace(/(]+>.*?)<\/p>/g,"$1");content=content.replace(/]*)>\s*/gi,"\n\n");content=content.replace(/\s*/gi,"");content=content.replace(/\s*<\/p>\s*/gi,"\n\n");content=content.replace(/\n[\s\u00a0]+\n/g,"\n\n");content=content.replace(/\s*\s*/gi,"\n");content=content.replace(/\s*\s*/g,"\n");content=content.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi,"\n\n[caption$1[/caption]\n\n");content=content.replace(/caption\]\n\n+\[caption/g,"caption]\n\n[caption");blocklist2="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset";content=content.replace(new RegExp("\\s*<(("+blocklist2+") ?[^>]*)\\s*>","g"),"\n<$1>");content=content.replace(new RegExp("\\s*("+blocklist2+")>\\s*","g"),"$1>\n");content=content.replace(/]*)>/g,"\t");if(content.indexOf("/g,function(a){return a.replace(/[\r\n]+/g,"")})}content=content.replace(/<\/p#>/g,"\n");content=content.replace(/\s*(]+>[\s\S]*?<\/p>)/g,"\n$1");content=content.replace(/^\s+/,"");content=content.replace(/[\s\u00a0]+$/,"");content=content.replace(//g,"\n");return content},ajax_set:function(){var self=this;self.editor.nicInstances[0].saveContent();self._super()}});FrontEndEditor.fieldTypes=fieldTypes;$(document).ready(function($){$(".fee-filter-widget_title, .fee-filter-widget_text").each(function(){var $el=$(this);var id=$el.parents(".widget").attr("id");if(id){$el.attr("data-fee",id)}else{$el.replaceWith($el.html())}});$.each(FrontEndEditor.data.fields,function(name,type){$(".fee-filter-"+name).each(function(){var $el=$(this);var id=$el.attr("data-fee");var parts=id.split("#");switch(name){case"post_meta":type=parts[2];break;case"editable_option":type=parts[1];break}new fieldTypes[type]($el,type,name,id)})});if(FrontEndEditor.data.tooltip){$.fn.qtip.styles.fee={height:10,paddingTop:"4px",paddingRight:"5px",paddingBottom:"6px",paddingLeft:"25px",background:"#bbbebf url("+FrontEndEditor.data.tooltip.icon+") top left no-repeat",color:"#ffffff",textAlign:"left",lineHeight:"100%",fontFamily:"sans-serif",fontSize:"14px",opacity:"0.75",border:{width:0,radius:5,color:"#bbbebf"},tip:"bottomLeft",name:"dark"};$(".fee-field").qtip({content:FrontEndEditor.data.tooltip.text,position:{corner:{target:"topMiddle"},adjust:{x:0,y:-40}},show:{effect:"fade"},style:{name:"fee"}})}})})(jQuery); \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/editor.png b/blog/wp-content/plugins/front-end-editor/editor/editor.png new file mode 100644 index 0000000..1bc05e8 Binary files /dev/null and b/blog/wp-content/plugins/front-end-editor/editor/editor.png differ diff --git a/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.dev.js b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.dev.js new file mode 100644 index 0000000..0258a66 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.dev.js @@ -0,0 +1,2149 @@ +/*! + * jquery.qtip. The jQuery tooltip plugin + * + * Copyright (c) 2009 Craig Thompson + * http://craigsworks.com + * + * Licensed under MIT + * http://www.opensource.org/licenses/mit-license.php + * + * Launch : February 2009 + * Version : 1.0.0-rc3 + * Released: Tuesday 12th May, 2009 - 00:00 + * Debug: jquery.qtip.debug.js + */ +(function($) +{ + // Implementation + $.fn.qtip = function(options, blanket) + { + var i, id, interfaces, opts, obj, command, config, api; + + // Return API / Interfaces if requested + if(typeof options == 'string') + { + // Make sure API data exists if requested + if(typeof $(this).data('qtip') !== 'object') + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.NO_TOOLTIP_PRESENT, false); + + // Return requested object + if(options == 'api') + return $(this).data('qtip').interfaces[ $(this).data('qtip').current ]; + else if(options == 'interfaces') + return $(this).data('qtip').interfaces; + } + + // Validate provided options + else + { + // Set null options object if no options are provided + if(!options) options = {}; + + // Sanitize option data + if(typeof options.content !== 'object' || (options.content.jquery && options.content.length > 0)) options.content = { text: options.content }; + if(typeof options.content.title !== 'object') options.content.title = { text: options.content.title }; + if(typeof options.position !== 'object') options.position = { corner: options.position }; + if(typeof options.position.corner !== 'object') options.position.corner = { target: options.position.corner, tooltip: options.position.corner }; + if(typeof options.show !== 'object') options.show = { when: options.show }; + if(typeof options.show.when !== 'object') options.show.when = { event: options.show.when }; + if(typeof options.show.effect !== 'object') options.show.effect = { type: options.show.effect }; + if(typeof options.hide !== 'object') options.hide = { when: options.hide }; + if(typeof options.hide.when !== 'object') options.hide.when = { event: options.hide.when }; + if(typeof options.hide.effect !== 'object') options.hide.effect = { type: options.hide.effect }; + if(typeof options.style !== 'object') options.style = { name: options.style }; + options.style = sanitizeStyle(options.style); + + // Build main options object + opts = $.extend(true, {}, $.fn.qtip.defaults, options); + + // Inherit all style properties into one syle object and include original options + opts.style = buildStyle.call({ options: opts }, opts.style); + opts.user = $.extend(true, {}, options); + }; + + // Iterate each matched element + return $(this).each(function() // Return original elements as per jQuery guidelines + { + // Check for API commands + if(typeof options == 'string') + { + command = options.toLowerCase(); + interfaces = $(this).qtip('interfaces'); + + // Make sure API data exists$('.qtip').qtip('destroy') + if(typeof interfaces == 'object') + { + // Check if API call is a BLANKET DESTROY command + if(blanket === true && command == 'destroy') + while(interfaces.length > 0) interfaces[interfaces.length-1].destroy(); + + // API call is not a BLANKET DESTROY command + else + { + // Check if supplied command effects this tooltip only (NOT BLANKET) + if(blanket !== true) interfaces = [ $(this).qtip('api') ]; + + // Execute command on chosen qTips + for(i = 0; i < interfaces.length; i++) + { + // Destroy command doesn't require tooltip to be rendered + if(command == 'destroy') interfaces[i].destroy(); + + // Only call API if tooltip is rendered and it wasn't a destroy call + else if(interfaces[i].status.rendered === true) + { + if(command == 'show') interfaces[i].show(); + else if(command == 'hide') interfaces[i].hide(); + else if(command == 'focus') interfaces[i].focus(); + else if(command == 'disable') interfaces[i].disable(true); + else if(command == 'enable') interfaces[i].disable(false); + }; + }; + }; + }; + } + + // No API commands, continue with qTip creation + else + { + // Create unique configuration object + config = $.extend(true, {}, opts); + config.hide.effect.length = opts.hide.effect.length; + config.show.effect.length = opts.show.effect.length; + + // Sanitize target options + if(config.position.container === false) config.position.container = $(document.body); + if(config.position.target === false) config.position.target = $(this); + if(config.show.when.target === false) config.show.when.target = $(this); + if(config.hide.when.target === false) config.hide.when.target = $(this); + + // Determine tooltip ID (Reuse array slots if possible) + id = $.fn.qtip.interfaces.length; + for(i = 0; i < id; i++) + { + if(typeof $.fn.qtip.interfaces[i] == 'undefined'){ id = i; break; }; + }; + + // Instantiate the tooltip + obj = new qTip($(this), config, id); + + // Add API references + $.fn.qtip.interfaces[id] = obj; + + // Check if element already has qTip data assigned + if( $(this).data('qtip') ) + { + // Set new current interface id + if(typeof $(this).attr('qtip') === 'undefined') + $(this).data('qtip').current = $(this).data('qtip').interfaces.length; + + // Push new API interface onto interfaces array + $(this).data('qtip').interfaces.push(obj); + } + + // No qTip data is present, create now + else $(this).data('qtip', { current: 0, interfaces: [obj] }); + + // If prerendering is disabled, create tooltip on showEvent + if(config.content.prerender === false && config.show.when.event !== false && config.show.ready !== true) + { + config.show.when.target.bind(config.show.when.event+'.qtip-'+id+'-create', { qtip: id }, function(event) + { + // Retrieve API interface via passed qTip Id + api = $.fn.qtip.interfaces[ event.data.qtip ]; + + // Unbind show event and cache mouse coords + api.options.show.when.target.unbind(api.options.show.when.event+'.qtip-'+event.data.qtip+'-create'); + api.cache.mouse = { x: event.pageX, y: event.pageY }; + + // Render tooltip and start the event sequence + construct.call( api ); + api.options.show.when.target.trigger(api.options.show.when.event); + }); + } + + // Prerendering is enabled, create tooltip now + else + { + // Set mouse position cache to top left of the element + obj.cache.mouse = { + x: config.show.when.target.offset().left, + y: config.show.when.target.offset().top + }; + + // Construct the tooltip + construct.call(obj); + } + }; + }); + }; + + // Instantiator + function qTip(target, options, id) + { + // Declare this reference + var self = this; + + // Setup class attributes + self.id = id; + self.options = options; + self.status = { + animated: false, + rendered: false, + disabled: false, + focused: false + }; + self.elements = { + target: target.addClass(self.options.style.classes.target), + tooltip: null, + wrapper: null, + content: null, + contentWrapper: null, + title: null, + button: null, + tip: null, + bgiframe: null + }; + self.cache = { + mouse: {}, + position: {}, + toggle: 0 + }; + self.timers = {}; + + // Define exposed API methods + $.extend(self, self.options.api, + { + show: function(event) + { + var returned, solo; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'show'); + + // Only continue if element is visible + if(self.elements.tooltip.css('display') !== 'none') return self; + + // Clear animation queue + self.elements.tooltip.stop(true, false); + + // Call API method and if return value is false, halt + returned = self.beforeShow.call(self, event); + if(returned === false) return self; + + // Define afterShow callback method + function afterShow() + { + // Call API method and focus if it isn't static + if(self.options.position.type !== 'static') self.focus(); + self.onShow.call(self, event); + + // Prevent antialias from disappearing in IE7 by removing filter attribute + if($.browser.msie) self.elements.tooltip.get(0).style.removeAttribute('filter'); + }; + + // Maintain toggle functionality if enabled + self.cache.toggle = 1; + + // Update tooltip position if it isn't static + if(self.options.position.type !== 'static') + self.updatePosition(event, (self.options.show.effect.length > 0)); + + // Hide other tooltips if tooltip is solo + if(typeof self.options.show.solo == 'object') solo = $(self.options.show.solo); + else if(self.options.show.solo === true) solo = $('div.qtip').not(self.elements.tooltip); + if(solo) solo.each(function(){ if($(this).qtip('api').status.rendered === true) $(this).qtip('api').hide(); }); + + // Show tooltip + if(typeof self.options.show.effect.type == 'function') + { + self.options.show.effect.type.call(self.elements.tooltip, self.options.show.effect.length); + self.elements.tooltip.queue(function(){ afterShow(); $(this).dequeue(); }); + } + else + { + switch(self.options.show.effect.type.toLowerCase()) + { + case 'fade': + self.elements.tooltip.fadeIn(self.options.show.effect.length, afterShow); + break; + case 'slide': + self.elements.tooltip.slideDown(self.options.show.effect.length, function() + { + afterShow(); + if(self.options.position.type !== 'static') self.updatePosition(event, true); + }); + break; + case 'grow': + self.elements.tooltip.show(self.options.show.effect.length, afterShow); + break; + default: + self.elements.tooltip.show(null, afterShow); + break; + }; + + // Add active class to tooltip + self.elements.tooltip.addClass(self.options.style.classes.active); + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_SHOWN, 'show'); + }, + + hide: function(event) + { + var returned; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'hide'); + + // Only continue if element is visible + else if(self.elements.tooltip.css('display') === 'none') return self; + + // Stop show timer and animation queue + clearTimeout(self.timers.show); + self.elements.tooltip.stop(true, false); + + // Call API method and if return value is false, halt + returned = self.beforeHide.call(self, event); + if(returned === false) return self; + + // Define afterHide callback method + function afterHide(){ self.onHide.call(self, event); }; + + // Maintain toggle functionality if enabled + self.cache.toggle = 0; + + // Hide tooltip + if(typeof self.options.hide.effect.type == 'function') + { + self.options.hide.effect.type.call(self.elements.tooltip, self.options.hide.effect.length); + self.elements.tooltip.queue(function(){ afterHide(); $(this).dequeue(); }); + } + else + { + switch(self.options.hide.effect.type.toLowerCase()) + { + case 'fade': + self.elements.tooltip.fadeOut(self.options.hide.effect.length, afterHide); + break; + case 'slide': + self.elements.tooltip.slideUp(self.options.hide.effect.length, afterHide); + break; + case 'grow': + self.elements.tooltip.hide(self.options.hide.effect.length, afterHide); + break; + default: + self.elements.tooltip.hide(null, afterHide); + break; + }; + + // Remove active class to tooltip + self.elements.tooltip.removeClass(self.options.style.classes.active); + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_HIDDEN, 'hide'); + }, + + updatePosition: function(event, animate) + { + var i, target, tooltip, coords, mapName, imagePos, newPosition, ieAdjust, ie6Adjust, borderAdjust, mouseAdjust, offset, curPosition, returned + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updatePosition'); + + // If tooltip is static, return + else if(self.options.position.type == 'static') + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.CANNOT_POSITION_STATIC, 'updatePosition'); + + // Define property objects + target = { + position: { left: 0, top: 0 }, + dimensions: { height: 0, width: 0 }, + corner: self.options.position.corner.target + }; + tooltip = { + position: self.getPosition(), + dimensions: self.getDimensions(), + corner: self.options.position.corner.tooltip + }; + + // Target is an HTML element + if(self.options.position.target !== 'mouse') + { + // If the HTML element is AREA, calculate position manually + if(self.options.position.target.get(0).nodeName.toLowerCase() == 'area') + { + // Retrieve coordinates from coords attribute and parse into integers + coords = self.options.position.target.attr('coords').split(','); + for(i = 0; i < coords.length; i++) coords[i] = parseInt(coords[i]); + + // Setup target position object + mapName = self.options.position.target.parent('map').attr('name'); + imagePos = $('img[usemap="#'+mapName+'"]:first').offset(); + target.position = { + left: Math.floor(imagePos.left + coords[0]), + top: Math.floor(imagePos.top + coords[1]) + }; + + // Determine width and height of the area + switch(self.options.position.target.attr('shape').toLowerCase()) + { + case 'rect': + target.dimensions = { + width: Math.ceil(Math.abs(coords[2] - coords[0])), + height: Math.ceil(Math.abs(coords[3] - coords[1])) + }; + break; + + case 'circle': + target.dimensions = { + width: coords[2] + 1, + height: coords[2] + 1 + }; + break; + + case 'poly': + target.dimensions = { + width: coords[0], + height: coords[1] + }; + + for(i = 0; i < coords.length; i++) + { + if(i % 2 == 0) + { + if(coords[i] > target.dimensions.width) + target.dimensions.width = coords[i]; + if(coords[i] < coords[0]) + target.position.left = Math.floor(imagePos.left + coords[i]); + } + else + { + if(coords[i] > target.dimensions.height) + target.dimensions.height = coords[i]; + if(coords[i] < coords[1]) + target.position.top = Math.floor(imagePos.top + coords[i]); + }; + }; + + target.dimensions.width = target.dimensions.width - (target.position.left - imagePos.left); + target.dimensions.height = target.dimensions.height - (target.position.top - imagePos.top); + break; + + default: + return $.fn.qtip.log.error.call(self, 4, $.fn.qtip.constants.INVALID_AREA_SHAPE, 'updatePosition'); + break; + }; + + // Adjust position by 2 pixels (Positioning bug?) + target.dimensions.width -= 2; target.dimensions.height -= 2; + } + + // Target is the document + else if(self.options.position.target.add(document.body).length === 1) + { + target.position = { left: $(document).scrollLeft(), top: $(document).scrollTop() }; + target.dimensions = { height: $(window).height(), width: $(window).width() }; + } + + // Target is a regular HTML element, find position normally + else + { + // Check if the target is another tooltip. If its animated, retrieve position from newPosition data + if(typeof self.options.position.target.attr('qtip') !== 'undefined') + target.position = self.options.position.target.qtip('api').cache.position; + else + target.position = self.options.position.target.offset(); + + // Setup dimensions objects + target.dimensions = { + height: self.options.position.target.outerHeight(), + width: self.options.position.target.outerWidth() + }; + }; + + // Calculate correct target corner position + newPosition = $.extend({}, target.position); + if(target.corner.search(/right/i) !== -1) + newPosition.left += target.dimensions.width; + + if(target.corner.search(/bottom/i) !== -1) + newPosition.top += target.dimensions.height; + + if(target.corner.search(/((top|bottom)Middle)|center/) !== -1) + newPosition.left += (target.dimensions.width / 2); + + if(target.corner.search(/((left|right)Middle)|center/) !== -1) + newPosition.top += (target.dimensions.height / 2); + } + + // Mouse is the target, set position to current mouse coordinates + else + { + // Setup target position and dimensions objects + target.position = newPosition = { left: self.cache.mouse.x, top: self.cache.mouse.y }; + target.dimensions = { height: 1, width: 1 }; + }; + + // Calculate correct target corner position + if(tooltip.corner.search(/right/i) !== -1) + newPosition.left -= tooltip.dimensions.width; + + if(tooltip.corner.search(/bottom/i) !== -1) + newPosition.top -= tooltip.dimensions.height; + + if(tooltip.corner.search(/((top|bottom)Middle)|center/) !== -1) + newPosition.left -= (tooltip.dimensions.width / 2); + + if(tooltip.corner.search(/((left|right)Middle)|center/) !== -1) + newPosition.top -= (tooltip.dimensions.height / 2); + + // Setup IE adjustment variables (Pixel gap bugs) + ieAdjust = ($.browser.msie) ? 1 : 0; // And this is why I hate IE... + ie6Adjust = ($.browser.msie && parseInt($.browser.version.charAt(0)) === 6) ? 1 : 0; // ...and even more so IE6! + + // Adjust for border radius + if(self.options.style.border.radius > 0) + { + if(tooltip.corner.search(/Left/) !== -1) + newPosition.left -= self.options.style.border.radius; + else if(tooltip.corner.search(/Right/) !== -1) + newPosition.left += self.options.style.border.radius; + + if(tooltip.corner.search(/Top/) !== -1) + newPosition.top -= self.options.style.border.radius; + else if(tooltip.corner.search(/Bottom/) !== -1) + newPosition.top += self.options.style.border.radius; + }; + + // IE only adjustments (Pixel perfect!) + if(ieAdjust) + { + if(tooltip.corner.search(/top/) !== -1) + newPosition.top -= ieAdjust + else if(tooltip.corner.search(/bottom/) !== -1) + newPosition.top += ieAdjust + + if(tooltip.corner.search(/left/) !== -1) + newPosition.left -= ieAdjust + else if(tooltip.corner.search(/right/) !== -1) + newPosition.left += ieAdjust + + if(tooltip.corner.search(/leftMiddle|rightMiddle/) !== -1) + newPosition.top -= 1 + }; + + // If screen adjustment is enabled, apply adjustments + if(self.options.position.adjust.screen === true) + newPosition = screenAdjust.call(self, newPosition, target, tooltip); + + // If mouse is the target, prevent tooltip appearing directly under the mouse + if(self.options.position.target === 'mouse' && self.options.position.adjust.mouse === true) + { + if(self.options.position.adjust.screen === true && self.elements.tip) + mouseAdjust = self.elements.tip.attr('rel'); + else + mouseAdjust = self.options.position.corner.tooltip; + + newPosition.left += (mouseAdjust.search(/right/i) !== -1) ? -6 : 6; + newPosition.top += (mouseAdjust.search(/bottom/i) !== -1) ? -6 : 6; + } + + // Initiate bgiframe plugin in IE6 if tooltip overlaps a select box or object element + if(!self.elements.bgiframe && $.browser.msie && parseInt($.browser.version.charAt(0)) == 6) + { + $('select, object').each(function() + { + offset = $(this).offset(); + offset.bottom = offset.top + $(this).height(); + offset.right = offset.left + $(this).width(); + + if(newPosition.top + tooltip.dimensions.height >= offset.top + && newPosition.left + tooltip.dimensions.width >= offset.left) + bgiframe.call(self); + }); + }; + + // Add user xy adjustments + newPosition.left += self.options.position.adjust.x; + newPosition.top += self.options.position.adjust.y; + + // Set new tooltip position if its moved, animate if enabled + curPosition = self.getPosition(); + if(newPosition.left != curPosition.left || newPosition.top != curPosition.top) + { + // Call API method and if return value is false, halt + returned = self.beforePositionUpdate.call(self, event); + if(returned === false) return self; + + // Cache new position + self.cache.position = newPosition; + + // Check if animation is enabled + if(animate === true) + { + // Set animated status + self.status.animated = true; + + // Animate and reset animated status on animation end + self.elements.tooltip.animate(newPosition, 200, 'swing', function(){ self.status.animated = false }); + } + + // Set new position via CSS + else self.elements.tooltip.css(newPosition); + + // Call API method and log event if its not a mouse move + self.onPositionUpdate.call(self, event); + if(typeof event !== 'undefined' && event.type && event.type !== 'mousemove') + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_POSITION_UPDATED, 'updatePosition'); + }; + + return self; + }, + + updateWidth: function(newWidth) + { + var hidden; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateWidth'); + + // Make sure supplied width is a number and if not, return + else if(newWidth && typeof newWidth !== 'number') + return $.fn.qtip.log.error.call(self, 2, 'newWidth must be of type number', 'updateWidth'); + + // Setup elements which must be hidden during width update + hidden = self.elements.contentWrapper.siblings().add(self.elements.tip).add(self.elements.button); + + // Calculate the new width if one is not supplied + if(!newWidth) + { + // Explicit width is set + if(typeof self.options.style.width.value == 'number') + newWidth = self.options.style.width.value; + + // No width is set, proceed with auto detection + else + { + // Set width to auto initally to determine new width and hide other elements + self.elements.tooltip.css({ width: 'auto' }); + hidden.hide(); + + // Set position and zoom to defaults to prevent IE hasLayout bug + if($.browser.msie) + self.elements.wrapper.add(self.elements.contentWrapper.children()).css({ zoom: 'normal' }); + + // Set the new width + newWidth = self.getDimensions().width + 1; + + // Make sure its within the maximum and minimum width boundries + if(!self.options.style.width.value) + { + if(newWidth > self.options.style.width.max) newWidth = self.options.style.width.max + if(newWidth < self.options.style.width.min) newWidth = self.options.style.width.min + }; + }; + }; + + // Adjust newWidth by 1px if width is odd (IE6 rounding bug fix) + if(newWidth % 2 !== 0) newWidth -= 1; + + // Set the new calculated width and unhide other elements + self.elements.tooltip.width(newWidth); + hidden.show(); + + // Set the border width, if enabled + if(self.options.style.border.radius) + { + self.elements.tooltip.find('.qtip-betweenCorners').each(function(i) + { + $(this).width(newWidth - (self.options.style.border.radius * 2)); + }) + }; + + // IE only adjustments + if($.browser.msie) + { + // Reset position and zoom to give the wrapper layout (IE hasLayout bug) + self.elements.wrapper.add(self.elements.contentWrapper.children()).css({ zoom: '1' }); + + // Set the new width + self.elements.wrapper.width(newWidth); + + // Adjust BGIframe height and width if enabled + if(self.elements.bgiframe) self.elements.bgiframe.width(newWidth).height(self.getDimensions.height); + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_WIDTH_UPDATED, 'updateWidth'); + }, + + updateStyle: function(name) + { + var tip, borders, context, corner, coordinates; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateStyle'); + + // Return if style is not defined or name is not a string + else if(typeof name !== 'string' || !$.fn.qtip.styles[name]) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.STYLE_NOT_DEFINED, 'updateStyle'); + + // Set the new style object + self.options.style = buildStyle.call(self, $.fn.qtip.styles[name], self.options.user.style); + + // Update initial styles of content and title elements + self.elements.content.css( jQueryStyle(self.options.style) ); + if(self.options.content.title.text !== false) + self.elements.title.css( jQueryStyle(self.options.style.title, true) ); + + // Update CSS border colour + self.elements.contentWrapper.css({ borderColor: self.options.style.border.color }); + + // Update tip color if enabled + if(self.options.style.tip.corner !== false) + { + if($('').get(0).getContext) + { + // Retrieve canvas context and clear + tip = self.elements.tooltip.find('.qtip-tip canvas:first'); + context = tip.get(0).getContext('2d'); + context.clearRect(0,0,300,300); + + // Draw new tip + corner = tip.parent('div[rel]:first').attr('rel'); + coordinates = calculateTip(corner, self.options.style.tip.size.width, self.options.style.tip.size.height); + drawTip.call(self, tip, coordinates, self.options.style.tip.color || self.options.style.border.color); + } + else if($.browser.msie) + { + // Set new fillcolor attribute + tip = self.elements.tooltip.find('.qtip-tip [nodeName="shape"]'); + tip.attr('fillcolor', self.options.style.tip.color || self.options.style.border.color); + }; + }; + + // Update border colors if enabled + if(self.options.style.border.radius > 0) + { + self.elements.tooltip.find('.qtip-betweenCorners').css({ backgroundColor: self.options.style.border.color }); + + if($('').get(0).getContext) + { + borders = calculateBorders(self.options.style.border.radius) + self.elements.tooltip.find('.qtip-wrapper canvas').each(function() + { + // Retrieve canvas context and clear + context = $(this).get(0).getContext('2d'); + context.clearRect(0,0,300,300); + + // Draw new border + corner = $(this).parent('div[rel]:first').attr('rel') + drawBorder.call(self, $(this), borders[corner], + self.options.style.border.radius, self.options.style.border.color); + }); + } + else if($.browser.msie) + { + // Set new fillcolor attribute on each border corner + self.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function() + { + $(this).attr('fillcolor', self.options.style.border.color) + }); + }; + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_STYLE_UPDATED, 'updateStyle'); + }, + + updateContent: function(content, reposition) + { + var parsedContent, images, loadedImages; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateContent'); + + // Make sure content is defined before update + else if(!content) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.NO_CONTENT_PROVIDED, 'updateContent'); + + // Call API method and set new content if a string is returned + parsedContent = self.beforeContentUpdate.call(self, content); + if(typeof parsedContent == 'string') content = parsedContent; + else if(parsedContent === false) return; + + // Set position and zoom to defaults to prevent IE hasLayout bug + if($.browser.msie) self.elements.contentWrapper.children().css({ zoom: 'normal' }); + + // Append new content if its a DOM array and show it if hidden + if(content.jquery && content.length > 0) + content.clone(true).appendTo(self.elements.content).show(); + + // Content is a regular string, insert the new content + else self.elements.content.html(content); + + // Check if images need to be loaded before position is updated to prevent mis-positioning + images = self.elements.content.find('img[complete=false]'); + if(images.length > 0) + { + loadedImages = 0; + images.each(function(i) + { + $('') + .load(function(){ if(++loadedImages == images.length) afterLoad(); }); + }); + } + else afterLoad(); + + function afterLoad() + { + // Update the tooltip width + self.updateWidth(); + + // If repositioning is enabled, update positions + if(reposition !== false) + { + // Update position if tooltip isn't static + if(self.options.position.type !== 'static') + self.updatePosition(self.elements.tooltip.is(':visible'), true); + + // Reposition the tip if enabled + if(self.options.style.tip.corner !== false) + positionTip.call(self); + }; + }; + + // Call API method and log event + self.onContentUpdate.call(self); + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_CONTENT_UPDATED, 'loadContent'); + }, + + loadContent: function(url, data, method) + { + var returned; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'loadContent'); + + // Call API method and if return value is false, halt + returned = self.beforeContentLoad.call(self); + if(returned === false) return self; + + // Load content using specified request type + if(method == 'post') + $.post(url, data, setupContent); + else + $.get(url, data, setupContent); + + function setupContent(content) + { + // Call API method and log event + self.onContentLoad.call(self); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_CONTENT_LOADED, 'loadContent'); + + // Update the content + self.updateContent(content); + }; + + return self; + }, + + updateTitle: function(content) + { + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateTitle'); + + // Make sure content is defined before update + else if(!content) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.NO_CONTENT_PROVIDED, 'updateTitle'); + + // Call API method and if return value is false, halt + returned = self.beforeTitleUpdate.call(self); + if(returned === false) return self; + + // Set the new content and reappend the button if enabled + if(self.elements.button) self.elements.button = self.elements.button.clone(true); + self.elements.title.html(content) + if(self.elements.button) self.elements.title.prepend(self.elements.button); + + // Call API method and log event + self.onTitleUpdate.call(self); + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_TITLE_UPDATED, 'updateTitle'); + }, + + focus: function(event) + { + var curIndex, newIndex, elemIndex, returned; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'focus'); + + else if(self.options.position.type == 'static') + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.CANNOT_FOCUS_STATIC, 'focus'); + + // Set z-index variables + curIndex = parseInt( self.elements.tooltip.css('z-index') ); + newIndex = 6000 + $('div.qtip[qtip]').length - 1; + + // Only update the z-index if it has changed and tooltip is not already focused + if(!self.status.focused && curIndex !== newIndex) + { + // Call API method and if return value is false, halt + returned = self.beforeFocus.call(self, event); + if(returned === false) return self; + + // Loop through all other tooltips + $('div.qtip[qtip]').not(self.elements.tooltip).each(function() + { + if($(this).qtip('api').status.rendered === true) + { + elemIndex = parseInt($(this).css('z-index')); + + // Reduce all other tooltip z-index by 1 + if(typeof elemIndex == 'number' && elemIndex > -1) + $(this).css({ zIndex: parseInt( $(this).css('z-index') ) - 1 }); + + // Set focused status to false + $(this).qtip('api').status.focused = false; + } + }) + + // Set the new z-index and set focus status to true + self.elements.tooltip.css({ zIndex: newIndex }); + self.status.focused = true; + + // Call API method and log event + self.onFocus.call(self, event); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_FOCUSED, 'focus'); + }; + + return self; + }, + + disable: function(state) + { + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'disable'); + + if(state) + { + // Tooltip is not already disabled, proceed + if(!self.status.disabled) + { + // Set the disabled flag and log event + self.status.disabled = true; + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_DISABLED, 'disable'); + } + + // Tooltip is already disabled, inform user via log + else $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED, 'disable'); + } + else + { + // Tooltip is not already enabled, proceed + if(self.status.disabled) + { + // Reassign events, set disable status and log + self.status.disabled = false; + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_ENABLED, 'disable'); + } + + // Tooltip is already enabled, inform the user via log + else $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED, 'disable'); + }; + + return self; + }, + + destroy: function() + { + var i, returned, interfaces; + + // Call API method and if return value is false, halt + returned = self.beforeDestroy.call(self); + if(returned === false) return self; + + // Check if tooltip is rendered + if(self.status.rendered) + { + // Remove event handlers and remove element + self.options.show.when.target.unbind('mousemove.qtip', self.updatePosition); + self.options.show.when.target.unbind('mouseout.qtip', self.hide); + self.options.show.when.target.unbind(self.options.show.when.event + '.qtip'); + self.options.hide.when.target.unbind(self.options.hide.when.event + '.qtip'); + self.elements.tooltip.unbind(self.options.hide.when.event + '.qtip'); + self.elements.tooltip.unbind('mouseover.qtip', self.focus); + self.elements.tooltip.remove(); + } + + // Tooltip isn't yet rendered, remove render event + else self.options.show.when.target.unbind(self.options.show.when.event+'.qtip-create'); + + // Check to make sure qTip data is present on target element + if(typeof self.elements.target.data('qtip') == 'object') + { + // Remove API references from interfaces object + interfaces = self.elements.target.data('qtip').interfaces; + if(typeof interfaces == 'object' && interfaces.length > 0) + { + // Remove API from interfaces array + for(i = 0; i < interfaces.length - 1; i++) + if(interfaces[i].id == self.id) interfaces.splice(i, 1) + } + } + delete $.fn.qtip.interfaces[self.id]; + + // Set qTip current id to previous tooltips API if available + if(typeof interfaces == 'object' && interfaces.length > 0) + self.elements.target.data('qtip').current = interfaces.length -1; + else + self.elements.target.removeData('qtip'); + + // Call API method and log destroy + self.onDestroy.call(self); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_DESTROYED, 'destroy'); + + return self.elements.target + }, + + getPosition: function() + { + var show, offset; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'getPosition'); + + show = (self.elements.tooltip.css('display') !== 'none') ? false : true; + + // Show and hide tooltip to make sure coordinates are returned + if(show) self.elements.tooltip.css({ visiblity: 'hidden' }).show(); + offset = self.elements.tooltip.offset(); + if(show) self.elements.tooltip.css({ visiblity: 'visible' }).hide(); + + return offset; + }, + + getDimensions: function() + { + var show, dimensions; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'getDimensions'); + + show = (!self.elements.tooltip.is(':visible')) ? true : false; + + // Show and hide tooltip to make sure dimensions are returned + if(show) self.elements.tooltip.css({ visiblity: 'hidden' }).show(); + dimensions = { + height: self.elements.tooltip.outerHeight(), + width: self.elements.tooltip.outerWidth() + }; + if(show) self.elements.tooltip.css({ visiblity: 'visible' }).hide(); + + return dimensions; + } + }); + }; + + // Define priamry construct function + function construct() + { + var self, adjust, content, url, data, method, tempLength; + self = this; + + // Call API method + self.beforeRender.call(self); + + // Set rendered status to true + self.status.rendered = true; + + // Create initial tooltip elements + self.elements.tooltip = '' + + ' ' + + ' ' + + ' ' + + ''; + + // Append to container element + self.elements.tooltip = $(self.elements.tooltip); + self.elements.tooltip.appendTo(self.options.position.container) + + // Setup tooltip qTip data + self.elements.tooltip.data('qtip', { current: 0, interfaces: [self] }); + + // Setup element references + self.elements.wrapper = self.elements.tooltip.children('div:first'); + self.elements.contentWrapper = self.elements.wrapper.children('div:first').css({ background: self.options.style.background }); + self.elements.content = self.elements.contentWrapper.children('div:first').css( jQueryStyle(self.options.style) ); + + // Apply IE hasLayout fix to wrapper and content elements + if($.browser.msie) self.elements.wrapper.add(self.elements.content).css({ zoom: 1 }); + + // Setup tooltip attributes + if(self.options.hide.when.event == 'unfocus') self.elements.tooltip.attr('unfocus', true); + + // If an explicit width is set, updateWidth prior to setting content to prevent dirty rendering + if(typeof self.options.style.width.value == 'number') self.updateWidth(); + + // Create borders and tips if supported by the browser + if($('').get(0).getContext || $.browser.msie) + { + // Create border + if(self.options.style.border.radius > 0) + createBorder.call(self); + else + self.elements.contentWrapper.css({ border: self.options.style.border.width+'px solid '+self.options.style.border.color }); + + // Create tip if enabled + if(self.options.style.tip.corner !== false) + createTip.call(self); + } + + // Neither canvas or VML is supported, tips and borders cannot be drawn! + else + { + // Set defined border width + self.elements.contentWrapper.css({ border: self.options.style.border.width+'px solid '+self.options.style.border.color }); + + // Reset border radius and tip + self.options.style.border.radius = 0; + self.options.style.tip.corner = false; + + // Inform via log + $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED, 'render'); + }; + + // Use the provided content string or DOM array + if((typeof self.options.content.text == 'string' && self.options.content.text.length > 0) + || (self.options.content.text.jquery && self.options.content.text.length > 0)) + content = self.options.content.text; + + // Use title string for content if present + else if(typeof self.elements.target.attr('title') == 'string' && self.elements.target.attr('title').length > 0) + { + content = self.elements.target.attr('title').replace("\\n", ''); + self.elements.target.attr('title', ''); // Remove title attribute to prevent default tooltip showing + } + + // No title is present, use alt attribute instead + else if(typeof self.elements.target.attr('alt') == 'string' && self.elements.target.attr('alt').length > 0) + { + content = self.elements.target.attr('alt').replace("\\n", ''); + self.elements.target.attr('alt', ''); // Remove alt attribute to prevent default tooltip showing + } + + // No valid content was provided, inform via log + else + { + content = ' '; + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.NO_VALID_CONTENT, 'render'); + }; + + // Set the tooltips content and create title if enabled + if(self.options.content.title.text !== false) createTitle.call(self); + self.updateContent(content); + + // Assign events and toggle tooltip with focus + assignEvents.call(self); + if(self.options.show.ready === true) self.show(); + + // Retrieve ajax content if provided + if(self.options.content.url !== false) + { + url = self.options.content.url; + data = self.options.content.data; + method = self.options.content.method || 'get'; + self.loadContent(url, data, method); + }; + + // Call API method and log event + self.onRender.call(self); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_RENDERED, 'render'); + }; + + // Create borders using canvas and VML + function createBorder() + { + var self, i, width, radius, color, coordinates, containers, size, betweenWidth, betweenCorners, borderTop, borderBottom, borderCoord, sideWidth, vertWidth; + self = this; + + // Destroy previous border elements, if present + self.elements.wrapper.find('.qtip-borderBottom, .qtip-borderTop').remove(); + + // Setup local variables + width = self.options.style.border.width; + radius = self.options.style.border.radius; + color = self.options.style.border.color || self.options.style.tip.color; + + // Calculate border coordinates + coordinates = calculateBorders(radius); + + // Create containers for the border shapes + containers = {}; + for(i in coordinates) + { + // Create shape container + containers[i] = ''; + + // Canvas is supported + if($('').get(0).getContext) + containers[i] += ''; + + // No canvas, but if it's IE use VML + else if($.browser.msie) + { + size = radius * 2 + 3; + containers[i] += ''; + + }; + + containers[i] += ''; + }; + + // Create between corners elements + betweenWidth = self.getDimensions().width - (Math.max(width, radius) * 2); + betweenCorners = ''; + + // Create top border container + borderTop = '' + + containers['topLeft'] + containers['topRight'] + betweenCorners; + self.elements.wrapper.prepend(borderTop); + + // Create bottom border container + borderBottom = '' + + containers['bottomLeft'] + containers['bottomRight'] + betweenCorners; + self.elements.wrapper.append(borderBottom); + + // Draw the borders if canvas were used (Delayed til after DOM creation) + if($('').get(0).getContext) + { + self.elements.wrapper.find('canvas').each(function() + { + borderCoord = coordinates[ $(this).parent('[rel]:first').attr('rel') ]; + drawBorder.call(self, $(this), borderCoord, radius, color); + }) + } + + // Create a phantom VML element (IE won't show the last created VML element otherwise) + else if($.browser.msie) self.elements.tooltip.append(''); + + // Setup contentWrapper border + sideWidth = Math.max(radius, (radius + (width - radius)) ) + vertWidth = Math.max(width - radius, 0); + self.elements.contentWrapper.css({ + border: '0px solid ' + color, + borderWidth: vertWidth + 'px ' + sideWidth + 'px' + }) + }; + + // Border canvas draw method + function drawBorder(canvas, coordinates, radius, color) + { + // Create corner + var context = canvas.get(0).getContext('2d'); + context.fillStyle = color; + context.beginPath(); + context.arc(coordinates[0], coordinates[1], radius, 0, Math.PI * 2, false); + context.fill(); + }; + + // Create tip using canvas and VML + function createTip(corner) + { + var self, color, coordinates, coordsize, path; + self = this; + + // Destroy previous tip, if there is one + if(self.elements.tip !== null) self.elements.tip.remove(); + + // Setup color and corner values + color = self.options.style.tip.color || self.options.style.border.color; + if(self.options.style.tip.corner === false) return; + else if(!corner) corner = self.options.style.tip.corner; + + // Calculate tip coordinates + coordinates = calculateTip(corner, self.options.style.tip.size.width, self.options.style.tip.size.height); + + // Create tip element + self.elements.tip = ''; + + // Use canvas element if supported + if($('').get(0).getContext) + self.elements.tip += ''; + + // Canvas not supported - Use VML (IE) + else if($.browser.msie) + { + // Create coordize and tip path using tip coordinates + coordsize = self.options.style.tip.size.width + ',' + self.options.style.tip.size.height; + path = 'm' + coordinates[0][0] + ',' + coordinates[0][1]; + path += ' l' + coordinates[1][0] + ',' + coordinates[1][1]; + path += ' ' + coordinates[2][0] + ',' + coordinates[2][1]; + path += ' xe'; + + // Create VML element + self.elements.tip += ''; + + // Create a phantom VML element (IE won't show the last created VML element otherwise) + self.elements.tip += ''; + + // Prevent tooltip appearing above the content (IE z-index bug) + self.elements.contentWrapper.css('position', 'relative'); + }; + + // Attach new tip to tooltip element + self.elements.tooltip.prepend(self.elements.tip + ''); + + // Create element reference and draw the canvas tip (Delayed til after DOM creation) + self.elements.tip = self.elements.tooltip.find('.'+self.options.style.classes.tip).eq(0); + if($('').get(0).getContext) + drawTip.call(self, self.elements.tip.find('canvas:first'), coordinates, color); + + // Fix IE small tip bug + if(corner.search(/top/) !== -1 && $.browser.msie && parseInt($.browser.version.charAt(0)) === 6) + self.elements.tip.css({ marginTop: -4 }); + + // Set the tip position + positionTip.call(self, corner); + }; + + // Canvas tip drawing method + function drawTip(canvas, coordinates, color) + { + // Setup properties + var context = canvas.get(0).getContext('2d'); + context.fillStyle = color; + + // Create tip + context.beginPath(); + context.moveTo(coordinates[0][0], coordinates[0][1]); + context.lineTo(coordinates[1][0], coordinates[1][1]); + context.lineTo(coordinates[2][0], coordinates[2][1]); + context.fill(); + }; + + function positionTip(corner) + { + var self, ieAdjust, paddingCorner, paddingSize, newMargin; + self = this; + + // Return if tips are disabled or tip is not yet rendered + if(self.options.style.tip.corner === false || !self.elements.tip) return; + if(!corner) corner = self.elements.tip.attr('rel'); + + // Setup adjustment variables + ieAdjust = positionAdjust = ($.browser.msie) ? 1 : 0; + + // Set initial position + self.elements.tip.css(corner.match(/left|right|top|bottom/)[0], 0); + + // Set position of tip to correct side + if(corner.search(/top|bottom/) !== -1) + { + // Adjustments for IE6 - 0.5px border gap bug + if($.browser.msie) + { + if(parseInt($.browser.version.charAt(0)) === 6) + positionAdjust = (corner.search(/top/) !== -1) ? -3 : 1; + else + positionAdjust = (corner.search(/top/) !== -1) ? 1 : 2; + }; + + if(corner.search(/Middle/) !== -1) + self.elements.tip.css({ left: '50%', marginLeft: -(self.options.style.tip.size.width / 2) }); + + else if(corner.search(/Left/) !== -1) + self.elements.tip.css({ left: self.options.style.border.radius - ieAdjust }); + + else if(corner.search(/Right/) !== -1) + self.elements.tip.css({ right: self.options.style.border.radius + ieAdjust }); + + if(corner.search(/top/) !== -1) + self.elements.tip.css({ top: -positionAdjust }); + else + self.elements.tip.css({ bottom: positionAdjust }); + + } + else if(corner.search(/left|right/) !== -1) + { + // Adjustments for IE6 - 0.5px border gap bug + if($.browser.msie) + positionAdjust = (parseInt($.browser.version.charAt(0)) === 6) ? 1 : ((corner.search(/left/) !== -1) ? 1 : 2); + + if(corner.search(/Middle/) !== -1) + self.elements.tip.css({ top: '50%', marginTop: -(self.options.style.tip.size.height / 2) }); + + else if(corner.search(/Top/) !== -1) + self.elements.tip.css({ top: self.options.style.border.radius - ieAdjust }); + + else if(corner.search(/Bottom/) !== -1) + self.elements.tip.css({ bottom: self.options.style.border.radius + ieAdjust }); + + if(corner.search(/left/) !== -1) + self.elements.tip.css({ left: -positionAdjust }); + else + self.elements.tip.css({ right: positionAdjust }); + }; + + // Adjust tooltip padding to compensate for tip + paddingCorner = 'padding-' + corner.match(/left|right|top|bottom/)[0]; + paddingSize = self.options.style.tip.size[ (paddingCorner.search(/left|right/) !== -1) ? 'width' : 'height' ]; + self.elements.tooltip.css('padding', 0); + self.elements.tooltip.css(paddingCorner, paddingSize); + + // Match content margin to prevent gap bug in IE6 ONLY + if($.browser.msie && parseInt($.browser.version.charAt(0)) == 6) + { + newMargin = parseInt(self.elements.tip.css('margin-top')) || 0; + newMargin += parseInt(self.elements.content.css('margin-top')) || 0; + + self.elements.tip.css({ marginTop: newMargin }); + }; + }; + + // Create title bar for content + function createTitle() + { + var self = this; + + // Destroy previous title element, if present + if(self.elements.title !== null) self.elements.title.remove(); + + // Create title element + self.elements.title = $('') + .css( jQueryStyle(self.options.style.title, true) ) + .css({ zoom: ($.browser.msie) ? 1 : 0 }) + .prependTo(self.elements.contentWrapper); + + // Update title with contents if enabled + if(self.options.content.title.text) self.updateTitle.call(self, self.options.content.title.text); + + // Create title close buttons if enabled + if(self.options.content.title.button !== false + && typeof self.options.content.title.button == 'string') + { + self.elements.button = $('') + .css( jQueryStyle(self.options.style.button, true) ) + .html(self.options.content.title.button) + .prependTo(self.elements.title) + .click(function(event){ if(!self.status.disabled) self.hide(event) }); + }; + }; + + // Assign hide and show events + function assignEvents() + { + var self, showTarget, hideTarget, inactiveEvents; + self = this; + + // Setup event target variables + showTarget = self.options.show.when.target; + hideTarget = self.options.hide.when.target; + + // Add tooltip as a hideTarget is its fixed + if(self.options.hide.fixed) hideTarget = hideTarget.add(self.elements.tooltip); + + // Check if the hide event is special 'inactive' type + if(self.options.hide.when.event == 'inactive') + { + // Define events which reset the 'inactive' event handler + inactiveEvents = ['click', 'dblclick', 'mousedown', 'mouseup', 'mousemove', + 'mouseout', 'mouseenter', 'mouseleave', 'mouseover' ]; + + // Define 'inactive' event timer method + function inactiveMethod(event) + { + if(self.status.disabled === true) return; + + //Clear and reset the timer + clearTimeout(self.timers.inactive); + self.timers.inactive = setTimeout(function() + { + // Unassign 'inactive' events + $(inactiveEvents).each(function() + { + hideTarget.unbind(this+'.qtip-inactive'); + self.elements.content.unbind(this+'.qtip-inactive'); + }); + + // Hide the tooltip + self.hide(event); + } + , self.options.hide.delay); + }; + } + + // Check if the tooltip is 'fixed' + else if(self.options.hide.fixed === true) + { + self.elements.tooltip.bind('mouseover.qtip', function() + { + if(self.status.disabled === true) return; + + // Reset the hide timer + clearTimeout(self.timers.hide); + }); + }; + + // Define show event method + function showMethod(event) + { + if(self.status.disabled === true) return; + + // If set, hide tooltip when inactive for delay period + if(self.options.hide.when.event == 'inactive') + { + // Assign each reset event + $(inactiveEvents).each(function() + { + hideTarget.bind(this+'.qtip-inactive', inactiveMethod); + self.elements.content.bind(this+'.qtip-inactive', inactiveMethod); + }); + + // Start the inactive timer + inactiveMethod(); + }; + + // Clear hide timers + clearTimeout(self.timers.show); + clearTimeout(self.timers.hide); + + // Start show timer + self.timers.show = setTimeout(function(){ self.show(event); }, self.options.show.delay); + }; + + // Define hide event method + function hideMethod(event) + { + if(self.status.disabled === true) return; + + // Prevent hiding if tooltip is fixed and event target is the tooltip + if(self.options.hide.fixed === true + && self.options.hide.when.event.search(/mouse(out|leave)/i) !== -1 + && $(event.relatedTarget).parents('div.qtip[qtip]').length > 0) + { + // Prevent default and popagation + event.stopPropagation(); + event.preventDefault(); + + // Reset the hide timer + clearTimeout(self.timers.hide); + return false; + }; + + // Clear timers and stop animation queue + clearTimeout(self.timers.show); + clearTimeout(self.timers.hide); + self.elements.tooltip.stop(true, true); + + // If tooltip has displayed, start hide timer + self.timers.hide = setTimeout(function(){ self.hide(event); }, self.options.hide.delay); + }; + + // Both events and targets are identical, apply events using a toggle + if((self.options.show.when.target.add(self.options.hide.when.target).length === 1 + && self.options.show.when.event == self.options.hide.when.event + && self.options.hide.when.event !== 'inactive') + || self.options.hide.when.event == 'unfocus') + { + self.cache.toggle = 0; + // Use a toggle to prevent hide/show conflicts + showTarget.bind(self.options.show.when.event + '.qtip', function(event) + { + if(self.cache.toggle == 0) showMethod(event); + else hideMethod(event); + }); + } + + // Events are not identical, bind normally + else + { + showTarget.bind(self.options.show.when.event + '.qtip', showMethod); + + // If the hide event is not 'inactive', bind the hide method + if(self.options.hide.when.event !== 'inactive') + hideTarget.bind(self.options.hide.when.event + '.qtip', hideMethod); + }; + + // Focus the tooltip on mouseover + if(self.options.position.type.search(/(fixed|absolute)/) !== -1) + self.elements.tooltip.bind('mouseover.qtip', self.focus); + + // If mouse is the target, update tooltip position on mousemove + if(self.options.position.target === 'mouse' && self.options.position.type !== 'static') + { + showTarget.bind('mousemove.qtip', function(event) + { + // Set the new mouse positions if adjustment is enabled + self.cache.mouse = { x: event.pageX, y: event.pageY }; + + // Update the tooltip position only if the tooltip is visible and adjustment is enabled + if(self.status.disabled === false + && self.options.position.adjust.mouse === true + && self.options.position.type !== 'static' + && self.elements.tooltip.css('display') !== 'none') + self.updatePosition(event); + }); + }; + }; + + // Screen position adjustment + function screenAdjust(position, target, tooltip) + { + var self, adjustedPosition, adjust, newCorner, overflow, corner; + self = this; + + // Setup corner and adjustment variable + if(tooltip.corner == 'center') return target.position // TODO: 'center' corner adjustment + adjustedPosition = $.extend({}, position); + newCorner = { x: false, y: false }; + + // Define overflow properties + overflow = { + left: (adjustedPosition.left < $.fn.qtip.cache.screen.scroll.left), + right: (adjustedPosition.left + tooltip.dimensions.width + 2 >= $.fn.qtip.cache.screen.width + $.fn.qtip.cache.screen.scroll.left), + top: (adjustedPosition.top < $.fn.qtip.cache.screen.scroll.top), + bottom: (adjustedPosition.top + tooltip.dimensions.height + 2 >= $.fn.qtip.cache.screen.height + $.fn.qtip.cache.screen.scroll.top) + }; + + // Determine new positioning properties + adjust = { + left: (overflow.left && (tooltip.corner.search(/right/i) != -1 || (tooltip.corner.search(/right/i) == -1 && !overflow.right))), + right: (overflow.right && (tooltip.corner.search(/left/i) != -1 || (tooltip.corner.search(/left/i) == -1 && !overflow.left))), + top: (overflow.top && tooltip.corner.search(/top/i) == -1), + bottom: (overflow.bottom && tooltip.corner.search(/bottom/i) == -1) + }; + + // Tooltip overflows off the left side of the screen + if(adjust.left) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.left = target.position.left + target.dimensions.width; + else + adjustedPosition.left = self.cache.mouse.x + + newCorner.x = 'Left'; + } + + // Tooltip overflows off the right side of the screen + else if(adjust.right) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.left = target.position.left - tooltip.dimensions.width; + else + adjustedPosition.left = self.cache.mouse.x - tooltip.dimensions.width; + + newCorner.x = 'Right'; + }; + + // Tooltip overflows off the top of the screen + if(adjust.top) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.top = target.position.top + target.dimensions.height; + else + adjustedPosition.top = self.cache.mouse.y + + newCorner.y = 'top'; + } + + // Tooltip overflows off the bottom of the screen + else if(adjust.bottom) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.top = target.position.top - tooltip.dimensions.height; + else + adjustedPosition.top = self.cache.mouse.y - tooltip.dimensions.height; + + newCorner.y = 'bottom'; + }; + + // Don't adjust if resulting position is negative + if(adjustedPosition.left < 0) + { + adjustedPosition.left = position.left; + newCorner.x = false; + }; + if(adjustedPosition.top < 0) + { + adjustedPosition.top = position.top; + newCorner.y = false; + }; + + // Change tip corner if positioning has changed and tips are enabled + if(self.options.style.tip.corner !== false) + { + // Determine new corner properties + adjustedPosition.corner = new String(tooltip.corner); + if(newCorner.x !== false) adjustedPosition.corner = adjustedPosition.corner.replace(/Left|Right|Middle/, newCorner.x); + if(newCorner.y !== false) adjustedPosition.corner = adjustedPosition.corner.replace(/top|bottom/, newCorner.y); + + // Adjust tip if position has changed and tips are enabled + if(adjustedPosition.corner !== self.elements.tip.attr('rel')) + createTip.call(self, adjustedPosition.corner); + }; + + return adjustedPosition; + }; + + // Build a jQuery style object from supplied style object + function jQueryStyle(style, sub) + { + var styleObj, i; + + styleObj = $.extend(true, {}, style); + for(i in styleObj) + { + if(sub === true && i.search(/(tip|classes)/i) !== -1) + delete styleObj[i]; + else if(!sub && i.search(/(width|border|tip|title|classes|user)/i) !== -1) + delete styleObj[i]; + }; + + return styleObj; + }; + + // Sanitize styles + function sanitizeStyle(style) + { + if(typeof style.tip !== 'object') style.tip = { corner: style.tip }; + if(typeof style.tip.size !== 'object') style.tip.size = { width: style.tip.size, height: style.tip.size }; + if(typeof style.border !== 'object') style.border = { width: style.border }; + if(typeof style.width !== 'object') style.width = { value: style.width }; + if(typeof style.width.max == 'string') style.width.max = parseInt(style.width.max.replace(/([0-9]+)/i, "$1")); + if(typeof style.width.min == 'string') style.width.min = parseInt(style.width.min.replace(/([0-9]+)/i, "$1")); + + // Convert deprecated x and y tip values to width/height + if(typeof style.tip.size.x == 'number') + { + style.tip.size.width = style.tip.size.x; + delete style.tip.size.x; + }; + if(typeof style.tip.size.y == 'number') + { + style.tip.size.height = style.tip.size.y; + delete style.tip.size.y; + }; + + return style; + }; + + // Build styles recursively with inheritance + function buildStyle() + { + var self, i, styleArray, styleExtend, finalStyle, ieAdjust; + self = this; + + // Build style options from supplied arguments + styleArray = [true, {}]; + for(i = 0; i < arguments.length; i++) + styleArray.push(arguments[i]); + styleExtend = [ $.extend.apply($, styleArray) ]; + + // Loop through each named style inheritance + while(typeof styleExtend[0].name == 'string') + { + // Sanitize style data and append to extend array + styleExtend.unshift( sanitizeStyle($.fn.qtip.styles[ styleExtend[0].name ]) ); + }; + + // Make sure resulting tooltip className represents final style + styleExtend.unshift(true, {classes:{ tooltip: 'qtip-' + (arguments[0].name || 'defaults') }}, $.fn.qtip.styles.defaults); + + // Extend into a single style object + finalStyle = $.extend.apply($, styleExtend); + + // Adjust tip size if needed (IE 1px adjustment bug fix) + ieAdjust = ($.browser.msie) ? 1 : 0; + finalStyle.tip.size.width += ieAdjust; + finalStyle.tip.size.height += ieAdjust; + + // Force even numbers for pixel precision + if(finalStyle.tip.size.width % 2 > 0) finalStyle.tip.size.width += 1; + if(finalStyle.tip.size.height % 2 > 0) finalStyle.tip.size.height += 1; + + // Sanitize final styles tip corner value + if(finalStyle.tip.corner === true) + finalStyle.tip.corner = (self.options.position.corner.tooltip === 'center') ? false : self.options.position.corner.tooltip; + + return finalStyle; + }; + + // Tip coordinates calculator + function calculateTip(corner, width, height) + { + // Define tip coordinates in terms of height and width values + var tips = { + bottomRight: [[0,0], [width,height], [width,0]], + bottomLeft: [[0,0], [width,0], [0,height]], + topRight: [[0,height], [width,0], [width,height]], + topLeft: [[0,0], [0,height], [width,height]], + topMiddle: [[0,height], [width / 2,0], [width,height]], + bottomMiddle: [[0,0], [width,0], [width / 2,height]], + rightMiddle: [[0,0], [width,height / 2], [0,height]], + leftMiddle: [[width,0], [width,height], [0,height / 2]] + }; + tips.leftTop = tips.bottomRight; + tips.rightTop = tips.bottomLeft; + tips.leftBottom = tips.topRight; + tips.rightBottom = tips.topLeft; + + return tips[corner]; + }; + + // Border coordinates calculator + function calculateBorders(radius) + { + var borders; + + // Use canvas element if supported + if($('').get(0).getContext) + { + borders = { + topLeft: [radius,radius], topRight: [0,radius], + bottomLeft: [radius,0], bottomRight: [0,0] + }; + } + + // Canvas not supported - Use VML (IE) + else if($.browser.msie) + { + borders = { + topLeft: [-90,90,0], topRight: [-90,90,-radius], + bottomLeft: [90,270,0], bottomRight: [90, 270,-radius] + }; + }; + + return borders; + }; + + // BGIFRAME JQUERY PLUGIN ADAPTION + // Special thanks to Brandon Aaron for this plugin + // http://plugins.jquery.com/project/bgiframe + function bgiframe() + { + var self, html, dimensions; + self = this; + dimensions = self.getDimensions(); + + // Setup iframe HTML string + html = ''; + + // Append the new HTML and setup element reference + self.elements.bgiframe = self.elements.wrapper.prepend(html).children('.qtip-bgiframe:first'); + }; + + // Assign cache and event initialisation on document load + $(document).ready(function() + { + // Setup library cache with window scroll and dimensions of document + $.fn.qtip.cache = { + screen: { + scroll: { left: $(window).scrollLeft(), top: $(window).scrollTop() }, + width: $(window).width(), + height: $(window).height() + } + }; + + // Adjust positions of the tooltips on window resize or scroll if enabled + var adjustTimer; + $(window).bind('resize scroll', function(event) + { + clearTimeout(adjustTimer); + adjustTimer = setTimeout(function() + { + // Readjust cached screen values + if(event.type === 'scroll') + $.fn.qtip.cache.screen.scroll = { left: $(window).scrollLeft(), top: $(window).scrollTop() }; + else + { + $.fn.qtip.cache.screen.width = $(window).width(); + $.fn.qtip.cache.screen.height = $(window).height(); + }; + + for(i = 0; i < $.fn.qtip.interfaces.length; i++) + { + // Access current elements API + var api = $.fn.qtip.interfaces[i]; + + // Update position if resize or scroll adjustments are enabled + if(api.status.rendered === true + && (api.options.position.type !== 'static' + || api.options.position.adjust.scroll && event.type === 'scroll' + || api.options.position.adjust.resize && event.type === 'resize')) + { + // Queue the animation so positions are updated correctly + api.updatePosition(event, true); + } + }; + } + , 100); + }) + + // Hide unfocus toolipts on document mousedown + $(document).bind('mousedown.qtip', function(event) + { + if($(event.target).parents('div.qtip').length === 0) + { + $('.qtip[unfocus]').each(function() + { + var api = $(this).qtip("api"); + + // Only hide if its visible and not the tooltips target + if($(this).is(':visible') && !api.status.disabled + && $(event.target).add(api.elements.target).length > 1) + api.hide(event); + }) + }; + }) + }); + + // Define qTip API interfaces array + $.fn.qtip.interfaces = [] + + // Define log and constant place holders + $.fn.qtip.log = { error: function(){ return this; } }; + $.fn.qtip.constants = {}; + + // Define configuration defaults + $.fn.qtip.defaults = { + // Content + content: { + prerender: false, + text: false, + url: false, + data: null, + title: { + text: false, + button: false + } + }, + // Position + position: { + target: false, + corner: { + target: 'bottomRight', + tooltip: 'topLeft' + }, + adjust: { + x: 0, y: 0, + mouse: true, + screen: false, + scroll: true, + resize: true + }, + type: 'absolute', + container: false + }, + // Effects + show: { + when: { + target: false, + event: 'mouseover' + }, + effect: { + type: 'fade', + length: 100 + }, + delay: 140, + solo: false, + ready: false + }, + hide: { + when: { + target: false, + event: 'mouseout' + }, + effect: { + type: 'fade', + length: 100 + }, + delay: 0, + fixed: false + }, + // Callbacks + api: { + beforeRender: function(){}, + onRender: function(){}, + beforePositionUpdate: function(){}, + onPositionUpdate: function(){}, + beforeShow: function(){}, + onShow: function(){}, + beforeHide: function(){}, + onHide: function(){}, + beforeContentUpdate: function(){}, + onContentUpdate: function(){}, + beforeContentLoad: function(){}, + onContentLoad: function(){}, + beforeTitleUpdate: function(){}, + onTitleUpdate: function(){}, + beforeDestroy: function(){}, + onDestroy: function(){}, + beforeFocus: function(){}, + onFocus: function(){} + } + }; + + $.fn.qtip.styles = { + defaults: { + background: 'white', + color: '#111', + overflow: 'hidden', + textAlign: 'left', + width: { + min: 0, + max: 250 + }, + padding: '5px 9px', + border: { + width: 1, + radius: 0, + color: '#d3d3d3' + }, + tip: { + corner: false, + color: false, + size: { width: 13, height: 13 }, + opacity: 1 + }, + title: { + background: '#e1e1e1', + fontWeight: 'bold', + padding: '7px 12px' + }, + button: { + cursor: 'pointer' + }, + classes: { + target: '', + tip: 'qtip-tip', + title: 'qtip-title', + button: 'qtip-button', + content: 'qtip-content', + active: 'qtip-active' + } + }, + cream: { + border: { + width: 3, + radius: 0, + color: '#F9E98E' + }, + title: { + background: '#F0DE7D', + color: '#A27D35' + }, + background: '#FBF7AA', + color: '#A27D35', + + classes: { tooltip: 'qtip-cream' } + }, + light: { + border: { + width: 3, + radius: 0, + color: '#E2E2E2' + }, + title: { + background: '#f1f1f1', + color: '#454545' + }, + background: 'white', + color: '#454545', + + classes: { tooltip: 'qtip-light' } + }, + dark: { + border: { + width: 3, + radius: 0, + color: '#303030' + }, + title: { + background: '#404040', + color: '#f3f3f3' + }, + background: '#505050', + color: '#f3f3f3', + + classes: { tooltip: 'qtip-dark' } + }, + red: { + border: { + width: 3, + radius: 0, + color: '#CE6F6F' + }, + title: { + background: '#f28279', + color: '#9C2F2F' + }, + background: '#F79992', + color: '#9C2F2F', + + classes: { tooltip: 'qtip-red' } + }, + green: { + border: { + width: 3, + radius: 0, + color: '#A9DB66' + }, + title: { + background: '#b9db8c', + color: '#58792E' + }, + background: '#CDE6AC', + color: '#58792E', + + classes: { tooltip: 'qtip-green' } + }, + blue: { + border: { + width: 3, + radius: 0, + color: '#ADD9ED' + }, + title: { + background: '#D0E9F5', + color: '#5E99BD' + }, + background: '#E5F6FE', + color: '#4D9FBF', + + classes: { tooltip: 'qtip-blue' } + } + }; +})(jQuery); diff --git a/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.js b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.js new file mode 100644 index 0000000..98b0b85 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.js @@ -0,0 +1,15 @@ +/* + * jquery.qtip. The jQuery tooltip plugin + * + * Copyright (c) 2009 Craig Thompson + * http://craigsworks.com + * + * Licensed under MIT + * http://www.opensource.org/licenses/mit-license.php + * + * Launch : February 2009 + * Version : 1.0.0-rc3 + * Released: Tuesday 12th May, 2009 - 00:00 + * Debug: jquery.qtip.debug.js + */ +(function($){$.fn.qtip=function(options,blanket){var i,id,interfaces,opts,obj,command,config,api;if(typeof options=="string"){if(typeof $(this).data("qtip")!=="object"){$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.NO_TOOLTIP_PRESENT,false)}if(options=="api"){return $(this).data("qtip").interfaces[$(this).data("qtip").current]}else{if(options=="interfaces"){return $(this).data("qtip").interfaces}}}else{if(!options){options={}}if(typeof options.content!=="object"||(options.content.jquery&&options.content.length>0)){options.content={text:options.content}}if(typeof options.content.title!=="object"){options.content.title={text:options.content.title}}if(typeof options.position!=="object"){options.position={corner:options.position}}if(typeof options.position.corner!=="object"){options.position.corner={target:options.position.corner,tooltip:options.position.corner}}if(typeof options.show!=="object"){options.show={when:options.show}}if(typeof options.show.when!=="object"){options.show.when={event:options.show.when}}if(typeof options.show.effect!=="object"){options.show.effect={type:options.show.effect}}if(typeof options.hide!=="object"){options.hide={when:options.hide}}if(typeof options.hide.when!=="object"){options.hide.when={event:options.hide.when}}if(typeof options.hide.effect!=="object"){options.hide.effect={type:options.hide.effect}}if(typeof options.style!=="object"){options.style={name:options.style}}options.style=sanitizeStyle(options.style);opts=$.extend(true,{},$.fn.qtip.defaults,options);opts.style=buildStyle.call({options:opts},opts.style);opts.user=$.extend(true,{},options)}return $(this).each(function(){if(typeof options=="string"){command=options.toLowerCase();interfaces=$(this).qtip("interfaces");if(typeof interfaces=="object"){if(blanket===true&&command=="destroy"){while(interfaces.length>0){interfaces[interfaces.length-1].destroy()}}else{if(blanket!==true){interfaces=[$(this).qtip("api")]}for(i=0;i0))}if(typeof self.options.show.solo=="object"){solo=$(self.options.show.solo)}else{if(self.options.show.solo===true){solo=$("div.qtip").not(self.elements.tooltip)}}if(solo){solo.each(function(){if($(this).qtip("api").status.rendered===true){$(this).qtip("api").hide()}})}if(typeof self.options.show.effect.type=="function"){self.options.show.effect.type.call(self.elements.tooltip,self.options.show.effect.length);self.elements.tooltip.queue(function(){afterShow();$(this).dequeue()})}else{switch(self.options.show.effect.type.toLowerCase()){case"fade":self.elements.tooltip.fadeIn(self.options.show.effect.length,afterShow);break;case"slide":self.elements.tooltip.slideDown(self.options.show.effect.length,function(){afterShow();if(self.options.position.type!=="static"){self.updatePosition(event,true)}});break;case"grow":self.elements.tooltip.show(self.options.show.effect.length,afterShow);break;default:self.elements.tooltip.show(null,afterShow);break}self.elements.tooltip.addClass(self.options.style.classes.active)}return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_SHOWN,"show")},hide:function(event){var returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"hide")}else{if(self.elements.tooltip.css("display")==="none"){return self}}clearTimeout(self.timers.show);self.elements.tooltip.stop(true,false);returned=self.beforeHide.call(self,event);if(returned===false){return self}function afterHide(){self.onHide.call(self,event)}self.cache.toggle=0;if(typeof self.options.hide.effect.type=="function"){self.options.hide.effect.type.call(self.elements.tooltip,self.options.hide.effect.length);self.elements.tooltip.queue(function(){afterHide();$(this).dequeue()})}else{switch(self.options.hide.effect.type.toLowerCase()){case"fade":self.elements.tooltip.fadeOut(self.options.hide.effect.length,afterHide);break;case"slide":self.elements.tooltip.slideUp(self.options.hide.effect.length,afterHide);break;case"grow":self.elements.tooltip.hide(self.options.hide.effect.length,afterHide);break;default:self.elements.tooltip.hide(null,afterHide);break}self.elements.tooltip.removeClass(self.options.style.classes.active)}return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_HIDDEN,"hide")},updatePosition:function(event,animate){var i,target,tooltip,coords,mapName,imagePos,newPosition,ieAdjust,ie6Adjust,borderAdjust,mouseAdjust,offset,curPosition,returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updatePosition")}else{if(self.options.position.type=="static"){return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.CANNOT_POSITION_STATIC,"updatePosition")}}target={position:{left:0,top:0},dimensions:{height:0,width:0},corner:self.options.position.corner.target};tooltip={position:self.getPosition(),dimensions:self.getDimensions(),corner:self.options.position.corner.tooltip};if(self.options.position.target!=="mouse"){if(self.options.position.target.get(0).nodeName.toLowerCase()=="area"){coords=self.options.position.target.attr("coords").split(",");for(i=0;itarget.dimensions.width){target.dimensions.width=coords[i]}if(coords[i]target.dimensions.height){target.dimensions.height=coords[i]}if(coords[i]0){if(tooltip.corner.search(/Left/)!==-1){newPosition.left-=self.options.style.border.radius}else{if(tooltip.corner.search(/Right/)!==-1){newPosition.left+=self.options.style.border.radius}}if(tooltip.corner.search(/Top/)!==-1){newPosition.top-=self.options.style.border.radius}else{if(tooltip.corner.search(/Bottom/)!==-1){newPosition.top+=self.options.style.border.radius}}}if(ieAdjust){if(tooltip.corner.search(/top/)!==-1){newPosition.top-=ieAdjust}else{if(tooltip.corner.search(/bottom/)!==-1){newPosition.top+=ieAdjust}}if(tooltip.corner.search(/left/)!==-1){newPosition.left-=ieAdjust}else{if(tooltip.corner.search(/right/)!==-1){newPosition.left+=ieAdjust}}if(tooltip.corner.search(/leftMiddle|rightMiddle/)!==-1){newPosition.top-=1}}if(self.options.position.adjust.screen===true){newPosition=screenAdjust.call(self,newPosition,target,tooltip)}if(self.options.position.target==="mouse"&&self.options.position.adjust.mouse===true){if(self.options.position.adjust.screen===true&&self.elements.tip){mouseAdjust=self.elements.tip.attr("rel")}else{mouseAdjust=self.options.position.corner.tooltip}newPosition.left+=(mouseAdjust.search(/right/i)!==-1)?-6:6;newPosition.top+=(mouseAdjust.search(/bottom/i)!==-1)?-6:6}if(!self.elements.bgiframe&&$.browser.msie&&parseInt($.browser.version.charAt(0))==6){$("select, object").each(function(){offset=$(this).offset();offset.bottom=offset.top+$(this).height();offset.right=offset.left+$(this).width();if(newPosition.top+tooltip.dimensions.height>=offset.top&&newPosition.left+tooltip.dimensions.width>=offset.left){bgiframe.call(self)}})}newPosition.left+=self.options.position.adjust.x;newPosition.top+=self.options.position.adjust.y;curPosition=self.getPosition();if(newPosition.left!=curPosition.left||newPosition.top!=curPosition.top){returned=self.beforePositionUpdate.call(self,event);if(returned===false){return self}self.cache.position=newPosition;if(animate===true){self.status.animated=true;self.elements.tooltip.animate(newPosition,200,"swing",function(){self.status.animated=false})}else{self.elements.tooltip.css(newPosition)}self.onPositionUpdate.call(self,event);if(typeof event!=="undefined"&&event.type&&event.type!=="mousemove"){$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_POSITION_UPDATED,"updatePosition")}}return self},updateWidth:function(newWidth){var hidden;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateWidth")}else{if(newWidth&&typeof newWidth!=="number"){return $.fn.qtip.log.error.call(self,2,"newWidth must be of type number","updateWidth")}}hidden=self.elements.contentWrapper.siblings().add(self.elements.tip).add(self.elements.button);if(!newWidth){if(typeof self.options.style.width.value=="number"){newWidth=self.options.style.width.value}else{self.elements.tooltip.css({width:"auto"});hidden.hide();if($.browser.msie){self.elements.wrapper.add(self.elements.contentWrapper.children()).css({zoom:"normal"})}newWidth=self.getDimensions().width+1;if(!self.options.style.width.value){if(newWidth>self.options.style.width.max){newWidth=self.options.style.width.max}if(newWidth").get(0).getContext){tip=self.elements.tooltip.find(".qtip-tip canvas:first");context=tip.get(0).getContext("2d");context.clearRect(0,0,300,300);corner=tip.parent("div[rel]:first").attr("rel");coordinates=calculateTip(corner,self.options.style.tip.size.width,self.options.style.tip.size.height);drawTip.call(self,tip,coordinates,self.options.style.tip.color||self.options.style.border.color)}else{if($.browser.msie){tip=self.elements.tooltip.find('.qtip-tip [nodeName="shape"]');tip.attr("fillcolor",self.options.style.tip.color||self.options.style.border.color)}}}if(self.options.style.border.radius>0){self.elements.tooltip.find(".qtip-betweenCorners").css({backgroundColor:self.options.style.border.color});if($("").get(0).getContext){borders=calculateBorders(self.options.style.border.radius);self.elements.tooltip.find(".qtip-wrapper canvas").each(function(){context=$(this).get(0).getContext("2d");context.clearRect(0,0,300,300);corner=$(this).parent("div[rel]:first").attr("rel");drawBorder.call(self,$(this),borders[corner],self.options.style.border.radius,self.options.style.border.color)})}else{if($.browser.msie){self.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function(){$(this).attr("fillcolor",self.options.style.border.color)})}}}return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_STYLE_UPDATED,"updateStyle")},updateContent:function(content,reposition){var parsedContent,images,loadedImages;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateContent")}else{if(!content){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateContent")}}parsedContent=self.beforeContentUpdate.call(self,content);if(typeof parsedContent=="string"){content=parsedContent}else{if(parsedContent===false){return}}if($.browser.msie){self.elements.contentWrapper.children().css({zoom:"normal"})}if(content.jquery&&content.length>0){content.clone(true).appendTo(self.elements.content).show()}else{self.elements.content.html(content)}images=self.elements.content.find("img[complete=false]");if(images.length>0){loadedImages=0;images.each(function(i){$('').load(function(){if(++loadedImages==images.length){afterLoad()}})})}else{afterLoad()}function afterLoad(){self.updateWidth();if(reposition!==false){if(self.options.position.type!=="static"){self.updatePosition(self.elements.tooltip.is(":visible"),true)}if(self.options.style.tip.corner!==false){positionTip.call(self)}}}self.onContentUpdate.call(self);return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_CONTENT_UPDATED,"loadContent")},loadContent:function(url,data,method){var returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"loadContent")}returned=self.beforeContentLoad.call(self);if(returned===false){return self}if(method=="post"){$.post(url,data,setupContent)}else{$.get(url,data,setupContent)}function setupContent(content){self.onContentLoad.call(self);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_CONTENT_LOADED,"loadContent");self.updateContent(content)}return self},updateTitle:function(content){if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateTitle")}else{if(!content){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateTitle")}}returned=self.beforeTitleUpdate.call(self);if(returned===false){return self}if(self.elements.button){self.elements.button=self.elements.button.clone(true)}self.elements.title.html(content);if(self.elements.button){self.elements.title.prepend(self.elements.button)}self.onTitleUpdate.call(self);return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_TITLE_UPDATED,"updateTitle")},focus:function(event){var curIndex,newIndex,elemIndex,returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"focus")}else{if(self.options.position.type=="static"){return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.CANNOT_FOCUS_STATIC,"focus")}}curIndex=parseInt(self.elements.tooltip.css("z-index"));newIndex=6000+$("div.qtip[qtip]").length-1;if(!self.status.focused&&curIndex!==newIndex){returned=self.beforeFocus.call(self,event);if(returned===false){return self}$("div.qtip[qtip]").not(self.elements.tooltip).each(function(){if($(this).qtip("api").status.rendered===true){elemIndex=parseInt($(this).css("z-index"));if(typeof elemIndex=="number"&&elemIndex>-1){$(this).css({zIndex:parseInt($(this).css("z-index"))-1})}$(this).qtip("api").status.focused=false}});self.elements.tooltip.css({zIndex:newIndex});self.status.focused=true;self.onFocus.call(self,event);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_FOCUSED,"focus")}return self},disable:function(state){if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"disable")}if(state){if(!self.status.disabled){self.status.disabled=true;$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_DISABLED,"disable")}else{$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED,"disable")}}else{if(self.status.disabled){self.status.disabled=false;$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_ENABLED,"disable")}else{$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED,"disable")}}return self},destroy:function(){var i,returned,interfaces;returned=self.beforeDestroy.call(self);if(returned===false){return self}if(self.status.rendered){self.options.show.when.target.unbind("mousemove.qtip",self.updatePosition);self.options.show.when.target.unbind("mouseout.qtip",self.hide);self.options.show.when.target.unbind(self.options.show.when.event+".qtip");self.options.hide.when.target.unbind(self.options.hide.when.event+".qtip");self.elements.tooltip.unbind(self.options.hide.when.event+".qtip");self.elements.tooltip.unbind("mouseover.qtip",self.focus);self.elements.tooltip.remove()}else{self.options.show.when.target.unbind(self.options.show.when.event+".qtip-create")}if(typeof self.elements.target.data("qtip")=="object"){interfaces=self.elements.target.data("qtip").interfaces;if(typeof interfaces=="object"&&interfaces.length>0){for(i=0;i0){self.elements.target.data("qtip").current=interfaces.length-1}else{self.elements.target.removeData("qtip")}self.onDestroy.call(self);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_DESTROYED,"destroy");return self.elements.target},getPosition:function(){var show,offset;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getPosition")}show=(self.elements.tooltip.css("display")!=="none")?false:true;if(show){self.elements.tooltip.css({visiblity:"hidden"}).show()}offset=self.elements.tooltip.offset();if(show){self.elements.tooltip.css({visiblity:"visible"}).hide()}return offset},getDimensions:function(){var show,dimensions;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getDimensions")}show=(!self.elements.tooltip.is(":visible"))?true:false;if(show){self.elements.tooltip.css({visiblity:"hidden"}).show()}dimensions={height:self.elements.tooltip.outerHeight(),width:self.elements.tooltip.outerWidth()};if(show){self.elements.tooltip.css({visiblity:"visible"}).hide()}return dimensions}})}function construct(){var self,adjust,content,url,data,method,tempLength;self=this;self.beforeRender.call(self);self.status.rendered=true;self.elements.tooltip=' ';self.elements.tooltip=$(self.elements.tooltip);self.elements.tooltip.appendTo(self.options.position.container);self.elements.tooltip.data("qtip",{current:0,interfaces:[self]});self.elements.wrapper=self.elements.tooltip.children("div:first");self.elements.contentWrapper=self.elements.wrapper.children("div:first").css({background:self.options.style.background});self.elements.content=self.elements.contentWrapper.children("div:first").css(jQueryStyle(self.options.style));if($.browser.msie){self.elements.wrapper.add(self.elements.content).css({zoom:1})}if(self.options.hide.when.event=="unfocus"){self.elements.tooltip.attr("unfocus",true)}if(typeof self.options.style.width.value=="number"){self.updateWidth()}if($("").get(0).getContext||$.browser.msie){if(self.options.style.border.radius>0){createBorder.call(self)}else{self.elements.contentWrapper.css({border:self.options.style.border.width+"px solid "+self.options.style.border.color})}if(self.options.style.tip.corner!==false){createTip.call(self)}}else{self.elements.contentWrapper.css({border:self.options.style.border.width+"px solid "+self.options.style.border.color});self.options.style.border.radius=0;self.options.style.tip.corner=false;$.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED,"render")}if((typeof self.options.content.text=="string"&&self.options.content.text.length>0)||(self.options.content.text.jquery&&self.options.content.text.length>0)){content=self.options.content.text}else{if(typeof self.elements.target.attr("title")=="string"&&self.elements.target.attr("title").length>0){content=self.elements.target.attr("title").replace("\\n","");self.elements.target.attr("title","")}else{if(typeof self.elements.target.attr("alt")=="string"&&self.elements.target.attr("alt").length>0){content=self.elements.target.attr("alt").replace("\\n","");self.elements.target.attr("alt","")}else{content=" ";$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.NO_VALID_CONTENT,"render")}}}if(self.options.content.title.text!==false){createTitle.call(self)}self.updateContent(content);assignEvents.call(self);if(self.options.show.ready===true){self.show()}if(self.options.content.url!==false){url=self.options.content.url;data=self.options.content.data;method=self.options.content.method||"get";self.loadContent(url,data,method)}self.onRender.call(self);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_RENDERED,"render")}function createBorder(){var self,i,width,radius,color,coordinates,containers,size,betweenWidth,betweenCorners,borderTop,borderBottom,borderCoord,sideWidth,vertWidth;self=this;self.elements.wrapper.find(".qtip-borderBottom, .qtip-borderTop").remove();width=self.options.style.border.width;radius=self.options.style.border.radius;color=self.options.style.border.color||self.options.style.tip.color;coordinates=calculateBorders(radius);containers={};for(i in coordinates){containers[i]='';if($("").get(0).getContext){containers[i]+=''}else{if($.browser.msie){size=radius*2+3;containers[i]+=''}}containers[i]+=""}betweenWidth=self.getDimensions().width-(Math.max(width,radius)*2);betweenCorners='';borderTop=''+containers.topLeft+containers.topRight+betweenCorners;self.elements.wrapper.prepend(borderTop);borderBottom=''+containers.bottomLeft+containers.bottomRight+betweenCorners;self.elements.wrapper.append(borderBottom);if($("").get(0).getContext){self.elements.wrapper.find("canvas").each(function(){borderCoord=coordinates[$(this).parent("[rel]:first").attr("rel")];drawBorder.call(self,$(this),borderCoord,radius,color)})}else{if($.browser.msie){self.elements.tooltip.append('')}}sideWidth=Math.max(radius,(radius+(width-radius)));vertWidth=Math.max(width-radius,0);self.elements.contentWrapper.css({border:"0px solid "+color,borderWidth:vertWidth+"px "+sideWidth+"px"})}function drawBorder(canvas,coordinates,radius,color){var context=canvas.get(0).getContext("2d");context.fillStyle=color;context.beginPath();context.arc(coordinates[0],coordinates[1],radius,0,Math.PI*2,false);context.fill()}function createTip(corner){var self,color,coordinates,coordsize,path;self=this;if(self.elements.tip!==null){self.elements.tip.remove()}color=self.options.style.tip.color||self.options.style.border.color;if(self.options.style.tip.corner===false){return}else{if(!corner){corner=self.options.style.tip.corner}}coordinates=calculateTip(corner,self.options.style.tip.size.width,self.options.style.tip.size.height);self.elements.tip='';if($("").get(0).getContext){self.elements.tip+=''}else{if($.browser.msie){coordsize=self.options.style.tip.size.width+","+self.options.style.tip.size.height;path="m"+coordinates[0][0]+","+coordinates[0][1];path+=" l"+coordinates[1][0]+","+coordinates[1][1];path+=" "+coordinates[2][0]+","+coordinates[2][1];path+=" xe";self.elements.tip+='';self.elements.tip+='';self.elements.contentWrapper.css("position","relative")}}self.elements.tooltip.prepend(self.elements.tip+"");self.elements.tip=self.elements.tooltip.find("."+self.options.style.classes.tip).eq(0);if($("").get(0).getContext){drawTip.call(self,self.elements.tip.find("canvas:first"),coordinates,color)}if(corner.search(/top/)!==-1&&$.browser.msie&&parseInt($.browser.version.charAt(0))===6){self.elements.tip.css({marginTop:-4})}positionTip.call(self,corner)}function drawTip(canvas,coordinates,color){var context=canvas.get(0).getContext("2d");context.fillStyle=color;context.beginPath();context.moveTo(coordinates[0][0],coordinates[0][1]);context.lineTo(coordinates[1][0],coordinates[1][1]);context.lineTo(coordinates[2][0],coordinates[2][1]);context.fill()}function positionTip(corner){var self,ieAdjust,paddingCorner,paddingSize,newMargin;self=this;if(self.options.style.tip.corner===false||!self.elements.tip){return}if(!corner){corner=self.elements.tip.attr("rel")}ieAdjust=positionAdjust=($.browser.msie)?1:0;self.elements.tip.css(corner.match(/left|right|top|bottom/)[0],0);if(corner.search(/top|bottom/)!==-1){if($.browser.msie){if(parseInt($.browser.version.charAt(0))===6){positionAdjust=(corner.search(/top/)!==-1)?-3:1}else{positionAdjust=(corner.search(/top/)!==-1)?1:2}}if(corner.search(/Middle/)!==-1){self.elements.tip.css({left:"50%",marginLeft:-(self.options.style.tip.size.width/2)})}else{if(corner.search(/Left/)!==-1){self.elements.tip.css({left:self.options.style.border.radius-ieAdjust})}else{if(corner.search(/Right/)!==-1){self.elements.tip.css({right:self.options.style.border.radius+ieAdjust})}}}if(corner.search(/top/)!==-1){self.elements.tip.css({top:-positionAdjust})}else{self.elements.tip.css({bottom:positionAdjust})}}else{if(corner.search(/left|right/)!==-1){if($.browser.msie){positionAdjust=(parseInt($.browser.version.charAt(0))===6)?1:((corner.search(/left/)!==-1)?1:2)}if(corner.search(/Middle/)!==-1){self.elements.tip.css({top:"50%",marginTop:-(self.options.style.tip.size.height/2)})}else{if(corner.search(/Top/)!==-1){self.elements.tip.css({top:self.options.style.border.radius-ieAdjust})}else{if(corner.search(/Bottom/)!==-1){self.elements.tip.css({bottom:self.options.style.border.radius+ieAdjust})}}}if(corner.search(/left/)!==-1){self.elements.tip.css({left:-positionAdjust})}else{self.elements.tip.css({right:positionAdjust})}}}paddingCorner="padding-"+corner.match(/left|right|top|bottom/)[0];paddingSize=self.options.style.tip.size[(paddingCorner.search(/left|right/)!==-1)?"width":"height"];self.elements.tooltip.css("padding",0);self.elements.tooltip.css(paddingCorner,paddingSize);if($.browser.msie&&parseInt($.browser.version.charAt(0))==6){newMargin=parseInt(self.elements.tip.css("margin-top"))||0;newMargin+=parseInt(self.elements.content.css("margin-top"))||0;self.elements.tip.css({marginTop:newMargin})}}function createTitle(){var self=this;if(self.elements.title!==null){self.elements.title.remove()}self.elements.title=$('').css(jQueryStyle(self.options.style.title,true)).css({zoom:($.browser.msie)?1:0}).prependTo(self.elements.contentWrapper);if(self.options.content.title.text){self.updateTitle.call(self,self.options.content.title.text)}if(self.options.content.title.button!==false&&typeof self.options.content.title.button=="string"){self.elements.button=$('').css(jQueryStyle(self.options.style.button,true)).html(self.options.content.title.button).prependTo(self.elements.title).click(function(event){if(!self.status.disabled){self.hide(event)}})}}function assignEvents(){var self,showTarget,hideTarget,inactiveEvents;self=this;showTarget=self.options.show.when.target;hideTarget=self.options.hide.when.target;if(self.options.hide.fixed){hideTarget=hideTarget.add(self.elements.tooltip)}if(self.options.hide.when.event=="inactive"){inactiveEvents=["click","dblclick","mousedown","mouseup","mousemove","mouseout","mouseenter","mouseleave","mouseover"];function inactiveMethod(event){if(self.status.disabled===true){return}clearTimeout(self.timers.inactive);self.timers.inactive=setTimeout(function(){$(inactiveEvents).each(function(){hideTarget.unbind(this+".qtip-inactive");self.elements.content.unbind(this+".qtip-inactive")});self.hide(event)},self.options.hide.delay)}}else{if(self.options.hide.fixed===true){self.elements.tooltip.bind("mouseover.qtip",function(){if(self.status.disabled===true){return}clearTimeout(self.timers.hide)})}}function showMethod(event){if(self.status.disabled===true){return}if(self.options.hide.when.event=="inactive"){$(inactiveEvents).each(function(){hideTarget.bind(this+".qtip-inactive",inactiveMethod);self.elements.content.bind(this+".qtip-inactive",inactiveMethod)});inactiveMethod()}clearTimeout(self.timers.show);clearTimeout(self.timers.hide);self.timers.show=setTimeout(function(){self.show(event)},self.options.show.delay)}function hideMethod(event){if(self.status.disabled===true){return}if(self.options.hide.fixed===true&&self.options.hide.when.event.search(/mouse(out|leave)/i)!==-1&&$(event.relatedTarget).parents("div.qtip[qtip]").length>0){event.stopPropagation();event.preventDefault();clearTimeout(self.timers.hide);return false}clearTimeout(self.timers.show);clearTimeout(self.timers.hide);self.elements.tooltip.stop(true,true);self.timers.hide=setTimeout(function(){self.hide(event)},self.options.hide.delay)}if((self.options.show.when.target.add(self.options.hide.when.target).length===1&&self.options.show.when.event==self.options.hide.when.event&&self.options.hide.when.event!=="inactive")||self.options.hide.when.event=="unfocus"){self.cache.toggle=0;showTarget.bind(self.options.show.when.event+".qtip",function(event){if(self.cache.toggle==0){showMethod(event)}else{hideMethod(event)}})}else{showTarget.bind(self.options.show.when.event+".qtip",showMethod);if(self.options.hide.when.event!=="inactive"){hideTarget.bind(self.options.hide.when.event+".qtip",hideMethod)}}if(self.options.position.type.search(/(fixed|absolute)/)!==-1){self.elements.tooltip.bind("mouseover.qtip",self.focus)}if(self.options.position.target==="mouse"&&self.options.position.type!=="static"){showTarget.bind("mousemove.qtip",function(event){self.cache.mouse={x:event.pageX,y:event.pageY};if(self.status.disabled===false&&self.options.position.adjust.mouse===true&&self.options.position.type!=="static"&&self.elements.tooltip.css("display")!=="none"){self.updatePosition(event)}})}}function screenAdjust(position,target,tooltip){var self,adjustedPosition,adjust,newCorner,overflow,corner;self=this;if(tooltip.corner=="center"){return target.position}adjustedPosition=$.extend({},position);newCorner={x:false,y:false};overflow={left:(adjustedPosition.left<$.fn.qtip.cache.screen.scroll.left),right:(adjustedPosition.left+tooltip.dimensions.width+2>=$.fn.qtip.cache.screen.width+$.fn.qtip.cache.screen.scroll.left),top:(adjustedPosition.top<$.fn.qtip.cache.screen.scroll.top),bottom:(adjustedPosition.top+tooltip.dimensions.height+2>=$.fn.qtip.cache.screen.height+$.fn.qtip.cache.screen.scroll.top)};adjust={left:(overflow.left&&(tooltip.corner.search(/right/i)!=-1||(tooltip.corner.search(/right/i)==-1&&!overflow.right))),right:(overflow.right&&(tooltip.corner.search(/left/i)!=-1||(tooltip.corner.search(/left/i)==-1&&!overflow.left))),top:(overflow.top&&tooltip.corner.search(/top/i)==-1),bottom:(overflow.bottom&&tooltip.corner.search(/bottom/i)==-1)};if(adjust.left){if(self.options.position.target!=="mouse"){adjustedPosition.left=target.position.left+target.dimensions.width}else{adjustedPosition.left=self.cache.mouse.x}newCorner.x="Left"}else{if(adjust.right){if(self.options.position.target!=="mouse"){adjustedPosition.left=target.position.left-tooltip.dimensions.width}else{adjustedPosition.left=self.cache.mouse.x-tooltip.dimensions.width}newCorner.x="Right"}}if(adjust.top){if(self.options.position.target!=="mouse"){adjustedPosition.top=target.position.top+target.dimensions.height}else{adjustedPosition.top=self.cache.mouse.y}newCorner.y="top"}else{if(adjust.bottom){if(self.options.position.target!=="mouse"){adjustedPosition.top=target.position.top-tooltip.dimensions.height}else{adjustedPosition.top=self.cache.mouse.y-tooltip.dimensions.height}newCorner.y="bottom"}}if(adjustedPosition.left<0){adjustedPosition.left=position.left;newCorner.x=false}if(adjustedPosition.top<0){adjustedPosition.top=position.top;newCorner.y=false}if(self.options.style.tip.corner!==false){adjustedPosition.corner=new String(tooltip.corner);if(newCorner.x!==false){adjustedPosition.corner=adjustedPosition.corner.replace(/Left|Right|Middle/,newCorner.x)}if(newCorner.y!==false){adjustedPosition.corner=adjustedPosition.corner.replace(/top|bottom/,newCorner.y)}if(adjustedPosition.corner!==self.elements.tip.attr("rel")){createTip.call(self,adjustedPosition.corner)}}return adjustedPosition}function jQueryStyle(style,sub){var styleObj,i;styleObj=$.extend(true,{},style);for(i in styleObj){if(sub===true&&i.search(/(tip|classes)/i)!==-1){delete styleObj[i]}else{if(!sub&&i.search(/(width|border|tip|title|classes|user)/i)!==-1){delete styleObj[i]}}}return styleObj}function sanitizeStyle(style){if(typeof style.tip!=="object"){style.tip={corner:style.tip}}if(typeof style.tip.size!=="object"){style.tip.size={width:style.tip.size,height:style.tip.size}}if(typeof style.border!=="object"){style.border={width:style.border}}if(typeof style.width!=="object"){style.width={value:style.width}}if(typeof style.width.max=="string"){style.width.max=parseInt(style.width.max.replace(/([0-9]+)/i,"$1"))}if(typeof style.width.min=="string"){style.width.min=parseInt(style.width.min.replace(/([0-9]+)/i,"$1"))}if(typeof style.tip.size.x=="number"){style.tip.size.width=style.tip.size.x;delete style.tip.size.x}if(typeof style.tip.size.y=="number"){style.tip.size.height=style.tip.size.y;delete style.tip.size.y}return style}function buildStyle(){var self,i,styleArray,styleExtend,finalStyle,ieAdjust;self=this;styleArray=[true,{}];for(i=0;i0){finalStyle.tip.size.width+=1}if(finalStyle.tip.size.height%2>0){finalStyle.tip.size.height+=1}if(finalStyle.tip.corner===true){finalStyle.tip.corner=(self.options.position.corner.tooltip==="center")?false:self.options.position.corner.tooltip}return finalStyle}function calculateTip(corner,width,height){var tips={bottomRight:[[0,0],[width,height],[width,0]],bottomLeft:[[0,0],[width,0],[0,height]],topRight:[[0,height],[width,0],[width,height]],topLeft:[[0,0],[0,height],[width,height]],topMiddle:[[0,height],[width/2,0],[width,height]],bottomMiddle:[[0,0],[width,0],[width/2,height]],rightMiddle:[[0,0],[width,height/2],[0,height]],leftMiddle:[[width,0],[width,height],[0,height/2]]};tips.leftTop=tips.bottomRight;tips.rightTop=tips.bottomLeft;tips.leftBottom=tips.topRight;tips.rightBottom=tips.topLeft;return tips[corner]}function calculateBorders(radius){var borders;if($("").get(0).getContext){borders={topLeft:[radius,radius],topRight:[0,radius],bottomLeft:[radius,0],bottomRight:[0,0]}}else{if($.browser.msie){borders={topLeft:[-90,90,0],topRight:[-90,90,-radius],bottomLeft:[90,270,0],bottomRight:[90,270,-radius]}}}return borders}function bgiframe(){var self,html,dimensions;self=this;dimensions=self.getDimensions();html='';self.elements.bgiframe=self.elements.wrapper.prepend(html).children(".qtip-bgiframe:first")}$(document).ready(function(){$.fn.qtip.cache={screen:{scroll:{left:$(window).scrollLeft(),top:$(window).scrollTop()},width:$(window).width(),height:$(window).height()}};var adjustTimer;$(window).bind("resize scroll",function(event){clearTimeout(adjustTimer);adjustTimer=setTimeout(function(){if(event.type==="scroll"){$.fn.qtip.cache.screen.scroll={left:$(window).scrollLeft(),top:$(window).scrollTop()}}else{$.fn.qtip.cache.screen.width=$(window).width();$.fn.qtip.cache.screen.height=$(window).height()}for(i=0;i<$.fn.qtip.interfaces.length;i++){var api=$.fn.qtip.interfaces[i];if(api.status.rendered===true&&(api.options.position.type!=="static"||api.options.position.adjust.scroll&&event.type==="scroll"||api.options.position.adjust.resize&&event.type==="resize")){api.updatePosition(event,true)}}},100)});$(document).bind("mousedown.qtip",function(event){if($(event.target).parents("div.qtip").length===0){$(".qtip[unfocus]").each(function(){var api=$(this).qtip("api");if($(this).is(":visible")&&!api.status.disabled&&$(event.target).add(api.elements.target).length>1){api.hide(event)}})}})});$.fn.qtip.interfaces=[];$.fn.qtip.log={error:function(){return this}};$.fn.qtip.constants={};$.fn.qtip.defaults={content:{prerender:false,text:false,url:false,data:null,title:{text:false,button:false}},position:{target:false,corner:{target:"bottomRight",tooltip:"topLeft"},adjust:{x:0,y:0,mouse:true,screen:false,scroll:true,resize:true},type:"absolute",container:false},show:{when:{target:false,event:"mouseover"},effect:{type:"fade",length:100},delay:140,solo:false,ready:false},hide:{when:{target:false,event:"mouseout"},effect:{type:"fade",length:100},delay:0,fixed:false},api:{beforeRender:function(){},onRender:function(){},beforePositionUpdate:function(){},onPositionUpdate:function(){},beforeShow:function(){},onShow:function(){},beforeHide:function(){},onHide:function(){},beforeContentUpdate:function(){},onContentUpdate:function(){},beforeContentLoad:function(){},onContentLoad:function(){},beforeTitleUpdate:function(){},onTitleUpdate:function(){},beforeDestroy:function(){},onDestroy:function(){},beforeFocus:function(){},onFocus:function(){}}};$.fn.qtip.styles={defaults:{background:"white",color:"#111",overflow:"hidden",textAlign:"left",width:{min:0,max:250},padding:"5px 9px",border:{width:1,radius:0,color:"#d3d3d3"},tip:{corner:false,color:false,size:{width:13,height:13},opacity:1},title:{background:"#e1e1e1",fontWeight:"bold",padding:"7px 12px"},button:{cursor:"pointer"},classes:{target:"",tip:"qtip-tip",title:"qtip-title",button:"qtip-button",content:"qtip-content",active:"qtip-active"}},cream:{border:{width:3,radius:0,color:"#F9E98E"},title:{background:"#F0DE7D",color:"#A27D35"},background:"#FBF7AA",color:"#A27D35",classes:{tooltip:"qtip-cream"}},light:{border:{width:3,radius:0,color:"#E2E2E2"},title:{background:"#f1f1f1",color:"#454545"},background:"white",color:"#454545",classes:{tooltip:"qtip-light"}},dark:{border:{width:3,radius:0,color:"#303030"},title:{background:"#404040",color:"#f3f3f3"},background:"#505050",color:"#f3f3f3",classes:{tooltip:"qtip-dark"}},red:{border:{width:3,radius:0,color:"#CE6F6F"},title:{background:"#f28279",color:"#9C2F2F"},background:"#F79992",color:"#9C2F2F",classes:{tooltip:"qtip-red"}},green:{border:{width:3,radius:0,color:"#A9DB66"},title:{background:"#b9db8c",color:"#58792E"},background:"#CDE6AC",color:"#58792E",classes:{tooltip:"qtip-green"}},blue:{border:{width:3,radius:0,color:"#ADD9ED"},title:{background:"#D0E9F5",color:"#5E99BD"},background:"#E5F6FE",color:"#4D9FBF",classes:{tooltip:"qtip-blue"}}}})(jQuery); \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/livequery.js b/blog/wp-content/plugins/front-end-editor/editor/livequery.js new file mode 100644 index 0000000..398f0a4 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/livequery.js @@ -0,0 +1,9 @@ +/* Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net) + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. + * + * Version: 1.0.3 + * Requires jQuery 1.1.3+ + * Docs: http://docs.jquery.com/Plugins/livequery + */ +(function($){$.extend($.fn,{livequery:function(type,fn,fn2){var self=this,q;if($.isFunction(type)){fn2=fn,fn=type,type=undefined}$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&type==query.type&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)){return(q=query)&&false}});q=q||new $.livequery(this.selector,this.context,type,fn,fn2);q.stopped=false;q.run();return this},expire:function(type,fn,fn2){var self=this;if($.isFunction(type)){fn2=fn,fn=type,type=undefined}$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&(!type||type==query.type)&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)&&!this.stopped){$.livequery.stop(query.id)}});return this}});$.livequery=function(selector,context,type,fn,fn2){this.selector=selector;this.context=context||document;this.type=type;this.fn=fn;this.fn2=fn2;this.elements=[];this.stopped=false;this.id=$.livequery.queries.push(this)-1;fn.$lqguid=fn.$lqguid||$.livequery.guid++;if(fn2){fn2.$lqguid=fn2.$lqguid||$.livequery.guid++}return this};$.livequery.prototype={stop:function(){var query=this;if(this.type){this.elements.unbind(this.type,this.fn)}else{if(this.fn2){this.elements.each(function(i,el){query.fn2.apply(el)})}}this.elements=[];this.stopped=true},run:function(){if(this.stopped){return}var query=this;var oEls=this.elements,els=$(this.selector,this.context),nEls=els.not(oEls);this.elements=els;if(this.type){nEls.bind(this.type,this.fn);if(oEls.length>0){$.each(oEls,function(i,el){if($.inArray(el,els)<0){$.event.remove(el,query.type,query.fn)}})}}else{nEls.each(function(){query.fn.apply(this)});if(this.fn2&&oEls.length>0){$.each(oEls,function(i,el){if($.inArray(el,els)<0){query.fn2.apply(el)}})}}}};$.extend($.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if($.livequery.running&&$.livequery.queue.length){var length=$.livequery.queue.length;while(length--){$.livequery.queries[$.livequery.queue.shift()].run()}}},pause:function(){$.livequery.running=false},play:function(){$.livequery.running=true;$.livequery.run()},registerPlugin:function(){$.each(arguments,function(i,n){if(!$.fn[n]){return}var old=$.fn[n];$.fn[n]=function(){var r=old.apply(this,arguments);$.livequery.run();return r}})},run:function(id){if(id!=undefined){if($.inArray(id,$.livequery.queue)<0){$.livequery.queue.push(id)}}else{$.each($.livequery.queries,function(id){if($.inArray(id,$.livequery.queue)<0){$.livequery.queue.push(id)}})}if($.livequery.timeout){clearTimeout($.livequery.timeout)}$.livequery.timeout=setTimeout($.livequery.checkQueue,20)},stop:function(id){if(id!=undefined){$.livequery.queries[id].stop()}else{$.each($.livequery.queries,function(id){$.livequery.queries[id].stop()})}}});$.livequery.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove");$(function(){$.livequery.play()});var init=$.prototype.init;$.prototype.init=function(a,c){var r=init.apply(this,arguments);if(a&&a.selector){r.context=a.context,r.selector=a.selector}if(typeof a=="string"){r.context=c||document,r.selector=a}return r};$.prototype.init.prototype=$.prototype})(jQuery); \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/nicedit/nicEdit.dev.js b/blog/wp-content/plugins/front-end-editor/editor/nicedit/nicEdit.dev.js new file mode 100644 index 0000000..161292d --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/nicedit/nicEdit.dev.js @@ -0,0 +1,1484 @@ +/* NicEdit - Micro Inline WYSIWYG + * Copyright 2007-2008 Brian Kirchoff + * + * NicEdit is distributed under the terms of the MIT license + * For more information visit http://nicedit.com/ + * Do not remove this copyright message + */ +var bkExtend = function(){ + var args = arguments; + if (args.length == 1) args = [this, args[0]]; + for (var prop in args[1]) args[0][prop] = args[1][prop]; + return args[0]; +}; +function bkClass() { } +bkClass.prototype.construct = function() {}; +bkClass.extend = function(def) { + var classDef = function() { + if (arguments[0] !== bkClass) { return this.construct.apply(this, arguments); } + }; + var proto = new this(bkClass); + bkExtend(proto,def); + classDef.prototype = proto; + classDef.extend = this.extend; + return classDef; +}; + +var bkElement = bkClass.extend({ + construct : function(elm,d) { + if(typeof(elm) == "string") { + elm = (d || document).createElement(elm); + } + elm = $BK(elm); + return elm; + }, + + appendTo : function(elm) { + elm.appendChild(this); + return this; + }, + + appendBefore : function(elm) { + elm.parentNode.insertBefore(this,elm); + return this; + }, + + addEvent : function(type, fn) { + bkLib.addEvent(this,type,fn); + return this; + }, + + setContent : function(c) { + this.innerHTML = c; + return this; + }, + + pos : function() { + var curleft = curtop = 0; + var o = obj = this; + if (obj.offsetParent) { + do { + curleft += obj.offsetLeft; + curtop += obj.offsetTop; + } while (obj = obj.offsetParent); + } + var b = (!window.opera) ? parseInt(this.getStyle('border-width') || this.style.border) || 0 : 0; + return [curleft+b,curtop+b+this.offsetHeight]; + }, + + noSelect : function() { + bkLib.noSelect(this); + return this; + }, + + parentTag : function(t) { + var elm = this; + do { + if(elm && elm.nodeName && elm.nodeName.toUpperCase() == t) { + return elm; + } + elm = elm.parentNode; + } while(elm); + return false; + }, + + hasClass : function(cls) { + return this.className.match(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)')); + }, + + addClass : function(cls) { + if (!this.hasClass(cls)) { this.className += " nicEdit-"+cls }; + return this; + }, + + removeClass : function(cls) { + if (this.hasClass(cls)) { + this.className = this.className.replace(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)'),' '); + } + return this; + }, + + setStyle : function(st) { + var elmStyle = this.style; + for(var itm in st) { + switch(itm) { + case 'float': + elmStyle['cssFloat'] = elmStyle['styleFloat'] = st[itm]; + break; + case 'opacity': + elmStyle.opacity = st[itm]; + elmStyle.filter = "alpha(opacity=" + Math.round(st[itm]*100) + ")"; + break; + case 'className': + this.className = st[itm]; + break; + default: + //if(document.compatMode || itm != "cursor") { // Nasty Workaround for IE 5.5 + elmStyle[itm] = st[itm]; + //} + } + } + return this; + }, + + getStyle : function( cssRule, d ) { + var doc = (!d) ? document.defaultView : d; + if(this.nodeType == 1) + return (doc && doc.getComputedStyle) ? doc.getComputedStyle( this, null ).getPropertyValue(cssRule) : this.currentStyle[ bkLib.camelize(cssRule) ]; + }, + + remove : function() { + this.parentNode.removeChild(this); + return this; + }, + + setAttributes : function(at) { + for(var itm in at) { + this[itm] = at[itm]; + } + return this; + } +}); + +var bkLib = { + isMSIE : (navigator.appVersion.indexOf("MSIE") != -1), + + addEvent : function(obj, type, fn) { + (obj.addEventListener) ? obj.addEventListener( type, fn, false ) : obj.attachEvent("on"+type, fn); + }, + + toArray : function(iterable) { + var length = iterable.length, results = new Array(length); + while (length--) { results[length] = iterable[length] }; + return results; + }, + + noSelect : function(element) { + if(element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') { + element.setAttribute('unselectable','on'); + } + for(var i=0;i.nicEdit-main p { margin: 0; }<\/scr"+"ipt>"); + $BK("__ie_onload").onreadystatechange = function() { + if (this.readyState == "complete"){bkLib.domLoaded();} + }; + } + window.onload = bkLib.domLoaded; + } +}; + +function $BK(elm) { + if(typeof(elm) == "string") { + elm = document.getElementById(elm); + } + return (elm && !elm.appendTo) ? bkExtend(elm,bkElement.prototype) : elm; +} + +var bkEvent = { + addEvent : function(evType, evFunc) { + if(evFunc) { + this.eventList = this.eventList || {}; + this.eventList[evType] = this.eventList[evType] || []; + this.eventList[evType].push(evFunc); + } + return this; + }, + fireEvent : function() { + var args = bkLib.toArray(arguments), evType = args.shift(); + if(this.eventList && this.eventList[evType]) { + for(var i=0;i'); + } + this.instanceDoc = document.defaultView; + this.elm.addEvent('mousedown',this.selected.closureListener(this)).addEvent('keypress',this.keyDown.closureListener(this)).addEvent('focus',this.selected.closure(this)).addEvent('blur',this.blur.closure(this)).addEvent('keyup',this.selected.closure(this)); + this.ne.fireEvent('add',this); + }, + + remove : function() { + this.saveContent(); + if(this.copyElm || this.options.hasPanel) { + this.editorContain.remove(); + this.e.setStyle({'display' : 'block'}); + this.ne.removePanel(); + } + this.disable(); + this.ne.fireEvent('remove',this); + }, + + disable : function() { + this.elm.setAttribute('contentEditable','false'); + }, + + getSel : function() { + return (window.getSelection) ? window.getSelection() : document.selection; + }, + + getRng : function() { + var s = this.getSel(); + if(!s) { return null; } + return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange(); + }, + + selRng : function(rng,s) { + if(window.getSelection) { + s.removeAllRanges(); + s.addRange(rng); + } else { + rng.select(); + } + }, + + selElm : function() { + var r = this.getRng(); + if(r.startContainer) { + var contain = r.startContainer; + if(r.cloneContents().childNodes.length == 1) { + for(var i=0;i'+((css) ? '' : '')+''+this.initialContent+'
]+>.*?)<\/p>/g, '$1
+ content = content.replace(/
/gi, '
and + content = content.replace(/\s*
/gi, ''); + content = content.replace(/\s*<\/p>\s*/gi, '\n\n'); + content = content.replace(/\n[\s\u00a0]+\n/g, '\n\n'); + content = content.replace(/\s*\s*/gi, '\n'); + + // Fix some block element newline issues + content = content.replace(/\s*
]+>[\s\S]*?<\/p>)/g, '\n$1'); + + // Trim whitespace + content = content.replace(/^\s+/, ''); + content = content.replace(/[\s\u00a0]+$/, ''); + + // put back the line breaks in pre|script + content = content.replace(//g, '\n'); + + return content; + }, + + ajax_set: function() { + var self = this; + + self.editor.nicInstances[0].saveContent(); + + self._super(); + } + }); + + // export + FrontEndEditor.fieldTypes = fieldTypes; + +$(document).ready(function($) { + // Widget fields hack: Add data-fee attr to each element + $('.fee-filter-widget_title, .fee-filter-widget_text').each(function() { + var $el = $(this); + var id = $el.parents('.widget').attr('id'); + + if ( id ) + $el.attr('data-fee', id); + else + // undo wrap; can't find widget id + $el.replaceWith($el.html()); + }); + + // Create field instances + $.each(FrontEndEditor.data.fields, function(name, type) { + $('.fee-filter-' + name).each(function() { + var $el = $(this); + + var id = $el.attr('data-fee'); + + var parts = id.split('#'); + + switch (name) { + case 'post_meta': type = parts[2]; break; + case 'editable_option': type = parts[1]; break; + } + + new fieldTypes[type]($el, type, name, id); + }); + }); + + // Tooltip init + if ( FrontEndEditor.data.tooltip ) { + $.fn.qtip.styles.fee = { + height: 10, + paddingTop: '4px', + paddingRight: '5px', + paddingBottom: '6px', + paddingLeft: '25px', + background: '#bbbebf url(' + FrontEndEditor.data.tooltip.icon + ') top left no-repeat', + color: '#ffffff', + textAlign: 'left', + lineHeight: '100%', + fontFamily: 'sans-serif', + fontSize: '14px', + opacity: '0.75', + border: { + width: 0, + radius: 5, + color: '#bbbebf' + }, + tip: 'bottomLeft', + name: 'dark' + }; + + $('.fee-field').qtip({ + content: FrontEndEditor.data.tooltip.text, + position: { corner: { target: 'topMiddle' }, adjust: { x: 0, y: -40 } }, + show: { + effect: 'fade' + }, + + style: { + name: 'fee' + } + }); + } +}); +})(jQuery); diff --git a/blog/wp-content/plugins/front-end-editor/editor/editor.js b/blog/wp-content/plugins/front-end-editor/editor/editor.js new file mode 100644 index 0000000..83ff808 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/editor.js @@ -0,0 +1 @@ +(function($){if(FrontEndEditor._loaded){return}FrontEndEditor._loaded=true;(function(){var initializing=false,fnTest=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(prop){var _super=this.prototype;initializing=true;var prototype=new this();initializing=false;for(var name in prop){prototype[name]=(typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name]))?(function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);this._super=tmp;return ret}})(name,prop[name]):prop[name]}function Class(){if(!initializing&&this.init){this.init.apply(this,arguments)}}Class.prototype=prototype;Class.constructor=Class;Class.extend=arguments.callee;return Class}})();var spinner=$("").attr({src:FrontEndEditor.data.spinner,"class":"front-editor-spinner"});var is_overlay=function($el){var attr=[$el.attr("id"),$el.attr("class"),$el.attr("rel")];var tokens=["lightbox","thickbox","shutter","awppost_link"];for(var i in tokens){for(var j in attr){if(attr[j].indexOf(tokens[i])!=-1){return true}}}return false};var resume=function(){if(FrontEndEditor._trap){return}var $link=FrontEndEditor._to_click;if(typeof $link=="undefined"){return}if(typeof $link.attr("href")!="undefined"&&$link.attr("href")!="#"){if($link.attr("target")=="_blank"){window.open($link.attr("href"))}else{window.location.href=$link.attr("href")}}delete FrontEndEditor._to_click};var fieldTypes={};fieldTypes.base=Class.extend({init:function($el,type,name,id){var self=this;self.set_el($el);self.type=type;self.name=name;self.id=id;self.bind(self.el,"click",self.click);self.bind(self.el,"dblclick",self.dblclick)},set_el:function($el){var self=this;self.el=$el;var $parent=self.el.parents("a");if(!$parent.length){return}var $link=$parent.clone(true).html(self.el.html());var $wrap=self.el.clone(true).html($link);$parent.replaceWith($wrap);self.el=$wrap;self.switched=true},click:function(ev){var $el=$(ev.target).closest("a");if(!$el.length){return}if(is_overlay($el)){return}ev.stopImmediatePropagation();ev.preventDefault();FrontEndEditor._to_click=$el;setTimeout(resume,300)},dblclick:function(ev){var self=this;ev.stopPropagation();ev.preventDefault();FrontEndEditor._trap=true},get_content:null,set_content:null,ajax_get_handler:null,ajax_set_handler:null,ajax_get:function(){var self=this;var data={nonce:FrontEndEditor.data.nonce,action:"front-editor",callback:"get",name:self.name,type:self.type,item_id:self.id};$.post(FrontEndEditor.data.ajax_url,data,function(response){self.ajax_get_handler(response)})},ajax_set:function(content){var self=this;content=content||self.get_content();var data={nonce:FrontEndEditor.data.nonce,action:"front-editor",callback:"save",name:self.name,type:self.type,item_id:self.id,content:content};$.post(FrontEndEditor.data.ajax_url,data,function(response){self.ajax_set_handler(response)})},bind:function(element,event,callback){var self=this;element.bind(event,function(ev){callback.call(self,ev)})}});fieldTypes.image=fieldTypes.base.extend({dblclick:function(ev){var self=this;self._super(ev);self.open_box()},open_box:function(){var self=this;tb_show(FrontEndEditor.data.image.change,FrontEndEditor.data.admin_url+"/media-upload.php?post_id=0&type=image&TB_iframe=true&width=640&editable_image=1");var $revert=$('').text(FrontEndEditor.data.image.revert);$revert.click(function(ev){self.ajax_set(-1)});$("#TB_ajaxWindowTitle").after($revert);$("#TB_closeWindowButton img").attr("src",FrontEndEditor.data.image.tb_close);self.bind($("#TB_iframeContent"),"load",self.replace_button)},replace_button:function(ev){var self=this;var $frame=$(ev.target).contents();$(".media-item",$frame).livequery(function(){var $item=$(this);var $button=$('').text(FrontEndEditor.data.image.change);$button.click(function(ev){self.ajax_set(self.get_content($item))});$(this).find(":submit, #go_button").replaceWith($button)})},get_content:function($item){var $field;$field=$item.find(".urlfile");if($field.length){return $field.attr("title")}$field=$item.find("#embed-src");if($field.length){return $field.val()}$field=$item.find("#src");if($field.length){return $field.val()}return false},ajax_set_handler:function(url){var self=this;if(url==-1){window.location.reload(true)}else{self.el.find("img").attr("src",url);tb_remove()}}});fieldTypes.thumbnail=fieldTypes.image.extend({replace_button:function(ev){var self=this;var $frame=$(ev.target).contents();$frame.find("#tab-type_url").remove();self._super(ev)},get_content:function($item){return $item.attr("id").replace("media-item-","")}});fieldTypes.input=fieldTypes.base.extend({init:function($el,type,name,id){var self=this;self.spinner=spinner.clone();self._super($el,type,name,id)},input_tag:'',create_input:function(){var self=this;self.input=$(self.input_tag);self.input.attr({id:"edit_"+self.el.attr("id"),"class":"fee-form-content"}).prependTo(self.form)},set_input:function(content){var self=this;self.input.val(content)},get_content:function(){var self=this;return self.input.val()},set_content:function(content){var self=this;if(self.switched){self.el.find("a").html(content)}else{self.el.html(content)}},ajax_get:function(){var self=this;self.el.hide().after(self.spinner.show());self.create_input();self._super()},ajax_set:function(){var self=this;self.el.before(self.spinner.show());self._super()},ajax_get_handler:function(content){var self=this;self.spinner.hide().replaceWith(self.form);self.set_input(content);self.input.focus()},ajax_set_handler:function(content){var self=this;self.set_content(content);self.spinner.hide();self.el.show()},dblclick:function(ev){var self=this;self._super(ev);self.form_handler()},form_handler:function(){var self=this;var form_remove=function(with_spinner){FrontEndEditor._trap=false;self.form.remove();if(with_spinner===true){self.el.before(self.spinner.show())}else{self.el.show()}self.el.trigger("fee_remove_form")};var form_submit=function(){self.ajax_set();form_remove(true)};self.save_button=$("").addClass("fee-form-save").text(FrontEndEditor.data.save_text).click(form_submit);self.cancel_button=$("").addClass("fee-form-cancel").text(FrontEndEditor.data.cancel_text).click(form_remove);var inline=self.type=="input"||self.type=="terminput";self.form=inline?$(""):$("");self.form.addClass("fee-form").addClass("fee-type-"+self.type).addClass("fee-filter-"+self.name).append(self.save_button).append(self.cancel_button);self.bind(self.form,"keypress",self.keypress);self.ajax_get()},keypress:function(ev){var self=this;var keys={ENTER:13,ESCAPE:27};var code=(ev.keyCode||ev.which||ev.charCode||0);if(code==keys.ENTER&&self.type=="input"){self.save_button.click()}if(code==keys.ESCAPE){self.cancel_button.click()}}});fieldTypes.terminput=fieldTypes.input.extend({set_input:function(content){var self=this;self._super(content);self.input.suggest(FrontEndEditor.data.ajax_url+"?action=ajax-tag-search&tax="+self.id.split("#")[1],{multiple:true,resultsClass:"fee-suggest-results",selectClass:"fee-suggest-over",matchClass:"fee-suggest-match"})}});fieldTypes.textarea=fieldTypes.input.extend({input_tag:''});fieldTypes.rich=fieldTypes.textarea.extend({set_input:function(content){var self=this;self._super(content);self.editor=new nicEditor(FrontEndEditor.data.nicedit).panelInstance(self.input.attr("id"));self.form.find(".nicEdit-main").focus()},get_content:function(){var self=this;return self.pre_wpautop(self.input.val())},pre_wpautop:function(content){var blocklist1,blocklist2;content=content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(a){a=a.replace(/[\r\n]*/g,"");return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"")});blocklist1="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset";content=content.replace(new RegExp("\\s*("+blocklist1+")>\\s*","g"),"$1>\n");content=content.replace(new RegExp("\\s*<(("+blocklist1+")[^>]*)>","g"),"\n<$1>");content=content.replace(/(]+>.*?)<\/p>/g,"$1");content=content.replace(/]*)>\s*/gi,"\n\n");content=content.replace(/\s*/gi,"");content=content.replace(/\s*<\/p>\s*/gi,"\n\n");content=content.replace(/\n[\s\u00a0]+\n/g,"\n\n");content=content.replace(/\s*\s*/gi,"\n");content=content.replace(/\s*\s*/g,"\n");content=content.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi,"\n\n[caption$1[/caption]\n\n");content=content.replace(/caption\]\n\n+\[caption/g,"caption]\n\n[caption");blocklist2="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset";content=content.replace(new RegExp("\\s*<(("+blocklist2+") ?[^>]*)\\s*>","g"),"\n<$1>");content=content.replace(new RegExp("\\s*("+blocklist2+")>\\s*","g"),"$1>\n");content=content.replace(/]*)>/g,"\t");if(content.indexOf("/g,function(a){return a.replace(/[\r\n]+/g,"")})}content=content.replace(/<\/p#>/g,"\n");content=content.replace(/\s*(]+>[\s\S]*?<\/p>)/g,"\n$1");content=content.replace(/^\s+/,"");content=content.replace(/[\s\u00a0]+$/,"");content=content.replace(//g,"\n");return content},ajax_set:function(){var self=this;self.editor.nicInstances[0].saveContent();self._super()}});FrontEndEditor.fieldTypes=fieldTypes;$(document).ready(function($){$(".fee-filter-widget_title, .fee-filter-widget_text").each(function(){var $el=$(this);var id=$el.parents(".widget").attr("id");if(id){$el.attr("data-fee",id)}else{$el.replaceWith($el.html())}});$.each(FrontEndEditor.data.fields,function(name,type){$(".fee-filter-"+name).each(function(){var $el=$(this);var id=$el.attr("data-fee");var parts=id.split("#");switch(name){case"post_meta":type=parts[2];break;case"editable_option":type=parts[1];break}new fieldTypes[type]($el,type,name,id)})});if(FrontEndEditor.data.tooltip){$.fn.qtip.styles.fee={height:10,paddingTop:"4px",paddingRight:"5px",paddingBottom:"6px",paddingLeft:"25px",background:"#bbbebf url("+FrontEndEditor.data.tooltip.icon+") top left no-repeat",color:"#ffffff",textAlign:"left",lineHeight:"100%",fontFamily:"sans-serif",fontSize:"14px",opacity:"0.75",border:{width:0,radius:5,color:"#bbbebf"},tip:"bottomLeft",name:"dark"};$(".fee-field").qtip({content:FrontEndEditor.data.tooltip.text,position:{corner:{target:"topMiddle"},adjust:{x:0,y:-40}},show:{effect:"fade"},style:{name:"fee"}})}})})(jQuery); \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/editor.png b/blog/wp-content/plugins/front-end-editor/editor/editor.png new file mode 100644 index 0000000..1bc05e8 Binary files /dev/null and b/blog/wp-content/plugins/front-end-editor/editor/editor.png differ diff --git a/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.dev.js b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.dev.js new file mode 100644 index 0000000..0258a66 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.dev.js @@ -0,0 +1,2149 @@ +/*! + * jquery.qtip. The jQuery tooltip plugin + * + * Copyright (c) 2009 Craig Thompson + * http://craigsworks.com + * + * Licensed under MIT + * http://www.opensource.org/licenses/mit-license.php + * + * Launch : February 2009 + * Version : 1.0.0-rc3 + * Released: Tuesday 12th May, 2009 - 00:00 + * Debug: jquery.qtip.debug.js + */ +(function($) +{ + // Implementation + $.fn.qtip = function(options, blanket) + { + var i, id, interfaces, opts, obj, command, config, api; + + // Return API / Interfaces if requested + if(typeof options == 'string') + { + // Make sure API data exists if requested + if(typeof $(this).data('qtip') !== 'object') + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.NO_TOOLTIP_PRESENT, false); + + // Return requested object + if(options == 'api') + return $(this).data('qtip').interfaces[ $(this).data('qtip').current ]; + else if(options == 'interfaces') + return $(this).data('qtip').interfaces; + } + + // Validate provided options + else + { + // Set null options object if no options are provided + if(!options) options = {}; + + // Sanitize option data + if(typeof options.content !== 'object' || (options.content.jquery && options.content.length > 0)) options.content = { text: options.content }; + if(typeof options.content.title !== 'object') options.content.title = { text: options.content.title }; + if(typeof options.position !== 'object') options.position = { corner: options.position }; + if(typeof options.position.corner !== 'object') options.position.corner = { target: options.position.corner, tooltip: options.position.corner }; + if(typeof options.show !== 'object') options.show = { when: options.show }; + if(typeof options.show.when !== 'object') options.show.when = { event: options.show.when }; + if(typeof options.show.effect !== 'object') options.show.effect = { type: options.show.effect }; + if(typeof options.hide !== 'object') options.hide = { when: options.hide }; + if(typeof options.hide.when !== 'object') options.hide.when = { event: options.hide.when }; + if(typeof options.hide.effect !== 'object') options.hide.effect = { type: options.hide.effect }; + if(typeof options.style !== 'object') options.style = { name: options.style }; + options.style = sanitizeStyle(options.style); + + // Build main options object + opts = $.extend(true, {}, $.fn.qtip.defaults, options); + + // Inherit all style properties into one syle object and include original options + opts.style = buildStyle.call({ options: opts }, opts.style); + opts.user = $.extend(true, {}, options); + }; + + // Iterate each matched element + return $(this).each(function() // Return original elements as per jQuery guidelines + { + // Check for API commands + if(typeof options == 'string') + { + command = options.toLowerCase(); + interfaces = $(this).qtip('interfaces'); + + // Make sure API data exists$('.qtip').qtip('destroy') + if(typeof interfaces == 'object') + { + // Check if API call is a BLANKET DESTROY command + if(blanket === true && command == 'destroy') + while(interfaces.length > 0) interfaces[interfaces.length-1].destroy(); + + // API call is not a BLANKET DESTROY command + else + { + // Check if supplied command effects this tooltip only (NOT BLANKET) + if(blanket !== true) interfaces = [ $(this).qtip('api') ]; + + // Execute command on chosen qTips + for(i = 0; i < interfaces.length; i++) + { + // Destroy command doesn't require tooltip to be rendered + if(command == 'destroy') interfaces[i].destroy(); + + // Only call API if tooltip is rendered and it wasn't a destroy call + else if(interfaces[i].status.rendered === true) + { + if(command == 'show') interfaces[i].show(); + else if(command == 'hide') interfaces[i].hide(); + else if(command == 'focus') interfaces[i].focus(); + else if(command == 'disable') interfaces[i].disable(true); + else if(command == 'enable') interfaces[i].disable(false); + }; + }; + }; + }; + } + + // No API commands, continue with qTip creation + else + { + // Create unique configuration object + config = $.extend(true, {}, opts); + config.hide.effect.length = opts.hide.effect.length; + config.show.effect.length = opts.show.effect.length; + + // Sanitize target options + if(config.position.container === false) config.position.container = $(document.body); + if(config.position.target === false) config.position.target = $(this); + if(config.show.when.target === false) config.show.when.target = $(this); + if(config.hide.when.target === false) config.hide.when.target = $(this); + + // Determine tooltip ID (Reuse array slots if possible) + id = $.fn.qtip.interfaces.length; + for(i = 0; i < id; i++) + { + if(typeof $.fn.qtip.interfaces[i] == 'undefined'){ id = i; break; }; + }; + + // Instantiate the tooltip + obj = new qTip($(this), config, id); + + // Add API references + $.fn.qtip.interfaces[id] = obj; + + // Check if element already has qTip data assigned + if( $(this).data('qtip') ) + { + // Set new current interface id + if(typeof $(this).attr('qtip') === 'undefined') + $(this).data('qtip').current = $(this).data('qtip').interfaces.length; + + // Push new API interface onto interfaces array + $(this).data('qtip').interfaces.push(obj); + } + + // No qTip data is present, create now + else $(this).data('qtip', { current: 0, interfaces: [obj] }); + + // If prerendering is disabled, create tooltip on showEvent + if(config.content.prerender === false && config.show.when.event !== false && config.show.ready !== true) + { + config.show.when.target.bind(config.show.when.event+'.qtip-'+id+'-create', { qtip: id }, function(event) + { + // Retrieve API interface via passed qTip Id + api = $.fn.qtip.interfaces[ event.data.qtip ]; + + // Unbind show event and cache mouse coords + api.options.show.when.target.unbind(api.options.show.when.event+'.qtip-'+event.data.qtip+'-create'); + api.cache.mouse = { x: event.pageX, y: event.pageY }; + + // Render tooltip and start the event sequence + construct.call( api ); + api.options.show.when.target.trigger(api.options.show.when.event); + }); + } + + // Prerendering is enabled, create tooltip now + else + { + // Set mouse position cache to top left of the element + obj.cache.mouse = { + x: config.show.when.target.offset().left, + y: config.show.when.target.offset().top + }; + + // Construct the tooltip + construct.call(obj); + } + }; + }); + }; + + // Instantiator + function qTip(target, options, id) + { + // Declare this reference + var self = this; + + // Setup class attributes + self.id = id; + self.options = options; + self.status = { + animated: false, + rendered: false, + disabled: false, + focused: false + }; + self.elements = { + target: target.addClass(self.options.style.classes.target), + tooltip: null, + wrapper: null, + content: null, + contentWrapper: null, + title: null, + button: null, + tip: null, + bgiframe: null + }; + self.cache = { + mouse: {}, + position: {}, + toggle: 0 + }; + self.timers = {}; + + // Define exposed API methods + $.extend(self, self.options.api, + { + show: function(event) + { + var returned, solo; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'show'); + + // Only continue if element is visible + if(self.elements.tooltip.css('display') !== 'none') return self; + + // Clear animation queue + self.elements.tooltip.stop(true, false); + + // Call API method and if return value is false, halt + returned = self.beforeShow.call(self, event); + if(returned === false) return self; + + // Define afterShow callback method + function afterShow() + { + // Call API method and focus if it isn't static + if(self.options.position.type !== 'static') self.focus(); + self.onShow.call(self, event); + + // Prevent antialias from disappearing in IE7 by removing filter attribute + if($.browser.msie) self.elements.tooltip.get(0).style.removeAttribute('filter'); + }; + + // Maintain toggle functionality if enabled + self.cache.toggle = 1; + + // Update tooltip position if it isn't static + if(self.options.position.type !== 'static') + self.updatePosition(event, (self.options.show.effect.length > 0)); + + // Hide other tooltips if tooltip is solo + if(typeof self.options.show.solo == 'object') solo = $(self.options.show.solo); + else if(self.options.show.solo === true) solo = $('div.qtip').not(self.elements.tooltip); + if(solo) solo.each(function(){ if($(this).qtip('api').status.rendered === true) $(this).qtip('api').hide(); }); + + // Show tooltip + if(typeof self.options.show.effect.type == 'function') + { + self.options.show.effect.type.call(self.elements.tooltip, self.options.show.effect.length); + self.elements.tooltip.queue(function(){ afterShow(); $(this).dequeue(); }); + } + else + { + switch(self.options.show.effect.type.toLowerCase()) + { + case 'fade': + self.elements.tooltip.fadeIn(self.options.show.effect.length, afterShow); + break; + case 'slide': + self.elements.tooltip.slideDown(self.options.show.effect.length, function() + { + afterShow(); + if(self.options.position.type !== 'static') self.updatePosition(event, true); + }); + break; + case 'grow': + self.elements.tooltip.show(self.options.show.effect.length, afterShow); + break; + default: + self.elements.tooltip.show(null, afterShow); + break; + }; + + // Add active class to tooltip + self.elements.tooltip.addClass(self.options.style.classes.active); + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_SHOWN, 'show'); + }, + + hide: function(event) + { + var returned; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'hide'); + + // Only continue if element is visible + else if(self.elements.tooltip.css('display') === 'none') return self; + + // Stop show timer and animation queue + clearTimeout(self.timers.show); + self.elements.tooltip.stop(true, false); + + // Call API method and if return value is false, halt + returned = self.beforeHide.call(self, event); + if(returned === false) return self; + + // Define afterHide callback method + function afterHide(){ self.onHide.call(self, event); }; + + // Maintain toggle functionality if enabled + self.cache.toggle = 0; + + // Hide tooltip + if(typeof self.options.hide.effect.type == 'function') + { + self.options.hide.effect.type.call(self.elements.tooltip, self.options.hide.effect.length); + self.elements.tooltip.queue(function(){ afterHide(); $(this).dequeue(); }); + } + else + { + switch(self.options.hide.effect.type.toLowerCase()) + { + case 'fade': + self.elements.tooltip.fadeOut(self.options.hide.effect.length, afterHide); + break; + case 'slide': + self.elements.tooltip.slideUp(self.options.hide.effect.length, afterHide); + break; + case 'grow': + self.elements.tooltip.hide(self.options.hide.effect.length, afterHide); + break; + default: + self.elements.tooltip.hide(null, afterHide); + break; + }; + + // Remove active class to tooltip + self.elements.tooltip.removeClass(self.options.style.classes.active); + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_HIDDEN, 'hide'); + }, + + updatePosition: function(event, animate) + { + var i, target, tooltip, coords, mapName, imagePos, newPosition, ieAdjust, ie6Adjust, borderAdjust, mouseAdjust, offset, curPosition, returned + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updatePosition'); + + // If tooltip is static, return + else if(self.options.position.type == 'static') + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.CANNOT_POSITION_STATIC, 'updatePosition'); + + // Define property objects + target = { + position: { left: 0, top: 0 }, + dimensions: { height: 0, width: 0 }, + corner: self.options.position.corner.target + }; + tooltip = { + position: self.getPosition(), + dimensions: self.getDimensions(), + corner: self.options.position.corner.tooltip + }; + + // Target is an HTML element + if(self.options.position.target !== 'mouse') + { + // If the HTML element is AREA, calculate position manually + if(self.options.position.target.get(0).nodeName.toLowerCase() == 'area') + { + // Retrieve coordinates from coords attribute and parse into integers + coords = self.options.position.target.attr('coords').split(','); + for(i = 0; i < coords.length; i++) coords[i] = parseInt(coords[i]); + + // Setup target position object + mapName = self.options.position.target.parent('map').attr('name'); + imagePos = $('img[usemap="#'+mapName+'"]:first').offset(); + target.position = { + left: Math.floor(imagePos.left + coords[0]), + top: Math.floor(imagePos.top + coords[1]) + }; + + // Determine width and height of the area + switch(self.options.position.target.attr('shape').toLowerCase()) + { + case 'rect': + target.dimensions = { + width: Math.ceil(Math.abs(coords[2] - coords[0])), + height: Math.ceil(Math.abs(coords[3] - coords[1])) + }; + break; + + case 'circle': + target.dimensions = { + width: coords[2] + 1, + height: coords[2] + 1 + }; + break; + + case 'poly': + target.dimensions = { + width: coords[0], + height: coords[1] + }; + + for(i = 0; i < coords.length; i++) + { + if(i % 2 == 0) + { + if(coords[i] > target.dimensions.width) + target.dimensions.width = coords[i]; + if(coords[i] < coords[0]) + target.position.left = Math.floor(imagePos.left + coords[i]); + } + else + { + if(coords[i] > target.dimensions.height) + target.dimensions.height = coords[i]; + if(coords[i] < coords[1]) + target.position.top = Math.floor(imagePos.top + coords[i]); + }; + }; + + target.dimensions.width = target.dimensions.width - (target.position.left - imagePos.left); + target.dimensions.height = target.dimensions.height - (target.position.top - imagePos.top); + break; + + default: + return $.fn.qtip.log.error.call(self, 4, $.fn.qtip.constants.INVALID_AREA_SHAPE, 'updatePosition'); + break; + }; + + // Adjust position by 2 pixels (Positioning bug?) + target.dimensions.width -= 2; target.dimensions.height -= 2; + } + + // Target is the document + else if(self.options.position.target.add(document.body).length === 1) + { + target.position = { left: $(document).scrollLeft(), top: $(document).scrollTop() }; + target.dimensions = { height: $(window).height(), width: $(window).width() }; + } + + // Target is a regular HTML element, find position normally + else + { + // Check if the target is another tooltip. If its animated, retrieve position from newPosition data + if(typeof self.options.position.target.attr('qtip') !== 'undefined') + target.position = self.options.position.target.qtip('api').cache.position; + else + target.position = self.options.position.target.offset(); + + // Setup dimensions objects + target.dimensions = { + height: self.options.position.target.outerHeight(), + width: self.options.position.target.outerWidth() + }; + }; + + // Calculate correct target corner position + newPosition = $.extend({}, target.position); + if(target.corner.search(/right/i) !== -1) + newPosition.left += target.dimensions.width; + + if(target.corner.search(/bottom/i) !== -1) + newPosition.top += target.dimensions.height; + + if(target.corner.search(/((top|bottom)Middle)|center/) !== -1) + newPosition.left += (target.dimensions.width / 2); + + if(target.corner.search(/((left|right)Middle)|center/) !== -1) + newPosition.top += (target.dimensions.height / 2); + } + + // Mouse is the target, set position to current mouse coordinates + else + { + // Setup target position and dimensions objects + target.position = newPosition = { left: self.cache.mouse.x, top: self.cache.mouse.y }; + target.dimensions = { height: 1, width: 1 }; + }; + + // Calculate correct target corner position + if(tooltip.corner.search(/right/i) !== -1) + newPosition.left -= tooltip.dimensions.width; + + if(tooltip.corner.search(/bottom/i) !== -1) + newPosition.top -= tooltip.dimensions.height; + + if(tooltip.corner.search(/((top|bottom)Middle)|center/) !== -1) + newPosition.left -= (tooltip.dimensions.width / 2); + + if(tooltip.corner.search(/((left|right)Middle)|center/) !== -1) + newPosition.top -= (tooltip.dimensions.height / 2); + + // Setup IE adjustment variables (Pixel gap bugs) + ieAdjust = ($.browser.msie) ? 1 : 0; // And this is why I hate IE... + ie6Adjust = ($.browser.msie && parseInt($.browser.version.charAt(0)) === 6) ? 1 : 0; // ...and even more so IE6! + + // Adjust for border radius + if(self.options.style.border.radius > 0) + { + if(tooltip.corner.search(/Left/) !== -1) + newPosition.left -= self.options.style.border.radius; + else if(tooltip.corner.search(/Right/) !== -1) + newPosition.left += self.options.style.border.radius; + + if(tooltip.corner.search(/Top/) !== -1) + newPosition.top -= self.options.style.border.radius; + else if(tooltip.corner.search(/Bottom/) !== -1) + newPosition.top += self.options.style.border.radius; + }; + + // IE only adjustments (Pixel perfect!) + if(ieAdjust) + { + if(tooltip.corner.search(/top/) !== -1) + newPosition.top -= ieAdjust + else if(tooltip.corner.search(/bottom/) !== -1) + newPosition.top += ieAdjust + + if(tooltip.corner.search(/left/) !== -1) + newPosition.left -= ieAdjust + else if(tooltip.corner.search(/right/) !== -1) + newPosition.left += ieAdjust + + if(tooltip.corner.search(/leftMiddle|rightMiddle/) !== -1) + newPosition.top -= 1 + }; + + // If screen adjustment is enabled, apply adjustments + if(self.options.position.adjust.screen === true) + newPosition = screenAdjust.call(self, newPosition, target, tooltip); + + // If mouse is the target, prevent tooltip appearing directly under the mouse + if(self.options.position.target === 'mouse' && self.options.position.adjust.mouse === true) + { + if(self.options.position.adjust.screen === true && self.elements.tip) + mouseAdjust = self.elements.tip.attr('rel'); + else + mouseAdjust = self.options.position.corner.tooltip; + + newPosition.left += (mouseAdjust.search(/right/i) !== -1) ? -6 : 6; + newPosition.top += (mouseAdjust.search(/bottom/i) !== -1) ? -6 : 6; + } + + // Initiate bgiframe plugin in IE6 if tooltip overlaps a select box or object element + if(!self.elements.bgiframe && $.browser.msie && parseInt($.browser.version.charAt(0)) == 6) + { + $('select, object').each(function() + { + offset = $(this).offset(); + offset.bottom = offset.top + $(this).height(); + offset.right = offset.left + $(this).width(); + + if(newPosition.top + tooltip.dimensions.height >= offset.top + && newPosition.left + tooltip.dimensions.width >= offset.left) + bgiframe.call(self); + }); + }; + + // Add user xy adjustments + newPosition.left += self.options.position.adjust.x; + newPosition.top += self.options.position.adjust.y; + + // Set new tooltip position if its moved, animate if enabled + curPosition = self.getPosition(); + if(newPosition.left != curPosition.left || newPosition.top != curPosition.top) + { + // Call API method and if return value is false, halt + returned = self.beforePositionUpdate.call(self, event); + if(returned === false) return self; + + // Cache new position + self.cache.position = newPosition; + + // Check if animation is enabled + if(animate === true) + { + // Set animated status + self.status.animated = true; + + // Animate and reset animated status on animation end + self.elements.tooltip.animate(newPosition, 200, 'swing', function(){ self.status.animated = false }); + } + + // Set new position via CSS + else self.elements.tooltip.css(newPosition); + + // Call API method and log event if its not a mouse move + self.onPositionUpdate.call(self, event); + if(typeof event !== 'undefined' && event.type && event.type !== 'mousemove') + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_POSITION_UPDATED, 'updatePosition'); + }; + + return self; + }, + + updateWidth: function(newWidth) + { + var hidden; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateWidth'); + + // Make sure supplied width is a number and if not, return + else if(newWidth && typeof newWidth !== 'number') + return $.fn.qtip.log.error.call(self, 2, 'newWidth must be of type number', 'updateWidth'); + + // Setup elements which must be hidden during width update + hidden = self.elements.contentWrapper.siblings().add(self.elements.tip).add(self.elements.button); + + // Calculate the new width if one is not supplied + if(!newWidth) + { + // Explicit width is set + if(typeof self.options.style.width.value == 'number') + newWidth = self.options.style.width.value; + + // No width is set, proceed with auto detection + else + { + // Set width to auto initally to determine new width and hide other elements + self.elements.tooltip.css({ width: 'auto' }); + hidden.hide(); + + // Set position and zoom to defaults to prevent IE hasLayout bug + if($.browser.msie) + self.elements.wrapper.add(self.elements.contentWrapper.children()).css({ zoom: 'normal' }); + + // Set the new width + newWidth = self.getDimensions().width + 1; + + // Make sure its within the maximum and minimum width boundries + if(!self.options.style.width.value) + { + if(newWidth > self.options.style.width.max) newWidth = self.options.style.width.max + if(newWidth < self.options.style.width.min) newWidth = self.options.style.width.min + }; + }; + }; + + // Adjust newWidth by 1px if width is odd (IE6 rounding bug fix) + if(newWidth % 2 !== 0) newWidth -= 1; + + // Set the new calculated width and unhide other elements + self.elements.tooltip.width(newWidth); + hidden.show(); + + // Set the border width, if enabled + if(self.options.style.border.radius) + { + self.elements.tooltip.find('.qtip-betweenCorners').each(function(i) + { + $(this).width(newWidth - (self.options.style.border.radius * 2)); + }) + }; + + // IE only adjustments + if($.browser.msie) + { + // Reset position and zoom to give the wrapper layout (IE hasLayout bug) + self.elements.wrapper.add(self.elements.contentWrapper.children()).css({ zoom: '1' }); + + // Set the new width + self.elements.wrapper.width(newWidth); + + // Adjust BGIframe height and width if enabled + if(self.elements.bgiframe) self.elements.bgiframe.width(newWidth).height(self.getDimensions.height); + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_WIDTH_UPDATED, 'updateWidth'); + }, + + updateStyle: function(name) + { + var tip, borders, context, corner, coordinates; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateStyle'); + + // Return if style is not defined or name is not a string + else if(typeof name !== 'string' || !$.fn.qtip.styles[name]) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.STYLE_NOT_DEFINED, 'updateStyle'); + + // Set the new style object + self.options.style = buildStyle.call(self, $.fn.qtip.styles[name], self.options.user.style); + + // Update initial styles of content and title elements + self.elements.content.css( jQueryStyle(self.options.style) ); + if(self.options.content.title.text !== false) + self.elements.title.css( jQueryStyle(self.options.style.title, true) ); + + // Update CSS border colour + self.elements.contentWrapper.css({ borderColor: self.options.style.border.color }); + + // Update tip color if enabled + if(self.options.style.tip.corner !== false) + { + if($('').get(0).getContext) + { + // Retrieve canvas context and clear + tip = self.elements.tooltip.find('.qtip-tip canvas:first'); + context = tip.get(0).getContext('2d'); + context.clearRect(0,0,300,300); + + // Draw new tip + corner = tip.parent('div[rel]:first').attr('rel'); + coordinates = calculateTip(corner, self.options.style.tip.size.width, self.options.style.tip.size.height); + drawTip.call(self, tip, coordinates, self.options.style.tip.color || self.options.style.border.color); + } + else if($.browser.msie) + { + // Set new fillcolor attribute + tip = self.elements.tooltip.find('.qtip-tip [nodeName="shape"]'); + tip.attr('fillcolor', self.options.style.tip.color || self.options.style.border.color); + }; + }; + + // Update border colors if enabled + if(self.options.style.border.radius > 0) + { + self.elements.tooltip.find('.qtip-betweenCorners').css({ backgroundColor: self.options.style.border.color }); + + if($('').get(0).getContext) + { + borders = calculateBorders(self.options.style.border.radius) + self.elements.tooltip.find('.qtip-wrapper canvas').each(function() + { + // Retrieve canvas context and clear + context = $(this).get(0).getContext('2d'); + context.clearRect(0,0,300,300); + + // Draw new border + corner = $(this).parent('div[rel]:first').attr('rel') + drawBorder.call(self, $(this), borders[corner], + self.options.style.border.radius, self.options.style.border.color); + }); + } + else if($.browser.msie) + { + // Set new fillcolor attribute on each border corner + self.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function() + { + $(this).attr('fillcolor', self.options.style.border.color) + }); + }; + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_STYLE_UPDATED, 'updateStyle'); + }, + + updateContent: function(content, reposition) + { + var parsedContent, images, loadedImages; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateContent'); + + // Make sure content is defined before update + else if(!content) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.NO_CONTENT_PROVIDED, 'updateContent'); + + // Call API method and set new content if a string is returned + parsedContent = self.beforeContentUpdate.call(self, content); + if(typeof parsedContent == 'string') content = parsedContent; + else if(parsedContent === false) return; + + // Set position and zoom to defaults to prevent IE hasLayout bug + if($.browser.msie) self.elements.contentWrapper.children().css({ zoom: 'normal' }); + + // Append new content if its a DOM array and show it if hidden + if(content.jquery && content.length > 0) + content.clone(true).appendTo(self.elements.content).show(); + + // Content is a regular string, insert the new content + else self.elements.content.html(content); + + // Check if images need to be loaded before position is updated to prevent mis-positioning + images = self.elements.content.find('img[complete=false]'); + if(images.length > 0) + { + loadedImages = 0; + images.each(function(i) + { + $('') + .load(function(){ if(++loadedImages == images.length) afterLoad(); }); + }); + } + else afterLoad(); + + function afterLoad() + { + // Update the tooltip width + self.updateWidth(); + + // If repositioning is enabled, update positions + if(reposition !== false) + { + // Update position if tooltip isn't static + if(self.options.position.type !== 'static') + self.updatePosition(self.elements.tooltip.is(':visible'), true); + + // Reposition the tip if enabled + if(self.options.style.tip.corner !== false) + positionTip.call(self); + }; + }; + + // Call API method and log event + self.onContentUpdate.call(self); + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_CONTENT_UPDATED, 'loadContent'); + }, + + loadContent: function(url, data, method) + { + var returned; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'loadContent'); + + // Call API method and if return value is false, halt + returned = self.beforeContentLoad.call(self); + if(returned === false) return self; + + // Load content using specified request type + if(method == 'post') + $.post(url, data, setupContent); + else + $.get(url, data, setupContent); + + function setupContent(content) + { + // Call API method and log event + self.onContentLoad.call(self); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_CONTENT_LOADED, 'loadContent'); + + // Update the content + self.updateContent(content); + }; + + return self; + }, + + updateTitle: function(content) + { + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateTitle'); + + // Make sure content is defined before update + else if(!content) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.NO_CONTENT_PROVIDED, 'updateTitle'); + + // Call API method and if return value is false, halt + returned = self.beforeTitleUpdate.call(self); + if(returned === false) return self; + + // Set the new content and reappend the button if enabled + if(self.elements.button) self.elements.button = self.elements.button.clone(true); + self.elements.title.html(content) + if(self.elements.button) self.elements.title.prepend(self.elements.button); + + // Call API method and log event + self.onTitleUpdate.call(self); + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_TITLE_UPDATED, 'updateTitle'); + }, + + focus: function(event) + { + var curIndex, newIndex, elemIndex, returned; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'focus'); + + else if(self.options.position.type == 'static') + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.CANNOT_FOCUS_STATIC, 'focus'); + + // Set z-index variables + curIndex = parseInt( self.elements.tooltip.css('z-index') ); + newIndex = 6000 + $('div.qtip[qtip]').length - 1; + + // Only update the z-index if it has changed and tooltip is not already focused + if(!self.status.focused && curIndex !== newIndex) + { + // Call API method and if return value is false, halt + returned = self.beforeFocus.call(self, event); + if(returned === false) return self; + + // Loop through all other tooltips + $('div.qtip[qtip]').not(self.elements.tooltip).each(function() + { + if($(this).qtip('api').status.rendered === true) + { + elemIndex = parseInt($(this).css('z-index')); + + // Reduce all other tooltip z-index by 1 + if(typeof elemIndex == 'number' && elemIndex > -1) + $(this).css({ zIndex: parseInt( $(this).css('z-index') ) - 1 }); + + // Set focused status to false + $(this).qtip('api').status.focused = false; + } + }) + + // Set the new z-index and set focus status to true + self.elements.tooltip.css({ zIndex: newIndex }); + self.status.focused = true; + + // Call API method and log event + self.onFocus.call(self, event); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_FOCUSED, 'focus'); + }; + + return self; + }, + + disable: function(state) + { + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'disable'); + + if(state) + { + // Tooltip is not already disabled, proceed + if(!self.status.disabled) + { + // Set the disabled flag and log event + self.status.disabled = true; + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_DISABLED, 'disable'); + } + + // Tooltip is already disabled, inform user via log + else $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED, 'disable'); + } + else + { + // Tooltip is not already enabled, proceed + if(self.status.disabled) + { + // Reassign events, set disable status and log + self.status.disabled = false; + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_ENABLED, 'disable'); + } + + // Tooltip is already enabled, inform the user via log + else $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED, 'disable'); + }; + + return self; + }, + + destroy: function() + { + var i, returned, interfaces; + + // Call API method and if return value is false, halt + returned = self.beforeDestroy.call(self); + if(returned === false) return self; + + // Check if tooltip is rendered + if(self.status.rendered) + { + // Remove event handlers and remove element + self.options.show.when.target.unbind('mousemove.qtip', self.updatePosition); + self.options.show.when.target.unbind('mouseout.qtip', self.hide); + self.options.show.when.target.unbind(self.options.show.when.event + '.qtip'); + self.options.hide.when.target.unbind(self.options.hide.when.event + '.qtip'); + self.elements.tooltip.unbind(self.options.hide.when.event + '.qtip'); + self.elements.tooltip.unbind('mouseover.qtip', self.focus); + self.elements.tooltip.remove(); + } + + // Tooltip isn't yet rendered, remove render event + else self.options.show.when.target.unbind(self.options.show.when.event+'.qtip-create'); + + // Check to make sure qTip data is present on target element + if(typeof self.elements.target.data('qtip') == 'object') + { + // Remove API references from interfaces object + interfaces = self.elements.target.data('qtip').interfaces; + if(typeof interfaces == 'object' && interfaces.length > 0) + { + // Remove API from interfaces array + for(i = 0; i < interfaces.length - 1; i++) + if(interfaces[i].id == self.id) interfaces.splice(i, 1) + } + } + delete $.fn.qtip.interfaces[self.id]; + + // Set qTip current id to previous tooltips API if available + if(typeof interfaces == 'object' && interfaces.length > 0) + self.elements.target.data('qtip').current = interfaces.length -1; + else + self.elements.target.removeData('qtip'); + + // Call API method and log destroy + self.onDestroy.call(self); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_DESTROYED, 'destroy'); + + return self.elements.target + }, + + getPosition: function() + { + var show, offset; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'getPosition'); + + show = (self.elements.tooltip.css('display') !== 'none') ? false : true; + + // Show and hide tooltip to make sure coordinates are returned + if(show) self.elements.tooltip.css({ visiblity: 'hidden' }).show(); + offset = self.elements.tooltip.offset(); + if(show) self.elements.tooltip.css({ visiblity: 'visible' }).hide(); + + return offset; + }, + + getDimensions: function() + { + var show, dimensions; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'getDimensions'); + + show = (!self.elements.tooltip.is(':visible')) ? true : false; + + // Show and hide tooltip to make sure dimensions are returned + if(show) self.elements.tooltip.css({ visiblity: 'hidden' }).show(); + dimensions = { + height: self.elements.tooltip.outerHeight(), + width: self.elements.tooltip.outerWidth() + }; + if(show) self.elements.tooltip.css({ visiblity: 'visible' }).hide(); + + return dimensions; + } + }); + }; + + // Define priamry construct function + function construct() + { + var self, adjust, content, url, data, method, tempLength; + self = this; + + // Call API method + self.beforeRender.call(self); + + // Set rendered status to true + self.status.rendered = true; + + // Create initial tooltip elements + self.elements.tooltip = '' + + ' ' + + ' ' + + ' ' + + ''; + + // Append to container element + self.elements.tooltip = $(self.elements.tooltip); + self.elements.tooltip.appendTo(self.options.position.container) + + // Setup tooltip qTip data + self.elements.tooltip.data('qtip', { current: 0, interfaces: [self] }); + + // Setup element references + self.elements.wrapper = self.elements.tooltip.children('div:first'); + self.elements.contentWrapper = self.elements.wrapper.children('div:first').css({ background: self.options.style.background }); + self.elements.content = self.elements.contentWrapper.children('div:first').css( jQueryStyle(self.options.style) ); + + // Apply IE hasLayout fix to wrapper and content elements + if($.browser.msie) self.elements.wrapper.add(self.elements.content).css({ zoom: 1 }); + + // Setup tooltip attributes + if(self.options.hide.when.event == 'unfocus') self.elements.tooltip.attr('unfocus', true); + + // If an explicit width is set, updateWidth prior to setting content to prevent dirty rendering + if(typeof self.options.style.width.value == 'number') self.updateWidth(); + + // Create borders and tips if supported by the browser + if($('').get(0).getContext || $.browser.msie) + { + // Create border + if(self.options.style.border.radius > 0) + createBorder.call(self); + else + self.elements.contentWrapper.css({ border: self.options.style.border.width+'px solid '+self.options.style.border.color }); + + // Create tip if enabled + if(self.options.style.tip.corner !== false) + createTip.call(self); + } + + // Neither canvas or VML is supported, tips and borders cannot be drawn! + else + { + // Set defined border width + self.elements.contentWrapper.css({ border: self.options.style.border.width+'px solid '+self.options.style.border.color }); + + // Reset border radius and tip + self.options.style.border.radius = 0; + self.options.style.tip.corner = false; + + // Inform via log + $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED, 'render'); + }; + + // Use the provided content string or DOM array + if((typeof self.options.content.text == 'string' && self.options.content.text.length > 0) + || (self.options.content.text.jquery && self.options.content.text.length > 0)) + content = self.options.content.text; + + // Use title string for content if present + else if(typeof self.elements.target.attr('title') == 'string' && self.elements.target.attr('title').length > 0) + { + content = self.elements.target.attr('title').replace("\\n", ''); + self.elements.target.attr('title', ''); // Remove title attribute to prevent default tooltip showing + } + + // No title is present, use alt attribute instead + else if(typeof self.elements.target.attr('alt') == 'string' && self.elements.target.attr('alt').length > 0) + { + content = self.elements.target.attr('alt').replace("\\n", ''); + self.elements.target.attr('alt', ''); // Remove alt attribute to prevent default tooltip showing + } + + // No valid content was provided, inform via log + else + { + content = ' '; + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.NO_VALID_CONTENT, 'render'); + }; + + // Set the tooltips content and create title if enabled + if(self.options.content.title.text !== false) createTitle.call(self); + self.updateContent(content); + + // Assign events and toggle tooltip with focus + assignEvents.call(self); + if(self.options.show.ready === true) self.show(); + + // Retrieve ajax content if provided + if(self.options.content.url !== false) + { + url = self.options.content.url; + data = self.options.content.data; + method = self.options.content.method || 'get'; + self.loadContent(url, data, method); + }; + + // Call API method and log event + self.onRender.call(self); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_RENDERED, 'render'); + }; + + // Create borders using canvas and VML + function createBorder() + { + var self, i, width, radius, color, coordinates, containers, size, betweenWidth, betweenCorners, borderTop, borderBottom, borderCoord, sideWidth, vertWidth; + self = this; + + // Destroy previous border elements, if present + self.elements.wrapper.find('.qtip-borderBottom, .qtip-borderTop').remove(); + + // Setup local variables + width = self.options.style.border.width; + radius = self.options.style.border.radius; + color = self.options.style.border.color || self.options.style.tip.color; + + // Calculate border coordinates + coordinates = calculateBorders(radius); + + // Create containers for the border shapes + containers = {}; + for(i in coordinates) + { + // Create shape container + containers[i] = ''; + + // Canvas is supported + if($('').get(0).getContext) + containers[i] += ''; + + // No canvas, but if it's IE use VML + else if($.browser.msie) + { + size = radius * 2 + 3; + containers[i] += ''; + + }; + + containers[i] += ''; + }; + + // Create between corners elements + betweenWidth = self.getDimensions().width - (Math.max(width, radius) * 2); + betweenCorners = ''; + + // Create top border container + borderTop = '' + + containers['topLeft'] + containers['topRight'] + betweenCorners; + self.elements.wrapper.prepend(borderTop); + + // Create bottom border container + borderBottom = '' + + containers['bottomLeft'] + containers['bottomRight'] + betweenCorners; + self.elements.wrapper.append(borderBottom); + + // Draw the borders if canvas were used (Delayed til after DOM creation) + if($('').get(0).getContext) + { + self.elements.wrapper.find('canvas').each(function() + { + borderCoord = coordinates[ $(this).parent('[rel]:first').attr('rel') ]; + drawBorder.call(self, $(this), borderCoord, radius, color); + }) + } + + // Create a phantom VML element (IE won't show the last created VML element otherwise) + else if($.browser.msie) self.elements.tooltip.append(''); + + // Setup contentWrapper border + sideWidth = Math.max(radius, (radius + (width - radius)) ) + vertWidth = Math.max(width - radius, 0); + self.elements.contentWrapper.css({ + border: '0px solid ' + color, + borderWidth: vertWidth + 'px ' + sideWidth + 'px' + }) + }; + + // Border canvas draw method + function drawBorder(canvas, coordinates, radius, color) + { + // Create corner + var context = canvas.get(0).getContext('2d'); + context.fillStyle = color; + context.beginPath(); + context.arc(coordinates[0], coordinates[1], radius, 0, Math.PI * 2, false); + context.fill(); + }; + + // Create tip using canvas and VML + function createTip(corner) + { + var self, color, coordinates, coordsize, path; + self = this; + + // Destroy previous tip, if there is one + if(self.elements.tip !== null) self.elements.tip.remove(); + + // Setup color and corner values + color = self.options.style.tip.color || self.options.style.border.color; + if(self.options.style.tip.corner === false) return; + else if(!corner) corner = self.options.style.tip.corner; + + // Calculate tip coordinates + coordinates = calculateTip(corner, self.options.style.tip.size.width, self.options.style.tip.size.height); + + // Create tip element + self.elements.tip = ''; + + // Use canvas element if supported + if($('').get(0).getContext) + self.elements.tip += ''; + + // Canvas not supported - Use VML (IE) + else if($.browser.msie) + { + // Create coordize and tip path using tip coordinates + coordsize = self.options.style.tip.size.width + ',' + self.options.style.tip.size.height; + path = 'm' + coordinates[0][0] + ',' + coordinates[0][1]; + path += ' l' + coordinates[1][0] + ',' + coordinates[1][1]; + path += ' ' + coordinates[2][0] + ',' + coordinates[2][1]; + path += ' xe'; + + // Create VML element + self.elements.tip += ''; + + // Create a phantom VML element (IE won't show the last created VML element otherwise) + self.elements.tip += ''; + + // Prevent tooltip appearing above the content (IE z-index bug) + self.elements.contentWrapper.css('position', 'relative'); + }; + + // Attach new tip to tooltip element + self.elements.tooltip.prepend(self.elements.tip + ''); + + // Create element reference and draw the canvas tip (Delayed til after DOM creation) + self.elements.tip = self.elements.tooltip.find('.'+self.options.style.classes.tip).eq(0); + if($('').get(0).getContext) + drawTip.call(self, self.elements.tip.find('canvas:first'), coordinates, color); + + // Fix IE small tip bug + if(corner.search(/top/) !== -1 && $.browser.msie && parseInt($.browser.version.charAt(0)) === 6) + self.elements.tip.css({ marginTop: -4 }); + + // Set the tip position + positionTip.call(self, corner); + }; + + // Canvas tip drawing method + function drawTip(canvas, coordinates, color) + { + // Setup properties + var context = canvas.get(0).getContext('2d'); + context.fillStyle = color; + + // Create tip + context.beginPath(); + context.moveTo(coordinates[0][0], coordinates[0][1]); + context.lineTo(coordinates[1][0], coordinates[1][1]); + context.lineTo(coordinates[2][0], coordinates[2][1]); + context.fill(); + }; + + function positionTip(corner) + { + var self, ieAdjust, paddingCorner, paddingSize, newMargin; + self = this; + + // Return if tips are disabled or tip is not yet rendered + if(self.options.style.tip.corner === false || !self.elements.tip) return; + if(!corner) corner = self.elements.tip.attr('rel'); + + // Setup adjustment variables + ieAdjust = positionAdjust = ($.browser.msie) ? 1 : 0; + + // Set initial position + self.elements.tip.css(corner.match(/left|right|top|bottom/)[0], 0); + + // Set position of tip to correct side + if(corner.search(/top|bottom/) !== -1) + { + // Adjustments for IE6 - 0.5px border gap bug + if($.browser.msie) + { + if(parseInt($.browser.version.charAt(0)) === 6) + positionAdjust = (corner.search(/top/) !== -1) ? -3 : 1; + else + positionAdjust = (corner.search(/top/) !== -1) ? 1 : 2; + }; + + if(corner.search(/Middle/) !== -1) + self.elements.tip.css({ left: '50%', marginLeft: -(self.options.style.tip.size.width / 2) }); + + else if(corner.search(/Left/) !== -1) + self.elements.tip.css({ left: self.options.style.border.radius - ieAdjust }); + + else if(corner.search(/Right/) !== -1) + self.elements.tip.css({ right: self.options.style.border.radius + ieAdjust }); + + if(corner.search(/top/) !== -1) + self.elements.tip.css({ top: -positionAdjust }); + else + self.elements.tip.css({ bottom: positionAdjust }); + + } + else if(corner.search(/left|right/) !== -1) + { + // Adjustments for IE6 - 0.5px border gap bug + if($.browser.msie) + positionAdjust = (parseInt($.browser.version.charAt(0)) === 6) ? 1 : ((corner.search(/left/) !== -1) ? 1 : 2); + + if(corner.search(/Middle/) !== -1) + self.elements.tip.css({ top: '50%', marginTop: -(self.options.style.tip.size.height / 2) }); + + else if(corner.search(/Top/) !== -1) + self.elements.tip.css({ top: self.options.style.border.radius - ieAdjust }); + + else if(corner.search(/Bottom/) !== -1) + self.elements.tip.css({ bottom: self.options.style.border.radius + ieAdjust }); + + if(corner.search(/left/) !== -1) + self.elements.tip.css({ left: -positionAdjust }); + else + self.elements.tip.css({ right: positionAdjust }); + }; + + // Adjust tooltip padding to compensate for tip + paddingCorner = 'padding-' + corner.match(/left|right|top|bottom/)[0]; + paddingSize = self.options.style.tip.size[ (paddingCorner.search(/left|right/) !== -1) ? 'width' : 'height' ]; + self.elements.tooltip.css('padding', 0); + self.elements.tooltip.css(paddingCorner, paddingSize); + + // Match content margin to prevent gap bug in IE6 ONLY + if($.browser.msie && parseInt($.browser.version.charAt(0)) == 6) + { + newMargin = parseInt(self.elements.tip.css('margin-top')) || 0; + newMargin += parseInt(self.elements.content.css('margin-top')) || 0; + + self.elements.tip.css({ marginTop: newMargin }); + }; + }; + + // Create title bar for content + function createTitle() + { + var self = this; + + // Destroy previous title element, if present + if(self.elements.title !== null) self.elements.title.remove(); + + // Create title element + self.elements.title = $('') + .css( jQueryStyle(self.options.style.title, true) ) + .css({ zoom: ($.browser.msie) ? 1 : 0 }) + .prependTo(self.elements.contentWrapper); + + // Update title with contents if enabled + if(self.options.content.title.text) self.updateTitle.call(self, self.options.content.title.text); + + // Create title close buttons if enabled + if(self.options.content.title.button !== false + && typeof self.options.content.title.button == 'string') + { + self.elements.button = $('') + .css( jQueryStyle(self.options.style.button, true) ) + .html(self.options.content.title.button) + .prependTo(self.elements.title) + .click(function(event){ if(!self.status.disabled) self.hide(event) }); + }; + }; + + // Assign hide and show events + function assignEvents() + { + var self, showTarget, hideTarget, inactiveEvents; + self = this; + + // Setup event target variables + showTarget = self.options.show.when.target; + hideTarget = self.options.hide.when.target; + + // Add tooltip as a hideTarget is its fixed + if(self.options.hide.fixed) hideTarget = hideTarget.add(self.elements.tooltip); + + // Check if the hide event is special 'inactive' type + if(self.options.hide.when.event == 'inactive') + { + // Define events which reset the 'inactive' event handler + inactiveEvents = ['click', 'dblclick', 'mousedown', 'mouseup', 'mousemove', + 'mouseout', 'mouseenter', 'mouseleave', 'mouseover' ]; + + // Define 'inactive' event timer method + function inactiveMethod(event) + { + if(self.status.disabled === true) return; + + //Clear and reset the timer + clearTimeout(self.timers.inactive); + self.timers.inactive = setTimeout(function() + { + // Unassign 'inactive' events + $(inactiveEvents).each(function() + { + hideTarget.unbind(this+'.qtip-inactive'); + self.elements.content.unbind(this+'.qtip-inactive'); + }); + + // Hide the tooltip + self.hide(event); + } + , self.options.hide.delay); + }; + } + + // Check if the tooltip is 'fixed' + else if(self.options.hide.fixed === true) + { + self.elements.tooltip.bind('mouseover.qtip', function() + { + if(self.status.disabled === true) return; + + // Reset the hide timer + clearTimeout(self.timers.hide); + }); + }; + + // Define show event method + function showMethod(event) + { + if(self.status.disabled === true) return; + + // If set, hide tooltip when inactive for delay period + if(self.options.hide.when.event == 'inactive') + { + // Assign each reset event + $(inactiveEvents).each(function() + { + hideTarget.bind(this+'.qtip-inactive', inactiveMethod); + self.elements.content.bind(this+'.qtip-inactive', inactiveMethod); + }); + + // Start the inactive timer + inactiveMethod(); + }; + + // Clear hide timers + clearTimeout(self.timers.show); + clearTimeout(self.timers.hide); + + // Start show timer + self.timers.show = setTimeout(function(){ self.show(event); }, self.options.show.delay); + }; + + // Define hide event method + function hideMethod(event) + { + if(self.status.disabled === true) return; + + // Prevent hiding if tooltip is fixed and event target is the tooltip + if(self.options.hide.fixed === true + && self.options.hide.when.event.search(/mouse(out|leave)/i) !== -1 + && $(event.relatedTarget).parents('div.qtip[qtip]').length > 0) + { + // Prevent default and popagation + event.stopPropagation(); + event.preventDefault(); + + // Reset the hide timer + clearTimeout(self.timers.hide); + return false; + }; + + // Clear timers and stop animation queue + clearTimeout(self.timers.show); + clearTimeout(self.timers.hide); + self.elements.tooltip.stop(true, true); + + // If tooltip has displayed, start hide timer + self.timers.hide = setTimeout(function(){ self.hide(event); }, self.options.hide.delay); + }; + + // Both events and targets are identical, apply events using a toggle + if((self.options.show.when.target.add(self.options.hide.when.target).length === 1 + && self.options.show.when.event == self.options.hide.when.event + && self.options.hide.when.event !== 'inactive') + || self.options.hide.when.event == 'unfocus') + { + self.cache.toggle = 0; + // Use a toggle to prevent hide/show conflicts + showTarget.bind(self.options.show.when.event + '.qtip', function(event) + { + if(self.cache.toggle == 0) showMethod(event); + else hideMethod(event); + }); + } + + // Events are not identical, bind normally + else + { + showTarget.bind(self.options.show.when.event + '.qtip', showMethod); + + // If the hide event is not 'inactive', bind the hide method + if(self.options.hide.when.event !== 'inactive') + hideTarget.bind(self.options.hide.when.event + '.qtip', hideMethod); + }; + + // Focus the tooltip on mouseover + if(self.options.position.type.search(/(fixed|absolute)/) !== -1) + self.elements.tooltip.bind('mouseover.qtip', self.focus); + + // If mouse is the target, update tooltip position on mousemove + if(self.options.position.target === 'mouse' && self.options.position.type !== 'static') + { + showTarget.bind('mousemove.qtip', function(event) + { + // Set the new mouse positions if adjustment is enabled + self.cache.mouse = { x: event.pageX, y: event.pageY }; + + // Update the tooltip position only if the tooltip is visible and adjustment is enabled + if(self.status.disabled === false + && self.options.position.adjust.mouse === true + && self.options.position.type !== 'static' + && self.elements.tooltip.css('display') !== 'none') + self.updatePosition(event); + }); + }; + }; + + // Screen position adjustment + function screenAdjust(position, target, tooltip) + { + var self, adjustedPosition, adjust, newCorner, overflow, corner; + self = this; + + // Setup corner and adjustment variable + if(tooltip.corner == 'center') return target.position // TODO: 'center' corner adjustment + adjustedPosition = $.extend({}, position); + newCorner = { x: false, y: false }; + + // Define overflow properties + overflow = { + left: (adjustedPosition.left < $.fn.qtip.cache.screen.scroll.left), + right: (adjustedPosition.left + tooltip.dimensions.width + 2 >= $.fn.qtip.cache.screen.width + $.fn.qtip.cache.screen.scroll.left), + top: (adjustedPosition.top < $.fn.qtip.cache.screen.scroll.top), + bottom: (adjustedPosition.top + tooltip.dimensions.height + 2 >= $.fn.qtip.cache.screen.height + $.fn.qtip.cache.screen.scroll.top) + }; + + // Determine new positioning properties + adjust = { + left: (overflow.left && (tooltip.corner.search(/right/i) != -1 || (tooltip.corner.search(/right/i) == -1 && !overflow.right))), + right: (overflow.right && (tooltip.corner.search(/left/i) != -1 || (tooltip.corner.search(/left/i) == -1 && !overflow.left))), + top: (overflow.top && tooltip.corner.search(/top/i) == -1), + bottom: (overflow.bottom && tooltip.corner.search(/bottom/i) == -1) + }; + + // Tooltip overflows off the left side of the screen + if(adjust.left) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.left = target.position.left + target.dimensions.width; + else + adjustedPosition.left = self.cache.mouse.x + + newCorner.x = 'Left'; + } + + // Tooltip overflows off the right side of the screen + else if(adjust.right) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.left = target.position.left - tooltip.dimensions.width; + else + adjustedPosition.left = self.cache.mouse.x - tooltip.dimensions.width; + + newCorner.x = 'Right'; + }; + + // Tooltip overflows off the top of the screen + if(adjust.top) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.top = target.position.top + target.dimensions.height; + else + adjustedPosition.top = self.cache.mouse.y + + newCorner.y = 'top'; + } + + // Tooltip overflows off the bottom of the screen + else if(adjust.bottom) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.top = target.position.top - tooltip.dimensions.height; + else + adjustedPosition.top = self.cache.mouse.y - tooltip.dimensions.height; + + newCorner.y = 'bottom'; + }; + + // Don't adjust if resulting position is negative + if(adjustedPosition.left < 0) + { + adjustedPosition.left = position.left; + newCorner.x = false; + }; + if(adjustedPosition.top < 0) + { + adjustedPosition.top = position.top; + newCorner.y = false; + }; + + // Change tip corner if positioning has changed and tips are enabled + if(self.options.style.tip.corner !== false) + { + // Determine new corner properties + adjustedPosition.corner = new String(tooltip.corner); + if(newCorner.x !== false) adjustedPosition.corner = adjustedPosition.corner.replace(/Left|Right|Middle/, newCorner.x); + if(newCorner.y !== false) adjustedPosition.corner = adjustedPosition.corner.replace(/top|bottom/, newCorner.y); + + // Adjust tip if position has changed and tips are enabled + if(adjustedPosition.corner !== self.elements.tip.attr('rel')) + createTip.call(self, adjustedPosition.corner); + }; + + return adjustedPosition; + }; + + // Build a jQuery style object from supplied style object + function jQueryStyle(style, sub) + { + var styleObj, i; + + styleObj = $.extend(true, {}, style); + for(i in styleObj) + { + if(sub === true && i.search(/(tip|classes)/i) !== -1) + delete styleObj[i]; + else if(!sub && i.search(/(width|border|tip|title|classes|user)/i) !== -1) + delete styleObj[i]; + }; + + return styleObj; + }; + + // Sanitize styles + function sanitizeStyle(style) + { + if(typeof style.tip !== 'object') style.tip = { corner: style.tip }; + if(typeof style.tip.size !== 'object') style.tip.size = { width: style.tip.size, height: style.tip.size }; + if(typeof style.border !== 'object') style.border = { width: style.border }; + if(typeof style.width !== 'object') style.width = { value: style.width }; + if(typeof style.width.max == 'string') style.width.max = parseInt(style.width.max.replace(/([0-9]+)/i, "$1")); + if(typeof style.width.min == 'string') style.width.min = parseInt(style.width.min.replace(/([0-9]+)/i, "$1")); + + // Convert deprecated x and y tip values to width/height + if(typeof style.tip.size.x == 'number') + { + style.tip.size.width = style.tip.size.x; + delete style.tip.size.x; + }; + if(typeof style.tip.size.y == 'number') + { + style.tip.size.height = style.tip.size.y; + delete style.tip.size.y; + }; + + return style; + }; + + // Build styles recursively with inheritance + function buildStyle() + { + var self, i, styleArray, styleExtend, finalStyle, ieAdjust; + self = this; + + // Build style options from supplied arguments + styleArray = [true, {}]; + for(i = 0; i < arguments.length; i++) + styleArray.push(arguments[i]); + styleExtend = [ $.extend.apply($, styleArray) ]; + + // Loop through each named style inheritance + while(typeof styleExtend[0].name == 'string') + { + // Sanitize style data and append to extend array + styleExtend.unshift( sanitizeStyle($.fn.qtip.styles[ styleExtend[0].name ]) ); + }; + + // Make sure resulting tooltip className represents final style + styleExtend.unshift(true, {classes:{ tooltip: 'qtip-' + (arguments[0].name || 'defaults') }}, $.fn.qtip.styles.defaults); + + // Extend into a single style object + finalStyle = $.extend.apply($, styleExtend); + + // Adjust tip size if needed (IE 1px adjustment bug fix) + ieAdjust = ($.browser.msie) ? 1 : 0; + finalStyle.tip.size.width += ieAdjust; + finalStyle.tip.size.height += ieAdjust; + + // Force even numbers for pixel precision + if(finalStyle.tip.size.width % 2 > 0) finalStyle.tip.size.width += 1; + if(finalStyle.tip.size.height % 2 > 0) finalStyle.tip.size.height += 1; + + // Sanitize final styles tip corner value + if(finalStyle.tip.corner === true) + finalStyle.tip.corner = (self.options.position.corner.tooltip === 'center') ? false : self.options.position.corner.tooltip; + + return finalStyle; + }; + + // Tip coordinates calculator + function calculateTip(corner, width, height) + { + // Define tip coordinates in terms of height and width values + var tips = { + bottomRight: [[0,0], [width,height], [width,0]], + bottomLeft: [[0,0], [width,0], [0,height]], + topRight: [[0,height], [width,0], [width,height]], + topLeft: [[0,0], [0,height], [width,height]], + topMiddle: [[0,height], [width / 2,0], [width,height]], + bottomMiddle: [[0,0], [width,0], [width / 2,height]], + rightMiddle: [[0,0], [width,height / 2], [0,height]], + leftMiddle: [[width,0], [width,height], [0,height / 2]] + }; + tips.leftTop = tips.bottomRight; + tips.rightTop = tips.bottomLeft; + tips.leftBottom = tips.topRight; + tips.rightBottom = tips.topLeft; + + return tips[corner]; + }; + + // Border coordinates calculator + function calculateBorders(radius) + { + var borders; + + // Use canvas element if supported + if($('').get(0).getContext) + { + borders = { + topLeft: [radius,radius], topRight: [0,radius], + bottomLeft: [radius,0], bottomRight: [0,0] + }; + } + + // Canvas not supported - Use VML (IE) + else if($.browser.msie) + { + borders = { + topLeft: [-90,90,0], topRight: [-90,90,-radius], + bottomLeft: [90,270,0], bottomRight: [90, 270,-radius] + }; + }; + + return borders; + }; + + // BGIFRAME JQUERY PLUGIN ADAPTION + // Special thanks to Brandon Aaron for this plugin + // http://plugins.jquery.com/project/bgiframe + function bgiframe() + { + var self, html, dimensions; + self = this; + dimensions = self.getDimensions(); + + // Setup iframe HTML string + html = ''; + + // Append the new HTML and setup element reference + self.elements.bgiframe = self.elements.wrapper.prepend(html).children('.qtip-bgiframe:first'); + }; + + // Assign cache and event initialisation on document load + $(document).ready(function() + { + // Setup library cache with window scroll and dimensions of document + $.fn.qtip.cache = { + screen: { + scroll: { left: $(window).scrollLeft(), top: $(window).scrollTop() }, + width: $(window).width(), + height: $(window).height() + } + }; + + // Adjust positions of the tooltips on window resize or scroll if enabled + var adjustTimer; + $(window).bind('resize scroll', function(event) + { + clearTimeout(adjustTimer); + adjustTimer = setTimeout(function() + { + // Readjust cached screen values + if(event.type === 'scroll') + $.fn.qtip.cache.screen.scroll = { left: $(window).scrollLeft(), top: $(window).scrollTop() }; + else + { + $.fn.qtip.cache.screen.width = $(window).width(); + $.fn.qtip.cache.screen.height = $(window).height(); + }; + + for(i = 0; i < $.fn.qtip.interfaces.length; i++) + { + // Access current elements API + var api = $.fn.qtip.interfaces[i]; + + // Update position if resize or scroll adjustments are enabled + if(api.status.rendered === true + && (api.options.position.type !== 'static' + || api.options.position.adjust.scroll && event.type === 'scroll' + || api.options.position.adjust.resize && event.type === 'resize')) + { + // Queue the animation so positions are updated correctly + api.updatePosition(event, true); + } + }; + } + , 100); + }) + + // Hide unfocus toolipts on document mousedown + $(document).bind('mousedown.qtip', function(event) + { + if($(event.target).parents('div.qtip').length === 0) + { + $('.qtip[unfocus]').each(function() + { + var api = $(this).qtip("api"); + + // Only hide if its visible and not the tooltips target + if($(this).is(':visible') && !api.status.disabled + && $(event.target).add(api.elements.target).length > 1) + api.hide(event); + }) + }; + }) + }); + + // Define qTip API interfaces array + $.fn.qtip.interfaces = [] + + // Define log and constant place holders + $.fn.qtip.log = { error: function(){ return this; } }; + $.fn.qtip.constants = {}; + + // Define configuration defaults + $.fn.qtip.defaults = { + // Content + content: { + prerender: false, + text: false, + url: false, + data: null, + title: { + text: false, + button: false + } + }, + // Position + position: { + target: false, + corner: { + target: 'bottomRight', + tooltip: 'topLeft' + }, + adjust: { + x: 0, y: 0, + mouse: true, + screen: false, + scroll: true, + resize: true + }, + type: 'absolute', + container: false + }, + // Effects + show: { + when: { + target: false, + event: 'mouseover' + }, + effect: { + type: 'fade', + length: 100 + }, + delay: 140, + solo: false, + ready: false + }, + hide: { + when: { + target: false, + event: 'mouseout' + }, + effect: { + type: 'fade', + length: 100 + }, + delay: 0, + fixed: false + }, + // Callbacks + api: { + beforeRender: function(){}, + onRender: function(){}, + beforePositionUpdate: function(){}, + onPositionUpdate: function(){}, + beforeShow: function(){}, + onShow: function(){}, + beforeHide: function(){}, + onHide: function(){}, + beforeContentUpdate: function(){}, + onContentUpdate: function(){}, + beforeContentLoad: function(){}, + onContentLoad: function(){}, + beforeTitleUpdate: function(){}, + onTitleUpdate: function(){}, + beforeDestroy: function(){}, + onDestroy: function(){}, + beforeFocus: function(){}, + onFocus: function(){} + } + }; + + $.fn.qtip.styles = { + defaults: { + background: 'white', + color: '#111', + overflow: 'hidden', + textAlign: 'left', + width: { + min: 0, + max: 250 + }, + padding: '5px 9px', + border: { + width: 1, + radius: 0, + color: '#d3d3d3' + }, + tip: { + corner: false, + color: false, + size: { width: 13, height: 13 }, + opacity: 1 + }, + title: { + background: '#e1e1e1', + fontWeight: 'bold', + padding: '7px 12px' + }, + button: { + cursor: 'pointer' + }, + classes: { + target: '', + tip: 'qtip-tip', + title: 'qtip-title', + button: 'qtip-button', + content: 'qtip-content', + active: 'qtip-active' + } + }, + cream: { + border: { + width: 3, + radius: 0, + color: '#F9E98E' + }, + title: { + background: '#F0DE7D', + color: '#A27D35' + }, + background: '#FBF7AA', + color: '#A27D35', + + classes: { tooltip: 'qtip-cream' } + }, + light: { + border: { + width: 3, + radius: 0, + color: '#E2E2E2' + }, + title: { + background: '#f1f1f1', + color: '#454545' + }, + background: 'white', + color: '#454545', + + classes: { tooltip: 'qtip-light' } + }, + dark: { + border: { + width: 3, + radius: 0, + color: '#303030' + }, + title: { + background: '#404040', + color: '#f3f3f3' + }, + background: '#505050', + color: '#f3f3f3', + + classes: { tooltip: 'qtip-dark' } + }, + red: { + border: { + width: 3, + radius: 0, + color: '#CE6F6F' + }, + title: { + background: '#f28279', + color: '#9C2F2F' + }, + background: '#F79992', + color: '#9C2F2F', + + classes: { tooltip: 'qtip-red' } + }, + green: { + border: { + width: 3, + radius: 0, + color: '#A9DB66' + }, + title: { + background: '#b9db8c', + color: '#58792E' + }, + background: '#CDE6AC', + color: '#58792E', + + classes: { tooltip: 'qtip-green' } + }, + blue: { + border: { + width: 3, + radius: 0, + color: '#ADD9ED' + }, + title: { + background: '#D0E9F5', + color: '#5E99BD' + }, + background: '#E5F6FE', + color: '#4D9FBF', + + classes: { tooltip: 'qtip-blue' } + } + }; +})(jQuery); diff --git a/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.js b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.js new file mode 100644 index 0000000..98b0b85 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.js @@ -0,0 +1,15 @@ +/* + * jquery.qtip. The jQuery tooltip plugin + * + * Copyright (c) 2009 Craig Thompson + * http://craigsworks.com + * + * Licensed under MIT + * http://www.opensource.org/licenses/mit-license.php + * + * Launch : February 2009 + * Version : 1.0.0-rc3 + * Released: Tuesday 12th May, 2009 - 00:00 + * Debug: jquery.qtip.debug.js + */ +(function($){$.fn.qtip=function(options,blanket){var i,id,interfaces,opts,obj,command,config,api;if(typeof options=="string"){if(typeof $(this).data("qtip")!=="object"){$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.NO_TOOLTIP_PRESENT,false)}if(options=="api"){return $(this).data("qtip").interfaces[$(this).data("qtip").current]}else{if(options=="interfaces"){return $(this).data("qtip").interfaces}}}else{if(!options){options={}}if(typeof options.content!=="object"||(options.content.jquery&&options.content.length>0)){options.content={text:options.content}}if(typeof options.content.title!=="object"){options.content.title={text:options.content.title}}if(typeof options.position!=="object"){options.position={corner:options.position}}if(typeof options.position.corner!=="object"){options.position.corner={target:options.position.corner,tooltip:options.position.corner}}if(typeof options.show!=="object"){options.show={when:options.show}}if(typeof options.show.when!=="object"){options.show.when={event:options.show.when}}if(typeof options.show.effect!=="object"){options.show.effect={type:options.show.effect}}if(typeof options.hide!=="object"){options.hide={when:options.hide}}if(typeof options.hide.when!=="object"){options.hide.when={event:options.hide.when}}if(typeof options.hide.effect!=="object"){options.hide.effect={type:options.hide.effect}}if(typeof options.style!=="object"){options.style={name:options.style}}options.style=sanitizeStyle(options.style);opts=$.extend(true,{},$.fn.qtip.defaults,options);opts.style=buildStyle.call({options:opts},opts.style);opts.user=$.extend(true,{},options)}return $(this).each(function(){if(typeof options=="string"){command=options.toLowerCase();interfaces=$(this).qtip("interfaces");if(typeof interfaces=="object"){if(blanket===true&&command=="destroy"){while(interfaces.length>0){interfaces[interfaces.length-1].destroy()}}else{if(blanket!==true){interfaces=[$(this).qtip("api")]}for(i=0;i0))}if(typeof self.options.show.solo=="object"){solo=$(self.options.show.solo)}else{if(self.options.show.solo===true){solo=$("div.qtip").not(self.elements.tooltip)}}if(solo){solo.each(function(){if($(this).qtip("api").status.rendered===true){$(this).qtip("api").hide()}})}if(typeof self.options.show.effect.type=="function"){self.options.show.effect.type.call(self.elements.tooltip,self.options.show.effect.length);self.elements.tooltip.queue(function(){afterShow();$(this).dequeue()})}else{switch(self.options.show.effect.type.toLowerCase()){case"fade":self.elements.tooltip.fadeIn(self.options.show.effect.length,afterShow);break;case"slide":self.elements.tooltip.slideDown(self.options.show.effect.length,function(){afterShow();if(self.options.position.type!=="static"){self.updatePosition(event,true)}});break;case"grow":self.elements.tooltip.show(self.options.show.effect.length,afterShow);break;default:self.elements.tooltip.show(null,afterShow);break}self.elements.tooltip.addClass(self.options.style.classes.active)}return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_SHOWN,"show")},hide:function(event){var returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"hide")}else{if(self.elements.tooltip.css("display")==="none"){return self}}clearTimeout(self.timers.show);self.elements.tooltip.stop(true,false);returned=self.beforeHide.call(self,event);if(returned===false){return self}function afterHide(){self.onHide.call(self,event)}self.cache.toggle=0;if(typeof self.options.hide.effect.type=="function"){self.options.hide.effect.type.call(self.elements.tooltip,self.options.hide.effect.length);self.elements.tooltip.queue(function(){afterHide();$(this).dequeue()})}else{switch(self.options.hide.effect.type.toLowerCase()){case"fade":self.elements.tooltip.fadeOut(self.options.hide.effect.length,afterHide);break;case"slide":self.elements.tooltip.slideUp(self.options.hide.effect.length,afterHide);break;case"grow":self.elements.tooltip.hide(self.options.hide.effect.length,afterHide);break;default:self.elements.tooltip.hide(null,afterHide);break}self.elements.tooltip.removeClass(self.options.style.classes.active)}return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_HIDDEN,"hide")},updatePosition:function(event,animate){var i,target,tooltip,coords,mapName,imagePos,newPosition,ieAdjust,ie6Adjust,borderAdjust,mouseAdjust,offset,curPosition,returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updatePosition")}else{if(self.options.position.type=="static"){return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.CANNOT_POSITION_STATIC,"updatePosition")}}target={position:{left:0,top:0},dimensions:{height:0,width:0},corner:self.options.position.corner.target};tooltip={position:self.getPosition(),dimensions:self.getDimensions(),corner:self.options.position.corner.tooltip};if(self.options.position.target!=="mouse"){if(self.options.position.target.get(0).nodeName.toLowerCase()=="area"){coords=self.options.position.target.attr("coords").split(",");for(i=0;itarget.dimensions.width){target.dimensions.width=coords[i]}if(coords[i]target.dimensions.height){target.dimensions.height=coords[i]}if(coords[i]0){if(tooltip.corner.search(/Left/)!==-1){newPosition.left-=self.options.style.border.radius}else{if(tooltip.corner.search(/Right/)!==-1){newPosition.left+=self.options.style.border.radius}}if(tooltip.corner.search(/Top/)!==-1){newPosition.top-=self.options.style.border.radius}else{if(tooltip.corner.search(/Bottom/)!==-1){newPosition.top+=self.options.style.border.radius}}}if(ieAdjust){if(tooltip.corner.search(/top/)!==-1){newPosition.top-=ieAdjust}else{if(tooltip.corner.search(/bottom/)!==-1){newPosition.top+=ieAdjust}}if(tooltip.corner.search(/left/)!==-1){newPosition.left-=ieAdjust}else{if(tooltip.corner.search(/right/)!==-1){newPosition.left+=ieAdjust}}if(tooltip.corner.search(/leftMiddle|rightMiddle/)!==-1){newPosition.top-=1}}if(self.options.position.adjust.screen===true){newPosition=screenAdjust.call(self,newPosition,target,tooltip)}if(self.options.position.target==="mouse"&&self.options.position.adjust.mouse===true){if(self.options.position.adjust.screen===true&&self.elements.tip){mouseAdjust=self.elements.tip.attr("rel")}else{mouseAdjust=self.options.position.corner.tooltip}newPosition.left+=(mouseAdjust.search(/right/i)!==-1)?-6:6;newPosition.top+=(mouseAdjust.search(/bottom/i)!==-1)?-6:6}if(!self.elements.bgiframe&&$.browser.msie&&parseInt($.browser.version.charAt(0))==6){$("select, object").each(function(){offset=$(this).offset();offset.bottom=offset.top+$(this).height();offset.right=offset.left+$(this).width();if(newPosition.top+tooltip.dimensions.height>=offset.top&&newPosition.left+tooltip.dimensions.width>=offset.left){bgiframe.call(self)}})}newPosition.left+=self.options.position.adjust.x;newPosition.top+=self.options.position.adjust.y;curPosition=self.getPosition();if(newPosition.left!=curPosition.left||newPosition.top!=curPosition.top){returned=self.beforePositionUpdate.call(self,event);if(returned===false){return self}self.cache.position=newPosition;if(animate===true){self.status.animated=true;self.elements.tooltip.animate(newPosition,200,"swing",function(){self.status.animated=false})}else{self.elements.tooltip.css(newPosition)}self.onPositionUpdate.call(self,event);if(typeof event!=="undefined"&&event.type&&event.type!=="mousemove"){$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_POSITION_UPDATED,"updatePosition")}}return self},updateWidth:function(newWidth){var hidden;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateWidth")}else{if(newWidth&&typeof newWidth!=="number"){return $.fn.qtip.log.error.call(self,2,"newWidth must be of type number","updateWidth")}}hidden=self.elements.contentWrapper.siblings().add(self.elements.tip).add(self.elements.button);if(!newWidth){if(typeof self.options.style.width.value=="number"){newWidth=self.options.style.width.value}else{self.elements.tooltip.css({width:"auto"});hidden.hide();if($.browser.msie){self.elements.wrapper.add(self.elements.contentWrapper.children()).css({zoom:"normal"})}newWidth=self.getDimensions().width+1;if(!self.options.style.width.value){if(newWidth>self.options.style.width.max){newWidth=self.options.style.width.max}if(newWidth").get(0).getContext){tip=self.elements.tooltip.find(".qtip-tip canvas:first");context=tip.get(0).getContext("2d");context.clearRect(0,0,300,300);corner=tip.parent("div[rel]:first").attr("rel");coordinates=calculateTip(corner,self.options.style.tip.size.width,self.options.style.tip.size.height);drawTip.call(self,tip,coordinates,self.options.style.tip.color||self.options.style.border.color)}else{if($.browser.msie){tip=self.elements.tooltip.find('.qtip-tip [nodeName="shape"]');tip.attr("fillcolor",self.options.style.tip.color||self.options.style.border.color)}}}if(self.options.style.border.radius>0){self.elements.tooltip.find(".qtip-betweenCorners").css({backgroundColor:self.options.style.border.color});if($("").get(0).getContext){borders=calculateBorders(self.options.style.border.radius);self.elements.tooltip.find(".qtip-wrapper canvas").each(function(){context=$(this).get(0).getContext("2d");context.clearRect(0,0,300,300);corner=$(this).parent("div[rel]:first").attr("rel");drawBorder.call(self,$(this),borders[corner],self.options.style.border.radius,self.options.style.border.color)})}else{if($.browser.msie){self.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function(){$(this).attr("fillcolor",self.options.style.border.color)})}}}return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_STYLE_UPDATED,"updateStyle")},updateContent:function(content,reposition){var parsedContent,images,loadedImages;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateContent")}else{if(!content){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateContent")}}parsedContent=self.beforeContentUpdate.call(self,content);if(typeof parsedContent=="string"){content=parsedContent}else{if(parsedContent===false){return}}if($.browser.msie){self.elements.contentWrapper.children().css({zoom:"normal"})}if(content.jquery&&content.length>0){content.clone(true).appendTo(self.elements.content).show()}else{self.elements.content.html(content)}images=self.elements.content.find("img[complete=false]");if(images.length>0){loadedImages=0;images.each(function(i){$('').load(function(){if(++loadedImages==images.length){afterLoad()}})})}else{afterLoad()}function afterLoad(){self.updateWidth();if(reposition!==false){if(self.options.position.type!=="static"){self.updatePosition(self.elements.tooltip.is(":visible"),true)}if(self.options.style.tip.corner!==false){positionTip.call(self)}}}self.onContentUpdate.call(self);return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_CONTENT_UPDATED,"loadContent")},loadContent:function(url,data,method){var returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"loadContent")}returned=self.beforeContentLoad.call(self);if(returned===false){return self}if(method=="post"){$.post(url,data,setupContent)}else{$.get(url,data,setupContent)}function setupContent(content){self.onContentLoad.call(self);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_CONTENT_LOADED,"loadContent");self.updateContent(content)}return self},updateTitle:function(content){if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateTitle")}else{if(!content){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateTitle")}}returned=self.beforeTitleUpdate.call(self);if(returned===false){return self}if(self.elements.button){self.elements.button=self.elements.button.clone(true)}self.elements.title.html(content);if(self.elements.button){self.elements.title.prepend(self.elements.button)}self.onTitleUpdate.call(self);return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_TITLE_UPDATED,"updateTitle")},focus:function(event){var curIndex,newIndex,elemIndex,returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"focus")}else{if(self.options.position.type=="static"){return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.CANNOT_FOCUS_STATIC,"focus")}}curIndex=parseInt(self.elements.tooltip.css("z-index"));newIndex=6000+$("div.qtip[qtip]").length-1;if(!self.status.focused&&curIndex!==newIndex){returned=self.beforeFocus.call(self,event);if(returned===false){return self}$("div.qtip[qtip]").not(self.elements.tooltip).each(function(){if($(this).qtip("api").status.rendered===true){elemIndex=parseInt($(this).css("z-index"));if(typeof elemIndex=="number"&&elemIndex>-1){$(this).css({zIndex:parseInt($(this).css("z-index"))-1})}$(this).qtip("api").status.focused=false}});self.elements.tooltip.css({zIndex:newIndex});self.status.focused=true;self.onFocus.call(self,event);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_FOCUSED,"focus")}return self},disable:function(state){if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"disable")}if(state){if(!self.status.disabled){self.status.disabled=true;$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_DISABLED,"disable")}else{$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED,"disable")}}else{if(self.status.disabled){self.status.disabled=false;$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_ENABLED,"disable")}else{$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED,"disable")}}return self},destroy:function(){var i,returned,interfaces;returned=self.beforeDestroy.call(self);if(returned===false){return self}if(self.status.rendered){self.options.show.when.target.unbind("mousemove.qtip",self.updatePosition);self.options.show.when.target.unbind("mouseout.qtip",self.hide);self.options.show.when.target.unbind(self.options.show.when.event+".qtip");self.options.hide.when.target.unbind(self.options.hide.when.event+".qtip");self.elements.tooltip.unbind(self.options.hide.when.event+".qtip");self.elements.tooltip.unbind("mouseover.qtip",self.focus);self.elements.tooltip.remove()}else{self.options.show.when.target.unbind(self.options.show.when.event+".qtip-create")}if(typeof self.elements.target.data("qtip")=="object"){interfaces=self.elements.target.data("qtip").interfaces;if(typeof interfaces=="object"&&interfaces.length>0){for(i=0;i0){self.elements.target.data("qtip").current=interfaces.length-1}else{self.elements.target.removeData("qtip")}self.onDestroy.call(self);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_DESTROYED,"destroy");return self.elements.target},getPosition:function(){var show,offset;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getPosition")}show=(self.elements.tooltip.css("display")!=="none")?false:true;if(show){self.elements.tooltip.css({visiblity:"hidden"}).show()}offset=self.elements.tooltip.offset();if(show){self.elements.tooltip.css({visiblity:"visible"}).hide()}return offset},getDimensions:function(){var show,dimensions;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getDimensions")}show=(!self.elements.tooltip.is(":visible"))?true:false;if(show){self.elements.tooltip.css({visiblity:"hidden"}).show()}dimensions={height:self.elements.tooltip.outerHeight(),width:self.elements.tooltip.outerWidth()};if(show){self.elements.tooltip.css({visiblity:"visible"}).hide()}return dimensions}})}function construct(){var self,adjust,content,url,data,method,tempLength;self=this;self.beforeRender.call(self);self.status.rendered=true;self.elements.tooltip=' ';self.elements.tooltip=$(self.elements.tooltip);self.elements.tooltip.appendTo(self.options.position.container);self.elements.tooltip.data("qtip",{current:0,interfaces:[self]});self.elements.wrapper=self.elements.tooltip.children("div:first");self.elements.contentWrapper=self.elements.wrapper.children("div:first").css({background:self.options.style.background});self.elements.content=self.elements.contentWrapper.children("div:first").css(jQueryStyle(self.options.style));if($.browser.msie){self.elements.wrapper.add(self.elements.content).css({zoom:1})}if(self.options.hide.when.event=="unfocus"){self.elements.tooltip.attr("unfocus",true)}if(typeof self.options.style.width.value=="number"){self.updateWidth()}if($("").get(0).getContext||$.browser.msie){if(self.options.style.border.radius>0){createBorder.call(self)}else{self.elements.contentWrapper.css({border:self.options.style.border.width+"px solid "+self.options.style.border.color})}if(self.options.style.tip.corner!==false){createTip.call(self)}}else{self.elements.contentWrapper.css({border:self.options.style.border.width+"px solid "+self.options.style.border.color});self.options.style.border.radius=0;self.options.style.tip.corner=false;$.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED,"render")}if((typeof self.options.content.text=="string"&&self.options.content.text.length>0)||(self.options.content.text.jquery&&self.options.content.text.length>0)){content=self.options.content.text}else{if(typeof self.elements.target.attr("title")=="string"&&self.elements.target.attr("title").length>0){content=self.elements.target.attr("title").replace("\\n","");self.elements.target.attr("title","")}else{if(typeof self.elements.target.attr("alt")=="string"&&self.elements.target.attr("alt").length>0){content=self.elements.target.attr("alt").replace("\\n","");self.elements.target.attr("alt","")}else{content=" ";$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.NO_VALID_CONTENT,"render")}}}if(self.options.content.title.text!==false){createTitle.call(self)}self.updateContent(content);assignEvents.call(self);if(self.options.show.ready===true){self.show()}if(self.options.content.url!==false){url=self.options.content.url;data=self.options.content.data;method=self.options.content.method||"get";self.loadContent(url,data,method)}self.onRender.call(self);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_RENDERED,"render")}function createBorder(){var self,i,width,radius,color,coordinates,containers,size,betweenWidth,betweenCorners,borderTop,borderBottom,borderCoord,sideWidth,vertWidth;self=this;self.elements.wrapper.find(".qtip-borderBottom, .qtip-borderTop").remove();width=self.options.style.border.width;radius=self.options.style.border.radius;color=self.options.style.border.color||self.options.style.tip.color;coordinates=calculateBorders(radius);containers={};for(i in coordinates){containers[i]='';if($("").get(0).getContext){containers[i]+=''}else{if($.browser.msie){size=radius*2+3;containers[i]+=''}}containers[i]+=""}betweenWidth=self.getDimensions().width-(Math.max(width,radius)*2);betweenCorners='';borderTop=''+containers.topLeft+containers.topRight+betweenCorners;self.elements.wrapper.prepend(borderTop);borderBottom=''+containers.bottomLeft+containers.bottomRight+betweenCorners;self.elements.wrapper.append(borderBottom);if($("").get(0).getContext){self.elements.wrapper.find("canvas").each(function(){borderCoord=coordinates[$(this).parent("[rel]:first").attr("rel")];drawBorder.call(self,$(this),borderCoord,radius,color)})}else{if($.browser.msie){self.elements.tooltip.append('')}}sideWidth=Math.max(radius,(radius+(width-radius)));vertWidth=Math.max(width-radius,0);self.elements.contentWrapper.css({border:"0px solid "+color,borderWidth:vertWidth+"px "+sideWidth+"px"})}function drawBorder(canvas,coordinates,radius,color){var context=canvas.get(0).getContext("2d");context.fillStyle=color;context.beginPath();context.arc(coordinates[0],coordinates[1],radius,0,Math.PI*2,false);context.fill()}function createTip(corner){var self,color,coordinates,coordsize,path;self=this;if(self.elements.tip!==null){self.elements.tip.remove()}color=self.options.style.tip.color||self.options.style.border.color;if(self.options.style.tip.corner===false){return}else{if(!corner){corner=self.options.style.tip.corner}}coordinates=calculateTip(corner,self.options.style.tip.size.width,self.options.style.tip.size.height);self.elements.tip='';if($("").get(0).getContext){self.elements.tip+=''}else{if($.browser.msie){coordsize=self.options.style.tip.size.width+","+self.options.style.tip.size.height;path="m"+coordinates[0][0]+","+coordinates[0][1];path+=" l"+coordinates[1][0]+","+coordinates[1][1];path+=" "+coordinates[2][0]+","+coordinates[2][1];path+=" xe";self.elements.tip+='';self.elements.tip+='';self.elements.contentWrapper.css("position","relative")}}self.elements.tooltip.prepend(self.elements.tip+"");self.elements.tip=self.elements.tooltip.find("."+self.options.style.classes.tip).eq(0);if($("").get(0).getContext){drawTip.call(self,self.elements.tip.find("canvas:first"),coordinates,color)}if(corner.search(/top/)!==-1&&$.browser.msie&&parseInt($.browser.version.charAt(0))===6){self.elements.tip.css({marginTop:-4})}positionTip.call(self,corner)}function drawTip(canvas,coordinates,color){var context=canvas.get(0).getContext("2d");context.fillStyle=color;context.beginPath();context.moveTo(coordinates[0][0],coordinates[0][1]);context.lineTo(coordinates[1][0],coordinates[1][1]);context.lineTo(coordinates[2][0],coordinates[2][1]);context.fill()}function positionTip(corner){var self,ieAdjust,paddingCorner,paddingSize,newMargin;self=this;if(self.options.style.tip.corner===false||!self.elements.tip){return}if(!corner){corner=self.elements.tip.attr("rel")}ieAdjust=positionAdjust=($.browser.msie)?1:0;self.elements.tip.css(corner.match(/left|right|top|bottom/)[0],0);if(corner.search(/top|bottom/)!==-1){if($.browser.msie){if(parseInt($.browser.version.charAt(0))===6){positionAdjust=(corner.search(/top/)!==-1)?-3:1}else{positionAdjust=(corner.search(/top/)!==-1)?1:2}}if(corner.search(/Middle/)!==-1){self.elements.tip.css({left:"50%",marginLeft:-(self.options.style.tip.size.width/2)})}else{if(corner.search(/Left/)!==-1){self.elements.tip.css({left:self.options.style.border.radius-ieAdjust})}else{if(corner.search(/Right/)!==-1){self.elements.tip.css({right:self.options.style.border.radius+ieAdjust})}}}if(corner.search(/top/)!==-1){self.elements.tip.css({top:-positionAdjust})}else{self.elements.tip.css({bottom:positionAdjust})}}else{if(corner.search(/left|right/)!==-1){if($.browser.msie){positionAdjust=(parseInt($.browser.version.charAt(0))===6)?1:((corner.search(/left/)!==-1)?1:2)}if(corner.search(/Middle/)!==-1){self.elements.tip.css({top:"50%",marginTop:-(self.options.style.tip.size.height/2)})}else{if(corner.search(/Top/)!==-1){self.elements.tip.css({top:self.options.style.border.radius-ieAdjust})}else{if(corner.search(/Bottom/)!==-1){self.elements.tip.css({bottom:self.options.style.border.radius+ieAdjust})}}}if(corner.search(/left/)!==-1){self.elements.tip.css({left:-positionAdjust})}else{self.elements.tip.css({right:positionAdjust})}}}paddingCorner="padding-"+corner.match(/left|right|top|bottom/)[0];paddingSize=self.options.style.tip.size[(paddingCorner.search(/left|right/)!==-1)?"width":"height"];self.elements.tooltip.css("padding",0);self.elements.tooltip.css(paddingCorner,paddingSize);if($.browser.msie&&parseInt($.browser.version.charAt(0))==6){newMargin=parseInt(self.elements.tip.css("margin-top"))||0;newMargin+=parseInt(self.elements.content.css("margin-top"))||0;self.elements.tip.css({marginTop:newMargin})}}function createTitle(){var self=this;if(self.elements.title!==null){self.elements.title.remove()}self.elements.title=$('').css(jQueryStyle(self.options.style.title,true)).css({zoom:($.browser.msie)?1:0}).prependTo(self.elements.contentWrapper);if(self.options.content.title.text){self.updateTitle.call(self,self.options.content.title.text)}if(self.options.content.title.button!==false&&typeof self.options.content.title.button=="string"){self.elements.button=$('').css(jQueryStyle(self.options.style.button,true)).html(self.options.content.title.button).prependTo(self.elements.title).click(function(event){if(!self.status.disabled){self.hide(event)}})}}function assignEvents(){var self,showTarget,hideTarget,inactiveEvents;self=this;showTarget=self.options.show.when.target;hideTarget=self.options.hide.when.target;if(self.options.hide.fixed){hideTarget=hideTarget.add(self.elements.tooltip)}if(self.options.hide.when.event=="inactive"){inactiveEvents=["click","dblclick","mousedown","mouseup","mousemove","mouseout","mouseenter","mouseleave","mouseover"];function inactiveMethod(event){if(self.status.disabled===true){return}clearTimeout(self.timers.inactive);self.timers.inactive=setTimeout(function(){$(inactiveEvents).each(function(){hideTarget.unbind(this+".qtip-inactive");self.elements.content.unbind(this+".qtip-inactive")});self.hide(event)},self.options.hide.delay)}}else{if(self.options.hide.fixed===true){self.elements.tooltip.bind("mouseover.qtip",function(){if(self.status.disabled===true){return}clearTimeout(self.timers.hide)})}}function showMethod(event){if(self.status.disabled===true){return}if(self.options.hide.when.event=="inactive"){$(inactiveEvents).each(function(){hideTarget.bind(this+".qtip-inactive",inactiveMethod);self.elements.content.bind(this+".qtip-inactive",inactiveMethod)});inactiveMethod()}clearTimeout(self.timers.show);clearTimeout(self.timers.hide);self.timers.show=setTimeout(function(){self.show(event)},self.options.show.delay)}function hideMethod(event){if(self.status.disabled===true){return}if(self.options.hide.fixed===true&&self.options.hide.when.event.search(/mouse(out|leave)/i)!==-1&&$(event.relatedTarget).parents("div.qtip[qtip]").length>0){event.stopPropagation();event.preventDefault();clearTimeout(self.timers.hide);return false}clearTimeout(self.timers.show);clearTimeout(self.timers.hide);self.elements.tooltip.stop(true,true);self.timers.hide=setTimeout(function(){self.hide(event)},self.options.hide.delay)}if((self.options.show.when.target.add(self.options.hide.when.target).length===1&&self.options.show.when.event==self.options.hide.when.event&&self.options.hide.when.event!=="inactive")||self.options.hide.when.event=="unfocus"){self.cache.toggle=0;showTarget.bind(self.options.show.when.event+".qtip",function(event){if(self.cache.toggle==0){showMethod(event)}else{hideMethod(event)}})}else{showTarget.bind(self.options.show.when.event+".qtip",showMethod);if(self.options.hide.when.event!=="inactive"){hideTarget.bind(self.options.hide.when.event+".qtip",hideMethod)}}if(self.options.position.type.search(/(fixed|absolute)/)!==-1){self.elements.tooltip.bind("mouseover.qtip",self.focus)}if(self.options.position.target==="mouse"&&self.options.position.type!=="static"){showTarget.bind("mousemove.qtip",function(event){self.cache.mouse={x:event.pageX,y:event.pageY};if(self.status.disabled===false&&self.options.position.adjust.mouse===true&&self.options.position.type!=="static"&&self.elements.tooltip.css("display")!=="none"){self.updatePosition(event)}})}}function screenAdjust(position,target,tooltip){var self,adjustedPosition,adjust,newCorner,overflow,corner;self=this;if(tooltip.corner=="center"){return target.position}adjustedPosition=$.extend({},position);newCorner={x:false,y:false};overflow={left:(adjustedPosition.left<$.fn.qtip.cache.screen.scroll.left),right:(adjustedPosition.left+tooltip.dimensions.width+2>=$.fn.qtip.cache.screen.width+$.fn.qtip.cache.screen.scroll.left),top:(adjustedPosition.top<$.fn.qtip.cache.screen.scroll.top),bottom:(adjustedPosition.top+tooltip.dimensions.height+2>=$.fn.qtip.cache.screen.height+$.fn.qtip.cache.screen.scroll.top)};adjust={left:(overflow.left&&(tooltip.corner.search(/right/i)!=-1||(tooltip.corner.search(/right/i)==-1&&!overflow.right))),right:(overflow.right&&(tooltip.corner.search(/left/i)!=-1||(tooltip.corner.search(/left/i)==-1&&!overflow.left))),top:(overflow.top&&tooltip.corner.search(/top/i)==-1),bottom:(overflow.bottom&&tooltip.corner.search(/bottom/i)==-1)};if(adjust.left){if(self.options.position.target!=="mouse"){adjustedPosition.left=target.position.left+target.dimensions.width}else{adjustedPosition.left=self.cache.mouse.x}newCorner.x="Left"}else{if(adjust.right){if(self.options.position.target!=="mouse"){adjustedPosition.left=target.position.left-tooltip.dimensions.width}else{adjustedPosition.left=self.cache.mouse.x-tooltip.dimensions.width}newCorner.x="Right"}}if(adjust.top){if(self.options.position.target!=="mouse"){adjustedPosition.top=target.position.top+target.dimensions.height}else{adjustedPosition.top=self.cache.mouse.y}newCorner.y="top"}else{if(adjust.bottom){if(self.options.position.target!=="mouse"){adjustedPosition.top=target.position.top-tooltip.dimensions.height}else{adjustedPosition.top=self.cache.mouse.y-tooltip.dimensions.height}newCorner.y="bottom"}}if(adjustedPosition.left<0){adjustedPosition.left=position.left;newCorner.x=false}if(adjustedPosition.top<0){adjustedPosition.top=position.top;newCorner.y=false}if(self.options.style.tip.corner!==false){adjustedPosition.corner=new String(tooltip.corner);if(newCorner.x!==false){adjustedPosition.corner=adjustedPosition.corner.replace(/Left|Right|Middle/,newCorner.x)}if(newCorner.y!==false){adjustedPosition.corner=adjustedPosition.corner.replace(/top|bottom/,newCorner.y)}if(adjustedPosition.corner!==self.elements.tip.attr("rel")){createTip.call(self,adjustedPosition.corner)}}return adjustedPosition}function jQueryStyle(style,sub){var styleObj,i;styleObj=$.extend(true,{},style);for(i in styleObj){if(sub===true&&i.search(/(tip|classes)/i)!==-1){delete styleObj[i]}else{if(!sub&&i.search(/(width|border|tip|title|classes|user)/i)!==-1){delete styleObj[i]}}}return styleObj}function sanitizeStyle(style){if(typeof style.tip!=="object"){style.tip={corner:style.tip}}if(typeof style.tip.size!=="object"){style.tip.size={width:style.tip.size,height:style.tip.size}}if(typeof style.border!=="object"){style.border={width:style.border}}if(typeof style.width!=="object"){style.width={value:style.width}}if(typeof style.width.max=="string"){style.width.max=parseInt(style.width.max.replace(/([0-9]+)/i,"$1"))}if(typeof style.width.min=="string"){style.width.min=parseInt(style.width.min.replace(/([0-9]+)/i,"$1"))}if(typeof style.tip.size.x=="number"){style.tip.size.width=style.tip.size.x;delete style.tip.size.x}if(typeof style.tip.size.y=="number"){style.tip.size.height=style.tip.size.y;delete style.tip.size.y}return style}function buildStyle(){var self,i,styleArray,styleExtend,finalStyle,ieAdjust;self=this;styleArray=[true,{}];for(i=0;i0){finalStyle.tip.size.width+=1}if(finalStyle.tip.size.height%2>0){finalStyle.tip.size.height+=1}if(finalStyle.tip.corner===true){finalStyle.tip.corner=(self.options.position.corner.tooltip==="center")?false:self.options.position.corner.tooltip}return finalStyle}function calculateTip(corner,width,height){var tips={bottomRight:[[0,0],[width,height],[width,0]],bottomLeft:[[0,0],[width,0],[0,height]],topRight:[[0,height],[width,0],[width,height]],topLeft:[[0,0],[0,height],[width,height]],topMiddle:[[0,height],[width/2,0],[width,height]],bottomMiddle:[[0,0],[width,0],[width/2,height]],rightMiddle:[[0,0],[width,height/2],[0,height]],leftMiddle:[[width,0],[width,height],[0,height/2]]};tips.leftTop=tips.bottomRight;tips.rightTop=tips.bottomLeft;tips.leftBottom=tips.topRight;tips.rightBottom=tips.topLeft;return tips[corner]}function calculateBorders(radius){var borders;if($("").get(0).getContext){borders={topLeft:[radius,radius],topRight:[0,radius],bottomLeft:[radius,0],bottomRight:[0,0]}}else{if($.browser.msie){borders={topLeft:[-90,90,0],topRight:[-90,90,-radius],bottomLeft:[90,270,0],bottomRight:[90,270,-radius]}}}return borders}function bgiframe(){var self,html,dimensions;self=this;dimensions=self.getDimensions();html='';self.elements.bgiframe=self.elements.wrapper.prepend(html).children(".qtip-bgiframe:first")}$(document).ready(function(){$.fn.qtip.cache={screen:{scroll:{left:$(window).scrollLeft(),top:$(window).scrollTop()},width:$(window).width(),height:$(window).height()}};var adjustTimer;$(window).bind("resize scroll",function(event){clearTimeout(adjustTimer);adjustTimer=setTimeout(function(){if(event.type==="scroll"){$.fn.qtip.cache.screen.scroll={left:$(window).scrollLeft(),top:$(window).scrollTop()}}else{$.fn.qtip.cache.screen.width=$(window).width();$.fn.qtip.cache.screen.height=$(window).height()}for(i=0;i<$.fn.qtip.interfaces.length;i++){var api=$.fn.qtip.interfaces[i];if(api.status.rendered===true&&(api.options.position.type!=="static"||api.options.position.adjust.scroll&&event.type==="scroll"||api.options.position.adjust.resize&&event.type==="resize")){api.updatePosition(event,true)}}},100)});$(document).bind("mousedown.qtip",function(event){if($(event.target).parents("div.qtip").length===0){$(".qtip[unfocus]").each(function(){var api=$(this).qtip("api");if($(this).is(":visible")&&!api.status.disabled&&$(event.target).add(api.elements.target).length>1){api.hide(event)}})}})});$.fn.qtip.interfaces=[];$.fn.qtip.log={error:function(){return this}};$.fn.qtip.constants={};$.fn.qtip.defaults={content:{prerender:false,text:false,url:false,data:null,title:{text:false,button:false}},position:{target:false,corner:{target:"bottomRight",tooltip:"topLeft"},adjust:{x:0,y:0,mouse:true,screen:false,scroll:true,resize:true},type:"absolute",container:false},show:{when:{target:false,event:"mouseover"},effect:{type:"fade",length:100},delay:140,solo:false,ready:false},hide:{when:{target:false,event:"mouseout"},effect:{type:"fade",length:100},delay:0,fixed:false},api:{beforeRender:function(){},onRender:function(){},beforePositionUpdate:function(){},onPositionUpdate:function(){},beforeShow:function(){},onShow:function(){},beforeHide:function(){},onHide:function(){},beforeContentUpdate:function(){},onContentUpdate:function(){},beforeContentLoad:function(){},onContentLoad:function(){},beforeTitleUpdate:function(){},onTitleUpdate:function(){},beforeDestroy:function(){},onDestroy:function(){},beforeFocus:function(){},onFocus:function(){}}};$.fn.qtip.styles={defaults:{background:"white",color:"#111",overflow:"hidden",textAlign:"left",width:{min:0,max:250},padding:"5px 9px",border:{width:1,radius:0,color:"#d3d3d3"},tip:{corner:false,color:false,size:{width:13,height:13},opacity:1},title:{background:"#e1e1e1",fontWeight:"bold",padding:"7px 12px"},button:{cursor:"pointer"},classes:{target:"",tip:"qtip-tip",title:"qtip-title",button:"qtip-button",content:"qtip-content",active:"qtip-active"}},cream:{border:{width:3,radius:0,color:"#F9E98E"},title:{background:"#F0DE7D",color:"#A27D35"},background:"#FBF7AA",color:"#A27D35",classes:{tooltip:"qtip-cream"}},light:{border:{width:3,radius:0,color:"#E2E2E2"},title:{background:"#f1f1f1",color:"#454545"},background:"white",color:"#454545",classes:{tooltip:"qtip-light"}},dark:{border:{width:3,radius:0,color:"#303030"},title:{background:"#404040",color:"#f3f3f3"},background:"#505050",color:"#f3f3f3",classes:{tooltip:"qtip-dark"}},red:{border:{width:3,radius:0,color:"#CE6F6F"},title:{background:"#f28279",color:"#9C2F2F"},background:"#F79992",color:"#9C2F2F",classes:{tooltip:"qtip-red"}},green:{border:{width:3,radius:0,color:"#A9DB66"},title:{background:"#b9db8c",color:"#58792E"},background:"#CDE6AC",color:"#58792E",classes:{tooltip:"qtip-green"}},blue:{border:{width:3,radius:0,color:"#ADD9ED"},title:{background:"#D0E9F5",color:"#5E99BD"},background:"#E5F6FE",color:"#4D9FBF",classes:{tooltip:"qtip-blue"}}}})(jQuery); \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/livequery.js b/blog/wp-content/plugins/front-end-editor/editor/livequery.js new file mode 100644 index 0000000..398f0a4 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/livequery.js @@ -0,0 +1,9 @@ +/* Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net) + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. + * + * Version: 1.0.3 + * Requires jQuery 1.1.3+ + * Docs: http://docs.jquery.com/Plugins/livequery + */ +(function($){$.extend($.fn,{livequery:function(type,fn,fn2){var self=this,q;if($.isFunction(type)){fn2=fn,fn=type,type=undefined}$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&type==query.type&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)){return(q=query)&&false}});q=q||new $.livequery(this.selector,this.context,type,fn,fn2);q.stopped=false;q.run();return this},expire:function(type,fn,fn2){var self=this;if($.isFunction(type)){fn2=fn,fn=type,type=undefined}$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&(!type||type==query.type)&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)&&!this.stopped){$.livequery.stop(query.id)}});return this}});$.livequery=function(selector,context,type,fn,fn2){this.selector=selector;this.context=context||document;this.type=type;this.fn=fn;this.fn2=fn2;this.elements=[];this.stopped=false;this.id=$.livequery.queries.push(this)-1;fn.$lqguid=fn.$lqguid||$.livequery.guid++;if(fn2){fn2.$lqguid=fn2.$lqguid||$.livequery.guid++}return this};$.livequery.prototype={stop:function(){var query=this;if(this.type){this.elements.unbind(this.type,this.fn)}else{if(this.fn2){this.elements.each(function(i,el){query.fn2.apply(el)})}}this.elements=[];this.stopped=true},run:function(){if(this.stopped){return}var query=this;var oEls=this.elements,els=$(this.selector,this.context),nEls=els.not(oEls);this.elements=els;if(this.type){nEls.bind(this.type,this.fn);if(oEls.length>0){$.each(oEls,function(i,el){if($.inArray(el,els)<0){$.event.remove(el,query.type,query.fn)}})}}else{nEls.each(function(){query.fn.apply(this)});if(this.fn2&&oEls.length>0){$.each(oEls,function(i,el){if($.inArray(el,els)<0){query.fn2.apply(el)}})}}}};$.extend($.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if($.livequery.running&&$.livequery.queue.length){var length=$.livequery.queue.length;while(length--){$.livequery.queries[$.livequery.queue.shift()].run()}}},pause:function(){$.livequery.running=false},play:function(){$.livequery.running=true;$.livequery.run()},registerPlugin:function(){$.each(arguments,function(i,n){if(!$.fn[n]){return}var old=$.fn[n];$.fn[n]=function(){var r=old.apply(this,arguments);$.livequery.run();return r}})},run:function(id){if(id!=undefined){if($.inArray(id,$.livequery.queue)<0){$.livequery.queue.push(id)}}else{$.each($.livequery.queries,function(id){if($.inArray(id,$.livequery.queue)<0){$.livequery.queue.push(id)}})}if($.livequery.timeout){clearTimeout($.livequery.timeout)}$.livequery.timeout=setTimeout($.livequery.checkQueue,20)},stop:function(id){if(id!=undefined){$.livequery.queries[id].stop()}else{$.each($.livequery.queries,function(id){$.livequery.queries[id].stop()})}}});$.livequery.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove");$(function(){$.livequery.play()});var init=$.prototype.init;$.prototype.init=function(a,c){var r=init.apply(this,arguments);if(a&&a.selector){r.context=a.context,r.selector=a.selector}if(typeof a=="string"){r.context=c||document,r.selector=a}return r};$.prototype.init.prototype=$.prototype})(jQuery); \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/nicedit/nicEdit.dev.js b/blog/wp-content/plugins/front-end-editor/editor/nicedit/nicEdit.dev.js new file mode 100644 index 0000000..161292d --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/nicedit/nicEdit.dev.js @@ -0,0 +1,1484 @@ +/* NicEdit - Micro Inline WYSIWYG + * Copyright 2007-2008 Brian Kirchoff + * + * NicEdit is distributed under the terms of the MIT license + * For more information visit http://nicedit.com/ + * Do not remove this copyright message + */ +var bkExtend = function(){ + var args = arguments; + if (args.length == 1) args = [this, args[0]]; + for (var prop in args[1]) args[0][prop] = args[1][prop]; + return args[0]; +}; +function bkClass() { } +bkClass.prototype.construct = function() {}; +bkClass.extend = function(def) { + var classDef = function() { + if (arguments[0] !== bkClass) { return this.construct.apply(this, arguments); } + }; + var proto = new this(bkClass); + bkExtend(proto,def); + classDef.prototype = proto; + classDef.extend = this.extend; + return classDef; +}; + +var bkElement = bkClass.extend({ + construct : function(elm,d) { + if(typeof(elm) == "string") { + elm = (d || document).createElement(elm); + } + elm = $BK(elm); + return elm; + }, + + appendTo : function(elm) { + elm.appendChild(this); + return this; + }, + + appendBefore : function(elm) { + elm.parentNode.insertBefore(this,elm); + return this; + }, + + addEvent : function(type, fn) { + bkLib.addEvent(this,type,fn); + return this; + }, + + setContent : function(c) { + this.innerHTML = c; + return this; + }, + + pos : function() { + var curleft = curtop = 0; + var o = obj = this; + if (obj.offsetParent) { + do { + curleft += obj.offsetLeft; + curtop += obj.offsetTop; + } while (obj = obj.offsetParent); + } + var b = (!window.opera) ? parseInt(this.getStyle('border-width') || this.style.border) || 0 : 0; + return [curleft+b,curtop+b+this.offsetHeight]; + }, + + noSelect : function() { + bkLib.noSelect(this); + return this; + }, + + parentTag : function(t) { + var elm = this; + do { + if(elm && elm.nodeName && elm.nodeName.toUpperCase() == t) { + return elm; + } + elm = elm.parentNode; + } while(elm); + return false; + }, + + hasClass : function(cls) { + return this.className.match(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)')); + }, + + addClass : function(cls) { + if (!this.hasClass(cls)) { this.className += " nicEdit-"+cls }; + return this; + }, + + removeClass : function(cls) { + if (this.hasClass(cls)) { + this.className = this.className.replace(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)'),' '); + } + return this; + }, + + setStyle : function(st) { + var elmStyle = this.style; + for(var itm in st) { + switch(itm) { + case 'float': + elmStyle['cssFloat'] = elmStyle['styleFloat'] = st[itm]; + break; + case 'opacity': + elmStyle.opacity = st[itm]; + elmStyle.filter = "alpha(opacity=" + Math.round(st[itm]*100) + ")"; + break; + case 'className': + this.className = st[itm]; + break; + default: + //if(document.compatMode || itm != "cursor") { // Nasty Workaround for IE 5.5 + elmStyle[itm] = st[itm]; + //} + } + } + return this; + }, + + getStyle : function( cssRule, d ) { + var doc = (!d) ? document.defaultView : d; + if(this.nodeType == 1) + return (doc && doc.getComputedStyle) ? doc.getComputedStyle( this, null ).getPropertyValue(cssRule) : this.currentStyle[ bkLib.camelize(cssRule) ]; + }, + + remove : function() { + this.parentNode.removeChild(this); + return this; + }, + + setAttributes : function(at) { + for(var itm in at) { + this[itm] = at[itm]; + } + return this; + } +}); + +var bkLib = { + isMSIE : (navigator.appVersion.indexOf("MSIE") != -1), + + addEvent : function(obj, type, fn) { + (obj.addEventListener) ? obj.addEventListener( type, fn, false ) : obj.attachEvent("on"+type, fn); + }, + + toArray : function(iterable) { + var length = iterable.length, results = new Array(length); + while (length--) { results[length] = iterable[length] }; + return results; + }, + + noSelect : function(element) { + if(element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') { + element.setAttribute('unselectable','on'); + } + for(var i=0;i.nicEdit-main p { margin: 0; }<\/scr"+"ipt>"); + $BK("__ie_onload").onreadystatechange = function() { + if (this.readyState == "complete"){bkLib.domLoaded();} + }; + } + window.onload = bkLib.domLoaded; + } +}; + +function $BK(elm) { + if(typeof(elm) == "string") { + elm = document.getElementById(elm); + } + return (elm && !elm.appendTo) ? bkExtend(elm,bkElement.prototype) : elm; +} + +var bkEvent = { + addEvent : function(evType, evFunc) { + if(evFunc) { + this.eventList = this.eventList || {}; + this.eventList[evType] = this.eventList[evType] || []; + this.eventList[evType].push(evFunc); + } + return this; + }, + fireEvent : function() { + var args = bkLib.toArray(arguments), evType = args.shift(); + if(this.eventList && this.eventList[evType]) { + for(var i=0;i'); + } + this.instanceDoc = document.defaultView; + this.elm.addEvent('mousedown',this.selected.closureListener(this)).addEvent('keypress',this.keyDown.closureListener(this)).addEvent('focus',this.selected.closure(this)).addEvent('blur',this.blur.closure(this)).addEvent('keyup',this.selected.closure(this)); + this.ne.fireEvent('add',this); + }, + + remove : function() { + this.saveContent(); + if(this.copyElm || this.options.hasPanel) { + this.editorContain.remove(); + this.e.setStyle({'display' : 'block'}); + this.ne.removePanel(); + } + this.disable(); + this.ne.fireEvent('remove',this); + }, + + disable : function() { + this.elm.setAttribute('contentEditable','false'); + }, + + getSel : function() { + return (window.getSelection) ? window.getSelection() : document.selection; + }, + + getRng : function() { + var s = this.getSel(); + if(!s) { return null; } + return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange(); + }, + + selRng : function(rng,s) { + if(window.getSelection) { + s.removeAllRanges(); + s.addRange(rng); + } else { + rng.select(); + } + }, + + selElm : function() { + var r = this.getRng(); + if(r.startContainer) { + var contain = r.startContainer; + if(r.cloneContents().childNodes.length == 1) { + for(var i=0;i'+((css) ? '' : '')+''+this.initialContent+'
]+>.*?)<\/p>/g,"$1
/gi,"
/gi,"");content=content.replace(/\s*<\/p>\s*/gi,"\n\n");content=content.replace(/\n[\s\u00a0]+\n/g,"\n\n");content=content.replace(/\s*\s*/gi,"\n");content=content.replace(/\s*
]+>[\s\S]*?<\/p>)/g,"\n$1");content=content.replace(/^\s+/,"");content=content.replace(/[\s\u00a0]+$/,"");content=content.replace(//g,"\n");return content},ajax_set:function(){var self=this;self.editor.nicInstances[0].saveContent();self._super()}});FrontEndEditor.fieldTypes=fieldTypes;$(document).ready(function($){$(".fee-filter-widget_title, .fee-filter-widget_text").each(function(){var $el=$(this);var id=$el.parents(".widget").attr("id");if(id){$el.attr("data-fee",id)}else{$el.replaceWith($el.html())}});$.each(FrontEndEditor.data.fields,function(name,type){$(".fee-filter-"+name).each(function(){var $el=$(this);var id=$el.attr("data-fee");var parts=id.split("#");switch(name){case"post_meta":type=parts[2];break;case"editable_option":type=parts[1];break}new fieldTypes[type]($el,type,name,id)})});if(FrontEndEditor.data.tooltip){$.fn.qtip.styles.fee={height:10,paddingTop:"4px",paddingRight:"5px",paddingBottom:"6px",paddingLeft:"25px",background:"#bbbebf url("+FrontEndEditor.data.tooltip.icon+") top left no-repeat",color:"#ffffff",textAlign:"left",lineHeight:"100%",fontFamily:"sans-serif",fontSize:"14px",opacity:"0.75",border:{width:0,radius:5,color:"#bbbebf"},tip:"bottomLeft",name:"dark"};$(".fee-field").qtip({content:FrontEndEditor.data.tooltip.text,position:{corner:{target:"topMiddle"},adjust:{x:0,y:-40}},show:{effect:"fade"},style:{name:"fee"}})}})})(jQuery); \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/editor.png b/blog/wp-content/plugins/front-end-editor/editor/editor.png new file mode 100644 index 0000000..1bc05e8 Binary files /dev/null and b/blog/wp-content/plugins/front-end-editor/editor/editor.png differ diff --git a/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.dev.js b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.dev.js new file mode 100644 index 0000000..0258a66 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.dev.js @@ -0,0 +1,2149 @@ +/*! + * jquery.qtip. The jQuery tooltip plugin + * + * Copyright (c) 2009 Craig Thompson + * http://craigsworks.com + * + * Licensed under MIT + * http://www.opensource.org/licenses/mit-license.php + * + * Launch : February 2009 + * Version : 1.0.0-rc3 + * Released: Tuesday 12th May, 2009 - 00:00 + * Debug: jquery.qtip.debug.js + */ +(function($) +{ + // Implementation + $.fn.qtip = function(options, blanket) + { + var i, id, interfaces, opts, obj, command, config, api; + + // Return API / Interfaces if requested + if(typeof options == 'string') + { + // Make sure API data exists if requested + if(typeof $(this).data('qtip') !== 'object') + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.NO_TOOLTIP_PRESENT, false); + + // Return requested object + if(options == 'api') + return $(this).data('qtip').interfaces[ $(this).data('qtip').current ]; + else if(options == 'interfaces') + return $(this).data('qtip').interfaces; + } + + // Validate provided options + else + { + // Set null options object if no options are provided + if(!options) options = {}; + + // Sanitize option data + if(typeof options.content !== 'object' || (options.content.jquery && options.content.length > 0)) options.content = { text: options.content }; + if(typeof options.content.title !== 'object') options.content.title = { text: options.content.title }; + if(typeof options.position !== 'object') options.position = { corner: options.position }; + if(typeof options.position.corner !== 'object') options.position.corner = { target: options.position.corner, tooltip: options.position.corner }; + if(typeof options.show !== 'object') options.show = { when: options.show }; + if(typeof options.show.when !== 'object') options.show.when = { event: options.show.when }; + if(typeof options.show.effect !== 'object') options.show.effect = { type: options.show.effect }; + if(typeof options.hide !== 'object') options.hide = { when: options.hide }; + if(typeof options.hide.when !== 'object') options.hide.when = { event: options.hide.when }; + if(typeof options.hide.effect !== 'object') options.hide.effect = { type: options.hide.effect }; + if(typeof options.style !== 'object') options.style = { name: options.style }; + options.style = sanitizeStyle(options.style); + + // Build main options object + opts = $.extend(true, {}, $.fn.qtip.defaults, options); + + // Inherit all style properties into one syle object and include original options + opts.style = buildStyle.call({ options: opts }, opts.style); + opts.user = $.extend(true, {}, options); + }; + + // Iterate each matched element + return $(this).each(function() // Return original elements as per jQuery guidelines + { + // Check for API commands + if(typeof options == 'string') + { + command = options.toLowerCase(); + interfaces = $(this).qtip('interfaces'); + + // Make sure API data exists$('.qtip').qtip('destroy') + if(typeof interfaces == 'object') + { + // Check if API call is a BLANKET DESTROY command + if(blanket === true && command == 'destroy') + while(interfaces.length > 0) interfaces[interfaces.length-1].destroy(); + + // API call is not a BLANKET DESTROY command + else + { + // Check if supplied command effects this tooltip only (NOT BLANKET) + if(blanket !== true) interfaces = [ $(this).qtip('api') ]; + + // Execute command on chosen qTips + for(i = 0; i < interfaces.length; i++) + { + // Destroy command doesn't require tooltip to be rendered + if(command == 'destroy') interfaces[i].destroy(); + + // Only call API if tooltip is rendered and it wasn't a destroy call + else if(interfaces[i].status.rendered === true) + { + if(command == 'show') interfaces[i].show(); + else if(command == 'hide') interfaces[i].hide(); + else if(command == 'focus') interfaces[i].focus(); + else if(command == 'disable') interfaces[i].disable(true); + else if(command == 'enable') interfaces[i].disable(false); + }; + }; + }; + }; + } + + // No API commands, continue with qTip creation + else + { + // Create unique configuration object + config = $.extend(true, {}, opts); + config.hide.effect.length = opts.hide.effect.length; + config.show.effect.length = opts.show.effect.length; + + // Sanitize target options + if(config.position.container === false) config.position.container = $(document.body); + if(config.position.target === false) config.position.target = $(this); + if(config.show.when.target === false) config.show.when.target = $(this); + if(config.hide.when.target === false) config.hide.when.target = $(this); + + // Determine tooltip ID (Reuse array slots if possible) + id = $.fn.qtip.interfaces.length; + for(i = 0; i < id; i++) + { + if(typeof $.fn.qtip.interfaces[i] == 'undefined'){ id = i; break; }; + }; + + // Instantiate the tooltip + obj = new qTip($(this), config, id); + + // Add API references + $.fn.qtip.interfaces[id] = obj; + + // Check if element already has qTip data assigned + if( $(this).data('qtip') ) + { + // Set new current interface id + if(typeof $(this).attr('qtip') === 'undefined') + $(this).data('qtip').current = $(this).data('qtip').interfaces.length; + + // Push new API interface onto interfaces array + $(this).data('qtip').interfaces.push(obj); + } + + // No qTip data is present, create now + else $(this).data('qtip', { current: 0, interfaces: [obj] }); + + // If prerendering is disabled, create tooltip on showEvent + if(config.content.prerender === false && config.show.when.event !== false && config.show.ready !== true) + { + config.show.when.target.bind(config.show.when.event+'.qtip-'+id+'-create', { qtip: id }, function(event) + { + // Retrieve API interface via passed qTip Id + api = $.fn.qtip.interfaces[ event.data.qtip ]; + + // Unbind show event and cache mouse coords + api.options.show.when.target.unbind(api.options.show.when.event+'.qtip-'+event.data.qtip+'-create'); + api.cache.mouse = { x: event.pageX, y: event.pageY }; + + // Render tooltip and start the event sequence + construct.call( api ); + api.options.show.when.target.trigger(api.options.show.when.event); + }); + } + + // Prerendering is enabled, create tooltip now + else + { + // Set mouse position cache to top left of the element + obj.cache.mouse = { + x: config.show.when.target.offset().left, + y: config.show.when.target.offset().top + }; + + // Construct the tooltip + construct.call(obj); + } + }; + }); + }; + + // Instantiator + function qTip(target, options, id) + { + // Declare this reference + var self = this; + + // Setup class attributes + self.id = id; + self.options = options; + self.status = { + animated: false, + rendered: false, + disabled: false, + focused: false + }; + self.elements = { + target: target.addClass(self.options.style.classes.target), + tooltip: null, + wrapper: null, + content: null, + contentWrapper: null, + title: null, + button: null, + tip: null, + bgiframe: null + }; + self.cache = { + mouse: {}, + position: {}, + toggle: 0 + }; + self.timers = {}; + + // Define exposed API methods + $.extend(self, self.options.api, + { + show: function(event) + { + var returned, solo; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'show'); + + // Only continue if element is visible + if(self.elements.tooltip.css('display') !== 'none') return self; + + // Clear animation queue + self.elements.tooltip.stop(true, false); + + // Call API method and if return value is false, halt + returned = self.beforeShow.call(self, event); + if(returned === false) return self; + + // Define afterShow callback method + function afterShow() + { + // Call API method and focus if it isn't static + if(self.options.position.type !== 'static') self.focus(); + self.onShow.call(self, event); + + // Prevent antialias from disappearing in IE7 by removing filter attribute + if($.browser.msie) self.elements.tooltip.get(0).style.removeAttribute('filter'); + }; + + // Maintain toggle functionality if enabled + self.cache.toggle = 1; + + // Update tooltip position if it isn't static + if(self.options.position.type !== 'static') + self.updatePosition(event, (self.options.show.effect.length > 0)); + + // Hide other tooltips if tooltip is solo + if(typeof self.options.show.solo == 'object') solo = $(self.options.show.solo); + else if(self.options.show.solo === true) solo = $('div.qtip').not(self.elements.tooltip); + if(solo) solo.each(function(){ if($(this).qtip('api').status.rendered === true) $(this).qtip('api').hide(); }); + + // Show tooltip + if(typeof self.options.show.effect.type == 'function') + { + self.options.show.effect.type.call(self.elements.tooltip, self.options.show.effect.length); + self.elements.tooltip.queue(function(){ afterShow(); $(this).dequeue(); }); + } + else + { + switch(self.options.show.effect.type.toLowerCase()) + { + case 'fade': + self.elements.tooltip.fadeIn(self.options.show.effect.length, afterShow); + break; + case 'slide': + self.elements.tooltip.slideDown(self.options.show.effect.length, function() + { + afterShow(); + if(self.options.position.type !== 'static') self.updatePosition(event, true); + }); + break; + case 'grow': + self.elements.tooltip.show(self.options.show.effect.length, afterShow); + break; + default: + self.elements.tooltip.show(null, afterShow); + break; + }; + + // Add active class to tooltip + self.elements.tooltip.addClass(self.options.style.classes.active); + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_SHOWN, 'show'); + }, + + hide: function(event) + { + var returned; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'hide'); + + // Only continue if element is visible + else if(self.elements.tooltip.css('display') === 'none') return self; + + // Stop show timer and animation queue + clearTimeout(self.timers.show); + self.elements.tooltip.stop(true, false); + + // Call API method and if return value is false, halt + returned = self.beforeHide.call(self, event); + if(returned === false) return self; + + // Define afterHide callback method + function afterHide(){ self.onHide.call(self, event); }; + + // Maintain toggle functionality if enabled + self.cache.toggle = 0; + + // Hide tooltip + if(typeof self.options.hide.effect.type == 'function') + { + self.options.hide.effect.type.call(self.elements.tooltip, self.options.hide.effect.length); + self.elements.tooltip.queue(function(){ afterHide(); $(this).dequeue(); }); + } + else + { + switch(self.options.hide.effect.type.toLowerCase()) + { + case 'fade': + self.elements.tooltip.fadeOut(self.options.hide.effect.length, afterHide); + break; + case 'slide': + self.elements.tooltip.slideUp(self.options.hide.effect.length, afterHide); + break; + case 'grow': + self.elements.tooltip.hide(self.options.hide.effect.length, afterHide); + break; + default: + self.elements.tooltip.hide(null, afterHide); + break; + }; + + // Remove active class to tooltip + self.elements.tooltip.removeClass(self.options.style.classes.active); + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_HIDDEN, 'hide'); + }, + + updatePosition: function(event, animate) + { + var i, target, tooltip, coords, mapName, imagePos, newPosition, ieAdjust, ie6Adjust, borderAdjust, mouseAdjust, offset, curPosition, returned + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updatePosition'); + + // If tooltip is static, return + else if(self.options.position.type == 'static') + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.CANNOT_POSITION_STATIC, 'updatePosition'); + + // Define property objects + target = { + position: { left: 0, top: 0 }, + dimensions: { height: 0, width: 0 }, + corner: self.options.position.corner.target + }; + tooltip = { + position: self.getPosition(), + dimensions: self.getDimensions(), + corner: self.options.position.corner.tooltip + }; + + // Target is an HTML element + if(self.options.position.target !== 'mouse') + { + // If the HTML element is AREA, calculate position manually + if(self.options.position.target.get(0).nodeName.toLowerCase() == 'area') + { + // Retrieve coordinates from coords attribute and parse into integers + coords = self.options.position.target.attr('coords').split(','); + for(i = 0; i < coords.length; i++) coords[i] = parseInt(coords[i]); + + // Setup target position object + mapName = self.options.position.target.parent('map').attr('name'); + imagePos = $('img[usemap="#'+mapName+'"]:first').offset(); + target.position = { + left: Math.floor(imagePos.left + coords[0]), + top: Math.floor(imagePos.top + coords[1]) + }; + + // Determine width and height of the area + switch(self.options.position.target.attr('shape').toLowerCase()) + { + case 'rect': + target.dimensions = { + width: Math.ceil(Math.abs(coords[2] - coords[0])), + height: Math.ceil(Math.abs(coords[3] - coords[1])) + }; + break; + + case 'circle': + target.dimensions = { + width: coords[2] + 1, + height: coords[2] + 1 + }; + break; + + case 'poly': + target.dimensions = { + width: coords[0], + height: coords[1] + }; + + for(i = 0; i < coords.length; i++) + { + if(i % 2 == 0) + { + if(coords[i] > target.dimensions.width) + target.dimensions.width = coords[i]; + if(coords[i] < coords[0]) + target.position.left = Math.floor(imagePos.left + coords[i]); + } + else + { + if(coords[i] > target.dimensions.height) + target.dimensions.height = coords[i]; + if(coords[i] < coords[1]) + target.position.top = Math.floor(imagePos.top + coords[i]); + }; + }; + + target.dimensions.width = target.dimensions.width - (target.position.left - imagePos.left); + target.dimensions.height = target.dimensions.height - (target.position.top - imagePos.top); + break; + + default: + return $.fn.qtip.log.error.call(self, 4, $.fn.qtip.constants.INVALID_AREA_SHAPE, 'updatePosition'); + break; + }; + + // Adjust position by 2 pixels (Positioning bug?) + target.dimensions.width -= 2; target.dimensions.height -= 2; + } + + // Target is the document + else if(self.options.position.target.add(document.body).length === 1) + { + target.position = { left: $(document).scrollLeft(), top: $(document).scrollTop() }; + target.dimensions = { height: $(window).height(), width: $(window).width() }; + } + + // Target is a regular HTML element, find position normally + else + { + // Check if the target is another tooltip. If its animated, retrieve position from newPosition data + if(typeof self.options.position.target.attr('qtip') !== 'undefined') + target.position = self.options.position.target.qtip('api').cache.position; + else + target.position = self.options.position.target.offset(); + + // Setup dimensions objects + target.dimensions = { + height: self.options.position.target.outerHeight(), + width: self.options.position.target.outerWidth() + }; + }; + + // Calculate correct target corner position + newPosition = $.extend({}, target.position); + if(target.corner.search(/right/i) !== -1) + newPosition.left += target.dimensions.width; + + if(target.corner.search(/bottom/i) !== -1) + newPosition.top += target.dimensions.height; + + if(target.corner.search(/((top|bottom)Middle)|center/) !== -1) + newPosition.left += (target.dimensions.width / 2); + + if(target.corner.search(/((left|right)Middle)|center/) !== -1) + newPosition.top += (target.dimensions.height / 2); + } + + // Mouse is the target, set position to current mouse coordinates + else + { + // Setup target position and dimensions objects + target.position = newPosition = { left: self.cache.mouse.x, top: self.cache.mouse.y }; + target.dimensions = { height: 1, width: 1 }; + }; + + // Calculate correct target corner position + if(tooltip.corner.search(/right/i) !== -1) + newPosition.left -= tooltip.dimensions.width; + + if(tooltip.corner.search(/bottom/i) !== -1) + newPosition.top -= tooltip.dimensions.height; + + if(tooltip.corner.search(/((top|bottom)Middle)|center/) !== -1) + newPosition.left -= (tooltip.dimensions.width / 2); + + if(tooltip.corner.search(/((left|right)Middle)|center/) !== -1) + newPosition.top -= (tooltip.dimensions.height / 2); + + // Setup IE adjustment variables (Pixel gap bugs) + ieAdjust = ($.browser.msie) ? 1 : 0; // And this is why I hate IE... + ie6Adjust = ($.browser.msie && parseInt($.browser.version.charAt(0)) === 6) ? 1 : 0; // ...and even more so IE6! + + // Adjust for border radius + if(self.options.style.border.radius > 0) + { + if(tooltip.corner.search(/Left/) !== -1) + newPosition.left -= self.options.style.border.radius; + else if(tooltip.corner.search(/Right/) !== -1) + newPosition.left += self.options.style.border.radius; + + if(tooltip.corner.search(/Top/) !== -1) + newPosition.top -= self.options.style.border.radius; + else if(tooltip.corner.search(/Bottom/) !== -1) + newPosition.top += self.options.style.border.radius; + }; + + // IE only adjustments (Pixel perfect!) + if(ieAdjust) + { + if(tooltip.corner.search(/top/) !== -1) + newPosition.top -= ieAdjust + else if(tooltip.corner.search(/bottom/) !== -1) + newPosition.top += ieAdjust + + if(tooltip.corner.search(/left/) !== -1) + newPosition.left -= ieAdjust + else if(tooltip.corner.search(/right/) !== -1) + newPosition.left += ieAdjust + + if(tooltip.corner.search(/leftMiddle|rightMiddle/) !== -1) + newPosition.top -= 1 + }; + + // If screen adjustment is enabled, apply adjustments + if(self.options.position.adjust.screen === true) + newPosition = screenAdjust.call(self, newPosition, target, tooltip); + + // If mouse is the target, prevent tooltip appearing directly under the mouse + if(self.options.position.target === 'mouse' && self.options.position.adjust.mouse === true) + { + if(self.options.position.adjust.screen === true && self.elements.tip) + mouseAdjust = self.elements.tip.attr('rel'); + else + mouseAdjust = self.options.position.corner.tooltip; + + newPosition.left += (mouseAdjust.search(/right/i) !== -1) ? -6 : 6; + newPosition.top += (mouseAdjust.search(/bottom/i) !== -1) ? -6 : 6; + } + + // Initiate bgiframe plugin in IE6 if tooltip overlaps a select box or object element + if(!self.elements.bgiframe && $.browser.msie && parseInt($.browser.version.charAt(0)) == 6) + { + $('select, object').each(function() + { + offset = $(this).offset(); + offset.bottom = offset.top + $(this).height(); + offset.right = offset.left + $(this).width(); + + if(newPosition.top + tooltip.dimensions.height >= offset.top + && newPosition.left + tooltip.dimensions.width >= offset.left) + bgiframe.call(self); + }); + }; + + // Add user xy adjustments + newPosition.left += self.options.position.adjust.x; + newPosition.top += self.options.position.adjust.y; + + // Set new tooltip position if its moved, animate if enabled + curPosition = self.getPosition(); + if(newPosition.left != curPosition.left || newPosition.top != curPosition.top) + { + // Call API method and if return value is false, halt + returned = self.beforePositionUpdate.call(self, event); + if(returned === false) return self; + + // Cache new position + self.cache.position = newPosition; + + // Check if animation is enabled + if(animate === true) + { + // Set animated status + self.status.animated = true; + + // Animate and reset animated status on animation end + self.elements.tooltip.animate(newPosition, 200, 'swing', function(){ self.status.animated = false }); + } + + // Set new position via CSS + else self.elements.tooltip.css(newPosition); + + // Call API method and log event if its not a mouse move + self.onPositionUpdate.call(self, event); + if(typeof event !== 'undefined' && event.type && event.type !== 'mousemove') + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_POSITION_UPDATED, 'updatePosition'); + }; + + return self; + }, + + updateWidth: function(newWidth) + { + var hidden; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateWidth'); + + // Make sure supplied width is a number and if not, return + else if(newWidth && typeof newWidth !== 'number') + return $.fn.qtip.log.error.call(self, 2, 'newWidth must be of type number', 'updateWidth'); + + // Setup elements which must be hidden during width update + hidden = self.elements.contentWrapper.siblings().add(self.elements.tip).add(self.elements.button); + + // Calculate the new width if one is not supplied + if(!newWidth) + { + // Explicit width is set + if(typeof self.options.style.width.value == 'number') + newWidth = self.options.style.width.value; + + // No width is set, proceed with auto detection + else + { + // Set width to auto initally to determine new width and hide other elements + self.elements.tooltip.css({ width: 'auto' }); + hidden.hide(); + + // Set position and zoom to defaults to prevent IE hasLayout bug + if($.browser.msie) + self.elements.wrapper.add(self.elements.contentWrapper.children()).css({ zoom: 'normal' }); + + // Set the new width + newWidth = self.getDimensions().width + 1; + + // Make sure its within the maximum and minimum width boundries + if(!self.options.style.width.value) + { + if(newWidth > self.options.style.width.max) newWidth = self.options.style.width.max + if(newWidth < self.options.style.width.min) newWidth = self.options.style.width.min + }; + }; + }; + + // Adjust newWidth by 1px if width is odd (IE6 rounding bug fix) + if(newWidth % 2 !== 0) newWidth -= 1; + + // Set the new calculated width and unhide other elements + self.elements.tooltip.width(newWidth); + hidden.show(); + + // Set the border width, if enabled + if(self.options.style.border.radius) + { + self.elements.tooltip.find('.qtip-betweenCorners').each(function(i) + { + $(this).width(newWidth - (self.options.style.border.radius * 2)); + }) + }; + + // IE only adjustments + if($.browser.msie) + { + // Reset position and zoom to give the wrapper layout (IE hasLayout bug) + self.elements.wrapper.add(self.elements.contentWrapper.children()).css({ zoom: '1' }); + + // Set the new width + self.elements.wrapper.width(newWidth); + + // Adjust BGIframe height and width if enabled + if(self.elements.bgiframe) self.elements.bgiframe.width(newWidth).height(self.getDimensions.height); + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_WIDTH_UPDATED, 'updateWidth'); + }, + + updateStyle: function(name) + { + var tip, borders, context, corner, coordinates; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateStyle'); + + // Return if style is not defined or name is not a string + else if(typeof name !== 'string' || !$.fn.qtip.styles[name]) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.STYLE_NOT_DEFINED, 'updateStyle'); + + // Set the new style object + self.options.style = buildStyle.call(self, $.fn.qtip.styles[name], self.options.user.style); + + // Update initial styles of content and title elements + self.elements.content.css( jQueryStyle(self.options.style) ); + if(self.options.content.title.text !== false) + self.elements.title.css( jQueryStyle(self.options.style.title, true) ); + + // Update CSS border colour + self.elements.contentWrapper.css({ borderColor: self.options.style.border.color }); + + // Update tip color if enabled + if(self.options.style.tip.corner !== false) + { + if($('').get(0).getContext) + { + // Retrieve canvas context and clear + tip = self.elements.tooltip.find('.qtip-tip canvas:first'); + context = tip.get(0).getContext('2d'); + context.clearRect(0,0,300,300); + + // Draw new tip + corner = tip.parent('div[rel]:first').attr('rel'); + coordinates = calculateTip(corner, self.options.style.tip.size.width, self.options.style.tip.size.height); + drawTip.call(self, tip, coordinates, self.options.style.tip.color || self.options.style.border.color); + } + else if($.browser.msie) + { + // Set new fillcolor attribute + tip = self.elements.tooltip.find('.qtip-tip [nodeName="shape"]'); + tip.attr('fillcolor', self.options.style.tip.color || self.options.style.border.color); + }; + }; + + // Update border colors if enabled + if(self.options.style.border.radius > 0) + { + self.elements.tooltip.find('.qtip-betweenCorners').css({ backgroundColor: self.options.style.border.color }); + + if($('').get(0).getContext) + { + borders = calculateBorders(self.options.style.border.radius) + self.elements.tooltip.find('.qtip-wrapper canvas').each(function() + { + // Retrieve canvas context and clear + context = $(this).get(0).getContext('2d'); + context.clearRect(0,0,300,300); + + // Draw new border + corner = $(this).parent('div[rel]:first').attr('rel') + drawBorder.call(self, $(this), borders[corner], + self.options.style.border.radius, self.options.style.border.color); + }); + } + else if($.browser.msie) + { + // Set new fillcolor attribute on each border corner + self.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function() + { + $(this).attr('fillcolor', self.options.style.border.color) + }); + }; + }; + + // Log event and return + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_STYLE_UPDATED, 'updateStyle'); + }, + + updateContent: function(content, reposition) + { + var parsedContent, images, loadedImages; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateContent'); + + // Make sure content is defined before update + else if(!content) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.NO_CONTENT_PROVIDED, 'updateContent'); + + // Call API method and set new content if a string is returned + parsedContent = self.beforeContentUpdate.call(self, content); + if(typeof parsedContent == 'string') content = parsedContent; + else if(parsedContent === false) return; + + // Set position and zoom to defaults to prevent IE hasLayout bug + if($.browser.msie) self.elements.contentWrapper.children().css({ zoom: 'normal' }); + + // Append new content if its a DOM array and show it if hidden + if(content.jquery && content.length > 0) + content.clone(true).appendTo(self.elements.content).show(); + + // Content is a regular string, insert the new content + else self.elements.content.html(content); + + // Check if images need to be loaded before position is updated to prevent mis-positioning + images = self.elements.content.find('img[complete=false]'); + if(images.length > 0) + { + loadedImages = 0; + images.each(function(i) + { + $('') + .load(function(){ if(++loadedImages == images.length) afterLoad(); }); + }); + } + else afterLoad(); + + function afterLoad() + { + // Update the tooltip width + self.updateWidth(); + + // If repositioning is enabled, update positions + if(reposition !== false) + { + // Update position if tooltip isn't static + if(self.options.position.type !== 'static') + self.updatePosition(self.elements.tooltip.is(':visible'), true); + + // Reposition the tip if enabled + if(self.options.style.tip.corner !== false) + positionTip.call(self); + }; + }; + + // Call API method and log event + self.onContentUpdate.call(self); + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_CONTENT_UPDATED, 'loadContent'); + }, + + loadContent: function(url, data, method) + { + var returned; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'loadContent'); + + // Call API method and if return value is false, halt + returned = self.beforeContentLoad.call(self); + if(returned === false) return self; + + // Load content using specified request type + if(method == 'post') + $.post(url, data, setupContent); + else + $.get(url, data, setupContent); + + function setupContent(content) + { + // Call API method and log event + self.onContentLoad.call(self); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_CONTENT_LOADED, 'loadContent'); + + // Update the content + self.updateContent(content); + }; + + return self; + }, + + updateTitle: function(content) + { + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateTitle'); + + // Make sure content is defined before update + else if(!content) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.NO_CONTENT_PROVIDED, 'updateTitle'); + + // Call API method and if return value is false, halt + returned = self.beforeTitleUpdate.call(self); + if(returned === false) return self; + + // Set the new content and reappend the button if enabled + if(self.elements.button) self.elements.button = self.elements.button.clone(true); + self.elements.title.html(content) + if(self.elements.button) self.elements.title.prepend(self.elements.button); + + // Call API method and log event + self.onTitleUpdate.call(self); + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_TITLE_UPDATED, 'updateTitle'); + }, + + focus: function(event) + { + var curIndex, newIndex, elemIndex, returned; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'focus'); + + else if(self.options.position.type == 'static') + return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.CANNOT_FOCUS_STATIC, 'focus'); + + // Set z-index variables + curIndex = parseInt( self.elements.tooltip.css('z-index') ); + newIndex = 6000 + $('div.qtip[qtip]').length - 1; + + // Only update the z-index if it has changed and tooltip is not already focused + if(!self.status.focused && curIndex !== newIndex) + { + // Call API method and if return value is false, halt + returned = self.beforeFocus.call(self, event); + if(returned === false) return self; + + // Loop through all other tooltips + $('div.qtip[qtip]').not(self.elements.tooltip).each(function() + { + if($(this).qtip('api').status.rendered === true) + { + elemIndex = parseInt($(this).css('z-index')); + + // Reduce all other tooltip z-index by 1 + if(typeof elemIndex == 'number' && elemIndex > -1) + $(this).css({ zIndex: parseInt( $(this).css('z-index') ) - 1 }); + + // Set focused status to false + $(this).qtip('api').status.focused = false; + } + }) + + // Set the new z-index and set focus status to true + self.elements.tooltip.css({ zIndex: newIndex }); + self.status.focused = true; + + // Call API method and log event + self.onFocus.call(self, event); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_FOCUSED, 'focus'); + }; + + return self; + }, + + disable: function(state) + { + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'disable'); + + if(state) + { + // Tooltip is not already disabled, proceed + if(!self.status.disabled) + { + // Set the disabled flag and log event + self.status.disabled = true; + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_DISABLED, 'disable'); + } + + // Tooltip is already disabled, inform user via log + else $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED, 'disable'); + } + else + { + // Tooltip is not already enabled, proceed + if(self.status.disabled) + { + // Reassign events, set disable status and log + self.status.disabled = false; + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_ENABLED, 'disable'); + } + + // Tooltip is already enabled, inform the user via log + else $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED, 'disable'); + }; + + return self; + }, + + destroy: function() + { + var i, returned, interfaces; + + // Call API method and if return value is false, halt + returned = self.beforeDestroy.call(self); + if(returned === false) return self; + + // Check if tooltip is rendered + if(self.status.rendered) + { + // Remove event handlers and remove element + self.options.show.when.target.unbind('mousemove.qtip', self.updatePosition); + self.options.show.when.target.unbind('mouseout.qtip', self.hide); + self.options.show.when.target.unbind(self.options.show.when.event + '.qtip'); + self.options.hide.when.target.unbind(self.options.hide.when.event + '.qtip'); + self.elements.tooltip.unbind(self.options.hide.when.event + '.qtip'); + self.elements.tooltip.unbind('mouseover.qtip', self.focus); + self.elements.tooltip.remove(); + } + + // Tooltip isn't yet rendered, remove render event + else self.options.show.when.target.unbind(self.options.show.when.event+'.qtip-create'); + + // Check to make sure qTip data is present on target element + if(typeof self.elements.target.data('qtip') == 'object') + { + // Remove API references from interfaces object + interfaces = self.elements.target.data('qtip').interfaces; + if(typeof interfaces == 'object' && interfaces.length > 0) + { + // Remove API from interfaces array + for(i = 0; i < interfaces.length - 1; i++) + if(interfaces[i].id == self.id) interfaces.splice(i, 1) + } + } + delete $.fn.qtip.interfaces[self.id]; + + // Set qTip current id to previous tooltips API if available + if(typeof interfaces == 'object' && interfaces.length > 0) + self.elements.target.data('qtip').current = interfaces.length -1; + else + self.elements.target.removeData('qtip'); + + // Call API method and log destroy + self.onDestroy.call(self); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_DESTROYED, 'destroy'); + + return self.elements.target + }, + + getPosition: function() + { + var show, offset; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'getPosition'); + + show = (self.elements.tooltip.css('display') !== 'none') ? false : true; + + // Show and hide tooltip to make sure coordinates are returned + if(show) self.elements.tooltip.css({ visiblity: 'hidden' }).show(); + offset = self.elements.tooltip.offset(); + if(show) self.elements.tooltip.css({ visiblity: 'visible' }).hide(); + + return offset; + }, + + getDimensions: function() + { + var show, dimensions; + + // Make sure tooltip is rendered and if not, return + if(!self.status.rendered) + return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'getDimensions'); + + show = (!self.elements.tooltip.is(':visible')) ? true : false; + + // Show and hide tooltip to make sure dimensions are returned + if(show) self.elements.tooltip.css({ visiblity: 'hidden' }).show(); + dimensions = { + height: self.elements.tooltip.outerHeight(), + width: self.elements.tooltip.outerWidth() + }; + if(show) self.elements.tooltip.css({ visiblity: 'visible' }).hide(); + + return dimensions; + } + }); + }; + + // Define priamry construct function + function construct() + { + var self, adjust, content, url, data, method, tempLength; + self = this; + + // Call API method + self.beforeRender.call(self); + + // Set rendered status to true + self.status.rendered = true; + + // Create initial tooltip elements + self.elements.tooltip = '' + + ' ' + + ' ' + + ' ' + + ''; + + // Append to container element + self.elements.tooltip = $(self.elements.tooltip); + self.elements.tooltip.appendTo(self.options.position.container) + + // Setup tooltip qTip data + self.elements.tooltip.data('qtip', { current: 0, interfaces: [self] }); + + // Setup element references + self.elements.wrapper = self.elements.tooltip.children('div:first'); + self.elements.contentWrapper = self.elements.wrapper.children('div:first').css({ background: self.options.style.background }); + self.elements.content = self.elements.contentWrapper.children('div:first').css( jQueryStyle(self.options.style) ); + + // Apply IE hasLayout fix to wrapper and content elements + if($.browser.msie) self.elements.wrapper.add(self.elements.content).css({ zoom: 1 }); + + // Setup tooltip attributes + if(self.options.hide.when.event == 'unfocus') self.elements.tooltip.attr('unfocus', true); + + // If an explicit width is set, updateWidth prior to setting content to prevent dirty rendering + if(typeof self.options.style.width.value == 'number') self.updateWidth(); + + // Create borders and tips if supported by the browser + if($('').get(0).getContext || $.browser.msie) + { + // Create border + if(self.options.style.border.radius > 0) + createBorder.call(self); + else + self.elements.contentWrapper.css({ border: self.options.style.border.width+'px solid '+self.options.style.border.color }); + + // Create tip if enabled + if(self.options.style.tip.corner !== false) + createTip.call(self); + } + + // Neither canvas or VML is supported, tips and borders cannot be drawn! + else + { + // Set defined border width + self.elements.contentWrapper.css({ border: self.options.style.border.width+'px solid '+self.options.style.border.color }); + + // Reset border radius and tip + self.options.style.border.radius = 0; + self.options.style.tip.corner = false; + + // Inform via log + $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED, 'render'); + }; + + // Use the provided content string or DOM array + if((typeof self.options.content.text == 'string' && self.options.content.text.length > 0) + || (self.options.content.text.jquery && self.options.content.text.length > 0)) + content = self.options.content.text; + + // Use title string for content if present + else if(typeof self.elements.target.attr('title') == 'string' && self.elements.target.attr('title').length > 0) + { + content = self.elements.target.attr('title').replace("\\n", ''); + self.elements.target.attr('title', ''); // Remove title attribute to prevent default tooltip showing + } + + // No title is present, use alt attribute instead + else if(typeof self.elements.target.attr('alt') == 'string' && self.elements.target.attr('alt').length > 0) + { + content = self.elements.target.attr('alt').replace("\\n", ''); + self.elements.target.attr('alt', ''); // Remove alt attribute to prevent default tooltip showing + } + + // No valid content was provided, inform via log + else + { + content = ' '; + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.NO_VALID_CONTENT, 'render'); + }; + + // Set the tooltips content and create title if enabled + if(self.options.content.title.text !== false) createTitle.call(self); + self.updateContent(content); + + // Assign events and toggle tooltip with focus + assignEvents.call(self); + if(self.options.show.ready === true) self.show(); + + // Retrieve ajax content if provided + if(self.options.content.url !== false) + { + url = self.options.content.url; + data = self.options.content.data; + method = self.options.content.method || 'get'; + self.loadContent(url, data, method); + }; + + // Call API method and log event + self.onRender.call(self); + $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_RENDERED, 'render'); + }; + + // Create borders using canvas and VML + function createBorder() + { + var self, i, width, radius, color, coordinates, containers, size, betweenWidth, betweenCorners, borderTop, borderBottom, borderCoord, sideWidth, vertWidth; + self = this; + + // Destroy previous border elements, if present + self.elements.wrapper.find('.qtip-borderBottom, .qtip-borderTop').remove(); + + // Setup local variables + width = self.options.style.border.width; + radius = self.options.style.border.radius; + color = self.options.style.border.color || self.options.style.tip.color; + + // Calculate border coordinates + coordinates = calculateBorders(radius); + + // Create containers for the border shapes + containers = {}; + for(i in coordinates) + { + // Create shape container + containers[i] = ''; + + // Canvas is supported + if($('').get(0).getContext) + containers[i] += ''; + + // No canvas, but if it's IE use VML + else if($.browser.msie) + { + size = radius * 2 + 3; + containers[i] += ''; + + }; + + containers[i] += ''; + }; + + // Create between corners elements + betweenWidth = self.getDimensions().width - (Math.max(width, radius) * 2); + betweenCorners = ''; + + // Create top border container + borderTop = '' + + containers['topLeft'] + containers['topRight'] + betweenCorners; + self.elements.wrapper.prepend(borderTop); + + // Create bottom border container + borderBottom = '' + + containers['bottomLeft'] + containers['bottomRight'] + betweenCorners; + self.elements.wrapper.append(borderBottom); + + // Draw the borders if canvas were used (Delayed til after DOM creation) + if($('').get(0).getContext) + { + self.elements.wrapper.find('canvas').each(function() + { + borderCoord = coordinates[ $(this).parent('[rel]:first').attr('rel') ]; + drawBorder.call(self, $(this), borderCoord, radius, color); + }) + } + + // Create a phantom VML element (IE won't show the last created VML element otherwise) + else if($.browser.msie) self.elements.tooltip.append(''); + + // Setup contentWrapper border + sideWidth = Math.max(radius, (radius + (width - radius)) ) + vertWidth = Math.max(width - radius, 0); + self.elements.contentWrapper.css({ + border: '0px solid ' + color, + borderWidth: vertWidth + 'px ' + sideWidth + 'px' + }) + }; + + // Border canvas draw method + function drawBorder(canvas, coordinates, radius, color) + { + // Create corner + var context = canvas.get(0).getContext('2d'); + context.fillStyle = color; + context.beginPath(); + context.arc(coordinates[0], coordinates[1], radius, 0, Math.PI * 2, false); + context.fill(); + }; + + // Create tip using canvas and VML + function createTip(corner) + { + var self, color, coordinates, coordsize, path; + self = this; + + // Destroy previous tip, if there is one + if(self.elements.tip !== null) self.elements.tip.remove(); + + // Setup color and corner values + color = self.options.style.tip.color || self.options.style.border.color; + if(self.options.style.tip.corner === false) return; + else if(!corner) corner = self.options.style.tip.corner; + + // Calculate tip coordinates + coordinates = calculateTip(corner, self.options.style.tip.size.width, self.options.style.tip.size.height); + + // Create tip element + self.elements.tip = ''; + + // Use canvas element if supported + if($('').get(0).getContext) + self.elements.tip += ''; + + // Canvas not supported - Use VML (IE) + else if($.browser.msie) + { + // Create coordize and tip path using tip coordinates + coordsize = self.options.style.tip.size.width + ',' + self.options.style.tip.size.height; + path = 'm' + coordinates[0][0] + ',' + coordinates[0][1]; + path += ' l' + coordinates[1][0] + ',' + coordinates[1][1]; + path += ' ' + coordinates[2][0] + ',' + coordinates[2][1]; + path += ' xe'; + + // Create VML element + self.elements.tip += ''; + + // Create a phantom VML element (IE won't show the last created VML element otherwise) + self.elements.tip += ''; + + // Prevent tooltip appearing above the content (IE z-index bug) + self.elements.contentWrapper.css('position', 'relative'); + }; + + // Attach new tip to tooltip element + self.elements.tooltip.prepend(self.elements.tip + ''); + + // Create element reference and draw the canvas tip (Delayed til after DOM creation) + self.elements.tip = self.elements.tooltip.find('.'+self.options.style.classes.tip).eq(0); + if($('').get(0).getContext) + drawTip.call(self, self.elements.tip.find('canvas:first'), coordinates, color); + + // Fix IE small tip bug + if(corner.search(/top/) !== -1 && $.browser.msie && parseInt($.browser.version.charAt(0)) === 6) + self.elements.tip.css({ marginTop: -4 }); + + // Set the tip position + positionTip.call(self, corner); + }; + + // Canvas tip drawing method + function drawTip(canvas, coordinates, color) + { + // Setup properties + var context = canvas.get(0).getContext('2d'); + context.fillStyle = color; + + // Create tip + context.beginPath(); + context.moveTo(coordinates[0][0], coordinates[0][1]); + context.lineTo(coordinates[1][0], coordinates[1][1]); + context.lineTo(coordinates[2][0], coordinates[2][1]); + context.fill(); + }; + + function positionTip(corner) + { + var self, ieAdjust, paddingCorner, paddingSize, newMargin; + self = this; + + // Return if tips are disabled or tip is not yet rendered + if(self.options.style.tip.corner === false || !self.elements.tip) return; + if(!corner) corner = self.elements.tip.attr('rel'); + + // Setup adjustment variables + ieAdjust = positionAdjust = ($.browser.msie) ? 1 : 0; + + // Set initial position + self.elements.tip.css(corner.match(/left|right|top|bottom/)[0], 0); + + // Set position of tip to correct side + if(corner.search(/top|bottom/) !== -1) + { + // Adjustments for IE6 - 0.5px border gap bug + if($.browser.msie) + { + if(parseInt($.browser.version.charAt(0)) === 6) + positionAdjust = (corner.search(/top/) !== -1) ? -3 : 1; + else + positionAdjust = (corner.search(/top/) !== -1) ? 1 : 2; + }; + + if(corner.search(/Middle/) !== -1) + self.elements.tip.css({ left: '50%', marginLeft: -(self.options.style.tip.size.width / 2) }); + + else if(corner.search(/Left/) !== -1) + self.elements.tip.css({ left: self.options.style.border.radius - ieAdjust }); + + else if(corner.search(/Right/) !== -1) + self.elements.tip.css({ right: self.options.style.border.radius + ieAdjust }); + + if(corner.search(/top/) !== -1) + self.elements.tip.css({ top: -positionAdjust }); + else + self.elements.tip.css({ bottom: positionAdjust }); + + } + else if(corner.search(/left|right/) !== -1) + { + // Adjustments for IE6 - 0.5px border gap bug + if($.browser.msie) + positionAdjust = (parseInt($.browser.version.charAt(0)) === 6) ? 1 : ((corner.search(/left/) !== -1) ? 1 : 2); + + if(corner.search(/Middle/) !== -1) + self.elements.tip.css({ top: '50%', marginTop: -(self.options.style.tip.size.height / 2) }); + + else if(corner.search(/Top/) !== -1) + self.elements.tip.css({ top: self.options.style.border.radius - ieAdjust }); + + else if(corner.search(/Bottom/) !== -1) + self.elements.tip.css({ bottom: self.options.style.border.radius + ieAdjust }); + + if(corner.search(/left/) !== -1) + self.elements.tip.css({ left: -positionAdjust }); + else + self.elements.tip.css({ right: positionAdjust }); + }; + + // Adjust tooltip padding to compensate for tip + paddingCorner = 'padding-' + corner.match(/left|right|top|bottom/)[0]; + paddingSize = self.options.style.tip.size[ (paddingCorner.search(/left|right/) !== -1) ? 'width' : 'height' ]; + self.elements.tooltip.css('padding', 0); + self.elements.tooltip.css(paddingCorner, paddingSize); + + // Match content margin to prevent gap bug in IE6 ONLY + if($.browser.msie && parseInt($.browser.version.charAt(0)) == 6) + { + newMargin = parseInt(self.elements.tip.css('margin-top')) || 0; + newMargin += parseInt(self.elements.content.css('margin-top')) || 0; + + self.elements.tip.css({ marginTop: newMargin }); + }; + }; + + // Create title bar for content + function createTitle() + { + var self = this; + + // Destroy previous title element, if present + if(self.elements.title !== null) self.elements.title.remove(); + + // Create title element + self.elements.title = $('') + .css( jQueryStyle(self.options.style.title, true) ) + .css({ zoom: ($.browser.msie) ? 1 : 0 }) + .prependTo(self.elements.contentWrapper); + + // Update title with contents if enabled + if(self.options.content.title.text) self.updateTitle.call(self, self.options.content.title.text); + + // Create title close buttons if enabled + if(self.options.content.title.button !== false + && typeof self.options.content.title.button == 'string') + { + self.elements.button = $('') + .css( jQueryStyle(self.options.style.button, true) ) + .html(self.options.content.title.button) + .prependTo(self.elements.title) + .click(function(event){ if(!self.status.disabled) self.hide(event) }); + }; + }; + + // Assign hide and show events + function assignEvents() + { + var self, showTarget, hideTarget, inactiveEvents; + self = this; + + // Setup event target variables + showTarget = self.options.show.when.target; + hideTarget = self.options.hide.when.target; + + // Add tooltip as a hideTarget is its fixed + if(self.options.hide.fixed) hideTarget = hideTarget.add(self.elements.tooltip); + + // Check if the hide event is special 'inactive' type + if(self.options.hide.when.event == 'inactive') + { + // Define events which reset the 'inactive' event handler + inactiveEvents = ['click', 'dblclick', 'mousedown', 'mouseup', 'mousemove', + 'mouseout', 'mouseenter', 'mouseleave', 'mouseover' ]; + + // Define 'inactive' event timer method + function inactiveMethod(event) + { + if(self.status.disabled === true) return; + + //Clear and reset the timer + clearTimeout(self.timers.inactive); + self.timers.inactive = setTimeout(function() + { + // Unassign 'inactive' events + $(inactiveEvents).each(function() + { + hideTarget.unbind(this+'.qtip-inactive'); + self.elements.content.unbind(this+'.qtip-inactive'); + }); + + // Hide the tooltip + self.hide(event); + } + , self.options.hide.delay); + }; + } + + // Check if the tooltip is 'fixed' + else if(self.options.hide.fixed === true) + { + self.elements.tooltip.bind('mouseover.qtip', function() + { + if(self.status.disabled === true) return; + + // Reset the hide timer + clearTimeout(self.timers.hide); + }); + }; + + // Define show event method + function showMethod(event) + { + if(self.status.disabled === true) return; + + // If set, hide tooltip when inactive for delay period + if(self.options.hide.when.event == 'inactive') + { + // Assign each reset event + $(inactiveEvents).each(function() + { + hideTarget.bind(this+'.qtip-inactive', inactiveMethod); + self.elements.content.bind(this+'.qtip-inactive', inactiveMethod); + }); + + // Start the inactive timer + inactiveMethod(); + }; + + // Clear hide timers + clearTimeout(self.timers.show); + clearTimeout(self.timers.hide); + + // Start show timer + self.timers.show = setTimeout(function(){ self.show(event); }, self.options.show.delay); + }; + + // Define hide event method + function hideMethod(event) + { + if(self.status.disabled === true) return; + + // Prevent hiding if tooltip is fixed and event target is the tooltip + if(self.options.hide.fixed === true + && self.options.hide.when.event.search(/mouse(out|leave)/i) !== -1 + && $(event.relatedTarget).parents('div.qtip[qtip]').length > 0) + { + // Prevent default and popagation + event.stopPropagation(); + event.preventDefault(); + + // Reset the hide timer + clearTimeout(self.timers.hide); + return false; + }; + + // Clear timers and stop animation queue + clearTimeout(self.timers.show); + clearTimeout(self.timers.hide); + self.elements.tooltip.stop(true, true); + + // If tooltip has displayed, start hide timer + self.timers.hide = setTimeout(function(){ self.hide(event); }, self.options.hide.delay); + }; + + // Both events and targets are identical, apply events using a toggle + if((self.options.show.when.target.add(self.options.hide.when.target).length === 1 + && self.options.show.when.event == self.options.hide.when.event + && self.options.hide.when.event !== 'inactive') + || self.options.hide.when.event == 'unfocus') + { + self.cache.toggle = 0; + // Use a toggle to prevent hide/show conflicts + showTarget.bind(self.options.show.when.event + '.qtip', function(event) + { + if(self.cache.toggle == 0) showMethod(event); + else hideMethod(event); + }); + } + + // Events are not identical, bind normally + else + { + showTarget.bind(self.options.show.when.event + '.qtip', showMethod); + + // If the hide event is not 'inactive', bind the hide method + if(self.options.hide.when.event !== 'inactive') + hideTarget.bind(self.options.hide.when.event + '.qtip', hideMethod); + }; + + // Focus the tooltip on mouseover + if(self.options.position.type.search(/(fixed|absolute)/) !== -1) + self.elements.tooltip.bind('mouseover.qtip', self.focus); + + // If mouse is the target, update tooltip position on mousemove + if(self.options.position.target === 'mouse' && self.options.position.type !== 'static') + { + showTarget.bind('mousemove.qtip', function(event) + { + // Set the new mouse positions if adjustment is enabled + self.cache.mouse = { x: event.pageX, y: event.pageY }; + + // Update the tooltip position only if the tooltip is visible and adjustment is enabled + if(self.status.disabled === false + && self.options.position.adjust.mouse === true + && self.options.position.type !== 'static' + && self.elements.tooltip.css('display') !== 'none') + self.updatePosition(event); + }); + }; + }; + + // Screen position adjustment + function screenAdjust(position, target, tooltip) + { + var self, adjustedPosition, adjust, newCorner, overflow, corner; + self = this; + + // Setup corner and adjustment variable + if(tooltip.corner == 'center') return target.position // TODO: 'center' corner adjustment + adjustedPosition = $.extend({}, position); + newCorner = { x: false, y: false }; + + // Define overflow properties + overflow = { + left: (adjustedPosition.left < $.fn.qtip.cache.screen.scroll.left), + right: (adjustedPosition.left + tooltip.dimensions.width + 2 >= $.fn.qtip.cache.screen.width + $.fn.qtip.cache.screen.scroll.left), + top: (adjustedPosition.top < $.fn.qtip.cache.screen.scroll.top), + bottom: (adjustedPosition.top + tooltip.dimensions.height + 2 >= $.fn.qtip.cache.screen.height + $.fn.qtip.cache.screen.scroll.top) + }; + + // Determine new positioning properties + adjust = { + left: (overflow.left && (tooltip.corner.search(/right/i) != -1 || (tooltip.corner.search(/right/i) == -1 && !overflow.right))), + right: (overflow.right && (tooltip.corner.search(/left/i) != -1 || (tooltip.corner.search(/left/i) == -1 && !overflow.left))), + top: (overflow.top && tooltip.corner.search(/top/i) == -1), + bottom: (overflow.bottom && tooltip.corner.search(/bottom/i) == -1) + }; + + // Tooltip overflows off the left side of the screen + if(adjust.left) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.left = target.position.left + target.dimensions.width; + else + adjustedPosition.left = self.cache.mouse.x + + newCorner.x = 'Left'; + } + + // Tooltip overflows off the right side of the screen + else if(adjust.right) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.left = target.position.left - tooltip.dimensions.width; + else + adjustedPosition.left = self.cache.mouse.x - tooltip.dimensions.width; + + newCorner.x = 'Right'; + }; + + // Tooltip overflows off the top of the screen + if(adjust.top) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.top = target.position.top + target.dimensions.height; + else + adjustedPosition.top = self.cache.mouse.y + + newCorner.y = 'top'; + } + + // Tooltip overflows off the bottom of the screen + else if(adjust.bottom) + { + if(self.options.position.target !== 'mouse') + adjustedPosition.top = target.position.top - tooltip.dimensions.height; + else + adjustedPosition.top = self.cache.mouse.y - tooltip.dimensions.height; + + newCorner.y = 'bottom'; + }; + + // Don't adjust if resulting position is negative + if(adjustedPosition.left < 0) + { + adjustedPosition.left = position.left; + newCorner.x = false; + }; + if(adjustedPosition.top < 0) + { + adjustedPosition.top = position.top; + newCorner.y = false; + }; + + // Change tip corner if positioning has changed and tips are enabled + if(self.options.style.tip.corner !== false) + { + // Determine new corner properties + adjustedPosition.corner = new String(tooltip.corner); + if(newCorner.x !== false) adjustedPosition.corner = adjustedPosition.corner.replace(/Left|Right|Middle/, newCorner.x); + if(newCorner.y !== false) adjustedPosition.corner = adjustedPosition.corner.replace(/top|bottom/, newCorner.y); + + // Adjust tip if position has changed and tips are enabled + if(adjustedPosition.corner !== self.elements.tip.attr('rel')) + createTip.call(self, adjustedPosition.corner); + }; + + return adjustedPosition; + }; + + // Build a jQuery style object from supplied style object + function jQueryStyle(style, sub) + { + var styleObj, i; + + styleObj = $.extend(true, {}, style); + for(i in styleObj) + { + if(sub === true && i.search(/(tip|classes)/i) !== -1) + delete styleObj[i]; + else if(!sub && i.search(/(width|border|tip|title|classes|user)/i) !== -1) + delete styleObj[i]; + }; + + return styleObj; + }; + + // Sanitize styles + function sanitizeStyle(style) + { + if(typeof style.tip !== 'object') style.tip = { corner: style.tip }; + if(typeof style.tip.size !== 'object') style.tip.size = { width: style.tip.size, height: style.tip.size }; + if(typeof style.border !== 'object') style.border = { width: style.border }; + if(typeof style.width !== 'object') style.width = { value: style.width }; + if(typeof style.width.max == 'string') style.width.max = parseInt(style.width.max.replace(/([0-9]+)/i, "$1")); + if(typeof style.width.min == 'string') style.width.min = parseInt(style.width.min.replace(/([0-9]+)/i, "$1")); + + // Convert deprecated x and y tip values to width/height + if(typeof style.tip.size.x == 'number') + { + style.tip.size.width = style.tip.size.x; + delete style.tip.size.x; + }; + if(typeof style.tip.size.y == 'number') + { + style.tip.size.height = style.tip.size.y; + delete style.tip.size.y; + }; + + return style; + }; + + // Build styles recursively with inheritance + function buildStyle() + { + var self, i, styleArray, styleExtend, finalStyle, ieAdjust; + self = this; + + // Build style options from supplied arguments + styleArray = [true, {}]; + for(i = 0; i < arguments.length; i++) + styleArray.push(arguments[i]); + styleExtend = [ $.extend.apply($, styleArray) ]; + + // Loop through each named style inheritance + while(typeof styleExtend[0].name == 'string') + { + // Sanitize style data and append to extend array + styleExtend.unshift( sanitizeStyle($.fn.qtip.styles[ styleExtend[0].name ]) ); + }; + + // Make sure resulting tooltip className represents final style + styleExtend.unshift(true, {classes:{ tooltip: 'qtip-' + (arguments[0].name || 'defaults') }}, $.fn.qtip.styles.defaults); + + // Extend into a single style object + finalStyle = $.extend.apply($, styleExtend); + + // Adjust tip size if needed (IE 1px adjustment bug fix) + ieAdjust = ($.browser.msie) ? 1 : 0; + finalStyle.tip.size.width += ieAdjust; + finalStyle.tip.size.height += ieAdjust; + + // Force even numbers for pixel precision + if(finalStyle.tip.size.width % 2 > 0) finalStyle.tip.size.width += 1; + if(finalStyle.tip.size.height % 2 > 0) finalStyle.tip.size.height += 1; + + // Sanitize final styles tip corner value + if(finalStyle.tip.corner === true) + finalStyle.tip.corner = (self.options.position.corner.tooltip === 'center') ? false : self.options.position.corner.tooltip; + + return finalStyle; + }; + + // Tip coordinates calculator + function calculateTip(corner, width, height) + { + // Define tip coordinates in terms of height and width values + var tips = { + bottomRight: [[0,0], [width,height], [width,0]], + bottomLeft: [[0,0], [width,0], [0,height]], + topRight: [[0,height], [width,0], [width,height]], + topLeft: [[0,0], [0,height], [width,height]], + topMiddle: [[0,height], [width / 2,0], [width,height]], + bottomMiddle: [[0,0], [width,0], [width / 2,height]], + rightMiddle: [[0,0], [width,height / 2], [0,height]], + leftMiddle: [[width,0], [width,height], [0,height / 2]] + }; + tips.leftTop = tips.bottomRight; + tips.rightTop = tips.bottomLeft; + tips.leftBottom = tips.topRight; + tips.rightBottom = tips.topLeft; + + return tips[corner]; + }; + + // Border coordinates calculator + function calculateBorders(radius) + { + var borders; + + // Use canvas element if supported + if($('').get(0).getContext) + { + borders = { + topLeft: [radius,radius], topRight: [0,radius], + bottomLeft: [radius,0], bottomRight: [0,0] + }; + } + + // Canvas not supported - Use VML (IE) + else if($.browser.msie) + { + borders = { + topLeft: [-90,90,0], topRight: [-90,90,-radius], + bottomLeft: [90,270,0], bottomRight: [90, 270,-radius] + }; + }; + + return borders; + }; + + // BGIFRAME JQUERY PLUGIN ADAPTION + // Special thanks to Brandon Aaron for this plugin + // http://plugins.jquery.com/project/bgiframe + function bgiframe() + { + var self, html, dimensions; + self = this; + dimensions = self.getDimensions(); + + // Setup iframe HTML string + html = ''; + + // Append the new HTML and setup element reference + self.elements.bgiframe = self.elements.wrapper.prepend(html).children('.qtip-bgiframe:first'); + }; + + // Assign cache and event initialisation on document load + $(document).ready(function() + { + // Setup library cache with window scroll and dimensions of document + $.fn.qtip.cache = { + screen: { + scroll: { left: $(window).scrollLeft(), top: $(window).scrollTop() }, + width: $(window).width(), + height: $(window).height() + } + }; + + // Adjust positions of the tooltips on window resize or scroll if enabled + var adjustTimer; + $(window).bind('resize scroll', function(event) + { + clearTimeout(adjustTimer); + adjustTimer = setTimeout(function() + { + // Readjust cached screen values + if(event.type === 'scroll') + $.fn.qtip.cache.screen.scroll = { left: $(window).scrollLeft(), top: $(window).scrollTop() }; + else + { + $.fn.qtip.cache.screen.width = $(window).width(); + $.fn.qtip.cache.screen.height = $(window).height(); + }; + + for(i = 0; i < $.fn.qtip.interfaces.length; i++) + { + // Access current elements API + var api = $.fn.qtip.interfaces[i]; + + // Update position if resize or scroll adjustments are enabled + if(api.status.rendered === true + && (api.options.position.type !== 'static' + || api.options.position.adjust.scroll && event.type === 'scroll' + || api.options.position.adjust.resize && event.type === 'resize')) + { + // Queue the animation so positions are updated correctly + api.updatePosition(event, true); + } + }; + } + , 100); + }) + + // Hide unfocus toolipts on document mousedown + $(document).bind('mousedown.qtip', function(event) + { + if($(event.target).parents('div.qtip').length === 0) + { + $('.qtip[unfocus]').each(function() + { + var api = $(this).qtip("api"); + + // Only hide if its visible and not the tooltips target + if($(this).is(':visible') && !api.status.disabled + && $(event.target).add(api.elements.target).length > 1) + api.hide(event); + }) + }; + }) + }); + + // Define qTip API interfaces array + $.fn.qtip.interfaces = [] + + // Define log and constant place holders + $.fn.qtip.log = { error: function(){ return this; } }; + $.fn.qtip.constants = {}; + + // Define configuration defaults + $.fn.qtip.defaults = { + // Content + content: { + prerender: false, + text: false, + url: false, + data: null, + title: { + text: false, + button: false + } + }, + // Position + position: { + target: false, + corner: { + target: 'bottomRight', + tooltip: 'topLeft' + }, + adjust: { + x: 0, y: 0, + mouse: true, + screen: false, + scroll: true, + resize: true + }, + type: 'absolute', + container: false + }, + // Effects + show: { + when: { + target: false, + event: 'mouseover' + }, + effect: { + type: 'fade', + length: 100 + }, + delay: 140, + solo: false, + ready: false + }, + hide: { + when: { + target: false, + event: 'mouseout' + }, + effect: { + type: 'fade', + length: 100 + }, + delay: 0, + fixed: false + }, + // Callbacks + api: { + beforeRender: function(){}, + onRender: function(){}, + beforePositionUpdate: function(){}, + onPositionUpdate: function(){}, + beforeShow: function(){}, + onShow: function(){}, + beforeHide: function(){}, + onHide: function(){}, + beforeContentUpdate: function(){}, + onContentUpdate: function(){}, + beforeContentLoad: function(){}, + onContentLoad: function(){}, + beforeTitleUpdate: function(){}, + onTitleUpdate: function(){}, + beforeDestroy: function(){}, + onDestroy: function(){}, + beforeFocus: function(){}, + onFocus: function(){} + } + }; + + $.fn.qtip.styles = { + defaults: { + background: 'white', + color: '#111', + overflow: 'hidden', + textAlign: 'left', + width: { + min: 0, + max: 250 + }, + padding: '5px 9px', + border: { + width: 1, + radius: 0, + color: '#d3d3d3' + }, + tip: { + corner: false, + color: false, + size: { width: 13, height: 13 }, + opacity: 1 + }, + title: { + background: '#e1e1e1', + fontWeight: 'bold', + padding: '7px 12px' + }, + button: { + cursor: 'pointer' + }, + classes: { + target: '', + tip: 'qtip-tip', + title: 'qtip-title', + button: 'qtip-button', + content: 'qtip-content', + active: 'qtip-active' + } + }, + cream: { + border: { + width: 3, + radius: 0, + color: '#F9E98E' + }, + title: { + background: '#F0DE7D', + color: '#A27D35' + }, + background: '#FBF7AA', + color: '#A27D35', + + classes: { tooltip: 'qtip-cream' } + }, + light: { + border: { + width: 3, + radius: 0, + color: '#E2E2E2' + }, + title: { + background: '#f1f1f1', + color: '#454545' + }, + background: 'white', + color: '#454545', + + classes: { tooltip: 'qtip-light' } + }, + dark: { + border: { + width: 3, + radius: 0, + color: '#303030' + }, + title: { + background: '#404040', + color: '#f3f3f3' + }, + background: '#505050', + color: '#f3f3f3', + + classes: { tooltip: 'qtip-dark' } + }, + red: { + border: { + width: 3, + radius: 0, + color: '#CE6F6F' + }, + title: { + background: '#f28279', + color: '#9C2F2F' + }, + background: '#F79992', + color: '#9C2F2F', + + classes: { tooltip: 'qtip-red' } + }, + green: { + border: { + width: 3, + radius: 0, + color: '#A9DB66' + }, + title: { + background: '#b9db8c', + color: '#58792E' + }, + background: '#CDE6AC', + color: '#58792E', + + classes: { tooltip: 'qtip-green' } + }, + blue: { + border: { + width: 3, + radius: 0, + color: '#ADD9ED' + }, + title: { + background: '#D0E9F5', + color: '#5E99BD' + }, + background: '#E5F6FE', + color: '#4D9FBF', + + classes: { tooltip: 'qtip-blue' } + } + }; +})(jQuery); diff --git a/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.js b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.js new file mode 100644 index 0000000..98b0b85 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/jquery.qtip.js @@ -0,0 +1,15 @@ +/* + * jquery.qtip. The jQuery tooltip plugin + * + * Copyright (c) 2009 Craig Thompson + * http://craigsworks.com + * + * Licensed under MIT + * http://www.opensource.org/licenses/mit-license.php + * + * Launch : February 2009 + * Version : 1.0.0-rc3 + * Released: Tuesday 12th May, 2009 - 00:00 + * Debug: jquery.qtip.debug.js + */ +(function($){$.fn.qtip=function(options,blanket){var i,id,interfaces,opts,obj,command,config,api;if(typeof options=="string"){if(typeof $(this).data("qtip")!=="object"){$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.NO_TOOLTIP_PRESENT,false)}if(options=="api"){return $(this).data("qtip").interfaces[$(this).data("qtip").current]}else{if(options=="interfaces"){return $(this).data("qtip").interfaces}}}else{if(!options){options={}}if(typeof options.content!=="object"||(options.content.jquery&&options.content.length>0)){options.content={text:options.content}}if(typeof options.content.title!=="object"){options.content.title={text:options.content.title}}if(typeof options.position!=="object"){options.position={corner:options.position}}if(typeof options.position.corner!=="object"){options.position.corner={target:options.position.corner,tooltip:options.position.corner}}if(typeof options.show!=="object"){options.show={when:options.show}}if(typeof options.show.when!=="object"){options.show.when={event:options.show.when}}if(typeof options.show.effect!=="object"){options.show.effect={type:options.show.effect}}if(typeof options.hide!=="object"){options.hide={when:options.hide}}if(typeof options.hide.when!=="object"){options.hide.when={event:options.hide.when}}if(typeof options.hide.effect!=="object"){options.hide.effect={type:options.hide.effect}}if(typeof options.style!=="object"){options.style={name:options.style}}options.style=sanitizeStyle(options.style);opts=$.extend(true,{},$.fn.qtip.defaults,options);opts.style=buildStyle.call({options:opts},opts.style);opts.user=$.extend(true,{},options)}return $(this).each(function(){if(typeof options=="string"){command=options.toLowerCase();interfaces=$(this).qtip("interfaces");if(typeof interfaces=="object"){if(blanket===true&&command=="destroy"){while(interfaces.length>0){interfaces[interfaces.length-1].destroy()}}else{if(blanket!==true){interfaces=[$(this).qtip("api")]}for(i=0;i0))}if(typeof self.options.show.solo=="object"){solo=$(self.options.show.solo)}else{if(self.options.show.solo===true){solo=$("div.qtip").not(self.elements.tooltip)}}if(solo){solo.each(function(){if($(this).qtip("api").status.rendered===true){$(this).qtip("api").hide()}})}if(typeof self.options.show.effect.type=="function"){self.options.show.effect.type.call(self.elements.tooltip,self.options.show.effect.length);self.elements.tooltip.queue(function(){afterShow();$(this).dequeue()})}else{switch(self.options.show.effect.type.toLowerCase()){case"fade":self.elements.tooltip.fadeIn(self.options.show.effect.length,afterShow);break;case"slide":self.elements.tooltip.slideDown(self.options.show.effect.length,function(){afterShow();if(self.options.position.type!=="static"){self.updatePosition(event,true)}});break;case"grow":self.elements.tooltip.show(self.options.show.effect.length,afterShow);break;default:self.elements.tooltip.show(null,afterShow);break}self.elements.tooltip.addClass(self.options.style.classes.active)}return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_SHOWN,"show")},hide:function(event){var returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"hide")}else{if(self.elements.tooltip.css("display")==="none"){return self}}clearTimeout(self.timers.show);self.elements.tooltip.stop(true,false);returned=self.beforeHide.call(self,event);if(returned===false){return self}function afterHide(){self.onHide.call(self,event)}self.cache.toggle=0;if(typeof self.options.hide.effect.type=="function"){self.options.hide.effect.type.call(self.elements.tooltip,self.options.hide.effect.length);self.elements.tooltip.queue(function(){afterHide();$(this).dequeue()})}else{switch(self.options.hide.effect.type.toLowerCase()){case"fade":self.elements.tooltip.fadeOut(self.options.hide.effect.length,afterHide);break;case"slide":self.elements.tooltip.slideUp(self.options.hide.effect.length,afterHide);break;case"grow":self.elements.tooltip.hide(self.options.hide.effect.length,afterHide);break;default:self.elements.tooltip.hide(null,afterHide);break}self.elements.tooltip.removeClass(self.options.style.classes.active)}return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_HIDDEN,"hide")},updatePosition:function(event,animate){var i,target,tooltip,coords,mapName,imagePos,newPosition,ieAdjust,ie6Adjust,borderAdjust,mouseAdjust,offset,curPosition,returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updatePosition")}else{if(self.options.position.type=="static"){return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.CANNOT_POSITION_STATIC,"updatePosition")}}target={position:{left:0,top:0},dimensions:{height:0,width:0},corner:self.options.position.corner.target};tooltip={position:self.getPosition(),dimensions:self.getDimensions(),corner:self.options.position.corner.tooltip};if(self.options.position.target!=="mouse"){if(self.options.position.target.get(0).nodeName.toLowerCase()=="area"){coords=self.options.position.target.attr("coords").split(",");for(i=0;itarget.dimensions.width){target.dimensions.width=coords[i]}if(coords[i]target.dimensions.height){target.dimensions.height=coords[i]}if(coords[i]0){if(tooltip.corner.search(/Left/)!==-1){newPosition.left-=self.options.style.border.radius}else{if(tooltip.corner.search(/Right/)!==-1){newPosition.left+=self.options.style.border.radius}}if(tooltip.corner.search(/Top/)!==-1){newPosition.top-=self.options.style.border.radius}else{if(tooltip.corner.search(/Bottom/)!==-1){newPosition.top+=self.options.style.border.radius}}}if(ieAdjust){if(tooltip.corner.search(/top/)!==-1){newPosition.top-=ieAdjust}else{if(tooltip.corner.search(/bottom/)!==-1){newPosition.top+=ieAdjust}}if(tooltip.corner.search(/left/)!==-1){newPosition.left-=ieAdjust}else{if(tooltip.corner.search(/right/)!==-1){newPosition.left+=ieAdjust}}if(tooltip.corner.search(/leftMiddle|rightMiddle/)!==-1){newPosition.top-=1}}if(self.options.position.adjust.screen===true){newPosition=screenAdjust.call(self,newPosition,target,tooltip)}if(self.options.position.target==="mouse"&&self.options.position.adjust.mouse===true){if(self.options.position.adjust.screen===true&&self.elements.tip){mouseAdjust=self.elements.tip.attr("rel")}else{mouseAdjust=self.options.position.corner.tooltip}newPosition.left+=(mouseAdjust.search(/right/i)!==-1)?-6:6;newPosition.top+=(mouseAdjust.search(/bottom/i)!==-1)?-6:6}if(!self.elements.bgiframe&&$.browser.msie&&parseInt($.browser.version.charAt(0))==6){$("select, object").each(function(){offset=$(this).offset();offset.bottom=offset.top+$(this).height();offset.right=offset.left+$(this).width();if(newPosition.top+tooltip.dimensions.height>=offset.top&&newPosition.left+tooltip.dimensions.width>=offset.left){bgiframe.call(self)}})}newPosition.left+=self.options.position.adjust.x;newPosition.top+=self.options.position.adjust.y;curPosition=self.getPosition();if(newPosition.left!=curPosition.left||newPosition.top!=curPosition.top){returned=self.beforePositionUpdate.call(self,event);if(returned===false){return self}self.cache.position=newPosition;if(animate===true){self.status.animated=true;self.elements.tooltip.animate(newPosition,200,"swing",function(){self.status.animated=false})}else{self.elements.tooltip.css(newPosition)}self.onPositionUpdate.call(self,event);if(typeof event!=="undefined"&&event.type&&event.type!=="mousemove"){$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_POSITION_UPDATED,"updatePosition")}}return self},updateWidth:function(newWidth){var hidden;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateWidth")}else{if(newWidth&&typeof newWidth!=="number"){return $.fn.qtip.log.error.call(self,2,"newWidth must be of type number","updateWidth")}}hidden=self.elements.contentWrapper.siblings().add(self.elements.tip).add(self.elements.button);if(!newWidth){if(typeof self.options.style.width.value=="number"){newWidth=self.options.style.width.value}else{self.elements.tooltip.css({width:"auto"});hidden.hide();if($.browser.msie){self.elements.wrapper.add(self.elements.contentWrapper.children()).css({zoom:"normal"})}newWidth=self.getDimensions().width+1;if(!self.options.style.width.value){if(newWidth>self.options.style.width.max){newWidth=self.options.style.width.max}if(newWidth").get(0).getContext){tip=self.elements.tooltip.find(".qtip-tip canvas:first");context=tip.get(0).getContext("2d");context.clearRect(0,0,300,300);corner=tip.parent("div[rel]:first").attr("rel");coordinates=calculateTip(corner,self.options.style.tip.size.width,self.options.style.tip.size.height);drawTip.call(self,tip,coordinates,self.options.style.tip.color||self.options.style.border.color)}else{if($.browser.msie){tip=self.elements.tooltip.find('.qtip-tip [nodeName="shape"]');tip.attr("fillcolor",self.options.style.tip.color||self.options.style.border.color)}}}if(self.options.style.border.radius>0){self.elements.tooltip.find(".qtip-betweenCorners").css({backgroundColor:self.options.style.border.color});if($("").get(0).getContext){borders=calculateBorders(self.options.style.border.radius);self.elements.tooltip.find(".qtip-wrapper canvas").each(function(){context=$(this).get(0).getContext("2d");context.clearRect(0,0,300,300);corner=$(this).parent("div[rel]:first").attr("rel");drawBorder.call(self,$(this),borders[corner],self.options.style.border.radius,self.options.style.border.color)})}else{if($.browser.msie){self.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function(){$(this).attr("fillcolor",self.options.style.border.color)})}}}return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_STYLE_UPDATED,"updateStyle")},updateContent:function(content,reposition){var parsedContent,images,loadedImages;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateContent")}else{if(!content){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateContent")}}parsedContent=self.beforeContentUpdate.call(self,content);if(typeof parsedContent=="string"){content=parsedContent}else{if(parsedContent===false){return}}if($.browser.msie){self.elements.contentWrapper.children().css({zoom:"normal"})}if(content.jquery&&content.length>0){content.clone(true).appendTo(self.elements.content).show()}else{self.elements.content.html(content)}images=self.elements.content.find("img[complete=false]");if(images.length>0){loadedImages=0;images.each(function(i){$('').load(function(){if(++loadedImages==images.length){afterLoad()}})})}else{afterLoad()}function afterLoad(){self.updateWidth();if(reposition!==false){if(self.options.position.type!=="static"){self.updatePosition(self.elements.tooltip.is(":visible"),true)}if(self.options.style.tip.corner!==false){positionTip.call(self)}}}self.onContentUpdate.call(self);return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_CONTENT_UPDATED,"loadContent")},loadContent:function(url,data,method){var returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"loadContent")}returned=self.beforeContentLoad.call(self);if(returned===false){return self}if(method=="post"){$.post(url,data,setupContent)}else{$.get(url,data,setupContent)}function setupContent(content){self.onContentLoad.call(self);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_CONTENT_LOADED,"loadContent");self.updateContent(content)}return self},updateTitle:function(content){if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateTitle")}else{if(!content){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateTitle")}}returned=self.beforeTitleUpdate.call(self);if(returned===false){return self}if(self.elements.button){self.elements.button=self.elements.button.clone(true)}self.elements.title.html(content);if(self.elements.button){self.elements.title.prepend(self.elements.button)}self.onTitleUpdate.call(self);return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_TITLE_UPDATED,"updateTitle")},focus:function(event){var curIndex,newIndex,elemIndex,returned;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"focus")}else{if(self.options.position.type=="static"){return $.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.CANNOT_FOCUS_STATIC,"focus")}}curIndex=parseInt(self.elements.tooltip.css("z-index"));newIndex=6000+$("div.qtip[qtip]").length-1;if(!self.status.focused&&curIndex!==newIndex){returned=self.beforeFocus.call(self,event);if(returned===false){return self}$("div.qtip[qtip]").not(self.elements.tooltip).each(function(){if($(this).qtip("api").status.rendered===true){elemIndex=parseInt($(this).css("z-index"));if(typeof elemIndex=="number"&&elemIndex>-1){$(this).css({zIndex:parseInt($(this).css("z-index"))-1})}$(this).qtip("api").status.focused=false}});self.elements.tooltip.css({zIndex:newIndex});self.status.focused=true;self.onFocus.call(self,event);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_FOCUSED,"focus")}return self},disable:function(state){if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"disable")}if(state){if(!self.status.disabled){self.status.disabled=true;$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_DISABLED,"disable")}else{$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED,"disable")}}else{if(self.status.disabled){self.status.disabled=false;$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_ENABLED,"disable")}else{$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED,"disable")}}return self},destroy:function(){var i,returned,interfaces;returned=self.beforeDestroy.call(self);if(returned===false){return self}if(self.status.rendered){self.options.show.when.target.unbind("mousemove.qtip",self.updatePosition);self.options.show.when.target.unbind("mouseout.qtip",self.hide);self.options.show.when.target.unbind(self.options.show.when.event+".qtip");self.options.hide.when.target.unbind(self.options.hide.when.event+".qtip");self.elements.tooltip.unbind(self.options.hide.when.event+".qtip");self.elements.tooltip.unbind("mouseover.qtip",self.focus);self.elements.tooltip.remove()}else{self.options.show.when.target.unbind(self.options.show.when.event+".qtip-create")}if(typeof self.elements.target.data("qtip")=="object"){interfaces=self.elements.target.data("qtip").interfaces;if(typeof interfaces=="object"&&interfaces.length>0){for(i=0;i0){self.elements.target.data("qtip").current=interfaces.length-1}else{self.elements.target.removeData("qtip")}self.onDestroy.call(self);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_DESTROYED,"destroy");return self.elements.target},getPosition:function(){var show,offset;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getPosition")}show=(self.elements.tooltip.css("display")!=="none")?false:true;if(show){self.elements.tooltip.css({visiblity:"hidden"}).show()}offset=self.elements.tooltip.offset();if(show){self.elements.tooltip.css({visiblity:"visible"}).hide()}return offset},getDimensions:function(){var show,dimensions;if(!self.status.rendered){return $.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getDimensions")}show=(!self.elements.tooltip.is(":visible"))?true:false;if(show){self.elements.tooltip.css({visiblity:"hidden"}).show()}dimensions={height:self.elements.tooltip.outerHeight(),width:self.elements.tooltip.outerWidth()};if(show){self.elements.tooltip.css({visiblity:"visible"}).hide()}return dimensions}})}function construct(){var self,adjust,content,url,data,method,tempLength;self=this;self.beforeRender.call(self);self.status.rendered=true;self.elements.tooltip=' ';self.elements.tooltip=$(self.elements.tooltip);self.elements.tooltip.appendTo(self.options.position.container);self.elements.tooltip.data("qtip",{current:0,interfaces:[self]});self.elements.wrapper=self.elements.tooltip.children("div:first");self.elements.contentWrapper=self.elements.wrapper.children("div:first").css({background:self.options.style.background});self.elements.content=self.elements.contentWrapper.children("div:first").css(jQueryStyle(self.options.style));if($.browser.msie){self.elements.wrapper.add(self.elements.content).css({zoom:1})}if(self.options.hide.when.event=="unfocus"){self.elements.tooltip.attr("unfocus",true)}if(typeof self.options.style.width.value=="number"){self.updateWidth()}if($("").get(0).getContext||$.browser.msie){if(self.options.style.border.radius>0){createBorder.call(self)}else{self.elements.contentWrapper.css({border:self.options.style.border.width+"px solid "+self.options.style.border.color})}if(self.options.style.tip.corner!==false){createTip.call(self)}}else{self.elements.contentWrapper.css({border:self.options.style.border.width+"px solid "+self.options.style.border.color});self.options.style.border.radius=0;self.options.style.tip.corner=false;$.fn.qtip.log.error.call(self,2,$.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED,"render")}if((typeof self.options.content.text=="string"&&self.options.content.text.length>0)||(self.options.content.text.jquery&&self.options.content.text.length>0)){content=self.options.content.text}else{if(typeof self.elements.target.attr("title")=="string"&&self.elements.target.attr("title").length>0){content=self.elements.target.attr("title").replace("\\n","");self.elements.target.attr("title","")}else{if(typeof self.elements.target.attr("alt")=="string"&&self.elements.target.attr("alt").length>0){content=self.elements.target.attr("alt").replace("\\n","");self.elements.target.attr("alt","")}else{content=" ";$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.NO_VALID_CONTENT,"render")}}}if(self.options.content.title.text!==false){createTitle.call(self)}self.updateContent(content);assignEvents.call(self);if(self.options.show.ready===true){self.show()}if(self.options.content.url!==false){url=self.options.content.url;data=self.options.content.data;method=self.options.content.method||"get";self.loadContent(url,data,method)}self.onRender.call(self);$.fn.qtip.log.error.call(self,1,$.fn.qtip.constants.EVENT_RENDERED,"render")}function createBorder(){var self,i,width,radius,color,coordinates,containers,size,betweenWidth,betweenCorners,borderTop,borderBottom,borderCoord,sideWidth,vertWidth;self=this;self.elements.wrapper.find(".qtip-borderBottom, .qtip-borderTop").remove();width=self.options.style.border.width;radius=self.options.style.border.radius;color=self.options.style.border.color||self.options.style.tip.color;coordinates=calculateBorders(radius);containers={};for(i in coordinates){containers[i]='';if($("").get(0).getContext){containers[i]+=''}else{if($.browser.msie){size=radius*2+3;containers[i]+=''}}containers[i]+=""}betweenWidth=self.getDimensions().width-(Math.max(width,radius)*2);betweenCorners='';borderTop=''+containers.topLeft+containers.topRight+betweenCorners;self.elements.wrapper.prepend(borderTop);borderBottom=''+containers.bottomLeft+containers.bottomRight+betweenCorners;self.elements.wrapper.append(borderBottom);if($("").get(0).getContext){self.elements.wrapper.find("canvas").each(function(){borderCoord=coordinates[$(this).parent("[rel]:first").attr("rel")];drawBorder.call(self,$(this),borderCoord,radius,color)})}else{if($.browser.msie){self.elements.tooltip.append('')}}sideWidth=Math.max(radius,(radius+(width-radius)));vertWidth=Math.max(width-radius,0);self.elements.contentWrapper.css({border:"0px solid "+color,borderWidth:vertWidth+"px "+sideWidth+"px"})}function drawBorder(canvas,coordinates,radius,color){var context=canvas.get(0).getContext("2d");context.fillStyle=color;context.beginPath();context.arc(coordinates[0],coordinates[1],radius,0,Math.PI*2,false);context.fill()}function createTip(corner){var self,color,coordinates,coordsize,path;self=this;if(self.elements.tip!==null){self.elements.tip.remove()}color=self.options.style.tip.color||self.options.style.border.color;if(self.options.style.tip.corner===false){return}else{if(!corner){corner=self.options.style.tip.corner}}coordinates=calculateTip(corner,self.options.style.tip.size.width,self.options.style.tip.size.height);self.elements.tip='';if($("").get(0).getContext){self.elements.tip+=''}else{if($.browser.msie){coordsize=self.options.style.tip.size.width+","+self.options.style.tip.size.height;path="m"+coordinates[0][0]+","+coordinates[0][1];path+=" l"+coordinates[1][0]+","+coordinates[1][1];path+=" "+coordinates[2][0]+","+coordinates[2][1];path+=" xe";self.elements.tip+='';self.elements.tip+='';self.elements.contentWrapper.css("position","relative")}}self.elements.tooltip.prepend(self.elements.tip+"");self.elements.tip=self.elements.tooltip.find("."+self.options.style.classes.tip).eq(0);if($("").get(0).getContext){drawTip.call(self,self.elements.tip.find("canvas:first"),coordinates,color)}if(corner.search(/top/)!==-1&&$.browser.msie&&parseInt($.browser.version.charAt(0))===6){self.elements.tip.css({marginTop:-4})}positionTip.call(self,corner)}function drawTip(canvas,coordinates,color){var context=canvas.get(0).getContext("2d");context.fillStyle=color;context.beginPath();context.moveTo(coordinates[0][0],coordinates[0][1]);context.lineTo(coordinates[1][0],coordinates[1][1]);context.lineTo(coordinates[2][0],coordinates[2][1]);context.fill()}function positionTip(corner){var self,ieAdjust,paddingCorner,paddingSize,newMargin;self=this;if(self.options.style.tip.corner===false||!self.elements.tip){return}if(!corner){corner=self.elements.tip.attr("rel")}ieAdjust=positionAdjust=($.browser.msie)?1:0;self.elements.tip.css(corner.match(/left|right|top|bottom/)[0],0);if(corner.search(/top|bottom/)!==-1){if($.browser.msie){if(parseInt($.browser.version.charAt(0))===6){positionAdjust=(corner.search(/top/)!==-1)?-3:1}else{positionAdjust=(corner.search(/top/)!==-1)?1:2}}if(corner.search(/Middle/)!==-1){self.elements.tip.css({left:"50%",marginLeft:-(self.options.style.tip.size.width/2)})}else{if(corner.search(/Left/)!==-1){self.elements.tip.css({left:self.options.style.border.radius-ieAdjust})}else{if(corner.search(/Right/)!==-1){self.elements.tip.css({right:self.options.style.border.radius+ieAdjust})}}}if(corner.search(/top/)!==-1){self.elements.tip.css({top:-positionAdjust})}else{self.elements.tip.css({bottom:positionAdjust})}}else{if(corner.search(/left|right/)!==-1){if($.browser.msie){positionAdjust=(parseInt($.browser.version.charAt(0))===6)?1:((corner.search(/left/)!==-1)?1:2)}if(corner.search(/Middle/)!==-1){self.elements.tip.css({top:"50%",marginTop:-(self.options.style.tip.size.height/2)})}else{if(corner.search(/Top/)!==-1){self.elements.tip.css({top:self.options.style.border.radius-ieAdjust})}else{if(corner.search(/Bottom/)!==-1){self.elements.tip.css({bottom:self.options.style.border.radius+ieAdjust})}}}if(corner.search(/left/)!==-1){self.elements.tip.css({left:-positionAdjust})}else{self.elements.tip.css({right:positionAdjust})}}}paddingCorner="padding-"+corner.match(/left|right|top|bottom/)[0];paddingSize=self.options.style.tip.size[(paddingCorner.search(/left|right/)!==-1)?"width":"height"];self.elements.tooltip.css("padding",0);self.elements.tooltip.css(paddingCorner,paddingSize);if($.browser.msie&&parseInt($.browser.version.charAt(0))==6){newMargin=parseInt(self.elements.tip.css("margin-top"))||0;newMargin+=parseInt(self.elements.content.css("margin-top"))||0;self.elements.tip.css({marginTop:newMargin})}}function createTitle(){var self=this;if(self.elements.title!==null){self.elements.title.remove()}self.elements.title=$('').css(jQueryStyle(self.options.style.title,true)).css({zoom:($.browser.msie)?1:0}).prependTo(self.elements.contentWrapper);if(self.options.content.title.text){self.updateTitle.call(self,self.options.content.title.text)}if(self.options.content.title.button!==false&&typeof self.options.content.title.button=="string"){self.elements.button=$('').css(jQueryStyle(self.options.style.button,true)).html(self.options.content.title.button).prependTo(self.elements.title).click(function(event){if(!self.status.disabled){self.hide(event)}})}}function assignEvents(){var self,showTarget,hideTarget,inactiveEvents;self=this;showTarget=self.options.show.when.target;hideTarget=self.options.hide.when.target;if(self.options.hide.fixed){hideTarget=hideTarget.add(self.elements.tooltip)}if(self.options.hide.when.event=="inactive"){inactiveEvents=["click","dblclick","mousedown","mouseup","mousemove","mouseout","mouseenter","mouseleave","mouseover"];function inactiveMethod(event){if(self.status.disabled===true){return}clearTimeout(self.timers.inactive);self.timers.inactive=setTimeout(function(){$(inactiveEvents).each(function(){hideTarget.unbind(this+".qtip-inactive");self.elements.content.unbind(this+".qtip-inactive")});self.hide(event)},self.options.hide.delay)}}else{if(self.options.hide.fixed===true){self.elements.tooltip.bind("mouseover.qtip",function(){if(self.status.disabled===true){return}clearTimeout(self.timers.hide)})}}function showMethod(event){if(self.status.disabled===true){return}if(self.options.hide.when.event=="inactive"){$(inactiveEvents).each(function(){hideTarget.bind(this+".qtip-inactive",inactiveMethod);self.elements.content.bind(this+".qtip-inactive",inactiveMethod)});inactiveMethod()}clearTimeout(self.timers.show);clearTimeout(self.timers.hide);self.timers.show=setTimeout(function(){self.show(event)},self.options.show.delay)}function hideMethod(event){if(self.status.disabled===true){return}if(self.options.hide.fixed===true&&self.options.hide.when.event.search(/mouse(out|leave)/i)!==-1&&$(event.relatedTarget).parents("div.qtip[qtip]").length>0){event.stopPropagation();event.preventDefault();clearTimeout(self.timers.hide);return false}clearTimeout(self.timers.show);clearTimeout(self.timers.hide);self.elements.tooltip.stop(true,true);self.timers.hide=setTimeout(function(){self.hide(event)},self.options.hide.delay)}if((self.options.show.when.target.add(self.options.hide.when.target).length===1&&self.options.show.when.event==self.options.hide.when.event&&self.options.hide.when.event!=="inactive")||self.options.hide.when.event=="unfocus"){self.cache.toggle=0;showTarget.bind(self.options.show.when.event+".qtip",function(event){if(self.cache.toggle==0){showMethod(event)}else{hideMethod(event)}})}else{showTarget.bind(self.options.show.when.event+".qtip",showMethod);if(self.options.hide.when.event!=="inactive"){hideTarget.bind(self.options.hide.when.event+".qtip",hideMethod)}}if(self.options.position.type.search(/(fixed|absolute)/)!==-1){self.elements.tooltip.bind("mouseover.qtip",self.focus)}if(self.options.position.target==="mouse"&&self.options.position.type!=="static"){showTarget.bind("mousemove.qtip",function(event){self.cache.mouse={x:event.pageX,y:event.pageY};if(self.status.disabled===false&&self.options.position.adjust.mouse===true&&self.options.position.type!=="static"&&self.elements.tooltip.css("display")!=="none"){self.updatePosition(event)}})}}function screenAdjust(position,target,tooltip){var self,adjustedPosition,adjust,newCorner,overflow,corner;self=this;if(tooltip.corner=="center"){return target.position}adjustedPosition=$.extend({},position);newCorner={x:false,y:false};overflow={left:(adjustedPosition.left<$.fn.qtip.cache.screen.scroll.left),right:(adjustedPosition.left+tooltip.dimensions.width+2>=$.fn.qtip.cache.screen.width+$.fn.qtip.cache.screen.scroll.left),top:(adjustedPosition.top<$.fn.qtip.cache.screen.scroll.top),bottom:(adjustedPosition.top+tooltip.dimensions.height+2>=$.fn.qtip.cache.screen.height+$.fn.qtip.cache.screen.scroll.top)};adjust={left:(overflow.left&&(tooltip.corner.search(/right/i)!=-1||(tooltip.corner.search(/right/i)==-1&&!overflow.right))),right:(overflow.right&&(tooltip.corner.search(/left/i)!=-1||(tooltip.corner.search(/left/i)==-1&&!overflow.left))),top:(overflow.top&&tooltip.corner.search(/top/i)==-1),bottom:(overflow.bottom&&tooltip.corner.search(/bottom/i)==-1)};if(adjust.left){if(self.options.position.target!=="mouse"){adjustedPosition.left=target.position.left+target.dimensions.width}else{adjustedPosition.left=self.cache.mouse.x}newCorner.x="Left"}else{if(adjust.right){if(self.options.position.target!=="mouse"){adjustedPosition.left=target.position.left-tooltip.dimensions.width}else{adjustedPosition.left=self.cache.mouse.x-tooltip.dimensions.width}newCorner.x="Right"}}if(adjust.top){if(self.options.position.target!=="mouse"){adjustedPosition.top=target.position.top+target.dimensions.height}else{adjustedPosition.top=self.cache.mouse.y}newCorner.y="top"}else{if(adjust.bottom){if(self.options.position.target!=="mouse"){adjustedPosition.top=target.position.top-tooltip.dimensions.height}else{adjustedPosition.top=self.cache.mouse.y-tooltip.dimensions.height}newCorner.y="bottom"}}if(adjustedPosition.left<0){adjustedPosition.left=position.left;newCorner.x=false}if(adjustedPosition.top<0){adjustedPosition.top=position.top;newCorner.y=false}if(self.options.style.tip.corner!==false){adjustedPosition.corner=new String(tooltip.corner);if(newCorner.x!==false){adjustedPosition.corner=adjustedPosition.corner.replace(/Left|Right|Middle/,newCorner.x)}if(newCorner.y!==false){adjustedPosition.corner=adjustedPosition.corner.replace(/top|bottom/,newCorner.y)}if(adjustedPosition.corner!==self.elements.tip.attr("rel")){createTip.call(self,adjustedPosition.corner)}}return adjustedPosition}function jQueryStyle(style,sub){var styleObj,i;styleObj=$.extend(true,{},style);for(i in styleObj){if(sub===true&&i.search(/(tip|classes)/i)!==-1){delete styleObj[i]}else{if(!sub&&i.search(/(width|border|tip|title|classes|user)/i)!==-1){delete styleObj[i]}}}return styleObj}function sanitizeStyle(style){if(typeof style.tip!=="object"){style.tip={corner:style.tip}}if(typeof style.tip.size!=="object"){style.tip.size={width:style.tip.size,height:style.tip.size}}if(typeof style.border!=="object"){style.border={width:style.border}}if(typeof style.width!=="object"){style.width={value:style.width}}if(typeof style.width.max=="string"){style.width.max=parseInt(style.width.max.replace(/([0-9]+)/i,"$1"))}if(typeof style.width.min=="string"){style.width.min=parseInt(style.width.min.replace(/([0-9]+)/i,"$1"))}if(typeof style.tip.size.x=="number"){style.tip.size.width=style.tip.size.x;delete style.tip.size.x}if(typeof style.tip.size.y=="number"){style.tip.size.height=style.tip.size.y;delete style.tip.size.y}return style}function buildStyle(){var self,i,styleArray,styleExtend,finalStyle,ieAdjust;self=this;styleArray=[true,{}];for(i=0;i0){finalStyle.tip.size.width+=1}if(finalStyle.tip.size.height%2>0){finalStyle.tip.size.height+=1}if(finalStyle.tip.corner===true){finalStyle.tip.corner=(self.options.position.corner.tooltip==="center")?false:self.options.position.corner.tooltip}return finalStyle}function calculateTip(corner,width,height){var tips={bottomRight:[[0,0],[width,height],[width,0]],bottomLeft:[[0,0],[width,0],[0,height]],topRight:[[0,height],[width,0],[width,height]],topLeft:[[0,0],[0,height],[width,height]],topMiddle:[[0,height],[width/2,0],[width,height]],bottomMiddle:[[0,0],[width,0],[width/2,height]],rightMiddle:[[0,0],[width,height/2],[0,height]],leftMiddle:[[width,0],[width,height],[0,height/2]]};tips.leftTop=tips.bottomRight;tips.rightTop=tips.bottomLeft;tips.leftBottom=tips.topRight;tips.rightBottom=tips.topLeft;return tips[corner]}function calculateBorders(radius){var borders;if($("").get(0).getContext){borders={topLeft:[radius,radius],topRight:[0,radius],bottomLeft:[radius,0],bottomRight:[0,0]}}else{if($.browser.msie){borders={topLeft:[-90,90,0],topRight:[-90,90,-radius],bottomLeft:[90,270,0],bottomRight:[90,270,-radius]}}}return borders}function bgiframe(){var self,html,dimensions;self=this;dimensions=self.getDimensions();html='';self.elements.bgiframe=self.elements.wrapper.prepend(html).children(".qtip-bgiframe:first")}$(document).ready(function(){$.fn.qtip.cache={screen:{scroll:{left:$(window).scrollLeft(),top:$(window).scrollTop()},width:$(window).width(),height:$(window).height()}};var adjustTimer;$(window).bind("resize scroll",function(event){clearTimeout(adjustTimer);adjustTimer=setTimeout(function(){if(event.type==="scroll"){$.fn.qtip.cache.screen.scroll={left:$(window).scrollLeft(),top:$(window).scrollTop()}}else{$.fn.qtip.cache.screen.width=$(window).width();$.fn.qtip.cache.screen.height=$(window).height()}for(i=0;i<$.fn.qtip.interfaces.length;i++){var api=$.fn.qtip.interfaces[i];if(api.status.rendered===true&&(api.options.position.type!=="static"||api.options.position.adjust.scroll&&event.type==="scroll"||api.options.position.adjust.resize&&event.type==="resize")){api.updatePosition(event,true)}}},100)});$(document).bind("mousedown.qtip",function(event){if($(event.target).parents("div.qtip").length===0){$(".qtip[unfocus]").each(function(){var api=$(this).qtip("api");if($(this).is(":visible")&&!api.status.disabled&&$(event.target).add(api.elements.target).length>1){api.hide(event)}})}})});$.fn.qtip.interfaces=[];$.fn.qtip.log={error:function(){return this}};$.fn.qtip.constants={};$.fn.qtip.defaults={content:{prerender:false,text:false,url:false,data:null,title:{text:false,button:false}},position:{target:false,corner:{target:"bottomRight",tooltip:"topLeft"},adjust:{x:0,y:0,mouse:true,screen:false,scroll:true,resize:true},type:"absolute",container:false},show:{when:{target:false,event:"mouseover"},effect:{type:"fade",length:100},delay:140,solo:false,ready:false},hide:{when:{target:false,event:"mouseout"},effect:{type:"fade",length:100},delay:0,fixed:false},api:{beforeRender:function(){},onRender:function(){},beforePositionUpdate:function(){},onPositionUpdate:function(){},beforeShow:function(){},onShow:function(){},beforeHide:function(){},onHide:function(){},beforeContentUpdate:function(){},onContentUpdate:function(){},beforeContentLoad:function(){},onContentLoad:function(){},beforeTitleUpdate:function(){},onTitleUpdate:function(){},beforeDestroy:function(){},onDestroy:function(){},beforeFocus:function(){},onFocus:function(){}}};$.fn.qtip.styles={defaults:{background:"white",color:"#111",overflow:"hidden",textAlign:"left",width:{min:0,max:250},padding:"5px 9px",border:{width:1,radius:0,color:"#d3d3d3"},tip:{corner:false,color:false,size:{width:13,height:13},opacity:1},title:{background:"#e1e1e1",fontWeight:"bold",padding:"7px 12px"},button:{cursor:"pointer"},classes:{target:"",tip:"qtip-tip",title:"qtip-title",button:"qtip-button",content:"qtip-content",active:"qtip-active"}},cream:{border:{width:3,radius:0,color:"#F9E98E"},title:{background:"#F0DE7D",color:"#A27D35"},background:"#FBF7AA",color:"#A27D35",classes:{tooltip:"qtip-cream"}},light:{border:{width:3,radius:0,color:"#E2E2E2"},title:{background:"#f1f1f1",color:"#454545"},background:"white",color:"#454545",classes:{tooltip:"qtip-light"}},dark:{border:{width:3,radius:0,color:"#303030"},title:{background:"#404040",color:"#f3f3f3"},background:"#505050",color:"#f3f3f3",classes:{tooltip:"qtip-dark"}},red:{border:{width:3,radius:0,color:"#CE6F6F"},title:{background:"#f28279",color:"#9C2F2F"},background:"#F79992",color:"#9C2F2F",classes:{tooltip:"qtip-red"}},green:{border:{width:3,radius:0,color:"#A9DB66"},title:{background:"#b9db8c",color:"#58792E"},background:"#CDE6AC",color:"#58792E",classes:{tooltip:"qtip-green"}},blue:{border:{width:3,radius:0,color:"#ADD9ED"},title:{background:"#D0E9F5",color:"#5E99BD"},background:"#E5F6FE",color:"#4D9FBF",classes:{tooltip:"qtip-blue"}}}})(jQuery); \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/livequery.js b/blog/wp-content/plugins/front-end-editor/editor/livequery.js new file mode 100644 index 0000000..398f0a4 --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/livequery.js @@ -0,0 +1,9 @@ +/* Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net) + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. + * + * Version: 1.0.3 + * Requires jQuery 1.1.3+ + * Docs: http://docs.jquery.com/Plugins/livequery + */ +(function($){$.extend($.fn,{livequery:function(type,fn,fn2){var self=this,q;if($.isFunction(type)){fn2=fn,fn=type,type=undefined}$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&type==query.type&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)){return(q=query)&&false}});q=q||new $.livequery(this.selector,this.context,type,fn,fn2);q.stopped=false;q.run();return this},expire:function(type,fn,fn2){var self=this;if($.isFunction(type)){fn2=fn,fn=type,type=undefined}$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&(!type||type==query.type)&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)&&!this.stopped){$.livequery.stop(query.id)}});return this}});$.livequery=function(selector,context,type,fn,fn2){this.selector=selector;this.context=context||document;this.type=type;this.fn=fn;this.fn2=fn2;this.elements=[];this.stopped=false;this.id=$.livequery.queries.push(this)-1;fn.$lqguid=fn.$lqguid||$.livequery.guid++;if(fn2){fn2.$lqguid=fn2.$lqguid||$.livequery.guid++}return this};$.livequery.prototype={stop:function(){var query=this;if(this.type){this.elements.unbind(this.type,this.fn)}else{if(this.fn2){this.elements.each(function(i,el){query.fn2.apply(el)})}}this.elements=[];this.stopped=true},run:function(){if(this.stopped){return}var query=this;var oEls=this.elements,els=$(this.selector,this.context),nEls=els.not(oEls);this.elements=els;if(this.type){nEls.bind(this.type,this.fn);if(oEls.length>0){$.each(oEls,function(i,el){if($.inArray(el,els)<0){$.event.remove(el,query.type,query.fn)}})}}else{nEls.each(function(){query.fn.apply(this)});if(this.fn2&&oEls.length>0){$.each(oEls,function(i,el){if($.inArray(el,els)<0){query.fn2.apply(el)}})}}}};$.extend($.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if($.livequery.running&&$.livequery.queue.length){var length=$.livequery.queue.length;while(length--){$.livequery.queries[$.livequery.queue.shift()].run()}}},pause:function(){$.livequery.running=false},play:function(){$.livequery.running=true;$.livequery.run()},registerPlugin:function(){$.each(arguments,function(i,n){if(!$.fn[n]){return}var old=$.fn[n];$.fn[n]=function(){var r=old.apply(this,arguments);$.livequery.run();return r}})},run:function(id){if(id!=undefined){if($.inArray(id,$.livequery.queue)<0){$.livequery.queue.push(id)}}else{$.each($.livequery.queries,function(id){if($.inArray(id,$.livequery.queue)<0){$.livequery.queue.push(id)}})}if($.livequery.timeout){clearTimeout($.livequery.timeout)}$.livequery.timeout=setTimeout($.livequery.checkQueue,20)},stop:function(id){if(id!=undefined){$.livequery.queries[id].stop()}else{$.each($.livequery.queries,function(id){$.livequery.queries[id].stop()})}}});$.livequery.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove");$(function(){$.livequery.play()});var init=$.prototype.init;$.prototype.init=function(a,c){var r=init.apply(this,arguments);if(a&&a.selector){r.context=a.context,r.selector=a.selector}if(typeof a=="string"){r.context=c||document,r.selector=a}return r};$.prototype.init.prototype=$.prototype})(jQuery); \ No newline at end of file diff --git a/blog/wp-content/plugins/front-end-editor/editor/nicedit/nicEdit.dev.js b/blog/wp-content/plugins/front-end-editor/editor/nicedit/nicEdit.dev.js new file mode 100644 index 0000000..161292d --- /dev/null +++ b/blog/wp-content/plugins/front-end-editor/editor/nicedit/nicEdit.dev.js @@ -0,0 +1,1484 @@ +/* NicEdit - Micro Inline WYSIWYG + * Copyright 2007-2008 Brian Kirchoff + * + * NicEdit is distributed under the terms of the MIT license + * For more information visit http://nicedit.com/ + * Do not remove this copyright message + */ +var bkExtend = function(){ + var args = arguments; + if (args.length == 1) args = [this, args[0]]; + for (var prop in args[1]) args[0][prop] = args[1][prop]; + return args[0]; +}; +function bkClass() { } +bkClass.prototype.construct = function() {}; +bkClass.extend = function(def) { + var classDef = function() { + if (arguments[0] !== bkClass) { return this.construct.apply(this, arguments); } + }; + var proto = new this(bkClass); + bkExtend(proto,def); + classDef.prototype = proto; + classDef.extend = this.extend; + return classDef; +}; + +var bkElement = bkClass.extend({ + construct : function(elm,d) { + if(typeof(elm) == "string") { + elm = (d || document).createElement(elm); + } + elm = $BK(elm); + return elm; + }, + + appendTo : function(elm) { + elm.appendChild(this); + return this; + }, + + appendBefore : function(elm) { + elm.parentNode.insertBefore(this,elm); + return this; + }, + + addEvent : function(type, fn) { + bkLib.addEvent(this,type,fn); + return this; + }, + + setContent : function(c) { + this.innerHTML = c; + return this; + }, + + pos : function() { + var curleft = curtop = 0; + var o = obj = this; + if (obj.offsetParent) { + do { + curleft += obj.offsetLeft; + curtop += obj.offsetTop; + } while (obj = obj.offsetParent); + } + var b = (!window.opera) ? parseInt(this.getStyle('border-width') || this.style.border) || 0 : 0; + return [curleft+b,curtop+b+this.offsetHeight]; + }, + + noSelect : function() { + bkLib.noSelect(this); + return this; + }, + + parentTag : function(t) { + var elm = this; + do { + if(elm && elm.nodeName && elm.nodeName.toUpperCase() == t) { + return elm; + } + elm = elm.parentNode; + } while(elm); + return false; + }, + + hasClass : function(cls) { + return this.className.match(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)')); + }, + + addClass : function(cls) { + if (!this.hasClass(cls)) { this.className += " nicEdit-"+cls }; + return this; + }, + + removeClass : function(cls) { + if (this.hasClass(cls)) { + this.className = this.className.replace(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)'),' '); + } + return this; + }, + + setStyle : function(st) { + var elmStyle = this.style; + for(var itm in st) { + switch(itm) { + case 'float': + elmStyle['cssFloat'] = elmStyle['styleFloat'] = st[itm]; + break; + case 'opacity': + elmStyle.opacity = st[itm]; + elmStyle.filter = "alpha(opacity=" + Math.round(st[itm]*100) + ")"; + break; + case 'className': + this.className = st[itm]; + break; + default: + //if(document.compatMode || itm != "cursor") { // Nasty Workaround for IE 5.5 + elmStyle[itm] = st[itm]; + //} + } + } + return this; + }, + + getStyle : function( cssRule, d ) { + var doc = (!d) ? document.defaultView : d; + if(this.nodeType == 1) + return (doc && doc.getComputedStyle) ? doc.getComputedStyle( this, null ).getPropertyValue(cssRule) : this.currentStyle[ bkLib.camelize(cssRule) ]; + }, + + remove : function() { + this.parentNode.removeChild(this); + return this; + }, + + setAttributes : function(at) { + for(var itm in at) { + this[itm] = at[itm]; + } + return this; + } +}); + +var bkLib = { + isMSIE : (navigator.appVersion.indexOf("MSIE") != -1), + + addEvent : function(obj, type, fn) { + (obj.addEventListener) ? obj.addEventListener( type, fn, false ) : obj.attachEvent("on"+type, fn); + }, + + toArray : function(iterable) { + var length = iterable.length, results = new Array(length); + while (length--) { results[length] = iterable[length] }; + return results; + }, + + noSelect : function(element) { + if(element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') { + element.setAttribute('unselectable','on'); + } + for(var i=0;i.nicEdit-main p { margin: 0; }<\/scr"+"ipt>"); + $BK("__ie_onload").onreadystatechange = function() { + if (this.readyState == "complete"){bkLib.domLoaded();} + }; + } + window.onload = bkLib.domLoaded; + } +}; + +function $BK(elm) { + if(typeof(elm) == "string") { + elm = document.getElementById(elm); + } + return (elm && !elm.appendTo) ? bkExtend(elm,bkElement.prototype) : elm; +} + +var bkEvent = { + addEvent : function(evType, evFunc) { + if(evFunc) { + this.eventList = this.eventList || {}; + this.eventList[evType] = this.eventList[evType] || []; + this.eventList[evType].push(evFunc); + } + return this; + }, + fireEvent : function() { + var args = bkLib.toArray(arguments), evType = args.shift(); + if(this.eventList && this.eventList[evType]) { + for(var i=0;i'); + } + this.instanceDoc = document.defaultView; + this.elm.addEvent('mousedown',this.selected.closureListener(this)).addEvent('keypress',this.keyDown.closureListener(this)).addEvent('focus',this.selected.closure(this)).addEvent('blur',this.blur.closure(this)).addEvent('keyup',this.selected.closure(this)); + this.ne.fireEvent('add',this); + }, + + remove : function() { + this.saveContent(); + if(this.copyElm || this.options.hasPanel) { + this.editorContain.remove(); + this.e.setStyle({'display' : 'block'}); + this.ne.removePanel(); + } + this.disable(); + this.ne.fireEvent('remove',this); + }, + + disable : function() { + this.elm.setAttribute('contentEditable','false'); + }, + + getSel : function() { + return (window.getSelection) ? window.getSelection() : document.selection; + }, + + getRng : function() { + var s = this.getSel(); + if(!s) { return null; } + return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange(); + }, + + selRng : function(rng,s) { + if(window.getSelection) { + s.removeAllRanges(); + s.addRange(rng); + } else { + rng.select(); + } + }, + + selElm : function() { + var r = this.getRng(); + if(r.startContainer) { + var contain = r.startContainer; + if(r.cloneContents().childNodes.length == 1) { + for(var i=0;i'+((css) ? '' : '')+''+this.initialContent+'