-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from SimplyEdit/tripleBinding
Triple binding
- Loading branch information
Showing
74 changed files
with
45,815 additions
and
930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
hope.register( 'hope.annotation', function() { | ||
|
||
function hopeAnnotation(range, tag) { | ||
this.range = hope.range.create(range); | ||
this.tag = tag; | ||
Object.freeze(this); | ||
} | ||
|
||
hopeAnnotation.prototype.delete = function( range ) { | ||
return new hopeAnnotation( this.range.delete( range ), this.tag ); | ||
}; | ||
|
||
hopeAnnotation.prototype.copy = function( range ) { | ||
return new hopeAnnotation( this.range.copy( range ), this.tag ); | ||
}; | ||
|
||
hopeAnnotation.prototype.compare = function( annotation ) { | ||
return this.range.compare( annotation.range ); | ||
}; | ||
|
||
hopeAnnotation.prototype.has = function( tag ) { | ||
//FIXME: should be able to specify attributes and attribute values as well | ||
return this.stripTag() == hope.annotation.stripTag(tag); | ||
}; | ||
|
||
hopeAnnotation.prototype.toString = function() { | ||
return this.range + ':' + this.tag; | ||
}; | ||
|
||
hopeAnnotation.prototype.stripTag = function() { | ||
return hope.annotation.stripTag(this.tag); | ||
}; | ||
|
||
hopeAnnotation.prototype.isBlock = function() { | ||
return (hope.render.html.rules.nestingSets.block.indexOf(hope.annotation.stripTag(this.tag)) != -1 ); // FIXME: this should not know about hope.render.html; | ||
}; | ||
|
||
this.create = function( range, tag ) { | ||
return new hopeAnnotation( range, tag ); | ||
}; | ||
|
||
this.stripTag = function(tag) { | ||
return tag.split(' ')[0]; | ||
}; | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
hope.register('hope.editor.events', function() { | ||
|
||
if ( typeof hope.global.addEventListener != 'undefined' ) { | ||
this.listen = function( el, event, callback, capture ) { | ||
return el.addEventListener( event, callback, capture ); | ||
}; | ||
} else if ( typeof hope.global.attachEvent != 'undefined' ) { | ||
this.listen = function( el, event, callback, capture ) { | ||
return el.attachEvent( 'on' + event, function() { | ||
var evt = hope.global.event; | ||
var self = evt.srcElement; | ||
if ( !self ) { | ||
self = hope.global; | ||
} | ||
return callback.call( self, evt ); | ||
} ); | ||
}; | ||
} else { | ||
throw new hope.Exception( 'Browser is not supported', 'hope.editor.events.1' ); | ||
} | ||
|
||
this.cancel = function( evt ) { | ||
if ( typeof evt.stopPropagation != 'undefined' ) { | ||
evt.stopPropagation(); | ||
} | ||
if ( typeof evt.preventDefault != 'undefined' ) { | ||
evt.preventDefault(); | ||
} | ||
if ( typeof evt.cancelBubble != 'undefined' ) { | ||
evt.cancelBubble = true; | ||
} | ||
return false; | ||
}; | ||
|
||
} ); |
Oops, something went wrong.