惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Palo Alto Networks Blog
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
博客园_首页
博客园 - 三生石上(FineUI控件)
G
Google Developers Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
P
Privacy & Cybersecurity Law Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
Secure Thoughts
爱范儿
爱范儿
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
H
Help Net Security
The Cloudflare Blog
Recorded Future
Recorded Future
Attack and Defense Labs
Attack and Defense Labs
J
Java Code Geeks
O
OpenAI News
T
Tor Project blog
B
Blog RSS Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
PCI Perspectives
PCI Perspectives
V
Visual Studio Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
About on SuperTechFans
www.infosecurity-magazine.com
www.infosecurity-magazine.com
W
WeLiveSecurity
Cyberwarzone
Cyberwarzone
云风的 BLOG
云风的 BLOG
Security Latest
Security Latest
S
Schneier on Security
Know Your Adversary
Know Your Adversary
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
Vulnerabilities – Threatpost
D
DataBreaches.Net
宝玉的分享
宝玉的分享
T
Troy Hunt's Blog
V
V2EX
Cisco Talos Blog
Cisco Talos Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Latest news
Latest news
量子位
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - {:)

[译]删除IE收藏夹下的“链接”文件夹 Javascript Cheat Sheet(Javascript 速查手冊) CSS Cheat-Sheet(CSS速查手冊) 我们不需要企业偶像,我们需要企业英雄 [轉]jQuery selectors (JQuery选择器) 和JQuery Cheat sheet (JQuery 速查手冊) YKWIM - {:) - 博客园 Discover the difference among Types: is operator,typeof keyword and GetType method the status code returned from the server was:500 Don't use GetType() with Page.ClientScript.RegisterClientScriptBlock() DNS 服務器地址被篡改 Outlook2007 連接到Exchange Server 失敗 装了KIS2009之后 10月22日链接篇: ASP.NET, Visual Studio, WPF 和 Silverlight - Scott Guthrie 博客中文版 - 博客堂 The Coding Standard Communication with the underlying transaction manager has failed 程序员八荣八耻 SCORM -LMS-SCO Data课件与平台交互机制圖解 解决安装SP3后,Window Media Player 播放器不能播放的问题 解決VS無法拖拽控件到頁面的問題 Use Refresh() function right in WebGrid with javascript
Some JavaScript Source Code About WebInput
{:) · 2008-07-01 · via 博客园 - {:)

/*
WebInput.NET CustomEditor V1.2 for WebGrid.NET Enterprise Version 3.5 and 4.0
Copyright (c) 2004 Intersoft Solutions Corp. All rights reserved.
Unauthorized distribution or modification of this script is strictly prohibited.

Last Modified Date: 5/2/2006
Version: 1.2.5000.13

Public Properties:
-

Set column-level properties for editor in CustomEditorProperties using WebGrid.NET Designer.

Features and behavior:
- Own key handler.
- No base editor.
- Full OOP and implemented advanced interface
- Support WebGrid.NET Enterprise 4.0

Dependencies:
-Shared\ISCore.jse (WebUI.NET Client Framework)
-WebInput\*.jse (WebInput Core Scripts)
*/

