Modified:
/exhibit/trunk/src/webapp/api/extensions/data-editor/README.txt
/exhibit/trunk/src/webapp/api/extensions/data-editor/data-editor-extension-bundle-debug.js
/exhibit/trunk/src/webapp/api/extensions/data-editor/data-editor-extension-bundle.css
/exhibit/trunk/src/webapp/api/extensions/data-editor/data-editor-extension-bundle.js
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/data-editor.js
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/editor.js
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/enum-field.js
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/list-field.js
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/number-field.js
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/text-field.js
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/ticklist-field.js
/exhibit/trunk/src/webapp/api/extensions/data-editor/styles/data-editor.css
=======================================
--- /exhibit/trunk/src/webapp/api/extensions/data-editor/README.txt Tue
Jan 3 04:39:05 2012
+++ /exhibit/trunk/src/webapp/api/extensions/data-editor/README.txt Fri
Jan 6 08:39:42 2012
@@ -56,6 +56,21 @@
Runs at start/end of showing an edit lens (when in edit mode). Param
'itemId' is the id of the selected item. Return false from
onBeforeEdit()
to cancel edit lens display for that item (editor UI will not be
displayed).
+
+boolean onBeforeDelete(itemId)
+void onDelete(itemId)
+ Runs at start/end of deleting an item (when in edit mode). Param
+ 'itemId' is the id of the selected item. Return false from
onBeforeDelete()
+ to cancel deletion.
+
+boolean onBeforeClone(src_itemId)
+item onCloning(src_itemId,new_itemId,item)
+void onClone(src_itemId)
+ Runs during item cloning (when in edit mode). Param 'src_itemId' is the
+ source item id. Return false from onBeforeClone() to cancel the clone.
+ The onCloning() event gives access to the item object before it is
+ saved into the Exhibit database. The item will have been assigned a
+ unique id or label (new_itemId) based on the source item id or label.
boolean onBeforeSave(itemId,item)
boolean onSave(itemId,item)
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/data-editor-extension-bundle-debug.js
Wed Jan 4 08:48:32 2012
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/data-editor-extension-bundle-debug.js
Fri Jan 6 08:39:42 2012
@@ -12,8 +12,8 @@
Exhibit.DataEdit.EDIT_ROLE_EDIT="editorEditButton";
Exhibit.DataEdit.EDIT_ROLE_DELETE="editorDeleteButton";
Exhibit.DataEdit.EDIT_ROLE_CLONE="editorCloneButton";
+Exhibit.DataEdit.EDIT_ROLE_CREATE="editorCreateButton";
Exhibit.DataEdit.EDIT_ROLE_SAVE="editorSaveButton";
-Exhibit.DataEdit.EDIT_ROLE_CANCEL="editorCancelButton";
Exhibit.DataEdit.EDIT_ROLE_STATUS="editorStatus";
Exhibit.DataEdit.CREATE_MODE=1;
Exhibit.DataEdit.UPDATE_MODE=2;
@@ -24,7 +24,7 @@
Exhibit.DataEdit._lifeCycleEventHandlers_=[];
Exhibit.DataEdit.activate=function(){var self=this;
if(Exhibit.DataEdit._lock_){if(!Exhibit.DataEdit._invokeEventHandlers("onBeforeActivateClose")){return ;
-}Exhibit.DataEdit.cancel();
+}database._listeners.fire("onAfterLoadingItems",[]);
Exhibit.DataEdit._setEditLock(false);
Exhibit.DataEdit._invokeEventHandlers("onActivateClose");
return ;
@@ -53,10 +53,16 @@
$(this).click(function(){Exhibit.DataEdit.clone(id);
});
});
+var filterCreate=function(idx){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_CREATE;
+};
+$("*",this).filter(filterCreate).each(function(idx){$(this).css("display","Block");
+$(this).click(function(){Exhibit.DataEdit.create(id);
+});
+});
}else{var xy=$(this).offset();
var w=$(this).outerWidth(true);
var h=$(this).outerHeight(true);
-var overlay='<div class="'+Exhibit.DataEdit.EDIT_INJECT_MARKER+'"
onMouseOver="Exhibit.DataEdit._rollIn_(this)"
onMouseOut="Exhibit.DataEdit._rollOut_(this)" style="position:Absolute ;
top:'+xy.top+"px ; left:"+xy.left+"px ; width:"+w+"px ; height:"+h+'px ;
cursor:Help ; border:2px #dddddd Dotted;"><div
onclick="Exhibit.DataEdit.edit(\''+id+'\')" style="width:'+w+"px ;
height:"+h+'px ; background:Black; opacity:0.0; filter:alpha(opacity=0);
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0);"></div><div
class="__buttonBar__" style="position:Absolute ; top:4px ; right: 2px ;
display:None;"><span onclick="Exhibit.DataEdit.clone(\''+id+'\')"
style="background:Red ; color:White ; padding:0.25em 0.5em ;
cursor:Pointer ; margin-right:10px;">Clone</span><span
onclick="Exhibit.DataEdit.de1ete(\''+id+'\')" style="background:Red ;
color:White ; padding:0.25em 0.5em ;
cursor:Pointer ;">Delete</span></div></div>';
+var overlay='<div id="__MARKER__'+id+'"
class="'+Exhibit.DataEdit.EDIT_INJECT_MARKER+'"
onMouseOver="Exhibit.DataEdit._rollIn_(this)"
onMouseOut="Exhibit.DataEdit._rollOut_(this)" style="position:Absolute ;
top:'+xy.top+"px ; left:"+xy.left+"px ; width:"+w+"px ; height:"+h+'px ;
cursor:Help ; border:2px #dddddd Dotted;"><div
onclick="Exhibit.DataEdit.edit(\''+id+'\')" style="width:'+w+"px ;
height:"+h+'px ; background:Black; opacity:0.0; filter:alpha(opacity=0);
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0);"></div><div
class="__buttonBar__" style="position:Absolute ; top:4px ; right: 2px ;
display:None; background:Red ; color:White ; padding:0.25em 0.5em"><span
onclick="Exhibit.DataEdit.create(\''+id+'\')"
style="text-decoration:Underline ; cursor:Pointer ;">New</span> |
<span onclick="Exhibit.DataEdit.clone(\''+id+'\')"
style="text-decoration:Underline ; cursor:Pointer ;">Clone</span> |
<span onclick="Exhibit.DataEdit.de1ete(\''+id+'\')"
style="text-decoration:Underline ;
cursor:Pointer ;">Delete</span></div></div>';
$(this).append(overlay);
}});
Exhibit.DataEdit._invokeEventHandlers("onActivate");
@@ -71,13 +77,17 @@
}var self=this;
var filter=function(idx){return($(this).attr("ex:itemid"));
};
-$("*").filter(filter).each(function(idx){var
filterEdit=function(idx){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT;
+$("*").filter(filter).each(function(idx){var id=$(this).attr("ex:itemid");
+var markerId="__MARKER__"+id;
+if(id==itemId){var filterEdit=function(idx){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT;
};
$("*",this).filter(filterEdit).css("display","None");
-$("."+Exhibit.DataEdit.EDIT_INJECT_MARKER,this).remove();
-if($(this).attr("ex:itemid")==itemId){var editor=new
Exhibit.DataEdit.Editor(itemId,this);
+$("#"+markerId,this).remove();
+var editor=new Exhibit.DataEdit.Editor(itemId,this);
Exhibit.DataEdit._editors_[itemId]=editor;
editor.apply();
+}else{var xy=$(this).offset();
+$("#"+markerId,this).css("top",xy.top+"px").css("left",xy.left+"px");
}});
Exhibit.DataEdit._invokeEventHandlers("onEdit",itemId);
};
@@ -90,8 +100,8 @@
Exhibit.DataEdit._invokeEventHandlers("onDelete",itemId);
};
Exhibit.DataEdit.clone=function(itemId){if(!Exhibit.DataEdit._invokeEventHandlers("onBeforeClone",itemId)){return ;
-}if(confirm("Do you really want to clone this item?\nItem: "+itemId)){var
prop=(database.getObject(itemId,"id"))?"id":"label";
-var _id=database.getObject(itemId,prop);
+}if(confirm("Do you really want to clone this item?\nItem: "+itemId)){var
keyProp=(database.getObject(itemId,"id"))?"id":"label";
+var _id=database.getObject(itemId,keyProp);
if(!_id||_id!=itemId){return ;
}if(_id.match(/\d+$/)){var m=_id.match(/(.*?)(\d*)$/);
var base=m[1];
@@ -101,13 +111,41 @@
_id=base+n;
}else{_id=_id+"2";
}var item=database._spo[itemId];
-item[prop]=_id;
-database.loadData({items:[item]});
+item[keyProp]=_id;
+var hType="onCloning";
+for(var i=0;
+i<Exhibit.DataEdit._lifeCycleEventHandlers_.length;
+i++){var handler=Exhibit.DataEdit._lifeCycleEventHandlers_[i];
+item=(handler[hType])?handler[hType](itemId,_id,item):item;
+}database.loadData({items:[item]});
}else{return ;
}database._listeners.fire("onAfterLoadingItems",[]);
Exhibit.DataEdit._setEditLock(false);
Exhibit.DataEdit._invokeEventHandlers("onClone",itemId);
};
+Exhibit.DataEdit.create=function(itemId){if(!Exhibit.DataEdit._invokeEventHandlers("onBeforeCreate",itemId)){return ;
+}var item={};
+var srcItem=database._spo[itemId];
+for(p in srcItem){var o=database.getObject(itemId,p);
+if(typeof o=="number"){item[p]=0;
+}else{if(typeof o=="boolean"){item[p]=false;
+}else{if(typeof o=="string"){if(o.match(/^(\+|
\-)?\d+(\.\d+)?$/)){item[p]=0;
+}else{item[p]="";
+}}else{item[p]="";
+}}}}var type=database.getObject(itemId,"type");
+item["type"]=(type)?type:"item";
+var keyProp=(database.getObject(itemId,"id"))?"id":"label";
+item[keyProp]="item"+(new Date().getTime());
+var hType="onCreating";
+for(var i=0;
+i<Exhibit.DataEdit._lifeCycleEventHandlers_.length;
+i++){var handler=Exhibit.DataEdit._lifeCycleEventHandlers_[i];
+item=(handler[hType])?handler[hType](item[keyProp],item):item;
+}database.loadData({items:[item]});
+database._listeners.fire("onAfterLoadingItems",[]);
+Exhibit.DataEdit._setEditLock(false);
+Exhibit.DataEdit._invokeEventHandlers("onCreate",itemId);
+};
Exhibit.DataEdit.save=function(itemId){var self=this;
var mode=Exhibit.DataEdit.UPDATE_MODE;
var editor=Exhibit.DataEdit._editors_[itemId];
@@ -119,18 +157,12 @@
}for(var fieldId in fields){fields[fieldId].setError(false);
}for(var fieldId in fields){var f=fields[fieldId];
if(Exhibit.DataEdit._saveField(itemId,fieldId,f)){return ;
-}}database._listeners.fire("onAfterLoadingItems",[]);
-Exhibit.DataEdit._setEditLock(false);
-var success=Exhibit.DataEdit._invokeEventHandlers("onSave",itemId,item);
+}}var success=Exhibit.DataEdit._invokeEventHandlers("onSave",itemId,item);
Exhibit.DataEdit._checkForSaveFailure(success);
};
-Exhibit.DataEdit.cancel=function(){if(!Exhibit.DataEdit._invokeEventHandlers("onBeforeCancel")){return ;
-}database._listeners.fire("onAfterLoadingItems",[]);
-Exhibit.DataEdit._setEditLock(false);
-Exhibit.DataEdit._invokeEventHandlers("onCancel");
-};
Exhibit.DataEdit._setEditLock=function(b){Exhibit.DataEdit._lock_=b;
-$(".exhibitDataEditButton #symbol").html(Exhibit.DataEdit._lock_?'<span
class="on">✔</span>':'<span class="off">✖</span>');
+$(".exhibitDataEditButton
#editorToggleSymbol").html(Exhibit.DataEdit._lock_?'<span
class="on">✔</span>':'<span class="off">✖</span>');
+$(".exhibitDataEditButton
#editorToggleText").html(Exhibit.DataEdit._lock_?"Stop editing":"Start
editing");
};
Exhibit.DataEdit.onChange=function(itemId,fieldId){var
editor=Exhibit.DataEdit._editors_[itemId];
var fields=editor.getFields();
@@ -215,7 +247,7 @@
});
}catch(err){SimileAjax.Debug.warn(err);
}});
-}else{var buttonHTML='<div style="position:Fixed; right:1em;
top:1em;"><div class="'+Exhibit.DataEdit.EDIT_BUTTON+'"><a
href="javascript:Exhibit.DataEdit.activate();"><div><span id="symbol"><span
class="off">✖</span></span> Editor</div></a></div></div>';
+}else{var buttonHTML='<div style="position:Fixed; right:1em;
top:1em;"><div class="'+Exhibit.DataEdit.EDIT_BUTTON+'"><a
href="javascript:Exhibit.DataEdit.activate();"><div><span
id="editorToggleSymbol"><span class="off">✖</span></span> <span
id="editorToggleText">Start editing</span></div></a></div></div>';
var body=$("body").first().append(buttonHTML);
}};
Exhibit.DataEdit._setup_scanForEditButtonInDisplayLens=function(){var
filterEdit=function(idx){return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT;
@@ -278,12 +310,6 @@
});
self._hasSaveButton=true;
});
-var cancelFilter=function(idx){return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_CANCEL;
-};
-$("*",self._jqThis).filter(cancelFilter).each(function(idx){$(this).click(function(){Exhibit.DataEdit.cancel();
-});
-self._hasCancelButton=true;
-});
var statusFilter=function(idx){return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_STATUS;
};
$("*",self._jqThis).filter(statusFilter).each(function(idx){$(this).attr("id",Exhibit.DataEdit.EDIT_MESSAGE);
@@ -302,7 +328,7 @@
f._saveOnChange=(!self._hasSaveButton);
}catch(err){self.log(err,prop,val,this);
SimileAjax.Debug.warn(err);
-}self._addFieldComponent(this,prop,f,onShow);
+}self._addFieldComponent(this,prop,f,onShow,true);
}catch(err){self.log(err,prop,val,this);
}});
}for(var i=0;
@@ -323,7 +349,7 @@
f._saveOnChange=true;
}catch(err){self.log(err,prop,val,self);
SimileAjax.Debug.warn(err);
-}self._addFieldComponent(this,prop,f,onShow);
+}self._addFieldComponent(this,prop,f,onShow,false);
}}catch(err){self.log(err,prop,val,self);
}});
for(var i=0;
@@ -347,9 +373,22 @@
}var m=exp.match(/^\.(.+)?\.?/);
return(m&&m.length>1)?m[1]:null;
};
-Exhibit.DataEdit.Editor.prototype._addFieldComponent=function(jq,prop,f,onShow){if(f){this._fields[prop]=f;
-$(jq).replaceWith(f.getHTML(onShow));
-}else{$(jq).replaceWith('<span style="color:Red;">Failed to
initalise</span>');
+Exhibit.DataEdit.Editor.prototype._addFieldComponent=function(jq,prop,f,onShow,usingLens){if(f){this._fields[prop]=f;
+var h=f.getHTML(onShow);
+var srcDim={width:$(jq).width(),height:$(jq).height()};
+var prefDim=f["_prefDimensions"];
+if(!usingLens&&prefDim&&((srcDim.width<prefDim.width)||
(srcDim.height<prefDim.height))){h='<span style="display:Inline-Block;
position:Relative; width:'+srcDim.width+"px;
height:"+srcDim.height+'px;">'+h+"</span>";
+$(jq).replaceWith(h);
+$("#"+f._divId).mouseenter(function(ev){var
pos=$(this).parent().position();
+$(this).width(prefDim.width).height(prefDim.height).css("z-index","1000");
+}).mouseleave(function(ev){$(this).width(srcDim.width).height(srcDim.height).css("z-index","Auto");
+}).css("position","Absolute").css("top","0px").css("left","0px");
+if(srcDim.width<=0){srcDim.width=10;
+$("#"+f._divId).width(srcDim.width);
+}if(srcDim.height<=0){srcDim.height=10;
+$("#"+f._divId).height(srcDim.height);
+}}else{$(jq).replaceWith(h);
+}}else{$(jq).replaceWith('<span style="color:Red;">Failed to
initalise</span>');
}};
Exhibit.DataEdit.Editor._uniqueObjects=function(itemType,predicate){var
v=[];
var itemKeys=database.getAllItems().toArray();
@@ -397,23 +436,15 @@
s=s+props[i]+":"+v+"; ";
}}return s;
};
-Exhibit.DataEdit.Editor._getLineHeight=function(el){var h=null;
-if(el.currentStyle){h=el.currentStyle["lineHeight"];
-}else{if(document.defaultView!=undefined&&document.defaultView.getComputedStyle!=undefined){h=document.defaultView.getComputedStyle(el,null).getPropertyValue("line-height");
-}}if(h){if(h.indexOf("px")>=0){return parseInt(h.replace(/px/,""));
-}else{if(el.parentNode!=null){return
Exhibit.DataEdit.Editor._getLineHeight(el.parentNode);
-}else{return 16;
-}}}else{return 16;
-}};
-Exhibit.DataEdit.Editor._getLineHeight2=function(el){var
el2=document.createElement("div");
-el2.style.fontFamily=el.style.fontFamily;
-el2.style.fontSize=el.style.fontSize;
-el2.style.fontStyle=el.style.fontStyle;
-el2.style.fontVariant=el.style.fontVariant;
-el2.style.fontWeight=el.style.fontWeight;
-el2.style.lineHeight=el.style.lineHeight;
-el2.innerHTML="Mj";
-return el2.offsetHeight;
+Exhibit.DataEdit.Editor._getColRowDimensions=function(jq,cols,rows){$(jq).prepend('<span
id="__SIZE_GUESSER__">M</span>');
+var textW=$("#__SIZE_GUESSER__",jq).width();
+var textH=$("#__SIZE_GUESSER__",jq).height();
+$("#__SIZE_GUESSER__",jq).remove();
+return{width:(cols*textW),height:(rows*textH)};
+};
+Exhibit.DataEdit.Editor._uid=(new Date).getTime();
+Exhibit.DataEdit.Editor._getUID=function(){Exhibit.DataEdit.Editor._uid++;
+return Exhibit.DataEdit.Editor._uid;
};
Exhibit.DataEdit.Editor.matchExactStringFromList=function(str,list){var
lstr=str.toLowerCase();
for(var i=0;
@@ -468,7 +499,7 @@
this._itemId=iid;
this._propId=pid;
this._value=val;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(jq).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens=noLens;
@@ -1149,7 +1180,7 @@
this._itemId=iid;
this._propId=pid;
this._value=val;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(jq).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens=noLens;
@@ -1227,7 +1258,7 @@
this._itemId=iid;
this._propId=pid;
this._value=val;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(jq).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens=noLens;
@@ -1275,25 +1306,25 @@
this._itemId=iid;
this._propId=pid;
this._value=val;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(jq).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens=noLens;
this._matchDisplayLens=Exhibit.DataEdit.Editor._parseTrueFalse($(jq).attr("ex:useDisplayStyle"));
this._saveOnChange=false;
+this._prefDimensions=null;
this._largeText=Exhibit.DataEdit.Editor._parseTrueFalse($(jq).attr("ex:large"));
this._rows=parseInt($(jq).attr("ex:rows"));
this._cols=parseInt($(jq).attr("ex:cols"));
if(this._value==undefined){this._value="";
}if((typeof this._value)!="string"){throw"Invalid data for TextField";
}};
-Exhibit.DataEdit.Editor.TextField.prototype.getHTML=function(onShow){var
style=null;
-if(this._noEditorLens||
this._matchDisplayLens){style=Exhibit.DataEdit.Editor._extractStyle(this._jqThis)+"border-width:
0px; width: "+$(this._jqThis).width()+"px;
height: "+$(this._jqThis).height()+"px; ";
+Exhibit.DataEdit.Editor.TextField.prototype.getHTML=function(onShow){var
textDim=Exhibit.DataEdit.Editor._getColRowDimensions(this._jqThis,1,1);
+this._prefDimensions={width:textDim.width*10,height:textDim.height*1};
+var style=null;
+if(this._noEditorLens||
this._matchDisplayLens){style=Exhibit.DataEdit.Editor._extractStyle(this._jqThis)+"border-width:
0px; border-style: None; padding: 0px;
width: "+$(this._jqThis).width()+"px;
height: "+$(this._jqThis).height()+"px; ";
var contH=$(this._jqThis).height();
-$(this._jqThis).prepend('<span id="__SIZE_GUESSER__">M</span>');
-var textH=$("#__SIZE_GUESSER__",this._jqThis).height();
-$("#__SIZE_GUESSER__",this._jqThis).remove();
-this._largeText=((contH/textH)>=2);
+this._largeText=((contH/textDim.height)>=2);
}var
onChange=(this._saveOnChange)?"Exhibit.DataEdit.onChange('"+this._itemId+"','"+this._propId+"')":"";
if(this._largeText){var c=this._cols?this._cols:null;
var r=this._rows?this._rows:null;
@@ -1321,7 +1352,7 @@
this._itemId=iid;
this._propId=pid;
this._value=val;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(jq).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens=noLens;
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/data-editor-extension-bundle.css
Wed Sep 28 07:08:21 2011
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/data-editor-extension-bundle.css
Fri Jan 6 08:39:42 2012
@@ -28,9 +28,9 @@
color: #000000;
background-color: #dddddd;
}
-.exhibitDataEditButton #symbol { color: White; }
-.exhibitDataEditButton #symbol .on { background-color: Green; }
-.exhibitDataEditButton #symbol .off { background-color: #888888; }
+.exhibitDataEditButton #editorToggleSymbol { color: White; }
+.exhibitDataEditButton #editorToggleSymbol .on { background-color: Green; }
+.exhibitDataEditButton #editorToggleSymbol .off { background-color:
#888888; }
/*
* Components
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/data-editor-extension-bundle.js
Wed Jan 4 08:48:32 2012
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/data-editor-extension-bundle.js
Fri Jan 6 08:39:42 2012
@@ -12,8 +12,8 @@
Exhibit.DataEdit.EDIT_ROLE_EDIT="editorEditButton";
Exhibit.DataEdit.EDIT_ROLE_DELETE="editorDeleteButton";
Exhibit.DataEdit.EDIT_ROLE_CLONE="editorCloneButton";
+Exhibit.DataEdit.EDIT_ROLE_CREATE="editorCreateButton";
Exhibit.DataEdit.EDIT_ROLE_SAVE="editorSaveButton";
-Exhibit.DataEdit.EDIT_ROLE_CANCEL="editorCancelButton";
Exhibit.DataEdit.EDIT_ROLE_STATUS="editorStatus";
Exhibit.DataEdit.CREATE_MODE=1;
Exhibit.DataEdit.UPDATE_MODE=2;
@@ -24,7 +24,7 @@
Exhibit.DataEdit._lifeCycleEventHandlers_=[];
Exhibit.DataEdit.activate=function(){var A=this;
if(Exhibit.DataEdit._lock_){if(!Exhibit.DataEdit._invokeEventHandlers("onBeforeActivateClose")){return ;
-}Exhibit.DataEdit.cancel();
+}database._listeners.fire("onAfterLoadingItems",[]);
Exhibit.DataEdit._setEditLock(false);
Exhibit.DataEdit._invokeEventHandlers("onActivateClose");
return ;
@@ -33,30 +33,36 @@
Exhibit.DataEdit._editors_={};
var B=function(C){return $(this).attr("ex:itemid");
};
-$("*").filter(B).each(function(K){var D=$(this).attr("ex:itemid");
-var E=function(M){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT;
+$("*").filter(B).each(function(L){var D=$(this).attr("ex:itemid");
+var E=function(N){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT;
};
var F=$("*",this).filter(E);
-if(F.length>0){F.each(function(M){$(this).css("display","Block");
+if(F.length>0){F.each(function(N){$(this).css("display","Block");
$(this).click(function(){Exhibit.DataEdit.edit(D);
});
});
-var C=function(M){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_DELETE;
+var C=function(N){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_DELETE;
};
-$("*",this).filter(C).each(function(M){$(this).css("display","Block");
+$("*",this).filter(C).each(function(N){$(this).css("display","Block");
$(this).click(function(){Exhibit.DataEdit.de1ete(D);
});
});
-var I=function(M){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_CLONE;
+var I=function(N){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_CLONE;
};
-$("*",this).filter(I).each(function(M){$(this).css("display","Block");
+$("*",this).filter(I).each(function(N){$(this).css("display","Block");
$(this).click(function(){Exhibit.DataEdit.clone(D);
});
});
-}else{var L=$(this).offset();
-var J=$(this).outerWidth(true);
+var J=function(N){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_CREATE;
+};
+$("*",this).filter(J).each(function(N){$(this).css("display","Block");
+$(this).click(function(){Exhibit.DataEdit.create(D);
+});
+});
+}else{var M=$(this).offset();
+var K=$(this).outerWidth(true);
var H=$(this).outerHeight(true);
-var G='<div class="'+Exhibit.DataEdit.EDIT_INJECT_MARKER+'"
onMouseOver="Exhibit.DataEdit._rollIn_(this)"
onMouseOut="Exhibit.DataEdit._rollOut_(this)" style="position:Absolute ;
top:'+L.top+"px ; left:"+L.left+"px ; width:"+J+"px ; height:"+H+'px ;
cursor:Help ; border:2px #dddddd Dotted;"><div
onclick="Exhibit.DataEdit.edit(\''+D+'\')" style="width:'+J+"px ;
height:"+H+'px ; background:Black; opacity:0.0; filter:alpha(opacity=0);
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0);"></div><div
class="__buttonBar__" style="position:Absolute ; top:4px ; right: 2px ;
display:None;"><span onclick="Exhibit.DataEdit.clone(\''+D+'\')"
style="background:Red ; color:White ; padding:0.25em 0.5em ;
cursor:Pointer ; margin-right:10px;">Clone</span><span
onclick="Exhibit.DataEdit.de1ete(\''+D+'\')" style="background:Red ;
color:White ; padding:0.25em 0.5em ;
cursor:Pointer ;">Delete</span></div></div>';
+var G='<div id="__MARKER__'+D+'"
class="'+Exhibit.DataEdit.EDIT_INJECT_MARKER+'"
onMouseOver="Exhibit.DataEdit._rollIn_(this)"
onMouseOut="Exhibit.DataEdit._rollOut_(this)" style="position:Absolute ;
top:'+M.top+"px ; left:"+M.left+"px ; width:"+K+"px ; height:"+H+'px ;
cursor:Help ; border:2px #dddddd Dotted;"><div
onclick="Exhibit.DataEdit.edit(\''+D+'\')" style="width:'+K+"px ;
height:"+H+'px ; background:Black; opacity:0.0; filter:alpha(opacity=0);
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0);"></div><div
class="__buttonBar__" style="position:Absolute ; top:4px ; right: 2px ;
display:None; background:Red ; color:White ; padding:0.25em 0.5em"><span
onclick="Exhibit.DataEdit.create(\''+D+'\')"
style="text-decoration:Underline ; cursor:Pointer ;">New</span> |
<span onclick="Exhibit.DataEdit.clone(\''+D+'\')"
style="text-decoration:Underline ; cursor:Pointer ;">Clone</span> |
<span onclick="Exhibit.DataEdit.de1ete(\''+D+'\')"
style="text-decoration:Underline ;
cursor:Pointer ;">Delete</span></div></div>';
$(this).append(G);
}});
Exhibit.DataEdit._invokeEventHandlers("onActivate");
@@ -71,13 +77,17 @@
}var A=this;
var B=function(D){return($(this).attr("ex:itemid"));
};
-$("*").filter(B).each(function(D){var F=function(G){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT;
+$("*").filter(B).each(function(D){var I=$(this).attr("ex:itemid");
+var F="__MARKER__"+I;
+if(I==C){var G=function(J){return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT;
};
-$("*",this).filter(F).css("display","None");
-$("."+Exhibit.DataEdit.EDIT_INJECT_MARKER,this).remove();
-if($(this).attr("ex:itemid")==C){var E=new Exhibit.DataEdit.Editor(C,this);
+$("*",this).filter(G).css("display","None");
+$("#"+F,this).remove();
+var E=new Exhibit.DataEdit.Editor(C,this);
Exhibit.DataEdit._editors_[C]=E;
E.apply();
+}else{var H=$(this).offset();
+$("#"+F,this).css("top",H.top+"px").css("left",H.left+"px");
}});
Exhibit.DataEdit._invokeEventHandlers("onEdit",C);
};
@@ -91,23 +101,51 @@
};
Exhibit.DataEdit.clone=function(E){if(!Exhibit.DataEdit._invokeEventHandlers("onBeforeClone",E)){return ;
}if(confirm("Do you really want to clone this item?\nItem: "+E)){var
G=(database.getObject(E,"id"))?"id":"label";
-var B=database.getObject(E,G);
-if(!B||B!=E){return ;
-}if(B.match(/\d+$/)){var A=B.match(/(.*?)(\d*)$/);
-var D=A[1];
-var F=(A[2].length)?parseInt(A[2]):0;
-do{F++;
-}while(database.containsItem(D+F));
-B=D+F;
-}else{B=B+"2";
-}var C=database._spo[E];
-C[G]=B;
-database.loadData({items:[C]});
+var F=database.getObject(E,G);
+if(!F||F!=E){return ;
+}if(F.match(/\d+$/)){var C=F.match(/(.*?)(\d*)$/);
+var A=C[1];
+var B=(C[2].length)?parseInt(C[2]):0;
+do{B++;
+}while(database.containsItem(A+B));
+F=A+B;
+}else{F=F+"2";
+}var I=database._spo[E];
+I[G]=F;
+var J="onCloning";
+for(var D=0;
+D<Exhibit.DataEdit._lifeCycleEventHandlers_.length;
+D++){var H=Exhibit.DataEdit._lifeCycleEventHandlers_[D];
+I=(H[J])?H[J](E,F,I):I;
+}database.loadData({items:[I]});
}else{return ;
}database._listeners.fire("onAfterLoadingItems",[]);
Exhibit.DataEdit._setEditLock(false);
Exhibit.DataEdit._invokeEventHandlers("onClone",E);
};
+Exhibit.DataEdit.create=function(E){if(!Exhibit.DataEdit._invokeEventHandlers("onBeforeCreate",E)){return ;
+}var H={};
+var B=database._spo[E];
+for(p in B){var A=database.getObject(E,p);
+if(typeof A=="number"){H[p]=0;
+}else{if(typeof A=="boolean"){H[p]=false;
+}else{if(typeof A=="string"){if(A.match(/^(\+|\-)?\d+(\.\d+)?$/)){H[p]=0;
+}else{H[p]="";
+}}else{H[p]="";
+}}}}var D=database.getObject(E,"type");
+H["type"]=(D)?D:"item";
+var F=(database.getObject(E,"id"))?"id":"label";
+H[F]="item"+(new Date().getTime());
+var I="onCreating";
+for(var C=0;
+C<Exhibit.DataEdit._lifeCycleEventHandlers_.length;
+C++){var G=Exhibit.DataEdit._lifeCycleEventHandlers_[C];
+H=(G[I])?G[I](H[F],H):H;
+}database.loadData({items:[H]});
+database._listeners.fire("onAfterLoadingItems",[]);
+Exhibit.DataEdit._setEditLock(false);
+Exhibit.DataEdit._invokeEventHandlers("onCreate",E);
+};
Exhibit.DataEdit.save=function(F){var I=this;
var A=Exhibit.DataEdit.UPDATE_MODE;
var D=Exhibit.DataEdit._editors_[F];
@@ -119,18 +157,12 @@
}for(var E in B){B[E].setError(false);
}for(var E in B){var C=B[E];
if(Exhibit.DataEdit._saveField(F,E,C)){return ;
-}}database._listeners.fire("onAfterLoadingItems",[]);
-Exhibit.DataEdit._setEditLock(false);
-var G=Exhibit.DataEdit._invokeEventHandlers("onSave",F,H);
+}}var G=Exhibit.DataEdit._invokeEventHandlers("onSave",F,H);
Exhibit.DataEdit._checkForSaveFailure(G);
};
-Exhibit.DataEdit.cancel=function(){if(!Exhibit.DataEdit._invokeEventHandlers("onBeforeCancel")){return ;
-}database._listeners.fire("onAfterLoadingItems",[]);
-Exhibit.DataEdit._setEditLock(false);
-Exhibit.DataEdit._invokeEventHandlers("onCancel");
-};
Exhibit.DataEdit._setEditLock=function(A){Exhibit.DataEdit._lock_=A;
-$(".exhibitDataEditButton #symbol").html(Exhibit.DataEdit._lock_?'<span
class="on">✔</span>':'<span class="off">✖</span>');
+$(".exhibitDataEditButton
#editorToggleSymbol").html(Exhibit.DataEdit._lock_?'<span
class="on">✔</span>':'<span class="off">✖</span>');
+$(".exhibitDataEditButton
#editorToggleText").html(Exhibit.DataEdit._lock_?"Stop editing":"Start
editing");
};
Exhibit.DataEdit.onChange=function(G,B){var
C=Exhibit.DataEdit._editors_[G];
var A=C.getFields();
@@ -215,7 +247,7 @@
});
}catch(F){SimileAjax.Debug.warn(F);
}});
-}else{var D='<div style="position:Fixed; right:1em; top:1em;"><div
class="'+Exhibit.DataEdit.EDIT_BUTTON+'"><a
href="javascript:Exhibit.DataEdit.activate();"><div><span id="symbol"><span
class="off">✖</span></span> Editor</div></a></div></div>';
+}else{var D='<div style="position:Fixed; right:1em; top:1em;"><div
class="'+Exhibit.DataEdit.EDIT_BUTTON+'"><a
href="javascript:Exhibit.DataEdit.activate();"><div><span
id="editorToggleSymbol"><span class="off">✖</span></span> <span
id="editorToggleText">Start editing</span></div></a></div></div>';
var A=$("body").first().append(D);
}};
Exhibit.DataEdit._setup_scanForEditButtonInDisplayLens=function(){var
B=function(C){return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT;
@@ -272,21 +304,15 @@
}};
Exhibit.DataEdit.Editor.prototype.applyWithLens=function(B){var A=this;
$(A._jqThis).html(B._lensHTML);
-var D=function(I){return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_SAVE;
+var D=function(H){return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_SAVE;
};
-$("*",A._jqThis).filter(D).each(function(I){$(this).click(function(){Exhibit.DataEdit.save(A._itemId);
+$("*",A._jqThis).filter(D).each(function(H){$(this).click(function(){Exhibit.DataEdit.save(A._itemId);
});
A._hasSaveButton=true;
});
-var H=function(I){return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_CANCEL;
+var G=function(H){return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_STATUS;
};
-$("*",A._jqThis).filter(H).each(function(I){$(this).click(function(){Exhibit.DataEdit.cancel();
-});
-A._hasCancelButton=true;
-});
-var G=function(I){return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_STATUS;
-};
-$("*",A._jqThis).filter(G).each(function(I){$(this).attr("id",Exhibit.DataEdit.EDIT_MESSAGE);
+$("*",A._jqThis).filter(G).each(function(H){$(this).attr("id",Exhibit.DataEdit.EDIT_MESSAGE);
A._hasStatus=true;
});
var F=[];
@@ -294,16 +320,16 @@
C<Exhibit.DataEdit.Editor._COMPONENTS_.length;
C++){var E=Exhibit.DataEdit.Editor._COMPONENTS_[C];
A.log("Scanning for "+E);
-Exhibit.DataEdit.Editor[E].domFilter(A._jqThis,function(I){var M,L,K;
-try{M=A._getContent(this);
-if(!M){throw"Missing target (ex:content)";
-}L=(A._exists(M))?A._getValues(M):undefined;
-try{K=new Exhibit.DataEdit.Editor[E](this,A._itemId,M,L,false);
-K._saveOnChange=(!A._hasSaveButton);
-}catch(J){A.log(J,M,L,this);
-SimileAjax.Debug.warn(J);
-}A._addFieldComponent(this,M,K,F);
-}catch(J){A.log(J,M,L,this);
+Exhibit.DataEdit.Editor[E].domFilter(A._jqThis,function(H){var L,K,J;
+try{L=A._getContent(this);
+if(!L){throw"Missing target (ex:content)";
+}K=(A._exists(L))?A._getValues(L):undefined;
+try{J=new Exhibit.DataEdit.Editor[E](this,A._itemId,L,K,false);
+J._saveOnChange=(!A._hasSaveButton);
+}catch(I){A.log(I,L,K,this);
+SimileAjax.Debug.warn(I);
+}A._addFieldComponent(this,L,J,F,true);
+}catch(I){A.log(I,L,K,this);
}});
}for(var C=0;
C<F.length;
@@ -323,7 +349,7 @@
H._saveOnChange=true;
}catch(G){A.log(G,K,J,A);
SimileAjax.Debug.warn(G);
-}A._addFieldComponent(this,K,H,D);
+}A._addFieldComponent(this,K,H,D,false);
}}catch(G){A.log(G,K,J,A);
}});
for(var B=0;
@@ -347,9 +373,22 @@
}var A=B.match(/^\.(.+)?\.?/);
return(A&&A.length>1)?A[1]:null;
};
-Exhibit.DataEdit.Editor.prototype._addFieldComponent=function(D,C,A,B){if(A){this._fields[C]=A;
-$(D).replaceWith(A.getHTML(B));
-}else{$(D).replaceWith('<span style="color:Red;">Failed to
initalise</span>');
+Exhibit.DataEdit.Editor.prototype._addFieldComponent=function(H,G,E,F,A){if(E){this._fields[G]=E;
+var D=E.getHTML(F);
+var C={width:$(H).width(),height:$(H).height()};
+var B=E["_prefDimensions"];
+if(!A&&B&&((C.width<B.width)||(C.height<B.height))){D='<span
style="display:Inline-Block; position:Relative; width:'+C.width+"px;
height:"+C.height+'px;">'+D+"</span>";
+$(H).replaceWith(D);
+$("#"+E._divId).mouseenter(function(I){var J=$(this).parent().position();
+$(this).width(B.width).height(B.height).css("z-index","1000");
+}).mouseleave(function(I){$(this).width(C.width).height(C.height).css("z-index","Auto");
+}).css("position","Absolute").css("top","0px").css("left","0px");
+if(C.width<=0){C.width=10;
+$("#"+E._divId).width(C.width);
+}if(C.height<=0){C.height=10;
+$("#"+E._divId).height(C.height);
+}}else{$(H).replaceWith(D);
+}}else{$(H).replaceWith('<span style="color:Red;">Failed to
initalise</span>');
}};
Exhibit.DataEdit.Editor._uniqueObjects=function(F,A){var B=[];
var G=database.getAllItems().toArray();
@@ -397,23 +436,15 @@
C=C+D[B]+":"+A+"; ";
}}return C;
};
-Exhibit.DataEdit.Editor._getLineHeight=function(B){var A=null;
-if(B.currentStyle){A=B.currentStyle["lineHeight"];
-}else{if(document.defaultView!=undefined&&document.defaultView.getComputedStyle!=undefined){A=document.defaultView.getComputedStyle(B,null).getPropertyValue("line-height");
-}}if(A){if(A.indexOf("px")>=0){return parseInt(A.replace(/px/,""));
-}else{if(B.parentNode!=null){return
Exhibit.DataEdit.Editor._getLineHeight(B.parentNode);
-}else{return 16;
-}}}else{return 16;
-}};
-Exhibit.DataEdit.Editor._getLineHeight2=function(B){var
A=document.createElement("div");
-A.style.fontFamily=B.style.fontFamily;
-A.style.fontSize=B.style.fontSize;
-A.style.fontStyle=B.style.fontStyle;
-A.style.fontVariant=B.style.fontVariant;
-A.style.fontWeight=B.style.fontWeight;
-A.style.lineHeight=B.style.lineHeight;
-A.innerHTML="Mj";
-return A.offsetHeight;
+Exhibit.DataEdit.Editor._getColRowDimensions=function(E,D,C){$(E).prepend('<span
id="__SIZE_GUESSER__">M</span>');
+var A=$("#__SIZE_GUESSER__",E).width();
+var B=$("#__SIZE_GUESSER__",E).height();
+$("#__SIZE_GUESSER__",E).remove();
+return{width:(D*A),height:(C*B)};
+};
+Exhibit.DataEdit.Editor._uid=(new Date).getTime();
+Exhibit.DataEdit.Editor._getUID=function(){Exhibit.DataEdit.Editor._uid++;
+return Exhibit.DataEdit.Editor._uid;
};
Exhibit.DataEdit.Editor.matchExactStringFromList=function(D,C){var
B=D.toLowerCase();
for(var A=0;
@@ -468,7 +499,7 @@
this._itemId=E;
this._propId=B;
this._value=F;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(G).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(G).attr("ex:disableFor"));
this._noEditorLens=D;
@@ -1149,7 +1180,7 @@
this._itemId=E;
this._propId=B;
this._value=F;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(G).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(G).attr("ex:disableFor"));
this._noEditorLens=D;
@@ -1227,7 +1258,7 @@
this._itemId=D;
this._propId=B;
this._value=E;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(F).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(F).attr("ex:disableFor"));
this._noEditorLens=C;
@@ -1275,31 +1306,31 @@
this._itemId=C;
this._propId=A;
this._value=D;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(E).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(E).attr("ex:disableFor"));
this._noEditorLens=B;
this._matchDisplayLens=Exhibit.DataEdit.Editor._parseTrueFalse($(E).attr("ex:useDisplayStyle"));
this._saveOnChange=false;
+this._prefDimensions=null;
this._largeText=Exhibit.DataEdit.Editor._parseTrueFalse($(E).attr("ex:large"));
this._rows=parseInt($(E).attr("ex:rows"));
this._cols=parseInt($(E).attr("ex:cols"));
if(this._value==undefined){this._value="";
}if((typeof this._value)!="string"){throw"Invalid data for TextField";
}};
-Exhibit.DataEdit.Editor.TextField.prototype.getHTML=function(H){var D=null;
-if(this._noEditorLens||
this._matchDisplayLens){D=Exhibit.DataEdit.Editor._extractStyle(this._jqThis)+"border-width:
0px; width: "+$(this._jqThis).width()+"px;
height: "+$(this._jqThis).height()+"px; ";
-var C=$(this._jqThis).height();
-$(this._jqThis).prepend('<span id="__SIZE_GUESSER__">M</span>');
-var F=$("#__SIZE_GUESSER__",this._jqThis).height();
-$("#__SIZE_GUESSER__",this._jqThis).remove();
-this._largeText=((C/F)>=2);
-}var
B=(this._saveOnChange)?"Exhibit.DataEdit.onChange('"+this._itemId+"','"+this._propId+"')":"";
+Exhibit.DataEdit.Editor.TextField.prototype.getHTML=function(H){var
B=Exhibit.DataEdit.Editor._getColRowDimensions(this._jqThis,1,1);
+this._prefDimensions={width:B.width*10,height:B.height*1};
+var E=null;
+if(this._noEditorLens||
this._matchDisplayLens){E=Exhibit.DataEdit.Editor._extractStyle(this._jqThis)+"border-width:
0px; border-style: None; padding: 0px;
width: "+$(this._jqThis).width()+"px;
height: "+$(this._jqThis).height()+"px; ";
+var D=$(this._jqThis).height();
+this._largeText=((D/B.height)>=2);
+}var
C=(this._saveOnChange)?"Exhibit.DataEdit.onChange('"+this._itemId+"','"+this._propId+"')":"";
if(this._largeText){var G=this._cols?this._cols:null;
-var E=this._rows?this._rows:null;
-var
A=Exhibit.DataEdit.Editor._htmlTag("textarea",{"id":this._divId,"style":D,"class":"exhibitDataEditTextAreaField","rows":E,"cols":G,"onchange":B},$(this._jqThis).get()[0],false);
+var F=this._rows?this._rows:null;
+var
A=Exhibit.DataEdit.Editor._htmlTag("textarea",{"id":this._divId,"style":E,"class":"exhibitDataEditTextAreaField","rows":F,"cols":G,"onchange":C},$(this._jqThis).get()[0],false);
return A+this._value+"</textarea>";
-}else{var
A=Exhibit.DataEdit.Editor._htmlTag("input",{"id":this._divId,"style":D,"class":"exhibitDataEditTextField","type":"Text","value":this._value,"onchange":B},$(this._jqThis).get()[0],true);
+}else{var
A=Exhibit.DataEdit.Editor._htmlTag("input",{"id":this._divId,"style":E,"class":"exhibitDataEditTextField","type":"Text","value":this._value,"onchange":C},$(this._jqThis).get()[0],true);
return A;
}};
Exhibit.DataEdit.Editor.TextField.prototype.getValue=function(){var
A=$("#"+this._divId).get();
@@ -1321,7 +1352,7 @@
this._itemId=F;
this._propId=B;
this._value=G;
-this._divId="__DATAEDITOR__"+this._propId;
+this._divId="__DATAEDITOR__"+this._propId+"_"+Exhibit.DataEdit.Editor._getUID();
this._validators=$(H).attr("ex:validators");
this._disabledFor=Exhibit.DataEdit.Editor._parseDisabledFor($(H).attr("ex:disableFor"));
this._noEditorLens=E;
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/data-editor.js
Wed Jan 4 08:48:32 2012
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/data-editor.js
Fri Jan 6 08:39:42 2012
@@ -81,8 +81,9 @@
Exhibit.DataEdit.EDIT_ROLE_EDIT = "editorEditButton";
Exhibit.DataEdit.EDIT_ROLE_DELETE = "editorDeleteButton";
Exhibit.DataEdit.EDIT_ROLE_CLONE = "editorCloneButton";
+Exhibit.DataEdit.EDIT_ROLE_CREATE = "editorCreateButton";
Exhibit.DataEdit.EDIT_ROLE_SAVE = "editorSaveButton";
-Exhibit.DataEdit.EDIT_ROLE_CANCEL = "editorCancelButton";
+/*Exhibit.DataEdit.EDIT_ROLE_CANCEL = "editorCancelButton";*/
Exhibit.DataEdit.EDIT_ROLE_STATUS = "editorStatus";
/** Database mutation modes. */
@@ -111,7 +112,8 @@
// Locked? Cancel.
if(Exhibit.DataEdit._lock_) {
if(!Exhibit.DataEdit._invokeEventHandlers('onBeforeActivateClose')) {
return; }
- Exhibit.DataEdit.cancel();
+ /*Exhibit.DataEdit.cancel();*/
+ database._listeners.fire("onAfterLoadingItems",[]);
Exhibit.DataEdit._setEditLock(false);
Exhibit.DataEdit._invokeEventHandlers('onActivateClose');
return;
@@ -136,7 +138,7 @@
$(this).css('display','Block');
$(this).click(function() { Exhibit.DataEdit.edit(id); }); // Attach
onclick
});
- // Now look for delete/clone buttons
+ // Now look for new/clone/delete buttons
var filterDelete = function(idx) { return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_DELETE; }
$('*',this).filter(filterDelete).each(function(idx) {
$(this).css('display','Block');
@@ -147,6 +149,11 @@
$(this).css('display','Block');
$(this).click(function() { Exhibit.DataEdit.clone(id); }); // Attach
onclick
});
+ var filterCreate = function(idx) { return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_CREATE; }
+ $('*',this).filter(filterCreate).each(function(idx) {
+ $(this).css('display','Block');
+ $(this).click(function() { Exhibit.DataEdit.create(id); }); // Attach
onclick
+ });
} else {
// No: add overlay to display <div>
// Add clickable overlay onto display lens.
@@ -156,7 +163,8 @@
// Due to limitations with the way IE7/8 handles mouse events, we need
to create
// an invisible (but 'painted', as in it is filled with a bg col) inner
<div>
var overlay =
- '<div class="'+Exhibit.DataEdit.EDIT_INJECT_MARKER+'" '+
+ '<div id="__MARKER__'+id+'" '+
+ 'class="'+Exhibit.DataEdit.EDIT_INJECT_MARKER+'" '+
'onMouseOver="Exhibit.DataEdit._rollIn_(this)"
onMouseOut="Exhibit.DataEdit._rollOut_(this)" '+
'style="position:Absolute ; top:'+xy.top+'px ; left:'+xy.left+'px ;
width:'+w+'px ; height:'+h+'px ; '+
'cursor:Help ; border:2px #dddddd Dotted;">'+
@@ -165,11 +173,15 @@
'style="width:'+w+'px ; height:'+h+'px ; '+
'background:Black; opacity:0.0; filter:alpha(opacity=0);
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0);">'+
'</div>'+
- '<div class="__buttonBar__" style="position:Absolute ; top:4px ;
right: 2px ; display:None;">'+
+ '<div class="__buttonBar__" style="position:Absolute ; top:4px ;
right: 2px ; display:None; background:Red ; color:White ; padding:0.25em
0.5em">'+
+ '<span onclick="Exhibit.DataEdit.create(\''+id+'\')" '+
+ 'style="text-decoration:Underline ; cursor:Pointer ;">New</span>'+
+ ' | '+
'<span onclick="Exhibit.DataEdit.clone(\''+id+'\')" '+
- 'style="background:Red ; color:White ; padding:0.25em 0.5em ;
cursor:Pointer ; margin-right:10px;">Clone</span>'+
+ 'style="text-decoration:Underline ; cursor:Pointer ;">Clone</span>'+
+ ' | '+
'<span onclick="Exhibit.DataEdit.de1ete(\''+id+'\')" '+
- 'style="background:Red ; color:White ; padding:0.25em 0.5em ;
cursor:Pointer ;">Delete</span>'+
+ 'style="text-decoration:Underline ;
cursor:Pointer ;">Delete</span>'+
'</div>'+
'</div>';
$(this).append(overlay);
@@ -196,19 +208,25 @@
var filter = function(idx) { return ($(this).attr("ex:itemid")); }
// FIXME: Can we be more efficient than '*' ?
$('*').filter(filter).each(function(idx) {
- // Hide user defined <div ex:role="editorEditButton"> (if they exist)
- var filterEdit = function(idx) { return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT; }
- $('*',this).filter(filterEdit).css('display','None'); // Important: see
FIXME [1] at foot of code
- // Strip away all edit overlays (if they exist)
- $('.'+Exhibit.DataEdit.EDIT_INJECT_MARKER,this).remove();
-
- // If this is the item/lens being edited, change to editor
- if($(this).attr("ex:itemid") == itemId) {
- // Get lens...
+ var id = $(this).attr("ex:itemid");
+ var markerId = '__MARKER__'+id;
+ // If this is the item/lens selected for editing, change to editor
+ if(id == itemId) {
+ // Hide user defined <div ex:role="editorEditButton"> (if they exist)
+ var filterEdit = function(idx) { return
$(this).attr("_ex:role")==Exhibit.DataEdit.EDIT_ROLE_EDIT; }
+ $('*',this).filter(filterEdit).css('display','None'); // Important:
see FIXME [1] at foot of code
+ // Strip away edit overlay (red dotted box) if exists
+ $('#'+markerId,this).remove();
+ // Display lens...
// var lens = new Exhibit.DataEdit.Lens(el);
- var editor = new Exhibit.DataEdit.Editor(itemId,this);
+ var editor = new Exhibit.DataEdit.Editor(itemId,this);
Exhibit.DataEdit._editors_[itemId] = editor;
editor.apply();
+ } else {
+ // Move the edit marker (red dotted box) if exists, to account for
+ // rejigging of page caused by editor.
+ var xy = $(this).offset();
+ $('#'+markerId,this).css('top',xy.top+'px').css('left',xy.left+'px');
}
});
@@ -216,7 +234,7 @@
}
/** STEP2b: Click on [delete] link. */
-/* IMPORTANT: this function is named de-ONE-ete, IE can't have functions
named 'delete', apparently! */
+/* IMPORTANT: this function is named de-ONE-ete, IE can't use keywords
for functions names, apparently! */
Exhibit.DataEdit.de1ete = function(itemId) {
if(!Exhibit.DataEdit._invokeEventHandlers('onBeforeDelete',itemId)) {
return; }
@@ -227,7 +245,7 @@
database.removeObjects(itemId,p);
}
} else {
- return;
+ return; // confirm() == false
}
// Cause Exhibit to re-eval its views/facets, and close edit window
database._listeners.fire("onAfterLoadingItems",[]);
@@ -240,10 +258,11 @@
Exhibit.DataEdit.clone = function(itemId) {
if(!Exhibit.DataEdit._invokeEventHandlers('onBeforeClone',itemId)) {
return; }
+ // Clone this item?
if(confirm("Do you really want to clone this item?\nItem: "+itemId)) {
- // Label or id?
- var prop = (database.getObject(itemId,'id')) ? 'id' : 'label';
- var _id = database.getObject(itemId,prop);
+ // Item uses label or id as 'key'?
+ var keyProp = (database.getObject(itemId,'id')) ? 'id' : 'label';
+ var _id = database.getObject(itemId,keyProp);
if(!_id || _id!=itemId) { return; } // _id!=itemId should never fail!!
// If the id ends in digits, attempt to increment
if(_id.match(/\d+$/)) {
@@ -252,17 +271,23 @@
var base = m[1];
var n = (m[2].length) ? parseInt(m[2]) : 0; // Test should never be
false!
do { n++; } while(database.containsItem(base+n));
- _id = base+n; // Now we have a unique id.
+ _id = base+n;
} else {
- // Doesn't end in digit
+ // Doesn't end in digit, so add one
_id = _id+'2';
}
- // Save cloned item
+ // Clone item, change id/label, call cloning callback
var item = database._spo[itemId];
- item[prop] = _id;
+ item[keyProp] = _id;
+ var hType = 'onCloning';
+ for(var i=0;i<Exhibit.DataEdit._lifeCycleEventHandlers_.length;i++) {
+ var handler = Exhibit.DataEdit._lifeCycleEventHandlers_[i];
+ item = (handler[hType]) ? handler[hType](itemId,_id,item) : item;
+ }
+ // Save cloned item
database.loadData( { items:[item] } );
} else {
- return;
+ return; // confirm() == false
}
// Cause Exhibit to re-eval its views/facets, and close edit window
database._listeners.fire("onAfterLoadingItems",[]);
@@ -270,6 +295,51 @@
Exhibit.DataEdit._invokeEventHandlers('onClone',itemId);
}
+
+/** STEP2d: Click on [new] link. */
+Exhibit.DataEdit.create = function(itemId) {
+ if(!Exhibit.DataEdit._invokeEventHandlers('onBeforeCreate',itemId)) {
return; }
+
+ var item = {};
+ // Create empty item using source example
+ var srcItem = database._spo[itemId];
+ for(p in srcItem) {
+ var o = database.getObject(itemId,p);
+ if(typeof o=='number') {
+ item[p] = 0;
+ }
+ else if(typeof o=='boolean') {
+ item[p] = false;
+ }
+ else if(typeof o=='string') {
+ if(o.match(/^(\+|\-)?\d+(\.\d+)?$/)) { item[p]=0; }
+ else { item[p]=''; }
+ }
+ else {
+ item[p] = '';
+ }
+ }
+ // Clone source item's type
+ var type = database.getObject(itemId,'type');
+ item['type'] = (type) ? type : 'item';
+ // Key
+ var keyProp = (database.getObject(itemId,'id')) ? 'id' : 'label';
+ item[keyProp] = 'item' + (new Date().getTime());
+ // Call creating callback
+ var hType = 'onCreating';
+ for(var i=0;i<Exhibit.DataEdit._lifeCycleEventHandlers_.length;i++) {
+ var handler = Exhibit.DataEdit._lifeCycleEventHandlers_[i];
+ item = (handler[hType]) ? handler[hType](item[keyProp],item) : item;
+ }
+ // Save
+ database.loadData( { items:[item] } );
+
+ // Cause Exhibit to re-eval its views/facets, and close edit window
+ database._listeners.fire("onAfterLoadingItems",[]);
+ Exhibit.DataEdit._setEditLock(false); // FIXME try/catch/*finally*
+
+ Exhibit.DataEdit._invokeEventHandlers('onCreate',itemId);
+}
/** STEP3a: Click on [save] link. */
Exhibit.DataEdit.save = function(itemId) {
@@ -294,14 +364,17 @@
if( Exhibit.DataEdit._saveField(itemId,fieldId,f) ) { return; }
}
// Cause Exhibit to re-eval its views/facets, and close edit window
+ /* Reloading Exhibit on save not supported after multi item edit
introduced.
database._listeners.fire("onAfterLoadingItems",[]);
Exhibit.DataEdit._setEditLock(false); // FIXME try/catch/*finally*
+ */
var success = Exhibit.DataEdit._invokeEventHandlers('onSave',itemId,item);
Exhibit.DataEdit._checkForSaveFailure(success);
}
/** STEP3b: Click on [cancel] link. */
+/* [CANCEL] no longer supported after multi item edit introduced.
Exhibit.DataEdit.cancel = function() {
if(!Exhibit.DataEdit._invokeEventHandlers('onBeforeCancel')) { return; }
@@ -311,14 +384,17 @@
Exhibit.DataEdit._invokeEventHandlers('onCancel');
}
+*/
/* Set up clear the edit lock (also set the edit button appearence). */
Exhibit.DataEdit._setEditLock = function(b) {
Exhibit.DataEdit._lock_ = b;
// Alter the global button
// FIXME: For speed, cache result from selector?
- $('.exhibitDataEditButton #symbol').html(
+ $('.exhibitDataEditButton #editorToggleSymbol').html(
Exhibit.DataEdit._lock_ ? '<span class="on">✔</span>' : '<span
class="off">✖</span>');
+ $('.exhibitDataEditButton #editorToggleText').html(
+ Exhibit.DataEdit._lock_ ? 'Stop editing' : 'Start editing');
}
/* When in field saving mode (because [SAVE] button missing) each editing
@@ -518,7 +594,7 @@
var buttonHTML =
'<div style="position:Fixed; right:1em; top:1em;">'+
'<div class="'+Exhibit.DataEdit.EDIT_BUTTON+'">'+
- '<a href="javascript:Exhibit.DataEdit.activate();"><div><span
id="symbol"><span class="off">✖</span></span> Editor</div></a>'+
+ '<a href="javascript:Exhibit.DataEdit.activate();"><div><span
id="editorToggleSymbol"><span class="off">✖</span></span> <span
id="editorToggleText">Start editing</span></div></a>'+
'</div>'+
'</div>';
var body = $('body').first().append(buttonHTML);
=======================================
--- /exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/editor.js
Wed Jan 4 08:48:32 2012
+++ /exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/editor.js
Fri Jan 6 08:39:42 2012
@@ -89,11 +89,13 @@
$(this).click(function() { Exhibit.DataEdit.save(self._itemId); });
self._hasSaveButton = true;
});
+ /* [CANCEL] no longer supported after multi item edit introduced.
var cancelFilter = function(idx) { return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_CANCEL; }
$('*',self._jqThis).filter(cancelFilter).each(function(idx) {
$(this).click(function() { Exhibit.DataEdit.cancel(); });
self._hasCancelButton = true;
});
+ */
var statusFilter = function(idx) { return
$(this).attr("ex:role")==Exhibit.DataEdit.EDIT_ROLE_STATUS; }
$('*',self._jqThis).filter(statusFilter).each(function(idx) {
$(this).attr('id',Exhibit.DataEdit.EDIT_MESSAGE);
@@ -118,12 +120,12 @@
val = (self._exists(prop)) ? self._getValues(prop) : undefined ;
try {
f = new Exhibit.DataEdit.Editor[c](this,self._itemId,prop,val,false);
- f._saveOnChange = (!self._hasSaveButton); // No [SAVE]? Switch on
field saving mode
+ f._saveOnChange = (!self._hasSaveButton); // No [SAVE] button?
Switch on field saving mode
} catch(err) {
self.log(err,prop,val,this);
SimileAjax.Debug.warn(err);
}
- self._addFieldComponent(this,prop,f,onShow);
+ self._addFieldComponent(this,prop,f,onShow,true);
}catch(err) { self.log(err,prop,val,this); }
});
}
@@ -158,7 +160,7 @@
self.log(err,prop,val,self);
SimileAjax.Debug.warn(err);
}
- self._addFieldComponent(this,prop,f,onShow); // jq = this
+ self._addFieldComponent(this,prop,f,onShow,false); // jq = this
}
}catch(err) { self.log(err,prop,val,self); }
});
@@ -212,10 +214,31 @@
}
}
}*/
-Exhibit.DataEdit.Editor.prototype._addFieldComponent =
function(jq,prop,f,onShow) {
+Exhibit.DataEdit.Editor.prototype._addFieldComponent =
function(jq,prop,f,onShow,usingLens) {
if(f) {
this._fields[prop] = f;
- $(jq).replaceWith(f.getHTML(onShow));
+ var h = f.getHTML(onShow);
+ // Auto-resize?
+ var srcDim = { width:$(jq).width() , height:$(jq).height() };
+ var prefDim = f['_prefDimensions']; // Has _prefDimensions..?
+ if(!usingLens && prefDim && ((srcDim.width<prefDim.width) ||
(srcDim.height<prefDim.height))) {
+ h = '<span style="display:Inline-Block; position:Relative;
width:'+srcDim.width+'px; height:'+srcDim.height+'px;">'+h+'</span>';
+ $(jq).replaceWith(h);
+ $('#'+f._divId)
+ .mouseenter(function(ev) { // Mouse enter: upsize and raise
+ var pos = $(this).parent().position();
+
$(this).width(prefDim.width).height(prefDim.height).css('z-index','1000');
+ })
+ .mouseleave(function(ev) { // Mouse leave: downsize and lower
+
$(this).width(srcDim.width).height(srcDim.height).css('z-index','Auto');
+ })
+ .css('position','Absolute').css('top','0px').css('left','0px');
+ // Empty text may cause 0 sized fields. 10 pixels min seems sensible.
+ if(srcDim.width<=0) { srcDim.width=10;
$('#'+f._divId).width(srcDim.width); }
+ if(srcDim.height<=0) { srcDim.height=10;
$('#'+f._divId).height(srcDim.height); }
+ } else {
+ $(jq).replaceWith(h);
+ }
} else {
$(jq).replaceWith('<span style="color:Red;">Failed to initalise</span>');
}
@@ -301,36 +324,24 @@
return null;
}
}*/
-/** Return line height of element, as best it can be guessed. */
-Exhibit.DataEdit.Editor._getLineHeight = function(el) {
- var h = null;
- if(el.currentStyle) {
- h = el.currentStyle['lineHeight']; // IE
- } else if(document.defaultView!=undefined &&
document.defaultView.getComputedStyle!=undefined) {
- h =
document.defaultView.getComputedStyle(el,null).getPropertyValue('line-height');
// Moz/Chrome/W3C
- }
- // Parse
- if(h) {
- if(h.indexOf('px')>=0) { return parseInt(h.replace(/px/,'')); }
- else if(el.parentNode!=null) { return
Exhibit.DataEdit.Editor._getLineHeight(el.parentNode); }
- else { return 16; }
- } else {
- return 16;
- }
-}
-/** Return line height of element, as best it can be guessed. */
-Exhibit.DataEdit.Editor._getLineHeight2 = function(el) {
- var el2 = document.createElement('div');
- el2.style.fontFamily = el.style.fontFamily;
- el2.style.fontSize = el.style.fontSize;
- el2.style.fontStyle = el.style.fontStyle;
- el2.style.fontVariant = el.style.fontVariant;
- el2.style.fontWeight = el.style.fontWeight;
- el2.style.lineHeight = el.style.lineHeight;
- el2.innerHTML = "Mj";
-
- return el2.offsetHeight;
-}
+/** Using inherited font, how big in pixels would some text (cols x rows)
be? */
+Exhibit.DataEdit.Editor._getColRowDimensions = function(jq,cols,rows) {
+ /* Yeah, so apparently the only cross-browser way to get line height in
pixels is to
+ * inject a <span> into the start of the element, ask for it's height,
then remove it!! */
+ $(jq).prepend('<span id="__SIZE_GUESSER__">M</span>');
+ var textW = $('#__SIZE_GUESSER__',jq).width();
+ var textH = $('#__SIZE_GUESSER__',jq).height();
+ $('#__SIZE_GUESSER__',jq).remove();
+ return { width:(cols*textW) , height:(rows*textH) };
+}
+/** Unique ids -- handy! */
+Exhibit.DataEdit.Editor._uid = (new Date).getTime();
+Exhibit.DataEdit.Editor._getUID = function() {
+ // FIXME: Not thread safe!!
+ Exhibit.DataEdit.Editor._uid++;
+ return Exhibit.DataEdit.Editor._uid;
+}
+
/** Return match, or closest match. */
Exhibit.DataEdit.Editor.matchExactStringFromList = function(str,list) {
var lstr = str.toLowerCase();
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/enum-field.js
Fri Sep 23 02:21:25 2011
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/enum-field.js
Fri Jan 6 08:39:42 2012
@@ -20,7 +20,7 @@
this._itemId = iid; // Database item (subject) id
this._propId = pid; // Database property (predicate)
this._value = val; // <string>
- this._divId = '__DATAEDITOR__'+this._propId;
+ this._divId
= '__DATAEDITOR__'+this._propId+'_'+Exhibit.DataEdit.Editor._getUID();
this._validators = $(jq).attr("ex:validators");
this._disabledFor =
Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens = noLens; // No editor lens?
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/list-field.js
Fri Sep 23 02:21:25 2011
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/list-field.js
Fri Jan 6 08:39:42 2012
@@ -21,7 +21,7 @@
this._itemId = iid; // Database item (subject) id
this._propId = pid; // Database property (predicate)
this._value = val; // <Array>
- this._divId = '__DATAEDITOR__'+this._propId;
+ this._divId
= '__DATAEDITOR__'+this._propId+'_'+Exhibit.DataEdit.Editor._getUID();
this._validators = $(jq).attr("ex:validators");
this._disabledFor =
Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens = noLens; // No editor lens?
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/number-field.js
Fri Sep 23 02:21:25 2011
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/number-field.js
Fri Jan 6 08:39:42 2012
@@ -28,7 +28,7 @@
this._itemId = iid; // Database item (subject) id
this._propId = pid; // Database property (predicate)
this._value = val; // <number>
- this._divId = '__DATAEDITOR__'+this._propId;
+ this._divId
= '__DATAEDITOR__'+this._propId+'_'+Exhibit.DataEdit.Editor._getUID();
this._validators = $(jq).attr("ex:validators");
this._disabledFor =
Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens = noLens; // No editor lens?
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/text-field.js
Tue Oct 11 05:03:04 2011
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/text-field.js
Fri Jan 6 08:39:42 2012
@@ -24,12 +24,13 @@
this._itemId = iid; // Database item (subject) id
this._propId = pid; // Database property (predicate)
this._value = val; // <string>
- this._divId = '__DATAEDITOR__'+this._propId;
+ this._divId
= '__DATAEDITOR__'+this._propId+'_'+Exhibit.DataEdit.Editor._getUID();
this._validators = $(jq).attr("ex:validators");
this._disabledFor =
Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens = noLens; // No editor lens?
this._matchDisplayLens =
Exhibit.DataEdit.Editor._parseTrueFalse($(jq).attr("ex:useDisplayStyle"));
// Try to find into display lens
this._saveOnChange = false;
+ this._prefDimensions = null;
// For this component only
this._largeText =
Exhibit.DataEdit.Editor._parseTrueFalse($(jq).attr("ex:large")); // Use
<textarea> ?
this._rows = parseInt($(jq).attr("ex:rows"));
@@ -43,28 +44,15 @@
/** Create component HTML. */
Exhibit.DataEdit.Editor.TextField.prototype.getHTML = function(onShow) {
+ var textDim =
Exhibit.DataEdit.Editor._getColRowDimensions(this._jqThis,1,1);
+ this._prefDimensions = { width:textDim.width*10 , height:textDim.height*1
};
var style = null;
if(this._noEditorLens || this._matchDisplayLens) {
style = Exhibit.DataEdit.Editor._extractStyle(this._jqThis) +
- 'border-width: 0px; '+
+ 'border-width: 0px; border-style: None; padding: 0px; '+
'width: '+$(this._jqThis).width()+'px;
height: '+$(this._jqThis).height()+'px; ';
- /* FIXME: The below junk is various attempts to detect whether the <div>
content we're
- * editing spans multiple lines, so we can correctly use a <textarea> or
<input>. Seems
- * this isn't easy, so (in desperation more than anything else) always
use <textarea>. */
- // Switch to multiline?
- /*var h1 = $(this._jqThis).height();
- var h2 = $(this._jqThis).css('line-height');*/
- //console.log(
Exhibit.DataEdit.Editor._getComputedStyle($(this._jqThis).get()[0],'line-height')
);
- //console.log(
Exhibit.DataEdit.Editor._getComputedStyle($(this._jqThis).get()[0],'font-size')
);
- //var el = $(this._jqThis).get()[0];
- //console.log(Exhibit.DataEdit.Editor._getLineHeight(el));
- /* Yeah, so apparently the only cross-browser way to get line height in
pixels is to
- * inject a <span> into the start of the element, ask for it's height,
then remove it!! */
var contH = $(this._jqThis).height();
- $(this._jqThis).prepend('<span id="__SIZE_GUESSER__">M</span>');
- var textH = $('#__SIZE_GUESSER__',this._jqThis).height();
- $('#__SIZE_GUESSER__',this._jqThis).remove();
- this._largeText = ((contH/textH) >= 2);
+ this._largeText = ((contH/textDim.height) >= 2);
}
var onChange =
(this._saveOnChange) ? "Exhibit.DataEdit.onChange('"+this._itemId+"','"+this._propId+"')" : "";
if(this._largeText) {
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/ticklist-field.js
Tue Sep 27 07:58:11 2011
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/scripts/ticklist-field.js
Fri Jan 6 08:39:42 2012
@@ -21,7 +21,7 @@
this._itemId = iid; // Database item (subject) id
this._propId = pid; // Database property (predicate)
this._value = val; // <Array>
- this._divId = '__DATAEDITOR__'+this._propId;
+ this._divId
= '__DATAEDITOR__'+this._propId+'_'+Exhibit.DataEdit.Editor._getUID();
this._validators = $(jq).attr("ex:validators");
this._disabledFor =
Exhibit.DataEdit.Editor._parseDisabledFor($(jq).attr("ex:disableFor"));
this._noEditorLens = noLens; // No editor lens?
=======================================
---
/exhibit/trunk/src/webapp/api/extensions/data-editor/styles/data-editor.css
Wed Sep 28 07:08:21 2011
+++
/exhibit/trunk/src/webapp/api/extensions/data-editor/styles/data-editor.css
Fri Jan 6 08:39:42 2012
@@ -28,9 +28,9 @@
color: #000000;
background-color: #dddddd;
}
-.exhibitDataEditButton #symbol { color: White; }
-.exhibitDataEditButton #symbol .on { background-color: Green; }
-.exhibitDataEditButton #symbol .off { background-color: #888888; }
+.exhibitDataEditButton #editorToggleSymbol { color: White; }
+.exhibitDataEditButton #editorToggleSymbol .on { background-color: Green; }
+.exhibitDataEditButton #editorToggleSymbol .off { background-color:
#888888; }
/*
* Components