10
10
* @class tinymce.core.JqueryIntegration
11
11
* @private
12
12
*/
13
- ! function ( ) { var f , c , u , s = [ ] , p = "undefined" != typeof global ? global : window , d = p . jQuery , v = function ( ) {
13
+ ! function ( ) { function f ( ) {
14
14
// Reference to tinymce needs to be lazily evaluated since tinymce
15
15
// 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 = "" ;
17
17
// No match then just ignore the call
18
- if ( ! l . length ) return l ;
18
+ return l . length ?
19
19
// 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" ) ,
41
21
// 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 ) ?
43
23
// Delay the init call until tinymce is loaded
44
24
1 === c ?s . push ( a ) :a ( ) :( c = 1 , t = e . substring ( 0 , e . lastIndexOf ( "/" ) ) ,
45
25
// 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)?
48
28
// Setup tinyMCEPreInit object this will later be used by the TinyMCE
49
29
// core script to locate other resources like CSS files, dialogs etc
50
30
// 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 } ,
52
32
// url contains gzip then we assume it's a compressor
53
33
- 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 || "" ) ,
54
34
// 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 ) ) }
56
36
// Add core languages
57
37
n ( "langs/" + i + ".js" ) ,
58
38
// Add themes with languages
59
39
n ( "themes/" + o . theme + "/theme" + r + ".js" ) , n ( "themes/" + o . theme + "/langs/" + i + ".js" ) ,
60
40
// 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 ,
62
42
// 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 ( ) } ) } } ,
64
63
// Add :tinymce pseudo selector this will select elements that has been converted into editor instances
65
64
// 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 ( ) ) } } ) ;
67
66
// This function patches internal jQuery functions so that if
68
67
// you for example remove an div element containing an editor it's
69
68
// 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 ) {
73
70
// 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 ;
75
72
// Handle set value
76
73
/*jshint eqnull:true */ if ( null != i ) r . call ( t ) ,
77
74
// 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 = { } ;
79
78
// Loads or saves contents from/to textarea if the value
80
79
// argument is defined it will set the TinyMCE internal contents
81
80
// Patch some setter/getter functions these will
82
81
// now be able to set/get the contents of editor instances for
83
82
// 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 } } ) ,
86
85
// 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 ) } } ) ,
88
87
// 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 ,
90
89
// 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