1. Benoît Bar
  2. jscop

Commits

Benoît Bar  committed 946566b Merge

released jscop 0.4 - refacto from scratch

  • Participants
  • Parent commits 4a7688f, 484a295
  • Branches default

Comments (0)

Files changed (37)

File .hgignore

View file
 ^\.settings$
 syntax: regexp
 ^doc$
-syntax: regexp
-^\.settings$

File LICENCE.txt

View file
+The contents of this file are subject to the Mozilla Public License Version
+1.1 (the "License"); you may not use this file except in compliance with the
+License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
+
+Software distributed under the License is distributed on an "AS IS" basis,
+WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+the specific language governing rights and limitations under the License.
+
+The Original Code is Jscop javascript library.
+
+The Initial Developer of the Original Code is Benoit Bar
+<benoit.bar@scopart.fr>. Portions created by Initial Developer are Copyright
+(C) 2011 the Initail Developer. All Rights Reserved.
+
+Contributor(s): Julien Antony <julien.antony@scopart.fr> Alexis Couronne
+<alexis.couronne@scopart.fr>
+
+Alternatively, the contents of this file may be used under the terms of the
+GNU General Public License Version 2 or later (the "GPL"), or the GNU Lesser
+General Public License Version 2.1 or later (the "LGPL"), in which case the
+provisions of the GPL or the LGPL are applicable instead of those above. If
+you wish to allow use of your version of this file only under the terms of
+either the GPL or the LGPL, and not to allow others to use your version of
+this file under the terms of the MPL, indicate your decision by deleting the
+provisions above and replace them with the notice and other provisions
+required by the GPL or the LGPL. If you do not delete the provisions above, a
+recipient may use your version of this file under the terms of any one of the
+MPL, the GPL or the LGPL.

File example/factory/index.html

View file
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+		<link type="text/css" rel="stylesheet" href="style.css" />
+		<title>Jscop - Logger example</title>
+	</head>
+	<body>
+		<h1>Factory</h1>
+		<pre id="code">
+			// parent constructor
+			function CarMaker(){};
+
+			// a method of the parent
+			CarMaker.prototype.drive = function(){
+				return "Vroom, I have " + this.doors + " doors";
+			};
+
+			// define specific car makers
+			CarMaker.Compact = function(){
+				this.doors = 4;
+			};
+			CarMaker.Convertible = function(){
+				this.doors = 2;
+			};
+			CarMaker.SUV = function(){
+				this.doors = 24;
+			};
+
+			// transform CarMaker to factory
+			JSCOP.factory.makeFactory(CarMaker);
+
+			// Build specific cars
+			var corolla = CarMaker.build('Compact');
+			var solstice = CarMaker.build('Convertible');
+			var cherokee = CarMaker.build('SUV');
+
+			console.debug(corolla.drive()); // "Vroom, I have 4 doors"
+			console.debug(solstice.drive()); // "Vroom, I have 2 doors"
+			console.debug(cherokee.drive()); // "Vroom, I have 24 doors"
+		</pre>
+		<script id="jscop" type="text/javascript" src="../../src/jscop.js"></script>
+		<script id="jscop" type="text/javascript" src="../../src/core/inheritance.js"></script>
+		<script id="jscop" type="text/javascript" src="../../src/core/factory.js"></script>
+		<script type="text/javascript" src="main.js"></script>
+	</body>
+</html>

File example/factory/main.js

View file
+eval(document.getElementById("code").innerHTML);

File example/iterator/index.html

View file
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+		<link type="text/css" rel="stylesheet" href="style.css" />
+		<title>Jscop - Logger example</title>
+	</head>
+	<body>
+		<h1>Iterator</h1>
+		<pre id="code">
+			// defined an iterable object
+			var a = [1,2,3,4];
+
+			// making it iterable
+			JSCOP.iterator.makeIterable(a);
+
+			// getting iterator
+			var i = a.iterator();
+
+			// using iterator
+			while( i.hasNext() ){
+				console.debug( "Element : " + i.next() );
+			}
+
+			// Element : 1
+			// Element : 2
+			// Element : 3
+			// Element : 4
+		</pre>
+		<script id="jscop" type="text/javascript" src="../../src/jscop.js"></script>
+		<script id="jscop" type="text/javascript" src="../../src/core/iterator.js"></script>
+		<script type="text/javascript" src="main.js"></script>
+	</body>
+</html>

File example/iterator/main.js

View file
+eval(document.getElementById("code").innerHTML);

File example/observer/index.html

View file
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+		<link type="text/css" rel="stylesheet" href="style.css" />
+		<title>Jscop - Logger example</title>
+	</head>
+	<body>
+		<h1>Observer</h1>
+		<pre id="code">
+			// implementing the publisher
+			var paper = {
+				daily: function () {
+					this.fire("daily", "big news today");
+				},
+				monthly: function () {
+					this.fire("monthly", "interesting analysis");
+				}
+			};
+
+			// making paper as observable
+			JSCOP.observer.makeObservable(paper);
+
+			// implementing the subscriber
+			var joe = {
+				drinkCoffee: function (paper) {
+					console.log('Just read ' + paper);
+				},
+				sundayPreNap: function (monthly) {
+					console.log('About to fall asleep reading this ' + monthly);
+				}
+			};
+
+			// joe subscribes to the paper
+			paper.on('daily', joe.drinkCoffee);
+			paper.on('monthly', joe.sundayPreNap);
+
+			paper.daily();		// Just read big news today
+			paper.daily();		// Just read big news today
+			paper.daily();		// Just read big news today
+			paper.monthly();	// About to fall asleep reading this interesting analysis
+		</pre>
+		<script id="jscop" type="text/javascript" src="../../src/jscop.js"></script>
+		<script id="jscop" type="text/javascript" src="../../src/core/observer.js"></script>
+		<script type="text/javascript" src="main.js"></script>
+	</body>
+</html>

File example/observer/main.js

View file
+eval(document.getElementById("code").innerHTML);

File media/css/testRunner.css

View file
-body {
-	
+#counter-container {
+	margin-top: 50px;
+	font-size: 2em;
 }
 
-#progress {
-	width: 620px;
+#exception-counter, #failure-counter, #success-counter {
+	padding: 5px 15px 5px 5px;
+	margin: 5px;	
 }
 
-#run {
-	width: 10%;
-	padding: 7px 0;
+#failure-counter, #success-counter {
+	border-right: 1px solid #dddddd;	
 }
 
-#progressbar {
-	width: 60%;
-	margin-left: 1%;
+#success-counter {
+	color:#264409;
 }
 
-#countTest {
-	width: 20%;
-	margin-left: 1%;
-	padding-top: 10px;
+#failure-counter {
+	color:#8a1f11;
+}
+.success, .failure {
+	margin: 5px;
+	padding: 5px;
+}
+.success {
+	background:#E6EFC2;
+	color:#264409;
+	border-color:#C6D880;
 }
 
-#console {
-	border: 1px solid #000000;
-	margin-top: 10px;
-	width: 500px;
-	max-height: 406px;
-	overflow-y: scroll;
-}
-
-#console div.testcase {
-	padding: 2px;
-	margin-bottom:2px;
-	border:2px solid #ddd;
-}
-
-#console div.testcase.error {
+.failure {
 	background:#FBE3E4;
 	color:#8a1f11;
 	border-color:#FBC2C4;
-}
-
-#console div.testcase.success {
-	background:#E6EFC2;
-	color:#264409;
-	border-color:#C6D880;
 }

