{"version":3,"sources":["jquery.dirtyforms.helpers.tinymce.min.js"],"names":["$","window","document","undefined","tinymceSelector","ignoreSelector","tinymce","isDirty","$node","hasTinyMCE","filter","add","find","each","$field","this","data","content","getTinyMceContent","hash","getHashCode","originalHash","setClean","isNotDirty","storeOriginalValue","rescan","ignoreAnchorSelector","DirtyForms","helpers","push","length","e","getContent","format","replace","init","bind","ev","$form","target","$editor","append","oninit","str","i","chr","len","charCodeAt","jQuery"],"mappings":";;;;;CAMA,SAAUA,EAAGC,EAAQC,EAAUC,GAQ3B,GAAIC,GAAkB,kCAClBC,EAAiB,yCAGjBC,GAEAD,eAAgBA,EAChBE,QAAS,SAAUC,GACf,GAAID,IAAU,CAkCd,OAjCIE,GAAWD,IAEXA,EAAME,OAAON,GAAiBO,IAAIH,EAAMI,KAAKR,IAAkBS,KAAK,WAChE,GAAIC,GAASd,EAAEe,KAGf,IAA8C,mBAAnCD,GAAOE,KAAK,oBAGnB,GAAIF,EAAOR,UAAUC,UAIjB,MAHAA,IAAU,GAGH,MAER,CAEH,GAAIU,GAAUC,EAAkBJ,GAE5BK,EAAOC,EAAYH,GAEnBI,EAAeP,EAAOE,KAAK,kBAG/B,IAAIG,IAASE,EAIT,MAHAd,IAAU,GAGH,KAKhBA,GAEXe,SAAU,SAAUd,GACZC,EAAWD,IAGXA,EAAME,OAAON,GAAiBO,IAAIH,EAAMI,KAAKR,IAAkBS,KAAK,WAChE,GAAIC,GAASd,EAAEe,KAGXD,GAAOR,UAAUC,YAEjBO,EAAOR,UAAUiB,WAAa,GAIlCC,EAAmBV,MAI/BW,OAAQ,SAAUjB,GACVC,EAAWD,IACXA,EAAME,OAAON,GAAiBO,IAAIH,EAAMI,KAAKR,IAAkBS,KAAK,WAChE,GAAIC,GAASd,EAAEe,KAE+B,oBAAnCD,GAAOE,KAAK,oBACnBQ,EAAmBV,MAOnCY,qBAAsBrB,EAI1BL,GAAE2B,WAAWC,QAAQC,KAAKvB,EAI1B,IAAIG,GAAa,SAAUD,GACvB,IACI,MAAOA,GAAME,OAAON,GAAiB0B,OAAS,GAAKtB,EAAMI,KAAKR,GAAiB0B,OAAS,EAE5F,MAAOC,GACH,OAAO,IAIXb,EAAoB,SAAUJ,GAE9B,MAAOA,GAAOR,UAAU0B,YAAaC,OAAQ,QAASC,QAAQ,cAAe,SAG7EV,EAAqB,SAAUV,GAC/B,GAAIG,GAAUC,EAAkBJ,GAG5BK,EAAOC,EAAYH,EAGvBH,GAAOE,KAAK,kBAAmBG,IAI/BgB,EAAO,SAAU3B,GACbC,EAAWD,IACXA,EAAME,OAAON,GAAiBO,IAAIH,EAAMI,KAAKR,IAAkBS,KAAK,WAChEW,EAAmBxB,EAAEe,SAKjCf,GAAEE,GAAUkC,KAAK,kBAAmB,SAAUC,GAK1C,GAAIC,GAAQtC,EAAEqC,EAAGE,QACbC,EAAUxC,EAAE,6DAChBsC,GAAMG,OAAOD,GACbA,EAAQlC,SACJoC,OAAQ,WACJP,EAAKG,OAMjB,IAAIlB,GAAc,SAAUuB,GACxB,GAAcC,GAAGC,EAAKC,EAAlB3B,EAAO,CACX,IAAmB,IAAfwB,EAAIb,OAAc,MAAOX,EAC7B,KAAKyB,EAAI,EAAGE,EAAMH,EAAIb,OAAYgB,EAAJF,EAASA,IACnCC,EAAMF,EAAII,WAAWH,GACrBzB,GAASA,GAAQ,GAAKA,EAAQ0B,EAC9B1B,GAAQ,CAEZ,OAAOA,KAGZ6B,OAAQ/C,OAAQC","file":"jquery.dirtyforms.helpers.tinymce.min.js","sourceRoot":"/","sourcesContent":["/*!\nTinyMCE helper module (for jQuery Dirty Forms) | v2.0.0-beta00007 | github.com/snikch/jquery.dirtyforms\n(c) 2015 Mal Curtis\nLicense MIT\n*/\n\n(function($, window, document, undefined) {\n // Can't use ECMAScript 5's strict mode because several apps \n // including ASP.NET trace the stack via arguments.caller.callee \n // and Firefox dies if you try to trace through \"use strict\" call chains. \n // See jQuery issue (#13335)\n // Support: Firefox 18+\n //\"use strict\";\n\n var tinymceSelector = ':tinymce:not(.dirty-forms-temp)',\n ignoreSelector = '.mceEditor a,.mceMenu a,[name^=\"mce_\"]';\n\n // Create a new object, with an isDirty method\n var tinymce = {\n // Dirty Forms properties and methods\n ignoreSelector: ignoreSelector,\n isDirty: function ($node) {\n var isDirty = false;\n if (hasTinyMCE($node)) {\n // Search the current node and all descendant nodes that match the selector\n $node.filter(tinymceSelector).add($node.find(tinymceSelector)).each(function () {\n var $field = $(this);\n\n \n if (typeof $field.data('df-tinymce-orig') === 'undefined') {\n // For Dirty Forms < 2.0 and TinyMCE elements that were added via AJAX,\n // we default to using TinyMCE's isDirty behavior (which is stateless).\n if ($field.tinymce().isDirty()) {\n isDirty = true;\n \n // Return false to stop iterating.\n return false;\n }\n } else {\n // For Dirty Forms >= 2.0, we compare hash codes with the original content\n var content = getTinyMceContent($field);\n \n var hash = getHashCode(content);\n \n var originalHash = $field.data('df-tinymce-orig');\n \n\n if (hash !== originalHash) {\n isDirty = true;\n \n // Return false to stop iterating.\n return false;\n }\n }\n });\n }\n return isDirty;\n },\n setClean: function ($node) {\n if (hasTinyMCE($node)) {\n\n // Search the current node and all descendant nodes that match the selector\n $node.filter(tinymceSelector).add($node.find(tinymceSelector)).each(function () {\n var $field = $(this);\n\n // Set TinyMCE clean\n if ($field.tinymce().isDirty()) {\n \n $field.tinymce().isNotDirty = 1; //Force not dirty state\n }\n\n // Forget the original value and reset to the current state\n storeOriginalValue($field);\n });\n }\n },\n rescan: function ($node) {\n if (hasTinyMCE($node)) {\n $node.filter(tinymceSelector).add($node.find(tinymceSelector)).each(function () {\n var $field = $(this);\n\n if (typeof $field.data('df-tinymce-orig') !== 'undefined') {\n storeOriginalValue($field);\n }\n });\n }\n },\n\n // Patch for Dirty Forms < 2.0\n ignoreAnchorSelector: ignoreSelector\n };\n\n // Push the new object onto the helpers array\n $.DirtyForms.helpers.push(tinymce);\n\n // Fix: tinymce throws an error if the selector doesn't match anything\n // (such as when there are no textareas on the current page)\n var hasTinyMCE = function ($node) {\n try {\n return $node.filter(tinymceSelector).length > 0 || $node.find(tinymceSelector).length > 0;\n }\n catch (e) {\n return false;\n }\n };\n\n var getTinyMceContent = function ($field) {\n // Hack: TinyMCE puts an extra
tag at the end of a paragraph when it is edited, so ignore that case.\n return $field.tinymce().getContent({ format: 'raw' }).replace(/
<\\/p>/mg, '