mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-07-04 19:12:51 +00:00
Add "dir" attribute to reveal, edit, edit-text and edit-codemirror widgets
This commit is contained in:
parent
265e7a2da2
commit
b833103428
@ -71,6 +71,9 @@ function FramedEngine(options) {
|
|||||||
if(this.widget.editRows) {
|
if(this.widget.editRows) {
|
||||||
this.domNode.setAttribute("rows",this.widget.editRows);
|
this.domNode.setAttribute("rows",this.widget.editRows);
|
||||||
}
|
}
|
||||||
|
if(this.widget.editDir) {
|
||||||
|
this.domNode.setAttribute("dir",this.widget.editDir);
|
||||||
|
}
|
||||||
if(this.widget.editTabIndex) {
|
if(this.widget.editTabIndex) {
|
||||||
this.iframeNode.setAttribute("tabindex",this.widget.editTabIndex);
|
this.iframeNode.setAttribute("tabindex",this.widget.editTabIndex);
|
||||||
}
|
}
|
||||||
@ -97,6 +100,7 @@ FramedEngine.prototype.copyStyles = function() {
|
|||||||
this.domNode.style.width = "100%";
|
this.domNode.style.width = "100%";
|
||||||
this.domNode.style.margin = "0";
|
this.domNode.style.margin = "0";
|
||||||
this.domNode.style["background-color"] = this.widget.wiki.extractTiddlerDataItem(this.widget.wiki.getTiddlerText("$:/palette"),"tiddler-editor-background");
|
this.domNode.style["background-color"] = this.widget.wiki.extractTiddlerDataItem(this.widget.wiki.getTiddlerText("$:/palette"),"tiddler-editor-background");
|
||||||
|
this.domNode.style.direction = "";
|
||||||
// In Chrome setting -webkit-text-fill-color overrides the placeholder text colour
|
// In Chrome setting -webkit-text-fill-color overrides the placeholder text colour
|
||||||
this.domNode.style["-webkit-text-fill-color"] = "currentcolor";
|
this.domNode.style["-webkit-text-fill-color"] = "currentcolor";
|
||||||
};
|
};
|
||||||
|
@ -52,6 +52,9 @@ function SimpleEngine(options) {
|
|||||||
if(this.widget.editTabIndex) {
|
if(this.widget.editTabIndex) {
|
||||||
this.domNode.setAttribute("tabindex",this.widget.editTabIndex);
|
this.domNode.setAttribute("tabindex",this.widget.editTabIndex);
|
||||||
}
|
}
|
||||||
|
if(this.widget.editDir) {
|
||||||
|
this.domNode.setAttribute("dir",this.widget.editDir);
|
||||||
|
}
|
||||||
// Add an input event handler
|
// Add an input event handler
|
||||||
$tw.utils.addEventListeners(this.domNode,[
|
$tw.utils.addEventListeners(this.domNode,[
|
||||||
{name: "focus", handlerObject: this, handlerMethod: "handleFocusEvent"},
|
{name: "focus", handlerObject: this, handlerMethod: "handleFocusEvent"},
|
||||||
|
@ -177,6 +177,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
|||||||
this.editFocusPopup = this.getAttribute("focusPopup");
|
this.editFocusPopup = this.getAttribute("focusPopup");
|
||||||
this.editFocus = this.getAttribute("focus");
|
this.editFocus = this.getAttribute("focus");
|
||||||
this.editTabIndex = this.getAttribute("tabindex");
|
this.editTabIndex = this.getAttribute("tabindex");
|
||||||
|
this.editDir = this.getAttribute("dir");
|
||||||
// Get the default editor element tag and type
|
// Get the default editor element tag and type
|
||||||
var tag,type;
|
var tag,type;
|
||||||
if(this.editField === "text") {
|
if(this.editField === "text") {
|
||||||
@ -208,7 +209,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
|||||||
EditTextWidget.prototype.refresh = function(changedTiddlers) {
|
EditTextWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
var changedAttributes = this.computeAttributes();
|
var changedAttributes = this.computeAttributes();
|
||||||
// Completely rerender if any of our attributes have changed
|
// Completely rerender if any of our attributes have changed
|
||||||
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE]) {
|
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.dir || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE]) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else if(changedTiddlers[this.editTitle]) {
|
} else if(changedTiddlers[this.editTitle]) {
|
||||||
|
@ -48,6 +48,7 @@ EditWidget.prototype.execute = function() {
|
|||||||
this.editPlaceholder = this.getAttribute("placeholder");
|
this.editPlaceholder = this.getAttribute("placeholder");
|
||||||
this.editTabIndex = this.getAttribute("tabindex");
|
this.editTabIndex = this.getAttribute("tabindex");
|
||||||
this.editFocus = this.getAttribute("focus","");
|
this.editFocus = this.getAttribute("focus","");
|
||||||
|
this.editDir = this.getAttribute("dir");
|
||||||
// Choose the appropriate edit widget
|
// Choose the appropriate edit widget
|
||||||
this.editorType = this.getEditorType();
|
this.editorType = this.getEditorType();
|
||||||
// Make the child widgets
|
// Make the child widgets
|
||||||
@ -60,7 +61,8 @@ EditWidget.prototype.execute = function() {
|
|||||||
"class": {type: "string", value: this.editClass},
|
"class": {type: "string", value: this.editClass},
|
||||||
"placeholder": {type: "string", value: this.editPlaceholder},
|
"placeholder": {type: "string", value: this.editPlaceholder},
|
||||||
"tabindex": {type: "string", value: this.editTabIndex},
|
"tabindex": {type: "string", value: this.editTabIndex},
|
||||||
"focus": {type: "string", value: this.editFocus}
|
"focus": {type: "string", value: this.editFocus},
|
||||||
|
dir: {type: "string", value: this.editDir}
|
||||||
},
|
},
|
||||||
children: this.parseTreeNode.children
|
children: this.parseTreeNode.children
|
||||||
}]);
|
}]);
|
||||||
@ -94,7 +96,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
|
|||||||
EditWidget.prototype.refresh = function(changedTiddlers) {
|
EditWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
var changedAttributes = this.computeAttributes();
|
var changedAttributes = this.computeAttributes();
|
||||||
// Refresh if an attribute has changed, or the type associated with the target tiddler has changed
|
// Refresh if an attribute has changed, or the type associated with the target tiddler has changed
|
||||||
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || (changedTiddlers[this.editTitle] && this.getEditorType() !== this.editorType)) {
|
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.dir || (changedTiddlers[this.editTitle] && this.getEditorType() !== this.editorType)) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,6 +41,9 @@ RevealWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
if(this.style) {
|
if(this.style) {
|
||||||
domNode.setAttribute("style",this.style);
|
domNode.setAttribute("style",this.style);
|
||||||
}
|
}
|
||||||
|
if(this.direction) {
|
||||||
|
domNode.setAttribute("dir",this.direction);
|
||||||
|
}
|
||||||
parent.insertBefore(domNode,nextSibling);
|
parent.insertBefore(domNode,nextSibling);
|
||||||
this.renderChildren(domNode,null);
|
this.renderChildren(domNode,null);
|
||||||
if(!domNode.isTiddlyWikiFakeDom && this.type === "popup" && this.isOpen) {
|
if(!domNode.isTiddlyWikiFakeDom && this.type === "popup" && this.isOpen) {
|
||||||
@ -107,6 +110,7 @@ RevealWidget.prototype.execute = function() {
|
|||||||
this["default"] = this.getAttribute("default","");
|
this["default"] = this.getAttribute("default","");
|
||||||
this.animate = this.getAttribute("animate","no");
|
this.animate = this.getAttribute("animate","no");
|
||||||
this.retain = this.getAttribute("retain","no");
|
this.retain = this.getAttribute("retain","no");
|
||||||
|
this.direction = this.getAttribute("dir");
|
||||||
this.openAnimation = this.animate === "no" ? undefined : "open";
|
this.openAnimation = this.animate === "no" ? undefined : "open";
|
||||||
this.closeAnimation = this.animate === "no" ? undefined : "close";
|
this.closeAnimation = this.animate === "no" ? undefined : "close";
|
||||||
// Compute the title of the state tiddler and read it
|
// Compute the title of the state tiddler and read it
|
||||||
@ -199,7 +203,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
|
|||||||
*/
|
*/
|
||||||
RevealWidget.prototype.refresh = function(changedTiddlers) {
|
RevealWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
var changedAttributes = this.computeAttributes();
|
var changedAttributes = this.computeAttributes();
|
||||||
if(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || changedAttributes.positionAllowNegative || changedAttributes["default"] || changedAttributes.animate || changedAttributes.stateTitle || changedAttributes.stateField || changedAttributes.stateIndex) {
|
if(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || changedAttributes.positionAllowNegative || changedAttributes["default"] || changedAttributes.animate || changedAttributes.stateTitle || changedAttributes.stateField || changedAttributes.stateIndex || changedAttributes.direction) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -109,6 +109,9 @@ function CodeMirrorEngine(options) {
|
|||||||
if(this.widget.editTabIndex) {
|
if(this.widget.editTabIndex) {
|
||||||
config["tabindex"] = this.widget.editTabIndex;
|
config["tabindex"] = this.widget.editTabIndex;
|
||||||
}
|
}
|
||||||
|
if(this.widget.editDir) {
|
||||||
|
config.direction = this.widget.editDir;
|
||||||
|
}
|
||||||
// Create the CodeMirror instance
|
// Create the CodeMirror instance
|
||||||
this.cm = window.CodeMirror(function(cmDomNode) {
|
this.cm = window.CodeMirror(function(cmDomNode) {
|
||||||
// Note that this is a synchronous callback that is called before the constructor returns
|
// Note that this is a synchronous callback that is called before the constructor returns
|
||||||
|
Loading…
x
Reference in New Issue
Block a user