File misc/build/build.properties

View file
-licence = /*\nThe contents of this file are subject to the Mozilla Public License\nVersion 1.1 (the "License"); you may not use this file except in\ncompliance with the License. You may obtain a copy of the License at\nhttp://www.mozilla.org/MPL/\n\nSoftware distributed under the License is distributed on an "AS IS"\nbasis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\nLicense for the specific language governing rights and limitations\nunder the License.\n\nThe Original Code is Jscop javascript library.\n\nThe Initial Developer of the Original Code is Benoit Bar <benoit.bar@scopart.fr>.\nPortions created by Initial Developer are Copyright (C) 2011\nthe Initail Developer. All Rights Reserved.\n\nContributor(s):\n\tJulien Antony <julien.antony@scopart.fr>\n\tAlexis Couronne <alexis.couronne@scopart.fr>\n\nAlternatively, the contents of this file may be used under the terms\nof the GNU General Public License Version 2 or later (the  "GPL"), or\nthe GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\nin which case the provisions of the GPL or the LGPL are applicable instead\nof those above. If you wish to allow use of your version of this file only\nunder the terms of either the GPL or the LGPL, and not to allow others to\nuse your version of this file under the terms of the MPL, indicate your\ndecision by deleting  the provisions above and replace them with the notice\nand other provisions required by the GPL or the LGPL. If you do not delete\nthe provisions above, a recipient may use your version of this file under\nthe terms of any one of the MPL, the GPL or the LGPL.\n*/
+licence = /*! Jscop https://bitbucket.org/benoit_bar/jscop | https://bitbucket.org/benoit_bar/jscop/src LICENCE.txt */
 src.dir = src
 dist.dir = media/js
 jsdoc.dir = misc/lib/jsdoc-toolkit
 jsdoc.dest = doc
-#core
-#jscop/jscop.js, jscop/core/string.js, jscop/core/date.js, jscop/core/array.js, jscop/core/math.js, jscop/core/extend.js, jscop/core/utils.js, jscop/core/logger.js
-js.list = jscop/jscop.js, jscop/core/string.js, jscop/core/date.js, jscop/core/array.js, jscop/core/math.js, jscop/core/extend.js, jscop/core/utils.js, jscop/core/logger.js 
-js.version = 0.3
+js.list.core = jscop.js, core/string.js, core/date.js, core/array.js, core/math.js, core/inheritance.js
+js.list.utils = utils/logger.js
+js.list.pattern = pattern/decorator.js, pattern/factory.js, pattern/iterator.js, pattern/observer.js,
+js.list = ${js.list.core}, ${js.list.utils}, ${js.list.pattern} 
+js.version = 0.4
 compressor.jar = misc/lib/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar

File misc/build/build.xml

View file
 		<delete file="${file}" quiet="true"/>
 	</target>
 	
-    <target name="compress" depends="-init">
-    	<java jar="${jsdoc.dir}/jsrun.jar" fork="true" failonerror="true">
+	<target name="doc" depends="-init">
+		<java jar="${jsdoc.dir}/jsrun.jar" fork="true" failonerror="true">
             <arg line="${jsdoc.dir}/app/run.js"/>
             <arg line="-a"/>
             <arg line="-t=${jsdoc.dir}/templates/codeview.1.2"/>
             <arg line="-r=4"/>
             <arg line="${src.dir}"/>
         </java>
+	</target>
+	
+    <target name="compress" depends="-init">
         <antcall target="concat">
             <param name="dest" value="${dist.dir}/jscop-${js.version}.js"/>
             <param name="filelist" value="${js.list}"/>

File misc/jscop-formatting.xml

-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<profiles version="11">
-<profile kind="CodeFormatterProfile" name="scopart" version="11">
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_colon_in_case" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_block_in_case" value="next_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_compact_if" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_empty_lines" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_after_annotation" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.format_header" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.format_block_comments" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_colon_in_object_initializer" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_between_type_declarations" value="0"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_assignment" value="0"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_semicolon_in_for" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.tabulation.size" value="4"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_closing_brace_in_block" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_colon_in_default" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_for" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.align_type_members_on_columns" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_catch" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_while" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_switch" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.continuation_indentation_for_objlit_initializer" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.compiler.compliance" value="1.5"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_before_closing_brace_in_objlit_initializer" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.format_source_code" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_for" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.wrap_before_binary_operator" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_for" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_while" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_after_package" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_after_comma_in_objlit_initializer" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_switch" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.format_javadoc_comments" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indentation.size" value="4"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_objlit_initializer" value="end_of_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.compiler.source" value="1.5"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_catch" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_switch" value="next_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_catch" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.continuation_indentation" value="2"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_conditional_expression" value="80"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_if" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.indent_parameter_description" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_after_imports" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_switch" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.indent_root_tags" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_before_package" value="0"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_before_member_type" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_enum_constants" value="0"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_before_imports" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_while" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_binary_expression" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.lineSplit" value="160"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.format_html" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_before_method" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_in_empty_method_body" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.compiler.codegen.targetPlatform" value="1.5"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.keep_empty_objlit_initializer_on_one_line" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_statements_compare_to_block" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.format_line_comments" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_in_empty_block" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_block" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
-<setting id="org.eclipse.wst.jsdt.core.compiler.problem.assertIdentifier" value="error"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_colon_in_object_initializer" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.line_length" value="80"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_block" value="next_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_multiple_fields" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.indent_statements_compare_to_body" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.tabulation.char" value="space"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_opening_paren_in_if" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_between_import_groups" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_before_field" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_after_opening_brace_in_objlit_initializer" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.compact_else_if" value="true"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_paren_in_if" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="insert"/>
-<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
-</profile>
-</profiles>

File src/core/array.js

