Seditio Source
Root |
./othercms/Cotonti-0.6.25/plugins/chili/js/jquery.chili.toolbar.js
/*
 * ChiliToolbar v1.4
 *
 * Copyright (c) 2009 Orkan (orkans@gmail.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Installation:
 * Put these two lines in <HEAD> section, after jquery.chili.js
 *   <script src="jquery.chili-toolbar.js" type="text/javascript"></script>
 *   <link href="jquery.chili-toolbar.css" type="text/css" rel="styleshee
 *
 * $Rev: 32 $
 * $Date:: 2008-10-17 #$
 * $Build: 13 (2009-05-09)
 *
 * Depends:
 * jquery.chili.js
 *
 */
(function(A){ChiliBook.Toolbar={Version:"1.4",Chili:A.fn.chili,Command:{ViewSource:{Label:"view plain",Cmd:function(B){var C=window.open("",ChiliBook.Toolbar.Utils.PopUpTarget,"width=750, height=400, resizable=1, scrollbars=0");C.document.write('<textarea style="width:99%;height:99%">'+A.data(B,"chili.text").replace("&","&amp;")+"</textarea>");C.document.close()}},CopyToClipboard:{Label:"copy to clipboard",Cmd:function(B){if(window.clipboardData){window.clipboardData.setData("text",A.data(B,"chili.text"));ChiliBook.Toolbar.Lang.Clipboard_Y&&alert(ChiliBook.Toolbar.Lang.Clipboard_Y)}else{if(ChiliBook.Toolbar.Clipboard.Swf){if(!ChiliBook.Toolbar.Clipboard.Div){ChiliBook.Toolbar.Clipboard.Div=A("<div/>").appendTo(document.body)}ChiliBook.Toolbar.Clipboard.Div.html('<embed src="'+ChiliBook.Toolbar.Clipboard.Swf+'" FlashVars="clipboard='+encodeURIComponent(A.data(B,"chili.text"))+'" width="0" height="0" type="application/x-shockwave-flash"></embed>');ChiliBook.Toolbar.Lang.Clipboard_Y&&alert(ChiliBook.Toolbar.Lang.Clipboard_Y)}else{ChiliBook.Toolbar.Lang.Clipboard_N&&alert(ChiliBook.Toolbar.Lang.Clipboard_N)}}}},PrintSource:{Label:"print",Cmd:function(B){var E=A("<iframe/>").css({position:"absolute",width:0,height:0,left:0,top:0}).appendTo(document.body).get(0);var D=E.contentWindow.document;var C=B.parentNode;ChiliBook.Toolbar.Utils.CopyStyles(D);D.write("<"+C.tagName+' class="'+C.className+'"><'+B.tagName+' class="'+B.className+'">'+B.innerHTML+"</"+B.tagName+"></"+C.tagName+">");D.close();E.contentWindow.focus();E.contentWindow.print();alert(ChiliBook.Toolbar.Lang.Printing);document.body.removeChild(E)}},About:{Label:"?",Cmd:function(C){var B='<div class="colored" style="height:200px; text-align:center"><strong><a href="http://orkans-tmp.22web.net/chili_toolbar/" target="{T}">ChiliToolbar v{V}</a></strong><div style="padding:1em 22px">Highlight your snippets with<br />jQuery&#039;s <a href="http://noteslog.com/chili/" target="{T}">Chili</a> code highlighter<br />and display it in a<br /><a href="http://code.google.com/p/syntaxhighlighter/" target="{T}">SyntaxHighlighter</a> way!<br /><br />&copy; 2008-2009 <a href="mailto:orkans@gmail.com" target="{T}">Orkan</a><br /><br /><input type="button" value="OK" onClick="window.close()" style="padding:0 1em" /></div></div>';var D=window.open("","","width=300, height=200, scrollbars=0");var E=D.document;ChiliBook.Toolbar.Utils.CopyStyles(E);E.write(B.replace("{V}",ChiliBook.Toolbar.Version).replace("{T}",ChiliBook.Toolbar.Utils.PopUpTarget));E.close();D.focus()}}},Clipboard:{Swf:"clipboard.swf",Div:null},Utils:{CopyStyles:function(F){for(var C=0;C<document.styleSheets.length;C++){var D=document.styleSheets[C];var B=D.ownerNode?D.ownerNode:D.owningElement;var E=typeof D.media=="string"?D.media:D.media.mediaText;if(B.tagName.toLowerCase()=="link"){F.write('<link href="'+B.href+'" rel="stylesheet" type="text/css" '+(E?'media="'+E+'"':"")+" />")}else{F.write('<style type="text/css" '+(E?'media="'+E+'"':"")+">"+(D.cssText?D.cssText:B.textContent)+"</style>")}}F.write('<style type="text/css" media="all">\nhtml,body {margin:0;padding:0}\n</style>')},IEOverflowFix:"1.5em",FFOverflowFix:"1.5em",PopUpTarget:"main"},Lang:{Clipboard_Y:"The code is in your clipboard now",Clipboard_N:"Sorry, the code cannot be copied to your clipboard",Printing:"Printing..."}};A.fn.chili=function(B){this.bind("chili.before_coloring",function(){var C=this,F=A(this),E=A("<div/>").addClass("bar"),D=A("<div/>").addClass("tools");A.each(ChiliBook.Toolbar.Command,function(G,H){A('<a href="javascript:;"><span>'+H.Label+"</span></a>").click(function(){H.Cmd(C)}).appendTo(D)});F.before(E.append(D));F.data("chili.text",F.text())});this.bind("chili.after_coloring",function(){if(this.scrollWidth>this.offsetWidth){var E=null;if(A.browser.msie&&ChiliBook.Toolbar.Utils.IEOverflowFix){E={"padding-bottom":ChiliBook.Toolbar.Utils.IEOverflowFix,"overflow-y":"hidden"}}else{if(A.browser.mozilla&&ChiliBook.Toolbar.Utils.FFOverflowFix){var C=A(this).find("li").length;var D=A(this).html().match(/(\x0A|<br>)/ig);if((C==1)||(D&&D.length==1)||(!C&&!D)){E={"line-height":ChiliBook.Toolbar.Utils.FFOverflowFix}}}}if(E){A(this).css(E)}}});ChiliBook.Toolbar.Chili.apply(this,[B])}})(jQuery);