// Implementation object for WebInput.NET which contains set of required methods for custom editor interface.
// Format: CustomEditorName_Editor()
function WebInputNET_Editor()
{

 // #Start required interface implementation

 // Fired on WebGrid's initialization
 // Put codes to initialize custom editor's properties and create necessary objects here
 this.OnInitialize = function()
 {
 };

 // Initialize the WebInput only once
 this._Initialize = function()
 {
  var textEditor = this.GetTextEditor();
  var htmlObj = textEditor.HtmlObj;

  if (!textEditor._IsInitialized)
  {
   var grid = this.CustomEditor.Grid;
   var wi = this.GetTextEditorFrame();
   textEditor.HandleTab = true;
   Listener.Remove(htmlObj, "onkeydown", WIOnKeyDown_v1);
       Listener.Append(0, htmlObj, "onbeforedeactivate", WebInputNET_DeActivate);
       if (typeof(wgEditCtlKBHandler) == "function")
        Listener.Append(0, htmlObj, "onkeydown", function() {wgEditCtlKBHandler(grid, "WebInputNET"); WIOnKeyDown_v1(); WebInputNET_Keydown();});
       else
        Listener.Append(0, htmlObj, "onkeydown", function() {grid.EditKeyboardHandler("WebInputNET"); WIOnKeyDown_v1(); WebInputNET_Keydown();});
       
   Listener.Append(0, htmlObj, "onselectstart", function() {event.cancelBubble = true; event.returnValue = true; return true});
   grid.FrameObj.insertAdjacentElement("beforeEnd", wi);
   
   if (textEditor.DisplayFormat)
   {
    var _ctl = document.getElementById(textEditor.DisplayFormat.WindowInfo.ControlID);
    if (_ctl)
    {
     grid.FrameObj.insertAdjacentElement("beforeEnd", _ctl);
    }
   }
   
   if (textEditor.EditFormat)
   {
    var _ctl = document.getElementById(textEditor.EditFormat.WindowInfo.ControlID);
    if (_ctl)
    {
     grid.FrameObj.insertAdjacentElement("beforeEnd", _ctl);
    }
   
   }
   
   var ev = textEditor.Events;
   if (!ev) ev = new Object();
   if (!ev.OnDirty) ev.OnDirty = "";
   if (ev.OnDirty != "") ev.OnDirty += ";";
   
   ev.OnDirty += "WebInputNET_OnDirty('" + grid.Name + "')";
   
   textEditor.Events = ev;
   textEditor._IsInitialized = true;
  }
 };

 this.OnUnload = function()
 {
  var textEditor = this.GetTextEditor();
      Listener.Remove(textEditor.HtmlObj, "onbeforedeactivate", WebInputNET_DeActivate);
     Listener.Remove(textEditor.HtmlObj, "onkeydown", WebInputNET_Keydown);
 };

 // Fired when the control is entering edit mode
 // You can set default editor properties in this event
 this.OnEnterEditMode = function(activeCell, columnXml, isDirty)
 {

  this._Initialize();

  // use built-in WebGrid function to display the control
  var textEditorFrame = this.GetTextEditorFrame();

  wgDispObjGeneric(this.Grid, textEditorFrame, activeCell.element, 0, 1, false);

  // apply column-based editor properties if any
  this.SetProperties();

  // you should return the base editor element if any
  // otherwise, return the dropdown object

  var textEditor = this.GetTextEditor();
  
  if (textEditor.SkipSetValue) return textEditorFrame;
  
  //if (textEditor._WGI==null)
  //{
  // WGI always recreated because same instance can be used in multiple columns.
   var wgi = new Object();
   var dt = null;
   
   if (columnXml.attributes)
    dt = columnXml.attributes.getNamedItem("dataType").text;
   else
    dt = columnXml.DataType;
   
   dt = dt.replace("System.", "").toLowerCase();
   switch(dt)
   {
    case "single" :
    case "float" :
    case "double" :
    case "decimal" :
    case "sbyte" :
    case "byte" :
    case "short" :
    case "ushort" :
    case "int" :
    case "uint" :
    case "long" :
    case "ulong" :
    case "int16" :
    case "int32" :
    case "int64" :
    case "uint16" :
    case "uint32" :
    case "uint64" : wgi.dataType = "number"; break;
    default : wgi.dataType = dt;
   }

   if (columnXml.attributes)
    wgi.dataFormat = columnXml.attributes.getNamedItem("dataFormat").text;
   else
    wgi.dataFormat = columnXml.DataFormatString;

   if (wgi.dataType=="datetime")
   {
    var dti = textEditor.CultureInfo.DateTimeFormatInfo;
    if (wgi.dataFormat==null || wgi.dataFormat=="")
     wgi.dataFormat = dti.StandarFormat.GeneralLongTime;
    else
    {
     if (wgi.dataFormat.length==1) wgi.dataFormat = GetFullFormatDate(dti, wgi.dataFormat);
    }
   }

               textEditor._WGI = wgi;

  textEditorFrame.setActive();
  textEditor.DoFocus();
  textEditor.isDirty = false;
  textEditor.HtmlObj.isDirty = false;

  return textEditorFrame;
 };

 // Fired when the control is about to be displayed during enter edit mode.
 // The value of the editor need to be set to reflect current cell's text.
 this.OnSetValue = function(text, activeCell)
 {
  if (!this.ControlCreated) return false;

  var textEditor = this.GetTextEditor();
  if (textEditor.SkipSetValue) return;

  textEditor.isDirty = false;

  if (text == " ") text = "";

  var wgi = textEditor._WGI;
  var df = textEditor.DisplayFormat;
  var ef = textEditor.EditFormat;
  var dyf = textEditor.DynamicEditFormat;
  
  wgi.OldValue = text;

  if (df!=null || ef!=null || dyf!=null)
  {
   var ve = IS.GetValidationEngine();

   if (wgi.dataType=="datetime")
   {
    var cd = df!=null ? df.ClientData : ef.ClientData;
    with(cd)
    {
     Type = "DateTime";
     Format = wgi.dataFormat;
     OldValue = NewValue = text;
     PromptChar = null;
     IsValid = true;
    }
    ve.Validate(cd, textEditor.CultureInfo);
    var wgf = wgi.dataFormat;
    var dd = cd.DateData;
    if (wgf.indexOf("h")<0 && wgf.indexOf("H")<0) dd.Hour24 = dd.Hour12 = 1;
    if (wgf.indexOf("m")<0) dd.Minute = 0;
    if (wgf.indexOf("s")<0) dd.Second = 0;

    if ((wgf.indexOf("h")<0 && wgf.indexOf("H")<0) && wgf.indexOf("m")<0 && wgf.indexOf("s")<0)
                    {
                     with(cd)
         {
                          Format = textEditor.CultureInfo.DateTimeFormatInfo.StandarFormat.ShortDate;
      OldValue = NewValue = IS.GetCommonDateFormat(dd.Day, parseFloat(dd.Month)+1, dd.Year);
             }
    }
    else
    {
     var d = new Date(dd.Year, dd.Month, parseFloat(dd.Day), dd.Hour24, dd.Minute, dd.Second, dd.Fraction);
         var v = d.toDateString() + " " + d.toTimeString();
         with(cd)
         {
          Format = textEditor.CultureInfo.DateTimeFormatInfo.StandarFormat.GeneralLongTime;
                      OldValue = NewValue = v.substr(0, v.indexOf("UTC")-1);
     }
    }

    cd.IsValid = true;
    ve.Validate(cd, textEditor.CultureInfo);
    textEditor.Value = cd.FormattedValue;
   }
   else
   {
    if (wgi.dataType=="number")
    {
                     var cd = df!=null ? df.ClientData : (ef!=null ? ef.ClientData : dyf.ClientData);
     with(cd)
     {
      Type = "Number";
      Format = wgi.dataFormat;
      OldValue = NewValue = text;
      PromptChar = null;
      IsValid = true;
     }
     textEditor.Value = ve.UnMask(cd, textEditor.CultureInfo);
    }
    else
    {
     if (wgi.dataType=="string" && ef!=null)
     {
      textEditor.Text = textEditor.EditText = textEditor.Value = textEditor.HtmlObj.value = textEditor.EditFormat.ParseRawText(text);
     }
    }
   }
  }
  else
              textEditor.Text = textEditor.Value = text;

  if (textEditor.EditFormat==null)
  {
   textEditor.SetValueData(textEditor.Value);
  }
  else
  {
   var ef = textEditor.EditFormat;
   textEditor.EditText = textEditor.GetEditText();
   textEditor.SetValueData(textEditor.EditText);
  }

 };

 // Fired when the editor's content is changed.
 this.OnDirty = function() {
  var textEditor = this.GetTextEditor();
  textEditor.isDirty = true;
  this._GetLastEditCell().cellModified = true;
 };

 // Fired when the editor is about to exit edit mode
 this.OnExitEditMode = function(isCancel)
 {
  var textEditorFrame = this.GetTextEditorFrame();

  if (textEditorFrame && textEditorFrame.style.display != "none")
  {
   var te = this.GetTextEditor();
   te.DoLastBlur();
   te.HtmlObj.isActive = false;

   textEditorFrame.style.display = "none";

   if (isCancel)
   {
    if (!this.CustomEditor.IsRowDirty())
     this.OnCancel();
   } else
   {
    if (te.HtmlObj.isDirty || te.IsDirty)
    {
     this.OnDirty();
     var isValid = this.OnValidate();
     if (!isValid)
     {
      var curGrid = this.Grid;
      var activeCellElement = this.Grid.getLastEditObject().cellElement;
      var wi = te.EditFormat.WindowInfo;
      
      textEditorFrame.style.display = "";
      
      setTimeout(function()
      {
       // reactivate current edit object
       te.SkipSetValue = true;

       wgHighlightEditCell(activeCellElement);
       wgActivateEditMode(curGrid);
       textEditorFrame.setActive();
       te.SetFocus();

       te.SkipSetValue = false;
      }
      , 50
      );
      
      setTimeout(function()
      {
       // reshow error info
       WindowEngine.Show(wi);
       te.IsDirty = true;
      },
      500
      );
     }
     return isValid;
    }
   }
  }

  return true;
 };

 // Fired when the changes in editor is applied/accepted
 this.OnApply = function()
 {
  // not used in WebInput
 };

 // Fired when user cancel the changes in editor
 // by pressing Escape in editor or entire row changes cancel.
 this.OnCancel = function()
 {
  var textEditorFrame = this.GetTextEditorFrame();
        textEditorFrame.style.display = "none";

 };

 // Fired when the cell is about to exit edit mode
 // When the validation result is true, it will process to exit edit mode.
 this.OnValidate = function(activeCellElement)
 {
  var textEditor = this.GetTextEditor();
  var wgi = textEditor._WGI;
  var df = textEditor.DisplayFormat;
  var ef = textEditor.EditFormat;
  var dyf = textEditor.DynamicEditFormat;
  var isValid = false;
  if (ef)
  {
   var omv = document.getElementById(textEditor.Id + IS.MaskValidatorSuffix);
   isValid = MaskValidatorEvaluateIsValid(omv);
  }
  else
  {
   if (dyf)
   {
    var omv = document.getElementById(textEditor.Id + IS.MaskValidatorSuffix);
    isValid = DynamicMaskValidatorEvaluateIsValid(omv);
   }
   else
   {
    if (df)
    {
     var omv = document.getElementById(textEditor.Id + IS.FormatValidatorSuffix);
     isValid = FormatValidatorEvaluateIsValid(omv);
    }
   }
  }
  return isValid;
 };

 // Fired when user type on keyboard (only for customeditor that has baseeditor)
 this.OnKeyDown = function(keyCode)
 {
 };

 // Fired when dropdown button is clicked
 // Not used in WebInput
 this.OnDropdown = function()
 {
 };

 // Required method to get base editor element
 // Put codes to get the base editor element
 this.GetBaseEditorElement = function()
 {
  return this.GetTextEditorFrame();
 };

 // Required method to get dropdown button element
 // Put codes here to get the dropdown button element
 this.GetDropdownButtonElement = function()
 {
  return null;
 };

 // Required method to get dropdown list object
 this.GetDropdownObject = function()
 {
  return null;
 };

 // Required method to get the IsDirty status of the editor
 this.IsDirty = function()
 {
  var textEditor = this.GetTextEditor();
  return textEditor.isDirty;
 };

 // Required method to get the content of the editor
 this.GetText = function()
 {
  // always return originalText since we dont want to update to cell content
  // unless Update button in WebInput.NET is clicked.
  var textEditor = this.GetTextEditor();
  var wgi = textEditor._WGI;
  var df = textEditor.DisplayFormat;
  var ef = textEditor.EditFormat;
  var dyf = textEditor.DynamicEditFormat;

  if (!textEditor.isDirty)
  {
   // not edited at all
   return wgi.OldValue;
  }

  if (df!=null || ef!=null || dyf!=null)
  {
   var ve = IS.GetValidationEngine();

   if (wgi.dataType=="datetime")
   {
    var cd = df!=null ? df.ClientData : ef.ClientData;
    var dd = cd.DateData;
    var wgf = wgi.dataFormat;
    if (wgf.indexOf("h")<0 && wgf.indexOf("H")<0) dd.Hour24 = dd.Hour12 = 0;
    if (wgf.indexOf("m")<0) dd.Minute = 0;
    if (wgf.indexOf("s")<0) dd.Second = 0;
        var d = new Date(dd.Year, dd.Month, parseFloat(dd.Day), dd.Hour24, dd.Minute, dd.Second, dd.Fraction);
        var v = d.toDateString() + " " + d.toTimeString();
    v = v.substr(0, v.indexOf("UTC")-1);
    with(cd)
    {
     Type = "DateTime";
     Format = wgi.dataFormat;
     OldValue = NewValue = v;
     PromptChar = null;
     IsValid = true;
    }
    if (ve.Validate(cd, textEditor.CultureInfo))
     return cd.FormattedValue;
    else
     return textEditor.Text;
   }
   else
   {
    if (wgi.dataType=="number")
    {
                     var cd = df!=null ? df.ClientData : (ef!=null ? ef.ClientData : dyf.ClientData);
     with(cd)
     {
      Type = "Number";
      Format = wgi.dataFormat;
      OldValue = NewValue = textEditor.Value;
      PromptChar = null;
      IsValid = true;
     }
     if (ve.Validate(cd, textEditor.CultureInfo))
      return cd.FormattedValue;
     else
      return textEditor.Text;
    }
    else
    {
     if (wgi.dataType=="string" && ef!=null)
     {
      return textEditor.EditText.replace(new RegExp(ef.MaskInfo.PromptChar, "g"), " ");
     }
    }
   }
  }
  return textEditor.Text;
 };

 // Required method to get the value of the editor
 // Only useful when editor value is differ then content/text such as in Dropdownlist.
 this.GetValue = function()
 {
  // since this editor has same value and content,
  // simply return the text
  return this.GetText();
 };

 // Required method to apply editor properties defined in Column's CustomEditorProperties
 this.SetProperties = function()
 {
  var props = this.CustomEditor.GetColumnEditorProperties();
  var aProps = props.split(";");
  for (var i=0; i<aProps.length; i++)
  {
   this.SetProperty(aProps[i].split("=")[0], aProps[i].split("=")[1]);
  }
 };
 
 
 // Indicates whether default behavior of exit edit mode should be processed
 // This method is optional.
 this.ShouldProcessExitEditModeDefaultBehavior = function()
 {
  return true;
 };
 
 // Indicates the cell's content mode
 // This method is optional.
 this.GetContentMode = function()
 {
  // valid value is "Text" or "HTML"
  // if this method is not implemented, the default is Text.
  return "Text";
 };
 
 // #End interface implementation


 // #Start required properties
 
 this.Grid = null;
 this.CustomEditor = null;
 this._IsInitialized = false;
 
 // #End properties
 
 // #Start WebInput.NET editor functions
 this.DDBtn = null;
 this.ControlName = "WebInput.NET";
 this.OriginalText = "";
 this.ControlCreated = true;
 
 // Required method to apply individual property
 this.SetProperty = function(propName, propValue)
 {

  
 };

 // Method to initialize dropdown object (rich textbox server control)
 this.InitializeDropdownObject = function()
 {
  return true;
 };

 this.GetTextEditor = function()
 {
  var controlID = this._GetLastEditorClientID();
  var editor = IS.GetRuntimeObjectById(controlID);
  
  if (controlID.indexOf("$") > -1 && editor == null)
  {
      for (var i=0; i<IS.RuntimeObjects.length; i++)
      {
          if (IS.RuntimeObjects[i].ServerUniqueID == controlID)
          {
              editor = IS.RuntimeObjects[i];
              break;
          }
      }
  }
  editor.CustomEditor = this;
  return editor;
 };

 this.GetTextEditorFrame = function()
 {
  var controlID = this._GetLastEditorClientID();
  var editorF = document.getElementById(controlID + IS.FrameSuffix);

  return editorF;
 };

 this.GetContentCell = function()
 {
  var rowEl = this.CustomEditor.GetEditRowElement();
  if (wgIsRecordRow(rowEl))
  {
   // if row type is record
   return this.CustomEditor.GetEditCellElement();
  }
  else
  {
   // row type is either newrow or filterrow
   return this.CustomEditor.GetEditCellElement();
  }
 };

 this._GetLastEditCell = function()
 {
  if (this.Grid.LastEditObj)
   return this.Grid.LastEditObj.cellElement;
  else
   return this.CustomEditor.GetEditCellElement();
 };
 
 this._GetColumnXml = function()
 {
  var table = this.CustomEditor.GetTable();
  var name = wgGetColNameByCell(this._GetLastEditCell());
  var col = null;
  
  try { col = table.getColumn(name); }
  catch(e) { col = table.GetColumn(name); }
  return col;
 };

 this._GetLastEditorClientID = function() {
  var colXml = this._GetColumnXml();
  
  if (colXml.CustomEditorServerID)
  {
      var ServerID = colXml.CustomEditorServerID.replace("$", "_");
      return ServerID;
  }
  
  if (colXml.CustomEditorServerId)
   return colXml.CustomEditorServerId;
  else
   return colXml.getAttribute("ceID");
 };  
 // #End functions
 
return this;
}

function WebInputNET_Keydown()
{
  var c = IS.GetRuntimeObjectById(event.srcElement.id);

 if (c.CustomEditor)
 {
  var keyCode = event.keyCode;

  if (keyCode == 9)
  {
   event.cancelBubble = false;
   event.returnValue = false;
   event.keyCode = 0;
   return false;
  }
 }
 return true;
}

function WebInputNET_DeActivate()
{
 var c = IS.GetRuntimeObjectById(window.event.srcElement.id);
 if (c.CustomEditor)
 {
  if (c.isDirty) c.CustomEditor.OnApply();
 }
 event.returnValue = true;
 return true;
}

function WebInputNET_OnDirty(gridName)
{
 var grid = wgGetGridById(gridName);
 if (typeof(wgMarkEdit) == "function")
  wgMarkEdit(grid);
 else
  grid.MarkEdit();
}