View file
+if( JSCOP.isUndefined(Array.prototype.indexOf) ) {
+	/**
+	 * Returns the first (least) index of an element within the array equal to the
+	 * specified value, or -1 if none is found.
+	 *
+	 * @example
+	 * <pre>
+	 * var a = ['a', 'b', 'c'];
+	 * console.debug(a.indexOf('a'));	// 0
+	 * console.debug(a.indexOf('b'));	// 1
+	 * console.debug(a.indexOf('c'));	// 2
+	 * </pre>
+	 *
+	 * @this {Array}
+	 * @param {mixed} obj - Required. Element whose presence in this array is to be
+	 * tested.
+	 * @returns {Number} The first index of passed argument or -1 if none is found
+	 */
+	Array.prototype.indexOf = function(obj) {
+		var i,
+		length = this.length;
+		for( i = 0 ; i < length ; i += 1  ) {
+			if (this[i] === obj) {
+				return i;
+			}
+		}
+		return -1;
+	};
+}
+
+if( JSCOP.isUndefined(Array.prototype.lastIndexOf) ) {
+	/**
+	 * Returns the last (greatest) index of an element within the array equal to the
+	 * specified value, or -1 if none is found.
+	 *
+	 * @example
+	 * <pre>
+	 * var a = ['a', 'b', 'a'];
+	 * console.debug(a.lastIndexOf('a'))	// 2
+	 * </pre>
+	 *
+	 * @this {Array}
+	 * @param {mixed} obj - Required. Element whose presence in this array is to be
+	 * tested.
+	 * @returns {Number} The last index of passed argument or -1 if none is found
+	 */
+	Array.prototype.lastIndexOf = function(obj) {
+		var i;
+		for( i = this.length ; i ; --i  ) {
+			if (this[i] === obj) {
+				return i;
+			}
+		}
+		return -1;
+	};
+}
+
+if( JSCOP.isUndefined(Array.prototype.removeAt) ) {
+	/**
+	 * Removes the element at specified index from this array and returns the
+	 * removed element.
+	 *
+	 * @example
+	 * <pre>
+	 * var a = [ 'hello', 'world', '!' ];
+	 * a.removeAt( 1 );	// a = [ 'hello', '!' ]
+	 * </pre>
+	 *
+	 * @this {Array}
+	 * @param {Number} index - Required. An integer that specifies at what position
+	 * to remove element.
+	 * @returns {mixed} the removed element
+	 */
+	Array.prototype.removeAt = function( index ) {
+		this.splice( index, 1 );
+	};
+}
+
+if( JSCOP.isUndefined(Array.isArray) ) {
+	/**
+	 * Returns true if the passed argument is an array.
+	 *
+	 * @example
+	 * <pre>
+	 * var a = [1,2,3],
+	 * 	o = {props: 'a'},
+	 * 	f = function(){
+	 * 		return 'hello';
+	 * 	},
+	 * 	i = 3,
+	 * 	b = true,
+	 * 	s = 'a';
+	 * console.debug(Array.isArray(a));	// true
+	 * console.debug(Array.isArray(o));	// false
+	 * console.debug(Array.isArray(f));	// false
+	 * console.debug(Array.isArray(i));	// false
+	 * console.debug(Array.isArray(b));	// false
+	 * console.debug(Array.isArray(s));	// false
+	 * </pre>
+	 * @static
+	 * @param {mixed} obj - Required. Object to be tested.
+	 * @return {Boolean} True if the passed argument is an array.
+	 */
+	Array.isArray = function(obj) {
+		return Object.prototype.toString.call(obj) === "[object Array]";
+	};
+}

File src/core/date.js

