/** * ネームスペースを作成する。 * @param {String} path 作成するネームスペース。"."区切りで指定。 */ function namespace( path ) { var strs = path.split("."); var c = (function () { return this; })(); // グローバルオブジェクトを取得。 for(var i=0;i 0 ) { this.table.deleteRows( 0, this.length() ); } this.table.addRows(data); if ( this.sortBy ) { this.table.sortColumn( this.table.getColumn( this.sortBy) ); } }, length : function() { return this.table.getRecordSet().getLength(); }, add: function( data ) { this.table.addRow(data); }, remove: function( data ) { this.table.deleteRow(data); }, update: function( row, data ) { this.table.updateRow( row, data ); } } /** * 日時を「YY-MM-DD HH:mm:ss」形式にフォーマットします。 */ util.formatDate = function( d ) { return "" + d.getFullYear() + "-" + util.fillZero( (d.getMonth()+1), 2) + "-" + util.fillZero( d.getDate(), 2) + " " + util.fillZero( d.getHours(), 2) + ":" + util.fillZero( d.getMinutes(), 2) + ":" + util.fillZero( d.getSeconds(), 2); } util.fillZero = function( number, size ) { var s = number != 0 ? Math.log( number ) * Math.LOG10E : 0; for( i=1,n=size-s,str="";i
  • ") + "
  • "; } else { el.innerHTML = ""; } } } /** * 日付入力UI */ util.DateInput = function(elementId, title, start, end ) { this.elementId = elementId; this.title = title; this.dialog; this.calendar; this.start = start; this.end = end; this.listener = new util.Listener(); } util.DateInput.prototype = { template : new Template( '
    '+ '
    #{title}
    '+ '
    '+ ' '+ '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    '+ '
    '+ '
    '+ '
    '), initialize : function() { var self = this; var el = document.getElementById( this.elementId ); el.innerHTML = this.template.evaluate( { elementId: this.elementId, title: this.title.escapeHTML() } ); this.calendar = new YAHOO.widget.Calendar(this.elementId+"_cal", { iframe:false, // Turn iframe off, since container has iframe support. hide_blank_weeks:true // Enable, to demonstrate how we handle changing height, using changeContent }); // 日本語化 this.calendar.cfg.setProperty("MDY_YEAR_POSITION", 1); this.calendar.cfg.setProperty("MDY_MONTH_POSITION", 2); this.calendar.cfg.setProperty("MDY_DAY_POSITION", 3); this.calendar.cfg.setProperty("MY_YEAR_POSITION", 1); this.calendar.cfg.setProperty("MY_MONTH_POSITION", 2); this.calendar.cfg.setProperty("MONTHS_SHORT", ["1\u6708", "2\u6708", "3\u6708", "4\u6708", "5\u6708", "6\u6708", "7\u6708", "8\u6708", "9\u6708", "10\u6708", "11\u6708", "12\u6708"]); this.calendar.cfg.setProperty("MONTHS_LONG", ["1\u6708", "2\u6708", "3\u6708", "4\u6708", "5\u6708", "6\u6708", "7\u6708", "8\u6708", "9\u6708", "10\u6708", "11\u6708", "12\u6708"]); this.calendar.cfg.setProperty("WEEKDAYS_1CHAR", ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"]); this.calendar.cfg.setProperty("WEEKDAYS_SHORT", ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"]); this.calendar.cfg.setProperty("WEEKDAYS_MEDIUM",["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"]); this.calendar.cfg.setProperty("WEEKDAYS_LONG", ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"]); this.calendar.cfg.setProperty("MY_LABEL_YEAR_POSITION", 1); this.calendar.cfg.setProperty("MY_LABEL_MONTH_POSITION", 2); this.calendar.cfg.setProperty("MY_LABEL_YEAR_SUFFIX", "\u5E74"); this.calendar.cfg.setProperty("MY_LABEL_MONTH_SUFFIX", ""); // 利用可能な範囲を示すレンダーを設定 var s = new Date( this.start ); var e = new Date( this.end ); this.calendar.addRenderer( s.getFullYear() + "/" + (s.getMonth()+1) + "/" + s.getDate() +"-" + e.getFullYear() + "/" + (e.getMonth()+1) + "/" + e.getDate(), this.calendar.renderCellStyleHighlight1); this.calendar.render(); // クリックされたらダイアログを閉じる。 this.calendar.selectEvent.subscribe(function() { if (self.calendar.getSelectedDates().length > 0) { var selDate = self.calendar.getSelectedDates()[0]; document.getElementById( self.elementId+"_date_input" ).value = selDate.getFullYear() + "-" + util.fillZero( (selDate.getMonth()+1), 2) + "-" + util.fillZero( selDate.getDate(),2); } self.hide(); self.listener.fire( "selected", {date: self.getDate()} ); }); // ボタン this.button = new util.Button( this.elementId + "_button", "calendar", function() { self.show(); }, "カレンダーを表示"); this.button.setEnable( true ); YAHOO.util.Event.addListener( document.getElementById( this.elementId +"_date_input") , "blur", function( ev ) { self.listener.fire( "blur", {date: self.getDate()} ); }); YAHOO.util.Event.addListener(document.body, "click", function( ev ) { if ( self.visible ) { var target = YAHOO.util.Event.getTarget( ev ); while( target ) { if ( target.id == self.elementId ) { return; } target = target.parentNode; } self.hide(); } } ); self.hide(); }, show: function() { document.getElementById(this.elementId + "_cal").style.visibility = "visible"; this.visible = true; }, hide: function() { document.getElementById(this.elementId + "_cal").style.visibility = "hidden"; this.visible = false; }, destroy: function() { document.getElementById(this.elementId).innerHTML = ""; }, getDate : function() { var text = document.getElementById( this.elementId+"_date_input" ).value; if ( !text ) return null; var matches = text.match( /^(\d{4})\-(\d{1,2})-(\d{1,2})$/ ); if ( !matches ) return null; return new Date( Number( matches[1] ), Number( matches[2]-1 ), Number( matches[3] )); } } /** * SWFを取得する。 */ util.getSwf = function( name ) { if (navigator.appName.indexOf("Microsoft") != -1) { return window[name]; } else { return document[name]; } } /** * 色選択UI */ util.ColorPicker = function(elementId, color,callback) { this.elementId = elementId; this.color = color; this.callback = callback; } util.ColorPicker.prototype = { body: new Template( '
    ' + '
    '+ '
    #{body}
    '+ '
    '), init: function() { var self = this; var top = ""; var bottom = ""; var current = top; var list = ["11","33","55","77","99","BB","DD","FF"]; for ( var g=0,gn=list.length;g' if ( r <= 3 ) { top += str; } else { bottom+=str; } } if (r ==3) { top += ""; } } bottom += ""; } var body = top + bottom + "
    "; var el = document.getElementById( this.elementId ); el.innerHTML = this.body.evaluate( { id:this.elementId, body:body } ); var thumb = document.getElementById( "picker_thumb_" + this.elementId ); thumb.style.backgroundColor = this.color; thumb.onclick = function( ev ) { self.show(); return false; } // イベントを割り当て var blocks = document.getElementById("picker_table_" + this.elementId ).getElementsByTagName( "div" ); var enter = function() { thumb.style.backgroundColor = this.style.backgroundColor; this.style.border = "1px solid #FFFFFF "; } var out = function() { thumb.style.backgroundColor = self.color; this.style.border = "1px solid " + this.style.backgroundColor; } var click = function() { thumb.style.backgroundColor = this.style.backgroundColor; self.color = this.style.backgroundColor; if ( self.callback ) { self.callback.call( null, self.color ); } } for ( var i=0,n=blocks.length;i= path.length ) return ""; return path.substring( i+1 ); }, /** * 末尾の"/"以前の名前を取得する */ dirname : function(path) { if (!path) return ""; var i = path.lastIndexOf("/"); if (i <= 0 ) return ""; return path.substring( 0, i ); }, /** * 指定ディリクトリ配下のファイル/フォルダであるか評価する * @param path {String} 評価対象のパス * @param dir {String} 親ディレクトリ * @return {Boolean} 親ディレクトリの配下の要素であればtrue */ isChild : function( path, dir ) { return path.startsWith( dir + "/" ); }, /** * パスの配列を探索し、親とその子が含まれていれば、親だけを残す。 * @param paths {Array:String} パスの配列 * @return {Array:String} 親のみのパス */ normarize : function(paths) { var result = []; paths = paths.sortBy( function( value ) { return value.length; } ); for ( var j=0;j