Showing
101 changed files
with
926 additions
and
292 deletions
| ... | @@ -29,14 +29,17 @@ class HomeController extends Controller | ... | @@ -29,14 +29,17 @@ class HomeController extends Controller |
| 29 | public function index() | 29 | public function index() |
| 30 | { | 30 | { |
| 31 | $activity = Activity::latest(10); | 31 | $activity = Activity::latest(10); |
| 32 | - $recents = $this->signedIn ? Views::getUserRecentlyViewed(12, 0) : $this->entityRepo->getRecentlyCreatedBooks(10); | 32 | + $draftPages = $this->signedIn ? $this->entityRepo->getUserDraftPages(6) : []; |
| 33 | + $recentFactor = count($draftPages) > 0 ? 0.5 : 1; | ||
| 34 | + $recents = $this->signedIn ? Views::getUserRecentlyViewed(12*$recentFactor, 0) : $this->entityRepo->getRecentlyCreatedBooks(10*$recentFactor); | ||
| 33 | $recentlyCreatedPages = $this->entityRepo->getRecentlyCreatedPages(5); | 35 | $recentlyCreatedPages = $this->entityRepo->getRecentlyCreatedPages(5); |
| 34 | $recentlyUpdatedPages = $this->entityRepo->getRecentlyUpdatedPages(5); | 36 | $recentlyUpdatedPages = $this->entityRepo->getRecentlyUpdatedPages(5); |
| 35 | return view('home', [ | 37 | return view('home', [ |
| 36 | 'activity' => $activity, | 38 | 'activity' => $activity, |
| 37 | 'recents' => $recents, | 39 | 'recents' => $recents, |
| 38 | 'recentlyCreatedPages' => $recentlyCreatedPages, | 40 | 'recentlyCreatedPages' => $recentlyCreatedPages, |
| 39 | - 'recentlyUpdatedPages' => $recentlyUpdatedPages | 41 | + 'recentlyUpdatedPages' => $recentlyUpdatedPages, |
| 42 | + 'draftPages' => $draftPages | ||
| 40 | ]); | 43 | ]); |
| 41 | } | 44 | } |
| 42 | 45 | ... | ... |
| ... | @@ -32,9 +32,9 @@ class ImageController extends Controller | ... | @@ -32,9 +32,9 @@ class ImageController extends Controller |
| 32 | parent::__construct(); | 32 | parent::__construct(); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | - | ||
| 36 | /** | 35 | /** |
| 37 | * Get all images for a specific type, Paginated | 36 | * Get all images for a specific type, Paginated |
| 37 | + * @param string $type | ||
| 38 | * @param int $page | 38 | * @param int $page |
| 39 | * @return \Illuminate\Http\JsonResponse | 39 | * @return \Illuminate\Http\JsonResponse |
| 40 | */ | 40 | */ |
| ... | @@ -55,7 +55,6 @@ class ImageController extends Controller | ... | @@ -55,7 +55,6 @@ class ImageController extends Controller |
| 55 | return response()->json($imgData); | 55 | return response()->json($imgData); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | - | ||
| 59 | /** | 58 | /** |
| 60 | * Handles image uploads for use on pages. | 59 | * Handles image uploads for use on pages. |
| 61 | * @param string $type | 60 | * @param string $type |
| ... | @@ -66,13 +65,15 @@ class ImageController extends Controller | ... | @@ -66,13 +65,15 @@ class ImageController extends Controller |
| 66 | { | 65 | { |
| 67 | $this->checkPermission('image-create-all'); | 66 | $this->checkPermission('image-create-all'); |
| 68 | $this->validate($request, [ | 67 | $this->validate($request, [ |
| 69 | - 'file' => 'image|mimes:jpeg,gif,png' | 68 | + 'file' => 'image|mimes:jpeg,gif,png', |
| 69 | + 'uploaded_to' => 'integer|exists:pages,id' | ||
| 70 | ]); | 70 | ]); |
| 71 | 71 | ||
| 72 | $imageUpload = $request->file('file'); | 72 | $imageUpload = $request->file('file'); |
| 73 | 73 | ||
| 74 | try { | 74 | try { |
| 75 | - $image = $this->imageRepo->saveNew($imageUpload, $type); | 75 | + $uploadedTo = $request->has('uploaded_to') ? $request->get('uploaded_to') : 0; |
| 76 | + $image = $this->imageRepo->saveNew($imageUpload, $type, $uploadedTo); | ||
| 76 | } catch (ImageUploadException $e) { | 77 | } catch (ImageUploadException $e) { |
| 77 | return response($e->getMessage(), 500); | 78 | return response($e->getMessage(), 500); |
| 78 | } | 79 | } |
| ... | @@ -98,7 +99,7 @@ class ImageController extends Controller | ... | @@ -98,7 +99,7 @@ class ImageController extends Controller |
| 98 | 99 | ||
| 99 | /** | 100 | /** |
| 100 | * Update image details | 101 | * Update image details |
| 101 | - * @param $imageId | 102 | + * @param integer $imageId |
| 102 | * @param Request $request | 103 | * @param Request $request |
| 103 | * @return \Illuminate\Http\JsonResponse | 104 | * @return \Illuminate\Http\JsonResponse |
| 104 | */ | 105 | */ |
| ... | @@ -113,7 +114,6 @@ class ImageController extends Controller | ... | @@ -113,7 +114,6 @@ class ImageController extends Controller |
| 113 | return response()->json($image); | 114 | return response()->json($image); |
| 114 | } | 115 | } |
| 115 | 116 | ||
| 116 | - | ||
| 117 | /** | 117 | /** |
| 118 | * Deletes an image and all thumbnail/image files | 118 | * Deletes an image and all thumbnail/image files |
| 119 | * @param PageRepo $pageRepo | 119 | * @param PageRepo $pageRepo | ... | ... |
| ... | @@ -49,20 +49,38 @@ class PageController extends Controller | ... | @@ -49,20 +49,38 @@ class PageController extends Controller |
| 49 | public function create($bookSlug, $chapterSlug = false) | 49 | public function create($bookSlug, $chapterSlug = false) |
| 50 | { | 50 | { |
| 51 | $book = $this->bookRepo->getBySlug($bookSlug); | 51 | $book = $this->bookRepo->getBySlug($bookSlug); |
| 52 | - $chapter = $chapterSlug ? $this->chapterRepo->getBySlug($chapterSlug, $book->id) : false; | 52 | + $chapter = $chapterSlug ? $this->chapterRepo->getBySlug($chapterSlug, $book->id) : null; |
| 53 | $parent = $chapter ? $chapter : $book; | 53 | $parent = $chapter ? $chapter : $book; |
| 54 | $this->checkOwnablePermission('page-create', $parent); | 54 | $this->checkOwnablePermission('page-create', $parent); |
| 55 | $this->setPageTitle('Create New Page'); | 55 | $this->setPageTitle('Create New Page'); |
| 56 | - return view('pages/create', ['book' => $book, 'chapter' => $chapter]); | 56 | + |
| 57 | + $draft = $this->pageRepo->getDraftPage($book, $chapter); | ||
| 58 | + return redirect($draft->getUrl()); | ||
| 57 | } | 59 | } |
| 58 | 60 | ||
| 59 | /** | 61 | /** |
| 60 | - * Store a newly created page in storage. | 62 | + * Show form to continue editing a draft page. |
| 61 | - * @param Request $request | ||
| 62 | * @param $bookSlug | 63 | * @param $bookSlug |
| 64 | + * @param $pageId | ||
| 65 | + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | ||
| 66 | + */ | ||
| 67 | + public function editDraft($bookSlug, $pageId) | ||
| 68 | + { | ||
| 69 | + $book = $this->bookRepo->getBySlug($bookSlug); | ||
| 70 | + $draft = $this->pageRepo->getById($pageId, true); | ||
| 71 | + $this->checkOwnablePermission('page-create', $draft); | ||
| 72 | + $this->setPageTitle('Edit Page Draft'); | ||
| 73 | + | ||
| 74 | + return view('pages/create', ['draft' => $draft, 'book' => $book]); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * Store a new page by changing a draft into a page. | ||
| 79 | + * @param Request $request | ||
| 80 | + * @param string $bookSlug | ||
| 63 | * @return Response | 81 | * @return Response |
| 64 | */ | 82 | */ |
| 65 | - public function store(Request $request, $bookSlug) | 83 | + public function store(Request $request, $bookSlug, $pageId) |
| 66 | { | 84 | { |
| 67 | $this->validate($request, [ | 85 | $this->validate($request, [ |
| 68 | 'name' => 'required|string|max:255' | 86 | 'name' => 'required|string|max:255' |
| ... | @@ -70,12 +88,15 @@ class PageController extends Controller | ... | @@ -70,12 +88,15 @@ class PageController extends Controller |
| 70 | 88 | ||
| 71 | $input = $request->all(); | 89 | $input = $request->all(); |
| 72 | $book = $this->bookRepo->getBySlug($bookSlug); | 90 | $book = $this->bookRepo->getBySlug($bookSlug); |
| 73 | - $chapterId = ($request->has('chapter') && $this->chapterRepo->idExists($request->get('chapter'))) ? $request->get('chapter') : null; | ||
| 74 | - $parent = $chapterId !== null ? $this->chapterRepo->getById($chapterId) : $book; | ||
| 75 | - $this->checkOwnablePermission('page-create', $parent); | ||
| 76 | $input['priority'] = $this->bookRepo->getNewPriority($book); | 91 | $input['priority'] = $this->bookRepo->getNewPriority($book); |
| 77 | 92 | ||
| 78 | - $page = $this->pageRepo->saveNew($input, $book, $chapterId); | 93 | + $draftPage = $this->pageRepo->getById($pageId, true); |
| 94 | + | ||
| 95 | + $chapterId = $draftPage->chapter_id; | ||
| 96 | + $parent = $chapterId !== 0 ? $this->chapterRepo->getById($chapterId) : $book; | ||
| 97 | + $this->checkOwnablePermission('page-create', $parent); | ||
| 98 | + | ||
| 99 | + $page = $this->pageRepo->publishDraft($draftPage, $input); | ||
| 79 | 100 | ||
| 80 | Activity::add($page, 'page_create', $book->id); | 101 | Activity::add($page, 'page_create', $book->id); |
| 81 | return redirect($page->getUrl()); | 102 | return redirect($page->getUrl()); |
| ... | @@ -108,6 +129,17 @@ class PageController extends Controller | ... | @@ -108,6 +129,17 @@ class PageController extends Controller |
| 108 | } | 129 | } |
| 109 | 130 | ||
| 110 | /** | 131 | /** |
| 132 | + * Get page from an ajax request. | ||
| 133 | + * @param $pageId | ||
| 134 | + * @return \Illuminate\Http\JsonResponse | ||
| 135 | + */ | ||
| 136 | + public function getPageAjax($pageId) | ||
| 137 | + { | ||
| 138 | + $page = $this->pageRepo->getById($pageId); | ||
| 139 | + return response()->json($page); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 111 | * Show the form for editing the specified page. | 143 | * Show the form for editing the specified page. |
| 112 | * @param $bookSlug | 144 | * @param $bookSlug |
| 113 | * @param $pageSlug | 145 | * @param $pageSlug |
| ... | @@ -119,6 +151,25 @@ class PageController extends Controller | ... | @@ -119,6 +151,25 @@ class PageController extends Controller |
| 119 | $page = $this->pageRepo->getBySlug($pageSlug, $book->id); | 151 | $page = $this->pageRepo->getBySlug($pageSlug, $book->id); |
| 120 | $this->checkOwnablePermission('page-update', $page); | 152 | $this->checkOwnablePermission('page-update', $page); |
| 121 | $this->setPageTitle('Editing Page ' . $page->getShortName()); | 153 | $this->setPageTitle('Editing Page ' . $page->getShortName()); |
| 154 | + $page->isDraft = false; | ||
| 155 | + | ||
| 156 | + // Check for active editing | ||
| 157 | + $warnings = []; | ||
| 158 | + if ($this->pageRepo->isPageEditingActive($page, 60)) { | ||
| 159 | + $warnings[] = $this->pageRepo->getPageEditingActiveMessage($page, 60); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + // Check for a current draft version for this user | ||
| 163 | + if ($this->pageRepo->hasUserGotPageDraft($page, $this->currentUser->id)) { | ||
| 164 | + $draft = $this->pageRepo->getUserPageDraft($page, $this->currentUser->id); | ||
| 165 | + $page->name = $draft->name; | ||
| 166 | + $page->html = $draft->html; | ||
| 167 | + $page->isDraft = true; | ||
| 168 | + $warnings [] = $this->pageRepo->getUserPageDraftMessage($draft); | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + if (count($warnings) > 0) session()->flash('warning', implode("\n", $warnings)); | ||
| 172 | + | ||
| 122 | return view('pages/edit', ['page' => $page, 'book' => $book, 'current' => $page]); | 173 | return view('pages/edit', ['page' => $page, 'book' => $book, 'current' => $page]); |
| 123 | } | 174 | } |
| 124 | 175 | ||
| ... | @@ -143,6 +194,25 @@ class PageController extends Controller | ... | @@ -143,6 +194,25 @@ class PageController extends Controller |
| 143 | } | 194 | } |
| 144 | 195 | ||
| 145 | /** | 196 | /** |
| 197 | + * Save a draft update as a revision. | ||
| 198 | + * @param Request $request | ||
| 199 | + * @param $pageId | ||
| 200 | + * @return \Illuminate\Http\JsonResponse | ||
| 201 | + */ | ||
| 202 | + public function saveDraft(Request $request, $pageId) | ||
| 203 | + { | ||
| 204 | + $page = $this->pageRepo->getById($pageId, true); | ||
| 205 | + $this->checkOwnablePermission('page-update', $page); | ||
| 206 | + if ($page->draft) { | ||
| 207 | + $draft = $this->pageRepo->updateDraftPage($page, $request->only(['name', 'html'])); | ||
| 208 | + } else { | ||
| 209 | + $draft = $this->pageRepo->saveUpdateDraft($page, $request->only(['name', 'html'])); | ||
| 210 | + } | ||
| 211 | + $updateTime = $draft->updated_at->format('H:i'); | ||
| 212 | + return response()->json(['status' => 'success', 'message' => 'Draft saved at ' . $updateTime]); | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 146 | * Redirect from a special link url which | 216 | * Redirect from a special link url which |
| 147 | * uses the page id rather than the name. | 217 | * uses the page id rather than the name. |
| 148 | * @param $pageId | 218 | * @param $pageId |
| ... | @@ -169,9 +239,25 @@ class PageController extends Controller | ... | @@ -169,9 +239,25 @@ class PageController extends Controller |
| 169 | return view('pages/delete', ['book' => $book, 'page' => $page, 'current' => $page]); | 239 | return view('pages/delete', ['book' => $book, 'page' => $page, 'current' => $page]); |
| 170 | } | 240 | } |
| 171 | 241 | ||
| 242 | + | ||
| 243 | + /** | ||
| 244 | + * Show the deletion page for the specified page. | ||
| 245 | + * @param $bookSlug | ||
| 246 | + * @param $pageId | ||
| 247 | + * @return \Illuminate\View\View | ||
| 248 | + * @throws NotFoundException | ||
| 249 | + */ | ||
| 250 | + public function showDeleteDraft($bookSlug, $pageId) | ||
| 251 | + { | ||
| 252 | + $book = $this->bookRepo->getBySlug($bookSlug); | ||
| 253 | + $page = $this->pageRepo->getById($pageId, true); | ||
| 254 | + $this->checkOwnablePermission('page-update', $page); | ||
| 255 | + $this->setPageTitle('Delete Draft Page ' . $page->getShortName()); | ||
| 256 | + return view('pages/delete', ['book' => $book, 'page' => $page, 'current' => $page]); | ||
| 257 | + } | ||
| 258 | + | ||
| 172 | /** | 259 | /** |
| 173 | * Remove the specified page from storage. | 260 | * Remove the specified page from storage. |
| 174 | - * | ||
| 175 | * @param $bookSlug | 261 | * @param $bookSlug |
| 176 | * @param $pageSlug | 262 | * @param $pageSlug |
| 177 | * @return Response | 263 | * @return Response |
| ... | @@ -183,6 +269,24 @@ class PageController extends Controller | ... | @@ -183,6 +269,24 @@ class PageController extends Controller |
| 183 | $page = $this->pageRepo->getBySlug($pageSlug, $book->id); | 269 | $page = $this->pageRepo->getBySlug($pageSlug, $book->id); |
| 184 | $this->checkOwnablePermission('page-delete', $page); | 270 | $this->checkOwnablePermission('page-delete', $page); |
| 185 | Activity::addMessage('page_delete', $book->id, $page->name); | 271 | Activity::addMessage('page_delete', $book->id, $page->name); |
| 272 | + session()->flash('success', 'Page deleted'); | ||
| 273 | + $this->pageRepo->destroy($page); | ||
| 274 | + return redirect($book->getUrl()); | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + /** | ||
| 278 | + * Remove the specified draft page from storage. | ||
| 279 | + * @param $bookSlug | ||
| 280 | + * @param $pageId | ||
| 281 | + * @return Response | ||
| 282 | + * @throws NotFoundException | ||
| 283 | + */ | ||
| 284 | + public function destroyDraft($bookSlug, $pageId) | ||
| 285 | + { | ||
| 286 | + $book = $this->bookRepo->getBySlug($bookSlug); | ||
| 287 | + $page = $this->pageRepo->getById($pageId, true); | ||
| 288 | + $this->checkOwnablePermission('page-update', $page); | ||
| 289 | + session()->flash('success', 'Draft deleted'); | ||
| 186 | $this->pageRepo->destroy($page); | 290 | $this->pageRepo->destroy($page); |
| 187 | return redirect($book->getUrl()); | 291 | return redirect($book->getUrl()); |
| 188 | } | 292 | } |
| ... | @@ -249,7 +353,7 @@ class PageController extends Controller | ... | @@ -249,7 +353,7 @@ class PageController extends Controller |
| 249 | $pdfContent = $this->exportService->pageToPdf($page); | 353 | $pdfContent = $this->exportService->pageToPdf($page); |
| 250 | return response()->make($pdfContent, 200, [ | 354 | return response()->make($pdfContent, 200, [ |
| 251 | 'Content-Type' => 'application/octet-stream', | 355 | 'Content-Type' => 'application/octet-stream', |
| 252 | - 'Content-Disposition' => 'attachment; filename="'.$pageSlug.'.pdf' | 356 | + 'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.pdf' |
| 253 | ]); | 357 | ]); |
| 254 | } | 358 | } |
| 255 | 359 | ||
| ... | @@ -266,7 +370,7 @@ class PageController extends Controller | ... | @@ -266,7 +370,7 @@ class PageController extends Controller |
| 266 | $containedHtml = $this->exportService->pageToContainedHtml($page); | 370 | $containedHtml = $this->exportService->pageToContainedHtml($page); |
| 267 | return response()->make($containedHtml, 200, [ | 371 | return response()->make($containedHtml, 200, [ |
| 268 | 'Content-Type' => 'application/octet-stream', | 372 | 'Content-Type' => 'application/octet-stream', |
| 269 | - 'Content-Disposition' => 'attachment; filename="'.$pageSlug.'.html' | 373 | + 'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.html' |
| 270 | ]); | 374 | ]); |
| 271 | } | 375 | } |
| 272 | 376 | ||
| ... | @@ -283,7 +387,7 @@ class PageController extends Controller | ... | @@ -283,7 +387,7 @@ class PageController extends Controller |
| 283 | $containedHtml = $this->exportService->pageToPlainText($page); | 387 | $containedHtml = $this->exportService->pageToPlainText($page); |
| 284 | return response()->make($containedHtml, 200, [ | 388 | return response()->make($containedHtml, 200, [ |
| 285 | 'Content-Type' => 'application/octet-stream', | 389 | 'Content-Type' => 'application/octet-stream', |
| 286 | - 'Content-Disposition' => 'attachment; filename="'.$pageSlug.'.txt' | 390 | + 'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.txt' |
| 287 | ]); | 391 | ]); |
| 288 | } | 392 | } |
| 289 | 393 | ... | ... |
| ... | @@ -27,17 +27,20 @@ Route::group(['middleware' => 'auth'], function () { | ... | @@ -27,17 +27,20 @@ Route::group(['middleware' => 'auth'], function () { |
| 27 | 27 | ||
| 28 | // Pages | 28 | // Pages |
| 29 | Route::get('/{bookSlug}/page/create', 'PageController@create'); | 29 | Route::get('/{bookSlug}/page/create', 'PageController@create'); |
| 30 | - Route::post('/{bookSlug}/page', 'PageController@store'); | 30 | + Route::get('/{bookSlug}/draft/{pageId}', 'PageController@editDraft'); |
| 31 | + Route::post('/{bookSlug}/page/{pageId}', 'PageController@store'); | ||
| 31 | Route::get('/{bookSlug}/page/{pageSlug}', 'PageController@show'); | 32 | Route::get('/{bookSlug}/page/{pageSlug}', 'PageController@show'); |
| 32 | Route::get('/{bookSlug}/page/{pageSlug}/export/pdf', 'PageController@exportPdf'); | 33 | Route::get('/{bookSlug}/page/{pageSlug}/export/pdf', 'PageController@exportPdf'); |
| 33 | Route::get('/{bookSlug}/page/{pageSlug}/export/html', 'PageController@exportHtml'); | 34 | Route::get('/{bookSlug}/page/{pageSlug}/export/html', 'PageController@exportHtml'); |
| 34 | Route::get('/{bookSlug}/page/{pageSlug}/export/plaintext', 'PageController@exportPlainText'); | 35 | Route::get('/{bookSlug}/page/{pageSlug}/export/plaintext', 'PageController@exportPlainText'); |
| 35 | Route::get('/{bookSlug}/page/{pageSlug}/edit', 'PageController@edit'); | 36 | Route::get('/{bookSlug}/page/{pageSlug}/edit', 'PageController@edit'); |
| 36 | Route::get('/{bookSlug}/page/{pageSlug}/delete', 'PageController@showDelete'); | 37 | Route::get('/{bookSlug}/page/{pageSlug}/delete', 'PageController@showDelete'); |
| 38 | + Route::get('/{bookSlug}/draft/{pageId}/delete', 'PageController@showDeleteDraft'); | ||
| 37 | Route::get('/{bookSlug}/page/{pageSlug}/restrict', 'PageController@showRestrict'); | 39 | Route::get('/{bookSlug}/page/{pageSlug}/restrict', 'PageController@showRestrict'); |
| 38 | Route::put('/{bookSlug}/page/{pageSlug}/restrict', 'PageController@restrict'); | 40 | Route::put('/{bookSlug}/page/{pageSlug}/restrict', 'PageController@restrict'); |
| 39 | Route::put('/{bookSlug}/page/{pageSlug}', 'PageController@update'); | 41 | Route::put('/{bookSlug}/page/{pageSlug}', 'PageController@update'); |
| 40 | Route::delete('/{bookSlug}/page/{pageSlug}', 'PageController@destroy'); | 42 | Route::delete('/{bookSlug}/page/{pageSlug}', 'PageController@destroy'); |
| 43 | + Route::delete('/{bookSlug}/draft/{pageId}', 'PageController@destroyDraft'); | ||
| 41 | 44 | ||
| 42 | // Revisions | 45 | // Revisions |
| 43 | Route::get('/{bookSlug}/page/{pageSlug}/revisions', 'PageController@showRevisions'); | 46 | Route::get('/{bookSlug}/page/{pageSlug}/revisions', 'PageController@showRevisions'); |
| ... | @@ -75,6 +78,11 @@ Route::group(['middleware' => 'auth'], function () { | ... | @@ -75,6 +78,11 @@ Route::group(['middleware' => 'auth'], function () { |
| 75 | Route::delete('/{imageId}', 'ImageController@destroy'); | 78 | Route::delete('/{imageId}', 'ImageController@destroy'); |
| 76 | }); | 79 | }); |
| 77 | 80 | ||
| 81 | + // Ajax routes | ||
| 82 | + Route::put('/ajax/page/{id}/save-draft', 'PageController@saveDraft'); | ||
| 83 | + Route::get('/ajax/page/{id}', 'PageController@getPageAjax'); | ||
| 84 | + Route::delete('/ajax/page/{id}', 'PageController@ajaxDestroy'); | ||
| 85 | + | ||
| 78 | // Links | 86 | // Links |
| 79 | Route::get('/link/{id}', 'PageController@redirectFromLink'); | 87 | Route::get('/link/{id}', 'PageController@redirectFromLink'); |
| 80 | 88 | ... | ... |
| ... | @@ -34,13 +34,15 @@ class Page extends Entity | ... | @@ -34,13 +34,15 @@ class Page extends Entity |
| 34 | 34 | ||
| 35 | public function revisions() | 35 | public function revisions() |
| 36 | { | 36 | { |
| 37 | - return $this->hasMany('BookStack\PageRevision')->orderBy('created_at', 'desc'); | 37 | + return $this->hasMany('BookStack\PageRevision')->where('type', '=', 'version')->orderBy('created_at', 'desc'); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | public function getUrl() | 40 | public function getUrl() |
| 41 | { | 41 | { |
| 42 | $bookSlug = $this->getAttribute('bookSlug') ? $this->getAttribute('bookSlug') : $this->book->slug; | 42 | $bookSlug = $this->getAttribute('bookSlug') ? $this->getAttribute('bookSlug') : $this->book->slug; |
| 43 | - return '/books/' . $bookSlug . '/page/' . $this->slug; | 43 | + $midText = $this->draft ? '/draft/' : '/page/'; |
| 44 | + $idComponent = $this->draft ? $this->id : $this->slug; | ||
| 45 | + return '/books/' . $bookSlug . $midText . $idComponent; | ||
| 44 | } | 46 | } |
| 45 | 47 | ||
| 46 | public function getExcerpt($length = 100) | 48 | public function getExcerpt($length = 100) | ... | ... |
| 1 | -<?php | 1 | +<?php namespace BookStack; |
| 2 | - | ||
| 3 | -namespace BookStack; | ||
| 4 | 2 | ||
| 5 | use Illuminate\Database\Eloquent\Model; | 3 | use Illuminate\Database\Eloquent\Model; |
| 6 | 4 | ||
| ... | @@ -8,16 +6,28 @@ class PageRevision extends Model | ... | @@ -8,16 +6,28 @@ class PageRevision extends Model |
| 8 | { | 6 | { |
| 9 | protected $fillable = ['name', 'html', 'text']; | 7 | protected $fillable = ['name', 'html', 'text']; |
| 10 | 8 | ||
| 9 | + /** | ||
| 10 | + * Get the user that created the page revision | ||
| 11 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
| 12 | + */ | ||
| 11 | public function createdBy() | 13 | public function createdBy() |
| 12 | { | 14 | { |
| 13 | return $this->belongsTo('BookStack\User', 'created_by'); | 15 | return $this->belongsTo('BookStack\User', 'created_by'); |
| 14 | } | 16 | } |
| 15 | 17 | ||
| 18 | + /** | ||
| 19 | + * Get the page this revision originates from. | ||
| 20 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
| 21 | + */ | ||
| 16 | public function page() | 22 | public function page() |
| 17 | { | 23 | { |
| 18 | return $this->belongsTo('BookStack\Page'); | 24 | return $this->belongsTo('BookStack\Page'); |
| 19 | } | 25 | } |
| 20 | 26 | ||
| 27 | + /** | ||
| 28 | + * Get the url for this revision. | ||
| 29 | + * @return string | ||
| 30 | + */ | ||
| 21 | public function getUrl() | 31 | public function getUrl() |
| 22 | { | 32 | { |
| 23 | return $this->page->getUrl() . '/revisions/' . $this->id; | 33 | return $this->page->getUrl() . '/revisions/' . $this->id; | ... | ... |
| ... | @@ -213,15 +213,27 @@ class BookRepo extends EntityRepo | ... | @@ -213,15 +213,27 @@ class BookRepo extends EntityRepo |
| 213 | $chapters = $chapterQuery->get(); | 213 | $chapters = $chapterQuery->get(); |
| 214 | $children = $pages->merge($chapters); | 214 | $children = $pages->merge($chapters); |
| 215 | $bookSlug = $book->slug; | 215 | $bookSlug = $book->slug; |
| 216 | + | ||
| 216 | $children->each(function ($child) use ($bookSlug) { | 217 | $children->each(function ($child) use ($bookSlug) { |
| 217 | $child->setAttribute('bookSlug', $bookSlug); | 218 | $child->setAttribute('bookSlug', $bookSlug); |
| 218 | if ($child->isA('chapter')) { | 219 | if ($child->isA('chapter')) { |
| 219 | $child->pages->each(function ($page) use ($bookSlug) { | 220 | $child->pages->each(function ($page) use ($bookSlug) { |
| 220 | $page->setAttribute('bookSlug', $bookSlug); | 221 | $page->setAttribute('bookSlug', $bookSlug); |
| 221 | }); | 222 | }); |
| 223 | + $child->pages = $child->pages->sortBy(function($child, $key) { | ||
| 224 | + $score = $child->priority; | ||
| 225 | + if ($child->draft) $score -= 100; | ||
| 226 | + return $score; | ||
| 227 | + }); | ||
| 222 | } | 228 | } |
| 223 | }); | 229 | }); |
| 224 | - return $children->sortBy('priority'); | 230 | + |
| 231 | + // Sort items with drafts first then by priority. | ||
| 232 | + return $children->sortBy(function($child, $key) { | ||
| 233 | + $score = $child->priority; | ||
| 234 | + if ($child->isA('page') && $child->draft) $score -= 100; | ||
| 235 | + return $score; | ||
| 236 | + }); | ||
| 225 | } | 237 | } |
| 226 | 238 | ||
| 227 | /** | 239 | /** | ... | ... |
| ... | @@ -66,7 +66,13 @@ class ChapterRepo extends EntityRepo | ... | @@ -66,7 +66,13 @@ class ChapterRepo extends EntityRepo |
| 66 | */ | 66 | */ |
| 67 | public function getChildren(Chapter $chapter) | 67 | public function getChildren(Chapter $chapter) |
| 68 | { | 68 | { |
| 69 | - return $this->restrictionService->enforcePageRestrictions($chapter->pages())->get(); | 69 | + $pages = $this->restrictionService->enforcePageRestrictions($chapter->pages())->get(); |
| 70 | + // Sort items with drafts first then by priority. | ||
| 71 | + return $pages->sortBy(function($child, $key) { | ||
| 72 | + $score = $child->priority; | ||
| 73 | + if ($child->draft) $score -= 100; | ||
| 74 | + return $score; | ||
| 75 | + }); | ||
| 70 | } | 76 | } |
| 71 | 77 | ||
| 72 | /** | 78 | /** | ... | ... |
| ... | @@ -5,6 +5,7 @@ use BookStack\Chapter; | ... | @@ -5,6 +5,7 @@ use BookStack\Chapter; |
| 5 | use BookStack\Entity; | 5 | use BookStack\Entity; |
| 6 | use BookStack\Page; | 6 | use BookStack\Page; |
| 7 | use BookStack\Services\RestrictionService; | 7 | use BookStack\Services\RestrictionService; |
| 8 | +use BookStack\User; | ||
| 8 | 9 | ||
| 9 | class EntityRepo | 10 | class EntityRepo |
| 10 | { | 11 | { |
| ... | @@ -79,7 +80,7 @@ class EntityRepo | ... | @@ -79,7 +80,7 @@ class EntityRepo |
| 79 | public function getRecentlyCreatedPages($count = 20, $page = 0, $additionalQuery = false) | 80 | public function getRecentlyCreatedPages($count = 20, $page = 0, $additionalQuery = false) |
| 80 | { | 81 | { |
| 81 | $query = $this->restrictionService->enforcePageRestrictions($this->page) | 82 | $query = $this->restrictionService->enforcePageRestrictions($this->page) |
| 82 | - ->orderBy('created_at', 'desc'); | 83 | + ->orderBy('created_at', 'desc')->where('draft', '=', false); |
| 83 | if ($additionalQuery !== false && is_callable($additionalQuery)) { | 84 | if ($additionalQuery !== false && is_callable($additionalQuery)) { |
| 84 | $additionalQuery($query); | 85 | $additionalQuery($query); |
| 85 | } | 86 | } |
| ... | @@ -112,10 +113,25 @@ class EntityRepo | ... | @@ -112,10 +113,25 @@ class EntityRepo |
| 112 | public function getRecentlyUpdatedPages($count = 20, $page = 0) | 113 | public function getRecentlyUpdatedPages($count = 20, $page = 0) |
| 113 | { | 114 | { |
| 114 | return $this->restrictionService->enforcePageRestrictions($this->page) | 115 | return $this->restrictionService->enforcePageRestrictions($this->page) |
| 116 | + ->where('draft', '=', false) | ||
| 115 | ->orderBy('updated_at', 'desc')->skip($page * $count)->take($count)->get(); | 117 | ->orderBy('updated_at', 'desc')->skip($page * $count)->take($count)->get(); |
| 116 | } | 118 | } |
| 117 | 119 | ||
| 118 | /** | 120 | /** |
| 121 | + * Get draft pages owned by the current user. | ||
| 122 | + * @param int $count | ||
| 123 | + * @param int $page | ||
| 124 | + */ | ||
| 125 | + public function getUserDraftPages($count = 20, $page = 0) | ||
| 126 | + { | ||
| 127 | + $user = auth()->user(); | ||
| 128 | + return $this->page->where('draft', '=', true) | ||
| 129 | + ->where('created_by', '=', $user->id) | ||
| 130 | + ->orderBy('updated_at', 'desc') | ||
| 131 | + ->skip($count * $page)->take($count)->get(); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + /** | ||
| 119 | * Updates entity restrictions from a request | 135 | * Updates entity restrictions from a request |
| 120 | * @param $request | 136 | * @param $request |
| 121 | * @param Entity $entity | 137 | * @param Entity $entity | ... | ... |
| ... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | ||
| 4 | use BookStack\Image; | 4 | use BookStack\Image; |
| 5 | use BookStack\Services\ImageService; | 5 | use BookStack\Services\ImageService; |
| 6 | +use BookStack\Services\RestrictionService; | ||
| 6 | use Setting; | 7 | use Setting; |
| 7 | use Symfony\Component\HttpFoundation\File\UploadedFile; | 8 | use Symfony\Component\HttpFoundation\File\UploadedFile; |
| 8 | 9 | ||
| ... | @@ -11,16 +12,19 @@ class ImageRepo | ... | @@ -11,16 +12,19 @@ class ImageRepo |
| 11 | 12 | ||
| 12 | protected $image; | 13 | protected $image; |
| 13 | protected $imageService; | 14 | protected $imageService; |
| 15 | + protected $restictionService; | ||
| 14 | 16 | ||
| 15 | /** | 17 | /** |
| 16 | * ImageRepo constructor. | 18 | * ImageRepo constructor. |
| 17 | * @param Image $image | 19 | * @param Image $image |
| 18 | * @param ImageService $imageService | 20 | * @param ImageService $imageService |
| 21 | + * @param RestrictionService $restrictionService | ||
| 19 | */ | 22 | */ |
| 20 | - public function __construct(Image $image, ImageService $imageService) | 23 | + public function __construct(Image $image, ImageService $imageService, RestrictionService $restrictionService) |
| 21 | { | 24 | { |
| 22 | $this->image = $image; | 25 | $this->image = $image; |
| 23 | $this->imageService = $imageService; | 26 | $this->imageService = $imageService; |
| 27 | + $this->restictionService = $restrictionService; | ||
| 24 | } | 28 | } |
| 25 | 29 | ||
| 26 | 30 | ||
| ... | @@ -34,7 +38,6 @@ class ImageRepo | ... | @@ -34,7 +38,6 @@ class ImageRepo |
| 34 | return $this->image->findOrFail($id); | 38 | return $this->image->findOrFail($id); |
| 35 | } | 39 | } |
| 36 | 40 | ||
| 37 | - | ||
| 38 | /** | 41 | /** |
| 39 | * Gets a load images paginated, filtered by image type. | 42 | * Gets a load images paginated, filtered by image type. |
| 40 | * @param string $type | 43 | * @param string $type |
| ... | @@ -51,6 +54,7 @@ class ImageRepo | ... | @@ -51,6 +54,7 @@ class ImageRepo |
| 51 | $images = $images->where('created_by', '=', $userFilter); | 54 | $images = $images->where('created_by', '=', $userFilter); |
| 52 | } | 55 | } |
| 53 | 56 | ||
| 57 | + $images = $this->restictionService->filterRelatedPages($images, 'images', 'uploaded_to'); | ||
| 54 | $images = $images->orderBy('created_at', 'desc')->skip($pageSize * $page)->take($pageSize + 1)->get(); | 58 | $images = $images->orderBy('created_at', 'desc')->skip($pageSize * $page)->take($pageSize + 1)->get(); |
| 55 | $hasMore = count($images) > $pageSize; | 59 | $hasMore = count($images) > $pageSize; |
| 56 | 60 | ||
| ... | @@ -69,11 +73,12 @@ class ImageRepo | ... | @@ -69,11 +73,12 @@ class ImageRepo |
| 69 | * Save a new image into storage and return the new image. | 73 | * Save a new image into storage and return the new image. |
| 70 | * @param UploadedFile $uploadFile | 74 | * @param UploadedFile $uploadFile |
| 71 | * @param string $type | 75 | * @param string $type |
| 76 | + * @param int $uploadedTo | ||
| 72 | * @return Image | 77 | * @return Image |
| 73 | */ | 78 | */ |
| 74 | - public function saveNew(UploadedFile $uploadFile, $type) | 79 | + public function saveNew(UploadedFile $uploadFile, $type, $uploadedTo = 0) |
| 75 | { | 80 | { |
| 76 | - $image = $this->imageService->saveNewFromUpload($uploadFile, $type); | 81 | + $image = $this->imageService->saveNewFromUpload($uploadFile, $type, $uploadedTo); |
| 77 | $this->loadThumbs($image); | 82 | $this->loadThumbs($image); |
| 78 | return $image; | 83 | return $image; |
| 79 | } | 84 | } | ... | ... |
| 1 | <?php namespace BookStack\Repos; | 1 | <?php namespace BookStack\Repos; |
| 2 | 2 | ||
| 3 | - | ||
| 4 | use Activity; | 3 | use Activity; |
| 5 | use BookStack\Book; | 4 | use BookStack\Book; |
| 5 | +use BookStack\Chapter; | ||
| 6 | use BookStack\Exceptions\NotFoundException; | 6 | use BookStack\Exceptions\NotFoundException; |
| 7 | +use Carbon\Carbon; | ||
| 8 | +use DOMDocument; | ||
| 7 | use Illuminate\Support\Str; | 9 | use Illuminate\Support\Str; |
| 8 | use BookStack\Page; | 10 | use BookStack\Page; |
| 9 | use BookStack\PageRevision; | 11 | use BookStack\PageRevision; |
| 10 | 12 | ||
| 11 | class PageRepo extends EntityRepo | 13 | class PageRepo extends EntityRepo |
| 12 | { | 14 | { |
| 15 | + | ||
| 13 | protected $pageRevision; | 16 | protected $pageRevision; |
| 14 | 17 | ||
| 15 | /** | 18 | /** |
| ... | @@ -24,21 +27,27 @@ class PageRepo extends EntityRepo | ... | @@ -24,21 +27,27 @@ class PageRepo extends EntityRepo |
| 24 | 27 | ||
| 25 | /** | 28 | /** |
| 26 | * Base query for getting pages, Takes restrictions into account. | 29 | * Base query for getting pages, Takes restrictions into account. |
| 30 | + * @param bool $allowDrafts | ||
| 27 | * @return mixed | 31 | * @return mixed |
| 28 | */ | 32 | */ |
| 29 | - private function pageQuery() | 33 | + private function pageQuery($allowDrafts = false) |
| 30 | { | 34 | { |
| 31 | - return $this->restrictionService->enforcePageRestrictions($this->page, 'view'); | 35 | + $query = $this->restrictionService->enforcePageRestrictions($this->page, 'view'); |
| 36 | + if (!$allowDrafts) { | ||
| 37 | + $query = $query->where('draft', '=', false); | ||
| 38 | + } | ||
| 39 | + return $query; | ||
| 32 | } | 40 | } |
| 33 | 41 | ||
| 34 | /** | 42 | /** |
| 35 | * Get a page via a specific ID. | 43 | * Get a page via a specific ID. |
| 36 | * @param $id | 44 | * @param $id |
| 45 | + * @param bool $allowDrafts | ||
| 37 | * @return mixed | 46 | * @return mixed |
| 38 | */ | 47 | */ |
| 39 | - public function getById($id) | 48 | + public function getById($id, $allowDrafts = false) |
| 40 | { | 49 | { |
| 41 | - return $this->pageQuery()->findOrFail($id); | 50 | + return $this->pageQuery($allowDrafts)->findOrFail($id); |
| 42 | } | 51 | } |
| 43 | 52 | ||
| 44 | /** | 53 | /** |
| ... | @@ -66,9 +75,10 @@ class PageRepo extends EntityRepo | ... | @@ -66,9 +75,10 @@ class PageRepo extends EntityRepo |
| 66 | public function findPageUsingOldSlug($pageSlug, $bookSlug) | 75 | public function findPageUsingOldSlug($pageSlug, $bookSlug) |
| 67 | { | 76 | { |
| 68 | $revision = $this->pageRevision->where('slug', '=', $pageSlug) | 77 | $revision = $this->pageRevision->where('slug', '=', $pageSlug) |
| 69 | - ->whereHas('page', function($query) { | 78 | + ->whereHas('page', function ($query) { |
| 70 | $this->restrictionService->enforcePageRestrictions($query); | 79 | $this->restrictionService->enforcePageRestrictions($query); |
| 71 | }) | 80 | }) |
| 81 | + ->where('type', '=', 'version') | ||
| 72 | ->where('book_slug', '=', $bookSlug)->orderBy('created_at', 'desc') | 82 | ->where('book_slug', '=', $bookSlug)->orderBy('created_at', 'desc') |
| 73 | ->with('page')->first(); | 83 | ->with('page')->first(); |
| 74 | return $revision !== null ? $revision->page : null; | 84 | return $revision !== null ? $revision->page : null; |
| ... | @@ -120,6 +130,47 @@ class PageRepo extends EntityRepo | ... | @@ -120,6 +130,47 @@ class PageRepo extends EntityRepo |
| 120 | return $page; | 130 | return $page; |
| 121 | } | 131 | } |
| 122 | 132 | ||
| 133 | + | ||
| 134 | + /** | ||
| 135 | + * Publish a draft page to make it a normal page. | ||
| 136 | + * Sets the slug and updates the content. | ||
| 137 | + * @param Page $draftPage | ||
| 138 | + * @param array $input | ||
| 139 | + * @return Page | ||
| 140 | + */ | ||
| 141 | + public function publishDraft(Page $draftPage, array $input) | ||
| 142 | + { | ||
| 143 | + $draftPage->fill($input); | ||
| 144 | + | ||
| 145 | + $draftPage->slug = $this->findSuitableSlug($draftPage->name, $draftPage->book->id); | ||
| 146 | + $draftPage->html = $this->formatHtml($input['html']); | ||
| 147 | + $draftPage->text = strip_tags($draftPage->html); | ||
| 148 | + $draftPage->draft = false; | ||
| 149 | + | ||
| 150 | + $draftPage->save(); | ||
| 151 | + return $draftPage; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + /** | ||
| 155 | + * Get a new draft page instance. | ||
| 156 | + * @param Book $book | ||
| 157 | + * @param Chapter|null $chapter | ||
| 158 | + * @return static | ||
| 159 | + */ | ||
| 160 | + public function getDraftPage(Book $book, $chapter) | ||
| 161 | + { | ||
| 162 | + $page = $this->page->newInstance(); | ||
| 163 | + $page->name = 'New Page'; | ||
| 164 | + $page->created_by = auth()->user()->id; | ||
| 165 | + $page->updated_by = auth()->user()->id; | ||
| 166 | + $page->draft = true; | ||
| 167 | + | ||
| 168 | + if ($chapter) $page->chapter_id = $chapter->id; | ||
| 169 | + | ||
| 170 | + $book->pages()->save($page); | ||
| 171 | + return $page; | ||
| 172 | + } | ||
| 173 | + | ||
| 123 | /** | 174 | /** |
| 124 | * Formats a page's html to be tagged correctly | 175 | * Formats a page's html to be tagged correctly |
| 125 | * within the system. | 176 | * within the system. |
| ... | @@ -128,9 +179,9 @@ class PageRepo extends EntityRepo | ... | @@ -128,9 +179,9 @@ class PageRepo extends EntityRepo |
| 128 | */ | 179 | */ |
| 129 | protected function formatHtml($htmlText) | 180 | protected function formatHtml($htmlText) |
| 130 | { | 181 | { |
| 131 | - if($htmlText == '') return $htmlText; | 182 | + if ($htmlText == '') return $htmlText; |
| 132 | libxml_use_internal_errors(true); | 183 | libxml_use_internal_errors(true); |
| 133 | - $doc = new \DOMDocument(); | 184 | + $doc = new DOMDocument(); |
| 134 | $doc->loadHTML(mb_convert_encoding($htmlText, 'HTML-ENTITIES', 'UTF-8')); | 185 | $doc->loadHTML(mb_convert_encoding($htmlText, 'HTML-ENTITIES', 'UTF-8')); |
| 135 | 186 | ||
| 136 | $container = $doc->documentElement; | 187 | $container = $doc->documentElement; |
| ... | @@ -257,11 +308,16 @@ class PageRepo extends EntityRepo | ... | @@ -257,11 +308,16 @@ class PageRepo extends EntityRepo |
| 257 | } | 308 | } |
| 258 | 309 | ||
| 259 | // Update with new details | 310 | // Update with new details |
| 311 | + $userId = auth()->user()->id; | ||
| 260 | $page->fill($input); | 312 | $page->fill($input); |
| 261 | $page->html = $this->formatHtml($input['html']); | 313 | $page->html = $this->formatHtml($input['html']); |
| 262 | $page->text = strip_tags($page->html); | 314 | $page->text = strip_tags($page->html); |
| 263 | - $page->updated_by = auth()->user()->id; | 315 | + $page->updated_by = $userId; |
| 264 | $page->save(); | 316 | $page->save(); |
| 317 | + | ||
| 318 | + // Remove all update drafts for this user & page. | ||
| 319 | + $this->userUpdateDraftsQuery($page, $userId)->delete(); | ||
| 320 | + | ||
| 265 | return $page; | 321 | return $page; |
| 266 | } | 322 | } |
| 267 | 323 | ||
| ... | @@ -297,6 +353,7 @@ class PageRepo extends EntityRepo | ... | @@ -297,6 +353,7 @@ class PageRepo extends EntityRepo |
| 297 | $revision->book_slug = $page->book->slug; | 353 | $revision->book_slug = $page->book->slug; |
| 298 | $revision->created_by = auth()->user()->id; | 354 | $revision->created_by = auth()->user()->id; |
| 299 | $revision->created_at = $page->updated_at; | 355 | $revision->created_at = $page->updated_at; |
| 356 | + $revision->type = 'version'; | ||
| 300 | $revision->save(); | 357 | $revision->save(); |
| 301 | // Clear old revisions | 358 | // Clear old revisions |
| 302 | if ($this->pageRevision->where('page_id', '=', $page->id)->count() > 50) { | 359 | if ($this->pageRevision->where('page_id', '=', $page->id)->count() > 50) { |
| ... | @@ -307,6 +364,153 @@ class PageRepo extends EntityRepo | ... | @@ -307,6 +364,153 @@ class PageRepo extends EntityRepo |
| 307 | } | 364 | } |
| 308 | 365 | ||
| 309 | /** | 366 | /** |
| 367 | + * Save a page update draft. | ||
| 368 | + * @param Page $page | ||
| 369 | + * @param array $data | ||
| 370 | + * @return PageRevision | ||
| 371 | + */ | ||
| 372 | + public function saveUpdateDraft(Page $page, $data = []) | ||
| 373 | + { | ||
| 374 | + $userId = auth()->user()->id; | ||
| 375 | + $drafts = $this->userUpdateDraftsQuery($page, $userId)->get(); | ||
| 376 | + | ||
| 377 | + if ($drafts->count() > 0) { | ||
| 378 | + $draft = $drafts->first(); | ||
| 379 | + } else { | ||
| 380 | + $draft = $this->pageRevision->newInstance(); | ||
| 381 | + $draft->page_id = $page->id; | ||
| 382 | + $draft->slug = $page->slug; | ||
| 383 | + $draft->book_slug = $page->book->slug; | ||
| 384 | + $draft->created_by = $userId; | ||
| 385 | + $draft->type = 'update_draft'; | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + $draft->fill($data); | ||
| 389 | + $draft->save(); | ||
| 390 | + return $draft; | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + /** | ||
| 394 | + * Update a draft page. | ||
| 395 | + * @param Page $page | ||
| 396 | + * @param array $data | ||
| 397 | + * @return Page | ||
| 398 | + */ | ||
| 399 | + public function updateDraftPage(Page $page, $data = []) | ||
| 400 | + { | ||
| 401 | + $page->fill($data); | ||
| 402 | + | ||
| 403 | + if (isset($data['html'])) { | ||
| 404 | + $page->text = strip_tags($data['html']); | ||
| 405 | + } | ||
| 406 | + | ||
| 407 | + $page->save(); | ||
| 408 | + return $page; | ||
| 409 | + } | ||
| 410 | + | ||
| 411 | + /** | ||
| 412 | + * The base query for getting user update drafts. | ||
| 413 | + * @param Page $page | ||
| 414 | + * @param $userId | ||
| 415 | + * @return mixed | ||
| 416 | + */ | ||
| 417 | + private function userUpdateDraftsQuery(Page $page, $userId) | ||
| 418 | + { | ||
| 419 | + return $this->pageRevision->where('created_by', '=', $userId) | ||
| 420 | + ->where('type', 'update_draft') | ||
| 421 | + ->where('page_id', '=', $page->id) | ||
| 422 | + ->orderBy('created_at', 'desc'); | ||
| 423 | + } | ||
| 424 | + | ||
| 425 | + /** | ||
| 426 | + * Checks whether a user has a draft version of a particular page or not. | ||
| 427 | + * @param Page $page | ||
| 428 | + * @param $userId | ||
| 429 | + * @return bool | ||
| 430 | + */ | ||
| 431 | + public function hasUserGotPageDraft(Page $page, $userId) | ||
| 432 | + { | ||
| 433 | + return $this->userUpdateDraftsQuery($page, $userId)->count() > 0; | ||
| 434 | + } | ||
| 435 | + | ||
| 436 | + /** | ||
| 437 | + * Get the latest updated draft revision for a particular page and user. | ||
| 438 | + * @param Page $page | ||
| 439 | + * @param $userId | ||
| 440 | + * @return mixed | ||
| 441 | + */ | ||
| 442 | + public function getUserPageDraft(Page $page, $userId) | ||
| 443 | + { | ||
| 444 | + return $this->userUpdateDraftsQuery($page, $userId)->first(); | ||
| 445 | + } | ||
| 446 | + | ||
| 447 | + /** | ||
| 448 | + * Get the notification message that informs the user that they are editing a draft page. | ||
| 449 | + * @param PageRevision $draft | ||
| 450 | + * @return string | ||
| 451 | + */ | ||
| 452 | + public function getUserPageDraftMessage(PageRevision $draft) | ||
| 453 | + { | ||
| 454 | + $message = 'You are currently editing a draft that was last saved ' . $draft->updated_at->diffForHumans() . '.'; | ||
| 455 | + if ($draft->page->updated_at->timestamp > $draft->updated_at->timestamp) { | ||
| 456 | + $message .= "\n This page has been updated by since that time. It is recommended that you discard this draft."; | ||
| 457 | + } | ||
| 458 | + return $message; | ||
| 459 | + } | ||
| 460 | + | ||
| 461 | + /** | ||
| 462 | + * Check if a page is being actively editing. | ||
| 463 | + * Checks for edits since last page updated. | ||
| 464 | + * Passing in a minuted range will check for edits | ||
| 465 | + * within the last x minutes. | ||
| 466 | + * @param Page $page | ||
| 467 | + * @param null $minRange | ||
| 468 | + * @return bool | ||
| 469 | + */ | ||
| 470 | + public function isPageEditingActive(Page $page, $minRange = null) | ||
| 471 | + { | ||
| 472 | + $draftSearch = $this->activePageEditingQuery($page, $minRange); | ||
| 473 | + return $draftSearch->count() > 0; | ||
| 474 | + } | ||
| 475 | + | ||
| 476 | + /** | ||
| 477 | + * Get a notification message concerning the editing activity on | ||
| 478 | + * a particular page. | ||
| 479 | + * @param Page $page | ||
| 480 | + * @param null $minRange | ||
| 481 | + * @return string | ||
| 482 | + */ | ||
| 483 | + public function getPageEditingActiveMessage(Page $page, $minRange = null) | ||
| 484 | + { | ||
| 485 | + $pageDraftEdits = $this->activePageEditingQuery($page, $minRange)->get(); | ||
| 486 | + $userMessage = $pageDraftEdits->count() > 1 ? $pageDraftEdits->count() . ' users have' : $pageDraftEdits->first()->createdBy->name . ' has'; | ||
| 487 | + $timeMessage = $minRange === null ? 'since the page was last updated' : 'in the last ' . $minRange . ' minutes'; | ||
| 488 | + $message = '%s started editing this page %s. Take care not to overwrite each other\'s updates!'; | ||
| 489 | + return sprintf($message, $userMessage, $timeMessage); | ||
| 490 | + } | ||
| 491 | + | ||
| 492 | + /** | ||
| 493 | + * A query to check for active update drafts on a particular page. | ||
| 494 | + * @param Page $page | ||
| 495 | + * @param null $minRange | ||
| 496 | + * @return mixed | ||
| 497 | + */ | ||
| 498 | + private function activePageEditingQuery(Page $page, $minRange = null) | ||
| 499 | + { | ||
| 500 | + $query = $this->pageRevision->where('type', '=', 'update_draft') | ||
| 501 | + ->where('page_id', '=', $page->id) | ||
| 502 | + ->where('updated_at', '>', $page->updated_at) | ||
| 503 | + ->where('created_by', '!=', auth()->user()->id) | ||
| 504 | + ->with('createdBy'); | ||
| 505 | + | ||
| 506 | + if ($minRange !== null) { | ||
| 507 | + $query = $query->where('updated_at', '>=', Carbon::now()->subMinutes($minRange)); | ||
| 508 | + } | ||
| 509 | + | ||
| 510 | + return $query; | ||
| 511 | + } | ||
| 512 | + | ||
| 513 | + /** | ||
| 310 | * Gets a single revision via it's id. | 514 | * Gets a single revision via it's id. |
| 311 | * @param $id | 515 | * @param $id |
| 312 | * @return mixed | 516 | * @return mixed | ... | ... |
| ... | @@ -42,13 +42,15 @@ class ImageService | ... | @@ -42,13 +42,15 @@ class ImageService |
| 42 | * Saves a new image from an upload. | 42 | * Saves a new image from an upload. |
| 43 | * @param UploadedFile $uploadedFile | 43 | * @param UploadedFile $uploadedFile |
| 44 | * @param string $type | 44 | * @param string $type |
| 45 | + * @param int $uploadedTo | ||
| 45 | * @return mixed | 46 | * @return mixed |
| 47 | + * @throws ImageUploadException | ||
| 46 | */ | 48 | */ |
| 47 | - public function saveNewFromUpload(UploadedFile $uploadedFile, $type) | 49 | + public function saveNewFromUpload(UploadedFile $uploadedFile, $type, $uploadedTo = 0) |
| 48 | { | 50 | { |
| 49 | $imageName = $uploadedFile->getClientOriginalName(); | 51 | $imageName = $uploadedFile->getClientOriginalName(); |
| 50 | $imageData = file_get_contents($uploadedFile->getRealPath()); | 52 | $imageData = file_get_contents($uploadedFile->getRealPath()); |
| 51 | - return $this->saveNew($imageName, $imageData, $type); | 53 | + return $this->saveNew($imageName, $imageData, $type, $uploadedTo); |
| 52 | } | 54 | } |
| 53 | 55 | ||
| 54 | 56 | ||
| ... | @@ -73,10 +75,11 @@ class ImageService | ... | @@ -73,10 +75,11 @@ class ImageService |
| 73 | * @param string $imageName | 75 | * @param string $imageName |
| 74 | * @param string $imageData | 76 | * @param string $imageData |
| 75 | * @param string $type | 77 | * @param string $type |
| 78 | + * @param int $uploadedTo | ||
| 76 | * @return Image | 79 | * @return Image |
| 77 | * @throws ImageUploadException | 80 | * @throws ImageUploadException |
| 78 | */ | 81 | */ |
| 79 | - private function saveNew($imageName, $imageData, $type) | 82 | + private function saveNew($imageName, $imageData, $type, $uploadedTo = 0) |
| 80 | { | 83 | { |
| 81 | $storage = $this->getStorage(); | 84 | $storage = $this->getStorage(); |
| 82 | $secureUploads = setting('app-secure-images'); | 85 | $secureUploads = setting('app-secure-images'); |
| ... | @@ -100,7 +103,8 @@ class ImageService | ... | @@ -100,7 +103,8 @@ class ImageService |
| 100 | 'name' => $imageName, | 103 | 'name' => $imageName, |
| 101 | 'path' => $fullPath, | 104 | 'path' => $fullPath, |
| 102 | 'url' => $this->getPublicUrl($fullPath), | 105 | 'url' => $this->getPublicUrl($fullPath), |
| 103 | - 'type' => $type | 106 | + 'type' => $type, |
| 107 | + 'uploaded_to' => $uploadedTo | ||
| 104 | ]; | 108 | ]; |
| 105 | 109 | ||
| 106 | if (auth()->user() && auth()->user()->id !== 0) { | 110 | if (auth()->user() && auth()->user()->id !== 0) { | ... | ... |
| ... | @@ -8,15 +8,16 @@ class RestrictionService | ... | @@ -8,15 +8,16 @@ class RestrictionService |
| 8 | protected $userRoles; | 8 | protected $userRoles; |
| 9 | protected $isAdmin; | 9 | protected $isAdmin; |
| 10 | protected $currentAction; | 10 | protected $currentAction; |
| 11 | + protected $currentUser; | ||
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| 13 | * RestrictionService constructor. | 14 | * RestrictionService constructor. |
| 14 | */ | 15 | */ |
| 15 | public function __construct() | 16 | public function __construct() |
| 16 | { | 17 | { |
| 17 | - $user = auth()->user(); | 18 | + $this->currentUser = auth()->user(); |
| 18 | - $this->userRoles = $user ? auth()->user()->roles->pluck('id') : []; | 19 | + $this->userRoles = $this->currentUser ? $this->currentUser->roles->pluck('id') : []; |
| 19 | - $this->isAdmin = $user ? auth()->user()->hasRole('admin') : false; | 20 | + $this->isAdmin = $this->currentUser ? $this->currentUser->hasRole('admin') : false; |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | /** | 23 | /** |
| ... | @@ -48,6 +49,16 @@ class RestrictionService | ... | @@ -48,6 +49,16 @@ class RestrictionService |
| 48 | */ | 49 | */ |
| 49 | public function enforcePageRestrictions($query, $action = 'view') | 50 | public function enforcePageRestrictions($query, $action = 'view') |
| 50 | { | 51 | { |
| 52 | + // Prevent drafts being visible to others. | ||
| 53 | + $query = $query->where(function ($query) { | ||
| 54 | + $query->where('draft', '=', false); | ||
| 55 | + if ($this->currentUser) { | ||
| 56 | + $query->orWhere(function ($query) { | ||
| 57 | + $query->where('draft', '=', true)->where('created_by', '=', $this->currentUser->id); | ||
| 58 | + }); | ||
| 59 | + } | ||
| 60 | + }); | ||
| 61 | + | ||
| 51 | if ($this->isAdmin) return $query; | 62 | if ($this->isAdmin) return $query; |
| 52 | $this->currentAction = $action; | 63 | $this->currentAction = $action; |
| 53 | return $this->pageRestrictionQuery($query); | 64 | return $this->pageRestrictionQuery($query); |
| ... | @@ -254,6 +265,30 @@ class RestrictionService | ... | @@ -254,6 +265,30 @@ class RestrictionService |
| 254 | } | 265 | } |
| 255 | 266 | ||
| 256 | /** | 267 | /** |
| 268 | + * Filters pages that are a direct relation to another item. | ||
| 269 | + * @param $query | ||
| 270 | + * @param $tableName | ||
| 271 | + * @param $entityIdColumn | ||
| 272 | + * @return mixed | ||
| 273 | + */ | ||
| 274 | + public function filterRelatedPages($query, $tableName, $entityIdColumn) | ||
| 275 | + { | ||
| 276 | + if ($this->isAdmin) return $query; | ||
| 277 | + $this->currentAction = 'view'; | ||
| 278 | + $tableDetails = ['tableName' => $tableName, 'entityIdColumn' => $entityIdColumn]; | ||
| 279 | + return $query->where(function ($query) use (&$tableDetails) { | ||
| 280 | + $query->where(function ($query) use (&$tableDetails) { | ||
| 281 | + $query->whereExists(function ($query) use (&$tableDetails) { | ||
| 282 | + $query->select('*')->from('pages')->whereRaw('pages.id=' . $tableDetails['tableName'] . '.' . $tableDetails['entityIdColumn']) | ||
| 283 | + ->where(function ($query) { | ||
| 284 | + $this->pageRestrictionQuery($query); | ||
| 285 | + }); | ||
| 286 | + })->orWhere($tableDetails['entityIdColumn'], '=', 0); | ||
| 287 | + }); | ||
| 288 | + }); | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + /** | ||
| 257 | * The query to check the restrictions on an entity. | 292 | * The query to check the restrictions on an entity. |
| 258 | * @param $query | 293 | * @param $query |
| 259 | * @param $tableName | 294 | * @param $tableName | ... | ... |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use Illuminate\Database\Schema\Blueprint; | ||
| 4 | +use Illuminate\Database\Migrations\Migration; | ||
| 5 | + | ||
| 6 | +class AddPageRevisionTypes extends Migration | ||
| 7 | +{ | ||
| 8 | + /** | ||
| 9 | + * Run the migrations. | ||
| 10 | + * | ||
| 11 | + * @return void | ||
| 12 | + */ | ||
| 13 | + public function up() | ||
| 14 | + { | ||
| 15 | + Schema::table('page_revisions', function (Blueprint $table) { | ||
| 16 | + $table->string('type')->default('version'); | ||
| 17 | + $table->index('type'); | ||
| 18 | + }); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * Reverse the migrations. | ||
| 23 | + * | ||
| 24 | + * @return void | ||
| 25 | + */ | ||
| 26 | + public function down() | ||
| 27 | + { | ||
| 28 | + Schema::table('page_revisions', function (Blueprint $table) { | ||
| 29 | + $table->dropColumn('type'); | ||
| 30 | + }); | ||
| 31 | + } | ||
| 32 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use Illuminate\Database\Schema\Blueprint; | ||
| 4 | +use Illuminate\Database\Migrations\Migration; | ||
| 5 | + | ||
| 6 | +class AddPageDrafts extends Migration | ||
| 7 | +{ | ||
| 8 | + /** | ||
| 9 | + * Run the migrations. | ||
| 10 | + * | ||
| 11 | + * @return void | ||
| 12 | + */ | ||
| 13 | + public function up() | ||
| 14 | + { | ||
| 15 | + Schema::table('pages', function(Blueprint $table) { | ||
| 16 | + $table->boolean('draft')->default(false); | ||
| 17 | + $table->index('draft'); | ||
| 18 | + }); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * Reverse the migrations. | ||
| 23 | + * | ||
| 24 | + * @return void | ||
| 25 | + */ | ||
| 26 | + public function down() | ||
| 27 | + { | ||
| 28 | + Schema::table('pages', function (Blueprint $table) { | ||
| 29 | + $table->dropColumn('draft'); | ||
| 30 | + }); | ||
| 31 | + } | ||
| 32 | +} |
| 1 | -tinymce.PluginManager.add("advlist",function(e){function t(e,t){var n=[];return tinymce.each(t.split(/[ ,]/),function(e){n.push({text:e.replace(/\-/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),data:"default"==e?"":e})}),n}function n(t,n){e.undoManager.transact(function(){var r,i=e.dom,o=e.selection;r=i.getParent(o.getNode(),"ol,ul"),r&&r.nodeName==t&&n!==!1||e.execCommand("UL"==t?"InsertUnorderedList":"InsertOrderedList"),n=n===!1?a[t]:n,a[t]=n,r=i.getParent(o.getNode(),"ol,ul"),r&&(i.setStyle(r,"listStyleType",n?n:null),r.removeAttribute("data-mce-style")),e.focus()})}function r(t){var n=e.dom.getStyle(e.dom.getParent(e.selection.getNode(),"ol,ul"),"listStyleType")||"";t.control.items().each(function(e){e.active(e.settings.data===n)})}var i,o,a={};i=t("OL",e.getParam("advlist_number_styles","default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman")),o=t("UL",e.getParam("advlist_bullet_styles","default,circle,disc,square")),e.addButton("numlist",{type:"splitbutton",tooltip:"Numbered list",menu:i,onshow:r,onselect:function(e){n("OL",e.control.settings.data)},onclick:function(){n("OL",!1)}}),e.addButton("bullist",{type:"splitbutton",tooltip:"Bullet list",menu:o,onshow:r,onselect:function(e){n("UL",e.control.settings.data)},onclick:function(){n("UL",!1)}})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("advlist",function(a){function b(a,b){var c=[];return tinymce.each(b.split(/[ ,]/),function(a){c.push({text:a.replace(/\-/g," ").replace(/\b\w/g,function(a){return a.toUpperCase()}),data:"default"==a?"":a})}),c}function c(b,c){a.undoManager.transact(function(){var d,e=a.dom,f=a.selection;d=e.getParent(f.getNode(),"ol,ul"),d&&d.nodeName==b&&c!==!1||a.execCommand("UL"==b?"InsertUnorderedList":"InsertOrderedList"),c=c===!1?g[b]:c,g[b]=c,d=e.getParent(f.getNode(),"ol,ul"),d&&(e.setStyle(d,"listStyleType",c?c:null),d.removeAttribute("data-mce-style")),a.focus()})}function d(b){var c=a.dom.getStyle(a.dom.getParent(a.selection.getNode(),"ol,ul"),"listStyleType")||"";b.control.items().each(function(a){a.active(a.settings.data===c)})}var e,f,g={};e=b("OL",a.getParam("advlist_number_styles","default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman")),f=b("UL",a.getParam("advlist_bullet_styles","default,circle,disc,square")),a.addButton("numlist",{type:"splitbutton",tooltip:"Numbered list",menu:e,onshow:d,onselect:function(a){c("OL",a.control.settings.data)},onclick:function(){c("OL",!1)}}),a.addButton("bullist",{type:"splitbutton",tooltip:"Bullet list",menu:f,onshow:d,onselect:function(a){c("UL",a.control.settings.data)},onclick:function(){c("UL",!1)}})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("anchor",function(e){function t(){var t=e.selection.getNode(),n="",r="A"==t.tagName&&""===e.dom.getAttrib(t,"href");r&&(n=t.name||t.id||""),e.windowManager.open({title:"Anchor",body:{type:"textbox",name:"name",size:40,label:"Name",value:n},onsubmit:function(n){var i=n.data.name;r?t.id=i:(e.selection.collapse(!0),e.execCommand("mceInsertContent",!1,e.dom.createHTML("a",{id:i})))}})}e.addCommand("mceAnchor",t),e.addButton("anchor",{icon:"anchor",tooltip:"Anchor",onclick:t,stateSelector:"a:not([href])"}),e.addMenuItem("anchor",{icon:"anchor",text:"Anchor",context:"insert",onclick:t})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("anchor",function(a){function b(){var b=a.selection.getNode(),c="",d="A"==b.tagName&&""===a.dom.getAttrib(b,"href");d&&(c=b.name||b.id||""),a.windowManager.open({title:"Anchor",body:{type:"textbox",name:"name",size:40,label:"Name",value:c},onsubmit:function(c){var e=c.data.name;d?b.id=e:(a.selection.collapse(!0),a.execCommand("mceInsertContent",!1,a.dom.createHTML("a",{id:e})))}})}a.addCommand("mceAnchor",b),a.addButton("anchor",{icon:"anchor",tooltip:"Anchor",onclick:b,stateSelector:"a:not([href])"}),a.addMenuItem("anchor",{icon:"anchor",text:"Anchor",context:"insert",onclick:b})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("autolink",function(e){function t(e){i(e,-1,"(",!0)}function n(e){i(e,0,"",!0)}function r(e){i(e,-1,"",!1)}function i(e,t,n){function r(e,t){if(0>t&&(t=0),3==e.nodeType){var n=e.data.length;t>n&&(t=n)}return t}function i(e,t){1!=e.nodeType||e.hasChildNodes()?a.setStart(e,r(e,t)):a.setStartBefore(e)}function o(e,t){1!=e.nodeType||e.hasChildNodes()?a.setEnd(e,r(e,t)):a.setEndAfter(e)}var a,s,l,c,u,d,f,p,m,h;if("A"!=e.selection.getNode().tagName){if(a=e.selection.getRng(!0).cloneRange(),a.startOffset<5){if(p=a.endContainer.previousSibling,!p){if(!a.endContainer.firstChild||!a.endContainer.firstChild.nextSibling)return;p=a.endContainer.firstChild.nextSibling}if(m=p.length,i(p,m),o(p,m),a.endOffset<5)return;s=a.endOffset,c=p}else{if(c=a.endContainer,3!=c.nodeType&&c.firstChild){for(;3!=c.nodeType&&c.firstChild;)c=c.firstChild;3==c.nodeType&&(i(c,0),o(c,c.nodeValue.length))}s=1==a.endOffset?2:a.endOffset-1-t}l=s;do i(c,s>=2?s-2:0),o(c,s>=1?s-1:0),s-=1,h=a.toString();while(" "!=h&&""!==h&&160!=h.charCodeAt(0)&&s-2>=0&&h!=n);a.toString()==n||160==a.toString().charCodeAt(0)?(i(c,s),o(c,l),s+=1):0===a.startOffset?(i(c,0),o(c,l)):(i(c,s),o(c,l)),d=a.toString(),"."==d.charAt(d.length-1)&&o(c,l-1),d=a.toString(),f=d.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+\-]+@)(.+)$/i),f&&("www."==f[1]?f[1]="http://www.":/@$/.test(f[1])&&!/^mailto:/.test(f[1])&&(f[1]="mailto:"+f[1]),u=e.selection.getBookmark(),e.selection.setRng(a),e.execCommand("createlink",!1,f[1]+f[2]),e.selection.moveToBookmark(u),e.nodeChanged())}}var o;return e.on("keydown",function(t){return 13==t.keyCode?r(e):void 0}),tinymce.Env.ie?void e.on("focus",function(){if(!o){o=!0;try{e.execCommand("AutoUrlDetect",!1,!0)}catch(t){}}}):(e.on("keypress",function(n){return 41==n.keyCode?t(e):void 0}),void e.on("keyup",function(t){return 32==t.keyCode?n(e):void 0}))}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("autolink",function(a){function b(a){e(a,-1,"(",!0)}function c(a){e(a,0,"",!0)}function d(a){e(a,-1,"",!1)}function e(a,b,c){function d(a,b){if(0>b&&(b=0),3==a.nodeType){var c=a.data.length;b>c&&(b=c)}return b}function e(a,b){1!=a.nodeType||a.hasChildNodes()?h.setStart(a,d(a,b)):h.setStartBefore(a)}function f(a,b){1!=a.nodeType||a.hasChildNodes()?h.setEnd(a,d(a,b)):h.setEndAfter(a)}var h,i,j,k,l,m,n,o,p,q;if("A"!=a.selection.getNode().tagName){if(h=a.selection.getRng(!0).cloneRange(),h.startOffset<5){if(o=h.endContainer.previousSibling,!o){if(!h.endContainer.firstChild||!h.endContainer.firstChild.nextSibling)return;o=h.endContainer.firstChild.nextSibling}if(p=o.length,e(o,p),f(o,p),h.endOffset<5)return;i=h.endOffset,k=o}else{if(k=h.endContainer,3!=k.nodeType&&k.firstChild){for(;3!=k.nodeType&&k.firstChild;)k=k.firstChild;3==k.nodeType&&(e(k,0),f(k,k.nodeValue.length))}i=1==h.endOffset?2:h.endOffset-1-b}j=i;do e(k,i>=2?i-2:0),f(k,i>=1?i-1:0),i-=1,q=h.toString();while(" "!=q&&""!==q&&160!=q.charCodeAt(0)&&i-2>=0&&q!=c);h.toString()==c||160==h.toString().charCodeAt(0)?(e(k,i),f(k,j),i+=1):0===h.startOffset?(e(k,0),f(k,j)):(e(k,i),f(k,j)),m=h.toString(),"."==m.charAt(m.length-1)&&f(k,j-1),m=h.toString(),n=m.match(g),n&&("www."==n[1]?n[1]="http://www.":/@$/.test(n[1])&&!/^mailto:/.test(n[1])&&(n[1]="mailto:"+n[1]),l=a.selection.getBookmark(),a.selection.setRng(h),a.execCommand("createlink",!1,n[1]+n[2]),a.selection.moveToBookmark(l),a.nodeChanged())}}var f,g=/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+\-]+@)(.+)$/i;return a.settings.autolink_pattern&&(g=a.settings.autolink_pattern),a.on("keydown",function(b){return 13==b.keyCode?d(a):void 0}),tinymce.Env.ie?void a.on("focus",function(){if(!f){f=!0;try{a.execCommand("AutoUrlDetect",!1,!0)}catch(b){}}}):(a.on("keypress",function(c){return 41==c.keyCode?b(a):void 0}),void a.on("keyup",function(b){return 32==b.keyCode?c(a):void 0}))}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("autoresize",function(e){function t(){return e.plugins.fullscreen&&e.plugins.fullscreen.isFullscreen()}function n(r){var a,s,l,c,u,d,f,p,m,h,g,v,y=tinymce.DOM;if(s=e.getDoc()){if(l=s.body,c=s.documentElement,u=i.autoresize_min_height,!l||r&&"setcontent"===r.type&&r.initial||t())return void(l&&c&&(l.style.overflowY="auto",c.style.overflowY="auto"));f=e.dom.getStyle(l,"margin-top",!0),p=e.dom.getStyle(l,"margin-bottom",!0),m=e.dom.getStyle(l,"padding-top",!0),h=e.dom.getStyle(l,"padding-bottom",!0),g=e.dom.getStyle(l,"border-top-width",!0),v=e.dom.getStyle(l,"border-bottom-width",!0),d=l.offsetHeight+parseInt(f,10)+parseInt(p,10)+parseInt(m,10)+parseInt(h,10)+parseInt(g,10)+parseInt(v,10),(isNaN(d)||0>=d)&&(d=tinymce.Env.ie?l.scrollHeight:tinymce.Env.webkit&&0===l.clientHeight?0:l.offsetHeight),d>i.autoresize_min_height&&(u=d),i.autoresize_max_height&&d>i.autoresize_max_height?(u=i.autoresize_max_height,l.style.overflowY="auto",c.style.overflowY="auto"):(l.style.overflowY="hidden",c.style.overflowY="hidden",l.scrollTop=0),u!==o&&(a=u-o,y.setStyle(e.iframeElement,"height",u+"px"),o=u,tinymce.isWebKit&&0>a&&n(r))}}function r(t,i,o){tinymce.util.Delay.setEditorTimeout(e,function(){n({}),t--?r(t,i,o):o&&o()},i)}var i=e.settings,o=0;e.settings.inline||(i.autoresize_min_height=parseInt(e.getParam("autoresize_min_height",e.getElement().offsetHeight),10),i.autoresize_max_height=parseInt(e.getParam("autoresize_max_height",0),10),e.on("init",function(){var t,n;t=e.getParam("autoresize_overflow_padding",1),n=e.getParam("autoresize_bottom_margin",50),t!==!1&&e.dom.setStyles(e.getBody(),{paddingLeft:t,paddingRight:t}),n!==!1&&e.dom.setStyles(e.getBody(),{paddingBottom:n})}),e.on("nodechange setcontent keyup FullscreenStateChanged",n),e.getParam("autoresize_on_init",!0)&&e.on("init",function(){r(20,100,function(){r(5,1e3)})}),e.addCommand("mceAutoResize",n))}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("autoresize",function(a){function b(){return a.plugins.fullscreen&&a.plugins.fullscreen.isFullscreen()}function c(d){var g,h,i,j,k,l,m,n,o,p,q,r,s=tinymce.DOM;if(h=a.getDoc()){if(i=h.body,j=h.documentElement,k=e.autoresize_min_height,!i||d&&"setcontent"===d.type&&d.initial||b())return void(i&&j&&(i.style.overflowY="auto",j.style.overflowY="auto"));m=a.dom.getStyle(i,"margin-top",!0),n=a.dom.getStyle(i,"margin-bottom",!0),o=a.dom.getStyle(i,"padding-top",!0),p=a.dom.getStyle(i,"padding-bottom",!0),q=a.dom.getStyle(i,"border-top-width",!0),r=a.dom.getStyle(i,"border-bottom-width",!0),l=i.offsetHeight+parseInt(m,10)+parseInt(n,10)+parseInt(o,10)+parseInt(p,10)+parseInt(q,10)+parseInt(r,10),(isNaN(l)||0>=l)&&(l=tinymce.Env.ie?i.scrollHeight:tinymce.Env.webkit&&0===i.clientHeight?0:i.offsetHeight),l>e.autoresize_min_height&&(k=l),e.autoresize_max_height&&l>e.autoresize_max_height?(k=e.autoresize_max_height,i.style.overflowY="auto",j.style.overflowY="auto"):(i.style.overflowY="hidden",j.style.overflowY="hidden",i.scrollTop=0),k!==f&&(g=k-f,s.setStyle(a.iframeElement,"height",k+"px"),f=k,tinymce.isWebKit&&0>g&&c(d))}}function d(b,e,f){tinymce.util.Delay.setEditorTimeout(a,function(){c({}),b--?d(b,e,f):f&&f()},e)}var e=a.settings,f=0;a.settings.inline||(e.autoresize_min_height=parseInt(a.getParam("autoresize_min_height",a.getElement().offsetHeight),10),e.autoresize_max_height=parseInt(a.getParam("autoresize_max_height",0),10),a.on("init",function(){var b,c;b=a.getParam("autoresize_overflow_padding",1),c=a.getParam("autoresize_bottom_margin",50),b!==!1&&a.dom.setStyles(a.getBody(),{paddingLeft:b,paddingRight:b}),c!==!1&&a.dom.setStyles(a.getBody(),{paddingBottom:c})}),a.on("nodechange setcontent keyup FullscreenStateChanged",c),a.getParam("autoresize_on_init",!0)&&a.on("init",function(){d(20,100,function(){d(5,1e3)})}),a.addCommand("mceAutoResize",c))}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce._beforeUnloadHandler=function(){var e;return tinymce.each(tinymce.editors,function(t){t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&t.getParam("autosave_ask_before_unload",!0)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))}),e},tinymce.PluginManager.add("autosave",function(e){function t(e,t){var n={s:1e3,m:6e4};return e=/^(\d+)([ms]?)$/.exec(""+(e||t)),(e[2]?n[e[2]]:1)*parseInt(e,10)}function n(){var e=parseInt(p.getItem(u+"time"),10)||0;return(new Date).getTime()-e>f.autosave_retention?(r(!1),!1):!0}function r(t){p.removeItem(u+"draft"),p.removeItem(u+"time"),t!==!1&&e.fire("RemoveDraft")}function i(){!c()&&e.isDirty()&&(p.setItem(u+"draft",e.getContent({format:"raw",no_events:!0})),p.setItem(u+"time",(new Date).getTime()),e.fire("StoreDraft"))}function o(){n()&&(e.setContent(p.getItem(u+"draft"),{format:"raw"}),e.fire("RestoreDraft"))}function a(){d||(setInterval(function(){e.removed||i()},f.autosave_interval),d=!0)}function s(){var t=this;t.disabled(!n()),e.on("StoreDraft RestoreDraft RemoveDraft",function(){t.disabled(!n())}),a()}function l(){e.undoManager.beforeChange(),o(),r(),e.undoManager.add()}function c(t){var n=e.settings.forced_root_block;return t=tinymce.trim("undefined"==typeof t?e.getBody().innerHTML:t),""===t||new RegExp("^<"+n+"[^>]*>((\xa0| |[ ]|<br[^>]*>)+?|)</"+n+">|<br>$","i").test(t)}var u,d,f=e.settings,p=tinymce.util.LocalStorage;u=f.autosave_prefix||"tinymce-autosave-{path}{query}-{id}-",u=u.replace(/\{path\}/g,document.location.pathname),u=u.replace(/\{query\}/g,document.location.search),u=u.replace(/\{id\}/g,e.id),f.autosave_interval=t(f.autosave_interval,"30s"),f.autosave_retention=t(f.autosave_retention,"20m"),e.addButton("restoredraft",{title:"Restore last draft",onclick:l,onPostRender:s}),e.addMenuItem("restoredraft",{text:"Restore last draft",onclick:l,onPostRender:s,context:"file"}),e.settings.autosave_restore_when_empty!==!1&&(e.on("init",function(){n()&&c()&&o()}),e.on("saveContent",function(){r()})),window.onbeforeunload=tinymce._beforeUnloadHandler,this.hasDraft=n,this.storeDraft=i,this.restoreDraft=o,this.removeDraft=r,this.isEmpty=c}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce._beforeUnloadHandler=function(){var a;return tinymce.each(tinymce.editors,function(b){b.plugins.autosave&&b.plugins.autosave.storeDraft(),!a&&b.isDirty()&&b.getParam("autosave_ask_before_unload",!0)&&(a=b.translate("You have unsaved changes are you sure you want to navigate away?"))}),a},tinymce.PluginManager.add("autosave",function(a){function b(a,b){var c={s:1e3,m:6e4};return a=/^(\d+)([ms]?)$/.exec(""+(a||b)),(a[2]?c[a[2]]:1)*parseInt(a,10)}function c(){var a=parseInt(n.getItem(k+"time"),10)||0;return(new Date).getTime()-a>m.autosave_retention?(d(!1),!1):!0}function d(b){n.removeItem(k+"draft"),n.removeItem(k+"time"),b!==!1&&a.fire("RemoveDraft")}function e(){!j()&&a.isDirty()&&(n.setItem(k+"draft",a.getContent({format:"raw",no_events:!0})),n.setItem(k+"time",(new Date).getTime()),a.fire("StoreDraft"))}function f(){c()&&(a.setContent(n.getItem(k+"draft"),{format:"raw"}),a.fire("RestoreDraft"))}function g(){l||(setInterval(function(){a.removed||e()},m.autosave_interval),l=!0)}function h(){var b=this;b.disabled(!c()),a.on("StoreDraft RestoreDraft RemoveDraft",function(){b.disabled(!c())}),g()}function i(){a.undoManager.beforeChange(),f(),d(),a.undoManager.add()}function j(b){var c=a.settings.forced_root_block;return b=tinymce.trim("undefined"==typeof b?a.getBody().innerHTML:b),""===b||new RegExp("^<"+c+"[^>]*>((\xa0| |[ ]|<br[^>]*>)+?|)</"+c+">|<br>$","i").test(b)}var k,l,m=a.settings,n=tinymce.util.LocalStorage;k=m.autosave_prefix||"tinymce-autosave-{path}{query}-{id}-",k=k.replace(/\{path\}/g,document.location.pathname),k=k.replace(/\{query\}/g,document.location.search),k=k.replace(/\{id\}/g,a.id),m.autosave_interval=b(m.autosave_interval,"30s"),m.autosave_retention=b(m.autosave_retention,"20m"),a.addButton("restoredraft",{title:"Restore last draft",onclick:i,onPostRender:h}),a.addMenuItem("restoredraft",{text:"Restore last draft",onclick:i,onPostRender:h,context:"file"}),a.settings.autosave_restore_when_empty!==!1&&(a.on("init",function(){c()&&j()&&f()}),a.on("saveContent",function(){d()})),window.onbeforeunload=tinymce._beforeUnloadHandler,this.hasDraft=c,this.storeDraft=e,this.restoreDraft=f,this.removeDraft=d,this.isEmpty=j}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -!function(){tinymce.create("tinymce.plugins.BBCodePlugin",{init:function(e){var t=this,n=e.getParam("bbcode_dialect","punbb").toLowerCase();e.on("beforeSetContent",function(e){e.content=t["_"+n+"_bbcode2html"](e.content)}),e.on("postProcess",function(e){e.set&&(e.content=t["_"+n+"_bbcode2html"](e.content)),e.get&&(e.content=t["_"+n+"_html2bbcode"](e.content))})},getInfo:function(){return{longname:"BBCode Plugin",author:"Ephox Corp",authorurl:"http://www.tinymce.com",infourl:"http://www.tinymce.com/wiki.php/Plugin:bbcode"}},_punbb_html2bbcode:function(e){function t(t,n){e=e.replace(t,n)}return e=tinymce.trim(e),t(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"),t(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),t(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),t(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),t(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),t(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]"),t(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"),t(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]"),t(/<font>(.*?)<\/font>/gi,"$1"),t(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]"),t(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]"),t(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]"),t(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"),t(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]"),t(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"),t(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]"),t(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"),t(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]"),t(/<\/(strong|b)>/gi,"[/b]"),t(/<(strong|b)>/gi,"[b]"),t(/<\/(em|i)>/gi,"[/i]"),t(/<(em|i)>/gi,"[i]"),t(/<\/u>/gi,"[/u]"),t(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]"),t(/<u>/gi,"[u]"),t(/<blockquote[^>]*>/gi,"[quote]"),t(/<\/blockquote>/gi,"[/quote]"),t(/<br \/>/gi,"\n"),t(/<br\/>/gi,"\n"),t(/<br>/gi,"\n"),t(/<p>/gi,""),t(/<\/p>/gi,"\n"),t(/ |\u00a0/gi," "),t(/"/gi,'"'),t(/</gi,"<"),t(/>/gi,">"),t(/&/gi,"&"),e},_punbb_bbcode2html:function(e){function t(t,n){e=e.replace(t,n)}return e=tinymce.trim(e),t(/\n/gi,"<br />"),t(/\[b\]/gi,"<strong>"),t(/\[\/b\]/gi,"</strong>"),t(/\[i\]/gi,"<em>"),t(/\[\/i\]/gi,"</em>"),t(/\[u\]/gi,"<u>"),t(/\[\/u\]/gi,"</u>"),t(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>'),t(/\[url\](.*?)\[\/url\]/gi,'<a href="$1">$1</a>'),t(/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />'),t(/\[color=(.*?)\](.*?)\[\/color\]/gi,'<font color="$1">$2</font>'),t(/\[code\](.*?)\[\/code\]/gi,'<span class="codeStyle">$1</span> '),t(/\[quote.*?\](.*?)\[\/quote\]/gi,'<span class="quoteStyle">$1</span> '),e}}),tinymce.PluginManager.add("bbcode",tinymce.plugins.BBCodePlugin)}(); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +!function(){tinymce.create("tinymce.plugins.BBCodePlugin",{init:function(a){var b=this,c=a.getParam("bbcode_dialect","punbb").toLowerCase();a.on("beforeSetContent",function(a){a.content=b["_"+c+"_bbcode2html"](a.content)}),a.on("postProcess",function(a){a.set&&(a.content=b["_"+c+"_bbcode2html"](a.content)),a.get&&(a.content=b["_"+c+"_html2bbcode"](a.content))})},getInfo:function(){return{longname:"BBCode Plugin",author:"Ephox Corp",authorurl:"http://www.tinymce.com",infourl:"http://www.tinymce.com/wiki.php/Plugin:bbcode"}},_punbb_html2bbcode:function(a){function b(b,c){a=a.replace(b,c)}return a=tinymce.trim(a),b(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"),b(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),b(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),b(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),b(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),b(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]"),b(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"),b(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]"),b(/<font>(.*?)<\/font>/gi,"$1"),b(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]"),b(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]"),b(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]"),b(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"),b(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]"),b(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"),b(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]"),b(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"),b(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]"),b(/<\/(strong|b)>/gi,"[/b]"),b(/<(strong|b)>/gi,"[b]"),b(/<\/(em|i)>/gi,"[/i]"),b(/<(em|i)>/gi,"[i]"),b(/<\/u>/gi,"[/u]"),b(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]"),b(/<u>/gi,"[u]"),b(/<blockquote[^>]*>/gi,"[quote]"),b(/<\/blockquote>/gi,"[/quote]"),b(/<br \/>/gi,"\n"),b(/<br\/>/gi,"\n"),b(/<br>/gi,"\n"),b(/<p>/gi,""),b(/<\/p>/gi,"\n"),b(/ |\u00a0/gi," "),b(/"/gi,'"'),b(/</gi,"<"),b(/>/gi,">"),b(/&/gi,"&"),a},_punbb_bbcode2html:function(a){function b(b,c){a=a.replace(b,c)}return a=tinymce.trim(a),b(/\n/gi,"<br />"),b(/\[b\]/gi,"<strong>"),b(/\[\/b\]/gi,"</strong>"),b(/\[i\]/gi,"<em>"),b(/\[\/i\]/gi,"</em>"),b(/\[u\]/gi,"<u>"),b(/\[\/u\]/gi,"</u>"),b(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>'),b(/\[url\](.*?)\[\/url\]/gi,'<a href="$1">$1</a>'),b(/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />'),b(/\[color=(.*?)\](.*?)\[\/color\]/gi,'<font color="$1">$2</font>'),b(/\[code\](.*?)\[\/code\]/gi,'<span class="codeStyle">$1</span> '),b(/\[quote.*?\](.*?)\[\/quote\]/gi,'<span class="quoteStyle">$1</span> '),a}}),tinymce.PluginManager.add("bbcode",tinymce.plugins.BBCodePlugin)}(); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
| 1 | -tinymce.PluginManager.add("code",function(e){function t(){var t=e.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:e.getParam("code_dialog_width",600),minHeight:e.getParam("code_dialog_height",Math.min(tinymce.DOM.getViewPort().h-200,500)),spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(t){e.focus(),e.undoManager.transact(function(){e.setContent(t.data.code)}),e.selection.setCursorLocation(),e.nodeChanged()}});t.find("#code").value(e.getContent({source_view:!0}))}e.addCommand("mceCodeEditor",t),e.addButton("code",{icon:"code",tooltip:"Source code",onclick:t}),e.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:t})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("code",function(a){function b(){var b=a.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:a.getParam("code_dialog_width",600),minHeight:a.getParam("code_dialog_height",Math.min(tinymce.DOM.getViewPort().h-200,500)),spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(b){a.focus(),a.undoManager.transact(function(){a.setContent(b.data.code)}),a.selection.setCursorLocation(),a.nodeChanged()}});b.find("#code").value(a.getContent({source_view:!0}))}a.addCommand("mceCodeEditor",b),a.addButton("code",{icon:"code",tooltip:"Source code",onclick:b}),a.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:b})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
| 1 | -tinymce.PluginManager.add("colorpicker",function(e){function t(t,n){function r(e){var t=new tinymce.util.Color(e),n=t.toRgb();o.fromJSON({r:n.r,g:n.g,b:n.b,hex:t.toHex().substr(1)}),i(t.toHex())}function i(e){o.find("#preview")[0].getEl().style.background=e}var o=e.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:n,onchange:function(){var e=this.rgb();o&&(o.find("#r").value(e.r),o.find("#g").value(e.g),o.find("#b").value(e.b),o.find("#hex").value(this.value().substr(1)),i(this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var e,t,n=o.find("colorpicker")[0];return e=this.name(),t=this.value(),"hex"==e?(t="#"+t,r(t),void n.value(t)):(t={r:o.find("#r").value(),g:o.find("#g").value(),b:o.find("#b").value()},n.value(t),void r(t))}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){t("#"+this.toJSON().hex)}});r(n)}e.settings.color_picker_callback||(e.settings.color_picker_callback=t)}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("colorpicker",function(a){function b(b,c){function d(a){var b=new tinymce.util.Color(a),c=b.toRgb();f.fromJSON({r:c.r,g:c.g,b:c.b,hex:b.toHex().substr(1)}),e(b.toHex())}function e(a){f.find("#preview")[0].getEl().style.background=a}var f=a.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:c,onchange:function(){var a=this.rgb();f&&(f.find("#r").value(a.r),f.find("#g").value(a.g),f.find("#b").value(a.b),f.find("#hex").value(this.value().substr(1)),e(this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var a,b,c=f.find("colorpicker")[0];return a=this.name(),b=this.value(),"hex"==a?(b="#"+b,d(b),void c.value(b)):(b={r:f.find("#r").value(),g:f.find("#g").value(),b:f.find("#b").value()},c.value(b),void d(b))}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){b("#"+this.toJSON().hex)}});d(c)}a.settings.color_picker_callback||(a.settings.color_picker_callback=b)}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("contextmenu",function(e){var t,n=e.settings.contextmenu_never_use_native;e.on("contextmenu",function(r){var i,o=e.getDoc();if(!r.ctrlKey||n){if(r.preventDefault(),tinymce.Env.mac&&tinymce.Env.webkit&&2==r.button&&o.caretRangeFromPoint&&e.selection.setRng(o.caretRangeFromPoint(r.x,r.y)),i=e.settings.contextmenu||"link image inserttable | cell row column deletetable",t)t.show();else{var a=[];tinymce.each(i.split(/[ ,]/),function(t){var n=e.menuItems[t];"|"==t&&(n={text:t}),n&&(n.shortcut="",a.push(n))});for(var s=0;s<a.length;s++)"|"==a[s].text&&(0===s||s==a.length-1)&&a.splice(s,1);t=new tinymce.ui.Menu({items:a,context:"contextmenu",classes:"contextmenu"}).renderTo(),e.on("remove",function(){t.remove(),t=null})}var l={x:r.pageX,y:r.pageY};e.inline||(l=tinymce.DOM.getPos(e.getContentAreaContainer()),l.x+=r.clientX,l.y+=r.clientY),t.moveTo(l.x,l.y)}})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("contextmenu",function(a){var b,c=a.settings.contextmenu_never_use_native;a.on("contextmenu",function(d){var e,f=a.getDoc();if(!d.ctrlKey||c){if(d.preventDefault(),tinymce.Env.mac&&tinymce.Env.webkit&&2==d.button&&f.caretRangeFromPoint&&a.selection.setRng(f.caretRangeFromPoint(d.x,d.y)),e=a.settings.contextmenu||"link image inserttable | cell row column deletetable",b)b.show();else{var g=[];tinymce.each(e.split(/[ ,]/),function(b){var c=a.menuItems[b];"|"==b&&(c={text:b}),c&&(c.shortcut="",g.push(c))});for(var h=0;h<g.length;h++)"|"==g[h].text&&(0!==h&&h!=g.length-1||g.splice(h,1));b=new tinymce.ui.Menu({items:g,context:"contextmenu",classes:"contextmenu"}).renderTo(),a.on("remove",function(){b.remove(),b=null})}var i={x:d.pageX,y:d.pageY};a.inline||(i=tinymce.DOM.getPos(a.getContentAreaContainer()),i.x+=d.clientX,i.y+=d.clientY),b.moveTo(i.x,i.y)}})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("directionality",function(e){function t(t){var n,r=e.dom,i=e.selection.getSelectedBlocks();i.length&&(n=r.getAttrib(i[0],"dir"),tinymce.each(i,function(e){r.getParent(e.parentNode,"*[dir='"+t+"']",r.getRoot())||(n!=t?r.setAttrib(e,"dir",t):r.setAttrib(e,"dir",null))}),e.nodeChanged())}function n(e){var t=[];return tinymce.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(n){t.push(n+"[dir="+e+"]")}),t.join(",")}e.addCommand("mceDirectionLTR",function(){t("ltr")}),e.addCommand("mceDirectionRTL",function(){t("rtl")}),e.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:n("ltr")}),e.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:n("rtl")})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("directionality",function(a){function b(b){var c,d=a.dom,e=a.selection.getSelectedBlocks();e.length&&(c=d.getAttrib(e[0],"dir"),tinymce.each(e,function(a){d.getParent(a.parentNode,"*[dir='"+b+"']",d.getRoot())||(c!=b?d.setAttrib(a,"dir",b):d.setAttrib(a,"dir",null))}),a.nodeChanged())}function c(a){var b=[];return tinymce.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(c){b.push(c+"[dir="+a+"]")}),b.join(",")}a.addCommand("mceDirectionLTR",function(){b("ltr")}),a.addCommand("mceDirectionRTL",function(){b("rtl")}),a.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:c("ltr")}),a.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:c("rtl")})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("emoticons",function(e,t){function n(){var e;return e='<table role="list" class="mce-grid">',tinymce.each(r,function(n){e+="<tr>",tinymce.each(n,function(n){var r=t+"/img/smiley-"+n+".gif";e+='<td><a href="#" data-mce-url="'+r+'" data-mce-alt="'+n+'" tabindex="-1" role="option" aria-label="'+n+'"><img src="'+r+'" style="width: 18px; height: 18px" role="presentation" /></a></td>'}),e+="</tr>"}),e+="</table>"}var r=[["cool","cry","embarassed","foot-in-mouth"],["frown","innocent","kiss","laughing"],["money-mouth","sealed","smile","surprised"],["tongue-out","undecided","wink","yell"]];e.addButton("emoticons",{type:"panelbutton",panel:{role:"application",autohide:!0,html:n,onclick:function(t){var n=e.dom.getParent(t.target,"a");n&&(e.insertContent('<img src="'+n.getAttribute("data-mce-url")+'" alt="'+n.getAttribute("data-mce-alt")+'" />'),this.hide())}},tooltip:"Emoticons"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("emoticons",function(a,b){function c(){var a;return a='<table role="list" class="mce-grid">',tinymce.each(d,function(c){a+="<tr>",tinymce.each(c,function(c){var d=b+"/img/smiley-"+c+".gif";a+='<td><a href="#" data-mce-url="'+d+'" data-mce-alt="'+c+'" tabindex="-1" role="option" aria-label="'+c+'"><img src="'+d+'" style="width: 18px; height: 18px" role="presentation" /></a></td>'}),a+="</tr>"}),a+="</table>"}var d=[["cool","cry","embarassed","foot-in-mouth"],["frown","innocent","kiss","laughing"],["money-mouth","sealed","smile","surprised"],["tongue-out","undecided","wink","yell"]];a.addButton("emoticons",{type:"panelbutton",panel:{role:"application",autohide:!0,html:c,onclick:function(b){var c=a.dom.getParent(b.target,"a");c&&(a.insertContent('<img src="'+c.getAttribute("data-mce-url")+'" alt="'+c.getAttribute("data-mce-alt")+'" />'),this.hide())}},tooltip:"Emoticons"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("example",function(e,t){e.addButton("example",{text:"My button",icon:!1,onclick:function(){e.windowManager.open({title:"Example plugin",body:[{type:"textbox",name:"title",label:"Title"}],onsubmit:function(t){e.insertContent("Title: "+t.data.title)}})}}),e.addMenuItem("example",{text:"Example plugin",context:"tools",onclick:function(){e.windowManager.open({title:"TinyMCE site",url:t+"/dialog.html",width:600,height:400,buttons:[{text:"Insert",onclick:function(){var t=e.windowManager.getWindows()[0];e.insertContent(t.getContentWindow().document.getElementById("content").value),t.close()}},{text:"Close",onclick:"close"}]})}})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("example",function(a,b){a.addButton("example",{text:"My button",icon:!1,onclick:function(){a.windowManager.open({title:"Example plugin",body:[{type:"textbox",name:"title",label:"Title"}],onsubmit:function(b){a.insertContent("Title: "+b.data.title)}})}}),a.addMenuItem("example",{text:"Example plugin",context:"tools",onclick:function(){a.windowManager.open({title:"TinyMCE site",url:b+"/dialog.html",width:600,height:400,buttons:[{text:"Insert",onclick:function(){var b=a.windowManager.getWindows()[0];a.insertContent(b.getContentWindow().document.getElementById("content").value),b.close()}},{text:"Close",onclick:"close"}]})}})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
| 1 | -tinymce.PluginManager.add("fullscreen",function(e){function t(){var e,t,n=window,r=document,i=r.body;return i.offsetWidth&&(e=i.offsetWidth,t=i.offsetHeight),n.innerWidth&&n.innerHeight&&(e=n.innerWidth,t=n.innerHeight),{w:e,h:t}}function n(){function n(){c.setStyle(f,"height",t().h-(d.clientHeight-f.clientHeight))}var u,d,f,p,m=document.body,h=document.documentElement;l=!l,d=e.getContainer(),u=d.style,f=e.getContentAreaContainer().firstChild,p=f.style,l?(r=p.width,i=p.height,p.width=p.height="100%",a=u.width,s=u.height,u.width=u.height="",c.addClass(m,"mce-fullscreen"),c.addClass(h,"mce-fullscreen"),c.addClass(d,"mce-fullscreen"),c.bind(window,"resize",n),n(),o=n):(p.width=r,p.height=i,a&&(u.width=a),s&&(u.height=s),c.removeClass(m,"mce-fullscreen"),c.removeClass(h,"mce-fullscreen"),c.removeClass(d,"mce-fullscreen"),c.unbind(window,"resize",o)),e.fire("FullscreenStateChanged",{state:l})}var r,i,o,a,s,l=!1,c=tinymce.DOM;return e.settings.inline?void 0:(e.on("init",function(){e.addShortcut("Meta+Alt+F","",n)}),e.on("remove",function(){o&&c.unbind(window,"resize",o)}),e.addCommand("mceFullScreen",n),e.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Meta+Alt+F",selectable:!0,onClick:n,onPostRender:function(){var t=this;e.on("FullscreenStateChanged",function(e){t.active(e.state)})},context:"view"}),e.addButton("fullscreen",{tooltip:"Fullscreen",shortcut:"Meta+Alt+F",onClick:n,onPostRender:function(){var t=this;e.on("FullscreenStateChanged",function(e){t.active(e.state)})}}),{isFullscreen:function(){return l}})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("fullscreen",function(a){function b(){var a,b,c=window,d=document,e=d.body;return e.offsetWidth&&(a=e.offsetWidth,b=e.offsetHeight),c.innerWidth&&c.innerHeight&&(a=c.innerWidth,b=c.innerHeight),{w:a,h:b}}function c(){var a=tinymce.DOM.getViewPort();return{x:a.x,y:a.y}}function d(a){scrollTo(a.x,a.y)}function e(){function e(){m.setStyle(p,"height",b().h-(o.clientHeight-p.clientHeight))}var n,o,p,q,r=document.body,s=document.documentElement;l=!l,o=a.getContainer(),n=o.style,p=a.getContentAreaContainer().firstChild,q=p.style,l?(k=c(),f=q.width,g=q.height,q.width=q.height="100%",i=n.width,j=n.height,n.width=n.height="",m.addClass(r,"mce-fullscreen"),m.addClass(s,"mce-fullscreen"),m.addClass(o,"mce-fullscreen"),m.bind(window,"resize",e),e(),h=e):(q.width=f,q.height=g,i&&(n.width=i),j&&(n.height=j),m.removeClass(r,"mce-fullscreen"),m.removeClass(s,"mce-fullscreen"),m.removeClass(o,"mce-fullscreen"),m.unbind(window,"resize",h),d(k)),a.fire("FullscreenStateChanged",{state:l})}var f,g,h,i,j,k,l=!1,m=tinymce.DOM;return a.settings.inline?void 0:(a.on("init",function(){a.addShortcut("Meta+Alt+F","",e)}),a.on("remove",function(){h&&m.unbind(window,"resize",h)}),a.addCommand("mceFullScreen",e),a.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Meta+Alt+F",selectable:!0,onClick:function(){e(),a.focus()},onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})},context:"view"}),a.addButton("fullscreen",{tooltip:"Fullscreen",shortcut:"Meta+Alt+F",onClick:e,onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})}}),{isFullscreen:function(){return l}})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("hr",function(e){e.addCommand("InsertHorizontalRule",function(){e.execCommand("mceInsertContent",!1,"<hr />")}),e.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),e.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("hr",function(a){a.addCommand("InsertHorizontalRule",function(){a.execCommand("mceInsertContent",!1,"<hr />")}),a.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),a.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | -tinymce.PluginManager.add("importcss",function(e){function t(t){var n=e.settings,r=n.skin!==!1?n.skin||"lightgray":!1;if(r){var i=n.skin_url;return i=i?e.documentBaseURI.toAbsolute(i):tinymce.baseURL+"/skins/"+r,t===i+"/content"+(e.inline?".inline":"")+".min.css"}return!1}function n(e){return"string"==typeof e?function(t){return-1!==t.indexOf(e)}:e instanceof RegExp?function(t){return e.test(t)}:e}function r(n,r){function i(e,n){var s,l=e.href;if(l&&r(l,n)&&!t(l)){a(e.imports,function(e){i(e,!0)});try{s=e.cssRules||e.rules}catch(c){}a(s,function(e){e.styleSheet?i(e.styleSheet,!0):e.selectorText&&a(e.selectorText.split(","),function(e){o.push(tinymce.trim(e))})})}}var o=[],s={};a(e.contentCSS,function(e){s[e]=!0}),r||(r=function(e,t){return t||s[e]});try{a(n.styleSheets,function(e){i(e)})}catch(l){}return o}function i(t){var n,r=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(t);if(r){var i=r[1],o=r[2].substr(1).split(".").join(" "),a=tinymce.makeMap("a,img");return r[1]?(n={title:t},e.schema.getTextBlockElements()[i]?n.block=i:e.schema.getBlockElements()[i]||a[i.toLowerCase()]?n.selector=i:n.inline=i):r[2]&&(n={inline:"span",title:t.substr(1),classes:o}),e.settings.importcss_merge_classes!==!1?n.classes=o:n.attributes={"class":o},n}}var o=this,a=tinymce.each;e.on("renderFormatsMenu",function(t){var s=e.settings,l={},c=s.importcss_selector_converter||i,u=n(s.importcss_selector_filter),d=t.control;e.settings.importcss_append||d.items().remove();var f=[];tinymce.each(s.importcss_groups,function(e){e=tinymce.extend({},e),e.filter=n(e.filter),f.push(e)}),a(r(t.doc||e.getDoc(),n(s.importcss_file_filter)),function(t){if(-1===t.indexOf(".mce-")&&!l[t]&&(!u||u(t))){var n,r=c.call(o,t);if(r){var i=r.name||tinymce.DOM.uniqueId();if(f)for(var a=0;a<f.length;a++)if(!f[a].filter||f[a].filter(t)){f[a].item||(f[a].item={text:f[a].title,menu:[]}),n=f[a].item.menu;break}e.formatter.register(i,r);var s=tinymce.extend({},d.settings.itemDefaults,{text:r.title,format:i});n?n.push(s):d.add(s)}l[t]=!0}}),a(f,function(e){d.add(e.item)}),t.control.renderNew()}),o.convertSelectorToFormat=i}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("importcss",function(a){function b(a){var b=tinymce.Env.cacheSuffix;return"string"==typeof a&&(a=a.replace("?"+b,"").replace("&"+b,"")),a}function c(b){var c=a.settings,d=c.skin!==!1?c.skin||"lightgray":!1;if(d){var e=c.skin_url;return e=e?a.documentBaseURI.toAbsolute(e):tinymce.baseURL+"/skins/"+d,b===e+"/content"+(a.inline?".inline":"")+".min.css"}return!1}function d(a){return"string"==typeof a?function(b){return-1!==b.indexOf(a)}:a instanceof RegExp?function(b){return a.test(b)}:a}function e(d,e){function f(a,d){var i,j=a.href;if(j=b(j),j&&e(j,d)&&!c(j)){h(a.imports,function(a){f(a,!0)});try{i=a.cssRules||a.rules}catch(k){}h(i,function(a){a.styleSheet?f(a.styleSheet,!0):a.selectorText&&h(a.selectorText.split(","),function(a){g.push(tinymce.trim(a))})})}}var g=[],i={};h(a.contentCSS,function(a){i[a]=!0}),e||(e=function(a,b){return b||i[a]});try{h(d.styleSheets,function(a){f(a)})}catch(j){}return g}function f(b){var c,d=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(b);if(d){var e=d[1],f=d[2].substr(1).split(".").join(" "),g=tinymce.makeMap("a,img");return d[1]?(c={title:b},a.schema.getTextBlockElements()[e]?c.block=e:a.schema.getBlockElements()[e]||g[e.toLowerCase()]?c.selector=e:c.inline=e):d[2]&&(c={inline:"span",title:b.substr(1),classes:f}),a.settings.importcss_merge_classes!==!1?c.classes=f:c.attributes={"class":f},c}}var g=this,h=tinymce.each;a.on("renderFormatsMenu",function(b){var c=a.settings,i={},j=c.importcss_selector_converter||f,k=d(c.importcss_selector_filter),l=b.control;a.settings.importcss_append||l.items().remove();var m=[];tinymce.each(c.importcss_groups,function(a){a=tinymce.extend({},a),a.filter=d(a.filter),m.push(a)}),h(e(b.doc||a.getDoc(),d(c.importcss_file_filter)),function(b){if(-1===b.indexOf(".mce-")&&!i[b]&&(!k||k(b))){var c,d=j.call(g,b);if(d){var e=d.name||tinymce.DOM.uniqueId();if(m)for(var f=0;f<m.length;f++)if(!m[f].filter||m[f].filter(b)){m[f].item||(m[f].item={text:m[f].title,menu:[]}),c=m[f].item.menu;break}a.formatter.register(e,d);var h=tinymce.extend({},l.settings.itemDefaults,{text:d.title,format:e});c?c.push(h):l.add(h)}i[b]=!0}}),h(m,function(a){l.add(a.item)}),b.control.renderNew()}),g.convertSelectorToFormat=f}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("insertdatetime",function(e){function t(t,n){function r(e,t){if(e=""+e,e.length<t)for(var n=0;n<t-e.length;n++)e="0"+e;return e}return n=n||new Date,t=t.replace("%D","%m/%d/%Y"),t=t.replace("%r","%I:%M:%S %p"),t=t.replace("%Y",""+n.getFullYear()),t=t.replace("%y",""+n.getYear()),t=t.replace("%m",r(n.getMonth()+1,2)),t=t.replace("%d",r(n.getDate(),2)),t=t.replace("%H",""+r(n.getHours(),2)),t=t.replace("%M",""+r(n.getMinutes(),2)),t=t.replace("%S",""+r(n.getSeconds(),2)),t=t.replace("%I",""+((n.getHours()+11)%12+1)),t=t.replace("%p",""+(n.getHours()<12?"AM":"PM")),t=t.replace("%B",""+e.translate(l[n.getMonth()])),t=t.replace("%b",""+e.translate(s[n.getMonth()])),t=t.replace("%A",""+e.translate(a[n.getDay()])),t=t.replace("%a",""+e.translate(o[n.getDay()])),t=t.replace("%%","%")}function n(n){var r=t(n);if(e.settings.insertdatetime_element){var i;i=t(/%[HMSIp]/.test(n)?"%Y-%m-%dT%H:%M":"%Y-%m-%d"),r='<time datetime="'+i+'">'+r+"</time>";var o=e.dom.getParent(e.selection.getStart(),"time");if(o)return void e.dom.setOuterHTML(o,r)}e.insertContent(r)}var r,i,o="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),a="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),s="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),l="January February March April May June July August September October November December".split(" "),c=[];e.addCommand("mceInsertDate",function(){n(e.getParam("insertdatetime_dateformat",e.translate("%Y-%m-%d")))}),e.addCommand("mceInsertTime",function(){n(e.getParam("insertdatetime_timeformat",e.translate("%H:%M:%S")))}),e.addButton("insertdatetime",{type:"splitbutton",title:"Insert date/time",onclick:function(){n(r||i)},menu:c}),tinymce.each(e.settings.insertdatetime_formats||["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"],function(e){i||(i=e),c.push({text:t(e),onclick:function(){r=e,n(e)}})}),e.addMenuItem("insertdatetime",{icon:"date",text:"Insert date/time",menu:c,context:"insert"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("insertdatetime",function(a){function b(b,c){function d(a,b){if(a=""+a,a.length<b)for(var c=0;c<b-a.length;c++)a="0"+a;return a}return c=c||new Date,b=b.replace("%D","%m/%d/%Y"),b=b.replace("%r","%I:%M:%S %p"),b=b.replace("%Y",""+c.getFullYear()),b=b.replace("%y",""+c.getYear()),b=b.replace("%m",d(c.getMonth()+1,2)),b=b.replace("%d",d(c.getDate(),2)),b=b.replace("%H",""+d(c.getHours(),2)),b=b.replace("%M",""+d(c.getMinutes(),2)),b=b.replace("%S",""+d(c.getSeconds(),2)),b=b.replace("%I",""+((c.getHours()+11)%12+1)),b=b.replace("%p",""+(c.getHours()<12?"AM":"PM")),b=b.replace("%B",""+a.translate(i[c.getMonth()])),b=b.replace("%b",""+a.translate(h[c.getMonth()])),b=b.replace("%A",""+a.translate(g[c.getDay()])),b=b.replace("%a",""+a.translate(f[c.getDay()])),b=b.replace("%%","%")}function c(c){var d=b(c);if(a.settings.insertdatetime_element){var e;e=b(/%[HMSIp]/.test(c)?"%Y-%m-%dT%H:%M":"%Y-%m-%d"),d='<time datetime="'+e+'">'+d+"</time>";var f=a.dom.getParent(a.selection.getStart(),"time");if(f)return void a.dom.setOuterHTML(f,d)}a.insertContent(d)}var d,e,f="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),g="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),h="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),i="January February March April May June July August September October November December".split(" "),j=[];a.addCommand("mceInsertDate",function(){c(a.getParam("insertdatetime_dateformat",a.translate("%Y-%m-%d")))}),a.addCommand("mceInsertTime",function(){c(a.getParam("insertdatetime_timeformat",a.translate("%H:%M:%S")))}),a.addButton("insertdatetime",{type:"splitbutton",title:"Insert date/time",onclick:function(){c(d||e)},menu:j}),tinymce.each(a.settings.insertdatetime_formats||["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"],function(a){e||(e=a),j.push({text:b(a),onclick:function(){d=a,c(a)}})}),a.addMenuItem("insertdatetime",{icon:"date",text:"Insert date/time",menu:j,context:"insert"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("layer",function(e){function t(e){do if(e.className&&-1!=e.className.indexOf("mceItemLayer"))return e;while(e=e.parentNode)}function n(t){var n=e.dom;tinymce.each(n.select("div,p",t),function(e){/^(absolute|relative|fixed)$/i.test(e.style.position)&&(e.hasVisual?n.addClass(e,"mceItemVisualAid"):n.removeClass(e,"mceItemVisualAid"),n.addClass(e,"mceItemLayer"))})}function r(n){var r,i,o=[],a=t(e.selection.getNode()),s=-1,l=-1;for(i=[],tinymce.walk(e.getBody(),function(e){1==e.nodeType&&/^(absolute|relative|static)$/i.test(e.style.position)&&i.push(e)},"childNodes"),r=0;r<i.length;r++)o[r]=i[r].style.zIndex?parseInt(i[r].style.zIndex,10):0,0>s&&i[r]==a&&(s=r);if(0>n){for(r=0;r<o.length;r++)if(o[r]<o[s]){l=r;break}l>-1?(i[s].style.zIndex=o[l],i[l].style.zIndex=o[s]):o[s]>0&&(i[s].style.zIndex=o[s]-1)}else{for(r=0;r<o.length;r++)if(o[r]>o[s]){l=r;break}l>-1?(i[s].style.zIndex=o[l],i[l].style.zIndex=o[s]):i[s].style.zIndex=o[s]+1}e.execCommand("mceRepaint")}function i(){var t=e.dom,n=t.getPos(t.getParent(e.selection.getNode(),"*")),r=e.getBody();e.dom.add(r,"div",{style:{position:"absolute",left:n.x,top:n.y>20?n.y:20,width:100,height:100},"class":"mceItemVisualAid mceItemLayer"},e.selection.getContent()||e.getLang("layer.content")),tinymce.Env.ie&&t.setHTML(r,r.innerHTML)}function o(){var n=t(e.selection.getNode());n||(n=e.dom.getParent(e.selection.getNode(),"DIV,P,IMG")),n&&("absolute"==n.style.position.toLowerCase()?(e.dom.setStyles(n,{position:"",left:"",top:"",width:"",height:""}),e.dom.removeClass(n,"mceItemVisualAid"),e.dom.removeClass(n,"mceItemLayer")):(n.style.left||(n.style.left="20px"),n.style.top||(n.style.top="20px"),n.style.width||(n.style.width=n.width?n.width+"px":"100px"),n.style.height||(n.style.height=n.height?n.height+"px":"100px"),n.style.position="absolute",e.dom.setAttrib(n,"data-mce-style",""),e.addVisual(e.getBody())),e.execCommand("mceRepaint"),e.nodeChanged())}e.addCommand("mceInsertLayer",i),e.addCommand("mceMoveForward",function(){r(1)}),e.addCommand("mceMoveBackward",function(){r(-1)}),e.addCommand("mceMakeAbsolute",function(){o()}),e.addButton("moveforward",{title:"layer.forward_desc",cmd:"mceMoveForward"}),e.addButton("movebackward",{title:"layer.backward_desc",cmd:"mceMoveBackward"}),e.addButton("absolute",{title:"layer.absolute_desc",cmd:"mceMakeAbsolute"}),e.addButton("insertlayer",{title:"layer.insertlayer_desc",cmd:"mceInsertLayer"}),e.on("init",function(){tinymce.Env.ie&&e.getDoc().execCommand("2D-Position",!1,!0)}),e.on("mouseup",function(n){var r=t(n.target);r&&e.dom.setAttrib(r,"data-mce-style","")}),e.on("mousedown",function(n){var r,i=n.target,o=e.getDoc();tinymce.Env.gecko&&(t(i)?"on"!==o.designMode&&(o.designMode="on",i=o.body,r=i.parentNode,r.removeChild(i),r.appendChild(i)):"on"==o.designMode&&(o.designMode="off"))}),e.on("NodeChange",n)}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("layer",function(a){function b(a){do if(a.className&&-1!=a.className.indexOf("mceItemLayer"))return a;while(a=a.parentNode)}function c(b){var c=a.dom;tinymce.each(c.select("div,p",b),function(a){/^(absolute|relative|fixed)$/i.test(a.style.position)&&(a.hasVisual?c.addClass(a,"mceItemVisualAid"):c.removeClass(a,"mceItemVisualAid"),c.addClass(a,"mceItemLayer"))})}function d(c){var d,e,f=[],g=b(a.selection.getNode()),h=-1,i=-1;for(e=[],tinymce.walk(a.getBody(),function(a){1==a.nodeType&&/^(absolute|relative|static)$/i.test(a.style.position)&&e.push(a)},"childNodes"),d=0;d<e.length;d++)f[d]=e[d].style.zIndex?parseInt(e[d].style.zIndex,10):0,0>h&&e[d]==g&&(h=d);if(0>c){for(d=0;d<f.length;d++)if(f[d]<f[h]){i=d;break}i>-1?(e[h].style.zIndex=f[i],e[i].style.zIndex=f[h]):f[h]>0&&(e[h].style.zIndex=f[h]-1)}else{for(d=0;d<f.length;d++)if(f[d]>f[h]){i=d;break}i>-1?(e[h].style.zIndex=f[i],e[i].style.zIndex=f[h]):e[h].style.zIndex=f[h]+1}a.execCommand("mceRepaint")}function e(){var b=a.dom,c=b.getPos(b.getParent(a.selection.getNode(),"*")),d=a.getBody();a.dom.add(d,"div",{style:{position:"absolute",left:c.x,top:c.y>20?c.y:20,width:100,height:100},"class":"mceItemVisualAid mceItemLayer"},a.selection.getContent()||a.getLang("layer.content")),tinymce.Env.ie&&b.setHTML(d,d.innerHTML)}function f(){var c=b(a.selection.getNode());c||(c=a.dom.getParent(a.selection.getNode(),"DIV,P,IMG")),c&&("absolute"==c.style.position.toLowerCase()?(a.dom.setStyles(c,{position:"",left:"",top:"",width:"",height:""}),a.dom.removeClass(c,"mceItemVisualAid"),a.dom.removeClass(c,"mceItemLayer")):(c.style.left||(c.style.left="20px"),c.style.top||(c.style.top="20px"),c.style.width||(c.style.width=c.width?c.width+"px":"100px"),c.style.height||(c.style.height=c.height?c.height+"px":"100px"),c.style.position="absolute",a.dom.setAttrib(c,"data-mce-style",""),a.addVisual(a.getBody())),a.execCommand("mceRepaint"),a.nodeChanged())}a.addCommand("mceInsertLayer",e),a.addCommand("mceMoveForward",function(){d(1)}),a.addCommand("mceMoveBackward",function(){d(-1)}),a.addCommand("mceMakeAbsolute",function(){f()}),a.addButton("moveforward",{title:"layer.forward_desc",cmd:"mceMoveForward"}),a.addButton("movebackward",{title:"layer.backward_desc",cmd:"mceMoveBackward"}),a.addButton("absolute",{title:"layer.absolute_desc",cmd:"mceMakeAbsolute"}),a.addButton("insertlayer",{title:"layer.insertlayer_desc",cmd:"mceInsertLayer"}),a.on("init",function(){tinymce.Env.ie&&a.getDoc().execCommand("2D-Position",!1,!0)}),a.on("mouseup",function(c){var d=b(c.target);d&&a.dom.setAttrib(d,"data-mce-style","")}),a.on("mousedown",function(c){var d,e=c.target,f=a.getDoc();tinymce.Env.gecko&&(b(e)?"on"!==f.designMode&&(f.designMode="on",e=f.body,d=e.parentNode,d.removeChild(e),d.appendChild(e)):"on"==f.designMode&&(f.designMode="off"))}),a.on("NodeChange",c)}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -!function(e){e.on("AddEditor",function(e){e.editor.settings.inline_styles=!1}),e.PluginManager.add("legacyoutput",function(t,n,r){t.on("init",function(){var n="p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",r=e.explode(t.settings.font_size_style_values),i=t.schema;t.formatter.register({alignleft:{selector:n,attributes:{align:"left"}},aligncenter:{selector:n,attributes:{align:"center"}},alignright:{selector:n,attributes:{align:"right"}},alignjustify:{selector:n,attributes:{align:"justify"}},bold:[{inline:"b",remove:"all"},{inline:"strong",remove:"all"},{inline:"span",styles:{fontWeight:"bold"}}],italic:[{inline:"i",remove:"all"},{inline:"em",remove:"all"},{inline:"span",styles:{fontStyle:"italic"}}],underline:[{inline:"u",remove:"all"},{inline:"span",styles:{textDecoration:"underline"},exact:!0}],strikethrough:[{inline:"strike",remove:"all"},{inline:"span",styles:{textDecoration:"line-through"},exact:!0}],fontname:{inline:"font",attributes:{face:"%value"}},fontsize:{inline:"font",attributes:{size:function(t){return e.inArray(r,t.value)+1}}},forecolor:{inline:"font",attributes:{color:"%value"}},hilitecolor:{inline:"font",styles:{backgroundColor:"%value"}}}),e.each("b,i,u,strike".split(","),function(e){i.addValidElements(e+"[*]")}),i.getElementRule("font")||i.addValidElements("font[face|size|color|style]"),e.each(n.split(","),function(e){var t=i.getElementRule(e);t&&(t.attributes.align||(t.attributes.align={},t.attributesOrder.push("align")))})}),t.addButton("fontsizeselect",function(){var e=[],n="8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7",r=t.settings.fontsize_formats||n;return t.$.each(r.split(" "),function(t,n){var r=n,i=n,o=n.split("=");o.length>1&&(r=o[0],i=o[1]),e.push({text:r,value:i})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:e,fixedWidth:!0,onPostRender:function(){var e=this;t.on("NodeChange",function(){var n;n=t.dom.getParent(t.selection.getNode(),"font"),n?e.value(n.size):e.value("")})},onclick:function(e){e.control.settings.value&&t.execCommand("FontSize",!1,e.control.settings.value)}}}),t.addButton("fontselect",function(){function e(e){e=e.replace(/;$/,"").split(";");for(var t=e.length;t--;)e[t]=e[t].split("=");return e}var n="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",i=[],o=e(t.settings.font_formats||n);return r.each(o,function(e,t){i.push({text:{raw:t[0]},value:t[1],textStyle:-1==t[1].indexOf("dings")?"font-family:"+t[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:i,fixedWidth:!0,onPostRender:function(){var e=this;t.on("NodeChange",function(){var n;n=t.dom.getParent(t.selection.getNode(),"font"),n?e.value(n.face):e.value("")})},onselect:function(e){e.control.settings.value&&t.execCommand("FontName",!1,e.control.settings.value)}}})})}(tinymce); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +!function(a){a.on("AddEditor",function(a){a.editor.settings.inline_styles=!1}),a.PluginManager.add("legacyoutput",function(b,c,d){b.on("init",function(){var c="p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",d=a.explode(b.settings.font_size_style_values),e=b.schema;b.formatter.register({alignleft:{selector:c,attributes:{align:"left"}},aligncenter:{selector:c,attributes:{align:"center"}},alignright:{selector:c,attributes:{align:"right"}},alignjustify:{selector:c,attributes:{align:"justify"}},bold:[{inline:"b",remove:"all"},{inline:"strong",remove:"all"},{inline:"span",styles:{fontWeight:"bold"}}],italic:[{inline:"i",remove:"all"},{inline:"em",remove:"all"},{inline:"span",styles:{fontStyle:"italic"}}],underline:[{inline:"u",remove:"all"},{inline:"span",styles:{textDecoration:"underline"},exact:!0}],strikethrough:[{inline:"strike",remove:"all"},{inline:"span",styles:{textDecoration:"line-through"},exact:!0}],fontname:{inline:"font",attributes:{face:"%value"}},fontsize:{inline:"font",attributes:{size:function(b){return a.inArray(d,b.value)+1}}},forecolor:{inline:"font",attributes:{color:"%value"}},hilitecolor:{inline:"font",styles:{backgroundColor:"%value"}}}),a.each("b,i,u,strike".split(","),function(a){e.addValidElements(a+"[*]")}),e.getElementRule("font")||e.addValidElements("font[face|size|color|style]"),a.each(c.split(","),function(a){var b=e.getElementRule(a);b&&(b.attributes.align||(b.attributes.align={},b.attributesOrder.push("align")))})}),b.addButton("fontsizeselect",function(){var a=[],c="8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7",d=b.settings.fontsize_formats||c;return b.$.each(d.split(" "),function(b,c){var d=c,e=c,f=c.split("=");f.length>1&&(d=f[0],e=f[1]),a.push({text:d,value:e})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:a,fixedWidth:!0,onPostRender:function(){var a=this;b.on("NodeChange",function(){var c;c=b.dom.getParent(b.selection.getNode(),"font"),c?a.value(c.size):a.value("")})},onclick:function(a){a.control.settings.value&&b.execCommand("FontSize",!1,a.control.settings.value)}}}),b.addButton("fontselect",function(){function a(a){a=a.replace(/;$/,"").split(";");for(var b=a.length;b--;)a[b]=a[b].split("=");return a}var c="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",e=[],f=a(b.settings.font_formats||c);return d.each(f,function(a,b){e.push({text:{raw:b[0]},value:b[1],textStyle:-1==b[1].indexOf("dings")?"font-family:"+b[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:e,fixedWidth:!0,onPostRender:function(){var a=this;b.on("NodeChange",function(){var c;c=b.dom.getParent(b.selection.getNode(),"font"),c?a.value(c.face):a.value("")})},onselect:function(a){a.control.settings.value&&b.execCommand("FontName",!1,a.control.settings.value)}}})})}(tinymce); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("link",function(e){function t(t){return function(){var n=e.settings.link_list;"string"==typeof n?tinymce.util.XHR.send({url:n,success:function(e){t(tinymce.util.JSON.parse(e))}}):"function"==typeof n?n(t):t(n)}}function n(e,t,n){function r(e,n){return n=n||[],tinymce.each(e,function(e){var i={text:e.text||e.title};e.menu?i.menu=r(e.menu):(i.value=e.value,t&&t(i)),n.push(i)}),n}return r(e,n||[])}function r(t){function r(e){var t=d.find("#text");(!t.value()||e.lastControl&&t.value()==e.lastControl.text())&&t.value(e.control.text()),d.find("#href").value(e.control.value())}function i(t){var n=[];return tinymce.each(e.dom.select("a:not([href])"),function(e){var r=e.name||e.id;r&&n.push({text:r,value:"#"+r,selected:-1!=t.indexOf("#"+r)})}),n.length?(n.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:n,onselect:r}):void 0}function o(){!u&&0===x.text.length&&f&&this.parent().parent().find("#text")[0].value(this.value())}function a(t){var n=t.meta||{};m&&m.value(e.convertURL(this.value(),"href")),tinymce.each(t.meta,function(e,t){d.find("#"+t).value(e)}),n.text||o.call(this)}function s(e){var t=C.getContent();if(/</.test(t)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(t)||-1==t.indexOf("href=")))return!1;if(e){var n,r=e.childNodes;if(0===r.length)return!1;for(n=r.length-1;n>=0;n--)if(3!=r[n].nodeType)return!1}return!0}var l,c,u,d,f,p,m,h,g,v,y,b,x={},C=e.selection,w=e.dom;l=C.getNode(),c=w.getParent(l,"a[href]"),f=s(),x.text=u=c?c.innerText||c.textContent:C.getContent({format:"text"}),x.href=c?w.getAttrib(c,"href"):"",c?x.target=w.getAttrib(c,"target"):e.settings.default_link_target&&(x.target=e.settings.default_link_target),(b=w.getAttrib(c,"rel"))&&(x.rel=b),(b=w.getAttrib(c,"class"))&&(x["class"]=b),(b=w.getAttrib(c,"title"))&&(x.title=b),f&&(p={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){x.text=this.value()}}),t&&(m={type:"listbox",label:"Link list",values:n(t,function(t){t.value=e.convertURL(t.value||t.url,"href")},[{text:"None",value:""}]),onselect:r,value:e.convertURL(x.href,"href"),onPostRender:function(){m=this}}),e.settings.target_list!==!1&&(e.settings.target_list||(e.settings.target_list=[{text:"None",value:""},{text:"New window",value:"_blank"}]),g={name:"target",type:"listbox",label:"Target",values:n(e.settings.target_list)}),e.settings.rel_list&&(h={name:"rel",type:"listbox",label:"Rel",values:n(e.settings.rel_list)}),e.settings.link_class_list&&(v={name:"class",type:"listbox",label:"Class",values:n(e.settings.link_class_list,function(t){t.value&&(t.textStyle=function(){return e.formatter.getCssText({inline:"a",classes:[t.value]})})})}),e.settings.link_title!==!1&&(y={name:"title",type:"textbox",label:"Title",value:x.title}),d=e.windowManager.open({title:"Insert link",data:x,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:a,onkeyup:o},p,y,i(x.href),m,h,g,v],onSubmit:function(t){function n(t,n){var r=e.selection.getRng();tinymce.util.Delay.setEditorTimeout(e,function(){e.windowManager.confirm(t,function(t){e.selection.setRng(r),n(t)})})}function r(){var t={href:i,target:x.target?x.target:null,rel:x.rel?x.rel:null,"class":x["class"]?x["class"]:null,title:x.title?x.title:null};c?(e.focus(),f&&x.text!=u&&("innerText"in c?c.innerText=x.text:c.textContent=x.text),w.setAttribs(c,t),C.select(c),e.undoManager.add()):f?e.insertContent(w.createHTML("a",t,w.encode(x.text))):e.execCommand("mceInsertLink",!1,t)}var i;return x=tinymce.extend(x,t.data),(i=x.href)?i.indexOf("@")>0&&-1==i.indexOf("//")&&-1==i.indexOf("mailto:")?void n("The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(e){e&&(i="mailto:"+i),r()}):e.settings.link_assume_external_targets&&!/^\w+:/i.test(i)||!e.settings.link_assume_external_targets&&/^\s*www[\.|\d\.]/i.test(i)?void n("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(e){e&&(i="http://"+i),r()}):void r():void e.execCommand("unlink")}})}e.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Meta+K",onclick:t(r),stateSelector:"a[href]"}),e.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",stateSelector:"a[href]"}),e.addShortcut("Meta+K","",t(r)),e.addCommand("mceLink",t(r)),this.showDialog=r,e.addMenuItem("link",{icon:"link",text:"Insert/edit link",shortcut:"Meta+K",onclick:t(r),stateSelector:"a[href]",context:"insert",prependToContext:!0})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("link",function(a){function b(b){return function(){var c=a.settings.link_list;"string"==typeof c?tinymce.util.XHR.send({url:c,success:function(a){b(tinymce.util.JSON.parse(a))}}):"function"==typeof c?c(b):b(c)}}function c(a,b,c){function d(a,c){return c=c||[],tinymce.each(a,function(a){var e={text:a.text||a.title};a.menu?e.menu=d(a.menu):(e.value=a.value,b&&b(e)),c.push(e)}),c}return d(a,c||[])}function d(b){function d(a){var b=l.find("#text");(!b.value()||a.lastControl&&b.value()==a.lastControl.text())&&b.value(a.control.text()),l.find("#href").value(a.control.value())}function e(b){var c=[];return tinymce.each(a.dom.select("a:not([href])"),function(a){var d=a.name||a.id;d&&c.push({text:d,value:"#"+d,selected:-1!=b.indexOf("#"+d)})}),c.length?(c.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:c,onselect:d}):void 0}function f(){!k&&0===u.text.length&&m&&this.parent().parent().find("#text")[0].value(this.value())}function g(b){var c=b.meta||{};o&&o.value(a.convertURL(this.value(),"href")),tinymce.each(b.meta,function(a,b){l.find("#"+b).value(a)}),c.text||f.call(this)}function h(a){var b=v.getContent();if(/</.test(b)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(b)||-1==b.indexOf("href=")))return!1;if(a){var c,d=a.childNodes;if(0===d.length)return!1;for(c=d.length-1;c>=0;c--)if(3!=d[c].nodeType)return!1}return!0}var i,j,k,l,m,n,o,p,q,r,s,t,u={},v=a.selection,w=a.dom;i=v.getNode(),j=w.getParent(i,"a[href]"),m=h(),u.text=k=j?j.innerText||j.textContent:v.getContent({format:"text"}),u.href=j?w.getAttrib(j,"href"):"",j?u.target=w.getAttrib(j,"target"):a.settings.default_link_target&&(u.target=a.settings.default_link_target),(t=w.getAttrib(j,"rel"))&&(u.rel=t),(t=w.getAttrib(j,"class"))&&(u["class"]=t),(t=w.getAttrib(j,"title"))&&(u.title=t),m&&(n={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){u.text=this.value()}}),b&&(o={type:"listbox",label:"Link list",values:c(b,function(b){b.value=a.convertURL(b.value||b.url,"href")},[{text:"None",value:""}]),onselect:d,value:a.convertURL(u.href,"href"),onPostRender:function(){o=this}}),a.settings.target_list!==!1&&(a.settings.target_list||(a.settings.target_list=[{text:"None",value:""},{text:"New window",value:"_blank"}]),q={name:"target",type:"listbox",label:"Target",values:c(a.settings.target_list)}),a.settings.rel_list&&(p={name:"rel",type:"listbox",label:"Rel",values:c(a.settings.rel_list)}),a.settings.link_class_list&&(r={name:"class",type:"listbox",label:"Class",values:c(a.settings.link_class_list,function(b){b.value&&(b.textStyle=function(){return a.formatter.getCssText({inline:"a",classes:[b.value]})})})}),a.settings.link_title!==!1&&(s={name:"title",type:"textbox",label:"Title",value:u.title}),l=a.windowManager.open({title:"Insert link",data:u,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:g,onkeyup:f},n,s,e(u.href),o,p,q,r],onSubmit:function(b){function c(b,c){var d=a.selection.getRng();tinymce.util.Delay.setEditorTimeout(a,function(){a.windowManager.confirm(b,function(b){a.selection.setRng(d),c(b)})})}function d(){var b={href:e,target:u.target?u.target:null,rel:u.rel?u.rel:null,"class":u["class"]?u["class"]:null,title:u.title?u.title:null};j?(a.focus(),m&&u.text!=k&&("innerText"in j?j.innerText=u.text:j.textContent=u.text),w.setAttribs(j,b),v.select(j),a.undoManager.add()):m?a.insertContent(w.createHTML("a",b,w.encode(u.text))):a.execCommand("mceInsertLink",!1,b)}var e;return u=tinymce.extend(u,b.data),(e=u.href)?e.indexOf("@")>0&&-1==e.indexOf("//")&&-1==e.indexOf("mailto:")?void c("The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(a){a&&(e="mailto:"+e),d()}):a.settings.link_assume_external_targets&&!/^\w+:/i.test(e)||!a.settings.link_assume_external_targets&&/^\s*www[\.|\d\.]/i.test(e)?void c("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(a){a&&(e="http://"+e),d()}):void d():void a.execCommand("unlink")}})}a.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Meta+K",onclick:b(d),stateSelector:"a[href]"}),a.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",stateSelector:"a[href]"}),a.addShortcut("Meta+K","",b(d)),a.addCommand("mceLink",b(d)),this.showDialog=d,a.addMenuItem("link",{icon:"link",text:"Insert/edit link",shortcut:"Meta+K",onclick:b(d),stateSelector:"a[href]",context:"insert",prependToContext:!0})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | -tinymce.PluginManager.add("nonbreaking",function(e){var t=e.getParam("nonbreaking_force_tab");if(e.addCommand("mceNonBreaking",function(){e.insertContent(e.plugins.visualchars&&e.plugins.visualchars.state?'<span class="mce-nbsp"> </span>':" "),e.dom.setAttrib(e.dom.select("span.mce-nbsp"),"data-mce-bogus","1")}),e.addButton("nonbreaking",{title:"Nonbreaking space",cmd:"mceNonBreaking"}),e.addMenuItem("nonbreaking",{text:"Nonbreaking space",cmd:"mceNonBreaking",context:"insert"}),t){var n=+t>1?+t:3;e.on("keydown",function(t){if(9==t.keyCode){if(t.shiftKey)return;t.preventDefault();for(var r=0;n>r;r++)e.execCommand("mceNonBreaking")}})}}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("nonbreaking",function(a){var b=a.getParam("nonbreaking_force_tab");if(a.addCommand("mceNonBreaking",function(){a.insertContent(a.plugins.visualchars&&a.plugins.visualchars.state?'<span class="mce-nbsp"> </span>':" "),a.dom.setAttrib(a.dom.select("span.mce-nbsp"),"data-mce-bogus","1")}),a.addButton("nonbreaking",{title:"Nonbreaking space",cmd:"mceNonBreaking"}),a.addMenuItem("nonbreaking",{text:"Nonbreaking space",cmd:"mceNonBreaking",context:"insert"}),b){var c=+b>1?+b:3;a.on("keydown",function(b){if(9==b.keyCode){if(b.shiftKey)return;b.preventDefault();for(var d=0;c>d;d++)a.execCommand("mceNonBreaking")}})}}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("noneditable",function(e){function t(e){return function(t){return-1!==(" "+t.attr("class")+" ").indexOf(e)}}function n(t){function n(t){var n=arguments,r=n[n.length-2];return r>0&&'"'==a.charAt(r-1)?t:'<span class="'+s+'" data-mce-content="'+e.dom.encode(n[0])+'">'+e.dom.encode("string"==typeof n[1]?n[1]:n[0])+"</span>"}var r=o.length,a=t.content,s=tinymce.trim(i);if("raw"!=t.format){for(;r--;)a=a.replace(o[r],n);t.content=a}}var r,i,o,a="contenteditable";r=" "+tinymce.trim(e.getParam("noneditable_editable_class","mceEditable"))+" ",i=" "+tinymce.trim(e.getParam("noneditable_noneditable_class","mceNonEditable"))+" ";var s=t(r),l=t(i);o=e.getParam("noneditable_regexp"),o&&!o.length&&(o=[o]),e.on("PreInit",function(){o&&e.on("BeforeSetContent",n),e.parser.addAttributeFilter("class",function(e){for(var t,n=e.length;n--;)t=e[n],s(t)?t.attr(a,"true"):l(t)&&t.attr(a,"false")}),e.serializer.addAttributeFilter(a,function(e){for(var t,n=e.length;n--;)t=e[n],(s(t)||l(t))&&(o&&t.attr("data-mce-content")?(t.name="#text",t.type=3,t.raw=!0,t.value=t.attr("data-mce-content")):t.attr(a,null))})})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("noneditable",function(a){function b(a){return function(b){return-1!==(" "+b.attr("class")+" ").indexOf(a)}}function c(b){function c(b){var c=arguments,d=c[c.length-2];return d>0&&'"'==g.charAt(d-1)?b:'<span class="'+h+'" data-mce-content="'+a.dom.encode(c[0])+'">'+a.dom.encode("string"==typeof c[1]?c[1]:c[0])+"</span>"}var d=f.length,g=b.content,h=tinymce.trim(e);if("raw"!=b.format){for(;d--;)g=g.replace(f[d],c);b.content=g}}var d,e,f,g="contenteditable";d=" "+tinymce.trim(a.getParam("noneditable_editable_class","mceEditable"))+" ",e=" "+tinymce.trim(a.getParam("noneditable_noneditable_class","mceNonEditable"))+" ";var h=b(d),i=b(e);f=a.getParam("noneditable_regexp"),f&&!f.length&&(f=[f]),a.on("PreInit",function(){f&&a.on("BeforeSetContent",c),a.parser.addAttributeFilter("class",function(a){for(var b,c=a.length;c--;)b=a[c],h(b)?b.attr(g,"true"):i(b)&&b.attr(g,"false")}),a.serializer.addAttributeFilter(g,function(a){for(var b,c=a.length;c--;)b=a[c],(h(b)||i(b))&&(f&&b.attr("data-mce-content")?(b.name="#text",b.type=3,b.raw=!0,b.value=b.attr("data-mce-content")):b.attr(g,null))})})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("pagebreak",function(e){var t="mce-pagebreak",n=e.getParam("pagebreak_separator","<!-- pagebreak -->"),r=new RegExp(n.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,function(e){return"\\"+e}),"gi"),i='<img src="'+tinymce.Env.transparentSrc+'" class="'+t+'" data-mce-resize="false" data-mce-placeholder />';e.addCommand("mcePageBreak",function(){e.settings.pagebreak_split_block?e.insertContent("<p>"+i+"</p>"):e.insertContent(i)}),e.addButton("pagebreak",{title:"Page break",cmd:"mcePageBreak"}),e.addMenuItem("pagebreak",{text:"Page break",icon:"pagebreak",cmd:"mcePageBreak",context:"insert"}),e.on("ResolveName",function(n){"IMG"==n.target.nodeName&&e.dom.hasClass(n.target,t)&&(n.name="pagebreak")}),e.on("click",function(n){n=n.target,"IMG"===n.nodeName&&e.dom.hasClass(n,t)&&e.selection.select(n)}),e.on("BeforeSetContent",function(e){e.content=e.content.replace(r,i)}),e.on("PreInit",function(){e.serializer.addNodeFilter("img",function(t){for(var r,i,o=t.length;o--;)if(r=t[o],i=r.attr("class"),i&&-1!==i.indexOf("mce-pagebreak")){var a=r.parent;if(e.schema.getBlockElements()[a.name]&&e.settings.pagebreak_split_block){a.type=3,a.value=n,a.raw=!0,r.remove();continue}r.type=3,r.value=n,r.raw=!0}})})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("pagebreak",function(a){var b="mce-pagebreak",c=a.getParam("pagebreak_separator","<!-- pagebreak -->"),d=new RegExp(c.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,function(a){return"\\"+a}),"gi"),e='<img src="'+tinymce.Env.transparentSrc+'" class="'+b+'" data-mce-resize="false" data-mce-placeholder />';a.addCommand("mcePageBreak",function(){a.settings.pagebreak_split_block?a.insertContent("<p>"+e+"</p>"):a.insertContent(e)}),a.addButton("pagebreak",{title:"Page break",cmd:"mcePageBreak"}),a.addMenuItem("pagebreak",{text:"Page break",icon:"pagebreak",cmd:"mcePageBreak",context:"insert"}),a.on("ResolveName",function(c){"IMG"==c.target.nodeName&&a.dom.hasClass(c.target,b)&&(c.name="pagebreak")}),a.on("click",function(c){c=c.target,"IMG"===c.nodeName&&a.dom.hasClass(c,b)&&a.selection.select(c)}),a.on("BeforeSetContent",function(a){a.content=a.content.replace(d,e)}),a.on("PreInit",function(){a.serializer.addNodeFilter("img",function(b){for(var d,e,f=b.length;f--;)if(d=b[f],e=d.attr("class"),e&&-1!==e.indexOf("mce-pagebreak")){var g=d.parent;if(a.schema.getBlockElements()[g.name]&&a.settings.pagebreak_split_block){g.type=3,g.value=c,g.raw=!0,d.remove();continue}d.type=3,d.value=c,d.raw=!0}})})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
| 1 | -tinymce.PluginManager.add("preview",function(e){var t=e.settings,n=!tinymce.Env.ie;e.addCommand("mcePreview",function(){e.windowManager.open({title:"Preview",width:parseInt(e.getParam("plugin_preview_width","650"),10),height:parseInt(e.getParam("plugin_preview_height","500"),10),html:'<iframe src="javascript:\'\'" frameborder="0"'+(n?' sandbox="allow-scripts"':"")+"></iframe>",buttons:{text:"Close",onclick:function(){this.parent().parent().close()}},onPostRender:function(){var r,i="";i+='<base href="'+e.documentBaseURI.getURI()+'">',tinymce.each(e.contentCSS,function(t){i+='<link type="text/css" rel="stylesheet" href="'+e.documentBaseURI.toAbsolute(t)+'">'});var o=t.body_id||"tinymce";-1!=o.indexOf("=")&&(o=e.getParam("body_id","","hash"),o=o[e.id]||o);var a=t.body_class||"";-1!=a.indexOf("=")&&(a=e.getParam("body_class","","hash"),a=a[e.id]||"");var s=e.settings.directionality?' dir="'+e.settings.directionality+'"':"";if(r="<!DOCTYPE html><html><head>"+i+'</head><body id="'+o+'" class="mce-content-body '+a+'"'+s+">"+e.getContent()+"</body></html>",n)this.getEl("body").firstChild.src="data:text/html;charset=utf-8,"+encodeURIComponent(r);else{var l=this.getEl("body").firstChild.contentWindow.document;l.open(),l.write(r),l.close()}}})}),e.addButton("preview",{title:"Preview",cmd:"mcePreview"}),e.addMenuItem("preview",{text:"Preview",cmd:"mcePreview",context:"view"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("preview",function(a){var b=a.settings,c=!tinymce.Env.ie;a.addCommand("mcePreview",function(){a.windowManager.open({title:"Preview",width:parseInt(a.getParam("plugin_preview_width","650"),10),height:parseInt(a.getParam("plugin_preview_height","500"),10),html:'<iframe src="javascript:\'\'" frameborder="0"'+(c?' sandbox="allow-scripts"':"")+"></iframe>",buttons:{text:"Close",onclick:function(){this.parent().parent().close()}},onPostRender:function(){var d,e="";e+='<base href="'+a.documentBaseURI.getURI()+'">',tinymce.each(a.contentCSS,function(b){e+='<link type="text/css" rel="stylesheet" href="'+a.documentBaseURI.toAbsolute(b)+'">'});var f=b.body_id||"tinymce";-1!=f.indexOf("=")&&(f=a.getParam("body_id","","hash"),f=f[a.id]||f);var g=b.body_class||"";-1!=g.indexOf("=")&&(g=a.getParam("body_class","","hash"),g=g[a.id]||"");var h=a.settings.directionality?' dir="'+a.settings.directionality+'"':"";if(d="<!DOCTYPE html><html><head>"+e+'</head><body id="'+f+'" class="mce-content-body '+g+'"'+h+">"+a.getContent()+"</body></html>",c)this.getEl("body").firstChild.src="data:text/html;charset=utf-8,"+encodeURIComponent(d);else{var i=this.getEl("body").firstChild.contentWindow.document;i.open(),i.write(d),i.close()}}})}),a.addButton("preview",{title:"Preview",cmd:"mcePreview"}),a.addMenuItem("preview",{text:"Preview",cmd:"mcePreview",context:"view"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("print",function(e){e.addCommand("mcePrint",function(){e.getWin().print()}),e.addButton("print",{title:"Print",cmd:"mcePrint"}),e.addShortcut("Meta+P","","mcePrint"),e.addMenuItem("print",{text:"Print",cmd:"mcePrint",icon:"print",shortcut:"Meta+P",context:"file"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("print",function(a){a.addCommand("mcePrint",function(){a.getWin().print()}),a.addButton("print",{title:"Print",cmd:"mcePrint"}),a.addShortcut("Meta+P","","mcePrint"),a.addMenuItem("print",{text:"Print",cmd:"mcePrint",icon:"print",shortcut:"Meta+P",context:"file"})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("save",function(e){function t(){var t;return t=tinymce.DOM.getParent(e.id,"form"),!e.getParam("save_enablewhendirty",!0)||e.isDirty()?(tinymce.triggerSave(),e.getParam("save_onsavecallback")?(e.execCallback("save_onsavecallback",e),void e.nodeChanged()):void(t?(e.setDirty(!1),(!t.onsubmit||t.onsubmit())&&("function"==typeof t.submit?t.submit():n(e.translate("Error: Form submit field collision."))),e.nodeChanged()):n(e.translate("Error: No form element found.")))):void 0}function n(t){e.notificationManager.open({text:t,type:"error"})}function r(){var t=tinymce.trim(e.startContent);return e.getParam("save_oncancelcallback")?void e.execCallback("save_oncancelcallback",e):(e.setContent(t),e.undoManager.clear(),void e.nodeChanged())}function i(){var t=this;e.on("nodeChange dirty",function(){t.disabled(e.getParam("save_enablewhendirty",!0)&&!e.isDirty())})}e.addCommand("mceSave",t),e.addCommand("mceCancel",r),e.addButton("save",{icon:"save",text:"Save",cmd:"mceSave",disabled:!0,onPostRender:i}),e.addButton("cancel",{text:"Cancel",icon:!1,cmd:"mceCancel",disabled:!0,onPostRender:i}),e.addShortcut("Meta+S","","mceSave")}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("save",function(a){function b(){var b;return b=tinymce.DOM.getParent(a.id,"form"),!a.getParam("save_enablewhendirty",!0)||a.isDirty()?(tinymce.triggerSave(),a.getParam("save_onsavecallback")?(a.execCallback("save_onsavecallback",a),void a.nodeChanged()):void(b?(a.setDirty(!1),b.onsubmit&&!b.onsubmit()||("function"==typeof b.submit?b.submit():c(a.translate("Error: Form submit field collision."))),a.nodeChanged()):c(a.translate("Error: No form element found.")))):void 0}function c(b){a.notificationManager.open({text:b,type:"error"})}function d(){var b=tinymce.trim(a.startContent);return a.getParam("save_oncancelcallback")?void a.execCallback("save_oncancelcallback",a):(a.setContent(b),a.undoManager.clear(),void a.nodeChanged())}function e(){var b=this;a.on("nodeChange dirty",function(){b.disabled(a.getParam("save_enablewhendirty",!0)&&!a.isDirty())})}a.addCommand("mceSave",b),a.addCommand("mceCancel",d),a.addButton("save",{icon:"save",text:"Save",cmd:"mceSave",disabled:!0,onPostRender:e}),a.addButton("cancel",{text:"Cancel",icon:!1,cmd:"mceCancel",disabled:!0,onPostRender:e}),a.addShortcut("Meta+S","","mceSave")}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | -tinymce.PluginManager.add("tabfocus",function(e){function t(e){9!==e.keyCode||e.ctrlKey||e.altKey||e.metaKey||e.preventDefault()}function n(t){function n(n){function o(e){return"BODY"===e.nodeName||"hidden"!=e.type&&"none"!=e.style.display&&"hidden"!=e.style.visibility&&o(e.parentNode)}function l(e){return/INPUT|TEXTAREA|BUTTON/.test(e.tagName)&&tinymce.get(t.id)&&-1!=e.tabIndex&&o(e)}if(s=r.select(":input:enabled,*[tabindex]:not(iframe)"),i(s,function(t,n){return t.id==e.id?(a=n,!1):void 0}),n>0){for(c=a+1;c<s.length;c++)if(l(s[c]))return s[c]}else for(c=a-1;c>=0;c--)if(l(s[c]))return s[c];return null}var a,s,l,c;if(!(9!==t.keyCode||t.ctrlKey||t.altKey||t.metaKey||t.isDefaultPrevented())&&(l=o(e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))),1==l.length&&(l[1]=l[0],l[0]=":prev"),s=t.shiftKey?":prev"==l[0]?n(-1):r.get(l[0]):":next"==l[1]?n(1):r.get(l[1]))){var u=tinymce.get(s.id||s.name);s.id&&u?u.focus():tinymce.util.Delay.setTimeout(function(){tinymce.Env.webkit||window.focus(),s.focus()},10),t.preventDefault()}}var r=tinymce.DOM,i=tinymce.each,o=tinymce.explode;e.on("init",function(){e.inline&&tinymce.DOM.setAttrib(e.getBody(),"tabIndex",null),e.on("keyup",t),tinymce.Env.gecko?e.on("keypress keydown",n):e.on("keydown",n)})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("tabfocus",function(a){function b(a){9!==a.keyCode||a.ctrlKey||a.altKey||a.metaKey||a.preventDefault()}function c(b){function c(c){function f(a){return"BODY"===a.nodeName||"hidden"!=a.type&&"none"!=a.style.display&&"hidden"!=a.style.visibility&&f(a.parentNode)}function i(a){return/INPUT|TEXTAREA|BUTTON/.test(a.tagName)&&tinymce.get(b.id)&&-1!=a.tabIndex&&f(a)}if(h=d.select(":input:enabled,*[tabindex]:not(iframe)"),e(h,function(b,c){return b.id==a.id?(g=c,!1):void 0}),c>0){for(j=g+1;j<h.length;j++)if(i(h[j]))return h[j]}else for(j=g-1;j>=0;j--)if(i(h[j]))return h[j];return null}var g,h,i,j;if(!(9!==b.keyCode||b.ctrlKey||b.altKey||b.metaKey||b.isDefaultPrevented())&&(i=f(a.getParam("tab_focus",a.getParam("tabfocus_elements",":prev,:next"))),1==i.length&&(i[1]=i[0],i[0]=":prev"),h=b.shiftKey?":prev"==i[0]?c(-1):d.get(i[0]):":next"==i[1]?c(1):d.get(i[1]))){var k=tinymce.get(h.id||h.name);h.id&&k?k.focus():tinymce.util.Delay.setTimeout(function(){tinymce.Env.webkit||window.focus(),h.focus()},10),b.preventDefault()}}var d=tinymce.DOM,e=tinymce.each,f=tinymce.explode;a.on("init",function(){a.inline&&tinymce.DOM.setAttrib(a.getBody(),"tabIndex",null),a.on("keyup",b),tinymce.Env.gecko?a.on("keypress keydown",c):a.on("keydown",c)})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
| 1 | -tinymce.PluginManager.add("template",function(e){function t(t){return function(){var n=e.settings.templates;"string"==typeof n?tinymce.util.XHR.send({url:n,success:function(e){t(tinymce.util.JSON.parse(e))}}):t(n)}}function n(t){function n(t){function n(t){if(-1==t.indexOf("<html>")){var n="";tinymce.each(e.contentCSS,function(t){n+='<link type="text/css" rel="stylesheet" href="'+e.documentBaseURI.toAbsolute(t)+'">'}),t="<!DOCTYPE html><html><head>"+n+"</head><body>"+t+"</body></html>"}t=o(t,"template_preview_replace_values");var i=r.find("iframe")[0].getEl().contentWindow.document;i.open(),i.write(t),i.close()}var a=t.control.value();a.url?tinymce.util.XHR.send({url:a.url,success:function(e){i=e,n(i)}}):(i=a.content,n(i)),r.find("#description")[0].text(t.control.value().description)}var r,i,s=[];if(!t||0===t.length){var l=e.translate("No templates defined.");return void e.notificationManager.open({text:l,type:"info"})}tinymce.each(t,function(e){s.push({selected:!s.length,text:e.title,value:{url:e.url,content:e.content,description:e.description}})}),r=e.windowManager.open({title:"Insert template",layout:"flex",direction:"column",align:"stretch",padding:15,spacing:10,items:[{type:"form",flex:0,padding:0,items:[{type:"container",label:"Templates",items:{type:"listbox",label:"Templates",name:"template",values:s,onselect:n}}]},{type:"label",name:"description",label:"Description",text:"\xa0"},{type:"iframe",flex:1,border:1}],onsubmit:function(){a(!1,i)},width:e.getParam("template_popup_width",600),height:e.getParam("template_popup_height",500)}),r.find("listbox")[0].fire("select")}function r(t,n){function r(e,t){if(e=""+e,e.length<t)for(var n=0;n<t-e.length;n++)e="0"+e;return e}var i="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),o="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),a="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),s="January February March April May June July August September October November December".split(" ");return n=n||new Date,t=t.replace("%D","%m/%d/%Y"),t=t.replace("%r","%I:%M:%S %p"),t=t.replace("%Y",""+n.getFullYear()),t=t.replace("%y",""+n.getYear()),t=t.replace("%m",r(n.getMonth()+1,2)),t=t.replace("%d",r(n.getDate(),2)),t=t.replace("%H",""+r(n.getHours(),2)),t=t.replace("%M",""+r(n.getMinutes(),2)),t=t.replace("%S",""+r(n.getSeconds(),2)),t=t.replace("%I",""+((n.getHours()+11)%12+1)),t=t.replace("%p",""+(n.getHours()<12?"AM":"PM")),t=t.replace("%B",""+e.translate(s[n.getMonth()])),t=t.replace("%b",""+e.translate(a[n.getMonth()])),t=t.replace("%A",""+e.translate(o[n.getDay()])),t=t.replace("%a",""+e.translate(i[n.getDay()])),t=t.replace("%%","%")}function i(t){var n=e.dom,r=e.getParam("template_replace_values");s(n.select("*",t),function(e){s(r,function(t,i){n.hasClass(e,i)&&"function"==typeof r[i]&&r[i](e)})})}function o(t,n){return s(e.getParam(n),function(e,n){"function"==typeof e&&(e=e(n)),t=t.replace(new RegExp("\\{\\$"+n+"\\}","g"),e)}),t}function a(t,n){function a(e,t){return new RegExp("\\b"+t+"\\b","g").test(e.className)}var l,c,u=e.dom,d=e.selection.getContent();n=o(n,"template_replace_values"),l=u.create("div",null,n),c=u.select(".mceTmpl",l),c&&c.length>0&&(l=u.create("div",null),l.appendChild(c[0].cloneNode(!0))),s(u.select("*",l),function(t){a(t,e.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))&&(t.innerHTML=r(e.getParam("template_cdate_format",e.getLang("template.cdate_format")))),a(t,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(t.innerHTML=r(e.getParam("template_mdate_format",e.getLang("template.mdate_format")))),a(t,e.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))&&(t.innerHTML=d)}),i(l),e.execCommand("mceInsertContent",!1,l.innerHTML),e.addVisual()}var s=tinymce.each;e.addCommand("mceInsertTemplate",a),e.addButton("template",{title:"Insert template",onclick:t(n)}),e.addMenuItem("template",{text:"Insert template",onclick:t(n),context:"insert"}),e.on("PreProcess",function(t){var n=e.dom;s(n.select("div",t.node),function(t){n.hasClass(t,"mceTmpl")&&(s(n.select("*",t),function(t){n.hasClass(t,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(t.innerHTML=r(e.getParam("template_mdate_format",e.getLang("template.mdate_format"))))}),i(t))})})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("template",function(a){function b(b){return function(){var c=a.settings.templates;return"function"==typeof c?void c(b):void("string"==typeof c?tinymce.util.XHR.send({url:c,success:function(a){b(tinymce.util.JSON.parse(a))}}):b(c))}}function c(b){function c(b){function c(b){if(-1==b.indexOf("<html>")){var c="";tinymce.each(a.contentCSS,function(b){c+='<link type="text/css" rel="stylesheet" href="'+a.documentBaseURI.toAbsolute(b)+'">'}),b="<!DOCTYPE html><html><head>"+c+"</head><body>"+b+"</body></html>"}b=f(b,"template_preview_replace_values");var e=d.find("iframe")[0].getEl().contentWindow.document;e.open(),e.write(b),e.close()}var g=b.control.value();g.url?tinymce.util.XHR.send({url:g.url,success:function(a){e=a,c(e)}}):(e=g.content,c(e)),d.find("#description")[0].text(b.control.value().description)}var d,e,h=[];if(!b||0===b.length){var i=a.translate("No templates defined.");return void a.notificationManager.open({text:i,type:"info"})}tinymce.each(b,function(a){h.push({selected:!h.length,text:a.title,value:{url:a.url,content:a.content,description:a.description}})}),d=a.windowManager.open({title:"Insert template",layout:"flex",direction:"column",align:"stretch",padding:15,spacing:10,items:[{type:"form",flex:0,padding:0,items:[{type:"container",label:"Templates",items:{type:"listbox",label:"Templates",name:"template",values:h,onselect:c}}]},{type:"label",name:"description",label:"Description",text:"\xa0"},{type:"iframe",flex:1,border:1}],onsubmit:function(){g(!1,e)},width:a.getParam("template_popup_width",600),height:a.getParam("template_popup_height",500)}),d.find("listbox")[0].fire("select")}function d(b,c){function d(a,b){if(a=""+a,a.length<b)for(var c=0;c<b-a.length;c++)a="0"+a;return a}var e="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),g="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),h="January February March April May June July August September October November December".split(" ");return c=c||new Date,b=b.replace("%D","%m/%d/%Y"),b=b.replace("%r","%I:%M:%S %p"),b=b.replace("%Y",""+c.getFullYear()),b=b.replace("%y",""+c.getYear()),b=b.replace("%m",d(c.getMonth()+1,2)),b=b.replace("%d",d(c.getDate(),2)),b=b.replace("%H",""+d(c.getHours(),2)),b=b.replace("%M",""+d(c.getMinutes(),2)),b=b.replace("%S",""+d(c.getSeconds(),2)),b=b.replace("%I",""+((c.getHours()+11)%12+1)),b=b.replace("%p",""+(c.getHours()<12?"AM":"PM")),b=b.replace("%B",""+a.translate(h[c.getMonth()])),b=b.replace("%b",""+a.translate(g[c.getMonth()])),b=b.replace("%A",""+a.translate(f[c.getDay()])),b=b.replace("%a",""+a.translate(e[c.getDay()])),b=b.replace("%%","%")}function e(b){var c=a.dom,d=a.getParam("template_replace_values");h(c.select("*",b),function(a){h(d,function(b,e){c.hasClass(a,e)&&"function"==typeof d[e]&&d[e](a)})})}function f(b,c){return h(a.getParam(c),function(a,c){"function"==typeof a&&(a=a(c)),b=b.replace(new RegExp("\\{\\$"+c+"\\}","g"),a)}),b}function g(b,c){function g(a,b){return new RegExp("\\b"+b+"\\b","g").test(a.className)}var i,j,k=a.dom,l=a.selection.getContent();c=f(c,"template_replace_values"),i=k.create("div",null,c),j=k.select(".mceTmpl",i),j&&j.length>0&&(i=k.create("div",null),i.appendChild(j[0].cloneNode(!0))),h(k.select("*",i),function(b){g(b,a.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))&&(b.innerHTML=d(a.getParam("template_cdate_format",a.getLang("template.cdate_format")))),g(b,a.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(b.innerHTML=d(a.getParam("template_mdate_format",a.getLang("template.mdate_format")))),g(b,a.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))&&(b.innerHTML=l)}),e(i),a.execCommand("mceInsertContent",!1,i.innerHTML),a.addVisual()}var h=tinymce.each;a.addCommand("mceInsertTemplate",g),a.addButton("template",{title:"Insert template",onclick:b(c)}),a.addMenuItem("template",{text:"Insert template",onclick:b(c),context:"insert"}),a.on("PreProcess",function(b){var c=a.dom;h(c.select("div",b.node),function(b){c.hasClass(b,"mceTmpl")&&(h(c.select("*",b),function(b){c.hasClass(b,a.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(b.innerHTML=d(a.getParam("template_mdate_format",a.getLang("template.mdate_format"))))}),e(b))})})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("textcolor",function(e){function t(t){var n;return e.dom.getParents(e.selection.getStart(),function(e){var r;(r=e.style["forecolor"==t?"color":"background-color"])&&(n=r)}),n}function n(){var t,n,r=[];for(n=e.settings.textcolor_map||["000000","Black","993300","Burnt orange","333300","Dark olive","003300","Dark green","003366","Dark azure","000080","Navy Blue","333399","Indigo","333333","Very dark gray","800000","Maroon","FF6600","Orange","808000","Olive","008000","Green","008080","Teal","0000FF","Blue","666699","Grayish blue","808080","Gray","FF0000","Red","FF9900","Amber","99CC00","Yellow green","339966","Sea green","33CCCC","Turquoise","3366FF","Royal blue","800080","Purple","999999","Medium gray","FF00FF","Magenta","FFCC00","Gold","FFFF00","Yellow","00FF00","Lime","00FFFF","Aqua","00CCFF","Sky blue","993366","Red violet","FFFFFF","White","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum"],t=0;t<n.length;t+=2)r.push({text:n[t+1],color:"#"+n[t]});return r}function r(){function t(e,t){var n="transparent"==e;return'<td class="mce-grid-cell'+(n?" mce-colorbtn-trans":"")+'"><div id="'+p+"-"+m++ +'" data-mce-color="'+(e?e:"")+'" role="option" tabIndex="-1" style="'+(e?"background-color: "+e:"")+'" title="'+tinymce.translate(t)+'">'+(n?"×":"")+"</div></td>"}var r,i,o,a,s,u,d,f=this,p=f._id,m=0;for(r=n(),r.push({text:tinymce.translate("No color"),color:"transparent"}),o='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',a=r.length-1,u=0;c>u;u++){for(o+="<tr>",s=0;l>s;s++)d=u*l+s,d>a?o+="<td></td>":(i=r[d],o+=t(i.color,i.text));o+="</tr>"}if(e.settings.color_picker_callback){for(o+='<tr><td colspan="'+l+'" class="mce-custom-color-btn"><div id="'+p+'-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" role="button" tabindex="-1" aria-labelledby="'+p+'-c" style="width: 100%"><button type="button" role="presentation" tabindex="-1">'+tinymce.translate("Custom...")+"</button></div></td></tr>",o+="<tr>",s=0;l>s;s++)o+=t("","Custom color");o+="</tr>"}return o+="</tbody></table>"}function i(t,n){e.undoManager.transact(function(){e.focus(),e.formatter.apply(t,{value:n}),e.nodeChanged()})}function o(t){e.undoManager.transact(function(){e.focus(),e.formatter.remove(t,{value:null},null,!0),e.nodeChanged()})}function a(n){function r(e){u.hidePanel(),u.color(e),i(u.settings.format,e)}function a(){u.hidePanel(),u.resetColor(),o(u.settings.format)}function s(e,t){e.style.background=t,e.setAttribute("data-mce-color",t)}var c,u=this.parent();tinymce.DOM.getParent(n.target,".mce-custom-color-btn")&&(u.hidePanel(),e.settings.color_picker_callback.call(e,function(e){var t,n,i,o=u.panel.getEl().getElementsByTagName("table")[0];for(t=tinymce.map(o.rows[o.rows.length-1].childNodes,function(e){return e.firstChild}),i=0;i<t.length&&(n=t[i],n.getAttribute("data-mce-color"));i++);if(i==l)for(i=0;l-1>i;i++)s(t[i],t[i+1].getAttribute("data-mce-color"));s(n,e),r(e)},t(u.settings.format))),c=n.target.getAttribute("data-mce-color"),c?(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),n.target.setAttribute("aria-selected",!0),this.lastId=n.target.id,"transparent"==c?a():r(c)):null!==c&&u.hidePanel()}function s(){var e=this;e._color?i(e.settings.format,e._color):o(e.settings.format)}var l,c;c=e.settings.textcolor_rows||5,l=e.settings.textcolor_cols||8,e.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{role:"application",ariaRemember:!0,html:r,onclick:a},onclick:s}),e.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{role:"application",ariaRemember:!0,html:r,onclick:a},onclick:s})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("textcolor",function(a){function b(b){var c;return a.dom.getParents(a.selection.getStart(),function(a){var d;(d=a.style["forecolor"==b?"color":"background-color"])&&(c=d)}),c}function c(){var b,c,d=[];for(c=a.settings.textcolor_map||["000000","Black","993300","Burnt orange","333300","Dark olive","003300","Dark green","003366","Dark azure","000080","Navy Blue","333399","Indigo","333333","Very dark gray","800000","Maroon","FF6600","Orange","808000","Olive","008000","Green","008080","Teal","0000FF","Blue","666699","Grayish blue","808080","Gray","FF0000","Red","FF9900","Amber","99CC00","Yellow green","339966","Sea green","33CCCC","Turquoise","3366FF","Royal blue","800080","Purple","999999","Medium gray","FF00FF","Magenta","FFCC00","Gold","FFFF00","Yellow","00FF00","Lime","00FFFF","Aqua","00CCFF","Sky blue","993366","Red violet","FFFFFF","White","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum"],b=0;b<c.length;b+=2)d.push({text:c[b+1],color:"#"+c[b]});return d}function d(){function b(a,b){var c="transparent"==a;return'<td class="mce-grid-cell'+(c?" mce-colorbtn-trans":"")+'"><div id="'+n+"-"+o++ +'" data-mce-color="'+(a?a:"")+'" role="option" tabIndex="-1" style="'+(a?"background-color: "+a:"")+'" title="'+tinymce.translate(b)+'">'+(c?"×":"")+"</div></td>"}var d,e,f,g,h,k,l,m=this,n=m._id,o=0;for(d=c(),d.push({text:tinymce.translate("No color"),color:"transparent"}),f='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',g=d.length-1,k=0;j>k;k++){for(f+="<tr>",h=0;i>h;h++)l=k*i+h,l>g?f+="<td></td>":(e=d[l],f+=b(e.color,e.text));f+="</tr>"}if(a.settings.color_picker_callback){for(f+='<tr><td colspan="'+i+'" class="mce-custom-color-btn"><div id="'+n+'-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" role="button" tabindex="-1" aria-labelledby="'+n+'-c" style="width: 100%"><button type="button" role="presentation" tabindex="-1">'+tinymce.translate("Custom...")+"</button></div></td></tr>",f+="<tr>",h=0;i>h;h++)f+=b("","Custom color");f+="</tr>"}return f+="</tbody></table>"}function e(b,c){a.undoManager.transact(function(){a.focus(),a.formatter.apply(b,{value:c}),a.nodeChanged()})}function f(b){a.undoManager.transact(function(){a.focus(),a.formatter.remove(b,{value:null},null,!0),a.nodeChanged()})}function g(c){function d(a){k.hidePanel(),k.color(a),e(k.settings.format,a)}function g(){k.hidePanel(),k.resetColor(),f(k.settings.format)}function h(a,b){a.style.background=b,a.setAttribute("data-mce-color",b)}var j,k=this.parent();tinymce.DOM.getParent(c.target,".mce-custom-color-btn")&&(k.hidePanel(),a.settings.color_picker_callback.call(a,function(a){var b,c,e,f=k.panel.getEl().getElementsByTagName("table")[0];for(b=tinymce.map(f.rows[f.rows.length-1].childNodes,function(a){return a.firstChild}),e=0;e<b.length&&(c=b[e],c.getAttribute("data-mce-color"));e++);if(e==i)for(e=0;i-1>e;e++)h(b[e],b[e+1].getAttribute("data-mce-color"));h(c,a),d(a)},b(k.settings.format))),j=c.target.getAttribute("data-mce-color"),j?(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),c.target.setAttribute("aria-selected",!0),this.lastId=c.target.id,"transparent"==j?g():d(j)):null!==j&&k.hidePanel()}function h(){var a=this;a._color?e(a.settings.format,a._color):f(a.settings.format)}var i,j;j=a.settings.textcolor_rows||5,i=a.settings.textcolor_cols||8,a.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h}),a.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("textpattern",function(e){function t(){return c&&(l.sort(function(e,t){return e.start.length>t.start.length?-1:e.start.length<t.start.length?1:0}),c=!1),l}function n(e){for(var n=t(),r=0;r<n.length;r++)if(0===e.indexOf(n[r].start)&&(!n[r].end||e.lastIndexOf(n[r].end)==e.length-n[r].end.length))return n[r]}function r(e,n,r){var i,o,a;for(i=t(),a=0;a<i.length;a++)if(o=i[a],o.end&&e.substr(n-o.end.length-r,o.end.length)==o.end)return o}function i(t){function i(){l=l.splitText(u),l.splitText(c-u-m),l.deleteData(0,p.start.length),l.deleteData(l.data.length-p.end.length,p.end.length)}var o,a,s,l,c,u,d,f,p,m,h;return o=e.selection,a=e.dom,o.isCollapsed()&&(s=o.getRng(!0),l=s.startContainer,c=s.startOffset,d=l.data,m=t?1:0,3==l.nodeType&&(p=r(d,c,m),p&&(u=Math.max(0,c-m),u=d.lastIndexOf(p.start,u-p.end.length-1),-1!==u&&(f=a.createRng(),f.setStart(l,u),f.setEnd(l,c-m),p=n(f.toString()),p&&p.end&&!(l.data.length<=p.start.length+p.end.length)))))?(h=e.formatter.get(p.format),h&&h[0].inline?(i(),e.formatter.apply(p.format,{},l),l):void 0):void 0}function o(){var t,r,i,o,a,s,l,c,u,d,f;if(t=e.selection,r=e.dom,t.isCollapsed()&&(l=r.getParent(t.getStart(),"p"))){for(u=new tinymce.dom.TreeWalker(l,l);a=u.next();)if(3==a.nodeType){o=a;break}if(o){if(c=n(o.data),!c)return;if(d=t.getRng(!0),i=d.startContainer,f=d.startOffset,o==i&&(f=Math.max(0,f-c.start.length)),tinymce.trim(o.data).length==c.start.length)return;c.format&&(s=e.formatter.get(c.format),s&&s[0].block&&(o.deleteData(0,c.start.length),e.formatter.apply(c.format,{},o),d.setStart(i,f),d.collapse(!0),t.setRng(d))),c.cmd&&e.undoManager.transact(function(){o.deleteData(0,c.start.length),e.execCommand(c.cmd)})}}}function a(){var t,n;n=i(),n&&(t=e.dom.createRng(),t.setStart(n,n.data.length),t.setEnd(n,n.data.length),e.selection.setRng(t)),o()}function s(){var t,n,r,o,a;t=i(!0),t&&(a=e.dom,n=t.data.slice(-1),/[\u00a0 ]/.test(n)&&(t.deleteData(t.data.length-1,1),r=a.doc.createTextNode(n),t.nextSibling?a.insertAfter(r,t.nextSibling):t.parentNode.appendChild(r),o=a.createRng(),o.setStart(r,1),o.setEnd(r,1),e.selection.setRng(o)))}var l,c=!0;l=e.settings.textpattern_patterns||[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}],e.on("keydown",function(e){13!=e.keyCode||tinymce.util.VK.modifierPressed(e)||a()},!0),e.on("keyup",function(e){32!=e.keyCode||tinymce.util.VK.modifierPressed(e)||s()}),this.getPatterns=t,this.setPatterns=function(e){l=e,c=!0}}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("textpattern",function(a){function b(){return j&&(i.sort(function(a,b){return a.start.length>b.start.length?-1:a.start.length<b.start.length?1:0}),j=!1),i}function c(a){for(var c=b(),d=0;d<c.length;d++)if(0===a.indexOf(c[d].start)&&(!c[d].end||a.lastIndexOf(c[d].end)==a.length-c[d].end.length))return c[d]}function d(a,c,d){var e,f,g;for(e=b(),g=0;g<e.length;g++)if(f=e[g],f.end&&a.substr(c-f.end.length-d,f.end.length)==f.end)return f}function e(b){function e(){i=i.splitText(k),i.splitText(j-k-o),i.deleteData(0,n.start.length),i.deleteData(i.data.length-n.end.length,n.end.length)}var f,g,h,i,j,k,l,m,n,o,p;return f=a.selection,g=a.dom,f.isCollapsed()&&(h=f.getRng(!0),i=h.startContainer,j=h.startOffset,l=i.data,o=b?1:0,3==i.nodeType&&(n=d(l,j,o),n&&(k=Math.max(0,j-o),k=l.lastIndexOf(n.start,k-n.end.length-1),-1!==k&&(m=g.createRng(),m.setStart(i,k),m.setEnd(i,j-o),n=c(m.toString()),n&&n.end&&!(i.data.length<=n.start.length+n.end.length)))))?(p=a.formatter.get(n.format),p&&p[0].inline?(e(),a.formatter.apply(n.format,{},i),i):void 0):void 0}function f(){var b,d,e,f,g,h,i,j,k,l,m;if(b=a.selection,d=a.dom,b.isCollapsed()&&(i=d.getParent(b.getStart(),"p"))){for(k=new tinymce.dom.TreeWalker(i,i);g=k.next();)if(3==g.nodeType){f=g;break}if(f){if(j=c(f.data),!j)return;if(l=b.getRng(!0),e=l.startContainer,m=l.startOffset,f==e&&(m=Math.max(0,m-j.start.length)),tinymce.trim(f.data).length==j.start.length)return;j.format&&(h=a.formatter.get(j.format),h&&h[0].block&&(f.deleteData(0,j.start.length),a.formatter.apply(j.format,{},f),l.setStart(e,m),l.collapse(!0),b.setRng(l))),j.cmd&&a.undoManager.transact(function(){f.deleteData(0,j.start.length),a.execCommand(j.cmd)})}}}function g(){var b,c;c=e(),c&&(b=a.dom.createRng(),b.setStart(c,c.data.length),b.setEnd(c,c.data.length),a.selection.setRng(b)),f()}function h(){var b,c,d,f,g;b=e(!0),b&&(g=a.dom,c=b.data.slice(-1),/[\u00a0 ]/.test(c)&&(b.deleteData(b.data.length-1,1),d=g.doc.createTextNode(c),b.nextSibling?g.insertAfter(d,b.nextSibling):b.parentNode.appendChild(d),f=g.createRng(),f.setStart(d,1),f.setEnd(d,1),a.selection.setRng(f)))}var i,j=!0;i=a.settings.textpattern_patterns||[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}],a.on("keydown",function(a){13!=a.keyCode||tinymce.util.VK.modifierPressed(a)||g()},!0),a.on("keyup",function(a){32!=a.keyCode||tinymce.util.VK.modifierPressed(a)||h()}),this.getPatterns=b,this.setPatterns=function(a){i=a,j=!0}}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -47,7 +47,7 @@ | ... | @@ -47,7 +47,7 @@ |
| 47 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8HybbxIoiuwjan04jep1iZ1XRlAo5bVgAAOw==); | 47 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8HybbxIoiuwjan04jep1iZ1XRlAo5bVgAAOw==); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | -.mce-visualblocks div { | 50 | +.mce-visualblocks div:not([data-mce-bogus]) { |
| 51 | padding-top: 10px; | 51 | padding-top: 10px; |
| 52 | border: 1px dashed #BBB; | 52 | border: 1px dashed #BBB; |
| 53 | margin-left: 3px; | 53 | margin-left: 3px; | ... | ... |
| 1 | -tinymce.PluginManager.add("visualblocks",function(e,t){function n(){var t=this;t.active(o),e.on("VisualBlocks",function(){t.active(e.dom.hasClass(e.getBody(),"mce-visualblocks"))})}var r,i,o;window.NodeList&&(e.addCommand("mceVisualBlocks",function(){var n,a=e.dom;r||(r=a.uniqueId(),n=a.create("link",{id:r,rel:"stylesheet",href:t+"/css/visualblocks.css"}),e.getDoc().getElementsByTagName("head")[0].appendChild(n)),e.on("PreviewFormats AfterPreviewFormats",function(t){o&&a.toggleClass(e.getBody(),"mce-visualblocks","afterpreviewformats"==t.type)}),a.toggleClass(e.getBody(),"mce-visualblocks"),o=e.dom.hasClass(e.getBody(),"mce-visualblocks"),i&&i.active(a.hasClass(e.getBody(),"mce-visualblocks")),e.fire("VisualBlocks")}),e.addButton("visualblocks",{title:"Show blocks",cmd:"mceVisualBlocks",onPostRender:n}),e.addMenuItem("visualblocks",{text:"Show blocks",cmd:"mceVisualBlocks",onPostRender:n,selectable:!0,context:"view",prependToContext:!0}),e.on("init",function(){e.settings.visualblocks_default_state&&e.execCommand("mceVisualBlocks",!1,null,{skip_focus:!0})}),e.on("remove",function(){e.dom.removeClass(e.getBody(),"mce-visualblocks")}))}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("visualblocks",function(a,b){function c(){var b=this;b.active(f),a.on("VisualBlocks",function(){b.active(a.dom.hasClass(a.getBody(),"mce-visualblocks"))})}var d,e,f;window.NodeList&&(a.addCommand("mceVisualBlocks",function(){var c,g=a.dom;d||(d=g.uniqueId(),c=g.create("link",{id:d,rel:"stylesheet",href:b+"/css/visualblocks.css"}),a.getDoc().getElementsByTagName("head")[0].appendChild(c)),a.on("PreviewFormats AfterPreviewFormats",function(b){f&&g.toggleClass(a.getBody(),"mce-visualblocks","afterpreviewformats"==b.type)}),g.toggleClass(a.getBody(),"mce-visualblocks"),f=a.dom.hasClass(a.getBody(),"mce-visualblocks"),e&&e.active(g.hasClass(a.getBody(),"mce-visualblocks")),a.fire("VisualBlocks")}),a.addButton("visualblocks",{title:"Show blocks",cmd:"mceVisualBlocks",onPostRender:c}),a.addMenuItem("visualblocks",{text:"Show blocks",cmd:"mceVisualBlocks",onPostRender:c,selectable:!0,context:"view",prependToContext:!0}),a.on("init",function(){a.settings.visualblocks_default_state&&a.execCommand("mceVisualBlocks",!1,null,{skip_focus:!0})}),a.on("remove",function(){a.dom.removeClass(a.getBody(),"mce-visualblocks")}))}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("visualchars",function(e){function t(t){function n(e){return'<span data-mce-bogus="1" class="mce-'+p[e]+'">'+e+"</span>"}function o(){var e,t="";for(e in p)t+=e;return new RegExp("["+t+"]","g")}function a(){var e,t="";for(e in p)t&&(t+=","),t+="span.mce-"+p[e];return t}var s,l,c,u,d,f,p,m,h=e.getBody(),g=e.selection;if(p={"\xa0":"nbsp","\xad":"shy"},r=!r,i.state=r,e.fire("VisualChars",{state:r}),m=o(),t&&(f=g.getBookmark()),r)for(l=[],tinymce.walk(h,function(e){3==e.nodeType&&e.nodeValue&&m.test(e.nodeValue)&&l.push(e)},"childNodes"),c=0;c<l.length;c++){for(u=l[c].nodeValue,u=u.replace(m,n),d=e.dom.create("div",null,u);s=d.lastChild;)e.dom.insertAfter(s,l[c]);e.dom.remove(l[c])}else for(l=e.dom.select(a(),h),c=l.length-1;c>=0;c--)e.dom.remove(l[c],1);g.moveToBookmark(f)}function n(){var t=this;e.on("VisualChars",function(e){t.active(e.state)})}var r,i=this;e.addCommand("mceVisualChars",t),e.addButton("visualchars",{title:"Show invisible characters",cmd:"mceVisualChars",onPostRender:n}),e.addMenuItem("visualchars",{text:"Show invisible characters",cmd:"mceVisualChars",onPostRender:n,selectable:!0,context:"view",prependToContext:!0}),e.on("beforegetcontent",function(e){r&&"raw"!=e.format&&!e.draft&&(r=!0,t(!1))})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("visualchars",function(a){function b(b){function c(a){return'<span data-mce-bogus="1" class="mce-'+n[a]+'">'+a+"</span>"}function f(){var a,b="";for(a in n)b+=a;return new RegExp("["+b+"]","g")}function g(){var a,b="";for(a in n)b&&(b+=","),b+="span.mce-"+n[a];return b}var h,i,j,k,l,m,n,o,p=a.getBody(),q=a.selection;if(n={"\xa0":"nbsp","\xad":"shy"},d=!d,e.state=d,a.fire("VisualChars",{state:d}),o=f(),b&&(m=q.getBookmark()),d)for(i=[],tinymce.walk(p,function(a){3==a.nodeType&&a.nodeValue&&o.test(a.nodeValue)&&i.push(a)},"childNodes"),j=0;j<i.length;j++){for(k=i[j].nodeValue,k=k.replace(o,c),l=a.dom.create("div",null,k);h=l.lastChild;)a.dom.insertAfter(h,i[j]);a.dom.remove(i[j])}else for(i=a.dom.select(g(),p),j=i.length-1;j>=0;j--)a.dom.remove(i[j],1);q.moveToBookmark(m)}function c(){var b=this;a.on("VisualChars",function(a){b.active(a.state)})}var d,e=this;a.addCommand("mceVisualChars",b),a.addButton("visualchars",{title:"Show invisible characters",cmd:"mceVisualChars",onPostRender:c}),a.addMenuItem("visualchars",{text:"Show invisible characters",cmd:"mceVisualChars",onPostRender:c,selectable:!0,context:"view",prependToContext:!0}),a.on("beforegetcontent",function(a){d&&"raw"!=a.format&&!a.draft&&(d=!0,b(!1))})}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -tinymce.PluginManager.add("wordcount",function(e){function t(){e.theme.panel.find("#wordcount").text(["Words: {0}",i.getCount()])}var n,r,i=this;n=e.getParam("wordcount_countregex",/[\w\u2019\x27\-\u00C0-\u1FFF]+/g),r=e.getParam("wordcount_cleanregex",/[0-9.(),;:!?%#$?\x27\x22_+=\\\/\-]*/g),e.on("init",function(){var n=e.theme.panel&&e.theme.panel.find("#statusbar")[0];n&&tinymce.util.Delay.setEditorTimeout(e,function(){n.insert({type:"label",name:"wordcount",text:["Words: {0}",i.getCount()],classes:"wordcount",disabled:e.settings.readonly},0),e.on("setcontent beforeaddundo",t),e.on("keyup",function(e){32==e.keyCode&&t()})},0)}),i.getCount=function(){var t=e.getContent({format:"raw"}),i=0;if(t){t=t.replace(/\.\.\./g," "),t=t.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," "),t=t.replace(/(\w+)(&#?[a-z0-9]+;)+(\w+)/i,"$1$3").replace(/&.+?;/g," "),t=t.replace(r,"");var o=t.match(n);o&&(i=o.length)}return i}}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +tinymce.PluginManager.add("wordcount",function(a){function b(){a.theme.panel.find("#wordcount").text(["Words: {0}",e.getCount()])}var c,d,e=this;c=a.getParam("wordcount_countregex",/[\w\u2019\x27\-\u00C0-\u1FFF]+/g),d=a.getParam("wordcount_cleanregex",/[0-9.(),;:!?%#$?\x27\x22_+=\\\/\-]*/g),a.on("init",function(){var c=a.theme.panel&&a.theme.panel.find("#statusbar")[0];c&&tinymce.util.Delay.setEditorTimeout(a,function(){c.insert({type:"label",name:"wordcount",text:["Words: {0}",e.getCount()],classes:"wordcount",disabled:a.settings.readonly},0),a.on("setcontent beforeaddundo",b),a.on("keyup",function(a){32==a.keyCode&&b()})},0)}),e.getCount=function(){var b=a.getContent({format:"raw"}),e=0;if(b){b=b.replace(/\.\.\./g," "),b=b.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," "),b=b.replace(/(\w+)(&#?[a-z0-9]+;)+(\w+)/i,"$1$3").replace(/&.+?;/g," "),b=b.replace(d,"");var f=b.match(c);f&&(e=f.length)}return e}}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -/* Content.Inline.less */ | 1 | +.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:black;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:normal;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3a3a3a;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-preview-object{display:inline-block;position:relative;margin:0 2px 0 2px;line-height:0;border:1px solid gray}.mce-preview-object .mce-shim{position:absolute;top:0;left:0;width:100%;height:100%;background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}figure.align-left{float:left}figure.align-right{float:right}figure.image.align-center{display:table;margin-left:auto;margin-right:auto}figure.image{display:inline-block;border:1px solid gray;margin:0 2px 0 1px;background:#f5f2f0}figure.image img{margin:8px 8px 0 8px}figure.image figcaption{margin:6px 8px 6px 8px;text-align:center}.mce-preview-object[data-mce-selected="2"] .mce-shim{display:none}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px !important;height:9px !important;border:1px dotted #3a3a3a;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#aaa}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#aaa;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid #f00;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid #008000;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #bbb}td[data-mce-selected],th[data-mce-selected]{background-color:#39f !important}.mce-edit-focus{outline:1px dotted #333}.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus{outline:2px solid #2d8ac7}.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover{outline:2px solid #7acaff}.mce-content-body *[contentEditable=false][data-mce-selected]{outline:2px solid #2d8ac7}.mce-resize-bar-dragging{background-color:blue;opacity:.25;filter:alpha(opacity=25);zoom:1} |
| 2 | -/* Content.Objects.less */ | ||
| 3 | -.mce-content-body .mce-reset { | ||
| 4 | - margin: 0; | ||
| 5 | - padding: 0; | ||
| 6 | - border: 0; | ||
| 7 | - outline: 0; | ||
| 8 | - vertical-align: top; | ||
| 9 | - background: transparent; | ||
| 10 | - text-decoration: none; | ||
| 11 | - color: black; | ||
| 12 | - font-family: Arial; | ||
| 13 | - font-size: 11px; | ||
| 14 | - text-shadow: none; | ||
| 15 | - float: none; | ||
| 16 | - position: static; | ||
| 17 | - width: auto; | ||
| 18 | - height: auto; | ||
| 19 | - white-space: nowrap; | ||
| 20 | - cursor: inherit; | ||
| 21 | - line-height: normal; | ||
| 22 | - font-weight: normal; | ||
| 23 | - text-align: left; | ||
| 24 | - -webkit-tap-highlight-color: transparent; | ||
| 25 | - -moz-box-sizing: content-box; | ||
| 26 | - -webkit-box-sizing: content-box; | ||
| 27 | - box-sizing: content-box; | ||
| 28 | - direction: ltr; | ||
| 29 | - max-width: none; | ||
| 30 | -} | ||
| 31 | -.mce-object { | ||
| 32 | - border: 1px dotted #3A3A3A; | ||
| 33 | - background: #d5d5d5 url(img/object.gif) no-repeat center; | ||
| 34 | -} | ||
| 35 | -.mce-preview-object { | ||
| 36 | - display: inline-block; | ||
| 37 | - position: relative; | ||
| 38 | - margin: 0 2px 0 2px; | ||
| 39 | - line-height: 0; | ||
| 40 | - border: 1px solid gray; | ||
| 41 | -} | ||
| 42 | -.mce-preview-object .mce-shim { | ||
| 43 | - position: absolute; | ||
| 44 | - top: 0; | ||
| 45 | - left: 0; | ||
| 46 | - width: 100%; | ||
| 47 | - height: 100%; | ||
| 48 | - background: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7); | ||
| 49 | -} | ||
| 50 | -figure.align-left { | ||
| 51 | - float: left; | ||
| 52 | -} | ||
| 53 | -figure.align-right { | ||
| 54 | - float: right; | ||
| 55 | -} | ||
| 56 | -figure.image { | ||
| 57 | - display: inline-block; | ||
| 58 | - border: 1px solid gray; | ||
| 59 | - margin: 0 2px 0 1px; | ||
| 60 | - background: #f5f2f0; | ||
| 61 | -} | ||
| 62 | -figure.image img { | ||
| 63 | - margin: 8px 8px 0 8px; | ||
| 64 | -} | ||
| 65 | -figure.image figcaption { | ||
| 66 | - margin: 6px 8px 6px 8px; | ||
| 67 | - text-align: center; | ||
| 68 | -} | ||
| 69 | -.mce-preview-object[data-mce-selected] .mce-shim { | ||
| 70 | - display: none; | ||
| 71 | -} | ||
| 72 | -.mce-pagebreak { | ||
| 73 | - cursor: default; | ||
| 74 | - display: block; | ||
| 75 | - border: 0; | ||
| 76 | - width: 100%; | ||
| 77 | - height: 5px; | ||
| 78 | - border: 1px dashed #666; | ||
| 79 | - margin-top: 15px; | ||
| 80 | - page-break-before: always; | ||
| 81 | -} | ||
| 82 | -@media print { | ||
| 83 | - .mce-pagebreak { | ||
| 84 | - border: 0px; | ||
| 85 | - } | ||
| 86 | -} | ||
| 87 | -.mce-item-anchor { | ||
| 88 | - cursor: default; | ||
| 89 | - display: inline-block; | ||
| 90 | - -webkit-user-select: all; | ||
| 91 | - -webkit-user-modify: read-only; | ||
| 92 | - -moz-user-select: all; | ||
| 93 | - -moz-user-modify: read-only; | ||
| 94 | - user-select: all; | ||
| 95 | - user-modify: read-only; | ||
| 96 | - width: 9px !important; | ||
| 97 | - height: 9px !important; | ||
| 98 | - border: 1px dotted #3A3A3A; | ||
| 99 | - background: #d5d5d5 url(img/anchor.gif) no-repeat center; | ||
| 100 | -} | ||
| 101 | -.mce-nbsp, | ||
| 102 | -.mce-shy { | ||
| 103 | - background: #AAA; | ||
| 104 | -} | ||
| 105 | -.mce-shy::after { | ||
| 106 | - content: '-'; | ||
| 107 | -} | ||
| 108 | -hr { | ||
| 109 | - cursor: default; | ||
| 110 | -} | ||
| 111 | -.mce-match-marker { | ||
| 112 | - background: #AAA; | ||
| 113 | - color: #fff; | ||
| 114 | -} | ||
| 115 | -.mce-match-marker-selected { | ||
| 116 | - background: #3399ff; | ||
| 117 | - color: #fff; | ||
| 118 | -} | ||
| 119 | -.mce-spellchecker-word { | ||
| 120 | - border-bottom: 2px solid #F00; | ||
| 121 | - cursor: default; | ||
| 122 | -} | ||
| 123 | -.mce-spellchecker-grammar { | ||
| 124 | - border-bottom: 2px solid #008000; | ||
| 125 | - cursor: default; | ||
| 126 | -} | ||
| 127 | -.mce-item-table, | ||
| 128 | -.mce-item-table td, | ||
| 129 | -.mce-item-table th, | ||
| 130 | -.mce-item-table caption { | ||
| 131 | - border: 1px dashed #BBB; | ||
| 132 | -} | ||
| 133 | -td.mce-item-selected, | ||
| 134 | -th.mce-item-selected { | ||
| 135 | - background-color: #3399ff !important; | ||
| 136 | -} | ||
| 137 | -.mce-edit-focus { | ||
| 138 | - outline: 1px dotted #333; | ||
| 139 | -} | ||
| 140 | -.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus { | ||
| 141 | - outline: 2px solid #2d8ac7; | ||
| 142 | -} | ||
| 143 | -.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover { | ||
| 144 | - outline: 2px solid #7ACAFF; | ||
| 145 | -} | ||
| 146 | -.mce-content-body *[contentEditable=false][data-mce-selected] { | ||
| 147 | - outline: 2px solid #2d8ac7; | ||
| 148 | -} | ||
| 149 | -.mce-resize-bar-dragging { | ||
| 150 | - background-color: blue; | ||
| 151 | - opacity: 0.25; | ||
| 152 | - filter: alpha(opacity=25); | ||
| 153 | - zoom: 1; | ||
| 154 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -body{background-color:#fff;color:#000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;scrollbar-3dlight-color:#f0f0ee;scrollbar-arrow-color:#676662;scrollbar-base-color:#f0f0ee;scrollbar-darkshadow-color:#ddd;scrollbar-face-color:#e0e0dd;scrollbar-highlight-color:#f0f0ee;scrollbar-shadow-color:#f0f0ee;scrollbar-track-color:#f5f5f5}td,th{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px}.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:black;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:normal;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3a3a3a;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-preview-object{display:inline-block;position:relative;margin:0 2px 0 2px;line-height:0;border:1px solid gray}.mce-preview-object .mce-shim{position:absolute;top:0;left:0;width:100%;height:100%;background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}figure.align-left{float:left}figure.align-right{float:right}figure.image{display:inline-block;border:1px solid gray;margin:0 2px 0 1px;background:#f5f2f0}figure.image img{margin:8px 8px 0 8px}figure.image figcaption{margin:6px 8px 6px 8px;text-align:center}.mce-preview-object[data-mce-selected] .mce-shim{display:none}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px !important;height:9px !important;border:1px dotted #3a3a3a;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#aaa}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#aaa;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid #f00;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid #008000;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #bbb}td.mce-item-selected,th.mce-item-selected{background-color:#39f !important}.mce-edit-focus{outline:1px dotted #333}.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus{outline:2px solid #2d8ac7}.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover{outline:2px solid #7acaff}.mce-content-body *[contentEditable=false][data-mce-selected]{outline:2px solid #2d8ac7}.mce-resize-bar-dragging{background-color:blue;opacity:.25;filter:alpha(opacity=25);zoom:1} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +body{background-color:#fff;color:#000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;scrollbar-3dlight-color:#f0f0ee;scrollbar-arrow-color:#676662;scrollbar-base-color:#f0f0ee;scrollbar-darkshadow-color:#ddd;scrollbar-face-color:#e0e0dd;scrollbar-highlight-color:#f0f0ee;scrollbar-shadow-color:#f0f0ee;scrollbar-track-color:#f5f5f5}td,th{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px}.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:black;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:normal;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3a3a3a;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-preview-object{display:inline-block;position:relative;margin:0 2px 0 2px;line-height:0;border:1px solid gray}.mce-preview-object .mce-shim{position:absolute;top:0;left:0;width:100%;height:100%;background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}figure.align-left{float:left}figure.align-right{float:right}figure.image.align-center{display:table;margin-left:auto;margin-right:auto}figure.image{display:inline-block;border:1px solid gray;margin:0 2px 0 1px;background:#f5f2f0}figure.image img{margin:8px 8px 0 8px}figure.image figcaption{margin:6px 8px 6px 8px;text-align:center}.mce-preview-object[data-mce-selected="2"] .mce-shim{display:none}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px !important;height:9px !important;border:1px dotted #3a3a3a;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#aaa}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#aaa;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid #f00;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid #008000;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #bbb}td[data-mce-selected],th[data-mce-selected]{background-color:#39f !important}.mce-edit-focus{outline:1px dotted #333}.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus{outline:2px solid #2d8ac7}.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover{outline:2px solid #7acaff}.mce-content-body *[contentEditable=false][data-mce-selected]{outline:2px solid #2d8ac7}.mce-resize-bar-dragging{background-color:blue;opacity:.25;filter:alpha(opacity=25);zoom:1} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff could not be displayed because it is too large.
public/uploads/.gitignore
100644 → 100755
File mode changed
| ... | @@ -4,6 +4,7 @@ module.exports = function (ngApp, events) { | ... | @@ -4,6 +4,7 @@ module.exports = function (ngApp, events) { |
| 4 | 4 | ||
| 5 | ngApp.controller('ImageManagerController', ['$scope', '$attrs', '$http', '$timeout', 'imageManagerService', | 5 | ngApp.controller('ImageManagerController', ['$scope', '$attrs', '$http', '$timeout', 'imageManagerService', |
| 6 | function ($scope, $attrs, $http, $timeout, imageManagerService) { | 6 | function ($scope, $attrs, $http, $timeout, imageManagerService) { |
| 7 | + | ||
| 7 | $scope.images = []; | 8 | $scope.images = []; |
| 8 | $scope.imageType = $attrs.imageType; | 9 | $scope.imageType = $attrs.imageType; |
| 9 | $scope.selectedImage = false; | 10 | $scope.selectedImage = false; |
| ... | @@ -12,6 +13,8 @@ module.exports = function (ngApp, events) { | ... | @@ -12,6 +13,8 @@ module.exports = function (ngApp, events) { |
| 12 | $scope.hasMore = false; | 13 | $scope.hasMore = false; |
| 13 | $scope.imageUpdateSuccess = false; | 14 | $scope.imageUpdateSuccess = false; |
| 14 | $scope.imageDeleteSuccess = false; | 15 | $scope.imageDeleteSuccess = false; |
| 16 | + $scope.uploadedTo = $attrs.uploadedTo; | ||
| 17 | + | ||
| 15 | var page = 0; | 18 | var page = 0; |
| 16 | var previousClickTime = 0; | 19 | var previousClickTime = 0; |
| 17 | var dataLoaded = false; | 20 | var dataLoaded = false; |
| ... | @@ -213,4 +216,96 @@ module.exports = function (ngApp, events) { | ... | @@ -213,4 +216,96 @@ module.exports = function (ngApp, events) { |
| 213 | }]); | 216 | }]); |
| 214 | 217 | ||
| 215 | 218 | ||
| 219 | + ngApp.controller('PageEditController', ['$scope', '$http', '$attrs', '$interval', '$timeout', function ($scope, $http, $attrs, $interval, $timeout) { | ||
| 220 | + | ||
| 221 | + $scope.editorOptions = require('./pages/page-form'); | ||
| 222 | + $scope.editorHtml = ''; | ||
| 223 | + $scope.draftText = ''; | ||
| 224 | + var pageId = Number($attrs.pageId); | ||
| 225 | + var isEdit = pageId !== 0; | ||
| 226 | + var autosaveFrequency = 30; // AutoSave interval in seconds. | ||
| 227 | + $scope.isUpdateDraft = Number($attrs.pageUpdateDraft) === 1; | ||
| 228 | + $scope.isNewPageDraft = Number($attrs.pageNewDraft) === 1; | ||
| 229 | + if ($scope.isUpdateDraft || $scope.isNewPageDraft) { | ||
| 230 | + $scope.draftText = 'Editing Draft' | ||
| 231 | + } else { | ||
| 232 | + $scope.draftText = 'Editing Page' | ||
| 233 | + }; | ||
| 234 | + | ||
| 235 | + var autoSave = false; | ||
| 236 | + | ||
| 237 | + var currentContent = { | ||
| 238 | + title: false, | ||
| 239 | + html: false | ||
| 240 | + }; | ||
| 241 | + | ||
| 242 | + if (isEdit) { | ||
| 243 | + setTimeout(() => { | ||
| 244 | + startAutoSave(); | ||
| 245 | + }, 1000); | ||
| 246 | + } | ||
| 247 | + | ||
| 248 | + $scope.editorChange = function () {} | ||
| 249 | + | ||
| 250 | + /** | ||
| 251 | + * Start the AutoSave loop, Checks for content change | ||
| 252 | + * before performing the costly AJAX request. | ||
| 253 | + */ | ||
| 254 | + function startAutoSave() { | ||
| 255 | + currentContent.title = $('#name').val(); | ||
| 256 | + currentContent.html = $scope.editorHtml; | ||
| 257 | + | ||
| 258 | + autoSave = $interval(() => { | ||
| 259 | + var newTitle = $('#name').val(); | ||
| 260 | + var newHtml = $scope.editorHtml; | ||
| 261 | + | ||
| 262 | + if (newTitle !== currentContent.title || newHtml !== currentContent.html) { | ||
| 263 | + currentContent.html = newHtml; | ||
| 264 | + currentContent.title = newTitle; | ||
| 265 | + saveDraft(newTitle, newHtml); | ||
| 266 | + } | ||
| 267 | + }, 1000 * autosaveFrequency); | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + /** | ||
| 271 | + * Save a draft update into the system via an AJAX request. | ||
| 272 | + * @param title | ||
| 273 | + * @param html | ||
| 274 | + */ | ||
| 275 | + function saveDraft(title, html) { | ||
| 276 | + $http.put('/ajax/page/' + pageId + '/save-draft', { | ||
| 277 | + name: title, | ||
| 278 | + html: html | ||
| 279 | + }).then((responseData) => { | ||
| 280 | + $scope.draftText = responseData.data.message; | ||
| 281 | + if (!$scope.isNewPageDraft) $scope.isUpdateDraft = true; | ||
| 282 | + }); | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | + $scope.forceDraftSave = function() { | ||
| 286 | + var newTitle = $('#name').val(); | ||
| 287 | + var newHtml = $scope.editorHtml; | ||
| 288 | + saveDraft(newTitle, newHtml); | ||
| 289 | + }; | ||
| 290 | + | ||
| 291 | + /** | ||
| 292 | + * Discard the current draft and grab the current page | ||
| 293 | + * content from the system via an AJAX request. | ||
| 294 | + */ | ||
| 295 | + $scope.discardDraft = function () { | ||
| 296 | + $http.get('/ajax/page/' + pageId).then((responseData) => { | ||
| 297 | + if (autoSave) $interval.cancel(autoSave); | ||
| 298 | + $scope.draftText = 'Editing Page'; | ||
| 299 | + $scope.isUpdateDraft = false; | ||
| 300 | + $scope.$broadcast('html-update', responseData.data.html); | ||
| 301 | + $('#name').val(responseData.data.name); | ||
| 302 | + $timeout(() => { | ||
| 303 | + startAutoSave(); | ||
| 304 | + }, 1000); | ||
| 305 | + events.emit('success', 'Draft discarded, The editor has been updated with the current page content'); | ||
| 306 | + }); | ||
| 307 | + }; | ||
| 308 | + | ||
| 309 | + }]); | ||
| 310 | + | ||
| 216 | }; | 311 | }; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -110,7 +110,8 @@ module.exports = function (ngApp, events) { | ... | @@ -110,7 +110,8 @@ module.exports = function (ngApp, events) { |
| 110 | scope: { | 110 | scope: { |
| 111 | uploadUrl: '@', | 111 | uploadUrl: '@', |
| 112 | eventSuccess: '=', | 112 | eventSuccess: '=', |
| 113 | - eventError: '=' | 113 | + eventError: '=', |
| 114 | + uploadedTo: '@' | ||
| 114 | }, | 115 | }, |
| 115 | link: function (scope, element, attrs) { | 116 | link: function (scope, element, attrs) { |
| 116 | var dropZone = new DropZone(element[0].querySelector('.dropzone-container'), { | 117 | var dropZone = new DropZone(element[0].querySelector('.dropzone-container'), { |
| ... | @@ -120,6 +121,8 @@ module.exports = function (ngApp, events) { | ... | @@ -120,6 +121,8 @@ module.exports = function (ngApp, events) { |
| 120 | dz.on('sending', function (file, xhr, data) { | 121 | dz.on('sending', function (file, xhr, data) { |
| 121 | var token = window.document.querySelector('meta[name=token]').getAttribute('content'); | 122 | var token = window.document.querySelector('meta[name=token]').getAttribute('content'); |
| 122 | data.append('_token', token); | 123 | data.append('_token', token); |
| 124 | + var uploadedTo = typeof scope.uploadedTo === 'undefined' ? 0 : scope.uploadedTo; | ||
| 125 | + data.append('uploaded_to', uploadedTo); | ||
| 123 | }); | 126 | }); |
| 124 | if (typeof scope.eventSuccess !== 'undefined') dz.on('success', scope.eventSuccess); | 127 | if (typeof scope.eventSuccess !== 'undefined') dz.on('success', scope.eventSuccess); |
| 125 | dz.on('success', function (file, data) { | 128 | dz.on('success', function (file, data) { |
| ... | @@ -162,5 +165,42 @@ module.exports = function (ngApp, events) { | ... | @@ -162,5 +165,42 @@ module.exports = function (ngApp, events) { |
| 162 | }; | 165 | }; |
| 163 | }]); | 166 | }]); |
| 164 | 167 | ||
| 168 | + ngApp.directive('tinymce', ['$timeout', function($timeout) { | ||
| 169 | + return { | ||
| 170 | + restrict: 'A', | ||
| 171 | + scope: { | ||
| 172 | + tinymce: '=', | ||
| 173 | + mceModel: '=', | ||
| 174 | + mceChange: '=' | ||
| 175 | + }, | ||
| 176 | + link: function (scope, element, attrs) { | ||
| 177 | + | ||
| 178 | + function tinyMceSetup(editor) { | ||
| 179 | + editor.on('ExecCommand change NodeChange ObjectResized', (e) => { | ||
| 180 | + var content = editor.getContent(); | ||
| 181 | + $timeout(() => { | ||
| 182 | + scope.mceModel = content; | ||
| 183 | + }); | ||
| 184 | + scope.mceChange(content); | ||
| 185 | + }); | ||
| 186 | + | ||
| 187 | + editor.on('init', (e) => { | ||
| 188 | + scope.mceModel = editor.getContent(); | ||
| 189 | + }); | ||
| 190 | + | ||
| 191 | + scope.$on('html-update', (event, value) => { | ||
| 192 | + editor.setContent(value); | ||
| 193 | + editor.selection.select(editor.getBody(), true); | ||
| 194 | + editor.selection.collapse(false); | ||
| 195 | + scope.mceModel = editor.getContent(); | ||
| 196 | + }); | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + scope.tinymce.extraSetups.push(tinyMceSetup); | ||
| 200 | + tinymce.init(scope.tinymce); | ||
| 201 | + } | ||
| 202 | + } | ||
| 203 | + }]) | ||
| 204 | + | ||
| 165 | 205 | ||
| 166 | }; | 206 | }; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -54,10 +54,10 @@ $.expr[":"].contains = $.expr.createPseudo(function (arg) { | ... | @@ -54,10 +54,10 @@ $.expr[":"].contains = $.expr.createPseudo(function (arg) { |
| 54 | // Global jQuery Elements | 54 | // Global jQuery Elements |
| 55 | $(function () { | 55 | $(function () { |
| 56 | 56 | ||
| 57 | - | ||
| 58 | var notifications = $('.notification'); | 57 | var notifications = $('.notification'); |
| 59 | var successNotification = notifications.filter('.pos'); | 58 | var successNotification = notifications.filter('.pos'); |
| 60 | var errorNotification = notifications.filter('.neg'); | 59 | var errorNotification = notifications.filter('.neg'); |
| 60 | + var warningNotification = notifications.filter('.warning'); | ||
| 61 | // Notification Events | 61 | // Notification Events |
| 62 | window.Events.listen('success', function (text) { | 62 | window.Events.listen('success', function (text) { |
| 63 | successNotification.hide(); | 63 | successNotification.hide(); |
| ... | @@ -66,6 +66,10 @@ $(function () { | ... | @@ -66,6 +66,10 @@ $(function () { |
| 66 | successNotification.show(); | 66 | successNotification.show(); |
| 67 | }, 1); | 67 | }, 1); |
| 68 | }); | 68 | }); |
| 69 | + window.Events.listen('warning', function (text) { | ||
| 70 | + warningNotification.find('span').text(text); | ||
| 71 | + warningNotification.show(); | ||
| 72 | + }); | ||
| 69 | window.Events.listen('error', function (text) { | 73 | window.Events.listen('error', function (text) { |
| 70 | errorNotification.find('span').text(text); | 74 | errorNotification.find('span').text(text); |
| 71 | errorNotification.show(); | 75 | errorNotification.show(); |
| ... | @@ -119,11 +123,5 @@ function elemExists(selector) { | ... | @@ -119,11 +123,5 @@ function elemExists(selector) { |
| 119 | return document.querySelector(selector) !== null; | 123 | return document.querySelector(selector) !== null; |
| 120 | } | 124 | } |
| 121 | 125 | ||
| 122 | -// TinyMCE editor | ||
| 123 | -if (elemExists('#html-editor')) { | ||
| 124 | - var tinyMceOptions = require('./pages/page-form'); | ||
| 125 | - tinymce.init(tinyMceOptions); | ||
| 126 | -} | ||
| 127 | - | ||
| 128 | // Page specific items | 126 | // Page specific items |
| 129 | require('./pages/page-show'); | 127 | require('./pages/page-show'); | ... | ... |
| 1 | -module.exports = { | 1 | +var mceOptions = module.exports = { |
| 2 | selector: '#html-editor', | 2 | selector: '#html-editor', |
| 3 | content_css: [ | 3 | content_css: [ |
| 4 | '/css/styles.css' | 4 | '/css/styles.css' |
| ... | @@ -51,8 +51,13 @@ module.exports = { | ... | @@ -51,8 +51,13 @@ module.exports = { |
| 51 | args.content = ''; | 51 | args.content = ''; |
| 52 | } | 52 | } |
| 53 | }, | 53 | }, |
| 54 | + extraSetups: [], | ||
| 54 | setup: function (editor) { | 55 | setup: function (editor) { |
| 55 | 56 | ||
| 57 | + for (var i = 0; i < mceOptions.extraSetups.length; i++) { | ||
| 58 | + mceOptions.extraSetups[i](editor); | ||
| 59 | + } | ||
| 60 | + | ||
| 56 | (function () { | 61 | (function () { |
| 57 | var wrap; | 62 | var wrap; |
| 58 | 63 | ... | ... |
| ... | @@ -188,3 +188,7 @@ input:checked + .toggle-switch { | ... | @@ -188,3 +188,7 @@ input:checked + .toggle-switch { |
| 188 | #login-form label.toggle-switch { | 188 | #login-form label.toggle-switch { |
| 189 | margin-left: $-xl; | 189 | margin-left: $-xl; |
| 190 | } | 190 | } |
| 191 | + | ||
| 192 | +.image-picker img { | ||
| 193 | + background-color: #BBB; | ||
| 194 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -161,6 +161,11 @@ form.search-box { | ... | @@ -161,6 +161,11 @@ form.search-box { |
| 161 | } | 161 | } |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | +.faded span.faded-text { | ||
| 165 | + display: inline-block; | ||
| 166 | + padding: $-s; | ||
| 167 | +} | ||
| 168 | + | ||
| 164 | .faded-small { | 169 | .faded-small { |
| 165 | color: #000; | 170 | color: #000; |
| 166 | font-size: 0.9em; | 171 | font-size: 0.9em; |
| ... | @@ -183,6 +188,9 @@ form.search-box { | ... | @@ -183,6 +188,9 @@ form.search-box { |
| 183 | padding-left: 0; | 188 | padding-left: 0; |
| 184 | } | 189 | } |
| 185 | } | 190 | } |
| 191 | + &.text-center { | ||
| 192 | + text-align: center; | ||
| 193 | + } | ||
| 186 | } | 194 | } |
| 187 | 195 | ||
| 188 | .setting-nav { | 196 | .setting-nav { | ... | ... |
| ... | @@ -4,6 +4,10 @@ | ... | @@ -4,6 +4,10 @@ |
| 4 | html { | 4 | html { |
| 5 | background-color: #FFFFFF; | 5 | background-color: #FFFFFF; |
| 6 | height: 100%; | 6 | height: 100%; |
| 7 | + overflow-y: scroll; | ||
| 8 | + &.flexbox { | ||
| 9 | + overflow-y: hidden; | ||
| 10 | + } | ||
| 7 | } | 11 | } |
| 8 | body { | 12 | body { |
| 9 | font-family: $text; | 13 | font-family: $text; |
| ... | @@ -13,6 +17,10 @@ body { | ... | @@ -13,6 +17,10 @@ body { |
| 13 | -webkit-font-smoothing: antialiased; | 17 | -webkit-font-smoothing: antialiased; |
| 14 | } | 18 | } |
| 15 | 19 | ||
| 20 | +button { | ||
| 21 | + font-size: 100%; | ||
| 22 | +} | ||
| 23 | + | ||
| 16 | table { | 24 | table { |
| 17 | min-width: 100px; | 25 | min-width: 100px; |
| 18 | td { | 26 | td { | ... | ... |
| ... | @@ -16,6 +16,9 @@ | ... | @@ -16,6 +16,9 @@ |
| 16 | margin: $-s 0 0 0; | 16 | margin: $-s 0 0 0; |
| 17 | border-left: 5px solid $color-page; | 17 | border-left: 5px solid $color-page; |
| 18 | padding: $-xs 0 $-xs $-m; | 18 | padding: $-xs 0 $-xs $-m; |
| 19 | + &.draft { | ||
| 20 | + border-left-color: $color-page-draft; | ||
| 21 | + } | ||
| 19 | } | 22 | } |
| 20 | hr { | 23 | hr { |
| 21 | margin-top: 0; | 24 | margin-top: 0; |
| ... | @@ -26,6 +29,12 @@ | ... | @@ -26,6 +29,12 @@ |
| 26 | .page { | 29 | .page { |
| 27 | border-left: 5px solid $color-page; | 30 | border-left: 5px solid $color-page; |
| 28 | } | 31 | } |
| 32 | + .page.draft { | ||
| 33 | + border-left: 5px solid $color-page-draft; | ||
| 34 | + .text-page { | ||
| 35 | + color: $color-page-draft; | ||
| 36 | + } | ||
| 37 | + } | ||
| 29 | .chapter { | 38 | .chapter { |
| 30 | border-left: 5px solid $color-chapter; | 39 | border-left: 5px solid $color-chapter; |
| 31 | } | 40 | } |
| ... | @@ -182,6 +191,12 @@ | ... | @@ -182,6 +191,12 @@ |
| 182 | background-color: rgba($color-page, 0.1); | 191 | background-color: rgba($color-page, 0.1); |
| 183 | } | 192 | } |
| 184 | } | 193 | } |
| 194 | + .list-item-page.draft { | ||
| 195 | + border-left: 5px solid $color-page-draft; | ||
| 196 | + } | ||
| 197 | + .page.draft .page, .list-item-page.draft a.page { | ||
| 198 | + color: $color-page-draft !important; | ||
| 199 | + } | ||
| 185 | .sub-menu { | 200 | .sub-menu { |
| 186 | display: none; | 201 | display: none; |
| 187 | padding-left: 0; | 202 | padding-left: 0; |
| ... | @@ -234,7 +249,6 @@ | ... | @@ -234,7 +249,6 @@ |
| 234 | position: absolute; | 249 | position: absolute; |
| 235 | } | 250 | } |
| 236 | 251 | ||
| 237 | - | ||
| 238 | .activity-list-item { | 252 | .activity-list-item { |
| 239 | padding: $-s 0; | 253 | padding: $-s 0; |
| 240 | color: #888; | 254 | color: #888; |
| ... | @@ -304,6 +318,9 @@ ul.pagination { | ... | @@ -304,6 +318,9 @@ ul.pagination { |
| 304 | font-size: 0.75em; | 318 | font-size: 0.75em; |
| 305 | margin-top: $-xs; | 319 | margin-top: $-xs; |
| 306 | } | 320 | } |
| 321 | + .page.draft .text-page { | ||
| 322 | + color: $color-page-draft; | ||
| 323 | + } | ||
| 307 | } | 324 | } |
| 308 | .entity-list.compact { | 325 | .entity-list.compact { |
| 309 | font-size: 0.6em; | 326 | font-size: 0.6em; | ... | ... |
| ... | @@ -206,6 +206,12 @@ p.secondary, p .secondary, span.secondary, .text-secondary { | ... | @@ -206,6 +206,12 @@ p.secondary, p .secondary, span.secondary, .text-secondary { |
| 206 | &:hover { | 206 | &:hover { |
| 207 | color: $color-page; | 207 | color: $color-page; |
| 208 | } | 208 | } |
| 209 | + &.draft { | ||
| 210 | + color: $color-page-draft; | ||
| 211 | + } | ||
| 212 | + &.draft:hover { | ||
| 213 | + color: $color-page-draft; | ||
| 214 | + } | ||
| 209 | } | 215 | } |
| 210 | .text-chapter { | 216 | .text-chapter { |
| 211 | color: $color-chapter; | 217 | color: $color-chapter; |
| ... | @@ -217,20 +223,22 @@ p.secondary, p .secondary, span.secondary, .text-secondary { | ... | @@ -217,20 +223,22 @@ p.secondary, p .secondary, span.secondary, .text-secondary { |
| 217 | span.highlight { | 223 | span.highlight { |
| 218 | //background-color: rgba($primary, 0.2); | 224 | //background-color: rgba($primary, 0.2); |
| 219 | font-weight: bold; | 225 | font-weight: bold; |
| 220 | - //padding: 2px 4px; | 226 | + padding: 2px 4px; |
| 221 | } | 227 | } |
| 222 | 228 | ||
| 223 | /* | 229 | /* |
| 224 | * Lists | 230 | * Lists |
| 225 | */ | 231 | */ |
| 226 | ul { | 232 | ul { |
| 227 | - padding-left: $-m * 1.5; | 233 | + padding-left: $-m * 1.3; |
| 228 | - list-style: disc inside; | 234 | + list-style: disc; |
| 235 | + overflow: hidden; | ||
| 229 | } | 236 | } |
| 230 | 237 | ||
| 231 | ol { | 238 | ol { |
| 232 | - list-style: decimal inside; | 239 | + list-style: decimal; |
| 233 | - padding-left: $-m * 1.5; | 240 | + padding-left: $-m * 1.3; |
| 241 | + overflow: hidden; | ||
| 234 | } | 242 | } |
| 235 | 243 | ||
| 236 | /* | 244 | /* | ... | ... |
| ... | @@ -38,12 +38,14 @@ $primary-dark: #0288D1; | ... | @@ -38,12 +38,14 @@ $primary-dark: #0288D1; |
| 38 | $secondary: #e27b41; | 38 | $secondary: #e27b41; |
| 39 | $positive: #52A256; | 39 | $positive: #52A256; |
| 40 | $negative: #E84F4F; | 40 | $negative: #E84F4F; |
| 41 | +$warning: $secondary; | ||
| 41 | $primary-faded: rgba(21, 101, 192, 0.15); | 42 | $primary-faded: rgba(21, 101, 192, 0.15); |
| 42 | 43 | ||
| 43 | // Item Colors | 44 | // Item Colors |
| 44 | $color-book: #009688; | 45 | $color-book: #009688; |
| 45 | $color-chapter: #ef7c3c; | 46 | $color-chapter: #ef7c3c; |
| 46 | $color-page: $primary; | 47 | $color-page: $primary; |
| 48 | +$color-page-draft: #9A60DA; | ||
| 47 | 49 | ||
| 48 | // Text colours | 50 | // Text colours |
| 49 | $text-dark: #444; | 51 | $text-dark: #444; | ... | ... |
| ... | @@ -88,6 +88,10 @@ body.dragging, body.dragging * { | ... | @@ -88,6 +88,10 @@ body.dragging, body.dragging * { |
| 88 | background-color: $negative; | 88 | background-color: $negative; |
| 89 | color: #EEE; | 89 | color: #EEE; |
| 90 | } | 90 | } |
| 91 | + &.warning { | ||
| 92 | + background-color: $secondary; | ||
| 93 | + color: #EEE; | ||
| 94 | + } | ||
| 91 | } | 95 | } |
| 92 | 96 | ||
| 93 | // Loading icon | 97 | // Loading icon | ... | ... |
| 1 | <!DOCTYPE html> | 1 | <!DOCTYPE html> |
| 2 | -<html> | 2 | +<html class="@yield('body-class')"> |
| 3 | <head> | 3 | <head> |
| 4 | <title>{{ isset($pageTitle) ? $pageTitle . ' | ' : '' }}{{ setting('app-name', 'BookStack') }}</title> | 4 | <title>{{ isset($pageTitle) ? $pageTitle . ' | ' : '' }}{{ setting('app-name', 'BookStack') }}</title> |
| 5 | 5 | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | <p class="text-muted chapter-toggle"><i class="zmdi zmdi-caret-right"></i> <i class="zmdi zmdi-file-text"></i> <span>{{ count($chapter->pages) }} Pages</span></p> | 14 | <p class="text-muted chapter-toggle"><i class="zmdi zmdi-caret-right"></i> <i class="zmdi zmdi-file-text"></i> <span>{{ count($chapter->pages) }} Pages</span></p> |
| 15 | <div class="inset-list"> | 15 | <div class="inset-list"> |
| 16 | @foreach($chapter->pages as $page) | 16 | @foreach($chapter->pages as $page) |
| 17 | - <h4><a href="{{$page->getUrl()}}"><i class="zmdi zmdi-file-text"></i>{{$page->name}}</a></h4> | 17 | + <h4 class="@if($page->draft) draft @endif"><a href="{{$page->getUrl()}}" class="text-page @if($page->draft) draft @endif"><i class="zmdi zmdi-file-text"></i>{{$page->name}}</a></h4> |
| 18 | @endforeach | 18 | @endforeach |
| 19 | </div> | 19 | </div> |
| 20 | @endif | 20 | @endif | ... | ... |
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <div class="row"> | 7 | <div class="row"> |
| 8 | <div class="col-md-4 faded"> | 8 | <div class="col-md-4 faded"> |
| 9 | <div class="breadcrumbs"> | 9 | <div class="breadcrumbs"> |
| 10 | - <a href="{{$book->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-book"></i>{{ $book->name }}</a> | 10 | + <a href="{{$book->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-book"></i>{{ $book->getShortName() }}</a> |
| 11 | </div> | 11 | </div> |
| 12 | </div> | 12 | </div> |
| 13 | <div class="col-md-8 faded"> | 13 | <div class="col-md-8 faded"> | ... | ... |
| ... | @@ -23,6 +23,12 @@ | ... | @@ -23,6 +23,12 @@ |
| 23 | <div class="row"> | 23 | <div class="row"> |
| 24 | 24 | ||
| 25 | <div class="col-sm-4"> | 25 | <div class="col-sm-4"> |
| 26 | + <div id="recent-drafts"> | ||
| 27 | + @if(count($draftPages) > 0) | ||
| 28 | + <h3>My Recent Drafts</h3> | ||
| 29 | + @include('partials/entity-list', ['entities' => $draftPages, 'style' => 'compact']) | ||
| 30 | + @endif | ||
| 31 | + </div> | ||
| 26 | @if($signedIn) | 32 | @if($signedIn) |
| 27 | <h3>My Recently Viewed</h3> | 33 | <h3>My Recently Viewed</h3> |
| 28 | @else | 34 | @else | ... | ... |
| 1 | @extends('base') | 1 | @extends('base') |
| 2 | 2 | ||
| 3 | @section('head') | 3 | @section('head') |
| 4 | - <script src="/libs/tinymce/tinymce.min.js?ver=4.3.2"></script> | 4 | + <script src="/libs/tinymce/tinymce.min.js?ver=4.3.7"></script> |
| 5 | @stop | 5 | @stop |
| 6 | 6 | ||
| 7 | @section('body-class', 'flexbox') | 7 | @section('body-class', 'flexbox') |
| 8 | 8 | ||
| 9 | @section('content') | 9 | @section('content') |
| 10 | 10 | ||
| 11 | - <div class="flex-fill flex" ng-non-bindable> | 11 | + <div class="flex-fill flex"> |
| 12 | - <form action="{{$book->getUrl() . '/page'}}" method="POST" class="flex flex-fill"> | 12 | + <form action="{{$book->getUrl() . '/page/' . $draft->id}}" method="POST" class="flex flex-fill"> |
| 13 | - @include('pages/form') | 13 | + @include('pages/form', ['model' => $draft]) |
| 14 | - @if($chapter) | ||
| 15 | - <input type="hidden" name="chapter" value="{{$chapter->id}}"> | ||
| 16 | - @endif | ||
| 17 | </form> | 14 | </form> |
| 18 | </div> | 15 | </div> |
| 19 | - @include('partials/image-manager', ['imageType' => 'gallery']) | 16 | + @include('partials/image-manager', ['imageType' => 'gallery', 'uploaded_to' => $draft->id]) |
| 20 | @stop | 17 | @stop |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -3,8 +3,8 @@ | ... | @@ -3,8 +3,8 @@ |
| 3 | @section('content') | 3 | @section('content') |
| 4 | 4 | ||
| 5 | <div class="container small" ng-non-bindable> | 5 | <div class="container small" ng-non-bindable> |
| 6 | - <h1>Delete Page</h1> | 6 | + <h1>Delete {{ $page->draft ? 'Draft' : '' }} Page</h1> |
| 7 | - <p class="text-neg">Are you sure you want to delete this page?</p> | 7 | + <p class="text-neg">Are you sure you want to delete this {{ $page->draft ? 'draft' : '' }} page?</p> |
| 8 | 8 | ||
| 9 | <form action="{{$page->getUrl()}}" method="POST"> | 9 | <form action="{{$page->getUrl()}}" method="POST"> |
| 10 | {!! csrf_field() !!} | 10 | {!! csrf_field() !!} | ... | ... |
| 1 | @extends('base') | 1 | @extends('base') |
| 2 | 2 | ||
| 3 | @section('head') | 3 | @section('head') |
| 4 | - <script src="/libs/tinymce/tinymce.min.js?ver=4.3.2"></script> | 4 | + <script src="/libs/tinymce/tinymce.min.js?ver=4.3.7"></script> |
| 5 | @stop | 5 | @stop |
| 6 | 6 | ||
| 7 | @section('body-class', 'flexbox') | 7 | @section('body-class', 'flexbox') |
| 8 | 8 | ||
| 9 | @section('content') | 9 | @section('content') |
| 10 | 10 | ||
| 11 | - <div class="flex-fill flex" ng-non-bindable> | 11 | + <div class="flex-fill flex"> |
| 12 | - <form action="{{$page->getUrl()}}" method="POST" class="flex flex-fill"> | 12 | + <form action="{{$page->getUrl()}}" data-page-id="{{ $page->id }}" method="POST" class="flex flex-fill"> |
| 13 | <input type="hidden" name="_method" value="PUT"> | 13 | <input type="hidden" name="_method" value="PUT"> |
| 14 | @include('pages/form', ['model' => $page]) | 14 | @include('pages/form', ['model' => $page]) |
| 15 | </form> | 15 | </form> |
| 16 | </div> | 16 | </div> |
| 17 | - @include('partials/image-manager', ['imageType' => 'gallery']) | 17 | + @include('partials/image-manager', ['imageType' => 'gallery', 'uploaded_to' => $page->id]) |
| 18 | 18 | ||
| 19 | @stop | 19 | @stop |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | 1 | ||
| 2 | - | 2 | +<div class="page-editor flex-fill flex" ng-controller="PageEditController" page-id="{{ $model->id or 0 }}" page-new-draft="{{ $model->draft or 0 }}" page-update-draft="{{ $model->isDraft or 0 }}"> |
| 3 | - | ||
| 4 | -<div class="page-editor flex-fill flex" ng-non-bindable> | ||
| 5 | 3 | ||
| 6 | {{ csrf_field() }} | 4 | {{ csrf_field() }} |
| 7 | <div class="faded-small toolbar"> | 5 | <div class="faded-small toolbar"> |
| ... | @@ -9,12 +7,28 @@ | ... | @@ -9,12 +7,28 @@ |
| 9 | <div class="row"> | 7 | <div class="row"> |
| 10 | <div class="col-sm-4 faded"> | 8 | <div class="col-sm-4 faded"> |
| 11 | <div class="action-buttons text-left"> | 9 | <div class="action-buttons text-left"> |
| 10 | + <a href="{{ back()->getTargetUrl() }}" class="text-button text-primary"><i class="zmdi zmdi-arrow-left"></i>Back</a> | ||
| 12 | <a onclick="$('body>header').slideToggle();" class="text-button text-primary"><i class="zmdi zmdi-swap-vertical"></i>Toggle Header</a> | 11 | <a onclick="$('body>header').slideToggle();" class="text-button text-primary"><i class="zmdi zmdi-swap-vertical"></i>Toggle Header</a> |
| 13 | </div> | 12 | </div> |
| 14 | </div> | 13 | </div> |
| 15 | - <div class="col-sm-8 faded"> | 14 | + <div class="col-sm-4 faded text-center"> |
| 16 | - <div class="action-buttons"> | 15 | + |
| 17 | - <a href="{{ back()->getTargetUrl() }}" class="text-button text-primary"><i class="zmdi zmdi-close"></i>Cancel</a> | 16 | + <div dropdown class="dropdown-container"> |
| 17 | + <a dropdown-toggle class="text-primary text-button"><span class="faded-text" ng-bind="draftText"></span> <i class="zmdi zmdi-more-vert"></i></a> | ||
| 18 | + <ul> | ||
| 19 | + <li> | ||
| 20 | + <a ng-click="forceDraftSave()" class="text-pos"><i class="zmdi zmdi-save"></i>Save Draft</a> | ||
| 21 | + </li> | ||
| 22 | + <li ng-if="isNewPageDraft"> | ||
| 23 | + <a href="{{$model->getUrl()}}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete Draft</a> | ||
| 24 | + </li> | ||
| 25 | + </ul> | ||
| 26 | + </div> | ||
| 27 | + </div> | ||
| 28 | + <div class="col-sm-4 faded"> | ||
| 29 | + <div class="action-buttons" ng-cloak> | ||
| 30 | + | ||
| 31 | + <button type="button" ng-if="isUpdateDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button> | ||
| 18 | <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button> | 32 | <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button> |
| 19 | </div> | 33 | </div> |
| 20 | </div> | 34 | </div> |
| ... | @@ -22,13 +36,13 @@ | ... | @@ -22,13 +36,13 @@ |
| 22 | </div> | 36 | </div> |
| 23 | </div> | 37 | </div> |
| 24 | 38 | ||
| 25 | - <div class="title-input page-title clearfix"> | 39 | + <div class="title-input page-title clearfix" ng-non-bindable> |
| 26 | <div class="input"> | 40 | <div class="input"> |
| 27 | @include('form/text', ['name' => 'name', 'placeholder' => 'Page Title']) | 41 | @include('form/text', ['name' => 'name', 'placeholder' => 'Page Title']) |
| 28 | </div> | 42 | </div> |
| 29 | </div> | 43 | </div> |
| 30 | <div class="edit-area flex-fill flex"> | 44 | <div class="edit-area flex-fill flex"> |
| 31 | - <textarea id="html-editor" name="html" rows="5" | 45 | + <textarea id="html-editor" tinymce="editorOptions" mce-change="editorChange" mce-model="editorHtml" name="html" rows="5" |
| 32 | @if($errors->has('html')) class="neg" @endif>@if(isset($model) || old('html')){{htmlspecialchars( old('html') ? old('html') : $model->html)}}@endif</textarea> | 46 | @if($errors->has('html')) class="neg" @endif>@if(isset($model) || old('html')){{htmlspecialchars( old('html') ? old('html') : $model->html)}}@endif</textarea> |
| 33 | @if($errors->has('html')) | 47 | @if($errors->has('html')) |
| 34 | <div class="text-neg text-small">{{ $errors->first('html') }}</div> | 48 | <div class="text-neg text-small">{{ $errors->first('html') }}</div> | ... | ... |
| 1 | -<div class="page"> | 1 | +<div class="page {{$page->draft ? 'draft' : ''}}"> |
| 2 | <h3> | 2 | <h3> |
| 3 | <a href="{{ $page->getUrl() }}" class="text-page"><i class="zmdi zmdi-file-text"></i>{{ $page->name }}</a> | 3 | <a href="{{ $page->getUrl() }}" class="text-page"><i class="zmdi zmdi-file-text"></i>{{ $page->name }}</a> |
| 4 | </h3> | 4 | </h3> | ... | ... |
| ... | @@ -24,10 +24,10 @@ | ... | @@ -24,10 +24,10 @@ |
| 24 | 24 | ||
| 25 | <table class="table"> | 25 | <table class="table"> |
| 26 | <tr> | 26 | <tr> |
| 27 | - <th>Name</th> | 27 | + <th width="40%">Name</th> |
| 28 | - <th colspan="2">Created By</th> | 28 | + <th colspan="2" width="20%">Created By</th> |
| 29 | - <th>Revision Date</th> | 29 | + <th width="20%">Revision Date</th> |
| 30 | - <th>Actions</th> | 30 | + <th width="20%">Actions</th> |
| 31 | </tr> | 31 | </tr> |
| 32 | @foreach($page->revisions as $revision) | 32 | @foreach($page->revisions as $revision) |
| 33 | <tr> | 33 | <tr> |
| ... | @@ -38,7 +38,7 @@ | ... | @@ -38,7 +38,7 @@ |
| 38 | @endif | 38 | @endif |
| 39 | </td> | 39 | </td> |
| 40 | <td> @if($revision->createdBy) {{$revision->createdBy->name}} @else Deleted User @endif</td> | 40 | <td> @if($revision->createdBy) {{$revision->createdBy->name}} @else Deleted User @endif</td> |
| 41 | - <td><small>{{$revision->created_at->format('jS F, Y H:i:s')}} ({{$revision->created_at->diffForHumans()}})</small></td> | 41 | + <td><small>{{$revision->created_at->format('jS F, Y H:i:s')}} <br> ({{$revision->created_at->diffForHumans()}})</small></td> |
| 42 | <td> | 42 | <td> |
| 43 | <a href="{{$revision->getUrl()}}" target="_blank">Preview</a> | 43 | <a href="{{$revision->getUrl()}}" target="_blank">Preview</a> |
| 44 | <span class="text-muted"> | </span> | 44 | <span class="text-muted"> | </span> | ... | ... |
| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | @foreach($sidebarTree as $bookChild) | 8 | @foreach($sidebarTree as $bookChild) |
| 9 | - <li class="list-item-{{ $bookChild->getClassName() }} {{ $bookChild->getClassName() }}"> | 9 | + <li class="list-item-{{ $bookChild->getClassName() }} {{ $bookChild->getClassName() }} {{ $bookChild->isA('page') && $bookChild->draft ? 'draft' : '' }}"> |
| 10 | <a href="{{$bookChild->getUrl()}}" class="{{ $bookChild->getClassName() }} {{ $current->matches($bookChild)? 'selected' : '' }}"> | 10 | <a href="{{$bookChild->getUrl()}}" class="{{ $bookChild->getClassName() }} {{ $current->matches($bookChild)? 'selected' : '' }}"> |
| 11 | @if($bookChild->isA('chapter'))<i class="zmdi zmdi-collection-bookmark"></i>@else <i class="zmdi zmdi-file-text"></i>@endif{{ $bookChild->name }} | 11 | @if($bookChild->isA('chapter'))<i class="zmdi zmdi-collection-bookmark"></i>@else <i class="zmdi zmdi-file-text"></i>@endif{{ $bookChild->name }} |
| 12 | </a> | 12 | </a> |
| ... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
| 17 | </p> | 17 | </p> |
| 18 | <ul class="menu sub-menu inset-list @if($bookChild->matchesOrContains($current)) open @endif"> | 18 | <ul class="menu sub-menu inset-list @if($bookChild->matchesOrContains($current)) open @endif"> |
| 19 | @foreach($bookChild->pages as $childPage) | 19 | @foreach($bookChild->pages as $childPage) |
| 20 | - <li class="list-item-page"> | 20 | + <li class="list-item-page {{ $childPage->isA('page') && $childPage->draft ? 'draft' : '' }}"> |
| 21 | <a href="{{$childPage->getUrl()}}" class="page {{ $current->matches($childPage)? 'selected' : '' }}"> | 21 | <a href="{{$childPage->getUrl()}}" class="page {{ $current->matches($childPage)? 'selected' : '' }}"> |
| 22 | <i class="zmdi zmdi-file-text"></i> {{ $childPage->name }} | 22 | <i class="zmdi zmdi-file-text"></i> {{ $childPage->name }} |
| 23 | </a> | 23 | </a> | ... | ... |
| 1 | -<div id="image-manager" image-type="{{ $imageType }}" ng-controller="ImageManagerController"> | 1 | +<div id="image-manager" image-type="{{ $imageType }}" ng-controller="ImageManagerController" uploaded-to="{{ $uploaded_to or 0 }}"> |
| 2 | <div class="overlay anim-slide" ng-show="showing" ng-cloak ng-click="hide()"> | 2 | <div class="overlay anim-slide" ng-show="showing" ng-cloak ng-click="hide()"> |
| 3 | <div class="image-manager-body" ng-click="$event.stopPropagation()"> | 3 | <div class="image-manager-body" ng-click="$event.stopPropagation()"> |
| 4 | 4 | ||
| ... | @@ -22,7 +22,7 @@ | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | ||
| 23 | <div class="image-manager-sidebar"> | 23 | <div class="image-manager-sidebar"> |
| 24 | <h2>Images</h2> | 24 | <h2>Images</h2> |
| 25 | - <drop-zone upload-url="@{{getUploadUrl()}}" event-success="uploadSuccess"></drop-zone> | 25 | + <drop-zone upload-url="@{{getUploadUrl()}}" uploaded-to="@{{uploadedTo}}" event-success="uploadSuccess"></drop-zone> |
| 26 | <div class="image-manager-details anim fadeIn" ng-show="selectedImage"> | 26 | <div class="image-manager-details anim fadeIn" ng-show="selectedImage"> |
| 27 | 27 | ||
| 28 | <hr class="even"> | 28 | <hr class="even"> | ... | ... |
| 1 | 1 | ||
| 2 | <div class="notification anim pos" @if(!Session::has('success')) style="display:none;" @endif> | 2 | <div class="notification anim pos" @if(!Session::has('success')) style="display:none;" @endif> |
| 3 | - <i class="zmdi zmdi-check-circle"></i> <span>{{ Session::get('success') }}</span> | 3 | + <i class="zmdi zmdi-check-circle"></i> <span>{!! nl2br(htmlentities(Session::get('success'))) !!}</span> |
| 4 | +</div> | ||
| 5 | + | ||
| 6 | +<div class="notification anim warning stopped" @if(!Session::has('warning')) style="display:none;" @endif> | ||
| 7 | + <i class="zmdi zmdi-info"></i> <span>{!! nl2br(htmlentities(Session::get('warning'))) !!}</span> | ||
| 4 | </div> | 8 | </div> |
| 5 | 9 | ||
| 6 | <div class="notification anim neg stopped" @if(!Session::has('error')) style="display:none;" @endif> | 10 | <div class="notification anim neg stopped" @if(!Session::has('error')) style="display:none;" @endif> |
| 7 | - <i class="zmdi zmdi-alert-circle"></i> <span>{{ Session::get('error') }}</span> | 11 | + <i class="zmdi zmdi-alert-circle"></i> <span>{!! nl2br(htmlentities(Session::get('error'))) !!}</span> |
| 8 | </div> | 12 | </div> | ... | ... |
| ... | @@ -7,7 +7,11 @@ | ... | @@ -7,7 +7,11 @@ |
| 7 | <h1>Search Results <span class="text-muted">{{$searchTerm}}</span></h1> | 7 | <h1>Search Results <span class="text-muted">{{$searchTerm}}</span></h1> |
| 8 | 8 | ||
| 9 | <p> | 9 | <p> |
| 10 | + | ||
| 11 | + @if(count($pages) > 0) | ||
| 10 | <a href="/search/pages?term={{$searchTerm}}" class="text-page"><i class="zmdi zmdi-file-text"></i>View all matched pages</a> | 12 | <a href="/search/pages?term={{$searchTerm}}" class="text-page"><i class="zmdi zmdi-file-text"></i>View all matched pages</a> |
| 13 | + @endif | ||
| 14 | + | ||
| 11 | 15 | ||
| 12 | @if(count($chapters) > 0) | 16 | @if(count($chapters) > 0) |
| 13 | | 17 | | ... | ... |
| ... | @@ -88,8 +88,11 @@ class EntityTest extends TestCase | ... | @@ -88,8 +88,11 @@ class EntityTest extends TestCase |
| 88 | $this->asAdmin() | 88 | $this->asAdmin() |
| 89 | // Navigate to page create form | 89 | // Navigate to page create form |
| 90 | ->visit($chapter->getUrl()) | 90 | ->visit($chapter->getUrl()) |
| 91 | - ->click('New Page') | 91 | + ->click('New Page'); |
| 92 | - ->seePageIs($chapter->getUrl() . '/create-page') | 92 | + |
| 93 | + $draftPage = \BookStack\Page::where('draft', '=', true)->orderBy('created_at', 'desc')->first(); | ||
| 94 | + | ||
| 95 | + $this->seePageIs($draftPage->getUrl()) | ||
| 93 | // Fill out form | 96 | // Fill out form |
| 94 | ->type($page->name, '#name') | 97 | ->type($page->name, '#name') |
| 95 | ->type($page->html, '#html') | 98 | ->type($page->html, '#html') | ... | ... |
tests/Entity/PageDraftTest.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +class PageDraftTest extends TestCase | ||
| 5 | +{ | ||
| 6 | + protected $page; | ||
| 7 | + protected $pageRepo; | ||
| 8 | + | ||
| 9 | + public function setUp() | ||
| 10 | + { | ||
| 11 | + parent::setUp(); | ||
| 12 | + $this->page = \BookStack\Page::first(); | ||
| 13 | + $this->pageRepo = app('\BookStack\Repos\PageRepo'); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + public function test_draft_content_shows_if_available() | ||
| 17 | + { | ||
| 18 | + $addedContent = '<p>test message content</p>'; | ||
| 19 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 20 | + ->dontSeeInField('html', $addedContent); | ||
| 21 | + | ||
| 22 | + $newContent = $this->page->html . $addedContent; | ||
| 23 | + $this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]); | ||
| 24 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 25 | + ->seeInField('html', $newContent); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public function test_draft_not_visible_by_others() | ||
| 29 | + { | ||
| 30 | + $addedContent = '<p>test message content</p>'; | ||
| 31 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 32 | + ->dontSeeInField('html', $addedContent); | ||
| 33 | + | ||
| 34 | + $newContent = $this->page->html . $addedContent; | ||
| 35 | + $newUser = $this->getNewUser(); | ||
| 36 | + $this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]); | ||
| 37 | + $this->actingAs($newUser)->visit($this->page->getUrl() . '/edit') | ||
| 38 | + ->dontSeeInField('html', $newContent); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public function test_alert_message_shows_if_editing_draft() | ||
| 42 | + { | ||
| 43 | + $this->asAdmin(); | ||
| 44 | + $this->pageRepo->saveUpdateDraft($this->page, ['html' => 'test content']); | ||
| 45 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 46 | + ->see('You are currently editing a draft'); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public function test_alert_message_shows_if_someone_else_editing() | ||
| 50 | + { | ||
| 51 | + $nonEditedPage = \BookStack\Page::take(10)->get()->last(); | ||
| 52 | + $addedContent = '<p>test message content</p>'; | ||
| 53 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 54 | + ->dontSeeInField('html', $addedContent); | ||
| 55 | + | ||
| 56 | + $newContent = $this->page->html . $addedContent; | ||
| 57 | + $newUser = $this->getNewUser(); | ||
| 58 | + $this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]); | ||
| 59 | + | ||
| 60 | + $this->actingAs($newUser) | ||
| 61 | + ->visit($this->page->getUrl() . '/edit') | ||
| 62 | + ->see('Admin has started editing this page'); | ||
| 63 | + $this->flushSession(); | ||
| 64 | + $this->visit($nonEditedPage->getUrl() . '/edit') | ||
| 65 | + ->dontSeeInElement('.notification', 'Admin has started editing this page'); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public function test_draft_pages_show_on_homepage() | ||
| 69 | + { | ||
| 70 | + $book = \BookStack\Book::first(); | ||
| 71 | + $this->asAdmin()->visit('/') | ||
| 72 | + ->dontSeeInElement('#recent-drafts', 'New Page') | ||
| 73 | + ->visit($book->getUrl() . '/page/create') | ||
| 74 | + ->visit('/') | ||
| 75 | + ->seeInElement('#recent-drafts', 'New Page'); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + public function test_draft_pages_not_visible_by_others() | ||
| 79 | + { | ||
| 80 | + $book = \BookStack\Book::first(); | ||
| 81 | + $chapter = $book->chapters->first(); | ||
| 82 | + $newUser = $this->getNewUser(); | ||
| 83 | + | ||
| 84 | + $this->actingAs($newUser)->visit('/') | ||
| 85 | + ->visit($book->getUrl() . '/page/create') | ||
| 86 | + ->visit($chapter->getUrl() . '/create-page') | ||
| 87 | + ->visit($book->getUrl()) | ||
| 88 | + ->seeInElement('.page-list', 'New Page'); | ||
| 89 | + | ||
| 90 | + $this->asAdmin() | ||
| 91 | + ->visit($book->getUrl()) | ||
| 92 | + ->dontSeeInElement('.page-list', 'New Page') | ||
| 93 | + ->visit($chapter->getUrl()) | ||
| 94 | + ->dontSeeInElement('.page-list', 'New Page'); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | +} |
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment