1010 * @class tinymce.core.JqueryIntegration
1111 * @private
1212 */
13- ! function ( ) { var f , c , u , s = [ ] , p = "undefined" != typeof global ? global : window , d = p . jQuery , v = function ( ) {
13+ ! function ( ) { function f ( ) {
1414// Reference to tinymce needs to be lazily evaluated since tinymce
1515// might be loaded through the compressor or other means
16- return p . tinymce } ; d . fn . tinymce = function ( o ) { var e , t , i , l = this , r = "" ;
16+ return d . tinymce } var p , c , u , s = [ ] , d = "undefined" != typeof global ? global : window , m = d . jQuery ; m . fn . tinymce = function ( o ) { var e , t , i , n , l = this , r = "" ;
1717// No match then just ignore the call
18- if ( ! l . length ) return l ;
18+ return l . length ?
1919// Get editor instance
20- if ( ! o ) return v ( ) ?v ( ) . get ( l [ 0 ] . id ) :null ; l . css ( "visibility" , "hidden" ) ; // Hide textarea to avoid flicker
21- var n , a = function ( ) { var a = [ ] , c = 0 ;
22- // Apply patches to the jQuery object, only once
23- u || ( m ( ) , u = ! 0 ) ,
24- // Create an editor instance for each matched node
25- l . each ( function ( e , t ) { var n , i = t . id , r = o . oninit ;
26- // Generate unique id for target element if needed
27- i || ( t . id = i = v ( ) . DOM . uniqueId ( ) ) ,
28- // Only init the editor once
29- v ( ) . get ( i ) || (
30- // Create editor instance and render it
31- n = v ( ) . createEditor ( i , o ) , a . push ( n ) , n . on ( "init" , function ( ) { var e , t = r ; l . css ( "visibility" , "" ) ,
32- // Run this if the oninit setting is defined
33- // this logic will fire the oninit callback ones each
34- // matched editor instance is initialized
35- r && ++ c == a . length && ( "string" == typeof t && ( e = - 1 === t . indexOf ( "." ) ?null :v ( ) . resolve ( t . replace ( / \. \w + $ / , "" ) ) , t = v ( ) . resolve ( t ) ) ,
36- // Call the oninit function with the object
37- t . apply ( e || v ( ) , a ) ) } ) ) } ) ,
38- // Render the editor instances in a separate loop since we
39- // need to have the full editors array used in the onInit calls
40- d . each ( a , function ( e , t ) { t . render ( ) } ) } ;
20+ o ?( l . css ( "visibility" , "hidden" ) ,
4121// Load TinyMCE on demand, if we need to
42- return p . tinymce || c || ! ( e = o . script_url ) ?
22+ d . tinymce || c || ! ( e = o . script_url ) ?
4323// Delay the init call until tinymce is loaded
44241 === c ?s . push ( a ) :a ( ) :( c = 1 , t = e . substring ( 0 , e . lastIndexOf ( "/" ) ) ,
4525// Check if it's a dev/src version they want to load then
@@ -48,45 +28,64 @@ return p.tinymce||c||!(e=o.script_url)?
4828// Setup tinyMCEPreInit object this will later be used by the TinyMCE
4929// core script to locate other resources like CSS files, dialogs etc
5030// You can also predefined a tinyMCEPreInit object and then it will use that instead
51- p . tinymce = p . tinyMCEPreInit || { base :t , suffix :r } ,
31+ d . tinymce = d . tinyMCEPreInit || { base :t , suffix :r } ,
5232// url contains gzip then we assume it's a compressor
5333- 1 != e . indexOf ( "gzip" ) && ( i = o . language || "en" , e = e + ( / \? / . test ( e ) ?"&" :"?" ) + "js=true&core=true&suffix=" + escape ( r ) + "&themes=" + escape ( o . theme || "modern" ) + "&plugins=" + escape ( o . plugins || "" ) + "&languages=" + ( i || "" ) ,
5434// Check if compressor script is already loaded otherwise setup a basic one
55- p . tinyMCE_GZ || ( p . tinyMCE_GZ = { start :function ( ) { var n = function ( e ) { v ( ) . ScriptLoader . markDone ( v ( ) . baseURI . toAbsolute ( e ) ) } ;
35+ d . tinyMCE_GZ || ( d . tinyMCE_GZ = { start :function ( ) { function n ( e ) { f ( ) . ScriptLoader . markDone ( f ( ) . baseURI . toAbsolute ( e ) ) }
5636// Add core languages
5737n ( "langs/" + i + ".js" ) ,
5838// Add themes with languages
5939n ( "themes/" + o . theme + "/theme" + r + ".js" ) , n ( "themes/" + o . theme + "/langs/" + i + ".js" ) ,
6040// Add plugins with languages
61- d . each ( o . plugins . split ( "," ) , function ( e , t ) { t && ( n ( "plugins/" + t + "/plugin" + r + ".js" ) , n ( "plugins/" + t + "/langs/" + i + ".js" ) ) } ) } , end :function ( ) { } } ) ) , ( n = document . createElement ( "script" ) ) . type = "text/javascript" , n . onload = n . onreadystatechange = function ( e ) { e = e || window . event , 2 === c || "load" != e . type && ! / c o m p l e t e | l o a d e d / . test ( n . readyState ) || ( v ( ) . dom . Event . domLoaded = 1 , c = 2 ,
41+ m . each ( o . plugins . split ( "," ) , function ( e , t ) { t && ( n ( "plugins/" + t + "/plugin" + r + ".js" ) , n ( "plugins/" + t + "/langs/" + i + ".js" ) ) } ) } , end :function ( ) { } } ) ) , ( n = document . createElement ( "script" ) ) . type = "text/javascript" , n . onload = n . onreadystatechange = function ( e ) { e = e || window . event , 2 === c || "load" != e . type && ! / c o m p l e t e | l o a d e d / . test ( n . readyState ) || ( f ( ) . dom . Event . domLoaded = 1 , c = 2 ,
6242// Execute callback after mainscript has been loaded and before the initialization occurs
63- o . script_loaded && o . script_loaded ( ) , a ( ) , d . each ( s , function ( e , t ) { t ( ) } ) ) } , n . src = e , document . body . appendChild ( n ) ) , l } ,
43+ o . script_loaded && o . script_loaded ( ) , a ( ) , m . each ( s , function ( e , t ) { t ( ) } ) ) } , n . src = e , document . body . appendChild ( n ) ) , l ) :f ( ) ?f ( ) . get ( l [ 0 ] . id ) :null :l ; function a ( ) { var a = [ ] , c = 0 ;
44+ // Apply patches to the jQuery object, only once
45+ u || ( v ( ) , u = ! 0 ) ,
46+ // Create an editor instance for each matched node
47+ l . each ( function ( e , t ) { var n , i = t . id , r = o . oninit ;
48+ // Generate unique id for target element if needed
49+ i || ( t . id = i = f ( ) . DOM . uniqueId ( ) ) ,
50+ // Only init the editor once
51+ f ( ) . get ( i ) || (
52+ // Create editor instance and render it
53+ n = f ( ) . createEditor ( i , o ) , a . push ( n ) , n . on ( "init" , function ( ) { var e , t = r ; l . css ( "visibility" , "" ) ,
54+ // Run this if the oninit setting is defined
55+ // this logic will fire the oninit callback ones each
56+ // matched editor instance is initialized
57+ r && ++ c == a . length && ( "string" == typeof t && ( e = - 1 === t . indexOf ( "." ) ?null :f ( ) . resolve ( t . replace ( / \. \w + $ / , "" ) ) , t = f ( ) . resolve ( t ) ) ,
58+ // Call the oninit function with the object
59+ t . apply ( e || f ( ) , a ) ) } ) ) } ) ,
60+ // Render the editor instances in a separate loop since we
61+ // need to have the full editors array used in the onInit calls
62+ m . each ( a , function ( e , t ) { t . render ( ) } ) } } ,
6463// Add :tinymce pseudo selector this will select elements that has been converted into editor instances
6564// it's now possible to use things like $('*:tinymce') to get all TinyMCE bound elements.
66- d . extend ( d . expr [ ":" ] , { tinymce :function ( e ) { var t ; return ! ! ( e . id && "tinymce" in p && ( t = v ( ) . get ( e . id ) ) && t . editorManager === v ( ) ) } } ) ;
65+ m . extend ( m . expr [ ":" ] , { tinymce :function ( e ) { var t ; return ! ! ( e . id && "tinymce" in d && ( t = f ( ) . get ( e . id ) ) && t . editorManager === f ( ) ) } } ) ;
6766// This function patches internal jQuery functions so that if
6867// you for example remove an div element containing an editor it's
6968// automatically destroyed by the TinyMCE API
70- var m = function ( ) {
71- // Removes any child editor instances by looking for editor wrapper elements
72- var r = function ( e ) {
69+ var v = function ( ) { function r ( e ) {
7370// If the function is remove
74- "remove" === e && this . each ( function ( e , t ) { var n = l ( t ) ; n && n . remove ( ) } ) , this . find ( "span.mceEditor,div.mceEditor" ) . each ( function ( e , t ) { var n = v ( ) . get ( t . id . replace ( / _ p a r e n t $ / , "" ) ) ; n && n . remove ( ) } ) } , o = function ( i ) { var e , t = this ;
71+ "remove" === e && this . each ( function ( e , t ) { var n = u ( t ) ; n && n . remove ( ) } ) , this . find ( "span.mceEditor,div.mceEditor" ) . each ( function ( e , t ) { var n = f ( ) . get ( t . id . replace ( / _ p a r e n t $ / , "" ) ) ; n && n . remove ( ) } ) } function o ( i ) { var e , t = this ;
7572// Handle set value
7673/*jshint eqnull:true */ if ( null != i ) r . call ( t ) ,
7774// Saves the contents before get/set value of textarea/div
78- t . each ( function ( e , t ) { var n ; ( n = v ( ) . get ( t . id ) ) && n . setContent ( i ) } ) ; else if ( 0 < t . length && ( e = v ( ) . get ( t [ 0 ] . id ) ) ) return e . getContent ( ) } , l = function ( e ) { var t = null ; return e && e . id && p . tinymce && ( t = v ( ) . get ( e . id ) ) , t } , u = function ( e ) { return ! ! ( e && e . length && p . tinymce && e . is ( ":tinymce" ) ) } , s = { } ;
75+ t . each ( function ( e , t ) { var n ; ( n = f ( ) . get ( t . id ) ) && n . setContent ( i ) } ) ; else if ( 0 < t . length && ( e = f ( ) . get ( t [ 0 ] . id ) ) ) return e . getContent ( ) } function l ( e ) { return e && e . length && d . tinymce && e . is ( ":tinymce" ) }
76+ // Removes any child editor instances by looking for editor wrapper elements
77+ var u = function ( e ) { var t = null ; return e && e . id && d . tinymce ?f ( ) . get ( e . id ) :t } , s = { } ;
7978// Loads or saves contents from/to textarea if the value
8079// argument is defined it will set the TinyMCE internal contents
8180// Patch some setter/getter functions these will
8281// now be able to set/get the contents of editor instances for
8382// example $('#editorid').html('Content'); will update the TinyMCE iframe instance
84- d . each ( [ "text" , "html" , "val" ] , function ( e , t ) { var a = s [ t ] = d . fn [ t ] , c = "text" === t ; d . fn [ t ] = function ( e ) { var t = this ; if ( ! u ( t ) ) return a . apply ( t , arguments ) ; if ( e !== f ) return o . call ( t . filter ( ":tinymce" ) , e ) , a . apply ( t . not ( ":tinymce" ) , arguments ) , t ; // return original set for chaining
85- var i = "" , r = arguments ; return ( c ?t :t . eq ( 0 ) ) . each ( function ( e , t ) { var n = l ( t ) ; i += n ?c ?n . getContent ( ) . replace ( / < (?: " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ ' " > ] ) * > / g, "" ) :n . getContent ( { save :! 0 } ) :a . apply ( d ( t ) , r ) } ) , i } } ) ,
83+ m . each ( [ "text" , "html" , "val" ] , function ( e , t ) { var a = s [ t ] = m . fn [ t ] , c = "text" === t ; m . fn [ t ] = function ( e ) { var t = this ; if ( ! l ( t ) ) return a . apply ( t , arguments ) ; if ( e !== p ) return o . call ( t . filter ( ":tinymce" ) , e ) , a . apply ( t . not ( ":tinymce" ) , arguments ) , t ; // return original set for chaining
84+ var i = "" , r = arguments ; return ( c ?t :t . eq ( 0 ) ) . each ( function ( e , t ) { var n = u ( t ) ; i += n ?c ?n . getContent ( ) . replace ( / < (?: " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ ' " > ] ) * > / g, "" ) :n . getContent ( { save :! 0 } ) :a . apply ( m ( t ) , r ) } ) , i } } ) ,
8685// Makes it possible to use $('#id').append("content"); to append contents to the TinyMCE editor iframe
87- d . each ( [ "append" , "prepend" ] , function ( e , t ) { var n = s [ t ] = d . fn [ t ] , r = "prepend" === t ; d . fn [ t ] = function ( i ) { var e = this ; return u ( e ) ?i !== f ?( "string" == typeof i && e . filter ( ":tinymce" ) . each ( function ( e , t ) { var n = l ( t ) ; n && n . setContent ( r ?i + n . getContent ( ) :n . getContent ( ) + i ) } ) , n . apply ( e . not ( ":tinymce" ) , arguments ) , e ) :void 0 :n . apply ( e , arguments ) } } ) ,
86+ m . each ( [ "append" , "prepend" ] , function ( e , t ) { var n = s [ t ] = m . fn [ t ] , r = "prepend" === t ; m . fn [ t ] = function ( i ) { var e = this ; return l ( e ) ?i !== p ?( "string" == typeof i && e . filter ( ":tinymce" ) . each ( function ( e , t ) { var n = u ( t ) ; n && n . setContent ( r ?i + n . getContent ( ) :n . getContent ( ) + i ) } ) , n . apply ( e . not ( ":tinymce" ) , arguments ) , e ) :void 0 :n . apply ( e , arguments ) } } ) ,
8887// Makes sure that the editor instance gets properly destroyed when the parent element is removed
89- d . each ( [ "remove" , "replaceWith" , "replaceAll" , "empty" ] , function ( e , t ) { var n = s [ t ] = d . fn [ t ] ; d . fn [ t ] = function ( ) { return r . call ( this , t ) , n . apply ( this , arguments ) } } ) , s . attr = d . fn . attr ,
88+ m . each ( [ "remove" , "replaceWith" , "replaceAll" , "empty" ] , function ( e , t ) { var n = s [ t ] = m . fn [ t ] ; m . fn [ t ] = function ( ) { return r . call ( this , t ) , n . apply ( this , arguments ) } } ) , s . attr = m . fn . attr ,
9089// Makes sure that $('#tinymce_id').attr('value') gets the editors current HTML contents
91- d . fn . attr = function ( e , t ) { var n = this , i = arguments ; if ( ! e || "value" !== e || ! u ( n ) ) return s . attr . apply ( n , i ) ; if ( t !== f ) return o . call ( n . filter ( ":tinymce" ) , t ) , s . attr . apply ( n . not ( ":tinymce" ) , i ) , n ; // return original set for chaining
92- var r = n [ 0 ] , a = l ( r ) ; return a ?a . getContent ( { save :! 0 } ) :s . attr . apply ( d ( r ) , i ) } } } ( ) ;
90+ m . fn . attr = function ( e , t ) { var n = this , i = arguments ; if ( ! e || "value" !== e || ! l ( n ) ) return s . attr . apply ( n , i ) ; if ( t !== p ) return o . call ( n . filter ( ":tinymce" ) , t ) , s . attr . apply ( n . not ( ":tinymce" ) , i ) , n ; // return original set for chaining
91+ var r = n [ 0 ] , a = u ( r ) ; return a ?a . getContent ( { save :! 0 } ) :s . attr . apply ( m ( r ) , i ) } } } ( ) ;
0 commit comments