-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
643b03d
commit 8024e64
Showing
8 changed files
with
126 additions
and
27 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
34 changes: 34 additions & 0 deletions
34
djangoproject/statfiles/static/js/contenteditable/contenteditable.js
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,34 @@ | ||
angular.module('contenteditable', []). | ||
directive('contenteditable', function () { | ||
return { | ||
restrict: 'A', // only activate on element attribute | ||
require: '?ngModel', // get a hold of NgModelController | ||
link: function (scope, element, attrs, ngModel) { | ||
if (!ngModel) return; // do nothing if no ng-model | ||
|
||
// Specify how UI should be updated | ||
ngModel.$render = function () { | ||
element.html(ngModel.$viewValue || ''); | ||
}; | ||
|
||
// Listen for change events to enable binding | ||
element.on('blur keyup change', function () { | ||
scope.$apply(readViewText); | ||
}); | ||
|
||
// No need to initialize, AngularJS will initialize the text based on ng-model attribute | ||
|
||
// Write data to the model | ||
function readViewText() { | ||
var html = element[0].innerHTML; | ||
// When we clear the content editable the browser leaves a <br> behind | ||
// If strip-br attribute is provided then we strip this out | ||
if (attrs.stripBr) { | ||
html = html.replace(/<br>/g,""); | ||
element[0].innerHTML = html; | ||
} | ||
ngModel.$setViewValue(html); | ||
} | ||
} | ||
}; | ||
}); |
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
<div> | ||
<span href class="tag" ng-repeat="tag in tags" style="margin-right: 10px;"> | ||
{[{tag}]} | ||
<a href ng-show="editable" ng-click="remove($index)">x</a> | ||
</span> | ||
<div> | ||
<input type="text" ng-model="newtag" ng-show="editable" ng-keypress="keypress()"> | ||
<div ng-show="poptags"> | ||
<ul> | ||
<li ng-repeat="poptag in poptags" ng-click="addTag(poptag)">{{ poptag.name }}</li> | ||
</ul> | ||
</div> | ||
<img src="/static/img2/ajax-loader.gif" ng-show="loading"> | ||
</div> | ||
<a class="iconized tag right" ng-hide="editingTags" ng-click="editingTags=true" style="margin:2px">edit tags</a> | ||
<a class="iconized done right" ng-show="editingTags" ng-click="editingTags=false" style="margin:2px">done</a> | ||
<div class="clearfix"></div> | ||
<div ng-class="{fakeinput:editingTags}" ng-click="focus()"> | ||
<span href class="tag" ng-repeat="tag in tags">{[{tag}]} <a href ng-show="editingTags" ng-click="remove($index)">x</a></span> | ||
<span style="position:relative" ng-show="editingTags"> | ||
<span class="newtag" contenteditable='true' strip-br="true" ng-model="newtag" ng-keypress="tagChanged()" ng-change="tagChanged()" ng-class="{padding5:(newtag.length>0)}"></span> | ||
<div class="fs-box" ng-show="poptags" style="position:absolute;z-index:1000;"> | ||
<ul><li ng-repeat="poptag in poptags" ng-click="addTag(poptag)">{{ poptag.name }}</li></ul> | ||
</div> | ||
<img src="/static/img2/ajax-loader.gif" ng-show="loading"> | ||
</span> | ||
</div> | ||
</div> |
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
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