www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit f746fe5e9eac38468027b6ad17a9c8e08f5b5a55
parent 8368e5fc6b5f129f0fb42768eb956064d921d0d4
Author: gduperon <gduperon@5d9ba3ac-444b-4713-9fb3-0b58e79229a2>
Date:   Mon, 19 Apr 2010 00:42:38 +0000

Améliorations du log, début déffichage des blocs.

git-svn-id: https://projetud.info-ufr.univ-montp2.fr/svn/flin607-2009-gduperon@17 5d9ba3ac-444b-4713-9fb3-0b58e79229a2

Diffstat:
Mjside/ide.js | 58+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mjside/index.html | 15+++++++++++++--
Ajside/jquery.scrollTo.js | 216+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ajside/jquery.scrollTo.url | 1+
Mjside/style.css | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
5 files changed, 357 insertions(+), 9 deletions(-)

diff --git a/jside/ide.js b/jside/ide.js @@ -3,10 +3,66 @@ $(document).ready(function () { }); function init() { + $w = new world(); + + $('#nouveau-bloc').click(uiNouveauBloc); + $('#nouveau-lien').click(uiNouveauLien); + logPause = false; + $('#log-pause').click(logPauseToggle); + log("Démarré."); log("Ajoutez des blocs à l'espace de travail pour construire un programme."); } +function world() { + this.blocs = []; + this.maxuid = 0; + this.addBloc = function () { + var b = new bloc(this.maxuid++); + this.blocs.push(b); + return b; + } +} + +function bloc(uid) { + this.uid = uid; + this.nom = "Nouveau bloc"; + this.blocs = []; + this.connexions = []; +} + +function uiNouveauBloc() { + var b = $w.addBloc(); + $('#edition').append("<div id=\"edition-" + b.uid + "\"></div>"); + var div = $('#edition-' + b.uid); + div.width(250); + div.height(100); + div.css('top', 100); + div.css('left', 200); +/* div.left(100); */ + div.addClass("bloc parent"); + log("Nouveau bloc."); +} + +function uiNouveauLien() { + log("Nouveau lien."); +} + +function logPauseToggle() { + if (logPause) { + $('#log-contenu').stop().scrollTo($('#log-contenu :last'), 200); + logPause = false; + $('#log-pause').text("pause"); + } else { + logPause = true; + $('#log-contenu').stop(); + $('#log-pause').text("play"); + } +} + function log(msg) { - $('#log-content').append("<p>"+msg+"</p>"); + var elem = $('#log-contenu').append("<p>"+msg+"</p>"); + if (!logPause) { + $('#log-contenu').stop().scrollTo($('#log-contenu :last'), 100); + } } diff --git a/jside/index.html b/jside/index.html @@ -5,12 +5,23 @@ <title>IDE</title> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="jquery-1.4.2.js"></script> + <script type="text/javascript" src="jquery.scrollTo.js"></script> <script type="text/javascript" src="ide.js"></script> </head> <body id="body"> + <div id="outils"> + <a href="#" class="bouton" id="nouveau-bloc">Nouveau bloc</a> + <a href="#" class="bouton" id="nouveau-lien">Nouveau lien</a> + <div class="clear"></div> + </div> + <div id="edition"> + </div> <div id="log"> - <h2>Log</h2> - <div id="log-content"> + <div id="log-en-tete"> + <h2>Log</h2> + <a href="#" class="bouton" id="log-pause">pause</a> + </div> + <div id="log-contenu"> </div> </div> </body> diff --git a/jside/jquery.scrollTo.js b/jside/jquery.scrollTo.js @@ -0,0 +1,215 @@ +/** + * jQuery.ScrollTo + * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com + * Dual licensed under MIT and GPL. + * Date: 5/25/2009 + * + * @projectDescription Easy element scrolling using jQuery. + * http://flesler.blogspot.com/2007/10/jqueryscrollto.html + * Works with jQuery +1.2.6. Tested on FF 2/3, IE 6/7/8, Opera 9.5/6, Safari 3, Chrome 1 on WinXP. + * + * @author Ariel Flesler + * @version 1.4.2 + * + * @id jQuery.scrollTo + * @id jQuery.fn.scrollTo + * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements. + * The different options for target are: + * - A number position (will be applied to all axes). + * - A string position ('44', '100px', '+=90', etc ) will be applied to all axes + * - A jQuery/DOM element ( logically, child of the element to scroll ) + * - A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc ) + * - A hash { top:x, left:y }, x and y can be any kind of number/string like above. +* - A percentage of the container's dimension/s, for example: 50% to go to the middle. + * - The string 'max' for go-to-end. + * @param {Number} duration The OVERALL length of the animation, this argument can be the settings object instead. + * @param {Object,Function} settings Optional set of settings or the onAfter callback. + * @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'. + * @option {Number} duration The OVERALL length of the animation. + * @option {String} easing The easing method for the animation. + * @option {Boolean} margin If true, the margin of the target element will be deducted from the final position. + * @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }. + * @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes. + * @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends. + * @option {Function} onAfter Function to be called after the scrolling ends. + * @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends. + * @return {jQuery} Returns the same jQuery object, for chaining. + * + * @desc Scroll to a fixed position + * @example $('div').scrollTo( 340 ); + * + * @desc Scroll relatively to the actual position + * @example $('div').scrollTo( '+=340px', { axis:'y' } ); + * + * @dec Scroll using a selector (relative to the scrolled element) + * @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } ); + * + * @ Scroll to a DOM element (same for jQuery object) + * @example var second_child = document.getElementById('container').firstChild.nextSibling; + * $('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){ + * alert('scrolled!!'); + * }}); + * + * @desc Scroll on both axes, to different values + * @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } ); + */ +;(function( $ ){ + + var $scrollTo = $.scrollTo = function( target, duration, settings ){ + $(window).scrollTo( target, duration, settings ); + }; + + $scrollTo.defaults = { + axis:'xy', + duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1 + }; + + // Returns the element that needs to be animated to scroll the window. + // Kept for backwards compatibility (specially for localScroll & serialScroll) + $scrollTo.window = function( scope ){ + return $(window)._scrollable(); + }; + + // Hack, hack, hack :) + // Returns the real elements to scroll (supports window/iframes, documents and regular nodes) + $.fn._scrollable = function(){ + return this.map(function(){ + var elem = this, + isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1; + + if( !isWin ) + return elem; + + var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem; + + return $.browser.safari || doc.compatMode == 'BackCompat' ? + doc.body : + doc.documentElement; + }); + }; + + $.fn.scrollTo = function( target, duration, settings ){ + if( typeof duration == 'object' ){ + settings = duration; + duration = 0; + } + if( typeof settings == 'function' ) + settings = { onAfter:settings }; + + if( target == 'max' ) + target = 9e9; + + settings = $.extend( {}, $scrollTo.defaults, settings ); + // Speed is still recognized for backwards compatibility + duration = duration || settings.speed || settings.duration; + // Make sure the settings are given right + settings.queue = settings.queue && settings.axis.length > 1; + + if( settings.queue ) + // Let's keep the overall duration + duration /= 2; + settings.offset = both( settings.offset ); + settings.over = both( settings.over ); + + return this._scrollable().each(function(){ + var elem = this, + $elem = $(elem), + targ = target, toff, attr = {}, + win = $elem.is('html,body'); + + switch( typeof targ ){ + // A number will pass the regex + case 'number': + case 'string': + if( /^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ) ){ + targ = both( targ ); + // We are done + break; + } + // Relative selector, no break! + targ = $(targ,this); + case 'object': + // DOMElement / jQuery + if( targ.is || targ.style ) + // Get the real position of the target + toff = (targ = $(targ)).offset(); + } + $.each( settings.axis.split(''), function( i, axis ){ + var Pos = axis == 'x' ? 'Left' : 'Top', + pos = Pos.toLowerCase(), + key = 'scroll' + Pos, + old = elem[key], + max = $scrollTo.max(elem, axis); + + if( toff ){// jQuery / DOMElement + attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] ); + + // If it's a dom element, reduce the margin + if( settings.margin ){ + attr[key] -= parseInt(targ.css('margin'+Pos)) || 0; + attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0; + } + + attr[key] += settings.offset[pos] || 0; + + if( settings.over[pos] ) + // Scroll to a fraction of its width/height + attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos]; + }else{ + var val = targ[pos]; + // Handle percentage values + attr[key] = val.slice && val.slice(-1) == '%' ? + parseFloat(val) / 100 * max + : val; + } + + // Number or 'number' + if( /^\d+$/.test(attr[key]) ) + // Check the limits + attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max ); + + // Queueing axes + if( !i && settings.queue ){ + // Don't waste time animating, if there's no need. + if( old != attr[key] ) + // Intermediate animation + animate( settings.onAfterFirst ); + // Don't animate this axis again in the next iteration. + delete attr[key]; + } + }); + + animate( settings.onAfter ); + + function animate( callback ){ + $elem.animate( attr, duration, settings.easing, callback && function(){ + callback.call(this, target, settings); + }); + }; + + }).end(); + }; + + // Max scrolling position, works on quirks mode + // It only fails (not too badly) on IE, quirks mode. + $scrollTo.max = function( elem, axis ){ + var Dim = axis == 'x' ? 'Width' : 'Height', + scroll = 'scroll'+Dim; + + if( !$(elem).is('html,body') ) + return elem[scroll] - $(elem)[Dim.toLowerCase()](); + + var size = 'client' + Dim, + html = elem.ownerDocument.documentElement, + body = elem.ownerDocument.body; + + return Math.max( html[scroll], body[scroll] ) + - Math.min( html[size] , body[size] ); + + }; + + function both( val ){ + return typeof val == 'object' ? val : { top:val, left:val }; + }; + +})( jQuery ); +\ No newline at end of file diff --git a/jside/jquery.scrollTo.url b/jside/jquery.scrollTo.url @@ -0,0 +1 @@ +http://plugins.jquery.com/project/ScrollTo diff --git a/jside/style.css b/jside/style.css @@ -1,11 +1,13 @@ +body { + margin: 0; +} + #log { - border-top: thin solid gray; - padding-bottom: 1.7em; position: absolute; + top: 75%; bottom: 0; left: 0; right: 0; - height: 20%; } #log p { @@ -14,18 +16,80 @@ margin: 0; } -#log h2 { +#log-en-tete { padding: 0 1em; margin: 0; font-size: small; background-color: lightgray; } -#log-content { +#log h2 { + display: inline; + font-size: 100%; + margin-right : 1em; +} + +#log-en-tete .bouton { + color: #333; + border-color: #999; + background-color: #eee +} + +#log-en-tete .bouton:hover { + color: #555; + border-color: #ccc; + background-color: #fff +} + +#log-contenu { position: absolute; - top: 1em; + top: 1.7em; /* Hack, mais CSS ne nous permettra pas de faire mieux… :( */ bottom: 0; left: 0; right: 0; overflow: auto; +} + +#outils { + margin: 0; +} + +.bouton { + display: inline-block; + padding: 0.1em 0.2em; + margin: 0.2em; + text-decoration: none; + border-width: thin; + border-style: solid; +} + +#outils .bouton { + color: #242; + border-color: #8a8; + background-color: #efd; +} + +#outils .bouton:hover { + color: #422; + border-color: #a88; + background-color: #fed; +} + +#outils .clear { + clear:both; +} + +#edition { + position: absolute; + border: thick solid gray; + top: 1.9em; /* Hack, mais CSS ne nous permettra pas de faire mieux… :( */ + bottom: 25%; + left: 0; + right: 0; +} + +.bloc.parent { + background-color: lightgray; + border: medium solid gray; + position: absolute; } \ No newline at end of file