Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions ite.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ angular.module( 'InlineTextEditor', ['ngSanitize']);
function inlineTextEditor($sce, $compile, $timeout, $window, $sanitize){
return {
restrict: 'A',
require: '?ngModel',
link: function($scope, element, attrs, ngModel) {

require: ['?ngModel', '?editMode'],
link: function($scope, element, attrs, args) {
var ngModel = args[0];
var editMode = args[1] || false;
var html, savedSelection, clickPosition, overToolbar, originalToolbar, toolbar;

if (!ngModel) { return; }
Expand All @@ -16,6 +17,10 @@ function inlineTextEditor($sce, $compile, $timeout, $window, $sanitize){
element.html(ngModel.$viewValue || '');
};

attrs.$observe('editMode', function(value) {
editMode = value;
});

// Write data to the model
function read() {
var html = element.html();
Expand Down Expand Up @@ -116,7 +121,7 @@ function inlineTextEditor($sce, $compile, $timeout, $window, $sanitize){
var start = range.anchorOffset;
var end = range.focusOffset;

if (!range.isCollapsed) {
if (!range.isCollapsed && eval(editMode)) {
createToolbar();
} else {
removeToolbar();
Expand Down