r66248 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66247‎ | r66248 | r66249 >
Date:01:01, 12 May 2010
Author:neilk
Status:deferred
Tags:
Comment:
basically working in trunk now
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizardJsModule/css/jquery.tipsy.css (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizardJsModule/css/jquery.tipsy.gif (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizardJsModule/jquery (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizardJsModule/jquery/plugins (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizardJsModule/jquery/plugins/jquery.tipsy.js (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizardJsModule/loader.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizardJsModule/jquery/plugins/jquery.tipsy.js
@@ -0,0 +1,194 @@
 2+// tipsy, facebook style tooltips for jquery
 3+// version 1.0.0a
 4+// (c) 2008-2010 jason frame [jason@onehackoranother.com]
 5+// releated under the MIT license
 6+
 7+(function($) {
 8+
 9+ function fixTitle($ele) {
 10+ if ($ele.attr('title') || typeof($ele.attr('original-title')) != 'string') {
 11+ $ele.attr('original-title', $ele.attr('title') || '').removeAttr('title');
 12+ }
 13+ }
 14+
 15+ function Tipsy(element, options) {
 16+ this.$element = $(element);
 17+ this.options = options;
 18+ this.enabled = true;
 19+ fixTitle(this.$element);
 20+ }
 21+
 22+ Tipsy.prototype = {
 23+ show: function() {
 24+ var title = this.getTitle();
 25+ if (title && this.enabled) {
 26+ var $tip = this.tip();
 27+
 28+ $tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title);
 29+ $tip[0].className = 'tipsy'; // reset classname in case of dynamic gravity
 30+ $tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
 31+
 32+ var pos = $.extend({}, this.$element.offset(), {
 33+ width: this.$element[0].offsetWidth,
 34+ height: this.$element[0].offsetHeight
 35+ });
 36+
 37+ var actualWidth = $tip[0].offsetWidth, actualHeight = $tip[0].offsetHeight;
 38+ var gravity = (typeof this.options.gravity == 'function')
 39+ ? this.options.gravity.call(this.$element[0])
 40+ : this.options.gravity;
 41+
 42+ var tp;
 43+ switch (gravity.charAt(0)) {
 44+ case 'n':
 45+ tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2};
 46+ break;
 47+ case 's':
 48+ tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2};
 49+ break;
 50+ case 'e':
 51+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset};
 52+ break;
 53+ case 'w':
 54+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset};
 55+ break;
 56+ }
 57+
 58+ if (gravity.length == 2) {
 59+ if (gravity.charAt(1) == 'w') {
 60+ tp.left = pos.left + pos.width / 2 - 15;
 61+ } else {
 62+ tp.left = pos.left + pos.width / 2 - actualWidth + 15;
 63+ }
 64+ }
 65+
 66+ $tip.css(tp).addClass('tipsy-' + gravity);
 67+
 68+ if (this.options.fade) {
 69+ $tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity});
 70+ } else {
 71+ $tip.css({visibility: 'visible', opacity: this.options.opacity});
 72+ }
 73+ }
 74+ },
 75+
 76+ hide: function() {
 77+ if (this.options.fade) {
 78+ this.tip().stop().fadeOut(function() { $(this).remove(); });
 79+ } else {
 80+ this.tip().remove();
 81+ }
 82+ },
 83+
 84+ getTitle: function() {
 85+ var title, $e = this.$element, o = this.options;
 86+ fixTitle($e);
 87+ var title, o = this.options;
 88+ if (typeof o.title == 'string') {
 89+ title = $e.attr(o.title == 'title' ? 'original-title' : o.title);
 90+ } else if (typeof o.title == 'function') {
 91+ title = o.title.call($e[0]);
 92+ }
 93+ title = ('' + title).replace(/(^\s*|\s*$)/, "");
 94+ return title || o.fallback;
 95+ },
 96+
 97+ tip: function() {
 98+ if (!this.$tip) {
 99+ this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"/></div>');
 100+ }
 101+ return this.$tip;
 102+ },
 103+
 104+ validate: function() {
 105+ if (!this.$element[0].parentNode) this.hide();
 106+ },
 107+
 108+ enable: function() { this.enabled = true; },
 109+ disable: function() { this.enabled = false; },
 110+ toggleEnabled: function() { this.enabled = !this.enabled; }
 111+ };
 112+
 113+ $.fn.tipsy = function(options) {
 114+
 115+ if (options === true) {
 116+ return this.data('tipsy');
 117+ } else if (typeof options == 'string') {
 118+ return this.data('tipsy')[options]();
 119+ }
 120+
 121+ options = $.extend({}, $.fn.tipsy.defaults, options);
 122+
 123+ function get(ele) {
 124+ var tipsy = $.data(ele, 'tipsy');
 125+ if (!tipsy) {
 126+ tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options));
 127+ $.data(ele, 'tipsy', tipsy);
 128+ }
 129+ return tipsy;
 130+ }
 131+
 132+ function enter() {
 133+ var tipsy = get(this);
 134+ tipsy.hoverState = 'in';
 135+ if (options.delayIn == 0) {
 136+ tipsy.show();
 137+ } else {
 138+ setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn);
 139+ }
 140+ };
 141+
 142+ function leave() {
 143+ var tipsy = get(this);
 144+ tipsy.hoverState = 'out';
 145+ if (options.delayOut == 0) {
 146+ tipsy.hide();
 147+ } else {
 148+ setTimeout(function() { if (tipsy.hoverState == 'out') tipsy.hide(); }, options.delayOut);
 149+ }
 150+ };
 151+
 152+ if (!options.live) this.each(function() { get(this); });
 153+
 154+ if (options.trigger != 'manual') {
 155+ var binder = options.live ? 'live' : 'bind',
 156+ eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus',
 157+ eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur';
 158+ this[binder](eventIn, enter)[binder](eventOut, leave);
 159+ }
 160+
 161+ return this;
 162+
 163+ };
 164+
 165+ $.fn.tipsy.defaults = {
 166+ delayIn: 0,
 167+ delayOut: 0,
 168+ fade: false,
 169+ fallback: '',
 170+ gravity: 'n',
 171+ html: false,
 172+ live: false,
 173+ offset: 0,
 174+ opacity: 0.8,
 175+ title: 'title',
 176+ trigger: 'hover'
 177+ };
 178+
 179+ // Overwrite this method to provide options on a per-element basis.
 180+ // For example, you could store the gravity in a 'tipsy-gravity' attribute:
 181+ // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
 182+ // (remember - do not modify 'options' in place!)
 183+ $.fn.tipsy.elementOptions = function(ele, options) {
 184+ return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
 185+ };
 186+
 187+ $.fn.tipsy.autoNS = function() {
 188+ return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
 189+ };
 190+
 191+ $.fn.tipsy.autoWE = function() {
 192+ return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
 193+ };
 194+
 195+})(jQuery);