View file
+JSCOP.namespace("JSCOP.date");
+/**
+ * @namespace JSCOP.date
+ */
+JSCOP.date = ( function() {
+	var masks,
+	i18n;
+	/**
+	 * Named masks
+	 *
+	 * @static
+	 * @fieldOf JSCOP.date
+	 */
+	masks = {
+		"default" : "ddd mmm dd yyyy HH:MM:ss",
+		shortDate : "m/d/yy",
+		mediumDate : "mmm d, yyyy",
+		longDate : "mmmm d, yyyy",
+		fullDate : "dddd, mmmm d, yyyy",
+		shortTime : "h:MM TT",
+		mediumTime : "h:MM:ss TT",
+		longTime : "h:MM:ss TT Z",
+		isoDate : "yyyy-mm-dd",
+		isoTime : "HH:MM:ss",
+		isoDateTime : "yyyy-mm-dd'T'HH:MM:ss",
+		isoUtcDateTime : "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
+	};
+
+	/**
+	 * i18n days and months name
+	 *
+	 * @static
+	 * @fieldOf JSCOP.date
+	 */
+	i18n = {
+		dayNames : [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
+		monthNames : [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June",
+		"July", "August", "September", "October", "November", "December" ]
+	};
+
+	return {
+		masks : masks,
+		i18n : i18n
+	}
+}());
+if( JSCOP.isUndefined(Date.prototype.format) ) {
+	/**
+	 * Return a formated date corresponding to a mask
+	 * <table>
+	 * <tr>
+	 * <th colspan="2"><u>Possible masks</u></th>
+	 * </td>
+	 * <tr>
+	 * <th>d</th>
+	 * <td>Day of the month as digits; no leading zero for single-digit days.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>dd</th>
+	 * <td> Day of the month as digits; leading zero for single-digit days.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>ddd</th>
+	 * <td>Day of the week as a three-letter abbreviation.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>dddd</th>
+	 * <td>Day of the week as its full name.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>m</th>
+	 * <td>Month as digits; no leading zero for single-digit months.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>mm</th>
+	 * <td>Month as digits; leading zero for single-digit months.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>mmm</th>
+	 * <td>Month as a three-letter abbreviation.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>mmmm</th>
+	 * <td>Month as its full name.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>yy</th>
+	 * <td>Year as last two digits; leading zero for years less than 10.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>yyyy</th>
+	 * <td>Year represented by four digits.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>h</th>
+	 * <td>Hours; no leading zero for single-digit hours (12-hour clock).</td>
+	 * </tr>
+	 * <tr>
+	 * <th>hh</th>
+	 * <td>Hours; leading zero for single-digit hours (12-hour clock).</td>
+	 * </tr>
+	 * <tr>
+	 * <th>H</th>
+	 * <td>Hours; no leading zero for single-digit hours (24-hour clock).</td>
+	 * </tr>
+	 * <tr>
+	 * <th>HH</th>
+	 * <td>Hours; leading zero for single-digit hours (24-hour clock).</td>
+	 * </tr>
+	 * <tr>
+	 * <th>M</th>
+	 * <td>Minutes; no leading zero for single-digit minutes. Uppercase M unlike CF
+	 * timeFormat's m to avoid conflict with months.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>MM</th>
+	 * <td>Minutes; leading zero for single-digit minutes. Uppercase MM unlike CF
+	 * timeFormat's mm to avoid conflict with months.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>s</th>
+	 * <td>Seconds; no leading zero for single-digit seconds.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>ss</th>
+	 * <td>Seconds; leading zero for single-digit seconds.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>l or L</th>
+	 * <td>Milliseconds. l gives 3 digits. L gives 2 digits.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>t</th>
+	 * <td>Lowercase, single-character time marker string: a or p. No equivalent in
+	 * CF.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>tt</th>
+	 * <td>Lowercase, two-character time marker string: am or pm. No equivalent in
+	 * CF.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>T</th>
+	 * <td>Uppercase, single-character time marker string: A or P. Uppercase T
+	 * unlike CF's t to allow for user-specified casing.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>TT</th>
+	 * <td>Uppercase, two-character time marker string: AM or PM. Uppercase TT
+	 * unlike CF's tt to allow for user-specified casing.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>Z</th>
+	 * <td>US timezone abbreviation, e.g. EST or MDT. With non-US timezones or in
+	 * the Opera browser, the GMT/UTC offset is returned, e.g. GMT-0500. No
+	 * equivalent in CF.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>o</th>
+	 * <td>GMT/UTC timezone offset, e.g. -0500 or +0230. No equivalent in CF.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>S</th>
+	 * <td>The date's ordinal suffix (st, nd, rd, or th). Works well with d. No
+	 * equivalent in CF.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>'…' or "…"</th>
+	 * <td>Literal character sequence. Surrounding quotes are removed. No
+	 * equivalent in CF.</td>
+	 * </tr>
+	 * <tr>
+	 * <th>UTC:</th>
+	 * <td>Must be the first four characters of the mask. Converts the date from
+	 * local time to UTC/GMT/Zulu time before applying the mask. The "UTC:" prefix
+	 * is removed. No equivalent in CF.</td>
+	 * </tr>
+	 * <tr>
+	 * <th colspan="2"><u>Named masks</u></th>
+	 * </tr>
+	 * <tr>
+	 * <th>default</th>
+	 * <td>ddd mmm dd yyyy HH:MM:ss</td>
+	 * </tr>
+	 * <tr>
+	 * <th>shortDate</th>
+	 * <td>m/d/yy</td>
+	 * </tr>
+	 * <tr>
+	 * <th>mediumDate</th>
+	 * <td>mmm d, yyyy</td>
+	 * </tr>
+	 * <tr>
+	 * <th>longDate</th>
+	 * <td>mmmm d, yyyy</td>
+	 * </tr>
+	 * <tr>
+	 * <th>fullDate</th>
+	 * <td>dddd, mmmm d, yyyy</td>
+	 * </tr>
+	 * <tr>
+	 * <th>shortTime</th>
+	 * <td>h:MM TT</td>
+	 * </tr>
+	 * <tr>
+	 * <th>mediumTime</th>
+	 * <td>h:MM:ss TT</td>
+	 * </tr>
+	 * <tr>
+	 * <th>longTime</th>
+	 * <td>h:MM:ss TT Z</td>
+	 * </tr>
+	 * <tr>
+	 * <th>isoDate</th>
+	 * <td>yyyy-mm-dd</td>
+	 * </tr>
+	 * <tr>
+	 * <th>isoTime</th>
+	 * <td>HH:MM:ss</td>
+	 * </tr>
+	 * <tr>
+	 * <th>isoDateTime</th>
+	 * <td>yyyy-mm-dd'T'HH:MM:ss</td>
+	 * </tr>
+	 * <tr>
+	 * <th>isoUtcDateTime</th>
+	 * <td>UTC:yyyy-mm-dd'T'HH:MM:ss'Z'</td>
+	 * </tr>
+	 * </table>
+	 *
+	 * @example
+	 *
+	 * <pre>
+	 * var date = new Date();
+	 * console.debug(date.format( "dd/mm/yyyy HH:MM:ss" ));	// 29/04/2011 16:27:33
+	 * </pre>
+	 *
+	 * @this {Date}
+	 * @param {String} mask - Optional. Mask for date formatting.
+	 * @param {Boolean} utc - Optional. Specified if date is utc or not.
+	 * @returns {String} the formated date depending of the specified format.
+	 */
+	Date.prototype.format = function( mask, utc ) {
+		var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
+			timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
+			timezoneClip = /[^-+\dA-Z]/g,
+			date = this,
+			masks = JSCOP.date.masks,
+			i18n = JSCOP.date.i18n;
+		/**
+		 * @ignore
+		 */
+		var pad = function( val, len ) {
+			val = String( val );
+			len = len || 2;
+			while( val.length < len ) {
+				val = "0" + val;
+			}
+			return val;
+		};
+		mask = String( masks[ mask ] || mask || masks[ "default" ] );
+
+		// Allow setting the utc argument via the mask
+		if( mask.slice( 0, 4 ) == "UTC:" ) {
+			mask = mask.slice( 4 );
+			utc = true;
+		}
+
+		var _ = utc ? "getUTC" : "get", d = date[ _ + "Date" ](), D = date[ _ + "Day" ](), m = date[ _ + "Month" ](), y = date[ _ + "FullYear" ](), H = date[ _
+		+ "Hours" ](), M = date[ _ + "Minutes" ](), s = date[ _ + "Seconds" ](), L = date[ _ + "Milliseconds" ](), o = utc ? 0 : date.getTimezoneOffset(), flags = {
+			d : d,
+			dd : pad( d ),
+			ddd : i18n.dayNames[ D ],
+			dddd : i18n.dayNames[ D + 7 ],
+			m : m + 1,
+			mm : pad( m + 1 ),
+			mmm : i18n.monthNames[ m ],
+			mmmm : i18n.monthNames[ m + 12 ],
+			yy : String( y ).slice( 2 ),
+			yyyy : y,
+			h : H % 12 || 12,
+			hh : pad( H % 12 || 12 ),
+			H : H,
+			HH : pad( H ),
+			M : M,
+			MM : pad( M ),
+			s : s,
+			ss : pad( s ),
+			l : pad( L, 3 ),
+			L : pad( L > 99 ? Math.round( L / 10 ) : L ),
+			t : H < 12 ? "a" : "p",
+			tt : H < 12 ? "am" : "pm",
+			T : H < 12 ? "A" : "P",
+			TT : H < 12 ? "AM" : "PM",
+			Z : utc ? "UTC" : ( String( date ).match( timezone ) || [ "" ] ).pop().replace( timezoneClip, "" ),
+			o : ( o > 0 ? "-" : "+" ) + pad( Math.floor( Math.abs( o ) / 60 ) * 100 + Math.abs( o ) % 60, 4 ),
+			S : [ "th", "st", "nd", "rd" ][ d % 10 > 3 ? 0 : ( d % 100 - d % 10 != 10 ) * d % 10 ]
+		};
+
+		return mask.replace( token, function( $0 ) {
+			return $0 in flags ? flags[ $0 ] : $0.slice( 1, $0.length - 1 );
+		} );
+	};
+}

File src/core/inheritance.js

View file
+JSCOP.namespace("inheritance");
+/**
+ * @namespace JSCOP.inheritance
+ */
+JSCOP.inheritance = ( function() {
+	/**
+	 * Copy all properties of parent in child
+	 *
+	 * @methodOf JSCOP.inheritance
+	 * @param {Object} parent - Required. The parent object
+	 * @param {Object} child - Optional. The child object
+	 * @return {Object} The child with parent properties
+	 */
+	function extend(parent, child) {
+		var i;
+		child = child || {};
+		for( i in parent ) {
+			if( parent.hasOwnProperty(i) ) {
+				child[i] = parent[i];
+			}
+		}
+		return child;
+	}
+
+	/**
+	 * Copy recursively all properties of parent in child
+	 *
+	 * @methodOf JSCOP.inheritance
+	 * @param {Object} parent - Required. The parent object
+	 * @param {Object} child - Optional. The child object
+	 * @return {Object} The child with parent properties
+	 */
+	function extendDeep(parent, child) {
+		var i,
+		toStr = Object.prototype.toString,
+		astr = "[object Array]";
+		child = child || {};
+		for( i in parent ) {
+			if( parent.hasOwnProperty(i) ) {
+				if( typeof parent[i] === "object" ) {
+					child[i] = (toStr.call(parent[i]) === astr) ? [] : {};
+					extendDeep(parent[i], child[i]);
+				} else {
+					child[i] = parent[i];
+				}
+			}
+		}
+		return child;
+	}
+
+	/**
+	 * Copy all properties of passed arguments to a child object
+	 *
+	 * @methodOf JSCOP.inheritance
+	 * @param {Object} parents - Required. A list of parent objects
+	 * @return {Object} A child with parents properties
+	 */
+	function mix() {
+		var arg, prop, child = {};
+		for( arg = 0 ; arg < arguments.length ; arg += 1 ) {
+			for( prop in arguments[arg] ) {
+				if( arguments[arg].hasOwnProperty(prop) ) {
+					child[prop] = arguments[arg][prop];
+				}
+			}
+		}
+		return child;
+	}
+
+	return {
+		extend: extend,
+		extendDeep: extendDeep,
+		mix: mix
+	};
+}());
+if( JSCOP.isUndefined(Function.prototype.method)  ) {
+	/**
+	 * Object augmentation. This method takes a method name and a function, adding
+	 * them to the object as a public method.
+	 *
+	 * @example
+	 * <pre>
+	 * function Parenizor( value ) {
+	 *     this.setValue( value );
+	 * }
+	 * Parenizor.method( 'setValue', function( value ) {
+	 *     this.value = value;
+	 *     return this;
+	 * });
+	 * Parenizor.method( 'getValue', function() {
+	 *     return this.value;
+	 * });
+	 * Parenizor.method( 'toString', function() {
+	 *     return '(' + this.getValue() + ')';
+	 * });
+	 *
+	 * var p = new Parenizor("Hello wolrd !");
+	 * console.debug(p.toString());	// (Hello wolrd !)
+	 * </pre>
+	 *
+	 * @this {Function}
+	 * @param {String} name - Required. The method name
+	 * @param {Function} func - Required. Implementation of the method
+	 * @returns {Function} Current class
+	 */
+	Function.prototype.method = function( name, func ) {
+		this.prototype[ name ] = func;
+		return this;
+	};
+}
+
+if( JSCOP.isUndefined(Object.create)  ) {
+	/**
+	 * Creates a new object whose prototype is the passed in parent object and whose
+	 * properties are those specified by descriptor.
+	 *
+	 * @example
+	 * <pre>
+	 * var parent = {
+	 * 	name: "Peter",
+	 *	say: function(){
+	 * 		return "My name is " + this.name;
+	 * 	}
+	 * }
+	 * var child = Object.create(parent, {
+	 * 	age: { value: 2 } // ECMA5 descriptor
+	 * });
+	 * console.debug(child.hasOwnProperty("name"));	// true
+	 * console.debug(child.hasOwnProperty("age"));	// true
+	 * console.debug(child.say());	// My name is Peter
+	 * </pre>
+	 *
+	 * @static
+	 * @param {Object} parent - Required. The parent object.
+	 * @param {Object} descriptor - Optionnal. Porperties of the new object
+	 * @return {Object} A new object based on parent
+	 */
+	Object.create = ( function() {
+		function F() {
+		};
+
+		return function (parent) {
+			F.prototype = parent;
+			return new F();
+		};
+	}());
+}
+
+if( JSCOP.isUndefined(Function.prototype.bind) ) {
+	/**
+	 * Sets the value of ‘this’ inside the function to always be the value of thisArg
+	 * when the function is called. Optionally, function arguments can be specified
+	 * (arg1, arg2, etc) that will automatically be prepended to the argument list
+	 * whenever this function is called.
+	 *
+	 * @example
+	 * <pre>
+	 * var one = {
+	 * 	name: "object",
+	 * 	say: function (greet) {
+	 * 		return greet + ", " + this.name;
+	 * 	}
+	 * };
+	 * one.say('hi');	// hi, object
+	 * var two = {
+	 * 	name: "another object",
+	 * 	say: function(greet){
+	 *		var twosay = one.say.bind(two);
+	 *		return twosay(greet);
+	 *	},
+	 * };
+	 * two.say('yo');	// yo, another object
+	 * </pre>
+	 *
+	 * @this {Function}
+	 * @param {Object} thisArg - Required. The scope of bind
+	 * @param {arguments} arguments - Optional. A list of arguments passe to the
+	 * binded function
+	 * @return {Function} - A function with thisArg as scope
+	 */
+	Function.prototype.bind = function( thisArg ) {
+		var fn = this,
+		slice = Array.prototype.slice,
+		args = slice.call(arguments, 1);
+		return function () {
+			return fn.apply(thisArg, args.concat(slice.call(arguments)));
+		}
+	};
+}

File src/core/math.js

View file
+if( JSCOP.isUndefined(Math.getLimitedNumber) ) {
+	/**
+	 * Returns the given value if it is contained between min and max or min/max if
+	 * value is outside.
+	 *
+	 * @example
+	 * <pre>
+	 * console.debug(Math.constrain(5, 1, 3));	// 3
+	 * console.debug(Math.constrain(5, 4, 9));	// 5
+	 * console.debug(Math.constrain(5, 7, 9));	// 7
+	 * </pre>
+	 * 
+	 * @static
+	 * @param {Number} value - Required. Value to be limited.
+	 * @param {Number} min - Required. Limit minimal.
+	 * @param {Number} max - Required. Limit maximal.
+	 * @returns {Number} the given value if it is contained between min and max or
+	 * min/max if value is outside.
+	 */
+	Math.constrain = function( value, min, max ) {
+		if( value < min ) {
+			return min;
+		}
+		if( value > max ) {
+			return max;
+		}
+		return value;
+	};
+}
+
+if( JSCOP.isUndefined(Math.hasIntersection) ) {
+	/**
+	 * Returns 1 if the two lines, defined by the given coordinates, intersect
+	 *
+	 * @example
+	 * <pre>
+	 * console.debug(Math.hasIntersection(0, 0, 2, 2, 2, 0, 0, 2));		// 1
+	 * console.debug(Math.hasIntersection(0, 0, 2, 2, -1, -1, 1, 1));	// -1
+	 * </pre>
+	 * 
+	 * @static
+	 * @param {Number} x1 - Required. first x coordinated of first line
+	 * @param {Number} y1 - Required. first y coordinated of first line
+	 * @param {Number} x2 - Required. second x coordinated of first line
+	 * @param {Number} y2 - Required. second y coordinated of first line
+	 * @param {Number} x3 - Required. first x coordinated of second line
+	 * @param {Number} y3 - Required. first y coordinated of second line
+	 * @param {Number} x4 - Required. second x coordinated of second line
+	 * @param {Number} y3 - Required. second y coordinated of second line
+	 * @returns {Number} 1 if the two lines intersect
+	 */
+	Math.hasIntersection = function( x1, y1, x2, y2, x3, y3, x4, y4 ) {
+		var D = {
+			x : x2 - x1,
+			y : y2 - y1
+		};
+		var E = {
+			x : x4 - x3,
+			y : y4 - y3
+		};
+		var denominator = D.x * E.y - D.y * E.x;
+		if( denominator == 0 ) {
+			return -1; // Error, borderline
+		}
+		var t = -( x1 * E.y - x3 * E.y - E.x * y1 + E.x * y3 ) / denominator;
+		if( t < 0 || t >= 1 ) {
+			return 0;
+		}
+		var u = -( -D.x * y1 + D.x * y3 + D.y * x1 - D.y * x3 ) / denominator;
+		if( u < 0 || u >= 1 ) {
+			return 0;
+		}
+		return 1;
+	};
+}

File src/core/string.js

View file
+if( JSCOP.isUndefined(String.prototype.startWith) ) {
+	/**
+	 * Check if string start with value parameter
+	 *
+	 * @example
+	 * <pre>
+	 * var s = "Hello world";
+	 * console.debug(s.startWith('Hel'));	// true;
+	 * console.debug(s.startWith('ell'));	// false;
+	 * </pre>
+	 * 
+	 * @this {String}
+	 * @param {String} value - Required. The search value in this string
+	 * @returns {Boolean} true if this string start with the specified value
+	 */
+	String.prototype.startWith = function( value ) {
+		return this.substring( value.length, 0 ) == value;
+	};
+}
+
+if( JSCOP.isUndefined(String.prototype.endWith) ) {
+	/**
+	 * Check if string end with value parameter
+	 *
+	 * @example
+	 * <pre>
+	 * var s = "Hello world";
+	 * console.debug(s.endWith('rld'));	// true;
+	 * console.debug(s.endWith('orl'));	// false;
+	 * </pre>
+	 * 
+	 * @this {String}
+	 * @param {String} value - Required. The search value in this string
+	 * @returns {Boolean} true if string end with the specified value.
+	 */
+	String.prototype.endWith = function( value ) {
+		var length = this.length;
+		return this.substring( (length - value.length), length ) == value;
+	};
+}

File src/jscop.js

View file
+/**
+ * @namespace JSCOP
+ */
+var JSCOP = JSCOP || ( function(global) {
+	var name = 'jscop',
+		version = '0.4',
+		imgUrl = '../img/';
+
+	/**
+	 * Return the framework name
+	 *
+	 * @methodOf JSCOP
+	 * @return {String} The name of the framework
+	 */
+	function getName() {
+		return name;
+	}
+
+	/**
+	 * Return the framework version
+	 *
+	 * @methodOf JSCOP
+	 * @return {String} The version of the framework
+	 */
+	function getVersion() {
+		return version;
+	}
+
+	/**
+	 * Return the url to images
+	 * 
+	 * @methodOf JSCOP
+	 * @return {String} The url for images
+	 */
+	function getImgUrl() {
+		return imgUrl;
+	}
+	
+	/**
+	 * Set the image url
+	 * 
+	 * @methodOf JSCOP
+	 * @param {String} url - Required. The new url for images
+	 */
+	function setImgUrl( url ) {
+		imgUrl = url;
+	}
+
+	/**
+	 * Define a namesapce if doesn't exist
+	 *
+	 * @methodOf JSCOP
+	 * @param {String} ns_string - Required. The namespace as string
+	 * @return {Object} the namespace object
+	 */
+	function namespace(ns_string) {
+		var parts = ns_string.split('.'),
+		parent = JSCOP,
+		i;
+
+		//strip redundant leading global
+		if( parts[0] === "JSCOP" ) {
+			parts = parts.slice(1);
+		}
+
+		for( i = 0 ; i < parts.length ; i++ ) {
+			// create a property if it doesn't exist
+			if( typeof parent[parts[i]] === "undefined" ) {
+				parent[parts[i]] = {};
+			}
+			parent = parent[parts[i]];
+		}
+		return parent;
+	}
+
+	/**
+	 * Test if the passed function is undefined
+	 *
+	 * @methodOf JSCOP
+	 * @param {Function} fn - Required. The function to test
+	 * @return {Boolean} True if the function is undefined
+	 */
+	function isUndefined(fn) {
+		return (typeof fn === "undefined");
+	}
+
+	/**
+	 * Test if the passed object is a function
+	 *
+	 * @methodOf JSCOP
+	 * @param {mixed} obj - Required. The object to test
+	 * @return {Boolean} True if the object is a function
+	 */
+	function isFunction(obj) {
+		return (typeof obj === 'function');
+	}
+
+	/**
+     * Preload a list of images after a delay
+     * 
+     * @methodOf JSCOP
+     * @params {Array} imgs - Required. A array of image urls
+     * @param {Number} delay - Optional. A delay in milliseconds before preloading images. 5000 By default.
+     */
+	function imagesPreload(imgs, delay) {
+		if( !Array.isArray(imgs) ) {
+			throw {
+				name: "Error",
+				message: "The imgs argument must be an array but it is a " + (typeof imgs)
+			}
+		}
+		var delay = delay || 5000,
+			i, 
+			cache = [], 
+			img;
+		setTimeout(function(){
+	        for( i = imgs.length ; i ; i -= 1 )
+	        {
+	            img = document.createElement( 'img' );
+	            img.src = imgs[ i - 1 ];
+	            if( cache.indexOf( img ) === -1 )
+	            {
+		            cache.push( img );
+	            }
+	        }
+		}, delay);
+	}
+	
+	return {
+		global : global,
+		namespace : namespace,
+		getName : getName,
+		getVersion: getVersion,
+		getImgUrl: getImgUrl,
+		setImgUrl: setImgUrl,
+		isUndefined : isUndefined,
+		isFunction : isFunction,
+		imagesPreload: imagesPreload
+	};
+}(this));

File src/jscop/core/utils.js

-/*
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
- * 
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * 
- * The Original Code is Jscop javascript library.
- * 
- * The Initial Developer of the Original Code is Benoit Bar
- * <benoit.bar@scopart.fr>. Portions created by Initial Developer are Copyright
- * (C) 2011 the Initail Developer. All Rights Reserved.
- * 
- * Contributor(s): Julien Antony <julien.antony@scopart.fr> Alexis Couronne
- * <alexis.couronne@scopart.fr>
- * 
- * Alternatively, the contents of this file may be used under the terms of the
- * GNU General Public License Version 2 or later (the "GPL"), or the GNU Lesser
- * General Public License Version 2.1 or later (the "LGPL"), in which case the
- * provisions of the GPL or the LGPL are applicable instead of those above. If
- * you wish to allow use of your version of this file only under the terms of
- * either the GPL or the LGPL, and not to allow others to use your version of
- * this file under the terms of the MPL, indicate your decision by deleting the
- * provisions above and replace them with the notice and other provisions
- * required by the GPL or the LGPL. If you do not delete the provisions above, a
- * recipient may use your version of this file under the terms of any one of the
- * MPL, the GPL or the LGPL.
- */
-
-/**
- * @namespace Provide utilities function
- */
-jscop.utils = {
-    /**
-     * Return a string representation of the given object
-     * 
-     * @static
-     * @param {mixed}
-     *            obj - Required. The object to show in string representation
-     * @returns {String} The string representation of the given object
-     */
-    toString : function( obj )
-    {
-        var s = '<object ';
-        for( var i in obj )
-        {
-            if( !$.isFunction( obj[ i ] ) )
-            {
-                s += i + '="' + obj[ i ] + '" ';
-            }
-        }
-        if( s.length > 1 )
-        {
-            s = s.substr( 0, s.length - 1 );
-        }
-        s += ' />';
-        return s;
-    },
-
-    /**
-     * Return the className of the given object
-     * 
-     * @param {Object}
-     *            obj - Required. Object for which the class name will be
-     *            returned
-     * @return {String} The class name of the given object
-     */
-    getClassName : function( obj )
-    {
-        if( obj && obj.constructor && obj.constructor.toString )
-        {
-            var arr = obj.constructor.toString().match( /function\s*(\w+)/ );
-            if( arr && arr.length == 2 )
-            {
-                return arr[ 1 ];
-            }
-        }
-        return undefined;
-    },
-
-    /**
-     * Return all methods name of the given object
-     * 
-     * @param {Object}
-     *            obj - Required. Object for which the class name will be
-     *            returned
-     * @return {String} The methods name of the given object
-     */
-    help : function( obj )
-    {
-        var s = this.getClassName( obj ) + '[ ';
-        for( var i in obj )
-        {
-            if( obj.hasOwnProperty( i ) )
-            {
-                s += i;
-                s += $.isFunction( obj[ i ] ) ? '(), ' : ', ';
-            }
-        }
-        if( s.length > 2 )
-        {
-            s = s.substr( 0, s.length - 2 );
-        }
-        s += ' ]';
-        return s;
-    }
-};

File src/pattern/decorator.js

View file
+if( JSCOP.isUndefined(Function.prototype.before) ) {
+	/**
+	 * Return a function that adds the function passed as arguments to execute before
+	 * the current function
+	 *
+	 * @example
+	 * <pre>
+	 * // function definition
+	 * var fn = function(name){
+	 * 	console.debug(name);
+	 * };
+	 * // decorator definition
+	 * fn = fn.before(function(){
+	 * 	console.debug('Hello');
+	 * });
+	 * fn('Peter');
+	 * // Hello
+	 * // Peter
+	 * </pre>
+	 * 
+	 * @this {Function}
+	 * @param {Function} beforeFunc - Required. The function to execute before
+	 * @param {obj} scope - Required. The object that defines the scope
+	 * @return {Function} A function who execute the decorator then the current
+	 * function
+	 */
+	Function.prototype.before = function(beforeFunc, scope) {
+		var self = this;
+		return function() {
+			beforeFunc.apply(scope, arguments);
+			return self.apply(scope, arguments);
+		};
+	};
+}
+
+if( JSCOP.isUndefined(Function.prototype.after) ) {
+	/**
+	 * Return a function that adds the function passed as arguments to execute after
+	 * the current function
+	 *
+	 * @example
+	 * <pre>
+	 * // function definition
+	 * var fn = function(name){
+	 * 	console.debug(name);
+	 * };
+	 * // decorator definition
+	 * fn = fn.after(function(){
+	 * 	console.debug('is alive !');
+	 * });
+	 * fn('Peter');
+	 * // Peter
+	 * // is alive !
+	 * </pre>
+	 * 
+	 * @this {Function}
+	 * @param {Function} afterFunc - Required. The function to execute after
+	 * @param {obj} scope - Required. The object that defines the scope
+	 * @return {Function} A function that execute the current function then the
+	 * decorator
+	 */
+	Function.prototype.after = function(afterFunc, scope) {
+		var self = this;
+		return function() {
+			var result = self.apply(scope, arguments);
+			afterFunc.apply(scope, arguments);
+			return result;
+		};
+	};
+}

File src/pattern/factory.js

View file
+JSCOP.namespace("JSCOP.factory");
+/**
+ * @namespace JSCOP.factory
+ * @requires JSCOP.inheritance
+ */
+JSCOP.factory = ( function() {
+	var inheritance = JSCOP.inheritance;
+
+	/**
+	 * Returns an object according to the type passed as argument
+	 *
+	 * @this {Object} The factory object
+	 * @param {String} type - Required. The type of the object to build
+	 * @return {Object} a new object according to the type
+	 */
+	function build(type) {
+		var newObj;
+		if( typeof this[type] !== "function" ) {
+			throw {
+				name : "Error",
+				message : type + " doesn't exist"
+			};
+		}
+
+		if( this[type].isAlreadyBuild === undefined ) {
+			inheritance.extend(this.prototype, this[type].prototype);
+			this[type].isAlreadyBuild = true;
+		}
+
+		newObj = new this[type]();
+		return newObj;
+	};
+
+	/**
+	 * Make an object as factory by adding the build function to the object passed as
+	 * argument
+	 *
+	 * @example
+	 * <pre>
+	 * // parent constructor
+	 * function CarMaker(){};
+	 *
+	 * // a method of the parent
+	 * CarMaker.prototype.drive = function(){
+	 * 	return "Vroom, I have " + this.doors + " doors";
+	 * };
+	 *
+	 * // define specific car makers
+	 * CarMaker.Compact = function(){
+	 * 	this.doors = 4;
+	 * };
+	 * CarMaker.Convertible = function(){
+	 * 	this.doors = 2;
+	 * };
+	 * CarMaker.SUV = function(){
+	 * 	this.doors = 24;
+	 * };
+	 *
+	 * // making CarMaker as factory
+	 * JSCOP.factory.makeFactory(CarMaker);
+	 *
+	 * // Build specific cars
+	 * var corolla = CarMaker.build('Compact');
+	 * var solstice = CarMaker.build('Convertible');
+	 * var cherokee = CarMaker.build('SUV');
+	 *
+	 * corolla.drive();		// "Vroom, I have 4 doors"
+	 * solstice.drive();	// "Vroom, I have 2 doors"
+	 * cherokee.drive();	// "Vroom, I have 24 doors"
+	 * </pre>
+	 *
+	 * @methodOf JSCOP.factory
+	 * @param {Object} o - Required. The object that will be a factory
+	 */
+	function makeFactory(o) {
+		o.build = build.bind(o);
+	}
+
+	return {
+		makeFactory: makeFactory
+	}
+
+}());

File src/pattern/iterator.js

View file
+JSCOP.namespace("JSCOP.iterator");
+/**
+ * @namespace JSCOP.iterator
+ */
+JSCOP.iterator = ( function() {
+	/**
+	 * Return an iterator object
+	 *
+	 * @param {mixed} data - Required. A object to be iterate
+	 * @return {Object} An iterator for data
+	 */
+	function iterator(data) {
+		var index = 0,
+		length = data.length;
+
+		return {
+			next : function() {
+				var element;
+				if( !this.hasNext() ) {
+					return null;
+				}
+				element = data[index];
+				index = index + 1;
+				return element;
+			},
+			hasNext : function() {
+				return index < length;
+			},
+			rewind : function() {
+				index = 0;
+			},
+			current : function() {
+				return data[index];
+			}
+		};
+	};
+
+	/**
+	 * Make an object as iterable by adding the method iterator to the object passed
+	 * as argument
+	 *
+	 * @example
+	 * <pre>
+	 * // defined an iterable object
+	 * var a = [1,2,3,4];
+	 * 
+	 * // making it iterable
+	 * JSCOP.iterator.makeIterable(a);
+	 * 
+	 * // getting iterator
+	 * var i = a.iterator();
+	 * 
+	 * // using iterator
+	 * while( i.hasNext() ){
+	 * 	console.debug( "Element : " + i.next() );
+	 * }
+	 * 
+	 * // Element : 1
+	 * // Element : 2
+	 * // Element : 3
+	 * // Element : 4
+	 * </pre>
+	 * 
+	 * @methodOf JSCOP.iterator
+	 * @param {Object} o - Required. The object that will be iterable
+	 * @param {data} data - Optional. The object that will be iterate. If undefined
+	 * data is the object passed as first argument
+	 */
+	function makeIterable(o, data) {
+		if( typeof o.iterator === "undefined" ) {
+			var d = data || o,
+			i = iterator(d);
+			/**
+			 * @ignore
+			 */
+			o.iterator = function() {
+				i.rewind();
+				return i;
+			};
+		}
+	}
+
+	return {
+		makeIterable: makeIterable
+	}
+}());

File src/pattern/observer.js

View file
+JSCOP.namespace("JSCOP.observer");
+/**
+ * @namespace JSCOP.observer
+ */
+JSCOP.observer = ( function() {
+	/**
+	 * A publisher object
+	 */
+	var publisher = {
+		/**
+		 * A list of subscribers
+		 *
+		 * @property subscribers
+		 * @type {Object}
+		 */
+		subscribers: {
+			any: []
+		},
+
+		/**
+		 * Add a subscriber for a type of event
+		 *
+		 * @this {publisher}
+		 * @name on
+		 * @methodOf {publisher}
+		 * @param {String} type - Required. The event type
+		 * @param {Function} fn - Required. The callback function when event type is
+		 * fired
+		 * @param {Object} context - Optional. The scope of the callback function
+		 */
+		on: function (type, fn, context) {
+			type = type || 'any';
+			fn = typeof fn === "function" ? fn : context[fn];
+			if (typeof this.subscribers[type] === "undefined") {
+				this.subscribers[type] = [];
+			}
+			this.subscribers[type].push({
+				fn: fn,
+				context: context || this
+			});
+		},
+		/**
+		 * Remove a subscriber for a type of event
+		 *
+		 * @this {publisher}
+		 * @name remove
+		 * @methodOf {publisher}
+		 * @param {String} type - Required. The event type
+		 * @param {Function} fn - Required. The callback function when event type is
+		 * fired
+		 * @param {Object} context - Optional. The scope of the callback function
+		 */
+		remove: function (type, fn, context) {
+			this.visitSubscribers('unsubscribe', type, fn, context);
+		},
+		/**
+		 * Fire an event type
+		 *
+		 * @this {publisher}
+		 * @name fire
+		 * @methodOf {publisher}
+		 * @param {String} type - Required. The event type
+		 * @param {mixed} publication - Optional. Arguments passed to callback of
+		 * subscribers
+		 */
+		fire: function (type, publication) {
+			this.visitSubscribers('publish', type, publication);
+		},
+		/**
+		 * Performed the passed argument action
+		 *
+		 * @this {publisher}
+		 * @name visitSubscribers
+		 * @methodOf {publisher}
+		 * @param {String} action - Required. The action to performed
+		 * @param {String} type - Required. The event type
+		 * @param {mixed} arg - Optional. Arguments passed to the subscribers's callback
+		 * function
+		 * @param {Object} context - Optional. The scope of subscribers's callback
+		 * function
+		 */
+		visitSubscribers: function (action, type, arg, context) {
+			var pubtype = type || 'any',
+			subscribers = this.subscribers[pubtype],
+			i,
+			max = subscribers ? subscribers.length : 0;
+			for (i = 0; i < max; i += 1) {
+				if (action === 'publish') {
+					subscribers[i].fn.call(subscribers[i].context, arg);
+				} else {
+					if (subscribers[i].fn === arg && subscribers[i].context === context) {
+						subscribers.splice(i, 1);
+					}
+				}
+			}
+		}
+	};
+
+	/**
+	 * Make an object as observable by copying all methods of publisher in the object
+	 * passed as argument
+	 *
+	 * @example
+	 * <pre>
+	 * // implementing the publisher
+	 * var paper = {
+	 * 	daily: function () {
+	 * 		this.fire("daily", "big news today");
+	 * 	},
+	 * 	monthly: function () {
+	 * 		this.fire("monthly", "interesting analysis");
+	 * 	}
+	 * };
+	 *
+	 * // making paper as observable
+	 * JSCOP.observer.makeObservable(paper);
+	 *
+	 * // implementing the subscriber
+	 * var joe = {
+	 *	drinkCoffee: function (paper) {
+	 *		console.log('Just read ' + paper);
+	 *	},
+	 *	sundayPreNap: function (monthly) {
+	 *		console.log('About to fall asleep reading this ' + monthly);
+	 *	}
+	 * };
+	 *
+	 * // joe subscribes to the paper
+	 * paper.on('daily', joe.drinkCoffee);
+	 * paper.on('monthly', joe.sundayPreNap);
+	 *
+	 * paper.daily();		// Just read big news today
+	 * paper.daily();		// Just read big news today
+	 * paper.daily();		// Just read big news today
+	 * paper.monthly();	// About to fall asleep reading this interesting analysis
+	 * </pre>
+	 *
+	 * @methodOf JSCOP.observer
+	 * @param {Object} o - Required. The object that will be observable
+	 */
+	function makeObservable(o) {
+		var i;
+		for (i in publisher) {
+			if (publisher.hasOwnProperty(i) && typeof publisher[i] === "function") {
+				o[i] = publisher[i];
+			}
+		}
+		o.subscribers = {
+			any: []
+		};
+	}
+
+	return {
+		makeObservable : makeObservable
+	}
+
+}());

File src/utils/logger.js

View file
+JSCOP.namespace("JSCOP.Logger");
+JSCOP.Logger = ( function() {
+	/**
+	 * Construct a Logger object
+	 *
+	 * @example
+	 * <pre>
+	 * //Build a logger with default settings
+	 * var logger = new JSCOP.Logger( "MyClass" );
+	 *
+	 * //Log messages in html console
+	 * JSCOP.Logger.settings.appender = JSCOP.Logger.HTMLLoggerAppender;
+	 * var logger = new JSCOP.Logger( "MyClass" );
+	 *
+	 * //Specified level for a class
+	 * JSCOP.Logger.settings.level = {
+	 *     "MyClass" : JSCOP.Logger.DEBUG,
+	 *     "OtherClass" : JSCOP.Logger.FATAL
+	 * }
+	 * // Note : the root level has priority over class levels
+	 * </pre>
+	 *
+	 * @constructor
+	 * @name JSCOP.Logger
+	 * @this {JSCOP.Logger}
+	 * @param {String} classLogged - Required. The class to log
+	 * @param {Object} appender - Optional. The console appender
+	 */
+	var Logger = function(classLogged, appender) {
+		this.classLogged = classLogged;
+		this.appender = appender === undefined ? Logger.settings.appender : appender;
+	}
+	/**
+	 * Append a debug message if it is to be displayed
+	 *
+	 * @name debug
+	 * @methodOf JSCOP.Logger.prototype
+	 * @this {JSCOP.Logger}
+	 * @param {String} message - Required. The message to log
+	 */
+	.method('debug', function(message) {
+		this.log('debug', Logger.DEBUG, message);
+	})
+	/**
+	 * Append an dir message if it is to be displayed
+	 *
+	 * @name dir
+	 * @methodOf JSCOP.Logger.prototype
+	 * @this {JSCOP.Logger}
+	 * @param {String} message - Required. The message to log
+	 */
+	.method('dir', function(message) {
+		this.log('dir', Logger.DIR, message);
+	})
+	/**
+	 * Append an info message if it is to be displayed
+	 *
+	 * @name info
+	 * @methodOf JSCOP.Logger.prototype
+	 * @this {JSCOP.Logger}
+	 * @param {String} message - Required. The message to log
+	 */
+	.method('info', function(message) {
+		this.log('info', Logger.INFO, message);
+	})
+	/**
+	 * Append an warn message if it is to be displayed
+	 *
+	 * @name warn
+	 * @methodOf JSCOP.Logger.prototype
+	 * @this {JSCOP.Logger}
+	 * @param {String} message - Required. The message to log
+	 */
+	.method('warn', function(message) {
+		this.log('warn', Logger.WARN, message);
+	})
+	/**
+	 * Append an error message if it is to be displayed
+	 *
+	 * @name error
+	 * @methodOf JSCOP.Logger.prototype
+	 * @this {JSCOP.Logger}
+	 * @param {String} message - Required. The message to log
+	 */
+	.method('error', function(message) {
+		this.log('error', Logger.ERROR, message);
+	})
+	/**
+	 * Append an fatal message if it is to be displayed and throw an error
+	 *
+	 * @name fatal
+	 * @methodOf JSCOP.Logger.prototype
+	 * @this {JSCOP.Logger}
+	 * @param {String} message - Required. The message to log
+	 */
+	.method('fatal', function(message) {
+		this.log('fatal', Logger.FATAL, message);
+		throw {
+			name: "Error",
+			message: "A fatal error occured : " + message
+		}
+	})
+	/**