/* * Stupidv1.4.8 - jQuery menu widget * Copyright (c) 2008 Joel Birch * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * CHANGELOG: */ ;(function($){ $.fn.stupid = function(settings,iplayer){ if(settings){ $.fn.stupid.settings=$.extend($.fn.stupid.defaults, settings); } return this.each(function(){ $.fn.stupid.init($(this),$.fn.stupid.settings); if(iplayer){ $.fn.stupid.player=iplayer; } }); }; var st = $.fn.stupid, unique = false; st.settings ={}; st.grid = []; st.defaults = { x_axise:[1,2,3,4,5,6,7,8], y_axise:[1,2,3,4,5,6,7,8], blurEvent:undefined, //@todo data.row,data.colum data:[], dtime:[], duration:2000, size:{'height':20,'width':20,'margin':10,'border':2} }; var _width = st.defaults.size.width, _height = st.defaults.size.height, _border = st.defaults.size.border, _margin = st.defaults.size.margin; /* * input with x-axise y-axise (Array),gird (double array) * default 10x15 grid * * */ //private function var randST = function(){ return (Math.random()*10) > 5 ? 's' :'t'; }, defaultGridData = function(){ var dataObject = new Array(st.settings.x_axise.length); for(var i=0;i').addClass('little_boy_house'); for(var ii=0;ii').addClass('LB-axises'), xaxise = $('
').addClass('LB-x-axise'), yaxise = $('
').addClass('LB-y-axise'), _x = st.settings.x_axise, _y = st.settings.y_axise; for(var i=0;i<_x.length; i=i+1){ $('').html(_x[i]) .width(_width).height(_height) .css('margin-left',(_border+_margin)) .css('margin-top',0).appendTo(xaxise); } xaxise.width(rows*(_width+_border+_margin)) .height(_height+_border) .css('margin-left',0+_width/2); for(var j=0;j<_y.length; j+=1){ $('').html(_y[j]).width(_width).height(_height) .css('margin-top',(_border+_margin)) .css('margin-left',0).appendTo(yaxise); } yaxise.height(colums*(_height+_border+_margin)) .width(_width+_border) .css('margin-top',-(_height+_border)+_height/2); axises.append(xaxise,yaxise).appendTo(st.wrapper); st.wrapper.height(colums*(_height+_margin+_border)) .width(rows*(_width+_margin+_border)); }; st.setGridsEvent = function(item,x,y){ $(item).mouseover(function(e){ e.currentTarget.focus(); var that = e.currentTarget; var temp = $(that).val(); $(that).keyup(function(evt){ switch(evt.keyCode){ case 83: $(that).val('s'); keyInValue(that,'s'); break; case 84: $(that).val('t'); keyInValue(that,'t'); break; // case 37: // @todo case 37 //left // case 38: //up // case 39: //right // case 40: //down } }); }); $(item).change(function(e){ var that=e.currentTarget; var temp = $(that).val(); if($(that).val() !=='s' && $(that).val() !=='t'){ $(that).val(temp.substr(0,1)); } }); var itid; $(item).focusin( function(){ if(st.player){ itid=window.setInterval(function(){ var time = st.settings.dtime[y][x]; st.player.seek(time); },st.settings.duration); } }); $(item).focusout(function(){ if(itid){ window.clearInterval(itid); } if(st.settings.blur!==undefined){ st.settings.blur.apply(item,item); } }); }; st.output = function(){ return st.dataObject.data; }; //@todo st.save default data => modify data output })(jQuery);