|
1 | 1 | # ui-date directive [](https://travis-ci.org/angular-ui/ui-tinymce)
|
2 | 2 |
|
3 |
| -This directive allows you to add a date-picker to your form elements. |
| 3 | +This directive allows you to add a TinyMCE editor to your form elements. |
4 | 4 |
|
5 | 5 | # Requirements
|
6 | 6 |
|
7 | 7 | - AngularJS
|
8 |
| -- JQuery |
9 |
| -- JQueryUI |
10 |
| -- [Date.toISOString()](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString) (requires [polyfill](https://github.com/kriskowal/es5-shim/) for ≤IE8) |
| 8 | +- TinyMCE 3 |
11 | 9 |
|
12 | 10 | # Testing
|
13 | 11 |
|
14 |
| -We use testacular and jshint to ensure the quality of the code. The easiest way to run these checks is to use grunt: |
| 12 | +We use karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use grunt: |
15 | 13 |
|
16 | 14 | npm install -g grunt-cli
|
17 | 15 | npm install
|
18 | 16 | bower install
|
19 | 17 | grunt
|
20 | 18 |
|
21 |
| -The testacular task will try to open Chrome as a browser in which to run the tests. Make sure this is available or change the configuration in `test\test.config.js` |
| 19 | +The karma task will try to open Chrome as a browser in which to run the tests. Make sure this is available or change the configuration in `test\test.config.js` |
22 | 20 |
|
23 | 21 | # Usage
|
24 | 22 |
|
25 | 23 | We use [bower](http://twitter.github.com/bower/) for dependency management. Add
|
26 | 24 |
|
27 | 25 | dependencies: {
|
28 |
| - "angular-ui-date": "latest" |
| 26 | + "angular-ui-tinymce": "latest" |
29 | 27 | }
|
30 | 28 |
|
31 | 29 | To your `components.json` file. Then run
|
32 | 30 |
|
33 | 31 | bower install
|
34 | 32 |
|
35 |
| -This will copy the ui-date files into your `components` folder, along with its dependencies. Load the script files in your application: |
| 33 | +This will copy the ui-tinymce files into your `components` folder, along with its dependencies. Load the script files in your application: |
36 | 34 |
|
37 |
| - <script type="text/javascript" src="components/jquery/jquery.js"></script> |
38 |
| - <script type="text/javascript" src="components/jquery-ui\ui\jquery-ui.custom.js"></script> |
| 35 | + <script type="text/javascript" src="components/tinymce/tinymce.js"></script> |
39 | 36 | <script type="text/javascript" src="components/angular/angular.js"></script>
|
40 |
| - <script type="text/javascript" src="components/angular-ui-date/date.js"></script> |
| 37 | + <script type="text/javascript" src="components/angular-ui-tinymce/tinymce.js"></script> |
41 | 38 |
|
42 | 39 | Add the date module as a dependency to your application module:
|
43 | 40 |
|
44 |
| - var myAppModule = angular.module('MyApp', ['ui.date']) |
| 41 | + var myAppModule = angular.module('MyApp', ['ui.tinymce']) |
45 | 42 |
|
46 | 43 | Apply the directive to your form elements:
|
47 | 44 |
|
48 |
| - <input ui-date> |
| 45 | + <form method="post"> |
| 46 | + <textarea id="tinymce" ui-tinymce ng-model="tinymceModel"></textarea> |
| 47 | + </form> |
49 | 48 |
|
50 | 49 | ## Options
|
51 | 50 |
|
52 |
| -All the jQueryUI DatePicker options can be passed through the directive. |
| 51 | +All the TinyMCE options can be passed through the directive. |
53 | 52 |
|
54 | 53 | myAppModule.controller('MyController', function($scope) {
|
55 |
| - $scope.dateOptions = { |
56 |
| - changeYear: true, |
57 |
| - changeMonth: true, |
58 |
| - yearRange: '1900:-0' |
| 54 | + $scope.tinymceOptions = { |
| 55 | + handle_event_callback: function (e) { |
| 56 | + // put logic here for keypress |
| 57 | + } |
59 | 58 | };
|
60 | 59 | });
|
61 | 60 |
|
62 |
| - <input ui-date="dateOptions" name="DateOfBirth"> |
63 |
| - |
64 |
| -## Static Inline Picker |
65 |
| - |
66 |
| -If you want a static picker then simply apply the directive to a div rather than an input element. |
67 |
| - |
68 |
| - <div ui-date="dateOptions" name="DateOfBirth"></div> |
| 61 | + <form method="post"> |
| 62 | + <textarea id="tinymce" ui-tinymce ng-model="tinymceModel"></textarea> |
| 63 | + </form> |
69 | 64 |
|
70 | 65 | ## Working with ng-model
|
71 | 66 |
|
72 |
| -The ui-date directive plays nicely with ng-model and validation directives such as ng-required. |
73 |
| - |
74 |
| -If you add the ng-model directive to same the element as ui-date then the picked date is automatically synchronized with the model value. |
75 |
| - |
76 |
| -_The ui-date directive stores and expects the model value to be a standard javascript Date object._ |
77 |
| - |
78 |
| -## ui-date-format directive |
79 |
| -The ui-date directive only works with Date objects. |
80 |
| -If you want to pass date strings to and from the date directive via ng-model then you must use the ui-date-format directive. |
81 |
| -This directive specifies the format of the date string that will be expected in the ng-model. |
82 |
| -The format string syntax is that defined by the JQueryUI Date picker. For example |
| 67 | +The ui-date directive plays nicely with the ng-model directive such as ng-required. |
83 | 68 |
|
84 |
| - <input ui-date ui-date-format="DD, d MM, yy" ng-model="myDate"> |
| 69 | +If you add the ng-model directive to same the element as ui-tinymce then the text in the editor is automatically synchronized with the model value. |
85 | 70 |
|
86 |
| -Now you can set myDate in the controller. |
87 |
| - |
88 |
| - $scope.myDate = "Thursday, 11 October, 2012"; |
89 |
| - |
90 |
| -## ng-required directive |
91 |
| - |
92 |
| -If you apply the required directive to element then the form element is invalid until a date is picked. |
93 |
| - |
94 |
| -Note: Remember that the ng-required directive must be explictly set, i.e. to "true". This is especially true on divs: |
95 |
| - |
96 |
| - <div ui-date="dateOptions" name="DateOfBirth" ng-required="true"></div> |
| 71 | +_ng-model and the id are required_. |
97 | 72 |
|
| 73 | +_The ui-date directive stores and expects the model value to be a standard javascript Date object._ |
98 | 74 |
|
0 commit comments