Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improve the configuration options

  • Loading branch information...
commit b7e381e7974937edf91ea553c281b6c8ac999152 1 parent 0ecf9d9
@aercolino authored
View
82 src/core.js
@@ -1,12 +1,70 @@
+
+ $.extend($.chili, {
+ /**
+ * Returns the language piece of data for the given dom_element
+ *
+ * @param {Element} dom_element
+ *
+ * @return String
+ */
+ codeLanguage: function( dom_element ) {
+ var classes = $(dom_element).attr('class');
+ var matches = classes.match(/\bchili-lang-(\w+)/);
+ var result = matches ? matches[1] : '';
+ return result;
+ },
+
+ /**
+ * Returns the line numbers data for the given dom_element
+ *
+ * @param {Element} dom_element
+ *
+ * @return Array
+ */
+ codeLineNumbers: function( dom_element ) {
+ var classes = $(dom_element).attr('class');
+ var matches = classes.match(/\bchili-ln-(\d+)-([\w][\w\-]*)|\bchili-ln-(\d+)/);
+ var result = ! matches
+ ? null
+ : matches[3]
+ ? [ matches[0], matches[3], '' ]
+ : [ matches[0], matches[1], matches[2] ];
+ return result;
+ },
+
+ /**
+ * Returns the codes of any character of the given text
+ * (Used for developing Chili)
+ *
+ * @param {String} text
+ *
+ * @return String
+ */
+ revealChars: function ( text )
+ {
+ var result = [];
+ for (var i=0, iTop=text.length; i<iTop; i++)
+ {
+ result.push(text[i] + ' <- ' + text.charCodeAt(i));
+ }
+ result = result.join('\n');
+ return result;
+ },
+
+ queue: {},
+
+ recipes: {}
+ });
+
+
/**
- * Highlights currently selected elements according to the given options
+ * Highlights currently selected elements accordingly to the given options
*
* @param {Object} options
*/
$.fn.chili = function( options )
{
- var nbsp = '&#160;';
var system = {
version: "next", // development started on 2010-01-06
@@ -22,7 +80,7 @@
* the leading "&#160;" also helps fixing a bug in Opera that
* prevents empty list items from showing up in ordered lists
*/
- writingEOL: nbsp + "<br />",
+ writingEOL: '&#160;<br />',
/**
* we need readingEOL to find lines when adding numbers
@@ -30,16 +88,18 @@
* it must be the very end of line of writingEOL as it is read from
* the text of the element writingEOL was written into
*/
- readingEOL: "<br>",
+ readingEOL: '<br>',
- writingSpace: nbsp,
- writingTab: repeat( nbsp, $.chili.options.tabSpaces )
+ writingSpace: '&#160;',
+ writingTab: repeat( '&#160;', $.chili.whiteSpace.tabWidth )
};
- $.extend( $.chili, $.chili.options, options || {}, system );
+ var globals = $.extend({}, $.chili);
+ $.extend( $.chili, system, options || {} );
this.each(function()
{
askDish( this );
});
+ $.chili = globals;
return this;
/**
@@ -67,7 +127,7 @@
*/
function getRecipePath( recipeName )
{
- var result = $.chili.recipeFolder + 'jquery.chili.recipes.' + recipeName + '.js';
+ var result = $.chili.dynamic.origin + 'jquery.chili.recipes.' + recipeName + '.js';
return result;
}
@@ -637,7 +697,7 @@
return result;
}
var path = getRecipePath( detected['recipeName'] );
- if ( $.chili.recipeLoading )
+ if ( $.chili.dynamic.active )
{
// dynamic setups come here too
if (! $.chili.queue[ path ])
@@ -772,7 +832,7 @@
if ( '' == recipeName )
return;
var path = getRecipePath( recipeName );
- if ( $.chili.recipeLoading && ! $.chili.recipes[ recipeName ] )
+ if ( $.chili.dynamic.active && ! $.chili.recipes[ recipeName ] )
{
// dynamic setups come here
if ( ! $.chili.queue[ path ] )
@@ -813,7 +873,7 @@
function fixWhiteSpaceAfterReading( text )
{
text = text.replace(/\r\n?/g, '\n');
- if ( $.chili.options.suppressInitialEmptyLine )
+ if ( $.chili.whiteSpace.no1stLine )
{
text = text.replace(/^\n/, '');
}
View
20 src/examples/bad-php-is-ok-n.html
@@ -1,22 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - Bad PHP is OK</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - Bad PHP is OK</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
@@ -26,8 +14,8 @@
<script id="setup" type="text/javascript">
-$.chili.options.automatic = false;
-$.chili.options.lineNumbers = true;
+$.chili.options.automatic.active = false;
+$.chili.options.decoration.lineNumbers = true;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
18 src/examples/bad-php-is-ok.html
@@ -1,22 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - Bad PHP is OK</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - Bad PHP is OK</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
@@ -26,7 +14,7 @@
<script id="setup" type="text/javascript">
-$.chili.options.automatic = false;
+$.chili.options.automatic.active = false;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
12 src/examples/examples.css
@@ -1,14 +1,4 @@
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-
+/* http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino */
/* this is just some jQuery magic for your viewing pleasure */
img {
View
12 src/examples/examples.js
@@ -1,14 +1,4 @@
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-
+/* http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino */
/* this is just some jQuery magic for your viewing pleasure */
$( function() {
View
20 src/examples/geshi1.0.7.22-n.html
@@ -1,22 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - GeSHi 1.0.7.22</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - GeSHi 1.0.7.22</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
@@ -26,8 +14,8 @@
<script id="setup" type="text/javascript">
-$.chili.options.automatic = false;
-$.chili.options.lineNumbers = true;
+$.chili.options.automatic.active = false;
+$.chili.options.decoration.lineNumbers = true;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
18 src/examples/geshi1.0.7.22.html
@@ -1,22 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - GeSHi 1.0.7.22</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - GeSHi 1.0.7.22</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
@@ -26,7 +14,7 @@
<script id="setup" type="text/javascript">
-$.chili.options.automatic = false;
+$.chili.options.automatic.active = false;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
20 src/examples/html-css-javascript-n.html
@@ -1,22 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - HTML, CSS, JavaScript</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - HTML, CSS, JavaScript</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
@@ -26,8 +14,8 @@
<script id="setup" type="text/javascript">
-$.chili.options.automatic = false;
-$.chili.options.lineNumbers = true;
+$.chili.options.automatic.active = false;
+$.chili.options.decoration.lineNumbers = true;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
18 src/examples/html-css-javascript.html
@@ -1,22 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - HTML, CSS, JavaScript</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - HTML, CSS, JavaScript</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
@@ -26,7 +14,7 @@
<script id="setup" type="text/javascript">
-$.chili.options.automatic = false;
+$.chili.options.automatic.active = false;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
23 src/examples/jquery1.2.6-n.html
@@ -1,31 +1,20 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - jQuery 1.2.6</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - jQuery 1.2.6</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
<script id="setup" type="text/javascript">
-$.chili.options.recipeFolder = "../recipes/";
-$.chili.options.automatic = false;
-$.chili.options.lineNumbers = true;
+$.chili.options.dynamic.origin = "../recipes/";
+$.chili.options.automatic.active = false;
+$.chili.options.selection.active = false;
+$.chili.options.decoration.lineNumbers = true;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
21 src/examples/jquery1.2.6.html
@@ -1,30 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - jQuery 1.2.6</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - jQuery 1.2.6</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
<script id="setup" type="text/javascript">
-$.chili.options.recipeFolder = "../recipes/";
-$.chili.options.automatic = false;
+$.chili.options.dynamic.origin = "../recipes/";
+$.chili.options.automatic.active = false;
+$.chili.options.selection.active = false;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
19 src/examples/local-line-numbers.html
@@ -1,22 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - Local Line Numbers</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - Local Line Numbers</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
@@ -26,7 +14,6 @@
<script id="setup" type="text/javascript">
-$.chili.options.automatic = true;
</script>
<script type="text/javascript" src="examples.js"></script>
@@ -56,7 +43,7 @@ <h3 id="highlight" style="color:red; display:none;">
<div class="section">
<h3>CODE with class="chili-lang-php"</h3>
<p>
- A CODE without a line numbers class honors the lineNumbers option.
+ A CODE without a line numbers class honors the decoration.lineNumbers option.
</p>
<pre><code class="chili-lang-php">
/**#@+
View
20 src/examples/other-languages-n.html
@@ -1,30 +1,18 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - Other Languages</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - Other Languages</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
<script id="setup" type="text/javascript">
-$.chili.options.recipeFolder = "../recipes/";
-$.chili.options.lineNumbers = true;
+$.chili.options.dynamic.origin = "../recipes/";
+$.chili.options.decoration.lineNumbers = true;
</script>
View
18 src/examples/other-languages.html
@@ -1,29 +1,17 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - Other Languages</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - Other Languages</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
<script id="setup" type="text/javascript">
-$.chili.options.recipeFolder = "../recipes/";
+$.chili.options.dynamic.origin = "../recipes/";
</script>
View
20 src/examples/php-html-css-javascript-n.html
@@ -1,22 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - PHP, HTML, CSS, JavaScript</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - PHP, HTML, CSS, JavaScript</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
@@ -26,8 +14,8 @@
<script id="setup" type="text/javascript">
-$.chili.options.automatic = false;
-$.chili.options.lineNumbers = true;
+$.chili.options.automatic.active = false;
+$.chili.options.decoration.lineNumbers = true;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
18 src/examples/php-html-css-javascript.html
@@ -1,22 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- http://noteslog.com/chili/ - Copyright 2010 / Andrea Ercolino -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<title>TESTING CHILI 2.2 - PHP, HTML, CSS, JavaScript</title>
-
-<script type="text/javascript">
-/*
-===============================================================================
-Chili is the jQuery code highlighter plugin
-...............................................................................
-LICENSE: http://www.opensource.org/licenses/mit-license.php
-WEBSITE: http://noteslog.com/chili/
-
- Copyright 2008 / Andrea Ercolino
-===============================================================================
-*/
-</script>
+<title>TESTING CHILI 3.0 - PHP, HTML, CSS, JavaScript</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.chili.js"></script>
@@ -26,7 +14,7 @@
<script id="setup" type="text/javascript">
-$.chili.options.automatic = false;
+$.chili.options.automatic.active = false;
$( function() {
$( '#highlight' )
.one( 'click', function() {
View
2  src/jquery.chili.recipes.js
@@ -1,4 +1,4 @@
-jQuery.chili.options.recipeLoading = false;
+jQuery.chili.options.dynamic.active = false;
View
2  src/line_numbers.js
@@ -13,7 +13,7 @@
addLineNumbers( dom_element );
setLineNumbersStart.apply( dom_element, ln );
}
- else if ( $.chili.options.lineNumbers )
+ else if ( $.chili.decoration.lineNumbers )
{
addLineNumbers(dom_element);
}
View
6 src/runner.js
@@ -1,8 +1,10 @@
$(function()
{
- if ($.chili.options.automatic)
+ $.extend( $.chili, $.chili.options, $.chili.system );
+
+ if ($.chili.automatic.active)
{
- $($.chili.options.automaticSelector).chili();
+ $($.chili.automatic.selector, $.chili.automatic.context).chili();
}
});
View
23 src/text_selection.js
@@ -5,8 +5,8 @@
*/
function fixTextSelection( dom_element )
{
- //opera and safari select PRE text correctly
- if ($.browser.msie || $.browser.mozilla)
+ //chrome, opera, and safari select PRE text correctly
+ if ($.chili.selection.active && ($.browser.msie || $.browser.mozilla))
{
var element = null;
$(dom_element)
@@ -105,21 +105,24 @@
*/
function makeDialog( selected, event )
{
- var container_tag = $.browser.msie
- ? ('<textarea style="' + $.chili.options.selectionStyle + '">')
- : ('<pre style="' + $.chili.options.selectionStyle + '">');
+ var boxOptions = $.chili.selection.box;
+ var boxTag = $.browser.msie
+ ? ('<textarea style="' + boxOptions.style + '">')
+ : ('<pre style="' + boxOptions.style + '">');
- var result = $(container_tag)
+ var boxElement = $(boxTag)
.appendTo( 'body' )
.text( selected )
.attr( 'id', 'chili_selection' )
.click( function() { $(this).remove(); } )
;
- var top = event.pageY - Math.round( result.height() / 2 ) + "px";
- var left = event.pageX - Math.round( result.width() / 2 ) + "px";
- result.css( { top: top, left: left } );
+ var top = boxOptions.top(event.pageX, event.pageY,
+ boxElement.width(), boxElement.height());
+ var left = boxOptions.left(event.pageX, event.pageY,
+ boxElement.width(), boxElement.height());
+ boxElement.css( { top: top, left: left } );
- return result;
+ return boxElement;
}
/**
View
89 src/user_options.js
@@ -2,56 +2,45 @@
$.extend({
chili: {
options: {
- suppressInitialEmptyLine: true,
- tabSpaces: 4,
- automatic: true,
- automaticSelector: "code",
- lineNumbers: !true,
- recipeLoading: true,
- recipeFolder: "" // used like: recipeFolder + recipeName + '.js'
- },
- codeLanguage: function( el ) {
- var classes = $(el).attr('class');
- var matches = classes.match(/\bchili-lang-(\w+)/);
- var result = matches ? matches[1] : '';
- return result;
- },
- codeLineNumbers: function( el ) {
- var classes = $(el).attr('class');
- var matches = classes.match(/\bchili-ln-(\d+)-([\w][\w\-]*)|\bchili-ln-(\d+)/);
- var result = ! matches
- ? null
- : matches[3]
- ? [ matches[0], matches[3], '' ]
- : [ matches[0], matches[1], matches[2] ];
- return result;
- },
- selectionStyle: [
- "position:absolute; z-index:3000; overflow:scroll;",
- "width:16em;",
- "height:9em;",
- "border:1px solid gray;",
- "padding:15px;",
- "background-color:yellow;"
- ].join(' '),
- /**
- * Returns the codes of any character of the given text
- *
- * @param {String} text
- *
- * @return String
- */
- revealChars: function ( text )
- {
- var result = [];
- for (var i=0, iTop=text.length; i<iTop; i++)
- {
- result.push(text[i] + ' <- ' + text.charCodeAt(i));
+ whiteSpace: {
+ tabWidth: 4, //spaces
+ no1stLine: true //if empty
+ },
+ automatic: {
+ active: true,
+ selector: "code",
+ context: document
+ },
+ dynamic: {
+ active: true,
+ origin: '' //used like: recipeFolder + recipeName + '.js'
+ },
+ decoration: {
+ lineNumbers: !true
+ },
+ selection: {
+ active: true,
+ box: {
+ style: [
+ "position:absolute; z-index:3000; overflow:scroll;",
+ "width:16em;",
+ "height:9em;",
+ "border:1px solid gray;",
+ "padding:1em;",
+ "background-color:white;"
+ ].join(' '),
+ top: function(pageX, pageY, width, height)
+ {
+ var result = pageY - Math.round( height / 2 );
+ return result;
+ },
+ left: function(pageX, pageY, width, height)
+ {
+ var result = pageX /*- Math.round( width / 2 )*/;
+ return result;
+ }
+ }
}
- result = result.join('\n');
- return result;
- },
- queue: {},
- recipes: {} //repository
+ }
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.