Property changes on: trunk/extensions/UploadWizard/UploadWizardJsModule/jquery/plugins/jquery.tipsy.js
___________________________________________________________________
Name: svn:eol-style
1196 + native
Index: trunk/extensions/UploadWizard/UploadWizardJsModule/loader.js
@@ -13,15 +13,16 @@
1414 mw.addClassFilePaths( {
1515 "mw.LanguageUpWiz" : "mw.LanguageUpWiz.js",
1616 "mw.UploadWizard" : "mw.UploadWizard.js",
17 - "mw.style.uploadWizard" : "css/uploadWizard.css",
 17+ "mw.style.uploadWizard" : "css/uploadWizard.css",
1818
1919 "mw.UploadApiProcessor" : "mw.UploadApiProcessor.js",
2020 "mw.IframeTransport" : "mw.IframeTransport.js",
2121 "mw.ApiUploadHandler" : "mw.ApiUploadHandler.js",
2222 "mw.DestinationChecker" : "mw.DestinationChecker.js",
2323
24 - "mw.MockUploadHandler" : "mw.MockUploadHandler.js"
25 -
 24+ "mw.MockUploadHandler" : "mw.MockUploadHandler.js",
 25+ "$j.fn.tipsy" : "jquery/plugins/jquery.tipsy.js",
 26+ "mw.style.tipsy" : "css/jquery.tipsy.css"
2627 });
2728
2829 //Set a variable for the base upload interface for easy inclution
Index: trunk/extensions/UploadWizard/UploadWizardJsModule/css/jquery.tipsy.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/UploadWizard/UploadWizardJsModule/css/jquery.tipsy.gif
___________________________________________________________________
Name: svn:mime-type
2930 + application/octet-stream
Index: trunk/extensions/UploadWizard/UploadWizardJsModule/css/jquery.tipsy.css
@@ -0,0 +1,12 @@
 2+.tipsy { padding: 5px; font-size: 10px; position: absolute; z-index: 100000; }
 3+ .tipsy-inner { padding: 5px 8px 4px 8px; background-color: black; color: white; max-width: 200px; text-align: center; }
 4+ .tipsy-inner { border-radius: 3px; -moz-border-radius:3px; -webkit-border-radius:3px; }
 5+ .tipsy-arrow { position: absolute; background: url('jquery.tipsy.gif') no-repeat top left; width: 9px; height: 5px; }
 6+ .tipsy-n .tipsy-arrow { top: 0; left: 50%; margin-left: -4px; }
 7+ .tipsy-nw .tipsy-arrow { top: 0; left: 10px; }
 8+ .tipsy-ne .tipsy-arrow { top: 0; right: 10px; }
 9+ .tipsy-s .tipsy-arrow { bottom: 0; left: 50%; margin-left: -4px; background-position: bottom left; }
 10+ .tipsy-sw .tipsy-arrow { bottom: 0; left: 10px; background-position: bottom left; }
 11+ .tipsy-se .tipsy-arrow { bottom: 0; right: 10px; background-position: bottom left; }
 12+ .tipsy-e .tipsy-arrow { top: 50%; margin-top: -4px; right: 0; width: 5px; height: 9px; background-position: top right; }
 13+ .tipsy-w .tipsy-arrow { top: 50%; margin-top: -4px; left: 0; width: 5px; height: 9px; }
Property changes on: trunk/extensions/UploadWizard/UploadWizardJsModule/css/jquery.tipsy.css
___________________________________________________________________
Name: svn:eol-style
114 + native

Status & tagging log