Ignore:
Timestamp:
10/02/08 17:07:26 (11 years ago)
Author:
douglas
Message:

FIXED Ticket #1176 Merging new dialogs branch back to trunk.

Location:
trunk/plugins/SuperClean
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/SuperClean/dialog.html

    r728 r1044  
    11<h1 id="[h1]"><l10n>Clean up HTML</l10n></h1> 
    2 <div style="margin-left: 10px;"> 
     2<div style="margin-left: 10px;" id="[main]"> 
    33    <l10n>Please select from the following cleaning options...</l10n> 
    44    <!--filters--> 
    5   <div style="margin-top: 10px;"> 
    6     <input type="button" id="[ok]"     value="_(OK)"     /> 
    7     <input type="button" id="[cancel]" value="_(Cancel)" /> 
    8   </div> 
    95</div> 
     6 
     7<div id="[waiting]" style="display:none;margin:3em 1em;text-align:center"><l10n>Please stand by while cleaning in process...</l10n></div> 
     8<div id="[alert]" style="display:none;margin:3em 1em;text-align:center"></l10n></div> 
     9 
     10<div class="buttons" id="[buttons]"> 
     11  <input type="button" id="[ok]"     value="_(OK)"     /> 
     12  <input type="button" id="[cancel]" value="_(Cancel)" /> 
     13</div> 
  • trunk/plugins/SuperClean/lang/de.js

    r677 r1044  
    1414  "Cancel": "Abbrechen", 
    1515  "Tidy failed.  Check your HTML for syntax errors.": "SÀubern fehlgeschlagen. ÜberprÃŒfen Sie Ihren Code auf Fehler.", 
    16   "You don't have anything to tidy!": "Es gibt nichts zu sÀubern...!" 
     16  "You don't have anything to tidy!": "Es gibt nichts zu sÀubern...!", 
     17  "Please stand by while cleaning in process..." : "Bitte warten Sie, wÀhrend die SÀuberung lÀuft..." 
    1718}; 
  • trunk/plugins/SuperClean/super-clean.js

    r999 r1044  
    1 // Make our right side panel and insert appropriatly 
     1/** superClean combines HTMLTidy, Word Cleaning and font stripping into a single function 
     2 *  it works a bit differently in how it asks for parameters */ 
     3 
    24function SuperClean(editor, args) 
    35{ 
     
    2527SuperClean.prototype._lc = function(string) { 
    2628    return Xinha._lc(string, 'SuperClean'); 
    27 }; 
    28  
    29 /** superClean combines HTMLTidy, Word Cleaning and font stripping into a single function 
    30  *  it works a bit differently in how it asks for parameters */ 
    31  
    32 SuperClean.prototype._superClean = function(opts, obj) 
    33 { 
    34   var superclean = this; 
    35  
    36   // Do the clean if we got options 
    37   var doOK = function() 
    38   { 
    39     var opts = superclean._dialog.hide(); 
    40     var editor = superclean.editor; 
    41  
    42     if(opts.word_clean) editor._wordClean(); 
    43     var D = editor.getInnerHTML(); 
    44  
    45     for(var filter in editor.config.SuperClean.filters) 
    46     { 
    47       if(filter=='tidy' || filter=='word_clean') continue; 
    48       if(opts[filter]) 
    49       { 
    50         D = SuperClean.filterFunctions[filter](D, editor); 
    51       } 
    52     } 
    53  
    54     D = D.replace(/(style|class)="\s*"/gi, ''); 
    55     D = D.replace(/<(font|span)\s*>/gi, ''); 
    56  
    57     editor.setHTML(D); 
    58  
    59     if(opts.tidy) 
    60     { 
    61       var callback = function(javascriptResponse)  
    62       {  
    63         eval("var response = " + javascriptResponse); 
    64         switch (response.action) 
    65         { 
    66           case 'setHTML': 
    67             editor.setHTML(response.value); 
    68           break; 
    69           case 'alert': 
    70             alert(superclean._lc(response.value)); 
    71           break; 
    72         } 
    73       } 
    74       Xinha._postback(editor.config.SuperClean.tidy_handler, {'content' : editor.getInnerHTML()},callback); 
    75     } 
    76     return true; 
    77   } 
    78  
    79   if(this.editor.config.SuperClean.show_dialog) 
    80   { 
    81     var inputs = {}; 
    82     this._dialog.show(inputs, doOK); 
    83   } 
    84   else 
    85   { 
    86     var editor = this.editor; 
    87     var html = editor.getInnerHTML(); 
    88     for(var filter in editor.config.SuperClean.filters) 
    89     { 
    90       if(filter=='tidy') continue; //call tidy last 
    91       html = SuperClean.filterFunctions[filter](html, editor); 
    92     } 
    93  
    94     html = html.replace(/(style|class)="\s*"/gi, ''); 
    95     html = html.replace(/<(font|span)\s*>/gi, ''); 
    96  
    97     editor.setHTML(html); 
    98  
    99     if(editor.config.SuperClean.filters.tidy) 
    100     { 
    101       SuperClean.filterFunctions.tidy(html, editor); 
    102     } 
    103   } 
    10429}; 
    10530 
     
    13156              }, 
    13257  //if false all filters are applied, if true a dialog asks what filters should be used 
    133   'show_dialog': true 
     58  'show_dialog': false 
    13459}; 
    13560 
    13661SuperClean.filterFunctions = { }; 
    137 SuperClean.filterFunctions.remove_colors = function(D) 
    138 { 
    139   D = D.replace(/color="?[^" >]*"?/gi, ''); 
    140   // { (stops jedit's fold breaking) 
    141   D = D.replace(/([^-])color:[^;}"']+;?/gi, '$1'); 
    142   return(D); 
    143 }; 
    144 SuperClean.filterFunctions.remove_sizes = function(D) 
    145 { 
    146   D = D.replace(/size="?[^" >]*"?/gi, ''); 
    147   // { (stops jedit's fold breaking) 
    148   D = D.replace(/font-size:[^;}"']+;?/gi, ''); 
    149   return(D); 
    150 }; 
    151 SuperClean.filterFunctions.remove_faces = function(D) 
    152 { 
    153   D = D.replace(/face="?[^" >]*"?/gi, ''); 
    154   // { (stops jedit's fold breaking) 
    155   D = D.replace(/font-family:[^;}"']+;?/gi, ''); 
    156   return(D); 
    157 }; 
    158 SuperClean.filterFunctions.remove_lang = function(D) 
    159 { 
    160   D = D.replace(/lang="?[^" >]*"?/gi, ''); 
    161   return(D); 
    162 }; 
    163 SuperClean.filterFunctions.word_clean = function(html, editor) 
    164 { 
    165   editor.setHTML(html); 
    166   editor._wordClean(); 
    167   return editor.getInnerHTML(); 
    168 }; 
    169  
    170 SuperClean.filterFunctions.remove_fancy_quotes = function(D) 
    171 { 
    172   D = D.replace(new RegExp(String.fromCharCode(8216),"g"),"'"); 
    173   D = D.replace(new RegExp(String.fromCharCode(8217),"g"),"'"); 
    174   D = D.replace(new RegExp(String.fromCharCode(8218),"g"),"'"); 
    175   D = D.replace(new RegExp(String.fromCharCode(8219),"g"),"'"); 
    176   D = D.replace(new RegExp(String.fromCharCode(8220),"g"),"\""); 
    177   D = D.replace(new RegExp(String.fromCharCode(8221),"g"),"\""); 
    178   D = D.replace(new RegExp(String.fromCharCode(8222),"g"),"\""); 
    179   D = D.replace(new RegExp(String.fromCharCode(8223),"g"),"\""); 
    180   return D; 
    181 }; 
    182  
    183 SuperClean.filterFunctions.tidy = function(html, editor) 
    184 { 
    185   Xinha._postback(editor.config.SuperClean.tidy_handler, {'content' : html}, 
    186                       function(javascriptResponse) { eval(javascriptResponse) }); 
    187 }; 
    18862 
    18963 
     64SuperClean.prototype.onGenerateOnce = function() 
     65{ 
    19066 
    191 SuperClean.prototype.onGenerate = function() 
    192 { 
    193   if(this.editor.config.SuperClean.show_dialog && !this._dialog) 
    194   { 
    195     this._dialog = new SuperClean.Dialog(this); 
    196   } 
    19767  if(this.editor.config.tidy_handler) 
    19868  { 
     
    20575    this.editor.config.filters.tidy = null; 
    20676  } 
     77  SuperClean.loadAssets(); 
     78  this.loadFilters(); 
     79}; 
    20780 
     81SuperClean.prototype.onUpdateToolbar = function() 
     82{  
     83  if (!(SuperClean.methodsReady && SuperClean.html)) 
     84  { 
     85    this.editor._toolbarObjects.superclean.state("enabled", false); 
     86  } 
     87  else this.onUpdateToolbar = null; 
     88}; 
     89 
     90SuperClean.loadAssets = function() 
     91{ 
     92  var self = SuperClean; 
     93  if (self.loading) return; 
     94  self.loading = true; 
     95  Xinha._getback(Xinha.getPluginDir("SuperClean") + '/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 
     96  Xinha._getback( Xinha.getPluginDir("SuperClean") + '/dialog.html', function(getback) { self.html = getback; } ); 
     97}; 
     98 
     99SuperClean.prototype.loadFilters = function() 
     100{ 
    208101  var sc = this; 
    209102  //load the filter-functions 
    210103  for(var filter in this.editor.config.SuperClean.filters) 
    211104  { 
     105    if (/^(remove_colors|remove_sizes|remove_faces|remove_lang|word_clean|remove_fancy_quotes|tidy)$/.test(filter)) continue; //skip built-in functions 
     106     
    212107    if(!SuperClean.filterFunctions[filter]) 
    213108    { 
     
    222117                      function(func) { 
    223118                        eval('SuperClean.filterFunctions.'+filter+'='+func+';'); 
    224                         sc.onGenerate(); 
     119                        sc.loadFilters(); 
    225120                      }); 
    226121      } 
     
    229124  } 
    230125}; 
    231 // Inline Dialog for SuperClean 
    232  
    233  
    234 SuperClean.Dialog = function (SuperClean) 
    235 { 
    236   var  lDialog = this; 
    237   this.Dialog_nxtid = 0; 
    238   this.SuperClean = SuperClean; 
    239   this.id = { }; // This will be filled below with a replace, nifty 
    240  
    241   this.ready = false; 
    242   this.files  = false; 
    243   this.html   = false; 
    244   this.dialog = false; 
    245  
    246   // load the dTree script 
    247   this._prepareDialog(); 
    248  
    249 }; 
    250  
    251 SuperClean.Dialog.prototype._prepareDialog = function() 
    252 { 
    253   var lDialog = this; 
    254   var SuperClean = this.SuperClean; 
    255  
    256   if(this.html == false) 
    257   { 
    258     Xinha._getback(Xinha.getPluginDir("SuperClean") + '/dialog.html', function(txt) { lDialog.html = txt; lDialog._prepareDialog(); }); 
    259     return; 
    260   } 
    261  
    262   var htmlFilters = ""; 
    263   for(var filter in this.SuperClean.editor.config.SuperClean.filters) 
    264   { 
    265     htmlFilters += "    <div>\n"; 
    266     var filtDetail = this.SuperClean.editor.config.SuperClean.filters[filter]; 
    267     if(typeof filtDetail.label == 'undefined') 
    268     { 
    269       htmlFilters += "        <input type=\"checkbox\" name=\"["+filter+"]\" id=\"["+filter+"]\" checked />\n"; 
    270       htmlFilters += "        <label for=\"["+filter+"]\">"+this.SuperClean.editor.config.SuperClean.filters[filter]+"</label>\n"; 
    271     } 
    272     else 
    273     { 
    274       htmlFilters += "        <input type=\"checkbox\" name=\"["+filter+"]\" id=\"["+filter+"]\" " + (filtDetail.checked ? "checked" : "") + " />\n"; 
    275       htmlFilters += "        <label for=\"["+filter+"]\">"+filtDetail.label+"</label>\n"; 
    276     } 
    277     htmlFilters += "    </div>\n"; 
    278   } 
    279   this.html = this.html.replace('<!--filters-->', htmlFilters); 
    280  
    281   var html = this.html; 
    282  
    283   // Now we have everything we need, so we can build the dialog. 
    284   var dialog = this.dialog = new Xinha.Dialog(SuperClean.editor, this.html, 'SuperClean'); 
    285  
    286   this.ready = true; 
    287 }; 
    288  
    289 SuperClean.Dialog.prototype._lc = SuperClean.prototype._lc; 
    290  
    291 SuperClean.Dialog.prototype.show = function(inputs, ok, cancel) 
    292 { 
    293   if(!this.ready) 
    294   { 
    295     var lDialog = this; 
    296     window.setTimeout(function() {lDialog.show(inputs,ok,cancel);},100); 
    297     return; 
    298   } 
    299  
    300   // Connect the OK and Cancel buttons 
    301   var dialog = this.dialog; 
    302   var lDialog = this; 
    303   if(ok) 
    304   { 
    305     this.dialog.getElementById('ok').onclick = ok; 
    306   } 
    307   else 
    308   { 
    309     this.dialog.getElementById('ok').onclick = function() {lDialog.hide();}; 
    310   } 
    311  
    312   if(cancel) 
    313   { 
    314     this.dialog.getElementById('cancel').onclick = cancel; 
    315   } 
    316   else 
    317   { 
    318     this.dialog.getElementById('cancel').onclick = function() { lDialog.hide()}; 
    319   } 
    320  
    321   // Show the dialog 
    322   this.SuperClean.editor.disableToolbar(['fullscreen','SuperClean']); 
    323  
    324   this.dialog.show(inputs); 
    325  
    326   // Init the sizes 
    327   this.dialog.onresize(); 
    328 }; 
    329  
    330 SuperClean.Dialog.prototype.hide = function() 
    331 { 
    332   this.SuperClean.editor.enableToolbar(); 
    333   return this.dialog.hide(); 
    334 }; 
Note: See TracChangeset for help on using the changeset viewer.