spree_editor 0.50.0 → 0.50.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Versionfile +3 -0
- data/app/controllers/admin/editor_settings_controller.rb +5 -11
- data/app/views/admin/editor_settings/edit.html.erb +20 -19
- data/app/views/shared/editor_engines/_tiny_mce.html.erb +16 -33
- data/app/views/shared/editor_engines/_yui_rich_editor.html.erb +60 -7
- data/config/locales/en.yml +1 -0
- data/config/locales/es.yml +45 -0
- data/config/locales/ru.yml +2 -0
- data/lib/editor_configuration.rb +2 -2
- data/public/images/html_editor.gif +0 -0
- data/public/javascripts/tinymce/langs/en.js +56 -3
- data/public/javascripts/tinymce/plugins/advhr/langs/en_dlg.js +2 -0
- data/public/javascripts/tinymce/plugins/advhr/rule.htm +30 -29
- data/public/javascripts/tinymce/plugins/advimage/image.htm +34 -31
- data/public/javascripts/tinymce/plugins/advimage/js/image.js +20 -5
- data/public/javascripts/tinymce/plugins/advimage/langs/en_dlg.js +2 -0
- data/public/javascripts/tinymce/plugins/advlink/js/advlink.js +21 -17
- data/public/javascripts/tinymce/plugins/advlink/langs/en_dlg.js +4 -2
- data/public/javascripts/tinymce/plugins/advlink/link.htm +35 -30
- data/public/javascripts/tinymce/plugins/advlist/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/advlist/editor_plugin_src.js +10 -3
- data/public/javascripts/tinymce/plugins/autolink/editor_plugin.js +1 -0
- data/public/javascripts/tinymce/plugins/autolink/editor_plugin_src.js +169 -0
- data/public/javascripts/tinymce/plugins/autoresize/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/autoresize/editor_plugin_src.js +12 -3
- data/public/javascripts/tinymce/plugins/autosave/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/autosave/editor_plugin_src.js +13 -4
- data/public/javascripts/tinymce/plugins/bbcode/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/bbcode/editor_plugin_src.js +1 -1
- data/public/javascripts/tinymce/plugins/contextmenu/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/contextmenu/editor_plugin_src.js +30 -16
- data/public/javascripts/tinymce/plugins/emotions/emotions.htm +15 -14
- data/public/javascripts/tinymce/plugins/fullpage/css/fullpage.css +3 -42
- data/public/javascripts/tinymce/plugins/fullpage/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/fullpage/editor_plugin_src.js +309 -63
- data/public/javascripts/tinymce/plugins/fullpage/fullpage.htm +18 -330
- data/public/javascripts/tinymce/plugins/fullpage/js/fullpage.js +199 -438
- data/public/javascripts/tinymce/plugins/fullscreen/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/fullscreen/editor_plugin_src.js +10 -2
- data/public/javascripts/tinymce/plugins/inlinepopups/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/inlinepopups/editor_plugin_src.js +76 -15
- data/public/javascripts/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css +0 -10
- data/public/javascripts/tinymce/plugins/layer/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/layer/editor_plugin_src.js +2 -0
- data/public/javascripts/tinymce/plugins/legacyoutput/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/legacyoutput/editor_plugin_src.js +31 -28
- data/public/javascripts/tinymce/plugins/lists/editor_plugin.js +1 -0
- data/public/javascripts/tinymce/plugins/lists/editor_plugin_src.js +617 -0
- data/public/javascripts/tinymce/plugins/media/css/media.css +5 -4
- data/public/javascripts/tinymce/plugins/media/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/media/editor_plugin_src.js +652 -296
- data/public/javascripts/tinymce/plugins/media/js/media.js +327 -603
- data/public/javascripts/tinymce/plugins/media/langs/en_dlg.js +8 -2
- data/public/javascripts/tinymce/plugins/media/media.htm +283 -288
- data/public/javascripts/tinymce/plugins/media/moxieplayer.swf +0 -0
- data/public/javascripts/tinymce/plugins/nonbreaking/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/nonbreaking/editor_plugin_src.js +1 -1
- data/public/javascripts/tinymce/plugins/noneditable/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/noneditable/editor_plugin_src.js +2 -0
- data/public/javascripts/tinymce/plugins/pagebreak/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/pagebreak/editor_plugin_src.js +1 -4
- data/public/javascripts/tinymce/plugins/paste/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/paste/editor_plugin_src.js +118 -137
- data/public/javascripts/tinymce/plugins/searchreplace/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/searchreplace/editor_plugin_src.js +4 -0
- data/public/javascripts/tinymce/plugins/searchreplace/js/searchreplace.js +14 -10
- data/public/javascripts/tinymce/plugins/searchreplace/searchreplace.htm +17 -16
- data/public/javascripts/tinymce/plugins/spellchecker/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/spellchecker/editor_plugin_src.js +55 -37
- data/public/javascripts/tinymce/plugins/style/js/props.js +2 -8
- data/public/javascripts/tinymce/plugins/style/langs/en_dlg.js +8 -1
- data/public/javascripts/tinymce/plugins/style/props.htm +513 -398
- data/public/javascripts/tinymce/plugins/tabfocus/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/tabfocus/editor_plugin_src.js +30 -28
- data/public/javascripts/tinymce/plugins/table/cell.htm +12 -12
- data/public/javascripts/tinymce/plugins/table/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/table/editor_plugin_src.js +97 -34
- data/public/javascripts/tinymce/plugins/table/js/cell.js +9 -11
- data/public/javascripts/tinymce/plugins/table/js/row.js +13 -18
- data/public/javascripts/tinymce/plugins/table/js/table.js +8 -12
- data/public/javascripts/tinymce/plugins/table/langs/en_dlg.js +1 -1
- data/public/javascripts/tinymce/plugins/table/merge_cells.htm +11 -11
- data/public/javascripts/tinymce/plugins/table/row.htm +10 -8
- data/public/javascripts/tinymce/plugins/table/table.htm +54 -53
- data/public/javascripts/tinymce/plugins/template/js/template.js +1 -1
- data/public/javascripts/tinymce/plugins/visualchars/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/visualchars/editor_plugin_src.js +1 -1
- data/public/javascripts/tinymce/plugins/wordcount/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/wordcount/editor_plugin_src.js +35 -19
- data/public/javascripts/tinymce/plugins/xhtmlxtras/abbr.htm +6 -5
- data/public/javascripts/tinymce/plugins/xhtmlxtras/acronym.htm +6 -5
- data/public/javascripts/tinymce/plugins/xhtmlxtras/attributes.htm +6 -5
- data/public/javascripts/tinymce/plugins/xhtmlxtras/cite.htm +5 -4
- data/public/javascripts/tinymce/plugins/xhtmlxtras/del.htm +9 -8
- data/public/javascripts/tinymce/plugins/xhtmlxtras/editor_plugin.js +1 -1
- data/public/javascripts/tinymce/plugins/xhtmlxtras/editor_plugin_src.js +6 -6
- data/public/javascripts/tinymce/plugins/xhtmlxtras/ins.htm +11 -10
- data/public/javascripts/tinymce/plugins/xhtmlxtras/js/attributes.js +1 -16
- data/public/javascripts/tinymce/plugins/xhtmlxtras/js/del.js +2 -2
- data/public/javascripts/tinymce/plugins/xhtmlxtras/js/element_common.js +3 -5
- data/public/javascripts/tinymce/plugins/xhtmlxtras/js/ins.js +4 -3
- data/public/javascripts/tinymce/themes/advanced/about.htm +3 -5
- data/public/javascripts/tinymce/themes/advanced/anchor.htm +5 -5
- data/public/javascripts/tinymce/themes/advanced/charmap.htm +39 -40
- data/public/javascripts/tinymce/themes/advanced/color_picker.htm +10 -9
- data/public/javascripts/tinymce/themes/advanced/editor_template.js +1 -1
- data/public/javascripts/tinymce/themes/advanced/editor_template_src.js +172 -41
- data/public/javascripts/tinymce/themes/advanced/image.htm +51 -51
- data/public/javascripts/tinymce/themes/advanced/img/flash.gif +0 -0
- data/public/javascripts/tinymce/themes/advanced/img/iframe.gif +0 -0
- data/public/javascripts/tinymce/themes/advanced/img/pagebreak.gif +0 -0
- data/public/javascripts/tinymce/themes/advanced/img/quicktime.gif +0 -0
- data/public/javascripts/tinymce/themes/advanced/img/realmedia.gif +0 -0
- data/public/javascripts/tinymce/themes/advanced/img/shockwave.gif +0 -0
- data/public/javascripts/tinymce/themes/advanced/img/trans.gif +0 -0
- data/public/javascripts/tinymce/themes/advanced/img/video.gif +0 -0
- data/public/javascripts/tinymce/themes/advanced/img/windowsmedia.gif +0 -0
- data/public/javascripts/tinymce/themes/advanced/js/about.js +1 -0
- data/public/javascripts/tinymce/themes/advanced/js/anchor.js +5 -0
- data/public/javascripts/tinymce/themes/advanced/js/charmap.js +26 -6
- data/public/javascripts/tinymce/themes/advanced/js/color_picker.js +108 -32
- data/public/javascripts/tinymce/themes/advanced/js/image.js +3 -1
- data/public/javascripts/tinymce/themes/advanced/js/link.js +4 -7
- data/public/javascripts/tinymce/themes/advanced/js/source_editor.js +1 -1
- data/public/javascripts/tinymce/themes/advanced/langs/en.js +8 -2
- data/public/javascripts/tinymce/themes/advanced/langs/en_dlg.js +6 -3
- data/public/javascripts/tinymce/themes/advanced/link.htm +27 -28
- data/public/javascripts/tinymce/themes/advanced/shortcuts.htm +47 -0
- data/public/javascripts/tinymce/themes/advanced/skins/default/content.css +11 -0
- data/public/javascripts/tinymce/themes/advanced/skins/default/ui.css +4 -4
- data/public/javascripts/tinymce/themes/advanced/skins/highcontrast/content.css +23 -0
- data/public/javascripts/tinymce/themes/advanced/skins/highcontrast/dialog.css +105 -0
- data/public/javascripts/tinymce/themes/advanced/skins/highcontrast/ui.css +101 -0
- data/public/javascripts/tinymce/themes/advanced/skins/o2k7/content.css +10 -0
- data/public/javascripts/tinymce/themes/advanced/skins/o2k7/dialog.css +1 -0
- data/public/javascripts/tinymce/themes/advanced/skins/o2k7/ui.css +5 -4
- data/public/javascripts/tinymce/themes/advanced/skins/o2k7/ui_black.css +1 -1
- data/public/javascripts/tinymce/themes/advanced/skins/o2k7/ui_silver.css +1 -1
- data/public/javascripts/tinymce/themes/advanced/source_editor.htm +3 -3
- data/public/javascripts/tinymce/themes/simple/editor_template.js +1 -1
- data/public/javascripts/tinymce/themes/simple/editor_template_src.js +1 -2
- data/public/javascripts/tinymce/tiny_mce.js +1 -1
- data/public/javascripts/tinymce/tiny_mce_popup.js +1 -1
- data/public/javascripts/tinymce/tiny_mce_src.js +6488 -4070
- data/public/javascripts/tinymce/utils/form_utils.js +14 -4
- data/public/javascripts/tinymce/utils/mctabs.js +95 -10
- data/public/javascripts/tinymce/utils/validate.js +35 -3
- data/public/stylesheets/editor.css +23 -0
- data/spree_editor.gemspec +2 -2
- metadata +25 -4
@@ -35,53 +35,14 @@
|
|
35
35
|
width: 240px;
|
36
36
|
}
|
37
37
|
|
38
|
-
/* Head list classes */
|
39
|
-
|
40
|
-
.headlistwrapper {
|
41
|
-
width: 100%;
|
42
|
-
}
|
43
|
-
|
44
|
-
.addbutton, .removebutton, .moveupbutton, .movedownbutton {
|
45
|
-
border-top: 1px solid;
|
46
|
-
border-left: 1px solid;
|
47
|
-
border-bottom: 1px solid;
|
48
|
-
border-right: 1px solid;
|
49
|
-
border-color: #F0F0EE;
|
50
|
-
cursor: default;
|
51
|
-
display: block;
|
52
|
-
width: 20px;
|
53
|
-
height: 20px;
|
54
|
-
}
|
55
|
-
|
56
38
|
#doctypes {
|
57
39
|
width: 200px;
|
58
40
|
}
|
59
41
|
|
60
|
-
|
61
|
-
border: 1px solid #0A246A;
|
62
|
-
background-color: #B6BDD2;
|
63
|
-
}
|
64
|
-
|
65
|
-
.addbutton {
|
66
|
-
background-image: url('../images/add.gif');
|
67
|
-
float: left;
|
68
|
-
margin-right: 3px;
|
69
|
-
}
|
70
|
-
|
71
|
-
.removebutton {
|
72
|
-
background-image: url('../images/remove.gif');
|
73
|
-
float: left;
|
74
|
-
}
|
75
|
-
|
76
|
-
.moveupbutton {
|
77
|
-
background-image: url('../images/move_up.gif');
|
78
|
-
float: left;
|
79
|
-
margin-right: 3px;
|
80
|
-
}
|
42
|
+
/* Head list classes */
|
81
43
|
|
82
|
-
.
|
83
|
-
|
84
|
-
float: left;
|
44
|
+
.headlistwrapper {
|
45
|
+
width: 100%;
|
85
46
|
}
|
86
47
|
|
87
48
|
.selected {
|
@@ -1 +1 @@
|
|
1
|
-
(function(){tinymce.create("tinymce.plugins.FullPagePlugin",{init:function(
|
1
|
+
(function(){var b=tinymce.each,a=tinymce.html.Node;tinymce.create("tinymce.plugins.FullPagePlugin",{init:function(c,d){var e=this;e.editor=c;c.addCommand("mceFullPageProperties",function(){c.windowManager.open({file:d+"/fullpage.htm",width:430+parseInt(c.getLang("fullpage.delta_width",0)),height:495+parseInt(c.getLang("fullpage.delta_height",0)),inline:1},{plugin_url:d,data:e._htmlToData()})});c.addButton("fullpage",{title:"fullpage.desc",cmd:"mceFullPageProperties"});c.onBeforeSetContent.add(e._setContent,e);c.onGetContent.add(e._getContent,e)},getInfo:function(){return{longname:"Fullpage",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullpage",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_htmlToData:function(){var f=this._parseHeader(),h={},c,i,g,e=this.editor;function d(l,j){var k=l.attr(j);return k||""}h.fontface=e.getParam("fullpage_default_fontface","");h.fontsize=e.getParam("fullpage_default_fontsize","");i=f.firstChild;if(i.type==7){h.xml_pi=true;g=/encoding="([^"]+)"/.exec(i.value);if(g){h.docencoding=g[1]}}i=f.getAll("#doctype")[0];if(i){h.doctype="<!DOCTYPE"+i.value+">"}i=f.getAll("title")[0];if(i&&i.firstChild){h.metatitle=i.firstChild.value}b(f.getAll("meta"),function(m){var k=m.attr("name"),j=m.attr("http-equiv"),l;if(k){h["meta"+k.toLowerCase()]=m.attr("content")}else{if(j=="Content-Type"){l=/charset\s*=\s*(.*)\s*/gi.exec(m.attr("content"));if(l){h.docencoding=l[1]}}}});i=f.getAll("html")[0];if(i){h.langcode=d(i,"lang")||d(i,"xml:lang")}i=f.getAll("link")[0];if(i&&i.attr("rel")=="stylesheet"){h.stylesheet=i.attr("href")}i=f.getAll("body")[0];if(i){h.langdir=d(i,"dir");h.style=d(i,"style");h.visited_color=d(i,"vlink");h.link_color=d(i,"link");h.active_color=d(i,"alink")}return h},_dataToHtml:function(g){var f,d,h,j,k,e=this.editor.dom;function c(n,l,m){n.attr(l,m?m:undefined)}function i(l){if(d.firstChild){d.insert(l,d.firstChild)}else{d.append(l)}}f=this._parseHeader();d=f.getAll("head")[0];if(!d){j=f.getAll("html")[0];d=new a("head",1);if(j.firstChild){j.insert(d,j.firstChild,true)}else{j.append(d)}}j=f.firstChild;if(g.xml_pi){k='version="1.0"';if(g.docencoding){k+=' encoding="'+g.docencoding+'"'}if(j.type!=7){j=new a("xml",7);f.insert(j,f.firstChild,true)}j.value=k}else{if(j&&j.type==7){j.remove()}}j=f.getAll("#doctype")[0];if(g.doctype){if(!j){j=new a("#doctype",10);if(g.xml_pi){f.insert(j,f.firstChild)}else{i(j)}}j.value=g.doctype.substring(9,g.doctype.length-1)}else{if(j){j.remove()}}j=f.getAll("title")[0];if(g.metatitle){if(!j){j=new a("title",1);j.append(new a("#text",3)).value=g.metatitle;i(j)}}if(g.docencoding){j=null;b(f.getAll("meta"),function(l){if(l.attr("http-equiv")=="Content-Type"){j=l}});if(!j){j=new a("meta",1);j.attr("http-equiv","Content-Type");j.shortEnded=true;i(j)}j.attr("content","text/html; charset="+g.docencoding)}b("keywords,description,author,copyright,robots".split(","),function(m){var l=f.getAll("meta"),n,p,o=g["meta"+m];for(n=0;n<l.length;n++){p=l[n];if(p.attr("name")==m){if(o){p.attr("content",o)}else{p.remove()}return}}if(o){j=new a("meta",1);j.attr("name",m);j.attr("content",o);j.shortEnded=true;i(j)}});j=f.getAll("link")[0];if(j&&j.attr("rel")=="stylesheet"){if(g.stylesheet){j.attr("href",g.stylesheet)}else{j.remove()}}else{if(g.stylesheet){j=new a("link",1);j.attr({rel:"stylesheet",text:"text/css",href:g.stylesheet});j.shortEnded=true;i(j)}}j=f.getAll("body")[0];if(j){c(j,"dir",g.langdir);c(j,"style",g.style);c(j,"vlink",g.visited_color);c(j,"link",g.link_color);c(j,"alink",g.active_color);e.setAttribs(this.editor.getBody(),{style:g.style,dir:g.dir,vLink:g.visited_color,link:g.link_color,aLink:g.active_color})}j=f.getAll("html")[0];if(j){c(j,"lang",g.langcode);c(j,"xml:lang",g.langcode)}h=new tinymce.html.Serializer({validate:false,indent:true,apply_source_formatting:true,indent_before:"head,html,body,meta,title,script,link,style",indent_after:"head,html,body,meta,title,script,link,style"}).serialize(f);this.head=h.substring(0,h.indexOf("</body>"))},_parseHeader:function(){return new tinymce.html.DomParser({validate:false,root_name:"#document"}).parse(this.head)},_setContent:function(g,d){var m=this,i,c,h=d.content,f,l="",e=m.editor.dom,j;function k(n){return n.replace(/<\/?[A-Z]+/g,function(o){return o.toLowerCase()})}if(d.format=="raw"&&m.head){return}if(d.source_view&&g.getParam("fullpage_hide_in_source_view")){return}h=h.replace(/<(\/?)BODY/gi,"<$1body");i=h.indexOf("<body");if(i!=-1){i=h.indexOf(">",i);m.head=k(h.substring(0,i+1));c=h.indexOf("</body",i);if(c==-1){c=h.length}d.content=h.substring(i+1,c);m.foot=k(h.substring(c))}else{m.head=this._getDefaultHeader();m.foot="\n</body>\n</html>"}f=m._parseHeader();b(f.getAll("style"),function(n){if(n.firstChild){l+=n.firstChild.value}});j=f.getAll("body")[0];if(j){e.setAttribs(m.editor.getBody(),{style:j.attr("style")||"",dir:j.attr("dir")||"",vLink:j.attr("vlink")||"",link:j.attr("link")||"",aLink:j.attr("alink")||""})}if(l){e.add(m.editor.getDoc().getElementsByTagName("head")[0],"style",{id:"fullpage_styles"},l)}else{e.remove("fullpage_styles")}},_getDefaultHeader:function(){var f="",c=this.editor,e,d="";if(c.getParam("fullpage_default_xml_pi")){f+='<?xml version="1.0" encoding="'+c.getParam("fullpage_default_encoding","ISO-8859-1")+'" ?>\n'}f+=c.getParam("fullpage_default_doctype",'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');f+="\n<html>\n<head>\n";if(e=c.getParam("fullpage_default_title")){f+="<title>"+v+"</title>\n"}if(e=c.getParam("fullpage_default_encoding")){f+='<meta http-equiv="Content-Type" content="text/html; charset='+e+'" />\n'}if(e=c.getParam("fullpage_default_font_family")){d+="font-family: "+e+";"}if(e=c.getParam("fullpage_default_font_size")){d+="font-size: "+e+";"}if(e=c.getParam("fullpage_default_text_color")){d+="color: "+e+";"}f+="</head>\n<body"+(d?' style="'+d+'"':"")+">\n";return f},_getContent:function(d,e){var c=this;if(!e.source_view||!d.getParam("fullpage_hide_in_source_view")){e.content=tinymce.trim(c.head)+"\n"+tinymce.trim(e.content)+"\n"+tinymce.trim(c.foot)}}});tinymce.PluginManager.add("fullpage",tinymce.plugins.FullPagePlugin)})();
|
@@ -9,6 +9,8 @@
|
|
9
9
|
*/
|
10
10
|
|
11
11
|
(function() {
|
12
|
+
var each = tinymce.each, Node = tinymce.html.Node;
|
13
|
+
|
12
14
|
tinymce.create('tinymce.plugins.FullPagePlugin', {
|
13
15
|
init : function(ed, url) {
|
14
16
|
var t = this;
|
@@ -24,7 +26,7 @@
|
|
24
26
|
inline : 1
|
25
27
|
}, {
|
26
28
|
plugin_url : url,
|
27
|
-
|
29
|
+
data : t._htmlToData()
|
28
30
|
});
|
29
31
|
});
|
30
32
|
|
@@ -32,7 +34,6 @@
|
|
32
34
|
ed.addButton('fullpage', {title : 'fullpage.desc', cmd : 'mceFullPageProperties'});
|
33
35
|
|
34
36
|
ed.onBeforeSetContent.add(t._setContent, t);
|
35
|
-
ed.onSetContent.add(t._setBodyAttribs, t);
|
36
37
|
ed.onGetContent.add(t._getContent, t);
|
37
38
|
},
|
38
39
|
|
@@ -48,106 +49,351 @@
|
|
48
49
|
|
49
50
|
// Private plugin internal methods
|
50
51
|
|
51
|
-
|
52
|
-
var
|
52
|
+
_htmlToData : function() {
|
53
|
+
var headerFragment = this._parseHeader(), data = {}, nodes, elm, matches, editor = this.editor;
|
53
54
|
|
54
|
-
|
55
|
-
|
55
|
+
function getAttr(elm, name) {
|
56
|
+
var value = elm.attr(name);
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
kv = bdattr[i].split('=');
|
60
|
-
k = kv[0].replace(/\s/,'');
|
61
|
-
v = kv[1];
|
58
|
+
return value || '';
|
59
|
+
};
|
62
60
|
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
// Default some values
|
62
|
+
data.fontface = editor.getParam("fullpage_default_fontface", "");
|
63
|
+
data.fontsize = editor.getParam("fullpage_default_fontsize", "");
|
64
|
+
|
65
|
+
// Parse XML PI
|
66
|
+
elm = headerFragment.firstChild;
|
67
|
+
if (elm.type == 7) {
|
68
|
+
data.xml_pi = true;
|
69
|
+
matches = /encoding="([^"]+)"/.exec(elm.value);
|
70
|
+
if (matches)
|
71
|
+
data.docencoding = matches[1];
|
72
|
+
}
|
66
73
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
74
|
+
// Parse doctype
|
75
|
+
elm = headerFragment.getAll('#doctype')[0];
|
76
|
+
if (elm)
|
77
|
+
data.doctype = '<!DOCTYPE' + elm.value + ">";
|
71
78
|
|
72
|
-
|
73
|
-
|
79
|
+
// Parse title element
|
80
|
+
elm = headerFragment.getAll('title')[0];
|
81
|
+
if (elm && elm.firstChild) {
|
82
|
+
data.metatitle = elm.firstChild.value;
|
83
|
+
}
|
84
|
+
|
85
|
+
// Parse meta elements
|
86
|
+
each(headerFragment.getAll('meta'), function(meta) {
|
87
|
+
var name = meta.attr('name'), httpEquiv = meta.attr('http-equiv'), matches;
|
88
|
+
|
89
|
+
if (name)
|
90
|
+
data['meta' + name.toLowerCase()] = meta.attr('content');
|
91
|
+
else if (httpEquiv == "Content-Type") {
|
92
|
+
matches = /charset\s*=\s*(.*)\s*/gi.exec(meta.attr('content'));
|
93
|
+
|
94
|
+
if (matches)
|
95
|
+
data.docencoding = matches[1];
|
74
96
|
}
|
97
|
+
});
|
98
|
+
|
99
|
+
// Parse html attribs
|
100
|
+
elm = headerFragment.getAll('html')[0];
|
101
|
+
if (elm)
|
102
|
+
data.langcode = getAttr(elm, 'lang') || getAttr(elm, 'xml:lang');
|
103
|
+
|
104
|
+
// Parse stylesheet
|
105
|
+
elm = headerFragment.getAll('link')[0];
|
106
|
+
if (elm && elm.attr('rel') == 'stylesheet')
|
107
|
+
data.stylesheet = elm.attr('href');
|
108
|
+
|
109
|
+
// Parse body parts
|
110
|
+
elm = headerFragment.getAll('body')[0];
|
111
|
+
if (elm) {
|
112
|
+
data.langdir = getAttr(elm, 'dir');
|
113
|
+
data.style = getAttr(elm, 'style');
|
114
|
+
data.visited_color = getAttr(elm, 'vlink');
|
115
|
+
data.link_color = getAttr(elm, 'link');
|
116
|
+
data.active_color = getAttr(elm, 'alink');
|
75
117
|
}
|
118
|
+
|
119
|
+
return data;
|
76
120
|
},
|
77
121
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
122
|
+
_dataToHtml : function(data) {
|
123
|
+
var headerFragment, headElement, html, elm, value, dom = this.editor.dom;
|
124
|
+
|
125
|
+
function setAttr(elm, name, value) {
|
126
|
+
elm.attr(name, value ? value : undefined);
|
127
|
+
};
|
128
|
+
|
129
|
+
function addHeadNode(node) {
|
130
|
+
if (headElement.firstChild)
|
131
|
+
headElement.insert(node, headElement.firstChild);
|
132
|
+
else
|
133
|
+
headElement.append(node);
|
134
|
+
};
|
135
|
+
|
136
|
+
headerFragment = this._parseHeader();
|
137
|
+
headElement = headerFragment.getAll('head')[0];
|
138
|
+
if (!headElement) {
|
139
|
+
elm = headerFragment.getAll('html')[0];
|
140
|
+
headElement = new Node('head', 1);
|
141
|
+
|
142
|
+
if (elm.firstChild)
|
143
|
+
elm.insert(headElement, elm.firstChild, true);
|
144
|
+
else
|
145
|
+
elm.append(headElement);
|
146
|
+
}
|
147
|
+
|
148
|
+
// Add/update/remove XML-PI
|
149
|
+
elm = headerFragment.firstChild;
|
150
|
+
if (data.xml_pi) {
|
151
|
+
value = 'version="1.0"';
|
152
|
+
|
153
|
+
if (data.docencoding)
|
154
|
+
value += ' encoding="' + data.docencoding + '"';
|
155
|
+
|
156
|
+
if (elm.type != 7) {
|
157
|
+
elm = new Node('xml', 7);
|
158
|
+
headerFragment.insert(elm, headerFragment.firstChild, true);
|
159
|
+
}
|
160
|
+
|
161
|
+
elm.value = value;
|
162
|
+
} else if (elm && elm.type == 7)
|
163
|
+
elm.remove();
|
164
|
+
|
165
|
+
// Add/update/remove doctype
|
166
|
+
elm = headerFragment.getAll('#doctype')[0];
|
167
|
+
if (data.doctype) {
|
168
|
+
if (!elm) {
|
169
|
+
elm = new Node('#doctype', 10);
|
170
|
+
|
171
|
+
if (data.xml_pi)
|
172
|
+
headerFragment.insert(elm, headerFragment.firstChild);
|
173
|
+
else
|
174
|
+
addHeadNode(elm);
|
175
|
+
}
|
176
|
+
|
177
|
+
elm.value = data.doctype.substring(9, data.doctype.length - 1);
|
178
|
+
} else if (elm)
|
179
|
+
elm.remove();
|
180
|
+
|
181
|
+
// Add/update/remove title
|
182
|
+
elm = headerFragment.getAll('title')[0];
|
183
|
+
if (data.metatitle) {
|
184
|
+
if (!elm) {
|
185
|
+
elm = new Node('title', 1);
|
186
|
+
elm.append(new Node('#text', 3)).value = data.metatitle;
|
187
|
+
addHeadNode(elm);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
// Add meta encoding
|
192
|
+
if (data.docencoding) {
|
193
|
+
elm = null;
|
194
|
+
each(headerFragment.getAll('meta'), function(meta) {
|
195
|
+
if (meta.attr('http-equiv') == 'Content-Type')
|
196
|
+
elm = meta;
|
197
|
+
});
|
198
|
+
|
199
|
+
if (!elm) {
|
200
|
+
elm = new Node('meta', 1);
|
201
|
+
elm.attr('http-equiv', 'Content-Type');
|
202
|
+
elm.shortEnded = true;
|
203
|
+
addHeadNode(elm);
|
204
|
+
}
|
205
|
+
|
206
|
+
elm.attr('content', 'text/html; charset=' + data.docencoding);
|
207
|
+
}
|
208
|
+
|
209
|
+
// Add/update/remove meta
|
210
|
+
each('keywords,description,author,copyright,robots'.split(','), function(name) {
|
211
|
+
var nodes = headerFragment.getAll('meta'), i, meta, value = data['meta' + name];
|
212
|
+
|
213
|
+
for (i = 0; i < nodes.length; i++) {
|
214
|
+
meta = nodes[i];
|
215
|
+
|
216
|
+
if (meta.attr('name') == name) {
|
217
|
+
if (value)
|
218
|
+
meta.attr('content', value);
|
219
|
+
else
|
220
|
+
meta.remove();
|
221
|
+
|
222
|
+
return;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
if (value) {
|
227
|
+
elm = new Node('meta', 1);
|
228
|
+
elm.attr('name', name);
|
229
|
+
elm.attr('content', value);
|
230
|
+
elm.shortEnded = true;
|
231
|
+
|
232
|
+
addHeadNode(elm);
|
233
|
+
}
|
82
234
|
});
|
235
|
+
|
236
|
+
// Add/update/delete link
|
237
|
+
elm = headerFragment.getAll('link')[0];
|
238
|
+
if (elm && elm.attr('rel') == 'stylesheet') {
|
239
|
+
if (data.stylesheet)
|
240
|
+
elm.attr('href', data.stylesheet);
|
241
|
+
else
|
242
|
+
elm.remove();
|
243
|
+
} else if (data.stylesheet) {
|
244
|
+
elm = new Node('link', 1);
|
245
|
+
elm.attr({
|
246
|
+
rel : 'stylesheet',
|
247
|
+
text : 'text/css',
|
248
|
+
href : data.stylesheet
|
249
|
+
});
|
250
|
+
elm.shortEnded = true;
|
251
|
+
|
252
|
+
addHeadNode(elm);
|
253
|
+
}
|
254
|
+
|
255
|
+
// Update body attributes
|
256
|
+
elm = headerFragment.getAll('body')[0];
|
257
|
+
if (elm) {
|
258
|
+
setAttr(elm, 'dir', data.langdir);
|
259
|
+
setAttr(elm, 'style', data.style);
|
260
|
+
setAttr(elm, 'vlink', data.visited_color);
|
261
|
+
setAttr(elm, 'link', data.link_color);
|
262
|
+
setAttr(elm, 'alink', data.active_color);
|
263
|
+
|
264
|
+
// Update iframe body as well
|
265
|
+
dom.setAttribs(this.editor.getBody(), {
|
266
|
+
style : data.style,
|
267
|
+
dir : data.dir,
|
268
|
+
vLink : data.visited_color,
|
269
|
+
link : data.link_color,
|
270
|
+
aLink : data.active_color
|
271
|
+
});
|
272
|
+
}
|
273
|
+
|
274
|
+
// Set html attributes
|
275
|
+
elm = headerFragment.getAll('html')[0];
|
276
|
+
if (elm) {
|
277
|
+
setAttr(elm, 'lang', data.langcode);
|
278
|
+
setAttr(elm, 'xml:lang', data.langcode);
|
279
|
+
}
|
280
|
+
|
281
|
+
// Serialize header fragment and crop away body part
|
282
|
+
html = new tinymce.html.Serializer({
|
283
|
+
validate: false,
|
284
|
+
indent: true,
|
285
|
+
apply_source_formatting : true,
|
286
|
+
indent_before: 'head,html,body,meta,title,script,link,style',
|
287
|
+
indent_after: 'head,html,body,meta,title,script,link,style'
|
288
|
+
}).serialize(headerFragment);
|
289
|
+
|
290
|
+
this.head = html.substring(0, html.indexOf('</body>'));
|
291
|
+
},
|
292
|
+
|
293
|
+
_parseHeader : function() {
|
294
|
+
// Parse the contents with a DOM parser
|
295
|
+
return new tinymce.html.DomParser({
|
296
|
+
validate: false,
|
297
|
+
root_name: '#document'
|
298
|
+
}).parse(this.head);
|
83
299
|
},
|
84
300
|
|
85
301
|
_setContent : function(ed, o) {
|
86
|
-
var
|
302
|
+
var self = this, startPos, endPos, content = o.content, headerFragment, styles = '', dom = self.editor.dom, elm;
|
303
|
+
|
304
|
+
function low(s) {
|
305
|
+
return s.replace(/<\/?[A-Z]+/g, function(a) {
|
306
|
+
return a.toLowerCase();
|
307
|
+
})
|
308
|
+
};
|
87
309
|
|
88
310
|
// Ignore raw updated if we already have a head, this will fix issues with undo/redo keeping the head/foot separate
|
89
|
-
if (o.format == 'raw' &&
|
311
|
+
if (o.format == 'raw' && self.head)
|
90
312
|
return;
|
91
313
|
|
92
314
|
if (o.source_view && ed.getParam('fullpage_hide_in_source_view'))
|
93
315
|
return;
|
94
316
|
|
95
317
|
// Parse out head, body and footer
|
96
|
-
|
97
|
-
|
318
|
+
content = content.replace(/<(\/?)BODY/gi, '<$1body');
|
319
|
+
startPos = content.indexOf('<body');
|
98
320
|
|
99
|
-
if (
|
100
|
-
|
101
|
-
|
321
|
+
if (startPos != -1) {
|
322
|
+
startPos = content.indexOf('>', startPos);
|
323
|
+
self.head = low(content.substring(0, startPos + 1));
|
102
324
|
|
103
|
-
|
104
|
-
if (
|
105
|
-
|
325
|
+
endPos = content.indexOf('</body', startPos);
|
326
|
+
if (endPos == -1)
|
327
|
+
endPos = content.length;
|
106
328
|
|
107
|
-
o.content =
|
108
|
-
|
329
|
+
o.content = content.substring(startPos + 1, endPos);
|
330
|
+
self.foot = low(content.substring(endPos));
|
331
|
+
} else {
|
332
|
+
self.head = this._getDefaultHeader();
|
333
|
+
self.foot = '\n</body>\n</html>';
|
334
|
+
}
|
109
335
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
336
|
+
// Parse header and update iframe
|
337
|
+
headerFragment = self._parseHeader();
|
338
|
+
each(headerFragment.getAll('style'), function(node) {
|
339
|
+
if (node.firstChild)
|
340
|
+
styles += node.firstChild.value;
|
341
|
+
});
|
115
342
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
343
|
+
elm = headerFragment.getAll('body')[0];
|
344
|
+
if (elm) {
|
345
|
+
dom.setAttribs(self.editor.getBody(), {
|
346
|
+
style : elm.attr('style') || '',
|
347
|
+
dir : elm.attr('dir') || '',
|
348
|
+
vLink : elm.attr('vlink') || '',
|
349
|
+
link : elm.attr('link') || '',
|
350
|
+
aLink : elm.attr('alink') || ''
|
351
|
+
});
|
352
|
+
}
|
122
353
|
|
123
|
-
|
124
|
-
|
354
|
+
if (styles)
|
355
|
+
dom.add(self.editor.getDoc().getElementsByTagName('head')[0], 'style', {id : 'fullpage_styles'}, styles);
|
356
|
+
else
|
357
|
+
dom.remove('fullpage_styles');
|
358
|
+
},
|
125
359
|
|
126
|
-
|
127
|
-
|
360
|
+
_getDefaultHeader : function() {
|
361
|
+
var header = '', editor = this.editor, value, styles = '';
|
128
362
|
|
129
|
-
|
130
|
-
|
363
|
+
if (editor.getParam('fullpage_default_xml_pi'))
|
364
|
+
header += '<?xml version="1.0" encoding="' + editor.getParam('fullpage_default_encoding', 'ISO-8859-1') + '" ?>\n';
|
131
365
|
|
132
|
-
|
133
|
-
|
366
|
+
header += editor.getParam('fullpage_default_doctype', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
|
367
|
+
header += '\n<html>\n<head>\n';
|
134
368
|
|
135
|
-
|
136
|
-
|
369
|
+
if (value = editor.getParam('fullpage_default_title'))
|
370
|
+
header += '<title>' + v + '</title>\n';
|
137
371
|
|
138
|
-
|
139
|
-
|
140
|
-
|
372
|
+
if (value = editor.getParam('fullpage_default_encoding'))
|
373
|
+
header += '<meta http-equiv="Content-Type" content="text/html; charset=' + value + '" />\n';
|
374
|
+
|
375
|
+
if (value = editor.getParam('fullpage_default_font_family'))
|
376
|
+
styles += 'font-family: ' + value + ';';
|
377
|
+
|
378
|
+
if (value = editor.getParam('fullpage_default_font_size'))
|
379
|
+
styles += 'font-size: ' + value + ';';
|
380
|
+
|
381
|
+
if (value = editor.getParam('fullpage_default_text_color'))
|
382
|
+
styles += 'color: ' + value + ';';
|
383
|
+
|
384
|
+
header += '</head>\n<body' + (styles ? ' style="' + styles + '"' : '') + '>\n';
|
385
|
+
|
386
|
+
return header;
|
141
387
|
},
|
142
388
|
|
143
389
|
_getContent : function(ed, o) {
|
144
|
-
var
|
390
|
+
var self = this;
|
145
391
|
|
146
392
|
if (!o.source_view || !ed.getParam('fullpage_hide_in_source_view'))
|
147
|
-
o.content = tinymce.trim(
|
393
|
+
o.content = tinymce.trim(self.head) + '\n' + tinymce.trim(o.content) + '\n' + tinymce.trim(self.foot);
|
148
394
|
}
|
149
395
|
});
|
150
396
|
|
151
397
|
// Register plugin
|
152
398
|
tinymce.PluginManager.add('fullpage', tinymce.plugins.FullPagePlugin);
|
153
|
-
})();
|
399
|
+
})();
|