Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge with branch menubutton

  • Loading branch information...
commit 6a0afb1f9ecb0a29d103815e81be9bad0cfed12d 2 parents ade49fc + 60feba2
@pdl authored
View
5 .gitignore
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
*.bak
*~
*.old
@@ -17,3 +18,7 @@ MYMETA.*
.TemporaryItems
.Trashes
.fseventsd
+=======
+*~
+
+>>>>>>> 60feba2b59bf545d08f8c334ceec8305de73b4d9
View
48 bex-spec.md
@@ -0,0 +1,48 @@
+# BEX - Browser Editor for XML
+
+Node
+- Element
+- Text
+- Attribute
+- Other
+- List
+
+### Core methods
+
+#### Manipulation
+
+new
+insertBefore
+insertAfter
+appendNode
+setData
+setName
+unbind
+destroy
+
+List->
+remove
+
+#### Traversal
+
+children
+parent
+following
+preceding
+attributes
+name
+
+### Derived methods
+
+#### Manipulation
+
+moveBeforePrevious
+moveAfterNext
+moveAfterParent
+moveIntoPreceding
+append
+prepend
+before
+after
+
+$text->bisect ::= insertAfter, substring
View
34 html/local.test.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
+ <title>Test</title>
+<!-- <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/sunny/jquery-ui.css" /> -->
+ <link rel="stylesheet" type="text/css" href="../jquery/smoothness/jquery-ui-1.8.23.custom.css" />
+ <link rel="stylesheet" type="text/css" href="../css/ui.bextextnode.css"/>
+<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script> -->
+ <script src="../jquery/jquery-1.8.0.js"></script>
+ <script src="../jquery/jquery-ui-1.8.23.custom.min.js"></script>
+ <script src="../zc/zen_textarea.js"></script>
+ <script src="../js/jquery.ui.bexcontents.js"></script>
+ <script src="../js/jquery.ui.bexchildnode.js"></script>
+ <script src="../js/jquery.ui.bexparentnode.js"></script>
+ <script src="../js/jquery.ui.bexmenubutton.js"></script>
+ <script src="../js/jquery.ui.bextextcontainer.js"></script>
+ <script src="../js/jquery.ui.bextextnode.js"></script>
+ <script src="../js/jquery.ui.bexcommentnode.js"></script>
+ <script src="../js/jquery.ui.bexcdatasection.js"></script>
+ <script src="../js/jquery.ui.bexelement.js"></script>
+ <script src="../js/jquery.ui.bexdocument.js"></script>
+ <script src="../js/bex.js"></script>
+</head>
+<body style="font-size: 1em; font-family:sans-serif;">
+ <!--
+ div.document>ul.contents>li>div.element>(ul.menu>li*3>a)+(dl.attributes>dt+dd)+ul.contents>li
+ -->
+
+ <textarea name="" id="bexme" cols="30" rows="10">&lt;root&gt;&lt;element/&gt;text&lt;element/&gt;&lt;comment&gt;<!-- this is a comment </body> -->&lt;/comment&gt;&lt;cdata&gt;<![CDATA[%{ <&$_> }]]>&lt;/cdata&gt;&lt;/root&gt;</textarea>
+
+</body>
+</html>
View
21 html/test.html
@@ -8,9 +8,6 @@
<link rel="stylesheet" type="text/css" href="../css/ui.bextextnode.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
-<!-- <script src="../jquery/jquery-1.8.0.js"></script>
- <script src="../jquery/jquery-ui-1.8.23.custom.min.js"></script>
- <script src="../zc/zen_textarea.js"></script>-->
<script src="../js/jquery.ui.bexcontents.js"></script>
<script src="../js/jquery.ui.bexchildnode.js"></script>
<script src="../js/jquery.ui.bexparentnode.js"></script>
@@ -21,6 +18,24 @@
<script src="../js/jquery.ui.bexcdatasection.js"></script>
<script src="../js/jquery.ui.bexelement.js"></script>
<script src="../js/jquery.ui.bexdocument.js"></script>
+ <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/sunny/jquery-ui.css" /> -->
+ <link rel="stylesheet" type="text/css" href="../jquery/smoothness/jquery-ui-1.8.23.custom.css" />
+ <link rel="stylesheet" type="text/css" href="../css/ui.bextextnode.css"/>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
+ <script src="../jquery/jquery-1.8.0.js"></script>
+ <script src="../jquery/jquery-ui-1.8.23.custom.min.js"></script>
+ <script src="../zc/zen_textarea.js"></script>
+ <script src="../js/bex.contents.js"></script>
+ <script src="../js/bex.childnode.js"></script>
+ <script src="../js/bex.parentnode.js"></script>
+ <script src="../js/bex.menubutton.js"></script>
+ <script src="../js/bex.textcontainer.js"></script>
+ <script src="../js/bex.textnode.js"></script>
+ <script src="../js/bex.commentnode.js"></script>
+ <script src="../js/bex.cdatasection.js"></script>
+ <script src="../js/bex.element.js"></script>
+ <script src="../js/bex.document.js"></script>
<script src="../js/bex.js"></script>
</head>
<body style="font-size: 1em; font-family:sans-serif;">
View
2  js/jquery.ui.bexcdatasection.js → js/bex.cdatasection.js
@@ -1,5 +1,5 @@
(function($) {
- $.widget("ui.bexcdatasection", {
+ $.widget("bex.bexcdatasection", {
options: {
},
View
2  js/jquery.ui.bexchildnode.js → js/bex.childnode.js
@@ -14,7 +14,7 @@ Used by:
*/
(function($) {
- $.widget("ui.bexchildnode", {
+ $.widget("bex.bexchildnode", {
options: {
},
View
2  js/jquery.ui.bexcommentnode.js → js/bex.commentnode.js
@@ -1,5 +1,5 @@
(function($) {
- $.widget("ui.bexcommentnode", {
+ $.widget("bex.bexcommentnode", {
options: {
},
View
0  js/bexcommon.js → js/bex.common.js
File renamed without changes
View
2  js/jquery.ui.bexcontents.js → js/bex.contents.js
@@ -1,5 +1,5 @@
(function($) {
- $.widget("ui.bexcontents", {
+ $.widget("bex.bexcontents", {
options: {
},
_create: function() {
View
2  js/jquery.ui.bexdocument.js → js/bex.document.js
@@ -1,5 +1,5 @@
(function($) {
- $.widget("ui.bexdocument", {
+ $.widget("bex.bexdocument", {
options: {
},
_create: function() {
View
5 js/jquery.ui.bexelement.js → js/bex.element.js
@@ -1,5 +1,5 @@
(function($) {
- $.widget("ui.bexelement", {
+ $.widget("bex.bexelement", {
options: {
from: $('<element/>')
},
@@ -10,7 +10,8 @@
.addClass("ui-widget ui-widget-contents ui-helper-reset bex-element");
var bexheader = $('<div></div>').addClass("ui-widget-header ui-corner-all bex-element-header").appendTo(el);
el.bexparentnode().bexchildnode();
- var menu = $("<button></button>").bexmenubutton().appendTo(bexheader);
+ var menu = $("<button></button>").appendTo(bexheader);
+ el.bexmenubutton({"button": menu});
var bexnodename = $('<span></span>')
.text(o.from[0].nodeName)
.bextextcontainer({pattern:'[a-zA-Z][\w]*'})
View
64 js/jquery.ui.bexmenubutton.js → js/bex.menubutton.js
@@ -1,12 +1,20 @@
(function($) {
- $.widget("ui.bexmenubutton", {
+ var validName = "[a-zA-Z_][a-zA-Z_0-9\-]*";
+ var validBexName = "bex\.(menubutton|elementnode|childnode|documentnode|parentnode|[a-z]+)\.([a-zA-Z_][a-zA-Z_0-9\-]*)";
+ $.widget("bex.bexmenubutton", {
options: {
+ commands: {}
},
_create: function() {
var self = this;
var o = self.options;
- var el = self.element
- .button({
+ var el = self.element;
+ var button = self.options.button;
+ if (!typeof button){
+ button = $("<button></button>").appendTo(el)
+ }
+ self.button = button;
+ button.button({
text: false,
icons: {
primary: "ui-icon-triangle-1-s"
@@ -23,9 +31,9 @@
{
label: "Before Preceding",
action: function(){
- var controller = self.controller();
+ var controller = self.element;
$(controller).bexchildnode('precedingSibling').bexchildnode("insertPreceding", controller);
- $(self.element).focus();
+ $(self.button).focus();
}
}
]
@@ -33,7 +41,7 @@
{
label: "Delete",
action: function(){
- $(self.controller()).bexchildnode('removeNode');
+ $(self.element).bexchildnode('removeNode');
}
}
];
@@ -53,12 +61,12 @@
for (var i=0; i<menuoptions.length; i++){
add_menuoption(bexcontextmenu, menuoptions[i]);
}
- bexcontextmenu.menu().show().appendTo(self.controller());
+ bexcontextmenu.menu().show().appendTo(self.button);
})
/* Define the keyboard commands */
.keyup(function(e){
/* alert( "Keyup " + e.keyCode + " CtrlKey: "+e.ctrlKey); */
- var controller = self.controller();
+ var controller = self.element;
var keyCode = e.keyCode;
if (e.ctrlKey)
@@ -67,19 +75,19 @@
{
case 37: /*LEFT: Insert after parent*/
$(controller).bexchildnode('parent').bexchildnode("insertFollowing", controller);
- $(self.element).focus();
+ $(self.button).focus();
break;
case 38: /*UP: Insert before previous*/
$(controller).bexchildnode('precedingSibling').bexchildnode("insertPreceding", controller);
- $(self.element).focus();
+ $(self.button).focus();
break;
case 39: /*RIGHT: Append to previous*/
$(controller).bexchildnode('precedingSibling').bexparentnode("append", controller);
- $(self.element).focus();
+ $(self.button).focus();
break;
case 40: /*DOWN: Insert after following */
$(controller).bexchildnode('followingSibling').bexchildnode("insertFollowing", controller);
- $(self.element).focus();
+ $(self.button).focus();
break;
case 46: /*DELETE*/
$( "#bex-dlg-confirm-delete" ).dialog({
@@ -88,8 +96,8 @@
modal: true,
title: 'Confirm node deletion',
close: function(){
- if (self.element){
- self.element.focus();
+ if (self.button){
+ self.button.focus();
}
},
buttons: {
@@ -108,8 +116,8 @@
modal: true,
title: 'Insert Node',
close: function(){
- if (self.element){
- self.element.focus();
+ if (self.button){
+ self.button.focus();
}
},
buttons: {
@@ -164,9 +172,23 @@
});
return self;
},
- controller: function() {
+ addCommand: function(command) {
var self = this;
- return $(self.element).parents('.bex-textnode, .bex-element').first();
+ var commands = self.commands;
+ commands[command.name] = command;
+ /*
+ if (command.name && validName.match(command.name)){
+ self.commands[command.name] = command;
+ }
+ if (command.name && validBexName.match(command.name)){
+ command.action = function () {self.element[ns](method)}
+ self.commands[command.name] = command;
+ }*/
+ return self;
+ },
+ execCommand: function(commandName){
+ var self = this;
+ self.commands[commandName](self);
},
destroy: function() {
@@ -180,10 +202,10 @@
/*
- TODO: Make bexmenubutton apply to the controlling element. It will either find and use an existing button as the button or, if it cannot, it will just append a button.
-
+ DONE: Make bexmenubutton apply to the controlling element. It will either find and use an existing button as the button or, if it cannot, it will just append a button.
+
Commands are always user-facing and if they require parameters, will demand them.
-
+ TODO: Write the following methods
addCommand ( {
name: 'insertBefore',
action: function(){}
View
2  js/jquery.ui.bexparentnode.js → js/bex.parentnode.js
@@ -1,5 +1,5 @@
(function($) {
- $.widget("ui.bexparentnode", {
+ $.widget("bex.bexparentnode", {
options: {
},
_create: function() {
View
2  js/jquery.ui.bextextcontainer.js → js/bex.textcontainer.js
@@ -1,5 +1,5 @@
(function($) {
- $.widget("ui.bextextcontainer", {
+ $.widget("bex.bextextcontainer", {
options: {
pattern: ''
},
View
5 js/jquery.ui.bextextnode.js → js/bex.textnode.js
@@ -1,5 +1,5 @@
(function($) {
- $.widget("ui.bextextnode", {
+ $.widget("bex.bextextnode", {
options: {
},
@@ -12,8 +12,9 @@
.addClass("ui-widget bex-textnode ui-helper-reset")
.bexchildnode();
var
- menu = $("<button></button>").bexmenubutton().appendTo(el),
+ menu = $("<button></button>").appendTo(el),
textcontainer = $("<span></span>").text(textcontent).bextextcontainer().appendTo(el);
+ el.bexmenubutton({"button": menu})
self._trigger("added", null);
return self;
},

0 comments on commit 6a0afb1

Please sign in to comment.
Something went wrong with that request. Please try again.