PageRenderTime 34ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/common/js/xheditor.plugins.js

http://lazycms.googlecode.com/
JavaScript | 107 lines | 73 code | 5 blank | 29 comment | 5 complexity | acf057e029779f0e7921ae5ba0538913 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1
  1. /**
  2. * +---------------------------------------------------------------------------+
  3. * | LL LLLL LL L LLLL LLLL |
  4. * | LL LL L LLL LL LL L LL LL |
  5. * | LL LLLL LLLLL LL LL LL LLLL LLL LL LL LL LL |
  6. * | LL LL LL LL LL LL L LLL LL LLLLL LL LL LL |
  7. * | LL LLLLL LL LLLL LL L L LL LLLLL LL LL LL |
  8. * | LL LL LL LL LLLL LL L LL LL LLLL LL |
  9. * | LL LL LL LL LL LL L L LL L LL LLLL LL |
  10. * | LLLLLL LLLLL LLLLL LL LLLL L LL LLLL LL LLLLLL |
  11. * | LL |
  12. * | LL |
  13. * +---------------------------------------------------------------------------+
  14. * | Copyright (C) 2007-2010 LazyCMS.com All rights reserved. |
  15. * +---------------------------------------------------------------------------+
  16. * | LazyCMS is free software. See LICENSE for copyright notices and details. |
  17. * +---------------------------------------------------------------------------+
  18. *
  19. * xheditor plugins
  20. *
  21. * @author Lukin <my@lukin.cn>
  22. * @version $Id: xheditor.plugins.js 749 2011-03-06 16:06:50Z mylukin $
  23. */
  24. var xhePlugins = window.xhePlugins = {
  25. // Flv
  26. Flv:{c:'xhePlugins_btnFlv',t:_('Insert Flv Video'),h:1,e:function(){
  27. var _this = this,jParent = _this.getParent('embed[type=application/x-shockwave-flash][lazytype=Flv]');
  28. var jFlv = $('<div>' + _('Flv URL:') + ' <input type="text" id="xheFlvUrl" value="http://" class="xheText" /></div>'+
  29. '<div>' + _('Dimension:') + ' <input type="text" id="xheFlvWidth" style="width:40px;" value="480" /> x <input type="text" id="xheFlvHeight" style="width:40px;" value="400" /></div>'+
  30. '<div style="text-align:right;"><input type="button" id="xheSave" value="' + _('Ok') + '" /></div>'),
  31. jUrl = $('#xheFlvUrl',jFlv),
  32. jWidth = $('#xheFlvWidth',jFlv),
  33. jHeight = $('#xheFlvHeight',jFlv),
  34. jSave = $('#xheSave',jFlv);
  35. if (_this.settings.upVideoUrl)
  36. _this.uploadInit(jUrl, _this.settings.upVideoUrl, _this.settings.upVideoExt);
  37. jSave.click(function(){
  38. _this.loadBookmark();
  39. _this.pasteHTML('<embed width="'+jWidth.val()+'" height="'+jHeight.val()+'" lazysrc="'+jUrl.val()+'" flashvars="file='+jUrl.val()+'" src="'+LazyCMS.ROOT+'common/editor/plugins/mediaplayer/player.swf" quality="high" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" lazytype="Flv" />');
  40. _this.hidePanel();
  41. return false;
  42. });
  43. _this.showDialog(jFlv);
  44. if(jParent.length==1)
  45. {
  46. jUrl.val(jParent.attr('lazysrc'));
  47. jWidth.val(jParent.attr('width'));
  48. jHeight.val(jParent.attr('height'));
  49. }
  50. }},
  51. // google map
  52. GoogleMap:{c:'xhePlugins_btnGoogleMap',t:_('Insert Google map'),e:function(){
  53. var _this=this;
  54. _this.showIframeModal(_('Google Maps'),'{editorRoot}plugins/googlemap/map.html',function(r){
  55. _this.pasteHTML('<img src="' + r.src + '" alt="' + r.title + '" />');
  56. },522,435);
  57. }},
  58. // Pagebreak
  59. Pagebreak:{c:'xhePlugins_btnPageBreak',t:_('Insert Pagebreak'),e:function(){
  60. this.pasteHTML('<img class="xhePageBreak" src="' + LazyCMS.ROOT + 'common/images/blank.gif" alt="" />');
  61. }},
  62. // Removelink
  63. Removelink:{c:'xhePlugins_btnRemoveLink',t:_('Remove external links'),e:function(){
  64. var source = this.getSource(),
  65. host = document.location.host;
  66. source = source.replace(/<a[^>]+?href\s*=\s*["']?([^"']+)[^>]*>(.+?)<\/a>/ig,function(all,url,text){
  67. // http:// ?????????????
  68. if (('http://' == url.substr(0,7) && url.substring(7,host.length+7) != host)
  69. || ('https://' == url.substr(0,8) && url.substring(8,host.length+8) != host)
  70. || ('ftp://' == url.substr(0,6) && url.substring(6,host.length+6) != host)) {
  71. all = text;
  72. }
  73. return all;
  74. });
  75. this.setSource(source);
  76. }},
  77. // Explorer
  78. Explorer:{c:'xhePlugins_btnExplorer',t:_('Explorer'),e:function(){
  79. return $(this).explorer();
  80. }}
  81. };
  82. var xheFilter = window.xheFilter = {
  83. SetSource: function(source) {
  84. var html = String(source);
  85. html = html.replace(/\r?\n/g,'');
  86. html = html.replace(/(<embed(?:\s+[^>]*?)?)(flashvars\s*=\s*"file=)([^"]+)("(?:\s+[^>]*?)?(?:src\s*=\s*"[^"]*mediaplayer\/player.swf")(?:\s+[^>]*?)?(?:\s+type\s*=\s*"\s*application\/x-shockwave-flash\s*"|\s+classid\s*=\s*"\s*clsid:d27cdb6e-ae6d-11cf-96b8-4445535400000\s*")[^>]*?\/>)/ig,function(all,start,flashvars,file,end){
  87. return start + 'lazysrc="' + file + '" lazytype="Flv" ' + flashvars + file + end;
  88. });
  89. html = html.replace(/<!--pagebreak-->/ig,'<img class="xhePageBreak" src="' + LazyCMS.ROOT + 'common/images/blank.gif" alt="" />');
  90. return html;
  91. },
  92. GetSource: function(source) {
  93. var html = String(source);
  94. html = html.replace(/(<embed(?:\s+[^>]*?)?)(?:lazysrc\s*=\s*"[^"]*"\s)([^>]*?)(?:lazytype\s*=\s*"[^"]*"\s)([^>]*?\/>)/ig,function(all,start,center,end){
  95. return start + center + end;
  96. });
  97. html = html.replace(/<img\s*class\s*=\s*"xhePageBreak"[^>]*\/>/ig,function(all){
  98. return '<!--pagebreak-->';
  99. });
  100. return html;
  101. }
  102. };