Index: trunk/phase3/js2/mwEmbed/example_usage/Add_Media_Wizard.html |
— | — | @@ -11,9 +11,10 @@ |
12 | 12 | border:medium none; |
13 | 13 | } |
14 | 14 | </style> |
15 | | - <script type="text/javascript" src="../mv_embed.js?debug=true"></script> |
| 15 | + <!-- <script type="text/javascript" src="../mv_embed.js?debug=true"></script> --> |
| 16 | + <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mv_embed,remoteSearchDriver,$j.ui,$j.ui.resizable,$j.ui.draggable,$j.ui.dialog,$j.ui.tabs,$j.ui.sortable,$j.cookie,baseRemoteSearch&urid=1257728132531&debug=true&uselang=en"></script> |
16 | 17 | <script type="text/javascript"> |
17 | | - mwAddOnloadHook(function(){ |
| 18 | + js2AddOnloadHook(function(){ |
18 | 19 | $j('#add_media_link').addMediaWiz( { |
19 | 20 | 'profile':'html_edit', |
20 | 21 | 'target_textbox': '#wpTextbox1', |
Index: trunk/phase3/js2/mwEmbed/jquery/plugins/jquery.textSelection.js |
— | — | @@ -0,0 +1,323 @@ |
| 2 | +/** |
| 3 | + * These plugins provide extra functionality for interaction with textareas. |
| 4 | + */ |
| 5 | +( function( $ ) { $.fn.extend( { |
| 6 | +/** |
| 7 | + * Get the currently selected text in this textarea. Will focus the textarea |
| 8 | + * in some browsers (IE/Opera) |
| 9 | + */ |
| 10 | +textSelection: function() { |
| 11 | + var e = this.jquery ? this[0] : this; |
| 12 | + var retval = ''; |
| 13 | + if ( e.style.display == 'none' ) { |
| 14 | + // Do nothing |
| 15 | + } else if ( document.selection && document.selection.createRange ) { |
| 16 | + e.focus(); |
| 17 | + var range = document.selection.createRange(); |
| 18 | + retval = range.text; |
| 19 | + } else if ( e.selectionStart || e.selectionStart == '0' ) { |
| 20 | + retval = e.value.substring( e.selectionStart, e.selectionEnd ); |
| 21 | + } |
| 22 | + return retval; |
| 23 | +}, |
| 24 | +/** |
| 25 | + * Ported from skins/common/edit.js by Trevor Parscal |
| 26 | + * (c) 2009 Wikimedia Foundation (GPLv2) - http://www.wikimedia.org |
| 27 | + * |
| 28 | + * Inserts text at the begining and end of a text selection, optionally |
| 29 | + * inserting text at the caret when selection is empty. |
| 30 | + * |
| 31 | + * @param pre Text to insert before selection |
| 32 | + * @param peri Text to insert at caret if selection is empty |
| 33 | + * @param post Text to insert after selection |
| 34 | + * @param ownline If true, put the inserted text is on its own line |
| 35 | + * @param replace If true, replaces any selected text with peri; if false, peri is ignored and selected text is left alone |
| 36 | + */ |
| 37 | +encapsulateSelection: function( pre, peri, post, ownline, replace ) { |
| 38 | + return this.each( function() { |
| 39 | + /** |
| 40 | + * Check if the selected text is the same as the insert text |
| 41 | + */ |
| 42 | + function checkSelectedText() { |
| 43 | + if ( !selText ) { |
| 44 | + selText = peri; |
| 45 | + isSample = true; |
| 46 | + } else if ( replace ) { |
| 47 | + selText = peri; |
| 48 | + } else if ( selText.charAt( selText.length - 1 ) == ' ' ) { |
| 49 | + // Exclude ending space char |
| 50 | + selText = selText.substring(0, selText.length - 1); |
| 51 | + post += ' '; |
| 52 | + } |
| 53 | + } |
| 54 | + var selText = $(this).getSelection(); |
| 55 | + var isSample = false; |
| 56 | + if ( this.style.display == 'none' ) { |
| 57 | + // Do nothing |
| 58 | + } else if ( this.selectionStart || this.selectionStart == '0' ) { |
| 59 | + // Mozilla/Opera |
| 60 | + $(this).focus(); |
| 61 | + var startPos = this.selectionStart; |
| 62 | + var endPos = this.selectionEnd; |
| 63 | + checkSelectedText(); |
| 64 | + if ( ownline ) { |
| 65 | + if ( startPos != 0 && this.value.charAt( startPos - 1 ) != "\n" ) { |
| 66 | + pre = "\n" + pre; |
| 67 | + } |
| 68 | + if ( this.value.charAt( endPos ) != "\n" ) { |
| 69 | + post += "\n"; |
| 70 | + } |
| 71 | + } |
| 72 | + this.value = this.value.substring( 0, startPos ) + pre + selText + post + this.value.substring( endPos, this.value.length ); |
| 73 | + if ( window.opera ) { |
| 74 | + pre = pre.replace( /\r?\n/g, "\r\n" ); |
| 75 | + selText = selText.replace( /\r?\n/g, "\r\n" ); |
| 76 | + post = post.replace( /\r?\n/g, "\r\n" ); |
| 77 | + } |
| 78 | + if ( isSample ) { |
| 79 | + this.selectionStart = startPos + pre.length; |
| 80 | + this.selectionEnd = startPos + pre.length + selText.length; |
| 81 | + } else { |
| 82 | + this.selectionStart = startPos + pre.length + selText.length + post.length; |
| 83 | + this.selectionEnd = this.selectionStart; |
| 84 | + } |
| 85 | + } else if ( document.selection && document.selection.createRange ) { |
| 86 | + // IE |
| 87 | + $(this).focus(); |
| 88 | + var range = document.selection.createRange(); |
| 89 | + if ( ownline && range.moveStart ) { |
| 90 | + var range2 = document.selection.createRange(); |
| 91 | + range2.collapse(); |
| 92 | + range2.moveStart( 'character', -1 ); |
| 93 | + // FIXME: Which check is correct? |
| 94 | + if ( range2.text != "\r" && range2.text != "\n" && range2.text != "" ) { |
| 95 | + pre = "\n" + pre; |
| 96 | + } |
| 97 | + var range3 = document.selection.createRange(); |
| 98 | + range3.collapse( false ); |
| 99 | + range3.moveEnd( 'character', 1 ); |
| 100 | + if ( range3.text != "\r" && range3.text != "\n" && range3.text != "" ) { |
| 101 | + post += "\n"; |
| 102 | + } |
| 103 | + } |
| 104 | + checkSelectedText(); |
| 105 | + range.text = pre + selText + post; |
| 106 | + if ( isSample && range.moveStart ) { |
| 107 | + range.moveStart( 'character', - post.length - selText.length ); |
| 108 | + range.moveEnd( 'character', - post.length ); |
| 109 | + } |
| 110 | + range.select(); |
| 111 | + } |
| 112 | + // Scroll the textarea to the inserted text |
| 113 | + $(this).scrollToCaretPosition(); |
| 114 | + $(this).trigger( 'encapsulateSelection', [ pre, peri, post, ownline, replace ] ); |
| 115 | + }); |
| 116 | +}, |
| 117 | +/** |
| 118 | + * Ported from Wikia's LinkSuggest extension |
| 119 | + * https://svn.wikia-code.com/wikia/trunk/extensions/wikia/LinkSuggest |
| 120 | + * Some code copied from |
| 121 | + * http://www.dedestruct.com/2008/03/22/howto-cross-browser-cursor-position-in-textareas/ |
| 122 | + * |
| 123 | + * Get the position (in resolution of bytes not nessecarily characters) |
| 124 | + * in a textarea |
| 125 | + */ |
| 126 | + getCaretPosition: function( startAndEnd ) { |
| 127 | + function getCaret( e ) { |
| 128 | + var caretPos = 0, endPos = 0; |
| 129 | + if ( $.browser.msie ) { |
| 130 | + // IE Support |
| 131 | + var postFinished = false; |
| 132 | + var periFinished = false; |
| 133 | + var postFinished = false; |
| 134 | + var preText, rawPreText, periText; |
| 135 | + var rawPeriText, postText, rawPostText; |
| 136 | + // Create range containing text in the selection |
| 137 | + var periRange = document.selection.createRange().duplicate(); |
| 138 | + // Create range containing text before the selection |
| 139 | + var preRange = document.body.createTextRange(); |
| 140 | + // Select all the text |
| 141 | + preRange.moveToElementText(e); |
| 142 | + // Move the end where we need it |
| 143 | + preRange.setEndPoint("EndToStart", periRange); |
| 144 | + // Create range containing text after the selection |
| 145 | + var postRange = document.body.createTextRange(); |
| 146 | + // Select all the text |
| 147 | + postRange.moveToElementText(e); |
| 148 | + // Move the start where we need it |
| 149 | + postRange.setEndPoint("StartToEnd", periRange); |
| 150 | + // Load the text values we need to compare |
| 151 | + preText = rawPreText = preRange.text; |
| 152 | + periText = rawPeriText = periRange.text; |
| 153 | + postText = rawPostText = postRange.text; |
| 154 | + /* |
| 155 | + * Check each range for trimmed newlines by shrinking the range by 1 |
| 156 | + * character and seeing if the text property has changed. If it has |
| 157 | + * not changed then we know that IE has trimmed a \r\n from the end. |
| 158 | + */ |
| 159 | + do { |
| 160 | + if ( !postFinished ) { |
| 161 | + if ( preRange.compareEndPoints( "StartToEnd", preRange ) == 0 ) { |
| 162 | + postFinished = true; |
| 163 | + } else { |
| 164 | + preRange.moveEnd( "character", -1 ) |
| 165 | + if ( preRange.text == preText ) { |
| 166 | + rawPreText += "\r\n"; |
| 167 | + } else { |
| 168 | + postFinished = true; |
| 169 | + } |
| 170 | + } |
| 171 | + } |
| 172 | + if ( !periFinished ) { |
| 173 | + if ( periRange.compareEndPoints( "StartToEnd", periRange ) == 0 ) { |
| 174 | + periFinished = true; |
| 175 | + } else { |
| 176 | + periRange.moveEnd( "character", -1 ) |
| 177 | + if ( periRange.text == periText ) { |
| 178 | + rawPeriText += "\r\n"; |
| 179 | + } else { |
| 180 | + periFinished = true; |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | + if ( !postFinished ) { |
| 185 | + if ( postRange.compareEndPoints("StartToEnd", postRange) == 0 ) { |
| 186 | + postFinished = true; |
| 187 | + } else { |
| 188 | + postRange.moveEnd( "character", -1 ) |
| 189 | + if ( postRange.text == postText ) { |
| 190 | + rawPostText += "\r\n"; |
| 191 | + } else { |
| 192 | + postFinished = true; |
| 193 | + } |
| 194 | + } |
| 195 | + } |
| 196 | + } while ( ( !postFinished || !periFinished || !postFinished ) ); |
| 197 | + caretPos = rawPreText.replace( /\r\n/g, "\n" ).length; |
| 198 | + endPos = caretPos + rawPeriText.replace( /\r\n/g, "\n" ).length; |
| 199 | + } else if ( e.selectionStart || e.selectionStart == '0' ) { |
| 200 | + // Firefox support |
| 201 | + caretPos = e.selectionStart; |
| 202 | + endPos = e.selectionEnd; |
| 203 | + } |
| 204 | + return startAndEnd ? [ caretPos, endPos ] : caretPos; |
| 205 | + } |
| 206 | + return getCaret( this.get( 0 ) ); |
| 207 | +}, |
| 208 | +setSelection: function( start, end ) { |
| 209 | + if ( typeof end == 'undefined' ) |
| 210 | + end = start; |
| 211 | + return this.each( function() { |
| 212 | + if ( this.selectionStart || this.selectionStart == '0' ) { |
| 213 | + // Opera 9.0 doesn't allow setting selectionStart past |
| 214 | + // selectionEnd; any attempts to do that will be ignored |
| 215 | + // Make sure to set them in the right order |
| 216 | + if ( start > this.selectionEnd ) { |
| 217 | + this.selectionEnd = end; |
| 218 | + this.selectionStart = start; |
| 219 | + } else { |
| 220 | + this.selectionStart = start; |
| 221 | + this.selectionEnd = end; |
| 222 | + } |
| 223 | + } else if ( document.body.createTextRange ) { |
| 224 | + var selection = document.body.createTextRange(); |
| 225 | + selection.moveToElementText( this ); |
| 226 | + var length = selection.text.length; |
| 227 | + selection.moveStart( 'character', start ); |
| 228 | + selection.moveEnd( 'character', -length + end ); |
| 229 | + selection.select(); |
| 230 | + } |
| 231 | + }); |
| 232 | +}, |
| 233 | +/** |
| 234 | + * Ported from Wikia's LinkSuggest extension |
| 235 | + * https://svn.wikia-code.com/wikia/trunk/extensions/wikia/LinkSuggest |
| 236 | + * |
| 237 | + * Scroll a textarea to the current cursor position. You can set the cursor |
| 238 | + * position with setSelection() |
| 239 | + * @param force boolean Whether to force a scroll even if the caret position |
| 240 | + * is already visible. Defaults to false |
| 241 | + */ |
| 242 | +scrollToCaretPosition: function( force ) { |
| 243 | + function getLineLength( e ) { |
| 244 | + return Math.floor( e.scrollWidth / ( $.os.name == 'linux' ? 7 : 8 ) ); |
| 245 | + } |
| 246 | + function getCaretScrollPosition( e ) { |
| 247 | + // FIXME: This functions sucks and is off by a few lines most |
| 248 | + // of the time. It should be replaced by something decent. |
| 249 | + var text = e.value.replace( /\r/g, "" ); |
| 250 | + var caret = $( e ).getCaretPosition(); |
| 251 | + var lineLength = getLineLength( e ); |
| 252 | + var row = 0; |
| 253 | + var charInLine = 0; |
| 254 | + var lastSpaceInLine = 0; |
| 255 | + for ( i = 0; i < caret; i++ ) { |
| 256 | + charInLine++; |
| 257 | + if ( text.charAt( i ) == " " ) { |
| 258 | + lastSpaceInLine = charInLine; |
| 259 | + } else if ( text.charAt( i ) == "\n" ) { |
| 260 | + lastSpaceInLine = 0; |
| 261 | + charInLine = 0; |
| 262 | + row++; |
| 263 | + } |
| 264 | + if ( charInLine > lineLength ) { |
| 265 | + if ( lastSpaceInLine > 0 ) { |
| 266 | + charInLine = charInLine - lastSpaceInLine; |
| 267 | + lastSpaceInLine = 0; |
| 268 | + row++; |
| 269 | + } |
| 270 | + } |
| 271 | + } |
| 272 | + var nextSpace = 0; |
| 273 | + for ( j = caret; j < caret + lineLength; j++ ) { |
| 274 | + if ( |
| 275 | + text.charAt( j ) == " " || |
| 276 | + text.charAt( j ) == "\n" || |
| 277 | + caret == text.length |
| 278 | + ) { |
| 279 | + nextSpace = j; |
| 280 | + break; |
| 281 | + } |
| 282 | + } |
| 283 | + if ( nextSpace > lineLength && caret <= lineLength ) { |
| 284 | + charInLine = caret - lastSpaceInLine; |
| 285 | + row++; |
| 286 | + } |
| 287 | + return ( $.os.name == 'mac' ? 13 : ( $.os.name == 'linux' ? 15 : 16 ) ) * row; |
| 288 | + } |
| 289 | + return this.each(function() { |
| 290 | + if ( this.selectionStart || this.selectionStart == '0' ) { |
| 291 | + // Mozilla |
| 292 | + var scroll = getCaretScrollPosition( this ); |
| 293 | + if ( force || scroll < $(this).scrollTop() || |
| 294 | + scroll > $(this).scrollTop() + $(this).height() ) |
| 295 | + $(this).scrollTop( scroll ); |
| 296 | + } else if ( document.selection && document.selection.createRange ) { |
| 297 | + // IE / Opera |
| 298 | + /* |
| 299 | + * IE automatically scrolls the selected text to the |
| 300 | + * bottom of the textarea at range.select() time, except |
| 301 | + * if it was already in view and the cursor position |
| 302 | + * wasn't changed, in which case it does nothing. To |
| 303 | + * cover that case, we'll force it to act by moving one |
| 304 | + * character back and forth. |
| 305 | + */ |
| 306 | + var range = document.selection.createRange(); |
| 307 | + var pos = $(this).getCaretPosition(); |
| 308 | + var oldScrollTop = this.scrollTop; |
| 309 | + range.moveToElementText( this ); |
| 310 | + range.collapse(); |
| 311 | + range.move( 'character', pos + 1); |
| 312 | + range.select(); |
| 313 | + if ( this.scrollTop != oldScrollTop ) |
| 314 | + this.scrollTop += range.offsetTop; |
| 315 | + else if ( force ) { |
| 316 | + range.move( 'character', -1 ); |
| 317 | + range.select(); |
| 318 | + } |
| 319 | + } |
| 320 | + $(this).trigger( 'scrollToPosition' ); |
| 321 | + } ); |
| 322 | +} |
| 323 | + |
| 324 | +} ); } )( jQuery ); |
\ No newline at end of file |
Index: trunk/phase3/js2/mwEmbed/jquery/jquery.ui/ui/ui.core.js |
— | — | @@ -516,4 +516,4 @@ |
517 | 517 | delay: 0 |
518 | 518 | }; |
519 | 519 | |
520 | | -})(jQuery); |
| 520 | +})(jQuery); |
\ No newline at end of file |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js |
— | — | @@ -257,10 +257,6 @@ |
258 | 258 | //@@todo for cleaner config we should set _this.opt to the provided options) |
259 | 259 | $j.extend( _this, default_remote_search_options, options); |
260 | 260 | |
261 | | - //update the base text: |
262 | | - if(_this.target_textbox) |
263 | | - _this.getTexboxSelection(); |
264 | | - |
265 | 261 | //modify the content provider config based on options: |
266 | 262 | for(var i in this.content_providers){ |
267 | 263 | if( _this.enabled_cps == 'all' && !this.disp_item ){ |
— | — | @@ -460,6 +456,10 @@ |
461 | 457 | }, |
462 | 458 | doInitDisplay:function(){ |
463 | 459 | var _this = this; |
| 460 | + |
| 461 | + //try and get the text selection: |
| 462 | + _this.getTexboxSelection(); |
| 463 | + |
464 | 464 | //setup the parent container: |
465 | 465 | this.init_modal(); |
466 | 466 | //fill in the html: |
— | — | @@ -479,54 +479,30 @@ |
480 | 480 | var _this = this; |
481 | 481 | js_log("doReDisplay::"); |
482 | 482 | //update the base text: |
483 | | - if( _this.target_textbox ) |
484 | | - _this.getTexboxSelection(); |
| 483 | + _this.getTexboxSelection(); |
| 484 | + if( _this.default_query != $j('#rsd_q').val() ){ |
| 485 | + $j('#rsd_q').val( _this.default_query ); |
| 486 | + _this.runSearch(); |
| 487 | + } |
485 | 488 | //$j(_this.target_container).dialog("open"); |
486 | 489 | $j(_this.target_container).parents('.ui-dialog').fadeIn('slow'); |
487 | 490 | //re-center the dialog: |
488 | 491 | $j(_this.target_container).dialog('option', 'position','center'); |
489 | 492 | }, |
490 | 493 | //gets the in and out points for insert position or grabs the selected text for search |
491 | | - getTexboxSelection:function(){ |
492 | | - //update the caretPos |
493 | | - this.getCaretPos(); |
494 | | - |
495 | | - //if we have highlighted text use that as the query: (would be fun to add context menu once we have rich editor in-place) |
496 | | - if( this.caret_pos.selection ) |
497 | | - this.default_query = this.caret_pos.selection |
498 | | - |
499 | | - }, |
500 | | - getCaretPos:function(){ |
501 | | - this.caret_pos={}; |
502 | | - var txtarea = $j(this.target_textbox).get(0); |
503 | | - var getTextCusorStartPos = function (o){ |
504 | | - if (o.createTextRange) { |
505 | | - var r = document.selection.createRange().duplicate() |
506 | | - r.moveEnd('character', o.value.length) |
507 | | - if (r.text == '') return o.value.length |
508 | | - return o.value.lastIndexOf(r.text) |
509 | | - } else return o.selectionStart |
510 | | - } |
511 | | - var getTextCusorEndPos = function (o){ |
512 | | - if (o.createTextRange) { |
513 | | - var r = document.selection.createRange().duplicate(); |
514 | | - r.moveStart('character', -o.value.length); |
515 | | - return r.text.length; |
516 | | - } else{ |
517 | | - return o.selectionEnd |
| 494 | + getTexboxSelection:function(){ |
| 495 | + if(this.target_textbox){ |
| 496 | + //get the selection text: |
| 497 | + var ts = $j(this.target_textbox).textSelection(); |
| 498 | + if(ts!=''){ |
| 499 | + this.default_query = ts; |
518 | 500 | } |
| 501 | + //get the caretPos / value |
| 502 | + this.caret_pos={}; |
| 503 | + this.caret_pos.text = $j(this.target_textbox).val(); |
| 504 | + this.caret_pos.s = $j(this.target_textbox).getCaretPosition(); |
519 | 505 | } |
520 | | - this.caret_pos.s = getTextCusorStartPos( txtarea ); |
521 | | - this.caret_pos.e = getTextCusorEndPos( txtarea ); |
522 | | - this.caret_pos.text = txtarea.value; |
523 | | - if(this.caret_pos.s && this.caret_pos.e && |
524 | | - (this.caret_pos.s != this.caret_pos.e)) |
525 | | - this.caret_pos.selection = this.caret_pos.text.substring(this.caret_pos.s, this.caret_pos.e).replace(/ /g, '\xa0') || '\xa0'; |
526 | | - |
527 | | - js_log('got caret_pos:' + this.caret_pos.s); |
528 | | - //restore text value: (creating textRanges sometimes screws with the text content) |
529 | | - $j(this.target_textbox).val( this.caret_pos.text ); |
530 | | - }, |
| 506 | + }, |
531 | 507 | init_modal:function(){ |
532 | 508 | js_log("init_modal"); |
533 | 509 | var _this = this; |
Index: trunk/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -88,6 +88,7 @@ |
89 | 89 | "$j.cookie" : "jquery/plugins/jquery.cookie.js", |
90 | 90 | "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", |
91 | 91 | "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", |
| 92 | + "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
92 | 93 | |
93 | 94 | "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", |
94 | 95 | "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", |
— | — | @@ -1004,13 +1005,14 @@ |
1005 | 1006 | * checks for jQuery and adds the $j noConflict var |
1006 | 1007 | */ |
1007 | 1008 | jQueryCheck: function( callback ) { |
1008 | | - js_log( 'jQueryCheck::' ); |
| 1009 | + //js_log( 'jQueryCheck::' ); |
| 1010 | + var _this = this; |
1009 | 1011 | // Skip stuff if $j is already loaded: |
1010 | 1012 | if( _global['$j'] && callback ){ |
1011 | 1013 | callback(); |
1012 | | - return ; |
1013 | | - } |
1014 | | - var _this = this; |
| 1014 | + if( _this.jQuerySetupFlag ) |
| 1015 | + return ; |
| 1016 | + } |
1015 | 1017 | // Load jQuery |
1016 | 1018 | _this.doLoad([ |
1017 | 1019 | 'window.jQuery' |
— | — | @@ -1020,7 +1022,7 @@ |
1021 | 1023 | _global['$j'] = jQuery.noConflict(); |
1022 | 1024 | } |
1023 | 1025 | if( _this.jQuerySetupFlag == false){ |
1024 | | - js_log('setup mv_embed jQuery bindings'); |
| 1026 | + //js_log('setup mv_embed jQuery bindings'); |
1025 | 1027 | //setup our global settings using the (jQuery helper) |
1026 | 1028 | |
1027 | 1029 | // Set up the skin path |
— | — | @@ -1104,8 +1106,10 @@ |
1105 | 1107 | }, |
1106 | 1108 | runReadyEvents: function() { |
1107 | 1109 | js_log( "runReadyEvents" ); |
1108 | | - while( this.onReadyEvents.length ) { |
1109 | | - this.onReadyEvents.shift()(); |
| 1110 | + while( this.onReadyEvents.length ) { |
| 1111 | + var func = this.onReadyEvents.shift(); |
| 1112 | + //js_log('run onReady:: ' + func ); |
| 1113 | + func(); |
1110 | 1114 | } |
1111 | 1115 | } |
1112 | 1116 | } |
— | — | @@ -1172,15 +1176,16 @@ |
1173 | 1177 | |
1174 | 1178 | //js2AddOnloadHook: ensure jQuery and the DOM are ready |
1175 | 1179 | function js2AddOnloadHook( func ) { |
1176 | | - //js_log('js2AddOnloadHook::' ); |
1177 | | - // If we have already run the DOM-ready function, just run the function directly: |
1178 | | - if( mvJsLoader.doneReadyEvents ) { |
1179 | | - func(); |
1180 | | - } else { |
1181 | | - mvJsLoader.jQueryCheck( function() { |
| 1180 | + //js_log('js2AddOnloadHook:: jquery:' + typeof window.jQuery + ' $j: ' + typeof $j); |
| 1181 | + //check for jQuery then add the load event (to run after video tag rewrites (if present) |
| 1182 | + mvJsLoader.jQueryCheck( function() { |
| 1183 | + if( mvJsLoader.doneReadyEvents ) { |
| 1184 | + //js_log('run queued event: ' + func); |
| 1185 | + func(); |
| 1186 | + } else { |
1182 | 1187 | mvJsLoader.addLoadEvent( func ); |
1183 | | - }) |
1184 | | - } |
| 1188 | + } |
| 1189 | + }); |
1185 | 1190 | } |
1186 | 1191 | // Deprecated mwAddOnloadHook in favor of js2 naming (for clear separation of js2 code from old MW code |
1187 | 1192 | var mwAddOnloadHook = js2AddOnloadHook; |
— | — | @@ -1302,6 +1307,7 @@ |
1303 | 1308 | mvJsLoader.doLoadDepMode([ |
1304 | 1309 | [ 'remoteSearchDriver', |
1305 | 1310 | '$j.cookie', |
| 1311 | + '$j.fn.textSelection', |
1306 | 1312 | '$j.ui' |
1307 | 1313 | ],[ |
1308 | 1314 | '$j.ui.resizable', |
Index: trunk/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js |
— | — | @@ -1726,7 +1726,7 @@ |
1727 | 1727 | //@@todo support position config |
1728 | 1728 | var loc = $j(this).position(); |
1729 | 1729 | if($j('#metaBox_'+this.id).length==0){ |
1730 | | - var theight = (parseInt( this.height ) < 200) ? 200 : this.height; |
| 1730 | + var theight = (parseInt( this.height ) < 200) ? 200 : parseInt( this.height ); |
1731 | 1731 | $j(this).after('<div class="ui-widget ui-widget-content ui-corner-all" style="position:absolute;z-index:10;'+ |
1732 | 1732 | 'top:' + (loc.top) + 'px;' + |
1733 | 1733 | 'left:' + (parseInt( loc.left ) + parseInt(this.width) + 10 ) + 'px;' + |
Index: trunk/phase3/js2/remoteMwEmbed.js |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | |
7 | 7 | var urlparts = getRemoteEmbedPath(); |
8 | 8 | var mwEmbedHostPath = urlparts[0]; |
9 | | -var mwRemoteVersion = '1.0'; |
| 9 | +var mwRemoteVersion = '1.02'; |
10 | 10 | |
11 | 11 | reqArguments = urlparts[1]; |
12 | 12 | |
Index: trunk/phase3/js2/editPage.js |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | ); |
48 | 48 | } |
49 | 49 | //add to old toolbar if wikiEditor did not remove '#toolbar' from the page: |
50 | | - setTimeout(function(){ |
| 50 | + setTimeout(function(){ |
51 | 51 | if( $j('#btn-add-media-wiz').length == 0 && $j( '#toolbar' ).length != 0 ){ |
52 | 52 | $j( '#toolbar' ).append( '<img style="cursor:pointer" id="btn-add-media-wiz" src="' + |
53 | 53 | mv_skin_img_path + 'Button_add_media.png">' ); |