diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e28e69132..76981253b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,6 +1,6 @@ --- name: Bug report -about: Create a report to help us improve +about: Report a bug in the software title: '' labels: '' assignees: '' diff --git a/.github/ISSUE_TEMPLATE/initial-instance-configuration.md b/.github/ISSUE_TEMPLATE/initial-instance-configuration.md new file mode 100644 index 000000000..09a41b1f5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/initial-instance-configuration.md @@ -0,0 +1,57 @@ +--- +name: Initial instance configuration +about: Difficulty configuring a CryptPad instance +title: CONFIG +labels: configuration +assignees: '' + +--- + +We receive many issues from people that have tried to set up a new CryptPad instance that does not load any of the interactive editors or which mostly works but has particular problems with the sheet editor. + +Before you create an issue: + +## Confirm that the problem stems from your instance and not from your browser + +Not all browsers support CryptPad correctly, and various browser extensions interfere with its intended behaviour. + +https://CryptPad.fr is a good reference point that you can use to confirm that your browser can load a correctly configured instance. If you can't load CryptPad.fr then the problem may be with your browser, its configuration, or one of its active extensions. + +## See your instance's checkup page + +If your instance is able to at least partially load some pages then you should be able to access the diagnostic page `http(s):///checkup/`. It will perform some automated tests of your instance's configuration and will provide hints indicating: + +1. what is incorrect about your configuration +2. what to change in order to correct the problem + +## Write down the exact steps you followed to configure your instance + +0. Provide the URL of the guide you followed +1. Confirm that your system has the necessary pre-requisites + * Did you fetch the source code with `git` as recommended? + * Have you installed the recommend version of Nodejs (12.14.0) using [NVM](https://github.com/nvm-sh/nvm)? + * Have you installed `bower` using `npm`? + * Have you fetched the latest source code? Run `git branch` and confirm that it returns either `main` or [the latest of our releases](github.com/xwiki-labs/cryptpad/releases/latest). +2. Did you copy `cryptpad/config/config.example.js` to `cryptpad/config/config.js`, read the comments, and edit the fields which are described as being necessary for a production environment? +3. Did you restart the application server (`server.js`) after making configuration changes? +4. Are you running NGINX as a reverse proxy as we recommend? +5. Have you generated an SSL certificate that is valid for both the domains that are required by the sandboxing system? +6. Do the domains in your NGINX conf match those in `cryptpad/config/config.js`? + +## Review the steps you took + +If the answer to any of the above questions is _No_ then that is the most likely cause of your difficulty. + +Identifying the problem on your own reduces the time we spend answering GitHub issues and leaves more time to fix actual bugs and develop new features. + +## Create a detailed report + +If you believe you've done all of those steps correctly then proceed with creating an issue with the following: + +0. A concise description of the problem you're experiencing and why you believe it stems from a bug in the software and not a configuration issue +1. The list of all the steps you wrote down when following our instructions above +2. A link to your instance so we can easily load your `/checkup/` page for ourselves +3. A list of any errors visible in your browser's console on whichever page is not behaving as expected +4. A list of any further steps you've taken to debug the problem on your own + +Finally, remove the text of this issue template and leave only the content you've written. diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dd0f5091..bcb7e9230 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,50 +1,164 @@ -# Pending +# WIP -* PRs - * comment config.js about supporting multiple domains in httpUnsafeOrigin - * add decreePath - * explicitly pass archivePath when initializing stores - * fix incorrect API in `scripts/migrations/migrate-tasks-v1.js` -* login/register - * delete login block when deleting account - * more careful checks when changing user password -* checkup page - * fixed typo - * progress bar - * test - * websockets - * sandbox CSP - * login block -* admin page - * support responses to closed tickets - * collapse very long messages -* open properties menu for pads that aren't stored in your drive -* help menu that only links to docs - * remove unused (nested) keys -* display survey URL -* support 'KB' in Util.magnitudeOfBytes -* degraded mode - * decide on a number -* sheets - * fix naming collisions between images in spreadsheets - * degraded mode not supported - * getPropChannels - * pinning? - * oo rebuild - * OnlyOffice v6.2 - * some buttons that we were hiding have new ids and needed to be hidden again -* translations - * updated catch-phrase (Collaboration suite\nend-to-end-encrypted and open-source -* CKEditor - * cursor jump when clicking on a comment bubble - * keybindings for common styles - * test if this affects scroll position (it shouldn't) - * check that CTRL-space doesn't mess with anything and that it is what Google uses - * test on Mac -* nodrive - * load anonymous accounts without creating a drive - * faster load time, less junk on the server +* fix opening links from temporary shared folders on iphone or other contexts that do not support shared workers +* add checkup test for disabling google FLoC +* update lodash devDependency +# 4.5.0 + +## Goals + +This release cycle we aimed to complete three major milestones: the official release of our calendar app, the ability for admins to close registration on their instance, and the deployment of the admin section of our [official documentation](https://docs.cryptpad.fr/en/admin_guide/index.html). We spent the remainder of our time addressing a growing backlog of issues on GitHub by fixing a number of weird bugs. + +## Update notes + +This release includes a new GitHub issue template (`cryptpad/.github/ISSUE_TEMPLATE/initial-instance-configuration.md`). The intent of this file is to make it clear that _Bug Reports_ are for intended for bugs in the software itself, not for soliciting help in configuring your personal server. Such issues take away time that we'd rather spend improving the platform for everybody's benefit, rather than for single administrators. + +Sometimes difficulty configuring an instance does stem from an actual bug, however, most of the time these issues relate to the use of an unsupported configuration or failure to correctly follow installation instructions. The issue template includes some basic debugging steps which should identify the vast majority of problems. Beyond its primary goal of narrowing the scope of our issue tracker, we hope it will also be useful as an offline reference for administrators attempting to debug their instance. + +This template references the /checkup/ page that we've been steadily improving over the last few releases. It now includes even more tests to diagnose instance configuration problems, each with their own messages that provide some fairly detailed hints about what is wrong when an error is detected. This release introduces a number of tests that print _warnings_ that won't break an instance but might detract from users' experience. We recommend checking this page on your instance with each release as we will continue to improve it on an regular basis, and it might detect some errors of which you were unaware. + +Otherwise, this release includes some changes to the provided example NGINX config file. It now includes a header designed to disable clients' participation in Google's [FLoC network](https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea), as well as some basic rules related to the addition of our calendar app and OnlyOffice's two remaining editors (which are still not officially supported despite their inclusion here). + +Lastly, any instance administrators that have had to customize their instance in order to disable registration can instead rely on a built-in feature that is available on the main page of the admin panel. Checking the "Close registration" checkbox will cause the application server to reject the creation of new "login blocks" (which store users' encrypted account credentials) while permitting existing users to change their passwords. Clients will be informed that registration is closed via the `/api/config` endpoint, causing the registration page to display a notice instead of the usual form. You may need to use the `FLUSH CACHE` button which can found on the same page of the admin panel in order to force clients to load the updated server config. + +To update from 4.4.0 to 4.5.0: + +1. Apply the documented NGINX configuration +2. Stop your server +3. Get the latest code with git +4. Install the latest dependencies with `bower update` and `npm i` +5. Restart your server + +## Features + +* We included a first version of our new calendar app in our last release, however, it was only accessible by URL as there were no links to it in the UI. We've spent time implementing the basic features we expect of any of our apps, including translated UI text (the first version was mostly for us to test) and the ability to import/export .ics files (via ical.js), and the ability to view and store a calendar shared via its URL. It also introduces support for configurable reminders (which can be disabled via the _notifications_ panel of your settings page) and fixes a number of style issues that occurred on small screens. You can access the calendar app via the _user admin menu_ found at the top-right corner of your screen. +* The _What-is-CryptPad_ page now includes the logo of our latest sponsor: [NGI DAPSI](https://dapsi.ngi.eu) (the Data and Portability Services Incubator). DAPSI is another branch of the European Next Generation Internet initiative which has already done so much for our project. Over the next nine months we will use their funding and mentorship to improve CryptPad's interoperability with other services via support for open and de-facto file formats and increasingly intuitive workflows for import and export of your documents. There is already a lot of demand for this functionality, so we're very grateful to finally have the support necessary to take on this big project. +* We've merged a contribution that implements a preference for the rich text editor to open links in a single click instead of treating them as text with a clickable bubble that contains a link. This can be configured on the rich text panel of your settings page. +* The _File_ menu in our apps now includes a _Store in CryptDrive_. This option appears when you have not already stored the document you are currently viewing and when the prompt to store the file has been dismissed or intentionally suppressed via the _never ask_ setting for pad storage. +* We've added support for the display of a configurable _Roadmap_ URL in the footer that can be found on our static pages. This is included mostly for our own purposes of increasing the visibility of the project's planned development, but administrators can also use it however they want to keep their own users informed of their upcoming plans. This value can be set via the host instance's `customize/application_config.js`. An example is included in `cryptpad/www/common/application_config_internal.js`. +* Following the addition of some basic telemetry in our 4.3.1 release we observed that about 20% of newly registered users actually opened the _What is CryptPad_ document which was automatically created in their drive. As such, we've removed the code responsible for its creation along with the translations of its text. New users will instead be directed to read our docs. + +## Bug fixes + +* Our 4.4.0 release included functionality allowing administrators to broadcast notifications to all the users of their instance. Since then, we noticed that clients were incorrectly "pinning" the log file which stores a record of all messages broadcast in this fashion. In other words, they were informing the server that it should continue to store this file on their behalf and that its size should count against their storage quota. We added an explicit exception to code responsible for generating the list of documents that should be "pinned". +* Right-clicking on rendered markdown extensions in the code editor's preview pane opens a custom menu that offers some basic options. This menu incorrectly displayed some options that were appropriate for encrypted uploads, but not for other extensions such _markmap_, _mathjax_, and _mermaid_. We now handle these explicitly and provide options to export to the relevant image format. +* In one more example of a long list of browser quirks that have broken CryptPad in bizarre ways, we learned that the web engine that used by all browsers available for iPhone incorrectly handles click events on elements that contain buttons. Rather than emitting a single click event in response to user action, the engine seems to emit an event for each sibling _button_ tag regardless of whether it is visible. The HTML structure of the list/grid view mode toggle in the drive caused the engine to emit two click events, immediately toggling the view mode away from and back to its original state. Since Apple has an anti-competitive policy requiring every browser to use the engine they provide (as opposed to independent ones which include speed-boosting optimizations, modern features, and frequent bug fixes), this means that iPhone users could not switch to an alternative. Anyway, we changed the HTML structure that was working well in literally every other browser to make this better for iPhone users. +* There were some CSS selectors in the code app that caused the preview pane to be hidden on narrow screens. This rule is no longer applied when the client loads in embed/present mode, which disable all other UI to display only the preview pane. +* We identified and addressed an unhandled error on the registration page which could have caused clients to act as though the upload of their accounts encrypted credentials had succeeded when it had not. This could result in the inability to access their content on successive login attempts. +* The whiteboard editor allows users to upload images for inclusion in their whiteboard up to a certain size. It was brought to our attention that the enforced size limit was compared against the size of the image after it had been encoded, while the resulting error message suggested that it was measuring the size of the image as uploaded. We've updated this limit to account for the encoding's overhead. +* We've added some extra error handling to diffDOM, the library we use to compute and apply a minimal set of patches to a document. It was brought to our attention that it did not correctly parse and compare some input that is valid in the HTML dialect used to display emails but does not commonly occur in modern browsers. This crashed the renderer with a DOMException error when it tried to apply the malformed attribute. +* Lastly, as usual, we've received a variety of questions and bug reports related to spreadsheets. We've added some guards to prevent the creation of invalid checkpoints. If a generated checkpoint is larger than the maximum file size limit allowed for a particular user we avoid successive attempts to upload within that same session, which avoids spamming the user with repeated warnings of failed uploads. We updated the notice that informs users when conversion to Office formats is not supported in their browser to recommend a recent version of Firefox or Chrome, and displayed the same notice when importing. We also updated the function which checks whether the APIs required for conversion were present, as it checked for SharedArrayBuffers and Atomics but not WebAssembly, all of which are necessary. Finally, we made some minor changes that allow the sheet editor to lock and unlock faster when a checkpoint is loaded and applied, resulting in less disruption to the user's work. + +# 4.4.0 + +## Goals + +Our main goal for this release was to complete the first steps of our ["Dialogue" project](https://nlnet.nl/project/CryptPadForms/), which will introduce surveys into CryptPad. We've also put considerable effort towards addressing some configuration issues, correcting some inconsistently translated UI, and writing some new documentation. + +## Update notes + +This release removes the default privacy policy that has been included in CryptPad up until now. It included some assertions that were true of our own instance (CryptPad.fr) which we couldn't guarantee on third-party instances. We've updated our custom configuration to link to a privacy policy that was written in a rich text pad. You can do the same on your instance by editing `cryptpad/customize/application_config.js` to include the absolute URL of your instance, like so: `AppConfig.privacy = "https://cryptpad.your.website/privacy.html";`. + +We've clarified a point about telemetry in the notes of our 4.3.1 release. The text suggested that users on your instance would send telemetry to OUR webserver. It has been clarified to reflect that telemetry from your users is only ever sent to your instance. + +We've spent some time working on improving our (officially) unreleased integrations of OnlyOffice's presentation and document editors. We've advised against enabling these editors on your instance. This release includes changes that may not be fully backwards compatible. If your users rely on either editor we advise that you not update until they have had an opportunity to back up their documents. We still aren't officially supporting either editor and we may make further breaking changes in the future. Consider this a warning and not an advertizement of their readiness! + +This release also includes changes to the recommended NGINX configuration. Compare your instance's config against `cryptpad/docs/example.nginx.conf` and apply all the new changes before updating. In particular, you'll want to pay attention to the configuration for a newly exposed server API (`/api/broadcast`). This should work much the same as `/api/config`, so if you're using a non-standard configuration that uses more than one server you may want to proxy it in a similar fashion. + +Lastly, we've made some big improvements to the `/checkup/` page which performs some basic tests to confirm that your instance is configured correctly. It now provides some much more detailed descriptions of what might be wrong and how you can start debugging any issues that were identified. If you experience any problems after updating please review this page to assess your instance for any known issues before asking for help. + +To update from 4.3.1 to 4.4.0: + +1. Apply the documented NGINX configuration +2. Stop your server +3. Get the latest code with git +4. Install the latest dependencies with `bower update` and `npm i` +5. Restart your server + +This release requires updates to both clientside and serverside dependencies. **You will experience problems if you skip any of the above steps.** + +## Features + +* 4.4.0 includes a basic version of a calendar app. There are no links to it anywhere in the platform, its translations are hardcoded, and its title includes the text **BETA**. It's included in this release so that we can test and improve it for the next release, however, it should not be considered stable. Use it at your own risk! Our plan for this app is to offer the ability to set and review reminders for deadlines in CryptPad. We haven't secured funding for more advanced functionality, however, our team is available for sponsored development if you'd like to provide funding to include such improvements in our short-term roadmap. +* The admin panel now includes several closely related features in its "broadcast" tab, which allows administrators to send a few types of notifications to all users: + 1. _Maintenance notices_ inform users that the service may be unavailable during a specified time range. + 2. _Survey notices_ inform users that the instance administrators have published a new survey and would like their feedback. We plan to use this on CryptPad.fr to perform some voluntary user studies on an ongoing basis. + 3. _Broadcast messages_ allow admins to send all users a custom message with optional localization in their users' preferred language. +* The drive now includes a "Getting started" message and a link to our docs, like all our other apps. This replaces the creation of a personal "What is CryptPad" pad in the user's drive when they register. +* We recently wrote some scripts to automatically review our translations. This exposed some inconsistencies and incorrectly applied attributes in translations that included HTML. Since it's not reasonable to expect translators to know HTML, we've taken some steps to remove all but the most basic markup from translatable messages. Instead, more advanced attributes are applied via JavaScript. This makes it easier than ever to translate CryptPad as well as providing a more consistent experience to those using translations written by contributors. + +## Bug fixes + +* Premium users are now prompted to cancel their subscriptions before deleting their accounts. +* The /logout/ page will now clear users' local document cache. Admins can recommend that users try loading this page when users are mysteriously unable to load their drive (or that of a team). If you find that this solves a user's problem, please report their exact problem so we can investigate the underlying cause. +* The _support_ page guards against type errors that appear to have been caused by third-party extensions interfering with some browser APIs and rewriting URLs. +* We found that anonymous users who had not created a drive were not able to use the "Make a copy" functionality on a pad that they were viewing. This has been fixed. +* We noticed that under some unknown circumstances it was possible for users to store documents with invalid document IDs in their drive. We've added a few guards that detect these invalid channels and we're working on a solution to automatically repair them, if possible. +* Links to anchors in read-only rich text documents now navigate to the correct section of the document rather than opening a new tab. +* We've made a large number of improvements to our OnlyOffice integration. This will primarily affect the sheet app, but it also paves the way for us to introduce presentations and text documents in a future release. + * We now inform OnlyOffice of user-list changes, which should fix the incorrect display of users names when they lock a portion of a document. + * Text documents and presentations use a different data format than sheets for locking the document. We've adjusted our code to handle these formats. + * We've fixed some lock-related errors in sheets that could be triggered when receiving checkpoints from other users while editing in strict mode. + * We've adjusted some CSS selectors intended to hide parts of OnlyOffice's UI that are invalid within CryptPad, since those elements' IDs have changed since the last version. + * OnlyOffice's cursors now use your CryptPad account's preferred color. + * We now handle some errors that occurred when documents were migrated by a user editing a sheet in embed mode. + * OnlyOffice modified some of the APIs used to lock a document, so we've adjusted our code to match. +* We found and fixed a race condition which could be triggered when loading a shared folder included in more than one of your user or team drives. + +# 4.3.1 + +This minor release addresses some bugs discovered after deploying and tagging 4.3.0 + +* We found that some browser extensions interfered with checks to determine whether a registered user was correctly logged in, which resulted in some disabled functionality. If you are running extensions that actively delete the tokens that keep you logged your session should now stay alive until you close all its active tabs, after which you will have to log back in. +* Our 4.2.0 update introduced a new internal format for spreadsheets which broke support for spreadsheet templates using the older format. This release implements a compatibility layer. +* We fixed some minor bugs in our rich text editor. Section links in the table of contents now navigate correctly. Adding a comment to a link no longer prevents clicking on that link. +* A race condition that caused poll titles to reset occasionally has been fixed. +* We've added a little bit of telemetry to tell the application server when a newly registered user opens the new user guide which is automatically added to their drive. We're considering either rewriting or removing this guide, so it's helpful to be able to determine how often people actually read it. +* An error introduced in 4.3.0 was preventing the creation of new teams. It's been fixed. +* 4.3.0 temporarily broke the sheet editor for iPad users. Migrations to a new internal format that were run while the editor was in a bad state produced some invalid data that prevented sheets from loading correctly. This release improves the platforms ability to recover from bad states like this and improves its ability to detect the kind of errors we observed. + +# 4.3.0 (D) + +## Goals + +This release is a continuation of our recent efforts to stabilize the platform, fixing small bugs and inconsistencies that we missed when developing larger features. In the meantime we've received reports of the platform performing poorly under various unusual circumstances, so we've developed some targeted fixes to both improve user experience and decrease the load on our server. + +## Update notes + +This release should be fairly simple for admins. + +To update from 4.2.1 to 4.3.0: + +1. Stop your server +2. Get the latest code with git +3. Install the latest dependencies with `bower update` and `npm i` +4. Restart your server + +## Features + +* We're introducing a "degraded mode" for most of our editors (all except polls and sheets). This follows reports we received that CryptPad performed poorly in settings where a relatively large number of users with *edit* rights were connected simultaneously. To alleviate this, some non-essential features will be disabled when a number of concurrent editors is reached, in order to save computing power on client devices. The user-list will stop being updated as users join and leave, users cursors will stop being displayed, and the chat will not be disabled. Sessions will enter this mode when 8 or more editors are present. This threshold can be configured via `customize/application_config.js` by setting a `degradedLimit` attribute. +* CryptPad was recently used to distribute some high-profile documents. For the first time we were able to observe our server supporting more than 1000 concurrent viewers in a single pad and around 350000 unique visitors over the course of a few days. While the distributed document incurred very little load, CryptPad created a drive for each visitor the first time they visited. Most of these drives were presumably abandoned as these users did not return to create or edit their own documents. Such users that directly load an existing document without having previously visited the platform will no longer create a drive automatically, unless they explicitly visit a page which requires it. This behaviour is supported in most of our editors except sheets and polls. This should result in faster load times for new users, but just in case it causes any issues we've made it easy to disable. Instance admins can disable "no-drive mode" via `customize/application_config.js` by setting `allowDrivelessMode` to `false`. +* We've updated our sheet editor to use OnlyOffice 6.2, which includes support for pivot tables, among a range of other improvements. +* Our rich text editor now features some keyboard shortcuts to apply some commonly used styles: + * heading size 1-6: ctrl+alt+1-6 + * "div": ctrl+alt+8 + * "preformatted": ctrl+alt+9 + * paragraph: ctrl+alt+0 + * remove styles from selection: ctrl+space +* We've removed a large number of strings that were included in the "Getting started" box that was displayed to new users in each of our editors. Instead, this box simply contains a link to the relevant page in our documentation. Our intent is to both simplify the interface for newcomers and reduce the number of strings that require translation. +* We've continued to progress on our "checkup page" which performs some routine checks to see whether the host instance is correctly configured. While its hints are not especially helpful for admins without reading the code to understand what they are testing, they do detect a fairly wide range of issues and have already helped us to identify some inconsistencies in our recommended configuration. We plan to link directly from this page to the relevant sections of a configuration guide an in upcoming release. +* The admin support ticket interface has been updated to collapse very long messages in response to some ticket threads submitted in the last few weeks. We also found that sometimes we needed more information after a ticket had been closed, so we added the ability to re-open closed tickets. +* Some time ago we removed the "Survey link" option from the user admin dropdown menu (found in the top-right corner of the page). This release re-enables it for instances that explicitly provide a link to a survey, however, we no longer provide a link to a survey by default. + +## Bug fixes + +* We finally reviewed and merged a number of pull-requests that had been pending for some time. Collectively, they fixed some configuration issues and type errors in some of our older scripts. +* Sheets can now contain multiple images with the same name, whereas before they would conflict and one would be displayed multiple times. +* A recent change in our code to conditionally display size measurements in different magnitudes (GB, MB) removed support for Kilobytes (KB). This release restores the previous behaviour. +* We believe we've identified and corrected an issue that caused the rich text editor to scroll to the top of the document when the button to add a comment was clicked. +* We recently made it such that documents owned by a particular user would not be automatically re-added to that user's drive when they viewed them. This change revealed a number of odd cases where various commands (destroy, add password, get document size, etc.) did not work as expected unless the document was first added to their drive. We reviewed many of these features and corrected the underlying issues that caused these commands to fail. +* We performed a similar review of various commands related to user accounts and identified a number of issues that caused account deletion to fail. # 4.2.1 diff --git a/bower.json b/bower.json index f9a3dc5be..82a9931ea 100644 --- a/bower.json +++ b/bower.json @@ -41,7 +41,7 @@ "diff-dom": "2.1.1", "nthen": "0.1.7", "open-sans-fontface": "^1.4.2", - "bootstrap-tokenfield": "^0.12.1", + "bootstrap-tokenfield": "0.12.1", "localforage": "^1.5.2", "html2canvas": "^0.4.1", "croppie": "^2.5.0", diff --git a/config/config.example.js b/config/config.example.js index 855a848e3..f53f3bb5b 100644 --- a/config/config.example.js +++ b/config/config.example.js @@ -54,7 +54,7 @@ module.exports = { * and it may have unintended consequences in practice. * */ - httpUnsafeOrigin: 'http://localhost:3000/', + httpUnsafeOrigin: 'http://localhost:3000', /* httpSafeOrigin is the URL that is used for the 'sandbox' described above. * If you're testing or developing with CryptPad on your local machine then @@ -162,15 +162,6 @@ module.exports = { */ //blockDailyCheck: false, - /* - * By default users get 50MB of storage by registering on an instance. - * You can set this value to whatever you want. - * - * hint: 50MB is 50 * 1024 * 1024 - */ - //defaultStorageLimit: 50 * 1024 * 1024, - - /* ===================== * STORAGE * ===================== */ @@ -226,29 +217,6 @@ module.exports = { */ //maxUploadSize: 20 * 1024 * 1024, - /* - * CryptPad allows administrators to give custom limits to their friends. - * add an entry for each friend, identified by their user id, - * which can be found on the settings page. Include a 'limit' (number of bytes), - * a 'plan' (string), and a 'note' (string). - * - * hint: 1GB is 1024 * 1024 * 1024 bytes - */ -/* - customLimits: { - "[cryptpad-user1@my.awesome.website/YZgXQxKR0Rcb6r6CmxHPdAGLVludrAF2lEnkbx1vVOo=]": { - limit: 20 * 1024 * 1024 * 1024, - plan: 'insider', - note: 'storage space donated by my.awesome.website' - }, - "[cryptpad-user2@my.awesome.website/GdflkgdlkjeworijfkldfsdflkjeEAsdlEnkbx1vVOo=]": { - limit: 10 * 1024 * 1024 * 1024, - plan: 'insider', - note: 'storage space donated by my.awesome.website' - } - }, -*/ - /* Users with premium accounts (those with a plan included in their customLimit) * can benefit from an increased upload size limit. By default they are restricted to the same * upload size as any other registered user. diff --git a/customize.dist/images/logo_ngi_dapsi.png b/customize.dist/images/logo_ngi_dapsi.png new file mode 100644 index 000000000..efd52c482 Binary files /dev/null and b/customize.dist/images/logo_ngi_dapsi.png differ diff --git a/customize.dist/login.js b/customize.dist/login.js index 035a11d72..74e5e86f6 100644 --- a/customize.dist/login.js +++ b/customize.dist/login.js @@ -135,10 +135,6 @@ define([ Exports.mergeAnonDrive = 1; }; - var setCreateReadme = function () { - Exports.createReadme = 1; - }; - Exports.loginOrRegister = function (uname, passwd, isRegister, shouldImport, cb) { if (typeof(cb) !== 'function') { return; } @@ -372,7 +368,6 @@ define([ proxy.curvePrivate = opt.curvePrivate; proxy.login_name = uname; proxy[Constants.displayNameKey] = uname; - setCreateReadme(); if (shouldImport) { setMergeAnonDrive(); } else { @@ -397,7 +392,7 @@ define([ // send an RPC to store the block which you created. console.log("initializing rpc interface"); - Pinpad.create(RT.network, RT.proxy, waitFor(function (e, _rpc) { + Pinpad.create(RT.network, Block.keysToRPCFormat(res.opt.blockKeys), waitFor(function (e, _rpc) { if (e) { waitFor.abort(); console.error(e); // INVALID_KEYS @@ -419,7 +414,10 @@ define([ var blockRequest = Block.serialize(JSON.stringify(toPublish), res.opt.blockKeys); rpc.writeLoginBlock(blockRequest, waitFor(function (e) { - if (e) { return void console.error(e); } + if (e) { + console.error(e); + return void cb(e); + } console.log("blockInfo available at:", blockHash); LocalStore.setBlockHash(blockHash); @@ -436,9 +434,6 @@ define([ if (Exports.mergeAnonDrive) { loginOpts.mergeAnonDrive = 1; } - if (Exports.createReadme) { - loginOpts.createReadme = 1; - } h = Hash.getLoginURL(h, loginOpts); var parser = document.createElement('a'); @@ -539,6 +534,9 @@ define([ }); }); break; + case 'E_RESTRICTED': + UI.errorLoadingScreen(Messages.register_registrationIsClosed); + break; default: // UNHANDLED ERROR hashing = false; UI.errorLoadingScreen(Messages.login_unhandledError); diff --git a/customize.dist/messages.js b/customize.dist/messages.js index b2a264b70..977405db1 100755 --- a/customize.dist/messages.js +++ b/customize.dist/messages.js @@ -120,10 +120,6 @@ define(req, function(AppConfig, Default, Language) { } }; - messages.driveReadme = '["BODY",{"class":"cke_editable cke_editable_themed cke_contents_ltr cke_show_borders","contenteditable":"true","spellcheck":"false","style":"color: rgb(51, 51, 51);"},' + - '[["H1",{},["'+messages.readme_welcome+'"]],["P",{},["'+messages.readme_p1+'"]],["P",{},["'+messages.readme_p2+'"]],["HR",{},[]],["H2",{},["'+messages.readme_cat1+'",["BR",{},[]]]],["UL",{},[["LI",{},["'+messages._getKey("readme_cat1_l1", ['",["STRONG",{},["'+messages.newButton+'"]],"', '",["STRONG",{},["'+messages.type.pad+'"]],"'])+'"]],["LI",{},["'+messages.readme_cat1_l2+'"]],["LI",{},["'+messages._getKey("readme_cat1_l3", ['",["STRONG",{},["'+messages.fm_unsortedName+'"]],"'])+'",["UL",{},[["LI",{},["'+messages._getKey("readme_cat1_l3_l1", ['",["STRONG",{},["'+messages.fm_rootName+'"]],"'])+'"]],["LI",{},["'+messages.readme_cat1_l3_l2+'"]]]]]],["LI",{},["'+messages._getKey("readme_cat1_l4", ['",["STRONG",{},["'+messages.fm_trashName+'"]],"'])+'",["BR",{},[]]]]]],["P",{},[["BR",{},[]]]],["H2",{},["'+messages.readme_cat2+'",["BR",{},[]]]],["UL",{},[["LI",{},["'+messages._getKey("readme_cat2_l1", ['",["STRONG",{},["'+messages.shareButton+'"]],"', '",["STRONG",{},["'+messages.edit+'"]],"', '",["STRONG",{},["'+messages.view+'"]],"'])+'"]],["LI",{},["'+messages.readme_cat2_l2+'"]]]],["P",{},[["BR",{},[]]]],["H2",{},["'+messages.readme_cat3+'"]],["UL",{},[["LI",{},["'+messages.readme_cat3_l1+'"]],["LI",{},["'+messages.readme_cat3_l2+'"]],["LI",{},["'+messages.readme_cat3_l3+'",["BR",{},[]]]]]]],' + - '{"metadata":{"defaultTitle":"' + messages.driveReadmeTitle + '","title":"' + messages.driveReadmeTitle + '"}}]'; - return messages; }); diff --git a/customize.dist/pages.js b/customize.dist/pages.js index ff2b90b40..e3ae2b83e 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -4,7 +4,8 @@ define([ '/customize/application_config.js', '/customize/messages.js', 'jquery', -], function (h, Language, AppConfig, Msg, $) { + '/api/config', +], function (h, Language, AppConfig, Msg, $, ApiConfig) { var Pages = {}; Pages.setHTML = function (e, html) { @@ -12,6 +13,36 @@ define([ return e; }; + Pages.externalLink = function (el, href) { + if (!el) { return el; } + el.setAttribute("rel", "noopener noreferrer"); + el.setAttribute("target", "_blank"); + if (typeof(href) === 'string') { + el.setAttribute("href", href); + } + return el; + }; + + // this rewrites URLS to point to the appropriate translation: + // French, German, or English as a default + var documentedLanguages = ['en', 'fr', 'de']; + Pages.localizeDocsLink = function (href) { + try { + var lang = Msg._getLanguage(); + if (documentedLanguages.indexOf(lang) > 0) { + return href.replace('/en/', '/' + lang + '/'); + } + } catch (err) { + console.error(err); + // if it fails just use the default href (English) + } + return href; + }; + + Pages.documentationLink = function (el, href) { + return Pages.externalLink(el, Pages.localizeDocsLink(href)); + }; + var languageSelector = function () { var options = []; var languages = Msg._languages; @@ -45,6 +76,7 @@ define([ }; var footLink = function (ref, loc, text) { + if (!ref) { return; } var attrs = { href: ref, }; @@ -62,15 +94,29 @@ define([ var imprintUrl = AppConfig.imprint && (typeof(AppConfig.imprint) === "boolean" ? '/imprint.html' : AppConfig.imprint); - Pages.versionString = "v4.3.0"; + Pages.versionString = "v4.5.0"; + // used for the about menu Pages.imprintLink = AppConfig.imprint ? footLink(imprintUrl, 'imprint') : undefined; Pages.privacyLink = footLink(AppConfig.privacy, 'privacy'); Pages.githubLink = footLink('https://github.com/xwiki-labs/cryptpad', null, 'GitHub'); Pages.docsLink = footLink('https://docs.cryptpad.fr', 'docs_link'); + Pages.roadmapLink = footLink(AppConfig.roadmap, 'footer_roadmap'); Pages.infopageFooter = function () { + var terms = footLink('/terms.html', 'footer_tos'); // FIXME this should be configurable like the other legal pages + var legalFooter; + + // only display the legal part of the footer if it has content + if (terms || Pages.privacyLink || Pages.imprintLink) { + legalFooter = footerCol('footer_legal', [ + terms, + Pages.privacyLink, + Pages.imprintLink, + ]); + } + return h('footer', [ h('div.container', [ h('div.row', [ @@ -96,12 +142,9 @@ define([ footLink('/contact.html', 'contact'), footLink('https://github.com/xwiki-labs/cryptpad/wiki/Contributors', 'footer_team'), footLink('http://www.xwiki.com', null, 'XWiki SAS'), + Pages.roadmapLink, ]), - footerCol('footer_legal', [ - footLink('/terms.html', 'footer_tos'), - Pages.privacyLink, - Pages.imprintLink, - ]), + legalFooter, ]) ]), h('div.cp-version-footer', [ @@ -114,10 +157,16 @@ define([ Pages.infopageTopbar = function () { var rightLinks; var username = window.localStorage.getItem('User_name'); + var registerLink; + + if (!ApiConfig.restrictRegistration) { + registerLink = h('a.nav-item.nav-link.cp-register-btn', { href: '/register/'}, Msg.login_register); + } + if (username === null) { rightLinks = [ h('a.nav-item.nav-link.cp-login-btn', { href: '/login/'}, Msg.login_login), - h('a.nav-item.nav-link.cp-register-btn', { href: '/register/'}, Msg.login_register) + registerLink, ]; } else { rightLinks = h('a.nav-item.nav-link.cp-user-btn', { href: '/drive/' }, [ diff --git a/customize.dist/pages/contact.js b/customize.dist/pages/contact.js index 88a5053e3..b86ad4480 100644 --- a/customize.dist/pages/contact.js +++ b/customize.dist/pages/contact.js @@ -7,8 +7,13 @@ define([ ], function (Config, h, Msg, Pages, LocalStore) { return function () { - var adminEmail = Config.adminEmail && Config.adminEmail !== 'i.did.not.read.my.config@cryptpad.fr'; + var developerEmail = "contact@cryptpad.fr"; + var adminEmail = Config.adminEmail && [ + 'i.did.not.read.my.config@cryptpad.fr', + developerEmail + ].indexOf(Config.adminEmail) === -1; var adminMailbox = Config.supportMailbox && LocalStore.isLoggedIn(); + return h('div#cp-main', [ Pages.infopageTopbar(), h('div.container.cp-container', [ @@ -110,7 +115,7 @@ define([ ) ), h('div.col-12.col-sm-6.col-md-3.col-lg-3', - h('a.card', {href : "mailto:contact@cryptpad.fr"}, + h('a.card', {href : "mailto:" + developerEmail}, h('div.card-body', h('p', [ h('img', { diff --git a/customize.dist/pages/features.js b/customize.dist/pages/features.js index ff67c6912..ee82d5d67 100644 --- a/customize.dist/pages/features.js +++ b/customize.dist/pages/features.js @@ -146,7 +146,7 @@ define([ ]), ]); var availableFeatures = - (Config.allowSubscriptions && accounts.upgradeURL) ? + (Config.allowSubscriptions && accounts.upgradeURL && !Config.restrictRegistration) ? [anonymousFeatures, registeredFeatures, premiumFeatures] : [anonymousFeatures, registeredFeatures]; diff --git a/customize.dist/pages/index.js b/customize.dist/pages/index.js index f15d1819b..3257126e9 100644 --- a/customize.dist/pages/index.js +++ b/customize.dist/pages/index.js @@ -80,6 +80,12 @@ define([ }); } + var supportText = Pages.setHTML(h('span'), Msg.home_support); + Pages.documentationLink(supportText.querySelector('a'), "https://docs.cryptpad.fr/en/how_to_contribute.html"); + + var opensource = Pages.setHTML(h('p'), Msg.home_opensource); + Pages.externalLink(opensource.querySelector('a'), "https://github.com/xwiki-labs/cryptpad"); + var blocks = [ h('div.row.cp-page-section', [ h('div.col-sm-6', @@ -103,7 +109,7 @@ define([ h('div.row.cp-page-section', [ h('div.col-sm-6', [ h('h2', Msg.home_opensource_title), - Pages.setHTML(h('p'), Msg.home_opensource), + opensource, h('img.small-logo.cp-img-invert', { src: '/customize/images/logo_AGPLv3.svg', alt: 'APGL3 License Logo' @@ -111,7 +117,7 @@ define([ ]), h('div.col-sm-6', [ h('h2', Msg.home_support_title), - Pages.setHTML(h('span'), Msg.home_support), + supportText, subscribeButton, Pages.crowdfundingButton(function () { Feedback.send('HOME_SUPPORT_CRYPTPAD'); diff --git a/customize.dist/pages/login.js b/customize.dist/pages/login.js index 5322c663f..45d3a3707 100644 --- a/customize.dist/pages/login.js +++ b/customize.dist/pages/login.js @@ -2,8 +2,9 @@ define([ '/common/hyperscript.js', '/common/common-interface.js', '/customize/messages.js', - '/customize/pages.js' -], function (h, UI, Msg, Pages) { + '/customize/pages.js', + '/api/config', +], function (h, UI, Msg, Pages, Config) { return function () { return [h('div#cp-main', [ Pages.infopageTopbar(), @@ -32,7 +33,10 @@ define([ ]), h('div.extra', [ h('button.login', Msg.login_login), - h('button#register.cp-secondary', Msg.login_register) + (Config.restrictRegistration? + undefined: + h('button#register.cp-secondary', Msg.login_register) + ) ]) ]), h('div.col-md-3') diff --git a/customize.dist/pages/privacy.js b/customize.dist/pages/privacy.js deleted file mode 100644 index 84a43ad3f..000000000 --- a/customize.dist/pages/privacy.js +++ /dev/null @@ -1,36 +0,0 @@ -define([ - '/common/hyperscript.js', - '/customize/messages.js', - '/customize/pages.js' -], function (h, Msg, Pages) { - return function () { - return h('div#cp-main', [ - Pages.infopageTopbar(), - h('div.container.cp-container.cp-privacy',[ - h('div.row.cp-page-title', h('h1', Msg.policy_title)), - h('h2', Msg.policy_whatweknow), - Pages.setHTML(h('p'), Msg.policy_whatweknow_p1), - - h('h2', Msg.policy_howweuse), - h('p', Msg.policy_howweuse_p1), - h('p', Msg.policy_howweuse_p2), - - h('h2', Msg.policy_whatwetell), - h('p', Msg.policy_whatwetell_p1), - - h('h2', Msg.policy_links), - h('p', Msg.policy_links_p1), - - h('h2', Msg.policy_ads), - h('p', Msg.policy_ads_p1), - - h('h2', Msg.policy_choices), - h('p', Msg.policy_choices_open), - Pages.setHTML(h('p'), Msg.policy_choices_vpn), - ]), - Pages.infopageFooter() - ]); - }; - -}); - diff --git a/customize.dist/pages/register.js b/customize.dist/pages/register.js index c9e28bed4..cf05defa5 100644 --- a/customize.dist/pages/register.js +++ b/customize.dist/pages/register.js @@ -9,11 +9,37 @@ define([ return function () { var urlArgs = Config.requireConf.urlArgs; - return [h('div#cp-main', [ - Pages.infopageTopbar(), - h('div.container.cp-container', [ - h('div.row.cp-page-title', h('h1', Msg.register_header)), - h('div.row.cp-register-det', [ + var tos = $(UI.createCheckbox('accept-terms')).find('.cp-checkmark-label').append(Msg.register_acceptTerms).parent()[0]; + $(tos).find('a').attr({ + href: '/terms.html', + target: '_blank', + tabindex: '-1', + }); + + + var frame = function (content) { + return [ + h('div#cp-main', [ + Pages.infopageTopbar(), + h('div.container.cp-container', [ + h('div.row.cp-page-title', h('h1', Msg.register_header)), + //h('div.row.cp-register-det', content), + ].concat(content)), + ]), + Pages.infopageFooter(), + ]; + }; + + if (Config.restrictRegistration) { + return frame([ + h('div.cp-restricted-registration', [ + h('p', Msg.register_registrationIsClosed), + ]) + ]); + } + + return frame([ + h('div.row.cp-register-det', [ h('div#data.hidden.col-md-6', [ h('h2', Msg.register_notes_title), Pages.setHTML(h('div.cp-register-notes'), Msg.register_notes) @@ -47,16 +73,13 @@ define([ UI.createCheckbox('import-recent', Msg.register_importRecent, true) ]), h('div.checkbox-container', [ - $(UI.createCheckbox('accept-terms')).find('.cp-checkmark-label').append(Msg.register_acceptTerms).parent()[0] + tos, ]), h('button#register', Msg.login_register) ]) ]), - ]), - ]), - - Pages.infopageFooter(), - ])]; + ]) + ]); }; }); diff --git a/customize.dist/pages/what-is-cryptpad.js b/customize.dist/pages/what-is-cryptpad.js index b5d2f8ac4..b1c3de3d0 100644 --- a/customize.dist/pages/what-is-cryptpad.js +++ b/customize.dist/pages/what-is-cryptpad.js @@ -17,6 +17,9 @@ define([ }; return function () { + var xwiki_info = Pages.setHTML(h('span'), Msg.whatis_xwiki_info); + Pages.externalLink(xwiki_info.querySelector('a'), "https://xwiki.com"); + return h('div#cp-main', [ Pages.infopageTopbar(), h('div.container.cp-container', [ @@ -52,7 +55,7 @@ define([ h('div.row.cp-page-section', [ h('div.col-md-6', [ Pages.setHTML(h('h2'), Msg.whatis_drive), - Pages.setHTML(h('spam'), Msg.whatis_drive_info), + Pages.setHTML(h('span'), Msg.whatis_drive_info), ]), h('div.col-md-6', [ h('img.cp-shadow', { @@ -86,12 +89,14 @@ define([ 'https://www.mozilla.org/en-US/moss/'), logoLink('NGI Trust logo', '/customize/images/logo_ngi_trust.png', 'https://www.ngi.eu/ngi-projects/ngi-trust/'), + logoLink('NGI DAPSI LOGO', '/customize/images/logo_ngi_dapsi.png', + 'https://dapsi.ngi.eu/'), ]), ]), h('div.row.cp-page-section', [ h('div.col-md-6', [ Pages.setHTML(h('h2'), Msg.whatis_xwiki), - Pages.setHTML(h('spam'), Msg.whatis_xwiki_info), + xwiki_info, ]), h('div.col-md-6.small-logos', [ h('img', { diff --git a/customize.dist/privacy.html b/customize.dist/privacy.html deleted file mode 100644 index f1cf1b429..000000000 --- a/customize.dist/privacy.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - CryptPad: Collaboration suite, encrypted and open-source - - - - - - - - diff --git a/customize.dist/src/less2/include/alertify.less b/customize.dist/src/less2/include/alertify.less index 2f95a637e..96b8e7cde 100644 --- a/customize.dist/src/less2/include/alertify.less +++ b/customize.dist/src/less2/include/alertify.less @@ -58,12 +58,17 @@ width: 100%; height: 100%; z-index: 100000; // alertify container + outline: none; font: @colortheme_app-font; .cp-checkmark { color: @cryptpad_text_col; } + .cp-admin-message { + color: @cryptpad_text_col; + } + .cp-inline-alert-text { flex: 1; } diff --git a/customize.dist/src/less2/include/colortheme-dark.less b/customize.dist/src/less2/include/colortheme-dark.less index fc17d7d24..588d1888e 100644 --- a/customize.dist/src/less2/include/colortheme-dark.less +++ b/customize.dist/src/less2/include/colortheme-dark.less @@ -13,8 +13,8 @@ whiteboard: #a72ba7; kanban: #8C4; sheet: #40865c; - oodoc: #5170B5; - ooslide: #C65D27; + doc: #5170B5; + presentation: #C65D27; file: #CD2532; } @@ -414,3 +414,15 @@ @cp_whiteboard-board-border: @cryptpad_color_grey_800; @cp_whiteboard-bg: @cp_app-bg; @cp_whiteboard-fg: @cryptpad_text_col; + +// Flatpickr +@cp_flatpickr-bg: @cryptpad_color_grey_800; +@cp_flatpickr-highlight: @cryptpad_color_brand_300; +@cp_flatpickr-highlight-text: @cryptpad_color_grey_800; + +// Calendar + +@cp_calendar-border: @cryptpad_color_grey_600; +@cp_calendar-now: @cryptpad_color_brand_300; +@cp_calendar-now-fg: @cryptpad_color_grey_800; + diff --git a/customize.dist/src/less2/include/colortheme.less b/customize.dist/src/less2/include/colortheme.less index f353758c8..3ab249f9f 100644 --- a/customize.dist/src/less2/include/colortheme.less +++ b/customize.dist/src/less2/include/colortheme.less @@ -13,8 +13,8 @@ whiteboard: #a72ba7; kanban: #8C4; sheet: #40865c; - oodoc: #5170B5; - ooslide: #C65D27; + doc: #5170B5; + presentation: #C65D27; file: #CD2532; } @@ -190,7 +190,7 @@ // Dropdown @cp_dropdown-fg: @cryptpad_text_col; @cp_dropdown-bg: @cryptpad_color_grey_100; -@cp_dropdown-bg-hover: @cryptpad_color_grey_100; +@cp_dropdown-bg-hover: @cryptpad_color_grey_200; @cp_dropdown-bg-active: @cryptpad_color_grey_300; // Rendered Markdown @@ -414,3 +414,14 @@ @cp_whiteboard-board-border: @cryptpad_color_grey_600; @cp_whiteboard-bg: @cp_app-bg; @cp_whiteboard-fg: @cryptpad_text_col; + +// Flatpickr +@cp_flatpickr-bg: @cryptpad_color_grey_50; +@cp_flatpickr-highlight: @cryptpad_color_brand_fadest; +@cp_flatpickr-highlight-text: @cryptpad_text_col; + +// Calendar + +@cp_calendar-border: @cryptpad_color_grey_300; +@cp_calendar-now: @cryptpad_color_brand; +@cp_calendar-now-fg: @cryptpad_color_grey_200; diff --git a/customize.dist/src/less2/include/cursor.less b/customize.dist/src/less2/include/cursor.less index 355cf4076..132922c21 100644 --- a/customize.dist/src/less2/include/cursor.less +++ b/customize.dist/src/less2/include/cursor.less @@ -1,6 +1,12 @@ .cursor_main() { // CodeMirror .cp-codemirror-cursor { + &:before { + content: ""; + display: inline-block; + } + + cursor: default; background-color: red; background-clip: padding-box; @@ -8,8 +14,8 @@ border: 2px solid red; border-right-color: transparent !important; border-left-color: transparent !important; - margin-left: -3px; - margin-right: -3px; + display: inline-block; + margin: -2px -3px; } .cp-codemirror-selection { background-color: rgba(255,0,0,0.3); diff --git a/customize.dist/src/less2/include/drive.less b/customize.dist/src/less2/include/drive.less index 9b9294e86..d287951b5 100644 --- a/customize.dist/src/less2/include/drive.less +++ b/customize.dist/src/less2/include/drive.less @@ -606,7 +606,7 @@ } } - .cp-app-drive-content-list { + div.cp-app-drive-content-list { .cp-app-drive-element-grid { display: none; } @@ -896,7 +896,13 @@ .cp-toolbar-bottom { .cp-toolbar-bottom-right { .fa-history { order: 50; } - .fa-list, .fa-th-large { order: 25; } + // .fa-list, .fa-th-large, + .cp-app-drive-viewmode-button { + order: 25; + i { + margin-right: 0; + } + } #cp-app-drive-toolbar-context-mobile, #cp-app-drive-toolbar-contextbuttons { order: 0; } #cp-app-drive-toolbar-context-mobile { .fa { margin: 0 !important; } diff --git a/customize.dist/src/less2/include/forms.less b/customize.dist/src/less2/include/forms.less index ae1096946..ffe061fa3 100644 --- a/customize.dist/src/less2/include/forms.less +++ b/customize.dist/src/less2/include/forms.less @@ -1,5 +1,6 @@ @import (reference) "./colortheme-all.less"; @import (reference) "./variables.less"; +@import (reference) "./tools.less"; .forms_main() { --LessLoader_require: LessLoader_currentFile(); @@ -8,19 +9,25 @@ & { @alertify_padding-base: @variables_padding; - input:not(.form-control):not([type="checkbox"]), textarea, div.cp-textarea { + input:not(.numInput):not(.form-control):not([type="checkbox"]), textarea, div.cp-textarea { // background-color: @alertify-input-fg; color: @cp_forms-fg; background-color: @cp_forms-bg; border: 1px solid @cp_forms-border; - width: 100%; font-size: 100%; padding: @alertify_padding-base; + &:not(.tui-full-calendar-content) { + width: 100%; + } + &.tui-full-calendar-content { + font-size: @colortheme_app-font-size; + } &[readonly] { background-color: @cp_forms-readonly; border-color: @cp_forms-readonly-border; color: @cp_forms-fg; } + .tools_placeholder-color(); } input:not(.form-control) { @@ -112,6 +119,11 @@ &.no-margin { margin: 0; } + &.small { + line-height: initial; + padding: 5px; + height: auto !important; + } &:hover, &:not(:disabled):not(.disabled):active, &:focus { color: @cp_buttons-fg; @@ -169,7 +181,7 @@ &:hover, &:not(:disabled):active, &:focus { border-color: @cryptpad_text_col; color: @cryptpad_text_col; - background-color: fade(@cryptpad_text_col, 25%); + background-color: fade(@cryptpad_text_col, 10%); } } @@ -184,6 +196,7 @@ } &.btn-register { margin-top: 10px !important; + white-space: normal; } @@ -279,4 +292,90 @@ color: @cp_drive-infobox-fg; } } + + // Flatpickr + body { + .flatpickr-calendar { + background: @cp_flatpickr-bg; + color: @cryptpad_text_col; + border-radius: 0; + box-shadow: @variables_shadow; + -webkit-box-shadow: @variables_shadow; + &.arrowTop::before, &.arrowTop::after { + border-bottom: 0; + } + .flatpickr-months { + .flatpickr-month, .flatpickr-months, .flatpickr-next-month, .flatpickr-prev-month { + color: @cryptpad_text_col; + fill: @cryptpad_text_col; + &:hover { + svg { + fill: @cryptpad_text_col; + } + } + } + .flatpickr-current-month { + span.cur-month:hover { + background: fade(@cryptpad_text_col, 10%); + } + .numInputWrapper span.arrowUp:after { + border-bottom-color: @cryptpad_text_col; + } + .numInputWrapper span.arrowDown:after { + border-top-color: @cryptpad_text_col; + } + } + } + .flatpickr-innerContainer { + border-bottom: 0; + .flatpickr-weekdays { + span.flatpickr-weekday { + color: @cryptpad_text_col; + } + } + .flatpickr-days { + border-left: 0; + border-right: 0; + .flatpickr-day { + color: @cryptpad_text_col; + &:hover { + background-color: fade(@cryptpad_text_col, 10%); + border: 0; + } + &.selected { + background: @cp_flatpickr-highlight; + color: @cp_flatpickr-highlight-text; + border: 0; + } + } + .flatpickr-disabled { + color: fade(@cryptpad_text_col, 20%); + } + } + } + .flatpickr-time { + border-top: none; + .flatpickr-time-separator, .flatpickr-am-pm { + color: @cryptpad_text_col; + } + .flatpickr-am-pm { + &:hover { + background-color: fade(@cryptpad_text_col, 10%); + } + } + .numInputWrapper { + .numInput, .arrowUp, .arrowDown { + color: @cryptpad_text_col; + &:hover, &:focus { + background-color: fade(@cryptpad_text_col, 10%); + } + } + span.arrowDown::after, span.arrowUp::after { + border-top-color: @cryptpad_text_col; + border-bottom-color: @cryptpad_text_col; + } + } + } + } + } } diff --git a/customize.dist/src/less2/include/modal.less b/customize.dist/src/less2/include/modal.less index feed09a70..d99e79896 100644 --- a/customize.dist/src/less2/include/modal.less +++ b/customize.dist/src/less2/include/modal.less @@ -70,7 +70,7 @@ justify-content: center; } - input { + input:not(.tui-full-calendar-content):not(.numInput) { padding: 8px 12px; margin: 1em; width: 300px; diff --git a/customize.dist/src/less2/include/notifications.less b/customize.dist/src/less2/include/notifications.less index 46209eb6a..f3bc8c0b4 100644 --- a/customize.dist/src/less2/include/notifications.less +++ b/customize.dist/src/less2/include/notifications.less @@ -17,6 +17,16 @@ .cp-notification { min-height: @notif-height; display: flex; + .cp-broadcast { + display: flex; + font-size: 30px; + align-items: center; + padding: 0 5px; + color: @cp_dropdown-fg; + &.preview:not(.fa-calendar) { + color: @cryptpad_color_red; + } + } .cp-avatar { .avatar_main(30px); padding: 0 5px; diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index 24bb09c11..31846b391 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -400,7 +400,7 @@ button { .toolbar_button; - &.cp-notifications-bell { + &.cp-notifications-bell, &.cp-maintenance-wrench { color: @cryptpad_text_col; } } @@ -506,7 +506,7 @@ } .cp-toolbar-user { height: @toolbar_line-height; - .cp-toolbar-notifications { + .cp-toolbar-notifications, .cp-toolbar-maintenance { height: @toolbar_line-height; width: @toolbar_line-height; margin-left: 0; @@ -709,7 +709,7 @@ height: 43px; } } - .cp-toolbar-link, .cp-toolbar-notifications { + .cp-toolbar-link, .cp-toolbar-notifications, .cp-toolbar-maintenance { line-height: @toolbar_top-height; width: @toolbar_top-height; height: @toolbar_top-height; @@ -717,7 +717,7 @@ box-sizing: border-box; display: inline-block; } - .cp-toolbar-notifications { + .cp-toolbar-notifications, .cp-toolbar-maintenance { text-align: center; font-size: 32px; margin-left: 10px; @@ -996,6 +996,9 @@ display: flex; #cp-toolbar-chat-drawer-open { order: 0; } #cp-toolbar-userlist-drawer-open { order: 1; } + & > .cp-dropdown-container { + height: @toolbar_line-height; + } } .cp-toolbar-bottom-right { diff --git a/customize.dist/src/less2/include/tools.less b/customize.dist/src/less2/include/tools.less index 87650ccdd..2b385cf6a 100644 --- a/customize.dist/src/less2/include/tools.less +++ b/customize.dist/src/less2/include/tools.less @@ -4,16 +4,20 @@ @color: @cp_forms-placeholder; &::-webkit-input-placeholder { /* WebKit, Blink, Edge */ color: @color; + font-weight: normal; } &::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ color: @color; opacity: 1; /* Firefox */ + font-weight: normal; } &:-ms-input-placeholder { /* Internet Explorer 10-11 */ color: @color; + font-weight: normal; } &::-ms-input-placeholder { /* Microsoft Edge */ color: @color; + font-weight: normal; } } diff --git a/customize.dist/src/less2/pages/page-feedback.less b/customize.dist/src/less2/pages/page-feedback.less new file mode 100644 index 000000000..d55eddd7b --- /dev/null +++ b/customize.dist/src/less2/pages/page-feedback.less @@ -0,0 +1,20 @@ +@import (reference) "../include/colortheme-all.less"; +@import (reference) "../include/font.less"; + +html, body { + .font_main(); + margin: 0px; + padding: 0px; + background-color: @cp_static-bg !important; + color: @cryptpad_text_col; + font-family: "IBM Plex Mono"; + a { + color: @cryptpad_color_link; + } +} +body { + width: 50%; + min-width: 650px; + margin: auto; +} + diff --git a/customize.dist/src/less2/pages/page-register.less b/customize.dist/src/less2/pages/page-register.less index ce4309822..1ce8bbd5f 100644 --- a/customize.dist/src/less2/pages/page-register.less +++ b/customize.dist/src/less2/pages/page-register.less @@ -52,6 +52,9 @@ } } + .cp-restricted-registration { + text-align: center !important; + } .cp-register-det { #data { diff --git a/customize.dist/src/less2/pages/page-report.less b/customize.dist/src/less2/pages/page-report.less new file mode 100644 index 000000000..bd2cd6c60 --- /dev/null +++ b/customize.dist/src/less2/pages/page-report.less @@ -0,0 +1,17 @@ +@import (reference) "../include/colortheme-all.less"; +@import (reference) "../include/font.less"; +//@import (reference) "../include/forms.less"; +@import (reference) "../include/alertify.less"; + +html, body { + .font_main(); + .alertify_main(); + height: 100%; + margin: 0px; + padding: 0px; + background-color: @cp_static-bg !important; + color: @cryptpad_text_col; + font-family: "IBM Plex Mono"; +} + + diff --git a/customize.dist/template.js b/customize.dist/template.js index 7721339f3..0e9b3f2b9 100644 --- a/customize.dist/template.js +++ b/customize.dist/template.js @@ -50,7 +50,6 @@ $(function () { } else if (/^\/login\//.test(pathname)) { require([ '/login/main.js' ], function () {}); } else if (/^\/($|^\/index\.html$)/.test(pathname)) { - // TODO use different top bar require([ '/customize/main.js', ], function () {}); } else { require([ '/customize/main.js', ], function () {}); diff --git a/docs/example.nginx.conf b/docs/example.nginx.conf index 2c677436b..78e4f30ce 100644 --- a/docs/example.nginx.conf +++ b/docs/example.nginx.conf @@ -60,8 +60,11 @@ server { add_header Access-Control-Allow-Origin "*"; # add_header X-Frame-Options "SAMEORIGIN"; + # Opt out of Google's FLoC Network + add_header Permissions-Policy interest-cohort=(); + set $coop ''; - if ($uri ~ ^\/sheet\/.*$) { set $coop 'same-origin'; } + if ($uri ~ ^\/(sheet|presentation|doc)\/.*$) { set $coop 'same-origin'; } # Enable SharedArrayBuffer in Firefox (for .xlsx export) add_header Cross-Origin-Resource-Policy cross-origin; @@ -116,7 +119,7 @@ server { set $unsafe 0; # the following assets are loaded via the sandbox domain # they unfortunately still require exceptions to the sandboxing to work correctly. - if ($uri = "/sheet/inner.html") { set $unsafe 1; } + if ($uri ~ ^\/(sheet|doc|presentation)\/inner.html.*$) { set $unsafe 1; } if ($uri ~ ^\/common\/onlyoffice\/.*\/index\.html.*$) { set $unsafe 1; } # everything except the sandbox domain is a privileged scope, as they might be used to handle keys @@ -159,7 +162,7 @@ server { # /api/config is loaded once per page load and is used to retrieve # the caching variable which is applied to every other resource # which is loaded during that session. - location = /api/config { + location ~ ^/api/(config|broadcast).*$ { proxy_pass http://localhost:3000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; @@ -204,7 +207,7 @@ server { # The nodejs server has some built-in forwarding rules to prevent # URLs like /pad from resulting in a 404. This simply adds a trailing slash # to a variety of applications. - location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media|profile|contacts|todo|filepicker|debug|kanban|sheet|support|admin|notifications|teams)$ { + location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media|profile|contacts|todo|filepicker|debug|kanban|sheet|support|admin|notifications|teams|calendar|presentation|doc)$ { rewrite ^(.*)$ $1/ redirect; } diff --git a/lib/commands/admin-rpc.js b/lib/commands/admin-rpc.js index 32338b772..9ab86bdf2 100644 --- a/lib/commands/admin-rpc.js +++ b/lib/commands/admin-rpc.js @@ -348,6 +348,9 @@ var commands = { CLEAR_CACHED_CHANNEL_INDEX: clearChannelIndex, GET_CACHED_CHANNEL_INDEX: getChannelIndex, + // TODO implement admin historyTrim + // TODO implement kick from channel + // TODO implement force-disconnect user(s)? CLEAR_CACHED_CHANNEL_METADATA: clearChannelMetadata, GET_CACHED_CHANNEL_METADATA: getChannelMetadata, diff --git a/lib/commands/block.js b/lib/commands/block.js index 3a264c167..8180cb68e 100644 --- a/lib/commands/block.js +++ b/lib/commands/block.js @@ -86,47 +86,122 @@ var createLoginBlockPath = function (Env, publicKey) { // FIXME BLOCKS return Path.join(Env.paths.block, safeKey.slice(0, 2), safeKey); }; -Block.writeLoginBlock = function (Env, safeKey, msg, cb) { // FIXME BLOCKS +Block.validateAncestorProof = function (Env, proof, _cb) { + var cb = Util.once(Util.mkAsync(_cb)); +/* prove that you own an existing block by signing for its publicKey */ + try { + var parsed = JSON.parse(proof); + var pub = parsed[0]; + var u8_pub = Nacl.util.decodeBase64(pub); + var sig = parsed[1]; + var u8_sig = Nacl.util.decodeBase64(sig); + var valid = false; + nThen(function (w) { + valid = Nacl.sign.detached.verify(u8_pub, u8_sig, u8_pub); + if (!valid) { + w.abort(); + return void cb('E_INVALID_ANCESTOR_PROOF'); + } + // else fall through to next step + }).nThen(function (w) { + var path = createLoginBlockPath(Env, pub); + Fs.access(path, Fs.constants.F_OK, w(function (err) { + if (!err) { return; } + w.abort(); // else + return void cb("E_MISSING_ANCESTOR"); + })); + }).nThen(function () { + cb(void 0, pub); + }); + } catch (err) { + return void cb(err); + } +}; + +Block.writeLoginBlock = function (Env, safeKey, msg, _cb) { // FIXME BLOCKS + var cb = Util.once(Util.mkAsync(_cb)); //console.log(msg); var publicKey = msg[0]; var signature = msg[1]; var block = msg[2]; + var registrationProof = msg[3]; + var previousKey; - validateLoginBlock(Env, publicKey, signature, block, function (e, validatedBlock) { - if (e) { return void cb(e); } - if (!(validatedBlock instanceof Uint8Array)) { return void cb('E_INVALID_BLOCK'); } - - // derive the filepath - var path = createLoginBlockPath(Env, publicKey); - - // make sure the path is valid - if (typeof(path) !== 'string') { - return void cb('E_INVALID_BLOCK_PATH'); + var validatedBlock, parsed, path; + nThen(function (w) { + if (Util.escapeKeyCharacters(publicKey) !== safeKey) { + w.abort(); + return void cb("INCORRECT_KEY"); } - - var parsed = Path.parse(path); - if (!parsed || typeof(parsed.dir) !== 'string') { - return void cb("E_INVALID_BLOCK_PATH_2"); - } - - nThen(function (w) { - // make sure the path to the file exists - Fse.mkdirp(parsed.dir, w(function (e) { - if (e) { - w.abort(); - cb(e); - } - })); - }).nThen(function () { - // actually write the block - - // flow is dumb and I need to guard against this which will never happen - /*:: if (typeof(validatedBlock) === 'undefined') { throw new Error('should never happen'); } */ - /*:: if (typeof(path) === 'undefined') { throw new Error('should never happen'); } */ - Fs.writeFile(path, Buffer.from(validatedBlock), { encoding: "binary", }, function (err) { - if (err) { return void cb(err); } - cb(); + }).nThen(function (w) { + if (!Env.restrictRegistration) { return; } + if (!registrationProof) { + // we allow users with existing blocks to create new ones + // call back with error if registration is restricted and no proof of an existing block was provided + w.abort(); + Env.Log.info("BLOCK_REJECTED_REGISTRATION", { + safeKey: safeKey, + publicKey: publicKey, }); + return cb("E_RESTRICTED"); + } + Env.validateAncestorProof(registrationProof, w(function (err, provenKey) { + if (err || !provenKey) { // double check that a key was validated + w.abort(); + Env.Log.warn('BLOCK_REJECTED_INVALID_ANCESTOR', { + error: err, + }); + return void cb("E_RESTRICTED"); + } + previousKey = provenKey; + })); + }).nThen(function (w) { + validateLoginBlock(Env, publicKey, signature, block, w(function (e, _validatedBlock) { + if (e) { + w.abort(); + return void cb(e); + } + if (!(_validatedBlock instanceof Uint8Array)) { + w.abort(); + return void cb('E_INVALID_BLOCK'); + } + + validatedBlock = _validatedBlock; + + // derive the filepath + path = createLoginBlockPath(Env, publicKey); + + // make sure the path is valid + if (typeof(path) !== 'string') { + return void cb('E_INVALID_BLOCK_PATH'); + } + + parsed = Path.parse(path); + if (!parsed || typeof(parsed.dir) !== 'string') { + w.abort(); + return void cb("E_INVALID_BLOCK_PATH_2"); + } + })); + }).nThen(function (w) { + // make sure the path to the file exists + Fse.mkdirp(parsed.dir, w(function (e) { + if (e) { + w.abort(); + cb(e); + } + })); + }).nThen(function () { + // actually write the block + Fs.writeFile(path, Buffer.from(validatedBlock), { encoding: "binary", }, function (err) { + if (err) { return void cb(err); } + Env.Log.info('BLOCK_WRITE_BY_OWNER', { + safeKey: safeKey, + blockId: publicKey, + isChange: Boolean(registrationProof), + previousKey: previousKey, + path: path, + }); + cb(); }); }); }; @@ -146,26 +221,33 @@ Block.removeLoginBlock = function (Env, safeKey, msg, cb) { // FIXME BLOCKS var signature = msg[1]; var block = Nacl.util.decodeUTF8('DELETE_BLOCK'); // clients and the server will have to agree on this constant - validateLoginBlock(Env, publicKey, signature, block, function (e /*::, validatedBlock */) { - if (e) { return void cb(e); } - // derive the filepath - var path = createLoginBlockPath(Env, publicKey); - - // make sure the path is valid - if (typeof(path) !== 'string') { - return void cb('E_INVALID_BLOCK_PATH'); + nThen(function (w) { + if (Util.escapeKeyCharacters(publicKey) !== safeKey) { + w.abort(); + return void cb("INCORRECT_KEY"); } + }).nThen(function () { + validateLoginBlock(Env, publicKey, signature, block, function (e /*::, validatedBlock */) { + if (e) { return void cb(e); } + // derive the filepath + var path = createLoginBlockPath(Env, publicKey); - // FIXME COLDSTORAGE - Fs.unlink(path, function (err) { - Env.Log.info('DELETION_BLOCK_BY_OWNER_RPC', { - publicKey: publicKey, - path: path, - status: err? String(err): 'SUCCESS', + // make sure the path is valid + if (typeof(path) !== 'string') { + return void cb('E_INVALID_BLOCK_PATH'); + } + + // FIXME COLDSTORAGE + Fs.unlink(path, function (err) { + Env.Log.info('DELETION_BLOCK_BY_OWNER_RPC', { + publicKey: publicKey, + path: path, + status: err? String(err): 'SUCCESS', + }); + + if (err) { return void cb(err); } + cb(); }); - - if (err) { return void cb(err); } - cb(); }); }); }; diff --git a/lib/commands/channel.js b/lib/commands/channel.js index 86ab7bc8c..e69f93180 100644 --- a/lib/commands/channel.js +++ b/lib/commands/channel.js @@ -191,7 +191,8 @@ var ARRAY_LINE = /^\[/; */ Channel.isNewChannel = function (Env, channel, cb) { if (!Core.isValidId(channel)) { return void cb('INVALID_CHAN'); } - if (channel.length !== 32) { return void cb('INVALID_CHAN'); } + if (channel.length !== HK.STANDARD_CHANNEL_LENGTH && + channel.length !== HK.ADMIN_CHANNEL_LENGTH) { return void cb('INVALID_CHAN'); } // TODO replace with readMessagesBin var done = false; @@ -229,7 +230,8 @@ Channel.writePrivateMessage = function (Env, args, _cb, Server, netfluxId) { if (!msg) { return void cb("INVALID_MESSAGE"); } // don't support anything except regular channels - if (!Core.isValidId(channelId) || channelId.length !== 32) { + if (!Core.isValidId(channelId) || (channelId.length !== HK.STANDARD_CHANNEL_LENGTH + && channelId.length !== HK.ADMIN_CHANNEL_LENGTH)) { return void cb("INVALID_CHAN"); } @@ -254,6 +256,11 @@ Channel.writePrivateMessage = function (Env, args, _cb, Server, netfluxId) { var session = HK.getNetfluxSession(Env, netfluxId); var allowed = HK.listAllowedUsers(metadata); + // Special broadcast channel + if (channelId.length === HK.ADMIN_CHANNEL_LENGTH) { + allowed = Env.admins; + } + if (HK.isUserSessionAllowed(allowed, session)) { return; } w.abort(); @@ -278,12 +285,19 @@ Channel.writePrivateMessage = function (Env, args, _cb, Server, netfluxId) { // historyKeeper already knows how to handle metadata and message validation, so we just pass it off here // if the message isn't valid it won't be stored. - Env.historyKeeper.channelMessage(Server, channelStruct, fullMessage); + Env.historyKeeper.channelMessage(Server, channelStruct, fullMessage, function (err) { + if (err) { + // Message not stored... + return void cb(err); + } - Server.getChannelUserList(channelId).forEach(function (userId) { - Server.send(userId, fullMessage); + // Broadcast the message + Server.getChannelUserList(channelId).forEach(function (userId) { + Server.send(userId, fullMessage); + }); }); + cb(); }); }; diff --git a/lib/commands/core.js b/lib/commands/core.js index f4e6a9f70..a0be7cd67 100644 --- a/lib/commands/core.js +++ b/lib/commands/core.js @@ -10,7 +10,11 @@ Core.SESSION_EXPIRATION_TIME = 60 * 1000; Core.isValidId = function (chan) { return chan && chan.length && /^[a-zA-Z0-9=+-]*$/.test(chan) && - [32, 48].indexOf(chan.length) > -1; + [32, 33, 48].indexOf(chan.length) > -1; +}; + +Core.isValidPublicKey = function (owner) { + return typeof(owner) === 'string' && owner.length === 44; }; var makeToken = Core.makeToken = function () { diff --git a/lib/commands/metadata.js b/lib/commands/metadata.js index 896c89f31..9b6a23e02 100644 --- a/lib/commands/metadata.js +++ b/lib/commands/metadata.js @@ -9,7 +9,18 @@ const HK = require("../hk-util"); Data.getMetadataRaw = function (Env, channel /* channelName */, _cb) { const cb = Util.once(Util.mkAsync(_cb)); if (!Core.isValidId(channel)) { return void cb('INVALID_CHAN'); } - if (channel.length !== HK.STANDARD_CHANNEL_LENGTH) { return cb("INVALID_CHAN_LENGTH"); } + if (channel.length !== HK.STANDARD_CHANNEL_LENGTH && + channel.length !== HK.ADMIN_CHANNEL_LENGTH) { return cb("INVALID_CHAN_LENGTH"); } + + // return synthetic metadata for admin broadcast channels as a safety net + // in case anybody manages to write metadata + if (channel.length === HK.ADMIN_CHANNEL_LENGTH) { + return void cb(void 0, { + channel: channel, + creation: +new Date(), + owners: Env.admins, + }); + } var cached = Env.metadata_cache[channel]; if (HK.isMetadataMessage(cached)) { diff --git a/lib/decrees.js b/lib/decrees.js index 2672efdd3..eed840057 100644 --- a/lib/decrees.js +++ b/lib/decrees.js @@ -1,4 +1,5 @@ var Decrees = module.exports; +var Core = require("./commands/core"); /* Admin decrees which modify global server state @@ -24,6 +25,15 @@ SET_PREMIUM_UPLOAD_SIZE DISABLE_INTEGRATED_TASKS DISABLE_INTEGRATED_EVICTION +// BROADCAST +SET_LAST_BROADCAST_HASH +SET_SURVEY_URL +SET_MAINTENANCE + +// EASIER CONFIG +SET_ADMIN_EMAIL +SET_SUPPORT_MAILBOX + NOT IMPLEMENTED: // RESTRICTED REGISTRATION @@ -32,9 +42,11 @@ REVOKE_INVITE REDEEM_INVITE // 2.0 -Env.adminEmail -Env.supportMailbox Env.DEV_MODE || Env.FRESH_MODE, + +ADD_ADMIN_KEY +RM_ADMIN_KEY + */ var commands = {}; @@ -83,6 +95,20 @@ var isNonNegativeNumber = function (n) { }; */ +var default_validator = function () { return true; }; +var makeGenericSetter = function (attr, validator) { + validator = validator || default_validator; + return function (Env, args) { + if (!validator(args)) { + throw new Error("INVALID_ARGS"); + } + var value = args[0]; + if (value === Env[attr]) { return false; } + Env[attr] = value; + return true; + }; +}; + var isInteger = function (n) { return !(typeof(n) !== 'number' || isNaN(n) || (n % 1) !== 0); }; @@ -92,15 +118,7 @@ var args_isInteger = function (args) { }; var makeIntegerSetter = function (attr) { - return function (Env, args) { - if (!args_isInteger(args)) { - throw new Error('INVALID_ARGS'); - } - var integer = args[0]; - if (integer === Env[attr]) { return false; } - Env[attr] = integer; - return true; - }; + return makeGenericSetter(attr, args_isInteger); }; // CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_MAX_UPLOAD_SIZE', [50 * 1024 * 1024]]], console.log) @@ -121,6 +139,52 @@ commands.SET_ARCHIVE_RETENTION_TIME = makeIntegerSetter('archiveRetentionTime'); // CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_ACCOUNT_RETENTION_TIME', [365]]], console.log) commands.SET_ACCOUNT_RETENTION_TIME = makeIntegerSetter('accountRetentionTime'); +var args_isString = function (args) { + return Array.isArray(args) && typeof(args[0]) === "string"; +}; + +// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_ADMIN_EMAIL', ['admin@website.tld']]], console.log) +commands.SET_ADMIN_EMAIL = makeGenericSetter('adminEmail', args_isString); + +// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_SUPPORT_MAILBOX', ["Tdz6+fE9N9XXBY93rW5qeNa/k27yd40c0vq7EJyt7jA="]]], console.log) +commands.SET_SUPPORT_MAILBOX = makeGenericSetter('supportMailbox', function (args) { + return args_isString(args) && Core.isValidPublicKey(args[0]); +}); + +// Maintenance: Empty string or an object with a start and end time +var isNumber = function (value) { + return typeof(value) === "number" && !isNaN(value); +}; +var args_isMaintenance = function (args) { + return Array.isArray(args) && args[0] && + (args[0] === "" || (isNumber(args[0].end) && isNumber(args[0].start))); +}; + +// we anticipate that we'll add language-specific surveys in the future +// whenever that happens we can relax validation a bit to support more formats +var makeBroadcastSetter = function (attr, validation) { + return function (Env, args) { + if ((validation && !validation(args)) && !args_isString(args)) { + throw new Error('INVALID_ARGS'); + } + var str = args[0]; + if (str === Env[attr]) { return false; } + Env[attr] = str; + Env.broadcastCache = {}; + return true; + }; +}; + +// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_LAST_BROADCAST_HASH', [hash]]], console.log) +commands.SET_LAST_BROADCAST_HASH = makeBroadcastSetter('lastBroadcastHash'); + +// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_SURVEY_URL', [url]]], console.log) +commands.SET_SURVEY_URL = makeBroadcastSetter('surveyURL'); + +// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_MAINTENANCE', [{start: +Date, end: +Date}]]], console.log) +// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_MAINTENANCE', [""]]], console.log) +commands.SET_MAINTENANCE = makeBroadcastSetter('maintenance', args_isMaintenance); + var Quota = require("./commands/quota"); var Keys = require("./keys"); var Util = require("./common-util"); diff --git a/lib/defaults.js b/lib/defaults.js index 3d5e74576..635e155be 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -48,6 +48,7 @@ Default.httpHeaders = function () { "X-XSS-Protection": "1; mode=block", "X-Content-Type-Options": "nosniff", "Access-Control-Allow-Origin": "*", + "Permissions-policy":"interest-cohort=()" }; }; Default.mainPages = function () { diff --git a/lib/env.js b/lib/env.js index 97d3893f9..389f059f6 100644 --- a/lib/env.js +++ b/lib/env.js @@ -19,8 +19,10 @@ module.exports.create = function (config) { FRESH_MODE: true, DEV_MODE: false, configCache: {}, + broadcastCache: {}, flushCache: function () { Env.configCache = {}; + Env.broadcastCache = {}; Env.FRESH_KEY = +new Date(); if (!(Env.DEV_MODE || Env.FRESH_MODE)) { Env.FRESH_MODE = true; } if (!Env.Log) { return; } @@ -65,6 +67,11 @@ module.exports.create = function (config) { paths: {}, //msgStore: config.store, + // /api/broadcast + lastBroadcastHash: '', + surveyURL: undefined, + maintenance: undefined, + netfluxUsers: {}, pinStore: undefined, @@ -82,6 +89,11 @@ module.exports.create = function (config) { } }, +/* FIXME restrictRegistration is initialized as false and then overridden by admin decree + There is a narrow window in which someone could register before the server updates this value. + See also the cached 'restrictRegistration' value in server.js#serveConfig +*/ + restrictRegistration: false, allowSubscriptions: config.allowSubscriptions === true, blockDailyCheck: config.blockDailyCheck === true, diff --git a/lib/historyKeeper.js b/lib/historyKeeper.js index fb7a5ebc8..daa041b5f 100644 --- a/lib/historyKeeper.js +++ b/lib/historyKeeper.js @@ -158,6 +158,7 @@ module.exports.create = function (Env, cb) { pinPath: Env.paths.pin, filePath: Env.paths.data, archivePath: Env.paths.archive, + blockPath: Env.paths.block, inactiveTime: Env.inactiveTime, archiveRetentionTime: Env.archiveRetentionTime, diff --git a/lib/hk-util.js b/lib/hk-util.js index 8780addcd..7c244c174 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -34,6 +34,7 @@ const getHash = HK.getHash = function (msg, Log) { // historyKeeper should explicitly store any channel // with a 32 character id const STANDARD_CHANNEL_LENGTH = HK.STANDARD_CHANNEL_LENGTH = 32; +const ADMIN_CHANNEL_LENGTH = HK.ADMIN_CHANNEL_LENGTH = 33; // historyKeeper should not store messages sent to any channel // with a 34 character id @@ -661,6 +662,8 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) { if (txid) { msg[0] = txid; } Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(msg)], readMore); }, (err) => { + // Any error but ENOENT: abort + // ENOENT is allowed in case we want to create a new pad if (err && err.code !== 'ENOENT') { if (err.message === "EUNKNOWN") { Log.error("HK_GET_HISTORY", { @@ -675,11 +678,28 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) { err: err && err.message || err, stack: err && err.stack, }); } + // FIXME err.message isn't useful for users const parsedMsg = {error:err.message, channel: channelName, txid: txid}; Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg)]); return; } + // If we're asking for a specific version (lastKnownHash) but we receive an + // ENOENT, this is not a pad creation so we need to abort. + if (err && err.code === 'ENOENT' && lastKnownHash) { +/* + This informs clients that the pad they're trying to load was deleted by its owner. + The user in question might be reconnecting or might have loaded the document from their cache. + The owner that deleted it could be another user or the same user from a different device. + Either way, the respectful thing to do is display an error screen informing them that the content + is no longer on the server so they don't abuse the data and so that they don't unintentionally continue + to edit it in a broken state. +*/ + const parsedMsg2 = {error:'EDELETED', channel: channelName, txid: txid}; + Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg2)]); + return; + } + if (msgCount === 0 && !metadata_cache[channelName] && Server.channelContainsUser(channelName, userId)) { handleFirstMessage(Env, channelName, metadata); Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(metadata)]); @@ -883,6 +903,11 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) { // don't store messages if the channel id indicates that it's an ephemeral message if (!channel.id || channel.id.length === EPHEMERAL_CHANNEL_LENGTH) { return void cb(); } + // Admin channel. We can only write to this one from private message (RPC) + if (channel.id.length === ADMIN_CHANNEL_LENGTH && msgStruct[1] !== null) { + return void cb('ERESTRICTED_ADMIN'); + } + const isCp = /^cp\|/.test(msgStruct[4]); let id; if (isCp) { @@ -893,8 +918,9 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) { // more straightforward and reliable. if (Array.isArray(id) && id[2] && id[2] === channel.lastSavedCp) { // Reject duplicate checkpoints - // XXX not an error? the checkpoint is already here so we can assume it's stored - return void cb('DUPLICATE'); + return void cb(); + // not an error? the checkpoint is already here so we can assume it's stored + //return void cb('DUPLICATE'); } } diff --git a/lib/metadata.js b/lib/metadata.js index 97f2e484a..d320a5c9b 100644 --- a/lib/metadata.js +++ b/lib/metadata.js @@ -1,4 +1,5 @@ var Meta = module.exports; +var Core = require("./commands/core"); var deduplicate = require("./common-util").deduplicateString; @@ -35,9 +36,7 @@ the owners field is guaranteed to exist. var commands = {}; -var isValidPublicKey = function (owner) { - return typeof(owner) === 'string' && owner.length === 44; -}; +var isValidPublicKey = Core.isValidPublicKey; // isValidPublicKey is a better indication of what the above function does // I'm preserving this function name in case we ever want to expand its diff --git a/lib/storage/blob.js b/lib/storage/blob.js index 044eeaeaa..e5c7a2fce 100644 --- a/lib/storage/blob.js +++ b/lib/storage/blob.js @@ -295,7 +295,7 @@ var owned_upload_complete = function (Env, safeKey, id, cb) { // removeBlob var remove = function (Env, blobId, cb) { var blobPath = makeBlobPath(Env, blobId); - Fs.unlink(blobPath, cb); // TODO COLDSTORAGE + Fs.unlink(blobPath, cb); }; // removeProof diff --git a/lib/storage/file.js b/lib/storage/file.js index d890cb0b9..825f14066 100644 --- a/lib/storage/file.js +++ b/lib/storage/file.js @@ -567,7 +567,7 @@ var listChannels = function (root, handler, cb, fast) { var metadataName; // if the current file is not the channel data, then it must be metadata - if (!/^[0-9a-fA-F]{32}\.ndjson$/.test(item)) { + if (!/^[0-9a-fA-F]{32, 33}\.ndjson$/.test(item)) { metadataName = item; channelName = item.replace(/\.metadata/, ''); @@ -584,7 +584,7 @@ var listChannels = function (root, handler, cb, fast) { } var channel = metadataName.replace(/\.metadata.ndjson$/, ''); - if ([32, 34, 44].indexOf(channel.length) === -1) { return; } + if ([32, 33, 34, 44].indexOf(channel.length) === -1) { return; } // otherwise throw it on the pile sema.take(function (give) { diff --git a/lib/workers/db-worker.js b/lib/workers/db-worker.js index 5274445eb..8585cc3f6 100644 --- a/lib/workers/db-worker.js +++ b/lib/workers/db-worker.js @@ -4,6 +4,7 @@ const HK = require("../hk-util"); const Store = require("../storage/file"); const BlobStore = require("../storage/blob"); +const Block = require("../commands/block"); const Util = require("../common-util"); const nThen = require("nthen"); const Meta = require("../metadata"); @@ -47,6 +48,7 @@ const init = function (config, _cb) { Env.paths = { pin: config.pinPath, + block: config.blockPath, }; Env.inactiveTime = config.inactiveTime; @@ -391,7 +393,8 @@ const getPinState = function (data, cb) { const _getFileSize = function (channel, _cb) { var cb = Util.once(Util.mkAsync(_cb)); if (!Core.isValidId(channel)) { return void cb('INVALID_CHAN'); } - if (channel.length === 32) { + if (channel.length === HK.STANDARD_CHANNEL_LENGTH || + channel.length === HK.ADMIN_CHANNEL_LENGTH) { return void store.getChannelSize(channel, function (e, size) { if (e) { if (e.code === 'ENOENT') { return void cb(void 0, 0); } @@ -687,6 +690,10 @@ COMMANDS.HASH_CHANNEL_LIST = function (data, cb) { cb(void 0, hash); }; +COMMANDS.VALIDATE_ANCESTOR_PROOF = function (data, cb) { + Block.validateAncestorProof(Env, data && data.proof, cb); +}; + process.on('message', function (data) { if (!data || !data.txid || !data.pid) { return void process.send({ diff --git a/lib/workers/index.js b/lib/workers/index.js index 25c18d947..85c66eeb5 100644 --- a/lib/workers/index.js +++ b/lib/workers/index.js @@ -444,6 +444,13 @@ Workers.initialize = function (Env, config, _cb) { }, cb); }; + Env.validateAncestorProof = function (proof, cb) { + sendCommand({ + command: 'VALIDATE_ANCESTOR_PROOF', + proof: proof, + }, cb); + }; + cb(void 0); }); }; diff --git a/package-lock.json b/package-lock.json index 447f6a468..75b03cfe1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cryptpad", - "version": "4.3.0", + "version": "4.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -403,9 +403,9 @@ } }, "chainpad-server": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/chainpad-server/-/chainpad-server-5.0.0.tgz", - "integrity": "sha512-rfJxcWdF5InMPnNkhMWD+VRwzKUcUQktMG7DpEs90zuB7w6e8rs4MAOTEmc2rgK5EB0fYTlOMdSft58hKnbgHw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/chainpad-server/-/chainpad-server-5.1.0.tgz", + "integrity": "sha512-BdjgOOLTXXo1EjQ7lURDe7oqsqfQISNvwhILfp3K3diY2K1hxpPLbjYzOSgxNOTADeOAff0xnInR5eUCESVWaQ==", "requires": { "nthen": "0.1.8", "pull-stream": "^3.6.9", @@ -1706,9 +1706,9 @@ } }, "lodash": { - "version": "4.17.19", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", - "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, "lodash.merge": { diff --git a/package.json b/package.json index c059c6bd0..3314ffd17 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cryptpad", "description": "realtime collaborative visual editor with zero knowlege server", - "version": "4.3.0", + "version": "4.5.0", "license": "AGPL-3.0+", "repository": { "type": "git", @@ -14,7 +14,7 @@ "dependencies": { "@mcrowe/minibloom": "^0.2.0", "chainpad-crypto": "^0.2.5", - "chainpad-server": "^5.0.0", + "chainpad-server": "^5.1.0", "express": "~4.16.0", "fs-extra": "^7.0.0", "get-folder-size": "^2.0.1", diff --git a/scripts/find-html-translations.js b/scripts/find-html-translations.js new file mode 100644 index 000000000..dabdbac4b --- /dev/null +++ b/scripts/find-html-translations.js @@ -0,0 +1,96 @@ +var EN = require("../www/common/translations/messages.json"); + +var simpleTags = [ + '
', + '
', + '
', + '', + '', + + // FIXME + "", + '

', + '

', + + // FIXME register_notes + '', + '
  • ', + '
  • ', + '', + '', +]; + +['a', 'b', 'em', 'p', 'i'].forEach(function (tag) { + simpleTags.push('<' + tag + '>'); + simpleTags.push(''); +}); + +// these keys are known to be problematic +var KNOWN_ISSUES = [ // FIXME + //'newVersion', + //'fm_info_anonymous', + //'register_notes', +]; + +var processLang = function (map, lang, primary) { + var announced = false; + var announce = function () { + if (announced) { return; } + announced = true; + console.log("NEXT LANGUAGE: ", lang); + }; + + Object.keys(map).forEach(function (k) { + if (!EN[k]) { return; } + if (KNOWN_ISSUES.indexOf(k) !== -1) { return; } + + var s = map[k]; + if (typeof(s) !== 'string') { return; } + var usesHTML; + + s.replace(/<.*?>/g, function (html) { + if (simpleTags.indexOf(html) !== -1) { return; } + announce(); + usesHTML = true; + if (!primary) { + console.log("{%s}", html); + } + }); + + if (usesHTML) { + announce(); + console.log("%s", s); + console.log("[%s]\n", k); + } + }); +}; + +processLang(EN, 'en', true); + +[ + 'ar', + 'bn_BD', + 'ca', + 'de', + 'es', + 'fi', + 'fr', + 'hi', + 'it', + 'ja', + 'nb', + 'nl', + 'pl', + 'pt-br', + 'ro', + 'ru', + 'sv', + 'te', + 'tr', + 'zh', +].forEach(function (lang) { + var map = require("../www/common/translations/messages." + lang + ".json"); + if (!Object.keys(map).length) { return; } + processLang(map, lang); +}); diff --git a/server.js b/server.js index f3ee71d0b..3a71f83b8 100644 --- a/server.js +++ b/server.js @@ -16,15 +16,19 @@ var Env = require("./lib/env").create(config); var app = Express(); +var canonicalizeOrigin = function (s) { + return (s || '').trim().replace(/\/+$/, ''); +}; + (function () { // you absolutely must provide an 'httpUnsafeOrigin' if (typeof(config.httpUnsafeOrigin) !== 'string') { throw new Error("No 'httpUnsafeOrigin' provided"); } - config.httpUnsafeOrigin = config.httpUnsafeOrigin.trim(); + config.httpUnsafeOrigin = canonicalizeOrigin(config.httpUnsafeOrigin); if (typeof(config.httpSafeOrigin) === 'string') { - config.httpSafeOrigin = config.httpSafeOrigin.trim().replace(/\/$/, ''); + config.httpSafeOrigin = canonicalizeOrigin(config.httpSafeOrigin); } // fall back to listening on a local address @@ -39,6 +43,7 @@ var app = Express(); } if (typeof(config.httpSafeOrigin) !== 'string') { + Env.NO_SANDBOX = true; if (typeof(config.httpSafePort) !== 'number') { config.httpSafePort = config.httpPort + 1; } @@ -102,18 +107,37 @@ var setHeaders = (function () { return function (req, res) { // apply a bunch of cross-origin headers for XLSX export in FF and printing elsewhere applyHeaderMap(res, { - "Cross-Origin-Resource-Policy": 'cross-origin', "Cross-Origin-Opener-Policy": /^\/sheet\//.test(req.url)? 'same-origin': '', "Cross-Origin-Embedder-Policy": 'require-corp', }); + if (Env.NO_SANDBOX) { // handles correct configuration for local development + // https://stackoverflow.com/questions/11531121/add-duplicate-http-response-headers-in-nodejs + applyHeaderMap(res, { + "Cross-Origin-Resource-Policy": 'cross-origin', + }); + } + // Don't set CSP headers on /api/config because they aren't necessary and they cause problems // when duplicated by NGINX in production environments - if (/^\/api\/config/.test(req.url)) { return; } + if (/^\/api\/(broadcast|config)/.test(req.url)) { + /* + if (Env.NO_SANDBOX) { + applyHeaderMap(res, { + "Cross-Origin-Resource-Policy": 'cross-origin', + }); + } + */ + return; + } + applyHeaderMap(res, { + "Cross-Origin-Resource-Policy": 'cross-origin', + }); + // targeted CSP, generic policies, maybe custom headers const h = [ /^\/common\/onlyoffice\/.*\/index\.html.*/, - /^\/(sheet|ooslide|oodoc)\/inner\.html.*/, + /^\/(sheet|presentation|doc)\/inner\.html.*/, ].some((regex) => { return regex.test(req.url); }) ? padHeaders : headers; @@ -197,46 +221,14 @@ app.use("/customize.dist", Express.static(__dirname + '/customize.dist')); app.use(/^\/[^\/]*$/, Express.static('customize')); app.use(/^\/[^\/]*$/, Express.static('customize.dist')); -var serveConfig = (function () { - // if dev mode: never cache - var cacheString = function () { - return (Env.FRESH_KEY? '-' + Env.FRESH_KEY: '') + (Env.DEV_MODE? '-' + (+new Date()): ''); - }; - - var template = function (host) { - return [ - 'define(function(){', - 'var obj = ' + JSON.stringify({ - requireConf: { - waitSeconds: 600, - urlArgs: 'ver=' + Package.version + cacheString(), - }, - removeDonateButton: (config.removeDonateButton === true), - allowSubscriptions: (config.allowSubscriptions === true), - websocketPath: config.externalWebsocketURL, - httpUnsafeOrigin: config.httpUnsafeOrigin, - adminEmail: Env.adminEmail, - adminKeys: Env.admins, - inactiveTime: Env.inactiveTime, - supportMailbox: Env.supportMailbox, - defaultStorageLimit: Env.defaultStorageLimit, - maxUploadSize: Env.maxUploadSize, - premiumUploadSize: Env.premiumUploadSize, - }, null, '\t'), - 'obj.httpSafeOrigin = ' + (function () { - if (config.httpSafeOrigin) { return '"' + config.httpSafeOrigin + '"'; } - if (config.httpSafePort) { - return "(function () { return window.location.origin.replace(/\:[0-9]+$/, ':" + - config.httpSafePort + "'); }())"; - } - return 'window.location.origin'; - }()), - 'return obj', - '});' - ].join(';\n') - }; +// if dev mode: never cache +var cacheString = function () { + return (Env.FRESH_KEY? '-' + Env.FRESH_KEY: '') + (Env.DEV_MODE? '-' + (+new Date()): ''); +}; +var makeRouteCache = function (template, cacheName) { var cleanUp = {}; + var cache = Env[cacheName] = Env[cacheName] || {}; return function (req, res) { var host = req.headers.host.replace(/\:[0-9]+/, ''); @@ -251,24 +243,75 @@ var serveConfig = (function () { // FIXME mutable // we must be able to clear the cache when updating any mutable key // if there's nothing cached for that key... - if (!Env.configCache[cacheKey]) { + if (!cache[cacheKey]) { // generate the response and cache it in memory - Env.configCache[cacheKey] = template(host); + cache[cacheKey] = template(host); // and create a function to conditionally evict cache entries // which have not been accessed in the last 20 seconds cleanUp[cacheKey] = Util.throttle(function () { delete cleanUp[cacheKey]; - delete Env.configCache[cacheKey]; + delete cache[cacheKey]; }, 20000); } // successive calls to this function cleanUp[cacheKey](); - return void res.send(Env.configCache[cacheKey]); + return void res.send(cache[cacheKey]); }; -}()); +}; + +var serveConfig = makeRouteCache(function (host) { + return [ + 'define(function(){', + 'var obj = ' + JSON.stringify({ + requireConf: { + waitSeconds: 600, + urlArgs: 'ver=' + Package.version + cacheString(), + }, + removeDonateButton: (config.removeDonateButton === true), + allowSubscriptions: (config.allowSubscriptions === true), + websocketPath: config.externalWebsocketURL, + httpUnsafeOrigin: config.httpUnsafeOrigin, + adminEmail: Env.adminEmail, + adminKeys: Env.admins, + inactiveTime: Env.inactiveTime, + supportMailbox: Env.supportMailbox, + defaultStorageLimit: Env.defaultStorageLimit, + maxUploadSize: Env.maxUploadSize, + premiumUploadSize: Env.premiumUploadSize, + restrictRegistration: Env.restrictRegistration, // FIXME see the race condition in env.js + }, null, '\t'), + 'obj.httpSafeOrigin = ' + (function () { + if (config.httpSafeOrigin) { return '"' + config.httpSafeOrigin + '"'; } + if (config.httpSafePort) { + return "(function () { return window.location.origin.replace(/\:[0-9]+$/, ':" + + config.httpSafePort + "'); }())"; + } + return 'window.location.origin'; + }()), + 'return obj', + '});' + ].join(';\n') +}, 'configCache'); + +var serveBroadcast = makeRouteCache(function (host) { + var maintenance = Env.maintenance; + if (maintenance && maintenance.end && maintenance.end < (+new Date())) { + maintenance = undefined; + } + return [ + 'define(function(){', + 'return ' + JSON.stringify({ + lastBroadcastHash: Env.lastBroadcastHash, + surveyURL: Env.surveyURL, + maintenance: maintenance + }, null, '\t'), + '});' + ].join(';\n') +}, 'broadcastCache'); app.get('/api/config', serveConfig); +app.get('/api/broadcast', serveBroadcast); var four04_path = Path.resolve(__dirname + '/customize.dist/404.html'); var custom_four04_path = Path.resolve(__dirname + '/customize/404.html'); diff --git a/www/admin/app-admin.less b/www/admin/app-admin.less index c9b8bdc02..17450361c 100644 --- a/www/admin/app-admin.less +++ b/www/admin/app-admin.less @@ -14,8 +14,12 @@ display: flex; flex-flow: column; + a { + color: @cryptpad_color_link; + text-decoration: underline; + } - .cp-admin-setlimit-form { + .cp-admin-setlimit-form, .cp-admin-broadcast-form { label { font-weight: normal !important; } @@ -199,5 +203,85 @@ } } + .cp-admin-broadcast-form { + input.flatpickr-input { + width: 307.875px !important; // same width as flatpickr calendar + } + .cp-broadcast-active { + display: flex; + flex-flow: column; + align-items: start; + padding: 10px; + background-color: @cp_sidebar-left-bg; + color: @cp_sidebar-left-fg; + p { + margin: 0; + } + } + .cp-broadcast-form-submit { + margin-top: 30px; + button { + margin-bottom: 10px !important; + } + } + .cp-broadcast-container { + display: flex; + flex-flow: column; + } + .cp-broadcast-lang { + margin: 30px; + margin-bottom: 0; + display: flex; + flex-flow: column; + align-items: baseline; + .cp-checkmark { + margin: 5px 0; + } + } + div.cp-broadcast-languages { + & > label.cp-checkmark:not(:last-child) { + margin-right: 20px; + } + } + .cp-broadcast-preview { + vertical-align: bottom !important; + } + .cp-broadcast-delete { + width: 100%; + min-width: 600px; + tbody { + tr { + background-color: @cp_support-msg-bg; + padding: 5px; + td { + padding: 5px; + button { + margin: 0 !important; + } + } + } + } + .cp-notification { + display: flex; + align-items: center; + .cp-avatar, .cp-broadcast, .cp-notification-dismiss { + display: none; + } + p { + margin: 0 !important; + } + .cp-notification-content { + width: 100%; + padding: 10px; + } + .cp-clickable { + cursor: pointer; + &:hover { + background-color: @cp_dropdown-bg-hover; + } + } + } + } + } } diff --git a/www/admin/inner.js b/www/admin/inner.js index 6f0b9d2df..ffc9a561c 100644 --- a/www/admin/inner.js +++ b/www/admin/inner.js @@ -1,6 +1,7 @@ define([ 'jquery', '/api/config', + '/customize/application_config.js', '/bower_components/chainpad-crypto/crypto.js', '/common/toolbar.js', '/bower_components/nthen/index.js', @@ -14,12 +15,16 @@ define([ '/common/common-signing-keys.js', '/support/ui.js', + '/lib/datepicker/flatpickr.js', + + 'css!/lib/datepicker/flatpickr.min.css', 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'less!/admin/app-admin.less', ], function ( $, ApiConfig, + AppConfig, Crypto, Toolbar, nThen, @@ -31,7 +36,8 @@ define([ Util, Hash, Keys, - Support + Support, + Flatpickr ) { var APP = { @@ -47,7 +53,7 @@ define([ 'cp-admin-update-limit', 'cp-admin-archive', 'cp-admin-unarchive', - // 'cp-admin-registration', + 'cp-admin-registration', ], 'quota': [ // Msg.admin_cat_quota 'cp-admin-defaultlimit', @@ -67,6 +73,11 @@ define([ 'cp-admin-support-list', 'cp-admin-support-init' ], + 'broadcast': [ // Msg.admin_cat_broadcast + 'cp-admin-maintenance', + 'cp-admin-survey', + 'cp-admin-broadcast', + ], 'performance': [ // Msg.admin_cat_performance 'cp-admin-refresh-performance', 'cp-admin-performance-profiling', @@ -242,36 +253,32 @@ define([ create['registration'] = function () { var key = 'registration'; - var $div = makeBlock(key, true); // Msg.admin_registrationHint, .admin_registrationTitle, .admin_registrationButton - var $button = $div.find('button'); + var $div = makeBlock(key); // Msg.admin_registrationHint, .admin_registrationTitle, .admin_registrationButton + var state = APP.instanceStatus.restrictRegistration; - if (state) { - $button.text(Messages.admin_registrationAllow); - } else { - $button.removeClass('btn-primary').addClass('btn-danger'); - } - var called = false; - $div.find('button').click(function () { - called = true; + var $cbox = $(UI.createCheckbox('cp-settings-userfeedback', + Messages.admin_registrationTitle, + state, { label: { class: 'noTitle' } })); + var spinner = UI.makeSpinner($cbox); + var $checkbox = $cbox.find('input').on('change', function() { + spinner.spin(); + var val = $checkbox.is(':checked') || false; + $checkbox.attr('disabled', 'disabled'); sFrameChan.query('Q_ADMIN_RPC', { cmd: 'ADMIN_DECREE', - data: ['RESTRICT_REGISTRATION', [!state]] + data: ['RESTRICT_REGISTRATION', [val]] }, function (e) { if (e) { UI.warn(Messages.error); console.error(e); } APP.updateStatus(function () { - called = false; + spinner.done(); state = APP.instanceStatus.restrictRegistration; - if (state) { - console.log($button); - $button.text(Messages.admin_registrationAllow); - $button.addClass('btn-primary').removeClass('btn-danger'); - } else { - $button.text(Messages.admin_registrationButton); - $button.removeClass('btn-primary').addClass('btn-danger'); - } + $checkbox[0].checked = state; + $checkbox.removeAttr('disabled'); }); }); }); + $cbox.appendTo($div); + return $div; }; @@ -496,7 +503,7 @@ define([ } var size = Array.isArray(obj) && obj[0]; if (typeof(size) !== "number") { return; } - UI.alert(Util.getPrettySize(size, Messages)); + UI.alert(getPrettySize(size)); }); }); @@ -559,6 +566,13 @@ define([ sFrameChan.query('Q_ADMIN_RPC', { cmd: 'GET_FILE_DESCRIPTOR_COUNT', }, function (e, data) { + if (e || (data && data.error)) { + console.error(e, data); + $div.append(h('pre', { + style: 'text-decoration: underline', + }, String(e || data.error))); + return; + } console.log(e, data); $div.find('pre').remove(); $div.append(h('pre', String(data))); @@ -930,6 +944,542 @@ define([ return; }; + var getApi = function (cb) { + return function () { + require(['/api/broadcast?'+ (+new Date())], function (Broadcast) { + cb(Broadcast); + setTimeout(function () { + try { + var ctx = require.s.contexts._; + var defined = ctx.defined; + Object.keys(defined).forEach(function (href) { + if (/^\/api\/broadcast\?[0-9]{13}/.test(href)) { + delete defined[href]; + return; + } + }); + } catch (e) {} + }); + }); + }; + }; + + // Update the lastBroadcastHash in /api/broadcast if we can do it. + // To do so, find the last "BROADCAST_CUSTOM" in the current history and use the previous + // message's hash. + // If the last BROADCAST_CUSTOM has been deleted by an admin, we can use the most recent + // message's hash. + var checkLastBroadcastHash = function () { + var deleted = []; + + require(['/api/broadcast?'+ (+new Date())], function (BCast) { + var hash = BCast.lastBroadcastHash || '1'; // Truthy value if no lastKnownHash + common.mailbox.getNotificationsHistory('broadcast', null, hash, function (e, msgs) { + if (e) { return void console.error(e); } + + // No history, nothing to change + if (!Array.isArray(msgs)) { return; } + if (!msgs.length) { return; } + + var lastHash; + var next = false; + + // Start from the most recent messages until you find a CUSTOM message and + // check if it has been deleted + msgs.reverse().some(function (data) { + var c = data.content; + + // This is the hash we want to keep + if (next) { + if (!c || !c.hash) { return; } + lastHash = c.hash; + next = false; + return true; + } + + // initialize with the most recent hash + if (!lastHash && c && c.hash) { lastHash = c.hash; } + + var msg = c && c.msg; + if (!msg) { return; } + + // Remember all deleted messages + if (msg.type === "BROADCAST_DELETE") { + deleted.push(Util.find(msg, ['content', 'uid'])); + } + + // Only check custom messages + if (msg.type !== "BROADCAST_CUSTOM") { return; } + + // If the most recent CUSTOM message has been deleted, it means we don't + // need to keep any message and we can continue with lastHash as the most + // recent broadcast message. + if (deleted.indexOf(msg.uid) !== -1) { return true; } + + // We just found the oldest message we want to keep, move one iteration + // further into the loop to get the next message's hash. + // If this is the end of the loop, don't bump lastBroadcastHash at all. + next = true; + }); + + // If we don't have to bump our lastBroadcastHash, abort + if (next) { return; } + + // Otherwise, bump to lastHash + console.warn('Updating last broadcast hash to', lastHash); + sFrameChan.query('Q_ADMIN_RPC', { + cmd: 'ADMIN_DECREE', + data: ['SET_LAST_BROADCAST_HASH', [lastHash]] + }, function (e) { + if (e) { + console.error(e); + return; + } + console.log('lastBroadcastHash updated'); + }); + }); + }); + + }; + + create['broadcast'] = function () { + var key = 'broadcast'; + var $div = makeBlock(key); // Msg.admin_broadcastHint, admin_broadcastTitle + + var form = h('div.cp-admin-broadcast-form'); + var $form = $(form).appendTo($div); + + var refresh = getApi(function (Broadcast) { + var button = h('button.btn.btn-primary', Messages.admin_broadcastButton); + var $button = $(button); + var removeButton = h('button.btn.btn-danger', Messages.admin_broadcastCancel); + var active = h('div.cp-broadcast-active', h('p', Messages.admin_broadcastActive)); + var $active = $(active); + var activeUid; + var deleted = []; + + // Render active message (if there is one) + var hash = Broadcast.lastBroadcastHash || '1'; // Truthy value if no lastKnownHash + common.mailbox.getNotificationsHistory('broadcast', null, hash, function (e, msgs) { + if (e) { return void console.error(e); } + if (!Array.isArray(msgs)) { return; } + if (!msgs.length) { + $active.hide(); + } + msgs.reverse().some(function (data) { + var c = data.content; + var msg = c && c.msg; + if (!msg) { return; } + if (msg.type === "BROADCAST_DELETE") { + deleted.push(Util.find(msg, ['content', 'uid'])); + } + if (msg.type !== "BROADCAST_CUSTOM") { return; } + if (deleted.indexOf(msg.uid) !== -1) { return true; } + + // We found an active custom message, show it + var el = common.mailbox.createElement(data); + var table = h('table.cp-broadcast-delete'); + var $table = $(table); + var uid = Util.find(data, ['content', 'msg', 'uid']); + var time = Util.find(data, ['content', 'msg', 'content', 'time']); + var tr = h('tr', { 'data-uid': uid }, [ + h('td', 'ID: '+uid), + h('td', new Date(time || 0).toLocaleString()), + h('td', el), + h('td.delete', removeButton), + ]); + $table.append(tr); + $active.append(table); + activeUid = uid; + + return true; + }); + if (!activeUid) { $active.hide(); } + }); + + // Custom message + var container = h('div.cp-broadcast-container'); + var $container = $(container); + var languages = Messages._languages; + var keys = Object.keys(languages).sort(); + + // Always keep the textarea ordered by language code + var reorder = function () { + $container.find('.cp-broadcast-lang').each(function (i, el) { + var $el = $(el); + var l = $el.attr('data-lang'); + $el.css('order', keys.indexOf(l)); + }); + }; + + // Remove a textarea + var removeLang = function (l) { + $container.find('.cp-broadcast-lang[data-lang="'+l+'"]').remove(); + + var hasDefault = $container.find('.cp-broadcast-lang .cp-checkmark input:checked').length; + if (!hasDefault) { + $container.find('.cp-broadcast-lang').first().find('.cp-checkmark input').prop('checked', 'checked'); + } + }; + + var getData = function () { return false; }; + var onPreview = function (l) { + var data = getData(); + if (data === false) { return void UI.warn(Messages.error); } + + var msg = { + uid: Util.uid(), + type: 'BROADCAST_CUSTOM', + content: data + }; + common.mailbox.onMessage({ + lang: l, + type: 'broadcast', + content: { + msg: msg, + hash: 'LOCAL|' + JSON.stringify(msg).slice(0,58) + } + }, function () { + UI.log(Messages.saved); + }); + }; + + // Add a textarea + var addLang = function (l) { + if ($container.find('.cp-broadcast-lang[data-lang="'+l+'"]').length) { return; } + var preview = h('button.btn.btn-secondary', Messages.broadcast_preview); + $(preview).click(function () { + onPreview(l); + }); + var bcastDefault = Messages.broadcast_defaultLanguage; + var first = !$container.find('.cp-broadcast-lang').length; + var radio = UI.createRadio('broadcastDefault', null, bcastDefault, first, { + 'data-lang': l, + label: {class: 'noTitle'} + }); + $container.append(h('div.cp-broadcast-lang', { 'data-lang': l }, [ + h('h4', languages[l]), + h('label', Messages.kanban_body), + h('textarea'), + radio, + preview + ])); + reorder(); + }; + + // Checkboxes to select translations + var boxes = keys.map(function (l) { + var $cbox = $(UI.createCheckbox('cp-broadcast-custom-lang-'+l, + languages[l], false, { label: { class: 'noTitle' } })); + var $check = $cbox.find('input').on('change', function () { + var c = $check.is(':checked'); + if (c) { return void addLang(l); } + removeLang(l); + }); + if (l === 'en') { + setTimeout(function () { + $check.click(); + }); + } + return $cbox[0]; + }); + + // Extract form data + getData = function () { + var map = {}; + var defaultLanguage; + var error = false; + $container.find('.cp-broadcast-lang').each(function (i, el) { + var $el = $(el); + var l = $el.attr('data-lang'); + if (!l) { error = true; return; } + var text = $el.find('textarea').val(); + if (!text.trim()) { error = true; return; } + if ($el.find('.cp-checkmark input').is(':checked')) { + defaultLanguage = l; + } + map[l] = text; + }); + if (!Object.keys(map).length) { + console.error('You must select at least one language'); + return false; + } + if (error) { + console.error('One of the selected languages has no data'); + return false; + } + return { + defaultLanguage: defaultLanguage, + content: map + }; + }; + + var send = function (data) { + $button.prop('disabled', 'disabled'); + //data.time = +new Date(); // FIXME not used anymore? + common.mailbox.sendTo('BROADCAST_CUSTOM', data, {}, function (err) { + if (err) { + $button.prop('disabled', ''); + console.error(err); + return UI.warn(Messages.error); + } + UI.log(Messages.saved); + refresh(); + + checkLastBroadcastHash(); + }); + }; + + $button.click(function () { + var data = getData(); + if (data === false) { return void UI.warn(Messages.error); } + send(data); + }); + + UI.confirmButton(removeButton, { + classes: 'btn-danger', + }, function () { + if (!activeUid) { return; } + common.mailbox.sendTo('BROADCAST_DELETE', { + uid: activeUid + }, {}, function (err) { + if (err) { return UI.warn(Messages.error); } + UI.log(Messages.saved); + refresh(); + checkLastBroadcastHash(); + }); + }); + + // Make the form + $form.empty().append([ + active, + h('label', Messages.broadcast_translations), + h('div.cp-broadcast-languages', boxes), + container, + h('div.cp-broadcast-form-submit', [ + h('br'), + button + ]) + ]); + }); + refresh(); + + return $div; + }; + + create['maintenance'] = function () { + var key = 'maintenance'; + var $div = makeBlock(key); // Msg.admin_maintenanceHint, admin_maintenanceTitle + + var form = h('div.cp-admin-broadcast-form'); + var $form = $(form).appendTo($div); + + var refresh = getApi(function (Broadcast) { + var button = h('button.btn.btn-primary', Messages.admin_maintenanceButton); + var $button = $(button); + var removeButton = h('button.btn.btn-danger', Messages.admin_maintenanceCancel); + var active; + + if (Broadcast && Broadcast.maintenance) { + var m = Broadcast.maintenance; + if (m.start && m.end && m.end >= (+new Date())) { + active = h('div.cp-broadcast-active', [ + UI.setHTML(h('p'), Messages._getKey('broadcast_maintenance', [ + new Date(m.start).toLocaleString(), + new Date(m.end).toLocaleString(), + ])), + removeButton + ]); + } + } + + // Start and end date pickers + var start = h('input'); + var end = h('input'); + var $start = $(start); + var $end = $(end); + var is24h = false; + try { + is24h = !new Intl.DateTimeFormat(navigator.language, { hour: 'numeric' }).format(0).match(/AM/); + } catch (e) {} + + var endPickr = Flatpickr(end, { + enableTime: true, + time_24hr: is24h, + minDate: new Date() + }); + Flatpickr(start, { + enableTime: true, + time_24hr: is24h, + minDate: new Date(), + onChange: function () { + endPickr.set('minDate', new Date($start.val())); + } + }); + + // Extract form data + var getData = function () { + var start = +new Date($start.val()); + var end = +new Date($end.val()); + if (isNaN(start) || isNaN(end)) { + console.error('Invalid dates'); + return false; + } + return { + start: start, + end: end + }; + }; + + var send = function (data) { + $button.prop('disabled', 'disabled'); + sFrameChan.query('Q_ADMIN_RPC', { + cmd: 'ADMIN_DECREE', + data: ['SET_MAINTENANCE', [data]] + }, function (e) { + if (e) { + UI.warn(Messages.error); console.error(e); + $button.prop('disabled', ''); + return; + } + // Maintenance applied, send notification + common.mailbox.sendTo('BROADCAST_MAINTENANCE', {}, {}, function () { + refresh(); + checkLastBroadcastHash(); + }); + }); + + }; + $button.click(function () { + var data = getData(); + if (data === false) { return void UI.warn(Messages.error); } + send(data); + }); + UI.confirmButton(removeButton, { + classes: 'btn-danger', + }, function () { + send(""); + }); + + $form.empty().append([ + active, + h('label', Messages.broadcast_start), + start, + h('label', Messages.broadcast_end), + end, + h('br'), + h('div.cp-broadcast-form-submit', [ + button + ]) + ]); + }); + refresh(); + + common.makeUniversal('broadcast', { + onEvent: function (obj) { + var cmd = obj.ev; + if (cmd !== "MAINTENANCE") { return; } + refresh(); + } + }); + + return $div; + }; + create['survey'] = function () { + var key = 'survey'; + var $div = makeBlock(key); // Msg.admin_surveyHint, admin_surveyTitle + + var form = h('div.cp-admin-broadcast-form'); + var $form = $(form).appendTo($div); + + var refresh = getApi(function (Broadcast) { + var button = h('button.btn.btn-primary', Messages.admin_surveyButton); + var $button = $(button); + var removeButton = h('button.btn.btn-danger', Messages.admin_surveyCancel); + var active; + + if (Broadcast && Broadcast.surveyURL) { + var a = h('a', {href: Broadcast.surveyURL}, Messages.admin_surveyActive); + $(a).click(function (e) { + e.preventDefault(); + common.openUnsafeURL(Broadcast.surveyURL); + }); + active = h('div.cp-broadcast-active', [ + h('p', a), + removeButton + ]); + } + + // Survey form + var label = h('label', Messages.broadcast_surveyURL); + var input = h('input'); + var $input = $(input); + + // Extract form data + var getData = function () { + var url = $input.val(); + if (!Util.isValidURL(url)) { + console.error('Invalid URL'); + return false; + } + return url; + }; + + var send = function (data) { + $button.prop('disabled', 'disabled'); + sFrameChan.query('Q_ADMIN_RPC', { + cmd: 'ADMIN_DECREE', + data: ['SET_SURVEY_URL', [data]] + }, function (e) { + if (e) { + $button.prop('disabled', ''); + UI.warn(Messages.error); console.error(e); + return; + } + // Maintenance applied, send notification + common.mailbox.sendTo('BROADCAST_SURVEY', { + url: data + }, {}, function () { + refresh(); + checkLastBroadcastHash(); + }); + }); + + }; + $button.click(function () { + var data = getData(); + if (data === false) { return void UI.warn(Messages.error); } + send(data); + }); + UI.confirmButton(removeButton, { + classes: 'btn-danger', + }, function () { + send(""); + }); + + $form.empty().append([ + active, + label, + input, + h('br'), + h('div.cp-broadcast-form-submit', [ + button + ]) + ]); + }); + refresh(); + + common.makeUniversal('broadcast', { + onEvent: function (obj) { + var cmd = obj.ev; + if (cmd !== "SURVEY") { return; } + refresh(); + } + }); + + return $div; + }; + var onRefreshPerformance = Util.mkEvent(); create['refresh-performance'] = function () { @@ -1010,6 +1560,7 @@ define([ stats: 'fa fa-line-chart', quota: 'fa fa-hdd-o', support: 'fa fa-life-ring', + broadcast: 'fa fa-bullhorn', performance: 'fa fa-heartbeat', }; @@ -1094,8 +1645,7 @@ define([ var privateData = metadataMgr.getPrivateData(); common.setTabTitle(Messages.adminPage || 'Administration'); - if (!privateData.edPublic || !ApiConfig.adminKeys || !Array.isArray(ApiConfig.adminKeys) - || ApiConfig.adminKeys.indexOf(privateData.edPublic) === -1) { + if (!common.isAdmin()) { return void UI.errorLoadingScreen(Messages.admin_authError || '403 Forbidden'); } diff --git a/www/assert/assertions.js b/www/assert/assertions.js index a1f6944fb..8e2351cf7 100644 --- a/www/assert/assertions.js +++ b/www/assert/assertions.js @@ -3,8 +3,9 @@ define([], function () { var failMessages = []; var passed = 0; var ASSERTS = []; - + var MESSAGES = []; var assert = function (test, msg) { + MESSAGES.push(msg || false); ASSERTS.push(function (cb, i) { test(function (result) { if (result === true) { @@ -17,7 +18,7 @@ define([], function () { output: result, }); } - }); + }, msg); }); }; diff --git a/www/calendar/app-calendar.less b/www/calendar/app-calendar.less new file mode 100644 index 000000000..d48914532 --- /dev/null +++ b/www/calendar/app-calendar.less @@ -0,0 +1,431 @@ +@import (reference) '../../customize/src/less2/include/framework.less'; +@import (reference) '../../customize/src/less2/include/sidebar-layout.less'; +@import (reference) '../../customize/src/less2/include/tools.less'; +@import (reference) '../../customize/src/less2/include/avatar.less'; + +&.cp-app-calendar { + + .framework_min_main(); + .sidebar-layout_main(); + + display: flex; + flex-flow: column; + + .cp-toolbar-bottom-mid > div { + .cp-small { display: none; } + } + + #cp-sidebarlayout-container #cp-sidebarlayout-rightside { + padding: 0; + & > div { + margin: 0; + } + + .cp-forcehide { + display: none !important; + } + + .tui-full-calendar-layout { + background-color: @cp_sidebar-right-bg !important; + color: @cryptpad_text_col; + display: flex; + flex-flow: column; + .tui-full-calendar-week-container { + min-height: 0; + display: flex; + flex-flow: column; + .tui-full-calendar-vlayout-area { + display: flex; + flex-flow: column; + flex: 1; + min-height: 0; + & > div:last-child { + flex: 1; + min-height: 0; + } + } + } + .tui-full-calendar-weekday-filled { + background-color: @cp_dropdown-bg-hover !important; + } + + .tui-full-calendar-timegrid-hourmarker-time { + color: @cp_calendar-now !important; + } + .tui-full-calendar-timegrid-hourmarker-line-left, .tui-full-calendar-timegrid-hourmarker-line-today { + border-color: @cp_calendar-now !important; + } + .tui-full-calendar-timegrid-todaymarker { + background-color: @cp_calendar-now !important; + } + + .tui-full-calendar-month { + display: flex; + flex-flow: column; + & > div:last-child { + display: flex; + flex-flow: column; + flex: 1; + min-height: 0; + overflow: hidden; + } + .tui-full-calendar-today .tui-full-calendar-weekday-grid-date-decorator { + background-color: @cp_calendar-now !important; + color: @cp_calendar-now-fg !important; + } + .tui-full-calendar-weekday-schedule-time .tui-full-calendar-weekday-schedule-title { + color: @cryptpad_text_col !important; + } + .tui-full-calendar-extra-date { + .tui-full-calendar-weekday-grid-date { + color: @cp_sidebar-hint !important; + opacity: 0.5; + } + } + .tui-full-calendar-weekday-grid-date { + color: @cryptpad_text_col !important; + } + .tui-full-calendar-month-dayname-item span { + color: @cryptpad_text_col !important; + } + } + .tui-full-calendar-dayname * { + color: @cryptpad_text_col !important; + } + .tui-full-calendar-month-more { + background-color: @cp_sidebar-right-bg !important; + color: @cryptpad_text_col; + span { + color: @cryptpad_text_col !important; + } + } + } + .tui-full-calendar-timegrid-timezone { + background-color: @cp_sidebar-right-bg !important; + .tui-full-calendar-timegrid-hour { + color: @cryptpad_text_col !important; + } + color: @cryptpad_text_col; + } + .tui-full-calendar-timegrid-gridline, .tui-full-calendar-time-date { + border-color: @cp_calendar-border !important; + } + .tui-full-calendar-splitter, .tui-full-calendar-left, .tui-full-calendar-dayname-container, .tui-full-calendar-weekday-grid-line { + border-color: @cp_calendar-border !important; + + } + .tui-full-calendar-popup-container { + background: @cp_flatpickr-bg; + color: @cryptpad_text_col; + .tui-full-calendar-icon:not(.tui-full-calendar-calendar-dot):not(.tui-full-calendar-dropdown-arrow):not(.tui-full-calendar-ic-checkbox) { + display: none; + } + } + li.tui-full-calendar-popup-section-item { + padding: 0 6px; + height: 32px; + } + .tui-full-calendar-popup-section-item { + height: auto; + margin: 0; + &:not(li):not(button) { + padding: 0; + margin-top: 5px; + } + #tui-full-calendar-schedule-calendar { + width: 179px; + top: 0; + } + &:not(button) { + border: none; + display: inline-flex; + align-items: center; + &:hover { + background-color: @cp_dropdown-bg-hover; + } + .tui-full-calendar-content { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font: @colortheme_app-font; + } + input { flex: 1; } + } + } + .tui-full-calendar-section-date-dash { + height: auto; + } + .tui-full-calendar-section-title, .tui-full-calendar-section-location { + width: 100%; + } + .tui-full-calendar-dropdown-menu { + top: 38px; + width: 221px; // same as button + background-color: @cp_dropdown-bg; + color: @cp_dropdown-fg; + } + .tui-full-calendar-section-state, #tui-full-calendar-schedule-private { + display: none !important; + } + + .tui-full-calendar-popup:not(.tui-full-calendar-popup-detail) { + .tui-full-calendar-section-calendar { + width: 221px; // 50% + } + .tui-full-calendar-popup-section { + display: flex; + align-items: center; + flex-wrap: wrap; + .tui-full-calendar-section-start-date, .tui-full-calendar-section-end-date { + flex: 1; + } + .tui-full-calendar-section-allday { + width: 100%; + height: 32px; + } + } + } + .tui-full-calendar-popup-detail { + font: @colortheme_app-font; + color: @cryptpad_text_col; + .tui-full-calendar-popup-container { + padding-bottom: 17px; + } + .tui-full-calendar-popup-detail-date { + font-size: 14px; + } + .tui-full-calendar-section-button { + border: 0; + display: flex; + align-items: center; + button { + flex: 1; + margin: 0; + } + } + .tui-full-calendar-popup-vertical-line { + visibility: hidden; + width: 10px; + } + } + + .cp-calendar-add-notif { + flex-flow: column; + align-items: baseline !important; + margin: 10px 0; + .cp-notif-label { + color: @cp_sidebar-hint; + margin-right: 20px; + } + * { + font-size: @colortheme_app-font-size; + font-weight: normal; + } + & > div { + display: flex; + } + .cp-calendar-notif-list-container { + margin-bottom: 10px; + } + .cp-calendar-notif-list { + display: flex; + flex-flow: column; + .cp-notif-entry { + margin-bottom: 2px; + .cp-notif-value { + width: 170px; + display: inline-flex; + .cp-before { + flex: 1; + min-width: 0; + } + } + span:not(:last-child) { + margin-right: 5px; + } + } + } + .cp-notif-empty { + display: none; + } + .cp-calendar-notif-list:empty ~ .cp-notif-empty { + display: block; + } + .cp-calendar-notif-form { + align-items: center; + margin-bottom: 20px; + input { + width: 100px; + } + } + } + + .cp-calendar-close { + height: auto; + line-height: initial; + border: 1px solid; + &:not(:hover) { + background: transparent; + } + } + } + + #cp-toolbar .cp-calendar-browse { + display: flex; + align-items: center; + } + + #cp-sidebarlayout-leftside { + & > div { + padding: 10px + } + .cp-calendar-new { + display: flex; + align-items: center; + justify-content: space-between; + } + .cp-calendar-list { + overflow-y: auto; + .cp-calendar-team { + height: 30px; + .avatar_main(30px); + .cp-avatar { + margin-right: 10px; + } + .cp-name { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + display: flex; + align-items: center; + justify-content: center; + margin: 5px 0; + &:not(:first-child) { + margin-top: 30px; + } + } + .cp-calendar-entry { + display: flex; + align-items: center; + justify-content: space-between; + padding: 5px; + &:not(.cp-unclickable) { + cursor: pointer; + } + .cp-dropdown-container { + position: initial; + } + &.cp-ghost { + padding: 0; + button { + .tools_unselectable(); + cursor: pointer; + width: 100%; + display: flex; + justify-content: space-between; + background: transparent; + border: 1px solid @cryptpad_text_col; + height: 36px; + font: @colortheme_app-font; + align-items: center; + color: @cryptpad_text_col; + &:hover { + background: @cp_sidebar-left-active; + } + } + } + &:not(:last-child) { + margin-bottom: 10px; + } + &:hover { + background: fade(@cryptpad_text_col, 10%); + } + &.cp-restricted { + color: @cp_drive-header-fg; + } + .cp-calendar-icon { + width: 36px; + display: inline-flex; + height: 36px; + margin: -5px; + align-items: center; + justify-content: center; + } + &.cp-active { + background: @cp_sidebar-left-active; + .cp-calendar-inactive { + display: none; + } + } + &:not(.cp-active) { + .cp-calendar-icon { + background: transparent !important; + } + .cp-calendar-active { + display: none; + } + } + .tools_unselectable(); + .cp-calendar-color { + display: inline-block; + border-radius: 50%; + width: 15px; + height: 15px; + flex-shrink: 0; + } + .cp-calendar-title { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + padding: 0 5px; + } + } + } + } + .cp-calendar-colorpicker { + width: 100px; + height: 25px; + cursor: pointer; + border: 1px solid @cp_forms-border; + } + + @media (max-width: @browser_media-medium-screen) { + .cp-calendar-newevent { + i { + margin: 0 !important; + } + span { + display: none; + } + } + .tui-full-calendar-dayname-leftmargin, .tui-full-calendar-timegrid-right { + margin-left: 40px !important; + } + .tui-full-calendar-allday-left, .tui-full-calendar-timegrid-left { + width: 40px !important; + } + .tui-full-calendar-dayname > span { + display: flex; + flex-flow: column; + line-height: 0; + justify-content: center; + align-items: center; + height: 100%; + } + .tui-full-calendar-dayname * { + font-size: 11px; + line-height: initial; + height: auto; + } + .cp-toolbar-bottom-mid > div { + :not(:first-child) { + display: none; + } + :first-child { + display: inline-block; + } + } + } +} + diff --git a/www/calendar/export.js b/www/calendar/export.js new file mode 100644 index 000000000..64775762b --- /dev/null +++ b/www/calendar/export.js @@ -0,0 +1,208 @@ +// This file is used when a user tries to export the entire CryptDrive. +// Calendars will be exported using this format instead of plain text. +define([ + '/customize/pages.js', +], function (Pages) { + var module = {}; + + var getICSDate = function (str) { + var date = new Date(str); + + var m = date.getUTCMonth() + 1; + var d = date.getUTCDate(); + var h = date.getUTCHours(); + var min = date.getUTCMinutes(); + + var year = date.getUTCFullYear().toString(); + var month = m < 10 ? "0" + m : m.toString(); + var day = d < 10 ? "0" + d : d.toString(); + var hours = h < 10 ? "0" + h : h.toString(); + var minutes = min < 10 ? "0" + min : min.toString(); + + return year + month + day + "T" + hours + minutes + "00Z"; + }; + + + var getDate = function (str, end) { + var date = new Date(str); + if (end) { + date.setDate(date.getDate() + 1); + } + var m = date.getUTCMonth() + 1; + var d = date.getUTCDate(); + + var year = date.getUTCFullYear().toString(); + var month = m < 10 ? "0" + m : m.toString(); + var day = d < 10 ? "0" + d : d.toString(); + + return year+month+day; + }; + + var MINUTE = 60; + var HOUR = MINUTE * 60; + var DAY = HOUR * 24; + + + module.main = function (userDoc) { + var content = userDoc.content; + + var ICS = [ + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'PRODID:-//CryptPad//CryptPad Calendar '+Pages.versionString+'//EN', + 'METHOD:PUBLISH', + ]; + + Object.keys(content).forEach(function (uid) { + var data = content[uid]; + // DTSTAMP: now... + // UID: uid + var start, end; + if (data.isAllDay && data.startDay && data.endDay) { + start = "DTSTART;VALUE=DATE:" + getDate(data.startDay); + end = "DTEND;VALUE=DATE:" + getDate(data.endDay, true); + } else { + start = "DTSTART:"+getICSDate(data.start); + end = "DTEND:"+getICSDate(data.end); + } + + Array.prototype.push.apply(ICS, [ + 'BEGIN:VEVENT', + 'DTSTAMP:'+getICSDate(+new Date()), + 'UID:'+uid, + start, + end, + 'SUMMARY:'+ data.title, + 'LOCATION:'+ data.location, + ]); + + if (Array.isArray(data.reminders)) { + data.reminders.forEach(function (valueMin) { + var time = valueMin * 60; + var days = Math.floor(time / DAY); + time -= days * DAY; + var hours = Math.floor(time / HOUR); + time -= hours * HOUR; + var minutes = Math.floor(time / MINUTE); + time -= minutes * MINUTE; + var seconds = time; + + var str = "-P" + days + "D"; + if (hours || minutes || seconds) { + str += "T" + hours + "H" + minutes + "M" + seconds + "S"; + } + Array.prototype.push.apply(ICS, [ + 'BEGIN:VALARM', + 'ACTION:DISPLAY', + 'DESCRIPTION:This is an event reminder', + 'TRIGGER:'+str, + 'END:VALARM' + ]); + }); + } + + if (Array.isArray(data.cp_hidden)) { + Array.prototype.push.apply(ICS, data.cp_hidden); + } + + ICS.push('END:VEVENT'); + }); + + ICS.push('END:VCALENDAR'); + + return new Blob([ ICS.join('\n') ], { type: 'text/calendar;charset=utf-8' }); + }; + + module.import = function (content, id, cb) { + require(['/lib/ical.min.js'], function () { + var ICAL = window.ICAL; + var res = {}; + + var vcalendar; + try { + var jcalData = ICAL.parse(content); + vcalendar = new ICAL.Component(jcalData); + } catch (e) { + return void cb(e); + } + + //var method = vcalendar.getFirstPropertyValue('method'); + //if (method !== "PUBLISH") { return void cb('NOT_SUPPORTED'); } + + // Add all timezones in iCalendar object to TimezoneService + // if they are not already registered. + var timezones = vcalendar.getAllSubcomponents("vtimezone"); + timezones.forEach(function (timezone) { + if (!(ICAL.TimezoneService.has(timezone.getFirstPropertyValue("tzid")))) { + ICAL.TimezoneService.register(timezone); + } + }); + + var events = vcalendar.getAllSubcomponents('vevent'); + events.forEach(function (ev) { + var uid = ev.getFirstPropertyValue('uid'); + if (!uid) { return; } + + // Get start and end time + var isAllDay = false; + var start = ev.getFirstPropertyValue('dtstart'); + var end = ev.getFirstPropertyValue('dtend'); + if (start.isDate && end.isDate) { + isAllDay = true; + start = String(start); + end.adjust(-1); // Substract one day + end = String(end); + } else { + start = +start.toJSDate(); + end = +end.toJSDate(); + } + + // Store other properties + var used = ['dtstart', 'dtend', 'uid', 'summary', 'location', 'dtstamp']; + var hidden = []; + ev.getAllProperties().forEach(function (p) { + if (used.indexOf(p.name) !== -1) { return; } + // This is an unused property + hidden.push(p.toICALString()); + }); + + // Get reminders + var reminders = []; + ev.getAllSubcomponents('valarm').forEach(function (al) { + var action = al.getFirstPropertyValue('action'); + if (action !== 'DISPLAY') { + // Email notification: keep it in "hidden" and create a cryptpad notification + hidden.push(al.toString()); + } + var trigger = al.getFirstPropertyValue('trigger'); + var minutes = -trigger.toSeconds() / 60; + if (reminders.indexOf(minutes) === -1) { reminders.push(minutes); } + }); + + // Create event + res[uid] = { + calendarId: id, + id: uid, + category: 'time', + title: ev.getFirstPropertyValue('summary'), + location: ev.getFirstPropertyValue('location'), + isAllDay: isAllDay, + start: start, + end: end, + reminders: reminders, + cp_hidden: hidden + }; + + if (!hidden.length) { delete res[uid].cp_hidden; } + if (!reminders.length) { delete res[uid].reminders; } + + }); + + cb(null, res); + }); + }; + + return module; +}); + + diff --git a/www/calendar/index.html b/www/calendar/index.html new file mode 100644 index 000000000..96a3cce86 --- /dev/null +++ b/www/calendar/index.html @@ -0,0 +1,12 @@ + + + + CryptPad + + + + + + + + diff --git a/www/calendar/inner.html b/www/calendar/inner.html new file mode 100644 index 000000000..8c77c4fd7 --- /dev/null +++ b/www/calendar/inner.html @@ -0,0 +1,18 @@ + + + + + + + + +
    +
    + + + diff --git a/www/calendar/inner.js b/www/calendar/inner.js new file mode 100644 index 000000000..58262f956 --- /dev/null +++ b/www/calendar/inner.js @@ -0,0 +1,1292 @@ +define([ + 'jquery', + 'json.sortify', + '/bower_components/chainpad-crypto/crypto.js', + '/common/toolbar.js', + '/bower_components/nthen/index.js', + '/common/sframe-common.js', + '/common/common-util.js', + '/common/common-hash.js', + '/common/common-interface.js', + '/common/common-ui-elements.js', + '/common/common-realtime.js', + '/common/clipboard.js', + '/common/inner/common-mediatag.js', + '/common/hyperscript.js', + '/customize/messages.js', + '/customize/application_config.js', + '/lib/calendar/tui-calendar.min.js', + '/calendar/export.js', + + '/common/inner/share.js', + '/common/inner/access.js', + '/common/inner/properties.js', + + '/common/jscolor.js', + '/bower_components/file-saver/FileSaver.min.js', + 'css!/lib/calendar/tui-calendar.min.css', + 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', + 'less!/calendar/app-calendar.less', +], function ( + $, + JSONSortify, + Crypto, + Toolbar, + nThen, + SFCommon, + Util, + Hash, + UI, + UIElements, + Realtime, + Clipboard, + MT, + h, + Messages, + AppConfig, + Calendar, + Export, + Share, Access, Properties + ) +{ + var SaveAs = window.saveAs; + var APP = window.APP = { + calendars: {} + }; + + var common; + var metadataMgr; + var sframeChan; + + var onCalendarsUpdate = Util.mkEvent(); + + var newCalendar = function (data, cb) { + APP.module.execCommand('CREATE', data, function (obj) { + if (obj && obj.error) { return void cb(obj.error); } + cb(null, obj); + }); + }; + var updateCalendar = function (data, cb) { + APP.module.execCommand('UPDATE', data, function (obj) { + if (obj && obj.error) { return void cb(obj.error); } + cb(null, obj); + }); + }; + var deleteCalendar = function (data, cb) { + APP.module.execCommand('DELETE', data, function (obj) { + if (obj && obj.error) { return void cb(obj.error); } + cb(null, obj); + }); + }; + var importCalendar = function (data, cb) { + APP.module.execCommand('IMPORT', data, function (obj) { + if (obj && obj.error) { return void cb(obj.error); } + cb(null, obj); + }); + }; + var importICSCalendar = function (data, cb) { + APP.module.execCommand('IMPORT_ICS', data, function (obj) { + if (obj && obj.error) { return void cb(obj.error); } + cb(null, obj); + }); + }; + var newEvent = function (data, cb) { + APP.module.execCommand('CREATE_EVENT', data, function (obj) { + if (obj && obj.error) { return void cb(obj.error); } + cb(null, obj); + }); + }; + var updateEvent = function (data, cb) { + APP.module.execCommand('UPDATE_EVENT', data, function (obj) { + if (obj && obj.error) { return void cb(obj.error); } + cb(null, obj); + }); + }; + var deleteEvent = function (data, cb) { + APP.module.execCommand('DELETE_EVENT', data, function (obj) { + if (obj && obj.error) { return void cb(obj.error); } + cb(null, obj); + }); + }; + + var getContrast = function (color) { + var rgb = Util.hexToRGB(color); + // http://www.w3.org/TR/AERT#color-contrast + var brightness = Math.round(((parseInt(rgb[0]) * 299) + + (parseInt(rgb[1]) * 587) + + (parseInt(rgb[2]) * 114)) / 1000); + return (brightness > 125) ? '#424242' : '#EEEEEE'; + }; + + var getWeekDays = function (large) { + var baseDate = new Date(Date.UTC(2017, 0, 1)); // just a Sunday + var weekDays = []; + for(var i = 0; i < 7; i++) { + weekDays.push(baseDate.toLocaleDateString(undefined, { weekday: 'long' })); + baseDate.setDate(baseDate.getDate() + 1); + } + if (!large) { + weekDays = weekDays.map(function (day) { return day.slice(0,3); }); + } + return weekDays.map(function (day) { return day.replace(/^./, function (str) { return str.toUpperCase(); }); }); + }; + + + + var getCalendars = function () { + return Object.keys(APP.calendars).map(function (id) { + var c = APP.calendars[id]; + if (c.hidden || c.restricted || c.loading) { return; } + var md = Util.find(c, ['content', 'metadata']); + if (!md) { return void console.error('Ignore calendar without metadata'); } + return { + id: id, + name: md.title, + color: getContrast(md.color), + bgColor: md.color, + dragBgColor: md.color, + borderColor: md.color, + }; + }).filter(Boolean); + }; + var getSchedules = function () { + var s = []; + var calendars = Object.keys(APP.calendars); + if (APP.currentCalendar) { + var currentCal = calendars.filter(function (id) { + var c = APP.calendars[id]; + var t = c.teams || []; + if (id !== APP.currentCalendar) { return; } + return t.length === 1 && t[0] === 0; + }); + if (currentCal.length) { calendars = currentCal; } + } + calendars.forEach(function (id) { + var c = APP.calendars[id]; + if (c.hidden || c.restricted || c.loading) { return; } + var data = c.content || {}; + Object.keys(data.content || {}).forEach(function (uid) { + var obj = data.content[uid]; + obj.title = obj.title || ""; + obj.location = obj.location || ""; + if (obj.isAllDay && obj.startDay) { obj.start = +new Date(obj.startDay); } + if (obj.isAllDay && obj.endDay) { + var endDate = new Date(obj.endDay); + endDate.setHours(23); + endDate.setMinutes(59); + endDate.setSeconds(59); + obj.end = +endDate; + } + if (c.readOnly) { + obj.isReadOnly = true; + } + s.push(data.content[uid]); + }); + }); + return s; + }; + var renderCalendar = function () { + var cal = APP.calendar; + if (!cal) { return; } + + cal.clear(); + cal.setCalendars(getCalendars()); + cal.createSchedules(getSchedules(), true); + cal.render(); + }; + var onCalendarUpdate = function (data) { + var cal = APP.calendar; + + if (data.deleted) { + // Remove this calendar + delete APP.calendars[data.id]; + } else { + // Update local data + APP.calendars[data.id] = data; + } + + // If calendar if initialized, update it + if (!cal) { return; } + onCalendarsUpdate.fire(); + renderCalendar(); + }; + + var getTime = function (time) { + var d = new Date(); + d.setHours(time.hour); + d.setMinutes(time.minutes); + return d.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}); + }; + + // If this browser doesn't support options to toLocaleTimeString, use default layout + if (!(function () { + // Modern browser will return a RangeError if the "locale" argument is invalid. + // Note: the "locale" argument has the same browser compatibility table as the "options" + try { + new Date().toLocaleTimeString('i'); + } catch (e) { + return e.name === 'RangeError'; + } + })()) { getTime = undefined; } + + var templates = { + popupSave: function (obj) { + APP.editModalData = obj.data && obj.data.root; + return Messages.settings_save; + }, + popupUpdate: function(obj) { + APP.editModalData = obj.data && obj.data.root; + return Messages.calendar_update; + }, + monthGridHeaderExceed: function(hiddenSchedules) { + return '' + Messages._getKey('calendar_more', [hiddenSchedules]) + ''; + }, + popupEdit: function() { return Messages.poll_edit; }, + popupDelete: function() { return Messages.kanban_delete; }, + popupDetailLocation: function(schedule) { + // TODO detect url and create 'a' tag + return Messages._getKey('calendar_location', [Util.fixHTML(schedule.location)]); + }, + popupIsAllDay: function() { return Messages.calendar_allDay; }, + titlePlaceholder: function() { return Messages.calendar_title; }, + locationPlaceholder: function() { return Messages.calendar_loc; }, + alldayTitle: function() { + return ''+Messages.calendar_allDay+''; + }, + timegridDisplayTime: getTime, + timegridDisplayPrimaryTime: getTime, + popupDetailDate: function(isAllDay, start, end) { + var startDate = start._date.toLocaleDateString(); + var endDate = end._date.toLocaleDateString(); + if (isAllDay) { + if (startDate === endDate) { return startDate; } + return Messages._getKey('calendar_dateRange', [startDate, endDate]); + } + + var startTime = getTime({ + hour: start._date.getHours(), + minutes: start._date.getMinutes(), + }); + var endTime = getTime({ + hour: end._date.getHours(), + minutes: end._date.getMinutes(), + }); + + if (startDate === endDate && startTime === endTime) { + return start._date.toLocaleString(); + } + if (startDate === endDate) { + return Messages._getKey('calendar_dateTimeRange', [startDate, startTime, endTime]); + } + return Messages._getKey('calendar_dateRange', [start._date.toLocaleString(), end._date.toLocaleString()]); + } + }; + + var editCalendar = function (id) { + var isNew = !id; + var data = APP.calendars[id]; + if (id && !data) { return; } + var md = {}; + if (!isNew) { md = Util.find(data, ['content', 'metadata']); } + if (!md) { return; } + + // Create form data + var labelTitle = h('label', Messages.kanban_title); + var title = h('input'); + var $title = $(title); + $title.val(md.title || Messages.calendar_new); + var labelColor = h('label', Messages.kanban_color); + + var $colorPicker = $(h('div.cp-calendar-colorpicker')); + var jscolorL = new window.jscolor($colorPicker[0], { showOnClick: false, valueElement: undefined, zIndex: 100000 }); + $colorPicker.click(function() { + jscolorL.show(); + }); + if (md.color) { jscolorL.fromString(md.color); } + else { jscolorL.fromString(Util.getRandomColor()); } + + var form = h('div', [ + labelTitle, + title, + labelColor, + $colorPicker[0] + ]); + + var send = function (obj) { + if (isNew) { + return void newCalendar(obj, function (err) { + if (err) { console.error(err); return void UI.warn(Messages.error); } + UI.log(Messages.saved); + }); + } + obj.id = id; + updateCalendar(obj, function (err) { + if (err) { console.error(err); return void UI.warn(Messages.error); } + UI.log(Messages.saved); + }); + }; + var m = UI.dialog.customModal(form, { + buttons: [{ + className: 'cancel', + name: Messages.cancel, + onClick: function () {}, + keys: [27] + }, { + className: 'primary', + name: Messages.settings_save, + onClick: function () { + var color = jscolorL.toHEXString(); + var title = $title.val(); + var obj = { + color: color, + title: title + }; + if (!title || !title.trim() ||!/^#[0-9a-fA-F]{6}$/.test(color)) { + return true; + } + send(obj); + }, + keys: [13] + }] + }); + UI.openCustomModal(m); + }; + + var isReadOnly = function (id, teamId) { + var data = APP.calendars[id]; + return data.readOnly || (data.roTeams && data.roTeams.indexOf(teamId) !== -1); + }; + var makeEditDropdown = function (id, teamId) { + var options = []; + var privateData = metadataMgr.getPrivateData(); + var cantRemove = teamId === 0 || (teamId !== 1 && privateData.teams[teamId].viewer); + var data = APP.calendars[id]; + if (!data.readOnly) { + options.push({ + tag: 'a', + attributes: { + 'class': 'fa fa-pencil', + }, + content: h('span', Messages.tag_edit), + action: function (e) { + e.stopPropagation(); + editCalendar(id); + return true; + } + }); + } + if (APP.loggedIn && (data.teams.indexOf(1) === -1 || teamId === 0)) { + options.push({ + tag: 'a', + attributes: { + 'class': 'fa fa-clone', + }, + content: h('span', Messages.calendar_import), + action: function (e) { + e.stopPropagation(); + importCalendar({ + id: id, + teamId: teamId + }, function (err) { + if (err) { + console.error(err); + return void UI.warn(Messages.error); + } + }); + return true; + } + }); + } + if (!data.restricted) { + options.push({ + tag: 'a', + attributes: { + 'class': 'fa fa-shhare-alt', + }, + content: h('span', Messages.shareButton), + action: function (e) { + e.stopPropagation(); + var friends = common.getFriends(); + var cal = APP.calendars[id]; + var title = Util.find(cal, ['content', 'metadata', 'title']); + var color = Util.find(cal, ['content', 'metadata', 'color']); + Share.getShareModal(common, { + teamId: teamId === 1 ? undefined : teamId, + origin: APP.origin, + pathname: "/calendar/", + friends: friends, + title: title, + password: cal.password, + calendar: { + title: title, + color: color, + channel: id, + }, + common: common, + hashes: cal.hashes + }); + return true; + } + }); + options.push({ + tag: 'a', + attributes: { + 'class': 'fa fa-lock', + }, + content: h('span', Messages.accessButton), + action: function (e) { + e.stopPropagation(); + var cal = APP.calendars[id]; + var title = Util.find(cal, ['content', 'metadata', 'title']); + var color = Util.find(cal, ['content', 'metadata', 'color']); + var h = cal.hashes || {}; + var href = Hash.hashToHref(h.editHash || h.viewHash, 'calendar'); + Access.getAccessModal(common, { + title: title, + password: cal.password, + calendar: { + title: title, + color: color, + channel: id, + }, + common: common, + noExpiration: true, + noEditPassword: true, + channel: id, + href: href + }); + return true; + } + }); + + if (!data.readOnly) { + options.push({ + tag: 'a', + attributes: { + 'class': 'fa fa-upload', + }, + content: h('span', Messages.importButton), + action: function () { + UIElements.importContent('text/calendar', function (res) { + Export.import(res, id, function (err, json) { + if (err) { return void UI.warn(Messages.importError); } + importICSCalendar({ + id: id, + json: json + }, function (err) { + if (err) { return void UI.warn(Messages.error); } + UI.log(Messages.saved); + }); + + }); + }, { + accept: ['.ics'] + })(); + return true; + } + }); + } + options.push({ + tag: 'a', + attributes: { + 'class': 'fa fa-download', + }, + content: h('span', Messages.exportButton), + action: function (e) { + e.stopPropagation(); + var cal = APP.calendars[id]; + var suggestion = Util.find(cal, ['content', 'metadata', 'title']); + var types = []; + types.push({ + tag: 'a', + attributes: { + 'data-value': '.ics', + 'href': '#' + }, + content: '.ics' + }); + var dropdownConfig = { + text: '.ics', // Button initial text + caretDown: true, + options: types, // Entries displayed in the menu + isSelect: true, + initialValue: '.ics', + common: common + }; + var $select = UIElements.createDropdown(dropdownConfig); + UI.prompt(Messages.exportPrompt, + Util.fixFileName(suggestion), function (filename) + { + if (!(typeof(filename) === 'string' && filename)) { return; } + var ext = $select.getValue(); + filename = filename + ext; + var blob = Export.main(cal.content); + SaveAs(blob, filename); + }, { + typeInput: $select[0] + }); + return true; + } + }); + + + + options.push({ + tag: 'a', + attributes: { + 'class': 'fa fa-info-circle', + }, + content: h('span', Messages.propertiesButton), + action: function (e) { + e.stopPropagation(); + var cal = APP.calendars[id]; + var title = Util.find(cal, ['content', 'metadata', 'title']); + var color = Util.find(cal, ['content', 'metadata', 'color']); + var h = cal.hashes || {}; + var href = Hash.hashToHref(h.editHash || h.viewHash, 'calendar'); + Properties.getPropertiesModal(common, { + calendar: { + title: title, + color: color, + channel: id, + }, + common: common, + channel: id, + href: href + }); + return true; + } + }); + } + if (!cantRemove) { + options.push({ + tag: 'a', + attributes: { + 'class': 'fa fa-trash-o', + }, + content: h('span', Messages.kanban_delete), + action: function (e) { + e.stopPropagation(); + var cal = APP.calendars[id]; + var teams = (cal && cal.teams) || []; + var text = [ Messages.calendar_deleteConfirm ]; + if (teams.length === 1 && teams[0] !== 1) { + text[0] = Messages.calendar_deleteTeamConfirm; + } + if (cal.owned) { + text = text.concat([' ', Messages.calendar_deleteOwned]); + } + UI.confirm(h('span', text), function (yes) { + if (!yes) { return; } + deleteCalendar({ + id: id, + teamId: teamId, + }, function (err) { + if (err) { + console.error(err); + UI.warn(Messages.error); + } + }); + }); + } + }); + } + var dropdownConfig = { + text: '', + options: options, // Entries displayed in the menu + common: common, + buttonCls: 'btn btn-cancel fa fa-ellipsis-h small' + }; + return UIElements.createDropdown(dropdownConfig)[0]; + }; + var makeCalendarEntry = function (id, teamId) { + var data = APP.calendars[id]; + var edit; + if (data.loading) { + edit = h('i.fa.fa-spinner.fa-spin'); + } else { + edit = makeEditDropdown(id, teamId); + } + var md = Util.find(data, ['content', 'metadata']); + if (!md) { return; } + var active = data.hidden ? '' : '.cp-active'; + var restricted = data.restricted ? '.cp-restricted' : ''; + var temp = teamId === 0 ? '.cp-unclickable' : ''; + var calendar = h('div.cp-calendar-entry'+active+restricted+temp, { + 'data-uid': id + }, [ + h('span.cp-calendar-icon', { + style: 'background-color: '+md.color+';' + }, [ + h('i.cp-calendar-active.fa.fa-calendar', { + style: 'color: '+getContrast(md.color)+';' + }), + h('i.cp-calendar-inactive.fa.fa-calendar-o') + ]), + h('span.cp-calendar-title', md.title), + data.restricted ? h('i.fa.fa-ban', {title: Messages.fm_restricted}) : + (isReadOnly(id, teamId) ? h('i.fa.fa-eye', {title: Messages.readonly}) : undefined), + edit + ]); + var $calendar = $(calendar).click(function () { + if (teamId === 0) { return; } + data.hidden = !data.hidden; + if (APP.$calendars) { + APP.$calendars.find('[data-uid="'+id+'"]').toggleClass('cp-active', !data.hidden); + } else { + $(calendar).toggleClass('cp-active', !data.hidden); + } + + renderCalendar(); + }); + if (!data.loading) { + $calendar.contextmenu(function (ev) { + ev.preventDefault(); + $(edit).click(); + }); + } + if (APP.$calendars) { APP.$calendars.append(calendar); } + return calendar; + }; + var makeLeftside = function (calendar, $container) { + // Show calendars + var calendars = h('div.cp-calendar-list'); + var $calendars = APP.$calendars = $(calendars).appendTo($container); + onCalendarsUpdate.reg(function () { + $calendars.empty(); + var privateData = metadataMgr.getPrivateData(); + var filter = function (teamId) { + return Object.keys(APP.calendars || {}).filter(function (id) { + var cal = APP.calendars[id] || {}; + var teams = (cal.teams || []).map(function (tId) { return Number(tId); }); + return teams.indexOf(typeof(teamId) !== "undefined" ? Number(teamId) : 1) !== -1; + }); + }; + var tempCalendars = filter(0); + if (tempCalendars.length && tempCalendars[0] === APP.currentCalendar) { + APP.$calendars.append(h('div.cp-calendar-team', [ + h('span', Messages.calendar_tempCalendar) + ])); + makeCalendarEntry(tempCalendars[0], 0); + var importTemp = h('button', [ + h('i.fa.fa-calendar-plus-o'), + h('span', Messages.calendar_import_temp), + h('span') + ]); + $(importTemp).click(function () { + importCalendar({ + id: tempCalendars[0], + teamId: 0 + }, function (err) { + if (err) { + console.error(err); + return void UI.warn(Messages.error); + } + }); + }); + if (APP.loggedIn) { + APP.$calendars.append(h('div.cp-calendar-entry.cp-ghost', importTemp)); + } + return; + } + var myCalendars = filter(1); + if (myCalendars.length) { + var user = metadataMgr.getUserData(); + var avatar = h('span.cp-avatar'); + var name = user.name || Messages.anonymous; + common.displayAvatar($(avatar), user.avatar, name); + APP.$calendars.append(h('div.cp-calendar-team', [ + avatar, + h('span.cp-name', {title: name}, name) + ])); + } + myCalendars.forEach(function (id) { + makeCalendarEntry(id, 1); + }); + + // Add new button + var $newContainer = $(h('div.cp-calendar-entry.cp-ghost')).appendTo($calendars); + var newButton = h('button', [ + h('i.fa.fa-calendar-plus-o'), + h('span', Messages.calendar_new), + h('span') + ]); + $(newButton).click(function () { + editCalendar(); + }).appendTo($newContainer); + + Object.keys(privateData.teams).forEach(function (teamId) { + var calendars = filter(teamId); + if (!calendars.length) { return; } + var team = privateData.teams[teamId]; + var avatar = h('span.cp-avatar'); + common.displayAvatar($(avatar), team.avatar, team.displayName); + APP.$calendars.append(h('div.cp-calendar-team', [ + avatar, + h('span.cp-name', {title: team.name}, team.name) + ])); + calendars.forEach(function (id) { + makeCalendarEntry(id, teamId); + }); + }); + }); + onCalendarsUpdate.fire(); + + }; + + var ISO8601_week_no = function (dt) { + var tdt = new Date(dt.valueOf()); + var dayn = (dt.getDay() + 6) % 7; + tdt.setDate(tdt.getDate() - dayn + 3); + var firstThursday = tdt.valueOf(); + tdt.setMonth(0, 1); + if (tdt.getDay() !== 4) { + tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7); + } + return 1 + Math.ceil((firstThursday - tdt) / 604800000); + }; + + var updateDateRange = function () { + var range = APP.calendar._renderRange; + var start = range.start._date.toLocaleDateString(); + var end = range.end._date.toLocaleDateString(); + var week = ISO8601_week_no(range.start._date); + var date = [ + h('b.cp-small', Messages._getKey('calendar_weekNumber', [week])), + h('b', start), + h('span', ' - '), + h('b', end), + ]; + if (APP.calendar._viewName === "day") { + date = h('b', start); + } else if (APP.calendar._viewName === "month") { + var month; + var mid = new Date(Math.floor(((+range.start._date) + (+range.end._date)) / 2)); + try { + month = mid.toLocaleString('default', { + month: 'long', + year:'numeric' + }); + month = month.replace(/^./, function (str) { return str.toUpperCase(); }); + date = h('b', month); + } catch (e) { + // Use same as week range: first day of month to last day of month + } + } + APP.toolbar.$bottomM.empty().append(h('div', date)); + }; + var makeCalendar = function (view) { + var store = window.cryptpadStore; + + var $container = $('#cp-sidebarlayout-container'); + var leftside; + $container.append([ + leftside = h('div#cp-sidebarlayout-leftside'), + h('div#cp-sidebarlayout-rightside') + ]); + + var large = $(window).width() >= 800; + var cal = APP.calendar = new Calendar('#cp-sidebarlayout-rightside', { + defaultView: view || 'week', // weekly view option + taskView: false, + useCreationPopup: true, + useDetailPopup: true, + usageStatistics: false, + calendars: getCalendars(), + template: templates, + month: { + daynames: getWeekDays(large), + startDayOfWeek: 1, + }, + week: { + daynames: getWeekDays(large), + startDayOfWeek: 1, + } + }); + + $(window).on('resize', function () { + var _large = $(window).width() >= 800; + if (large !== _large) { + large = _large; + cal.setOptions({ + month: { + daynames: getWeekDays(_large), + startDayOfWeek: 1, + }, + week: { + daynames: getWeekDays(_large), + startDayOfWeek: 1, + } + }); + } + }); + + makeLeftside(cal, $(leftside)); + + cal.on('beforeCreateSchedule', function(event) { + // TODO Recurrence (later) + // On creation, select a recurrence rule (daily / weekly / monthly / more weird rules) + // then mark it under recurrence rule with a uid (the same for all the recurring events) + // ie: recurrenceRule: DAILY|{uid} + // Use template to hide "recurrenceRule" from the detailPopup or at least to use + // a non technical value + var reminders = APP.notificationsEntries; + + var startDate = event.start._date; + var endDate = event.end._date; + + var schedule = { + id: Util.uid(), + calendarId: event.calendarId, + title: Util.fixHTML(event.title), + category: "time", + location: Util.fixHTML(event.location), + start: +startDate, + isAllDay: event.isAllDay, + end: +endDate, + reminders: reminders, + }; + + newEvent(schedule, function (err) { + if (err) { + console.error(err); + return void UI.warn(err); + } + cal.createSchedules([schedule]); + }); + }); + cal.on('beforeUpdateSchedule', function(event) { + var changes = event.changes || {}; + delete changes.state; + if (changes.end) { changes.end = +new Date(changes.end._date); } + if (changes.start) { changes.start = +new Date(changes.start._date); } + var old = event.schedule; + + var oldReminders = Util.find(APP.calendars, [old.calendarId, 'content', 'content', old.id, 'reminders']); + var reminders = APP.notificationsEntries; + if (JSONSortify(oldReminders || []) !== JSONSortify(reminders)) { + changes.reminders = reminders; + } + + updateEvent({ + ev: old, + changes: changes + }, function (err) { + if (err) { + console.error(err); + return void UI.warn(err); + } + cal.updateSchedule(old.id, old.calendarId, changes); + }); + }); + cal.on('beforeDeleteSchedule', function(event) { + var data = event.schedule; + deleteEvent(event.schedule, function (err) { + if (err) { + console.error(err); + return void UI.warn(err); + } + cal.deleteSchedule(data.id, data.calendarId); + }); + }); + + $('body').on('keydown', function (e) { + if (e.which === 27) { + $('.tui-full-calendar-floating-layer').hide(); + } + }); + + updateDateRange(); + + renderCalendar(); + + // Toolbar + + // Change view mode + var options = ['day', 'week', 'month'].map(function (k) { + return { + tag: 'a', + attributes: { + 'class': 'cp-calendar-view', + 'data-value': k, + 'href': '#', + }, + content: Messages['calendar_'+k] + // Messages.calendar_day + // Messages.calendar_week + // Messages.calendar_month + }; + }); + var dropdownConfig = { + text: Messages.calendar_week, + options: options, // Entries displayed in the menu + isSelect: true, + common: common, + caretDown: true, + left: true, + }; + var $block = UIElements.createDropdown(dropdownConfig); + $block.setValue(view || 'week'); + var $views = $block.find('a'); + $views.click(function () { + var mode = $(this).attr('data-value'); + cal.changeView(mode); + updateDateRange(); + store.put('calendarView', mode, function () {}); + }); + APP.toolbar.$bottomR.append($block); + + // New event button + var newEventBtn = h('button.cp-calendar-newevent', [ + h('i.fa.fa-plus'), + h('span', Messages.calendar_newEvent) + ]); + $(newEventBtn).click(function (e) { + e.preventDefault(); + cal.openCreationPopup({isAllDay:false}); + }).appendTo(APP.toolbar.$bottomL); + + // Change page + var goLeft = h('button.fa.fa-chevron-left'); + var goRight = h('button.fa.fa-chevron-right'); + var goToday = h('button', Messages.calendar_today); + $(goLeft).click(function () { + cal.prev(); + updateDateRange(); + }); + $(goRight).click(function () { + cal.next(); + updateDateRange(); + }); + $(goToday).click(function () { + cal.today(); + updateDateRange(); + }); + APP.toolbar.$bottomL.append(h('div.cp-calendar-browse', [ + goLeft, goToday, goRight + ])); + + }; + + var parseNotif = function (minutes) { + var res = { + unit: 'minutes', + value: minutes + }; + var hours = minutes / 60; + if (!Number.isInteger(hours)) { return res; } + res.unit = 'hours'; + res.value = hours; + var days = hours / 24; + if (!Number.isInteger(days)) { return res; } + res.unit = 'days'; + res.value = days; + return res; + }; + var getNotificationDropdown = function () { + var ev = APP.editModalData; + var calId = ev.selectedCal.id; + // DEFAULT HERE [10] ==> 10 minutes before the event + var oldReminders = Util.find(APP.calendars, [calId, 'content', 'content', ev.id, 'reminders']) || [10]; + APP.notificationsEntries = []; + var number = h('input.tui-full-calendar-content', { + type: "number", + value: 10, + min: 1, + max: 60 + }); + var $number = $(number); + var options = ['minutes', 'hours', 'days'].map(function (k) { + return { + tag: 'a', + attributes: { + 'class': 'cp-calendar-reminder', + 'data-value': k, + 'href': '#', + }, + content: Messages['calendar_'+k] + // Messages.calendar_minutes + // Messages.calendar_hours + // Messages.calendar_days + }; + }); + var dropdownConfig = { + text: Messages.calendar_minutes, + options: options, // Entries displayed in the menu + isSelect: true, + common: common, + buttonCls: 'btn btn-secondary', + caretDown: true, + }; + + var $block = UIElements.createDropdown(dropdownConfig); + $block.setValue('minutes'); + var $types = $block.find('a'); + $types.click(function () { + var mode = $(this).attr('data-value'); + var max = mode === "minutes" ? 60 : 24; + $number.attr('max', max); + if ($number.val() > max) { $number.val(max); } + }); + var addNotif = h('button.btn.btn-primary-outline.fa.fa-plus'); + var $list = $(h('div.cp-calendar-notif-list')); + var listContainer = h('div.cp-calendar-notif-list-container', [ + h('span.cp-notif-label', Messages.calendar_notifications), + $list[0], + h('span.cp-notif-empty', Messages.calendar_noNotification) + ]); + var addNotification = function (unit, value) { + var unitValue = (unit === "minutes") ? 1 : (unit === "hours" ? 60 : (60*24)); + var del = h('button.btn.btn-danger-outline.small.fa.fa-times'); + var minutes = value * unitValue; + if ($list.find('[data-minutes="'+minutes+'"]').length) { return; } + var span = h('span.cp-notif-entry', { + 'data-minutes': minutes + }, [ + h('span.cp-notif-value', [ + h('span', value), + h('span', Messages['calendar_'+unit]), + h('span.cp-before', Messages.calendar_before) + ]), + del + ]); + $(del).click(function () { + $(span).remove(); + var idx = APP.notificationsEntries.indexOf(minutes); + APP.notificationsEntries.splice(idx, 1); + }); + $list.append(span); + APP.notificationsEntries.push(minutes); + }; + $(addNotif).click(function () { + var unit = $block.getValue(); + var value = $number.val(); + addNotification(unit, value); + }); + oldReminders.forEach(function (minutes) { + var p = parseNotif(minutes); + addNotification(p.unit, p.value); + }); + return h('div.tui-full-calendar-popup-section.cp-calendar-add-notif', [ + listContainer, + h('div.cp-calendar-notif-form', [ + h('span.cp-notif-label', Messages.calendar_addNotification), + number, + $block[0], + addNotif + ]) + ]); + }; + + var createToolbar = function () { + var displayed = ['useradmin', 'newpad', 'limit', 'pageTitle', 'notifications']; + var configTb = { + displayed: displayed, + sfCommon: common, + $container: APP.$toolbar, + pageTitle: Messages.calendar, + metadataMgr: common.getMetadataMgr(), + }; + APP.toolbar = Toolbar.create(configTb); + APP.toolbar.$rightside.hide(); + }; + + var onEvent = function (obj) { + var ev = obj.ev; + var data = obj.data; + if (ev === 'UPDATE') { + onCalendarUpdate(data); + return; + } + }; + + nThen(function (waitFor) { + $(waitFor(UI.addLoadingScreen)); + SFCommon.create(waitFor(function (c) { APP.common = common = c; })); + }).nThen(function (waitFor) { + APP.$toolbar = $('#cp-toolbar'); + sframeChan = common.getSframeChannel(); + sframeChan.onReady(waitFor()); + }).nThen(function (/*waitFor*/) { + createToolbar(); + metadataMgr = common.getMetadataMgr(); + var privateData = metadataMgr.getPrivateData(); + var user = metadataMgr.getUserData(); + + APP.loggedIn = common.isLoggedIn(); + + common.setTabTitle(Messages.calendar); + + // Fix flatpickr selection + var MutationObserver = window.MutationObserver; + var onFlatPickr = function (el) { + // Don't close event creation popup when clicking on flatpickr + $(el).mousedown(function (e) { + e.stopPropagation(); + }); + }; + var observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + var node; + for (var i = 0; i < mutation.addedNodes.length; i++) { + node = mutation.addedNodes[i]; + if (node.classList && node.classList.contains('flatpickr-calendar')) { + onFlatPickr(node); + } + } + }); + }); + observer.observe($('body')[0], { + childList: true, + subtree: false + }); + + // Customize creation/update popup + var onCalendarPopup = function (el) { + var $el = $(el); + $el.find('.tui-full-calendar-confirm').addClass('btn btn-primary').prepend(h('i.fa.fa-floppy-o')); + $el.find('input').attr('autocomplete', 'off'); + $el.find('.tui-full-calendar-dropdown-button').addClass('btn btn-secondary'); + $el.find('.tui-full-calendar-popup-close').addClass('btn btn-cancel fa fa-times cp-calendar-close').empty(); + + var calendars = APP.calendars || {}; + var show = false; + $el.find('.tui-full-calendar-dropdown-menu li').each(function (i, li) { + var $li = $(li); + var id = $li.attr('data-calendar-id'); + var c = calendars[id]; + if (!c || c.readOnly) { + return void $li.remove(); + } + // If at least one calendar is editable, show the popup + show = true; + }); + if ($el.find('.tui-full-calendar-hide.tui-full-calendar-dropdown').length || !show) { + $el.hide(); + UI.warn(Messages.calendar_errorNoCalendar); + return; + } + var isUpdate = Boolean($el.find('#tui-full-calendar-schedule-title').val()); + if (!isUpdate) { $el.find('.tui-full-calendar-dropdown-menu li').first().click(); } + + var $button = $el.find('.tui-full-calendar-section-button-save'); + var div = getNotificationDropdown(); + $button.before(div); + + var $cbox = $el.find('#tui-full-calendar-schedule-allday'); + var $start = $el.find('.tui-full-calendar-section-start-date'); + var $dash = $el.find('.tui-full-calendar-section-date-dash'); + var $end = $el.find('.tui-full-calendar-section-end-date'); + var allDay = $cbox.is(':checked'); + if (allDay) { + $start.hide(); + $dash.hide(); + $end.hide(); + } + $el.find('.tui-full-calendar-section-allday').click(function () { + setTimeout(function () { + var allDay = $cbox.is(':checked'); + if (allDay) { + $start.hide(); + $dash.hide(); + $end.hide(); + return; + } + $start.show(); + $dash.show(); + $end.show(); + }); + }); + }; + var onCalendarEditPopup = function (el) { + var $el = $(el); + $el.find('.tui-full-calendar-popup-edit').addClass('btn btn-primary'); + $el.find('.tui-full-calendar-popup-edit .tui-full-calendar-icon').addClass('fa fa-pencil').removeClass('tui-full-calendar-icon'); + $el.find('.tui-full-calendar-popup-delete').addClass('btn btn-danger'); + $el.find('.tui-full-calendar-popup-delete .tui-full-calendar-icon').addClass('fa fa-trash').removeClass('tui-full-calendar-icon'); + $el.find('.tui-full-calendar-content').removeClass('tui-full-calendar-content'); + }; + var onPopupRemoved = function () { + var start, end; + if (window.CP_startPickr) { start = window.CP_startPickr.calendarContainer; } + if (window.CP_endPickr) { end = window.CP_endPickr.calendarContainer; } + $('.flatpickr-calendar').each(function (i, el) { + if (el === start || el === end) { return; } + $(el).remove(); + }); + }; + var observer2 = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + var node, _node; + for (var i = 0; i < mutation.addedNodes.length; i++) { + node = mutation.addedNodes[i]; + try { + if (node.classList && node.classList.contains('tui-full-calendar-popup') + && !node.classList.contains('tui-full-calendar-popup-detail')) { + onCalendarPopup(node); + } + if (node.classList && node.classList.contains('tui-full-calendar-popup') + && node.classList.contains('tui-full-calendar-popup-detail')) { + onCalendarEditPopup(node); + } + } catch (e) {} + } + for (var j = 0; j < mutation.removedNodes.length; j++) { + _node = mutation.addedNodes[j]; + try { + if (_node.classList && _node.classList.contains('tui-full-calendar-popup')) { + onPopupRemoved(); + } + } catch (e) {} + } + }); + }); + observer2.observe($('body')[0], { + childList: true, + subtree: true + }); + + APP.module = common.makeUniversal('calendar', { + onEvent: onEvent + }); + var store = window.cryptpadStore; + APP.module.execCommand('SUBSCRIBE', null, function (obj) { + if (obj.empty && !privateData.calendarHash) { + if (!privateData.loggedIn) { + return void UI.errorLoadingScreen(Messages.mustLogin, false, function () { + common.setLoginRedirect('login'); + }); + } + // No calendar yet, create one + newCalendar({ + teamId: 1, + initialCalendar: true, + color: user.color, + title: Messages.calendar_default + }, function (err) { + if (err) { return void UI.errorLoadingScreen(Messages.error); } + store.get('calendarView', makeCalendar); + UI.removeLoadingScreen(); + }); + return; + } + if (privateData.calendarHash) { + var hash = privateData.hashes.editHash || privateData.hashes.viewHash; + var secret = Hash.getSecrets('calendar', hash, privateData.password); + APP.currentCalendar = secret.channel; + APP.module.execCommand('OPEN', { + hash: hash, + password: privateData.password + }, function (obj) { + if (obj && obj.error) { console.error(obj.error); } + }); + } + store.get('calendarView', makeCalendar); + UI.removeLoadingScreen(); + }); + + APP.origin = privateData.origin; + + + }); +}); diff --git a/www/calendar/main.js b/www/calendar/main.js new file mode 100644 index 000000000..11b1ba4bf --- /dev/null +++ b/www/calendar/main.js @@ -0,0 +1,24 @@ +// Load #1, load as little as possible because we are in a race to get the loading screen up. +define([ + '/bower_components/nthen/index.js', + '/api/config', + '/common/dom-ready.js', + '/common/sframe-common-outer.js', +], function (nThen, ApiConfig, DomReady, SFCommonO) { + + // Loaded in load #2 + nThen(function (waitFor) { + DomReady.onReady(waitFor()); + }).nThen(function (waitFor) { + SFCommonO.initIframe(waitFor); + }).nThen(function (/*waitFor*/) { + var addData = function (meta) { + meta.calendarHash = Boolean(window.location.hash); + }; + SFCommonO.start({ + addData: addData, + noRealtime: true, + cache: true, + }); + }); +}); diff --git a/customize.dist/src/less2/pages/page-checkup.less b/www/checkup/app-checkup.less similarity index 53% rename from customize.dist/src/less2/pages/page-checkup.less rename to www/checkup/app-checkup.less index 2a05600c7..40e6a1add 100644 --- a/customize.dist/src/less2/pages/page-checkup.less +++ b/www/checkup/app-checkup.less @@ -1,7 +1,6 @@ -@import (reference) "../include/colortheme-all.less"; -@import (reference) "../include/font.less"; -//@import (reference) "../include/forms.less"; -@import (reference) "../include/alertify.less"; +@import (reference) "../../customize/src/less2/include/colortheme-all.less"; +@import (reference) "../../customize/src/less2/include/font.less"; +@import (reference) "../../customize/src/less2/include/alertify.less"; html, body { .font_main(); @@ -52,12 +51,29 @@ html, body { .advisory-text { display: inline-block; - word-break: break-all; + word-break: break-word; padding: 5px; //font-size: 16px; - border: 1px solid red; - background-color: @cp_alerts-danger-bg; - color: @cp_alerts-danger-text; + &.cp-danger { + border: 1px solid @cp_alerts-danger-bg; + background-color: @cp_alerts-danger-bg; + color: @cp_alerts-danger-text; + } + &.cp-warning { + border: 1px solid @cp_alerts-warning-bg; + background-color: @cp_alerts-warning-bg; + color: @cp_alerts-warning-text; + } + code { + word-break: keep-all; + font-style: italic; + } + a { + color: @cryptpad_color_link; + } + } + .cp-app-checkup-version { + text-decoration: underline; } iframe { diff --git a/www/checkup/main.js b/www/checkup/main.js index 5dcd1e8cf..87e310e32 100644 --- a/www/checkup/main.js +++ b/www/checkup/main.js @@ -12,45 +12,108 @@ define([ '/common/common-util.js', '/common/pinpad.js', '/common/outer/network-config.js', + '/customize/pages.js', '/bower_components/tweetnacl/nacl-fast.min.js', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', - 'less!/customize/src/less2/pages/page-checkup.less', + 'less!/checkup/app-checkup.less', ], function ($, ApiConfig, Assertions, h, Messages, DomReady, nThen, SFCommonO, Login, Hash, Util, Pinpad, - NetConfig) { - var assert = Assertions(); - + NetConfig, Pages) { + var Assert = Assertions(); var trimSlashes = function (s) { if (typeof(s) !== 'string') { return s; } return s.replace(/\/+$/, ''); }; - var _alert = function (content) { - return h('span.advisory-text', content); + var assert = function (f, msg) { + Assert(f, msg || h('span.advisory-text.cp-danger')); + }; + + var CONFIG_PATH = function () { + return h('code', 'cryptpad/config/config.js'); + }; + var API_CONFIG_LINK = function () { + return h('a', { + href: '/api/config', + target: '_blank', + }, '/api/config'); + }; + + var RESTART_WARNING = function () { + return h('span', [ + 'Changes to ', + CONFIG_PATH(), + ' will require a server restart in order for ', + API_CONFIG_LINK(), + ' to be updated.', + ]); }; var trimmedSafe = trimSlashes(ApiConfig.httpSafeOrigin); var trimmedUnsafe = trimSlashes(ApiConfig.httpUnsafeOrigin); - assert(function (cb) { + assert(function (cb, msg) { + msg.appendChild(h('span', [ + "CryptPad's sandbox requires that both ", + h('code', 'httpUnsafeOrigin'), + ' and ', + h('code', 'httpSafeOrigin'), + " be configured in ", + CONFIG_PATH(), + '. ', + RESTART_WARNING(), + ])); + //console.error(trimmedSafe, trimmedUnsafe); cb(Boolean(trimmedSafe && trimmedUnsafe)); - }, _alert("Sandbox configuration: ensure that both httpUnsafeOrigin and httpSafeOrigin are defined")); + }); + + assert(function (cb, msg) { + msg.appendChild(h('span', [ + h('code', 'httpUnsafeOrigin'), + ' and ', + h('code', 'httpSafeOrigin'), + ' are equivalent. ', + "In order for CryptPad's security features to be as effective as intended they must be different. ", + "See ", + CONFIG_PATH(), + '. ', + RESTART_WARNING(), + ])); - assert(function (cb) { return void cb(trimmedSafe !== trimmedUnsafe); - }, _alert('Sandbox configuration: httpUnsafeOrigin !== httpSafeOrigin')); + }); - assert(function (cb) { - cb(trimmedSafe === ApiConfig.httpSafeOrigin); - }, "httpSafeOrigin must not have a trailing slash"); + assert(function (cb, msg) { + msg.appendChild(h('span', [ + h('code', 'httpUnsafeOrigin'), + ' and ', + h('code', 'httpSafeOrigin'), + ' must not contain trailing slashes. This can be configured in ', + CONFIG_PATH(), + '. ', + RESTART_WARNING(), + ])); + cb(trimmedSafe === ApiConfig.httpSafeOrigin && trimmedUnsafe === ApiConfig.httpUnsafeOrigin); + }); - assert(function (cb) { + assert(function (cb, msg) { + msg.appendChild(h("span", [ + "It appears that you are trying to load this page via an origin other than its main domain (", + h('code', ApiConfig.httpUnsafeOrigin), + + "). See the ", + h('code', 'httpUnsafeOrigin'), + " option in ", + CONFIG_PATH(), + " which is exposed via ", + API_CONFIG_LINK(), + '.', + ])); var origin = window.location.origin; return void cb(ApiConfig.httpUnsafeOrigin === origin); - }, _alert('Sandbox configuration: loading via httpUnsafeOrigin')); - + }); var checkAvailability = function (url, cb) { $.ajax({ @@ -62,12 +125,38 @@ define([ }); }; - assert(function (cb) { + assert(function (cb, msg) { + msg.appendChild(h('span', [ + "The main domain (configured via ", + h('code', 'httpUnsafeOrigin'), + ' as ', + ApiConfig.httpUnsafeOrigin, + ' in ', + CONFIG_PATH(), + ' and exposed via ', + API_CONFIG_LINK(), + ') could not be reached.', + ])); + checkAvailability(trimmedUnsafe, cb); - }, _alert("Main domain is not available")); + }); // Try loading an iframe on the safe domain - assert(function (cb) { + assert(function (cb, msg) { + msg.appendChild(h('span', [ + "Your browser was not able to load an iframe using the origin specified as ", + h('code', "httpSafeOrigin"), + " (", + ApiConfig.httpSafeOrigin, + ") in ", + CONFIG_PATH(), + ". This can be caused by an invalid ", + h('code', 'httpUnsafeDomain'), + ', invalid CSP configuration in your reverse proxy, invalid SSL certificates, and many other factors. ', + 'More information about your particular error may be found in your browser console. ', + RESTART_WARNING(), + ])); + var to; nThen(function (waitFor) { DomReady.onReady(waitFor()); @@ -82,16 +171,24 @@ define([ clearTimeout(to); cb(true); }); - }, _alert("Sandbox domain is not available")); + }); // Test Websocket var evWSError = Util.mkEvent(true); - assert(function (cb) { + assert(function (_cb, msg) { + var timeoutErr = 'Could not connect to the websocket server within 5 seconds.'; + var cb = Util.once(Util.both(_cb, function (status) { + if (status === true) { return; } + msg.appendChild(h('span#websocket', [ + status || 'Unknown websocket error', + ])); + })); + var ws = new WebSocket(NetConfig.getWebsocketURL()); var to = setTimeout(function () { console.error('Websocket TIMEOUT'); evWSError.fire(); - cb('TIMEOUT (5 seconds)'); + cb(timeoutErr); }, 5000); ws.onopen = function () { clearTimeout(to); @@ -99,14 +196,40 @@ define([ }; ws.onerror = function (err) { clearTimeout(to); - console.error('Websocket error', err); + console.error('[Websocket error]', err); evWSError.fire(); - cb('WebSocket error: check your console'); + cb('Unable to connect to the websocket server. More information may be available in your browser console ([Websocket error]).'); }; - }, _alert("Websocket is not available")); + }); // Test login block - assert(function (cb) { + assert(function (_cb, msg) { + var websocketErr = "No WebSocket available"; + var cb = Util.once(Util.both(_cb, function (status) { + if (status === true) { return; } + if (status === websocketErr) { + msg.appendChild(h('span', [ + websocketErr, + ' See ', + h('a', { + href: '#websocket', + }, 'the related websocket error'), + ])); + return; + } + // else + msg.appendChild(h('span', [ + "Unable to create, retrieve, or remove encrypted credentials from the server. ", + "This is most commonly caused by a mismatch between the value of the ", + h('code', 'blockPath'), + ' value configured in ', + CONFIG_PATH(), + " and the corresponding settings in your reverse proxy's configuration file,", + " but it can also be explained by a websocket error. ", + RESTART_WARNING(), + ])); + })); + var bytes = new Uint8Array(Login.requiredBytes); var opt = Login.allocateBytes(bytes); @@ -121,7 +244,7 @@ define([ opt.keys = secret.keys; opt.channelHex = secret.channel; - var RT, rpc, exists; + var RT, rpc, exists, restricted; nThen(function (waitFor) { Util.fetch(blockUrl, waitFor(function (err) { @@ -132,7 +255,7 @@ define([ // If WebSockets aren't working, don't wait forever here evWSError.reg(function () { waitFor.abort(); - cb("No WebSocket (test number 6)"); + cb(websocketErr); }); // Create proxy Login.loadUserObject(opt, waitFor(function (err, rt) { @@ -163,6 +286,12 @@ define([ // Write block if (exists) { return; } rpc.writeLoginBlock(blockRequest, waitFor(function (e) { + // we should tolerate restricted registration + // and proceed to clean up after any data we've created + if (e === 'E_RESTRICTED') { + restricted = true; + return void cb(true); + } if (e) { waitFor.abort(); console.error("Can't write login block", e); @@ -170,6 +299,7 @@ define([ } })); }).nThen(function (waitFor) { + if (restricted) { return; } // Read block Util.fetch(blockUrl, waitFor(function (e) { if (e) { @@ -181,6 +311,7 @@ define([ }).nThen(function (waitFor) { // Remove block rpc.removeLoginBlock(removeRequest, waitFor(function (e) { + if (restricted) { return; } // an ENOENT is expected in the case of restricted registration, but we call this anyway to clean up any mess from previous tests. if (e) { waitFor.abort(); console.error("Can't remove login block", e); @@ -200,7 +331,207 @@ define([ cb(true); }); - }, _alert("Login block is not working (write/read/remove)")); + }); + + var sheetURL = '/common/onlyoffice/v4/web-apps/apps/spreadsheeteditor/main/index.html'; + + assert(function (cb, msg) { + msg.innerText = "Missing HTTP headers required for .xlsx export from sheets. "; + var url = sheetURL; + var expect = { + 'cross-origin-resource-policy': 'cross-origin', + 'cross-origin-embedder-policy': 'require-corp', + //'cross-origin-opener-policy': 'same-origin', // FIXME this is in our nginx config but not server.js + }; + + $.ajax(url, { + complete: function (xhr) { + cb(!Object.keys(expect).some(function (k) { + var response = xhr.getResponseHeader(k); + if (response !== expect[k]) { + msg.appendChild(h('span', [ + 'A value of ', + h('code', expect[k]), + ' was expected for the ', + h('code', k), + ' HTTP header, but instead a value of "', + h('code', response), + '" was received.', + ])); + return true; // returning true indicates that a value is incorrect + } + })); + }, + }); + }); + + assert(function (cb, msg) { + msg.innerText = "Missing HTTP header required to disable Google's Floc."; + $.ajax('/?'+ (+new Date()), { + complete: function (xhr) { + cb(xhr.getResponseHeader('permissions-policy') === 'interest-cohort=()'); + }, + }); + }); + + assert(function (cb, msg) { + msg = msg; + return void cb(true); + /* + msg.appendChild(h('span', [ + "The spreadsheet editor's code was not served with the required Content-Security Policy headers. ", + "This is most often caused by incorrectly configured sandbox parameters (", + h('code', 'httpUnsafeOrigin'), + ' and ', + h('code', 'httpSafeOrigin'), + ' in ', + CONFIG_PATH, + "), or settings in your reverse proxy's configuration which don't match your application server's config. ", + RESTART_WARNING(), + ])); + + $.ajax(sheetURL, { + complete: function (xhr) { + var csp = xhr.getResponseHeader('Content-Security-Policy'); + if (!/unsafe\-eval/.test(csp)) { + // OnlyOffice requires unsafe-eval + console.error('CSP', csp); + return cb("expected 'unsafe-eval'"); + } + if (!/unsafe\-inline/.test(csp)) { + // OnlyOffice also requires unsafe-inline + console.error('CSP', csp); + return cb("expected 'unsafe-inline'"); + } + cb(true); + }, + }); */ + }); + + assert(function (cb, msg) { + msg.appendChild(h('span', [ + h('code', '/api/broadcast'), + " could not be loaded. This can be caused by an outdated application server or an incorrectly configured reverse proxy. ", + "Even if the most recent code has been downloaded it's possible the application server has not been restarted. ", + "Your browser console may provide more details as to why this resource could not be loaded. ", + ])); + + $.ajax('/api/broadcast', { + dataType: 'text', + complete: function (xhr) { + console.log(xhr); + cb(xhr.status === 200); + }, + }); + }); + + var checkAPIHeaders = function (url, cb) { + $.ajax(url, { + dataType: 'text', + complete: function (xhr) { + var allHeaders = xhr.getAllResponseHeaders(); + var headers = {}; + var duplicated = allHeaders.split('\n').some(function (header) { + var duplicate; + header.replace(/([^:]+):(.*)/, function (all, type, value) { + type = type.trim(); + if (typeof(headers[type]) !== 'undefined') { + duplicate = true; + } + headers[type] = value.trim(); + }); + return duplicate; + }); + + var expect = { + 'cross-origin-resource-policy': 'cross-origin', + }; + var incorrect = Object.keys(expect).some(function (k) { + var response = xhr.getResponseHeader(k); + if (response !== expect[k]) { + return true; + } + }); + + if (duplicated || incorrect) { console.error(allHeaders); } + cb(!duplicated && !incorrect); + }, + }); + }; + + var INCORRECT_HEADER_TEXT = ' was served with duplicated or incorrect headers. Compare your reverse-proxy configuration against the provided example.'; + + assert(function (cb, msg) { + var url = '/api/config'; + msg.innerText = url + INCORRECT_HEADER_TEXT; + checkAPIHeaders(url, cb); + }); + + assert(function (cb, msg) { + var url = '/api/broadcast'; + msg.innerText = url + INCORRECT_HEADER_TEXT; + checkAPIHeaders(url, cb); + }); + + var setWarningClass = function (msg) { + $(msg).removeClass('cp-danger').addClass('cp-warning'); + }; + + assert(function (cb, msg) { + var email = ApiConfig.adminEmail; + if (typeof(email) === 'string' && email && email !== 'i.did.not.read.my.config@cryptpad.fr') { + return void cb(true); + } + + setWarningClass(msg); + msg.appendChild(h('span', [ + 'This instance does not provide a valid ', + h('code', 'adminEmail'), + ' which can make it difficult to contact its adminstrator to report vulnerabilities or abusive content.', + ' This can be configured in ', CONFIG_PATH(), '. ', + RESTART_WARNING(), + ])); + cb(email); + }); + + assert(function (cb, msg) { + var support = ApiConfig.supportMailbox; + setWarningClass(msg); + msg.appendChild(h('span', [ + "This instance's encrypted support ticket functionality has not been enabled. This can make it difficult for its users to safely report issues that concern sensitive information. ", + "This can be configured via the ", + h('code', 'supportMailbox'), + " attribute in ", + CONFIG_PATH(), + ". ", + RESTART_WARNING(), + ])); + cb(support && typeof(support) === 'string' && support.length === 44); + }); + + assert(function (cb, msg) { + var adminKeys = ApiConfig.adminKeys; + if (Array.isArray(adminKeys) && adminKeys.length >= 1 && typeof(adminKeys[0]) === 'string' && adminKeys[0].length === 44) { + return void cb(true); + } + setWarningClass(msg); + msg.appendChild(h('span', [ + "This instance has not been configured to support web administration. This can be enabled by adding a registered user's public signing key to the ", + h('code', 'adminKeys'), + ' array in ', + CONFIG_PATH(), + '. ', + RESTART_WARNING(), + ])); + cb(false); + }); + + if (false) { + assert(function (cb, msg) { + msg.innerText = 'fake test to simulate failure'; + cb(false); + }); + } var row = function (cells) { return h('tr', cells.map(function (cell) { @@ -220,7 +551,20 @@ define([ var completed = 0; var $progress = $('#cp-progress'); - assert.run(function (state) { + + var versionStatement = function () { + return h('p', [ + "This instance is running ", + h('span.cp-app-checkup-version',[ + "CryptPad", + ' ', + Pages.versionString, + ]), + '.', + ]); + }; + + Assert.run(function (state) { var errors = state.errors; var failed = errors.length; @@ -228,12 +572,17 @@ define([ var statusClass = failed? 'failure': 'success'; + var failedDetails = "Details found below"; + var successDetails = "This checkup only tests the most common configuration issues. You may still experience errors or incorrect behaviour."; + var details = h('p', failed? failedDetails: successDetails); + var summary = h('div.summary.' + statusClass, [ + versionStatement(), h('p', Messages._getKey('assert_numberOfTestsPassed', [ state.passed, state.total ])), - h('p', "Details found below"), + details, ]); var report = h('div.report', [ @@ -248,6 +597,7 @@ define([ completed++; Messages.assert_numberOfTestsCompleted = "{0} / {1} tests completed."; $progress.html('').append(h('div.report.pending.summary', [ + versionStatement(), h('p', [ h('i.fa.fa-spinner.fa-pulse'), h('span', Messages._getKey('assert_numberOfTestsCompleted', [completed, total])) diff --git a/www/code/app-code.less b/www/code/app-code.less index a6ccd864d..3fa3ccde8 100644 --- a/www/code/app-code.less +++ b/www/code/app-code.less @@ -129,13 +129,28 @@ } @media (max-width: @browser_media-medium-screen) { - #cp-app-code-container { - flex: 1; - max-width: 100%; - resize: none; - } - #cp-app-code-preview { - display: none !important; + #cp-app-code-editor { + &.cp-app-code-present { + #cp-app-code-container { display: none !important; } + #cp-app-code-preview { + flex: 1; + max-width: 100%; + border: 0; + #cp-app-code-preview-content { + margin: 10px; + } + } + } + &:not(.cp-app-code-present) { + #cp-app-code-container { + flex: 1; + max-width: 100%; + resize: none; + } + #cp-app-code-preview { + display: none !important; + } + } } } #cp-app-code-print { diff --git a/www/common/application_config_internal.js b/www/common/application_config_internal.js index 496e65f1f..c7b66c1e5 100644 --- a/www/common/application_config_internal.js +++ b/www/common/application_config_internal.js @@ -12,7 +12,7 @@ define(function() { * You should never remove the drive from this list. */ config.availablePadTypes = ['drive', 'teams', 'pad', 'sheet', 'code', 'slide', 'poll', 'kanban', 'whiteboard', - /*'oodoc', 'ooslide',*/ 'file', /*'todo',*/ 'contacts']; + /*'doc', 'presentation',*/ 'file', /*'todo',*/ 'contacts' /*, 'calendar' */]; /* The registered only types are apps restricted to registered users. * You should never remove apps from this list unless you know what you're doing. The apps * listed here by default can't work without a user account. @@ -20,7 +20,7 @@ define(function() { * users and these users will be redirected to the login page if they still try to access * the app */ - config.registeredOnlyTypes = ['file', 'contacts', 'oodoc', 'ooslide', 'notifications', 'support']; + config.registeredOnlyTypes = ['file', 'contacts', 'notifications', 'support']; /* CryptPad is available is multiple languages, but only English and French are maintained * by the developers. The other languages may be outdated, and any missing string for a langauge @@ -43,9 +43,15 @@ define(function() { /* You can display a link to your own privacy policy in the static pages footer. * To do so, set the following value to the absolute URL of your privacy policy. */ - config.privacy = '/privacy.html'; // config.privacy = 'https://xwiki.com/en/company/PrivacyPolicy'; + /* We (the project's developers) include the ability to display a 'Roadmap' in static pages footer. + * This is disabled by default. + * We use this to publish the project's development roadmap, but you can use it however you like. + * To do so, set the following value to an absolute URL. + */ + //config.roadmap = 'https://cryptpad.fr/kanban/#/2/kanban/view/PLM0C3tFWvYhd+EPzXrbT+NxB76Z5DtZhAA5W5hG9wo/'; + /* Cryptpad apps use a common API to display notifications to users * by default, notifications are hidden after 5 seconds * You can change their duration here (measured in milliseconds) @@ -115,8 +121,8 @@ define(function() { todo: 'cptools-todo', contacts: 'fa-address-book', kanban: 'cptools-kanban', - oodoc: 'fa-file-word-o', - ooslide: 'fa-file-powerpoint-o', + doc: 'fa-file-word-o', + presentation: 'fa-file-powerpoint-o', sheet: 'cptools-sheet', drive: 'fa-hdd-o', teams: 'fa-users', @@ -162,8 +168,6 @@ define(function() { // making it much faster to open new tabs. config.disableWorkers = false; - config.surveyURL = "https://survey.cryptpad.fr/index.php/672782"; - // Teams are always loaded during the initial loading screen (for the first tab only if // SharedWorkers are available). Allowing users to be members of multiple teams can // make them have a very slow loading time. To avoid impacting the user experience @@ -179,5 +183,23 @@ define(function() { // You can change the value here. // config.maxOwnedTeams = 5; + // The userlist displayed in collaborative documents is stored alongside the document data. + // Everytime someone with edit rights joins a document or modify their user data (display + // name, avatar, color, etc.), they update the "userlist" part of the document. When too many + // editors are in the same document, all these changes increase the risks of conflicts which + // require CPU time to solve. A "degraded" mode can now be set when a certain number of editors + // are in a document at the same time. This mode disables the userlist, the chat and the + // position of other users' cursor. You can configure the number of user from which the session + // will enter into degraded mode. A big number may result in collaborative edition being broken, + // but this number depends on the network and CPU performances of each user's device. + config.degradedLimit = 8; + + // In "legacy" mode, one-time users were always creating an "anonymous" drive when visiting CryptPad + // in which they could store their pads. The new "driveless" mode allow users to open an existing + // pad without creating a drive in the background. The drive will only be created if they visit + // a different page (Drive, Settings, etc.) or try to create a new pad themselves. You can disable + // the driveless mode by changing the following value to "false" + config.allowDrivelessMode = true; + return config; }); diff --git a/www/common/common-constants.js b/www/common/common-constants.js index fdae2b5de..0a1c1d7f6 100644 --- a/www/common/common-constants.js +++ b/www/common/common-constants.js @@ -15,6 +15,6 @@ define(['/customize/application_config.js'], function (AppConfig) { MAX_TEAMS_SLOTS: AppConfig.maxTeamsSlots || 5, MAX_TEAMS_OWNED: AppConfig.maxOwnedTeams || 5, // Apps - criticalApps: ['profile', 'settings', 'debug', 'admin', 'support', 'notifications'] + criticalApps: ['profile', 'settings', 'debug', 'admin', 'support', 'notifications', 'calendar'] }; }); diff --git a/www/common/common-hash.js b/www/common/common-hash.js index afdecbf57..cf3ca76a4 100644 --- a/www/common/common-hash.js +++ b/www/common/common-hash.js @@ -644,6 +644,10 @@ Version 4: Data URL when not a realtime link yet (new pad or "static" app) '/' + curvePublic.replace(/\//g, '-') + '/'; }; + Hash.isValidChannel = function (channelId) { + return /^[a-zA-Z0-9]{32,48}$/.test(channelId); + }; + Hash.isValidHref = function (href) { // Non-empty href? if (!href) { return; } diff --git a/www/common/common-interface.js b/www/common/common-interface.js index efd505ad4..dbcb089f3 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -739,6 +739,7 @@ define([ } }); }; + // TODO: make it such that the confirmButton's width does not change UI.confirmButton = function (originalBtn, config, _cb) { config = config || {}; var cb = Util.mkAsync(_cb); @@ -1257,10 +1258,13 @@ define([ Messages.dontShowAgain ]); + var footerSel = 'div.cp-corner-footer'; var popup = h('div.cp-corner-container', [ setHTML(h('div.cp-corner-text'), text), h('div.cp-corner-actions', actions), - setHTML(h('div.cp-corner-footer'), footer), + (typeof(footer) === 'string'? + setHTML(h(footerSel), footer): + h(footerSel, footer)), opts.dontShowAgain ? dontShowAgain : undefined ]); @@ -1430,13 +1434,13 @@ define([ */ UI.createDrawer = function ($button, $content) { $button.click(function () { + var topPos = $button[0].getBoundingClientRect().bottom; $content.toggle(); $button.removeClass('cp-toolbar-button-active'); if ($content.is(':visible')) { $button.addClass('cp-toolbar-button-active'); $content.focus(); var wh = $(window).height(); - var topPos = $button[0].getBoundingClientRect().bottom; $content.css('max-height', Math.floor(wh - topPos - 1)+'px'); } }); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 562c3757c..887eb147a 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1,6 +1,7 @@ define([ 'jquery', '/api/config', + '/api/broadcast', '/common/common-util.js', '/common/common-hash.js', '/common/common-language.js', @@ -17,7 +18,7 @@ define([ '/common/visible.js', 'css!/customize/fonts/cptools/style.css', -], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, Clipboard, +], function ($, Config, Broadcast, Util, Hash, Language, UI, Constants, Feedback, h, Clipboard, Messages, AppConfig, Pages, NThen, InviteInner, Visible) { var UIElements = {}; var urlArgs = Config.requireConf.urlArgs; @@ -126,7 +127,7 @@ define([ dcAlert = undefined; }; - var importContent = function (type, f, cfg) { + var importContent = UIElements.importContent = function (type, f, cfg) { return function () { var $files = $('', {type:"file"}); if (cfg && cfg.accept) { @@ -369,7 +370,7 @@ define([ h('div.cp-teams-invite-block', [ h('span', Messages.team_inviteLinkSetPassword), h('a.cp-teams-help.fa.fa-question-circle', { - href: origin + 'https://docs.cryptpad.fr/en/user_guide/security.html#passwords-for-documents-and-folders', + href: origin + Pages.localizeDocsLink('https://docs.cryptpad.fr/en/user_guide/security.html#passwords-for-documents-and-folders'), target: "_blank", 'data-tippy-placement': "right" }) @@ -574,12 +575,18 @@ define([ } else if (callback) {*/ // Old import button, used in settings - button - .click(common.prepareFeedback(type)) - .click(importContent((data && data.binary) ? 'application/octet-stream' : 'text/plain', callback, { + var importer = importContent((data && data.binary) ? 'application/octet-stream' : 'text/plain', callback, { accept: data ? data.accept : undefined, binary: data ? data.binary : undefined - })); + }); + + var handler = data.first? function () { + data.first(importer); + }: importer; //importContent; + + button + .click(common.prepareFeedback(type)) + .click(handler); //} break; case 'upload': @@ -714,8 +721,14 @@ define([ callback(err); return void UI.warn(Messages.fm_forbidden); } - var cMsg = common.isLoggedIn() ? Messages.movedToTrash : Messages.deleted; - var msg = common.fixLinks($('
    ').html(cMsg)); + var msg; + if (common.isLoggedIn()) { + msg = Pages.setHTML(h('div'), Messages.movedToTrash); + $(msg).find('a').attr('href', '/drive/'); + common.fixLinks(msg); + } else { + msg = h('div', Messages.deleted); + } UI.alert(msg); callback(); return; @@ -781,6 +794,28 @@ define([ h('span.cp-toolbar-name.cp-toolbar-drawer-element', Messages.toolbar_savetodrive) ])).click(common.prepareFeedback(type)); break; + case 'storeindrive': + button = $(h('button.cp-toolbar-storeindrive', { + style: 'display:none;' + }, [ + h('i.fa.fa-hdd-o'), + h('span.cp-toolbar-name.cp-toolbar-drawer-element', Messages.toolbar_storeInDrive) + ])).click(common.prepareFeedback(type)).click(function () { + $(button).hide(); + common.getSframeChannel().query("Q_AUTOSTORE_STORE", null, function (err, obj) { + var error = err || (obj && obj.error); + if (error) { + $(button).show(); + if (error === 'E_OVER_LIMIT') { + return void UI.warn(Messages.pinLimitReached); + } + return void UI.warn(Messages.autostore_error); + } + $(document).trigger('cpPadStored'); + UI.log(Messages.autostore_saved); + }); + }); + break; case 'hashtag': button = $('
    ')},getTextBox:function(){var t=$(this.el).find("textarea");return t&&t.length?t:void 0},setFocusToTextBox:function(){var t=$(this.el).find("textarea");if(t&&t.length){var e=t.val();t.focus(),t.val(""),t.val(e)}},getActiveTextBoxVal:function(){var t=$(this.el).find("textarea");return t&&t.length?t.val().trim():""},autoHeightTextBox:function(){function t(){n.scrollHeight>n.clientHeight?i.css({height:n.scrollHeight+s+"px"}):(a=n.clientHeight)>=o&&(i.css({height:o+"px"}),n.scrollHeight>n.clientHeight&&(r=Math.max(n.scrollHeight+s,o),i.css({height:r+"px"}))),e.autoScrollToEditButtons()}var e=this,i=$(this.el).find("textarea"),n=null,o=50,s=0,a=0,r=0;i&&i.length&&(n=i.get(0))&&(s=.25*parseInt(i.css("lineHeight"),10),t(),i.bind("input propertychange",t)),this.textBox=i},clearTextBoxBind:function(){this.textBox&&(this.textBox.unbind("input propertychange"),this.textBox=void 0)},autoScrollToEditButtons:function(){var t=$("#id-comments-change"),e=null,i=this.el.getBoundingClientRect(),n=0;t.length&&(e=t.get(0).getBoundingClientRect())&&i&&(n=i.bottom-(e.bottom+7))<0&&this.scroller.scrollTop(this.scroller.getScrollTop()-n)}}}());Common.Views.Comments=Common.UI.BaseView.extend(_.extend({el:"#left-panel-comments",template:_.template(e),addCommentHeight:45,newCommentHeight:110,textBoxAutoSizeLocked:void 0,viewmode:!1,_commentsViewOnItemClick:function(t,e,i,n){function o(){d.update()}var s,a,r,l,c,d=this;if(s=$(n.target))if(a=i.get("editText"),r=i.get("showReply"),l=i.get("uid"),c=s.attr("data-value"),s.hasClass("btn-edit"))_.isUndefined(c)?a||(d.fireEvent("comment:closeEditing"),i.set("editText",!0),t.autoHeightTextBox(),o(),t.setFocusToTextBox(),d.hookTextBox()):(d.fireEvent("comment:closeEditing",[l]),d.fireEvent("comment:editReply",[l,c]),d.commentsView.reply=c,t.autoHeightTextBox(),o(),d.hookTextBox(),t.autoScrollToEditButtons(),t.setFocusToTextBox());else if(s.hasClass("btn-delete"))_.isUndefined(c)?(d.fireEvent("comment:remove",[l]),Common.NotificationCenter.trigger("edit:complete",d)):d.fireEvent("comment:removeReply",[l,c]),d.fireEvent("comment:closeEditing"),o();else if(s.hasClass("user-reply"))d.fireEvent("comment:closeEditing"),i.set("showReply",!0),o(),t.autoHeightTextBox(),d.hookTextBox(),t.autoScrollToEditButtons(),t.setFocusToTextBox();else if(s.hasClass("btn-reply",!1))r&&(d.fireEvent("comment:addReply",[l,t.getActiveTextBoxVal()]),d.fireEvent("comment:closeEditing"),o());else if(s.hasClass("btn-close",!1))d.fireEvent("comment:closeEditing",[l]);else if(s.hasClass("btn-inner-edit",!1))_.isUndefined(d.commentsView.reply)?a&&d.fireEvent("comment:change",[l,t.getActiveTextBoxVal()]):(d.fireEvent("comment:changeReply",[l,d.commentsView.reply,t.getActiveTextBoxVal()]),d.commentsView.reply=void 0),d.fireEvent("comment:closeEditing"),o();else if(s.hasClass("btn-inner-close",!1))d.fireEvent("comment:closeEditing"),d.commentsView.reply=void 0,o();else if(s.hasClass("btn-resolve",!1)){var h=s.data("bs.tooltip");h&&(h.dontShow=!0),d.fireEvent("comment:resolve",[l]),o()}else if(s.hasClass("btn-resolve-check",!1)){var h=s.data("bs.tooltip");h&&(h.dontShow=!0),d.fireEvent("comment:resolve",[l]),o()}else if(!s.hasClass("msg-reply")&&!s.hasClass("btn-resolve-check")&&!s.hasClass("btn-resolve")){var p=!1;if(s.hasClass("user-message"))if(window.getSelection){var m=window.getSelection();p=""!==m.toString()}else document.selection&&(p=document.selection);d.fireEvent("comment:show",[l,!1,p])}},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t),this.store=this.options.store},render:function(){var e=this;if(this.rendered||(this.$el.html(this.template({textAddCommentToDoc:e.textAddCommentToDoc,textAddComment:e.textAddComment,textCancel:e.textCancel,textEnterCommentHint:e.textEnterCommentHint,maxCommLength:Asc.c_oAscMaxCellOrCommentLength})),this.buttonAddCommentToDoc=new Common.UI.Button({el:$(".btn.new",this.$el),enableToggle:!1}),this.buttonAdd=new Common.UI.Button({action:"add",el:$(".btn.add",this.$el),enableToggle:!1}),this.buttonCancel=new Common.UI.Button({el:$(".btn.cancel",this.$el),enableToggle:!1}),this.buttonAddCommentToDoc.on("click",_.bind(this.onClickShowBoxDocumentComment,this)),this.buttonAdd.on("click",_.bind(this.onClickAddDocumentComment,this)),this.buttonCancel.on("click",_.bind(this.onClickCancelDocumentComment,this)),this.txtComment=$("#comment-msg-new",this.el),this.txtComment.keydown(function(t){if(!t.ctrlKey&&!t.metaKey||t.altKey||t.keyCode!=Common.UI.Keys.RETURN){if(t.keyCode===Common.UI.Keys.TAB){var i,n,o;o=this.selectionStart,n=this.selectionEnd,i=$(this),i.val(i.val().substring(0,o)+"\t"+i.val().substring(n)),this.selectionStart=this.selectionEnd=o+1,t.stopImmediatePropagation(),t.preventDefault()}}else e.onClickAddDocumentComment(),t.stopImmediatePropagation()})),this.commentsView)this.commentsView.onResetItems();else{this.commentsView=new n({el:$(".messages-ct",e.el),store:e.store,itemTemplate:_.template(i(t,{textAddReply:e.textAddReply,textAdd:e.textAdd,textCancel:e.textCancel,textEdit:e.textEdit,textReply:e.textReply,textClose:e.textClose,maxCommLength:Asc.c_oAscMaxCellOrCommentLength}))});var o=function(t,i,n){i.tipsArray&&i.tipsArray.forEach(function(t){t.remove()});var o=[],s=$(i.el).find(".btn-resolve");s.tooltip({title:e.textResolve,placement:"cursor"}),s.each(function(t,e){o.push($(e).data("bs.tooltip").tip())}),s=$(i.el).find(".btn-resolve-check"),s.tooltip({title:e.textOpenAgain,placement:"cursor"}),s.each(function(t,e){o.push($(e).data("bs.tooltip").tip())}),i.tipsArray=o};this.commentsView.on({"item:add":o,"item:remove":o,"item:change":o,"item:click":this._commentsViewOnItemClick.bind(this)})}return this.rendered||this.setupLayout(),this.update(),this.rendered=!0,this},update:function(){this.updateLayout(),this.updateScrolls()},updateScrolls:function(){this.commentsView&&this.commentsView.scroller&&this.commentsView.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0})},showEditContainer:function(t){var e=$(".add-link-ct",this.el),i=$(".new-comment-ct",this.el);$(".messages-ct",this.el),$("#comments-box",this.el);this.layout.freezePanels(!t),t?(e.css({display:"none"}),i.css({display:"table-row"}),this.txtComment.val(""),this.txtComment.focus(),this.textBoxAutoSizeLocked=void 0):(e.css({display:"table-row"}),i.css({display:"none"})),this.updateLayout(),this.updateScrolls()},onClickShowBoxDocumentComment:function(){this.fireEvent("comment:closeEditing"),this.showEditContainer(!0)},onClickAddDocumentComment:function(){this.fireEvent("comment:add",[this,this.txtComment.val().trim(),void 0,!1,!0]),this.txtComment.val("")},onClickCancelDocumentComment:function(){this.showEditContainer(!1)},saveText:function(t){this.commentsView&&this.commentsView.cmpEl.find(".lock-area").length<1&&(this.textVal=void 0,t?this.commentsView.clearTextBoxBind():this.textVal=this.commentsView.getActiveTextBoxVal())},loadText:function(){if(this.textVal&&this.commentsView){var t=this.commentsView.getTextBox();t&&t.val(this.textVal)}},hookTextBox:function(){var t=this.commentsView.getTextBox();t&&t.keydown(function(t){if(!t.ctrlKey&&!t.metaKey||t.altKey||t.keyCode!=Common.UI.Keys.RETURN){if(t.keyCode===Common.UI.Keys.TAB){var e,i,n;n=this.selectionStart,i=this.selectionEnd,e=$(this),e.val(e.val().substring(0,n)+"\t"+e.val().substring(i)),this.selectionStart=this.selectionEnd=n+1,t.stopImmediatePropagation(),t.preventDefault()}}else{var o=$("#id-comments-change");o&&o.length&&o.click(),t.stopImmediatePropagation()}})},setupLayout:function(){var t=this,e=t.$el,i=$(".new-comment-ct",t.el),n=($(".add-link-ct",t.el),$("#comments-box",t.el)),o=n.find(" > .layout-item");t.layout=new Common.UI.VBoxLayout({box:n,freeze:!0,items:[{el:o[0],rely:!0,resize:{hidden:!1,autohide:!1,fmin:function(){var e=n.height();return"none"!==i.css("display")&&.5*e .layout-item");n.show(),this.layout.changeLayout([{el:a[0],rely:!0,resize:{hidden:!1,autohide:!1,fmin:function(){var t=s.height();return"none"!==i.css("display")&&.5*t'+t+""}),""}),(t.length<1e3||t.search(/\S{255,}/)<0)&&t.replace(Common.Utils.hostnameStrongRe,function(t){var o=/[\.,\?\+;:=!\(\)]+$/.exec(t);o&&(t=t.substring(0,o.index));var s=/(((^https?)|(^ftp)):\/\/)/i.test(t)?t:"http://"+t;return e=arguments[arguments.length-2],i=t.length,_.find(n,function(t){return e>=t.start&&et.start})||n.push({start:e,end:i+e,str:''+t+""}),""}),t.replace(Common.Utils.emailStrongRe,function(t){var o=/((^mailto:)\/\/)/i.test(t)?t:"mailto:"+t;return e=arguments[arguments.length-2],i=t.length,_.find(n,function(t){return e>=t.start&&et.start})||n.push({start:e,end:i+e,str:''+t+""}),""}),n=_.sortBy(n,function(t){return t.start});for(var o=n.length>0?Common.Utils.String.htmlEncode(t.substring(0,n[0].start))+n[0].str:Common.Utils.String.htmlEncode(t),s=1;s0&&(o+=Common.Utils.String.htmlEncode(t.substring(n[s-1].end,t.length))),o},pickEMail:function(t,e){var i=Common.Utils.String.htmlEncode(e).match(/\B[@+][A-Z0-9._%+-]+@[A-Z0-9._]+\.[A-Z]+\b/gi);i=_.map(i,function(t){return t.slice(1,t.length)}),i.length>0&&Common.Gateway.requestSendNotify({emails:i,actionId:t,actionLink:{action:{type:"comment",data:t}},message:e})},textComments:"Comments",textAnonym:"Guest",textAddCommentToDoc:"Add Comment to Document",textAddComment:"Add Comment",textCancel:"Cancel",textAddReply:"Add Reply",textReply:"Reply",textClose:"Close",textResolved:"Resolved",textResolve:"Resolve",textEnterCommentHint:"Enter your comment here",textEdit:"Edit",textAdd:"Add",textOpenAgain:"Open Again",textHintAddComment:"Add Comment"},Common.Views.Comments||{}))}),define("text!common/main/lib/template/Chat.template",[],function(){return'
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    '}),void 0===Common)var Common={};if(Common.Views=Common.Views||{},define("common/main/lib/view/Chat",["text!common/main/lib/template/Chat.template","common/main/lib/util/utils","common/main/lib/component/BaseView","common/main/lib/component/Layout"],function(t){"use strict";Common.Views.Chat=Common.UI.BaseView.extend(_.extend({el:"#left-panel-chat",template:_.template(t),storeUsers:void 0,storeMessages:void 0,tplUser:['
  • "<% if (!user.get("online")) { %> class="offline"<% } %>>','
    ;" >
    <%= scope.getUserName(user.get("username")) %>',"
    ","
  • "].join(""),templateUserList:_.template("
      <% for (originalId in users) { %><%= _.template(usertpl)({user: users[originalId][0], scope: scope}) %><% } %>
    "), tplMsg:["
  • ",'<% if (msg.get("type")==1) { %>','
    <%= msg.get("message") %>
    ',"<% } else { %>",'
    ','
    <%=msg.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " >
    <%= scope.getUserName(msg.get("username")) %>',"
    ",'',"<% } %>","
  • "].join(""),templateMsgList:_.template("
      <% _.each(messages, function(item) { %><%= _.template(msgtpl)({msg: item, scope: scope}) %><% }); %>
    "),events:{},usersBoxHeight:72,messageBoxHeight:70,addMessageBoxHeight:110,initialize:function(t){_.extend(this,t),Common.UI.BaseView.prototype.initialize.call(this,arguments),this.storeUsers.bind({add:_.bind(this._onResetUsers,this),change:_.bind(this._onResetUsers,this),reset:_.bind(this._onResetUsers,this)}),this.storeMessages.bind({add:_.bind(this._onAddMessage,this),reset:_.bind(this._onResetMessages,this)})},render:function(t){return t=t||this.el,$(t).html(this.template({scope:this,maxMsgLength:Asc.c_oAscMaxCellOrCommentLength})),this.panelBox=$("#chat-box",this.el),this.panelUsers=$("#chat-users",this.el),this.panelMessages=$("#chat-messages",this.el),this.txtMessage=$("#chat-msg-text",this.el),this.panelOptions=$("#chat-options",this.el),this.panelUsers.scroller=new Common.UI.Scroller({el:$("#chat-users"),useKeyboard:!0,minScrollbarLength:25}),this.panelMessages.scroller=new Common.UI.Scroller({el:$("#chat-messages"),includePadding:!0,useKeyboard:!0,minScrollbarLength:40}),$("#chat-msg-btn-add",this.el).on("click",_.bind(this._onBtnAddMessage,this)),this.txtMessage.on("keydown",_.bind(this._onKeyDown,this)),this.setupLayout(),this},focus:function(){var t=this;_.defer(function(){t.txtMessage.focus()},100),this.updateLayout(!0),this.setupAutoSizingTextBox()},_onKeyDown:function(t){t.keyCode==Common.UI.Keys.RETURN?!t.ctrlKey&&!t.metaKey||t.altKey||this._onBtnAddMessage(t):t.keyCode==Common.UI.Keys.ESC&&this.hide()},_onResetUsers:function(t,e){this.panelUsers&&(this.panelUsers.html(this.templateUserList({users:this.storeUsers.chain().filter(function(t){return t.get("online")}).groupBy(function(t){return t.get("idOriginal")}).value(),usertpl:this.tplUser,scope:this})),this.panelUsers.scroller.update({minScrollbarLength:25,alwaysVisibleY:!0}))},_onAddMessage:function(t,e,i){if(this.panelMessages){var n=this.panelMessages.find("ul");n&&n.length&&(this._prepareMessage(t),n.append(_.template(this.tplMsg)({msg:t,scope:this})),this.panelMessages.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0}),this.panelMessages.scroller.scrollTop(n.get(0).getBoundingClientRect().height))}},_onResetMessages:function(t,e){if(this.panelMessages){t.each(function(t){this._prepareMessage(t)},this),this.panelMessages.html(this.templateMsgList({messages:t.models,msgtpl:this.tplMsg,scope:this})),this.panelMessages.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0})}},_onBtnAddMessage:function(t){this.txtMessage&&(this.fireEvent("message:add",[this,this.txtMessage.val().trim()]),this.txtMessage.val(""),this.focus())},_prepareMessage:function(t){var e=this.storeUsers.findOriginalUser(t.get("userid"));t.set({usercolor:e?e.get("color"):null,message:this._pickLink(t.get("message"))},{silent:!0})},_pickLink:function(t){var e,i,n=[];t.replace(Common.Utils.ipStrongRe,function(t){var i=/[\.,\?\+;:=!\(\)]+$/.exec(t);return i&&(t=t.substring(0,i.index)),e=arguments[arguments.length-2],n.push({start:e,end:t.length+e,str:''+t+""}),""}),(t.length<1e3||t.search(/\S{255,}/)<0)&&t.replace(Common.Utils.hostnameStrongRe,function(t){var o=/[\.,\?\+;:=!\(\)]+$/.exec(t);o&&(t=t.substring(0,o.index));var s=/(((^https?)|(^ftp)):\/\/)/i.test(t)?t:"http://"+t;return e=arguments[arguments.length-2],i=t.length,_.find(n,function(t){return e>=t.start&&et.start})||n.push({start:e,end:i+e,str:''+t+""}),""}),t.replace(Common.Utils.emailStrongRe,function(t){var o=/((^mailto:)\/\/)/i.test(t)?t:"mailto:"+t;return e=arguments[arguments.length-2],i=t.length,_.find(n,function(t){return e>=t.start&&et.start})||n.push({start:e,end:i+e,str:''+t+""}),""}),n=_.sortBy(n,function(t){return t.start});for(var o=n.length>0?Common.Utils.String.htmlEncode(t.substring(0,n[0].start))+n[0].str:Common.Utils.String.htmlEncode(t),s=1;s0&&(o+=Common.Utils.String.htmlEncode(t.substring(n[s-1].end,t.length))),o},getUserName:function(t){return Common.Utils.String.htmlEncode(Common.Utils.UserInfoParser.getParsedName(t))},hide:function(){Common.UI.BaseView.prototype.hide.call(this,arguments),this.fireEvent("hide",this),this.textBoxAutoSizeLocked=void 0},setupLayout:function(){var t=this,e=$(t.el),i=this.panelBox.find(" > .layout-item");t.layout=new Common.UI.VBoxLayout({box:this.panelBox,items:[{el:i[0],rely:!0,behaviour:"splitter",resize:{hidden:!1,autohide:!1,fmin:function(){return t.usersBoxHeight},fmax:function(){return.5*t.panelBox.height()-t.messageBoxHeight}}},{el:i[1],rely:!0,behaviour:"splitter",resize:{hidden:!1,autohide:!1,fmin:function(){return Math.max(t.messageBoxHeight+t.usersBoxHeight,.5*t.panelBox.height())},fmax:function(){return t.panelBox.height()-t.addMessageBoxHeight}}},{el:i[2],stretch:!0}]}),t.layout.on("layout:resizedrag",function(e){t.updateScrolls(),t.usersCachedHeigt=t.panelUsers.height()+8+1,e.index||(t.textBoxAutoSizeLocked=!0)},this),$(window).on("resize",function(){"none"!==e.css("display")&&t.updateLayout()}),this.updateLayout();var n=this.panelBox.height();this.layout.setResizeValue(0,this.usersBoxHeight),this.layout.setResizeValue(1,Math.max(this.addMessageBoxHeight,Math.max(.5*n,n-t.panelOptions.height()-4))),this.setupAutoSizingTextBox(),this.txtMessage.bind("input propertychange",_.bind(this.updateHeightTextBox,this))},updateLayout:function(t){var e=this,i=this.panelBox.height();if(e.layout.setResizeValue(1,Math.max(e.addMessageBoxHeight,Math.max(.5*i,i-e.panelOptions.height()-4))),t){this.panelUsers.css("height");this.panelUsers.css("height","1px");var n=this.panelUsers.get(0).scrollHeight;e.layout.setResizeValue(0,Math.max(e.usersBoxHeight,Math.min(n+2,Math.floor(.5*i)-e.messageBoxHeight)))}else e.layout.setResizeValue(0,Math.max(e.usersBoxHeight,Math.min(e.usersCachedHeigt+2,Math.floor(.5*i)-e.messageBoxHeight)));e.updateScrolls(),e.updateHeightTextBox(null)},setupAutoSizingTextBox:function(){this.lineHeight=0,this.minHeight=44,this.lineHeight=1.25*parseInt(this.txtMessage.css("lineHeight"),10),this.updateHeightTextBox(!0)},updateHeightTextBox:function(t){var e,i,n=this.txtMessage;if(i=this.panelBox.height(),t&&0==n.val().length)return this.layout.setResizeValue(1,Math.max(this.addMessageBoxHeight,i-this.addMessageBoxHeight)),this.textBoxAutoSizeLocked=void 0,void this.updateScrolls();_.isUndefined(this.textBoxAutoSizeLocked)&&(n.height(),e=n.get(0).scrollHeight,n.css({height:this.minHeight+"px"}),n.height(),e=Math.max(n.get(0).scrollHeight+this.lineHeight,1),n.css({height:"100%"}),i=this.panelBox.height(),this.layout.setResizeValue(1,Math.max(this.addMessageBoxHeight,Math.min(i-e-40,i-this.addMessageBoxHeight)))&&this.updateScrolls())},updateScrolls:function(){this.panelUsers&&this.panelUsers.scroller&&this.panelMessages&&this.panelMessages.scroller&&(this.panelUsers.scroller.update({minScrollbarLength:25,alwaysVisibleY:!0}),this.panelMessages.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0}))},textSend:"Send"},Common.Views.Chat||{}))}),void 0===Common)var Common={};if(Common.Views=Common.Views||{},define("common/main/lib/view/History",["common/main/lib/util/utils","common/main/lib/component/BaseView","common/main/lib/component/Layout"],function(t){"use strict";Common.Views.History=Common.UI.BaseView.extend(_.extend({el:"#left-panel-history",storeHistory:void 0,template:_.template(['
    ','
    ','
    <%=scope.textCloseHistory%>
    ',"
    ",'
    ',"
    ",'
    ','
    <%=scope.textHideAll%>
    ',"
    ","
    "].join("")),initialize:function(t){_.extend(this,t),Common.UI.BaseView.prototype.initialize.call(this,arguments)},render:function(t){t=t||this.el,$(t).html(this.template({scope:this})).width((parseInt(Common.localStorage.getItem("de-mainmenu-width"))||MENU_SCALE_PART)-SCALE_MIN),this.viewHistoryList=new Common.UI.DataView({el:$("#history-list"),store:this.storeHistory,enableKeyEvents:!1,itemTemplate:_.template(['
    ','
    <%= created %>
    ',"<% if (markedAsVersion) { %>",'
    '+this.textVer+"<%=version%>
    ","<% } %>","<% if (isRevision && hasChanges) { %>",'
    ',"<% } %>",'
    ','
    ',"
    <%= Common.Utils.String.htmlEncode(Common.Utils.UserInfoParser.getParsedName(username)) %>","
    ","<% if (canRestore && selected) { %>",'","<% } %>","
    "].join(""))});var e=this;this.viewHistoryList.onClickItem=function(t,i,n){var o=$(n.target);if(o&&o.hasClass("revision-expand")){var s=!i.get("isExpanded");i.set("isExpanded",s);var a=e.storeHistory.findRevisions(i.get("revision"));if(a&&a.length>1)for(var r=1;r0&&(i.btnTip=o.data("bs.tooltip"))}};return this.viewHistoryList.on("item:add",i),this.viewHistoryList.on("item:change",i),this.btnBackToDocument=new Common.UI.Button({el:$("#history-btn-back"),enableToggle:!1}),this.btnExpand=new Common.UI.Button({el:$("#history-btn-expand"),enableToggle:!1}),this.trigger("render:after",this),this},textRestore:"Restore",textShow:"Expand",textHide:"Collapse",textCloseHistory:"Close History",textHideAll:"Hide detailed changes",textShowAll:"Show detailed changes",textVer:"ver."},Common.Views.History||{}))}),void 0===Common)var Common={};if(Common.Views=Common.Views||{},define("common/main/lib/view/Plugins",["common/main/lib/util/utils","common/main/lib/component/BaseView","common/main/lib/component/Layout","common/main/lib/component/Window"],function(t){"use strict";Common.Views.Plugins=Common.UI.BaseView.extend(_.extend({el:"#left-panel-plugins",storePlugins:void 0,template:_.template(['
    ','','
    ',"
    ","
    ",'",''].join("")),initialize:function(t){t.store=t.store||new Common.UI.TreeViewStore,t.emptyItemText=t.emptyItemText||"",t.itemTemplate=t.itemTemplate||_.template(['
    ',"<% if (hasSubItems) { %>",'
    ',"<% } %>","<% if (isNotHeader) { %>",'
    <%= name %>
    ',"<% } else if (isEmptyItem) { %>",'
    '+t.emptyItemText+"
    ","<% } else { %>",'
    <%= name %>
    ',"<% } %>","
    "].join("")),Common.UI.DataView.prototype.initialize.call(this,t)},onAddItem:function(t,e,i){var n=new Common.UI.DataViewItem({template:this.itemTemplate,model:t});if(n){var o=(this.$el||$(this.el)).find(".inner").addBack().filter(".inner");if(o){if(this.dataViewItems.length<1&&o.find(".empty-text").remove(),i&&void 0!==i.at){var s=i.at,a=o.find("> div");s>0?$(a.get(s-1)).after(n.render().el):a.length>0?$(a[s]).before(n.render().el):o.append(n.render().el),this.dataViewItems=this.dataViewItems.slice(0,s).concat(n).concat(this.dataViewItems.slice(s))}else o.append(n.render().el),this.dataViewItems.push(n);var r=t.get("name");if(r.length>37-2*t.get("level")&&t.set("tip",r),t.get("tip")){var l=$(n.el);l.attr("data-toggle","tooltip"),l.tooltip({title:t.get("tip"),placement:"cursor",zIndex:this.tipZIndex})}this.listenTo(n,"change",this.onChangeItem),this.listenTo(n,"remove",this.onRemoveItem),this.listenTo(n,"click",this.onClickItem),this.listenTo(n,"dblclick",this.onDblClickItem),this.listenTo(n,"select",this.onSelectItem),this.listenTo(n,"contextmenu",this.onContextMenuItem),this.isSuspendEvents||this.trigger("item:add",this,n,t)}}},onClickItem:function(t,e,i){var n=$(i.target);if(n&&n.hasClass("tree-caret")){var o=t.$el.data("bs.tooltip");o&&o.tip().remove();var s=!e.get("isExpanded");e.set("isExpanded",s),this.store[s?"expandSubItems":"collapseSubItems"](e),this.scroller.update({minScrollbarLength:40,alwaysVisibleY:this.scrollAlwaysVisible})}else Common.UI.DataView.prototype.onClickItem.call(this,t,e,i)},expandAll:function(){this.store.expandAll(),this.scroller.update({minScrollbarLength:40,alwaysVisibleY:this.scrollAlwaysVisible})},collapseAll:function(){this.store.collapseAll(),this.scroller.update({minScrollbarLength:40,alwaysVisibleY:this.scrollAlwaysVisible})},expandToLevel:function(t){this.store.expandToLevel(t),this.scroller.update({minScrollbarLength:40,alwaysVisibleY:this.scrollAlwaysVisible})},expandRecord:function(t){t&&(t.set("isExpanded",!0),this.store.expandSubItems(t),this.scroller.update({minScrollbarLength:40,alwaysVisibleY:this.scrollAlwaysVisible}))},collapseRecord:function(t){t&&(t.set("isExpanded",!1),this.store.collapseSubItems(t),this.scroller.update({minScrollbarLength:40,alwaysVisibleY:this.scrollAlwaysVisible}))},onKeyDown:function(t,e){if(!this.disabled)if(void 0===e&&(e=t),_.indexOf(this.moveKeys,e.keyCode)>-1||e.keyCode==Common.UI.Keys.RETURN){e.preventDefault(),e.stopPropagation();var i=this.getSelectedRec();if(null===this.lastSelectedRec&&(this.lastSelectedRec=i),e.keyCode==Common.UI.Keys.RETURN)this.lastSelectedRec=null,this.selectedBeforeHideRec&&(i=this.selectedBeforeHideRec),this.trigger("item:click",this,this,i,t),this.trigger("item:select",this,this,i,t),this.trigger("entervalue",this,i,t),this.parentMenu&&this.parentMenu.hide();else{var n=_.indexOf(this.store.models,i);if(n<0)if(e.keyCode==Common.UI.Keys.LEFT){var o=$(t.target).closest(".dropdown-submenu.over");o.length>0?(o.removeClass("over"),o.find("> a").focus()):n=0}else n=0;else if("both"==this.options.keyMoveDirection){var s=i.get("hasSubItems"),a=(i.get("hasParent"),i.get("isExpanded"));if(e.keyCode==Common.UI.Keys.LEFT)s&&a&&this.collapseRecord(i);else if(e.keyCode==Common.UI.Keys.RIGHT)s&&!a&&this.expandRecord(i);else if(e.keyCode==Common.UI.Keys.DOWN){for(var r=n+1;r=0;r--)if(this.store.at(r).get("isVisible")){n=r;break}}else n=e.keyCode==Common.UI.Keys.UP||e.keyCode==Common.UI.Keys.LEFT?Math.max(0,n-1):Math.min(this.store.length-1,n+1);void 0!==n&&n>=0&&(i=this.store.at(n)),i&&(this._fromKeyDown=!0,this.selectRecord(i),this._fromKeyDown=!1,this.scrollToRecord(i))}}else this.trigger("item:keydown",this,i,t)},focus:function(){this.cmpEl&&this.cmpEl.find(".treeview").focus()}}}())}),define("documenteditor/main/app/view/Navigation",["common/main/lib/util/utils","common/main/lib/component/BaseView","common/main/lib/component/Layout","common/main/lib/component/TreeView"],function(t){"use strict";DE.Views.Navigation=Common.UI.BaseView.extend(_.extend({el:"#left-panel-navigation",storeNavigation:void 0,template:_.template(['"].join("")),initialize:function(t){_.extend(this,t),Common.UI.BaseView.prototype.initialize.call(this,arguments)},render:function(t){return t=t||this.el,$(t).html(this.template({scope:this})),this.$el=$(t),this.viewNavigationList=new Common.UI.TreeView({el:$("#navigation-list"),store:this.storeNavigation,enableKeyEvents:!1,emptyText:this.txtEmpty,emptyItemText:this.txtEmptyItem,style:"border: none;"}),this.viewNavigationList.cmpEl.off("click"),this.navigationMenu=new Common.UI.Menu({items:[{caption:this.txtPromote,value:"promote"},{caption:this.txtDemote,value:"demote"},{caption:"--"},{caption:this.txtHeadingBefore,value:"before"},{caption:this.txtHeadingAfter,value:"after"},{caption:this.txtNewHeading,value:"new"},{caption:"--"},{caption:this.txtSelect,value:"select"},{caption:"--"},{caption:this.txtExpand,value:"expand"},{caption:this.txtCollapse,value:"collapse"},{caption:this.txtExpandToLevel,menu:new Common.UI.Menu({menuAlign:"tl-tr",style:"min-width: 60px;",items:[{caption:"1",value:1},{caption:"2",value:2},{caption:"3",value:3},{caption:"4",value:4},{caption:"5",value:5},{caption:"6",value:6},{caption:"7",value:7},{caption:"8",value:8},{caption:"9",value:9}]})}]}),this.trigger("render:after",this),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments),this.fireEvent("show",this)},hide:function(){Common.UI.BaseView.prototype.hide.call(this,arguments),this.fireEvent("hide",this)},ChangeSettings:function(t){},txtPromote:"Promote",txtDemote:"Demote",txtHeadingBefore:"New heading before",txtHeadingAfter:"New heading after",txtNewHeading:"New subheading",txtSelect:"Select content",txtExpand:"Expand all",txtCollapse:"Collapse all",txtExpandToLevel:"Expand to level...",txtEmpty:"There are no headings in the document.
    Apply a heading style to the text so that it appears in the table of contents.",txtEmptyItem:"Empty Heading"},DE.Views.Navigation||{}))}),define("documenteditor/main/app/view/LeftMenu",["text!documenteditor/main/app/template/LeftMenu.template","jquery","underscore","backbone","common/main/lib/component/Button","common/main/lib/view/About","common/main/lib/view/Comments","common/main/lib/view/Chat","common/main/lib/view/History","common/main/lib/view/Plugins","common/main/lib/view/About","common/main/lib/view/SearchDialog","documenteditor/main/app/view/FileMenu","documenteditor/main/app/view/Navigation"],function(t,e,i,n){"use strict";DE.Views.LeftMenu=n.View.extend(i.extend({el:"#left-menu",template:i.template(t),events:function(){return{"click #left-btn-comments":i.bind(this.onCoauthOptions,this),"click #left-btn-chat":i.bind(this.onCoauthOptions,this),"click #left-btn-plugins":i.bind(this.onCoauthOptions,this),"click #left-btn-navigation":i.bind(this.onCoauthOptions,this),"click #left-btn-support":function(){var t=this.mode.customization;t&&t.feedback&&t.feedback.url?window.open(t.feedback.url):window.open("https://support.onlyoffice.com")}}},initialize:function(){this.minimizedMode=!0,this._state={}},render:function(){var t=e(this.template({}));return this.btnSearch=new Common.UI.Button({action:"search",el:t.elementById("#left-btn-search"),hint:this.tipSearch+Common.Utils.String.platformKey("Ctrl+F"),disabled:!0,enableToggle:!0}),this.btnAbout=new Common.UI.Button({action:"about",el:t.elementById("#left-btn-about"),hint:this.tipAbout,enableToggle:!0,disabled:!0,toggleGroup:"leftMenuGroup"}),this.btnSupport=new Common.UI.Button({action:"support",el:t.elementById("#left-btn-support"),hint:this.tipSupport,disabled:!0}),this.btnComments=new Common.UI.Button({el:t.elementById("#left-btn-comments"),hint:this.tipComments+Common.Utils.String.platformKey("Ctrl+Shift+H"),enableToggle:!0,disabled:!0,toggleGroup:"leftMenuGroup"}),this.btnChat=new Common.UI.Button({el:t.elementById("#left-btn-chat"),hint:this.tipChat+Common.Utils.String.platformKey("Alt+Q"),enableToggle:!0,disabled:!0,toggleGroup:"leftMenuGroup"}),this.btnComments.hide(),this.btnChat.hide(),this.btnComments.on("click",this.onBtnMenuClick.bind(this)),this.btnComments.on("toggle",this.onBtnCommentsToggle.bind(this)),this.btnChat.on("click",this.onBtnMenuClick.bind(this)),this.btnPlugins=new Common.UI.Button({el:t.elementById("#left-btn-plugins"),hint:this.tipPlugins,enableToggle:!0,disabled:!0,toggleGroup:"leftMenuGroup"}),this.btnPlugins.hide(),this.btnPlugins.on("click",this.onBtnMenuClick.bind(this)),this.btnNavigation=new Common.UI.Button({el:t.elementById("#left-btn-navigation"),hint:this.tipNavigation,enableToggle:!0,disabled:!0,toggleGroup:"leftMenuGroup"}),this.btnNavigation.on("click",this.onBtnMenuClick.bind(this)),this.btnSearch.on("click",this.onBtnMenuClick.bind(this)),this.btnAbout.on("toggle",this.onBtnMenuToggle.bind(this)),this.menuFile=new DE.Views.FileMenu,this.btnAbout.panel=new Common.Views.About({el:"#about-menu-panel",appName:"Document Editor"}),this.$el.html(t),this},onBtnMenuToggle:function(t,e){e?(t.panel.show(),this._state.pluginIsRunning||this.$el.width(40),this.btnSearch.isActive()&&this.btnSearch.toggle(!1)):t.panel.hide(),DE.getController("Toolbar").DisableToolbar(1==e),this.supressEvents||Common.NotificationCenter.trigger("layout:changed","leftmenu")},onBtnCommentsToggle:function(t,e){e||this.fireEvent("comments:hide",this)},onBtnMenuClick:function(t,e){this.supressEvents=!0,this.btnAbout.toggle(!1),"search"==t.options.action||(t.pressed?this.$el.width()>40||this.$el.width(parseInt(Common.localStorage.getItem("de-mainmenu-width"))||300):this._state.pluginIsRunning||(Common.localStorage.setItem("de-mainmenu-width",this.$el.width()),this.$el.width(40))),this.supressEvents=!1,Common.NotificationCenter.trigger("layout:changed","leftmenu")},onCoauthOptions:function(t){this.mode.canCoAuthoring&&(this.mode.canViewComments&&(this.btnComments.pressed&&this.btnComments.$el.hasClass("notify")&&this.btnComments.$el.removeClass("notify"),this.panelComments[this.btnComments.pressed?"show":"hide"](),this.fireEvent(this.btnComments.pressed?"comments:show":"comments:hide",this)),this.mode.canChat&&(this.btnChat.pressed?(this.btnChat.$el.hasClass("notify")&&this.btnChat.$el.removeClass("notify"),this.panelChat.show(),this.panelChat.focus()):this.panelChat.hide())),this.panelNavigation&&(this.btnNavigation.pressed?this.panelNavigation.show():this.panelNavigation.hide())},setOptionsPanel:function(t,e){"chat"==t?this.panelChat=e.render("#left-panel-chat"):"comment"==t?this.panelComments=e:"history"==t?this.panelHistory=e.render("#left-panel-history"):"plugins"!=t||this.panelPlugins?"navigation"!=t||this.panelNavigation||(this.panelNavigation=e.render("#left-panel-navigation")):this.panelPlugins=e.render()},markCoauthOptions:function(t,e){"chat"!=t||!this.btnChat.isVisible()||this.btnChat.isDisabled()||this.btnChat.pressed||this.btnChat.$el.addClass("notify"),"comments"!=t||!this.btnComments.isVisible()||this.btnComments.pressed||this.btnComments.isDisabled()&&!e||this.btnComments.$el.addClass("notify")},close:function(t){this.menuFile.isVisible()?this.menuFile.hide():(this.btnAbout.toggle(!1),this._state.pluginIsRunning||this.$el.width(40),this.mode.canCoAuthoring&&(this.mode.canViewComments&&(this.panelComments.hide(),this.btnComments.pressed&&this.fireEvent("comments:hide",this),this.btnComments.toggle(!1,!0)),this.mode.canChat&&(this.panelChat.hide(),this.btnChat.toggle(!1))),this.mode.canPlugins&&this.panelPlugins&&!this._state.pluginIsRunning&&(this.panelPlugins.hide(),this.btnPlugins.toggle(!1,!0)),this.panelNavigation&&(this.panelNavigation.hide(),this.btnNavigation.toggle(!1,!0)))},isOpened:function(){var t=this.btnSearch.pressed;return!t&&(t=this.btnComments.pressed||this.btnChat.pressed),t},disableMenu:function(t,e){this.btnSearch.setDisabled(!1),this.btnAbout.setDisabled(!1),this.btnSupport.setDisabled(!1),this.btnComments.setDisabled(!1),this.btnChat.setDisabled(!1),this.btnPlugins.setDisabled(!1),this.btnNavigation.setDisabled(!1)},showMenu:function(t,e){var i=/^(\w+):?(\w*)$/.exec(t);"file"==i[1]?(this.menuFile.isVisible(),this.menuFile.show(i[2].length?i[2]:void 0,e)):"chat"==t?!this.btnChat.isVisible()||this.btnChat.isDisabled()||this.btnChat.pressed||(this.btnChat.toggle(!0),this.onBtnMenuClick(this.btnChat),this.onCoauthOptions(),this.panelChat.focus()):"comments"==t&&(!this.btnComments.isVisible()||this.btnComments.isDisabled()||this.btnComments.pressed||(this.btnComments.toggle(!0),this.onBtnMenuClick(this.btnComments),this.onCoauthOptions()))},getMenu:function(t){switch(t){default:return null;case"file":return this.menuFile;case"about":return this.btnAbout.panel}},setMode:function(t){return this.mode=t,this.btnAbout.panel.setMode(t),this},showHistory:function(){this._state.pluginIsRunning=!1,this.panelHistory.show(),this.panelHistory.$el.width((parseInt(Common.localStorage.getItem("de-mainmenu-width"))||300)-40),Common.NotificationCenter.trigger("layout:changed","history")},setDeveloperMode:function(t,n,o){if(this.$el.is(":visible")){if((t&Asc.c_oLicenseMode.Trial||t&Asc.c_oLicenseMode.Developer)&&!this.developerHint){var s="";t&Asc.c_oLicenseMode.Trial&&t&Asc.c_oLicenseMode.Developer?s=this.txtTrialDev:0!=(t&Asc.c_oLicenseMode.Trial)?s=this.txtTrial:0!=(t&Asc.c_oLicenseMode.Developer)&&(s=this.txtDeveloper),s=s.toUpperCase(),this.developerHint=e('
    '+s+"
    ").appendTo(this.$el),this.devHeight=this.developerHint.outerHeight(),!this.devHintInited&&e(window).on("resize",i.bind(this.onWindowResize,this)),this.devHintInited=!0}if(this.developerHint&&this.developerHint.toggleClass("hidden",!(t&Asc.c_oLicenseMode.Trial||t&Asc.c_oLicenseMode.Developer)),n&&!this.betaHint){var a=t?'style="margin-top: 4px;"':"",r=(o||"").split("."),l="";r.length>0&&(l+="v. "+r[0]),r.length>1&&(l+="."+r[1]),this.betaHint=e('
    "+l+" (beta)
    ").appendTo(this.$el),this.betaHeight=this.betaHint.outerHeight(),!this.devHintInited&&e(window).on("resize",i.bind(this.onWindowResize,this)),this.devHintInited=!0}this.betaHint&&this.betaHint.toggleClass("hidden",!n);var c=this.$el.find("button.btn-category:visible"),d=c.length>0?e(c[c.length-1]):null;this.minDevPosition=d?d.offset().top-d.offsetParent().offset().top+d.height()+20:20,this.onWindowResize()}},setLimitMode:function(){if(this.$el.is(":visible")){if(!this.limitHint){var t=this.txtLimit.toUpperCase();this.limitHint=e('
    '+t+"
    ").appendTo(this.$el),this.limitHeight=this.limitHint.outerHeight(),!this.devHintInited&&e(window).on("resize",i.bind(this.onWindowResize,this)),this.devHintInited=!0}this.limitHint&&this.limitHint.toggleClass("hidden",!1);var n=this.$el.find("button.btn-category:visible"),o=n.length>0?e(n[n.length-1]):null;this.minDevPosition=o?o.offset().top-o.offsetParent().offset().top+o.height()+20:20,this.onWindowResize()}},onWindowResize:function(){var t=(this.devHeight||0)+(this.betaHeight||0)+(this.limitHeight||0),e=Math.max((this.$el.height()-t)/2,this.minDevPosition);this.developerHint&&(this.developerHint.css("top",e),e+=this.devHeight),this.betaHint&&(this.betaHint.css("top",e),e+=this.betaHeight+4),this.limitHint&&this.limitHint.css("top",e)},tipComments:"Comments",tipChat:"Chat",tipAbout:"About",tipSupport:"Feedback & Support",tipSearch:"Search",tipPlugins:"Plugins",txtDeveloper:"DEVELOPER MODE",txtTrial:"TRIAL MODE",txtTrialDev:"Trial Developer Mode",tipNavigation:"Navigation",txtLimit:"Limit Access"},DE.Views.LeftMenu||{}))}),define("documenteditor/main/app/controller/Viewport",["core","common/main/lib/view/Header","documenteditor/main/app/view/Viewport","documenteditor/main/app/view/LeftMenu"],function(t){"use strict";DE.Controllers.Viewport=Backbone.Controller.extend(_.assign({models:[],collections:[],views:["Viewport","Common.Views.Header"],initialize:function(){var t=this;this.addListeners({FileMenu:{"menu:hide":t.onFileMenu.bind(t,"hide"),"menu:show":t.onFileMenu.bind(t,"show")},Toolbar:{"render:before":function(e){var i=DE.getController("Main").appOptions;e.setExtra("right",t.header.getPanel("right",i)),(!i.isEdit||i.customization&&i.customization.compactHeader)&&e.setExtra("left",t.header.getPanel("left",i))},"view:compact":function(e,i){t.header.mnuitemCompactToolbar.setChecked(i,!0),t.viewport.vlayout.getItem("toolbar").height=i?Common.Utils.InternalSettings.get("toolbar-height-compact"):Common.Utils.InternalSettings.get("toolbar-height-normal")},"undo:disabled":function(e){t.header.btnUndo&&(t.header.btnUndo.keepState?t.header.btnUndo.keepState.disabled=e:t.header.btnUndo.setDisabled(e))},"redo:disabled":function(e){t.header.btnRedo&&(t.header.btnRedo.keepState?t.header.btnRedo.keepState.disabled=e:t.header.btnRedo.setDisabled(e))},"print:disabled":function(e){t.header.btnPrint&&t.header.btnPrint.setDisabled(e)},"save:disabled":function(e){t.header.btnSave&&t.header.btnSave.setDisabled(e)}}})},setApi:function(t){this.api=t,this.api.asc_registerCallback("asc_onZoomChange",this.onApiZoomChange.bind(this)),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",this.onApiCoAuthoringDisconnect.bind(this)),Common.NotificationCenter.on("api:disconnect",this.onApiCoAuthoringDisconnect.bind(this))},getApi:function(){return this.api},onLaunch:function(){this.viewport=this.createView("Viewport").render(),this.api=new Asc.asc_docs_api({"id-view":"editor_sdk",translate:this.getApplication().getController("Main").translationTable}),this.header=this.createView("Common.Views.Header",{headerCaption:"Document Editor",storeUsers:DE.getCollection("Common.Collections.Users")}),Common.NotificationCenter.on("layout:changed",_.bind(this.onLayoutChanged,this)),$(window).on("resize",_.bind(this.onWindowResize,this));var t=$("#left-menu"),e=$("#left-panel-history");this.viewport.hlayout.on("layout:resizedrag",function(){this.api.Resize(),Common.localStorage.setItem("de-mainmenu-width",e.is(":visible")?e.width()+SCALE_MIN:t.width())},this),this.boxSdk=$("#editor_sdk"),this.boxSdk.css("border-left","none"),this.header.mnuitemFitPage=this.header.fakeMenuItem(),this.header.mnuitemFitWidth=this.header.fakeMenuItem(),Common.NotificationCenter.on("app:face",this.onAppShowed.bind(this)),Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this))},onAppShowed:function(t){var e=this;e.appConfig=t;var i=Common.Utils.InternalSettings,n=$(".toolbar-fullview-panel");if(n.css("top",i.get("toolbar-height-tabs")),e.viewport.$el.attr("applang",e.appConfig.lang.split(/[\-_]/)[0]),!t.isEdit||!Common.localStorage.itemExists("de-compact-toolbar")&&t.customization&&t.customization.compactToolbar){var o=e.viewport.vlayout.getItem("toolbar");o&&(o.height=i.get("toolbar-height-tabs"))}if(t.customization&&(t.customization.toolbarNoTabs&&e.viewport.vlayout.getItem("toolbar").el.addClass("style-off-tabs"),t.customization.toolbarHideFileName&&e.viewport.vlayout.getItem("toolbar").el.addClass("style-skip-docname")),t.isEdit&&(!t.customization||!t.customization.compactHeader)){var s=e.viewport.vlayout.getItem("title").el;s.html(e.header.getPanel("title",t)).show(),s.find(".extra").html(e.header.getPanel("left",t));var a=e.viewport.vlayout.getItem("toolbar");a.el.addClass("top-title"),a.height-=i.get("toolbar-height-tabs")-i.get("toolbar-height-tabs-top-title");var r=i.get("toolbar-height-tabs-top-title");i.set("toolbar-height-tabs",r),i.set("toolbar-height-compact",r),i.set("toolbar-height-normal",r+i.get("toolbar-height-controls")),n.css("top",r+i.get("document-title-height")),a=e.getApplication().getController("Toolbar").getView(),a.btnCollabChanges=e.header.btnSave}},onAppReady:function(t){var e=this;if(e.header.btnOptions){var i=!t.isEdit;t.isEdit&&(Common.localStorage.itemExists("de-compact-toolbar")?i=Common.localStorage.getBool("de-compact-toolbar"):t.customization&&t.customization.compactToolbar&&(i=!0)),e.header.mnuitemCompactToolbar=new Common.UI.MenuItem({caption:e.header.textCompactView,checked:i,checkable:!0,value:"toolbar"}),t.isEdit||(e.header.mnuitemCompactToolbar.hide(),Common.NotificationCenter.on("tab:visible",_.bind(function(t,i){"plugins"!=t&&"review"!=t||!i||e.header.mnuitemCompactToolbar.show()},this)));var n=new Common.UI.MenuItem({caption:e.header.textHideStatusBar,checked:Common.localStorage.getBool("de-hidden-status"),checkable:!0,value:"statusbar"});t.canBrandingExt&&t.customization&&!1===t.customization.statusBar&&n.hide();var o=new Common.UI.MenuItem({caption:e.header.textHideLines,checked:Common.localStorage.getBool("de-hidden-rulers"),checkable:!0,value:"rulers"});t.isEdit||o.hide(),e.header.mnuitemFitPage=new Common.UI.MenuItem({caption:e.textFitPage,checkable:!0,checked:e.header.mnuitemFitPage.isChecked(),value:"zoom:page"}),e.header.mnuitemFitWidth=new Common.UI.MenuItem({caption:e.textFitWidth,checkable:!0,checked:e.header.mnuitemFitWidth.isChecked(),value:"zoom:width"}),e.header.mnuZoom=new Common.UI.MenuItem({template:_.template(['"].join("")),stopPropagation:!0,value:e.header.mnuZoom.options.value}),e.header.btnOptions.setMenu(new Common.UI.Menu({cls:"pull-right",style:"min-width: 180px;",items:[e.header.mnuitemCompactToolbar,n,o,{caption:"--"},e.header.mnuitemFitPage,e.header.mnuitemFitWidth,e.header.mnuZoom,{caption:"--"},new Common.UI.MenuItem({caption:e.header.textAdvSettings,value:"advanced"})]}));var s=function(t){"up"==t?e.api.zoomIn():e.api.zoomOut(),Common.NotificationCenter.trigger("edit:complete",e.header)};new Common.UI.Button({el:$("#hdr-menu-zoom-out",e.header.mnuZoom.$el),cls:"btn-toolbar"}).on("click",s.bind(e,"down")),new Common.UI.Button({el:$("#hdr-menu-zoom-in",e.header.mnuZoom.$el),cls:"btn-toolbar"}).on("click",s.bind(e,"up")),e.header.btnOptions.menu.on("item:click",e.onOptionsItemClick.bind(this))}},onLayoutChanged:function(t){switch(t){default:this.viewport.vlayout.doLayout();case"rightmenu":this.viewport.hlayout.doLayout();break;case"history":var e=this.viewport.hlayout.items[1];e.resize.el&&(this.boxSdk.css("border-left",""),e.resize.el.show()), -this.viewport.hlayout.doLayout();break;case"leftmenu":var e=this.viewport.hlayout.items[0];e.resize.el&&(e.el.width()>40?(this.boxSdk.css("border-left",""),e.resize.el.show()):(e.resize.el.hide(),this.boxSdk.css("border-left","0 none"))),this.viewport.hlayout.doLayout();break;case"header":case"toolbar":case"status":this.viewport.vlayout.doLayout()}this.api.Resize()},onWindowResize:function(t){this.onLayoutChanged("window"),Common.NotificationCenter.trigger("window:resize")},onFileMenu:function(t){var e=this,i="show"==t;e.header.lockHeaderBtns("undo",i),e.header.lockHeaderBtns("redo",i),e.header.lockHeaderBtns("opts",i),e.header.lockHeaderBtns("users",i)},onApiZoomChange:function(t,e){this.header.mnuitemFitPage.setChecked(2==e,!0),this.header.mnuitemFitWidth.setChecked(1==e,!0),this.header.mnuZoom.options.value=t,this.header.mnuZoom.$el&&$(".menu-zoom label.zoom",this.header.mnuZoom.$el).html(t+"%")},onOptionsItemClick:function(t,e,i){var n=this;switch(e.value){case"toolbar":n.header.fireEvent("toolbar:setcompact",[t,e.isChecked()]);break;case"statusbar":n.header.fireEvent("statusbar:hide",[e,e.isChecked()]);break;case"rulers":n.api.asc_SetViewRulers(!e.isChecked()),Common.localStorage.setBool("de-hidden-rulers",e.isChecked()),Common.NotificationCenter.trigger("layout:changed","rulers"),Common.NotificationCenter.trigger("edit:complete",n.header);break;case"zoom:page":e.isChecked()?n.api.zoomFitToPage():n.api.zoomCustomMode(),Common.NotificationCenter.trigger("edit:complete",n.header);break;case"zoom:width":e.isChecked()?n.api.zoomFitToWidth():n.api.zoomCustomMode(),Common.NotificationCenter.trigger("edit:complete",n.header);break;case"advanced":n.header.fireEvent("file:settings",n.header)}},onApiCoAuthoringDisconnect:function(t){this.header&&(this.header.btnDownload&&!t&&this.header.btnDownload.hide(),this.header.btnPrint&&!t&&this.header.btnPrint.hide(),this.header.btnEdit&&this.header.btnEdit.hide())},textFitPage:"Fit to Page",textFitWidth:"Fit to Width"},DE.Controllers.Viewport))}),$(document).off("keydown.bs.dropdown.data-api").on("keydown.bs.dropdown.data-api","[data-toggle=dropdown], [role=menu]",onDropDownKeyDown),"ontouchstart"in document.documentElement&&$(document).on("click.bs.dropdown.data-api","[data-toggle=dropdown]",toggle),function(){function t(t){1!=t.which&&void 0!=t.which||clearMenus(/form-control/.test(t.target.className))}var e,i=$._data($(document).get(0),"events");i&&i.click&&i.click.every(function(t,i,n){return/click/.test(t.type)&&!t.selector&&/bs\..+\.dropdown/.test(t.namespace)&&(e=t.handler),!e}),e&&$(document).off("click.bs.dropdown.data-api",e).on("click.bs.dropdown.data-api",t)}(),define("common/main/lib/extend/Bootstrap",function(){}),void 0===Common)var Common={};if(define("common/main/lib/component/MenuItem",["common/main/lib/component/BaseView","common/main/lib/component/ToggleManager"],function(){"use strict";Common.UI.MenuItem=Common.UI.BaseView.extend({options:{id:null,cls:"",style:"",hint:!1,checkable:!1,checked:!1,allowDepress:!1,disabled:!1,value:null,toggleGroup:null,iconCls:"",menu:null,canFocused:!0},tagName:"li",template:_.template([' tabindex="-1" type="menuitem" <% }; if(!_.isUndefined(options.stopPropagation)) { %> data-stopPropagation="true" <% }; %> >',"<% if (!_.isEmpty(iconCls)) { %>",'',"<% } %>","<%= caption %>",""].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.id=e.options.id||Common.UI.getId(),this.cls=e.options.cls,this.style=e.options.style,this.caption=e.options.caption,this.menu=e.options.menu||null,this.checkable=e.options.checkable,this.checked=e.options.checked,e.allowDepress=e.options.allowDepress,this.disabled=e.options.disabled,this.value=e.options.value,this.toggleGroup=e.options.toggleGroup,this.template=e.options.template||this.template,this.iconCls=e.options.iconCls,this.hint=e.options.hint,this.rendered=!1,null===this.menu||this.menu instanceof Common.UI.Menu||this.menu instanceof Common.UI.MenuSimple||(this.menu=new Common.UI.Menu(_.extend({},e.options.menu))),e.options.el&&this.render()},render:function(){var t=this,e=t.$el||$(this.el);if(t.trigger("render:before",t),"--"===t.caption)e.addClass("divider");else if(!this.rendered){e.off("click"),Common.UI.ToggleManager.unregister(t),e.html(this.template({id:t.id,caption:t.caption,iconCls:t.iconCls,style:t.style,options:t.options})),t.menu&&(e.addClass("dropdown-submenu"),t.menu.render(e),e.mouseenter(_.bind(t.menu.alignPosition,t.menu)),e.focusout(_.bind(t.onBlurItem,t)),e.hover(_.bind(t.onHoverItem,t),_.bind(t.onUnHoverItem,t)));var i=e.children(":first");this.checkable&&i&&(i.toggleClass("checkable",this.checkable),i.toggleClass("no-checkmark",!1===this.options.checkmark),i.toggleClass("checked",this.checked),_.isEmpty(this.iconCls)||i.css("background-image","none")),t.options.hint&&(e.attr("data-toggle","tooltip"),e.tooltip({title:t.options.hint,placement:t.options.hintAnchor||function(t,e){var i=this.getPosition(),n=t.offsetWidth,o=t.offsetHeight,s=Common.Utils.innerWidth(),a=Common.Utils.innerHeight(),r=i.top,l=i.left+i.width+2;r+o>a&&(r=a-o-2),l+n>s&&(l=i.left-n-2),$(t).offset({top:r,left:l}).addClass("in")}})),this.disabled&&e.toggleClass("disabled",this.disabled),e.on("click",_.bind(this.onItemClick,this)),e.on("mousedown",_.bind(this.onItemMouseDown,this)),Common.UI.ToggleManager.register(t)}return t.cmpEl=e,t.rendered=!0,t.trigger("render:after",t),this},setCaption:function(t,e){this.caption=t,this.rendered&&(this.cmpEl.find("a").contents().last()[0].textContent=e?t:Common.Utils.String.htmlEncode(t))},setIconCls:function(t){if(this.rendered&&!_.isEmpty(this.iconCls)){var e=this.cmpEl.children(":first");e&&e.find(".menu-item-icon").removeClass(this.iconCls).addClass(t)}this.iconCls=t},setChecked:function(t,e){this.toggle(t,e)},isChecked:function(){return this.checked},setDisabled:function(t){this.disabled=!!t,this.rendered&&this.cmpEl.toggleClass("disabled",this.disabled)},isDisabled:function(){return this.disabled},toggle:function(t,e){var i=void 0===t?!this.checked:!!t;if(this.checkable){if(this.checked=i,this.rendered){var n=this.cmpEl.children(":first");n&&(n.toggleClass("checked",this.checked),_.isEmpty(this.iconCls)||n.css("background-image","none"))}e||this.trigger("toggle",this,i)}},onItemMouseDown:function(t){if(1!=t.which)return t.preventDefault(),t.stopPropagation(),!1;t.stopPropagation()},onItemClick:function(t){return(1==t.which||void 0===t.which&&!this.menu)&&(this.disabled||!this.allowDepress&&this.checked&&this.toggleGroup||this.menu||this.setChecked(!this.checked),this.menu?t.target.id!=this.id&&void(this.menu.isOver||this.cmpEl.removeClass("over")):!this.disabled&&void this.trigger("click",this,t))},onHoverItem:function(t){this._doHover(t)},onUnHoverItem:function(t){this._doUnHover(t)},onBlurItem:function(t){this._doUnHover(t)},_doHover:function(t){var e=this;e.menu&&!e.disabled&&(clearTimeout(e.hideMenuTimer),e.cmpEl.trigger("show.bs.dropdown"),e.expandMenuTimer=_.delay(function(){e.cmpEl.addClass("over"),e.cmpEl.trigger("shown.bs.dropdown")},200))},_doUnHover:function(t){var e=this;if(e.cmpEl.hasClass("dropdown-submenu")&&e.cmpEl.hasClass("over")&&(t&&t.relatedTarget&&e.cmpEl.find(t.relatedTarget).length>0||e.cmpEl.hasClass("focused-submenu")))return void e.cmpEl.removeClass("focused-submenu");if(e.menu&&!e.disabled&&(clearTimeout(e.expandMenuTimer),e.hideMenuTimer=_.delay(function(){e.menu.isOver||e.cmpEl.removeClass("over")},200),t&&"focusout"!==t.type)){var i=e.cmpEl.children(":focus");i.length>0&&(i.blur(),e.cmpEl.closest("ul").focus())}}}),Common.UI.MenuItemSeparator=function(t){return t=t||{},t.caption="--",new Common.UI.MenuItem(t)}}),void 0===Common)var Common={};if(define("common/main/lib/component/Menu",["common/main/lib/extend/Bootstrap","common/main/lib/component/BaseView","common/main/lib/component/MenuItem","common/main/lib/component/Scroller"],function(){"use strict";Common.UI.Menu=function(){var t=function(){var t=[],e={};return{register:function(i){e[i.id]=i,i.on("show:after",function(e){t.push(e)}).on("hide:after",function(e){var i=t.indexOf(e);i>-1&&t.splice(i,1)})},unregister:function(i){var n=t.indexOf(i);delete e[i.id],n>-1&&t.splice(n,1),i.off("show:after").off("hide:after")},hideAll:function(){return Common.NotificationCenter.trigger("menumanager:hideall"),!!(t&&t.length>0)&&(_.each(t,function(t){t&&t.hide()}),!0)}}}();return _.extend(Common.UI.BaseView.extend({options:{cls:"",style:"",itemTemplate:null,items:[],menuAlign:"tl-bl",menuAlignEl:null,offset:[0,0],cyclic:!0,search:!1,scrollAlwaysVisible:!0},template:_.template([''].join("")),initialize:function(e){Common.UI.BaseView.prototype.initialize.call(this,e);var i=this;this.id=this.options.id||Common.UI.getId(),this.itemTemplate=this.options.itemTemplate||Common.UI.MenuItem.prototype.template,this.rendered=!1,this.items=[],this.offset=[0,0],this.menuAlign=this.options.menuAlign,this.menuAlignEl=this.options.menuAlignEl,this.scrollAlwaysVisible=this.options.scrollAlwaysVisible,this.search=this.options.search,this.options.restoreHeight&&(this.options.restoreHeight="number"==typeof this.options.restoreHeight?this.options.restoreHeight:this.options.maxHeight?this.options.maxHeight:1e5,!this.options.maxHeight&&(this.options.maxHeight=this.options.restoreHeight)),this.options.cyclic||(this.options.cls+=" no-cyclic"),_.each(this.options.items,function(t){t instanceof Common.UI.MenuItem?i.items.push(t):i.items.push(new Common.UI.MenuItem(_.extend({tagName:"li",template:i.itemTemplate},t)))}),this.options.el&&this.render(),t.register(this)},remove:function(){t.unregister(this),Common.UI.BaseView.prototype.remove.call(this)},render:function(t){var e=this;this.trigger("render:before",this),this.cmpEl=e.$el||$(this.el),t?(this.setElement(t,!1),e.rendered||(this.cmpEl=$(this.template({options:e.options})),t.append(this.cmpEl))):e.rendered||(this.cmpEl=this.template({options:e.options}),this.$el.append(this.cmpEl));var i=this.cmpEl.parent(),n="menu"===i.attr("role")?i:i.find("[role=menu]");return this.menuRoot=n,n&&(e.rendered||_.each(e.items||[],function(t){n.append(t.render().el),t.on("click",_.bind(e.onItemClick,e)),t.on("toggle",_.bind(e.onItemToggle,e))}),this.options.maxHeight&&(n.css({"max-height":e.options.maxHeight}),this.scroller=new Common.UI.Scroller({el:e.$el.find(".dropdown-menu "),minScrollbarLength:30,suppressScrollX:!0,alwaysVisibleY:this.scrollAlwaysVisible})),n.css({position:"fixed",right:"auto",left:-1e3,top:-1e3}),this.parentEl=n.parent(),this.parentEl.on("show.bs.dropdown",_.bind(e.onBeforeShowMenu,e)),this.parentEl.on("shown.bs.dropdown",_.bind(e.onAfterShowMenu,e)),this.parentEl.on("hide.bs.dropdown",_.bind(e.onBeforeHideMenu,e)),this.parentEl.on("hidden.bs.dropdown",_.bind(e.onAfterHideMenu,e)),this.parentEl.on("keydown.after.bs.dropdown",_.bind(e.onAfterKeydownMenu,e)),n.hover(function(t){e.isOver=!0},function(t){e.isOver=!1})),this.rendered=!0,this.trigger("render:after",this),this},isVisible:function(){return this.rendered&&this.cmpEl.is(":visible")},show:function(){this.rendered&&this.parentEl&&!this.parentEl.hasClass("open")&&this.cmpEl.dropdown("toggle")},hide:function(){this.rendered&&this.parentEl&&(this.parentEl.hasClass("open")?this.cmpEl.dropdown("toggle"):this.parentEl.hasClass("over")&&this.parentEl.removeClass("over"))},insertItem:function(t,e){var i=this;this.cmpEl;if(e instanceof Common.UI.MenuItem||(e=new Common.UI.MenuItem(_.extend({tagName:"li",template:i.itemTemplate},e))),t<0||t>=i.items.length?i.items.push(e):i.items.splice(t,0,e),this.rendered){var n=this.menuRoot;n&&(t<0?n.append(e.render().el):0===t?n.prepend(e.render().el):n.children("li:nth-child("+(t+1)+")").before(e.render().el),e.on("click",_.bind(i.onItemClick,i)),e.on("toggle",_.bind(i.onItemToggle,i)))}},addItem:function(t){this.insertItem(-1,t)},removeItem:function(t){var e=this,i=e.items.indexOf(t);i>-1&&(e.items.splice(i,1),t.off("click").off("toggle"),t.remove())},removeItems:function(t,e){if(!(t>this.items.length-1)){t+e>this.items.length&&(e=this.items.length-t);for(var i=t;i li:first"),n=i.length?i.outerHeight():1;this.wheelSpeed=Math.min(Math.floor(e.height()/n)*n/10,20)}this.scroller.update({alwaysVisibleY:this.scrollAlwaysVisible,wheelSpeed:this.wheelSpeed});var o=e.find("> li .checked");if(o.length){var s=o.position().top,n=o.outerHeight(),a=e.outerHeight();if(s<0||s+n>a){var r=e.scrollTop()+s+(n-a)/2;r=Math.floor(r/n)*n,e.scrollTop(r)}setTimeout(function(){o.focus()},1)}}this._search={}},onBeforeHideMenu:function(t){this.trigger("hide:before",this,t),Common.UI.Scroller.isMouseCapture()&&t.preventDefault()},onAfterHideMenu:function(t,e){this.trigger("hide:after",this,t,e),Common.NotificationCenter.trigger("menu:hide",this,e)},onAfterKeydownMenu:function(t){if(this.trigger("keydown:before",this,t),!t.isDefaultPrevented())if(t.keyCode==Common.UI.Keys.RETURN){var e=$(t.target).closest("li");if(e.length<=0&&(e=$(t.target).parent().find("li .dataview")),e.length>0&&e.click(),e.hasClass("dropdown-submenu")||Common.UI.Menu.Manager.hideAll(),$(t.currentTarget).closest("li").hasClass("dropdown-submenu"))return t.stopPropagation(),!1}else if(t.keyCode==Common.UI.Keys.UP||t.keyCode==Common.UI.Keys.DOWN)this.fromKeyDown=!0;else if(t.keyCode==Common.UI.Keys.ESC);else if(this.search&&t.keyCode>64&&t.keyCode<91&&t.key){var i=this;if(clearTimeout(this._search.timer),this._search.timer=setTimeout(function(){i._search={}},1e3),!this._search.text&&(this._search.text=""),!this._search.char&&(this._search.char=t.key),this._search.char!==t.key&&(this._search.full=!0),this._search.text+=t.key,void 0===this._search.index){var n=this.menuRoot.find("> li").find("> a");this._search.index=n.index(n.filter(":focus"))}this.selectCandidate()}},selectCandidate:function(){for(var t,e,i=this._search.index||0,n=new RegExp("^"+(this._search.full?this._search.text:this._search.char),"i"),o=0;oi)){t=s,e=o;break}}if(t){this._search.index=e;var s=t.cmpEl.find("a");if(this.scroller){this.scroller.update({alwaysVisibleY:this.scrollAlwaysVisible,wheelSpeed:this.wheelSpeed});var a=s.position().top,r=s.outerHeight(),l=this.menuRoot.outerHeight();if(a<0||a+r>l){var c=this.menuRoot.scrollTop()+a;c=Math.floor(c/r)*r,this.menuRoot.scrollTop(c)}}s.focus()}},onItemClick:function(t,e){if(t.menu||(this.isOver=!1),t.options.stopPropagation){e.stopPropagation();var i=this;return void _.delay(function(){i.$el.parent().parent().find("[data-toggle=dropdown]").focus()},10)}this.trigger("item:click",this,t,e)},onItemToggle:function(t,e,i){this.trigger("item:toggle",this,t,e,i)},setOffset:function(t,e){this.offset[0]=_.isUndefined(t)?this.offset[0]:t,this.offset[1]=_.isUndefined(e)?this.offset[1]:e,this.alignPosition()},getOffset:function(){return this.offset},alignPosition:function(t,e){var i=this.menuRoot,n=this.menuAlignEl||i.parent(),o=this.menuAlign.match(/^([a-z]+)-([a-z]+)/),s=n.offset(),a=Common.Utils.innerWidth()-10,r=Common.Utils.innerHeight()-10,l=i.outerWidth(),c=i.outerHeight(),d=n.outerWidth(),h=n.outerHeight(),p={tl:[0,0],bl:[0,c],tr:[l,0],br:[l,c]},m={tl:[0,0],tr:[d,0],bl:[0,h],br:[d,h]},u=s.left-p[o[1]][0]+m[o[2]][0]+this.offset[0],g=s.top-p[o[1]][1]+m[o[2]][1]+this.offset[1];if(u+l>a&&(u=n.is("li.dropdown-submenu")?s.left-l+2:a-l),u<0&&(u=0),this.options.restoreHeight)"number"==typeof this.options.restoreHeight&&(g+c>r?(i.css("max-height",r-g+"px"),!this.scroller&&(this.scroller=new Common.UI.Scroller({el:this.$el.find(".dropdown-menu "),minScrollbarLength:30,suppressScrollX:!0,alwaysVisibleY:this.scrollAlwaysVisible})),this.wheelSpeed=void 0):g+cr+b.top&&(t&&"string"==typeof t?(o=t.match(/^([a-z]+)-([a-z]+)/),g=s.top-p[o[1]][1]+m[o[2]][1]+this.offset[1]+(e||0)):g=r-c),g',"<% _.each(items, function(item) { %>","<% if (!item.id) item.id = Common.UI.getId(); %>","<% item.checked = item.checked || false; %>","
  • <%= itemTemplate(item) %>
  • ","<% }) %>",""].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);this.id=this.options.id||Common.UI.getId(),this.itemTemplate=this.options.itemTemplate||_.template([' style="<%= style %>" <% } %>','<% if(typeof canFocused !== "undefined") { %> tabindex="-1" type="menuitem" <% } %>','<% if(typeof stopPropagation !== "undefined") { %> data-stopPropagation="true" <% } %>','class="<% if (checked) { %> checked <% } %>" >','<% if (typeof iconCls !== "undefined") { %>','',"<% } %>","<%= caption %>",""].join("")),this.rendered=!1,this.items=this.options.items||[],this.offset=[0,0],this.menuAlign=this.options.menuAlign,this.menuAlignEl=this.options.menuAlignEl,this.scrollAlwaysVisible=this.options.scrollAlwaysVisible,this.search=this.options.search,this.options.restoreHeight&&(this.options.restoreHeight="number"==typeof this.options.restoreHeight?this.options.restoreHeight:this.options.maxHeight?this.options.maxHeight:1e5,!this.options.maxHeight&&(this.options.maxHeight=this.options.restoreHeight)),this.options.cyclic||(this.options.cls+=" no-cyclic"),this.options.el&&this.render(),Common.UI.Menu.Manager.register(this)},remove:function(){Common.UI.Menu.Manager.unregister(this),Common.UI.BaseView.prototype.remove.call(this)},render:function(t){var e=this;this.trigger("render:before",this),this.cmpEl=e.$el||$(this.el),t&&this.setElement(t,!1),e.rendered||(this.cmpEl=$(this.template({items:e.items,itemTemplate:e.itemTemplate,options:e.options})),t?t.append(this.cmpEl):this.$el.append(this.cmpEl));var i=this.cmpEl.parent(),n="menu"===i.attr("role")?i:i.find("[role=menu]");return this.menuRoot=n,n&&(e.rendered||(n.on("click","li",_.bind(e.onItemClick,e)),n.on("mousedown","li",_.bind(e.onItemMouseDown,e))),this.options.maxHeight&&(n.css({"max-height":e.options.maxHeight}),this.scroller=new Common.UI.Scroller({el:e.$el.find(".dropdown-menu "),minScrollbarLength:30,suppressScrollX:!0,alwaysVisibleY:this.scrollAlwaysVisible})),n.css({position:"fixed",right:"auto",left:-1e3,top:-1e3}),this.parentEl=n.parent(),this.parentEl.on("show.bs.dropdown",_.bind(e.onBeforeShowMenu,e)),this.parentEl.on("shown.bs.dropdown",_.bind(e.onAfterShowMenu,e)),this.parentEl.on("hide.bs.dropdown",_.bind(e.onBeforeHideMenu,e)),this.parentEl.on("hidden.bs.dropdown",_.bind(e.onAfterHideMenu,e)),this.parentEl.on("keydown.after.bs.dropdown",_.bind(e.onAfterKeydownMenu,e)),n.hover(function(t){e.isOver=!0},function(t){e.isOver=!1})),this.rendered=!0,this.trigger("render:after",this),this},resetItems:function(t){this.items=t||[],this.$items=null;var e=_.template(["<% _.each(items, function(item) { %>","<% if (!item.id) item.id = Common.UI.getId(); %>","<% item.checked = item.checked || false; %>","
  • <%= itemTemplate(item) %>
  • ","<% }) %>"].join(""));this.cmpEl&&this.cmpEl.html(e({items:this.items,itemTemplate:this.itemTemplate,options:this.options}))},isVisible:function(){return this.rendered&&this.cmpEl.is(":visible")},show:function(){this.rendered&&this.parentEl&&!this.parentEl.hasClass("open")&&this.cmpEl.dropdown("toggle")},hide:function(){this.rendered&&this.parentEl&&(this.parentEl.hasClass("open")?this.cmpEl.dropdown("toggle"):this.parentEl.hasClass("over")&&this.parentEl.removeClass("over"))},onItemClick:function(t){if(1!=t.which&&void 0!==t.which)return!1;var e=$(t.currentTarget).closest("li").index(),i=e>=0?this.items[e]:null;if(i){if(i.disabled)return!1;if(i.checkable&&!i.checked&&this.setChecked(e,!i.checked),this.isOver=!1,i.stopPropagation){t.stopPropagation();var n=this;return void _.delay(function(){n.$el.parent().parent().find("[data-toggle=dropdown]").focus()},10)}this.trigger("item:click",this,i,t)}},onItemMouseDown:function(t){if(1!=t.which)return t.preventDefault(),t.stopPropagation(),!1;t.stopPropagation()},setChecked:function(t,e,i){this.toggle(t,e,i)},toggle:function(t,e,i){var n=!!e,o=this.items[t];if(this.clearAll(),o&&o.checkable){if(o.checked=n,this.rendered){var s=o.el||this.cmpEl.find("#"+o.id);s&&(s.toggleClass("checked",o.checked),_.isEmpty(o.iconCls)||s.css("background-image","none"))}i||this.trigger("item:toggle",this,o,n)}},setDisabled:function(t){this.disabled=!!t,this.rendered&&this.cmpEl.toggleClass("disabled",this.disabled)},isDisabled:function(){return this.disabled},onBeforeShowMenu:function(t){Common.NotificationCenter.trigger("menu:show"),this.trigger("show:before",this,t),this.alignPosition()},onAfterShowMenu:function(t){if(this.trigger("show:after",this,t),this.scroller){this.scroller.update({alwaysVisibleY:this.scrollAlwaysVisible});var e=this.menuRoot,i=e.find("> li .checked");if(i.length){var n=i.position().top,o=i.outerHeight(),s=e.outerHeight();if(n<0||n+o>s){var a=e.scrollTop()+n+(o-s)/2;a=Math.floor(a/o)*o,e.scrollTop(a)}setTimeout(function(){i.focus()},1)}}if(this._search={},this.search&&!this.$items){var r=this;this.$items=this.menuRoot.find("> li").find("> a"),_.each(this.$items,function(t,e){r.items[e].el=$(t)})}},onBeforeHideMenu:function(t){this.trigger("hide:before",this,t),Common.UI.Scroller.isMouseCapture()&&t.preventDefault()},onAfterHideMenu:function(t,e){this.trigger("hide:after",this,t,e),Common.NotificationCenter.trigger("menu:hide",this,e)},onAfterKeydownMenu:function(t){if(t.keyCode==Common.UI.Keys.RETURN){var e=$(t.target).closest("li");if(e.length<=0&&(e=$(t.target).parent().find("li .dataview")),e.length>0&&e.click(),e.hasClass("dropdown-submenu")||Common.UI.Menu.Manager.hideAll(),$(t.currentTarget).closest("li").hasClass("dropdown-submenu"))return t.stopPropagation(),!1}else if(t.keyCode==Common.UI.Keys.UP||t.keyCode==Common.UI.Keys.DOWN)this.fromKeyDown=!0;else if(t.keyCode==Common.UI.Keys.ESC);else if(this.search&&t.keyCode>64&&t.keyCode<91&&t.key){var i=this;clearTimeout(this._search.timer),this._search.timer=setTimeout(function(){i._search={}},1e3),!this._search.text&&(this._search.text=""),!this._search.char&&(this._search.char=t.key),this._search.char!==t.key&&(this._search.full=!0),this._search.text+=t.key,void 0===this._search.index&&(this._search.index=this.$items.index(this.$items.filter(":focus"))),this.selectCandidate()}},selectCandidate:function(){for(var t,e,i=this._search.index||0,n=new RegExp("^"+(this._search.full?this._search.text:this._search.char),"i"),o=0;oi)){t=s,e=o;break}}if(t){this._search.index=e;var s=t.el;if(this.scroller){this.scroller.update({alwaysVisibleY:this.scrollAlwaysVisible});var a=s.position().top,r=s.outerHeight(),l=this.menuRoot.outerHeight();if(a<0||a+r>l){var c=this.menuRoot.scrollTop()+a;c=Math.floor(c/r)*r,this.menuRoot.scrollTop(c)}}s.focus()}},setOffset:function(t,e){this.offset[0]=_.isUndefined(t)?this.offset[0]:t,this.offset[1]=_.isUndefined(e)?this.offset[1]:e,this.alignPosition()},getOffset:function(){return this.offset},alignPosition:function(t,e){var i=this.menuRoot,n=this.menuAlignEl||i.parent(),o=this.menuAlign.match(/^([a-z]+)-([a-z]+)/),s=n.offset(),a=Common.Utils.innerWidth(),r=Common.Utils.innerHeight()-10,l=i.outerWidth(),c=i.outerHeight(),d=n.outerWidth(),h=n.outerHeight(),p={tl:[0,0],bl:[0,c],tr:[l,0],br:[l,c]},m={tl:[0,0],tr:[d,0],bl:[0,h],br:[d,h]},u=s.left-p[o[1]][0]+m[o[2]][0]+this.offset[0],g=s.top-p[o[1]][1]+m[o[2]][1]+this.offset[1];u+l>a&&(u=n.is("li.dropdown-submenu")?s.left-l+2:a-l),this.options.restoreHeight?"number"==typeof this.options.restoreHeight&&(g+c>r?(i.css("max-height",r-g+"px"),!this.scroller&&(this.scroller=new Common.UI.Scroller({el:this.$el.find(".dropdown-menu "),minScrollbarLength:30,suppressScrollX:!0,alwaysVisibleY:this.scrollAlwaysVisible}))):g+cr&&(t&&"string"==typeof t?(o=t.match(/^([a-z]+)-([a-z]+)/),g=s.top-p[o[1]][1]+m[o[2]][1]+this.offset[1]+(e||0)):g=r-c),g<0&&(g=0)),this.options.additionalAlign?this.options.additionalAlign.call(this,i,u,g):i.css({left:Math.ceil(u),top:Math.ceil(g)})},clearAll:function(){this.cmpEl&&this.cmpEl.find("li > a.checked").removeClass("checked"),_.each(this.items,function(t){t.checked=!1})}})}),void 0===Common)var Common={};if(define("common/main/lib/component/Calendar",["common/main/lib/component/BaseView","common/main/lib/util/utils"],function(){"use strict";Common.UI.Calendar=Common.UI.BaseView.extend(_.extend({template:_.template(['
    ','
    ','
    ','
    ','
    ','
    ',"
    ",'
    ',"
    ","
    ",'
    ',"
    "].join("")),options:{date:void 0,firstday:0},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.monthNames=[this.textJanuary,this.textFebruary,this.textMarch,this.textApril,this.textMay,this.textJune,this.textJuly,this.textAugust,this.textSeptember,this.textOctober,this.textNovember,this.textDecember],this.dayNamesShort=[this.textShortSunday,this.textShortMonday,this.textShortTuesday,this.textShortWednesday,this.textShortThursday,this.textShortFriday,this.textShortSaturday],this.monthShortNames=[this.textShortJanuary,this.textShortFebruary,this.textShortMarch,this.textShortApril,this.textShortMay,this.textShortJune,this.textShortJuly,this.textShortAugust,this.textShortSeptember,this.textShortOctober,this.textShortNovember,this.textShortDecember],e.options.date=t.date,_.isUndefined(t.firstday)||0!==t.firstday&&1!==t.firstday||(e.options.firstday=t.firstday),e.enableKeyEvents=e.options.enableKeyEvents,e._state=void 0,e.render()},render:function(){var t=this;return t.cmpEl=t.$el||$(this.el),t.cmpEl.html(this.template()),t.currentDate=t.options.date||new Date,t.btnPrev=new Common.UI.Button({parentEl:t.cmpEl.find("#prev-arrow"),cls:"",iconCls:"arrow-prev img-commonctrl"}),t.btnPrev.on("click",_.bind(t.onClickPrev,t)),t.btnNext=new Common.UI.Button({parentEl:t.cmpEl.find("#next-arrow"),cls:"",iconCls:"arrow-next img-commonctrl"}),t.btnNext.on("click",_.bind(t.onClickNext,t)),t.cmpEl.on("keydown",function(e){t.trigger("calendar:keydown",t,e)}),t.renderMonth(t.currentDate),this.trigger("render:after",this),this},onClickPrev:function(){var t=this;if(0===t._state){var e=new Date(t.currentDate);e.setMonth(e.getMonth()-1),e.getFullYear()>0&&t.renderMonth(e)}else if(1===t._state){var e=new Date(t.currentDate);e.setFullYear(e.getFullYear()-1),e.getFullYear()>0&&t.renderMonths(e)}else if(2===t._state){var i,n=t.currentDate.getFullYear();n%10!=0?(i=String(n),i=Number(i.slice(0,-1)+"0")-1):i=n-1,i>0&&(t.currentDate.setFullYear(i),t.renderYears(i))}},onClickNext:function(){var t=this;if(0===t._state){var e=new Date(t.currentDate);e.setMonth(e.getMonth()+1),e.getFullYear()>0&&t.renderMonth(e)}else if(1===t._state){var e=new Date(t.currentDate);e.setFullYear(e.getFullYear()+1),e.getFullYear()>0&&t.renderMonths(e)}else if(2===t._state){var i,n=t.currentDate.getFullYear();n%10!=9?(i=String(n),i=Number(i.slice(0,-1)+"9")+1):i=n+1,i>0&&(t.currentDate.setFullYear(i),t.renderYears(i))}},renderYears:function(t){var e=this,t=_.isNumber(t)?t:e.currentDate?e.currentDate.getFullYear():(new Date).getFullYear();e._state=2;var i=t,n=t;if(i%10!=0){var o=String(t);i=Number(o.slice(0,-1)+"0")}if(n%10!=9){var o=String(t);n=Number(o.slice(0,-1)+"9")}e.topTitle=_.template([""].join("")),e.cmpEl.find(".calendar-header .title").html(e.topTitle),e.bottomTitle=_.template([""].join("")),e.cmpEl.find(".calendar-header .bottom-row").html(e.bottomTitle);for(var s=[],a=i-3,r=0;r<16;r++)s.push({year:a>0?a:"",isCurrentDecade:a>=i&&a<=n,disabled:!(a>0),selected:_.isDate(e.selectedDate)?a===e.selectedDate.getFullYear():a===(new Date).getFullYear()}),a++;e.yearPicker?e.yearPicker.store.reset(s):(e.yearPicker=new Common.UI.DataView({el:e.cmpEl.find(".calendar-content"),store:new Common.UI.DataViewStore(s),itemTemplate:_.template('
    <%= year %>
    ')}),e.yearPicker.on("item:click",function(t,i,n,o){var s=n.get("year"),a=new Date;a.setFullYear(s),e.renderMonths(a)}),e.enableKeyEvents&&this.yearPicker.on("item:keydown",function(t,e,i){i.keyCode==Common.UI.Keys.ESC&&Common.NotificationCenter.trigger("dataview:blur")})),e.enableKeyEvents&&_.delay(function(){e.monthPicker.focus()},10)},renderMonths:function(t){var e=this,i=_.isDate(t)?t:e.currentDate?e.currentDate:new Date,n=i.getFullYear();e._state=1,e.currentDate=i,e.topTitle=_.template(['
    "].join("")),e.cmpEl.find(".calendar-header .title").html(e.topTitle),e.cmpEl.find(".calendar-header .title").off(),e.cmpEl.find(".calendar-header .title").on("click",_.bind(e.renderYears,e)),e.bottomTitle=_.template([""].join("")),e.cmpEl.find(".calendar-header .bottom-row").html(e.bottomTitle);for(var o=[],s=new Date,a=0;a<12;a++)o.push({indexMonth:a,nameMonth:e.monthShortNames[a],year:n,curYear:!0,isCurrentMonth:a===i.getMonth(),selected:_.isDate(e.selectedDate)?a===e.selectedDate.getMonth()&&n===e.selectedDate.getFullYear():a===s.getMonth()&&n===s.getFullYear()});n+=1;for(var a=0;a<4;a++)o.push({indexMonth:a,nameMonth:e.monthShortNames[a],year:n,curYear:!1,selected:_.isDate(e.selectedDate)?a===e.selectedDate.getMonth()&&n===e.selectedDate.getFullYear():a===s.getMonth()&&n===s.getFullYear()});e.monthsPicker?e.monthsPicker.store.reset(o):(e.monthsPicker=new Common.UI.DataView({el:e.cmpEl.find(".calendar-content"),store:new Common.UI.DataViewStore(o),itemTemplate:_.template('
    <%= nameMonth %>
    ')}),e.monthsPicker.on("item:click",function(t,i,n,o){var s=n.get("indexMonth"),a=n.get("year"),r=new Date;r.setFullYear(a,s),e.renderMonth(r)}),e.enableKeyEvents&&this.monthsPicker.on("item:keydown",function(t,e,i){i.keyCode==Common.UI.Keys.ESC&&Common.NotificationCenter.trigger("dataview:blur")})), +this.viewport.hlayout.doLayout();break;case"leftmenu":var e=this.viewport.hlayout.items[0];e.resize.el&&(e.el.width()>40?(this.boxSdk.css("border-left",""),e.resize.el.show()):(e.resize.el.hide(),this.boxSdk.css("border-left","0 none"))),this.viewport.hlayout.doLayout();break;case"header":case"toolbar":case"status":this.viewport.vlayout.doLayout()}this.api.Resize()},onWindowResize:function(t){this.onLayoutChanged("window"),Common.NotificationCenter.trigger("window:resize")},onFileMenu:function(t){var e=this,i="show"==t;e.header.lockHeaderBtns("undo",i),e.header.lockHeaderBtns("redo",i),e.header.lockHeaderBtns("opts",i),e.header.lockHeaderBtns("users",i)},onApiZoomChange:function(t,e){this.header.mnuitemFitPage.setChecked(2==e,!0),this.header.mnuitemFitWidth.setChecked(1==e,!0),this.header.mnuZoom.options.value=t,this.header.mnuZoom.$el&&$(".menu-zoom label.zoom",this.header.mnuZoom.$el).html(t+"%")},onOptionsItemClick:function(t,e,i){var n=this;switch(e.value){case"toolbar":n.header.fireEvent("toolbar:setcompact",[t,e.isChecked()]);break;case"statusbar":n.header.fireEvent("statusbar:hide",[e,e.isChecked()]);break;case"rulers":n.api.asc_SetViewRulers(!e.isChecked()),Common.localStorage.setBool("de-hidden-rulers",e.isChecked()),Common.NotificationCenter.trigger("layout:changed","rulers"),Common.NotificationCenter.trigger("edit:complete",n.header);break;case"zoom:page":e.isChecked()?n.api.zoomFitToPage():n.api.zoomCustomMode(),Common.NotificationCenter.trigger("edit:complete",n.header);break;case"zoom:width":e.isChecked()?n.api.zoomFitToWidth():n.api.zoomCustomMode(),Common.NotificationCenter.trigger("edit:complete",n.header);break;case"advanced":n.header.fireEvent("file:settings",n.header)}},onApiCoAuthoringDisconnect:function(t){this.header&&(this.header.btnDownload&&!t&&this.header.btnDownload.hide(),this.header.btnPrint&&!t&&this.header.btnPrint.hide(),this.header.btnEdit&&this.header.btnEdit.hide())},textFitPage:"Fit to Page",textFitWidth:"Fit to Width"},DE.Controllers.Viewport))}),$(document).off("keydown.bs.dropdown.data-api").on("keydown.bs.dropdown.data-api","[data-toggle=dropdown], [role=menu]",onDropDownKeyDown),"ontouchstart"in document.documentElement&&$(document).on("click.bs.dropdown.data-api","[data-toggle=dropdown]",toggle),function(){function t(t){1!=t.which&&void 0!=t.which||clearMenus(/form-control/.test(t.target.className))}var e,i=$._data($(document).get(0),"events");i&&i.click&&i.click.every(function(t,i,n){return/click/.test(t.type)&&!t.selector&&/bs\..+\.dropdown/.test(t.namespace)&&(e=t.handler),!e}),e&&$(document).off("click.bs.dropdown.data-api",e).on("click.bs.dropdown.data-api",t)}(),define("common/main/lib/extend/Bootstrap",function(){}),void 0===Common)var Common={};if(define("common/main/lib/component/MenuItem",["common/main/lib/component/BaseView","common/main/lib/component/ToggleManager"],function(){"use strict";Common.UI.MenuItem=Common.UI.BaseView.extend({options:{id:null,cls:"",style:"",hint:!1,checkable:!1,checked:!1,allowDepress:!1,disabled:!1,value:null,toggleGroup:null,iconCls:"",menu:null,canFocused:!0},tagName:"li",template:_.template([' tabindex="-1" type="menuitem" <% }; if(!_.isUndefined(options.stopPropagation)) { %> data-stopPropagation="true" <% }; %> >',"<% if (!_.isEmpty(iconCls)) { %>",'',"<% } %>","<%= caption %>",""].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.id=e.options.id||Common.UI.getId(),this.cls=e.options.cls,this.style=e.options.style,this.caption=e.options.caption,this.menu=e.options.menu||null,this.checkable=e.options.checkable,this.checked=e.options.checked,e.allowDepress=e.options.allowDepress,this.disabled=e.options.disabled,this.value=e.options.value,this.toggleGroup=e.options.toggleGroup,this.template=e.options.template||this.template,this.iconCls=e.options.iconCls,this.hint=e.options.hint,this.rendered=!1,null===this.menu||this.menu instanceof Common.UI.Menu||this.menu instanceof Common.UI.MenuSimple||(this.menu=new Common.UI.Menu(_.extend({},e.options.menu))),e.options.el&&this.render()},render:function(){var t=this,e=t.$el||$(this.el);if(t.trigger("render:before",t),"--"===t.caption)e.addClass("divider");else if(!this.rendered){e.off("click"),Common.UI.ToggleManager.unregister(t),e.html(this.template({id:t.id,cls:t.cls,caption:t.caption,iconCls:t.iconCls,style:t.style,options:t.options})),t.menu&&(e.addClass("dropdown-submenu"),t.menu.render(e),e.mouseenter(_.bind(t.menu.alignPosition,t.menu)),e.focusout(_.bind(t.onBlurItem,t)),e.hover(_.bind(t.onHoverItem,t),_.bind(t.onUnHoverItem,t)));var i=e.children(":first");this.checkable&&i&&(i.toggleClass("checkable",this.checkable),i.toggleClass("no-checkmark",!1===this.options.checkmark),i.toggleClass("checked",this.checked),_.isEmpty(this.iconCls)||i.css("background-image","none")),t.options.hint&&(e.attr("data-toggle","tooltip"),e.tooltip({title:t.options.hint,placement:t.options.hintAnchor||function(t,e){var i=this.getPosition(),n=t.offsetWidth,o=t.offsetHeight,s=Common.Utils.innerWidth(),a=Common.Utils.innerHeight(),r=i.top,l=i.left+i.width+2;r+o>a&&(r=a-o-2),l+n>s&&(l=i.left-n-2),$(t).offset({top:r,left:l}).addClass("in")}})),this.disabled&&e.toggleClass("disabled",this.disabled),e.on("click",_.bind(this.onItemClick,this)),e.on("mousedown",_.bind(this.onItemMouseDown,this)),Common.UI.ToggleManager.register(t)}return t.cmpEl=e,t.rendered=!0,t.trigger("render:after",t),this},setCaption:function(t,e){this.caption=t,this.rendered&&(this.cmpEl.find("a").contents().last()[0].textContent=e?t:Common.Utils.String.htmlEncode(t))},setIconCls:function(t){if(this.rendered&&!_.isEmpty(this.iconCls)){var e=this.cmpEl.children(":first");e&&e.find(".menu-item-icon").removeClass(this.iconCls).addClass(t)}this.iconCls=t},setChecked:function(t,e){this.toggle(t,e)},isChecked:function(){return this.checked},setDisabled:function(t){this.disabled=!!t,this.rendered&&this.cmpEl.toggleClass("disabled",this.disabled)},isDisabled:function(){return this.disabled},toggle:function(t,e){var i=void 0===t?!this.checked:!!t;if(this.checkable){if(this.checked=i,this.rendered){var n=this.cmpEl.children(":first");n&&(n.toggleClass("checked",this.checked),_.isEmpty(this.iconCls)||n.css("background-image","none"))}e||this.trigger("toggle",this,i)}},onItemMouseDown:function(t){if(1!=t.which)return t.preventDefault(),t.stopPropagation(),!1;t.stopPropagation()},onItemClick:function(t){return(1==t.which||void 0===t.which&&!this.menu)&&(this.disabled||!this.allowDepress&&this.checked&&this.toggleGroup||this.menu||this.setChecked(!this.checked),this.menu?t.target.id!=this.id&&void(this.menu.isOver||this.cmpEl.removeClass("over")):!this.disabled&&void this.trigger("click",this,t))},onHoverItem:function(t){this._doHover(t)},onUnHoverItem:function(t){this._doUnHover(t)},onBlurItem:function(t){this._doUnHover(t)},_doHover:function(t){var e=this;e.menu&&!e.disabled&&(clearTimeout(e.hideMenuTimer),e.cmpEl.trigger("show.bs.dropdown"),e.expandMenuTimer=_.delay(function(){e.cmpEl.addClass("over"),e.cmpEl.trigger("shown.bs.dropdown")},200))},_doUnHover:function(t){var e=this;if(e.cmpEl.hasClass("dropdown-submenu")&&e.cmpEl.hasClass("over")&&(t&&t.relatedTarget&&e.cmpEl.find(t.relatedTarget).length>0||e.cmpEl.hasClass("focused-submenu")))return void e.cmpEl.removeClass("focused-submenu");if(e.menu&&!e.disabled&&(clearTimeout(e.expandMenuTimer),e.hideMenuTimer=_.delay(function(){e.menu.isOver||e.cmpEl.removeClass("over")},200),t&&"focusout"!==t.type)){var i=e.cmpEl.children(":focus");i.length>0&&(i.blur(),e.cmpEl.closest("ul").focus())}}}),Common.UI.MenuItemSeparator=function(t){return t=t||{},t.caption="--",new Common.UI.MenuItem(t)}}),void 0===Common)var Common={};if(define("common/main/lib/component/Menu",["common/main/lib/extend/Bootstrap","common/main/lib/component/BaseView","common/main/lib/component/MenuItem","common/main/lib/component/Scroller"],function(){"use strict";Common.UI.Menu=function(){var t=function(){var t=[],e={};return{register:function(i){e[i.id]=i,i.on("show:after",function(e){t.push(e)}).on("hide:after",function(e){var i=t.indexOf(e);i>-1&&t.splice(i,1)})},unregister:function(i){var n=t.indexOf(i);delete e[i.id],n>-1&&t.splice(n,1),i.off("show:after").off("hide:after")},hideAll:function(){return Common.NotificationCenter.trigger("menumanager:hideall"),!!(t&&t.length>0)&&(_.each(t,function(t){t&&t.hide()}),!0)}}}();return _.extend(Common.UI.BaseView.extend({options:{cls:"",style:"",itemTemplate:null,items:[],menuAlign:"tl-bl",menuAlignEl:null,offset:[0,0],cyclic:!0,search:!1,scrollAlwaysVisible:!0},template:_.template([''].join("")),initialize:function(e){Common.UI.BaseView.prototype.initialize.call(this,e);var i=this;this.id=this.options.id||Common.UI.getId(),this.itemTemplate=this.options.itemTemplate||Common.UI.MenuItem.prototype.template,this.rendered=!1,this.items=[],this.offset=[0,0],this.menuAlign=this.options.menuAlign,this.menuAlignEl=this.options.menuAlignEl,this.scrollAlwaysVisible=this.options.scrollAlwaysVisible,this.search=this.options.search,this.options.restoreHeight&&(this.options.restoreHeight="number"==typeof this.options.restoreHeight?this.options.restoreHeight:this.options.maxHeight?this.options.maxHeight:1e5,!this.options.maxHeight&&(this.options.maxHeight=this.options.restoreHeight)),this.options.cyclic||(this.options.cls+=" no-cyclic"),_.each(this.options.items,function(t){t instanceof Common.UI.MenuItem?i.items.push(t):i.items.push(new Common.UI.MenuItem(_.extend({tagName:"li",template:i.itemTemplate},t)))}),this.options.el&&this.render(),t.register(this)},remove:function(){t.unregister(this),Common.UI.BaseView.prototype.remove.call(this)},render:function(t){var e=this;this.trigger("render:before",this),this.cmpEl=e.$el||$(this.el),t?(this.setElement(t,!1),e.rendered||(this.cmpEl=$(this.template({options:e.options})),t.append(this.cmpEl))):e.rendered||(this.cmpEl=this.template({options:e.options}),this.$el.append(this.cmpEl));var i=this.cmpEl.parent(),n="menu"===i.attr("role")?i:i.find("[role=menu]");return this.menuRoot=n,n&&(e.rendered||_.each(e.items||[],function(t){n.append(t.render().el),t.on("click",_.bind(e.onItemClick,e)),t.on("toggle",_.bind(e.onItemToggle,e))}),this.options.maxHeight&&(n.css({"max-height":e.options.maxHeight}),this.scroller=new Common.UI.Scroller({el:e.$el.find(".dropdown-menu "),minScrollbarLength:30,suppressScrollX:!0,alwaysVisibleY:this.scrollAlwaysVisible})),n.css({position:"fixed",right:"auto",left:-1e3,top:-1e3}),this.parentEl=n.parent(),this.parentEl.on("show.bs.dropdown",_.bind(e.onBeforeShowMenu,e)),this.parentEl.on("shown.bs.dropdown",_.bind(e.onAfterShowMenu,e)),this.parentEl.on("hide.bs.dropdown",_.bind(e.onBeforeHideMenu,e)),this.parentEl.on("hidden.bs.dropdown",_.bind(e.onAfterHideMenu,e)),this.parentEl.on("keydown.after.bs.dropdown",_.bind(e.onAfterKeydownMenu,e)),n.hover(function(t){e.isOver=!0},function(t){e.isOver=!1})),this.rendered=!0,this.trigger("render:after",this),this},isVisible:function(){return this.rendered&&this.cmpEl.is(":visible")},show:function(){this.rendered&&this.parentEl&&!this.parentEl.hasClass("open")&&this.cmpEl.dropdown("toggle")},hide:function(){this.rendered&&this.parentEl&&(this.parentEl.hasClass("open")?this.cmpEl.dropdown("toggle"):this.parentEl.hasClass("over")&&this.parentEl.removeClass("over"))},insertItem:function(t,e){var i=this;this.cmpEl;if(e instanceof Common.UI.MenuItem||(e=new Common.UI.MenuItem(_.extend({tagName:"li",template:i.itemTemplate},e))),t<0||t>=i.items.length?i.items.push(e):i.items.splice(t,0,e),this.rendered){var n=this.menuRoot;n&&(t<0?n.append(e.render().el):0===t?n.prepend(e.render().el):n.children("li:nth-child("+(t+1)+")").before(e.render().el),e.on("click",_.bind(i.onItemClick,i)),e.on("toggle",_.bind(i.onItemToggle,i)))}},addItem:function(t){this.insertItem(-1,t)},removeItem:function(t){var e=this,i=e.items.indexOf(t);i>-1&&(e.items.splice(i,1),t.off("click").off("toggle"),t.remove())},removeItems:function(t,e){if(!(t>this.items.length-1)){t+e>this.items.length&&(e=this.items.length-t);for(var i=t;i li:first"),n=i.length?i.outerHeight():1;this.wheelSpeed=Math.min(Math.floor(e.height()/n)*n/10,20)}this.scroller.update({alwaysVisibleY:this.scrollAlwaysVisible,wheelSpeed:this.wheelSpeed});var o=e.find("> li .checked");if(o.length){var s=o.position().top,n=o.outerHeight(),a=e.outerHeight();if(s<0||s+n>a){var r=e.scrollTop()+s+(n-a)/2;r=Math.floor(r/n)*n,e.scrollTop(r)}setTimeout(function(){o.focus()},1)}}this._search={}},onBeforeHideMenu:function(t){this.trigger("hide:before",this,t),Common.UI.Scroller.isMouseCapture()&&t.preventDefault()},onAfterHideMenu:function(t,e){this.trigger("hide:after",this,t,e),Common.NotificationCenter.trigger("menu:hide",this,e)},onAfterKeydownMenu:function(t){if(this.trigger("keydown:before",this,t),!t.isDefaultPrevented())if(t.keyCode==Common.UI.Keys.RETURN){var e=$(t.target).closest("li");if(e.length<=0&&(e=$(t.target).parent().find("li .dataview")),e.length>0&&e.click(),e.hasClass("dropdown-submenu")||Common.UI.Menu.Manager.hideAll(),$(t.currentTarget).closest("li").hasClass("dropdown-submenu"))return t.stopPropagation(),!1}else if(t.keyCode==Common.UI.Keys.UP||t.keyCode==Common.UI.Keys.DOWN)this.fromKeyDown=!0;else if(t.keyCode==Common.UI.Keys.ESC);else if(this.search&&t.keyCode>64&&t.keyCode<91&&t.key){var i=this;if(clearTimeout(this._search.timer),this._search.timer=setTimeout(function(){i._search={}},1e3),!this._search.text&&(this._search.text=""),!this._search.char&&(this._search.char=t.key),this._search.char!==t.key&&(this._search.full=!0),this._search.text+=t.key,void 0===this._search.index){var n=this.menuRoot.find("> li").find("> a");this._search.index=n.index(n.filter(":focus"))}this.selectCandidate()}},selectCandidate:function(){for(var t,e,i=this._search.index||0,n=new RegExp("^"+(this._search.full?this._search.text:this._search.char),"i"),o=0;oi)){t=s,e=o;break}}if(t){this._search.index=e;var s=t.cmpEl.find("a");if(this.scroller){this.scroller.update({alwaysVisibleY:this.scrollAlwaysVisible,wheelSpeed:this.wheelSpeed});var a=s.position().top,r=s.outerHeight(),l=this.menuRoot.outerHeight();if(a<0||a+r>l){var c=this.menuRoot.scrollTop()+a;c=Math.floor(c/r)*r,this.menuRoot.scrollTop(c)}}s.focus()}},onItemClick:function(t,e){if(t.menu||(this.isOver=!1),t.options.stopPropagation){e.stopPropagation();var i=this;return void _.delay(function(){i.$el.parent().parent().find("[data-toggle=dropdown]").focus()},10)}this.trigger("item:click",this,t,e)},onItemToggle:function(t,e,i){this.trigger("item:toggle",this,t,e,i)},setOffset:function(t,e){this.offset[0]=_.isUndefined(t)?this.offset[0]:t,this.offset[1]=_.isUndefined(e)?this.offset[1]:e,this.alignPosition()},getOffset:function(){return this.offset},alignPosition:function(t,e){var i=this.menuRoot,n=this.menuAlignEl||i.parent(),o=this.menuAlign.match(/^([a-z]+)-([a-z]+)/),s=n.offset(),a=Common.Utils.innerWidth()-10,r=Common.Utils.innerHeight()-10,l=i.outerWidth(),c=i.outerHeight(),d=n.outerWidth(),h=n.outerHeight(),p={tl:[0,0],bl:[0,c],tr:[l,0],br:[l,c]},m={tl:[0,0],tr:[d,0],bl:[0,h],br:[d,h]},u=s.left-p[o[1]][0]+m[o[2]][0]+this.offset[0],g=s.top-p[o[1]][1]+m[o[2]][1]+this.offset[1];if(u+l>a&&(u=n.is("li.dropdown-submenu")?s.left-l+2:a-l),u<0&&(u=0),this.options.restoreHeight)"number"==typeof this.options.restoreHeight&&(g+c>r?(i.css("max-height",r-g+"px"),!this.scroller&&(this.scroller=new Common.UI.Scroller({el:this.$el.find(".dropdown-menu "),minScrollbarLength:30,suppressScrollX:!0,alwaysVisibleY:this.scrollAlwaysVisible})),this.wheelSpeed=void 0):g+cr+b.top&&(t&&"string"==typeof t?(o=t.match(/^([a-z]+)-([a-z]+)/),g=s.top-p[o[1]][1]+m[o[2]][1]+this.offset[1]+(e||0)):g=r-c),g',"<% _.each(items, function(item) { %>","<% if (!item.id) item.id = Common.UI.getId(); %>","<% item.checked = item.checked || false; %>","
  • <%= itemTemplate(item) %>
  • ","<% }) %>",""].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);this.id=this.options.id||Common.UI.getId(),this.itemTemplate=this.options.itemTemplate||_.template([' style="<%= style %>" <% } %>','<% if(typeof canFocused !== "undefined") { %> tabindex="-1" type="menuitem" <% } %>','<% if(typeof stopPropagation !== "undefined") { %> data-stopPropagation="true" <% } %>','class="<% if (checked) { %> checked <% } %>" >','<% if (typeof iconCls !== "undefined") { %>','',"<% } %>","<%= caption %>",""].join("")),this.rendered=!1,this.items=this.options.items||[],this.offset=[0,0],this.menuAlign=this.options.menuAlign,this.menuAlignEl=this.options.menuAlignEl,this.scrollAlwaysVisible=this.options.scrollAlwaysVisible,this.search=this.options.search,this.options.restoreHeight&&(this.options.restoreHeight="number"==typeof this.options.restoreHeight?this.options.restoreHeight:this.options.maxHeight?this.options.maxHeight:1e5,!this.options.maxHeight&&(this.options.maxHeight=this.options.restoreHeight)),this.options.cyclic||(this.options.cls+=" no-cyclic"),this.options.el&&this.render(),Common.UI.Menu.Manager.register(this)},remove:function(){Common.UI.Menu.Manager.unregister(this),Common.UI.BaseView.prototype.remove.call(this)},render:function(t){var e=this;this.trigger("render:before",this),this.cmpEl=e.$el||$(this.el),t&&this.setElement(t,!1),e.rendered||(this.cmpEl=$(this.template({items:e.items,itemTemplate:e.itemTemplate,options:e.options})),t?t.append(this.cmpEl):this.$el.append(this.cmpEl));var i=this.cmpEl.parent(),n="menu"===i.attr("role")?i:i.find("[role=menu]");return this.menuRoot=n,n&&(e.rendered||(n.on("click","li",_.bind(e.onItemClick,e)),n.on("mousedown","li",_.bind(e.onItemMouseDown,e))),this.options.maxHeight&&(n.css({"max-height":e.options.maxHeight}),this.scroller=new Common.UI.Scroller({el:e.$el.find(".dropdown-menu "),minScrollbarLength:30,suppressScrollX:!0,alwaysVisibleY:this.scrollAlwaysVisible})),n.css({position:"fixed",right:"auto",left:-1e3,top:-1e3}),this.parentEl=n.parent(),this.parentEl.on("show.bs.dropdown",_.bind(e.onBeforeShowMenu,e)),this.parentEl.on("shown.bs.dropdown",_.bind(e.onAfterShowMenu,e)),this.parentEl.on("hide.bs.dropdown",_.bind(e.onBeforeHideMenu,e)),this.parentEl.on("hidden.bs.dropdown",_.bind(e.onAfterHideMenu,e)),this.parentEl.on("keydown.after.bs.dropdown",_.bind(e.onAfterKeydownMenu,e)),n.hover(function(t){e.isOver=!0},function(t){e.isOver=!1})),this.rendered=!0,this.trigger("render:after",this),this},resetItems:function(t){this.items=t||[],this.$items=null;var e=_.template(["<% _.each(items, function(item) { %>","<% if (!item.id) item.id = Common.UI.getId(); %>","<% item.checked = item.checked || false; %>","
  • <%= itemTemplate(item) %>
  • ","<% }) %>"].join(""));this.cmpEl&&this.cmpEl.html(e({items:this.items,itemTemplate:this.itemTemplate,options:this.options}))},isVisible:function(){return this.rendered&&this.cmpEl.is(":visible")},show:function(){this.rendered&&this.parentEl&&!this.parentEl.hasClass("open")&&this.cmpEl.dropdown("toggle")},hide:function(){this.rendered&&this.parentEl&&(this.parentEl.hasClass("open")?this.cmpEl.dropdown("toggle"):this.parentEl.hasClass("over")&&this.parentEl.removeClass("over"))},onItemClick:function(t){if(1!=t.which&&void 0!==t.which)return!1;var e=$(t.currentTarget).closest("li").index(),i=e>=0?this.items[e]:null;if(i){if(i.disabled)return!1;if(i.checkable&&!i.checked&&this.setChecked(e,!i.checked),this.isOver=!1,i.stopPropagation){t.stopPropagation();var n=this;return void _.delay(function(){n.$el.parent().parent().find("[data-toggle=dropdown]").focus()},10)}this.trigger("item:click",this,i,t)}},onItemMouseDown:function(t){if(1!=t.which)return t.preventDefault(),t.stopPropagation(),!1;t.stopPropagation()},setChecked:function(t,e,i){this.toggle(t,e,i)},toggle:function(t,e,i){var n=!!e,o=this.items[t];if(this.clearAll(),o&&o.checkable){if(o.checked=n,this.rendered){var s=o.el||this.cmpEl.find("#"+o.id);s&&(s.toggleClass("checked",o.checked),_.isEmpty(o.iconCls)||s.css("background-image","none"))}i||this.trigger("item:toggle",this,o,n)}},setDisabled:function(t){this.disabled=!!t,this.rendered&&this.cmpEl.toggleClass("disabled",this.disabled)},isDisabled:function(){return this.disabled},onBeforeShowMenu:function(t){Common.NotificationCenter.trigger("menu:show"),this.trigger("show:before",this,t),this.alignPosition()},onAfterShowMenu:function(t){if(this.trigger("show:after",this,t),this.scroller){this.scroller.update({alwaysVisibleY:this.scrollAlwaysVisible});var e=this.menuRoot,i=e.find("> li .checked");if(i.length){var n=i.position().top,o=i.outerHeight(),s=e.outerHeight();if(n<0||n+o>s){var a=e.scrollTop()+n+(o-s)/2;a=Math.floor(a/o)*o,e.scrollTop(a)}setTimeout(function(){i.focus()},1)}}if(this._search={},this.search&&!this.$items){var r=this;this.$items=this.menuRoot.find("> li").find("> a"),_.each(this.$items,function(t,e){r.items[e].el=$(t)})}},onBeforeHideMenu:function(t){this.trigger("hide:before",this,t),Common.UI.Scroller.isMouseCapture()&&t.preventDefault()},onAfterHideMenu:function(t,e){this.trigger("hide:after",this,t,e),Common.NotificationCenter.trigger("menu:hide",this,e)},onAfterKeydownMenu:function(t){if(t.keyCode==Common.UI.Keys.RETURN){var e=$(t.target).closest("li");if(e.length<=0&&(e=$(t.target).parent().find("li .dataview")),e.length>0&&e.click(),e.hasClass("dropdown-submenu")||Common.UI.Menu.Manager.hideAll(),$(t.currentTarget).closest("li").hasClass("dropdown-submenu"))return t.stopPropagation(),!1}else if(t.keyCode==Common.UI.Keys.UP||t.keyCode==Common.UI.Keys.DOWN)this.fromKeyDown=!0;else if(t.keyCode==Common.UI.Keys.ESC);else if(this.search&&t.keyCode>64&&t.keyCode<91&&t.key){var i=this;clearTimeout(this._search.timer),this._search.timer=setTimeout(function(){i._search={}},1e3),!this._search.text&&(this._search.text=""),!this._search.char&&(this._search.char=t.key),this._search.char!==t.key&&(this._search.full=!0),this._search.text+=t.key,void 0===this._search.index&&(this._search.index=this.$items.index(this.$items.filter(":focus"))),this.selectCandidate()}},selectCandidate:function(){for(var t,e,i=this._search.index||0,n=new RegExp("^"+(this._search.full?this._search.text:this._search.char),"i"),o=0;oi)){t=s,e=o;break}}if(t){this._search.index=e;var s=t.el;if(this.scroller){this.scroller.update({alwaysVisibleY:this.scrollAlwaysVisible});var a=s.position().top,r=s.outerHeight(),l=this.menuRoot.outerHeight();if(a<0||a+r>l){var c=this.menuRoot.scrollTop()+a;c=Math.floor(c/r)*r,this.menuRoot.scrollTop(c)}}s.focus()}},setOffset:function(t,e){this.offset[0]=_.isUndefined(t)?this.offset[0]:t,this.offset[1]=_.isUndefined(e)?this.offset[1]:e,this.alignPosition()},getOffset:function(){return this.offset},alignPosition:function(t,e){var i=this.menuRoot,n=this.menuAlignEl||i.parent(),o=this.menuAlign.match(/^([a-z]+)-([a-z]+)/),s=n.offset(),a=Common.Utils.innerWidth(),r=Common.Utils.innerHeight()-10,l=i.outerWidth(),c=i.outerHeight(),d=n.outerWidth(),h=n.outerHeight(),p={tl:[0,0],bl:[0,c],tr:[l,0],br:[l,c]},m={tl:[0,0],tr:[d,0],bl:[0,h],br:[d,h]},u=s.left-p[o[1]][0]+m[o[2]][0]+this.offset[0],g=s.top-p[o[1]][1]+m[o[2]][1]+this.offset[1];u+l>a&&(u=n.is("li.dropdown-submenu")?s.left-l+2:a-l),this.options.restoreHeight?"number"==typeof this.options.restoreHeight&&(g+c>r?(i.css("max-height",r-g+"px"),!this.scroller&&(this.scroller=new Common.UI.Scroller({el:this.$el.find(".dropdown-menu "),minScrollbarLength:30,suppressScrollX:!0,alwaysVisibleY:this.scrollAlwaysVisible}))):g+cr&&(t&&"string"==typeof t?(o=t.match(/^([a-z]+)-([a-z]+)/),g=s.top-p[o[1]][1]+m[o[2]][1]+this.offset[1]+(e||0)):g=r-c),g<0&&(g=0)),this.options.additionalAlign?this.options.additionalAlign.call(this,i,u,g):i.css({left:Math.ceil(u),top:Math.ceil(g)})},clearAll:function(){this.cmpEl&&this.cmpEl.find("li > a.checked").removeClass("checked"),_.each(this.items,function(t){t.checked=!1})}})}),void 0===Common)var Common={};if(define("common/main/lib/component/Calendar",["common/main/lib/component/BaseView","common/main/lib/util/utils"],function(){"use strict";Common.UI.Calendar=Common.UI.BaseView.extend(_.extend({template:_.template(['
    ','
    ','
    ','
    ','
    ','
    ',"
    ",'
    ',"
    ","
    ",'
    ',"
    "].join("")),options:{date:void 0,firstday:0},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.monthNames=[this.textJanuary,this.textFebruary,this.textMarch,this.textApril,this.textMay,this.textJune,this.textJuly,this.textAugust,this.textSeptember,this.textOctober,this.textNovember,this.textDecember],this.dayNamesShort=[this.textShortSunday,this.textShortMonday,this.textShortTuesday,this.textShortWednesday,this.textShortThursday,this.textShortFriday,this.textShortSaturday],this.monthShortNames=[this.textShortJanuary,this.textShortFebruary,this.textShortMarch,this.textShortApril,this.textShortMay,this.textShortJune,this.textShortJuly,this.textShortAugust,this.textShortSeptember,this.textShortOctober,this.textShortNovember,this.textShortDecember],e.options.date=t.date,_.isUndefined(t.firstday)||0!==t.firstday&&1!==t.firstday||(e.options.firstday=t.firstday),e.enableKeyEvents=e.options.enableKeyEvents,e._state=void 0,e.render()},render:function(){var t=this;return t.cmpEl=t.$el||$(this.el),t.cmpEl.html(this.template()),t.currentDate=t.options.date||new Date,t.btnPrev=new Common.UI.Button({parentEl:t.cmpEl.find("#prev-arrow"),cls:"",iconCls:"arrow-prev img-commonctrl"}),t.btnPrev.on("click",_.bind(t.onClickPrev,t)),t.btnNext=new Common.UI.Button({parentEl:t.cmpEl.find("#next-arrow"),cls:"",iconCls:"arrow-next img-commonctrl"}),t.btnNext.on("click",_.bind(t.onClickNext,t)),t.cmpEl.on("keydown",function(e){t.trigger("calendar:keydown",t,e)}),t.renderMonth(t.currentDate),this.trigger("render:after",this),this},onClickPrev:function(){var t=this;if(0===t._state){var e=new Date(t.currentDate);e.setMonth(e.getMonth()-1),e.getFullYear()>0&&t.renderMonth(e)}else if(1===t._state){var e=new Date(t.currentDate);e.setFullYear(e.getFullYear()-1),e.getFullYear()>0&&t.renderMonths(e)}else if(2===t._state){var i,n=t.currentDate.getFullYear();n%10!=0?(i=String(n),i=Number(i.slice(0,-1)+"0")-1):i=n-1,i>0&&(t.currentDate.setFullYear(i),t.renderYears(i))}},onClickNext:function(){var t=this;if(0===t._state){var e=new Date(t.currentDate);e.setMonth(e.getMonth()+1),e.getFullYear()>0&&t.renderMonth(e)}else if(1===t._state){var e=new Date(t.currentDate);e.setFullYear(e.getFullYear()+1),e.getFullYear()>0&&t.renderMonths(e)}else if(2===t._state){var i,n=t.currentDate.getFullYear();n%10!=9?(i=String(n),i=Number(i.slice(0,-1)+"9")+1):i=n+1,i>0&&(t.currentDate.setFullYear(i),t.renderYears(i))}},renderYears:function(t){var e=this,t=_.isNumber(t)?t:e.currentDate?e.currentDate.getFullYear():(new Date).getFullYear();e._state=2;var i=t,n=t;if(i%10!=0){var o=String(t);i=Number(o.slice(0,-1)+"0")}if(n%10!=9){var o=String(t);n=Number(o.slice(0,-1)+"9")}e.topTitle=_.template([""].join("")),e.cmpEl.find(".calendar-header .title").html(e.topTitle),e.bottomTitle=_.template([""].join("")),e.cmpEl.find(".calendar-header .bottom-row").html(e.bottomTitle);for(var s=[],a=i-3,r=0;r<16;r++)s.push({year:a>0?a:"",isCurrentDecade:a>=i&&a<=n,disabled:!(a>0),selected:_.isDate(e.selectedDate)?a===e.selectedDate.getFullYear():a===(new Date).getFullYear()}),a++;e.yearPicker?e.yearPicker.store.reset(s):(e.yearPicker=new Common.UI.DataView({el:e.cmpEl.find(".calendar-content"),store:new Common.UI.DataViewStore(s),itemTemplate:_.template('
    <%= year %>
    ')}),e.yearPicker.on("item:click",function(t,i,n,o){var s=n.get("year"),a=new Date;a.setFullYear(s),e.renderMonths(a)}),e.enableKeyEvents&&this.yearPicker.on("item:keydown",function(t,e,i){i.keyCode==Common.UI.Keys.ESC&&Common.NotificationCenter.trigger("dataview:blur")})),e.enableKeyEvents&&_.delay(function(){e.monthPicker.focus()},10)},renderMonths:function(t){var e=this,i=_.isDate(t)?t:e.currentDate?e.currentDate:new Date,n=i.getFullYear();e._state=1,e.currentDate=i,e.topTitle=_.template(['
    "].join("")),e.cmpEl.find(".calendar-header .title").html(e.topTitle),e.cmpEl.find(".calendar-header .title").off(),e.cmpEl.find(".calendar-header .title").on("click",_.bind(e.renderYears,e)),e.bottomTitle=_.template([""].join("")),e.cmpEl.find(".calendar-header .bottom-row").html(e.bottomTitle);for(var o=[],s=new Date,a=0;a<12;a++)o.push({indexMonth:a,nameMonth:e.monthShortNames[a],year:n,curYear:!0,isCurrentMonth:a===i.getMonth(),selected:_.isDate(e.selectedDate)?a===e.selectedDate.getMonth()&&n===e.selectedDate.getFullYear():a===s.getMonth()&&n===s.getFullYear()});n+=1;for(var a=0;a<4;a++)o.push({indexMonth:a,nameMonth:e.monthShortNames[a],year:n,curYear:!1,selected:_.isDate(e.selectedDate)?a===e.selectedDate.getMonth()&&n===e.selectedDate.getFullYear():a===s.getMonth()&&n===s.getFullYear()});e.monthsPicker?e.monthsPicker.store.reset(o):(e.monthsPicker=new Common.UI.DataView({el:e.cmpEl.find(".calendar-content"),store:new Common.UI.DataViewStore(o),itemTemplate:_.template('
    <%= nameMonth %>
    ')}),e.monthsPicker.on("item:click",function(t,i,n,o){var s=n.get("indexMonth"),a=n.get("year"),r=new Date;r.setFullYear(a,s),e.renderMonth(r)}),e.enableKeyEvents&&this.monthsPicker.on("item:keydown",function(t,e,i){i.keyCode==Common.UI.Keys.ESC&&Common.NotificationCenter.trigger("dataview:blur")})), e.enableKeyEvents&&_.delay(function(){e.monthPicker.focus()},10)},renderMonth:function(t){var e=this;e._state=0;var i=e.options.firstday,n=t||new Date,o=n.getMonth(),s=(n.getDay(),n.getDate(),n.getFullYear());e.currentDate=n,e.topTitle=_.template(['
    ',"","
    "].join("")),e.cmpEl.find(".calendar-header .title").html(e.topTitle),e.cmpEl.find(".calendar-header .title").off(),e.cmpEl.find(".calendar-header .title").on("click",_.bind(e.renderMonths,e));for(var a="",r=i;r<7;r++)a+="";i>0&&(a+=""),e.cmpEl.find(".calendar-header .bottom-row").html(_.template(a));var l=[],c=new Date(n);c.setDate(1);var d,h,p,m=c.getDay(),u=e.daysInMonth(c.getTime()-864e6);d=0===i?m>0?u-(m-1):1:0===m?u-5:u-(m-2),m>0&&0===i||1===i?o-1>=0?(h=o-1,p=s):(h=11,p=s-1):(h=o,p=s);var g=new Date;g.setFullYear(p,h,d);for(var b=new Date,f=0;f<6;f++)for(var C=0;C<7;C++){var v=g.getDay(),y=g.getDate(),w=g.getMonth(),x=g.getFullYear();l.push({indexInWeek:v,dayNumber:y,month:w,year:x,isCurrentMonth:w===o,selected:_.isDate(e.selectedDate)?y===e.selectedDate.getDate()&&w===e.selectedDate.getMonth()&&x===e.selectedDate.getFullYear():y===b.getDate()&&w===b.getMonth()&&x===b.getFullYear()}),g.setDate(y+1)}e.monthPicker?e.monthPicker.store.reset(l):(e.monthPicker=new Common.UI.DataView({el:e.cmpEl.find(".calendar-content"),store:new Common.UI.DataViewStore(l),itemTemplate:_.template('
    <%= dayNumber %>
    ')}),e.monthPicker.on("item:click",function(t,i,n,o){var s=n.get("dayNumber"),a=n.get("month"),r=n.get("year");_.isUndefined(e.selectedDate)&&(e.selectedDate=new Date),e.selectedDate.setFullYear(r,a,s),e.trigger("date:click",e,e.selectedDate)}),e.enableKeyEvents&&this.monthPicker.on("item:keydown",function(t,e,i){i.keyCode==Common.UI.Keys.ESC&&Common.NotificationCenter.trigger("dataview:blur")})),e.enableKeyEvents&&_.delay(function(){e.monthPicker.focus()},10)},daysInMonth:function(t){var e;e=t?new Date(t):new Date;var i=new Date;return i.setFullYear(e.getFullYear(),e.getMonth()+1,0),i.getDate()},setDate:function(t){_.isDate(t)&&(this.selectedDate=new Date(t),this.renderMonth(this.selectedDate))},textJanuary:"January",textFebruary:"February",textMarch:"March",textApril:"April",textMay:"May",textJune:"June",textJuly:"July",textAugust:"August",textSeptember:"September",textOctober:"October",textNovember:"November",textDecember:"December",textShortJanuary:"Jan",textShortFebruary:"Feb",textShortMarch:"Mar",textShortApril:"Apr",textShortMay:"May",textShortJune:"Jun",textShortJuly:"Jul",textShortAugust:"Aug",textShortSeptember:"Sep",textShortOctober:"Oct",textShortNovember:"Nov",textShortDecember:"Dec",textShortSunday:"Su",textShortMonday:"Mo",textShortTuesday:"Tu",textShortWednesday:"We",textShortThursday:"Th",textShortFriday:"Fr",textShortSaturday:"Sa",textMonths:"Months",textYears:"Years"},Common.UI.Calendar||{}))}),void 0===Common)var Common={};if(define("common/main/lib/view/InsertTableDialog",["common/main/lib/component/Window"],function(){"use strict";Common.Views.InsertTableDialog=Common.UI.Window.extend(_.extend({options:{width:230,height:156,style:"min-width: 230px;",cls:"modal-dlg",split:!1,buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:t.split?this.txtTitleSplit:this.txtTitle},t||{}),this.template=['
    ','
    ','
    ',"
    ",'
    ','
    ',"
    ","
    "].join(""),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this.getChild();t.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.udColumns=new Common.UI.MetricSpinner({el:t.find(".columns-val"),step:1,width:64,value:2,defaultUnit:"",maxValue:63,minValue:1,allowDecimal:!1}),this.udRows=new Common.UI.MetricSpinner({el:t.find(".rows-val"),step:1,width:64,value:2,defaultUnit:"",maxValue:100,minValue:1,allowDecimal:!1})},getFocusedComponents:function(){return[this.udColumns,this.udRows]},getDefaultFocusableComponent:function(){return this.udColumns},onBtnClick:function(t){this.options.handler&&this.options.handler.call(this,t.currentTarget.attributes.result.value,{columns:this.udColumns.getNumberValue(),rows:this.udRows.getNumberValue()}),this.close()},onPrimary:function(){return this.options.handler&&this.options.handler.call(this,"ok",{columns:this.udColumns.getNumberValue(),rows:this.udRows.getNumberValue()}),this.close(),!1},txtTitle:"Table Size",txtTitleSplit:"Split Cell",txtColumns:"Number of Columns",txtRows:"Number of Rows",textInvalidRowsCols:"You need to specify valid rows and columns count.",txtMinText:"The minimum value for this field is {0}",txtMaxText:"The maximum value for this field is {0}"},Common.Views.InsertTableDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/view/CopyWarningDialog",["common/main/lib/component/Window"],function(){"use strict";Common.Views.CopyWarningDialog=Common.UI.Window.extend(_.extend({options:{width:500,height:325,cls:"modal-dlg copy-warning",buttons:["ok"]},initialize:function(t){_.extend(this.options,{title:this.textTitle,buttons:["ok"]},t||{}),this.template=['
    ','

    '+this.textMsg+"

    ",'
    ',"
    ",'

    '+Common.Utils.String.platformKey("Ctrl+C","{0}")+"

    ",'

    '+this.textToCopy+"

    ","
    ","
    ",'

    '+Common.Utils.String.platformKey("Ctrl+X","{0}")+"

    ",'

    '+this.textToCut+"

    ","
    ","
    ",'

    '+Common.Utils.String.platformKey("Ctrl+V","{0}")+"

    ",'

    '+this.textToPaste+"

    ","
    ","
    ",'
    ',"
    ",'
    '].join(""),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.chDontShow=new Common.UI.CheckBox({el:$("#copy-warning-checkbox"),labelText:this.textDontShow}),this.getChild().find(".btn").on("click",_.bind(this.onBtnClick,this)),this.autoSize()},autoSize:function(){var t=this.getChild(".box"),e=this.getChild(".footer"),i=this.getChild(".header"),n=this.getChild(".body");n.height(parseInt(t.height())+parseInt(e.css("height"))),this.setHeight(parseInt(n.css("height"))+parseInt(i.css("height")))},onBtnClick:function(t){this.options.handler&&this.options.handler.call(this,"checked"==this.chDontShow.getValue()),this.close()},onKeyPress:function(t){t.keyCode==Common.UI.Keys.RETURN&&(this.options.handler&&this.options.handler.call(this,"checked"==this.chDontShow.getValue()),this.close())},getSettings:function(){return"checked"==this.chDontShow.getValue()},textTitle:"Copy, Cut and Paste Actions",textMsg:"Copy, cut and paste actions using the editor toolbar buttons and context menu actions will be performed within this editor tab only.

    .To copy or paste to or from applications outside the editor tab use the following keyboard combinations:",textToCopy:"for Copy",textToPaste:"for Paste",textToCut:"for Cut",textDontShow:"Don't show this message again"},Common.Views.CopyWarningDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/component/RadioBox",["common/main/lib/component/BaseView","underscore"],function(t,e){"use strict";Common.UI.RadioBox=Common.UI.BaseView.extend({options:{labelText:""},disabled:!1,rendered:!1,template:e.template(''),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);this.name=this.options.name||Common.UI.getId(),this.render(),this.options.disabled&&this.setDisabled(this.options.disabled),void 0!==this.options.checked&&this.setValue(this.options.checked,!0),this.$radio.on("click",e.bind(this.onItemCheck,this))},render:function(){var t=this.$el||$(this.el);return t.html(this.template({labelText:this.options.labelText,name:this.name,id:Common.UI.getId("rdb-")})),this.$radio=t.find("input[type=radio]"),this.$label=t.find("label.radiobox"),this.rendered=!0,this},setDisabled:function(t){this.rendered&&(t!==this.disabled&&(this.$label.toggleClass("disabled",t),this.$radio.toggleClass("disabled",t),t?this.$radio.attr({disabled:t}):this.$radio.removeAttr("disabled")),this.disabled=t)},isDisabled:function(){return this.disabled},onItemCheck:function(t){this.disabled||this.setValue(!0)},setRawValue:function(t){var t=!0===t||"true"===t||"1"===t||1===t;$("input[type=radio][name="+this.name+"]").removeClass("checked"),this.$radio.toggleClass("checked",t),this.$radio.prop("checked",t)},setValue:function(t,e){if(this.rendered){var i=this.$radio.hasClass("checked");this.setRawValue(t),!0!==e&&i!==t&&this.trigger("change",this,this.$radio.is(":checked"))}else this.options.checked=t},getValue:function(){return this.$radio.is(":checked")},setCaption:function(t){this.$label.find("span").text(t)}})}),define("common/main/lib/view/OptionsDialog",["common/main/lib/component/Window","common/main/lib/component/RadioBox"],function(){"use strict";Common.Views.OptionsDialog=Common.UI.Window.extend(_.extend({options:{width:214,header:!0,style:"min-width: 214px;",cls:"modal-dlg",items:[],buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,t||{}),this.template=['
    ','<% if (typeof label !== "undefined" && label !=="") { %>','',"<% } %>","<% _.each(items, function(item, index) { %>","<% if (!item.id) item.id = Common.UI.getId(); %>",'
    ',"<% }) %>","
    "].join(""),this.options.tpl=_.template(this.template)(this.options),this.radio=[],Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=t.getChild(),i=this.options.items,n=!0,o=-1;if(i){for(var s=0;s=0&&this.radio[o].setValue(!0)}e.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this))},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},getSettings:function(){return this.currentCell},onPrimary:function(){return this._handleInput("ok"),!1}},Common.Views.OptionsDialog||{}))}),define("text!documenteditor/main/app/template/DropcapSettingsAdvanced.template",[],function(){return'
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n \n \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n \n \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n \n \n
    \n \n \n
    \n
    \n
    \n \n \n \n \n \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    '}),void 0===Common)var Common={};var FONT_TYPE_RECENT=4;if(define("common/main/lib/component/ComboBoxFonts",["common/main/lib/component/ComboBox"],function(){"use strict";Common.UI.ComboBoxFonts=Common.UI.ComboBox.extend(function(){var t=Asc.FONT_THUMBNAIL_HEIGHT||26,e=window.devicePixelRatio>1,i=document.createElement("canvas"),n=i.getContext("2d"),o="../../../../sdkjs/common/Images/fonts_thumbnail.png?"+window.CP_urlArgs,s="../../../../sdkjs/common/Images/fonts_thumbnail@2x.png?"+window.CP_urlArgs,a=1;return"object"==typeof window.AscDesktopEditor&&(o=window.AscDesktopEditor.getFontsSprite(),s=window.AscDesktopEditor.getFontsSprite(!0)),i.height=e?2*t:t,i.width=e?604:302,{template:_.template(['
    ',' ','
    ','','","
    "].join("")),initialize:function(t){Common.UI.ComboBox.prototype.initialize.call(this,_.extend(t,{displayField:"name",scroller:{wheelSpeed:20,alwaysVisibleY:!0,onChange:this.updateVisibleFontsTiles.bind(this)}})),this.recent=_.isNumber(t.recent)?t.recent:5;var e=Common.localStorage.getKeysFilter();this.appPrefix=e&&e.length?e.split(",")[0]:"",Common.NotificationCenter.on("fonts:load",_.bind(this.fillFonts,this))},render:function(t){var e=null,i="";return _.isUndefined(this._input)||(e=this._input.val(),i=this._input.attr("tabindex")),Common.UI.ComboBox.prototype.render.call(this,t),this.setRawValue(e),this._input.attr("tabindex",i),this._input.on("keyup",_.bind(this.onInputKeyUp,this)),this._input.on("keydown",_.bind(this.onInputKeyDown,this)),this._input.on("focus",_.bind(function(){this.inFormControl=!0},this)),this._input.on("blur",_.bind(function(){this.inFormControl=!1},this)),this},onAfterKeydownMenu:function(t){var e=this;if(t.keyCode==Common.UI.Keys.RETURN){if($(t.target).closest("input").length){if(this.lastValue===this._input.val())return!0;this._input.trigger("change")}else $(t.target).click(),this.rendered&&(Common.Utils.isIE?this._input.trigger("change",{onkeydown:!0}):this._input.blur());return!1}if(t.keyCode==Common.UI.Keys.ESC&&this.isMenuOpen())return this._input.val(this.lastValue),setTimeout(function(){e.closeMenu(),e.onAfterHideMenu(t)},10),!1;(t.keyCode==Common.UI.Keys.HOME&&!t.shiftKey||t.keyCode==Common.UI.Keys.END&&!t.shiftKey||t.keyCode==Common.UI.Keys.BACKSPACE&&!e._input.is(":focus"))&&this.isMenuOpen()&&(e._input.focus(),setTimeout(function(){e._input[0].selectionStart=e._input[0].selectionEnd=t.keyCode==Common.UI.Keys.HOME?0:e._input[0].value.length},10)),this.updateVisibleFontsTiles()},onInputKeyUp:function(t){if(t.keyCode!=Common.UI.Keys.RETURN&&t.keyCode!==Common.UI.Keys.SHIFT&&t.keyCode!==Common.UI.Keys.CTRL&&t.keyCode!==Common.UI.Keys.ALT&&t.keyCode!==Common.UI.Keys.LEFT&&t.keyCode!==Common.UI.Keys.RIGHT&&t.keyCode!==Common.UI.Keys.HOME&&t.keyCode!==Common.UI.Keys.END&&t.keyCode!==Common.UI.Keys.ESC&&t.keyCode!==Common.UI.Keys.INSERT&&t.keyCode!==Common.UI.Keys.TAB&&(t.stopPropagation(),this.selectCandidate(t.keyCode==Common.UI.Keys.DELETE||t.keyCode==Common.UI.Keys.BACKSPACE),this._selectedItem)){var e=this;void 0===e._timerSelection&&(e._timerSelection=setInterval(function(){if(!(new Date-e._inInputKeyDown<100)&&e._selectedItem){clearInterval(e._timerSelection),e._timerSelection=void 0;var t=e._input[0],i=e._selectedItem.get(e.displayField),n=t.value;e.rendered&&(document.selection?document.selection.createRange().text=i:(t.selectionStart||"0"==t.selectionStart)&&(t.value=i,t.selectionStart=n.length,t.selectionEnd=i.length))}},10))}},onInputKeyDown:function(t){this._inInputKeyDown=new Date;var e=this;t.keyCode==Common.UI.Keys.ESC?(this._input.val(this.lastValue),setTimeout(function(){e.closeMenu(),e.onAfterHideMenu(t)},10)):t.keyCode!=Common.UI.Keys.RETURN&&t.keyCode!=Common.UI.Keys.CTRL&&t.keyCode!=Common.UI.Keys.SHIFT&&t.keyCode!=Common.UI.Keys.ALT&&t.keyCode!=Common.UI.Keys.TAB?(this.isMenuOpen()||t.ctrlKey||this.openMenu(),t.keyCode==Common.UI.Keys.UP||t.keyCode==Common.UI.Keys.DOWN?_.delay(function(){var i=t.keyCode==Common.UI.Keys.DOWN?e.cmpEl.find("ul li.selected").nextAll("li:not(.divider)"):e.cmpEl.find("ul li.selected").prevAll("li:not(.divider)");i=i.length>0?i.eq(0):t.keyCode==Common.UI.Keys.DOWN?e.cmpEl.find("ul li:not(.divider):first"):e.cmpEl.find("ul li:not(.divider):last"),i=i.find("a"),e._skipInputChange=!0,i.focus(),e.updateVisibleFontsTiles()},10):e._skipInputChange=!1):t.keyCode==Common.UI.Keys.RETURN&&this._input.val()===e.lastValue&&this._input.trigger("change",{reapply:!0})},onInputChanged:function(t,e){if(!e||!e.synthetic){if(this._skipInputChange)return void(this._skipInputChange=!1);if(this._isMouseDownMenu)return void(this._isMouseDownMenu=!1);var i=$(t.target).val(),n={};if(!(this.lastValue!==i||e&&e.reapply))return void(e&&e.onkeydown&&this.trigger("combo:blur",this,t));n[this.valueField]=i,n[this.displayField]=i,this.trigger("changed:before",this,n,t),t.isDefaultPrevented()||(this._selectedItem?(n[this.valueField]=this._selectedItem.get(this.displayField),this.setRawValue(n[this.valueField]),this.trigger("selected",this,_.extend({},this._selectedItem.toJSON()),t),this.addItemToRecent(this._selectedItem),this.closeMenu()):(this.setRawValue(n[this.valueField]),n.isNewFont=!0,this.trigger("selected",this,n,t),this.closeMenu()),this.trigger("changed:after",this,n,t))}},getImageUri:function(o){if(o.cloneid){var s=$(this.el).find("ul > li#"+o.cloneid+" img");return null!=s?s[0].src:void 0}return e?(n.clearRect(0,0,604,2*t),n.drawImage(this.spriteThumbs,0,2*-Asc.FONT_THUMBNAIL_HEIGHT*Math.floor(o.imgidx/a))):(n.clearRect(0,0,302,t),n.drawImage(this.spriteThumbs,0,-Asc.FONT_THUMBNAIL_HEIGHT*Math.floor(o.imgidx/a))),i.toDataURL()},getImageWidth:function(){return 302},getImageHeight:function(){return t},getListItemHeight:function(){return 26},loadSprite:function(t){t&&(this.spriteThumbs=new Image,this.spriteThumbs.onload=t,this.spriteThumbs.src=e?s:o)},fillFonts:function(t,i){var n=this;this.loadSprite(function(){if(a=Math.floor(n.spriteThumbs.width/(e?604:302))||1,n.store.set(t.toJSON()),n.rendered=!1,_.isUndefined(n.scroller)||(n.scroller.destroy(),delete n.scroller),n._scrollerIsInited=!1,n.render($(n.el)),n._fontsArray=n.store.toJSON(),n.recent>0){n.store.on("add",n.onInsertItem,n),n.store.on("remove",n.onRemoveItem,n),Common.Utils.InternalSettings.set(n.appPrefix+"-settings-recent-fonts",Common.localStorage.getItem(n.appPrefix+"-settings-recent-fonts"));var i=Common.Utils.InternalSettings.get(n.appPrefix+"-settings-recent-fonts");i=i?i.split(";"):[],i.reverse().forEach(function(t){t&&n.addItemToRecent(n.store.findWhere({name:t}),!0)})}})},onApiChangeFont:function(t){var e=this,i=_.isFunction(t.get_Name)?t.get_Name():t.asc_getFontName();this.__name!==i&&(this.__nameId||(this.__nameId=setTimeout(function(){e.onApiChangeFontInternal(i),e.__nameId=null},100)))},onApiChangeFontInternal:function(t){if(!this.inFormControl&&(this.__name=t,this.getRawValue()!==t)){var e=this.store.findWhere({name:t});if($(".selected",$(this.el)).removeClass("selected"),e){this.setRawValue(e.get(this.displayField));var i=$("#"+e.get("id"),$(this.el)),n=$("ul.dropdown-menu",this.cmpEl);i&&n&&(i.addClass("selected"),this.recent<=0&&n.scrollTop(i.offset().top-n.offset().top))}else this.setRawValue(t)}},itemClicked:function(t){Common.UI.ComboBox.prototype.itemClicked.apply(this,arguments);var e=$(t.target).closest("li"),i=this.store.findWhere({id:e.attr("id")});this.addItemToRecent(i)},onInsertItem:function(t){$(this.el).find("ul").prepend(_.template(['
  • ','',"
  • "].join(""))({item:t.attributes,scope:this}))},onRemoveItem:function(t,e,i){$(this.el).find("ul > li#"+t.id).remove()},onBeforeShowMenu:function(t){if(this.store.length<1)return void t.preventDefault();if(Common.UI.ComboBox.prototype.onBeforeShowMenu.apply(this,arguments),!this.getSelectedRecord()&&this.getRawValue()){var e=this.store.where({name:this.getRawValue()});e&&e.length&&this.selectRecord(e[e.length-1])}},onAfterShowMenu:function(t){this.recent>0?(this.scroller&&!this._scrollerIsInited&&(this.scroller.update(),this._scrollerIsInited=!0),$(this.el).find("ul").scrollTop(0),this.trigger("show:after",this,t),this.flushVisibleFontsTiles(),this.updateVisibleFontsTiles(null,0)):Common.UI.ComboBox.prototype.onAfterShowMenu.apply(this,arguments)},onAfterHideMenu:function(t){this.lastValue!==this._input.val()&&this._input.val(this.lastValue),Common.UI.ComboBox.prototype.onAfterHideMenu.apply(this,arguments)},addItemToRecent:function(t,e){if(t&&!(this.recent<1)){var i=this.store.findWhere({name:t.get("name"),type:FONT_TYPE_RECENT});i&&this.store.remove(i);var n=this.store.where({type:FONT_TYPE_RECENT});n.length0&&s.length>0){o.addClass("selected");var a=o.position().top,r=s.scrollTop() ;0!=a&&s.scrollTop(r+a)}}},updateVisibleFontsTiles:function(i,n){var o=this,s=0,r=o.store.length,l=0;if(o.tiles||(o.tiles=[]),r!==o.tiles.length)for(s=o.tiles.length;s=0;--t)this.tiles[t]&&(this.tiles[t].parentNode.removeChild(this.tiles[t]),this.tiles[t]=null)}}}())}),void 0===Common)var Common={};if(define("common/main/lib/component/MetricSpinner",["common/main/lib/component/BaseView"],function(){"use strict";Common.UI.MetricSpinner=Common.UI.BaseView.extend({options:{minValue:0,maxValue:100,step:1,defaultUnit:"px",allowAuto:!1,autoText:"Auto",hold:!0,speed:"medium",width:90,allowDecimal:!0},disabled:!1,value:"0 px",rendered:!1,template:'
    ',initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this,i=e.$el||$(this.el);i.addClass("spinner"),i.on("mousedown",".spinner-up",_.bind(this.onMouseDown,this,!0)),i.on("mousedown",".spinner-down",_.bind(this.onMouseDown,this,!1)),i.on("mouseup",".spinner-up",_.bind(this.onMouseUp,this,!0)),i.on("mouseup",".spinner-down",_.bind(this.onMouseUp,this,!1)),i.on("mouseover",".spinner-up, .spinner-down",_.bind(this.onMouseOver,this)),i.on("mouseout",".spinner-up, .spinner-down",_.bind(this.onMouseOut,this)),i.on("keydown",".form-control",_.bind(this.onKeyDown,this)),i.on("keyup",".form-control",_.bind(this.onKeyUp,this)),i.on("blur",".form-control",_.bind(this.onBlur,this)),i.on("input",".form-control",_.bind(this.onInput,this)),this.options.allowDecimal||i.on("keypress",".form-control",_.bind(this.onKeyPress,this)),i.on("focus","input.form-control",function(){setTimeout(function(){e.$input&&e.$input.select()},1)}),Common.Utils.isGecko&&i.on("blur","input.form-control",function(){setTimeout(function(){e.$input&&(e.$input[0].selectionStart=e.$input[0].selectionEnd=0)},1)}),this.switches={count:1,enabled:!0,fromKeyDown:!1},"medium"===this.options.speed?this.switches.speed=300:"fast"===this.options.speed?this.switches.speed=100:this.switches.speed=500,this.render(),this.options.disabled&&this.setDisabled(this.options.disabled),void 0!==this.options.value&&(this.value=this.options.value),this.setRawValue(this.value),this.options.width&&i.width(this.options.width),void 0===this.options.defaultValue&&(this.options.defaultValue=this.options.minValue),this.oldValue=this.options.minValue,this.lastValue=null},render:function(){var t=this.$el||$(this.el);return t.html(this.template),this.$input=t.find(".form-control"),this.rendered=!0,void 0!=this.options.tabindex&&this.$input.attr("tabindex",this.options.tabindex),this},setDisabled:function(t){var e=this.$el||$(this.el);t!==this.disabled&&(e.find("button").toggleClass("disabled",t),e.toggleClass("disabled",t),t?this.$input.attr({disabled:t}):this.$input.removeAttr("disabled")),this.disabled=t},isDisabled:function(){return this.disabled},setDefaultUnit:function(t){if(this.options.defaultUnit!=t){var e=this.options.defaultUnit;this.options.defaultUnit=t,this.setMinValue(this._recalcUnits(this.options.minValue,e)),this.setMaxValue(this._recalcUnits(this.options.maxValue,e)),this.setValue(this._recalcUnits(this.getNumberValue(),e),!0)}},setMinValue:function(t){this.options.minValue=t},setMaxValue:function(t){this.options.maxValue=t},setStep:function(t){this.options.step=t},getNumberValue:function(){return this.checkAutoText(this.value)?-1:parseFloat(this.value)},getUnitValue:function(){return this.options.defaultUnit},getValue:function(){return this.value},setRawValue:function(t){this.$input&&this.$input.val(t)},getRawValue:function(){return this.$input.val()},setValue:function(t,e){var i=!1;if(this._fromKeyDown=!1,this.lastValue=this.value,void 0===t||""===t)this.value="";else if(this.options.allowAuto&&(Math.abs(Common.Utils.String.parseFloat(t)+1)<1e-4||this.checkAutoText(t)))this.value=this.options.autoText;else{var n=this._add(Common.Utils.String.parseFloat(t),0,this.options.allowDecimal?3:0);(void 0===t||isNaN(n))&&(n=this.oldValue,i=!0);var o=this.options.defaultUnit;if(void 0!==t.match){var s=t.match(/(px|em|%|en|ex|pt|"|cm|mm|pc|s|ms|см|мм|пт|сек|мс)$/i);null!==s&&"undefined"!==s[0]&&(o=s[0].toLowerCase())}this.options.defaultUnit===o||i||(n=this._recalcUnits(n,o)),n>this.options.maxValue&&(n=this.options.maxValue,i=!0),n','
    ','
    ',"
    ",""].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e,i,n=this,o=void 0,s={},a={},r={};n.id=n.options.id||Common.UI.getId(),n.clickOffset=n.options.clickOffset,n.overwriteStyle=n.options.overwriteStyle,n.maxBorderSize=n.options.maxBorderSize,n.halfBorderSize=n.options.halfBorderSize,n.defaultBorderSize=n.options.defaultBorderSize,n.defaultBorderColor=n.options.defaultBorderColor,n.col=n.options.col,n.row=n.options.row,e=n.defaultBorderSize,i=new Common.Utils.RGBColor(n.defaultBorderColor),s={top:e,right:e,bottom:e,left:e},a={top:i,right:i,bottom:i,left:i},r={top:1,right:1,bottom:1,left:1},n.rendered=!1;var l=function(){if(!_.isUndefined(o)){var t=s.left>.1&&s.left<1?1:s.left,e=Math.abs(n.halfBorderSize?.5*(t%2?t-1:t):t);t=s.right>.1&&s.right<1?1:s.right;var i=Math.abs(n.halfBorderSize?.5*(t%2?t+1:t):t);t=s.top>.1&&s.top<1?1:s.top;var l=Math.abs(n.halfBorderSize?.5*(t%2?t-1:t):t);t=s.bottom>.1&&s.bottom<1?1:s.bottom;var c=Math.abs(n.halfBorderSize?.5*(t%2?t+1:t):t),d="inset "+(e>.1&&e<1?1:e)+"px 0 0 "+a.left.toRGBA(r.left)+", inset "+-1*(i>.1&&i<1?1:i)+"px 0 0 "+a.right.toRGBA(r.right)+", inset 0 "+(l>.1&&l<1?1:l)+"px 0 "+a.top.toRGBA(r.top)+", inset 0 "+-1*(c>.1&&c<1?1:c)+"px 0 "+a.bottom.toRGBA(r.bottom);o.css("box-shadow",d)}};n.on("render:after",function(t){this.cmpEl&&(o=this.cmpEl.find(".cell-content"),l()),this.cmpEl.on("click",function(t){var o={x:t.pageX*Common.Utils.zoom()-n.cmpEl.offset().left,y:t.pageY*Common.Utils.zoom()-n.cmpEl.offset().top},c=function(t,e,i,n,o){var s,a,r=0;for(s=0,a=t-1;s0?0:e,a.top=i),n.fireEvent("borderclick",n,"t",s.top,a.top.toHex())):c(4,[d,d,d-n.clickOffset,d-n.clickOffset],[0,h,h-n.clickOffset,n.clickOffset],o.x,o.y)?(n.overwriteStyle?s.right==e&&a.right.isEqual(i)?s.right=0:(s.right=e,a.right=i,r.right=e<1?.3:1):(s.right=s.right>0?0:e,a.right=i),n.fireEvent("borderclick",n,"r",s.right,a.right.toHex())):c(4,[0,n.clickOffset,d-n.clickOffset,d],[h,h-n.clickOffset,h-n.clickOffset,h],o.x,o.y)?(n.overwriteStyle?s.bottom==e&&a.bottom.isEqual(i)?s.bottom=0:(s.bottom=e,a.bottom=i,r.bottom=e<1?.3:1):(s.bottom=s.bottom>0?0:e,a.bottom=i),n.fireEvent("borderclick",n,"b",s.bottom,a.bottom.toHex())):c(4,[0,n.clickOffset,n.clickOffset,0],[0,n.clickOffset,h-n.clickOffset,h],o.x,o.y)&&(n.overwriteStyle?s.left==e&&a.left.isEqual(i)?s.left=0:(s.left=e,a.left=i,r.left=e<1?.3:1):(s.left=s.left>0?0:e,a.left=i),n.fireEvent("borderclick",n,"l",s.left,a.left.toHex())),l()})}),n.setBordersSize=function(t,e){e=e>this.maxBorderSize?this.maxBorderSize:e,t.indexOf("t")>-1&&(s.top=e,r.top=e<1?.3:1),t.indexOf("r")>-1&&(s.right=e,r.right=e<1?.3:1),t.indexOf("b")>-1&&(s.bottom=e,r.bottom=e<1?.3:1),t.indexOf("l")>-1&&(s.left=e,r.left=e<1?.3:1),l()},n.setBordersColor=function(t,e){var i=new Common.Utils.RGBColor(e);t.indexOf("t")>-1&&(a.top=i),t.indexOf("r")>-1&&(a.right=i),t.indexOf("b")>-1&&(a.bottom=i),t.indexOf("l")>-1&&(a.left=i),l()},n.getBorderSize=function(t){switch(t){case"t":return s.top;case"r":return s.right;case"b":return s.bottom;case"l":return s.left}return null},n.getBorderColor=function(t){switch(t){case"t":return a.top.toHex();case"r":return a.right.toHex();case"b":return a.bottom.toHex();case"l":return a.left.toHex()}return null},n.setVirtualBorderSize=function(t){e=t>this.maxBorderSize?this.maxBorderSize:t},n.setVirtualBorderColor=function(t){var e=new Common.Utils.RGBColor(t);i.isEqual(e)||(i=e)},n.getVirtualBorderSize=function(){return e},n.getVirtualBorderColor=function(){return i.toHex()},n.options.el&&n.render()},render:function(t){var e=this;return this.trigger("render:before",this),e.rendered?this.cmpEl=this.$el:(this.cmpEl=$(this.template({id:this.id})),t?(this.setElement(t,!1),t.html(this.cmpEl)):this.$el.html(this.cmpEl)),e.rendered=!0,this.trigger("render:after",this),this}}),Common.UI.TableStyler=Common.UI.BaseView.extend({options:{width:200,height:200,rows:2,columns:2,cellPadding:10,tablePadding:10,overwriteStyle:!0,maxBorderSize:6,spacingMode:!1,defaultBorderSize:1,defaultBorderColor:"#ccc"},template:_.template(['
    ','
    ','
    ','
    ','',"",'',"","","","","
    ","
    ","
    ",'
    ','
    ','
    ','',"",'','',"","
    ","
    ","
    ",'
    ','',"<% for (var row = 0; row < scope.rows; row++) { %>","","<% for (var col = 0; col < scope.columns; col++) { %>",'',"<% } %>","","<% } %>","
    ","
    ",'
    ','
    ','',"",'','',"","
    ","
    ","
    ",'
    ','
    ','
    ','',"",'',"","","","","
    ","
    ","
    ",'
    ',"
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e,i,n,o,s,a,r,l,c,d,h,p,m=this;m.id=m.options.id||Common.UI.getId(),m.width=m.options.width,m.height=m.options.height,m.rows=m.options.rows,m.columns=m.options.columns,m.cellPadding=m.options.cellPadding,m.tablePadding=m.options.tablePadding,m.overwriteStyle=m.options.overwriteStyle,m.maxBorderSize=m.options.maxBorderSize,m.spacingMode=m.options.spacingMode,m.defaultBorderSize=m.options.defaultBorderSize,m.defaultBorderColor=m.options.defaultBorderColor,c=m.defaultBorderSize>m.maxBorderSize?m.maxBorderSize:m.defaultBorderSize,d=new Common.Utils.RGBColor(m.defaultBorderColor);var u={top:c,right:c,bottom:c,left:c},g={top:d,right:d,bottom:d,left:d};m.rendered=!1;var b=function(){e&&e.css("border-bottom",(u.top>.1&&u.top<1?1:u.top)+"px solid "+g.top.toRGBA(u.top<1?.2:1)),i&&i.css("border-right",(u.right>.1&&u.right<1?1:u.right)+"px solid "+g.right.toRGBA(u.right<1?.2:1)),n&&n.css("border-bottom",(u.bottom>.1&&u.bottom<1?1:u.bottom)+"px solid "+g.bottom.toRGBA(u.bottom<1?.2:1)),o&&o.css("border-right",(u.left>.1&&u.left<1?1:u.left)+"px solid "+g.left.toRGBA(u.left<1?.2:1)),f(s),f(a),f(r),f(l)},f=function(t){return t.hide(0,function(){$(this).show()})};m.on("render:after",function(t){var b=m.id;e=$("#"+b+"-table-top-border"),i=$("#"+b+"-table-right-border"),n=$("#"+b+"-table-bottom-border"),o=$("#"+b+"-table-left-border"),s=$("#"+b+"-table-top-border-selector"),a=$("#"+b+"-table-right-border-selector"),r=$("#"+b+"-table-bottom-border-selector"),l=$("#"+b+"-table-left-border-selector"),h=$("#"+b+"-table-content"),p=h.find(".cell-content"),h.find(".content-box").css("height",m.rows>1?"50%":"auto"),s.on("click",function(t){m.overwriteStyle?u.top==c&&g.top.isEqual(d)?u.top=0:(u.top=c,g.top=d):(u.top=u.top>0?0:c,g.top=d),e.css("border-bottom",(u.top>.1&&u.top<1?1:u.top)+"px solid "+g.top.toRGBA(u.top<1?.2:1)),f(s),m.fireEvent("borderclick",m,"t",u.top,g.top.toHex())}),a.on("click",function(t){m.overwriteStyle?u.right==c&&g.right.isEqual(d)?u.right=0:(u.right=c,g.right=d):(u.right=u.right>0?0:c,g.right=d),i.css("border-right",(u.right>.1&&u.right<1?1:u.right)+"px solid "+g.right.toRGBA(u.right<1?.2:1)),f(a),m.fireEvent("borderclick",m,"r",u.right,g.right.toHex())}),r.on("click",function(t){m.overwriteStyle?u.bottom==c&&g.bottom.isEqual(d)?u.bottom=0:(u.bottom=c,g.bottom=d):(u.bottom=u.bottom>0?0:c,g.bottom=d),n.css("border-bottom",(u.bottom>.1&&u.bottom<1?1:u.bottom)+"px solid "+g.bottom.toRGBA(u.bottom<1?.2:1)),f(r),m.fireEvent("borderclick",m,"b",u.bottom,g.bottom.toHex())}),l.on("click",function(t){m.overwriteStyle?u.left==c&&g.left.isEqual(d)?u.left=0:(u.left=c,g.left=d):(u.left=u.left>0?0:c,g.left=d),o.css("border-right",(u.left>.1&&u.left<1?1:u.left)+"px solid "+g.left.toRGBA(u.left<1?.2:1)),f(l),m.fireEvent("borderclick",m,"l",u.left,g.left.toHex())})}),m.getVirtualBorderSize=function(){return c},m.getVirtualBorderColor=function(){return d.toHex()},m.setVirtualBorderSize=function(t){t=t>m.maxBorderSize?m.maxBorderSize:t,c=t;for(var e=0;em.maxBorderSize?m.maxBorderSize:e,t.indexOf("t")>-1&&(u.top=e),t.indexOf("r")>-1&&(u.right=e),t.indexOf("b")>-1&&(u.bottom=e),t.indexOf("l")>-1&&(u.left=e),b()},m.setBordersColor=function(t,e){var i=new Common.Utils.RGBColor(e);t.indexOf("t")>-1&&(g.top=i),t.indexOf("r")>-1&&(g.right=i),t.indexOf("b")>-1&&(g.bottom=i),t.indexOf("l")>-1&&(g.left=i),b()},m.getBorderSize=function(t){switch(t){case"t":return u.top;case"r":return u.right;case"b":return u.bottom;case"l":return u.left}return null},m.getBorderColor=function(t){switch(t){case"t":return g.top.toHex();case"r":return g.right.toHex();case"b":return g.bottom.toHex();case"l":return g.left.toHex()}return null},m.setTableColor=function(t){h.css("background-color","transparent"==t?t:"#"+t)},m.setCellsColor=function(t){p.css("background-color","transparent"==t?t:"#"+t)},m.options.el&&m.render(null,{borderSize:u,borderColor:g,virtualBorderSize:c,virtualBorderColor:d})},render:function(t){var e=this,i=arguments[1];if(this.trigger("render:before",this),e.rendered?this.cmpEl=$(this.el):(this.cmpEl=$(this.template(_.extend({scope:e},i))),t?(this.setElement(t,!1),this.setElement(t,!1),t.html(this.cmpEl)):$(this.el).html(this.cmpEl)),!e.rendered){this.cmpEl;this._cells=[];for(var n=0;n0)for(s=0;s=e.rows-1?r.setBordersSize("b",0):r.setBordersSize("b",n),r.setBordersColor("b",o)}else if("l"==i){if(t.col>0)for(a=0;a=e.columns-1?r.setBordersSize("r",0):r.setBordersSize("r",n),r.setBordersColor("r",o)}})}}return e.rendered=!0,this.trigger("render:after",this),this},getCell:function(t,e){return _.findWhere(this._cells,{id:this.id+"-cell-"+t+"-"+e})}})}),define("text!common/main/lib/template/ExtendedColorDialog.template",[],function(){return'
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n\r\n'}),void 0===Common)var Common={};if(define("common/main/lib/component/HSBColorPicker",["common/main/lib/component/BaseView","common/main/lib/util/utils"],function(){"use strict";Common.UI.HSBColorPicker=Common.UI.BaseView.extend({template:_.template('
    <% if (this.showCurrentColor) { %>
    <% } %>
    <% if (this.changeSaturation) { %>
    <% } %>
    <% if (this.allowEmptyColor) { %>
    <%= this.textNoColor %>
    <% } %>
    '),color:"#ff0000",options:{allowEmptyColor:!1,changeSaturation:!0,showCurrentColor:!0},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e,i,n,o,s,a,r,l,c=this,d=(c.$el||$(this.el),0),h=100,p=100;c.allowEmptyColor=c.options.allowEmptyColor,c.changeSaturation=c.options.changeSaturation,c.showCurrentColor=c.options.showCurrentColor;var m=function(t,e){var i=new Common.Utils.RGBColor("hsb("+t.h+","+t.s+","+t.b+")"),n=i.toHex();c.color=e?"transparent":n,u(),c.trigger("changecolor",c,c.color)},u=function(){s.length>0&&a.length>0&&("transparent"==c.color?a.show():(s.css("background-color",c.color),a.hide())),n.length>0&&n.css("background-color",new Common.Utils.RGBColor("hsb("+d+", 100, 100)").toHex()),r.length>0&&(r[0].innerHTML="transparent"==c.color?c.textNoColor:c.color.toUpperCase()),e.length>0&&i.length>0&&(e.css("left",h+"%"),e.css("top",100-p+"%"),i.css("top",parseInt(100*d/360)+"%"))},g=function(t,i,o){if(e.length>0&&n.length>0){var s=[Math.max(0,Math.min(100,parseInt((t.pageX*Common.Utils.zoom()-n.offset().left)/n.width()*100))),Math.max(0,Math.min(100,parseInt((t.pageY*Common.Utils.zoom()-n.offset().top)/n.height()*100)))];e.css("left",s[0]+"%"),e.css("top",s[1]+"%"),h=s[0],p=100-s[1],m({h:d,s:h,b:p})}},b=function(t,e,n){if(i&&o){var s=Math.max(0,Math.min(100,parseInt((t.pageY*Common.Utils.zoom()-o.offset().top)/o.height()*100)));i.css("top",s+"%"),d=parseInt(360*s/100),m({h:d,s:h,b:p})}},f=function(t,e,i){$(document).on("mouseup",C),$(document).on("mousemove",g)},C=function(t,e,i){$(document).off("mouseup",C),$(document).off("mousemove",g),g(t)},v=function(t,e,i){$(document).on("mouseup",_),$(document).on("mousemove",b),b(t)},_=function(t,e,i){$(document).off("mouseup",_),$(document).off("mousemove",b)},y=function(t){var e=new Common.util.RGBColor(c.color).toHSB();m(e,!0)},w=function(t){var m,g=$(c.el);g&&(e=g.find(".cnt-hb-arrow"),i=g.find(".cnt-sat-arrow"),n=g.find(".cnt-hb"),o=g.find(".cnt-sat"),s=g.find(".color-value"),r=g.find(".color-text"),l=g.find(".empty-color"),s.length>0&&(a=s.find(".transparent-color")),n.length>0&&(n.off("mousedown"),n.on("mousedown",f)),o.length>0&&(o.off("mousedown"),o.on("mousedown",v)),l.length>0&&(l.off("click"),l.on("click",y)),m="transparent"==c.color?{h:0,s:100,b:100}:new Common.Utils.RGBColor(c.color).toHSB(),d=m.h,h=m.s,p=m.b,d==h&&d==p&&0==d&&(h=100),u())};c.setColor=function(t){if(c.color!=t){var e;e="transparent"==t?{h:0,s:100,b:100}:new Common.Utils.RGBColor(t).toHSB(),d=e.h,h=e.s,p=e.b,d==h&&d==p&&0==d&&(h=100),c.color=t,u()}},c.getColor=function(){return c.color},c.on("render:after",w),c.render()},render:function(){return(this.$el||$(this.el)).html(this.template()),this.trigger("render:after",this),this},textNoColor:"No Color"})}),void 0===Common)var Common={};if(define("common/main/lib/component/MaskedField",["common/main/lib/component/BaseView"],function(){"use strict";Common.UI.MaskedField=Common.UI.BaseView.extend({options:{maskExp:"",maxLength:999},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this,i=e.$el||$(this.el);i.addClass("masked-field user-select"),i.attr("maxlength",e.options.maxLength),i.on("keypress",function(t){var n=String.fromCharCode(t.which) ;e.options.maskExp.test(n)||t.ctrlKey||(t.keyCode==Common.UI.Keys.RETURN&&e.trigger("changed",e,i.val()),t.preventDefault(),t.stopPropagation())}),i.on("input",function(t){e.trigger("change",e,i.val())}),i.on("blur",function(t){e.trigger("changed",e,i.val())})},render:function(){return this},setValue:function(t){this.options.maskExp.test(t)&&t.length<=this.options.maxLength&&this.$el.val(t)},getValue:function(){this.$el.val()}})}),void 0===Common)var Common={};if(define("common/main/lib/view/ExtendedColorDialog",["text!common/main/lib/template/ExtendedColorDialog.template","common/main/lib/component/HSBColorPicker","common/main/lib/component/MetricSpinner","common/main/lib/component/MaskedField","common/main/lib/component/Window"],function(t){"use strict";Common.UI.ExtendedColorDialog=Common.UI.Window.extend(_.extend({tpl:_.template(t),options:{},rendered:!1,initialize:function(t){Common.UI.Window.prototype.initialize.call(this,{cls:"extended-color-dlg",tpl:this.tpl({txtNew:this.textNew,txtCurrent:this.textCurrent,txtAdd:this.addButtonText,txtCancel:this.cancelButtonText}),header:!1,width:340,height:272}),this.hexRe=/\s*#?([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)\s*/},render:function(){function t(t){e.trigger("onmodalresult",parseInt(t.currentTarget.attributes.result.value)),e.close(!0)}var e=this;return Common.UI.Window.prototype.render.call(this),this.colorsPicker=new Common.UI.HSBColorPicker({el:$("#id-hsb-colorpicker"),showCurrentColor:!1}),this.colorsPicker.on("changecolor",_.bind(this.onChangeColor,this)),this.colorNew=$("#field-new-color"),this.colorSaved=$("#field-start-color"),this.spinR=new Common.UI.MetricSpinner({el:$("#extended-spin-r"),step:1,width:63,value:"0",defaultUnit:"",maxValue:255,minValue:0,maskExp:/[0-9]/,allowDecimal:!1}),this.spinG=new Common.UI.MetricSpinner({el:$("#extended-spin-g"),step:1,width:63,value:"0",defaultUnit:"",maxValue:255,minValue:0,maskExp:/[0-9]/,allowDecimal:!1}),this.spinB=new Common.UI.MetricSpinner({el:$("#extended-spin-b"),step:1,width:63,value:"0",defaultUnit:"",maxValue:255,minValue:0,maskExp:/[0-9]/,allowDecimal:!1}),this.textColor=new Common.UI.MaskedField({el:$("#extended-text-color"),width:55,maskExp:/[a-fA-F0-9]/,maxLength:6}),this.spinR.on("change",_.bind(this.showColor,this,null,!0)).on("changing",_.bind(this.onChangingRGB,this,1)),this.spinG.on("change",_.bind(this.showColor,this,null,!0)).on("changing",_.bind(this.onChangingRGB,this,2)),this.spinB.on("change",_.bind(this.showColor,this,null,!0)).on("changing",_.bind(this.onChangingRGB,this,3)),this.textColor.on("change",_.bind(this.onChangeMaskedField,this)),this.textColor.on("changed",_.bind(this.onChangedMaskedField,this)),this.spinR.$el.find("input").attr("maxlength",3),this.spinG.$el.find("input").attr("maxlength",3),this.spinB.$el.find("input").attr("maxlength",3),this.on("close",function(){e.trigger("onmodalresult",0)}),$(this)[0].getChild(".footer .dlg-btn").on("click",t),this.rendered=!0,void 0!==this.color&&this.setColor(this.color),this},getFocusedComponents:function(){return[this.spinR,this.spinG,this.spinB,{cmp:this.textColor,selector:"input"}]},getDefaultFocusableComponent:function(){return this.getChild("#extended-text-color")},onChangeColor:function(t,e){this.colorNew.css({"background-color":e}),this.stopevents=!0;var i=e.match(this.hexRe);this.spinR.setValue(parseInt(i[1],16)),this.spinG.setValue(parseInt(i[2],16)),this.spinB.setValue(parseInt(i[3],16)),this.textColor.setValue((i[1]+i[2]+i[3]).toUpperCase()),this.stopevents=!1},showColor:function(t,e){if(!this.stopevents){var i=this.spinR.getNumberValue(),n=null==i||i<0?0:i>255?255:i;e&&this.spinR.setValue(n,!0),n=n.toString(16),i=this.spinG.getNumberValue();var o=null==i||i<0?0:i>255?255:i;e&&this.spinG.setValue(o,!0),o=o.toString(16),i=this.spinB.getNumberValue();var s=null==i||i<0?0:i>255?255:i;e&&this.spinB.setValue(s,!0),s=s.toString(16);var a=(1==n.length?"0"+n:n)+(1==o.length?"0"+o:o)+(1==s.length?"0"+s:s);this.colorsPicker.setColor("#"+a),"hex"!=t&&this.textColor.setValue(a.toUpperCase()),this.colorNew.css("background-color","#"+a)}},onChangingRGB:function(t,e,i,n){if(!this.stopevents){var o,s,a,r;switch(i=_.isEmpty(i)||isNaN(parseInt(i))?parseInt(e.getValue()):parseInt(i),t){case 1:o=(null==i||isNaN(i)||i<0?0:i>255?255:i).toString(16),r=this.spinG.getNumberValue(),s=(null==r||r<0?0:r>255?255:r).toString(16),r=this.spinB.getNumberValue(),a=(null==r||r<0?0:r>255?255:r).toString(16);break;case 2:r=this.spinR.getNumberValue(),o=(null==r||r<0?0:r>255?255:r).toString(16),s=(null==i||isNaN(i)||i<0?0:i>255?255:i).toString(16),r=this.spinB.getNumberValue(),a=(null==r||r<0?0:r>255?255:r).toString(16);break;case 3:r=this.spinR.getNumberValue(),o=(null==r||r<0?0:r>255?255:r).toString(16),r=this.spinG.getNumberValue(),s=(null==r||r<0?0:r>255?255:r).toString(16),a=(null==i||isNaN(i)||i<0?0:i>255?255:i).toString(16)}var l=(1==o.length?"0"+o:o)+(1==s.length?"0"+s:s)+(1==a.length?"0"+a:a);this.colorsPicker.setColor("#"+l),this.textColor.setValue(l.toUpperCase()),this.colorNew.css("background-color","#"+l)}},onChangeMaskedField:function(t,e){e=/^[a-fA-F0-9]{0,6}$/.test(e)?e:"000000",e="000000"+e;var i=e.match(/([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})$/i);this.stopevents=!0,this.spinR.setValue(parseInt(i[1],16)),this.spinG.setValue(parseInt(i[2],16)),this.spinB.setValue(parseInt(i[3],16)),this.stopevents=!1,this.rendered&&this.showColor("hex")},onChangedMaskedField:function(t,e){/^[a-fA-F0-9]{0,6}$/.test(e)&&!_.isEmpty(e)||t.setValue("000000"),this.rendered&&this.showColor("",!0)},getColor:function(){var t=/#?([a-fA-F0-9]{6})/.exec(this.colorsPicker.getColor());return t?t[1]:null},setColor:function(t){var e=this;if(!0!==this.rendered)return void(this.color=t);var i=/#?([a-fA-F0-9]{6})/.test(t)?t:"ff0000";e.colorsPicker.setColor("#"+i),function(){"transparent"==t?e.colorSaved.addClass("color-transparent"):(e.colorSaved.removeClass("color-transparent"),e.colorSaved.css("background-color","#"+t)),e.colorNew.css("background-color","#"+i)}(),e.stopevents=!0;var n=e.hexRe.exec(i);e.spinR.setValue(parseInt(n[1],16)),e.spinG.setValue(parseInt(n[2],16)),e.spinB.setValue(parseInt(n[3],16)),e.textColor.setValue((n[1]+n[2]+n[3]).toUpperCase()),e.stopevents=!1},onPrimary:function(){return this.trigger("onmodalresult",1),this.close(!0),!1},addButtonText:"Add",textNew:"New",textCurrent:"Current",textRGBErr:"The entered value is incorrect.
    Please enter a numeric value between 0 and 255.",textHexErr:"The entered value is incorrect.
    Please enter a value between 000000 and FFFFFF."},Common.UI.ExtendedColorDialog||{}))}),void 0===Common)var Common={};define("common/main/lib/component/ThemeColorPalette",["common/main/lib/component/BaseView","common/main/lib/view/ExtendedColorDialog"],function(){"use strict";Common.UI.ThemeColorPalette=Common.UI.BaseView.extend(_.extend({options:{dynamiccolors:10,standardcolors:10,themecolors:10,effects:5,allowReselect:!0,transparent:!1,value:"000000"},template:_.template('
    <% var me = this; %><% $(colors).each(function(num, item) { %><% if (me.isBlankSeparator(item)) { %>
    <% } else if (me.isSeparator(item)) { %>
    <% } else if (me.isColor(item)) { %>  <% } else if (me.isTransparent(item)) { %> <% } else if (me.isEffect(item)) { %> <% } else if (me.isCaption(item)) { %>
    <%=item%>
    <% } %><% }); %>
    <% if (me.options.dynamiccolors!==undefined) { %>
    <% for (var i=0; i <% } %><% } %>
    '),colorRe:/(?:^|\s)color-(.{6})(?:\s|$)/,selectedCls:"selected",initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this,i=e.$el||$(this.el);this.colors=e.options.colors||this.generateColorData(e.options.themecolors,e.options.effects,e.options.standardcolors,e.options.transparent),i.addClass("theme-colorpalette"),this.render(),this.options.updateColorsArr&&this.updateColors(this.options.updateColorsArr[0],this.options.updateColorsArr[1]),this.options.value&&this.select(this.options.value,!0),this.updateCustomColors(),i.closest(".btn-group").on("show.bs.dropdown",_.bind(this.updateCustomColors,this)),i.closest(".dropdown-submenu").on("show.bs.dropdown",_.bind(this.updateCustomColors,this)),i.on("click",_.bind(this.handleClick,this))},render:function(){return this.$el.html(this.template({colors:this.colors})),this},isBlankSeparator:function(t){return"string"==typeof t&&"-"==t},isSeparator:function(t){return"string"==typeof t&&"--"==t},isColor:function(t){return"string"==typeof t&&/[0-9A-F]{6}/.test(t)},isTransparent:function(t){return"string"==typeof t&&"transparent"==t},isCaption:function(t){return"string"==typeof t&&"-"!=t&&"--"!=t&&!/[0-9A-F]{6}|transparent/.test(t)},isEffect:function(t){return"object"==typeof t&&void 0!==t.effectId},getColor:function(){return this.value},updateCustomColors:function(){var t=this.$el||$(this.el);if(t){var e=t.find("a."+this.selectedCls),i=e.length>0&&/color-dynamic/.test(e[0].className)?e.attr("color"):void 0;i&&(i=i.toUpperCase(),e.removeClass(this.selectedCls));var n=Common.localStorage.getItem("asc."+Common.localStorage.getId()+".colors.custom");n=n?n.split(","):[];for(var o,s=-1,a=n.lengththis.options.dynamiccolors&&i.shift(),Common.localStorage.setItem(e,i.join().toUpperCase())},addNewColor:function(t){var e=this,i=new Common.UI.ExtendedColorDialog({});i.on("onmodalresult",function(t){e._isdlgopen=!1,1==t&&(e.setCustomColor(i.getColor()),e.fireEvent("select",e,i.getColor()))}),e._isdlgopen=!0,i.setColor(void 0!==e.value&&!1!==e.value?e.value:void 0!==t?t:"000000"),i.show()},isDialogOpen:function(){return 1==this._isdlgopen},select:function(t,e){var i=this.$el||$(this.el);if(i.find("a."+this.selectedCls).removeClass(this.selectedCls),"object"==typeof t){var n;void 0!==t.effectId?(n=i.find('a[effectid="'+t.effectId+'"]').first(),n.length>0?(n.addClass(this.selectedCls),this.value=n[0].className.match(this.colorRe)[1].toUpperCase()):this.value=!1):void 0!==t.effectValue&&(n=i.find('a[effectvalue="'+t.effectValue+'"].color-'+t.color.toUpperCase()).first(),n.length>0?(n.addClass(this.selectedCls),this.value=n[0].className.match(this.colorRe)[1].toUpperCase()):this.value=!1)}else if(/#?[a-fA-F0-9]{6}/.test(t)&&(t=/#?([a-fA-F0-9]{6})/.exec(t)[1].toUpperCase(),this.value=t),/^[a-fA-F0-9]{6}|transparent$/.test(t)&&_.indexOf(this.colors,t)>=0)_.indexOf(this.colors,this.value)<0&&(this.value=!1),(t!=this.value||this.options.allowReselect)&&("transparent"==t?i.find("a.color-transparent").addClass(this.selectedCls):i.find("a.palette-color.color-"+t).first().addClass(this.selectedCls),this.value=t,!0!==e&&this.fireEvent("select",this,t));else{var o=i.find("#"+t).first();0==o.length&&(o=i.find('a[color="'+t+'"]').first()),o.length>0&&(o.addClass(this.selectedCls),this.value=t.toUpperCase())}},selectByRGB:function(t,e){var i=this.$el||$(this.el);i.find("a."+this.selectedCls).removeClass(this.selectedCls);var n="object"==typeof t?t.color:t;if(/#?[a-fA-F0-9]{6}/.test(n)&&(n=/#?([a-fA-F0-9]{6})/.exec(n)[1].toUpperCase()),/^[a-fA-F0-9]{6}|transparent$/.test(n)&&(n!=this.value||this.options.allowReselect)){var o="transparent"==n?i.find("a.color-transparent"):i.find("a.color-"+n).first();0==o.length&&(o=i.find("#"+n).first()),0==o.length&&(o=i.find('a[color="'+n+'"]').first()),o.length>0&&(o.addClass(this.selectedCls),this.value=n),!0!==e&&this.fireEvent("select",this,n)}},updateColors:function(t,e,i){if(void 0!==t&&void 0!==e){var n=this,o=n.$el||$(this.el);void 0===n.aColorElements&&(n.aColorElements=o.find("a.palette-color")),void 0===n.aEffectElements&&(n.aEffectElements=o.find("a.palette-color-effect"));for(var s,a=0,r=0,l=0;l=e.length)continue;s=$(n.aColorElements[a]),s.removeClass("color-"+n.colors[l]),n.colors[l]=e[a].toUpperCase(),s.addClass("color-"+n.colors[l]),s.css({background:"#"+n.colors[l]}),s.find("span").first().css({background:"#"+n.colors[l]}),a++}else if("object"==typeof n.colors[l]&&void 0!==n.colors[l].effectId){if(r>=t.length)continue;s=$(n.aEffectElements[r]),t[r].color=t[r].color.toUpperCase(),n.colors[l].color!==t[r].color&&(s.removeClass("color-"+n.colors[l].color),s.addClass("color-"+t[r].color),s.css({background:"#"+t[r].color}),s.find("span").first().css({background:"#"+t[r].color})),n.colors[l].effectId!==t[r].effectId&&s.attr("effectid",""+t[r].effectId),n.colors[l].effectValue!==t[r].effectValue&&s.attr("effectvalue",""+t[r].effectValue),n.colors[l]=t[r],r++}if(i)this.select(i,!0);else{var c=o.find("a."+this.selectedCls);c.length&&c.hasClass("palette-color-effect")&&(this.value=c[0].className.match(this.colorRe)[1].toUpperCase())}this.options.updateColorsArr=void 0}},clearSelection:function(t){this.$el.find("a."+this.selectedCls).removeClass(this.selectedCls),this.value=void 0},generateColorData:function(t,e,i,n){var o=[],s=t>0&&e>0?t*e:0;if(t>0){o=[this.textThemeColors,"-"];for(var a=0;a0&&o.push("-");for(var a=0;a','",'
    ','
    '+e.contentTemplate+"
    ","",'
    '].join(""),e.tpl=_.template(this.template)(e),this.handler=e.handler,this.toggleGroup=e.toggleGroup,this.contentWidth=e.contentWidth,this.storageName=e.storageName,Common.UI.Window.prototype.initialize.call(this,e)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();e.find(".dlg-btn").on("click",_.bind(this.onDlgBtnClick,this)),this.btnsCategory=[],_.each(e.find(".btn-category"),function(e,i){var n=$(e),o=new Common.UI.Button({el:n,enableToggle:!0,toggleGroup:t.toggleGroup,allowDepress:!1,contentTarget:n.attr("content-target")});o.on("click",_.bind(t.onCategoryClick,t,o,i)),t.btnsCategory.push(o)});var i=e.find(".content-panel"),n=e.find(".menu-panel");i.width(this.contentWidth),e.width((n.length>0?n.width():0)+i.outerWidth()+2),this.content_panels=e.find(".settings-panel"),this.btnsCategory.length>0&&this.btnsCategory[0].toggle(!0,!0)},setHeight:function(t){Common.UI.Window.prototype.setHeight.call(this,t),this.getChild().find(".body > .box").css("height",t-85)},onDlgBtnClick:function(t){var e=t.currentTarget.attributes.result.value;this.handler&&this.handler.call(this,e,"ok"==e?this.getSettings():void 0)||this.close()},onCategoryClick:function(t,e){this.content_panels.filter(".active").removeClass("active"),$("#"+t.options.contentTarget).addClass("active")},getSettings:function(){},onPrimary:function(){if(!this.handler||!this.handler.call(this,"ok",this.getSettings()))return this.close(),!1},setActiveCategory:function(t){if(!(this.btnsCategory.length<1)){t=t>=0&&t0&&this._changedProps.put_H(Common.Utils.Metric.fnRecalcToMM(this.spnHeight.getNumberValue())))},t)),this.cmbHeight.setValue(this._arrHeight[0].value),this.spnHeight=new Common.UI.MetricSpinner({el:$("#frame-advanced-input-height"),maxValue:55.88,minValue:.02,step:.1,defaultUnit:"cm",value:""}).on("change",_.bind(function(e,i,n){if(t._changedProps){var o=Asc.linerule_Auto;t.cmbHeight.getValue()==t._arrHeight[1].value?o=Asc.linerule_Exact:t.cmbHeight.getValue()==t._arrHeight[2].value&&(o=Asc.linerule_AtLeast),o==Asc.linerule_Auto&&(t.cmbHeight.suspendEvents(),t.cmbHeight.setValue(t._arrHeight[2].value),o=Asc.linerule_AtLeast,t.cmbHeight.resumeEvents()),t._changedProps.put_HRule(o),t._changedProps.put_H(Common.Utils.Metric.fnRecalcToMM(e.getNumberValue()))}},t)),this.spnX=new Common.UI.MetricSpinner({el:$("#frame-advanced-input-hdist"),maxValue:55.87,minValue:0,step:.1,defaultUnit:"cm",value:"0 cm",width:"auto"}).on("change",_.bind(function(e,i,n){t._changedProps&&t._changedProps.put_HSpace(Common.Utils.Metric.fnRecalcToMM(e.getNumberValue()))},t)),this.spnY=new Common.UI.MetricSpinner({el:$("#frame-advanced-input-vdist"),maxValue:55.87,minValue:0,step:.1,defaultUnit:"cm",value:"0 cm",width:"auto"}).on("change",_.bind(function(e,i,n){t._changedProps&&t._changedProps.put_VSpace(Common.Utils.Metric.fnRecalcToMM(e.getNumberValue()))},t)),this._arrHAlign=[{displayValue:this.textLeft,value:Asc.c_oAscXAlign.Left},{displayValue:this.textCenter, @@ -31,16 +31,16 @@ Color:Common.Utils.ThemeColor.getHexColor(b.get_r(),b.get_g(),b.get_b())}:this.T return'
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n \n \n
    \n
    \n \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n \n \n
    \n
    \n
    \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n \n \n \n
    \n \n \n \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n \n
    \n
    \n
    \n
    \n'}),function(t,e){function i(t,e,i,n,o){this.Start=t,this.End=e,this.Name=i,this.Lid=n,this.Param=o}function n(t,e){var i=0,n=e.length-1,o=0,s=null;if(i>=n)return null;for(;i>1,s=e[o];if(s.Start>t)n=o-1;else{if(!(s.Endn?null:(s=e[i],s.Start>t||s.End','
    ','",'","
    ",'
    ','',"",'",'","","
    ','",'
    ',"
    ','",'
    ',"
    ",'',"",'","","",'","","
    ','
    ','
    ','
    ',"
    ",'
    ',"
    ","
    ","
    ","
    ","
    ','",'
    ',"
    ",'',"",'",'","","",'",'","","
    ','","',"
    ','
    ',"
    ','
    ',"
    ","
    ",'
    ','',"","","","","","","
    ","",'","
    ",'
    ',"
    ","
    ",""].join(""),this.options.tpl=_.template(this.template)(this.options);var h=e.length<1;h&&this.initFonts(),this.fillRecentSymbols();var p;if(t.font?p=t.font:n.length>0&&(p=n[0].font),p)for(var m=0;m0&&(s=n[0].symbol),h&&this.options.lang&&"en"!=this.options.lang){var u=this;f(this.options.lang,function(){u.updateRangeSelector()})}Common.UI.Window.prototype.initialize.call(this,this.options),this.on("resizing",_.bind(this.onWindowResizing,this)),this.on("resize",_.bind(this.onWindowResize,this)),a=!0},initFonts:function(){var t=this.api.pluginMethod_GetFontList();t.sort(function(t,e){return t.m_wsFontNamee.m_wsFontName?1:0});for(var i,n,s,a=[],r={},l=0;le.displayValue.toLowerCase()?1:-1}),l=0;l31&&t.getRangeBySymbol(i,l)){var c=0===n.find("#c"+l).length;s=l,a=!0,t.updateView(c,void 0,!1)}}).on("change:after",function(e,i,n){t.updateInput()}),this.symbolTablePanel=n.find("#symbol-table-scrollable-div"),this.previewPanel=n.find("#id-preview-data"),this.previewParent=this.previewPanel.parent(),this.previewScrolled=n.find("#id-preview"),this.previewInner=this.previewScrolled.find("div:first-child"),this.recentPanel=n.find("#symbol-table-recent"),this.fontLabel=n.find("#symbol-table-label-font"),this.boxPanel=n.find(".box"),this.updateView(void 0,void 0,void 0,!0);var r=[{symbol:"—",description:this.textEmDash,shortcutKey:"Alt+Ctrl+Num -",code:"2014"},{symbol:"–",description:this.textEnDash,shortcutKey:"",code:"2013"},{symbol:"‑",description:this.textNBHyphen,shortcutKey:"Ctrl+Shift+_",code:"002D",special:{NonBreakingHyphen:!0}},{symbol:"",description:this.textEmSpace,shortcutKey:"",code:"2003"},{symbol:"",description:this.textEnSpace,shortcutKey:"",code:"2002"},{symbol:"",description:this.textQEmSpace,shortcutKey:"",code:"2005"},{symbol:"°",description:this.textNBSpace,shortcutKey:"Ctrl+Shift+Space",code:"00A0"},{symbol:"©",description:this.textCopyright,shortcutKey:"",code:"00A9"},{symbol:"®",description:this.textRegistered,shortcutKey:"",code:"00AE"},{symbol:"™",description:this.textTradeMark,shortcutKey:"",code:"2122"},{symbol:"§",description:this.textSection,shortcutKey:"",code:"00A7"},{symbol:"¶",description:this.textPilcrow,shortcutKey:"",code:"00B6"},{symbol:"…",description:this.textEllipsis,shortcutKey:"",code:"2026"},{symbol:"‛",description:this.textSOQuote,shortcutKey:"",code:"2018"},{symbol:"’",description:this.textSCQuote,shortcutKey:"",code:"2019"},{symbol:"‟",description:this.textDOQuote,shortcutKey:"",code:"201C"},{symbol:"”",description:this.textDCQuote,shortcutKey:"",code:"201D"}];this.specialList=new Common.UI.ListView({el:n.find("#symbol-table-special-list"),store:new Common.UI.DataViewStore(r),simpleAddMode:!0,template:_.template(['
    '].join("")),itemTemplate:_.template(['
    ','
    <%= symbol %>
    ','
    <%= description %>
    ',"<% if ("+this.showShortcutKey+") { %>",'
    <%= shortcutKey %>
    ',"<% } %>","
    "].join(""))}),this.specialList.on("item:dblclick",_.bind(this.onDblClickSpecialItem,this)).on("entervalue",_.bind(this.onDblClickSpecialItem,this)),this.specialList.selectByIndex(0),this.lblShortCut=n.find("#symbol-table-lbl-shortcut"),this.lblShortCut.toggleClass("hidden",!this.showShortcutKey),n.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.symbolsPanel=n.find("#symbol-table-pnl-symbols"),this.specialPanel=n.find("#symbol-table-pnl-special")},show:function(){Common.UI.Window.prototype.show.apply(this,arguments),this.binding||(this.binding={}),this.binding.keydownSymbols=_.bind(this.onKeyDown,this),this.binding.keypressSymbols=_.bind(this.onKeyPress,this),$(document).on("keydown."+this.cid,"#symbol-table-scrollable-div #id-preview-data, #symbol-table-recent",this.binding.keydownSymbols),$(document).on("keypress."+this.cid,"#symbol-table-scrollable-div #id-preview-data, #symbol-table-recent",this.binding.keypressSymbols);var t=this.special&&!!Common.Utils.InternalSettings.get(this.appPrefix+"symbol-table-special");t?this.btnSpecial.toggle(!0):this.btnSymbols.toggle(!0),this.ShowHideElem(t)},close:function(t){$(document).off("keydown."+this.cid,this.binding.keydownSymbols),$(document).off("keypress."+this.cid,this.binding.keypressSymbols),this.special&&Common.Utils.InternalSettings.set(this.appPrefix+"symbol-table-special",this.btnSpecial.isActive()),Common.UI.Window.prototype.close.apply(this,arguments)},getPasteSymbol:function(t){var i,n=!1;if(t&&t.length>0)if(n="c"===t[0])i=e[o].displayValue;else{var a=parseInt(t.split("_")[2]);i=e[a].displayValue}return{font:i,symbol:this.encodeSurrogateChar(s),code:s,updateRecents:n}},getSpecialSymbol:function(){var t=this.specialList.getSelectedRec();return{font:void 0,symbol:this.encodeSurrogateChar(t.get("code")),code:parseInt(t.get("code"),16),special:t.get("special")}},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value,!0)},onPrimary:function(t){return this._handleInput("ok"),!1},_handleInput:function(t,e){if(e||!document.activeElement||"textarea"!=document.activeElement.localName||!/area_id/.test(document.activeElement.id)){var i=this.btnSpecial.isActive(),n="ok"==t?i?this.getSpecialSymbol():this.getPasteSymbol(this.$window.find(".cell-selected").attr("id")):{};this.options.handler&&this.options.handler.call(this,this,t,n),"ok"==t&&(!i&&this.checkRecent(s,n.font),!i&&n.updateRecents&&this.updateRecents(),this.type)||this.close()}},encodeSurrogateChar:function(t){if(t<65536)return String.fromCharCode(t);t-=65536;var e=55296|t>>10,i=56320|1023&t;return String.fromCharCode(e)+String.fromCharCode(i)},fixedCharCodeAt:function(t,e){e=e||0;var i,n,o=t.charCodeAt(e);if(55296<=o&&o<=56319){if(i=o,n=t.charCodeAt(e+1),isNaN(n))throw"Старшая часть суррогатной пары без следующей младшей в fixedCharCodeAt()";return 1024*(i-55296)+(n-56320)+65536}return!(56320<=o&&o<=57343)&&o},getArrRangesByFont:function(t){var i=getSupportedRangesByFont(e[t]);return 0===i.length&&i.push({Start:32,End:255}),i[0].Start<32&&(i[0].Start=32),i},getRangeBySymbol:function(t,e){for(var i=0;i=e)return t[i];return null},getRangeByName:function(t,e){for(var i=0;ie)return-1;if(i.Start<=e&&i.End>=e)return n+(e-i.Start);n+=i.End-i.Start+1}return-1},getCodeByLinearIndex:function(t,e){if(e<0)return-1;for(var i,n=0,o=t[0],s=0;se)return o.Start+e-n;n+=i}return-1},createTable:function(t,e,i){for(var n,o,s=e*i,a=0,r="",l=0;l>0==e-1?"style='border-bottom: none'":"",l&#'+t[l].toString(10)+""):r+='
    ",++a>=i&&(r+='
    ',a=0);this.previewPanel.html(r)},fillRecentSymbols:function(){var t,e=Common.localStorage.getItem(this.appPrefix+"recentSymbols");""!=e&&(t=JSON.parse(e)),_.isArray(t)&&(n=t)},saveRecent:function(){var t=JSON.stringify(n);Common.localStorage.setItem(this.appPrefix+"recentSymbols",t)},checkRecent:function(t,e){if(0===n.length)return void n.push({symbol:t,font:e});for(var i=0;i36&&n.splice(36,n.length-36),this.saveRecent()},createCell:function(t,i){var n="",o="";if(i){for(var s=0,a=0;a'+o+"");return r.addClass("cell"),r.addClass("noselect"),r.mousedown(_.bind(this.cellClickHandler,this)),i&&r.css("font-family","'"+i+"'"),r},cellClickHandler:function(t){var e=$(t.target).attr("id");if(e){var i=(new Date).getTime();if(e===h&&i-p<300)this.cellDblClickHandler(t);else{if("c"===e[0])s=parseInt(e.slice(1,e.length)),a=!0;else{var n=e.split("_");s=parseInt(n[1]),r=parseInt(n[2]),a=!1}this.updateView(!1)}h=t.target.id,p=i}},cellDblClickHandler:function(t){if(this.type){var e=this.getPasteSymbol($(t.target).attr("id"));this.checkRecent(s,e.font),e.updateRecents&&this.updateView(!1,void 0,void 0,!0),this.fireEvent("symbol:dblclick",this,"ok",e)}else this._handleInput("ok")},onDblClickSpecialItem:function(t){if(this.type){var e=this.getSpecialSymbol();this.fireEvent("symbol:dblclick",this,"ok",e)}else this._handleInput("ok")},updateRecents:function(){var t=this.recentPanel;t.empty();var e=this.getColsCount(),i=n.length;t.width(31*e);for(var o=0;o>0},getMaxHeight:function(){return this.symbolTablePanel.innerHeight()},getRowsCount:function(){return Math.max(1,this.getMaxHeight()/33>>0)},getAllSymbolsCount:function(t){for(var e,i=0,n=0;n>0)),h=d*s,p=a*s,m=[],u=0;u>0),b=Math.min(33*Math.floor(this.previewPanel.height()/33)/10,20),this.scrollerY=new Common.UI.Scroller({el:this.previewScrolled,minScrollbarLength:g,alwaysVisibleY:!0,wheelSpeed:b,useKeyboard:!1,onChange:_.bind(function(){this.scrollerY&&(this._preventUpdateScroll=!0,this.onScrollEnd(),this._preventUpdateScroll=!1,this.previewParent.height(m),this.previewParent.css({top:this.scrollerY.getScrollTop()}))},this)})),this._preventUpdateScroll||(this.scrollerY.update({minScrollbarLength:g,wheelSpeed:b}),this.scrollerY.scrollTop(33*f));var w=this.previewPanel.find(".cell");w.off("mousedown"),w.mousedown(_.bind(this.cellClickHandler,this))}d&&this.updateRecents(),this.$window.find(".cell").removeClass("cell-selected"),a?this.$window.find("#c"+s).addClass("cell-selected"):this.$window.find("#r_"+s+"_"+r).addClass("cell-selected"),!1!==c&&this.updateInput()},onScrollEnd:function(){if(this.scrollerY.getScrollTop()!==d){var t=this.getAllSymbolsCount(i),e=this.getColsCount(),n=this.getRowsCount(),o=Math.ceil(t/e),r=33*o,l=Math.max(0,Math.min(o-n,o*this.scrollerY.getScrollTop()/r+.5>>0));if(d=this.scrollerY.getScrollTop(),a){var c=this.previewPanel.children()[0];if(c){var h=c.id;if(h){var p=parseInt(h.slice(1,h.length)),m=this.getLinearIndexByCode(i,p),u=this.getLinearIndexByCode(i,s),g=u-m,b=l*e+g;s=this.getCodeByLinearIndex(i,b);var f=l*e;for(b-=e;-1===s&&b>=f;)s=this.getCodeByLinearIndex(i,b),b-=e;-1===s&&(s=this.getCodeByLinearIndex(i,f))}else s=this.getCodeByLinearIndex(i,l*e)}}else s=this.getCodeByLinearIndex(i,l*e),a=!0;this.updateView(!0,this.getCodeByLinearIndex(i,l*e))}},updateInput:function(){for(var t=s.toString(16).toUpperCase(),e=t.length,i=e;i<5;++i)t="0"+t;this.inputCode.setValue(t)},updateRangeSelector:function(){var e=this.getRangeBySymbol(i,s);if(e&&e.Name){this.cmbRange.setDisabled(!1);var n,o=[];for(n=0;n0&&(o=i[0].Start):e===Common.UI.Keys.END?i.length>0&&(o=i[i.length-1].End):n=!1,o>-1){s=o;var l=0===this.$window.find("#c"+s).length;this.updateView(l)}}else{var c,d;if(e===Common.UI.Keys.LEFT){if((c=this.$window.find(".cell-selected")[0])&&"r"===c.id[0]){var h=this.$window.find(c).prev();h.length>0&&(d=this.$window.find(h).attr("id").split("_"),s=parseInt(d[1]),r=parseInt(d[2]),this.updateView(!1))}}else if(e===Common.UI.Keys.RIGHT){if((c=this.$window.find(".cell-selected")[0])&&"r"===c.id[0]){var p=this.$window.find(c).next();p.length>0&&(d=this.$window.find(p).attr("id").split("_"),s=parseInt(d[1]),r=parseInt(d[2]),this.updateView(!1))}}else if(e===Common.UI.Keys.HOME){var g=this.$window.find("#recent-table").children()[0];g&&(d=g.id.split("_"),s=parseInt(d[1]),r=parseInt(d[2]),this.updateView(!1))}else if(e===Common.UI.Keys.END){var b=this.recentPanel.children(),f=b[b.length-1];f&&(d=f.id.split("_"),s=parseInt(d[1]),r=parseInt(d[2]),this.updateView(!1))}else n=!1}n&&(u=e,m=(new Date).getTime())}},onKeyPress:function(t){if(!document.activeElement||!document.activeElement.nodeName||"span"!==document.activeElement.nodeName.toLowerCase()){var e=t.which||t.charCode||t.keyCode||0;if(!(u===e&&Math.abs(m-(new Date).getTime())<1e3)){if(!isNaN(e)&&e>31){if(this.getRangeBySymbol(i,e)){var n=0===this.$window.find("#c"+e).length;s=e,a=!0,this.updateView(n,void 0,!0)}}t.preventDefault&&t.preventDefault()}}},onWindowResize:function(t){var e=this.getSize();if(t&&"start"==t[1])this._preventUpdateScroll=!0,this.curSize={resize:!1,width:e[0],height:e[1]};else if(this.curSize.resize){this._preventUpdateScroll=!1,this.curSize.height=e[1]-302+38*(this.special?0:1);var i=Math.max(1,this.curSize.height/33>>0),n=33*i;this.symbolTablePanel.css({height:this.curSize.height+"px"}),this.previewPanel.css({height:n+"px"}),this.previewScrolled.css({height:n+"px"}),this.scrollerY=null,this.updateView(void 0,void 0,void 0,!0),this.specialList.cmpEl.height(e[1]-156+38*(this.special?0:1)),!this.special&&(e[1]+=38);var o=JSON.stringify(e);Common.localStorage.setItem(this.appPrefix+"settings-size-symbol-table",o),Common.Utils.InternalSettings.set(this.appPrefix+"settings-size-symbol-table",o)}},onWindowResizing:function(){if(this.curSize){var t=this.getSize();if(t[0]!==this.curSize.width||t[1]!==this.curSize.height){this.curSize.resize||(this.curSize.resize=!0),this.curSize.width=t[0],this.curSize.height=t[1]-302+38*(this.special?0:1);var e=Math.max(1,this.curSize.height/33>>0),i=33*e;this.symbolTablePanel.css({height:this.curSize.height+"px"}),this.previewPanel.css({height:i+"px"}),this.previewScrolled.css({height:i+"px"}),this.specialList.cmpEl.height(t[1]-156+38*(this.special?0:1)),this.updateView(void 0,void 0,void 0,!0)}}},onModeClick:function(t,e,i){this.ShowHideElem(t)},ShowHideElem:function(t){this.symbolsPanel.toggleClass("hidden",t),this.specialPanel.toggleClass("hidden",!t);var e=this;_.delay(function(){t?e.specialList.focus():e.previewPanel.focus()},50)},textTitle:"Symbol",textFont:"Font",textRange:"Range",textRecent:"Recently used symbols",textCode:"Unicode HEX value",textSymbols:"Symbols",textSpecial:"Special characters",textCharacter:"Character",textShortcut:"Shortcut key",textEmDash:"Em Dash",textEnDash:"En Dash",textNBHyphen:"Non-breaking Hyphen",textSHyphen:"Soft Hyphen",textEmSpace:"Em Space",textEnSpace:"En Space",textQEmSpace:"1/4 Em Space",textNBSpace:"No-break Space",textCopyright:"Copyright Sign",textRegistered:"Registered Sign",textTradeMark:"Trade Mark Sign",textSection:"Section Sign",textPilcrow:"Pilcrow Sign",textEllipsis:"Horizontal Ellipsis",textSOQuote:"Single Opening Quote",textSCQuote:"Single Closing Quote",textDOQuote:"Double Opening Quote",textDCQuote:"Double Closing Quote"},Common.Views.SymbolTableDialog||{}))}),define("documenteditor/main/app/view/EditListItemDialog",["common/main/lib/component/Window","common/main/lib/component/InputField"],function(){"use strict";DE.Views.EditListItemDialog=Common.UI.Window.extend(_.extend({options:{width:330,header:!1,cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,t||{}),this.template=['
    ','
    ',"","
    ",'
    ','
    ',"","
    ",'
    ',"
    "].join(""),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this;t.inputName=new Common.UI.InputField({el:$("#id-dlg-label-name"),allowBlank:!1,blankError:t.textNameError,style:"width: 100%;",maxLength:256,validateOnBlur:!1,validation:function(t){return!!t||""}}),t.inputName._input.on("input",function(e){void 0==t.copyvalue&&t.inputValue.getValue()==t.inputName.getValue()&&(t.copyvalue=1),1==t.copyvalue?t.inputValue.setValue($(e.target).val()):2==t.copyvalue&&(t.copyvalue=0)}),t.inputValue=new Common.UI.InputField({el:$("#id-dlg-label-value"),style:"width: 100%;",maxLength:256,validateOnBlur:!1,validation:function(e){if(""!==e&&t.options.store){if(t.options.store.findWhere({value:e}))return t.textValueError}return!0}}),t.inputValue._input.on("input",function(e){void 0==t.copyvalue&&t.inputValue.getValue()==t.inputName.getValue()&&(t.copyvalue=2),2==t.copyvalue?t.inputName.setValue($(e.target).val()):1==t.copyvalue&&(t.copyvalue=0)}),this.getChild().find(".btn").on("click",_.bind(this.onBtnClick,this))},getFocusedComponents:function(){return[this.inputName,this.inputValue]},getDefaultFocusableComponent:function(){return this.inputName},onPrimary:function(t){return this._handleInput("ok"),!1},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},_handleInput:function(t){if(this.options.handler){if("ok"==t){if(!0!==this.inputName.checkValidate())return void this.inputName.focus();if(!0!==this.inputValue.checkValidate())return void this.inputValue.focus()}this.options.handler.call(this,t,this.inputName.getValue(),this.inputValue.getValue())}this.close()},setSettings:function(t){t&&(this.inputName.setValue(t.name||""),this.inputValue.setValue(t.value||""))},textDisplayName:"Display name",textValue:"Value",textNameError:"Display name must not be empty.",textValueError:"An item with the same value already exists."},DE.Views.EditListItemDialog||{}))}),define("documenteditor/main/app/view/ControlSettingsDialog",["text!documenteditor/main/app/template/ControlSettingsDialog.template","common/main/lib/util/utils","common/main/lib/component/CheckBox","common/main/lib/component/InputField","common/main/lib/view/AdvancedSettingsWindow","common/main/lib/view/SymbolTableDialog","documenteditor/main/app/view/EditListItemDialog"],function(t){"use strict";DE.Views.ControlSettingsDialog=Common.Views.AdvancedSettingsWindow.extend(_.extend({options:{contentWidth:310,height:392,toggleGroup:"control-adv-settings-group",storageName:"de-control-settings-adv-category"},initialize:function(e){_.extend(this.options,{title:this.textTitle,items:[{panelId:"id-adv-control-settings-general",panelCaption:this.strGeneral},{panelId:"id-adv-control-settings-lock",panelCaption:this.textLock},{panelId:"id-adv-control-settings-list",panelCaption:this.textCombobox},{panelId:"id-adv-control-settings-date",panelCaption:this.textDate},{panelId:"id-adv-control-settings-checkbox",panelCaption:this.textCheckbox},{panelId:"id-adv-control-settings-field",panelCaption:this.textField},{panelId:"id-adv-control-settings-additional",panelCaption:this.textAdditional}],contentTemplate:_.template(t)({scope:this})},e),this.handler=e.handler,this.props=e.props,this.api=e.api,Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this,this.options)},render:function(){Common.Views.AdvancedSettingsWindow.prototype.render.call(this);var t=this;this.txtName=new Common.UI.InputField({el:$("#control-settings-txt-name"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",maxLength:64,value:""}),this.txtTag=new Common.UI.InputField({el:$("#control-settings-txt-tag"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",maxLength:64,value:""}),this.txtPlaceholder=new Common.UI.InputField({el:$("#control-settings-txt-pholder"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",value:""}),this.cmbShow=new Common.UI.ComboBox({el:$("#control-settings-combo-show"),cls:"input-group-nr",menuStyle:"min-width: 120px;",editable:!1,takeFocusOnClose:!0,data:[{displayValue:this.textBox,value:Asc.c_oAscSdtAppearance.Frame},{displayValue:this.textNone,value:Asc.c_oAscSdtAppearance.Hidden}]}),this.cmbShow.setValue(Asc.c_oAscSdtAppearance.Frame),this.btnColor=new Common.UI.ColorButton({parentEl:$("#control-settings-color-btn"),additionalItems:[{id:"control-settings-system-color",caption:this.textSystemColor,template:_.template('<%= caption %>')},{caption:"--"}],additionalAlign:this.menuAddAlign,color:"000000",colors:["000000","993300","333300","003300","003366","000080","333399","333333","800000","FF6600","808000","00FF00","008080","0000FF","666699","808080","FF0000","FF9900","99CC00","339966","33CCCC","3366FF","800080","999999","FF00FF","FFCC00","FFFF00","00FF00","00FFFF","00CCFF","993366","C0C0C0","FF99CC","FFCC99","FFFF99","CCFFCC","CCFFFF","C9C8FF","CC99FF","FFFFFF"],paletteHeight:94}),this.btnColor.on("color:select",_.bind(this.onColorsSelect,this)),this.colors=this.btnColor.getPicker(),$("#control-settings-system-color").on("click",_.bind(this.onSystemColor,this)),this.btnApplyAll=new Common.UI.Button({el:$("#control-settings-btn-all")}),this.btnApplyAll.on("click",_.bind(this.applyAllClick,this)),this.chLockDelete=new Common.UI.CheckBox({el:$("#control-settings-chb-lock-delete"),labelText:this.txtLockDelete}),this.chLockEdit=new Common.UI.CheckBox({el:$("#control-settings-chb-lock-edit"),labelText:this.txtLockEdit}),this.list=new Common.UI.ListView({el:$("#control-settings-list",this.$window),store:new Common.UI.DataViewStore,emptyText:"",template:_.template(['
    '].join("")),itemTemplate:_.template(['
    ','
    <%= name %>
    ','
    <%= value %>
    ',"
    "].join("")),tabindex:1}),this.list.on("item:select",_.bind(this.onSelectItem,this)),this.btnAdd=new Common.UI.Button({el:$("#control-settings-btn-add")}),this.btnAdd.on("click",_.bind(this.onAddItem,this)),this.btnChange=new Common.UI.Button({el:$("#control-settings-btn-change")}),this.btnChange.on("click",_.bind(this.onChangeItem,this)),this.btnDelete=new Common.UI.Button({el:$("#control-settings-btn-delete")}),this.btnDelete.on("click",_.bind(this.onDeleteItem,this)),this.btnUp=new Common.UI.Button({el:$("#control-settings-btn-up")}),this.btnUp.on("click",_.bind(this.onMoveItem,this,!0)),this.btnDown=new Common.UI.Button({el:$("#control-settings-btn-down")}),this.btnDown.on("click",_.bind(this.onMoveItem,this,!1));var e=[{value:1068},{value:1026},{value:1029},{value:1031},{value:2055},{value:1032},{value:3081},{value:2057},{value:1033},{value:3082},{value:2058},{value:1035},{value:1036},{value:1040},{value:1041},{value:1042},{value:1062},{value:1043},{value:1045},{value:1046},{value:2070},{value:1049},{value:1051},{value:1060},{value:2077},{value:1053},{value:1055},{value:1058},{value:1066},{value:2052}];e.forEach(function(t){var e=Common.util.LanguageInfo.getLocalLanguageName(t.value);t.displayValue=e[1],t.langName=e[0]}),this.cmbLang=new Common.UI.ComboBox({el:$("#control-settings-lang"),menuStyle:"min-width: 100%; max-height: 185px;",cls:"input-group-nr",editable:!1,takeFocusOnClose:!0,data:e,search:!0,scrollAlwaysVisible:!0}),this.cmbLang.setValue(1033),this.cmbLang.on("selected",function(e,i){t.updateFormats(i.value)}),this.listFormats=new Common.UI.ListView({el:$("#control-settings-format"),store:new Common.UI.DataViewStore,scrollAlwaysVisible:!0,tabindex:1}),this.listFormats.on("item:select",_.bind(this.onSelectFormat,this)),this.txtDate=new Common.UI.InputField({el:$("#control-settings-txt-format"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",value:""}),this.btnEditChecked=new Common.UI.Button({el:$("#control-settings-btn-checked-edit"),hint:this.tipChange}),this.btnEditChecked.cmpEl.css({"font-size":"16px","line-height":"16px"}),this.btnEditChecked.on("click",_.bind(this.onEditCheckbox,this,!0)),this.btnEditUnchecked=new Common.UI.Button({el:$("#control-settings-btn-unchecked-edit"),hint:this.tipChange}),this.btnEditUnchecked.cmpEl.css({"font-size":"16px","line-height":"16px"}),this.btnEditUnchecked.on("click",_.bind(this.onEditCheckbox,this,!1)),this.txtGroupKey=new Common.UI.InputField({el:$("#control-settings-txt-groupkey"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",value:""}),this.txtKey=new Common.UI.InputField({el:$("#control-settings-txt-key"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",value:""}),this.txtLabel=new Common.UI.InputField({el:$("#control-settings-txt-label"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",value:""}),this.textareaHelp=this.$window.find("#control-settings-txt-help"),this.textareaHelp.keydown(function(e){e.keyCode==Common.UI.Keys.RETURN&&e.stopPropagation(),t.isHelpChanged=!0}),this.chRequired=new Common.UI.CheckBox({el:$("#control-settings-chb-required"),labelText:this.textRequired}),this.btnEditPlaceholder=new Common.UI.Button({el:$("#control-settings-btn-placeholder-edit"),hint:this.tipChange}),this.btnEditPlaceholder.cmpEl.css({"font-size":"16px","line-height":"16px"}),this.btnEditPlaceholder.on("click",_.bind(this.onEditPlaceholder,this)),this.spnWidth=new Common.UI.MetricSpinner({el:$("#control-settings-spin-width"),step:.1,width:80,defaultUnit:"cm",value:"Auto",allowAuto:!0,maxValue:55.88,minValue:.1}),this.spnMaxChars=new Common.UI.MetricSpinner({el:$("#control-settings-spin-max-chars"),step:1,width:53,defaultUnit:"",value:"10",maxValue:1e6,minValue:1}),this.chMaxChars=new Common.UI.CheckBox({el:$("#control-settings-chb-max-chars"),labelText:this.textMaxChars}),this.chMaxChars.on("change",_.bind(function(t,e,i,n){this.spnMaxChars.setDisabled("checked"!=t.getValue())},this)),this.chComb=new Common.UI.CheckBox({el:$("#control-settings-chb-comb"),labelText:this.textComb}),this.chComb.on("change",_.bind(function(t,e,i,n){var o="checked"==t.getValue();o&&this.chMaxChars.setValue(!0),this.btnEditPlaceholder.setDisabled(!o),this.spnWidth.setDisabled(!o)},this)),this.afterRender()},getFocusedComponents:function(){return[this.txtName,this.txtTag,this.txtPlaceholder,this.cmbShow,{cmp:this.list,selector:".listview"},this.txtDate,{cmp:this.listFormats,selector:".listview"},this.cmbLang]},onCategoryClick:function(t,e){Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this,t,e);var i=this;setTimeout(function(){0==e?i.txtName.focus():2==e?i.list.focus():3==e&&i.txtDate.focus()},100)},onColorsSelect:function(t,e){var i=this.btnColor.menu.$el.find("#control-settings-system-color > a");i.hasClass("selected")&&i.removeClass("selected"),this.isSystemColor=!1},onSystemColor:function(t){var e=Common.Utils.ThemeColor.getHexColor(220,220,220);this.btnColor.setColor(e),this.colors.clearSelection();var i=this.btnColor.menu.$el.find("#control-settings-system-color > a");!i.hasClass("selected")&&i.addClass("selected"),this.isSystemColor=!0},afterRender:function(){if(this.updateMetricUnit(),this._setDefaults(this.props),this.storageName){var t=Common.localStorage.getItem(this.storageName);this.setActiveCategory(null!==t?parseInt(t):0)}},show:function(){Common.Views.AdvancedSettingsWindow.prototype.show.apply(this,arguments)},_setDefaults:function(t){if(t){var e=t.get_Alias();if(this.txtName.setValue(e||""),e=t.get_Tag(),this.txtTag.setValue(e||""),e=t.get_PlaceholderText(),this.txtPlaceholder.setValue(e||""),e=t.get_Appearance(),null!==e&&void 0!==e&&this.cmbShow.setValue(e),e=t.get_Color(),this.isSystemColor=null===e,e)e=Common.Utils.ThemeColor.getHexColor(e.get_r(),e.get_g(),e.get_b()),this.colors.selectByRGB(e,!0);else{this.colors.clearSelection();var i=this.btnColor.menu.$el.find("#control-settings-system-color > a");!i.hasClass("selected")&&i.addClass("selected"),e=Common.Utils.ThemeColor.getHexColor(220,220,220)}this.btnColor.setColor(e),e=t.get_Lock(),void 0===e&&(e=Asc.c_oAscSdtLockType.Unlocked),this.chLockDelete.setValue(e==Asc.c_oAscSdtLockType.SdtContentLocked||e==Asc.c_oAscSdtLockType.SdtLocked),this.chLockEdit.setValue(e==Asc.c_oAscSdtLockType.SdtContentLocked||e==Asc.c_oAscSdtLockType.ContentLocked);var n,o=t.get_SpecificType();if(this.btnsCategory[2].setVisible(o==Asc.c_oAscContentControlSpecificType.ComboBox||o==Asc.c_oAscContentControlSpecificType.DropDownList),o==Asc.c_oAscContentControlSpecificType.ComboBox||o==Asc.c_oAscContentControlSpecificType.DropDownList){if(this.btnsCategory[2].setCaption(o==Asc.c_oAscContentControlSpecificType.ComboBox?this.textCombobox:this.textDropDown),n=o==Asc.c_oAscContentControlSpecificType.ComboBox?t.get_ComboBoxPr():t.get_DropDownListPr()){for(var s=n.get_ItemsCount(),a=[],r=0;r=0,!0),this.spnMaxChars.setDisabled(!e||e<0),this.spnMaxChars.setValue(e&&e>=0?e:10),e=b.get_Width(),this.spnWidth.setValue(0!==e&&void 0!==e?Common.Utils.Metric.fnRecalcFromMM(25.4*e/20/72):-1,!0)}o!=Asc.c_oAscContentControlSpecificType.CheckBox&&o!=Asc.c_oAscContentControlSpecificType.Picture||u||this.txtPlaceholder.cmpEl&&this.txtPlaceholder.cmpEl.closest("tr").hide()}},getSettings:function(){var t=new AscCommon.CContentControlPr;if(t.put_Alias(this.txtName.getValue()),t.put_Tag(this.txtTag.getValue()),t.put_PlaceholderText(this.txtPlaceholder.getValue()||" "),t.put_Appearance(this.cmbShow.getValue()),this.isSystemColor)t.put_Color(null);else{var e=Common.Utils.ThemeColor.getRgbColor(this.colors.getColor());t.put_Color(e.get_r(),e.get_g(),e.get_b())}var i=Asc.c_oAscSdtLockType.Unlocked;"checked"==this.chLockDelete.getValue()&&"checked"==this.chLockEdit.getValue()?i=Asc.c_oAscSdtLockType.SdtContentLocked:"checked"==this.chLockDelete.getValue()?i=Asc.c_oAscSdtLockType.SdtLocked:"checked"==this.chLockEdit.getValue()&&(i=Asc.c_oAscSdtLockType.ContentLocked),t.put_Lock(i);var n;if(this.type!=Asc.c_oAscContentControlSpecificType.ComboBox&&this.type!=Asc.c_oAscContentControlSpecificType.DropDownList||(n=this.type==Asc.c_oAscContentControlSpecificType.ComboBox?this.props.get_ComboBoxPr():this.props.get_DropDownListPr(),n.clear(),this.list.store.each(function(t,e){n.add_Item(t.get("name"),t.get("value"))}),this.type==Asc.c_oAscContentControlSpecificType.ComboBox?t.put_ComboBoxPr(n):t.put_DropDownListPr(n)),this.type==Asc.c_oAscContentControlSpecificType.DateTime&&(n=this.props.get_DateTimePr(),n.put_DateFormat(this.txtDate.getValue()),n.put_LangId(this.cmbLang.getValue()),t.put_DateTimePr(n)),this.type==Asc.c_oAscContentControlSpecificType.CheckBox&&(this.checkedBox&&this.checkedBox.changed||this.uncheckedBox&&this.uncheckedBox.changed)&&(n=this.props.get_CheckBoxPr(),this.checkedBox&&(n.put_CheckedSymbol(this.checkedBox.code),n.put_CheckedFont(this.checkedBox.font)),this.uncheckedBox&&(n.put_UncheckedSymbol(this.uncheckedBox.code),n.put_UncheckedFont(this.uncheckedBox.font)),t.put_CheckBoxPr(n)),this.btnsCategory[6].isVisible()){var o=new AscCommon.CSdtFormPr;o.put_Key(this.txtKey.getValue()),o.put_Label(this.txtLabel.getValue()),o.put_Required("checked"==this.chRequired.getValue()),this.isHelpChanged&&o.put_HelpText(this.textareaHelp.val()),this.type!=Asc.c_oAscContentControlSpecificType.CheckBox||this.$window.find(".group-key").hasClass("hidden")||(n=this.props.get_CheckBoxPr())&&(n.put_GroupKey(this.txtGroupKey.getValue()),t.put_CheckBoxPr(n)),t.put_FormPr(o)}if(this.btnsCategory[5].isVisible()){var s=new AscCommon.CSdtTextFormPr;if(this.spnWidth.getValue()){var a=this.spnWidth.getNumberValue();s.put_Width(a<=0?0:parseInt(72*Common.Utils.Metric.fnRecalcToMM(a)*20/25.4))}else s.put_Width(0);this.placeholder&&this.placeholder.changed&&(s.put_PlaceHolderSymbol(this.placeholder.code),s.put_PlaceHolderFont(this.placeholder.font)),s.put_Comb("checked"==this.chComb.getValue());var r="checked"==this.chMaxChars.getValue()||"checked"==this.chComb.getValue();s.put_MaxCharacters(r),r&&s.put_MaxCharacters(this.spnMaxChars.getNumberValue()||10),t.put_TextFormPr(s)}return t},onDlgBtnClick:function(t){var e="object"==typeof t?t.currentTarget.attributes.result.value:t;"ok"==e&&this.handler&&this.handler.call(this,e,this.getSettings()),this.close()},applyAllClick:function(t,e){if(this.api){var i=new AscCommon.CContentControlPr;if(i.put_Appearance(this.cmbShow.getValue()),this.isSystemColor)i.put_Color(null);else{var n=Common.Utils.ThemeColor.getRgbColor(this.colors.getColor());i.put_Color(n.get_r(),n.get_g(),n.get_b())}this.api.asc_SetContentControlProperties(i,null,!0)}},onSelectItem:function(t,e,i){this.disableListButtons(!1)},disableListButtons:function(t){void 0===t&&(t=!this.list.getSelectedRec()),this.btnChange.setDisabled(t),this.btnDelete.setDisabled(t),this.btnUp.setDisabled(t),this.btnDown.setDisabled(t)},onAddItem:function(){var t=this;new DE.Views.EditListItemDialog({store:t.list.store,handler:function(e,i,n){if("ok"==e){var o=t.list.store.add({value:n,name:i});o&&(t.list.selectRecord(o),t.list.scrollToRecord(o),t.disableListButtons())}t.list.focus()}}).show()},onChangeItem:function(){var t=this,e=this.list.getSelectedRec(),i=new DE.Views.EditListItemDialog({store:t.list.store,handler:function(i,n,o){"ok"==i&&e&&e.set({value:o,name:n}),t.list.focus()}});e&&i.show(),e&&i.setSettings({name:e.get("name"),value:e.get("value")})},onDeleteItem:function(t,e){var i=this.list.getSelectedRec();if(i){var n=this.list.store,o=_.indexOf(n.models,i);n.remove(i),o>n.length-1&&(o=n.length-1),n.length>0&&(this.list.selectByIndex(o),this.list.scrollToRecord(n.at(o)))}this.disableListButtons(),this.list.focus()},onMoveItem:function(t){var e=this.list.store,i=e.length,n=this.list.getSelectedRec();if(n){var o=e.indexOf(n);e.add(e.remove(n),{at:t?Math.max(0,o-1):Math.min(i-1,o+1)}),this.list.selectRecord(n),this.list.scrollToRecord(n)}this.list.focus()},updateFormats:function(t){if(this.datetime){for(var e=this.datetime,i=e.get_FormatsExamples(),n=[],o=0,s=i.length;o','
    ','
    ',"
    ",""].join(""),this.options.tpl=_.template(this.template)(this.options),this.props=this.options.props,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.spnStart=new Common.UI.CustomSpinner({el:$("#id-spin-set-value"),step:1,width:182,defaultUnit:"",value:1,maxValue:16383,minValue:0,allowDecimal:!1,maskExp:/[0-9]/}),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.spnStart.on("entervalue",_.bind(this.onPrimary,this)),this.spnStart.$el.find("input").focus(),this.afterRender()},afterRender:function(){this._setDefaults(this.props)},_setDefaults:function(t){t&&(this.spnStart.setValue(t.start),this.onFormatSelect(t.format))},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,t,this.getSettings()),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},getSettings:function(){return this.spnStart.getNumberValue()},onPrimary:function(){return this._handleInput("ok"),!1},onFormatSelect:function(t){var e=/[0-9]/,i=this;switch(t){case Asc.c_oAscNumberingFormat.UpperRoman:this.spnStart.options.toCustomFormat=this._10toRome,this.spnStart.options.fromCustomFormat=this._Rometo10,e=/[IVXLCDM]/;break;case Asc.c_oAscNumberingFormat.LowerRoman:this.spnStart.options.toCustomFormat=function(t){return i._10toRome(t).toLocaleLowerCase()},this.spnStart.options.fromCustomFormat=function(t){return i._Rometo10(t.toLocaleUpperCase())},e=/[ivxlcdm]/;break;case Asc.c_oAscNumberingFormat.UpperLetter:this.spnStart.options.toCustomFormat=this._10toS,this.spnStart.options.fromCustomFormat=this._Sto10,e=/[A-Z]/;break;case Asc.c_oAscNumberingFormat.LowerLetter:this.spnStart.options.toCustomFormat=function(t){return i._10toS(t).toLocaleLowerCase()},this.spnStart.options.fromCustomFormat=function(t){return i._Sto10(t.toLocaleUpperCase())},e=/[a-z]/;break;default:this.spnStart.options.toCustomFormat=function(t){return t},this.spnStart.options.fromCustomFormat=function(t){return t}}this.spnStart.setMask(e),this.spnStart.setValue(this.spnStart.getValue())},_10toS:function(t){t=parseInt(t);for(var e=Math.ceil(t/26),i=String.fromCharCode((t-1)%26+"A".charCodeAt(0)),n="",o=0;o0;)n=i[s][1],o=t-n,o>=0?(e+=i[s][0],t=o):s++;return e},_Rometo10:function(t){if(!/[IVXLCDM]/.test(t)||t.length<1)return 1;for(var e={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3},i=t.length-1,n=e[t.charAt(i)],o=n,s=i-1;s>=0;s--){var a=e[t.charAt(s)];if(a10)return 1;a*=-1}n+=a,o=Math.abs(a)}return n}},DE.Views.NumberingValueDialog||{}))}),define("documenteditor/main/app/view/CellsAddDialog",["common/main/lib/component/Window","common/main/lib/component/ComboBox","common/main/lib/component/MetricSpinner","common/main/lib/component/RadioBox"],function(){"use strict";DE.Views.CellsAddDialog=Common.UI.Window.extend(_.extend({options:{width:214,header:!0,style:"min-width: 214px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
    ','
    ','
    ','
    ',"
    ",'
    ','
    ',"
    "].join(""),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.cmbRowCol=new Common.UI.ComboBox({el:$("#table-combo-row-col"),cls:"input-group-nr",style:"width: 110px;",menuStyle:"min-width: 110px;",editable:!1,takeFocusOnClose:!0,scrollAlwaysVisible:!0,data:[{value:0,displayValue:this.textRow},{value:1,displayValue:this.textCol}]}),this.cmbRowCol.setValue(0),this.cmbRowCol.on("selected",_.bind(function(t,e){var i=0==e.value;this.spnCount.setMaxValue(i?100:64),this.spnCount.setValue(this.spnCount.getNumberValue()),this.radioBefore.setCaption(i?this.textUp:this.textLeft),this.radioAfter.setCaption(i?this.textDown:this.textRight)},this)),this.spnCount=new Common.UI.MetricSpinner({el:$("#table-spin-row-col"),step:1,width:65,value:1,defaultUnit:"",maxValue:100,minValue:1,allowDecimal:!1}),this.radioBefore=new Common.UI.RadioBox({el:$("#table-radio-before"),labelText:this.textUp,name:"asc-radio-table-cells-add",checked:!0}),this.radioAfter=new Common.UI.RadioBox({el:$("#table-radio-after"),labelText:this.textDown,name:"asc-radio-table-cells-add"}),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this))},getFocusedComponents:function(){return[this.cmbRowCol,this.spnCount]},getDefaultFocusableComponent:function(){return this.spnCount},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,t,this.getSettings()),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},getSettings:function(){return{row:0==this.cmbRowCol.getValue(),before:this.radioBefore.getValue(),count:this.spnCount.getNumberValue()}},onPrimary:function(){return this._handleInput("ok"),!1},textTitle:"Insert Several",textLeft:"To the left",textRight:"To the right",textUp:"Above the cursor",textDown:"Below the cursor",textRow:"Rows",textCol:"Columns"},DE.Views.CellsAddDialog||{}))}),define("documenteditor/main/app/view/DocumentHolder",["jquery","underscore","backbone","gateway","common/main/lib/util/utils","common/main/lib/component/Menu","common/main/lib/component/Calendar","common/main/lib/view/InsertTableDialog","common/main/lib/view/CopyWarningDialog","common/main/lib/view/OptionsDialog","documenteditor/main/app/view/DropcapSettingsAdvanced","documenteditor/main/app/view/HyperlinkSettingsDialog","documenteditor/main/app/view/ParagraphSettingsAdvanced","documenteditor/main/app/view/TableSettingsAdvanced","documenteditor/main/app/view/ControlSettingsDialog","documenteditor/main/app/view/NumberingValueDialog","documenteditor/main/app/view/CellsAddDialog"],function(t,e,i,n){"use strict";DE.Views.DocumentHolder=i.View.extend(e.extend({el:"#editor_sdk",template:null,events:{},initialize:function(){var i=this,n=DE.getCollection("Common.Collections.Users");i._TtHeight=20,i._currentSpellObj=void 0,i._currLang={},i.usertips=[],i.fastcoauthtips=[],i._currentMathObj=void 0,i._currentParaObjDisabled=!1,i._isDisabled=!1,i._state={};var o=function(n,o,s,a,r){if(!e.isUndefined(n)&&null!==n){Common.UI.Menu.Manager.hideAll();var l=[s.get_X(),s.get_Y()],c=t(i.el).find(Common.Utils.String.format("#menu-container-{0}",n.id));n.rendered||(c.length<1&&(c=t(Common.Utils.String.format('',n.id)),t(i.el).append(c)),n.render(c),n.cmpEl.attr({tabindex:"-1"})),c.css({left:l[0],top:l[1]}),n.show(),e.isFunction(n.options.initMenu)&&(n.options.initMenu(o),n.alignPosition()),e.delay(function(){n.cmpEl.focus()},10),i.currentMenu=n}},s=function(t){if(t&&e.isArray(t)){for(var n={},o=i.textMenu,s=!0,a=0;a0&&i.api.zoomIn(),t.preventDefault(),t.stopPropagation())}},h=function(e){if(i.api){var n=e.keyCode;if((e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey){if(n===Common.UI.Keys.NUM_PLUS||n===Common.UI.Keys.EQUALITY||Common.Utils.isGecko&&n===Common.UI.Keys.EQUALITY_FF||Common.Utils.isOpera&&43==n)return i.api.zoomIn(),e.preventDefault(),e.stopPropagation(),!1;if(n===Common.UI.Keys.NUM_MINUS||n===Common.UI.Keys.MINUS||Common.Utils.isGecko&&n===Common.UI.Keys.MINUS_FF||Common.Utils.isOpera&&45==n)return i.api.zoomOut(),e.preventDefault(),e.stopPropagation(),!1;if(48===n||96===n)return i.api.zoom(100),e.preventDefault(),e.stopPropagation(),!1}i.currentMenu&&i.currentMenu.isVisible()&&(n!=Common.UI.Keys.UP&&n!=Common.UI.Keys.DOWN||t("ul.dropdown-menu",i.currentMenu.el).focus()),n==Common.UI.Keys.ESC&&(Common.UI.Menu.Manager.hideAll(),Common.NotificationCenter.trigger("leftmenu:change","hide"))}},p=function(e){i._XY=[i.cmpEl.offset().left-t(window).scrollLeft(),i.cmpEl.offset().top-t(window).scrollTop()],i._Height=i.cmpEl.height(),i._BodyWidth=t("body").width()},m=function(e){var n=i.cmpEl;if(n){n.on("contextmenu",function(t){return t.preventDefault(),t.stopPropagation(),!1}),n.on("click",function(t){"canvas"==t.target.localName&&(i._preventClick?i._preventClick=!1:n.focus())}),n.on("mousedown",function(t){"canvas"==t.target.localName&&Common.UI.Menu.Manager.hideAll()});var o=/Firefox/i.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel";!function(t,e,i){t.addEventListener?t.addEventListener(e,i,!1):t.attachEvent("on"+e,i)}(i.el,o,d)}t(document).on("mousewheel",d),t(document).on("keydown",h),t(window).on("resize",p),DE.getController("Viewport").getView("Viewport").hlayout.on("layout:resizedrag",p)},u=function(t){if(n){var e=n.findUser(t);if(e)return Common.Utils.UserInfoParser.getParsedName(e.get("username"))}return i.guestText},g={toolTip:new Common.UI.Tooltip({owner:this,html:!0,title:"
    Press Ctrl and click link",cls:"link-tooltip"}),strTip:"",isHidden:!0,isVisible:!1},b=!0,f=function(t,e,n){!0===b&&(b=new Common.UI.Tooltip({owner:t.currentTarget,title:i.tipIsLocked}),b.show())},C=function(){if("object"==typeof b){b.hide(),b=void 0;for(var t=0;t0&&("object"==typeof b&&(b.hide(),b=!0),e.each(i.usertips,function(t){t.remove()})),i.usertips=[],i.usertipcount=0},w=null,x=!1,S=function(){g.isHidden&&g.isVisible&&(g.isVisible=!1,x=!0,g.toolTip.hide(function(){x=!1,w&&A(w),w=null}))},A=function(n){if(void 0===i._XY&&(i._XY=[i.cmpEl.offset().left-t(window).scrollLeft(),i.cmpEl.offset().top-t(window).scrollTop()],i._Height=i.cmpEl.height(),i._BodyWidth=t("body").width()),n){var o,s,a=n.get_Type();if(a==Asc.c_oAscMouseMoveDataTypes.Hyperlink||a==Asc.c_oAscMouseMoveDataTypes.Footnote||a==Asc.c_oAscMouseMoveDataTypes.Form){if(x)return void(w=n);if(a==Asc.c_oAscMouseMoveDataTypes.Hyperlink){var r=n.get_Hyperlink();if(!r)return;s=e.isEmpty(r.get_ToolTip())?r.get_Value():r.get_ToolTip()}else a==Asc.c_oAscMouseMoveDataTypes.Footnote?(s=n.get_FootnoteText(),s.length>1e3&&(s=s.substr(0,1e3)+"...")):a==Asc.c_oAscMouseMoveDataTypes.Form&&(s=n.get_FormHelpText(),s.length>1e3&&(s=s.substr(0,1e3)+"..."));var l=!1;g.isHidden=!1,s=Common.Utils.String.htmlEncode(s),(g.tipType!==a||g.tipLength!==s.length||g.strTip.indexOf(s)<0)&&(g.toolTip.setTitle(a==Asc.c_oAscMouseMoveDataTypes.Hyperlink?s+"
    "+i.txtPressLink+"":s),g.tipLength=s.length,g.strTip=s,g.tipType=a,l=!0),o=[n.get_X(),n.get_Y()],o[1]+=i._XY[1]-15,o[0]+=i._XY[0]+5,g.isVisible&&!l||(g.isVisible=!0,g.toolTip.show([-1e4,-1e4])),l&&(g.tipHeight=g.toolTip.getBSTip().$tip.height(),g.tipWidth=g.toolTip.getBSTip().$tip.width()),l=!1,o[0]+g.tipWidth>i._BodyWidth&&(o[0]=i._BodyWidth-g.tipWidth,l=!0),o[1]-g.tipHeight<0?o[1]=l?o[1]+30:0:o[1]-=g.tipHeight,g.toolTip.getBSTip().$tip.css({top:o[1]+"px",left:o[0]+"px"})}else if(n.get_Type()==Asc.c_oAscMouseMoveDataTypes.LockedObject&&i.mode.isEdit){var c;i.usertipcount>=i.usertips.length&&(c=t(document.createElement("div")),c.addClass("username-tip"),c.css({height:i._TtHeight+"px",position:"absolute",zIndex:"900",visibility:"visible"}),t(document.body).append(c),b&&(c.on("mouseover",f),c.on("mouseout",v)),i.usertips.push(c)),c=i.usertips[i.usertipcount],i.usertipcount++,s=u(n.get_UserId()),o=[n.get_X()+i._XY[0],n.get_Y()+i._XY[1]];var d=o[0];o[0]=i._BodyWidth-o[0],o[1]-=2==n.get_LockedObjectType()?i._TtHeight:0,o[1]>i._XY[1]&&o[1]+i._TtHeight
    '),i.cmpEl.append(s),i.btnSpecialPaste=new Common.UI.Button({parentEl:t("#id-document-holder-btn-special-paste"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-paste",menu:new Common.UI.Menu({items:[]})})),a.length>0){for(var r=i.btnSpecialPaste.menu,l=0;l0&&r.items[0].setChecked(!0,!0)}if(o.asc_getX()<0||o.asc_getY()<0)s.is(":visible")&&s.hide();else{var c=[o.asc_getX()+o.asc_getWidth()+3,o.asc_getY()+o.asc_getHeight()+3];s.css({left:c[0],top:c[1]}),s.show()}}},P=function(){var t=i.cmpEl.find("#special-paste-container");t.is(":visible")&&t.hide()},M=function(){var t,n,o;if(i.api&&i.mode.isEdit&&!i._isDisabled&&!DE.getController("LeftMenu").leftMenu.menuFile.isVisible()){var s=function(t,e){"ok"==e&&(n=t.getSettings(),!1!==o?i.api.add_Hyperlink(n):i.api.change_Hyperlink(n)),i.fireEvent("editcomplete",i)};if(!1!==(o=i.api.can_AddHyperlink()))t=new DE.Views.HyperlinkSettingsDialog({api:i.api,handler:s}),n=new Asc.CHyperlinkProperty,n.put_Text(o),t.show(),t.setSettings(n);else{var a=i.api.getSelectedElements();a&&e.isArray(a)&&e.each(a,function(t,e){a[e].get_ObjectType()==Asc.c_oAscTypeSelectElement.Hyperlink&&(n=a[e].get_ObjectValue())}),n&&(t=new DE.Views.HyperlinkSettingsDialog({api:i.api,handler:s}),t.show(),t.setSettings(n))}Common.component.Analytics.trackEvent("DocumentHolder","Add Hyperlink")}},E=function(t){if(i.mode.isEdit&&!i._isDisabled){var e=DE.getController("Common.Controllers.ExternalDiagramEditor").getView("Common.Views.ExternalDiagramEditor");e&&t&&(e.setEditMode(!0),e.show(),e.setChartData(new Asc.asc_CChartBinary(t)))}},U=function(){i.mode.isEdit=!1},V=function(t){i._currLang.id=t};this.changeLanguageMenu=function(t){if(null===i._currLang.id||void 0===i._currLang.id)t.clearAll();else{var n=e.findIndex(t.items,{langid:i._currLang.id});n>-1&&!t.items[n].checked&&t.setChecked(n,!0)}};var B=function(){var t,n=i.api.getSelectedElements(!0);if(n&&e.isArray(n))for(var o=0;o0?(n.setVisible(r.length>3),n.setDisabled(i._currentParaObjDisabled),e.each(r,function(t,e){var n=new Common.UI.MenuItem({caption:t,spellword:!0,disabled:i._currentParaObjDisabled}).on("click",function(t,e){i.api&&(i.api.asc_replaceMisspelledWord(t.caption,i._currentSpellObj),i.fireEvent("editcomplete",i))});e<3?s.push(n):a.push(n)}),s.length>0&&(t?e.each(s,function(t,e){i.textMenu.insertItem(e,t)}):e.each(s,function(t,e){i.menuSpellCheckTable.menu.insertItem(e,t)})),a.length>0&&e.each(a,function(t,e){n.menu.addItem(t)}),o.setVisible(!1)):(n.setVisible(!1),o.setVisible(!0),o.setCaption(i.noSpellVariantsText,!0))}},this.clearWordVariants=function(t){for(var e=t?i.textMenu:i.menuSpellCheckTable.menu,n=0;n0&&e.each(s,function(t,s){t.menu?e.each(t.menu.items,function(t){t.on("click",e.bind(i.equationCallback,i,t.options.equationProps))}):t.on("click",e.bind(i.equationCallback,i,t.options.equationProps)),o.insertItem(n,t),n++}),s.length},this.clearEquationMenu=function(t,n){for(var o=t?i.textMenu:i.tableMenu,s=n;s=0;r--){var l,c;if(l=a[r].get_ObjectType(),c=a[r].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Paragraph==l){o=new DE.Views.ParagraphSettingsAdvanced({tableStylerRows:2,tableStylerColumns:1,paragraphProps:c,borderProps:s.borderAdvancedProps,isChart:!0===t.isChart,api:s.api,handler:function(t,e){"ok"==t&&s.api&&(s.borderAdvancedProps=e.borderProps,s.api.paraApply(e.paragraphProps)),s.fireEvent("editcomplete",s)}});break}}}if(o)return o.show(),o},advancedFrameClick:function(t,e,i,n){Common.NotificationCenter.trigger("dropcap:settings",t)},advancedTableClick:function(t,i,n){var o,s=this;if(s.api){var a=s.api.getSelectedElements();if(a&&e.isArray(a))for(var r=a.length-1;r>=0;r--){var l,c;if(l=a[r].get_ObjectType(),c=a[r].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Table==l){o=new DE.Views.TableSettingsAdvanced({tableStylerRows:null===c.get_CellBorders().get_InsideH()&&1==c.get_CellSelect()?1:2,tableStylerColumns:null===c.get_CellBorders().get_InsideV()&&1==c.get_CellSelect()?1:2,tableProps:c,borderProps:s.borderAdvancedProps,sectionProps:s.api.asc_GetSectionProps(),handler:function(t,e){"ok"==t&&s.api&&(s.borderAdvancedProps=e.borderProps,s.api.tblApply(e.tableProps)),s.fireEvent("editcomplete",s)}});break}}}if(o)return o.show(),o},onRulerDblClick:function(e){Common.UI.Menu.Manager.hideAll();var i,n=this;if("tables"==e)(i=this.advancedTableClick())&&i.setActiveCategory(4);else if("indents"==e||"tabs"==e)(i=this.advancedParagraphClick({isChart:!1}))&&i.setActiveCategory("indents"==e?0:3);else if("margins"==e){if(n._state.lock_doc)return;i=new DE.Views.PageMarginsDialog({api:n.api,handler:function(e,i){if("ok"==i){var o=e.getSettings(),s=DE.getController("Toolbar").toolbar.btnPageMargins.menu.items[0];s.setVisible(!0),s.setChecked(!0),s.options.value=s.value=[o.get_TopMargin(),o.get_LeftMargin(),o.get_BottomMargin(),o.get_RightMargin()],t(s.el).html(s.template({id:Common.UI.getId(),caption:s.caption,options:s.options})),Common.localStorage.setItem("de-pgmargins-top",o.get_TopMargin()),Common.localStorage.setItem("de-pgmargins-left",o.get_LeftMargin()),Common.localStorage.setItem("de-pgmargins-bottom",o.get_BottomMargin()),Common.localStorage.setItem("de-pgmargins-right",o.get_RightMargin()),n.api.asc_SetSectionProps(o),n.fireEvent("editcomplete",n)}}}),i.show(),i.setSettings(n.api.asc_GetSectionProps())}else"columns"==e&&(i=new DE.Views.CustomColumnsDialog({handler:function(t,e){"ok"==e&&(n.api.asc_SetColumnsProps(t.getSettings()),n.fireEvent("editcomplete",n))}}),i.show(),i.setSettings(n.api.asc_GetColumnsProps()))},editHyperlink:function(t,e,i){var n,o=this;o.api&&(n=new DE.Views.HyperlinkSettingsDialog({api:o.api,handler:function(t,e){"ok"==e&&o.api.change_Hyperlink(n.getSettings()),o.fireEvent("editcomplete",o)}}),n.show(),n.setSettings(t.hyperProps.value))},onMenuSaveStyle:function(t,e,i){var n=this;n.api&&Common.NotificationCenter.trigger("style:commitsave",n.api.asc_GetStyleFromFormatting())},onMenuUpdateStyle:function(t,e,i){var n=this;n.api&&Common.NotificationCenter.trigger("style:commitchange",n.api.asc_GetStyleFromFormatting())},addComment:function(t,e,i){if(this.api&&this.mode.canCoAuthoring&&this.mode.canComments){this.suppressEditComplete=!0;var n=DE.getController("Common.Controllers.Comments");n&&n.addDummyComment()}},addHyperlink:function(t,e,i){var n,o=this;o.api&&(n=new DE.Views.HyperlinkSettingsDialog({api:o.api,handler:function(t,e){"ok"==e&&o.api.add_Hyperlink(t.getSettings()),o.fireEvent("editcomplete",o)}}),n.show(),n.setSettings(t.hyperProps.value),Common.component.Analytics.trackEvent("DocumentHolder","Add Hyperlink"))},editChartClick:function(){var t=DE.getController("Common.Controllers.ExternalDiagramEditor").getView("Common.Views.ExternalDiagramEditor");if(t){t.setEditMode(!0),t.show();var e=this.api.asc_getChartObject();e&&t.setChartData(new Asc.asc_CChartBinary(e))}},onCutCopyPaste:function(t,e){var i=this;if(i.api){("cut"==t.value?i.api.Cut():"copy"==t.value?i.api.Copy():i.api.Paste())||Common.localStorage.getBool("de-hide-copywarning")||new Common.Views.CopyWarningDialog({handler:function(t){t&&Common.localStorage.setItem("de-hide-copywarning",1),i.fireEvent("editcomplete",i)}}).show()}i.fireEvent("editcomplete",i)},onPrintSelection:function(t){if(this.api){var e=new Asc.asc_CAdjustPrint;e.asc_setPrintType(Asc.c_oAscPrintType.Selection);var i=new Asc.asc_CDownloadOptions(null,Common.Utils.isChrome||Common.Utils.isSafari||Common.Utils.isOpera);i.asc_setAdvancedOptions(e),this.api.asc_Print(i),this.fireEvent("editcomplete",this),Common.component.Analytics.trackEvent("DocumentHolder","Print Selection")}},onControlsSelect:function(t,e){var i=this,n=this.api.asc_GetContentControlProperties();n&&("settings"==t.value?new DE.Views.ControlSettingsDialog({props:n,api:i.api,handler:function(t,e){"ok"==t&&i.api.asc_SetContentControlProperties(e,n.get_InternalId()),i.fireEvent("editcomplete",i)}}).show():"remove"==t.value&&(n.get_FormPr()?this.api.asc_RemoveContentControl(n.get_InternalId()):this.api.asc_RemoveContentControlWrapper(n.get_InternalId()))),i.fireEvent("editcomplete",i)},onInsertCaption:function(){var t=this;new DE.Views.CaptionDialog({isObject:!0,handler:function(e,i){"ok"==e&&t.api.asc_AddObjectCaption(i),t.fireEvent("editcomplete",t)}}).show()},onContinueNumbering:function(t,e){this.api.asc_ContinueNumbering(),this.fireEvent("editcomplete",this)},onStartNumbering:function(t,e,i){if(1==t)this.api.asc_RestartNumbering(e.value.start);else{var n=this;new DE.Views.NumberingValueDialog({title:n.textNumberingValue,props:e.value,handler:function(t,e){"ok"==t&&n.api.asc_RestartNumbering(e),n.fireEvent("editcomplete",n)}}).show()}this.fireEvent("editcomplete",this)},onCellsRemove:function(){var t=this;new Common.Views.OptionsDialog({title:t.textTitleCellsRemove,items:[{caption:this.textLeft,value:"left"},{caption:this.textRow,value:"row"},{caption:this.textCol,value:"col"}],handler:function(e,i){if("ok"==i){var n=e.getSettings();"row"==n?t.api.remRow():"col"==n?t.api.remColumn():t.api.asc_RemoveTableCells()}t.fireEvent("editcomplete",t)}}).show(),this.fireEvent("editcomplete",this)},onCellsAdd:function(){var t=this;new DE.Views.CellsAddDialog({handler:function(e,i){"ok"==e&&(i.row?i.before?t.api.addRowAbove(i.count):t.api.addRowBelow(i.count):i.before?t.api.addColumnLeft(i.count):t.api.addColumnRight(i.count)),t.fireEvent("editcomplete",t)}}).show(),this.fireEvent("editcomplete",this)},createDelayedElementsViewer:function(){var t=this,i=new Common.UI.MenuItem({iconCls:"menu__icon btn-copy",caption:t.textCopy,value:"copy"}).on("click",e.bind(t.onCutCopyPaste,t)),n=new Common.UI.MenuItem({iconCls:"menu__icon btn-undo",caption:t.textUndo}).on("click",function(){t.api.Undo()}),o=new Common.UI.MenuItem({caption:"--"}),s=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-comments",caption:t.addCommentText}).on("click",e.bind(t.addComment,t)),a=new Common.UI.MenuItem({caption:this.strSign,value:0}).on("click",e.bind(t.onSignatureClick,t)),r=new Common.UI.MenuItem({caption:this.strDetails,value:1}).on("click",e.bind(t.onSignatureClick,t)),l=new Common.UI.MenuItem({caption:this.strSetup,value:2}).on("click",e.bind(t.onSignatureClick,t)),c=new Common.UI.MenuItem({caption:this.strDelete,value:3}).on("click",e.bind(t.onSignatureClick,t)),d=new Common.UI.MenuItem({caption:"--"}),h=new Common.UI.MenuItem({iconCls:"menu__icon btn-print",caption:t.txtPrintSelection}).on("click",e.bind(t.onPrintSelection,t));this.viewModeMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(p){var m=p.imgProps&&p.imgProps.value&&!e.isNull(p.imgProps.value.get_ChartProperties()),u=p.imgProps&&p.imgProps.value&&!e.isNull(p.imgProps.value.get_ShapeProperties()),g=p.imgProps&&p.imgProps.value&&t.mode.isSignatureSupport?p.imgProps.value.asc_getSignatureId():void 0,b=g?t.api.asc_getSignatureSetup(g):null,f=!!b&&t._canProtect,C=!!p.paraProps&&!(p.paraProps.value.can_DeleteBlockContentControl()&&p.paraProps.value.can_EditBlockContentControl()&&p.paraProps.value.can_DeleteInlineContentControl()&&p.paraProps.value.can_EditInlineContentControl()),v=!m&&!1!==t.api.can_AddQuotedComment()&&t.mode.canCoAuthoring&&t.mode.canComments&&!t._isDisabled&&!C;if(t.mode.compatibleFeatures&&(v=v&&!u),t.api.asc_IsContentControl()){var _=t.api.asc_GetContentControlProperties(),y=_?_.get_SpecificType():Asc.c_oAscContentControlSpecificType.None;v=v&&!(y==Asc.c_oAscContentControlSpecificType.CheckBox||y==Asc.c_oAscContentControlSpecificType.Picture||y==Asc.c_oAscContentControlSpecificType.ComboBox||y==Asc.c_oAscContentControlSpecificType.DropDownList||y==Asc.c_oAscContentControlSpecificType.DateTime)}n.setVisible(t.mode.canCoAuthoring&&t.mode.canComments&&!t._isDisabled),n.setDisabled(!t.api.asc_getCanUndo()&&!t._isDisabled),o.setVisible(f);var w=!!b&&b.asc_getRequested();a.setVisible(f&&w),r.setVisible(f&&!w),l.setVisible(f),c.setVisible(f&&!w),d.setVisible(v),f&&(a.cmpEl.attr("data-value",g),r.cmpEl.attr("data-value",b.asc_getId()),l.cmpEl.attr("data-value",g),c.cmpEl.attr("data-value",g)),s.setVisible(v),s.setDisabled(p.paraProps&&!0===p.paraProps.locked);var x=t.api&&t.api.can_CopyCut();i.setDisabled(!x),h.setVisible(t.mode.canPrint),h.setDisabled(!x)},items:[i,n,h,o,a,r,l,c,d,s]}).on("hide:after",function(e,i,n){if(t.suppressEditComplete)return void(t.suppressEditComplete=!1);n||t.fireEvent("editcomplete",t),t.currentMenu=null})},createDelayedElements:function(){var i=this,n=new Common.UI.MenuItem({caption:i.txtInsertCaption}).on("click",e.bind(i.onInsertCaption,i)),o=new Common.UI.MenuItem({caption:"--"}),s=new Common.UI.MenuItem({caption:i.txtInsertCaption}).on("click",e.bind(i.onInsertCaption,i)),a=new Common.UI.MenuItem({caption:"--"}),r=new Common.UI.MenuItem({caption:i.textAlign,menu:function(){function t(t,e){if(i.api){var n=Common.Utils.InternalSettings.get("de-img-align-to"),o=1==n?Asc.c_oAscObjectsAlignType.Page:i.api.asc_getSelectedDrawingObjectsCount()<2&&!n||2==n?Asc.c_oAscObjectsAlignType.Margin:Asc.c_oAscObjectsAlignType.Selected;t.value<6?(i.api.put_ShapesAlign(t.value,o),Common.component.Analytics.trackEvent("DocumentHolder","Shape Align")):6==t.value?(i.api.DistributeHorizontally(o),Common.component.Analytics.trackEvent("DocumentHolder","Distribute Horizontally")):7==t.value&&(i.api.DistributeVertically(o),Common.component.Analytics.trackEvent("DocumentHolder","Distribute Vertically"))}i.fireEvent("editcomplete",i)}return new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.textShapeAlignLeft,iconCls:"menu__icon shape-align-left",value:Asc.c_oAscAlignShapeType.ALIGN_LEFT}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignCenter,iconCls:"menu__icon shape-align-center",value:Asc.c_oAscAlignShapeType.ALIGN_CENTER}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignRight,iconCls:"menu__icon shape-align-right",value:Asc.c_oAscAlignShapeType.ALIGN_RIGHT}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignTop,iconCls:"menu__icon shape-align-top",value:Asc.c_oAscAlignShapeType.ALIGN_TOP}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignMiddle,iconCls:"menu__icon shape-align-middle",value:Asc.c_oAscAlignShapeType.ALIGN_MIDDLE}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignBottom,iconCls:"menu__icon shape-align-bottom",value:Asc.c_oAscAlignShapeType.ALIGN_BOTTOM}).on("click",t),{caption:"--"},new Common.UI.MenuItem({caption:i.txtDistribHor,iconCls:"menu__icon shape-distribute-hor",value:6}).on("click",t),new Common.UI.MenuItem({caption:i.txtDistribVert,iconCls:"menu__icon shape-distribute-vert",value:7}).on("click",t)]})}()}),l=new Common.UI.MenuItem({caption:this.txtGroup,iconCls:"menu__icon shape-group"}).on("click",function(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_Group(1),i.api.ImgApply(n)}i.fireEvent("editcomplete",this)}),c=new Common.UI.MenuItem({iconCls:"menu__icon shape-ungroup",caption:this.txtUngroup}).on("click",function(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_Group(-1),i.api.ImgApply(n)}i.fireEvent("editcomplete",this)}),d=new Common.UI.MenuItem({caption:i.textArrange,menu:function(){function t(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_ChangeLevel(t.options.valign),i.api.ImgApply(n)}i.fireEvent("editcomplete",i)}return new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.textArrangeFront,iconCls:"menu__icon arrange-front",valign:Asc.c_oAscChangeLevel.BringToFront}).on("click",t),new Common.UI.MenuItem({caption:i.textArrangeBack,iconCls:"menu__icon arrange-back",valign:Asc.c_oAscChangeLevel.SendToBack}).on("click",t),new Common.UI.MenuItem({caption:i.textArrangeForward,iconCls:"menu__icon arrange-forward",valign:Asc.c_oAscChangeLevel.BringForward}).on("click",t),new Common.UI.MenuItem({caption:i.textArrangeBackward,iconCls:"menu__icon arrange-backward",valign:Asc.c_oAscChangeLevel.BringBackward}).on("click",t),{caption:"--"},l,c]})}()}),h=new Common.UI.MenuItem({caption:i.textEditWrapBoundary,cls:"no-icon-wrap-item"}).on("click",function(t,e){i.api&&i.api.StartChangeWrapPolygon(),i.fireEvent("editcomplete",i)});this.menuImageWrap=new Common.UI.MenuItem({iconCls:"menu__icon wrap-inline",caption:i.textWrap,menu:function(){function t(t,e){if(i.api){var n=new Asc.asc_CImgProperty;if(n.put_WrappingStyle(t.options.wrapType),i.menuImageWrap._originalProps.get_WrappingStyle()===Asc.c_oAscWrapStyle2.Inline&&t.wrapType!==Asc.c_oAscWrapStyle2.Inline){n.put_PositionH(new Asc.CImagePositionH),n.get_PositionH().put_UseAlign(!1), -n.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var o=i.menuImageWrap._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column);n.get_PositionH().put_Value(o),n.put_PositionV(new Asc.CImagePositionV),n.get_PositionV().put_UseAlign(!1),n.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),o=i.menuImageWrap._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),n.get_PositionV().put_Value(o)}i.api.ImgApply(n)}i.fireEvent("editcomplete",i)}return new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.txtInline,iconCls:"menu__icon wrap-inline",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Inline,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtSquare,iconCls:"menu__icon wrap-square",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Square,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtTight,iconCls:"menu__icon wrap-tight",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Tight,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtThrough,iconCls:"menu__icon wrap-through",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Through,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtTopAndBottom,iconCls:"menu__icon wrap-topandbottom",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.TopAndBottom,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtInFront,iconCls:"menu__icon wrap-infront",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.InFront,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtBehind,iconCls:"menu__icon wrap-behind",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Behind,checkmark:!1,checkable:!0}).on("click",t),{caption:"--"},h]})}()});var p=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-image",caption:i.advancedText}).on("click",function(t,n){var o,s;if(i.api){var a=i.api.getSelectedElements();if(a&&e.isArray(a))for(var r=a.length-1;r>=0;r--)if(o=a[r].get_ObjectType(),s=a[r].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Image==o){var l;s.get_ChartProperties()||s.get_ShapeProperties()||i.menuOriginalSize.isDisabled()||!i.menuOriginalSize.isVisible()||(l=i.api.get_OriginalSizeImage())&&(l={width:l.get_ImageWidth(),height:l.get_ImageHeight()});var c=new DE.Views.ImageSettingsAdvanced({imageProps:s,sizeOriginal:l,api:i.api,sectionProps:i.api.asc_GetSectionProps(),handler:function(t,e){"ok"==t&&i.api&&i.api.ImgApply(e.imageProps),i.fireEvent("editcomplete",i)}});c.show(),c.btnOriginalSize.setVisible(i.menuOriginalSize.isVisible());break}}}),m=new Common.UI.MenuItem({caption:i.editChartText}).on("click",e.bind(i.editChartClick,i));this.menuOriginalSize=new Common.UI.MenuItem({caption:i.originalSizeText}).on("click",function(t,e){if(i.api){var n=i.api.get_OriginalSizeImage(),o=new Asc.asc_CImgProperty;o.put_Width(n.get_ImageWidth()),o.put_Height(n.get_ImageHeight()),o.put_ResetCrop(!0),i.api.ImgApply(o),i.fireEvent("editcomplete",this)}});var u=new Common.UI.MenuItem({caption:i.textReplace,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:this.textFromFile}).on("click",function(t){setTimeout(function(){i.api&&i.api.ChangeImageFromFile(),i.fireEvent("editcomplete",i)},10)}),new Common.UI.MenuItem({caption:this.textFromUrl}).on("click",function(t){new Common.Views.ImageFromUrlDialog({handler:function(t,n){if("ok"==t&&i.api){var o=n.replace(/ /g,"");if(!e.isEmpty(o)){var s=new Asc.asc_CImgProperty;s.put_ImageUrl(o),i.api.ImgApply(s)}}i.fireEvent("editcomplete",i)}}).show()}),new Common.UI.MenuItem({caption:this.textFromStorage}).on("click",function(t){Common.NotificationCenter.trigger("storage:image-load","change")})]})}),g=new Common.UI.MenuItem({iconCls:"menu__icon btn-copy",caption:i.textCopy,value:"copy"}).on("click",e.bind(i.onCutCopyPaste,i)),b=new Common.UI.MenuItem({iconCls:"menu__icon btn-paste",caption:i.textPaste,value:"paste"}).on("click",e.bind(i.onCutCopyPaste,i)),f=new Common.UI.MenuItem({iconCls:"menu__icon btn-cut",caption:i.textCut,value:"cut"}).on("click",e.bind(i.onCutCopyPaste,i)),C=new Common.UI.MenuItem({iconCls:"menu__icon btn-print",caption:i.txtPrintSelection}).on("click",e.bind(i.onPrintSelection,i)),v=new Common.UI.MenuItem({caption:this.strSign,value:0}).on("click",e.bind(i.onSignatureClick,i)),_=new Common.UI.MenuItem({caption:this.strSetup,value:2}).on("click",e.bind(i.onSignatureClick,i)),y=new Common.UI.MenuItem({caption:"--"}),w=new Common.UI.MenuItem({caption:i.textRotate,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({iconCls:"menu__icon btn-rotate-90",caption:this.textRotate90,value:1}).on("click",e.bind(i.onImgRotate,i)),new Common.UI.MenuItem({iconCls:"menu__icon btn-rotate-270",caption:this.textRotate270,value:0}).on("click",e.bind(i.onImgRotate,i)),{caption:"--"},new Common.UI.MenuItem({iconCls:"menu__icon btn-flip-hor",caption:this.textFlipH,value:1}).on("click",e.bind(i.onImgFlip,i)),new Common.UI.MenuItem({iconCls:"menu__icon btn-flip-vert",caption:this.textFlipV,value:0}).on("click",e.bind(i.onImgFlip,i))]})});i.menuImgCrop=new Common.UI.MenuItem({caption:i.textCrop,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.textCrop,checkable:!0,allowDepress:!0,value:0}).on("click",e.bind(i.onImgCrop,i)),new Common.UI.MenuItem({caption:i.textCropFill,value:1}).on("click",e.bind(i.onImgCrop,i)),new Common.UI.MenuItem({caption:i.textCropFit,value:2}).on("click",e.bind(i.onImgCrop,i))]})}),this.pictureMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(t){if(!e.isUndefined(t.imgProps)){var n=!t.imgProps.value.get_CanBeFlow(),o=t.imgProps.value.get_WrappingStyle();i.menuImageWrap._originalProps=t.imgProps.value;var s="menu__icon ";if(n){for(var a=0;a<6;a++)i.menuImageWrap.menu.items[a].setChecked(!1);s+="wrap-inline"}else switch(o){case Asc.c_oAscWrapStyle2.Inline:i.menuImageWrap.menu.items[0].setChecked(!0),s+="wrap-inline";break;case Asc.c_oAscWrapStyle2.Square:i.menuImageWrap.menu.items[1].setChecked(!0),s+="wrap-square";break;case Asc.c_oAscWrapStyle2.Tight:i.menuImageWrap.menu.items[2].setChecked(!0),s+="wrap-tight";break;case Asc.c_oAscWrapStyle2.Through:i.menuImageWrap.menu.items[3].setChecked(!0),s+="wrap-through";break;case Asc.c_oAscWrapStyle2.TopAndBottom:i.menuImageWrap.menu.items[4].setChecked(!0),s+="wrap-topandbottom";break;case Asc.c_oAscWrapStyle2.Behind:i.menuImageWrap.menu.items[6].setChecked(!0),s+="wrap-behind";break;case Asc.c_oAscWrapStyle2.InFront:i.menuImageWrap.menu.items[5].setChecked(!0),s+="wrap-infront";break;default:for(var a=0;a<6;a++)i.menuImageWrap.menu.items[a].setChecked(!1);s+="wrap-infront"}i.menuImageWrap.setIconCls(s),e.each(i.menuImageWrap.menu.items,function(t){t.setDisabled(n)});var x=t.imgProps.isImg&&t.imgProps.isChart||t.imgProps.isImg&&t.imgProps.isShape||t.imgProps.isShape&&t.imgProps.isChart;x?(p.setCaption(i.advancedText,!0),p.setIconCls("menu__icon btn-menu-image")):(p.setCaption(t.imgProps.isImg?i.imageText:t.imgProps.isChart?i.chartText:i.shapeText,!0),p.setIconCls("menu__icon "+(t.imgProps.isImg?"btn-menu-image":t.imgProps.isChart?"btn-menu-chart":"btn-menu-shape"))),m.setVisible(!e.isNull(t.imgProps.value.get_ChartProperties())&&!x),i.menuOriginalSize.setVisible(t.imgProps.isOnlyImg||!t.imgProps.isChart&&!t.imgProps.isShape);var S=i.api.asc_IsContentControl()?i.api.asc_GetContentControlProperties():null,A=S?S.get_Lock():Asc.c_oAscSdtLockType.Unlocked,k=A==Asc.c_oAscSdtLockType.SdtContentLocked||A==Asc.c_oAscSdtLockType.ContentLocked,T=t.imgProps.locked||void 0!==t.headerProps&&t.headerProps.locked||k,I=t.imgProps.value.asc_getPluginGuid();if(u.setVisible(t.imgProps.isOnlyImg&&(null===I||void 0===I)),u.isVisible()&&u.setDisabled(T||null===I),u.menu.items[2].setVisible(i.mode.canRequestInsertImage||i.mode.fileChoiceUrl&&i.mode.fileChoiceUrl.indexOf("{documentType}")>-1),w.setVisible(!t.imgProps.isChart&&(null===I||void 0===I)),w.isVisible()&&w.setDisabled(T),i.menuImgCrop.setVisible(i.api.asc_canEditCrop()),i.menuImgCrop.isVisible()&&i.menuImgCrop.setDisabled(T),m.isVisible()&&m.setDisabled(T||t.imgProps.value.get_SeveralCharts()),i.pictureMenu.items[19].setVisible(m.isVisible()),i.menuOriginalSize.setDisabled(T||null===t.imgProps.value.get_ImageUrl()||void 0===t.imgProps.value.get_ImageUrl()),p.setDisabled(T),r.setDisabled(T||o==Asc.c_oAscWrapStyle2.Inline),!T&&o!=Asc.c_oAscWrapStyle2.Inline){var P=i.api.asc_getSelectedDrawingObjectsCount(),M=Common.Utils.InternalSettings.get("de-img-align-to");r.menu.items[7].setDisabled(2==P&&(!M||3==M)),r.menu.items[8].setDisabled(2==P&&(!M||3==M))}d.setDisabled(o==Asc.c_oAscWrapStyle2.Inline||k),i.api&&(c.setDisabled(T||!i.api.CanUnGroup()),l.setDisabled(T||!i.api.CanGroup()),h.setDisabled(T||!i.api.CanChangeWrapPolygon())),i.menuImageWrap.setDisabled(T||t.imgProps.value.get_FromGroup()||n&&h.isDisabled()||!!S&&S.get_SpecificType()==Asc.c_oAscContentControlSpecificType.Picture);var E=i.api&&i.api.can_CopyCut();g.setDisabled(!E),f.setDisabled(T||!E),b.setDisabled(T),C.setVisible(i.mode.canPrint),C.setDisabled(!E);var U=t.imgProps&&t.imgProps.value&&i.mode.isSignatureSupport?t.imgProps.value.asc_getSignatureId():void 0,V=!!U;v.setVisible(V),_.setVisible(V),y.setVisible(V),V&&(v.cmpEl.attr("data-value",U),_.cmpEl.attr("data-value",U))}},items:[f,g,b,C,{caption:"--"},v,_,y,d,r,i.menuImageWrap,w,{caption:"--"},n,o,i.menuImgCrop,i.menuOriginalSize,u,m,{caption:"--"},p]}).on("hide:after",function(t,e,n){n||i.fireEvent("editcomplete",i),i.currentMenu=null});var x=new Common.UI.MenuItem({caption:i.txtInsertCaption}).on("click",e.bind(i.onInsertCaption,i)),S=new Common.UI.MenuItem({iconCls:"menu__icon btn-merge",caption:i.mergeCellsText}).on("click",function(t){i.api&&i.api.MergeCells()}),A=new Common.UI.MenuItem({caption:i.splitCellsText}).on("click",function(t){i.api&&new Common.Views.InsertTableDialog({split:!0,handler:function(t,e){"ok"==t&&(i.api&&i.api.SplitCell(e.columns,e.rows),Common.component.Analytics.trackEvent("DocumentHolder","Table")),i.fireEvent("editcomplete",i)}}).show()}),k=function(t,e){if(i.api){var n=new Asc.CTableProp;n.put_CellsVAlign(t.options.valign),i.api.tblApply(n)}},T=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-top",caption:i.cellAlignText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[i.menuTableCellTop=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-top",caption:i.textShapeAlignTop,toggleGroup:"popuptablecellalign",checkmark:!1,checkable:!0,checked:!1,valign:Asc.c_oAscVertAlignJc.Top}).on("click",e.bind(k,i)),i.menuTableCellCenter=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-middle",caption:i.textShapeAlignMiddle,toggleGroup:"popuptablecellalign",checkmark:!1,checkable:!0,checked:!1,valign:Asc.c_oAscVertAlignJc.Center}).on("click",e.bind(k,i)),i.menuTableCellBottom=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-bottom",caption:i.textShapeAlignBottom,toggleGroup:"popuptablecellalign",checkmark:!1,checkable:!0,checked:!1,valign:Asc.c_oAscVertAlignJc.Bottom}).on("click",e.bind(k,i))]})}),I=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-table",caption:i.advancedTableText}).on("click",e.bind(i.advancedTableClick,i)),P=new Common.UI.MenuItem({iconCls:"menu__icon btn-paragraph",caption:i.advancedParagraphText}).on("click",e.bind(i.advancedParagraphClick,i)),M=new Common.UI.MenuItem({caption:"--"}),E=new Common.UI.MenuItem({caption:i.editHyperlinkText}).on("click",e.bind(i.editHyperlink,i)),U=new Common.UI.MenuItem({caption:i.removeHyperlinkText}).on("click",function(t,e){i.api&&i.api.remove_Hyperlink(t.hyperProps.value),i.fireEvent("editcomplete",i)}),V=new Common.UI.MenuItem({iconCls:"menu__icon btn-inserthyperlink",caption:i.hyperlinkText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[E,U]})}),B=new Common.UI.MenuItem({iconCls:"menu__icon cc-remove",caption:i.textRemove,value:"remove"}).on("click",e.bind(i.onControlsSelect,i)),D=new Common.UI.MenuItem({caption:i.textSettings,value:"settings"}).on("click",e.bind(i.onControlsSelect,i)),F=new Common.UI.MenuItem({caption:i.textContentControls,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[B,D]})}),R=new Common.UI.MenuItem({caption:i.textTOC,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[{caption:i.textSettings,value:"settings"},{caption:i.textUpdateAll,value:"all"},{caption:i.textUpdatePages,value:"pages"}]})});R.menu.on("item:click",function(t,e,n){i.fireEvent("settings"==e.value?"links:contents":"links:update",[e.value,!0])});var L=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-comments",caption:i.addCommentText}).on("click",e.bind(i.addComment,i)),N=new Common.UI.MenuItem({iconCls:"menu__icon btn-inserthyperlink",caption:i.hyperlinkText}).on("click",e.bind(i.addHyperlink,i)),H=new Common.UI.MenuItem({caption:i.textFollow}).on("click",e.bind(i.onFollowMove,i));i.menuSpellTable=new Common.UI.MenuItem({caption:i.loadSpellText,disabled:!0}),i.menuSpellMoreTable=new Common.UI.MenuItem({caption:i.moreText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",restoreHeight:!0,items:[]})});var O=e.template(['','',"<%= caption %>",""].join(""));i.langTableMenu=new Common.UI.MenuItem({iconCls:"menu__icon btn-ic-doclang",caption:i.langText,menu:new Common.UI.MenuSimple({cls:"lang-menu",menuAlign:"tl-tr",restoreHeight:285,items:[],itemTemplate:O,search:!0})});var z=new Common.UI.MenuItem({caption:i.ignoreSpellText}).on("click",function(t){i.api&&(i.api.asc_ignoreMisspelledWord(i._currentSpellObj,!1),i.fireEvent("editcomplete",i))}),$=new Common.UI.MenuItem({caption:i.ignoreAllSpellText}).on("click",function(t){i.api&&(i.api.asc_ignoreMisspelledWord(i._currentSpellObj,!0),i.fireEvent("editcomplete",i))}),G=new Common.UI.MenuItem({caption:i.toDictionaryText}).on("click",function(t,e){i.api.asc_spellCheckAddToDictionary(i._currentSpellObj),i.fireEvent("editcomplete",i)}),W=new Common.UI.MenuItem({caption:"--"}),j=new Common.UI.MenuItem({caption:"--"});i.menuSpellCheckTable=new Common.UI.MenuItem({iconCls:"menu__icon btn-ic-docspell",caption:i.spellcheckText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[i.menuSpellTable,i.menuSpellMoreTable,W,z,$,G,{caption:"--"},i.langTableMenu]})});var K=new Common.UI.MenuItem({iconCls:"menu__icon btn-copy",caption:i.textCopy,value:"copy"}).on("click",e.bind(i.onCutCopyPaste,i)),q=new Common.UI.MenuItem({iconCls:"menu__icon btn-paste",caption:i.textPaste,value:"paste"}).on("click",e.bind(i.onCutCopyPaste,i)),Y=new Common.UI.MenuItem({iconCls:"menu__icon btn-cut",caption:i.textCut,value:"cut"}).on("click",e.bind(i.onCutCopyPaste,i)),X=new Common.UI.MenuItem({iconCls:"menu__icon btn-print",caption:i.txtPrintSelection}).on("click",e.bind(i.onPrintSelection,i)),J=new Common.UI.MenuItem({caption:"--"}),Z=new Common.UI.MenuItem({caption:i.textDistributeRows}).on("click",e.bind(function(){i.api&&i.api.asc_DistributeTableCells(!1),i.fireEvent("editcomplete",i)},i)),Q=new Common.UI.MenuItem({caption:i.textDistributeCols}).on("click",e.bind(function(){i.api&&i.api.asc_DistributeTableCells(!0),i.fireEvent("editcomplete",i)},i)),tt=function(t,e){if(i.api){var n=new Asc.CTableProp;n.put_CellsTextDirection(t.options.direction),i.api.tblApply(n)}},et=new Common.UI.MenuItem({iconCls:"menu__icon text-orient-hor",caption:i.directionText,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[i.menuTableDirectH=new Common.UI.MenuItem({caption:i.directHText,iconCls:"menu__icon text-orient-hor",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popuptabledirect",direction:Asc.c_oAscCellTextDirection.LRTB}).on("click",e.bind(tt,i)),i.menuTableDirect90=new Common.UI.MenuItem({caption:i.direct90Text,iconCls:"menu__icon text-orient-rdown",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popuptabledirect",direction:Asc.c_oAscCellTextDirection.TBRL}).on("click",e.bind(tt,i)),i.menuTableDirect270=new Common.UI.MenuItem({caption:i.direct270Text,iconCls:"menu__icon text-orient-rup",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popuptabledirect",direction:Asc.c_oAscCellTextDirection.BTLR}).on("click",e.bind(tt,i))]})}),it=new Common.UI.MenuItem({caption:i.textStartNewList}).on("click",e.bind(i.onStartNumbering,i,1)),nt=new Common.UI.MenuItem({caption:i.textStartNumberingFrom}).on("click",e.bind(i.onStartNumbering,i,"advanced")),ot=new Common.UI.MenuItem({caption:i.textContinueNumbering}).on("click",e.bind(i.onContinueNumbering,i)),st=new Common.UI.MenuItem({caption:i.bulletsText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[it,nt,ot]})}),at=new Common.UI.MenuItem({caption:i.textRefreshField}).on("click",function(t,e){i.api.asc_UpdateComplexField(t.options.fieldProps),i.fireEvent("editcomplete",i)}),rt=new Common.UI.MenuItem({caption:"--"});this.tableMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(t){if(!e.isUndefined(t.tableProps)){for(var n=t.mathProps&&t.mathProps.value,o=8;o<27;o++)i.tableMenu.items[o].setVisible(!n);var s=t.tableProps.value.get_CellsVAlign(),a="";switch(s){case Asc.c_oAscVertAlignJc.Top:a="menu__icon btn-align-top";break;case Asc.c_oAscVertAlignJc.Center:a="menu__icon btn-align-middle";break;case Asc.c_oAscVertAlignJc.Bottom:a="menu__icon btn-align-bottom"}T.setIconCls(a),i.menuTableCellTop.setChecked(s==Asc.c_oAscVertAlignJc.Top),i.menuTableCellCenter.setChecked(s==Asc.c_oAscVertAlignJc.Center),i.menuTableCellBottom.setChecked(s==Asc.c_oAscVertAlignJc.Bottom);var r=t.tableProps.value.get_CellsTextDirection();switch(a="",r){case Asc.c_oAscCellTextDirection.LRTB:a="menu__icon text-orient-hor";break;case Asc.c_oAscCellTextDirection.TBRL:a="menu__icon text-orient-rdown";break;case Asc.c_oAscCellTextDirection.BTLR:a="menu__icon text-orient-rup"}et.setIconCls(a),i.menuTableDirectH.setChecked(r==Asc.c_oAscCellTextDirection.LRTB),i.menuTableDirect90.setChecked(r==Asc.c_oAscCellTextDirection.TBRL),i.menuTableDirect270.setChecked(r==Asc.c_oAscCellTextDirection.BTLR);var l=t.tableProps.locked||void 0!==t.headerProps&&t.headerProps.locked;i.tableMenu.items[11].setDisabled(l),i.tableMenu.items[12].setDisabled(l),i.api&&(S.setDisabled(l||!i.api.CheckBeforeMergeCells()),A.setDisabled(l||!i.api.CheckBeforeSplitCells())),Z.setDisabled(l),Q.setDisabled(l),T.setDisabled(l),et.setDisabled(l),I.setDisabled(l);var c=i.api&&i.api.can_CopyCut();K.setDisabled(!c),Y.setDisabled(l||!c),q.setDisabled(l),X.setVisible(i.mode.canPrint),X.setDisabled(!c);var d=i.api.asc_GetCurrentNumberingId(),h=null!==d;if(st.setVisible(h),h){var p=i.api.asc_GetNumberingPr(d).get_Lvl(i.api.asc_GetCurrentNumberingLvl()),m=p.get_Format(),u=i.api.asc_GetCalculatedNumberingValue();it.setVisible(p.get_Start()!=u),it.value={start:p.get_Start()},nt.setVisible(m!=Asc.c_oAscNumberingFormat.Bullet),nt.value={format:m,start:u},it.setCaption(m==Asc.c_oAscNumberingFormat.Bullet?i.textSeparateList:i.textStartNewList),ot.setCaption(m==Asc.c_oAscNumberingFormat.Bullet?i.textJoinList:i.textContinueNumbering)}var g=null;i.api&&(g=i.api.can_AddHyperlink()),N.setVisible(void 0===t.hyperProps&&!1!==g),V.setVisible(void 0!==t.hyperProps),E.hyperProps=t.hyperProps,U.hyperProps=t.hyperProps,!1!==g&&(N.hyperProps={},N.hyperProps.value=new Asc.CHyperlinkProperty,N.hyperProps.value.put_Text(g));var b=i.api.asc_GetRevisionsChangesStack(),f=!1;H.value=null,e.each(b,function(t){t.get_Type()!=Asc.c_oAscRevisionsChangeType.TextAdd&&t.get_Type()!=Asc.c_oAscRevisionsChangeType.TextRem||t.get_MoveType()==Asc.c_oAscRevisionsMove.NoMove||(H.value=t,f=!0)}),H.setVisible(f),M.setVisible(N.isVisible()||V.isVisible()||st.isVisible()||H.isVisible()),P.setVisible(void 0!==t.paraProps),i._currentParaObjDisabled=l=t.paraProps.locked||void 0!==t.headerProps&&t.headerProps.locked,N.setDisabled(l),V.setDisabled(l||void 0!==t.hyperProps&&!0===t.hyperProps.isSeveralLinks),P.setDisabled(l),i.menuSpellCheckTable.setVisible(void 0!==t.spellProps&&!1===t.spellProps.value.get_Checked()),G.setVisible(i.mode.isDesktopApp),j.setVisible(void 0!==t.spellProps&&!1===t.spellProps.value.get_Checked()),i.langTableMenu.setDisabled(l),void 0!==t.spellProps&&!1===t.spellProps.value.get_Checked()&&null!==t.spellProps.value.get_Variants()&&void 0!==t.spellProps.value.get_Variants()?i.addWordVariants(!1):(i.menuSpellTable.setCaption(i.loadSpellText,!0),i.clearWordVariants(!1),i.menuSpellMoreTable.setVisible(!1)),i.menuSpellCheckTable.isVisible()&&i._currLang.id!==i._currLang.tableid&&(i.changeLanguageMenu(i.langTableMenu.menu),i._currLang.tableid=i._currLang.id);var C=0;n?C=i.addEquationMenu(!1,7):i.clearEquationMenu(!1,7),J.setVisible(n&&C>0);var v=!!t.paraProps&&!(t.paraProps.value.can_DeleteBlockContentControl()&&t.paraProps.value.can_EditBlockContentControl()&&t.paraProps.value.can_DeleteInlineContentControl()&&t.paraProps.value.can_EditInlineContentControl()),_=i.api.asc_GetTableOfContentsPr(!0),y=!_&&i.api.asc_IsContentControl();if(F.setVisible(y),y){var w=i.api.asc_GetContentControlProperties(),x=w?w.get_Lock():Asc.c_oAscSdtLockType.Unlocked,k=w&&w.get_FormPr();B.setDisabled(x==Asc.c_oAscSdtLockType.SdtContentLocked||x==Asc.c_oAscSdtLockType.SdtLocked),B.setCaption(k?i.getControlLabel(w):i.textRemoveControl),D.setVisible(i.mode.canEditContentControl&&!k);var O=w?w.get_SpecificType():Asc.c_oAscContentControlSpecificType.None;v=v||O==Asc.c_oAscContentControlSpecificType.CheckBox||O==Asc.c_oAscContentControlSpecificType.Picture||O==Asc.c_oAscContentControlSpecificType.ComboBox||O==Asc.c_oAscContentControlSpecificType.DropDownList||O==Asc.c_oAscContentControlSpecificType.DateTime}R.setVisible(_),L.setVisible(!1!==i.api.can_AddQuotedComment()&&i.mode.canCoAuthoring&&i.mode.canComments&&!v),L.setDisabled(void 0!==t.paraProps&&!0===t.paraProps.locked);var z=i.api.asc_GetCurrentComplexField();at.setVisible(!!z),at.setDisabled(l),rt.setVisible(!!z),z&&(at.options.fieldProps=z)}},items:[i.menuSpellCheckTable,j,Y,K,q,X,{caption:"--"},J,at,rt,{caption:i.selectText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",style:"width: 100px",items:[new Common.UI.MenuItem({caption:i.rowText}).on("click",function(t){i.api&&i.api.selectRow()}),new Common.UI.MenuItem({caption:i.columnText}).on("click",function(t){i.api&&i.api.selectColumn()}),new Common.UI.MenuItem({caption:i.cellText}).on("click",function(t){i.api&&i.api.selectCell()}),new Common.UI.MenuItem({caption:i.tableText}).on("click",function(t){i.api&&i.api.selectTable()})]})},{iconCls:"menu__icon btn-addcell",caption:i.insertText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.insertColumnLeftText}).on("click",function(t){i.api&&i.api.addColumnLeft()}),new Common.UI.MenuItem({caption:i.insertColumnRightText}).on("click",function(t){i.api&&i.api.addColumnRight()}),new Common.UI.MenuItem({caption:i.insertRowAboveText}).on("click",function(t){i.api&&i.api.addRowAbove()}),new Common.UI.MenuItem({caption:i.insertRowBelowText}).on("click",function(t){i.api&&i.api.addRowBelow()}),new Common.UI.MenuItem({caption:i.textSeveral}).on("click",function(t){i.onCellsAdd()})]})},{iconCls:"menu__icon btn-delcell",caption:i.deleteText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",style:"width: 100px",items:[new Common.UI.MenuItem({caption:i.rowText}).on("click",function(t){i.api&&i.api.remRow()}),new Common.UI.MenuItem({caption:i.columnText}).on("click",function(t){i.api&&i.api.remColumn()}),new Common.UI.MenuItem({caption:i.tableText}).on("click",function(t){i.api&&i.api.remTable()}),new Common.UI.MenuItem({caption:i.textCells}).on("click",function(t){i.onCellsRemove()})]})},{caption:"--"},S,A,{caption:"--"},Z,Q,{caption:"--"},T,et,{caption:"--"},x,{caption:"--"},I,{caption:"--"},L,st,N,V,H,M,F,R,P]}).on("hide:after",function(t,e,n){if(i.suppressEditComplete)return void(i.suppressEditComplete=!1);n||i.fireEvent("editcomplete",i),i.currentMenu=null});var lt=new Common.UI.MenuItem({caption:i.breakBeforeText,checkable:!0}).on("click",function(t,e){i.api.put_PageBreak(t.checked)}),ct=new Common.UI.MenuItem({caption:i.keepLinesText,checkable:!0}).on("click",function(t,e){i.api.put_KeepLines(t.checked)}),dt=function(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_VerticalTextAlign(t.options.valign),i.api.ImgApply(n)}},ht=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-top",caption:i.vertAlignText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[i.menuParagraphTop=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-top",caption:i.textShapeAlignTop,checkmark:!1,checkable:!0,checked:!1,toggleGroup:"popupparagraphvalign",valign:Asc.c_oAscVAlign.Top}).on("click",e.bind(dt,i)),i.menuParagraphCenter=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-middle",caption:i.textShapeAlignMiddle,checkmark:!1,checkable:!0,checked:!1,toggleGroup:"popupparagraphvalign",valign:Asc.c_oAscVAlign.Center}).on("click",e.bind(dt,i)),i.menuParagraphBottom=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-bottom",caption:i.textShapeAlignBottom,checkmark:!1,checkable:!0,checked:!1,toggleGroup:"popupparagraphvalign",valign:Asc.c_oAscVAlign.Bottom}).on("click",e.bind(dt,i))]})}),pt=function(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_Vert(t.options.direction),i.api.ImgApply(n)}},mt=new Common.UI.MenuItem({iconCls:"menu__icon text-orient-hor",caption:i.directionText,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[i.menuParagraphDirectH=new Common.UI.MenuItem({caption:i.directHText,iconCls:"menu__icon text-orient-hor",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popupparagraphdirect",direction:Asc.c_oAscVertDrawingText.normal}).on("click",e.bind(pt,i)),i.menuParagraphDirect90=new Common.UI.MenuItem({caption:i.direct90Text,iconCls:"menu__icon text-orient-rdown",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popupparagraphdirect",direction:Asc.c_oAscVertDrawingText.vert}).on("click",e.bind(pt,i)),i.menuParagraphDirect270=new Common.UI.MenuItem({caption:i.direct270Text,iconCls:"menu__icon text-orient-rup",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popupparagraphdirect",direction:Asc.c_oAscVertDrawingText.vert270}).on("click",e.bind(pt,i))]})}),ut=new Common.UI.MenuItem({iconCls:"menu__icon btn-paragraph",caption:i.advancedParagraphText}).on("click",e.bind(i.advancedParagraphClick,i)),gt=new Common.UI.MenuItem({caption:i.advancedFrameText}).on("click",e.bind(i.advancedFrameClick,i,!0)),bt=new Common.UI.MenuItem({iconCls:"menu__icon dropcap-intext",caption:i.advancedDropCapText}).on("click",e.bind(i.advancedFrameClick,i,!1)),ft=new Common.UI.MenuItem({caption:"--"}),Ct=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-comments",caption:i.addCommentText}).on("click",e.bind(i.addComment,i)),vt=new Common.UI.MenuItem({caption:"--"}),_t=new Common.UI.MenuItem({iconCls:"menu__icon btn-inserthyperlink",caption:i.hyperlinkText}).on("click",e.bind(i.addHyperlink,i)),yt=new Common.UI.MenuItem({caption:i.editHyperlinkText}).on("click",e.bind(i.editHyperlink,i)),wt=new Common.UI.MenuItem({caption:i.removeHyperlinkText}).on("click",function(t,e){i.api.remove_Hyperlink(t.hyperProps.value),i.fireEvent("editcomplete",i)}),xt=new Common.UI.MenuItem({iconCls:"menu__icon btn-inserthyperlink",caption:i.hyperlinkText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[yt,wt]})}),St=new Common.UI.MenuItemSeparator,At=new Common.UI.MenuItem({caption:i.styleText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[i.menuStyleSave=new Common.UI.MenuItem({caption:i.saveStyleText}).on("click",e.bind(i.onMenuSaveStyle,i)),i.menuStyleUpdate=new Common.UI.MenuItem({caption:i.updateStyleText.replace("%1",window.currentStyleName)}).on("click",e.bind(i.onMenuUpdateStyle,i))]})});i.menuSpellPara=new Common.UI.MenuItem({caption:i.loadSpellText,disabled:!0}),i.menuSpellMorePara=new Common.UI.MenuItem({caption:i.moreText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",restoreHeight:!0,items:[]})}),i.langParaMenu=new Common.UI.MenuItem({iconCls:"menu__icon btn-ic-doclang",caption:i.langText,menu:new Common.UI.MenuSimple({cls:"lang-menu",menuAlign:"tl-tr",restoreHeight:285,items:[],itemTemplate:O,search:!0})});var kt=new Common.UI.MenuItem({caption:i.ignoreSpellText}).on("click",function(t,e){i.api.asc_ignoreMisspelledWord(i._currentSpellObj,!1),i.fireEvent("editcomplete",i)}),Tt=new Common.UI.MenuItem({caption:i.ignoreAllSpellText}).on("click",function(t,e){i.api.asc_ignoreMisspelledWord(i._currentSpellObj,!0),i.fireEvent("editcomplete",i)}),It=new Common.UI.MenuItem({caption:i.toDictionaryText}).on("click",function(t,e){i.api.asc_spellCheckAddToDictionary(i._currentSpellObj),i.fireEvent("editcomplete",i)}),Pt=new Common.UI.MenuItem({caption:"--"}),Mt=new Common.UI.MenuItem({caption:"--"}),Et=new Common.UI.MenuItem({iconCls:"menu__icon btn-copy",caption:i.textCopy,value:"copy"}).on("click",e.bind(i.onCutCopyPaste,i)),Ut=new Common.UI.MenuItem({iconCls:"menu__icon btn-paste",caption:i.textPaste,value:"paste"}).on("click",e.bind(i.onCutCopyPaste,i)),Vt=new Common.UI.MenuItem({iconCls:"menu__icon btn-cut",caption:i.textCut,value:"cut"}).on("click",e.bind(i.onCutCopyPaste,i)),Bt=new Common.UI.MenuItem({iconCls:"menu__icon btn-print",caption:i.txtPrintSelection}).on("click",e.bind(i.onPrintSelection,i)),Dt=new Common.UI.MenuItem({caption:"--"}),Ft=new Common.UI.MenuItem({iconCls:"menu__icon cc-remove",caption:i.textRemoveControl,value:"remove"}).on("click",e.bind(i.onControlsSelect,i)),Rt=new Common.UI.MenuItem({caption:i.textEditControls,value:"settings"}).on("click",e.bind(i.onControlsSelect,i)),Lt=new Common.UI.MenuItem({caption:"--"}),Nt=new Common.UI.MenuItem({caption:i.textTOCSettings,value:"settings"}).on("click",function(t,e){i.fireEvent("links:contents",[t.value,!0])}),Ht=new Common.UI.MenuItem({caption:i.textUpdateTOC,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[{caption:i.textUpdateAll,value:"all"},{caption:i.textUpdatePages,value:"pages"}]})});Ht.menu.on("item:click",function(t,e,n){i.fireEvent("links:update",[e.value,!0])});var Ot=new Common.UI.MenuItem({caption:"--"}),zt=new Common.UI.MenuItem({caption:i.textRefreshField}).on("click",function(t,e){i.api.asc_UpdateComplexField(t.options.fieldProps),i.fireEvent("editcomplete",i)}),$t=new Common.UI.MenuItem({caption:"--"}),Gt=new Common.UI.MenuItem({caption:i.textStartNewList}).on("click",e.bind(i.onStartNumbering,i,1)),Wt=new Common.UI.MenuItem({caption:i.textStartNumberingFrom}).on("click",e.bind(i.onStartNumbering,i,"advanced")),jt=new Common.UI.MenuItem({caption:i.textContinueNumbering}).on("click",e.bind(i.onContinueNumbering,i)),Kt=new Common.UI.MenuItem({caption:"--"}),qt=new Common.UI.MenuItem({caption:i.textFollow}).on("click",e.bind(i.onFollowMove,i)),Yt=new Common.UI.MenuItem({caption:"--"});this.textMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(t){var n=t.imgProps&&t.imgProps.value&&!e.isNull(t.imgProps.value.get_ShapeProperties()),o=t.imgProps&&t.imgProps.value&&!e.isNull(t.imgProps.value.get_ChartProperties()),r=t.mathProps&&t.mathProps.value;if(ht.setVisible(n&&!o&&!r),mt.setVisible(n&&!o&&!r),n||o){var l=t.imgProps.value.get_VerticalTextAlign(),c="";switch(l){case Asc.c_oAscVAlign.Top:c="menu__icon btn-align-top";break;case Asc.c_oAscVAlign.Center:c="menu__icon btn-align-middle";break;case Asc.c_oAscVAlign.Bottom:c="menu__icon btn-align-bottom"}ht.setIconCls(c), -i.menuParagraphTop.setChecked(l==Asc.c_oAscVAlign.Top),i.menuParagraphCenter.setChecked(l==Asc.c_oAscVAlign.Center),i.menuParagraphBottom.setChecked(l==Asc.c_oAscVAlign.Bottom);var d=t.imgProps.value.get_Vert();switch(c="",d){case Asc.c_oAscVertDrawingText.normal:c="menu__icon text-orient-hor";break;case Asc.c_oAscVertDrawingText.vert:c="menu__icon text-orient-rdown";break;case Asc.c_oAscVertDrawingText.vert270:c="menu__icon text-orient-rup"}mt.setIconCls(c),i.menuParagraphDirectH.setChecked(d==Asc.c_oAscVertDrawingText.normal),i.menuParagraphDirect90.setChecked(d==Asc.c_oAscVertDrawingText.vert),i.menuParagraphDirect270.setChecked(d==Asc.c_oAscVertDrawingText.vert270)}ut.isChart=t.imgProps&&t.imgProps.isChart,lt.setVisible(!n&&!o&&!r),ct.setVisible(!n&&!o&&!r),t.paraProps&&(lt.setChecked(t.paraProps.value.get_PageBreakBefore()),ct.setChecked(t.paraProps.value.get_KeepLines()));var h=null;i.api&&(h=i.api.can_AddHyperlink()),_t.setVisible(void 0===t.hyperProps&&!1!==h),xt.setVisible(void 0!==t.hyperProps),vt.setVisible(_t.isVisible()||xt.isVisible()),yt.hyperProps=t.hyperProps,wt.hyperProps=t.hyperProps,!1!==h&&(_t.hyperProps={},_t.hyperProps.value=new Asc.CHyperlinkProperty,_t.hyperProps.value.put_Text(h));var p=t.paraProps.locked||void 0!==t.headerProps&&t.headerProps.locked;i._currentParaObjDisabled=p,_t.setDisabled(p),xt.setDisabled(p||void 0!==t.hyperProps&&!0===t.hyperProps.isSeveralLinks);var m=i.api.asc_GetRevisionsChangesStack(),u=!1;qt.value=null,e.each(m,function(t){t.get_Type()!=Asc.c_oAscRevisionsChangeType.TextAdd&&t.get_Type()!=Asc.c_oAscRevisionsChangeType.TextRem||t.get_MoveType()==Asc.c_oAscRevisionsMove.NoMove||(qt.value=t,u=!0)}),qt.setVisible(u),Yt.setVisible(u),lt.setDisabled(p||!e.isUndefined(t.headerProps)||!e.isUndefined(t.imgProps)),ct.setDisabled(p),ut.setDisabled(p),gt.setDisabled(p),bt.setDisabled(p),ht.setDisabled(p),mt.setDisabled(p);var g=i.api&&i.api.can_CopyCut();Et.setDisabled(!g),Vt.setDisabled(p||!g),Ut.setDisabled(p),Bt.setVisible(i.mode.canPrint),Bt.setDisabled(!g);var b=void 0!==t.spellProps&&!1===t.spellProps.value.get_Checked();i.menuSpellPara.setVisible(b),Mt.setVisible(b),kt.setVisible(b),Tt.setVisible(b),It.setVisible(b&&i.mode.isDesktopApp),i.langParaMenu.setVisible(b),i.langParaMenu.setDisabled(p),Pt.setVisible(b),b&&null!==t.spellProps.value.get_Variants()&&void 0!==t.spellProps.value.get_Variants()?i.addWordVariants(!0):(i.menuSpellPara.setCaption(i.loadSpellText,!0),i.clearWordVariants(!0),i.menuSpellMorePara.setVisible(!1)),i.langParaMenu.isVisible()&&i._currLang.id!==i._currLang.paraid&&(i.changeLanguageMenu(i.langParaMenu.menu),i._currLang.paraid=i._currLang.id);var f=0;r?f=i.addEquationMenu(!0,15):i.clearEquationMenu(!0,15),Dt.setVisible(r&&f>0),s.setVisible(r),a.setVisible(r);var C=t.paraProps.value.get_FramePr();gt.setVisible(void 0!==C),bt.setVisible(void 0!==C),C&&bt.setIconCls(C.get_DropCap()===Asc.c_oAscDropCap.Drop?"menu__icon dropcap-intext":"menu__icon dropcap-inmargin"),St.setVisible(i.mode.canEditStyles&&!o),At.setVisible(i.mode.canEditStyles&&!o),i.mode.canEditStyles&&!o&&i.menuStyleUpdate.setCaption(i.updateStyleText.replace("%1",DE.getController("Main").translationTable[window.currentStyleName]||window.currentStyleName));var v=!!t.paraProps&&!(t.paraProps.value.can_DeleteBlockContentControl()&&t.paraProps.value.can_EditBlockContentControl()&&t.paraProps.value.can_DeleteInlineContentControl()&&t.paraProps.value.can_EditInlineContentControl()),_=i.api.asc_GetTableOfContentsPr(!0),y=!_&&i.api.asc_IsContentControl(),w=y?i.api.asc_GetContentControlProperties():null,x=w&&w.get_FormPr();if(Ft.setVisible(y),Rt.setVisible(y&&i.mode.canEditContentControl&&!x),Lt.setVisible(y),y){var S=w?w.get_Lock():Asc.c_oAscSdtLockType.Unlocked;Ft.setDisabled(S==Asc.c_oAscSdtLockType.SdtContentLocked||S==Asc.c_oAscSdtLockType.SdtLocked),Ft.setCaption(x?i.getControlLabel(w):i.textRemoveControl);var A=w?w.get_SpecificType():Asc.c_oAscContentControlSpecificType.None;v=v||A==Asc.c_oAscContentControlSpecificType.CheckBox||A==Asc.c_oAscContentControlSpecificType.Picture||A==Asc.c_oAscContentControlSpecificType.ComboBox||A==Asc.c_oAscContentControlSpecificType.DropDownList||A==Asc.c_oAscContentControlSpecificType.DateTime}Nt.setVisible(_),Ht.setVisible(_),Ot.setVisible(_);var k=!o&&!1!==i.api.can_AddQuotedComment()&&i.mode.canCoAuthoring&&i.mode.canComments&&!v;i.mode.compatibleFeatures&&(k=k&&!n),ft.setVisible(k),Ct.setVisible(k),Ct.setDisabled(t.paraProps&&!0===t.paraProps.locked);var T=i.api.asc_GetCurrentComplexField();zt.setVisible(!!T),zt.setDisabled(p),$t.setVisible(!!T),T&&(zt.options.fieldProps=T);var I=i.api.asc_GetCurrentNumberingId(),P=null!==I;if(Kt.setVisible(P),Gt.setVisible(P),Wt.setVisible(P),jt.setVisible(P),P){var M=i.api.asc_GetNumberingPr(I).get_Lvl(i.api.asc_GetCurrentNumberingLvl()),E=M.get_Format(),U=i.api.asc_GetCalculatedNumberingValue();Gt.setVisible(M.get_Start()!=U),Gt.value={start:M.get_Start()},Wt.setVisible(E!=Asc.c_oAscNumberingFormat.Bullet),Wt.value={format:E,start:U},Gt.setCaption(E==Asc.c_oAscNumberingFormat.Bullet?i.textSeparateList:i.textStartNewList),jt.setCaption(E==Asc.c_oAscNumberingFormat.Bullet?i.textJoinList:i.textContinueNumbering)}},items:[i.menuSpellPara,i.menuSpellMorePara,Mt,kt,Tt,It,i.langParaMenu,Pt,Vt,Et,Ut,Bt,a,s,{caption:"--"},Dt,Ft,Rt,Lt,zt,$t,Nt,Ht,Ot,lt,ct,ht,mt,ut,gt,bt,ft,Ct,vt,_t,xt,Yt,qt,Kt,Gt,Wt,jt,St,At]}).on("hide:after",function(t,e,n){if(i.suppressEditComplete)return void(i.suppressEditComplete=!1);n||i.fireEvent("editcomplete",i),i.currentMenu=null});var Xt=new Common.UI.MenuItem({caption:i.editHeaderText});this.hdrMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(t){Xt.setCaption(t.Header?i.editHeaderText:i.editFooterText,!0),Xt.off("click").on("click",function(e){i.api&&(t.Header?i.api.GoToHeader(t.PageNum):i.api.GoToFooter(t.PageNum),i.fireEvent("editcomplete",i))})},items:[Xt]}).on("hide:after",function(t,e,n){n||i.fireEvent("editcomplete",i),i.currentMenu=null});var Jt=t("#id_buttonNextPage");Jt.attr("data-toggle","tooltip"),Jt.tooltip({title:i.textNextPage+Common.Utils.String.platformKey("Alt+PgDn"),placement:"top-right"});var Zt=t("#id_buttonPrevPage");Zt.attr("data-toggle","tooltip"),Zt.tooltip({title:i.textPrevPage+Common.Utils.String.platformKey("Alt+PgUp"),placement:"top-right"})},setLanguages:function(t){var i=this;if(t&&t.length>0&&i.langParaMenu&&i.langTableMenu){var n=[],o=[];e.each(t,function(t){var i={caption:t.displayValue,value:t.value,checkable:!0,langid:t.code,spellcheck:t.spellcheck};n.push(i),o.push(e.clone(i))}),i.langParaMenu.menu.resetItems(n),i.langTableMenu.menu.resetItems(o),i.langParaMenu.menu.on("item:click",function(t,n){i.api&&(e.isUndefined(n.langid)||i.api.put_TextPrLang(n.langid),i._currLang.paraid=n.langid,i.fireEvent("editcomplete",i))}),i.langTableMenu.menu.on("item:click",function(t,n,o){i.api&&(e.isUndefined(n.langid)||i.api.put_TextPrLang(n.langid),i._currLang.tableid=n.langid,i.fireEvent("editcomplete",i))})}},onSignatureClick:function(t){var e=t.cmpEl.attr("data-value");switch(t.value){case 0:Common.NotificationCenter.trigger("protect:sign",e);break;case 1:this.api.asc_ViewCertificate(e);break;case 2:Common.NotificationCenter.trigger("protect:signature","visible",this._isDisabled,e);break;case 3:this.api.asc_RemoveSignature(e)}},onImgRotate:function(t){var e=new Asc.asc_CImgProperty;e.asc_putRotAdd(3.14159265358979*(1==t.value?90:270)/180),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onImgFlip:function(t){var e=new Asc.asc_CImgProperty;1==t.value?e.asc_putFlipHInvert(!0):e.asc_putFlipVInvert(!0),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onImgCrop:function(t){1==t.value?this.api.asc_cropFill():2==t.value?this.api.asc_cropFit():t.checked?this.api.asc_startEditCrop():this.api.asc_endEditCrop(),this.fireEvent("editcomplete",this)},onFollowMove:function(t){this.api&&this.api.asc_FollowRevisionMove(t.value),this.fireEvent("editcomplete",this)},onHideContentControlsActions:function(){this.listControlMenu&&this.listControlMenu.isVisible()&&this.listControlMenu.hide();var t=this.cmpEl.find("#calendar-control-container");t.is(":visible")&&t.hide()},onShowDateActions:function(e,i,n){var o=e.pr,s=o.get_DateTimePr(),a=this.cmpEl.find("#calendar-control-container"),r=this;this._dateObj=o,a.length<1&&(a=t('
    '),this.cmpEl.append(a)),Common.UI.Menu.Manager.hideAll(),a.css({left:i,top:n}),a.show(),this.cmpCalendar||(this.cmpCalendar=new Common.UI.Calendar({el:this.cmpEl.find("#id-document-calendar-control"),enableKeyEvents:!0,firstday:1}),this.cmpCalendar.on("date:click",function(t,e){var i=r._dateObj.get_DateTimePr();i.put_FullDate(new Date(e)),r.api.asc_SetContentControlDatePickerDate(i),a.hide(),r.api.asc_UncheckContentControlButtons(),r.fireEvent("editcomplete",r)}),this.cmpCalendar.on("calendar:keydown",function(t,e){e.keyCode==Common.UI.Keys.ESC&&(a.hide(),r.api.asc_UncheckContentControlButtons())}),t(document).on("mousedown",function(t){"canvas"!==t.target.localName&&a.is(":visible")&&0==a.find(t.target).length&&(a.hide(),r.api.asc_UncheckContentControlButtons())})),this.cmpCalendar.setDate(new Date(s?s.get_FullDate():void 0));var l=a.offset(),c=Common.Utils.innerWidth(),d=Common.Utils.innerHeight()-10,h=this.cmpCalendar.cmpEl.outerWidth(),p=this.cmpCalendar.cmpEl.outerHeight(),m=l.left-h,u=l.top;u+p>d&&(u=d-p,m-=22),u<0&&(u=0),m+h>c&&(m=c-h),this.cmpCalendar.cmpEl.css({left:m,top:u}),this._preventClick=!0},onShowListActions:function(i,n,o){var s=i.type,a=i.pr,r=s==Asc.c_oAscContentControlSpecificType.ComboBox?a.get_ComboBoxPr():a.get_DropDownListPr(),l=!!a.get_FormPr(),c=this.listControlMenu,d=c?this.cmpEl.find(Common.Utils.String.format("#menu-container-{0}",c.id)):null,h=this;if(this._listObj=a,this._fromShowContentControls=!0,Common.UI.Menu.Manager.hideAll(),c||(this.listControlMenu=c=new Common.UI.Menu({maxHeight:207,menuAlign:"tr-bl",items:[]}),c.on("item:click",function(t,e){setTimeout(function(){-1!==e.value&&h.api.asc_SelectContentControlListItem(e.value,h._listObj.get_InternalId())},1)}),(!d||d.length<1)&&(d=t(Common.Utils.String.format('',c.id)),this.cmpEl.append(d)),c.render(d),c.cmpEl.attr({tabindex:"-1"}),c.on("hide:after",function(){h.listControlMenu.removeAll(),h._fromShowContentControls||h.api.asc_UncheckContentControlButtons()})),r){if(l){var p=a.get_PlaceholderText();c.addItem(new Common.UI.MenuItem({caption:""!==p.trim()?p:this.txtEmpty,value:"",template:e.template([' opacity: 0.6 <% } %>">',"<%= caption %>",""].join(""))}))}for(var m=r.get_ItemsCount(),u=0;u','
    ',"","
    ",'
    ',""].join(""),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this;t.inputUrl=new Common.UI.InputField({el:$("#id-dlg-url"),allowBlank:!1,blankError:t.txtEmpty,style:"width: 100%;",validateOnBlur:!1,validation:function(e){return!!/((^https?)|(^ftp)):\/\/.+/i.test(e)||t.txtNotUrl}}),this.getChild().find(".btn").on("click",_.bind(this.onBtnClick,this))},show:function(){Common.UI.Window.prototype.show.apply(this,arguments);var t=this;_.delay(function(){t.getChild("input").focus()},100)},onPrimary:function(t){return this._handleInput("ok"),!1},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},_handleInput:function(t){if(this.options.handler){if("ok"==t&&!0!==this.inputUrl.checkValidate())return void this.inputUrl.cmpEl.find("input").focus();this.options.handler.call(this,t,this.inputUrl.getValue())}this.close()},textUrl:"Paste an image URL:",txtEmpty:"This field is required",txtNotUrl:'This field should be a URL in the format "http://www.example.com"'},Common.Views.ImageFromUrlDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/component/LoadMask",["common/main/lib/component/BaseView"],function(){"use strict";Common.UI.LoadMask=Common.UI.BaseView.extend(function(){return{options:{cls:"",style:"",title:"Loading...",owner:document.body},template:_.template(['"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t),this.template=this.options.template||this.template,this.title=this.options.title,this.ownerEl=this.options.owner instanceof Common.UI.BaseView?$(this.options.owner.el):$(this.options.owner),this.loaderEl=$(this.template({id:this.id,cls:this.options.cls,style:this.options.style,title:this.title})),this.maskeEl=$('
    '),this.timerId=0},render:function(){return this},show:function(){var t=this.ownerEl,e=this.loaderEl,i=this.maskeEl;if(t.ismasked)return this;t.ismasked=!0;var n=this;return n.title!=n.options.title&&(n.options.title=n.title,$(".asc-loadmask-title",e).html(n.title)),n.timerId=setTimeout(function(){t.append(i),t.append(e),t&&0==t.closest(".asc-window.modal").length&&Common.util.Shortcuts.suspendEvents()},500),this},hide:function(){var t=this.ownerEl;this.timerId&&(clearTimeout(this.timerId),this.timerId=0),t&&t.ismasked&&(0!=t.closest(".asc-window.modal").length||Common.Utils.ModalWindow.isVisible()||Common.util.Shortcuts.resumeEvents(),this.maskeEl&&this.maskeEl.remove(),this.loaderEl&&this.loaderEl.remove()),delete t.ismasked},setTitle:function(t){this.title=t,this.ownerEl&&this.ownerEl.ismasked&&this.loaderEl&&$(".asc-loadmask-title",this.loaderEl).html(t)},isVisible:function(){return!!this.ownerEl.ismasked},updatePosition:function(){var t=this.ownerEl,e=this.loaderEl;t&&t.ismasked&&e&&(e.css({top:Math.round(t.height()/2-(e.height()+parseInt(e.css("padding-top"))+parseInt(e.css("padding-bottom")))/2)+"px",left:Math.round(t.width()/2-(e.width()+parseInt(e.css("padding-left"))+parseInt(e.css("padding-right")))/2)+"px"}),e.css({visibility:"visible"}))}}}())}),define("common/main/lib/view/SelectFileDlg",["common/main/lib/component/Window","common/main/lib/component/LoadMask"],function(){"use strict";Common.Views.SelectFileDlg=Common.UI.Window.extend(_.extend({initialize:function(t){var e={};_.extend(e,{title:this.textTitle,width:1024,height:621,header:!0},t),this.template=['
    '].join(""),e.tpl=_.template(this.template)(e),this.fileChoiceUrl=t.fileChoiceUrl||"",Common.UI.Window.prototype.initialize.call(this,e)},render:function(){Common.UI.Window.prototype.render.call(this),this.$window.find("> .body").css({height:"auto",overflow:"hidden"});var t=document.createElement("iframe");t.width="100%",t.height=585,t.align="top",t.frameBorder=0,t.scrolling="no",t.onload=_.bind(this._onLoad,this),$("#id-select-file-placeholder").append(t),this.loadMask=new Common.UI.LoadMask({owner:$("#id-select-file-placeholder")}),this.loadMask.setTitle(this.textLoading),this.loadMask.show(),t.src=this.fileChoiceUrl;var e=this;this._eventfunc=function(t){e._onWindowMessage(t)},this._bindWindowEvents.call(this),this.on("close",function(t){e._unbindWindowEvents()})},_bindWindowEvents:function(){window.addEventListener?window.addEventListener("message",this._eventfunc,!1):window.attachEvent&&window.attachEvent("onmessage",this._eventfunc)},_unbindWindowEvents:function(){window.removeEventListener?window.removeEventListener("message",this._eventfunc):window.detachEvent&&window.detachEvent("onmessage",this._eventfunc)},_onWindowMessage:function(t){if(t&&window.JSON)try{this._onMessage.call(this,window.JSON.parse(t.data))}catch(t){}},_onMessage:function(t){if(t&&"onlyoffice"==t.Referer&&void 0!==t.file){Common.NotificationCenter.trigger("window:close",this);var e=this;setTimeout(function(){_.isEmpty(t.file)||e.trigger("selectfile",e,t.file)},50)}},_onLoad:function(){this.loadMask&&this.loadMask.hide()},textTitle:"Select Data Source",textLoading:"Loading"},Common.Views.SelectFileDlg||{}))}),void 0===Common)var Common={};if(void 0===Common.define&&(Common.define={}),define("common/main/lib/util/define",[],function(){"use strict";Common.define.c_oAscMathMainType={Symbol:0,Fraction:1,Script:2,Radical:3,Integral:4,LargeOperator:5,Bracket:6,Function:7,Accent:8,LimitLog:9,Operator:10,Matrix:11},Common.define.c_oAscMathType={Symbol_pm:0,Symbol_infinity:1,Symbol_equals:2,Symbol_neq:3,Symbol_about:4,Symbol_times:5,Symbol_div:6,Symbol_factorial:7,Symbol_propto:8,Symbol_less:9,Symbol_ll:10,Symbol_greater:11,Symbol_gg:12,Symbol_leq:13,Symbol_geq:14,Symbol_mp:15,Symbol_cong:16,Symbol_approx:17,Symbol_equiv:18,Symbol_forall:19,Symbol_additional:20,Symbol_partial:21,Symbol_sqrt:22,Symbol_cbrt:23,Symbol_qdrt:24,Symbol_cup:25,Symbol_cap:26,Symbol_emptyset:27,Symbol_percent:28,Symbol_degree:29,Symbol_fahrenheit:30,Symbol_celsius:31,Symbol_inc:32,Symbol_nabla:33,Symbol_exists:34,Symbol_notexists:35,Symbol_in:36,Symbol_ni:37,Symbol_leftarrow:38,Symbol_uparrow:39,Symbol_rightarrow:40,Symbol_downarrow:41,Symbol_leftrightarrow:42,Symbol_therefore:43,Symbol_plus:44,Symbol_minus:45,Symbol_not:46,Symbol_ast:47,Symbol_bullet:48,Symbol_vdots:49,Symbol_cdots:50,Symbol_rddots:51,Symbol_ddots:52,Symbol_aleph:53,Symbol_beth:54,Symbol_QED:55,Symbol_alpha:65536,Symbol_beta:65537,Symbol_gamma:65538,Symbol_delta:65539,Symbol_varepsilon:65540,Symbol_epsilon:65541,Symbol_zeta:65542,Symbol_eta:65543,Symbol_theta:65544,Symbol_vartheta:65545,Symbol_iota:65546,Symbol_kappa:65547,Symbol_lambda:65548,Symbol_mu:65549,Symbol_nu:65550,Symbol_xsi:65551,Symbol_o:65552,Symbol_pi:65553,Symbol_varpi:65554,Symbol_rho:65555,Symbol_varrho:65556,Symbol_sigma:65557,Symbol_varsigma:65558,Symbol_tau:65559,Symbol_upsilon:65560,Symbol_varphi:65561,Symbol_phi:65562,Symbol_chi:65563,Symbol_psi:65564,Symbol_omega:65565,Symbol_Alpha:131072,Symbol_Beta:131073,Symbol_Gamma:131074,Symbol_Delta:131075,Symbol_Epsilon:131076,Symbol_Zeta:131077,Symbol_Eta:131078,Symbol_Theta:131079,Symbol_Iota:131080,Symbol_Kappa:131081,Symbol_Lambda:131082,Symbol_Mu:131083,Symbol_Nu:131084,Symbol_Xsi:131085,Symbol_O:131086,Symbol_Pi:131087,Symbol_Rho:131088,Symbol_Sigma:131089,Symbol_Tau:131090,Symbol_Upsilon:131091,Symbol_Phi:131092,Symbol_Chi:131093,Symbol_Psi:131094,Symbol_Omega:131095,FractionVertical:16777216,FractionDiagonal:16777217,FractionHorizontal:16777218,FractionSmall:16777219,FractionDifferential_1:16842752,FractionDifferential_2:16842753,FractionDifferential_3:16842754,FractionDifferential_4:16842755,FractionPi_2:16842756,ScriptSup:33554432,ScriptSub:33554433,ScriptSubSup:33554434,ScriptSubSupLeft:33554435,ScriptCustom_1:33619968,ScriptCustom_2:33619969,ScriptCustom_3:33619970,ScriptCustom_4:33619971,RadicalSqrt:50331648,RadicalRoot_n:50331649,RadicalRoot_2:50331650,RadicalRoot_3:50331651,RadicalCustom_1:50397184,RadicalCustom_2:50397185,Integral:67108864,IntegralSubSup:67108865,IntegralCenterSubSup:67108866,IntegralDouble:67108867,IntegralDoubleSubSup:67108868,IntegralDoubleCenterSubSup:67108869,IntegralTriple:67108870,IntegralTripleSubSup:67108871,IntegralTripleCenterSubSup:67108872,IntegralOriented:67174400,IntegralOrientedSubSup:67174401,IntegralOrientedCenterSubSup:67174402,IntegralOrientedDouble:67174403,IntegralOrientedDoubleSubSup:67174404,IntegralOrientedDoubleCenterSubSup:67174405,IntegralOrientedTriple:67174406,IntegralOrientedTripleSubSup:67174407,IntegralOrientedTripleCenterSubSup:67174408,Integral_dx:67239936,Integral_dy:67239937,Integral_dtheta:67239938,LargeOperator_Sum:83886080,LargeOperator_Sum_CenterSubSup:83886081,LargeOperator_Sum_SubSup:83886082,LargeOperator_Sum_CenterSub:83886083,LargeOperator_Sum_Sub:83886084,LargeOperator_Prod:83951616,LargeOperator_Prod_CenterSubSup:83951617,LargeOperator_Prod_SubSup:83951618,LargeOperator_Prod_CenterSub:83951619,LargeOperator_Prod_Sub:83951620,LargeOperator_CoProd:83951621, -LargeOperator_CoProd_CenterSubSup:83951622,LargeOperator_CoProd_SubSup:83951623,LargeOperator_CoProd_CenterSub:83951624,LargeOperator_CoProd_Sub:83951625,LargeOperator_Union:84017152,LargeOperator_Union_CenterSubSup:84017153,LargeOperator_Union_SubSup:84017154,LargeOperator_Union_CenterSub:84017155,LargeOperator_Union_Sub:84017156,LargeOperator_Intersection:84017157,LargeOperator_Intersection_CenterSubSup:84017158,LargeOperator_Intersection_SubSup:84017159,LargeOperator_Intersection_CenterSub:84017160,LargeOperator_Intersection_Sub:84017161,LargeOperator_Disjunction:84082688,LargeOperator_Disjunction_CenterSubSup:84082689,LargeOperator_Disjunction_SubSup:84082690,LargeOperator_Disjunction_CenterSub:84082691,LargeOperator_Disjunction_Sub:84082692,LargeOperator_Conjunction:84082693,LargeOperator_Conjunction_CenterSubSup:84082694,LargeOperator_Conjunction_SubSup:84082695,LargeOperator_Conjunction_CenterSub:84082696,LargeOperator_Conjunction_Sub:84082697,LargeOperator_Custom_1:84148224,LargeOperator_Custom_2:84148225,LargeOperator_Custom_3:84148226,LargeOperator_Custom_4:84148227,LargeOperator_Custom_5:84148228,Bracket_Round:100663296,Bracket_Square:100663297,Bracket_Curve:100663298,Bracket_Angle:100663299,Bracket_LowLim:100663300,Bracket_UppLim:100663301,Bracket_Line:100663302,Bracket_LineDouble:100663303,Bracket_Square_OpenOpen:100663304,Bracket_Square_CloseClose:100663305,Bracket_Square_CloseOpen:100663306,Bracket_SquareDouble:100663307,Bracket_Round_Delimiter_2:100728832,Bracket_Curve_Delimiter_2:100728833,Bracket_Angle_Delimiter_2:100728834,Bracket_Angle_Delimiter_3:100728835,Bracket_Round_OpenNone:100794368,Bracket_Round_NoneOpen:100794369,Bracket_Square_OpenNone:100794370,Bracket_Square_NoneOpen:100794371,Bracket_Curve_OpenNone:100794372,Bracket_Curve_NoneOpen:100794373,Bracket_Angle_OpenNone:100794374,Bracket_Angle_NoneOpen:100794375,Bracket_LowLim_OpenNone:100794376,Bracket_LowLim_NoneNone:100794377,Bracket_UppLim_OpenNone:100794378,Bracket_UppLim_NoneOpen:100794379,Bracket_Line_OpenNone:100794380,Bracket_Line_NoneOpen:100794381,Bracket_LineDouble_OpenNone:100794382,Bracket_LineDouble_NoneOpen:100794383,Bracket_SquareDouble_OpenNone:100794384,Bracket_SquareDouble_NoneOpen:100794385,Bracket_Custom_1:100859904,Bracket_Custom_2:100859905,Bracket_Custom_3:100859906,Bracket_Custom_4:100859907,Bracket_Custom_5:100925440,Bracket_Custom_6:100925441,Bracket_Custom_7:100925442,Function_Sin:117440512,Function_Cos:117440513,Function_Tan:117440514,Function_Csc:117440515,Function_Sec:117440516,Function_Cot:117440517,Function_1_Sin:117506048,Function_1_Cos:117506049,Function_1_Tan:117506050,Function_1_Csc:117506051,Function_1_Sec:117506052,Function_1_Cot:117506053,Function_Sinh:117571584,Function_Cosh:117571585,Function_Tanh:117571586,Function_Csch:117571587,Function_Sech:117571588,Function_Coth:117571589,Function_1_Sinh:117637120,Function_1_Cosh:117637121,Function_1_Tanh:117637122,Function_1_Csch:117637123,Function_1_Sech:117637124,Function_1_Coth:117637125,Function_Custom_1:117702656,Function_Custom_2:117702657,Function_Custom_3:117702658,Accent_Dot:134217728,Accent_DDot:134217729,Accent_DDDot:134217730,Accent_Hat:134217731,Accent_Check:134217732,Accent_Accent:134217733,Accent_Grave:134217734,Accent_Smile:134217735,Accent_Tilde:134217736,Accent_Bar:134217737,Accent_DoubleBar:134217738,Accent_CurveBracketTop:134217739,Accent_CurveBracketBot:134217740,Accent_GroupTop:134217741,Accent_GroupBot:134217742,Accent_ArrowL:134217743,Accent_ArrowR:134217744,Accent_ArrowD:134217745,Accent_HarpoonL:134217746,Accent_HarpoonR:134217747,Accent_BorderBox:134283264,Accent_BorderBoxCustom:134283265,Accent_BarTop:134348800,Accent_BarBot:134348801,Accent_Custom_1:134414336,Accent_Custom_2:134414337,Accent_Custom_3:134414338,LimitLog_LogBase:150994944,LimitLog_Log:150994945,LimitLog_Lim:150994946,LimitLog_Min:150994947,LimitLog_Max:150994948,LimitLog_Ln:150994949,LimitLog_Custom_1:151060480,LimitLog_Custom_2:151060481,Operator_ColonEquals:167772160,Operator_EqualsEquals:167772161,Operator_PlusEquals:167772162,Operator_MinusEquals:167772163,Operator_Definition:167772164,Operator_UnitOfMeasure:167772165,Operator_DeltaEquals:167772166,Operator_ArrowL_Top:167837696,Operator_ArrowR_Top:167837697,Operator_ArrowL_Bot:167837698,Operator_ArrowR_Bot:167837699,Operator_DoubleArrowL_Top:167837700,Operator_DoubleArrowR_Top:167837701,Operator_DoubleArrowL_Bot:167837702,Operator_DoubleArrowR_Bot:167837703,Operator_ArrowD_Top:167837704,Operator_ArrowD_Bot:167837705,Operator_DoubleArrowD_Top:167837706,Operator_DoubleArrowD_Bot:167837707,Operator_Custom_1:167903232,Operator_Custom_2:167903233,Matrix_1_2:184549376,Matrix_2_1:184549377,Matrix_1_3:184549378,Matrix_3_1:184549379,Matrix_2_2:184549380,Matrix_2_3:184549381,Matrix_3_2:184549382,Matrix_3_3:184549383,Matrix_Dots_Center:184614912,Matrix_Dots_Baseline:184614913,Matrix_Dots_Vertical:184614914,Matrix_Dots_Diagonal:184614915,Matrix_Identity_2:184680448,Matrix_Identity_2_NoZeros:184680449,Matrix_Identity_3:184680450,Matrix_Identity_3_NoZeros:184680451,Matrix_2_2_RoundBracket:184745984,Matrix_2_2_SquareBracket:184745985,Matrix_2_2_LineBracket:184745986,Matrix_2_2_DLineBracket:184745987,Matrix_Flat_Round:184811520,Matrix_Flat_Square:184811521},Common.define.chartData=_.extend(new function(){return{textLine:"Line",textColumn:"Column",textBar:"Bar",textArea:"Area",textPie:"Pie",textPoint:"XY (Scatter)",textStock:"Stock",textSurface:"Surface",textCharts:"Charts",textSparks:"Sparklines",textLineSpark:"Line",textColumnSpark:"Column",textWinLossSpark:"Win/Loss",getChartGroupData:function(t){return[{id:"menu-chart-group-bar",caption:this.textColumn,headername:t?this.textCharts:void 0},{id:"menu-chart-group-line",caption:this.textLine},{id:"menu-chart-group-pie",caption:this.textPie},{id:"menu-chart-group-hbar",caption:this.textBar},{id:"menu-chart-group-area",caption:this.textArea,inline:!0},{id:"menu-chart-group-scatter",caption:this.textPoint,inline:!0},{id:"menu-chart-group-stock",caption:this.textStock,inline:!0}]},getChartData:function(){return[{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barNormal,iconCls:"column-normal"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barStacked,iconCls:"column-stack"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barStackedPer,iconCls:"column-pstack"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barNormal3d,iconCls:"column-3d-normal"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barStacked3d,iconCls:"column-3d-stack"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barStackedPer3d,iconCls:"column-3d-pstack"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barNormal3dPerspective,iconCls:"column-3d-normal-per"},{group:"menu-chart-group-line",type:Asc.c_oAscChartTypeSettings.lineNormal,iconCls:"line-normal"},{group:"menu-chart-group-line",type:Asc.c_oAscChartTypeSettings.lineStacked,iconCls:"line-stack"},{group:"menu-chart-group-line",type:Asc.c_oAscChartTypeSettings.lineStackedPer,iconCls:"line-pstack"},{group:"menu-chart-group-line",type:Asc.c_oAscChartTypeSettings.line3d,iconCls:"line-3d"},{group:"menu-chart-group-pie",type:Asc.c_oAscChartTypeSettings.pie,iconCls:"pie-normal"},{group:"menu-chart-group-pie",type:Asc.c_oAscChartTypeSettings.doughnut,iconCls:"pie-doughnut"},{group:"menu-chart-group-pie",type:Asc.c_oAscChartTypeSettings.pie3d,iconCls:"pie-3d-normal"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarNormal,iconCls:"bar-normal"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarStacked,iconCls:"bar-stack"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarStackedPer,iconCls:"bar-pstack"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarNormal3d,iconCls:"bar-3d-normal"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarStacked3d,iconCls:"bar-3d-stack"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarStackedPer3d,iconCls:"bar-3d-pstack"},{group:"menu-chart-group-area",type:Asc.c_oAscChartTypeSettings.areaNormal,iconCls:"area-normal"},{group:"menu-chart-group-area",type:Asc.c_oAscChartTypeSettings.areaStacked,iconCls:"area-stack"},{group:"menu-chart-group-area",type:Asc.c_oAscChartTypeSettings.areaStackedPer,iconCls:"area-pstack"},{group:"menu-chart-group-scatter",type:Asc.c_oAscChartTypeSettings.scatter,iconCls:"point-normal"},{group:"menu-chart-group-stock",type:Asc.c_oAscChartTypeSettings.stock,iconCls:"stock-normal"}]},getSparkGroupData:function(t){return[{id:"menu-chart-group-sparkcolumn",inline:!0,headername:t?this.textSparks:void 0},{id:"menu-chart-group-sparkline",inline:!0},{id:"menu-chart-group-sparkwin",inline:!0}]},getSparkData:function(){return[{group:"menu-chart-group-sparkcolumn",type:Asc.c_oAscSparklineType.Column,allowSelected:!0,iconCls:"spark-column",tip:this.textColumnSpark},{group:"menu-chart-group-sparkline",type:Asc.c_oAscSparklineType.Line,allowSelected:!0,iconCls:"spark-line",tip:this.textLineSpark},{group:"menu-chart-group-sparkwin",type:Asc.c_oAscSparklineType.Stacked,allowSelected:!0,iconCls:"spark-win",tip:this.textWinLossSpark}]}}},Common.define.chartData||{})}),define("text!documenteditor/main/app/template/Toolbar.template",[],function(){return'
    \n
    \n
    \n <%= tabsmarkup %>\n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n
    \n \n \n \n \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    '}),define("text!documenteditor/main/app/template/ToolbarView.template",[],function(){return'
    \n
    \n
    \n <%= tabsmarkup %>\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    '}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/Font",["backbone"],function(t){"use strict";Common.Models.Font=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),name:null,cloneid:null,imgidx:0,type:0}}})}),void 0===Common)var Common={};if(Common.Collections=Common.Collections||{},define("common/main/lib/collection/Fonts",["backbone","common/main/lib/model/Font"],function(t){"use strict";Common.Collections.Fonts=t.Collection.extend({model:Common.Models.Font,comparator:function(t,e){var i=t.get("name").toLowerCase(),n=e.get("name").toLowerCase();return i==n?0:i',"<% _.each(colors, function(color, index) { %>",'',"<% }) %>",""].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.id=e.options.id,this.cls=e.options.cls,this.style=e.options.style,this.colors=e.options.colors||[],this.value=e.options.value,e.options.el&&e.render()},render:function(t){var e=this;return e.rendered?this.cmpEl=e.$el||$(this.el):(this.cmpEl=$(this.template({id:this.id,cls:this.cls,style:this.style,colors:this.colors})),t?(this.setElement(t,!1),t.html(this.cmpEl)):e.$el.html(this.cmpEl)),e.rendered||e.cmpEl.on("click","span.color-item",e.itemClick.bind(e)),e.rendered=!0,this},itemClick:function(t){var e=$(t.target);this.select(e.attr("data-color"))},select:function(t,e){if(this.value!=t){var i=this;$("span.color-item",this.cmpEl).removeClass("selected"),this.value=t,t&&/#?[a-fA-F0-9]{6}/.test(t)&&(t=/#?([a-fA-F0-9]{6})/.exec(t)[1].toUpperCase(),$("span[data-color="+t+"]",this.cmpEl).addClass("selected"),e||i.trigger("select",i,this.value))}}})}),void 0===Common)var Common={};if(define("common/main/lib/component/DimensionPicker",["common/main/lib/component/BaseView"],function(){"use strict";Common.UI.DimensionPicker=Common.UI.BaseView.extend(function(){return{options:{itemSize:18,minRows:5,minColumns:5,maxRows:20,maxColumns:20},template:_.template(['
    ','
    0x0
    ','
    ','
    ','
    ','
    ',"
    ","
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.render(),this.cmpEl=e.$el||$(this.el);var i=this.cmpEl;e.itemSize=e.options.itemSize,e.minRows=e.options.minRows,e.minColumns=e.options.minColumns,e.maxRows=e.options.maxRows,e.maxColumns=e.options.maxColumns,e.curColumns=0,e.curRows=0;var n=function(t){e.setTableSize(Math.ceil((void 0===t.offsetX?t.originalEvent.layerX:t.offsetX*Common.Utils.zoom())/e.itemSize),Math.ceil((void 0===t.offsetY?t.originalEvent.layerY:t.offsetY*Common.Utils.zoom())/e.itemSize),t)},o=function(t){e.setTableSize(0,0,t)},s=function(t){e.trigger("select",e,e.curColumns,e.curRows,t)};if(i){var a=i.find(".dimension-picker-mousecatcher");e.areaUnHighLighted=i.find(".dimension-picker-unhighlighted"),e.areaHighLighted=i.find(".dimension-picker-highlighted"),e.areaStatus=i.find(".dimension-picker-status"),i.css({width:e.minColumns+"em"}),a.css("z-index",1),a.width(e.maxColumns+"em").height(e.maxRows+"em"),e.areaUnHighLighted.width(e.minColumns+"em").height(e.minRows+"em"),e.areaStatus.html(e.curColumns+" x "+e.curRows),e.areaStatus.width(e.areaUnHighLighted.width()),a.on("mousemove",n),e.areaHighLighted.on("mousemove",n),e.areaUnHighLighted.on("mousemove",n),a.on("mouseleave",o),e.areaHighLighted.on("mouseleave",o),e.areaUnHighLighted.on("mouseleave",o),a.on("click",s),e.areaHighLighted.on("click",s),e.areaUnHighLighted.on("click",s)}},render:function(){return(this.$el||$(this.el)).html(this.template()),this},setTableSize:function(t,e,i){t>this.maxColumns&&(t=this.maxColumns),e>this.maxRows&&(e=this.maxRows),this.curColumns==t&&this.curRows==e||(this.curColumns=t,this.curRows=e,this.areaHighLighted.width(this.curColumns+"em").height(this.curRows+"em"),this.areaUnHighLighted.width((this.curColumnsthis.maxColumns?this.maxColumns:this.curColumns+1)+"em").height((this.curRowsthis.maxRows?this.maxRows:this.curRows+1)+"em"),this.cmpEl.width(this.areaUnHighLighted.width()),this.areaStatus.html(this.curColumns+" x "+this.curRows),this.areaStatus.width(this.areaUnHighLighted.width()),this.trigger("change",this,this.curColumns,this.curRows,i))},getColumnsCount:function(){return this.curColumns},getRowsCount:function(){return this.curRows}}}())}),void 0===Common)var Common={};if(define("common/main/lib/component/ComboDataView",["common/main/lib/component/BaseView","common/main/lib/component/DataView"],function(){"use strict";Common.UI.ComboDataView=Common.UI.BaseView.extend({options:{id:null,cls:"",style:"",hint:!1,itemWidth:80,itemHeight:40,menuMaxHeight:300,enableKeyEvents:!1,beforeOpenHandler:null,additionalMenuItems:null,showLast:!0,minWidth:-1},template:_.template(['
    ','
    ','
    ',"
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t),this.id=this.options.id||Common.UI.getId(),this.cls=this.options.cls,this.style=this.options.style,this.hint=this.options.hint,this.store=this.options.store||new Common.UI.DataViewStore,this.itemWidth=this.options.itemWidth,this.itemHeight=this.options.itemHeight,this.menuMaxHeight=this.options.menuMaxHeight,this.beforeOpenHandler=this.options.beforeOpenHandler,this.showLast=this.options.showLast,this.rootWidth=0,this.rootHeight=0,this.rendered=!1,this.needFillComboView=!1,this.minWidth=this.options.minWidth,this.fieldPicker=new Common.UI.DataView({cls:"field-picker",allowScrollbar:!1,itemTemplate:_.template(['
    ','','<% if (typeof title !== "undefined") {%>','<%= title %>',"<% } %>","
    "].join(""))}),this.openButton=new Common.UI.Button({cls:"open-menu",menu:new Common.UI.Menu({menuAlign:"tl-tl",offset:[0,3],items:[{template:_.template('')}]})}),null!=this.options.additionalMenuItems&&(this.openButton.menu.items=this.openButton.menu.items.concat(this.options.additionalMenuItems)),this.menuPicker=new Common.UI.DataView({cls:"menu-picker",parentMenu:this.openButton.menu,restoreHeight:this.menuMaxHeight,style:"max-height: "+this.menuMaxHeight+"px;",enableKeyEvents:this.options.enableKeyEvents,store:this.store,itemTemplate:_.template(['
    ','','<% if (typeof title !== "undefined") {%>','<%= title %>',"<% } %>","
    "].join(""))}),setInterval(_.bind(this.checkSize,this),500),this.options.el&&this.render()},render:function(t){if(!this.rendered){var e=this;e.trigger("render:before",e),e.cmpEl=e.$el||$(e.el);var i=e.template({id:e.id,cls:e.cls,style:e.style});t?(e.setElement(t,!1),e.cmpEl=$(i),t.html(e.cmpEl)):e.cmpEl.html(i),e.rootWidth=e.cmpEl.width(),e.rootHeight=e.cmpEl.height(),e.fieldPicker.render($(".view",e.cmpEl)),e.openButton.render($(".button",e.cmpEl)),e.menuPicker.render($(".menu-picker-container",e.cmpEl)),e.openButton.menu.cmpEl&&e.openButton.menu.cmpEl&&(e.openButton.menu.menuAlignEl=e.cmpEl,e.openButton.menu.cmpEl.css("min-width",e.itemWidth),e.openButton.menu.on("show:before",_.bind(e.onBeforeShowMenu,e)),e.openButton.menu.on("show:after",_.bind(e.onAfterShowMenu,e)),e.openButton.cmpEl.on("hide.bs.dropdown",_.bind(e.onBeforeHideMenu,e)),e.openButton.cmpEl.on("hidden.bs.dropdown",_.bind(e.onAfterHideMenu,e))),e.options.hint&&(e.cmpEl.attr("data-toggle","tooltip"),e.cmpEl.tooltip({title:e.options.hint,placement:e.options.hintAnchor||"cursor"})),e.fieldPicker.on("item:select",_.bind(e.onFieldPickerSelect,e)),e.menuPicker.on("item:select",_.bind(e.onMenuPickerSelect,e)),e.fieldPicker.on("item:click",_.bind(e.onFieldPickerClick,e)),e.menuPicker.on("item:click",_.bind(e.onMenuPickerClick,e)),e.fieldPicker.on("item:contextmenu",_.bind(e.onPickerItemContextMenu,e)),e.menuPicker.on("item:contextmenu",_.bind(e.onPickerItemContextMenu,e)),e.fieldPicker.el.addEventListener("contextmenu",_.bind(e.onPickerComboContextMenu,e),!1),e.menuPicker.el.addEventListener("contextmenu",_.bind(e.onPickerComboContextMenu,e),!1),e.onResize(),e.rendered=!0,e.trigger("render:after",e)}return this},checkSize:function(){if(this.cmpEl&&this.cmpEl.is(":visible")){var t=this,e=this.cmpEl.width(),i=this.cmpEl.height();if(e div:not(.grouped-data):not(.ps-scrollbar-x-rail):not(.ps-scrollbar-y-rail)")[0]);a.length>0&&(n.itemMarginLeft=parseInt(a.css("margin-left")),n.itemMarginRight=parseInt(a.css("margin-right")),n.itemPaddingLeft=parseInt(a.css("padding-left")),n.itemPaddingRight=parseInt(a.css("padding-right")),n.itemBorderLeft=parseInt(a.css("border-left-width")),n.itemBorderRight=parseInt(a.css("border-right-width")))}var r=o.indexOf(t);if(r<0)return;var l=o.length,c=Math.floor(Math.max(s.width(),n.minWidth)/(n.itemWidth+(n.itemMarginLeft||0)+(n.itemMarginRight||0)+(n.itemPaddingLeft||0)+(n.itemPaddingRight||0)+(n.itemBorderLeft||0)+(n.itemBorderRight||0))),d=[];s.height()/n.itemHeight>2&&(c*=Math.floor(s.height()/n.itemHeight)),r=Math.floor(r/c)*c,l-r1?t/2:t)},setItemHeight:function(t){this.itemHeight!=t&&(this.itemHeight=window.devicePixelRatio>1?t/2:t)},removeTips:function(){var t=this.menuPicker;_.each(t.dataViewItems,function(t){var e=t.$el.data("bs.tooltip");e&&e.tip().remove()},t)}})}),void 0===Common)var Common={};if(define("common/main/lib/component/SynchronizeTip",["common/main/lib/component/BaseView"],function(){"use strict";Common.UI.SynchronizeTip=Common.UI.BaseView.extend(_.extend(function(){return{options:{target:$(document.body),text:"",placement:"right",showLink:!0},template:_.template(['
    <%= scope.placement %>">','
    ','
    ',"
    ",'
    <%= scope.text %>
    ','
    ',"
    ","<% if ( scope.showLink ) { %>",'',"<% } %>","
    ","
    "].join("")),initialize:function(t){this.textSynchronize+=Common.Utils.String.platformKey("Ctrl+S"),Common.UI.BaseView.prototype.initialize.call(this,t),this.target=this.options.target,this.text=_.isEmpty(this.options.text)?this.textSynchronize:this.options.text,this.textLink=_.isEmpty(this.options.textLink)?this.textDontShow:this.options.textLink,this.placement=this.options.placement,this.showLink=this.options.showLink},render:function(){return this.cmpEl||(this.cmpEl=$(this.template({scope:this})),$(document.body).append(this.cmpEl),this.cmpEl.find(".close").on("click",_.bind(function(){this.trigger("closeclick")},this)),this.cmpEl.find(".show-link label").on("click",_.bind(function(){this.trigger("dontshowclick")},this))),this.applyPlacement(),this},show:function(){this.cmpEl?(this.applyPlacement(),this.cmpEl.show()):this.render()},hide:function(){this.cmpEl&&this.cmpEl.hide()},close:function(){this.cmpEl&&this.cmpEl.remove()},applyPlacement:function(){var t=this.target.offset(),e=Common.Utils.innerHeight();if("document"==this.placement);else if("top"==this.placement)this.cmpEl.css({bottom:e-t.top+"px",right:Common.Utils.innerWidth()-t.left-this.target.width()/2+"px"});else if("target"==this.placement)this.cmpEl.css({top:t.top+5+"px",left:t.left+5+"px"});else{var i=t.top+this.target.height()/2,n=this.cmpEl.height();i+n>e&&(i=e-n),"left"==this.placement?this.cmpEl.css({top:i+"px",right:Common.Utils.innerWidth()-t.left-5+"px"}):this.cmpEl.css({top:i+"px",left:t.left+this.target.width()+"px"})}},isVisible:function(){return this.cmpEl&&this.cmpEl.is(":visible")},textDontShow:"Don't show this message again",textSynchronize:"The document has been changed by another user.
    Please click to save your changes and reload the updates."}}(),Common.UI.SynchronizeTip||{}))}),define("common/main/lib/component/Mixtbar",["backbone","common/main/lib/component/BaseView"],function(t){"use strict";Common.UI.Mixtbar=Common.UI.BaseView.extend(function(){function t(t){var e=$(t.currentTarget).find("> a[data-tab]").data("tab");this.dblclick_el==e&&(this.fireEvent("change:compact",[e]),this.dblclick_el=void 0)}function e(t){this.isFolded&&($(t.target).parents(".toolbar, #file-menu-panel").length||o.$bar&&o.$bar.hasClass("expanded")&&this.collapse())}var i,n,o={timeout:2e3},s={},a=function(t,e){var n=i.scrollLeft();(n||"right"==t)&&i.animate({scrollLeft:"left"==t?n-100:n+100},200)};return{$tabs:void 0,$panels:void 0,isFolded:!1,initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);this.$layout=$(t.template({tabsmarkup:_.template('
      <% for(var i in items) { %><% if (typeof items[i] == "object") { %>
    • <% if (items[i].extcls) print(\' \' + items[i].extcls) %>"><%= items[i].caption %>
    • <% } %><% } %>
    ')({items:t.tabs})})),s.tabs=t.tabs,$(document.body).on("click",e.bind(this)),Common.NotificationCenter.on("tab:visible",_.bind(function(t,e){this.setVisible(t,e)},this))},afterRender:function(){var e=this;i=e.$(".tabs > ul"),e.$tabs=i.find("> li"),e.$panels=e.$(".box-panels > .panel"),o.$bar=e.$(".toolbar");var s=e.$(".tabs .scroll.right");n=e.$(".tabs .scroll.left"),n.on("click",a.bind(this,"left")),s.on("click",a.bind(this,"right")),i.on("dblclick","> .ribtab",t.bind(this)),i.on("click","> .ribtab",e.onTabClick.bind(this))},isTabActive:function(t){var e=this.$tabs.filter(".active").find("> a");return e.length&&e.data("tab")==t},setFolded:function(t){this.isFolded=t;var e=this;if(this.isFolded)o.$box||(o.$box=e.$el.find(".box-controls")),o.$bar.addClass("folded z-clear").toggleClass("expanded",!1),o.$bar.find(".tabs .ribtab").removeClass("active"),o.$bar.on($.support.transition.end,function(t){o.$bar.hasClass("folded")&&!o.$bar.hasClass("expanded")&&o.$bar.toggleClass("z-clear",!0)}),o.$box.on({mouseleave:function(t){},mouseenter:function(t){}});else{o.$bar.removeClass("folded z-clear"),o.$box.off();var i=o.$box.find(".panel.active");if(i.length){var n=i.data("tab");e.$tabs.find("> a[data-tab="+n+"]").parent().toggleClass("active",!0)}else n=e.$tabs.siblings(":not(.x-lone):visible").first().find("> a[data-tab]").data("tab"),e.setTab(n)}},collapse:function(){Common.UI.Menu.Manager.hideAll(),this.isFolded&&o.$bar&&(o.$bar.removeClass("expanded"),o.$bar.find(".tabs .ribtab").removeClass("active"))},expand:function(){o.$bar.removeClass("z-clear"),o.$bar.addClass("expanded")},onResize:function(t){this.hasTabInvisible()?i.parent().hasClass("short")||i.parent().addClass("short"):i.parent().hasClass("short")&&i.parent().removeClass("short"),this.processPanelVisible()},onTabClick:function(t){var e=this,i=$(t.currentTarget),n=i.find("> a[data-tab]").data("tab");i.hasClass("x-lone")?e.isFolded&&e.collapse():i.hasClass("active")?e._timerSetTab||(e.dblclick_el=n,e.isFolded&&(e.collapse(),setTimeout(function(){e.dblclick_el=void 0},500))):(e._timerSetTab=!0,setTimeout(function(){e._timerSetTab=!1},500),e.setTab(n),e.processPanelVisible(null,!0),e.isFolded?e.dblclick_el=n:(e.dblclick_timer&&clearTimeout(e.dblclick_timer),e.dblclick_timer=setTimeout(function(){e.dblclick_el=n,delete e.dblclick_timer},500)))},setTab:function(t){var e=this;if(t||(this.isFolded?this.collapse():t=this.lastPanel),t){e.$tabs.removeClass("active"),e.$panels.removeClass("active");var i=this.$panels.filter("[data-tab="+t+"]");i.length&&(this.lastPanel=t,i.addClass("active")),i.length?e.isFolded&&e.expand():e.isFolded&&e.collapse();var n=this.$tabs.find("> a[data-tab="+t+"]").parent();n.length&&n.addClass("active"),this.fireEvent("tab:active",[t])}},addTab:function(t,e,n){function o(t){return s.tabs[t]?s.tabs[t].action:o(--t)}var a=_.template('');s.tabs[n+1]=t;var r=o(n),l=this.$tabs||this.$layout.find(".tabs"),c=l.find("a[data-tab="+r+"]");c.length&&(c.parent().after(a(t)),e&&(l=this.$panels||this.$layout.find(".box-panels > .panel"),c=l.filter("[data-tab="+r+"]"),c.length?c.after(e):e.appendTo(this.$layout.find(".box-panels"))),this.$tabs&&(this.$tabs=i.find("> li")),this.$panels&&(this.$panels=this.$el.find(".box-panels > .panel")))},isCompact:function(){return this.isFolded},hasTabInvisible:function(){if(i.length<1)return!1;var t=Math.round(i.offset().left),e=Math.round(t+i.width()),n=this.$tabs.filter(":visible:first").get(0);if(!n)return!1;var o=n.getBoundingClientRect();return Math.round(o.left)e)},processPanelVisible:function(t,e){function i(){var e=t||n.$panels.filter(".active");if(e&&e.length){var i=e.parents(".box-controls").width(),o=e.data(),s=o.rightedge,a=o.buttons,r=o.flex;if(s||(s=e.get(0).getBoundingClientRect().right),a||(a=[],_.each(e.find(".btn-slot .x-huge"),function(t){a.push($(t).closest(".btn-slot"))}),o.buttons=a),r||(r=[],_.each(e.find(".group.flex"),function(t){var e=$(t);r.push({el:e,width:e.attr("data-group-width")||e.attr("max-width")})}),o.flex=r),s>i){if(r.length>0)for(var l=0;lparseInt(c.css("min-width")))return;c.css("width",c.css("min-width"))}for(var l=a.length-1;l>=0;l--){var d=a[l];if(!d.hasClass("compactwidth")&&(d.addClass("compactwidth"),(s=e.get(0).getBoundingClientRect().right)<=i))break}o.rightedge=s}else{for(var l=0;li)){d.addClass("compactwidth"),s=e.get(0).getBoundingClientRect().right;break}}if(o.rightedge=s,r.length>0&&e.find(".btn-slot.compactwidth").length<1)for(var l=0;l a[data-tab="+t+"]").parent().css("display",e?"":"none"),this.onResize())}}}())}),define("documenteditor/main/app/view/Toolbar",["jquery","underscore","backbone","text!documenteditor/main/app/template/Toolbar.template","text!documenteditor/main/app/template/ToolbarView.template","common/main/lib/collection/Fonts","common/main/lib/component/Button","common/main/lib/component/ComboBox","common/main/lib/component/DataView","common/main/lib/component/ColorPalette","common/main/lib/component/ThemeColorPalette","common/main/lib/component/Menu","common/main/lib/component/DimensionPicker","common/main/lib/component/Window","common/main/lib/component/ComboBoxFonts","common/main/lib/component/ComboDataView","common/main/lib/component/SynchronizeTip","common/main/lib/component/Mixtbar"],function(t,e,i,n,o){"use strict";DE.Views.Toolbar=Common.UI.Mixtbar.extend(e.extend(function(){return{el:"#toolbar",events:{},initialize:function(){var t=this;return this.SchemeNames=[this.txtScheme1,this.txtScheme2,this.txtScheme3,this.txtScheme4,this.txtScheme5,this.txtScheme6,this.txtScheme7,this.txtScheme8,this.txtScheme9,this.txtScheme10,this.txtScheme11,this.txtScheme12,this.txtScheme13,this.txtScheme14,this.txtScheme15,this.txtScheme16,this.txtScheme17,this.txtScheme18,this.txtScheme19,this.txtScheme20,this.txtScheme21],this.paragraphControls=[],this.toolbarControls=[],this.textOnlyControls=[],this._state={hasCollaborativeChanges:void 0,previewmode:!1},Common.NotificationCenter.on("app:ready",t.onAppReady.bind(this)),this},applyLayout:function(i){var s=this;if(i.isEdit){Common.UI.Mixtbar.prototype.initialize.call(this,{template:e.template(n),tabs:[{caption:s.textTabFile,action:"file",extcls:"canedit",haspanel:!1},{caption:s.textTabHome,action:"home",extcls:"canedit"},{caption:s.textTabInsert,action:"ins",extcls:"canedit"},{caption:s.textTabLayout,action:"layout",extcls:"canedit"},{caption:s.textTabLinks,action:"links",extcls:"canedit"}]}),this.btnSaveCls="btn-save",this.btnSaveTip=this.tipSave+Common.Utils.String.platformKey("Ctrl+S"),this.btnPrint=new Common.UI.Button({id:"id-toolbar-btn-print",cls:"btn-toolbar",iconCls:"toolbar__icon btn-print no-mask",signals:["disabled"]}),this.toolbarControls.push(this.btnPrint),this.btnSave=new Common.UI.Button({id:"id-toolbar-btn-save",cls:"btn-toolbar",iconCls:"toolbar__icon no-mask "+this.btnSaveCls,signals:["disabled"]}),this.toolbarControls.push(this.btnSave),this.btnCollabChanges=this.btnSave,this.btnUndo=new Common.UI.Button({id:"id-toolbar-btn-undo",cls:"btn-toolbar",iconCls:"toolbar__icon btn-undo",signals:["disabled"]}),this.toolbarControls.push(this.btnUndo),this.btnRedo=new Common.UI.Button({id:"id-toolbar-btn-redo",cls:"btn-toolbar",iconCls:"toolbar__icon btn-redo",signals:["disabled"]}),this.toolbarControls.push(this.btnRedo),this.btnCopy=new Common.UI.Button({id:"id-toolbar-btn-copy",cls:"btn-toolbar",iconCls:"toolbar__icon btn-copy"}),this.toolbarControls.push(this.btnCopy),this.btnPaste=new Common.UI.Button({id:"id-toolbar-btn-paste",cls:"btn-toolbar",iconCls:"toolbar__icon btn-paste"}),this.paragraphControls.push(this.btnPaste),this.btnIncFontSize=new Common.UI.Button({id:"id-toolbar-btn-incfont",cls:"btn-toolbar",iconCls:"toolbar__icon btn-incfont"}),this.paragraphControls.push(this.btnIncFontSize),this.btnDecFontSize=new Common.UI.Button({id:"id-toolbar-btn-decfont",cls:"btn-toolbar",iconCls:"toolbar__icon btn-decfont"}),this.paragraphControls.push(this.btnDecFontSize),this.btnBold=new Common.UI.Button({id:"id-toolbar-btn-bold",cls:"btn-toolbar",iconCls:"toolbar__icon btn-bold",enableToggle:!0}),this.paragraphControls.push(this.btnBold),this.btnItalic=new Common.UI.Button({id:"id-toolbar-btn-italic",cls:"btn-toolbar",iconCls:"toolbar__icon btn-italic",enableToggle:!0}),this.paragraphControls.push(this.btnItalic),this.btnUnderline=new Common.UI.Button({id:"id-toolbar-btn-underline",cls:"btn-toolbar",iconCls:"toolbar__icon btn-underline",enableToggle:!0}),this.paragraphControls.push(this.btnUnderline),this.btnStrikeout=new Common.UI.Button({id:"id-toolbar-btn-strikeout",cls:"btn-toolbar",iconCls:"toolbar__icon btn-strikeout",enableToggle:!0}),this.paragraphControls.push(this.btnStrikeout),this.btnSuperscript=new Common.UI.Button({id:"id-toolbar-btn-superscript",cls:"btn-toolbar",iconCls:"toolbar__icon btn-superscript",enableToggle:!0,toggleGroup:"superscriptGroup"}),this.paragraphControls.push(this.btnSuperscript),this.btnSubscript=new Common.UI.Button({id:"id-toolbar-btn-subscript",cls:"btn-toolbar",iconCls:"toolbar__icon btn-subscript",enableToggle:!0,toggleGroup:"superscriptGroup"}),this.paragraphControls.push(this.btnSubscript),this.btnHighlightColor=new Common.UI.Button({id:"id-toolbar-btn-highlight",cls:"btn-toolbar",iconCls:"toolbar__icon btn-highlight",enableToggle:!0,allowDepress:!0,split:!0,menu:new Common.UI.Menu({style:"min-width: 100px;",items:[{template:e.template('
    ')},{caption:"--"},this.mnuHighlightTransparent=new Common.UI.MenuItem({caption:this.strMenuNoFill,checkable:!0})]})}),this.paragraphControls.push(this.btnHighlightColor),this.textOnlyControls.push(this.btnHighlightColor),this.btnFontColor=new Common.UI.Button({id:"id-toolbar-btn-fontcolor",cls:"btn-toolbar",iconCls:"toolbar__icon btn-fontcolor",split:!0,menu:new Common.UI.Menu({cls:"shifted-left",items:[{id:"id-toolbar-menu-auto-fontcolor",caption:this.textAutoColor,template:e.template('<%= caption %>')},{caption:"--"},{template:e.template('
    ')},{template:e.template(''+this.textNewColor+"")}]})}),this.paragraphControls.push(this.btnFontColor),this.btnParagraphColor=new Common.UI.Button({id:"id-toolbar-btn-paracolor",cls:"btn-toolbar",iconCls:"toolbar__icon btn-paracolor",split:!0,menu:new Common.UI.Menu({items:[{template:e.template('
    ')},{template:e.template(''+this.textNewColor+"")}]})}),this.paragraphControls.push(this.btnParagraphColor),this.textOnlyControls.push(this.btnParagraphColor),this.btnAlignLeft=new Common.UI.Button({id:"id-toolbar-btn-align-left",cls:"btn-toolbar",iconCls:"toolbar__icon btn-align-left",enableToggle:!0,allowDepress:!1,toggleGroup:"alignGroup"}),this.paragraphControls.push(this.btnAlignLeft),this.btnAlignCenter=new Common.UI.Button({id:"id-toolbar-btn-align-center",cls:"btn-toolbar",iconCls:"toolbar__icon btn-align-center",enableToggle:!0,allowDepress:!1,toggleGroup:"alignGroup"}),this.paragraphControls.push(this.btnAlignCenter),this.btnAlignRight=new Common.UI.Button({id:"id-toolbar-btn-align-right",cls:"btn-toolbar",iconCls:"toolbar__icon btn-align-right",enableToggle:!0,allowDepress:!1,toggleGroup:"alignGroup"}),this.paragraphControls.push(this.btnAlignRight),this.btnAlignJust=new Common.UI.Button({id:"id-toolbar-btn-align-just",cls:"btn-toolbar",iconCls:"toolbar__icon btn-align-just",enableToggle:!0,allowDepress:!1,toggleGroup:"alignGroup"}),this.paragraphControls.push(this.btnAlignJust),this.btnDecLeftOffset=new Common.UI.Button({id:"id-toolbar-btn-decoffset",cls:"btn-toolbar",iconCls:"toolbar__icon btn-decoffset"}),this.paragraphControls.push(this.btnDecLeftOffset),this.btnIncLeftOffset=new Common.UI.Button({id:"id-toolbar-btn-incoffset",cls:"btn-toolbar",iconCls:"toolbar__icon btn-incoffset"}),this.paragraphControls.push(this.btnIncLeftOffset),this.btnLineSpace=new Common.UI.Button({id:"id-toolbar-btn-linespace",cls:"btn-toolbar",iconCls:"toolbar__icon btn-linespace",menu:new Common.UI.Menu({style:"min-width: 60px;",items:[{caption:"1.0",value:1,checkable:!0,toggleGroup:"linesize"},{caption:"1.15",value:1.15,checkable:!0,toggleGroup:"linesize"},{caption:"1.5",value:1.5,checkable:!0,toggleGroup:"linesize"},{caption:"2.0",value:2,checkable:!0,toggleGroup:"linesize"},{caption:"2.5",value:2.5,checkable:!0,toggleGroup:"linesize"},{caption:"3.0",value:3,checkable:!0,toggleGroup:"linesize"}]})}),this.paragraphControls.push(this.btnLineSpace),this.btnShowHidenChars=new Common.UI.Button({id:"id-toolbar-btn-hidenchars",cls:"btn-toolbar",iconCls:"toolbar__icon btn-paragraph",enableToggle:!0,split:!0,menu:new Common.UI.Menu({style:"min-width: 60px;",items:[{caption:this.mniHiddenChars,value:"characters",checkable:!0},{caption:this.mniHiddenBorders,value:"table",checkable:!0}]})}),this.toolbarControls.push(this.btnShowHidenChars),this.btnMarkers=new Common.UI.Button({id:"id-toolbar-btn-markers",cls:"btn-toolbar",iconCls:"toolbar__icon btn-setmarkers",enableToggle:!0,toggleGroup:"markersGroup",split:!0,menu:!0}),this.paragraphControls.push(this.btnMarkers),this.textOnlyControls.push(this.btnMarkers),this.btnNumbers=new Common.UI.Button({id:"id-toolbar-btn-numbering",cls:"btn-toolbar",iconCls:"toolbar__icon btn-numbering",enableToggle:!0,toggleGroup:"markersGroup",split:!0,menu:!0}),this.paragraphControls.push(this.btnNumbers),this.textOnlyControls.push(this.btnNumbers),this.btnMultilevels=new Common.UI.Button({id:"id-toolbar-btn-multilevels",cls:"btn-toolbar",iconCls:"toolbar__icon btn-multilevels",menu:!0}),this.paragraphControls.push(this.btnMultilevels),this.textOnlyControls.push(this.btnMultilevels);var a=function(t){var e={};for(var i in t)e[i]="object"==typeof t[i]?a(t[i]):t[i];return e};this.mnuMarkersPicker={conf:{index:0},selectByIndex:function(t){this.conf.index=t},deselectAll:function(){this.conf.index=-1}},this.mnuNumbersPicker=a(this.mnuMarkersPicker),this.mnuMultilevelPicker=a(this.mnuMarkersPicker),this.btnInsertTable=new Common.UI.Button({id:"tlbtn-inserttable",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-inserttable",caption:s.capBtnInsTable,menu:new Common.UI.Menu({items:[{template:e.template('
    ')},{caption:this.mniCustomTable,value:"custom"},{caption:this.mniDrawTable,value:"draw",checkable:!0},{caption:this.mniEraseTable,value:"erase",checkable:!0}]})}),this.paragraphControls.push(this.btnInsertTable),this.btnInsertImage=new Common.UI.Button({id:"tlbtn-insertimage",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-insertimage",caption:s.capBtnInsImage,menu:new Common.UI.Menu({items:[{caption:this.mniImageFromFile,value:"file"},{caption:this.mniImageFromUrl,value:"url"},{caption:this.mniImageFromStorage,value:"storage"}]})}),this.paragraphControls.push(this.btnInsertImage),this.btnInsertChart=new Common.UI.Button({id:"tlbtn-insertchart",cls:"btn-toolbar x-huge icon-top",caption:s.capBtnInsChart,iconCls:"toolbar__icon btn-insertchart",menu:!0}),this.paragraphControls.push(this.btnInsertChart),this.btnInsertText=new Common.UI.Button({id:"tlbtn-inserttext",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-text",caption:s.capBtnInsTextbox,enableToggle:!0}),this.paragraphControls.push(this.btnInsertText),this.btnInsertTextArt=new Common.UI.Button({id:"tlbtn-inserttextart",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-textart",caption:s.capBtnInsTextart,menu:new Common.UI.Menu({cls:"menu-shapes",items:[{template:e.template('
    ')}]})}),this.paragraphControls.push(this.btnInsertTextArt),this.btnEditHeader=new Common.UI.Button({id:"id-toolbar-btn-editheader",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-editheader",caption:s.capBtnInsHeader,menu:!0}),this.mnuPageNumberPosPicker={conf:{disabled:!1},isDisabled:function(){return this.conf.disabled},setDisabled:function(t){this.conf.disabled=t}},this.mnuPageNumCurrentPos=a(this.mnuPageNumberPosPicker),this.mnuInsertPageNum=a(this.mnuPageNumberPosPicker),this.mnuInsertPageCount=a(this.mnuPageNumberPosPicker),this.paragraphControls.push(this.mnuPageNumCurrentPos),this.paragraphControls.push(this.mnuInsertPageCount),this.toolbarControls.push(this.btnEditHeader),this.btnInsDateTime=new Common.UI.Button({id:"id-toolbar-btn-datetime",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-datetime",caption:s.capBtnDateTime}),this.paragraphControls.push(this.btnInsDateTime),this.btnBlankPage=new Common.UI.Button({id:"id-toolbar-btn-blankpage",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-blankpage",caption:s.capBtnBlankPage}),this.paragraphControls.push(this.btnBlankPage),this.btnInsertShape=new Common.UI.Button({id:"tlbtn-insertshape",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-insertshape",caption:s.capBtnInsShape,enableToggle:!0,menu:new Common.UI.Menu({cls:"menu-shapes"})}),this.paragraphControls.push(this.btnInsertShape),this.btnInsertEquation=new Common.UI.Button({id:"tlbtn-insertequation",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-insertequation",caption:s.capBtnInsEquation,split:!0,menu:new Common.UI.Menu({cls:"menu-shapes"})}),this.paragraphControls.push(this.btnInsertEquation),this.btnInsertSymbol=new Common.UI.Button({id:"tlbtn-insertsymbol",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-symbol",caption:s.capBtnInsSymbol}),this.paragraphControls.push(this.btnInsertSymbol),this.btnDropCap=new Common.UI.Button({id:"tlbtn-dropcap",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-dropcap",caption:s.capBtnInsDropcap,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",items:[{caption:this.textNone,iconCls:"menu__icon columns-one",checkable:!0,checkmark:!1,toggleGroup:"menuDropCap",value:Asc.c_oAscDropCap.None,checked:!0},{caption:this.textInText,iconCls:"menu__icon dropcap-intext",checkable:!0,checkmark:!1,toggleGroup:"menuDropCap",value:Asc.c_oAscDropCap.Drop},{caption:this.textInMargin,iconCls:"menu__icon dropcap-inmargin",checkable:!0,checkmark:!1,toggleGroup:"menuDropCap",value:Asc.c_oAscDropCap.Margin},{caption:"--"},this.mnuDropCapAdvanced=new Common.UI.MenuItem({caption:this.mniEditDropCap})]})}),this.paragraphControls.push(this.btnDropCap),this.btnContentControls=new Common.UI.Button({id:"tlbtn-controls",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-controls",caption:s.capBtnInsControls,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",items:[{caption:this.textPlainControl,iconCls:"menu__icon cc-plaintext",value:"plain"},{caption:this.textRichControl,iconCls:"menu__icon cc-richtext",value:"rich"},{caption:this.textPictureControl,value:"picture"},{caption:this.textComboboxControl,value:"combobox"},{caption:this.textDropdownControl,value:"dropdown"},{caption:this.textDateControl,value:"date"},{caption:this.textCheckboxControl,value:"checkbox"},{caption:"--"},{caption:this.textRemoveControl,iconCls:"menu__icon cc-remove",value:"remove"},{caption:"--"},{caption:this.mniEditControls,value:"settings"},{caption:this.mniHighlightControls,value:"highlight",menu:new Common.UI.Menu({menuAlign:"tl-tr",items:[this.mnuNoControlsColor=new Common.UI.MenuItem({id:"id-toolbar-menu-no-highlight-controls",caption:this.textNoHighlight,checkable:!0}),{caption:"--"},{template:e.template('
    ')},{template:e.template(''+this.textNewColor+"")}]})}]})}),this.btnColumns=new Common.UI.Button({id:"tlbtn-columns",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-columns",caption:s.capBtnColumns,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",items:[{caption:this.textColumnsOne,iconCls:"menu__icon columns-one",checkable:!0,checkmark:!1,toggleGroup:"menuColumns",value:0},{caption:this.textColumnsTwo,iconCls:"menu__icon columns-two",checkable:!0,checkmark:!1,toggleGroup:"menuColumns",value:1},{caption:this.textColumnsThree,iconCls:"menu__icon columns-three",checkable:!0,checkmark:!1,toggleGroup:"menuColumns",value:2},{caption:this.textColumnsLeft,iconCls:"menu__icon columns-left",checkmark:!1,checkable:!0,toggleGroup:"menuColumns",value:3},{caption:this.textColumnsRight,iconCls:"menu__icon columns-right",checkmark:!1,checkable:!0,toggleGroup:"menuColumns",value:4},{caption:"--"},{caption:this.textColumnsCustom,value:"advanced"}]})}),this.paragraphControls.push(this.btnColumns),this.btnPageOrient=new Common.UI.Button({id:"tlbtn-pageorient",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-pageorient",caption:s.capBtnPageOrient,menu:new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:this.textPortrait,iconCls:"menu__icon page-portrait",checkable:!0,checkmark:!1,toggleGroup:"menuOrient",value:!0},{caption:this.textLandscape,iconCls:"menu__icon page-landscape",checkable:!0,checkmark:!1,toggleGroup:"menuOrient",value:!1}]})}),this.toolbarControls.push(this.btnPageOrient);var r=e.template('
    <%= caption %>
    <% if (options.value !== null) { %>
    <% } %>
    ");this.btnPageMargins=new Common.UI.Button({id:"tlbtn-pagemargins",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-pagemargins",caption:s.capBtnMargins,menu:new Common.UI.Menu({items:[{caption:this.textMarginsLast,checkable:!0,template:r,toggleGroup:"menuPageMargins"},{caption:this.textMarginsNormal,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[20,30,20,15]},{caption:this.textMarginsUsNormal,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[25.4,25.4,25.4,25.4]},{caption:this.textMarginsNarrow,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[12.7,12.7,12.7,12.7]},{caption:this.textMarginsModerate,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[25.4,19.1,25.4,19.1]},{caption:this.textMarginsWide,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[25.4,50.8,25.4,50.8]},{caption:"--"},{caption:this.textPageMarginsCustom,value:"advanced"}]})}),this.toolbarControls.push(this.btnPageMargins);var l=e.template('
    <%= caption %>
    <%= parseFloat(Common.Utils.Metric.fnRecalcFromMM(options.value[0]).toFixed(2)) %> <%= Common.Utils.Metric.getCurrentMetricName() %> x <%= parseFloat(Common.Utils.Metric.fnRecalcFromMM(options.value[1]).toFixed(2)) %> <%= Common.Utils.Metric.getCurrentMetricName() %>
    ');this.btnPageSize=new Common.UI.Button({id:"tlbtn-pagesize",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-pagesize",caption:s.capBtnPageSize,menu:new Common.UI.Menu({restoreHeight:!0,items:[{caption:"US Letter",subtitle:"21,59cm x 27,94cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[215.9,279.4]},{caption:"US Legal",subtitle:"21,59cm x 35,56cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[215.9,355.6]},{caption:"A4",subtitle:"21cm x 29,7cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[210,297],checked:!0},{caption:"A5",subtitle:"14,81cm x 20,99cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[148,210]},{ -caption:"B5",subtitle:"17,6cm x 25,01cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[176,250]},{caption:"Envelope #10",subtitle:"10,48cm x 24,13cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[104.8,241.3]},{caption:"Envelope DL",subtitle:"11,01cm x 22,01cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[110,220]},{caption:"Tabloid",subtitle:"27,94cm x 43,17cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[279.4,431.8]},{caption:"A3",subtitle:"29,7cm x 42,01cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[297,420]},{caption:"Tabloid Oversize",subtitle:"30,48cm x 45,71cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[304.8,457.1]},{caption:"ROC 16K",subtitle:"19,68cm x 27,3cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[196.8,273]},{caption:"Envelope Choukei 3",subtitle:"11,99cm x 23,49cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[119.9,234.9]},{caption:"Super B/A3",subtitle:"33,02cm x 48,25cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[330.2,482.5]},{caption:"--"},{caption:this.textPageSizeCustom,value:"advanced"}]})}),this.toolbarControls.push(this.btnPageSize),this.btnLineNumbers=new Common.UI.Button({id:"tlbtn-line-numbers",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-line-numbering",caption:s.capBtnLineNumbers,menu:new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:this.textNone,checkable:!0,toggleGroup:"menuLineNumbers",value:0},{caption:this.textContinuous,checkable:!0,toggleGroup:"menuLineNumbers",value:1},{caption:this.textRestartEachPage,checkable:!0,toggleGroup:"menuLineNumbers",value:2},{caption:this.textRestartEachSection,checkable:!0,toggleGroup:"menuLineNumbers",value:3},{caption:this.textSuppressForCurrentParagraph,checkable:!0,allowDepress:!0,value:4},{caption:"--"},{caption:this.textCustomLineNumbers,value:5}]})}),this.btnClearStyle=new Common.UI.Button({id:"id-toolbar-btn-clearstyle",cls:"btn-toolbar",iconCls:"toolbar__icon btn-clearstyle"}),this.toolbarControls.push(this.btnClearStyle),this.btnCopyStyle=new Common.UI.Button({id:"id-toolbar-btn-copystyle",cls:"btn-toolbar",iconCls:"toolbar__icon btn-copystyle",enableToggle:!0}),this.toolbarControls.push(this.btnCopyStyle),this.btnColorSchemas=new Common.UI.Button({id:"id-toolbar-btn-colorschemas",cls:"btn-toolbar",iconCls:"toolbar__icon btn-colorschemas",menu:new Common.UI.Menu({cls:"shifted-left",items:[],restoreHeight:!0})}),this.toolbarControls.push(this.btnColorSchemas),this.btnMailRecepients=new Common.UI.Button({id:"id-toolbar-btn-mailrecepients",cls:"btn-toolbar",iconCls:"toolbar__icon btn-mailmerge"}),s.btnImgAlign=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-align",caption:s.capImgAlign,menu:!0}),s.btnImgGroup=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-group",caption:s.capImgGroup,menu:!0}),s.btnImgForward=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-frwd",caption:s.capImgForward,split:!0,menu:!0}),s.btnImgBackward=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-bkwd",caption:s.capImgBackward,split:!0,menu:!0}),s.btnImgWrapping=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-wrap",caption:s.capImgWrapping,menu:!0}),s.btnWatermark=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-watermark",caption:s.capBtnWatermark,menu:new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:this.textEditWatermark,value:"edit"},{caption:this.textRemWatermark,value:"remove"}]})}),s.toolbarControls.push(s.btnImgAlign,s.btnImgGroup,s.btnImgForward,s.btnImgBackward,s.btnImgWrapping,s.btnWatermark),this.mnuLineSpace=this.btnLineSpace.menu,this.mnuNonPrinting=this.btnShowHidenChars.menu,this.mnuInsertTable=this.btnInsertTable.menu,this.mnuInsertImage=this.btnInsertImage.menu,this.mnuPageSize=this.btnPageSize.menu,this.mnuColorSchema=this.btnColorSchemas.menu,this.cmbFontSize=new Common.UI.ComboBox({cls:"input-group-nr",menuStyle:"min-width: 55px;",hint:this.tipFontSize,data:[{value:8,displayValue:"8"},{value:9,displayValue:"9"},{value:10,displayValue:"10"},{value:11,displayValue:"11"},{value:12,displayValue:"12"},{value:14,displayValue:"14"},{value:16,displayValue:"16"},{value:18,displayValue:"18"},{value:20,displayValue:"20"},{value:22,displayValue:"22"},{value:24,displayValue:"24"},{value:26,displayValue:"26"},{value:28,displayValue:"28"},{value:36,displayValue:"36"},{value:48,displayValue:"48"},{value:72,displayValue:"72"},{value:96,displayValue:"96"}]}),this.paragraphControls.push(this.cmbFontSize),this.cmbFontName=new Common.UI.ComboBoxFonts({cls:"input-group-nr",menuCls:"scrollable-menu",menuStyle:"min-width: 325px;",hint:this.tipFontName,store:new Common.Collections.Fonts}),this.paragraphControls.push(this.cmbFontName),this.listStylesAdditionalMenuItem=new Common.UI.MenuItem({template:e.template('
    ")}),this.listStyles=new Common.UI.ComboDataView({cls:"combo-styles",itemWidth:104,itemHeight:38,enableKeyEvents:!0,additionalMenuItems:[this.listStylesAdditionalMenuItem],beforeOpenHandler:function(e){var i=this,n=i.openButton.menu;if(n.cmpEl){var o=t(i.cmpEl.find(".dataview.inner .style").get(0)).parent(),s=o.is(":visible")?parseInt(o.css("width")):i.itemWidth+parseInt(o.css("padding-left"))+parseInt(o.css("padding-right"))+parseInt(o.css("border-left-width"))+parseInt(o.css("border-right-width")),a=i.menuPicker.store.length>=6?6:i.menuPicker.store.length,r=Math.min(i.menuPicker.store.length,Math.round(t(".dataview",t(i.fieldPicker.el)).width()/(-1+s)+.5));r=r','
    ',""].join("")),this.listStyles.menuPicker.itemTemplate=e.template(['
    ','
    ',"
    "].join("")),this.paragraphControls.push(this.listStyles),this.textOnlyControls.push(this.listStyles),e.each(this.toolbarControls.concat(this.paragraphControls),function(t){e.isFunction(t.setDisabled)&&t.setDisabled(!0)}),this.btnMailRecepients.setDisabled(!0);var c=new Common.UI.MenuItem({caption:s.textStyleMenuUpdate}).on("click",e.bind(s.onStyleMenuUpdate,s)),d=new Common.UI.MenuItem({caption:s.textStyleMenuDelete}).on("click",e.bind(s.onStyleMenuDelete,s)),h=new Common.UI.MenuItem({caption:s.textStyleMenuRestore}).on("click",e.bind(s.onStyleMenuDelete,s)),p=new Common.UI.MenuItem({caption:s.textStyleMenuRestoreAll}).on("click",e.bind(s.onStyleMenuRestoreAll,s)),m=new Common.UI.MenuItem({caption:s.textStyleMenuDeleteAll}).on("click",e.bind(s.onStyleMenuDeleteAll,s));null==this.styleMenu&&(this.styleMenu=new Common.UI.Menu({items:[c,d,h,p,m]})),this.on("render:after",e.bind(this.onToolbarAfterRender,this))}else Common.UI.Mixtbar.prototype.initialize.call(this,{template:e.template(o),tabs:[{caption:s.textTabFile,action:"file",haspanel:!1}]});return this},render:function(e){var i=this;if(this.fireEvent("render:before",[this]),i.isCompactView=e.isCompactView,e.isEdit?i.$el.html(i.rendererComponents(i.$layout)):(i.$layout.find(".canedit").hide(),i.$layout.addClass("folded"),i.$el.html(i.$layout)),this.fireEvent("render:after",[this]),Common.UI.Mixtbar.prototype.afterRender.call(this),Common.NotificationCenter.on({"window:resize":function(){Common.UI.Mixtbar.prototype.onResize.apply(i,arguments)}}),e.isEdit){this.showSynchTip=!Common.localStorage.getBool("de-hide-synch"),this.needShowSynchTip=!1,i.setTab("home");var n=Common.localStorage.getItem("de-pgmargins-top"),o=Common.localStorage.getItem("de-pgmargins-left"),s=Common.localStorage.getItem("de-pgmargins-bottom"),a=Common.localStorage.getItem("de-pgmargins-right");if(null!==n&&null!==o&&null!==s&&null!==a){var r=this.btnPageMargins.menu.items[0];r.options.value=r.value=[parseFloat(n),parseFloat(o),parseFloat(s),parseFloat(a)],r.setVisible(!0),t(r.el).html(r.template({id:Common.UI.getId(),caption:r.caption,options:r.options}))}else this.btnPageMargins.menu.items[0].setVisible(!1)}return i.isCompactView&&i.setFolded(!0),this},onTabClick:function(e){var i=this,n=t(e.currentTarget).find("> a[data-tab]").data("tab"),o=i.isTabActive("file");Common.UI.Mixtbar.prototype.onTabClick.apply(i,arguments),o?i.fireEvent("file:close"):"file"==n&&(i.fireEvent("file:open"),i.setTab(n)),i.isTabActive("home")&&i.fireEvent("home:open")},rendererComponents:function(e){var i=t(e),n=function(t,e){Common.Utils.injectComponent(i.findById(t),e)};return n("#slot-field-fontname",this.cmbFontName),n("#slot-field-fontsize",this.cmbFontSize),n("#slot-btn-print",this.btnPrint),n("#slot-btn-save",this.btnSave),n("#slot-btn-undo",this.btnUndo),n("#slot-btn-redo",this.btnRedo),n("#slot-btn-copy",this.btnCopy),n("#slot-btn-paste",this.btnPaste),n("#slot-btn-incfont",this.btnIncFontSize),n("#slot-btn-decfont",this.btnDecFontSize),n("#slot-btn-bold",this.btnBold),n("#slot-btn-italic",this.btnItalic),n("#slot-btn-underline",this.btnUnderline),n("#slot-btn-strikeout",this.btnStrikeout),n("#slot-btn-superscript",this.btnSuperscript),n("#slot-btn-subscript",this.btnSubscript),n("#slot-btn-highlight",this.btnHighlightColor),n("#slot-btn-fontcolor",this.btnFontColor),n("#slot-btn-align-left",this.btnAlignLeft),n("#slot-btn-align-center",this.btnAlignCenter),n("#slot-btn-align-right",this.btnAlignRight),n("#slot-btn-align-just",this.btnAlignJust),n("#slot-btn-incoffset",this.btnIncLeftOffset),n("#slot-btn-decoffset",this.btnDecLeftOffset),n("#slot-btn-linespace",this.btnLineSpace),n("#slot-btn-hidenchars",this.btnShowHidenChars),n("#slot-btn-markers",this.btnMarkers),n("#slot-btn-numbering",this.btnNumbers),n("#slot-btn-multilevels",this.btnMultilevels),n("#slot-btn-instable",this.btnInsertTable),n("#slot-btn-insimage",this.btnInsertImage),n("#slot-btn-inschart",this.btnInsertChart),n("#slot-btn-instext",this.btnInsertText),n("#slot-btn-instextart",this.btnInsertTextArt),n("#slot-btn-dropcap",this.btnDropCap),n("#slot-btn-controls",this.btnContentControls),n("#slot-btn-columns",this.btnColumns),n("#slot-btn-line-numbers",this.btnLineNumbers),n("#slot-btn-editheader",this.btnEditHeader),n("#slot-btn-datetime",this.btnInsDateTime),n("#slot-btn-blankpage",this.btnBlankPage),n("#slot-btn-insshape",this.btnInsertShape),n("#slot-btn-insequation",this.btnInsertEquation),n("#slot-btn-inssymbol",this.btnInsertSymbol),n("#slot-btn-pageorient",this.btnPageOrient),n("#slot-btn-pagemargins",this.btnPageMargins),n("#slot-btn-pagesize",this.btnPageSize),n("#slot-btn-clearstyle",this.btnClearStyle),n("#slot-btn-copystyle",this.btnCopyStyle),n("#slot-btn-colorschemas",this.btnColorSchemas),n("#slot-btn-paracolor",this.btnParagraphColor),n("#slot-field-styles",this.listStyles),n("#slot-btn-mailrecepients",this.btnMailRecepients),n("#slot-img-align",this.btnImgAlign),n("#slot-img-group",this.btnImgGroup),n("#slot-img-movefrwd",this.btnImgForward),n("#slot-img-movebkwd",this.btnImgBackward),n("#slot-img-wrapping",this.btnImgWrapping),n("#slot-btn-watermark",this.btnWatermark),this.btnsPageBreak=Common.Utils.injectButtons(i.find(".btn-slot.btn-pagebreak"),"","toolbar__icon btn-pagebreak",this.capBtnInsPagebreak,void 0,!0,!0),Array.prototype.push.apply(this.paragraphControls,this.btnsPageBreak),i},onAppReady:function(t){var e=this;new Promise(function(t,e){t()}).then(function(){if(t.isEdit){e.btnsPageBreak.forEach(function(t){t.updateHint([e.textInsPageBreak,e.tipPageBreak]);var i=new Common.UI.Menu({menuAlign:"tl-tr",items:[{caption:e.textNextPage,value:Asc.c_oAscSectionBreakType.NextPage},{caption:e.textContPage,value:Asc.c_oAscSectionBreakType.Continuous},{caption:e.textEvenPage,value:Asc.c_oAscSectionBreakType.EvenPage},{caption:e.textOddPage,value:Asc.c_oAscSectionBreakType.OddPage}]}),n=new Common.UI.Menu({items:[{caption:e.textInsPageBreak,value:"page"},{caption:e.textInsColumnBreak,value:"column"},{caption:e.textInsSectionBreak,value:"section",menu:i}]});t.setMenu(n)});var i=DE.getController("DocumentHolder").getView();e.btnImgForward.updateHint(e.tipSendForward),e.btnImgForward.setMenu(new Common.UI.Menu({items:[{caption:i.textArrangeFront,iconCls:"menu__icon arrange-front",valign:Asc.c_oAscChangeLevel.BringToFront},{caption:i.textArrangeForward,iconCls:"menu__icon arrange-forward",valign:Asc.c_oAscChangeLevel.BringForward}]})),e.btnImgBackward.updateHint(e.tipSendBackward),e.btnImgBackward.setMenu(new Common.UI.Menu({items:[{caption:i.textArrangeBack,iconCls:"menu__icon arrange-back",valign:Asc.c_oAscChangeLevel.SendToBack},{caption:i.textArrangeBackward,iconCls:"menu__icon arrange-backward",valign:Asc.c_oAscChangeLevel.BringBackward}]})),e.btnImgAlign.updateHint(e.tipImgAlign),e.mniAlignToPage=new Common.UI.MenuItem({caption:e.txtPageAlign,checkable:!0,toggleGroup:"imgalign",value:-1}).on("click",function(t){Common.Utils.InternalSettings.set("de-img-align-to",1)}),e.mniAlignToMargin=new Common.UI.MenuItem({caption:e.txtMarginAlign,checkable:!0,toggleGroup:"imgalign",value:-1}).on("click",function(t){Common.Utils.InternalSettings.set("de-img-align-to",2)}),e.mniAlignObjects=new Common.UI.MenuItem({caption:e.txtObjectsAlign,checkable:!0,toggleGroup:"imgalign",value:-1}).on("click",function(t){Common.Utils.InternalSettings.set("de-img-align-to",3)}),e.mniDistribHor=new Common.UI.MenuItem({caption:e.txtDistribHor,iconCls:"menu__icon shape-distribute-hor",value:6}),e.mniDistribVert=new Common.UI.MenuItem({caption:e.txtDistribVert,iconCls:"menu__icon shape-distribute-vert",value:7}),e.btnImgAlign.setMenu(new Common.UI.Menu({cls:"shifted-right",items:[{caption:i.textShapeAlignLeft,iconCls:"menu__icon shape-align-left",value:Asc.c_oAscAlignShapeType.ALIGN_LEFT},{caption:i.textShapeAlignCenter,iconCls:"menu__icon shape-align-center",value:Asc.c_oAscAlignShapeType.ALIGN_CENTER},{caption:i.textShapeAlignRight,iconCls:"menu__icon shape-align-right",value:Asc.c_oAscAlignShapeType.ALIGN_RIGHT},{caption:i.textShapeAlignTop,iconCls:"menu__icon shape-align-top",value:Asc.c_oAscAlignShapeType.ALIGN_TOP},{caption:i.textShapeAlignMiddle,iconCls:"menu__icon shape-align-middle",value:Asc.c_oAscAlignShapeType.ALIGN_MIDDLE},{caption:i.textShapeAlignBottom,iconCls:"menu__icon shape-align-bottom",value:Asc.c_oAscAlignShapeType.ALIGN_BOTTOM},{caption:"--"},e.mniDistribHor,e.mniDistribVert,{caption:"--"},e.mniAlignToPage,e.mniAlignToMargin,e.mniAlignObjects]})),e.btnImgGroup.updateHint(e.tipImgGroup),e.btnImgGroup.setMenu(new Common.UI.Menu({items:[{caption:i.txtGroup,iconCls:"menu__icon shape-group",groupval:1},{caption:i.txtUngroup,iconCls:"menu__icon shape-ungroup",groupval:-1}]})),e.btnImgWrapping.updateHint(e.tipImgWrapping),e.btnImgWrapping.setMenu(new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:i.txtInline,iconCls:"menu__icon wrap-inline",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Inline,checkmark:!1,checkable:!0},{caption:i.txtSquare,iconCls:"menu__icon wrap-square",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Square,checkmark:!1,checkable:!0},{caption:i.txtTight,iconCls:"menu__icon wrap-tight",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Tight,checkmark:!1,checkable:!0},{caption:i.txtThrough,iconCls:"menu__icon wrap-through",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Through,checkmark:!1,checkable:!0},{caption:i.txtTopAndBottom,iconCls:"menu__icon wrap-topandbottom",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.TopAndBottom,checkmark:!1,checkable:!0},{caption:i.txtInFront,iconCls:"menu__icon wrap-infront",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.InFront,checkmark:!1,checkable:!0},{caption:i.txtBehind,iconCls:"menu__icon wrap-behind",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Behind,checkmark:!1,checkable:!0}]})),e.btnWatermark.updateHint(e.tipWatermark),!t.canFeatureContentControl&&e.btnContentControls.cmpEl&&e.btnContentControls.cmpEl.parents(".group").hide().prev(".separator").hide()}})},createDelayedElements:function(){this.api&&(this.mnuNonPrinting.items[0].setChecked(this.api.get_ShowParaMarks(),!0),this.mnuNonPrinting.items[1].setChecked(this.api.get_ShowTableEmptyLine(),!0),this.btnShowHidenChars.toggle(this.mnuNonPrinting.items[0].checked,!0),this.updateMetricUnit()),this.btnPrint.updateHint(this.tipPrint+Common.Utils.String.platformKey("Ctrl+P")),this.btnSave.updateHint(this.btnSaveTip),this.btnUndo.updateHint(this.tipUndo+Common.Utils.String.platformKey("Ctrl+Z")),this.btnRedo.updateHint(this.tipRedo+Common.Utils.String.platformKey("Ctrl+Y")),this.btnCopy.updateHint(this.tipCopy+Common.Utils.String.platformKey("Ctrl+C")),this.btnPaste.updateHint(this.tipPaste+Common.Utils.String.platformKey("Ctrl+V")),this.btnIncFontSize.updateHint(this.tipIncFont+Common.Utils.String.platformKey("Ctrl+]")),this.btnDecFontSize.updateHint(this.tipDecFont+Common.Utils.String.platformKey("Ctrl+[")),this.btnBold.updateHint(this.textBold+Common.Utils.String.platformKey("Ctrl+B")),this.btnItalic.updateHint(this.textItalic+Common.Utils.String.platformKey("Ctrl+I")),this.btnUnderline.updateHint(this.textUnderline+Common.Utils.String.platformKey("Ctrl+U")),this.btnStrikeout.updateHint(this.textStrikeout),this.btnSuperscript.updateHint(this.textSuperscript),this.btnSubscript.updateHint(this.textSubscript),this.btnHighlightColor.updateHint(this.tipHighlightColor),this.btnFontColor.updateHint(this.tipFontColor),this.btnParagraphColor.updateHint(this.tipPrColor),this.btnAlignLeft.updateHint(this.tipAlignLeft+Common.Utils.String.platformKey("Ctrl+L")),this.btnAlignCenter.updateHint(this.tipAlignCenter+Common.Utils.String.platformKey("Ctrl+E")),this.btnAlignRight.updateHint(this.tipAlignRight+Common.Utils.String.platformKey("Ctrl+R")),this.btnAlignJust.updateHint(this.tipAlignJust+Common.Utils.String.platformKey("Ctrl+J")),this.btnDecLeftOffset.updateHint(this.tipDecPrLeft+Common.Utils.String.platformKey("Ctrl+Shift+M")),this.btnIncLeftOffset.updateHint(this.tipIncPrLeft+Common.Utils.String.platformKey("Ctrl+M")),this.btnLineSpace.updateHint(this.tipLineSpace),this.btnShowHidenChars.updateHint(this.tipShowHiddenChars+Common.Utils.String.platformKey("Ctrl+*")),this.btnMarkers.updateHint(this.tipMarkers),this.btnNumbers.updateHint(this.tipNumbers),this.btnMultilevels.updateHint(this.tipMultilevels),this.btnInsertTable.updateHint(this.tipInsertTable),this.btnInsertImage.updateHint(this.tipInsertImage),this.btnInsertChart.updateHint(this.tipInsertChart),this.btnInsertText.updateHint(this.tipInsertText),this.btnInsertTextArt.updateHint(this.tipInsertTextArt),this.btnEditHeader.updateHint(this.tipEditHeader),this.btnInsDateTime.updateHint(this.tipDateTime),this.btnBlankPage.updateHint(this.tipBlankPage),this.btnInsertShape.updateHint(this.tipInsertShape),this.btnInsertEquation.updateHint(this.tipInsertEquation),this.btnInsertSymbol.updateHint(this.tipInsertSymbol),this.btnDropCap.updateHint(this.tipDropCap),this.btnContentControls.updateHint(this.tipControls),this.btnColumns.updateHint(this.tipColumns),this.btnPageOrient.updateHint(this.tipPageOrient),this.btnPageSize.updateHint(this.tipPageSize),this.btnPageMargins.updateHint(this.tipPageMargins),this.btnLineNumbers.updateHint(this.tipLineNumbers),this.btnClearStyle.updateHint(this.tipClearStyle),this.btnCopyStyle.updateHint(this.tipCopyStyle+Common.Utils.String.platformKey("Ctrl+Shift+C")),this.btnColorSchemas.updateHint(this.tipColorSchemas),this.btnMailRecepients.updateHint(this.tipMailRecepients);var i=this;this.btnMarkers.setMenu(new Common.UI.Menu({cls:"shifted-left",style:"min-width: 139px",items:[{template:e.template('')},this.mnuMarkerSettings=new Common.UI.MenuItem({caption:this.textListSettings,disabled:0==(this.mnuMarkersPicker.conf.index||0),value:"settings"})]})),this.btnNumbers.setMenu(new Common.UI.Menu({cls:"shifted-left",items:[{template:e.template('')},this.mnuNumberSettings=new Common.UI.MenuItem({caption:this.textListSettings,disabled:0==(this.mnuNumbersPicker.conf.index||0),value:"settings"})]})),this.btnMultilevels.setMenu(new Common.UI.Menu({cls:"shifted-left",style:"min-width: 90px",items:[{template:e.template('')},this.mnuMultilevelSettings=new Common.UI.MenuItem({caption:this.textListSettings,disabled:0==(this.mnuMultilevelPicker.conf.index||0),value:"settings"})]})),this.btnEditHeader.setMenu(new Common.UI.Menu({items:[{caption:this.mniEditHeader,value:"header"},{caption:this.mniEditFooter,value:"footer"},{caption:"--"},this.mnuInsertPageNum=new Common.UI.MenuItem({caption:this.textInsertPageNumber,disabled:this.mnuInsertPageNum.isDisabled(),menu:new Common.UI.Menu({cls:"shifted-left",menuAlign:"tl-tr",style:"min-width: 90px;",items:[{template:e.template('')},this.mnuPageNumCurrentPos=new Common.UI.MenuItem({caption:this.textToCurrent,disabled:this.mnuPageNumCurrentPos.isDisabled(),value:"current"})]})}),this.mnuInsertPageCount=new Common.UI.MenuItem({caption:this.textInsertPageCount,disabled:this.mnuInsertPageCount.isDisabled()})]})),this.paragraphControls.push(this.mnuPageNumCurrentPos),this.paragraphControls.push(this.mnuInsertPageCount),this.btnInsertChart.setMenu(new Common.UI.Menu({style:"width: 364px;padding-top: 12px;",items:[{template:e.template('')}]}));var n=function(o){new Common.UI.DataView({el:t("#id-toolbar-menu-insertchart"),parentMenu:o,showLast:!1,restoreHeight:421,groups:new Common.UI.DataViewGroupStore(Common.define.chartData.getChartGroupData()),store:new Common.UI.DataViewStore(Common.define.chartData.getChartData()),itemTemplate:e.template('
    ')}).on("item:click",function(t,e,n,o){n&&i.fireEvent("add:chart",[n.get("type")])}),o.off("show:before",n)};this.btnInsertChart.menu.on("show:before",n);var o=function(n){var s=DE.getCollection("Common.Collections.TextArt");s.length<1&&DE.getController("Main").fillTextArt(i.api.asc_getTextArtPreviews()),new Common.UI.DataView({el:t("#id-toolbar-menu-insart"),store:s,parentMenu:n,showLast:!1,itemTemplate:e.template('
    ')}).on("item:click",function(t,e,o,s){o&&i.fireEvent("insert:textart",[o.get("data")]),"click"!==s.type&&n.hide()}),n.off("show:before",o)};this.btnInsertTextArt.menu.on("show:before",o);var s=this.mnuMarkersPicker.conf;this.mnuMarkersPicker=new Common.UI.DataView({el:t("#id-toolbar-menu-markers"),parentMenu:this.btnMarkers.menu,restoreHeight:138,allowScrollbar:!1,store:new Common.UI.DataViewStore([{offsety:0,data:{type:0,subtype:-1}},{offsety:38,data:{type:0,subtype:1}},{offsety:76,data:{type:0,subtype:2}},{offsety:114,data:{type:0,subtype:3}},{offsety:152,data:{type:0,subtype:4}},{offsety:190,data:{type:0,subtype:5}},{offsety:228,data:{type:0,subtype:6}},{offsety:266,data:{type:0,subtype:7}},{offsety:684,data:{type:0,subtype:8}}]),itemTemplate:e.template('
    ')}),s&&this.mnuMarkersPicker.selectByIndex(s.index,!0),s=this.mnuNumbersPicker.conf,this.mnuNumbersPicker=new Common.UI.DataView({el:t("#id-toolbar-menu-numbering"),parentMenu:this.btnNumbers.menu,restoreHeight:92,allowScrollbar:!1,store:new Common.UI.DataViewStore([{offsety:0,data:{type:1,subtype:-1}},{offsety:570,data:{type:1,subtype:4}},{offsety:532,data:{type:1,subtype:5}},{offsety:608,data:{type:1,subtype:6}},{offsety:418,data:{type:1,subtype:1}},{offsety:456,data:{type:1,subtype:2}},{offsety:494,data:{type:1,subtype:3}},{offsety:646,data:{type:1,subtype:7}}]),itemTemplate:e.template('
    ')}),s&&this.mnuNumbersPicker.selectByIndex(s.index,!0),s=this.mnuMultilevelPicker.conf,this.mnuMultilevelPicker=new Common.UI.DataView({el:t("#id-toolbar-menu-multilevels"),parentMenu:this.btnMultilevels.menu,restoreHeight:92,allowScrollbar:!1,store:new Common.UI.DataViewStore([{offsety:0,data:{type:2,subtype:-1}},{offsety:304,data:{type:2,subtype:1}},{offsety:342,data:{type:2,subtype:2}},{offsety:380,data:{type:2,subtype:3}}]),itemTemplate:e.template('
    ')}),s&&this.mnuMultilevelPicker.selectByIndex(s.index,!0),s=this.mnuPageNumberPosPicker?this.mnuPageNumberPosPicker.conf:void 0,this.mnuPageNumberPosPicker=new Common.UI.DataView({el:t("#id-toolbar-menu-pageposition"),allowScrollbar:!1,store:new Common.UI.DataViewStore([{offsety:132,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_TOP,subtype:c_pageNumPosition.PAGE_NUM_POSITION_LEFT}},{offsety:99,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_TOP,subtype:c_pageNumPosition.PAGE_NUM_POSITION_CENTER}},{offsety:66,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_TOP,subtype:c_pageNumPosition.PAGE_NUM_POSITION_RIGHT}},{offsety:33,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM,subtype:c_pageNumPosition.PAGE_NUM_POSITION_LEFT}},{offsety:0,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM,subtype:c_pageNumPosition.PAGE_NUM_POSITION_CENTER}},{offsety:165,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM,subtype:c_pageNumPosition.PAGE_NUM_POSITION_RIGHT}}]),itemTemplate:e.template('
    ')}),s&&this.mnuPageNumberPosPicker.setDisabled(s.disabled),this.mnuTablePicker=new Common.UI.DimensionPicker({el:t("#id-toolbar-menu-tablepicker"),minRows:8,minColumns:10,maxRows:8,maxColumns:10})},onToolbarAfterRender:function(e){var i;this.btnHighlightColor.cmpEl&&(i=t('
    '),t("button:first-child",this.btnHighlightColor.cmpEl).append(i),this.btnHighlightColor.currentColor="FFFF00",i.css("background-color","#"+this.btnHighlightColor.currentColor),this.mnuHighlightColorPicker=new Common.UI.ColorPalette({el:t("#id-toolbar-menu-highlight"),colors:["FFFF00","00FF00","00FFFF","FF00FF","0000FF","FF0000","00008B","008B8B","006400","800080","8B0000","808000","FFFFFF","D3D3D3","A9A9A9","000000"]}),this.mnuHighlightColorPicker.select("FFFF00")),this.btnFontColor.cmpEl&&(i=t('
    '),t("button:first-child",this.btnFontColor.cmpEl).append(i),i.css("background-color",this.btnFontColor.currentColor||"transparent"),this.mnuFontColorPicker=new Common.UI.ThemeColorPalette({el:t("#id-toolbar-menu-fontcolor")})),this.btnParagraphColor.cmpEl&&(i=t('
    '),t("button:first-child",this.btnParagraphColor.cmpEl).append(i),i.css("background-color",this.btnParagraphColor.currentColor||"transparent"),this.mnuParagraphColorPicker=new Common.UI.ThemeColorPalette({el:t("#id-toolbar-menu-paracolor"),transparent:!0})),this.btnContentControls.cmpEl&&(this.mnuControlsColorPicker=new Common.UI.ThemeColorPalette({el:t("#id-toolbar-menu-controls-color"),colors:["000000","993300","333300","003300","003366","000080","333399","333333","800000","FF6600","808000","00FF00","008080","0000FF","666699","808080","FF0000","FF9900","99CC00","339966","33CCCC","3366FF","800080","999999","FF00FF","FFCC00","FFFF00","00FF00","00FFFF","00CCFF","993366","C0C0C0","FF99CC","FFCC99","FFFF99","CCFFCC","CCFFFF","C9C8FF","CC99FF","FFFFFF"]}))},updateMetricUnit:function(){for(var e=this.btnPageMargins.menu.items,i=0;i-1)},onSendThemeColorSchemes:function(t){var i=this;this.mnuColorSchema&&this.mnuColorSchema.items.length>0&&e.each(this.mnuColorSchema.items,function(t){t.remove()}),null==this.mnuColorSchema&&(this.mnuColorSchema=new Common.UI.Menu({cls:"shifted-left",restoreHeight:!0})),this.mnuColorSchema.items=[];var n=e.template(['','',"<% _.each(options.colors, function(color) { %>",'',"<% }) %>","",'<%= caption %>',""].join(""));e.each(t,function(t,e){for(var o=t.get_colors(),s=[],a=2;a<7;a++){var r="#"+Common.Utils.ThemeColor.getHexColor(o[a].get_r(),o[a].get_g(),o[a].get_b());s.push(r)}21==e&&this.mnuColorSchema.addItem({caption:"--"});var l=t.get_name();this.mnuColorSchema.addItem({template:n,cls:"color-schemas-menu",colors:s,caption:e<21?i.SchemeNames[e]||l:l,value:e,checkable:!0,toggleGroup:"menuSchema"})},this)},onCollaborativeChanges:function(){if(!this._state.hasCollaborativeChanges){if(!this.btnCollabChanges.rendered||this._state.previewmode)return void(this.needShowSynchTip=!0);this._state.hasCollaborativeChanges=!0,this.btnCollabChanges.cmpEl.addClass("notify"),this.showSynchTip?(this.btnCollabChanges.updateHint(""),void 0===this.synchTooltip&&this.createSynchTip(),this.synchTooltip.show()):this.btnCollabChanges.updateHint(this.tipSynchronize+Common.Utils.String.platformKey("Ctrl+S")),this.btnSave.setDisabled(!1),Common.Gateway.collaborativeChanges()}},createSynchTip:function(){this.synchTooltip=new Common.UI.SynchronizeTip({extCls:this.mode.customization&&this.mode.customization.compactHeader?void 0:"inc-index",target:this.btnCollabChanges.$el}),this.synchTooltip.on("dontshowclick",function(){this.showSynchTip=!1,this.synchTooltip.hide(), -this.btnCollabChanges.updateHint(this.tipSynchronize+Common.Utils.String.platformKey("Ctrl+S")),Common.localStorage.setItem("de-hide-synch",1)},this),this.synchTooltip.on("closeclick",function(){this.synchTooltip.hide(),this.btnCollabChanges.updateHint(this.tipSynchronize+Common.Utils.String.platformKey("Ctrl+S"))},this)},synchronizeChanges:function(){if(!this._state.previewmode&&this.btnCollabChanges.rendered){var t=this;t.btnCollabChanges.cmpEl.hasClass("notify")&&(t.btnCollabChanges.cmpEl.removeClass("notify"),this.synchTooltip&&this.synchTooltip.hide(),this.btnCollabChanges.updateHint(this.btnSaveTip),this.btnSave.setDisabled(!t.mode.forcesave),this._state.hasCollaborativeChanges=!1)}},onApiUsersChanged:function(t){var i=[];e.each(t,function(t){t.asc_getView()||i.push(t)});var n=this,o=e.size(i),s=o>1?"btn-save-coauth":"btn-save";s!==n.btnSaveCls&&n.btnCollabChanges.rendered&&(n.btnSaveTip=(o>1?n.tipSaveCoauth:n.tipSave)+Common.Utils.String.platformKey("Ctrl+S"),n.btnCollabChanges.updateHint(n.btnSaveTip),n.btnCollabChanges.$icon.removeClass(n.btnSaveCls).addClass(s),n.btnSaveCls=s)},onStyleMenuUpdate:function(t,e,i){var n=this;if(n.api){var o=n.api.asc_GetStyleFromFormatting(),s=t.styleTitle,a=o.get_Link();o.put_Name(s),a.put_Name(s+"_character"),n.api.asc_AddNewStyle(o),setTimeout(function(){n.listStyles.openButton.menu.hide()},100)}},onStyleMenuDelete:function(t,e,i){this.api&&this.api.asc_RemoveStyle(t.styleTitle)},onStyleMenuRestoreAll:function(t,i,n){var o=this;o.api&&e.each(window.styles.get_MergedStyles(),function(t){o.api.asc_IsStyleDefault(t.get_Name())&&o.api.asc_RemoveStyle(t.get_Name())})},onStyleMenuDeleteAll:function(t,e,i){this.api&&this.api.asc_RemoveAllCustomStyles()},textBold:"Bold",textItalic:"Italic",textUnderline:"Underline",textStrikeout:"Strikeout",textSuperscript:"Superscript",textSubscript:"Subscript",strMenuNoFill:"No Fill",tipFontName:"Font Name",tipFontSize:"Font Size",tipParagraphStyle:"Paragraph Style",tipCopy:"Copy",tipPaste:"Paste",tipUndo:"Undo",tipRedo:"Redo",tipPrint:"Print",tipSave:"Save",tipIncFont:"Increment font size",tipDecFont:"Decrement font size",tipHighlightColor:"Highlight color",tipFontColor:"Font color",tipMarkers:"Bullets",tipNumbers:"Numbering",tipMultilevels:"Outline",tipAlignLeft:"Align Left",tipAlignRight:"Align Right",tipAlignCenter:"Align Center",tipAlignJust:"Justified",tipDecPrLeft:"Decrease Indent",tipIncPrLeft:"Increase Indent",tipShowHiddenChars:"Nonprinting Characters",tipLineSpace:"Paragraph Line Spacing",tipPrColor:"Background color",tipInsertTable:"Insert Table",tipInsertImage:"Insert Image",tipPageBreak:"Insert Page or Section break",tipInsertNum:"Insert Page Number",tipClearStyle:"Clear Style",tipCopyStyle:"Copy Style",tipPageSize:"Page Size",tipPageOrient:"Page Orientation",tipBack:"Back",tipInsertShape:"Insert Autoshape",tipInsertEquation:"Insert Equation",mniImageFromFile:"Image from File",mniImageFromUrl:"Image from URL",mniCustomTable:"Insert Custom Table",textTitleError:"Error",textInsertPageNumber:"Insert page number",textToCurrent:"To Current Position",tipEditHeader:"Edit header or footer",mniEditHeader:"Edit Document Header",mniEditFooter:"Edit Document Footer",mniHiddenChars:"Nonprinting Characters",mniHiddenBorders:"Hidden Table Borders",tipSynchronize:"The document has been changed by another user. Please click to save your changes and reload the updates.",textNewColor:"Add New Custom Color",textAutoColor:"Automatic",tipInsertChart:"Insert Chart",tipColorSchemas:"Change Color Scheme",tipInsertText:"Insert Text",tipInsertTextArt:"Insert Text Art",mniEditDropCap:"Drop Cap Settings",textNone:"None",textInText:"In Text",textInMargin:"In Margin",tipDropCap:"Insert drop cap",txtScheme1:"Office",txtScheme2:"Grayscale",txtScheme3:"Apex",txtScheme4:"Aspect",txtScheme5:"Civic",txtScheme6:"Concourse",txtScheme7:"Equity",txtScheme8:"Flow",txtScheme9:"Foundry",txtScheme10:"Median",txtScheme11:"Metro",txtScheme12:"Module",txtScheme13:"Opulent",txtScheme14:"Oriel",txtScheme15:"Origin",txtScheme16:"Paper",txtScheme17:"Solstice",txtScheme18:"Technic",txtScheme19:"Trek",txtScheme20:"Urban",txtScheme21:"Verve",textInsPageBreak:"Insert Page Break",textInsColumnBreak:"Insert Column Break",textInsSectionBreak:"Insert Section Break",textNextPage:"Next Page",textContPage:"Continuous Page",textEvenPage:"Even Page",textOddPage:"Odd Page",tipSaveCoauth:"Save your changes for the other users to see them.",tipMailRecepients:"Mail Merge",textStyleMenuUpdate:"Update from select",textStyleMenuRestore:"Restore to default",textStyleMenuDelete:"Delete style",textStyleMenuRestoreAll:"Restore all to default styles",textStyleMenuDeleteAll:"Delete all custom styles",textStyleMenuNew:"New style from selection",tipColumns:"Insert columns",textColumnsOne:"One",textColumnsTwo:"Two",textColumnsThree:"Three",textColumnsLeft:"Left",textColumnsRight:"Right",tipPageMargins:"Page Margins",textMarginsLast:"Last Custom",textMarginsNormal:"Normal",textMarginsUsNormal:"US Normal",textMarginsNarrow:"Narrow",textMarginsModerate:"Moderate",textMarginsWide:"Wide",textPageMarginsCustom:"Custom margins",textTop:"Top: ",textLeft:"Left: ",textBottom:"Bottom: ",textRight:"Right: ",textPageSizeCustom:"Custom Page Size",textPortrait:"Portrait",textLandscape:"Landscape",textInsertPageCount:"Insert number of pages",tipChangeChart:"Change Chart Type",capBtnInsPagebreak:"Page Break",capBtnInsImage:"Image",capBtnInsTable:"Table",capBtnInsChart:"Chart",textTabFile:"File",textTabHome:"Home",textTabInsert:"Insert",textTabLayout:"Layout",textTabReview:"Review",capBtnInsShape:"Shape",capBtnInsTextbox:"Text Box",capBtnInsTextart:"Text Art",capBtnInsDropcap:"Drop Cap",capBtnInsEquation:"Equation",capBtnInsHeader:"Header/Footer",capBtnColumns:"Columns",capBtnPageOrient:"Orientation",capBtnMargins:"Margins",capBtnPageSize:"Size",tipImgAlign:"Align objects",tipImgGroup:"Group objects",tipImgWrapping:"Wrap text",tipSendForward:"Bring forward",tipSendBackward:"Send backward",capImgAlign:"Align",capImgGroup:"Group",capImgForward:"Bring Forward",capImgBackward:"Send Backward",capImgWrapping:"Wrapping",capBtnComment:"Comment",textColumnsCustom:"Custom Columns",textTabCollaboration:"Collaboration",textTabProtect:"Protection",textTabLinks:"References",capBtnInsControls:"Content Control",textRichControl:"Rich text",textPlainControl:"Plain text",textRemoveControl:"Remove",mniEditControls:"Settings",tipControls:"Insert content control",mniHighlightControls:"Highlight settings",textNoHighlight:"No highlighting",mniImageFromStorage:"Image from Storage",capBtnBlankPage:"Blank Page",tipBlankPage:"Insert blank page",txtDistribHor:"Distribute Horizontally",txtDistribVert:"Distribute Vertically",txtPageAlign:"Align to Page",txtMarginAlign:"Align to Margin",txtObjectsAlign:"Align Selected Objects",capBtnWatermark:"Watermark",textEditWatermark:"Custom Watermark",textRemWatermark:"Remove Watermark",tipWatermark:"Edit watermark",textPictureControl:"Picture",textComboboxControl:"Combo box",textCheckboxControl:"Check box",textDropdownControl:"Drop-down list",textDateControl:"Date",capBtnAddComment:"Add Comment",capBtnInsSymbol:"Symbol",tipInsertSymbol:"Insert symbol",mniDrawTable:"Draw Table",mniEraseTable:"Erase Table",textListSettings:"List Settings",capBtnDateTime:"Date & Time",tipDateTime:"Insert current date and time",capBtnLineNumbers:"Line Numbers",textContinuous:"Continuous",textRestartEachPage:"Restart Each Page",textRestartEachSection:"Restart Each Section",textSuppressForCurrentParagraph:"Suppress for Current Paragraph",textCustomLineNumbers:"Line Numbering Options",tipLineNumbers:"Show line numbers"}}(),DE.Views.Toolbar||{}))}),void 0===Common)var Common={};if(define("documenteditor/main/app/view/StyleTitleDialog",["common/main/lib/util/utils","common/main/lib/component/InputField","common/main/lib/component/Window"],function(){"use strict";DE.Views.StyleTitleDialog=Common.UI.Window.extend(_.extend({options:{width:350,height:196,style:"min-width: 230px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textHeader},t||{}),this.template=['
    ','",'
    ','",'
    ',"
    "].join(""),this.options.tpl=_.template(this.template)(this.options),this.options.formats=this.options.formats||[],Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();t.inputTitle=new Common.UI.InputField({el:$("#id-dlg-style-title"),allowBlank:!1,blankError:t.txtEmpty,style:"width: 100%;",validateOnBlur:!1,validation:function(e){return!(""==e)||t.txtNotEmpty}}),e.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.options.formats.unshift({value:-1,displayValue:this.txtSameAs}),this.cmbNextStyle=new Common.UI.ComboBox({el:$("#id-dlg-style-next-par"),style:"width: 100%;",menuStyle:"width: 100%; max-height: 210px;",editable:!1,takeFocusOnClose:!0,cls:"input-group-nr",data:this.options.formats,disabled:0==this.options.formats.length}),this.cmbNextStyle.setValue(-1)},getFocusedComponents:function(){return[this.inputTitle,this.cmbNextStyle]},getDefaultFocusableComponent:function(){return this.inputTitle},getTitle:function(){return this.inputTitle.getValue()},getNextStyle:function(){var t=this.cmbNextStyle.getValue();return-1!=t?t:null},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},_handleInput:function(t){if(this.options.handler){if("ok"==t){if(!0!==this.inputTitle.checkValidate())return void this.inputTitle.focus()}this.options.handler.call(this,this,t)}this.close()},textTitle:"Title",textHeader:"Create New Style",txtEmpty:"This field is required",txtNotEmpty:"Field must not be empty",textNextStyle:"Next paragraph style",txtSameAs:"Same as created new style"},DE.Views.StyleTitleDialog||{}))}),define("documenteditor/main/app/view/PageMarginsDialog",["common/main/lib/component/Window","common/main/lib/component/MetricSpinner"],function(){"use strict";DE.Views.PageMarginsDialog=Common.UI.Window.extend(_.extend({options:{width:404,header:!0,style:"min-width: 404px;",cls:"modal-dlg",id:"window-page-margins",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
    ','
    ','",'
    ','
    ','",'
    ',"
    ",'
    ','",'
    ',"
    ","
    ",'
    ','
    ','",'
    ',"
    ",'
    ','",'
    ',"
    ","
    ",'
    ','","
    ",'
    ','
    ',"
    ","
    ",'
    ','",'
    ',"
    ",'
    ','",'
    ',"
    ","
    ",'
    ','",'
    ',"
    ","
    "].join(""),this.options.tpl=_.template(this.template)(this.options),this.spinners=[],this._noApply=!1,this.maxMarginsW=this.maxMarginsH=0,this.api=this.options.api,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.spnTop=new Common.UI.MetricSpinner({el:$("#page-margins-spin-top"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:-55.87}),this.spnTop.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_TopMargin(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnTop),this.spnBottom=new Common.UI.MetricSpinner({el:$("#page-margins-spin-bottom"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:-55.87}),this.spnBottom.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_BottomMargin(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnBottom),this.spnLeft=new Common.UI.MetricSpinner({el:$("#page-margins-spin-left"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:0}),this.spnLeft.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_LeftMargin(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnLeft),this.spnRight=new Common.UI.MetricSpinner({el:$("#page-margins-spin-right"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:0}),this.spnRight.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_RightMargin(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnRight),this.spnGutter=new Common.UI.MetricSpinner({el:$("#page-margins-spin-gutter"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:0}),this.spnGutter.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_Gutter(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnGutter),this.cmbGutterPosition=new Common.UI.ComboBox({el:$("#page-margins-spin-gutter-position"),menuStyle:"min-width: 86px;",style:"width: 86px;",editable:!1,takeFocusOnClose:!0,cls:"input-group-nr",data:[{value:0,displayValue:this.textLeft},{value:1,displayValue:this.textTop}]}),this.cmbGutterPosition.on("selected",_.bind(function(t,e){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_GutterAtTop(e.value),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.cmbOrientation=new Common.UI.ComboBox({el:$("#page-margins-cmb-orientation"),menuStyle:"min-width: 180px;",style:"width: 180px;",editable:!1,takeFocusOnClose:!0,cls:"input-group-nr",data:[{value:0,displayValue:this.textPortrait},{value:1,displayValue:this.textLandscape}]}),this.cmbOrientation.on("selected",_.bind(function(t,e){if(this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.get_Orientation()!==e.value)){this.properties.put_TopMargin(Common.Utils.Metric.fnRecalcToMM(e.value?this.spnLeft.getNumberValue():this.spnRight.getNumberValue())),this.properties.put_BottomMargin(Common.Utils.Metric.fnRecalcToMM(e.value?this.spnRight.getNumberValue():this.spnLeft.getNumberValue())),this.properties.put_LeftMargin(Common.Utils.Metric.fnRecalcToMM(e.value?this.spnBottom.getNumberValue():this.spnTop.getNumberValue())),this.properties.put_RightMargin(Common.Utils.Metric.fnRecalcToMM(e.value?this.spnTop.getNumberValue():this.spnBottom.getNumberValue()));var i=this.properties.get_H();this.properties.put_H(this.properties.get_W()),this.properties.put_W(i),this.properties.put_Orientation(e.value),this.maxMarginsH=Common.Utils.Metric.fnRecalcFromMM(this.properties.get_H()-2.6),this.maxMarginsW=Common.Utils.Metric.fnRecalcFromMM(this.properties.get_W()-12.7),this.spnTop.setMaxValue(this.maxMarginsH),this.spnBottom.setMaxValue(this.maxMarginsH),this.spnLeft.setMaxValue(this.maxMarginsW),this.spnRight.setMaxValue(this.maxMarginsW),this.spnTop.setValue(Common.Utils.Metric.fnRecalcFromMM(this.properties.get_TopMargin()),!0),this.spnBottom.setValue(Common.Utils.Metric.fnRecalcFromMM(this.properties.get_BottomMargin()),!0),this.spnLeft.setValue(Common.Utils.Metric.fnRecalcFromMM(this.properties.get_LeftMargin()),!0),this.spnRight.setValue(Common.Utils.Metric.fnRecalcFromMM(this.properties.get_RightMargin()),!0),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties)}},this)),this.cmbMultiplePages=new Common.UI.ComboBox({el:$("#page-margins-cmb-multiple-pages"),menuStyle:"min-width: 180px;",style:"width: 180px;",editable:!1,takeFocusOnClose:!0,cls:"input-group-nr",data:[{value:0,displayValue:this.textNormal},{value:1,displayValue:this.textMirrorMargins}]}),this.cmbMultiplePages.on("selected",_.bind(function(t,e){0===e.value?(this.window.find("#margin-left-label").html(this.textLeft),this.window.find("#margin-right-label").html(this.textRight),this.cmbGutterPosition.setDisabled(!1)):(this.window.find("#margin-left-label").html(this.textInside),this.window.find("#margin-right-label").html(this.textOutside),this.cmbGutterPosition.setValue(0),this.cmbGutterPosition.setDisabled(!0)),this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_MirrorMargins(e.value),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.window=this.getChild(),this.window.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.updateMetricUnit()},getFocusedComponents:function(){return[this.spnTop,this.spnBottom,this.spnLeft,this.spnRight,this.spnGutter,this.cmbGutterPosition,this.cmbOrientation,this.cmbMultiplePages]},getDefaultFocusableComponent:function(){return this.spnTop},_handleInput:function(t){if(this.options.handler){if("ok"==t){var e=null;if(this.spnLeft.getNumberValue()+this.spnRight.getNumberValue()+(this.cmbGutterPosition.getValue()?0:this.spnGutter.getNumberValue())>this.maxMarginsW?e=this.txtMarginsW:Math.abs(this.spnTop.getNumberValue()+this.spnBottom.getNumberValue()+(this.cmbGutterPosition.getValue()?this.spnGutter.getNumberValue():0))>this.maxMarginsH&&(e=this.txtMarginsH),e)return void Common.UI.warning({title:this.notcriticalErrorTitle,msg:e})}this.options.handler.call(this,this,t)}this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},setSettings:function(t){if(t){this.properties=t,this.maxMarginsH=Common.Utils.Metric.fnRecalcFromMM(t.get_H()-2.6),this.maxMarginsW=Common.Utils.Metric.fnRecalcFromMM(t.get_W()-12.7),this.spnTop.setMaxValue(this.maxMarginsH),this.spnBottom.setMaxValue(this.maxMarginsH),this.spnLeft.setMaxValue(this.maxMarginsW),this.spnRight.setMaxValue(this.maxMarginsW),this.spnTop.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_TopMargin()),!0),this.spnBottom.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_BottomMargin()),!0),this.spnLeft.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_LeftMargin()),!0),this.spnRight.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_RightMargin()),!0),this.cmbOrientation.setValue(t.get_Orientation()),this.spnGutter.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_Gutter()),!0),this.cmbGutterPosition.setValue(t.get_GutterAtTop()?1:0);var e=t.get_MirrorMargins();this.cmbMultiplePages.setValue(e?1:0),e&&(this.window.find("#margin-left-label").html(this.textInside),this.window.find("#margin-right-label").html(this.textOutside),this.cmbGutterPosition.setValue(0)),this.cmbGutterPosition.setDisabled(e),this.api&&this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties)}},getSettings:function(){var t=new Asc.CDocumentSectionProps;return t.put_TopMargin(Common.Utils.Metric.fnRecalcToMM(this.spnTop.getNumberValue())),t.put_BottomMargin(Common.Utils.Metric.fnRecalcToMM(this.spnBottom.getNumberValue())),t.put_LeftMargin(Common.Utils.Metric.fnRecalcToMM(this.spnLeft.getNumberValue())),t.put_RightMargin(Common.Utils.Metric.fnRecalcToMM(this.spnRight.getNumberValue())),t.put_Orientation(this.cmbOrientation.getValue()),t.put_Gutter(Common.Utils.Metric.fnRecalcToMM(this.spnGutter.getNumberValue())),t.put_GutterAtTop(!!this.cmbGutterPosition.getValue()),t.put_MirrorMargins(!!this.cmbMultiplePages.getValue()),t.put_H(this.properties.get_H()),t.put_W(this.properties.get_W()),t},updateMetricUnit:function(){if(this.spinners)for(var t=0;t','',"",'","","",'","","","
    ','",'
    ',"
    ','",'
    ',"
    ",'",'
    ',"
    ","",'
    '].join(""),this.options.tpl=_.template(this.template)(this.options),this.spinners=[],this._noApply=!1,this.isOrientPortrait=!0,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.spnWidth=new Common.UI.MetricSpinner({el:$("#page-size-spin-width"),step:.1,width:86,defaultUnit:"cm",value:"10 cm",maxValue:118.9,minValue:0}),this.spinners.push(this.spnWidth),this.spnWidth.on("change",_.bind(function(t,e,i,n){!this._noApply&&this.cmbPreset.getValue()>-1&&this.cmbPreset.setValue(-1)},this)),this.spnHeight=new Common.UI.MetricSpinner({el:$("#page-size-spin-height"),step:.1,width:86,defaultUnit:"cm",value:"20 cm",maxValue:118.9,minValue:0}),this.spinners.push(this.spnHeight),this.spnHeight.on("change",_.bind(function(t,e,i,n){!this._noApply&&this.cmbPreset.getValue()>-1&&this.cmbPreset.setValue(-1)},this)),this.cmbPreset=new Common.UI.ComboBox({el:$("#page-size-combo-preset"),cls:"input-group-nr",menuStyle:"min-width: 183px;max-height: 208px;",editable:!1,takeFocusOnClose:!0,scrollAlwaysVisible:!0,data:[{value:0,displayValue:"US Letter",size:[215.9,279.4]},{value:1,displayValue:"US Legal",size:[215.9,355.6]},{value:2,displayValue:"A4",size:[210,297]},{value:3,displayValue:"A5",size:[148,210]},{value:4,displayValue:"B5",size:[176,250]},{value:5,displayValue:"Envelope #10",size:[104.8,241.3]},{value:6,displayValue:"Envelope DL",size:[110,220]},{value:7,displayValue:"Tabloid",size:[279.4,431.8]},{value:8,displayValue:"A3",size:[297,420]},{value:9,displayValue:"Tabloid Oversize",size:[304.8,457.1]},{value:10,displayValue:"ROC 16K",size:[196.8,273]},{value:11,displayValue:"Envelope Choukei 3",size:[119.9,234.9]},{value:12,displayValue:"Super B/A3",size:[330.2,482.5]},{value:13,displayValue:"A0",size:[841,1189]},{value:14,displayValue:"A1",size:[594,841]},{value:16,displayValue:"A2",size:[420,594]},{value:17,displayValue:"A6",size:[105,148]},{value:-1,displayValue:this.txtCustom,size:[]}]}),this.cmbPreset.setValue(-1),this.cmbPreset.on("selected",_.bind(function(t,e){this._noApply=!0,e.value<0||(this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(this.isOrientPortrait?e.size[0]:e.size[1]),!0),this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(this.isOrientPortrait?e.size[1]:e.size[0]),!0)),this._noApply=!1},this)),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.updateMetricUnit()},getFocusedComponents:function(){return[this.cmbPreset,this.spnWidth,this.spnHeight]},getDefaultFocusableComponent:function(){return this.cmbPreset},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},setSettings:function(t){if(t){this.isOrientPortrait=t.get_W()1&&(!e||3==e),!0),this.toolbar.mniAlignToMargin.setChecked(t<2&&!e||2==e,!0),this.toolbar.mniAlignToPage.setChecked(1==e,!0),this.toolbar.mniDistribHor.setDisabled(t<3&&this.toolbar.mniAlignObjects.isChecked()),this.toolbar.mniDistribVert.setDisabled(t<3&&this.toolbar.mniAlignObjects.isChecked())},onClickMenuAlign:function(t,e,i){ -var n=this.toolbar.mniAlignToPage.isChecked()?Asc.c_oAscObjectsAlignType.Page:this.toolbar.mniAlignToMargin.isChecked()?Asc.c_oAscObjectsAlignType.Margin:Asc.c_oAscObjectsAlignType.Selected;e.value>-1&&e.value<6?(this.api.put_ShapesAlign(e.value,n),Common.component.Analytics.trackEvent("ToolBar","Shape Align")):6==e.value?(this.api.DistributeHorizontally(n),Common.component.Analytics.trackEvent("ToolBar","Distribute")):7==e.value&&(this.api.DistributeVertically(n),Common.component.Analytics.trackEvent("ToolBar","Distribute")),this.toolbar.fireEvent("editcomplete",this.toolbar)},onClickMenuWrapping:function(e,i,n){var o=new Asc.asc_CImgProperty;if(o.put_WrappingStyle(i.options.wrapType),t.get_WrappingStyle()===Asc.c_oAscWrapStyle2.Inline&&i.options.wrapType!==Asc.c_oAscWrapStyle2.Inline){o.put_PositionH(new Asc.CImagePositionH),o.get_PositionH().put_UseAlign(!1),o.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var s=t.get_Value_X(Asc.c_oAscRelativeFromH.Column);o.get_PositionH().put_Value(s),o.put_PositionV(new Asc.CImagePositionV),o.get_PositionV().put_UseAlign(!1),o.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),s=t.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),o.get_PositionV().put_Value(s)}this.api.ImgApply(o),this.toolbar.fireEvent("editcomplete",this.toolbar)},onClickMenuGroup:function(t,e,i){var n=new Asc.asc_CImgProperty;n.put_Group(e.options.groupval),this.api.ImgApply(n),this.toolbar.fireEvent("editcomplete",this.toolbar)},onClickMenuForward:function(t,e,i){var n=new Asc.asc_CImgProperty;"forward"==t?n.put_ChangeLevel(Asc.c_oAscChangeLevel.BringForward):"backward"==t?n.put_ChangeLevel(Asc.c_oAscChangeLevel.BringBackward):n.put_ChangeLevel(e.options.valign),this.api.ImgApply(n),this.toolbar.fireEvent("editcomplete",this.toolbar)}}}())}),define("documenteditor/main/app/view/CustomColumnsDialog",["common/main/lib/component/Window","common/main/lib/component/MetricSpinner","common/main/lib/component/CheckBox"],function(){"use strict";DE.Views.CustomColumnsDialog=Common.UI.Window.extend(_.extend({options:{width:300,header:!0,style:"min-width: 216px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
    ','
    ','
    ',"
    ",'
    ','
    ',"
    ",'
    ','
    ',"
    ","
    ",'
    '].join(""),this.options.tpl=_.template(this.template)(this.options),this.spinners=[],this.totalWidth=558.7,this._noApply=!1,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this;this.spnColumns=new Common.UI.MetricSpinner({el:$("#custom-columns-spin-num"),step:1,allowDecimal:!1,width:100,defaultUnit:"",value:"1",maxValue:12,minValue:1}),this.spnColumns.on("change",function(e,i,n,o){var s=Common.Utils.Metric.fnRecalcToMM(t.spnSpacing.getNumberValue()),a=t.spnColumns.getNumberValue();t.chSeparator.setDisabled(a<2),t.spnSpacing.setDisabled(a<2),a<2&&(a=2);var r=parseFloat(((t.totalWidth-12.7*a)/(a-1)).toFixed(1));t.spnSpacing.setMaxValue(Common.Utils.Metric.fnRecalcFromMM(r)),s>r&&t.spnSpacing.setValue(Common.Utils.Metric.fnRecalcFromMM(r),!0)}),this.spnSpacing=new Common.UI.MetricSpinner({el:$("#custom-columns-spin-spacing"),step:.1,width:100,defaultUnit:"cm",value:"0 cm",maxValue:40.64,minValue:0}),this.spinners.push(this.spnSpacing),this.chSeparator=new Common.UI.CheckBox({el:$("#custom-columns-separator"),labelText:this.textSeparator}),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.updateMetricUnit()},getFocusedComponents:function(){return[this.spnColumns,this.spnSpacing]},getDefaultFocusableComponent:function(){return this.spnColumns},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(){return this._handleInput("ok"),!1},setSettings:function(t){if(t){var e=t.get_EqualWidth(),i=e?t.get_Num():t.get_ColsCount(),n=e?t.get_Space():i>1?t.get_Col(0).get_Space():12.5;this.chSeparator.setValue(t.get_Sep());var o=t.get_TotalWidth(),s=parseInt((o+.1)/(12.7+.1));this.spnColumns.setMaxValue(s),this.spnColumns.setValue(i,!0),this.chSeparator.setDisabled(i<2),this.spnSpacing.setDisabled(i<2),i<2&&(i=2),i>s&&(i=s);var a=parseFloat(((o-12.7*i)/(i-1)).toFixed(1));this.spnSpacing.setMaxValue(Common.Utils.Metric.fnRecalcFromMM(a)),this.spnSpacing.setValue(Common.Utils.Metric.fnRecalcFromMM(n),!0),this.totalWidth=o}},getSettings:function(){var t=new Asc.CDocumentColumnsProps;return t.put_EqualWidth(!0),t.put_Num(this.spnColumns.getNumberValue()),t.put_Space(Common.Utils.Metric.fnRecalcToMM(this.spnSpacing.getNumberValue())),t.put_Sep("checked"==this.chSeparator.getValue()),t},updateMetricUnit:function(){if(this.spinners)for(var t=0;t\n \n
    \n \n \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n \n
    \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n\n'}),define("documenteditor/main/app/view/WatermarkSettingsDialog",["text!documenteditor/main/app/template/WatermarkSettings.template","common/main/lib/util/utils","common/main/lib/component/RadioBox","common/main/lib/component/InputField","common/main/lib/view/AdvancedSettingsWindow"],function(t){"use strict";DE.Views.WatermarkText=new function(){var t;return{get:function(){return t},load:function(e){t=[],Common.Utils.loadConfig("resources/watermark/wm-text.json",function(i){for(var n in i){var o=Common.util.LanguageInfo.getLocalLanguageCode(n);o&&t.push({code:o,name:Common.util.LanguageInfo.getLocalLanguageName(o)[1],shortname:Common.util.LanguageInfo.getLocalLanguageName(o)[0],text:i[n]})}t.sort(function(t,e){return t.shortnamee.shortname?1:0}),e&&e(t)})}}},DE.Views.WatermarkSettingsDialog=Common.Views.AdvancedSettingsWindow.extend(_.extend({options:{contentWidth:400,height:442},initialize:function(e){var i=this;_.extend(this.options,{title:this.textTitle,template:_.template(['
    ','
    ','
    ',t,"
    ","
    ","
    "].join(""))({scope:this})},e),this.handler=e.handler,this.props=e.props,this.fontStore=e.fontStore,this.api=e.api,this.storage=!!e.storage,this.textControls=[],this.imageControls=[],this.fontName="Arial",this.text="",this.isAutoColor=!1,this.isImageLoaded=!1;var n=e.lang||"en",o=Common.util.LanguageInfo.getLocalLanguageCode(n);this.lang=o?{value:n,displayValue:Common.util.LanguageInfo.getLocalLanguageName(o)[1],default:!0}:{value:"en",displayValue:"English",default:!0},Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this,this.options)},render:function(){Common.Views.AdvancedSettingsWindow.prototype.render.call(this);var t=this;this.radioNone=new Common.UI.RadioBox({el:$("#watermark-radio-none"),name:"asc-radio-watermark-type",labelText:this.textNone,checked:!1}),this.radioNone.on("change",_.bind(function(t,e,i){e&&(this.props.put_Type(Asc.c_oAscWatermarkType.None),this.disableControls(Asc.c_oAscWatermarkType.None))},this)),this.radioImage=new Common.UI.RadioBox({el:$("#watermark-radio-image"),name:"asc-radio-watermark-type",labelText:this.textImageW,checked:!1}),this.radioImage.on("change",_.bind(function(t,e,i){e&&(this.props.put_Type(Asc.c_oAscWatermarkType.Image),this.disableControls(Asc.c_oAscWatermarkType.Image),this.focusControls())},this)),this.radioText=new Common.UI.RadioBox({el:$("#watermark-radio-text"),name:"asc-radio-watermark-type",labelText:this.textTextW,checked:!0}),this.radioText.on("change",_.bind(function(t,e,i){e&&(this.props.put_Type(Asc.c_oAscWatermarkType.Text),this.disableControls(Asc.c_oAscWatermarkType.Text),this.focusControls())},this)),this.btnSelectImage=new Common.UI.Button({parentEl:$("#watermark-select-image"),cls:"btn-text-menu-default",caption:this.textSelect,style:"width: 142px;",menu:new Common.UI.Menu({style:"min-width: 142px;",maxHeight:200,additionalAlign:this.menuAddAlign,items:[{caption:this.textFromFile,value:0},{caption:this.textFromUrl,value:1},{caption:this.textFromStorage,value:2}]})}),this.imageControls.push(this.btnSelectImage),this.btnSelectImage.menu.on("item:click",_.bind(this.onImageSelect,this)),this.btnSelectImage.menu.items[2].setVisible(this.storage),this._arrScale=[{displayValue:this.textAuto,value:-1},{displayValue:"500%",value:500},{displayValue:"200%",value:200},{displayValue:"150%",value:150},{displayValue:"100%",value:100},{displayValue:"50%",value:50}],this.cmbScale=new Common.UI.ComboBox({el:$("#watermark-combo-scale"),cls:"input-group-nr",menuStyle:"min-width: 142px;",data:this._arrScale,takeFocusOnClose:!0}).on("selected",_.bind(function(t,e){},this)),this.cmbScale.setValue(this._arrScale[0].value),this.imageControls.push(this.cmbScale),this.cmbLang=new Common.UI.ComboBox({el:$("#watermark-combo-lang"),cls:"input-group-nr",editable:!1,menuStyle:"min-width: 100%;max-height: 210px;",scrollAlwaysVisible:!0,data:[],takeFocusOnClose:!0}).on("selected",_.bind(this.onSelectLang,this)),this.cmbLang.setValue(Common.util.LanguageInfo.getLocalLanguageName(9)[1]),this.textControls.push(this.cmbLang),this.cmbText=new Common.UI.ComboBox({el:$("#watermark-combo-text"),cls:"input-group-nr",menuStyle:"min-width: 100%;max-height: 210px;",scrollAlwaysVisible:!0,displayField:"value",data:[{value:"ASAP"},{value:"CONFIDENTIAL"},{value:"COPY"},{value:"DO NOT COPY"},{value:"DRAFT"},{value:"ORIGINAL"},{value:"PERSONAL"},{value:"SAMPLE"},{value:"TOP SECRET"},{value:"URGENT"}],takeFocusOnClose:!0}).on("selected",_.bind(function(t,e){},this)),this.cmbText.setValue(this.cmbText.options.data[0].value),this.textControls.push(this.cmbText),this.cmbFonts=new Common.UI.ComboBoxFonts({el:$("#watermark-fonts"),cls:"input-group-nr",style:"width: 142px;",menuCls:"scrollable-menu",menuStyle:"min-width: 100%;max-height: 270px;",store:new Common.Collections.Fonts,recent:0,hint:this.tipFontName,takeFocusOnClose:!0}).on("selected",_.bind(function(t,e){this.fontName=e.name},this)),this.textControls.push(this.cmbFonts);var e=[{value:-1,displayValue:this.textAuto},{value:36,displayValue:"36"},{value:40,displayValue:"40"},{value:44,displayValue:"44"},{value:48,displayValue:"48"},{value:54,displayValue:"54"},{value:60,displayValue:"60"},{value:66,displayValue:"66"},{value:72,displayValue:"72"},{value:80,displayValue:"80"},{value:90,displayValue:"90"},{value:96,displayValue:"96"},{value:105,displayValue:"105"},{value:120,displayValue:"120"},{value:144,displayValue:"144"}];this.cmbFontSize=new Common.UI.ComboBox({el:$("#watermark-font-size"),cls:"input-group-nr",style:"width: 55px;",menuCls:"scrollable-menu",menuStyle:"min-width: 55px;max-height: 270px;",hint:this.tipFontSize,data:e,takeFocusOnClose:!0}),this.cmbFontSize.setValue(-1),this.textControls.push(this.cmbFontSize),this.btnBold=new Common.UI.Button({parentEl:$("#watermark-bold"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-bold",enableToggle:!0,hint:this.textBold}),this.textControls.push(this.btnBold),this.btnItalic=new Common.UI.Button({parentEl:$("#watermark-italic"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-italic",enableToggle:!0,hint:this.textItalic}),this.textControls.push(this.btnItalic),this.btnUnderline=new Common.UI.Button({parentEl:$("#watermark-underline"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-underline",enableToggle:!0,hint:this.textUnderline}),this.textControls.push(this.btnUnderline),this.btnStrikeout=new Common.UI.Button({parentEl:$("#watermark-strikeout"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-strikeout",enableToggle:!0,hint:this.textStrikeout}),this.textControls.push(this.btnStrikeout);this.btnTextColor=new Common.UI.Button({parentEl:$("#watermark-textcolor"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-fontcolor",hint:this.textColor,menu:new Common.UI.Menu({cls:"shifted-left",items:[{id:"watermark-auto-color",caption:this.textAuto,template:_.template('<%= caption %>')},{caption:"--"},{template:_.template('
    ')},{template:_.template(''+this.textNewColor+"")}]})}),this.mnuTextColorPicker=function(e,i){if(e&&e.cmpEl){e.currentColor="#c0c0c0";var n=$('
    ');$("button:first-child",e.cmpEl).append(n),n.css("background-color",e.currentColor);var o=new Common.UI.ThemeColorPalette({el:$(i)})}return e.menu.cmpEl.on("click",i+"-new",_.bind(function(){o.addNewColor("object"==typeof e.color?e.color.color:e.color)},t)),o.on("select",_.bind(t.onColorSelect,t)),o}(this.btnTextColor,"#watermark-menu-textcolor"),$("#watermark-auto-color").on("click",_.bind(this.onAutoColor,this)),this.textControls.push(this.btnTextColor),this.chTransparency=new Common.UI.CheckBox({el:$("#watermark-chb-transparency"),labelText:this.textTransparency,value:!0}),this.textControls.push(this.chTransparency),this.radioDiag=new Common.UI.RadioBox({el:$("#watermark-radio-diag"),name:"asc-radio-watermark-layout",labelText:this.textDiagonal,checked:!0}),this.textControls.push(this.radioDiag),this.radioHor=new Common.UI.RadioBox({el:$("#watermark-radio-hor"),name:"asc-radio-watermark-layout",labelText:this.textHor}),this.textControls.push(this.radioHor),this.btnOk=new Common.UI.Button({el:this.$window.find(".primary"),disabled:!0}),this.afterRender()},getFocusedComponents:function(){return[this.cmbLang,this.cmbText,this.cmbFonts,this.cmbFontSize,this.cmbScale]},getDefaultFocusableComponent:function(){return this.cmbLang.isDisabled()?this.cmbScale.isDisabled()?void 0:this.cmbScale:this.cmbLang},focusControls:function(){var t=this.getDefaultFocusableComponent();t&&setTimeout(function(){t.focus()},10)},onColorSelect:function(t,e){var i=this.btnTextColor.menu.$el.find("#watermark-auto-color > a");i.hasClass("selected")&&i.removeClass("selected"),this.isAutoColor=!1;var n="object"==typeof e?e.color:e;this.btnTextColor.currentColor=e,$(".btn-color-value-line",this.btnTextColor.cmpEl).css("background-color","#"+n)},updateThemeColors:function(){this.mnuTextColorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors())},addNewColor:function(t,e){t.addNewColor("object"==typeof e.color?e.color.color:e.color)},onAutoColor:function(t){var e=this.btnTextColor.menu.$el.find("#watermark-auto-color > a");!e.hasClass("selected")&&e.addClass("selected"),this.isAutoColor=!0;this.btnTextColor.currentColor="000",$(".btn-color-value-line",this.btnTextColor.cmpEl).css("background-color","#000"),this.mnuTextColorPicker.clearSelection()},afterRender:function(){this.cmbFonts.fillFonts(this.fontStore),this.cmbFonts.selectRecord(this.fontStore.findWhere({name:this.fontName})),this.updateThemeColors(),this._setDefaults(this.props);var t=this,e=function(){t.isImageLoaded=!0,t.btnOk.setDisabled(!1)};this.api.asc_registerCallback("asc_onWatermarkImageLoaded",e);var i=function(e){e&&e.url&&"watermark"==e.c&&t.props.put_ImageUrl(e.url,e.token)};Common.NotificationCenter.on("storage:image-insert",i),this.on("close",function(n){t.api.asc_unregisterCallback("asc_onWatermarkImageLoaded",e),Common.NotificationCenter.off("storage:image-insert",i)})},loadLanguages:function(){var t=this,e=!1,i=function(i){var n=[];if(t.languages=i,t.languages&&t.languages.forEach(function(t){n.push({displayValue:t.name,value:t.shortname,wmtext:t.text})}),n.length){t.cmbLang.setData(n);var o=t.loadWMText(t.lang.value);o&&t.lang.default?t.cmbLang.setValue(o):t.cmbLang.setValue(t.lang.displayValue),t.cmbLang.setDisabled(!t.radioText.getValue()),t.text&&t.cmbText.setValue(t.text)}else t.cmbLang.setDisabled(!0);e&&t.focusControls()},n=DE.Views.WatermarkText.get();e=!n,n?i(n):DE.Views.WatermarkText.load(i)},onSelectLang:function(t,e){if(e){var i=[];e.wmtext.forEach(function(t){i.push({value:t})}),this.lang=e,i.length>0&&(this.cmbText.setData(i),this.cmbText.setValue(i[0].value))}},loadWMText:function(t){if(t){var e=[],i=this.cmbLang.store.findWhere({value:t});return i||(i=this.cmbLang.store.findWhere({value:t.split(/[\-\_]/)[0]})),i||(i=this.cmbLang.store.findWhere({value:"en"})),i||(i=this.cmbLang.store.at(0)),i&&i.get("wmtext").forEach(function(t){e.push({value:t})}),e.length>0&&(this.cmbText.setData(e),this.cmbText.setValue(e[0].value)),i?i.get("displayValue"):null}},onImageSelect:function(t,e){if(1==e.value){var i=this;new Common.Views.ImageFromUrlDialog({handler:function(t,e){if("ok"==t){var n=e.replace(/ /g,"");_.isEmpty(n)||i.props.put_ImageUrl(n)}}}).show()}else 2==e.value?Common.NotificationCenter.trigger("storage:image-load","watermark"):this.props.showFileDialog()},_setDefaults:function(t){if(this.loadLanguages(),t){t.put_DivId("watermark-texture-img"),t.put_Api(this.api);var e,i=t.get_Type();if(i==Asc.c_oAscWatermarkType.None)this.radioNone.setValue(!0,!0);else if(i==Asc.c_oAscWatermarkType.Image)this.radioImage.setValue(!0,!0),this.isImageLoaded=!!t.get_ImageUrl(),e=t.get_Scale()||-1,this.cmbScale.setValue(e<0?-1:Math.round(100*e),Math.round(100*e)+" %");else{if(this.radioText.setValue(!0,!0),!t.get_IsDiagonal()&&this.radioHor.setValue(!0),this.chTransparency.setValue(t.get_Opacity()<255),e=t.get_TextPr()){var n=Common.util.LanguageInfo.getLocalLanguageName(e.get_Lang());this.lang={value:n[0],displayValue:n[1]},this.cmbLang.setValue(n[1]),this.loadWMText(n[0]);var o=e.get_FontFamily().get_Name();if(o){var s=this.cmbFonts.store.findWhere({name:o});this.fontName=s?s.get("name"):o,this.cmbFonts.setValue(this.fontName)}this.cmbFontSize.setValue(e.get_FontSize()),this.btnBold.toggle(e.get_Bold()),this.btnItalic.toggle(e.get_Italic()),this.btnUnderline.toggle(e.get_Underline()),this.btnStrikeout.toggle(e.get_Strikeout());var a=e.get_Color(),r=this.btnTextColor.menu.$el.find("#watermark-auto-color > a"),l="c0c0c0";if(a.get_auto())l="000",this.isAutoColor=!0,this.mnuTextColorPicker.clearSelection(),!r.hasClass("selected")&&r.addClass("selected");else if(r.hasClass("selected")&&r.removeClass("selected"),a&&(l=a.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?{color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b()),effectValue:a.get_value()}:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b())),"object"==typeof l){for(var c=!1,d=0;d<10;d++)if(Common.Utils.ThemeColor.ThemeValues[d]==l.effectValue){this.mnuTextColorPicker.select(l,!0),c=!0;break}c||this.mnuTextColorPicker.clearSelection()}else this.mnuTextColorPicker.select(l,!0);this.btnTextColor.currentColor=l,$(".btn-color-value-line",this.btnTextColor.cmpEl).css("background-color","#"+("object"==typeof l?l.color:l))}e=t.get_Text(),e&&this.cmbText.setValue(e),this.text=e||""}this.disableControls(i)}},getSettings:function(){var t=this.props,e=this.props.get_Type();if(e==Asc.c_oAscWatermarkType.Image)e=parseInt(this.cmbScale.getValue()),isNaN(e)&&(e=-1),t.put_Scale(e<0?e:e/100);else if(t.put_Text(this.cmbText.getValue()),t.put_IsDiagonal(this.radioDiag.getValue()),t.put_Opacity("checked"==this.chTransparency.getValue()?128:255),e=t.get_TextPr()||new Asc.CTextProp){e.put_FontSize(Math.min(this.cmbFontSize.getValue(),1638));var i=new AscCommon.asc_CTextFontFamily;i.put_Name(this.fontName),i.put_Index(-1),e.put_FontFamily(i),e.put_Bold(this.btnBold.pressed),e.put_Italic(this.btnItalic.pressed),e.put_Underline(this.btnUnderline.pressed),e.put_Strikeout(this.btnStrikeout.pressed),e.put_Lang(parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.lang.value)));var n=new Asc.asc_CColor;this.isAutoColor?n.put_auto(!0):n=Common.Utils.ThemeColor.getRgbColor(this.btnTextColor.currentColor),e.put_Color(n),t.put_TextPr(e)}return this.props},disableControls:function(t){var e=t!=Asc.c_oAscWatermarkType.Image;_.each(this.imageControls,function(t){t.setDisabled(e)}),e=t!=Asc.c_oAscWatermarkType.Text,_.each(this.textControls,function(t){t.setDisabled(e)}),this.cmbLang.setDisabled(e||!this.languages||this.languages.length<1),this.btnOk.setDisabled(t==Asc.c_oAscWatermarkType.Image&&!this.isImageLoaded)},onDlgBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(){return this._handleInput("ok"),!1},_handleInput:function(t){if(this.handler){if("ok"==t&&this.btnOk.isDisabled())return;this.handler.call(this,t,this.getSettings())}this.close()},textTitle:"Watermark Settings",textNone:"None",textImageW:"Image watermark",textTextW:"Text watermark",textFromUrl:"From URL",textFromFile:"From File",textScale:"Scale",textAuto:"Auto",textText:"Text",textFont:"Font",tipFontName:"Font Name",tipFontSize:"Font Size",textBold:"Bold",textItalic:"Italic",textUnderline:"Underline",textStrikeout:"Strikeout",textTransparency:"Semitransparent",textLayout:"Layout",textDiagonal:"Diagonal",textHor:"Horizontal",textColor:"Text color",textNewColor:"Add New Custom Color",textLanguage:"Language",textFromStorage:"From Storage",textSelect:"Select Image"},DE.Views.WatermarkSettingsDialog||{}))}),void 0===Common)var Common={};if(define("documenteditor/main/app/view/ListSettingsDialog",["common/main/lib/component/Window","common/main/lib/component/MetricSpinner","common/main/lib/component/ThemeColorPalette","common/main/lib/component/ColorButton","common/main/lib/component/ComboBox","common/main/lib/view/SymbolTableDialog"],function(){"use strict";DE.Views.ListSettingsDialog=Common.UI.Window.extend(_.extend({options:{type:0,width:300,height:422,style:"min-width: 240px;",cls:"modal-dlg",split:!1,buttons:["ok","cancel"]},initialize:function(t){this.type=t.type||0,_.extend(this.options,{title:this.txtTitle,height:2==this.type?376:422,width:2==this.type?430:300},t||{}),this.template=['
    ',"<% if (type == 2) { %>",'',"",'",'",'",'","","
    ','",'
    ',"
    ','",'
    ',"
    ','",'
    ',"
    ','",'
    ',"
    ","<% } else {%>",'',"",'",'","","",'",'","","
    ',"<% if (type == 0) { %>",'",'","<% } else { %>",'",'
    ',"<% } %>","
    ','",'
    ',"
    ','",'
    ',"
    ','",'
    ',"
    ","<% } %>",'',"",'","","","
    ","",'
    ',"
    ","
    "].join(""),this.props=t.props,this.level=t.level||0,this.api=t.api,this.options.tpl=_.template(this.template)(this.options),this.levels=[],Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();e.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.btnColor=new Common.UI.ColorButton({parentEl:e.find("#id-dlg-bullet-color"),additionalItems:[{id:"id-dlg-bullet-text-color",caption:this.txtLikeText,checkable:!0,toggleGroup:"list-settings-color",style:"padding-left: 20px;"},{id:"id-dlg-bullet-auto-color",caption:this.textAuto,checkable:!0,toggleGroup:"list-settings-color",style:"padding-left: 20px;"},{caption:"--"}],additionalAlign:this.menuAddAlign}),this.btnColor.on("color:select",_.bind(this.onColorsSelect,this)),this.btnColor.menu.items[0].on("toggle",_.bind(this.onLikeTextColor,this)),this.btnColor.menu.items[1].on("toggle",_.bind(this.onAutoColor,this)),this.colors=this.btnColor.getPicker(),this.btnEdit=new Common.UI.Button({el:e.find("#id-dlg-bullet-font")}),this.btnEdit.on("click",_.bind(this.onEditBullet,this));var i=["<% _.each(items, function(item) { %>",'
  • ','<%= item.displayValue %><% if (item.value === Asc.c_oAscNumberingFormat.Bullet) { %><%=item.symbol%><% } %>',"
  • ","<% }); %>"],n=['
    ','
    ','
    ','','","
    "]);this.cmbFormat=new Common.UI.ComboBoxCustom({el:e.find("#id-dlg-numbering-format"),menuStyle:"min-width: 100%;max-height: 183px;",style:2==this.type?"width: 107px;":"width: 129px;",editable:!1,template:_.template(n.join("")),itemsTemplate:_.template(i.join("")),takeFocusOnClose:!0,data:[{displayValue:this.txtNone,value:Asc.c_oAscNumberingFormat.None},{displayValue:"1, 2, 3,...",value:Asc.c_oAscNumberingFormat.Decimal},{displayValue:"a, b, c,...",value:Asc.c_oAscNumberingFormat.LowerLetter},{displayValue:"A, B, C,...",value:Asc.c_oAscNumberingFormat.UpperLetter},{displayValue:"i, ii, iii,...",value:Asc.c_oAscNumberingFormat.LowerRoman},{displayValue:"I, II, III,...",value:Asc.c_oAscNumberingFormat.UpperRoman}],updateFormControl:function(t){var e=$(this.el).find(".form-control");t?t.get("value")==Asc.c_oAscNumberingFormat.Bullet?e[0].innerHTML=t.get("displayValue")+''+t.get("symbol")+"":e[0].innerHTML=t.get("displayValue"):e[0].innerHTML=""}}),this.cmbFormat.on("selected",_.bind(function(e,i){if(this._changedProps)if(-1==i.value){var n=function(i){var n=t._changedProps.get_Format();if(n==Asc.c_oAscNumberingFormat.Bullet){var o=e.store -;o.findWhere({value:Asc.c_oAscNumberingFormat.Bullet,symbol:t.bulletProps.symbol,font:t.bulletProps.font})||o.add({displayValue:t.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:t.bulletProps.symbol,font:t.bulletProps.font},{at:o.length-1}),e.setData(o.models),e.selectRecord(e.store.findWhere({value:Asc.c_oAscNumberingFormat.Bullet,symbol:t.bulletProps.symbol,font:t.bulletProps.font}))}else e.setValue(n||"")};this.addNewBullet(n)}else{var o=this._changedProps.get_Format();this._changedProps.put_Format(i.value),i.value==Asc.c_oAscNumberingFormat.Bullet?(this.bulletProps.font=i.font,this.bulletProps.symbol=i.symbol,this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_FontFamily(this.bulletProps.font),this._changedProps.put_Text([new Asc.CAscNumberingLvlText]),this._changedProps.get_Text()[0].put_Value(this.bulletProps.symbol)):i.value!=Asc.c_oAscNumberingFormat.None&&o!=Asc.c_oAscNumberingFormat.Bullet||(this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_FontFamily(void 0),this._changedProps.put_Text([new Asc.CAscNumberingLvlText]),this._changedProps.get_Text()[0].put_Type(Asc.c_oAscNumberingLvlTextType.Num),this._changedProps.get_Text()[0].put_Value(this.level))}this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)},this)),this.cmbAlign=new Common.UI.ComboBox({el:e.find("#id-dlg-bullet-align"),menuStyle:"min-width: 100%;",editable:!1,cls:"input-group-nr",data:[{value:AscCommon.align_Left,displayValue:this.textLeft},{value:AscCommon.align_Center,displayValue:this.textCenter},{value:AscCommon.align_Right,displayValue:this.textRight}],takeFocusOnClose:!0}),this.cmbAlign.on("selected",_.bind(function(t,e){this._changedProps&&this._changedProps.put_Align(e.value),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)},this)),this.cmbSize=new Common.UI.ComboBox({el:e.find("#id-dlg-bullet-size"),menuStyle:"min-width: 100%;max-height: 183px;",editable:!1,cls:"input-group-nr",data:[{value:-1,displayValue:this.txtLikeText},{value:8,displayValue:"8"},{value:9,displayValue:"9"},{value:10,displayValue:"10"},{value:11,displayValue:"11"},{value:12,displayValue:"12"},{value:14,displayValue:"14"},{value:16,displayValue:"16"},{value:18,displayValue:"18"},{value:20,displayValue:"20"},{value:22,displayValue:"22"},{value:24,displayValue:"24"},{value:26,displayValue:"26"},{value:28,displayValue:"28"},{value:36,displayValue:"36"},{value:48,displayValue:"48"},{value:72,displayValue:"72"},{value:96,displayValue:"96"}],takeFocusOnClose:!0}),this.cmbSize.on("selected",_.bind(function(t,e){this._changedProps&&(this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_FontSize(e.value>0?e.value:void 0)),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)},this));for(var o=[],s=0;s<9;s++)o.push({value:s});this.levelsList=new Common.UI.ListView({el:$("#levels-list",this.$window),store:new Common.UI.DataViewStore(o),tabindex:1,itemTemplate:_.template('
    <%= (value+1) %>
    ')}),this.levelsList.on("item:select",_.bind(this.onSelectLevel,this)),this.afterRender()},getFocusedComponents:function(){return[this.cmbFormat,this.cmbAlign,this.cmbSize,{cmp:this.levelsList,selector:".listview"}]},getDefaultFocusableComponent:function(){return this.type>0?this.cmbFormat:this.cmbAlign},afterRender:function(){this.updateThemeColors(),this._setDefaults(this.props);var t=this,e=function(e){t.levelsList.selectByIndex(e)};this.api.asc_registerCallback("asc_onPreviewLevelChange",e),this.on("close",function(i){t.api.asc_unregisterCallback("asc_onPreviewLevelChange",e)})},updateThemeColors:function(){this.colors.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors())},onAutoColor:function(t,e){if(e){var i=Common.Utils.ThemeColor.getHexColor(0,0,0);if(this.btnColor.setColor(i),this.colors.clearSelection(),this._changedProps){this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr);var i=new Asc.asc_CColor;i.put_auto(!0),this._changedProps.get_TextPr().put_Color(i)}this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)}},onLikeTextColor:function(t,e){if(e){var i=Common.Utils.ThemeColor.getHexColor(255,255,255);this.btnColor.setColor(i),this.colors.clearSelection(),this._changedProps&&(this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_Color(void 0)),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)}},onColorsSelect:function(t,e){this._changedProps&&(this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_Color(Common.Utils.ThemeColor.getRgbColor(e))),this.btnColor.menu.items[0].setChecked(!1,!0),this.btnColor.menu.items[1].setChecked(!1,!0),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)},onEditBullet:function(t){this.addNewBullet()},addNewBullet:function(t){var e=this,i=e.bulletProps,n=function(n,o,s){"ok"==o&&(i.changed=!0,i.code=s.code,i.font=s.font,i.symbol=s.symbol,e._changedProps&&(e._changedProps.put_Format(Asc.c_oAscNumberingFormat.Bullet),e._changedProps.get_TextPr()||e._changedProps.put_TextPr(new AscCommonWord.CTextPr),e._changedProps.get_TextPr().put_FontFamily(i.font),e._changedProps.put_Text([new Asc.CAscNumberingLvlText]),e._changedProps.get_Text()[0].put_Value(i.symbol),e.api&&e.api.SetDrawImagePreviewBullet("bulleted-list-preview",e.props,e.level,2==e.type))),t&&t.call(e,o)},o=new Common.Views.SymbolTableDialog({api:e.options.api,lang:e.options.interfaceLang,modal:!0,type:0,font:i.font,symbol:i.symbol,handler:n});o.show(),o.on("symbol:dblclick",n)},_handleInput:function(t){if(this.options.handler){for(var e=[],i=[],n=0;n<9;n++)this.levels[n]&&(e.push(this.levels[n]),i.push(n));this.options.handler.call(this,t,{props:1==e.length?e[0]:e,num:1==i.length?i[0]:i})}this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},_setDefaults:function(t){if(this.bulletProps={},t){var e=t.get_Lvl(this.level);if(this.level<0&&(this.level=0),this.levels[this.level]=e||new Asc.CAscNumberingLvl(this.level),2==this.type){var i=this.cmbFormat.store;i.push([{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"·",font:"Symbol"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"o",font:"Courier New"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"§",font:"Wingdings"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"v",font:"Wingdings"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"Ø",font:"Wingdings"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"ü",font:"Wingdings"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"¨",font:"Symbol"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"–",font:"Arial"},{displayValue:this.txtNewBullet,value:-1}]),this.cmbFormat.setData(i.models),this.levelsList.selectByIndex(this.level)}else this.fillLevelProps(this.levels[this.level])}this._changedProps=this.levels[this.level]},onSelectLevel:function(t,e,i){this.level=i.get("value"),void 0===this.levels[this.level]&&(this.levels[this.level]=this.props.get_Lvl(this.level)),this.fillLevelProps(this.levels[this.level]),this._changedProps=this.levels[this.level]},fillLevelProps:function(t){if(t){this.cmbAlign.setValue(void 0!==t.get_Align()?t.get_Align():"");var e=t.get_Format(),i=t.get_TextPr(),n=t.get_Text();if(n&&e==Asc.c_oAscNumberingFormat.Bullet&&(this.bulletProps.symbol=n[0].get_Value()),i){this.cmbSize.setValue(i.get_FontSize()||-1),this.bulletProps.font=i.get_FontFamily();var o=i.get_Color();if(this.btnColor.menu.items[0].setChecked(void 0===o,!0),this.btnColor.menu.items[1].setChecked(!!o&&o.get_auto(),!0),o&&!o.get_auto())if("object"==typeof o){for(var s=!1,a=0;a<10;a++)if(Common.Utils.ThemeColor.ThemeValues[a]==o.effectValue){this.colors.select(o,!0),s=!0;break}s||this.colors.clearSelection(),o=Common.Utils.ThemeColor.getHexColor(o.get_r(),o.get_g(),o.get_b())}else this.colors.select(o,!0);else this.colors.clearSelection(),o=o&&o.get_auto()?"000000":"ffffff";this.btnColor.setColor(o)}this.type>0&&(e==Asc.c_oAscNumberingFormat.Bullet?(this.cmbFormat.store.findWhere({value:Asc.c_oAscNumberingFormat.Bullet,symbol:this.bulletProps.symbol,font:this.bulletProps.font})||this.cmbFormat.store.add({displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:this.bulletProps.symbol,font:this.bulletProps.font},{at:this.cmbFormat.store.length-1}),this.cmbFormat.setData(this.cmbFormat.store.models),this.cmbFormat.selectRecord(this.cmbFormat.store.findWhere({value:Asc.c_oAscNumberingFormat.Bullet,symbol:this.bulletProps.symbol,font:this.bulletProps.font}))):this.cmbFormat.setValue(void 0!==e?e:"")),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)}},txtTitle:"List Settings",txtSize:"Size",txtColor:"Color",txtBullet:"Bullet",txtFont:"Font and Symbol",txtAlign:"Alignment",textLeft:"Left",textCenter:"Center",textRight:"Right",textAuto:"Automatic",textPreview:"Preview",txtType:"Type",txtLikeText:"Like a text",textLevel:"Level",txtNone:"None",txtNewBullet:"New bullet",txtSymbol:"Symbol"},DE.Views.ListSettingsDialog||{}))}),define("documenteditor/main/app/view/DateTimeDialog",["common/main/lib/component/Window","common/main/lib/component/ComboBox","common/main/lib/component/ListView"],function(){"use strict";DE.Views.DateTimeDialog=Common.UI.Window.extend(_.extend({options:{width:350,style:"min-width: 230px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.txtTitle},t||{}),this.template=['
    ','
    ','","
    ",'
    ','
    ','","
    ",'
    ','
    ','
    ','","
    ","
    "].join(""),this.options.tpl=_.template(this.template)(this.options),this.api=this.options.api,this.lang=this.options.lang,this.handler=this.options.handler,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=[{value:1068},{value:1026},{value:1029},{value:1031},{value:2055},{value:1032},{value:3081},{value:2057},{value:1033},{value:3082},{value:2058},{value:1035},{value:1036},{value:1040},{value:1041},{value:1042},{value:1062},{value:1043},{value:1045},{value:1046},{value:2070},{value:1049},{value:1051},{value:1060},{value:2077},{value:1053},{value:1055},{value:1058},{value:1066},{value:2052}];t.forEach(function(t){var e=Common.util.LanguageInfo.getLocalLanguageName(t.value);t.displayValue=e[1],t.langName=e[0]}),this.cmbLang=new Common.UI.ComboBox({el:$("#datetime-dlg-lang"),menuStyle:"min-width: 100%; max-height: 185px;",cls:"input-group-nr",editable:!1,takeFocusOnClose:!0,data:t,search:!0,scrollAlwaysVisible:!0}),this.cmbLang.setValue(1033),this.cmbLang.on("selected",_.bind(function(t,e){this.updateFormats(e.value)},this)),this.chUpdate=new Common.UI.CheckBox({el:$("#datetime-dlg-update"),labelText:this.textUpdate}),this.chUpdate.on("change",_.bind(function(t,e,i,n){this.onSelectFormat(this.listFormats,null,this.listFormats.getSelectedRec())},this)),this.listFormats=new Common.UI.ListView({el:$("#datetime-dlg-format"),store:new Common.UI.DataViewStore,tabindex:1,scrollAlwaysVisible:!0}),this.listFormats.on("item:select",_.bind(this.onSelectFormat,this)),this.listFormats.on("item:dblclick",_.bind(this.onDblClickFormat,this)),this.listFormats.on("entervalue",_.bind(this.onPrimary,this)),this.btnDefault=new Common.UI.Button({el:$("#datetime-dlg-default")}),this.btnDefault.on("click",_.bind(function(t,e){var i=this.listFormats.getSelectedRec();Common.UI.warning({msg:Common.Utils.String.format(this.confirmDefault,Common.util.LanguageInfo.getLocalLanguageName(this.cmbLang.getValue())[1],i?i.get("value"):""),buttons:["yes","no"],primary:"yes",callback:_.bind(function(t){if("yes"==t){this.defaultFormats[this.cmbLang.getValue()]=i?i.get("format"):"";var e=[];for(var n in this.defaultFormats)n&&e.push({lang:n,format:this.defaultFormats[n]});var o=JSON.stringify(e);Common.localStorage.setItem("de-settings-datetime-default",o),Common.Utils.InternalSettings.set("de-settings-datetime-default",o)}},this)})},this)),this.$window.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.afterRender()},afterRender:function(){var t=this,e=Common.Utils.InternalSettings.get("de-settings-datetime-default"),i=e?JSON.parse(e):[];this.defaultFormats=[],i.forEach(function(e){e.lang&&(t.defaultFormats[parseInt(e.lang)]=e.format)}),this._setDefaults()},getFocusedComponents:function(){return[this.cmbLang,{cmp:this.listFormats,selector:".listview"}]},getDefaultFocusableComponent:function(){return this.cmbLang},_setDefaults:function(){if(this.props=new Asc.CAscDateTime,this.lang){var t=this.cmbLang.store.findWhere({value:this.lang});t=t?t.get("value"):1033,this.cmbLang.setValue(t)}this.updateFormats(this.cmbLang.getValue())},getSettings:function(){return this.props},updateFormats:function(t){this.props.put_Lang(t);for(var e=this.props.get_FormatsExamples(),i=[],n=this.listFormats.store,o=0,s=e.length;o','
    ','
    ','
    ','
    ','
    ',"
    ",'
    ",'
    ','
    ','
    ','
    ',"
    ',"
    ",""].join(""),this.options.tpl=_.template(this.template)(this.options),this.spinners=[],this._noApply=!1,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.chAddLineNumbering=new Common.UI.CheckBox({el:$("#line-numbers-add-line-numbering"),labelText:this.textAddLineNumbering}).on("change",_.bind(function(t,e,i,n){var o="checked"!==t.getValue();this.spnStartAt.setDisabled(o),this.spnFromText.setDisabled(o),this.spnCountBy.setDisabled(o),this.rbRestartEachPage.setDisabled(o),this.rbRestartEachSection.setDisabled(o),this.rbContinuous.setDisabled(o)},this)),this.spnStartAt=new Common.UI.MetricSpinner({el:$("#line-numbers-start-at"),step:1,width:80,defaultUnit:"",value:1,maxValue:32767,minValue:1,disabled:!0}),this.spnFromText=new Common.UI.MetricSpinner({el:$("#line-numbers-from-text"),step:.1,width:80,defaultUnit:"cm",value:"Auto",autoText:this.txtAutoText,maxValue:55.87,minValue:.1,allowAuto:!0,disabled:!0}),this.spinners.push(this.spnFromText),this.spnCountBy=new Common.UI.MetricSpinner({el:$("#line-numbers-count-by"),step:1,width:80,defaultUnit:"",value:1,maxValue:100,minValue:1,disabled:!0}),this.rbRestartEachPage=new Common.UI.RadioBox({el:$("#line-numbers-restart-each-page"),labelText:this.textRestartEachPage,name:"asc-radio-line-numbers",disabled:!0,checked:!0}),this.rbRestartEachSection=new Common.UI.RadioBox({el:$("#line-numbers-restart-each-section"),labelText:this.textRestartEachSection,name:"asc-radio-line-numbers",disabled:!0}),this.rbContinuous=new Common.UI.RadioBox({el:$("#line-numbers-continuous"),labelText:this.textContinuous,name:"asc-radio-line-numbers",disabled:!0}),this.cmbApply=new Common.UI.ComboBox({el:$("#line-numbers-combo-apply"),cls:"input-group-nr",menuStyle:"min-width: 150px;",editable:!1,data:[{displayValue:this.textSection,value:Asc.c_oAscSectionApplyType.Current},{displayValue:this.textForward,value:Asc.c_oAscSectionApplyType.ToEnd},{displayValue:this.textDocument,value:Asc.c_oAscSectionApplyType.All}]}),this.cmbApply.setValue(this.options.applyTo),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.updateMetricUnit()},afterRender:function(){},setSettings:function(t){if(t){var e=t.get_Restart();switch(this.chAddLineNumbering.setValue(!0),e){case Asc.c_oAscLineNumberRestartType.Continuous:this.rbContinuous.setValue(!0,!0);break;case Asc.c_oAscLineNumberRestartType.NewPage:this.rbRestartEachPage.setValue(!0,!0);break;case Asc.c_oAscLineNumberRestartType.NewSection:this.rbRestartEachSection.setValue(!0,!0)}this.spnStartAt.setValue(null!==t.get_Start()&&void 0!==t.get_Start()?t.get_Start():"",!0),this.spnFromText.setValue(null!==t.get_Distance()&&void 0!==t.get_Distance()?Common.Utils.Metric.fnRecalcFromMM(25.4*t.get_Distance()/20/72):-1,!0),this.spnCountBy.setValue(null!==t.get_CountBy()&&void 0!==t.get_CountBy()?t.get_CountBy():"",!0)}else this.chAddLineNumbering.setValue(!1)},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(){return this._handleInput("ok"),!1},getSettings:function(){var t;if("checked"===this.chAddLineNumbering.getValue()){t=new Asc.CSectionLnNumType,this.rbContinuous.getValue()?t.put_Restart(Asc.c_oAscLineNumberRestartType.Continuous):this.rbRestartEachPage.getValue()?t.put_Restart(Asc.c_oAscLineNumberRestartType.NewPage):this.rbRestartEachSection.getValue()&&t.put_Restart(Asc.c_oAscLineNumberRestartType.NewSection),t.put_Start(""!==this.spnStartAt.getValue()?this.spnStartAt.getNumberValue():void 0);var e=this.spnFromText.getNumberValue();t.put_Distance(e<0?null:parseInt(72*Common.Utils.Metric.fnRecalcToMM(e)*20/25.4)),t.put_CountBy(""!==this.spnCountBy.getValue()?this.spnCountBy.getNumberValue():void 0)}return{props:t,type:this.cmbApply.getValue()}},updateMetricUnit:function(){if(this.spinners)for(var t=0;t=0,!0),this.spnMaxChars.setDisabled(!e||e<0),this.spnMaxChars.setValue(e&&e>=0?e:10),e=b.get_Width(),this.spnWidth.setValue(0!==e&&void 0!==e?Common.Utils.Metric.fnRecalcFromMM(25.4*e/20/72):-1,!0)}o!=Asc.c_oAscContentControlSpecificType.CheckBox&&o!=Asc.c_oAscContentControlSpecificType.Picture||u||this.txtPlaceholder.cmpEl&&this.txtPlaceholder.cmpEl.closest("tr").hide()}},getSettings:function(){var t=new AscCommon.CContentControlPr;if(t.put_Alias(this.txtName.getValue()),t.put_Tag(this.txtTag.getValue()),t.put_PlaceholderText(this.txtPlaceholder.getValue()||" "),t.put_Appearance(this.cmbShow.getValue()),this.isSystemColor)t.put_Color(null);else{var e=Common.Utils.ThemeColor.getRgbColor(this.colors.getColor());t.put_Color(e.get_r(),e.get_g(),e.get_b())}var i=Asc.c_oAscSdtLockType.Unlocked;"checked"==this.chLockDelete.getValue()&&"checked"==this.chLockEdit.getValue()?i=Asc.c_oAscSdtLockType.SdtContentLocked:"checked"==this.chLockDelete.getValue()?i=Asc.c_oAscSdtLockType.SdtLocked:"checked"==this.chLockEdit.getValue()&&(i=Asc.c_oAscSdtLockType.ContentLocked),t.put_Lock(i);var n;if(this.type!=Asc.c_oAscContentControlSpecificType.ComboBox&&this.type!=Asc.c_oAscContentControlSpecificType.DropDownList||(n=this.type==Asc.c_oAscContentControlSpecificType.ComboBox?this.props.get_ComboBoxPr():this.props.get_DropDownListPr(),n.clear(),this.list.store.each(function(t,e){n.add_Item(t.get("name"),t.get("value"))}),this.type==Asc.c_oAscContentControlSpecificType.ComboBox?t.put_ComboBoxPr(n):t.put_DropDownListPr(n)),this.type==Asc.c_oAscContentControlSpecificType.DateTime&&(n=this.props.get_DateTimePr(),n.put_DateFormat(this.txtDate.getValue()),n.put_LangId(this.cmbLang.getValue()),t.put_DateTimePr(n)),this.type==Asc.c_oAscContentControlSpecificType.CheckBox&&(this.checkedBox&&this.checkedBox.changed||this.uncheckedBox&&this.uncheckedBox.changed)&&(n=this.props.get_CheckBoxPr(),this.checkedBox&&(n.put_CheckedSymbol(this.checkedBox.code),n.put_CheckedFont(this.checkedBox.font)),this.uncheckedBox&&(n.put_UncheckedSymbol(this.uncheckedBox.code),n.put_UncheckedFont(this.uncheckedBox.font)),t.put_CheckBoxPr(n)),this.btnsCategory[6].isVisible()){var o=new AscCommon.CSdtFormPr;o.put_Key(this.txtKey.getValue()),o.put_Label(this.txtLabel.getValue()),o.put_Required("checked"==this.chRequired.getValue()),this.isHelpChanged&&o.put_HelpText(this.textareaHelp.val()),this.type!=Asc.c_oAscContentControlSpecificType.CheckBox||this.$window.find(".group-key").hasClass("hidden")||(n=this.props.get_CheckBoxPr())&&(n.put_GroupKey(this.txtGroupKey.getValue()),t.put_CheckBoxPr(n)),t.put_FormPr(o)}if(this.btnsCategory[5].isVisible()){var s=new AscCommon.CSdtTextFormPr;if(this.spnWidth.getValue()){var a=this.spnWidth.getNumberValue();s.put_Width(a<=0?0:parseInt(72*Common.Utils.Metric.fnRecalcToMM(a)*20/25.4))}else s.put_Width(0);this.placeholder&&this.placeholder.changed&&(s.put_PlaceHolderSymbol(this.placeholder.code),s.put_PlaceHolderFont(this.placeholder.font)),s.put_Comb("checked"==this.chComb.getValue());var r="checked"==this.chMaxChars.getValue()||"checked"==this.chComb.getValue();s.put_MaxCharacters(r),r&&s.put_MaxCharacters(this.spnMaxChars.getNumberValue()||10),t.put_TextFormPr(s)}return t},onDlgBtnClick:function(t){var e="object"==typeof t?t.currentTarget.attributes.result.value:t;"ok"==e&&this.handler&&this.handler.call(this,e,this.getSettings()),this.close()},applyAllClick:function(t,e){if(this.api){var i=new AscCommon.CContentControlPr;if(i.put_Appearance(this.cmbShow.getValue()),this.isSystemColor)i.put_Color(null);else{var n=Common.Utils.ThemeColor.getRgbColor(this.colors.getColor());i.put_Color(n.get_r(),n.get_g(),n.get_b())}this.api.asc_SetContentControlProperties(i,null,!0)}},onSelectItem:function(t,e,i){this.disableListButtons(!1)},disableListButtons:function(t){void 0===t&&(t=!this.list.getSelectedRec()),this.btnChange.setDisabled(t),this.btnDelete.setDisabled(t),this.btnUp.setDisabled(t),this.btnDown.setDisabled(t)},onAddItem:function(){var t=this;new DE.Views.EditListItemDialog({store:t.list.store,handler:function(e,i,n){if("ok"==e){var o=t.list.store.add({value:n,name:i});o&&(t.list.selectRecord(o),t.list.scrollToRecord(o),t.disableListButtons())}t.list.focus()}}).show()},onChangeItem:function(){var t=this,e=this.list.getSelectedRec(),i=new DE.Views.EditListItemDialog({store:t.list.store,handler:function(i,n,o){"ok"==i&&e&&e.set({value:o,name:n}),t.list.focus()}});e&&i.show(),e&&i.setSettings({name:e.get("name"),value:e.get("value")})},onDeleteItem:function(t,e){var i=this.list.getSelectedRec();if(i){var n=this.list.store,o=_.indexOf(n.models,i);n.remove(i),o>n.length-1&&(o=n.length-1),n.length>0&&(this.list.selectByIndex(o),this.list.scrollToRecord(n.at(o)))}this.disableListButtons(),this.list.focus()},onMoveItem:function(t){var e=this.list.store,i=e.length,n=this.list.getSelectedRec();if(n){var o=e.indexOf(n);e.add(e.remove(n),{at:t?Math.max(0,o-1):Math.min(i-1,o+1)}),this.list.selectRecord(n),this.list.scrollToRecord(n)}this.list.focus()},updateFormats:function(t){if(this.datetime){for(var e=this.datetime,i=e.get_FormatsExamples(),n=[],o=0,s=i.length;o','
    ','
    ',"
    ",""].join(""),this.options.tpl=_.template(this.template)(this.options),this.props=this.options.props,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.spnStart=new Common.UI.CustomSpinner({el:$("#id-spin-set-value"),step:1,width:182,defaultUnit:"",value:1,maxValue:16383,minValue:0,allowDecimal:!1,maskExp:/[0-9]/}),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.spnStart.on("entervalue",_.bind(this.onPrimary,this)),this.spnStart.$el.find("input").focus(),this.afterRender()},afterRender:function(){this._setDefaults(this.props)},_setDefaults:function(t){t&&(this.spnStart.setValue(t.start),this.onFormatSelect(t.format))},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,t,this.getSettings()),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},getSettings:function(){return this.spnStart.getNumberValue()},onPrimary:function(){return this._handleInput("ok"),!1},onFormatSelect:function(t){var e=/[0-9]/,i=this;switch(t){case Asc.c_oAscNumberingFormat.UpperRoman:this.spnStart.options.toCustomFormat=this._10toRome,this.spnStart.options.fromCustomFormat=this._Rometo10,e=/[IVXLCDM]/;break;case Asc.c_oAscNumberingFormat.LowerRoman:this.spnStart.options.toCustomFormat=function(t){return i._10toRome(t).toLocaleLowerCase()},this.spnStart.options.fromCustomFormat=function(t){return i._Rometo10(t.toLocaleUpperCase())},e=/[ivxlcdm]/;break;case Asc.c_oAscNumberingFormat.UpperLetter:this.spnStart.options.toCustomFormat=this._10toS,this.spnStart.options.fromCustomFormat=this._Sto10,e=/[A-Z]/;break;case Asc.c_oAscNumberingFormat.LowerLetter:this.spnStart.options.toCustomFormat=function(t){return i._10toS(t).toLocaleLowerCase()},this.spnStart.options.fromCustomFormat=function(t){return i._Sto10(t.toLocaleUpperCase())},e=/[a-z]/;break;default:this.spnStart.options.toCustomFormat=function(t){return t},this.spnStart.options.fromCustomFormat=function(t){return t}}this.spnStart.setMask(e),this.spnStart.setValue(this.spnStart.getValue())},_10toS:function(t){t=parseInt(t);for(var e=Math.ceil(t/26),i=String.fromCharCode((t-1)%26+"A".charCodeAt(0)),n="",o=0;o0;)n=i[s][1],o=t-n,o>=0?(e+=i[s][0],t=o):s++;return e},_Rometo10:function(t){if(!/[IVXLCDM]/.test(t)||t.length<1)return 1;for(var e={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3},i=t.length-1,n=e[t.charAt(i)],o=n,s=i-1;s>=0;s--){var a=e[t.charAt(s)];if(a10)return 1;a*=-1}n+=a,o=Math.abs(a)}return n}},DE.Views.NumberingValueDialog||{}))}),define("documenteditor/main/app/view/CellsAddDialog",["common/main/lib/component/Window","common/main/lib/component/ComboBox","common/main/lib/component/MetricSpinner","common/main/lib/component/RadioBox"],function(){"use strict";DE.Views.CellsAddDialog=Common.UI.Window.extend(_.extend({options:{width:214,header:!0,style:"min-width: 214px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
    ','
    ','
    ','
    ',"
    ",'
    ','
    ',"
    "].join(""),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.cmbRowCol=new Common.UI.ComboBox({el:$("#table-combo-row-col"),cls:"input-group-nr",style:"width: 110px;",menuStyle:"min-width: 110px;",editable:!1,takeFocusOnClose:!0,scrollAlwaysVisible:!0,data:[{value:0,displayValue:this.textRow},{value:1,displayValue:this.textCol}]}),this.cmbRowCol.setValue(0),this.cmbRowCol.on("selected",_.bind(function(t,e){var i=0==e.value;this.spnCount.setMaxValue(i?100:64),this.spnCount.setValue(this.spnCount.getNumberValue()),this.radioBefore.setCaption(i?this.textUp:this.textLeft),this.radioAfter.setCaption(i?this.textDown:this.textRight)},this)),this.spnCount=new Common.UI.MetricSpinner({el:$("#table-spin-row-col"),step:1,width:65,value:1,defaultUnit:"",maxValue:100,minValue:1,allowDecimal:!1}),this.radioBefore=new Common.UI.RadioBox({el:$("#table-radio-before"),labelText:this.textUp,name:"asc-radio-table-cells-add",checked:!0}),this.radioAfter=new Common.UI.RadioBox({el:$("#table-radio-after"),labelText:this.textDown,name:"asc-radio-table-cells-add"}),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this))},getFocusedComponents:function(){return[this.cmbRowCol,this.spnCount]},getDefaultFocusableComponent:function(){return this.spnCount},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,t,this.getSettings()),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},getSettings:function(){return{row:0==this.cmbRowCol.getValue(),before:this.radioBefore.getValue(),count:this.spnCount.getNumberValue()}},onPrimary:function(){return this._handleInput("ok"),!1},textTitle:"Insert Several",textLeft:"To the left",textRight:"To the right",textUp:"Above the cursor",textDown:"Below the cursor",textRow:"Rows",textCol:"Columns"},DE.Views.CellsAddDialog||{}))}),define("documenteditor/main/app/view/DocumentHolder",["jquery","underscore","backbone","gateway","common/main/lib/util/utils","common/main/lib/component/Menu","common/main/lib/component/Calendar","common/main/lib/view/InsertTableDialog","common/main/lib/view/CopyWarningDialog","common/main/lib/view/OptionsDialog","documenteditor/main/app/view/DropcapSettingsAdvanced","documenteditor/main/app/view/HyperlinkSettingsDialog","documenteditor/main/app/view/ParagraphSettingsAdvanced","documenteditor/main/app/view/TableSettingsAdvanced","documenteditor/main/app/view/ControlSettingsDialog","documenteditor/main/app/view/NumberingValueDialog","documenteditor/main/app/view/CellsAddDialog"],function(t,e,i,n){"use strict";DE.Views.DocumentHolder=i.View.extend(e.extend({el:"#editor_sdk",template:null,events:{},initialize:function(){var i=this,n=DE.getCollection("Common.Collections.Users");i._TtHeight=20,i._currentSpellObj=void 0,i._currLang={},i.usertips=[],i.fastcoauthtips=[],i._currentMathObj=void 0,i._currentParaObjDisabled=!1,i._isDisabled=!1,i._state={};var o=function(n,o,s,a,r){if(!e.isUndefined(n)&&null!==n){Common.UI.Menu.Manager.hideAll();var l=[s.get_X(),s.get_Y()],c=t(i.el).find(Common.Utils.String.format("#menu-container-{0}",n.id));n.rendered||(c.length<1&&(c=t(Common.Utils.String.format('',n.id)),t(i.el).append(c)),n.render(c),n.cmpEl.attr({tabindex:"-1"})),c.css({left:l[0],top:l[1]}),n.show(),e.isFunction(n.options.initMenu)&&(n.options.initMenu(o),n.alignPosition()),e.delay(function(){n.cmpEl.focus()},10),i.currentMenu=n}},s=function(t){if(t&&e.isArray(t)){for(var n={},o=i.textMenu,s=!0,a=0;a0&&i.api.zoomIn(),t.preventDefault(),t.stopPropagation())}},h=function(e){if(i.api){var n=e.keyCode;if((e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey){if(n===Common.UI.Keys.NUM_PLUS||n===Common.UI.Keys.EQUALITY||Common.Utils.isGecko&&n===Common.UI.Keys.EQUALITY_FF||Common.Utils.isOpera&&43==n)return i.api.zoomIn(),e.preventDefault(),e.stopPropagation(),!1;if(n===Common.UI.Keys.NUM_MINUS||n===Common.UI.Keys.MINUS||Common.Utils.isGecko&&n===Common.UI.Keys.MINUS_FF||Common.Utils.isOpera&&45==n)return i.api.zoomOut(),e.preventDefault(),e.stopPropagation(),!1;if(48===n||96===n)return i.api.zoom(100),e.preventDefault(),e.stopPropagation(),!1}i.currentMenu&&i.currentMenu.isVisible()&&(n!=Common.UI.Keys.UP&&n!=Common.UI.Keys.DOWN||t("ul.dropdown-menu",i.currentMenu.el).focus()),n==Common.UI.Keys.ESC&&(Common.UI.Menu.Manager.hideAll(),Common.NotificationCenter.trigger("leftmenu:change","hide"))}},p=function(e){i._XY=[i.cmpEl.offset().left-t(window).scrollLeft(),i.cmpEl.offset().top-t(window).scrollTop()],i._Height=i.cmpEl.height(),i._BodyWidth=t("body").width()},m=function(e){var n=i.cmpEl;if(n){n.on("contextmenu",function(t){return t.preventDefault(),t.stopPropagation(),!1}),n.on("click",function(t){"canvas"==t.target.localName&&(i._preventClick?i._preventClick=!1:n.focus())}),n.on("mousedown",function(t){"canvas"==t.target.localName&&Common.UI.Menu.Manager.hideAll()});var o=/Firefox/i.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel";!function(t,e,i){t.addEventListener?t.addEventListener(e,i,!1):t.attachEvent("on"+e,i)}(i.el,o,d)}t(document).on("mousewheel",d),t(document).on("keydown",h),t(window).on("resize",p),DE.getController("Viewport").getView("Viewport").hlayout.on("layout:resizedrag",p)},u=function(t){if(n){var e=n.findUser(t);if(e)return Common.Utils.UserInfoParser.getParsedName(e.get("username"));if("string"==typeof t){var o,s=t.slice(0,-1);if(n.models.some(function(t){if(t.attributes&&t.attributes.idOriginal===s)return o=t,!0}),o&&o.attributes.username)return o.attributes.username}}return i.guestText},g={toolTip:new Common.UI.Tooltip({owner:this,html:!0,title:"
    Press Ctrl and click link",cls:"link-tooltip"}),strTip:"",isHidden:!0,isVisible:!1},b=!0,f=function(t,e,n){!0===b&&(b=new Common.UI.Tooltip({owner:t.currentTarget,title:i.tipIsLocked}),b.show())},C=function(){if("object"==typeof b){b.hide(),b=void 0;for(var t=0;t0&&("object"==typeof b&&(b.hide(),b=!0),e.each(i.usertips,function(t){t.remove()})),i.usertips=[],i.usertipcount=0},w=null,x=!1,S=function(){g.isHidden&&g.isVisible&&(g.isVisible=!1,x=!0,g.toolTip.hide(function(){x=!1,w&&A(w),w=null}))},A=function(n){if(void 0===i._XY&&(i._XY=[i.cmpEl.offset().left-t(window).scrollLeft(),i.cmpEl.offset().top-t(window).scrollTop()],i._Height=i.cmpEl.height(),i._BodyWidth=t("body").width()),n){var o,s,a=n.get_Type();if(a==Asc.c_oAscMouseMoveDataTypes.Hyperlink||a==Asc.c_oAscMouseMoveDataTypes.Footnote||a==Asc.c_oAscMouseMoveDataTypes.Form){if(x)return void(w=n);if(a==Asc.c_oAscMouseMoveDataTypes.Hyperlink){var r=n.get_Hyperlink();if(!r)return;s=e.isEmpty(r.get_ToolTip())?r.get_Value():r.get_ToolTip()}else a==Asc.c_oAscMouseMoveDataTypes.Footnote?(s=n.get_FootnoteText(),s.length>1e3&&(s=s.substr(0,1e3)+"...")):a==Asc.c_oAscMouseMoveDataTypes.Form&&(s=n.get_FormHelpText(),s.length>1e3&&(s=s.substr(0,1e3)+"..."));var l=!1;g.isHidden=!1,s=Common.Utils.String.htmlEncode(s),(g.tipType!==a||g.tipLength!==s.length||g.strTip.indexOf(s)<0)&&(g.toolTip.setTitle(a==Asc.c_oAscMouseMoveDataTypes.Hyperlink?s+"
    "+i.txtPressLink+"":s),g.tipLength=s.length,g.strTip=s,g.tipType=a,l=!0),o=[n.get_X(),n.get_Y()],o[1]+=i._XY[1]-15,o[0]+=i._XY[0]+5,g.isVisible&&!l||(g.isVisible=!0,g.toolTip.show([-1e4,-1e4])),l&&(g.tipHeight=g.toolTip.getBSTip().$tip.height(),g.tipWidth=g.toolTip.getBSTip().$tip.width()),l=!1,o[0]+g.tipWidth>i._BodyWidth&&(o[0]=i._BodyWidth-g.tipWidth,l=!0),o[1]-g.tipHeight<0?o[1]=l?o[1]+30:0:o[1]-=g.tipHeight,g.toolTip.getBSTip().$tip.css({top:o[1]+"px",left:o[0]+"px"})}else if(n.get_Type()==Asc.c_oAscMouseMoveDataTypes.LockedObject&&i.mode.isEdit){var c;i.usertipcount>=i.usertips.length&&(c=t(document.createElement("div")),c.addClass("username-tip"),c.css({height:i._TtHeight+"px",position:"absolute",zIndex:"900",visibility:"visible"}),t(document.body).append(c),b&&(c.on("mouseover",f),c.on("mouseout",v)),i.usertips.push(c)),c=i.usertips[i.usertipcount],i.usertipcount++,s=u(n.get_UserId()),o=[n.get_X()+i._XY[0],n.get_Y()+i._XY[1]];var d=o[0];o[0]=i._BodyWidth-o[0],o[1]-=2==n.get_LockedObjectType()?i._TtHeight:0,o[1]>i._XY[1]&&o[1]+i._TtHeight
    '),i.cmpEl.append(s),i.btnSpecialPaste=new Common.UI.Button({parentEl:t("#id-document-holder-btn-special-paste"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-paste",menu:new Common.UI.Menu({items:[]})})),a.length>0){for(var r=i.btnSpecialPaste.menu,l=0;l0&&r.items[0].setChecked(!0,!0)}if(o.asc_getX()<0||o.asc_getY()<0)s.is(":visible")&&s.hide();else{var c=[o.asc_getX()+o.asc_getWidth()+3,o.asc_getY()+o.asc_getHeight()+3];s.css({left:c[0],top:c[1]}),s.show()}}},P=function(){var t=i.cmpEl.find("#special-paste-container");t.is(":visible")&&t.hide()},M=function(){var t,n,o;if(i.api&&i.mode.isEdit&&!i._isDisabled&&!DE.getController("LeftMenu").leftMenu.menuFile.isVisible()){var s=function(t,e){"ok"==e&&(n=t.getSettings(),!1!==o?i.api.add_Hyperlink(n):i.api.change_Hyperlink(n)),i.fireEvent("editcomplete",i)};if(!1!==(o=i.api.can_AddHyperlink()))t=new DE.Views.HyperlinkSettingsDialog({api:i.api,handler:s}),n=new Asc.CHyperlinkProperty,n.put_Text(o),t.show(),t.setSettings(n);else{var a=i.api.getSelectedElements();a&&e.isArray(a)&&e.each(a,function(t,e){a[e].get_ObjectType()==Asc.c_oAscTypeSelectElement.Hyperlink&&(n=a[e].get_ObjectValue())}),n&&(t=new DE.Views.HyperlinkSettingsDialog({api:i.api,handler:s}),t.show(),t.setSettings(n))}Common.component.Analytics.trackEvent("DocumentHolder","Add Hyperlink")}},E=function(t){if(i.mode.isEdit&&!i._isDisabled){var e=DE.getController("Common.Controllers.ExternalDiagramEditor").getView("Common.Views.ExternalDiagramEditor");e&&t&&(e.setEditMode(!0),e.show(),e.setChartData(new Asc.asc_CChartBinary(t)))}},U=function(){i.mode.isEdit=!1},V=function(t){i._currLang.id=t};this.changeLanguageMenu=function(t){if(null===i._currLang.id||void 0===i._currLang.id)t.clearAll();else{var n=e.findIndex(t.items,{langid:i._currLang.id});n>-1&&!t.items[n].checked&&t.setChecked(n,!0)}};var B=function(){var t,n=i.api.getSelectedElements(!0);if(n&&e.isArray(n))for(var o=0;o0?(n.setVisible(r.length>3),n.setDisabled(i._currentParaObjDisabled),e.each(r,function(t,e){var n=new Common.UI.MenuItem({caption:t,spellword:!0,disabled:i._currentParaObjDisabled}).on("click",function(t,e){i.api&&(i.api.asc_replaceMisspelledWord(t.caption,i._currentSpellObj),i.fireEvent("editcomplete",i))});e<3?s.push(n):a.push(n)}),s.length>0&&(t?e.each(s,function(t,e){i.textMenu.insertItem(e,t)}):e.each(s,function(t,e){i.menuSpellCheckTable.menu.insertItem(e,t)})),a.length>0&&e.each(a,function(t,e){n.menu.addItem(t)}),o.setVisible(!1)):(n.setVisible(!1),o.setVisible(!0),o.setCaption(i.noSpellVariantsText,!0))}},this.clearWordVariants=function(t){for(var e=t?i.textMenu:i.menuSpellCheckTable.menu,n=0;n0&&e.each(s,function(t,s){t.menu?e.each(t.menu.items,function(t){t.on("click",e.bind(i.equationCallback,i,t.options.equationProps))}):t.on("click",e.bind(i.equationCallback,i,t.options.equationProps)),o.insertItem(n,t),n++}),s.length},this.clearEquationMenu=function(t,n){for(var o=t?i.textMenu:i.tableMenu,s=n;s=0;r--){var l,c;if(l=a[r].get_ObjectType(),c=a[r].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Paragraph==l){o=new DE.Views.ParagraphSettingsAdvanced({tableStylerRows:2,tableStylerColumns:1,paragraphProps:c,borderProps:s.borderAdvancedProps,isChart:!0===t.isChart,api:s.api,handler:function(t,e){"ok"==t&&s.api&&(s.borderAdvancedProps=e.borderProps,s.api.paraApply(e.paragraphProps)),s.fireEvent("editcomplete",s)}});break}}}if(o)return o.show(),o},advancedFrameClick:function(t,e,i,n){Common.NotificationCenter.trigger("dropcap:settings",t)},advancedTableClick:function(t,i,n){var o,s=this;if(s.api){var a=s.api.getSelectedElements();if(a&&e.isArray(a))for(var r=a.length-1;r>=0;r--){var l,c;if(l=a[r].get_ObjectType(),c=a[r].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Table==l){o=new DE.Views.TableSettingsAdvanced({tableStylerRows:null===c.get_CellBorders().get_InsideH()&&1==c.get_CellSelect()?1:2,tableStylerColumns:null===c.get_CellBorders().get_InsideV()&&1==c.get_CellSelect()?1:2,tableProps:c,borderProps:s.borderAdvancedProps,sectionProps:s.api.asc_GetSectionProps(),handler:function(t,e){"ok"==t&&s.api&&(s.borderAdvancedProps=e.borderProps,s.api.tblApply(e.tableProps)),s.fireEvent("editcomplete",s)}});break}}}if(o)return o.show(),o},onRulerDblClick:function(e){Common.UI.Menu.Manager.hideAll();var i,n=this;if("tables"==e)(i=this.advancedTableClick())&&i.setActiveCategory(4);else if("indents"==e||"tabs"==e)(i=this.advancedParagraphClick({isChart:!1}))&&i.setActiveCategory("indents"==e?0:3);else if("margins"==e){if(n._state.lock_doc)return;i=new DE.Views.PageMarginsDialog({api:n.api,handler:function(e,i){if("ok"==i){var o=e.getSettings(),s=DE.getController("Toolbar").toolbar.btnPageMargins.menu.items[0];s.setVisible(!0),s.setChecked(!0),s.options.value=s.value=[o.get_TopMargin(),o.get_LeftMargin(),o.get_BottomMargin(),o.get_RightMargin()],t(s.el).html(s.template({id:Common.UI.getId(),caption:s.caption,options:s.options})),Common.localStorage.setItem("de-pgmargins-top",o.get_TopMargin()),Common.localStorage.setItem("de-pgmargins-left",o.get_LeftMargin()),Common.localStorage.setItem("de-pgmargins-bottom",o.get_BottomMargin()),Common.localStorage.setItem("de-pgmargins-right",o.get_RightMargin()),n.api.asc_SetSectionProps(o),n.fireEvent("editcomplete",n)}}}),i.show(),i.setSettings(n.api.asc_GetSectionProps())}else"columns"==e&&(i=new DE.Views.CustomColumnsDialog({handler:function(t,e){"ok"==e&&(n.api.asc_SetColumnsProps(t.getSettings()),n.fireEvent("editcomplete",n))}}),i.show(),i.setSettings(n.api.asc_GetColumnsProps()))},editHyperlink:function(t,e,i){var n,o=this;o.api&&(n=new DE.Views.HyperlinkSettingsDialog({api:o.api,handler:function(t,e){"ok"==e&&o.api.change_Hyperlink(n.getSettings()),o.fireEvent("editcomplete",o)}}),n.show(),n.setSettings(t.hyperProps.value))},onMenuSaveStyle:function(t,e,i){var n=this;n.api&&Common.NotificationCenter.trigger("style:commitsave",n.api.asc_GetStyleFromFormatting())},onMenuUpdateStyle:function(t,e,i){var n=this;n.api&&Common.NotificationCenter.trigger("style:commitchange",n.api.asc_GetStyleFromFormatting())},addComment:function(t,e,i){if(this.api&&this.mode.canCoAuthoring&&this.mode.canComments){this.suppressEditComplete=!0;var n=DE.getController("Common.Controllers.Comments");n&&n.addDummyComment()}},addHyperlink:function(t,e,i){var n,o=this;o.api&&(n=new DE.Views.HyperlinkSettingsDialog({api:o.api,handler:function(t,e){"ok"==e&&o.api.add_Hyperlink(t.getSettings()),o.fireEvent("editcomplete",o)}}),n.show(),n.setSettings(t.hyperProps.value),Common.component.Analytics.trackEvent("DocumentHolder","Add Hyperlink"))},editChartClick:function(){var t=DE.getController("Common.Controllers.ExternalDiagramEditor").getView("Common.Views.ExternalDiagramEditor");if(t){t.setEditMode(!0),t.show();var e=this.api.asc_getChartObject();e&&t.setChartData(new Asc.asc_CChartBinary(e))}},onCutCopyPaste:function(t,e){var i=this;if(i.api){("cut"==t.value?i.api.Cut():"copy"==t.value?i.api.Copy():i.api.Paste())||Common.localStorage.getBool("de-hide-copywarning")||new Common.Views.CopyWarningDialog({handler:function(t){t&&Common.localStorage.setItem("de-hide-copywarning",1),i.fireEvent("editcomplete",i)}}).show()}i.fireEvent("editcomplete",i)},onPrintSelection:function(t){if(this.api){var e=new Asc.asc_CAdjustPrint;e.asc_setPrintType(Asc.c_oAscPrintType.Selection);var i=new Asc.asc_CDownloadOptions(null,Common.Utils.isChrome||Common.Utils.isSafari||Common.Utils.isOpera);i.asc_setAdvancedOptions(e),this.api.asc_Print(i),this.fireEvent("editcomplete",this),Common.component.Analytics.trackEvent("DocumentHolder","Print Selection")}},onControlsSelect:function(t,e){var i=this,n=this.api.asc_GetContentControlProperties();n&&("settings"==t.value?new DE.Views.ControlSettingsDialog({props:n,api:i.api,handler:function(t,e){"ok"==t&&i.api.asc_SetContentControlProperties(e,n.get_InternalId()),i.fireEvent("editcomplete",i)}}).show():"remove"==t.value&&(n.get_FormPr()?this.api.asc_RemoveContentControl(n.get_InternalId()):this.api.asc_RemoveContentControlWrapper(n.get_InternalId()))),i.fireEvent("editcomplete",i)},onInsertCaption:function(){var t=this;new DE.Views.CaptionDialog({isObject:!0,handler:function(e,i){"ok"==e&&t.api.asc_AddObjectCaption(i),t.fireEvent("editcomplete",t)}}).show()},onContinueNumbering:function(t,e){this.api.asc_ContinueNumbering(),this.fireEvent("editcomplete",this)},onStartNumbering:function(t,e,i){if(1==t)this.api.asc_RestartNumbering(e.value.start);else{var n=this;new DE.Views.NumberingValueDialog({title:n.textNumberingValue,props:e.value,handler:function(t,e){"ok"==t&&n.api.asc_RestartNumbering(e),n.fireEvent("editcomplete",n)}}).show()}this.fireEvent("editcomplete",this)},onCellsRemove:function(){var t=this;new Common.Views.OptionsDialog({title:t.textTitleCellsRemove,items:[{caption:this.textLeft,value:"left"},{caption:this.textRow,value:"row"},{caption:this.textCol,value:"col"}],handler:function(e,i){if("ok"==i){var n=e.getSettings();"row"==n?t.api.remRow():"col"==n?t.api.remColumn():t.api.asc_RemoveTableCells()}t.fireEvent("editcomplete",t)}}).show(),this.fireEvent("editcomplete",this)},onCellsAdd:function(){var t=this;new DE.Views.CellsAddDialog({handler:function(e,i){"ok"==e&&(i.row?i.before?t.api.addRowAbove(i.count):t.api.addRowBelow(i.count):i.before?t.api.addColumnLeft(i.count):t.api.addColumnRight(i.count)),t.fireEvent("editcomplete",t)}}).show(),this.fireEvent("editcomplete",this)},createDelayedElementsViewer:function(){var t=this,i=new Common.UI.MenuItem({iconCls:"menu__icon btn-copy",caption:t.textCopy,value:"copy"}).on("click",e.bind(t.onCutCopyPaste,t)),n=new Common.UI.MenuItem({iconCls:"menu__icon btn-undo",caption:t.textUndo}).on("click",function(){t.api.Undo()}),o=new Common.UI.MenuItem({caption:"--"}),s=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-comments",caption:t.addCommentText}).on("click",e.bind(t.addComment,t)),a=new Common.UI.MenuItem({caption:this.strSign,value:0}).on("click",e.bind(t.onSignatureClick,t)),r=new Common.UI.MenuItem({caption:this.strDetails,value:1}).on("click",e.bind(t.onSignatureClick,t)),l=new Common.UI.MenuItem({caption:this.strSetup,value:2}).on("click",e.bind(t.onSignatureClick,t)),c=new Common.UI.MenuItem({caption:this.strDelete,value:3}).on("click",e.bind(t.onSignatureClick,t)),d=new Common.UI.MenuItem({caption:"--"}),h=new Common.UI.MenuItem({iconCls:"menu__icon btn-print",caption:t.txtPrintSelection}).on("click",e.bind(t.onPrintSelection,t));this.viewModeMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(p){var m=p.imgProps&&p.imgProps.value&&!e.isNull(p.imgProps.value.get_ChartProperties()),u=p.imgProps&&p.imgProps.value&&!e.isNull(p.imgProps.value.get_ShapeProperties()),g=p.imgProps&&p.imgProps.value&&t.mode.isSignatureSupport?p.imgProps.value.asc_getSignatureId():void 0,b=g?t.api.asc_getSignatureSetup(g):null,f=!!b&&t._canProtect,C=!!p.paraProps&&!(p.paraProps.value.can_DeleteBlockContentControl()&&p.paraProps.value.can_EditBlockContentControl()&&p.paraProps.value.can_DeleteInlineContentControl()&&p.paraProps.value.can_EditInlineContentControl()),v=!m&&!1!==t.api.can_AddQuotedComment()&&t.mode.canCoAuthoring&&t.mode.canComments&&!t._isDisabled&&!C;if(t.mode.compatibleFeatures&&(v=v&&!u),t.api.asc_IsContentControl()){var _=t.api.asc_GetContentControlProperties(),y=_?_.get_SpecificType():Asc.c_oAscContentControlSpecificType.None;v=v&&!(y==Asc.c_oAscContentControlSpecificType.CheckBox||y==Asc.c_oAscContentControlSpecificType.Picture||y==Asc.c_oAscContentControlSpecificType.ComboBox||y==Asc.c_oAscContentControlSpecificType.DropDownList||y==Asc.c_oAscContentControlSpecificType.DateTime)}n.setVisible(t.mode.canCoAuthoring&&t.mode.canComments&&!t._isDisabled),n.setDisabled(!t.api.asc_getCanUndo()&&!t._isDisabled),o.setVisible(f);var w=!!b&&b.asc_getRequested();a.setVisible(f&&w),r.setVisible(f&&!w),l.setVisible(f),c.setVisible(f&&!w),d.setVisible(v),f&&(a.cmpEl.attr("data-value",g),r.cmpEl.attr("data-value",b.asc_getId()),l.cmpEl.attr("data-value",g),c.cmpEl.attr("data-value",g)),s.setVisible(v),s.setDisabled(p.paraProps&&!0===p.paraProps.locked);var x=t.api&&t.api.can_CopyCut();i.setDisabled(!x),h.setVisible(t.mode.canPrint),h.setDisabled(!x)},items:[i,n,h,o,a,r,l,c,d,s]}).on("hide:after",function(e,i,n){if(t.suppressEditComplete)return void(t.suppressEditComplete=!1);n||t.fireEvent("editcomplete",t),t.currentMenu=null})},createDelayedElements:function(){var i=this,n=new Common.UI.MenuItem({caption:i.txtInsertCaption}).on("click",e.bind(i.onInsertCaption,i)),o=new Common.UI.MenuItem({caption:"--"}),s=new Common.UI.MenuItem({caption:i.txtInsertCaption}).on("click",e.bind(i.onInsertCaption,i)),a=new Common.UI.MenuItem({caption:"--"}),r=new Common.UI.MenuItem({caption:i.textAlign,menu:function(){function t(t,e){if(i.api){var n=Common.Utils.InternalSettings.get("de-img-align-to"),o=1==n?Asc.c_oAscObjectsAlignType.Page:i.api.asc_getSelectedDrawingObjectsCount()<2&&!n||2==n?Asc.c_oAscObjectsAlignType.Margin:Asc.c_oAscObjectsAlignType.Selected;t.value<6?(i.api.put_ShapesAlign(t.value,o),Common.component.Analytics.trackEvent("DocumentHolder","Shape Align")):6==t.value?(i.api.DistributeHorizontally(o),Common.component.Analytics.trackEvent("DocumentHolder","Distribute Horizontally")):7==t.value&&(i.api.DistributeVertically(o),Common.component.Analytics.trackEvent("DocumentHolder","Distribute Vertically"))}i.fireEvent("editcomplete",i)}return new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.textShapeAlignLeft,iconCls:"menu__icon shape-align-left",value:Asc.c_oAscAlignShapeType.ALIGN_LEFT}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignCenter,iconCls:"menu__icon shape-align-center",value:Asc.c_oAscAlignShapeType.ALIGN_CENTER}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignRight,iconCls:"menu__icon shape-align-right",value:Asc.c_oAscAlignShapeType.ALIGN_RIGHT}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignTop,iconCls:"menu__icon shape-align-top",value:Asc.c_oAscAlignShapeType.ALIGN_TOP}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignMiddle,iconCls:"menu__icon shape-align-middle",value:Asc.c_oAscAlignShapeType.ALIGN_MIDDLE}).on("click",t),new Common.UI.MenuItem({caption:i.textShapeAlignBottom,iconCls:"menu__icon shape-align-bottom",value:Asc.c_oAscAlignShapeType.ALIGN_BOTTOM}).on("click",t),{caption:"--"},new Common.UI.MenuItem({caption:i.txtDistribHor,iconCls:"menu__icon shape-distribute-hor",value:6}).on("click",t),new Common.UI.MenuItem({caption:i.txtDistribVert,iconCls:"menu__icon shape-distribute-vert",value:7}).on("click",t)]})}()}),l=new Common.UI.MenuItem({caption:this.txtGroup,iconCls:"menu__icon shape-group"}).on("click",function(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_Group(1),i.api.ImgApply(n)}i.fireEvent("editcomplete",this)}),c=new Common.UI.MenuItem({iconCls:"menu__icon shape-ungroup",caption:this.txtUngroup}).on("click",function(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_Group(-1),i.api.ImgApply(n)}i.fireEvent("editcomplete",this)}),d=new Common.UI.MenuItem({caption:i.textArrange,menu:function(){function t(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_ChangeLevel(t.options.valign),i.api.ImgApply(n)}i.fireEvent("editcomplete",i)}return new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.textArrangeFront,iconCls:"menu__icon arrange-front",valign:Asc.c_oAscChangeLevel.BringToFront}).on("click",t),new Common.UI.MenuItem({caption:i.textArrangeBack,iconCls:"menu__icon arrange-back",valign:Asc.c_oAscChangeLevel.SendToBack}).on("click",t),new Common.UI.MenuItem({caption:i.textArrangeForward,iconCls:"menu__icon arrange-forward",valign:Asc.c_oAscChangeLevel.BringForward}).on("click",t),new Common.UI.MenuItem({caption:i.textArrangeBackward,iconCls:"menu__icon arrange-backward",valign:Asc.c_oAscChangeLevel.BringBackward}).on("click",t),{caption:"--"},l,c]})}()}),h=new Common.UI.MenuItem({caption:i.textEditWrapBoundary,cls:"no-icon-wrap-item"}).on("click",function(t,e){i.api&&i.api.StartChangeWrapPolygon(),i.fireEvent("editcomplete",i)});this.menuImageWrap=new Common.UI.MenuItem({iconCls:"menu__icon wrap-inline",caption:i.textWrap,menu:function(){function t(t,e){if(i.api){var n=new Asc.asc_CImgProperty;if(n.put_WrappingStyle(t.options.wrapType), +i.menuImageWrap._originalProps.get_WrappingStyle()===Asc.c_oAscWrapStyle2.Inline&&t.wrapType!==Asc.c_oAscWrapStyle2.Inline){n.put_PositionH(new Asc.CImagePositionH),n.get_PositionH().put_UseAlign(!1),n.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var o=i.menuImageWrap._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column);n.get_PositionH().put_Value(o),n.put_PositionV(new Asc.CImagePositionV),n.get_PositionV().put_UseAlign(!1),n.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),o=i.menuImageWrap._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),n.get_PositionV().put_Value(o)}i.api.ImgApply(n)}i.fireEvent("editcomplete",i)}return new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.txtInline,iconCls:"menu__icon wrap-inline",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Inline,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtSquare,iconCls:"menu__icon wrap-square",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Square,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtTight,iconCls:"menu__icon wrap-tight",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Tight,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtThrough,iconCls:"menu__icon wrap-through",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Through,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtTopAndBottom,iconCls:"menu__icon wrap-topandbottom",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.TopAndBottom,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtInFront,iconCls:"menu__icon wrap-infront",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.InFront,checkmark:!1,checkable:!0}).on("click",t),new Common.UI.MenuItem({caption:i.txtBehind,iconCls:"menu__icon wrap-behind",toggleGroup:"popuppicturewrapping",wrapType:Asc.c_oAscWrapStyle2.Behind,checkmark:!1,checkable:!0}).on("click",t),{caption:"--"},h]})}()});var p=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-image",caption:i.advancedText}).on("click",function(t,n){var o,s;if(i.api){var a=i.api.getSelectedElements();if(a&&e.isArray(a))for(var r=a.length-1;r>=0;r--)if(o=a[r].get_ObjectType(),s=a[r].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Image==o){var l;s.get_ChartProperties()||s.get_ShapeProperties()||i.menuOriginalSize.isDisabled()||!i.menuOriginalSize.isVisible()||(l=i.api.get_OriginalSizeImage())&&(l={width:l.get_ImageWidth(),height:l.get_ImageHeight()});var c=new DE.Views.ImageSettingsAdvanced({imageProps:s,sizeOriginal:l,api:i.api,sectionProps:i.api.asc_GetSectionProps(),handler:function(t,e){"ok"==t&&i.api&&i.api.ImgApply(e.imageProps),i.fireEvent("editcomplete",i)}});c.show(),c.btnOriginalSize.setVisible(i.menuOriginalSize.isVisible());break}}}),m=new Common.UI.MenuItem({caption:i.editChartText}).on("click",e.bind(i.editChartClick,i));this.menuOriginalSize=new Common.UI.MenuItem({caption:i.originalSizeText}).on("click",function(t,e){if(i.api){var n=i.api.get_OriginalSizeImage(),o=new Asc.asc_CImgProperty;o.put_Width(n.get_ImageWidth()),o.put_Height(n.get_ImageHeight()),o.put_ResetCrop(!0),i.api.ImgApply(o),i.fireEvent("editcomplete",this)}});var u=new Common.UI.MenuItem({caption:i.textReplace,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:this.textFromFile}).on("click",function(t){setTimeout(function(){i.api&&i.api.ChangeImageFromFile(),i.fireEvent("editcomplete",i)},10)}),new Common.UI.MenuItem({caption:this.textFromUrl,cls:"cp-from-url"}).on("click",function(t){new Common.Views.ImageFromUrlDialog({handler:function(t,n){if("ok"==t&&i.api){var o=n.replace(/ /g,"");if(!e.isEmpty(o)){var s=new Asc.asc_CImgProperty;s.put_ImageUrl(o),i.api.ImgApply(s)}}i.fireEvent("editcomplete",i)}}).show()}),new Common.UI.MenuItem({caption:this.textFromStorage}).on("click",function(t){Common.NotificationCenter.trigger("storage:image-load","change")})]})}),g=new Common.UI.MenuItem({iconCls:"menu__icon btn-copy",caption:i.textCopy,value:"copy"}).on("click",e.bind(i.onCutCopyPaste,i)),b=new Common.UI.MenuItem({iconCls:"menu__icon btn-paste",caption:i.textPaste,value:"paste"}).on("click",e.bind(i.onCutCopyPaste,i)),f=new Common.UI.MenuItem({iconCls:"menu__icon btn-cut",caption:i.textCut,value:"cut"}).on("click",e.bind(i.onCutCopyPaste,i)),C=new Common.UI.MenuItem({iconCls:"menu__icon btn-print",caption:i.txtPrintSelection}).on("click",e.bind(i.onPrintSelection,i)),v=new Common.UI.MenuItem({caption:this.strSign,value:0}).on("click",e.bind(i.onSignatureClick,i)),_=new Common.UI.MenuItem({caption:this.strSetup,value:2}).on("click",e.bind(i.onSignatureClick,i)),y=new Common.UI.MenuItem({caption:"--"}),w=new Common.UI.MenuItem({caption:i.textRotate,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({iconCls:"menu__icon btn-rotate-90",caption:this.textRotate90,value:1}).on("click",e.bind(i.onImgRotate,i)),new Common.UI.MenuItem({iconCls:"menu__icon btn-rotate-270",caption:this.textRotate270,value:0}).on("click",e.bind(i.onImgRotate,i)),{caption:"--"},new Common.UI.MenuItem({iconCls:"menu__icon btn-flip-hor",caption:this.textFlipH,value:1}).on("click",e.bind(i.onImgFlip,i)),new Common.UI.MenuItem({iconCls:"menu__icon btn-flip-vert",caption:this.textFlipV,value:0}).on("click",e.bind(i.onImgFlip,i))]})});i.menuImgCrop=new Common.UI.MenuItem({caption:i.textCrop,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.textCrop,checkable:!0,allowDepress:!0,value:0}).on("click",e.bind(i.onImgCrop,i)),new Common.UI.MenuItem({caption:i.textCropFill,value:1}).on("click",e.bind(i.onImgCrop,i)),new Common.UI.MenuItem({caption:i.textCropFit,value:2}).on("click",e.bind(i.onImgCrop,i))]})}),this.pictureMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(t){if(!e.isUndefined(t.imgProps)){var n=!t.imgProps.value.get_CanBeFlow(),o=t.imgProps.value.get_WrappingStyle();i.menuImageWrap._originalProps=t.imgProps.value;var s="menu__icon ";if(n){for(var a=0;a<6;a++)i.menuImageWrap.menu.items[a].setChecked(!1);s+="wrap-inline"}else switch(o){case Asc.c_oAscWrapStyle2.Inline:i.menuImageWrap.menu.items[0].setChecked(!0),s+="wrap-inline";break;case Asc.c_oAscWrapStyle2.Square:i.menuImageWrap.menu.items[1].setChecked(!0),s+="wrap-square";break;case Asc.c_oAscWrapStyle2.Tight:i.menuImageWrap.menu.items[2].setChecked(!0),s+="wrap-tight";break;case Asc.c_oAscWrapStyle2.Through:i.menuImageWrap.menu.items[3].setChecked(!0),s+="wrap-through";break;case Asc.c_oAscWrapStyle2.TopAndBottom:i.menuImageWrap.menu.items[4].setChecked(!0),s+="wrap-topandbottom";break;case Asc.c_oAscWrapStyle2.Behind:i.menuImageWrap.menu.items[6].setChecked(!0),s+="wrap-behind";break;case Asc.c_oAscWrapStyle2.InFront:i.menuImageWrap.menu.items[5].setChecked(!0),s+="wrap-infront";break;default:for(var a=0;a<6;a++)i.menuImageWrap.menu.items[a].setChecked(!1);s+="wrap-infront"}i.menuImageWrap.setIconCls(s),e.each(i.menuImageWrap.menu.items,function(t){t.setDisabled(n)});var x=t.imgProps.isImg&&t.imgProps.isChart||t.imgProps.isImg&&t.imgProps.isShape||t.imgProps.isShape&&t.imgProps.isChart;x?(p.setCaption(i.advancedText,!0),p.setIconCls("menu__icon btn-menu-image")):(p.setCaption(t.imgProps.isImg?i.imageText:t.imgProps.isChart?i.chartText:i.shapeText,!0),p.setIconCls("menu__icon "+(t.imgProps.isImg?"btn-menu-image":t.imgProps.isChart?"btn-menu-chart":"btn-menu-shape"))),m.setVisible(!e.isNull(t.imgProps.value.get_ChartProperties())&&!x),i.menuOriginalSize.setVisible(t.imgProps.isOnlyImg||!t.imgProps.isChart&&!t.imgProps.isShape);var S=i.api.asc_IsContentControl()?i.api.asc_GetContentControlProperties():null,A=S?S.get_Lock():Asc.c_oAscSdtLockType.Unlocked,k=A==Asc.c_oAscSdtLockType.SdtContentLocked||A==Asc.c_oAscSdtLockType.ContentLocked,T=t.imgProps.locked||void 0!==t.headerProps&&t.headerProps.locked||k,I=t.imgProps.value.asc_getPluginGuid();if(u.setVisible(t.imgProps.isOnlyImg&&(null===I||void 0===I)),u.isVisible()&&u.setDisabled(T||null===I),u.menu.items[2].setVisible(i.mode.canRequestInsertImage||i.mode.fileChoiceUrl&&i.mode.fileChoiceUrl.indexOf("{documentType}")>-1),w.setVisible(!t.imgProps.isChart&&(null===I||void 0===I)),w.isVisible()&&w.setDisabled(T),i.menuImgCrop.setVisible(i.api.asc_canEditCrop()),i.menuImgCrop.isVisible()&&i.menuImgCrop.setDisabled(T),m.isVisible()&&m.setDisabled(T||t.imgProps.value.get_SeveralCharts()),i.pictureMenu.items[19].setVisible(m.isVisible()),i.menuOriginalSize.setDisabled(T||null===t.imgProps.value.get_ImageUrl()||void 0===t.imgProps.value.get_ImageUrl()),p.setDisabled(T),r.setDisabled(T||o==Asc.c_oAscWrapStyle2.Inline),!T&&o!=Asc.c_oAscWrapStyle2.Inline){var P=i.api.asc_getSelectedDrawingObjectsCount(),M=Common.Utils.InternalSettings.get("de-img-align-to");r.menu.items[7].setDisabled(2==P&&(!M||3==M)),r.menu.items[8].setDisabled(2==P&&(!M||3==M))}d.setDisabled(o==Asc.c_oAscWrapStyle2.Inline||k),i.api&&(c.setDisabled(T||!i.api.CanUnGroup()),l.setDisabled(T||!i.api.CanGroup()),h.setDisabled(T||!i.api.CanChangeWrapPolygon())),i.menuImageWrap.setDisabled(T||t.imgProps.value.get_FromGroup()||n&&h.isDisabled()||!!S&&S.get_SpecificType()==Asc.c_oAscContentControlSpecificType.Picture);var E=i.api&&i.api.can_CopyCut();g.setDisabled(!E),f.setDisabled(T||!E),b.setDisabled(T),C.setVisible(i.mode.canPrint),C.setDisabled(!E);var U=t.imgProps&&t.imgProps.value&&i.mode.isSignatureSupport?t.imgProps.value.asc_getSignatureId():void 0,V=!!U;v.setVisible(V),_.setVisible(V),y.setVisible(V),V&&(v.cmpEl.attr("data-value",U),_.cmpEl.attr("data-value",U))}},items:[f,g,b,C,{caption:"--"},v,_,y,d,r,i.menuImageWrap,w,{caption:"--"},n,o,i.menuImgCrop,i.menuOriginalSize,u,m,{caption:"--"},p]}).on("hide:after",function(t,e,n){n||i.fireEvent("editcomplete",i),i.currentMenu=null});var x=new Common.UI.MenuItem({caption:i.txtInsertCaption}).on("click",e.bind(i.onInsertCaption,i)),S=new Common.UI.MenuItem({iconCls:"menu__icon btn-merge",caption:i.mergeCellsText}).on("click",function(t){i.api&&i.api.MergeCells()}),A=new Common.UI.MenuItem({caption:i.splitCellsText}).on("click",function(t){i.api&&new Common.Views.InsertTableDialog({split:!0,handler:function(t,e){"ok"==t&&(i.api&&i.api.SplitCell(e.columns,e.rows),Common.component.Analytics.trackEvent("DocumentHolder","Table")),i.fireEvent("editcomplete",i)}}).show()}),k=function(t,e){if(i.api){var n=new Asc.CTableProp;n.put_CellsVAlign(t.options.valign),i.api.tblApply(n)}},T=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-top",caption:i.cellAlignText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[i.menuTableCellTop=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-top",caption:i.textShapeAlignTop,toggleGroup:"popuptablecellalign",checkmark:!1,checkable:!0,checked:!1,valign:Asc.c_oAscVertAlignJc.Top}).on("click",e.bind(k,i)),i.menuTableCellCenter=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-middle",caption:i.textShapeAlignMiddle,toggleGroup:"popuptablecellalign",checkmark:!1,checkable:!0,checked:!1,valign:Asc.c_oAscVertAlignJc.Center}).on("click",e.bind(k,i)),i.menuTableCellBottom=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-bottom",caption:i.textShapeAlignBottom,toggleGroup:"popuptablecellalign",checkmark:!1,checkable:!0,checked:!1,valign:Asc.c_oAscVertAlignJc.Bottom}).on("click",e.bind(k,i))]})}),I=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-table",caption:i.advancedTableText}).on("click",e.bind(i.advancedTableClick,i)),P=new Common.UI.MenuItem({iconCls:"menu__icon btn-paragraph",caption:i.advancedParagraphText}).on("click",e.bind(i.advancedParagraphClick,i)),M=new Common.UI.MenuItem({caption:"--"}),E=new Common.UI.MenuItem({caption:i.editHyperlinkText}).on("click",e.bind(i.editHyperlink,i)),U=new Common.UI.MenuItem({caption:i.removeHyperlinkText}).on("click",function(t,e){i.api&&i.api.remove_Hyperlink(t.hyperProps.value),i.fireEvent("editcomplete",i)}),V=new Common.UI.MenuItem({iconCls:"menu__icon btn-inserthyperlink",caption:i.hyperlinkText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[E,U]})}),B=new Common.UI.MenuItem({iconCls:"menu__icon cc-remove",caption:i.textRemove,value:"remove"}).on("click",e.bind(i.onControlsSelect,i)),D=new Common.UI.MenuItem({caption:i.textSettings,value:"settings"}).on("click",e.bind(i.onControlsSelect,i)),F=new Common.UI.MenuItem({caption:i.textContentControls,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[B,D]})}),R=new Common.UI.MenuItem({caption:i.textTOC,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[{caption:i.textSettings,value:"settings"},{caption:i.textUpdateAll,value:"all"},{caption:i.textUpdatePages,value:"pages"}]})});R.menu.on("item:click",function(t,e,n){i.fireEvent("settings"==e.value?"links:contents":"links:update",[e.value,!0])});var L=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-comments",caption:i.addCommentText}).on("click",e.bind(i.addComment,i)),N=new Common.UI.MenuItem({iconCls:"menu__icon btn-inserthyperlink",caption:i.hyperlinkText}).on("click",e.bind(i.addHyperlink,i)),H=new Common.UI.MenuItem({caption:i.textFollow}).on("click",e.bind(i.onFollowMove,i));i.menuSpellTable=new Common.UI.MenuItem({caption:i.loadSpellText,disabled:!0}),i.menuSpellMoreTable=new Common.UI.MenuItem({caption:i.moreText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",restoreHeight:!0,items:[]})});var O=e.template(['','',"<%= caption %>",""].join(""));i.langTableMenu=new Common.UI.MenuItem({iconCls:"menu__icon btn-ic-doclang",caption:i.langText,menu:new Common.UI.MenuSimple({cls:"lang-menu",menuAlign:"tl-tr",restoreHeight:285,items:[],itemTemplate:O,search:!0})});var z=new Common.UI.MenuItem({caption:i.ignoreSpellText}).on("click",function(t){i.api&&(i.api.asc_ignoreMisspelledWord(i._currentSpellObj,!1),i.fireEvent("editcomplete",i))}),$=new Common.UI.MenuItem({caption:i.ignoreAllSpellText}).on("click",function(t){i.api&&(i.api.asc_ignoreMisspelledWord(i._currentSpellObj,!0),i.fireEvent("editcomplete",i))}),G=new Common.UI.MenuItem({caption:i.toDictionaryText}).on("click",function(t,e){i.api.asc_spellCheckAddToDictionary(i._currentSpellObj),i.fireEvent("editcomplete",i)}),W=new Common.UI.MenuItem({caption:"--"}),j=new Common.UI.MenuItem({caption:"--"});i.menuSpellCheckTable=new Common.UI.MenuItem({iconCls:"menu__icon btn-ic-docspell",caption:i.spellcheckText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[i.menuSpellTable,i.menuSpellMoreTable,W,z,$,G,{caption:"--"},i.langTableMenu]})});var K=new Common.UI.MenuItem({iconCls:"menu__icon btn-copy",caption:i.textCopy,value:"copy"}).on("click",e.bind(i.onCutCopyPaste,i)),q=new Common.UI.MenuItem({iconCls:"menu__icon btn-paste",caption:i.textPaste,value:"paste"}).on("click",e.bind(i.onCutCopyPaste,i)),Y=new Common.UI.MenuItem({iconCls:"menu__icon btn-cut",caption:i.textCut,value:"cut"}).on("click",e.bind(i.onCutCopyPaste,i)),X=new Common.UI.MenuItem({iconCls:"menu__icon btn-print",caption:i.txtPrintSelection}).on("click",e.bind(i.onPrintSelection,i)),J=new Common.UI.MenuItem({caption:"--"}),Z=new Common.UI.MenuItem({caption:i.textDistributeRows}).on("click",e.bind(function(){i.api&&i.api.asc_DistributeTableCells(!1),i.fireEvent("editcomplete",i)},i)),Q=new Common.UI.MenuItem({caption:i.textDistributeCols}).on("click",e.bind(function(){i.api&&i.api.asc_DistributeTableCells(!0),i.fireEvent("editcomplete",i)},i)),tt=function(t,e){if(i.api){var n=new Asc.CTableProp;n.put_CellsTextDirection(t.options.direction),i.api.tblApply(n)}},et=new Common.UI.MenuItem({iconCls:"menu__icon text-orient-hor",caption:i.directionText,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[i.menuTableDirectH=new Common.UI.MenuItem({caption:i.directHText,iconCls:"menu__icon text-orient-hor",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popuptabledirect",direction:Asc.c_oAscCellTextDirection.LRTB}).on("click",e.bind(tt,i)),i.menuTableDirect90=new Common.UI.MenuItem({caption:i.direct90Text,iconCls:"menu__icon text-orient-rdown",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popuptabledirect",direction:Asc.c_oAscCellTextDirection.TBRL}).on("click",e.bind(tt,i)),i.menuTableDirect270=new Common.UI.MenuItem({caption:i.direct270Text,iconCls:"menu__icon text-orient-rup",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popuptabledirect",direction:Asc.c_oAscCellTextDirection.BTLR}).on("click",e.bind(tt,i))]})}),it=new Common.UI.MenuItem({caption:i.textStartNewList}).on("click",e.bind(i.onStartNumbering,i,1)),nt=new Common.UI.MenuItem({caption:i.textStartNumberingFrom}).on("click",e.bind(i.onStartNumbering,i,"advanced")),ot=new Common.UI.MenuItem({caption:i.textContinueNumbering}).on("click",e.bind(i.onContinueNumbering,i)),st=new Common.UI.MenuItem({caption:i.bulletsText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[it,nt,ot]})}),at=new Common.UI.MenuItem({caption:i.textRefreshField}).on("click",function(t,e){i.api.asc_UpdateComplexField(t.options.fieldProps),i.fireEvent("editcomplete",i)}),rt=new Common.UI.MenuItem({caption:"--"});this.tableMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(t){if(!e.isUndefined(t.tableProps)){for(var n=t.mathProps&&t.mathProps.value,o=8;o<27;o++)i.tableMenu.items[o].setVisible(!n);var s=t.tableProps.value.get_CellsVAlign(),a="";switch(s){case Asc.c_oAscVertAlignJc.Top:a="menu__icon btn-align-top";break;case Asc.c_oAscVertAlignJc.Center:a="menu__icon btn-align-middle";break;case Asc.c_oAscVertAlignJc.Bottom:a="menu__icon btn-align-bottom"}T.setIconCls(a),i.menuTableCellTop.setChecked(s==Asc.c_oAscVertAlignJc.Top),i.menuTableCellCenter.setChecked(s==Asc.c_oAscVertAlignJc.Center),i.menuTableCellBottom.setChecked(s==Asc.c_oAscVertAlignJc.Bottom);var r=t.tableProps.value.get_CellsTextDirection();switch(a="",r){case Asc.c_oAscCellTextDirection.LRTB:a="menu__icon text-orient-hor";break;case Asc.c_oAscCellTextDirection.TBRL:a="menu__icon text-orient-rdown";break;case Asc.c_oAscCellTextDirection.BTLR:a="menu__icon text-orient-rup"}et.setIconCls(a),i.menuTableDirectH.setChecked(r==Asc.c_oAscCellTextDirection.LRTB),i.menuTableDirect90.setChecked(r==Asc.c_oAscCellTextDirection.TBRL),i.menuTableDirect270.setChecked(r==Asc.c_oAscCellTextDirection.BTLR);var l=t.tableProps.locked||void 0!==t.headerProps&&t.headerProps.locked;i.tableMenu.items[11].setDisabled(l),i.tableMenu.items[12].setDisabled(l),i.api&&(S.setDisabled(l||!i.api.CheckBeforeMergeCells()),A.setDisabled(l||!i.api.CheckBeforeSplitCells())),Z.setDisabled(l),Q.setDisabled(l),T.setDisabled(l),et.setDisabled(l),I.setDisabled(l);var c=i.api&&i.api.can_CopyCut();K.setDisabled(!c),Y.setDisabled(l||!c),q.setDisabled(l),X.setVisible(i.mode.canPrint),X.setDisabled(!c);var d=i.api.asc_GetCurrentNumberingId(),h=null!==d;if(st.setVisible(h),h){var p=i.api.asc_GetNumberingPr(d).get_Lvl(i.api.asc_GetCurrentNumberingLvl()),m=p.get_Format(),u=i.api.asc_GetCalculatedNumberingValue();it.setVisible(p.get_Start()!=u),it.value={start:p.get_Start()},nt.setVisible(m!=Asc.c_oAscNumberingFormat.Bullet),nt.value={format:m,start:u},it.setCaption(m==Asc.c_oAscNumberingFormat.Bullet?i.textSeparateList:i.textStartNewList),ot.setCaption(m==Asc.c_oAscNumberingFormat.Bullet?i.textJoinList:i.textContinueNumbering)}var g=null;i.api&&(g=i.api.can_AddHyperlink()),N.setVisible(void 0===t.hyperProps&&!1!==g),V.setVisible(void 0!==t.hyperProps),E.hyperProps=t.hyperProps,U.hyperProps=t.hyperProps,!1!==g&&(N.hyperProps={},N.hyperProps.value=new Asc.CHyperlinkProperty,N.hyperProps.value.put_Text(g));var b=i.api.asc_GetRevisionsChangesStack(),f=!1;H.value=null,e.each(b,function(t){t.get_Type()!=Asc.c_oAscRevisionsChangeType.TextAdd&&t.get_Type()!=Asc.c_oAscRevisionsChangeType.TextRem||t.get_MoveType()==Asc.c_oAscRevisionsMove.NoMove||(H.value=t,f=!0)}),H.setVisible(f),M.setVisible(N.isVisible()||V.isVisible()||st.isVisible()||H.isVisible()),P.setVisible(void 0!==t.paraProps),i._currentParaObjDisabled=l=t.paraProps.locked||void 0!==t.headerProps&&t.headerProps.locked,N.setDisabled(l),V.setDisabled(l||void 0!==t.hyperProps&&!0===t.hyperProps.isSeveralLinks),P.setDisabled(l),i.menuSpellCheckTable.setVisible(void 0!==t.spellProps&&!1===t.spellProps.value.get_Checked()),G.setVisible(i.mode.isDesktopApp),j.setVisible(void 0!==t.spellProps&&!1===t.spellProps.value.get_Checked()),i.langTableMenu.setDisabled(l),void 0!==t.spellProps&&!1===t.spellProps.value.get_Checked()&&null!==t.spellProps.value.get_Variants()&&void 0!==t.spellProps.value.get_Variants()?i.addWordVariants(!1):(i.menuSpellTable.setCaption(i.loadSpellText,!0),i.clearWordVariants(!1),i.menuSpellMoreTable.setVisible(!1)),i.menuSpellCheckTable.isVisible()&&i._currLang.id!==i._currLang.tableid&&(i.changeLanguageMenu(i.langTableMenu.menu),i._currLang.tableid=i._currLang.id);var C=0;n?C=i.addEquationMenu(!1,7):i.clearEquationMenu(!1,7),J.setVisible(n&&C>0);var v=!!t.paraProps&&!(t.paraProps.value.can_DeleteBlockContentControl()&&t.paraProps.value.can_EditBlockContentControl()&&t.paraProps.value.can_DeleteInlineContentControl()&&t.paraProps.value.can_EditInlineContentControl()),_=i.api.asc_GetTableOfContentsPr(!0),y=!_&&i.api.asc_IsContentControl();if(F.setVisible(y),y){var w=i.api.asc_GetContentControlProperties(),x=w?w.get_Lock():Asc.c_oAscSdtLockType.Unlocked,k=w&&w.get_FormPr();B.setDisabled(x==Asc.c_oAscSdtLockType.SdtContentLocked||x==Asc.c_oAscSdtLockType.SdtLocked),B.setCaption(k?i.getControlLabel(w):i.textRemoveControl),D.setVisible(i.mode.canEditContentControl&&!k);var O=w?w.get_SpecificType():Asc.c_oAscContentControlSpecificType.None;v=v||O==Asc.c_oAscContentControlSpecificType.CheckBox||O==Asc.c_oAscContentControlSpecificType.Picture||O==Asc.c_oAscContentControlSpecificType.ComboBox||O==Asc.c_oAscContentControlSpecificType.DropDownList||O==Asc.c_oAscContentControlSpecificType.DateTime}R.setVisible(_),L.setVisible(!1!==i.api.can_AddQuotedComment()&&i.mode.canCoAuthoring&&i.mode.canComments&&!v),L.setDisabled(void 0!==t.paraProps&&!0===t.paraProps.locked);var z=i.api.asc_GetCurrentComplexField();at.setVisible(!!z),at.setDisabled(l),rt.setVisible(!!z),z&&(at.options.fieldProps=z)}},items:[i.menuSpellCheckTable,j,Y,K,q,X,{caption:"--"},J,at,rt,{caption:i.selectText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",style:"width: 100px",items:[new Common.UI.MenuItem({caption:i.rowText}).on("click",function(t){i.api&&i.api.selectRow()}),new Common.UI.MenuItem({caption:i.columnText}).on("click",function(t){i.api&&i.api.selectColumn()}),new Common.UI.MenuItem({caption:i.cellText}).on("click",function(t){i.api&&i.api.selectCell()}),new Common.UI.MenuItem({caption:i.tableText}).on("click",function(t){i.api&&i.api.selectTable()})]})},{iconCls:"menu__icon btn-addcell",caption:i.insertText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[new Common.UI.MenuItem({caption:i.insertColumnLeftText}).on("click",function(t){i.api&&i.api.addColumnLeft()}),new Common.UI.MenuItem({caption:i.insertColumnRightText}).on("click",function(t){i.api&&i.api.addColumnRight()}),new Common.UI.MenuItem({caption:i.insertRowAboveText}).on("click",function(t){i.api&&i.api.addRowAbove()}),new Common.UI.MenuItem({caption:i.insertRowBelowText}).on("click",function(t){i.api&&i.api.addRowBelow()}),new Common.UI.MenuItem({caption:i.textSeveral}).on("click",function(t){i.onCellsAdd()})]})},{iconCls:"menu__icon btn-delcell",caption:i.deleteText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",style:"width: 100px",items:[new Common.UI.MenuItem({caption:i.rowText}).on("click",function(t){i.api&&i.api.remRow()}),new Common.UI.MenuItem({caption:i.columnText}).on("click",function(t){i.api&&i.api.remColumn()}),new Common.UI.MenuItem({caption:i.tableText}).on("click",function(t){i.api&&i.api.remTable()}),new Common.UI.MenuItem({caption:i.textCells}).on("click",function(t){i.onCellsRemove()})]})},{caption:"--"},S,A,{caption:"--"},Z,Q,{caption:"--"},T,et,{caption:"--"},x,{caption:"--"},I,{caption:"--"},L,st,N,V,H,M,F,R,P]}).on("hide:after",function(t,e,n){if(i.suppressEditComplete)return void(i.suppressEditComplete=!1);n||i.fireEvent("editcomplete",i),i.currentMenu=null});var lt=new Common.UI.MenuItem({caption:i.breakBeforeText,checkable:!0}).on("click",function(t,e){i.api.put_PageBreak(t.checked)}),ct=new Common.UI.MenuItem({caption:i.keepLinesText,checkable:!0}).on("click",function(t,e){i.api.put_KeepLines(t.checked)}),dt=function(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_VerticalTextAlign(t.options.valign),i.api.ImgApply(n)}},ht=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-top",caption:i.vertAlignText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[i.menuParagraphTop=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-top",caption:i.textShapeAlignTop,checkmark:!1,checkable:!0,checked:!1,toggleGroup:"popupparagraphvalign",valign:Asc.c_oAscVAlign.Top}).on("click",e.bind(dt,i)),i.menuParagraphCenter=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-middle",caption:i.textShapeAlignMiddle,checkmark:!1,checkable:!0,checked:!1,toggleGroup:"popupparagraphvalign",valign:Asc.c_oAscVAlign.Center}).on("click",e.bind(dt,i)),i.menuParagraphBottom=new Common.UI.MenuItem({iconCls:"menu__icon btn-align-bottom",caption:i.textShapeAlignBottom,checkmark:!1,checkable:!0,checked:!1,toggleGroup:"popupparagraphvalign",valign:Asc.c_oAscVAlign.Bottom}).on("click",e.bind(dt,i))]})}),pt=function(t,e){if(i.api){var n=new Asc.asc_CImgProperty;n.put_Vert(t.options.direction),i.api.ImgApply(n)}},mt=new Common.UI.MenuItem({iconCls:"menu__icon text-orient-hor",caption:i.directionText,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",menuAlign:"tl-tr",items:[i.menuParagraphDirectH=new Common.UI.MenuItem({caption:i.directHText,iconCls:"menu__icon text-orient-hor",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popupparagraphdirect",direction:Asc.c_oAscVertDrawingText.normal}).on("click",e.bind(pt,i)),i.menuParagraphDirect90=new Common.UI.MenuItem({caption:i.direct90Text,iconCls:"menu__icon text-orient-rdown",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popupparagraphdirect",direction:Asc.c_oAscVertDrawingText.vert}).on("click",e.bind(pt,i)),i.menuParagraphDirect270=new Common.UI.MenuItem({caption:i.direct270Text,iconCls:"menu__icon text-orient-rup",checkable:!0,checkmark:!1,checked:!1,toggleGroup:"popupparagraphdirect",direction:Asc.c_oAscVertDrawingText.vert270}).on("click",e.bind(pt,i))]})}),ut=new Common.UI.MenuItem({iconCls:"menu__icon btn-paragraph",caption:i.advancedParagraphText}).on("click",e.bind(i.advancedParagraphClick,i)),gt=new Common.UI.MenuItem({caption:i.advancedFrameText}).on("click",e.bind(i.advancedFrameClick,i,!0)),bt=new Common.UI.MenuItem({iconCls:"menu__icon dropcap-intext",caption:i.advancedDropCapText}).on("click",e.bind(i.advancedFrameClick,i,!1)),ft=new Common.UI.MenuItem({caption:"--"}),Ct=new Common.UI.MenuItem({iconCls:"menu__icon btn-menu-comments",caption:i.addCommentText}).on("click",e.bind(i.addComment,i)),vt=new Common.UI.MenuItem({caption:"--"}),_t=new Common.UI.MenuItem({iconCls:"menu__icon btn-inserthyperlink",caption:i.hyperlinkText}).on("click",e.bind(i.addHyperlink,i)),yt=new Common.UI.MenuItem({caption:i.editHyperlinkText}).on("click",e.bind(i.editHyperlink,i)),wt=new Common.UI.MenuItem({caption:i.removeHyperlinkText}).on("click",function(t,e){i.api.remove_Hyperlink(t.hyperProps.value),i.fireEvent("editcomplete",i)}),xt=new Common.UI.MenuItem({iconCls:"menu__icon btn-inserthyperlink",caption:i.hyperlinkText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[yt,wt]})}),St=new Common.UI.MenuItemSeparator,At=new Common.UI.MenuItem({caption:i.styleText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[i.menuStyleSave=new Common.UI.MenuItem({caption:i.saveStyleText}).on("click",e.bind(i.onMenuSaveStyle,i)),i.menuStyleUpdate=new Common.UI.MenuItem({caption:i.updateStyleText.replace("%1",window.currentStyleName)}).on("click",e.bind(i.onMenuUpdateStyle,i))]})});i.menuSpellPara=new Common.UI.MenuItem({caption:i.loadSpellText,disabled:!0}),i.menuSpellMorePara=new Common.UI.MenuItem({caption:i.moreText,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",restoreHeight:!0,items:[]})}),i.langParaMenu=new Common.UI.MenuItem({iconCls:"menu__icon btn-ic-doclang",caption:i.langText,menu:new Common.UI.MenuSimple({cls:"lang-menu",menuAlign:"tl-tr",restoreHeight:285,items:[],itemTemplate:O,search:!0})});var kt=new Common.UI.MenuItem({caption:i.ignoreSpellText}).on("click",function(t,e){i.api.asc_ignoreMisspelledWord(i._currentSpellObj,!1),i.fireEvent("editcomplete",i)}),Tt=new Common.UI.MenuItem({caption:i.ignoreAllSpellText}).on("click",function(t,e){i.api.asc_ignoreMisspelledWord(i._currentSpellObj,!0),i.fireEvent("editcomplete",i)}),It=new Common.UI.MenuItem({caption:i.toDictionaryText}).on("click",function(t,e){i.api.asc_spellCheckAddToDictionary(i._currentSpellObj),i.fireEvent("editcomplete",i)}),Pt=new Common.UI.MenuItem({caption:"--"}),Mt=new Common.UI.MenuItem({caption:"--"}),Et=new Common.UI.MenuItem({iconCls:"menu__icon btn-copy",caption:i.textCopy,value:"copy"}).on("click",e.bind(i.onCutCopyPaste,i)),Ut=new Common.UI.MenuItem({iconCls:"menu__icon btn-paste",caption:i.textPaste,value:"paste"}).on("click",e.bind(i.onCutCopyPaste,i)),Vt=new Common.UI.MenuItem({iconCls:"menu__icon btn-cut",caption:i.textCut,value:"cut"}).on("click",e.bind(i.onCutCopyPaste,i)),Bt=new Common.UI.MenuItem({iconCls:"menu__icon btn-print",caption:i.txtPrintSelection}).on("click",e.bind(i.onPrintSelection,i)),Dt=new Common.UI.MenuItem({caption:"--"}),Ft=new Common.UI.MenuItem({iconCls:"menu__icon cc-remove",caption:i.textRemoveControl,value:"remove"}).on("click",e.bind(i.onControlsSelect,i)),Rt=new Common.UI.MenuItem({caption:i.textEditControls,value:"settings"}).on("click",e.bind(i.onControlsSelect,i)),Lt=new Common.UI.MenuItem({caption:"--"}),Nt=new Common.UI.MenuItem({caption:i.textTOCSettings,value:"settings"}).on("click",function(t,e){i.fireEvent("links:contents",[t.value,!0])}),Ht=new Common.UI.MenuItem({caption:i.textUpdateTOC,menu:new Common.UI.Menu({cls:"shifted-right",menuAlign:"tl-tr",items:[{caption:i.textUpdateAll,value:"all"},{caption:i.textUpdatePages,value:"pages"}]})});Ht.menu.on("item:click",function(t,e,n){i.fireEvent("links:update",[e.value,!0])});var Ot=new Common.UI.MenuItem({caption:"--"}),zt=new Common.UI.MenuItem({caption:i.textRefreshField}).on("click",function(t,e){i.api.asc_UpdateComplexField(t.options.fieldProps),i.fireEvent("editcomplete",i)}),$t=new Common.UI.MenuItem({caption:"--"}),Gt=new Common.UI.MenuItem({caption:i.textStartNewList}).on("click",e.bind(i.onStartNumbering,i,1)),Wt=new Common.UI.MenuItem({caption:i.textStartNumberingFrom}).on("click",e.bind(i.onStartNumbering,i,"advanced")),jt=new Common.UI.MenuItem({caption:i.textContinueNumbering}).on("click",e.bind(i.onContinueNumbering,i)),Kt=new Common.UI.MenuItem({caption:"--"}),qt=new Common.UI.MenuItem({caption:i.textFollow}).on("click",e.bind(i.onFollowMove,i)),Yt=new Common.UI.MenuItem({caption:"--"});this.textMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(t){var n=t.imgProps&&t.imgProps.value&&!e.isNull(t.imgProps.value.get_ShapeProperties()),o=t.imgProps&&t.imgProps.value&&!e.isNull(t.imgProps.value.get_ChartProperties()),r=t.mathProps&&t.mathProps.value;if(ht.setVisible(n&&!o&&!r),mt.setVisible(n&&!o&&!r),n||o){var l=t.imgProps.value.get_VerticalTextAlign(),c="";switch(l){ +case Asc.c_oAscVAlign.Top:c="menu__icon btn-align-top";break;case Asc.c_oAscVAlign.Center:c="menu__icon btn-align-middle";break;case Asc.c_oAscVAlign.Bottom:c="menu__icon btn-align-bottom"}ht.setIconCls(c),i.menuParagraphTop.setChecked(l==Asc.c_oAscVAlign.Top),i.menuParagraphCenter.setChecked(l==Asc.c_oAscVAlign.Center),i.menuParagraphBottom.setChecked(l==Asc.c_oAscVAlign.Bottom);var d=t.imgProps.value.get_Vert();switch(c="",d){case Asc.c_oAscVertDrawingText.normal:c="menu__icon text-orient-hor";break;case Asc.c_oAscVertDrawingText.vert:c="menu__icon text-orient-rdown";break;case Asc.c_oAscVertDrawingText.vert270:c="menu__icon text-orient-rup"}mt.setIconCls(c),i.menuParagraphDirectH.setChecked(d==Asc.c_oAscVertDrawingText.normal),i.menuParagraphDirect90.setChecked(d==Asc.c_oAscVertDrawingText.vert),i.menuParagraphDirect270.setChecked(d==Asc.c_oAscVertDrawingText.vert270)}ut.isChart=t.imgProps&&t.imgProps.isChart,lt.setVisible(!n&&!o&&!r),ct.setVisible(!n&&!o&&!r),t.paraProps&&(lt.setChecked(t.paraProps.value.get_PageBreakBefore()),ct.setChecked(t.paraProps.value.get_KeepLines()));var h=null;i.api&&(h=i.api.can_AddHyperlink()),_t.setVisible(void 0===t.hyperProps&&!1!==h),xt.setVisible(void 0!==t.hyperProps),vt.setVisible(_t.isVisible()||xt.isVisible()),yt.hyperProps=t.hyperProps,wt.hyperProps=t.hyperProps,!1!==h&&(_t.hyperProps={},_t.hyperProps.value=new Asc.CHyperlinkProperty,_t.hyperProps.value.put_Text(h));var p=t.paraProps.locked||void 0!==t.headerProps&&t.headerProps.locked;i._currentParaObjDisabled=p,_t.setDisabled(p),xt.setDisabled(p||void 0!==t.hyperProps&&!0===t.hyperProps.isSeveralLinks);var m=i.api.asc_GetRevisionsChangesStack(),u=!1;qt.value=null,e.each(m,function(t){t.get_Type()!=Asc.c_oAscRevisionsChangeType.TextAdd&&t.get_Type()!=Asc.c_oAscRevisionsChangeType.TextRem||t.get_MoveType()==Asc.c_oAscRevisionsMove.NoMove||(qt.value=t,u=!0)}),qt.setVisible(u),Yt.setVisible(u),lt.setDisabled(p||!e.isUndefined(t.headerProps)||!e.isUndefined(t.imgProps)),ct.setDisabled(p),ut.setDisabled(p),gt.setDisabled(p),bt.setDisabled(p),ht.setDisabled(p),mt.setDisabled(p);var g=i.api&&i.api.can_CopyCut();Et.setDisabled(!g),Vt.setDisabled(p||!g),Ut.setDisabled(p),Bt.setVisible(i.mode.canPrint),Bt.setDisabled(!g);var b=void 0!==t.spellProps&&!1===t.spellProps.value.get_Checked();i.menuSpellPara.setVisible(b),Mt.setVisible(b),kt.setVisible(b),Tt.setVisible(b),It.setVisible(b&&i.mode.isDesktopApp),i.langParaMenu.setVisible(b),i.langParaMenu.setDisabled(p),Pt.setVisible(b),b&&null!==t.spellProps.value.get_Variants()&&void 0!==t.spellProps.value.get_Variants()?i.addWordVariants(!0):(i.menuSpellPara.setCaption(i.loadSpellText,!0),i.clearWordVariants(!0),i.menuSpellMorePara.setVisible(!1)),i.langParaMenu.isVisible()&&i._currLang.id!==i._currLang.paraid&&(i.changeLanguageMenu(i.langParaMenu.menu),i._currLang.paraid=i._currLang.id);var f=0;r?f=i.addEquationMenu(!0,15):i.clearEquationMenu(!0,15),Dt.setVisible(r&&f>0),s.setVisible(r),a.setVisible(r);var C=t.paraProps.value.get_FramePr();gt.setVisible(void 0!==C),bt.setVisible(void 0!==C),C&&bt.setIconCls(C.get_DropCap()===Asc.c_oAscDropCap.Drop?"menu__icon dropcap-intext":"menu__icon dropcap-inmargin"),St.setVisible(i.mode.canEditStyles&&!o),At.setVisible(i.mode.canEditStyles&&!o),i.mode.canEditStyles&&!o&&i.menuStyleUpdate.setCaption(i.updateStyleText.replace("%1",DE.getController("Main").translationTable[window.currentStyleName]||window.currentStyleName));var v=!!t.paraProps&&!(t.paraProps.value.can_DeleteBlockContentControl()&&t.paraProps.value.can_EditBlockContentControl()&&t.paraProps.value.can_DeleteInlineContentControl()&&t.paraProps.value.can_EditInlineContentControl()),_=i.api.asc_GetTableOfContentsPr(!0),y=!_&&i.api.asc_IsContentControl(),w=y?i.api.asc_GetContentControlProperties():null,x=w&&w.get_FormPr();if(Ft.setVisible(y),Rt.setVisible(y&&i.mode.canEditContentControl&&!x),Lt.setVisible(y),y){var S=w?w.get_Lock():Asc.c_oAscSdtLockType.Unlocked;Ft.setDisabled(S==Asc.c_oAscSdtLockType.SdtContentLocked||S==Asc.c_oAscSdtLockType.SdtLocked),Ft.setCaption(x?i.getControlLabel(w):i.textRemoveControl);var A=w?w.get_SpecificType():Asc.c_oAscContentControlSpecificType.None;v=v||A==Asc.c_oAscContentControlSpecificType.CheckBox||A==Asc.c_oAscContentControlSpecificType.Picture||A==Asc.c_oAscContentControlSpecificType.ComboBox||A==Asc.c_oAscContentControlSpecificType.DropDownList||A==Asc.c_oAscContentControlSpecificType.DateTime}Nt.setVisible(_),Ht.setVisible(_),Ot.setVisible(_);var k=!o&&!1!==i.api.can_AddQuotedComment()&&i.mode.canCoAuthoring&&i.mode.canComments&&!v;i.mode.compatibleFeatures&&(k=k&&!n),ft.setVisible(k),Ct.setVisible(k),Ct.setDisabled(t.paraProps&&!0===t.paraProps.locked);var T=i.api.asc_GetCurrentComplexField();zt.setVisible(!!T),zt.setDisabled(p),$t.setVisible(!!T),T&&(zt.options.fieldProps=T);var I=i.api.asc_GetCurrentNumberingId(),P=null!==I;if(Kt.setVisible(P),Gt.setVisible(P),Wt.setVisible(P),jt.setVisible(P),P){var M=i.api.asc_GetNumberingPr(I).get_Lvl(i.api.asc_GetCurrentNumberingLvl()),E=M.get_Format(),U=i.api.asc_GetCalculatedNumberingValue();Gt.setVisible(M.get_Start()!=U),Gt.value={start:M.get_Start()},Wt.setVisible(E!=Asc.c_oAscNumberingFormat.Bullet),Wt.value={format:E,start:U},Gt.setCaption(E==Asc.c_oAscNumberingFormat.Bullet?i.textSeparateList:i.textStartNewList),jt.setCaption(E==Asc.c_oAscNumberingFormat.Bullet?i.textJoinList:i.textContinueNumbering)}},items:[i.menuSpellPara,i.menuSpellMorePara,Mt,kt,Tt,It,i.langParaMenu,Pt,Vt,Et,Ut,Bt,a,s,{caption:"--"},Dt,Ft,Rt,Lt,zt,$t,Nt,Ht,Ot,lt,ct,ht,mt,ut,gt,bt,ft,Ct,vt,_t,xt,Yt,qt,Kt,Gt,Wt,jt,St,At]}).on("hide:after",function(t,e,n){if(i.suppressEditComplete)return void(i.suppressEditComplete=!1);n||i.fireEvent("editcomplete",i),i.currentMenu=null});var Xt=new Common.UI.MenuItem({caption:i.editHeaderText});this.hdrMenu=new Common.UI.Menu({cls:"shifted-right",initMenu:function(t){Xt.setCaption(t.Header?i.editHeaderText:i.editFooterText,!0),Xt.off("click").on("click",function(e){i.api&&(t.Header?i.api.GoToHeader(t.PageNum):i.api.GoToFooter(t.PageNum),i.fireEvent("editcomplete",i))})},items:[Xt]}).on("hide:after",function(t,e,n){n||i.fireEvent("editcomplete",i),i.currentMenu=null});var Jt=t("#id_buttonNextPage");Jt.attr("data-toggle","tooltip"),Jt.tooltip({title:i.textNextPage+Common.Utils.String.platformKey("Alt+PgDn"),placement:"top-right"});var Zt=t("#id_buttonPrevPage");Zt.attr("data-toggle","tooltip"),Zt.tooltip({title:i.textPrevPage+Common.Utils.String.platformKey("Alt+PgUp"),placement:"top-right"})},setLanguages:function(t){var i=this;if(t&&t.length>0&&i.langParaMenu&&i.langTableMenu){var n=[],o=[];e.each(t,function(t){var i={caption:t.displayValue,value:t.value,checkable:!0,langid:t.code,spellcheck:t.spellcheck};n.push(i),o.push(e.clone(i))}),i.langParaMenu.menu.resetItems(n),i.langTableMenu.menu.resetItems(o),i.langParaMenu.menu.on("item:click",function(t,n){i.api&&(e.isUndefined(n.langid)||i.api.put_TextPrLang(n.langid),i._currLang.paraid=n.langid,i.fireEvent("editcomplete",i))}),i.langTableMenu.menu.on("item:click",function(t,n,o){i.api&&(e.isUndefined(n.langid)||i.api.put_TextPrLang(n.langid),i._currLang.tableid=n.langid,i.fireEvent("editcomplete",i))})}},onSignatureClick:function(t){var e=t.cmpEl.attr("data-value");switch(t.value){case 0:Common.NotificationCenter.trigger("protect:sign",e);break;case 1:this.api.asc_ViewCertificate(e);break;case 2:Common.NotificationCenter.trigger("protect:signature","visible",this._isDisabled,e);break;case 3:this.api.asc_RemoveSignature(e)}},onImgRotate:function(t){var e=new Asc.asc_CImgProperty;e.asc_putRotAdd(3.14159265358979*(1==t.value?90:270)/180),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onImgFlip:function(t){var e=new Asc.asc_CImgProperty;1==t.value?e.asc_putFlipHInvert(!0):e.asc_putFlipVInvert(!0),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onImgCrop:function(t){1==t.value?this.api.asc_cropFill():2==t.value?this.api.asc_cropFit():t.checked?this.api.asc_startEditCrop():this.api.asc_endEditCrop(),this.fireEvent("editcomplete",this)},onFollowMove:function(t){this.api&&this.api.asc_FollowRevisionMove(t.value),this.fireEvent("editcomplete",this)},onHideContentControlsActions:function(){this.listControlMenu&&this.listControlMenu.isVisible()&&this.listControlMenu.hide();var t=this.cmpEl.find("#calendar-control-container");t.is(":visible")&&t.hide()},onShowDateActions:function(e,i,n){var o=e.pr,s=o.get_DateTimePr(),a=this.cmpEl.find("#calendar-control-container"),r=this;this._dateObj=o,a.length<1&&(a=t('
    '),this.cmpEl.append(a)),Common.UI.Menu.Manager.hideAll(),a.css({left:i,top:n}),a.show(),this.cmpCalendar||(this.cmpCalendar=new Common.UI.Calendar({el:this.cmpEl.find("#id-document-calendar-control"),enableKeyEvents:!0,firstday:1}),this.cmpCalendar.on("date:click",function(t,e){var i=r._dateObj.get_DateTimePr();i.put_FullDate(new Date(e)),r.api.asc_SetContentControlDatePickerDate(i),a.hide(),r.api.asc_UncheckContentControlButtons(),r.fireEvent("editcomplete",r)}),this.cmpCalendar.on("calendar:keydown",function(t,e){e.keyCode==Common.UI.Keys.ESC&&(a.hide(),r.api.asc_UncheckContentControlButtons())}),t(document).on("mousedown",function(t){"canvas"!==t.target.localName&&a.is(":visible")&&0==a.find(t.target).length&&(a.hide(),r.api.asc_UncheckContentControlButtons())})),this.cmpCalendar.setDate(new Date(s?s.get_FullDate():void 0));var l=a.offset(),c=Common.Utils.innerWidth(),d=Common.Utils.innerHeight()-10,h=this.cmpCalendar.cmpEl.outerWidth(),p=this.cmpCalendar.cmpEl.outerHeight(),m=l.left-h,u=l.top;u+p>d&&(u=d-p,m-=22),u<0&&(u=0),m+h>c&&(m=c-h),this.cmpCalendar.cmpEl.css({left:m,top:u}),this._preventClick=!0},onShowListActions:function(i,n,o){var s=i.type,a=i.pr,r=s==Asc.c_oAscContentControlSpecificType.ComboBox?a.get_ComboBoxPr():a.get_DropDownListPr(),l=!!a.get_FormPr(),c=this.listControlMenu,d=c?this.cmpEl.find(Common.Utils.String.format("#menu-container-{0}",c.id)):null,h=this;if(this._listObj=a,this._fromShowContentControls=!0,Common.UI.Menu.Manager.hideAll(),c||(this.listControlMenu=c=new Common.UI.Menu({maxHeight:207,menuAlign:"tr-bl",items:[]}),c.on("item:click",function(t,e){setTimeout(function(){-1!==e.value&&h.api.asc_SelectContentControlListItem(e.value,h._listObj.get_InternalId())},1)}),(!d||d.length<1)&&(d=t(Common.Utils.String.format('',c.id)),this.cmpEl.append(d)),c.render(d),c.cmpEl.attr({tabindex:"-1"}),c.on("hide:after",function(){h.listControlMenu.removeAll(),h._fromShowContentControls||h.api.asc_UncheckContentControlButtons()})),r){if(l){var p=a.get_PlaceholderText();c.addItem(new Common.UI.MenuItem({caption:""!==p.trim()?p:this.txtEmpty,value:"",template:e.template([' opacity: 0.6 <% } %>">',"<%= caption %>",""].join(""))}))}for(var m=r.get_ItemsCount(),u=0;u','
    ',"","
    ",'
    ',""].join(""),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this;t.inputUrl=new Common.UI.InputField({el:$("#id-dlg-url"),allowBlank:!1,blankError:t.txtEmpty,style:"width: 100%;",validateOnBlur:!1,validation:function(e){return!!/((^https?)|(^ftp)):\/\/.+/i.test(e)||t.txtNotUrl}}),this.getChild().find(".btn").on("click",_.bind(this.onBtnClick,this))},show:function(){Common.UI.Window.prototype.show.apply(this,arguments);var t=this;_.delay(function(){t.getChild("input").focus()},100)},onPrimary:function(t){return this._handleInput("ok"),!1},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},_handleInput:function(t){if(this.options.handler){if("ok"==t&&!0!==this.inputUrl.checkValidate())return void this.inputUrl.cmpEl.find("input").focus();this.options.handler.call(this,t,this.inputUrl.getValue())}this.close()},textUrl:"Paste an image URL:",txtEmpty:"This field is required",txtNotUrl:'This field should be a URL in the format "http://www.example.com"'},Common.Views.ImageFromUrlDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/component/LoadMask",["common/main/lib/component/BaseView"],function(){"use strict";Common.UI.LoadMask=Common.UI.BaseView.extend(function(){return{options:{cls:"",style:"",title:"Loading...",owner:document.body},template:_.template(['"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t),this.template=this.options.template||this.template,this.title=this.options.title,this.ownerEl=this.options.owner instanceof Common.UI.BaseView?$(this.options.owner.el):$(this.options.owner),this.loaderEl=$(this.template({id:this.id,cls:this.options.cls,style:this.options.style,title:this.title})),this.maskeEl=$('
    '),this.timerId=0},render:function(){return this},show:function(){var t=this.ownerEl,e=this.loaderEl,i=this.maskeEl;if(t.ismasked)return this;t.ismasked=!0;var n=this;return n.title!=n.options.title&&(n.options.title=n.title,$(".asc-loadmask-title",e).html(n.title)),n.timerId=setTimeout(function(){t.append(i),t.append(e),t&&0==t.closest(".asc-window.modal").length&&Common.util.Shortcuts.suspendEvents()},500),this},hide:function(){var t=this.ownerEl;this.timerId&&(clearTimeout(this.timerId),this.timerId=0),t&&t.ismasked&&(0!=t.closest(".asc-window.modal").length||Common.Utils.ModalWindow.isVisible()||Common.util.Shortcuts.resumeEvents(),this.maskeEl&&this.maskeEl.remove(),this.loaderEl&&this.loaderEl.remove()),delete t.ismasked},setTitle:function(t){this.title=t,this.ownerEl&&this.ownerEl.ismasked&&this.loaderEl&&$(".asc-loadmask-title",this.loaderEl).html(t)},isVisible:function(){return!!this.ownerEl.ismasked},updatePosition:function(){var t=this.ownerEl,e=this.loaderEl;t&&t.ismasked&&e&&(e.css({top:Math.round(t.height()/2-(e.height()+parseInt(e.css("padding-top"))+parseInt(e.css("padding-bottom")))/2)+"px",left:Math.round(t.width()/2-(e.width()+parseInt(e.css("padding-left"))+parseInt(e.css("padding-right")))/2)+"px"}),e.css({visibility:"visible"}))}}}())}),define("common/main/lib/view/SelectFileDlg",["common/main/lib/component/Window","common/main/lib/component/LoadMask"],function(){"use strict";Common.Views.SelectFileDlg=Common.UI.Window.extend(_.extend({initialize:function(t){var e={};_.extend(e,{title:this.textTitle,width:1024,height:621,header:!0},t),this.template=['
    '].join(""),e.tpl=_.template(this.template)(e),this.fileChoiceUrl=t.fileChoiceUrl||"",Common.UI.Window.prototype.initialize.call(this,e)},render:function(){Common.UI.Window.prototype.render.call(this),this.$window.find("> .body").css({height:"auto",overflow:"hidden"});var t=document.createElement("iframe");t.width="100%",t.height=585,t.align="top",t.frameBorder=0,t.scrolling="no",t.onload=_.bind(this._onLoad,this),$("#id-select-file-placeholder").append(t),this.loadMask=new Common.UI.LoadMask({owner:$("#id-select-file-placeholder")}),this.loadMask.setTitle(this.textLoading),this.loadMask.show(),t.src=this.fileChoiceUrl;var e=this;this._eventfunc=function(t){e._onWindowMessage(t)},this._bindWindowEvents.call(this),this.on("close",function(t){e._unbindWindowEvents()})},_bindWindowEvents:function(){window.addEventListener?window.addEventListener("message",this._eventfunc,!1):window.attachEvent&&window.attachEvent("onmessage",this._eventfunc)},_unbindWindowEvents:function(){window.removeEventListener?window.removeEventListener("message",this._eventfunc):window.detachEvent&&window.detachEvent("onmessage",this._eventfunc)},_onWindowMessage:function(t){if(t&&window.JSON)try{this._onMessage.call(this,window.JSON.parse(t.data))}catch(t){}},_onMessage:function(t){if(t&&"onlyoffice"==t.Referer&&void 0!==t.file){Common.NotificationCenter.trigger("window:close",this);var e=this;setTimeout(function(){_.isEmpty(t.file)||e.trigger("selectfile",e,t.file)},50)}},_onLoad:function(){this.loadMask&&this.loadMask.hide()},textTitle:"Select Data Source",textLoading:"Loading"},Common.Views.SelectFileDlg||{}))}),void 0===Common)var Common={};if(void 0===Common.define&&(Common.define={}),define("common/main/lib/util/define",[],function(){"use strict";Common.define.c_oAscMathMainType={Symbol:0,Fraction:1,Script:2,Radical:3,Integral:4,LargeOperator:5,Bracket:6,Function:7,Accent:8,LimitLog:9,Operator:10,Matrix:11},Common.define.c_oAscMathType={Symbol_pm:0,Symbol_infinity:1,Symbol_equals:2,Symbol_neq:3,Symbol_about:4,Symbol_times:5,Symbol_div:6,Symbol_factorial:7,Symbol_propto:8,Symbol_less:9,Symbol_ll:10,Symbol_greater:11,Symbol_gg:12,Symbol_leq:13,Symbol_geq:14,Symbol_mp:15,Symbol_cong:16,Symbol_approx:17,Symbol_equiv:18,Symbol_forall:19,Symbol_additional:20,Symbol_partial:21,Symbol_sqrt:22,Symbol_cbrt:23,Symbol_qdrt:24,Symbol_cup:25,Symbol_cap:26,Symbol_emptyset:27,Symbol_percent:28,Symbol_degree:29,Symbol_fahrenheit:30,Symbol_celsius:31,Symbol_inc:32,Symbol_nabla:33,Symbol_exists:34,Symbol_notexists:35,Symbol_in:36,Symbol_ni:37,Symbol_leftarrow:38,Symbol_uparrow:39,Symbol_rightarrow:40,Symbol_downarrow:41,Symbol_leftrightarrow:42,Symbol_therefore:43,Symbol_plus:44,Symbol_minus:45,Symbol_not:46,Symbol_ast:47,Symbol_bullet:48,Symbol_vdots:49,Symbol_cdots:50,Symbol_rddots:51,Symbol_ddots:52,Symbol_aleph:53,Symbol_beth:54,Symbol_QED:55,Symbol_alpha:65536,Symbol_beta:65537,Symbol_gamma:65538,Symbol_delta:65539,Symbol_varepsilon:65540,Symbol_epsilon:65541,Symbol_zeta:65542,Symbol_eta:65543,Symbol_theta:65544,Symbol_vartheta:65545,Symbol_iota:65546,Symbol_kappa:65547,Symbol_lambda:65548,Symbol_mu:65549,Symbol_nu:65550,Symbol_xsi:65551,Symbol_o:65552,Symbol_pi:65553,Symbol_varpi:65554,Symbol_rho:65555,Symbol_varrho:65556,Symbol_sigma:65557,Symbol_varsigma:65558,Symbol_tau:65559,Symbol_upsilon:65560,Symbol_varphi:65561,Symbol_phi:65562,Symbol_chi:65563,Symbol_psi:65564,Symbol_omega:65565,Symbol_Alpha:131072,Symbol_Beta:131073,Symbol_Gamma:131074,Symbol_Delta:131075,Symbol_Epsilon:131076,Symbol_Zeta:131077,Symbol_Eta:131078,Symbol_Theta:131079,Symbol_Iota:131080,Symbol_Kappa:131081,Symbol_Lambda:131082,Symbol_Mu:131083,Symbol_Nu:131084,Symbol_Xsi:131085,Symbol_O:131086,Symbol_Pi:131087,Symbol_Rho:131088,Symbol_Sigma:131089,Symbol_Tau:131090,Symbol_Upsilon:131091,Symbol_Phi:131092,Symbol_Chi:131093,Symbol_Psi:131094,Symbol_Omega:131095,FractionVertical:16777216,FractionDiagonal:16777217,FractionHorizontal:16777218,FractionSmall:16777219,FractionDifferential_1:16842752,FractionDifferential_2:16842753,FractionDifferential_3:16842754,FractionDifferential_4:16842755,FractionPi_2:16842756,ScriptSup:33554432,ScriptSub:33554433,ScriptSubSup:33554434,ScriptSubSupLeft:33554435,ScriptCustom_1:33619968,ScriptCustom_2:33619969,ScriptCustom_3:33619970,ScriptCustom_4:33619971,RadicalSqrt:50331648,RadicalRoot_n:50331649,RadicalRoot_2:50331650,RadicalRoot_3:50331651,RadicalCustom_1:50397184,RadicalCustom_2:50397185,Integral:67108864,IntegralSubSup:67108865,IntegralCenterSubSup:67108866,IntegralDouble:67108867,IntegralDoubleSubSup:67108868,IntegralDoubleCenterSubSup:67108869,IntegralTriple:67108870,IntegralTripleSubSup:67108871,IntegralTripleCenterSubSup:67108872,IntegralOriented:67174400,IntegralOrientedSubSup:67174401,IntegralOrientedCenterSubSup:67174402,IntegralOrientedDouble:67174403,IntegralOrientedDoubleSubSup:67174404,IntegralOrientedDoubleCenterSubSup:67174405,IntegralOrientedTriple:67174406,IntegralOrientedTripleSubSup:67174407,IntegralOrientedTripleCenterSubSup:67174408,Integral_dx:67239936,Integral_dy:67239937,Integral_dtheta:67239938,LargeOperator_Sum:83886080,LargeOperator_Sum_CenterSubSup:83886081,LargeOperator_Sum_SubSup:83886082,LargeOperator_Sum_CenterSub:83886083,LargeOperator_Sum_Sub:83886084, +LargeOperator_Prod:83951616,LargeOperator_Prod_CenterSubSup:83951617,LargeOperator_Prod_SubSup:83951618,LargeOperator_Prod_CenterSub:83951619,LargeOperator_Prod_Sub:83951620,LargeOperator_CoProd:83951621,LargeOperator_CoProd_CenterSubSup:83951622,LargeOperator_CoProd_SubSup:83951623,LargeOperator_CoProd_CenterSub:83951624,LargeOperator_CoProd_Sub:83951625,LargeOperator_Union:84017152,LargeOperator_Union_CenterSubSup:84017153,LargeOperator_Union_SubSup:84017154,LargeOperator_Union_CenterSub:84017155,LargeOperator_Union_Sub:84017156,LargeOperator_Intersection:84017157,LargeOperator_Intersection_CenterSubSup:84017158,LargeOperator_Intersection_SubSup:84017159,LargeOperator_Intersection_CenterSub:84017160,LargeOperator_Intersection_Sub:84017161,LargeOperator_Disjunction:84082688,LargeOperator_Disjunction_CenterSubSup:84082689,LargeOperator_Disjunction_SubSup:84082690,LargeOperator_Disjunction_CenterSub:84082691,LargeOperator_Disjunction_Sub:84082692,LargeOperator_Conjunction:84082693,LargeOperator_Conjunction_CenterSubSup:84082694,LargeOperator_Conjunction_SubSup:84082695,LargeOperator_Conjunction_CenterSub:84082696,LargeOperator_Conjunction_Sub:84082697,LargeOperator_Custom_1:84148224,LargeOperator_Custom_2:84148225,LargeOperator_Custom_3:84148226,LargeOperator_Custom_4:84148227,LargeOperator_Custom_5:84148228,Bracket_Round:100663296,Bracket_Square:100663297,Bracket_Curve:100663298,Bracket_Angle:100663299,Bracket_LowLim:100663300,Bracket_UppLim:100663301,Bracket_Line:100663302,Bracket_LineDouble:100663303,Bracket_Square_OpenOpen:100663304,Bracket_Square_CloseClose:100663305,Bracket_Square_CloseOpen:100663306,Bracket_SquareDouble:100663307,Bracket_Round_Delimiter_2:100728832,Bracket_Curve_Delimiter_2:100728833,Bracket_Angle_Delimiter_2:100728834,Bracket_Angle_Delimiter_3:100728835,Bracket_Round_OpenNone:100794368,Bracket_Round_NoneOpen:100794369,Bracket_Square_OpenNone:100794370,Bracket_Square_NoneOpen:100794371,Bracket_Curve_OpenNone:100794372,Bracket_Curve_NoneOpen:100794373,Bracket_Angle_OpenNone:100794374,Bracket_Angle_NoneOpen:100794375,Bracket_LowLim_OpenNone:100794376,Bracket_LowLim_NoneNone:100794377,Bracket_UppLim_OpenNone:100794378,Bracket_UppLim_NoneOpen:100794379,Bracket_Line_OpenNone:100794380,Bracket_Line_NoneOpen:100794381,Bracket_LineDouble_OpenNone:100794382,Bracket_LineDouble_NoneOpen:100794383,Bracket_SquareDouble_OpenNone:100794384,Bracket_SquareDouble_NoneOpen:100794385,Bracket_Custom_1:100859904,Bracket_Custom_2:100859905,Bracket_Custom_3:100859906,Bracket_Custom_4:100859907,Bracket_Custom_5:100925440,Bracket_Custom_6:100925441,Bracket_Custom_7:100925442,Function_Sin:117440512,Function_Cos:117440513,Function_Tan:117440514,Function_Csc:117440515,Function_Sec:117440516,Function_Cot:117440517,Function_1_Sin:117506048,Function_1_Cos:117506049,Function_1_Tan:117506050,Function_1_Csc:117506051,Function_1_Sec:117506052,Function_1_Cot:117506053,Function_Sinh:117571584,Function_Cosh:117571585,Function_Tanh:117571586,Function_Csch:117571587,Function_Sech:117571588,Function_Coth:117571589,Function_1_Sinh:117637120,Function_1_Cosh:117637121,Function_1_Tanh:117637122,Function_1_Csch:117637123,Function_1_Sech:117637124,Function_1_Coth:117637125,Function_Custom_1:117702656,Function_Custom_2:117702657,Function_Custom_3:117702658,Accent_Dot:134217728,Accent_DDot:134217729,Accent_DDDot:134217730,Accent_Hat:134217731,Accent_Check:134217732,Accent_Accent:134217733,Accent_Grave:134217734,Accent_Smile:134217735,Accent_Tilde:134217736,Accent_Bar:134217737,Accent_DoubleBar:134217738,Accent_CurveBracketTop:134217739,Accent_CurveBracketBot:134217740,Accent_GroupTop:134217741,Accent_GroupBot:134217742,Accent_ArrowL:134217743,Accent_ArrowR:134217744,Accent_ArrowD:134217745,Accent_HarpoonL:134217746,Accent_HarpoonR:134217747,Accent_BorderBox:134283264,Accent_BorderBoxCustom:134283265,Accent_BarTop:134348800,Accent_BarBot:134348801,Accent_Custom_1:134414336,Accent_Custom_2:134414337,Accent_Custom_3:134414338,LimitLog_LogBase:150994944,LimitLog_Log:150994945,LimitLog_Lim:150994946,LimitLog_Min:150994947,LimitLog_Max:150994948,LimitLog_Ln:150994949,LimitLog_Custom_1:151060480,LimitLog_Custom_2:151060481,Operator_ColonEquals:167772160,Operator_EqualsEquals:167772161,Operator_PlusEquals:167772162,Operator_MinusEquals:167772163,Operator_Definition:167772164,Operator_UnitOfMeasure:167772165,Operator_DeltaEquals:167772166,Operator_ArrowL_Top:167837696,Operator_ArrowR_Top:167837697,Operator_ArrowL_Bot:167837698,Operator_ArrowR_Bot:167837699,Operator_DoubleArrowL_Top:167837700,Operator_DoubleArrowR_Top:167837701,Operator_DoubleArrowL_Bot:167837702,Operator_DoubleArrowR_Bot:167837703,Operator_ArrowD_Top:167837704,Operator_ArrowD_Bot:167837705,Operator_DoubleArrowD_Top:167837706,Operator_DoubleArrowD_Bot:167837707,Operator_Custom_1:167903232,Operator_Custom_2:167903233,Matrix_1_2:184549376,Matrix_2_1:184549377,Matrix_1_3:184549378,Matrix_3_1:184549379,Matrix_2_2:184549380,Matrix_2_3:184549381,Matrix_3_2:184549382,Matrix_3_3:184549383,Matrix_Dots_Center:184614912,Matrix_Dots_Baseline:184614913,Matrix_Dots_Vertical:184614914,Matrix_Dots_Diagonal:184614915,Matrix_Identity_2:184680448,Matrix_Identity_2_NoZeros:184680449,Matrix_Identity_3:184680450,Matrix_Identity_3_NoZeros:184680451,Matrix_2_2_RoundBracket:184745984,Matrix_2_2_SquareBracket:184745985,Matrix_2_2_LineBracket:184745986,Matrix_2_2_DLineBracket:184745987,Matrix_Flat_Round:184811520,Matrix_Flat_Square:184811521},Common.define.chartData=_.extend(new function(){return{textLine:"Line",textColumn:"Column",textBar:"Bar",textArea:"Area",textPie:"Pie",textPoint:"XY (Scatter)",textStock:"Stock",textSurface:"Surface",textCharts:"Charts",textSparks:"Sparklines",textLineSpark:"Line",textColumnSpark:"Column",textWinLossSpark:"Win/Loss",getChartGroupData:function(t){return[{id:"menu-chart-group-bar",caption:this.textColumn,headername:t?this.textCharts:void 0},{id:"menu-chart-group-line",caption:this.textLine},{id:"menu-chart-group-pie",caption:this.textPie},{id:"menu-chart-group-hbar",caption:this.textBar},{id:"menu-chart-group-area",caption:this.textArea,inline:!0},{id:"menu-chart-group-scatter",caption:this.textPoint,inline:!0},{id:"menu-chart-group-stock",caption:this.textStock,inline:!0}]},getChartData:function(){return[{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barNormal,iconCls:"column-normal"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barStacked,iconCls:"column-stack"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barStackedPer,iconCls:"column-pstack"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barNormal3d,iconCls:"column-3d-normal"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barStacked3d,iconCls:"column-3d-stack"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barStackedPer3d,iconCls:"column-3d-pstack"},{group:"menu-chart-group-bar",type:Asc.c_oAscChartTypeSettings.barNormal3dPerspective,iconCls:"column-3d-normal-per"},{group:"menu-chart-group-line",type:Asc.c_oAscChartTypeSettings.lineNormal,iconCls:"line-normal"},{group:"menu-chart-group-line",type:Asc.c_oAscChartTypeSettings.lineStacked,iconCls:"line-stack"},{group:"menu-chart-group-line",type:Asc.c_oAscChartTypeSettings.lineStackedPer,iconCls:"line-pstack"},{group:"menu-chart-group-line",type:Asc.c_oAscChartTypeSettings.line3d,iconCls:"line-3d"},{group:"menu-chart-group-pie",type:Asc.c_oAscChartTypeSettings.pie,iconCls:"pie-normal"},{group:"menu-chart-group-pie",type:Asc.c_oAscChartTypeSettings.doughnut,iconCls:"pie-doughnut"},{group:"menu-chart-group-pie",type:Asc.c_oAscChartTypeSettings.pie3d,iconCls:"pie-3d-normal"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarNormal,iconCls:"bar-normal"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarStacked,iconCls:"bar-stack"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarStackedPer,iconCls:"bar-pstack"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarNormal3d,iconCls:"bar-3d-normal"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarStacked3d,iconCls:"bar-3d-stack"},{group:"menu-chart-group-hbar",type:Asc.c_oAscChartTypeSettings.hBarStackedPer3d,iconCls:"bar-3d-pstack"},{group:"menu-chart-group-area",type:Asc.c_oAscChartTypeSettings.areaNormal,iconCls:"area-normal"},{group:"menu-chart-group-area",type:Asc.c_oAscChartTypeSettings.areaStacked,iconCls:"area-stack"},{group:"menu-chart-group-area",type:Asc.c_oAscChartTypeSettings.areaStackedPer,iconCls:"area-pstack"},{group:"menu-chart-group-scatter",type:Asc.c_oAscChartTypeSettings.scatter,iconCls:"point-normal"},{group:"menu-chart-group-stock",type:Asc.c_oAscChartTypeSettings.stock,iconCls:"stock-normal"}]},getSparkGroupData:function(t){return[{id:"menu-chart-group-sparkcolumn",inline:!0,headername:t?this.textSparks:void 0},{id:"menu-chart-group-sparkline",inline:!0},{id:"menu-chart-group-sparkwin",inline:!0}]},getSparkData:function(){return[{group:"menu-chart-group-sparkcolumn",type:Asc.c_oAscSparklineType.Column,allowSelected:!0,iconCls:"spark-column",tip:this.textColumnSpark},{group:"menu-chart-group-sparkline",type:Asc.c_oAscSparklineType.Line,allowSelected:!0,iconCls:"spark-line",tip:this.textLineSpark},{group:"menu-chart-group-sparkwin",type:Asc.c_oAscSparklineType.Stacked,allowSelected:!0,iconCls:"spark-win",tip:this.textWinLossSpark}]}}},Common.define.chartData||{})}),define("text!documenteditor/main/app/template/Toolbar.template",[],function(){return'
    \n
    \n
    \n <%= tabsmarkup %>\n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n
    \n \n \n \n \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    '}),define("text!documenteditor/main/app/template/ToolbarView.template",[],function(){return'
    \n
    \n
    \n <%= tabsmarkup %>\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    '}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/Font",["backbone"],function(t){"use strict";Common.Models.Font=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),name:null,cloneid:null,imgidx:0,type:0}}})}),void 0===Common)var Common={};if(Common.Collections=Common.Collections||{},define("common/main/lib/collection/Fonts",["backbone","common/main/lib/model/Font"],function(t){"use strict";Common.Collections.Fonts=t.Collection.extend({model:Common.Models.Font,comparator:function(t,e){var i=t.get("name").toLowerCase(),n=e.get("name").toLowerCase();return i==n?0:i',"<% _.each(colors, function(color, index) { %>",'',"<% }) %>",""].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.id=e.options.id,this.cls=e.options.cls,this.style=e.options.style,this.colors=e.options.colors||[],this.value=e.options.value,e.options.el&&e.render()},render:function(t){var e=this;return e.rendered?this.cmpEl=e.$el||$(this.el):(this.cmpEl=$(this.template({id:this.id,cls:this.cls,style:this.style,colors:this.colors})),t?(this.setElement(t,!1),t.html(this.cmpEl)):e.$el.html(this.cmpEl)),e.rendered||e.cmpEl.on("click","span.color-item",e.itemClick.bind(e)),e.rendered=!0,this},itemClick:function(t){var e=$(t.target);this.select(e.attr("data-color"))},select:function(t,e){if(this.value!=t){var i=this;$("span.color-item",this.cmpEl).removeClass("selected"),this.value=t,t&&/#?[a-fA-F0-9]{6}/.test(t)&&(t=/#?([a-fA-F0-9]{6})/.exec(t)[1].toUpperCase(),$("span[data-color="+t+"]",this.cmpEl).addClass("selected"),e||i.trigger("select",i,this.value))}}})}),void 0===Common)var Common={};if(define("common/main/lib/component/DimensionPicker",["common/main/lib/component/BaseView"],function(){"use strict";Common.UI.DimensionPicker=Common.UI.BaseView.extend(function(){return{options:{itemSize:18,minRows:5,minColumns:5,maxRows:20,maxColumns:20},template:_.template(['
    ','
    0x0
    ','
    ','
    ','
    ','
    ',"
    ","
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.render(),this.cmpEl=e.$el||$(this.el);var i=this.cmpEl;e.itemSize=e.options.itemSize,e.minRows=e.options.minRows,e.minColumns=e.options.minColumns,e.maxRows=e.options.maxRows,e.maxColumns=e.options.maxColumns,e.curColumns=0,e.curRows=0;var n=function(t){e.setTableSize(Math.ceil((void 0===t.offsetX?t.originalEvent.layerX:t.offsetX*Common.Utils.zoom())/e.itemSize),Math.ceil((void 0===t.offsetY?t.originalEvent.layerY:t.offsetY*Common.Utils.zoom())/e.itemSize),t)},o=function(t){e.setTableSize(0,0,t)},s=function(t){e.trigger("select",e,e.curColumns,e.curRows,t)};if(i){var a=i.find(".dimension-picker-mousecatcher");e.areaUnHighLighted=i.find(".dimension-picker-unhighlighted"),e.areaHighLighted=i.find(".dimension-picker-highlighted"),e.areaStatus=i.find(".dimension-picker-status"),i.css({width:e.minColumns+"em"}),a.css("z-index",1),a.width(e.maxColumns+"em").height(e.maxRows+"em"),e.areaUnHighLighted.width(e.minColumns+"em").height(e.minRows+"em"),e.areaStatus.html(e.curColumns+" x "+e.curRows),e.areaStatus.width(e.areaUnHighLighted.width()),a.on("mousemove",n),e.areaHighLighted.on("mousemove",n),e.areaUnHighLighted.on("mousemove",n),a.on("mouseleave",o),e.areaHighLighted.on("mouseleave",o),e.areaUnHighLighted.on("mouseleave",o),a.on("click",s),e.areaHighLighted.on("click",s),e.areaUnHighLighted.on("click",s)}},render:function(){return(this.$el||$(this.el)).html(this.template()),this},setTableSize:function(t,e,i){t>this.maxColumns&&(t=this.maxColumns),e>this.maxRows&&(e=this.maxRows),this.curColumns==t&&this.curRows==e||(this.curColumns=t,this.curRows=e,this.areaHighLighted.width(this.curColumns+"em").height(this.curRows+"em"),this.areaUnHighLighted.width((this.curColumnsthis.maxColumns?this.maxColumns:this.curColumns+1)+"em").height((this.curRowsthis.maxRows?this.maxRows:this.curRows+1)+"em"),this.cmpEl.width(this.areaUnHighLighted.width()),this.areaStatus.html(this.curColumns+" x "+this.curRows),this.areaStatus.width(this.areaUnHighLighted.width()),this.trigger("change",this,this.curColumns,this.curRows,i))},getColumnsCount:function(){return this.curColumns},getRowsCount:function(){return this.curRows}}}())}),void 0===Common)var Common={};if(define("common/main/lib/component/ComboDataView",["common/main/lib/component/BaseView","common/main/lib/component/DataView"],function(){"use strict";Common.UI.ComboDataView=Common.UI.BaseView.extend({options:{id:null,cls:"",style:"",hint:!1,itemWidth:80,itemHeight:40,menuMaxHeight:300,enableKeyEvents:!1,beforeOpenHandler:null,additionalMenuItems:null,showLast:!0,minWidth:-1},template:_.template(['
    ','
    ','
    ',"
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t),this.id=this.options.id||Common.UI.getId(),this.cls=this.options.cls,this.style=this.options.style,this.hint=this.options.hint,this.store=this.options.store||new Common.UI.DataViewStore,this.itemWidth=this.options.itemWidth,this.itemHeight=this.options.itemHeight,this.menuMaxHeight=this.options.menuMaxHeight,this.beforeOpenHandler=this.options.beforeOpenHandler,this.showLast=this.options.showLast,this.rootWidth=0,this.rootHeight=0,this.rendered=!1,this.needFillComboView=!1,this.minWidth=this.options.minWidth,this.fieldPicker=new Common.UI.DataView({cls:"field-picker",allowScrollbar:!1,itemTemplate:_.template(['
    ','','<% if (typeof title !== "undefined") {%>','<%= title %>',"<% } %>","
    "].join(""))}),this.openButton=new Common.UI.Button({cls:"open-menu",menu:new Common.UI.Menu({menuAlign:"tl-tl",offset:[0,3],items:[{template:_.template('')}]})}),null!=this.options.additionalMenuItems&&(this.openButton.menu.items=this.openButton.menu.items.concat(this.options.additionalMenuItems)),this.menuPicker=new Common.UI.DataView({cls:"menu-picker",parentMenu:this.openButton.menu,restoreHeight:this.menuMaxHeight,style:"max-height: "+this.menuMaxHeight+"px;",enableKeyEvents:this.options.enableKeyEvents,store:this.store,itemTemplate:_.template(['
    ','','<% if (typeof title !== "undefined") {%>','<%= title %>',"<% } %>","
    "].join(""))}),setInterval(_.bind(this.checkSize,this),500),this.options.el&&this.render()},render:function(t){if(!this.rendered){var e=this;e.trigger("render:before",e),e.cmpEl=e.$el||$(e.el);var i=e.template({id:e.id,cls:e.cls,style:e.style});t?(e.setElement(t,!1),e.cmpEl=$(i),t.html(e.cmpEl)):e.cmpEl.html(i),e.rootWidth=e.cmpEl.width(),e.rootHeight=e.cmpEl.height(),e.fieldPicker.render($(".view",e.cmpEl)),e.openButton.render($(".button",e.cmpEl)),e.menuPicker.render($(".menu-picker-container",e.cmpEl)),e.openButton.menu.cmpEl&&e.openButton.menu.cmpEl&&(e.openButton.menu.menuAlignEl=e.cmpEl,e.openButton.menu.cmpEl.css("min-width",e.itemWidth),e.openButton.menu.on("show:before",_.bind(e.onBeforeShowMenu,e)),e.openButton.menu.on("show:after",_.bind(e.onAfterShowMenu,e)),e.openButton.cmpEl.on("hide.bs.dropdown",_.bind(e.onBeforeHideMenu,e)),e.openButton.cmpEl.on("hidden.bs.dropdown",_.bind(e.onAfterHideMenu,e))),e.options.hint&&(e.cmpEl.attr("data-toggle","tooltip"),e.cmpEl.tooltip({title:e.options.hint,placement:e.options.hintAnchor||"cursor"})),e.fieldPicker.on("item:select",_.bind(e.onFieldPickerSelect,e)),e.menuPicker.on("item:select",_.bind(e.onMenuPickerSelect,e)),e.fieldPicker.on("item:click",_.bind(e.onFieldPickerClick,e)),e.menuPicker.on("item:click",_.bind(e.onMenuPickerClick,e)),e.fieldPicker.on("item:contextmenu",_.bind(e.onPickerItemContextMenu,e)),e.menuPicker.on("item:contextmenu",_.bind(e.onPickerItemContextMenu,e)),e.fieldPicker.el.addEventListener("contextmenu",_.bind(e.onPickerComboContextMenu,e),!1),e.menuPicker.el.addEventListener("contextmenu",_.bind(e.onPickerComboContextMenu,e),!1),e.onResize(),e.rendered=!0,e.trigger("render:after",e)}return this},checkSize:function(){if(this.cmpEl&&this.cmpEl.is(":visible")){var t=this,e=this.cmpEl.width(),i=this.cmpEl.height();if(e div:not(.grouped-data):not(.ps-scrollbar-x-rail):not(.ps-scrollbar-y-rail)")[0]);a.length>0&&(n.itemMarginLeft=parseInt(a.css("margin-left")),n.itemMarginRight=parseInt(a.css("margin-right")),n.itemPaddingLeft=parseInt(a.css("padding-left")),n.itemPaddingRight=parseInt(a.css("padding-right")),n.itemBorderLeft=parseInt(a.css("border-left-width")),n.itemBorderRight=parseInt(a.css("border-right-width")))}var r=o.indexOf(t);if(r<0)return;var l=o.length,c=Math.floor(Math.max(s.width(),n.minWidth)/(n.itemWidth+(n.itemMarginLeft||0)+(n.itemMarginRight||0)+(n.itemPaddingLeft||0)+(n.itemPaddingRight||0)+(n.itemBorderLeft||0)+(n.itemBorderRight||0))),d=[];s.height()/n.itemHeight>2&&(c*=Math.floor(s.height()/n.itemHeight)),r=Math.floor(r/c)*c,l-r1?t/2:t)},setItemHeight:function(t){this.itemHeight!=t&&(this.itemHeight=window.devicePixelRatio>1?t/2:t)},removeTips:function(){var t=this.menuPicker;_.each(t.dataViewItems,function(t){var e=t.$el.data("bs.tooltip");e&&e.tip().remove()},t)}})}),void 0===Common)var Common={};if(define("common/main/lib/component/SynchronizeTip",["common/main/lib/component/BaseView"],function(){"use strict";Common.UI.SynchronizeTip=Common.UI.BaseView.extend(_.extend(function(){return{options:{target:$(document.body),text:"",placement:"right",showLink:!0},template:_.template(['
    <%= scope.placement %>">','
    ','
    ',"
    ",'
    <%= scope.text %>
    ','
    ',"
    ","<% if ( scope.showLink ) { %>",'',"<% } %>","
    ","
    "].join("")),initialize:function(t){this.textSynchronize+=Common.Utils.String.platformKey("Ctrl+S"),Common.UI.BaseView.prototype.initialize.call(this,t),this.target=this.options.target,this.text=_.isEmpty(this.options.text)?this.textSynchronize:this.options.text,this.textLink=_.isEmpty(this.options.textLink)?this.textDontShow:this.options.textLink,this.placement=this.options.placement,this.showLink=this.options.showLink},render:function(){return this.cmpEl||(this.cmpEl=$(this.template({scope:this})),$(document.body).append(this.cmpEl),this.cmpEl.find(".close").on("click",_.bind(function(){this.trigger("closeclick")},this)),this.cmpEl.find(".show-link label").on("click",_.bind(function(){this.trigger("dontshowclick")},this))),this.applyPlacement(),this},show:function(){this.cmpEl?(this.applyPlacement(),this.cmpEl.show()):this.render()},hide:function(){this.cmpEl&&this.cmpEl.hide()},close:function(){this.cmpEl&&this.cmpEl.remove()},applyPlacement:function(){var t=this.target.offset(),e=Common.Utils.innerHeight();if("document"==this.placement);else if("top"==this.placement)this.cmpEl.css({bottom:e-t.top+"px",right:Common.Utils.innerWidth()-t.left-this.target.width()/2+"px"});else if("target"==this.placement)this.cmpEl.css({top:t.top+5+"px",left:t.left+5+"px"});else{var i=t.top+this.target.height()/2,n=this.cmpEl.height();i+n>e&&(i=e-n),"left"==this.placement?this.cmpEl.css({top:i+"px",right:Common.Utils.innerWidth()-t.left-5+"px"}):this.cmpEl.css({top:i+"px",left:t.left+this.target.width()+"px"})}},isVisible:function(){return this.cmpEl&&this.cmpEl.is(":visible")},textDontShow:"Don't show this message again",textSynchronize:"The document has been changed by another user.
    Please click to save your changes and reload the updates."}}(),Common.UI.SynchronizeTip||{}))}),define("common/main/lib/component/Mixtbar",["backbone","common/main/lib/component/BaseView"],function(t){"use strict";Common.UI.Mixtbar=Common.UI.BaseView.extend(function(){function t(t){var e=$(t.currentTarget).find("> a[data-tab]").data("tab");this.dblclick_el==e&&(this.fireEvent("change:compact",[e]),this.dblclick_el=void 0)}function e(t){this.isFolded&&($(t.target).parents(".toolbar, #file-menu-panel").length||o.$bar&&o.$bar.hasClass("expanded")&&this.collapse())}var i,n,o={timeout:2e3},s={},a=function(t,e){var n=i.scrollLeft();(n||"right"==t)&&i.animate({scrollLeft:"left"==t?n-100:n+100},200)};return{$tabs:void 0,$panels:void 0,isFolded:!1,initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);this.$layout=$(t.template({tabsmarkup:_.template('
      <% for(var i in items) { %><% if (typeof items[i] == "object") { %>
    • <% if (items[i].extcls) print(\' \' + items[i].extcls) %>"><%= items[i].caption %>
    • <% } %><% } %>
    ')({items:t.tabs})})),s.tabs=t.tabs,$(document.body).on("click",e.bind(this)),Common.NotificationCenter.on("tab:visible",_.bind(function(t,e){this.setVisible(t,e)},this))},afterRender:function(){var e=this;i=e.$(".tabs > ul"),e.$tabs=i.find("> li"),e.$panels=e.$(".box-panels > .panel"),o.$bar=e.$(".toolbar");var s=e.$(".tabs .scroll.right");n=e.$(".tabs .scroll.left"),n.on("click",a.bind(this,"left")),s.on("click",a.bind(this,"right")),i.on("dblclick","> .ribtab",t.bind(this)),i.on("click","> .ribtab",e.onTabClick.bind(this))},isTabActive:function(t){var e=this.$tabs.filter(".active").find("> a");return e.length&&e.data("tab")==t},setFolded:function(t){this.isFolded=t;var e=this;if(this.isFolded)o.$box||(o.$box=e.$el.find(".box-controls")),o.$bar.addClass("folded z-clear").toggleClass("expanded",!1),o.$bar.find(".tabs .ribtab").removeClass("active"),o.$bar.on($.support.transition.end,function(t){o.$bar.hasClass("folded")&&!o.$bar.hasClass("expanded")&&o.$bar.toggleClass("z-clear",!0)}),o.$box.on({mouseleave:function(t){},mouseenter:function(t){}});else{o.$bar.removeClass("folded z-clear"),o.$box.off();var i=o.$box.find(".panel.active");if(i.length){var n=i.data("tab");e.$tabs.find("> a[data-tab="+n+"]").parent().toggleClass("active",!0)}else n=e.$tabs.siblings(":not(.x-lone):visible").first().find("> a[data-tab]").data("tab"),e.setTab(n)}},collapse:function(){Common.UI.Menu.Manager.hideAll(),this.isFolded&&o.$bar&&(o.$bar.removeClass("expanded"),o.$bar.find(".tabs .ribtab").removeClass("active"))},expand:function(){o.$bar.removeClass("z-clear"),o.$bar.addClass("expanded")},onResize:function(t){this.hasTabInvisible()?i.parent().hasClass("short")||i.parent().addClass("short"):i.parent().hasClass("short")&&i.parent().removeClass("short"),this.processPanelVisible()},onTabClick:function(t){var e=this,i=$(t.currentTarget),n=i.find("> a[data-tab]").data("tab");i.hasClass("x-lone")?e.isFolded&&e.collapse():i.hasClass("active")?e._timerSetTab||(e.dblclick_el=n,e.isFolded&&(e.collapse(),setTimeout(function(){e.dblclick_el=void 0},500))):(e._timerSetTab=!0,setTimeout(function(){e._timerSetTab=!1},500),e.setTab(n),e.processPanelVisible(null,!0),e.isFolded?e.dblclick_el=n:(e.dblclick_timer&&clearTimeout(e.dblclick_timer),e.dblclick_timer=setTimeout(function(){e.dblclick_el=n,delete e.dblclick_timer},500)))},setTab:function(t){var e=this;if(t||(this.isFolded?this.collapse():t=this.lastPanel),t){e.$tabs.removeClass("active"),e.$panels.removeClass("active");var i=this.$panels.filter("[data-tab="+t+"]");i.length&&(this.lastPanel=t,i.addClass("active")),i.length?e.isFolded&&e.expand():e.isFolded&&e.collapse();var n=this.$tabs.find("> a[data-tab="+t+"]").parent();n.length&&n.addClass("active"),this.fireEvent("tab:active",[t])}},addTab:function(t,e,n){function o(t){return s.tabs[t]?s.tabs[t].action:o(--t)}var a=_.template('');s.tabs[n+1]=t;var r=o(n),l=this.$tabs||this.$layout.find(".tabs"),c=l.find("a[data-tab="+r+"]");c.length&&(c.parent().after(a(t)),e&&(l=this.$panels||this.$layout.find(".box-panels > .panel"),c=l.filter("[data-tab="+r+"]"),c.length?c.after(e):e.appendTo(this.$layout.find(".box-panels"))),this.$tabs&&(this.$tabs=i.find("> li")),this.$panels&&(this.$panels=this.$el.find(".box-panels > .panel")))},isCompact:function(){return this.isFolded},hasTabInvisible:function(){if(i.length<1)return!1;var t=Math.round(i.offset().left),e=Math.round(t+i.width()),n=this.$tabs.filter(":visible:first").get(0);if(!n)return!1;var o=n.getBoundingClientRect();return Math.round(o.left)e)},processPanelVisible:function(t,e){function i(){var e=t||n.$panels.filter(".active");if(e&&e.length){var i=e.parents(".box-controls").width(),o=e.data(),s=o.rightedge,a=o.buttons,r=o.flex;if(s||(s=e.get(0).getBoundingClientRect().right),a||(a=[],_.each(e.find(".btn-slot .x-huge"),function(t){a.push($(t).closest(".btn-slot"))}),o.buttons=a),r||(r=[],_.each(e.find(".group.flex"),function(t){var e=$(t);r.push({el:e,width:e.attr("data-group-width")||e.attr("max-width")})}),o.flex=r),s>i){if(r.length>0)for(var l=0;lparseInt(c.css("min-width")))return;c.css("width",c.css("min-width"))}for(var l=a.length-1;l>=0;l--){var d=a[l];if(!d.hasClass("compactwidth")&&(d.addClass("compactwidth"),(s=e.get(0).getBoundingClientRect().right)<=i))break}o.rightedge=s}else{for(var l=0;li)){d.addClass("compactwidth"),s=e.get(0).getBoundingClientRect().right;break}}if(o.rightedge=s,r.length>0&&e.find(".btn-slot.compactwidth").length<1)for(var l=0;l a[data-tab="+t+"]").parent().css("display",e?"":"none"),this.onResize())}}}())}),define("documenteditor/main/app/view/Toolbar",["jquery","underscore","backbone","text!documenteditor/main/app/template/Toolbar.template","text!documenteditor/main/app/template/ToolbarView.template","common/main/lib/collection/Fonts","common/main/lib/component/Button","common/main/lib/component/ComboBox","common/main/lib/component/DataView","common/main/lib/component/ColorPalette","common/main/lib/component/ThemeColorPalette","common/main/lib/component/Menu","common/main/lib/component/DimensionPicker","common/main/lib/component/Window","common/main/lib/component/ComboBoxFonts","common/main/lib/component/ComboDataView","common/main/lib/component/SynchronizeTip","common/main/lib/component/Mixtbar"],function(t,e,i,n,o){"use strict";DE.Views.Toolbar=Common.UI.Mixtbar.extend(e.extend(function(){return{el:"#toolbar",events:{},initialize:function(){var t=this;return this.SchemeNames=[this.txtScheme1,this.txtScheme2,this.txtScheme3,this.txtScheme4,this.txtScheme5,this.txtScheme6,this.txtScheme7,this.txtScheme8,this.txtScheme9,this.txtScheme10,this.txtScheme11,this.txtScheme12,this.txtScheme13,this.txtScheme14,this.txtScheme15,this.txtScheme16,this.txtScheme17,this.txtScheme18,this.txtScheme19,this.txtScheme20,this.txtScheme21],this.paragraphControls=[],this.toolbarControls=[],this.textOnlyControls=[],this._state={hasCollaborativeChanges:void 0,previewmode:!1},Common.NotificationCenter.on("app:ready",t.onAppReady.bind(this)),this},applyLayout:function(i){var s=this;if(i.isEdit){Common.UI.Mixtbar.prototype.initialize.call(this,{template:e.template(n),tabs:[{caption:s.textTabFile,action:"file",extcls:"canedit",haspanel:!1},{caption:s.textTabHome,action:"home",extcls:"canedit"},{caption:s.textTabInsert,action:"ins",extcls:"canedit"},{caption:s.textTabLayout,action:"layout",extcls:"canedit"},{caption:s.textTabLinks,action:"links",extcls:"canedit"}]}),this.btnSaveCls="btn-save",this.btnSaveTip=this.tipSave+Common.Utils.String.platformKey("Ctrl+S"),this.btnPrint=new Common.UI.Button({id:"id-toolbar-btn-print",cls:"btn-toolbar",iconCls:"toolbar__icon btn-print no-mask",signals:["disabled"]}),this.toolbarControls.push(this.btnPrint),this.btnSave=new Common.UI.Button({id:"id-toolbar-btn-save",cls:"btn-toolbar",iconCls:"toolbar__icon no-mask "+this.btnSaveCls,signals:["disabled"]}),this.toolbarControls.push(this.btnSave),this.btnCollabChanges=this.btnSave,this.btnUndo=new Common.UI.Button({id:"id-toolbar-btn-undo",cls:"btn-toolbar",iconCls:"toolbar__icon btn-undo",signals:["disabled"]}),this.toolbarControls.push(this.btnUndo),this.btnRedo=new Common.UI.Button({id:"id-toolbar-btn-redo",cls:"btn-toolbar",iconCls:"toolbar__icon btn-redo",signals:["disabled"]}),this.toolbarControls.push(this.btnRedo),this.btnCopy=new Common.UI.Button({id:"id-toolbar-btn-copy",cls:"btn-toolbar",iconCls:"toolbar__icon btn-copy"}),this.toolbarControls.push(this.btnCopy),this.btnPaste=new Common.UI.Button({id:"id-toolbar-btn-paste",cls:"btn-toolbar",iconCls:"toolbar__icon btn-paste"}),this.paragraphControls.push(this.btnPaste),this.btnIncFontSize=new Common.UI.Button({id:"id-toolbar-btn-incfont",cls:"btn-toolbar",iconCls:"toolbar__icon btn-incfont"}),this.paragraphControls.push(this.btnIncFontSize),this.btnDecFontSize=new Common.UI.Button({id:"id-toolbar-btn-decfont",cls:"btn-toolbar",iconCls:"toolbar__icon btn-decfont"}),this.paragraphControls.push(this.btnDecFontSize),this.btnBold=new Common.UI.Button({id:"id-toolbar-btn-bold",cls:"btn-toolbar",iconCls:"toolbar__icon btn-bold",enableToggle:!0}),this.paragraphControls.push(this.btnBold),this.btnItalic=new Common.UI.Button({id:"id-toolbar-btn-italic",cls:"btn-toolbar",iconCls:"toolbar__icon btn-italic",enableToggle:!0}),this.paragraphControls.push(this.btnItalic),this.btnUnderline=new Common.UI.Button({id:"id-toolbar-btn-underline",cls:"btn-toolbar",iconCls:"toolbar__icon btn-underline",enableToggle:!0}),this.paragraphControls.push(this.btnUnderline),this.btnStrikeout=new Common.UI.Button({id:"id-toolbar-btn-strikeout",cls:"btn-toolbar",iconCls:"toolbar__icon btn-strikeout",enableToggle:!0}),this.paragraphControls.push(this.btnStrikeout),this.btnSuperscript=new Common.UI.Button({id:"id-toolbar-btn-superscript",cls:"btn-toolbar",iconCls:"toolbar__icon btn-superscript",enableToggle:!0,toggleGroup:"superscriptGroup"}),this.paragraphControls.push(this.btnSuperscript),this.btnSubscript=new Common.UI.Button({id:"id-toolbar-btn-subscript",cls:"btn-toolbar",iconCls:"toolbar__icon btn-subscript",enableToggle:!0,toggleGroup:"superscriptGroup"}),this.paragraphControls.push(this.btnSubscript),this.btnHighlightColor=new Common.UI.Button({id:"id-toolbar-btn-highlight",cls:"btn-toolbar",iconCls:"toolbar__icon btn-highlight",enableToggle:!0,allowDepress:!0,split:!0,menu:new Common.UI.Menu({style:"min-width: 100px;",items:[{template:e.template('
    ')},{caption:"--"},this.mnuHighlightTransparent=new Common.UI.MenuItem({caption:this.strMenuNoFill,checkable:!0})]})}),this.paragraphControls.push(this.btnHighlightColor),this.textOnlyControls.push(this.btnHighlightColor),this.btnFontColor=new Common.UI.Button({id:"id-toolbar-btn-fontcolor",cls:"btn-toolbar",iconCls:"toolbar__icon btn-fontcolor",split:!0,menu:new Common.UI.Menu({cls:"shifted-left",items:[{id:"id-toolbar-menu-auto-fontcolor",caption:this.textAutoColor,template:e.template('<%= caption %>')},{caption:"--"},{template:e.template('
    ')},{template:e.template(''+this.textNewColor+"")}]})}),this.paragraphControls.push(this.btnFontColor),this.btnParagraphColor=new Common.UI.Button({id:"id-toolbar-btn-paracolor",cls:"btn-toolbar",iconCls:"toolbar__icon btn-paracolor",split:!0,menu:new Common.UI.Menu({items:[{template:e.template('
    ')},{template:e.template(''+this.textNewColor+"")}]})}),this.paragraphControls.push(this.btnParagraphColor),this.textOnlyControls.push(this.btnParagraphColor),this.btnAlignLeft=new Common.UI.Button({id:"id-toolbar-btn-align-left",cls:"btn-toolbar",iconCls:"toolbar__icon btn-align-left",enableToggle:!0,allowDepress:!1,toggleGroup:"alignGroup"}),this.paragraphControls.push(this.btnAlignLeft),this.btnAlignCenter=new Common.UI.Button({id:"id-toolbar-btn-align-center",cls:"btn-toolbar",iconCls:"toolbar__icon btn-align-center",enableToggle:!0,allowDepress:!1,toggleGroup:"alignGroup"}),this.paragraphControls.push(this.btnAlignCenter),this.btnAlignRight=new Common.UI.Button({id:"id-toolbar-btn-align-right",cls:"btn-toolbar",iconCls:"toolbar__icon btn-align-right",enableToggle:!0,allowDepress:!1,toggleGroup:"alignGroup"}),this.paragraphControls.push(this.btnAlignRight),this.btnAlignJust=new Common.UI.Button({id:"id-toolbar-btn-align-just",cls:"btn-toolbar",iconCls:"toolbar__icon btn-align-just",enableToggle:!0,allowDepress:!1,toggleGroup:"alignGroup"}),this.paragraphControls.push(this.btnAlignJust),this.btnDecLeftOffset=new Common.UI.Button({id:"id-toolbar-btn-decoffset",cls:"btn-toolbar",iconCls:"toolbar__icon btn-decoffset"}),this.paragraphControls.push(this.btnDecLeftOffset),this.btnIncLeftOffset=new Common.UI.Button({id:"id-toolbar-btn-incoffset",cls:"btn-toolbar",iconCls:"toolbar__icon btn-incoffset"}),this.paragraphControls.push(this.btnIncLeftOffset),this.btnLineSpace=new Common.UI.Button({id:"id-toolbar-btn-linespace",cls:"btn-toolbar",iconCls:"toolbar__icon btn-linespace",menu:new Common.UI.Menu({style:"min-width: 60px;",items:[{caption:"1.0",value:1,checkable:!0,toggleGroup:"linesize"},{caption:"1.15",value:1.15,checkable:!0,toggleGroup:"linesize"},{caption:"1.5",value:1.5,checkable:!0,toggleGroup:"linesize"},{caption:"2.0",value:2,checkable:!0,toggleGroup:"linesize"},{caption:"2.5",value:2.5,checkable:!0,toggleGroup:"linesize"},{caption:"3.0",value:3,checkable:!0,toggleGroup:"linesize"}]})}),this.paragraphControls.push(this.btnLineSpace),this.btnShowHidenChars=new Common.UI.Button({id:"id-toolbar-btn-hidenchars",cls:"btn-toolbar",iconCls:"toolbar__icon btn-paragraph",enableToggle:!0,split:!0,menu:new Common.UI.Menu({style:"min-width: 60px;",items:[{caption:this.mniHiddenChars,value:"characters",checkable:!0},{caption:this.mniHiddenBorders,value:"table",checkable:!0}]})}),this.toolbarControls.push(this.btnShowHidenChars),this.btnMarkers=new Common.UI.Button({id:"id-toolbar-btn-markers",cls:"btn-toolbar",iconCls:"toolbar__icon btn-setmarkers",enableToggle:!0,toggleGroup:"markersGroup",split:!0,menu:!0}),this.paragraphControls.push(this.btnMarkers),this.textOnlyControls.push(this.btnMarkers),this.btnNumbers=new Common.UI.Button({id:"id-toolbar-btn-numbering",cls:"btn-toolbar",iconCls:"toolbar__icon btn-numbering",enableToggle:!0,toggleGroup:"markersGroup",split:!0,menu:!0}),this.paragraphControls.push(this.btnNumbers),this.textOnlyControls.push(this.btnNumbers),this.btnMultilevels=new Common.UI.Button({id:"id-toolbar-btn-multilevels",cls:"btn-toolbar",iconCls:"toolbar__icon btn-multilevels",menu:!0}),this.paragraphControls.push(this.btnMultilevels),this.textOnlyControls.push(this.btnMultilevels);var a=function(t){var e={};for(var i in t)e[i]="object"==typeof t[i]?a(t[i]):t[i];return e};this.mnuMarkersPicker={conf:{index:0},selectByIndex:function(t){this.conf.index=t},deselectAll:function(){this.conf.index=-1}},this.mnuNumbersPicker=a(this.mnuMarkersPicker),this.mnuMultilevelPicker=a(this.mnuMarkersPicker),this.btnInsertTable=new Common.UI.Button({id:"tlbtn-inserttable",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-inserttable",caption:s.capBtnInsTable,menu:new Common.UI.Menu({items:[{template:e.template('
    ')},{caption:this.mniCustomTable,value:"custom"},{caption:this.mniDrawTable,value:"draw",checkable:!0},{caption:this.mniEraseTable,value:"erase",checkable:!0}]})}),this.paragraphControls.push(this.btnInsertTable),this.btnInsertImage=new Common.UI.Button({id:"tlbtn-insertimage",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-insertimage",caption:s.capBtnInsImage,menu:new Common.UI.Menu({items:[{caption:this.mniImageFromFile,value:"file"},{cls:"cp-from-url",caption:this.mniImageFromUrl,value:"url"},{caption:this.mniImageFromStorage,value:"storage"}]})}),this.paragraphControls.push(this.btnInsertImage),this.btnInsertChart=new Common.UI.Button({id:"tlbtn-insertchart",cls:"btn-toolbar x-huge icon-top",caption:s.capBtnInsChart,iconCls:"toolbar__icon btn-insertchart",menu:!0}),this.paragraphControls.push(this.btnInsertChart),this.btnInsertText=new Common.UI.Button({id:"tlbtn-inserttext",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-text",caption:s.capBtnInsTextbox,enableToggle:!0}),this.paragraphControls.push(this.btnInsertText),this.btnInsertTextArt=new Common.UI.Button({id:"tlbtn-inserttextart",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-textart",caption:s.capBtnInsTextart,menu:new Common.UI.Menu({cls:"menu-shapes",items:[{template:e.template('
    ')}]})}),this.paragraphControls.push(this.btnInsertTextArt),this.btnEditHeader=new Common.UI.Button({id:"id-toolbar-btn-editheader",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-editheader",caption:s.capBtnInsHeader,menu:!0}),this.mnuPageNumberPosPicker={conf:{disabled:!1},isDisabled:function(){return this.conf.disabled},setDisabled:function(t){this.conf.disabled=t}},this.mnuPageNumCurrentPos=a(this.mnuPageNumberPosPicker),this.mnuInsertPageNum=a(this.mnuPageNumberPosPicker),this.mnuInsertPageCount=a(this.mnuPageNumberPosPicker),this.paragraphControls.push(this.mnuPageNumCurrentPos),this.paragraphControls.push(this.mnuInsertPageCount),this.toolbarControls.push(this.btnEditHeader),this.btnInsDateTime=new Common.UI.Button({id:"id-toolbar-btn-datetime",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-datetime",caption:s.capBtnDateTime}),this.paragraphControls.push(this.btnInsDateTime),this.btnBlankPage=new Common.UI.Button({id:"id-toolbar-btn-blankpage",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-blankpage",caption:s.capBtnBlankPage}),this.paragraphControls.push(this.btnBlankPage),this.btnInsertShape=new Common.UI.Button({id:"tlbtn-insertshape",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-insertshape",caption:s.capBtnInsShape,enableToggle:!0,menu:new Common.UI.Menu({cls:"menu-shapes"})}),this.paragraphControls.push(this.btnInsertShape),this.btnInsertEquation=new Common.UI.Button({id:"tlbtn-insertequation",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-insertequation",caption:s.capBtnInsEquation,split:!0,menu:new Common.UI.Menu({cls:"menu-shapes"})}),this.paragraphControls.push(this.btnInsertEquation),this.btnInsertSymbol=new Common.UI.Button({id:"tlbtn-insertsymbol",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-symbol",caption:s.capBtnInsSymbol}),this.paragraphControls.push(this.btnInsertSymbol),this.btnDropCap=new Common.UI.Button({id:"tlbtn-dropcap",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-dropcap",caption:s.capBtnInsDropcap,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",items:[{caption:this.textNone,iconCls:"menu__icon columns-one",checkable:!0,checkmark:!1,toggleGroup:"menuDropCap",value:Asc.c_oAscDropCap.None,checked:!0},{caption:this.textInText,iconCls:"menu__icon dropcap-intext",checkable:!0,checkmark:!1,toggleGroup:"menuDropCap",value:Asc.c_oAscDropCap.Drop},{caption:this.textInMargin,iconCls:"menu__icon dropcap-inmargin",checkable:!0,checkmark:!1,toggleGroup:"menuDropCap",value:Asc.c_oAscDropCap.Margin},{caption:"--"},this.mnuDropCapAdvanced=new Common.UI.MenuItem({caption:this.mniEditDropCap})]})}),this.paragraphControls.push(this.btnDropCap),this.btnContentControls=new Common.UI.Button({id:"tlbtn-controls",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-controls",caption:s.capBtnInsControls,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",items:[{caption:this.textPlainControl,iconCls:"menu__icon cc-plaintext",value:"plain"},{caption:this.textRichControl,iconCls:"menu__icon cc-richtext",value:"rich"},{caption:this.textPictureControl,value:"picture"},{caption:this.textComboboxControl,value:"combobox"},{caption:this.textDropdownControl,value:"dropdown"},{caption:this.textDateControl,value:"date"},{caption:this.textCheckboxControl,value:"checkbox"},{caption:"--"},{caption:this.textRemoveControl,iconCls:"menu__icon cc-remove",value:"remove"},{caption:"--"},{caption:this.mniEditControls,value:"settings"},{caption:this.mniHighlightControls,value:"highlight",menu:new Common.UI.Menu({menuAlign:"tl-tr",items:[this.mnuNoControlsColor=new Common.UI.MenuItem({id:"id-toolbar-menu-no-highlight-controls",caption:this.textNoHighlight,checkable:!0}),{caption:"--"},{template:e.template('
    ')},{template:e.template(''+this.textNewColor+"")}]})}]})}),this.btnColumns=new Common.UI.Button({id:"tlbtn-columns",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-columns",caption:s.capBtnColumns,menu:new Common.UI.Menu({cls:"ppm-toolbar shifted-right",items:[{caption:this.textColumnsOne,iconCls:"menu__icon columns-one",checkable:!0,checkmark:!1,toggleGroup:"menuColumns",value:0},{caption:this.textColumnsTwo,iconCls:"menu__icon columns-two",checkable:!0,checkmark:!1,toggleGroup:"menuColumns",value:1},{caption:this.textColumnsThree,iconCls:"menu__icon columns-three",checkable:!0,checkmark:!1,toggleGroup:"menuColumns",value:2},{caption:this.textColumnsLeft,iconCls:"menu__icon columns-left",checkmark:!1,checkable:!0,toggleGroup:"menuColumns",value:3},{caption:this.textColumnsRight,iconCls:"menu__icon columns-right",checkmark:!1,checkable:!0,toggleGroup:"menuColumns",value:4},{caption:"--"},{caption:this.textColumnsCustom,value:"advanced"}]})}),this.paragraphControls.push(this.btnColumns),this.btnPageOrient=new Common.UI.Button({id:"tlbtn-pageorient",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-pageorient",caption:s.capBtnPageOrient,menu:new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:this.textPortrait,iconCls:"menu__icon page-portrait",checkable:!0,checkmark:!1,toggleGroup:"menuOrient",value:!0},{caption:this.textLandscape,iconCls:"menu__icon page-landscape",checkable:!0,checkmark:!1,toggleGroup:"menuOrient",value:!1}]})}),this.toolbarControls.push(this.btnPageOrient);var r=e.template('
    <%= caption %>
    <% if (options.value !== null) { %>
    <% } %>
    ");this.btnPageMargins=new Common.UI.Button({id:"tlbtn-pagemargins",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-pagemargins",caption:s.capBtnMargins,menu:new Common.UI.Menu({items:[{caption:this.textMarginsLast,checkable:!0,template:r,toggleGroup:"menuPageMargins"},{caption:this.textMarginsNormal,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[20,30,20,15]},{caption:this.textMarginsUsNormal,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[25.4,25.4,25.4,25.4]},{caption:this.textMarginsNarrow,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[12.7,12.7,12.7,12.7]},{caption:this.textMarginsModerate,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[25.4,19.1,25.4,19.1]},{caption:this.textMarginsWide,checkable:!0,template:r,toggleGroup:"menuPageMargins",value:[25.4,50.8,25.4,50.8]},{caption:"--"},{caption:this.textPageMarginsCustom,value:"advanced"}]})}),this.toolbarControls.push(this.btnPageMargins);var l=e.template('
    <%= caption %>
    <%= parseFloat(Common.Utils.Metric.fnRecalcFromMM(options.value[0]).toFixed(2)) %> <%= Common.Utils.Metric.getCurrentMetricName() %> x <%= parseFloat(Common.Utils.Metric.fnRecalcFromMM(options.value[1]).toFixed(2)) %> <%= Common.Utils.Metric.getCurrentMetricName() %>
    ');this.btnPageSize=new Common.UI.Button({id:"tlbtn-pagesize",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-pagesize",caption:s.capBtnPageSize,menu:new Common.UI.Menu({restoreHeight:!0,items:[{caption:"US Letter",subtitle:"21,59cm x 27,94cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[215.9,279.4]},{caption:"US Legal",subtitle:"21,59cm x 35,56cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[215.9,355.6]},{caption:"A4",subtitle:"21cm x 29,7cm", +template:l,checkable:!0,toggleGroup:"menuPageSize",value:[210,297],checked:!0},{caption:"A5",subtitle:"14,81cm x 20,99cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[148,210]},{caption:"B5",subtitle:"17,6cm x 25,01cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[176,250]},{caption:"Envelope #10",subtitle:"10,48cm x 24,13cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[104.8,241.3]},{caption:"Envelope DL",subtitle:"11,01cm x 22,01cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[110,220]},{caption:"Tabloid",subtitle:"27,94cm x 43,17cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[279.4,431.8]},{caption:"A3",subtitle:"29,7cm x 42,01cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[297,420]},{caption:"Tabloid Oversize",subtitle:"30,48cm x 45,71cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[304.8,457.1]},{caption:"ROC 16K",subtitle:"19,68cm x 27,3cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[196.8,273]},{caption:"Envelope Choukei 3",subtitle:"11,99cm x 23,49cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[119.9,234.9]},{caption:"Super B/A3",subtitle:"33,02cm x 48,25cm",template:l,checkable:!0,toggleGroup:"menuPageSize",value:[330.2,482.5]},{caption:"--"},{caption:this.textPageSizeCustom,value:"advanced"}]})}),this.toolbarControls.push(this.btnPageSize),this.btnLineNumbers=new Common.UI.Button({id:"tlbtn-line-numbers",cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-line-numbering",caption:s.capBtnLineNumbers,menu:new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:this.textNone,checkable:!0,toggleGroup:"menuLineNumbers",value:0},{caption:this.textContinuous,checkable:!0,toggleGroup:"menuLineNumbers",value:1},{caption:this.textRestartEachPage,checkable:!0,toggleGroup:"menuLineNumbers",value:2},{caption:this.textRestartEachSection,checkable:!0,toggleGroup:"menuLineNumbers",value:3},{caption:this.textSuppressForCurrentParagraph,checkable:!0,allowDepress:!0,value:4},{caption:"--"},{caption:this.textCustomLineNumbers,value:5}]})}),this.btnClearStyle=new Common.UI.Button({id:"id-toolbar-btn-clearstyle",cls:"btn-toolbar",iconCls:"toolbar__icon btn-clearstyle"}),this.toolbarControls.push(this.btnClearStyle),this.btnCopyStyle=new Common.UI.Button({id:"id-toolbar-btn-copystyle",cls:"btn-toolbar",iconCls:"toolbar__icon btn-copystyle",enableToggle:!0}),this.toolbarControls.push(this.btnCopyStyle),this.btnColorSchemas=new Common.UI.Button({id:"id-toolbar-btn-colorschemas",cls:"btn-toolbar",iconCls:"toolbar__icon btn-colorschemas",menu:new Common.UI.Menu({cls:"shifted-left",items:[],restoreHeight:!0})}),this.toolbarControls.push(this.btnColorSchemas),this.btnMailRecepients=new Common.UI.Button({id:"id-toolbar-btn-mailrecepients",cls:"btn-toolbar",iconCls:"toolbar__icon btn-mailmerge"}),s.btnImgAlign=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-align",caption:s.capImgAlign,menu:!0}),s.btnImgGroup=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-group",caption:s.capImgGroup,menu:!0}),s.btnImgForward=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-frwd",caption:s.capImgForward,split:!0,menu:!0}),s.btnImgBackward=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-bkwd",caption:s.capImgBackward,split:!0,menu:!0}),s.btnImgWrapping=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-img-wrap",caption:s.capImgWrapping,menu:!0}),s.btnWatermark=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"toolbar__icon btn-watermark",caption:s.capBtnWatermark,menu:new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:this.textEditWatermark,value:"edit"},{caption:this.textRemWatermark,value:"remove"}]})}),s.toolbarControls.push(s.btnImgAlign,s.btnImgGroup,s.btnImgForward,s.btnImgBackward,s.btnImgWrapping,s.btnWatermark),this.mnuLineSpace=this.btnLineSpace.menu,this.mnuNonPrinting=this.btnShowHidenChars.menu,this.mnuInsertTable=this.btnInsertTable.menu,this.mnuInsertImage=this.btnInsertImage.menu,this.mnuPageSize=this.btnPageSize.menu,this.mnuColorSchema=this.btnColorSchemas.menu,this.cmbFontSize=new Common.UI.ComboBox({cls:"input-group-nr",menuStyle:"min-width: 55px;",hint:this.tipFontSize,data:[{value:8,displayValue:"8"},{value:9,displayValue:"9"},{value:10,displayValue:"10"},{value:11,displayValue:"11"},{value:12,displayValue:"12"},{value:14,displayValue:"14"},{value:16,displayValue:"16"},{value:18,displayValue:"18"},{value:20,displayValue:"20"},{value:22,displayValue:"22"},{value:24,displayValue:"24"},{value:26,displayValue:"26"},{value:28,displayValue:"28"},{value:36,displayValue:"36"},{value:48,displayValue:"48"},{value:72,displayValue:"72"},{value:96,displayValue:"96"}]}),this.paragraphControls.push(this.cmbFontSize),this.cmbFontName=new Common.UI.ComboBoxFonts({cls:"input-group-nr",menuCls:"scrollable-menu",menuStyle:"min-width: 325px;",hint:this.tipFontName,store:new Common.Collections.Fonts}),this.paragraphControls.push(this.cmbFontName),this.listStylesAdditionalMenuItem=new Common.UI.MenuItem({template:e.template('
    ")}),this.listStyles=new Common.UI.ComboDataView({cls:"combo-styles",itemWidth:104,itemHeight:38,enableKeyEvents:!0,additionalMenuItems:[this.listStylesAdditionalMenuItem],beforeOpenHandler:function(e){var i=this,n=i.openButton.menu;if(n.cmpEl){var o=t(i.cmpEl.find(".dataview.inner .style").get(0)).parent(),s=o.is(":visible")?parseInt(o.css("width")):i.itemWidth+parseInt(o.css("padding-left"))+parseInt(o.css("padding-right"))+parseInt(o.css("border-left-width"))+parseInt(o.css("border-right-width")),a=i.menuPicker.store.length>=6?6:i.menuPicker.store.length,r=Math.min(i.menuPicker.store.length,Math.round(t(".dataview",t(i.fieldPicker.el)).width()/(-1+s)+.5));r=r','
    ',""].join("")),this.listStyles.menuPicker.itemTemplate=e.template(['
    ','
    ',"
    "].join("")),this.paragraphControls.push(this.listStyles),this.textOnlyControls.push(this.listStyles),e.each(this.toolbarControls.concat(this.paragraphControls),function(t){e.isFunction(t.setDisabled)&&t.setDisabled(!0)}),this.btnMailRecepients.setDisabled(!0);var c=new Common.UI.MenuItem({caption:s.textStyleMenuUpdate}).on("click",e.bind(s.onStyleMenuUpdate,s)),d=new Common.UI.MenuItem({caption:s.textStyleMenuDelete}).on("click",e.bind(s.onStyleMenuDelete,s)),h=new Common.UI.MenuItem({caption:s.textStyleMenuRestore}).on("click",e.bind(s.onStyleMenuDelete,s)),p=new Common.UI.MenuItem({caption:s.textStyleMenuRestoreAll}).on("click",e.bind(s.onStyleMenuRestoreAll,s)),m=new Common.UI.MenuItem({caption:s.textStyleMenuDeleteAll}).on("click",e.bind(s.onStyleMenuDeleteAll,s));null==this.styleMenu&&(this.styleMenu=new Common.UI.Menu({items:[c,d,h,p,m]})),this.on("render:after",e.bind(this.onToolbarAfterRender,this))}else Common.UI.Mixtbar.prototype.initialize.call(this,{template:e.template(o),tabs:[{caption:s.textTabFile,action:"file",haspanel:!1}]});return this},render:function(e){var i=this;if(this.fireEvent("render:before",[this]),i.isCompactView=e.isCompactView,e.isEdit?i.$el.html(i.rendererComponents(i.$layout)):(i.$layout.find(".canedit").hide(),i.$layout.addClass("folded"),i.$el.html(i.$layout)),this.fireEvent("render:after",[this]),Common.UI.Mixtbar.prototype.afterRender.call(this),Common.NotificationCenter.on({"window:resize":function(){Common.UI.Mixtbar.prototype.onResize.apply(i,arguments)}}),e.isEdit){this.showSynchTip=!Common.localStorage.getBool("de-hide-synch"),this.needShowSynchTip=!1,i.setTab("home");var n=Common.localStorage.getItem("de-pgmargins-top"),o=Common.localStorage.getItem("de-pgmargins-left"),s=Common.localStorage.getItem("de-pgmargins-bottom"),a=Common.localStorage.getItem("de-pgmargins-right");if(null!==n&&null!==o&&null!==s&&null!==a){var r=this.btnPageMargins.menu.items[0];r.options.value=r.value=[parseFloat(n),parseFloat(o),parseFloat(s),parseFloat(a)],r.setVisible(!0),t(r.el).html(r.template({id:Common.UI.getId(),caption:r.caption,options:r.options}))}else this.btnPageMargins.menu.items[0].setVisible(!1)}return i.isCompactView&&i.setFolded(!0),this},onTabClick:function(e){var i=this,n=t(e.currentTarget).find("> a[data-tab]").data("tab"),o=i.isTabActive("file");Common.UI.Mixtbar.prototype.onTabClick.apply(i,arguments),o?i.fireEvent("file:close"):"file"==n&&(i.fireEvent("file:open"),i.setTab(n)),i.isTabActive("home")&&i.fireEvent("home:open")},rendererComponents:function(e){var i=t(e),n=function(t,e){Common.Utils.injectComponent(i.findById(t),e)};return n("#slot-field-fontname",this.cmbFontName),n("#slot-field-fontsize",this.cmbFontSize),n("#slot-btn-print",this.btnPrint),n("#slot-btn-save",this.btnSave),n("#slot-btn-undo",this.btnUndo),n("#slot-btn-redo",this.btnRedo),n("#slot-btn-copy",this.btnCopy),n("#slot-btn-paste",this.btnPaste),n("#slot-btn-incfont",this.btnIncFontSize),n("#slot-btn-decfont",this.btnDecFontSize),n("#slot-btn-bold",this.btnBold),n("#slot-btn-italic",this.btnItalic),n("#slot-btn-underline",this.btnUnderline),n("#slot-btn-strikeout",this.btnStrikeout),n("#slot-btn-superscript",this.btnSuperscript),n("#slot-btn-subscript",this.btnSubscript),n("#slot-btn-highlight",this.btnHighlightColor),n("#slot-btn-fontcolor",this.btnFontColor),n("#slot-btn-align-left",this.btnAlignLeft),n("#slot-btn-align-center",this.btnAlignCenter),n("#slot-btn-align-right",this.btnAlignRight),n("#slot-btn-align-just",this.btnAlignJust),n("#slot-btn-incoffset",this.btnIncLeftOffset),n("#slot-btn-decoffset",this.btnDecLeftOffset),n("#slot-btn-linespace",this.btnLineSpace),n("#slot-btn-hidenchars",this.btnShowHidenChars),n("#slot-btn-markers",this.btnMarkers),n("#slot-btn-numbering",this.btnNumbers),n("#slot-btn-multilevels",this.btnMultilevels),n("#slot-btn-instable",this.btnInsertTable),n("#slot-btn-insimage",this.btnInsertImage),n("#slot-btn-inschart",this.btnInsertChart),n("#slot-btn-instext",this.btnInsertText),n("#slot-btn-instextart",this.btnInsertTextArt),n("#slot-btn-dropcap",this.btnDropCap),n("#slot-btn-controls",this.btnContentControls),n("#slot-btn-columns",this.btnColumns),n("#slot-btn-line-numbers",this.btnLineNumbers),n("#slot-btn-editheader",this.btnEditHeader),n("#slot-btn-datetime",this.btnInsDateTime),n("#slot-btn-blankpage",this.btnBlankPage),n("#slot-btn-insshape",this.btnInsertShape),n("#slot-btn-insequation",this.btnInsertEquation),n("#slot-btn-inssymbol",this.btnInsertSymbol),n("#slot-btn-pageorient",this.btnPageOrient),n("#slot-btn-pagemargins",this.btnPageMargins),n("#slot-btn-pagesize",this.btnPageSize),n("#slot-btn-clearstyle",this.btnClearStyle),n("#slot-btn-copystyle",this.btnCopyStyle),n("#slot-btn-colorschemas",this.btnColorSchemas),n("#slot-btn-paracolor",this.btnParagraphColor),n("#slot-field-styles",this.listStyles),n("#slot-btn-mailrecepients",this.btnMailRecepients),n("#slot-img-align",this.btnImgAlign),n("#slot-img-group",this.btnImgGroup),n("#slot-img-movefrwd",this.btnImgForward),n("#slot-img-movebkwd",this.btnImgBackward),n("#slot-img-wrapping",this.btnImgWrapping),n("#slot-btn-watermark",this.btnWatermark),this.btnsPageBreak=Common.Utils.injectButtons(i.find(".btn-slot.btn-pagebreak"),"","toolbar__icon btn-pagebreak",this.capBtnInsPagebreak,void 0,!0,!0),Array.prototype.push.apply(this.paragraphControls,this.btnsPageBreak),i},onAppReady:function(t){var e=this;new Promise(function(t,e){t()}).then(function(){if(t.isEdit){e.btnsPageBreak.forEach(function(t){t.updateHint([e.textInsPageBreak,e.tipPageBreak]);var i=new Common.UI.Menu({menuAlign:"tl-tr",items:[{caption:e.textNextPage,value:Asc.c_oAscSectionBreakType.NextPage},{caption:e.textContPage,value:Asc.c_oAscSectionBreakType.Continuous},{caption:e.textEvenPage,value:Asc.c_oAscSectionBreakType.EvenPage},{caption:e.textOddPage,value:Asc.c_oAscSectionBreakType.OddPage}]}),n=new Common.UI.Menu({items:[{caption:e.textInsPageBreak,value:"page"},{caption:e.textInsColumnBreak,value:"column"},{caption:e.textInsSectionBreak,value:"section",menu:i}]});t.setMenu(n)});var i=DE.getController("DocumentHolder").getView();e.btnImgForward.updateHint(e.tipSendForward),e.btnImgForward.setMenu(new Common.UI.Menu({items:[{caption:i.textArrangeFront,iconCls:"menu__icon arrange-front",valign:Asc.c_oAscChangeLevel.BringToFront},{caption:i.textArrangeForward,iconCls:"menu__icon arrange-forward",valign:Asc.c_oAscChangeLevel.BringForward}]})),e.btnImgBackward.updateHint(e.tipSendBackward),e.btnImgBackward.setMenu(new Common.UI.Menu({items:[{caption:i.textArrangeBack,iconCls:"menu__icon arrange-back",valign:Asc.c_oAscChangeLevel.SendToBack},{caption:i.textArrangeBackward,iconCls:"menu__icon arrange-backward",valign:Asc.c_oAscChangeLevel.BringBackward}]})),e.btnImgAlign.updateHint(e.tipImgAlign),e.mniAlignToPage=new Common.UI.MenuItem({caption:e.txtPageAlign,checkable:!0,toggleGroup:"imgalign",value:-1}).on("click",function(t){Common.Utils.InternalSettings.set("de-img-align-to",1)}),e.mniAlignToMargin=new Common.UI.MenuItem({caption:e.txtMarginAlign,checkable:!0,toggleGroup:"imgalign",value:-1}).on("click",function(t){Common.Utils.InternalSettings.set("de-img-align-to",2)}),e.mniAlignObjects=new Common.UI.MenuItem({caption:e.txtObjectsAlign,checkable:!0,toggleGroup:"imgalign",value:-1}).on("click",function(t){Common.Utils.InternalSettings.set("de-img-align-to",3)}),e.mniDistribHor=new Common.UI.MenuItem({caption:e.txtDistribHor,iconCls:"menu__icon shape-distribute-hor",value:6}),e.mniDistribVert=new Common.UI.MenuItem({caption:e.txtDistribVert,iconCls:"menu__icon shape-distribute-vert",value:7}),e.btnImgAlign.setMenu(new Common.UI.Menu({cls:"shifted-right",items:[{caption:i.textShapeAlignLeft,iconCls:"menu__icon shape-align-left",value:Asc.c_oAscAlignShapeType.ALIGN_LEFT},{caption:i.textShapeAlignCenter,iconCls:"menu__icon shape-align-center",value:Asc.c_oAscAlignShapeType.ALIGN_CENTER},{caption:i.textShapeAlignRight,iconCls:"menu__icon shape-align-right",value:Asc.c_oAscAlignShapeType.ALIGN_RIGHT},{caption:i.textShapeAlignTop,iconCls:"menu__icon shape-align-top",value:Asc.c_oAscAlignShapeType.ALIGN_TOP},{caption:i.textShapeAlignMiddle,iconCls:"menu__icon shape-align-middle",value:Asc.c_oAscAlignShapeType.ALIGN_MIDDLE},{caption:i.textShapeAlignBottom,iconCls:"menu__icon shape-align-bottom",value:Asc.c_oAscAlignShapeType.ALIGN_BOTTOM},{caption:"--"},e.mniDistribHor,e.mniDistribVert,{caption:"--"},e.mniAlignToPage,e.mniAlignToMargin,e.mniAlignObjects]})),e.btnImgGroup.updateHint(e.tipImgGroup),e.btnImgGroup.setMenu(new Common.UI.Menu({items:[{caption:i.txtGroup,iconCls:"menu__icon shape-group",groupval:1},{caption:i.txtUngroup,iconCls:"menu__icon shape-ungroup",groupval:-1}]})),e.btnImgWrapping.updateHint(e.tipImgWrapping),e.btnImgWrapping.setMenu(new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:i.txtInline,iconCls:"menu__icon wrap-inline",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Inline,checkmark:!1,checkable:!0},{caption:i.txtSquare,iconCls:"menu__icon wrap-square",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Square,checkmark:!1,checkable:!0},{caption:i.txtTight,iconCls:"menu__icon wrap-tight",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Tight,checkmark:!1,checkable:!0},{caption:i.txtThrough,iconCls:"menu__icon wrap-through",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Through,checkmark:!1,checkable:!0},{caption:i.txtTopAndBottom,iconCls:"menu__icon wrap-topandbottom",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.TopAndBottom,checkmark:!1,checkable:!0},{caption:i.txtInFront,iconCls:"menu__icon wrap-infront",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.InFront,checkmark:!1,checkable:!0},{caption:i.txtBehind,iconCls:"menu__icon wrap-behind",toggleGroup:"imgwrapping",wrapType:Asc.c_oAscWrapStyle2.Behind,checkmark:!1,checkable:!0}]})),e.btnWatermark.updateHint(e.tipWatermark),!t.canFeatureContentControl&&e.btnContentControls.cmpEl&&e.btnContentControls.cmpEl.parents(".group").hide().prev(".separator").hide()}})},createDelayedElements:function(){this.api&&(this.mnuNonPrinting.items[0].setChecked(this.api.get_ShowParaMarks(),!0),this.mnuNonPrinting.items[1].setChecked(this.api.get_ShowTableEmptyLine(),!0),this.btnShowHidenChars.toggle(this.mnuNonPrinting.items[0].checked,!0),this.updateMetricUnit()),this.btnPrint.updateHint(this.tipPrint+Common.Utils.String.platformKey("Ctrl+P")),this.btnSave.updateHint(this.btnSaveTip),this.btnUndo.updateHint(this.tipUndo+Common.Utils.String.platformKey("Ctrl+Z")),this.btnRedo.updateHint(this.tipRedo+Common.Utils.String.platformKey("Ctrl+Y")),this.btnCopy.updateHint(this.tipCopy+Common.Utils.String.platformKey("Ctrl+C")),this.btnPaste.updateHint(this.tipPaste+Common.Utils.String.platformKey("Ctrl+V")),this.btnIncFontSize.updateHint(this.tipIncFont+Common.Utils.String.platformKey("Ctrl+]")),this.btnDecFontSize.updateHint(this.tipDecFont+Common.Utils.String.platformKey("Ctrl+[")),this.btnBold.updateHint(this.textBold+Common.Utils.String.platformKey("Ctrl+B")),this.btnItalic.updateHint(this.textItalic+Common.Utils.String.platformKey("Ctrl+I")),this.btnUnderline.updateHint(this.textUnderline+Common.Utils.String.platformKey("Ctrl+U")),this.btnStrikeout.updateHint(this.textStrikeout),this.btnSuperscript.updateHint(this.textSuperscript),this.btnSubscript.updateHint(this.textSubscript),this.btnHighlightColor.updateHint(this.tipHighlightColor),this.btnFontColor.updateHint(this.tipFontColor),this.btnParagraphColor.updateHint(this.tipPrColor),this.btnAlignLeft.updateHint(this.tipAlignLeft+Common.Utils.String.platformKey("Ctrl+L")),this.btnAlignCenter.updateHint(this.tipAlignCenter+Common.Utils.String.platformKey("Ctrl+E")),this.btnAlignRight.updateHint(this.tipAlignRight+Common.Utils.String.platformKey("Ctrl+R")),this.btnAlignJust.updateHint(this.tipAlignJust+Common.Utils.String.platformKey("Ctrl+J")),this.btnDecLeftOffset.updateHint(this.tipDecPrLeft+Common.Utils.String.platformKey("Ctrl+Shift+M")),this.btnIncLeftOffset.updateHint(this.tipIncPrLeft+Common.Utils.String.platformKey("Ctrl+M")),this.btnLineSpace.updateHint(this.tipLineSpace),this.btnShowHidenChars.updateHint(this.tipShowHiddenChars+Common.Utils.String.platformKey("Ctrl+*")),this.btnMarkers.updateHint(this.tipMarkers),this.btnNumbers.updateHint(this.tipNumbers),this.btnMultilevels.updateHint(this.tipMultilevels),this.btnInsertTable.updateHint(this.tipInsertTable),this.btnInsertImage.updateHint(this.tipInsertImage),this.btnInsertChart.updateHint(this.tipInsertChart),this.btnInsertText.updateHint(this.tipInsertText),this.btnInsertTextArt.updateHint(this.tipInsertTextArt),this.btnEditHeader.updateHint(this.tipEditHeader),this.btnInsDateTime.updateHint(this.tipDateTime),this.btnBlankPage.updateHint(this.tipBlankPage),this.btnInsertShape.updateHint(this.tipInsertShape),this.btnInsertEquation.updateHint(this.tipInsertEquation),this.btnInsertSymbol.updateHint(this.tipInsertSymbol),this.btnDropCap.updateHint(this.tipDropCap),this.btnContentControls.updateHint(this.tipControls),this.btnColumns.updateHint(this.tipColumns),this.btnPageOrient.updateHint(this.tipPageOrient),this.btnPageSize.updateHint(this.tipPageSize),this.btnPageMargins.updateHint(this.tipPageMargins),this.btnLineNumbers.updateHint(this.tipLineNumbers),this.btnClearStyle.updateHint(this.tipClearStyle),this.btnCopyStyle.updateHint(this.tipCopyStyle+Common.Utils.String.platformKey("Ctrl+Shift+C")),this.btnColorSchemas.updateHint(this.tipColorSchemas),this.btnMailRecepients.updateHint(this.tipMailRecepients);var i=this;this.btnMarkers.setMenu(new Common.UI.Menu({cls:"shifted-left",style:"min-width: 139px",items:[{template:e.template('')},this.mnuMarkerSettings=new Common.UI.MenuItem({caption:this.textListSettings,disabled:0==(this.mnuMarkersPicker.conf.index||0),value:"settings"})]})),this.btnNumbers.setMenu(new Common.UI.Menu({cls:"shifted-left",items:[{template:e.template('')},this.mnuNumberSettings=new Common.UI.MenuItem({caption:this.textListSettings,disabled:0==(this.mnuNumbersPicker.conf.index||0),value:"settings"})]})),this.btnMultilevels.setMenu(new Common.UI.Menu({cls:"shifted-left",style:"min-width: 90px",items:[{template:e.template('')},this.mnuMultilevelSettings=new Common.UI.MenuItem({caption:this.textListSettings,disabled:0==(this.mnuMultilevelPicker.conf.index||0),value:"settings"})]})),this.btnEditHeader.setMenu(new Common.UI.Menu({items:[{caption:this.mniEditHeader,value:"header"},{caption:this.mniEditFooter,value:"footer"},{caption:"--"},this.mnuInsertPageNum=new Common.UI.MenuItem({caption:this.textInsertPageNumber,disabled:this.mnuInsertPageNum.isDisabled(),menu:new Common.UI.Menu({cls:"shifted-left",menuAlign:"tl-tr",style:"min-width: 90px;",items:[{template:e.template('')},this.mnuPageNumCurrentPos=new Common.UI.MenuItem({caption:this.textToCurrent,disabled:this.mnuPageNumCurrentPos.isDisabled(),value:"current"})]})}),this.mnuInsertPageCount=new Common.UI.MenuItem({caption:this.textInsertPageCount,disabled:this.mnuInsertPageCount.isDisabled()})]})),this.paragraphControls.push(this.mnuPageNumCurrentPos),this.paragraphControls.push(this.mnuInsertPageCount),this.btnInsertChart.setMenu(new Common.UI.Menu({style:"width: 364px;padding-top: 12px;",items:[{template:e.template('')}]}));var n=function(o){new Common.UI.DataView({el:t("#id-toolbar-menu-insertchart"),parentMenu:o,showLast:!1,restoreHeight:421,groups:new Common.UI.DataViewGroupStore(Common.define.chartData.getChartGroupData()),store:new Common.UI.DataViewStore(Common.define.chartData.getChartData()),itemTemplate:e.template('
    ')}).on("item:click",function(t,e,n,o){n&&i.fireEvent("add:chart",[n.get("type")])}),o.off("show:before",n)};this.btnInsertChart.menu.on("show:before",n);var o=function(n){var s=DE.getCollection("Common.Collections.TextArt");s.length<1&&DE.getController("Main").fillTextArt(i.api.asc_getTextArtPreviews()),new Common.UI.DataView({el:t("#id-toolbar-menu-insart"),store:s,parentMenu:n,showLast:!1,itemTemplate:e.template('
    ')}).on("item:click",function(t,e,o,s){o&&i.fireEvent("insert:textart",[o.get("data")]),"click"!==s.type&&n.hide()}),n.off("show:before",o)};this.btnInsertTextArt.menu.on("show:before",o);var s=this.mnuMarkersPicker.conf;this.mnuMarkersPicker=new Common.UI.DataView({el:t("#id-toolbar-menu-markers"),parentMenu:this.btnMarkers.menu,restoreHeight:138,allowScrollbar:!1,store:new Common.UI.DataViewStore([{offsety:0,data:{type:0,subtype:-1}},{offsety:38,data:{type:0,subtype:1}},{offsety:76,data:{type:0,subtype:2}},{offsety:114,data:{type:0,subtype:3}},{offsety:152,data:{type:0,subtype:4}},{offsety:190,data:{type:0,subtype:5}},{offsety:228,data:{type:0,subtype:6}},{offsety:266,data:{type:0,subtype:7}},{offsety:684,data:{type:0,subtype:8}}]),itemTemplate:e.template('
    ')}),s&&this.mnuMarkersPicker.selectByIndex(s.index,!0),s=this.mnuNumbersPicker.conf,this.mnuNumbersPicker=new Common.UI.DataView({el:t("#id-toolbar-menu-numbering"),parentMenu:this.btnNumbers.menu,restoreHeight:92,allowScrollbar:!1,store:new Common.UI.DataViewStore([{offsety:0,data:{type:1,subtype:-1}},{offsety:570,data:{type:1,subtype:4}},{offsety:532,data:{type:1,subtype:5}},{offsety:608,data:{type:1,subtype:6}},{offsety:418,data:{type:1,subtype:1}},{offsety:456,data:{type:1,subtype:2}},{offsety:494,data:{type:1,subtype:3}},{offsety:646,data:{type:1,subtype:7}}]),itemTemplate:e.template('
    ')}),s&&this.mnuNumbersPicker.selectByIndex(s.index,!0),s=this.mnuMultilevelPicker.conf,this.mnuMultilevelPicker=new Common.UI.DataView({el:t("#id-toolbar-menu-multilevels"),parentMenu:this.btnMultilevels.menu,restoreHeight:92,allowScrollbar:!1,store:new Common.UI.DataViewStore([{offsety:0,data:{type:2,subtype:-1}},{offsety:304,data:{type:2,subtype:1}},{offsety:342,data:{type:2,subtype:2}},{offsety:380,data:{type:2,subtype:3}}]),itemTemplate:e.template('
    ')}),s&&this.mnuMultilevelPicker.selectByIndex(s.index,!0),s=this.mnuPageNumberPosPicker?this.mnuPageNumberPosPicker.conf:void 0,this.mnuPageNumberPosPicker=new Common.UI.DataView({el:t("#id-toolbar-menu-pageposition"),allowScrollbar:!1,store:new Common.UI.DataViewStore([{offsety:132,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_TOP,subtype:c_pageNumPosition.PAGE_NUM_POSITION_LEFT}},{offsety:99,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_TOP,subtype:c_pageNumPosition.PAGE_NUM_POSITION_CENTER}},{offsety:66,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_TOP,subtype:c_pageNumPosition.PAGE_NUM_POSITION_RIGHT}},{offsety:33,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM,subtype:c_pageNumPosition.PAGE_NUM_POSITION_LEFT}},{offsety:0,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM,subtype:c_pageNumPosition.PAGE_NUM_POSITION_CENTER}},{offsety:165,allowSelected:!1,data:{type:c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM,subtype:c_pageNumPosition.PAGE_NUM_POSITION_RIGHT}}]),itemTemplate:e.template('
    ')}),s&&this.mnuPageNumberPosPicker.setDisabled(s.disabled),this.mnuTablePicker=new Common.UI.DimensionPicker({el:t("#id-toolbar-menu-tablepicker"),minRows:8,minColumns:10,maxRows:8,maxColumns:10})},onToolbarAfterRender:function(e){var i;this.btnHighlightColor.cmpEl&&(i=t('
    '),t("button:first-child",this.btnHighlightColor.cmpEl).append(i),this.btnHighlightColor.currentColor="FFFF00",i.css("background-color","#"+this.btnHighlightColor.currentColor),this.mnuHighlightColorPicker=new Common.UI.ColorPalette({el:t("#id-toolbar-menu-highlight"),colors:["FFFF00","00FF00","00FFFF","FF00FF","0000FF","FF0000","00008B","008B8B","006400","800080","8B0000","808000","FFFFFF","D3D3D3","A9A9A9","000000"]}),this.mnuHighlightColorPicker.select("FFFF00")),this.btnFontColor.cmpEl&&(i=t('
    '),t("button:first-child",this.btnFontColor.cmpEl).append(i),i.css("background-color",this.btnFontColor.currentColor||"transparent"),this.mnuFontColorPicker=new Common.UI.ThemeColorPalette({el:t("#id-toolbar-menu-fontcolor")})),this.btnParagraphColor.cmpEl&&(i=t('
    '),t("button:first-child",this.btnParagraphColor.cmpEl).append(i),i.css("background-color",this.btnParagraphColor.currentColor||"transparent"),this.mnuParagraphColorPicker=new Common.UI.ThemeColorPalette({el:t("#id-toolbar-menu-paracolor"),transparent:!0})),this.btnContentControls.cmpEl&&(this.mnuControlsColorPicker=new Common.UI.ThemeColorPalette({el:t("#id-toolbar-menu-controls-color"),colors:["000000","993300","333300","003300","003366","000080","333399","333333","800000","FF6600","808000","00FF00","008080","0000FF","666699","808080","FF0000","FF9900","99CC00","339966","33CCCC","3366FF","800080","999999","FF00FF","FFCC00","FFFF00","00FF00","00FFFF","00CCFF","993366","C0C0C0","FF99CC","FFCC99","FFFF99","CCFFCC","CCFFFF","C9C8FF","CC99FF","FFFFFF"]}))},updateMetricUnit:function(){for(var e=this.btnPageMargins.menu.items,i=0;i-1)},onSendThemeColorSchemes:function(t){var i=this;this.mnuColorSchema&&this.mnuColorSchema.items.length>0&&e.each(this.mnuColorSchema.items,function(t){t.remove()}),null==this.mnuColorSchema&&(this.mnuColorSchema=new Common.UI.Menu({cls:"shifted-left",restoreHeight:!0})),this.mnuColorSchema.items=[];var n=e.template(['','',"<% _.each(options.colors, function(color) { %>",'',"<% }) %>","",'<%= caption %>',""].join(""));e.each(t,function(t,e){for(var o=t.get_colors(),s=[],a=2;a<7;a++){var r="#"+Common.Utils.ThemeColor.getHexColor(o[a].get_r(),o[a].get_g(),o[a].get_b());s.push(r)}21==e&&this.mnuColorSchema.addItem({caption:"--"});var l=t.get_name();this.mnuColorSchema.addItem({template:n,cls:"color-schemas-menu",colors:s,caption:e<21?i.SchemeNames[e]||l:l,value:e,checkable:!0,toggleGroup:"menuSchema"})},this)},onCollaborativeChanges:function(){if(!this._state.hasCollaborativeChanges){if(!this.btnCollabChanges.rendered||this._state.previewmode)return void(this.needShowSynchTip=!0);this._state.hasCollaborativeChanges=!0,this.btnCollabChanges.cmpEl.addClass("notify"),this.showSynchTip?(this.btnCollabChanges.updateHint(""),void 0===this.synchTooltip&&this.createSynchTip(),this.synchTooltip.show()):this.btnCollabChanges.updateHint(this.tipSynchronize+Common.Utils.String.platformKey("Ctrl+S")),this.btnSave.setDisabled(!1),Common.Gateway.collaborativeChanges()}},createSynchTip:function(){this.synchTooltip=new Common.UI.SynchronizeTip({extCls:this.mode.customization&&this.mode.customization.compactHeader?void 0:"inc-index", +target:this.btnCollabChanges.$el}),this.synchTooltip.on("dontshowclick",function(){this.showSynchTip=!1,this.synchTooltip.hide(),this.btnCollabChanges.updateHint(this.tipSynchronize+Common.Utils.String.platformKey("Ctrl+S")),Common.localStorage.setItem("de-hide-synch",1)},this),this.synchTooltip.on("closeclick",function(){this.synchTooltip.hide(),this.btnCollabChanges.updateHint(this.tipSynchronize+Common.Utils.String.platformKey("Ctrl+S"))},this)},synchronizeChanges:function(){if(!this._state.previewmode&&this.btnCollabChanges.rendered){var t=this;t.btnCollabChanges.cmpEl.hasClass("notify")&&(t.btnCollabChanges.cmpEl.removeClass("notify"),this.synchTooltip&&this.synchTooltip.hide(),this.btnCollabChanges.updateHint(this.btnSaveTip),this.btnSave.setDisabled(!t.mode.forcesave),this._state.hasCollaborativeChanges=!1)}},onApiUsersChanged:function(t){var i=[];e.each(t,function(t){t.asc_getView()||i.push(t)});var n=this,o=e.size(i),s=o>1?"btn-save-coauth":"btn-save";s!==n.btnSaveCls&&n.btnCollabChanges.rendered&&(n.btnSaveTip=(o>1?n.tipSaveCoauth:n.tipSave)+Common.Utils.String.platformKey("Ctrl+S"),n.btnCollabChanges.updateHint(n.btnSaveTip),n.btnCollabChanges.$icon.removeClass(n.btnSaveCls).addClass(s),n.btnSaveCls=s)},onStyleMenuUpdate:function(t,e,i){var n=this;if(n.api){var o=n.api.asc_GetStyleFromFormatting(),s=t.styleTitle,a=o.get_Link();o.put_Name(s),a.put_Name(s+"_character"),n.api.asc_AddNewStyle(o),setTimeout(function(){n.listStyles.openButton.menu.hide()},100)}},onStyleMenuDelete:function(t,e,i){this.api&&this.api.asc_RemoveStyle(t.styleTitle)},onStyleMenuRestoreAll:function(t,i,n){var o=this;o.api&&e.each(window.styles.get_MergedStyles(),function(t){o.api.asc_IsStyleDefault(t.get_Name())&&o.api.asc_RemoveStyle(t.get_Name())})},onStyleMenuDeleteAll:function(t,e,i){this.api&&this.api.asc_RemoveAllCustomStyles()},textBold:"Bold",textItalic:"Italic",textUnderline:"Underline",textStrikeout:"Strikeout",textSuperscript:"Superscript",textSubscript:"Subscript",strMenuNoFill:"No Fill",tipFontName:"Font Name",tipFontSize:"Font Size",tipParagraphStyle:"Paragraph Style",tipCopy:"Copy",tipPaste:"Paste",tipUndo:"Undo",tipRedo:"Redo",tipPrint:"Print",tipSave:"Save",tipIncFont:"Increment font size",tipDecFont:"Decrement font size",tipHighlightColor:"Highlight color",tipFontColor:"Font color",tipMarkers:"Bullets",tipNumbers:"Numbering",tipMultilevels:"Outline",tipAlignLeft:"Align Left",tipAlignRight:"Align Right",tipAlignCenter:"Align Center",tipAlignJust:"Justified",tipDecPrLeft:"Decrease Indent",tipIncPrLeft:"Increase Indent",tipShowHiddenChars:"Nonprinting Characters",tipLineSpace:"Paragraph Line Spacing",tipPrColor:"Background color",tipInsertTable:"Insert Table",tipInsertImage:"Insert Image",tipPageBreak:"Insert Page or Section break",tipInsertNum:"Insert Page Number",tipClearStyle:"Clear Style",tipCopyStyle:"Copy Style",tipPageSize:"Page Size",tipPageOrient:"Page Orientation",tipBack:"Back",tipInsertShape:"Insert Autoshape",tipInsertEquation:"Insert Equation",mniImageFromFile:"Image from File",mniImageFromUrl:"Image from URL",mniCustomTable:"Insert Custom Table",textTitleError:"Error",textInsertPageNumber:"Insert page number",textToCurrent:"To Current Position",tipEditHeader:"Edit header or footer",mniEditHeader:"Edit Document Header",mniEditFooter:"Edit Document Footer",mniHiddenChars:"Nonprinting Characters",mniHiddenBorders:"Hidden Table Borders",tipSynchronize:"The document has been changed by another user. Please click to save your changes and reload the updates.",textNewColor:"Add New Custom Color",textAutoColor:"Automatic",tipInsertChart:"Insert Chart",tipColorSchemas:"Change Color Scheme",tipInsertText:"Insert Text",tipInsertTextArt:"Insert Text Art",mniEditDropCap:"Drop Cap Settings",textNone:"None",textInText:"In Text",textInMargin:"In Margin",tipDropCap:"Insert drop cap",txtScheme1:"Office",txtScheme2:"Grayscale",txtScheme3:"Apex",txtScheme4:"Aspect",txtScheme5:"Civic",txtScheme6:"Concourse",txtScheme7:"Equity",txtScheme8:"Flow",txtScheme9:"Foundry",txtScheme10:"Median",txtScheme11:"Metro",txtScheme12:"Module",txtScheme13:"Opulent",txtScheme14:"Oriel",txtScheme15:"Origin",txtScheme16:"Paper",txtScheme17:"Solstice",txtScheme18:"Technic",txtScheme19:"Trek",txtScheme20:"Urban",txtScheme21:"Verve",textInsPageBreak:"Insert Page Break",textInsColumnBreak:"Insert Column Break",textInsSectionBreak:"Insert Section Break",textNextPage:"Next Page",textContPage:"Continuous Page",textEvenPage:"Even Page",textOddPage:"Odd Page",tipSaveCoauth:"Save your changes for the other users to see them.",tipMailRecepients:"Mail Merge",textStyleMenuUpdate:"Update from select",textStyleMenuRestore:"Restore to default",textStyleMenuDelete:"Delete style",textStyleMenuRestoreAll:"Restore all to default styles",textStyleMenuDeleteAll:"Delete all custom styles",textStyleMenuNew:"New style from selection",tipColumns:"Insert columns",textColumnsOne:"One",textColumnsTwo:"Two",textColumnsThree:"Three",textColumnsLeft:"Left",textColumnsRight:"Right",tipPageMargins:"Page Margins",textMarginsLast:"Last Custom",textMarginsNormal:"Normal",textMarginsUsNormal:"US Normal",textMarginsNarrow:"Narrow",textMarginsModerate:"Moderate",textMarginsWide:"Wide",textPageMarginsCustom:"Custom margins",textTop:"Top: ",textLeft:"Left: ",textBottom:"Bottom: ",textRight:"Right: ",textPageSizeCustom:"Custom Page Size",textPortrait:"Portrait",textLandscape:"Landscape",textInsertPageCount:"Insert number of pages",tipChangeChart:"Change Chart Type",capBtnInsPagebreak:"Page Break",capBtnInsImage:"Image",capBtnInsTable:"Table",capBtnInsChart:"Chart",textTabFile:"File",textTabHome:"Home",textTabInsert:"Insert",textTabLayout:"Layout",textTabReview:"Review",capBtnInsShape:"Shape",capBtnInsTextbox:"Text Box",capBtnInsTextart:"Text Art",capBtnInsDropcap:"Drop Cap",capBtnInsEquation:"Equation",capBtnInsHeader:"Header/Footer",capBtnColumns:"Columns",capBtnPageOrient:"Orientation",capBtnMargins:"Margins",capBtnPageSize:"Size",tipImgAlign:"Align objects",tipImgGroup:"Group objects",tipImgWrapping:"Wrap text",tipSendForward:"Bring forward",tipSendBackward:"Send backward",capImgAlign:"Align",capImgGroup:"Group",capImgForward:"Bring Forward",capImgBackward:"Send Backward",capImgWrapping:"Wrapping",capBtnComment:"Comment",textColumnsCustom:"Custom Columns",textTabCollaboration:"Collaboration",textTabProtect:"Protection",textTabLinks:"References",capBtnInsControls:"Content Control",textRichControl:"Rich text",textPlainControl:"Plain text",textRemoveControl:"Remove",mniEditControls:"Settings",tipControls:"Insert content control",mniHighlightControls:"Highlight settings",textNoHighlight:"No highlighting",mniImageFromStorage:"Image from Storage",capBtnBlankPage:"Blank Page",tipBlankPage:"Insert blank page",txtDistribHor:"Distribute Horizontally",txtDistribVert:"Distribute Vertically",txtPageAlign:"Align to Page",txtMarginAlign:"Align to Margin",txtObjectsAlign:"Align Selected Objects",capBtnWatermark:"Watermark",textEditWatermark:"Custom Watermark",textRemWatermark:"Remove Watermark",tipWatermark:"Edit watermark",textPictureControl:"Picture",textComboboxControl:"Combo box",textCheckboxControl:"Check box",textDropdownControl:"Drop-down list",textDateControl:"Date",capBtnAddComment:"Add Comment",capBtnInsSymbol:"Symbol",tipInsertSymbol:"Insert symbol",mniDrawTable:"Draw Table",mniEraseTable:"Erase Table",textListSettings:"List Settings",capBtnDateTime:"Date & Time",tipDateTime:"Insert current date and time",capBtnLineNumbers:"Line Numbers",textContinuous:"Continuous",textRestartEachPage:"Restart Each Page",textRestartEachSection:"Restart Each Section",textSuppressForCurrentParagraph:"Suppress for Current Paragraph",textCustomLineNumbers:"Line Numbering Options",tipLineNumbers:"Show line numbers"}}(),DE.Views.Toolbar||{}))}),void 0===Common)var Common={};if(define("documenteditor/main/app/view/StyleTitleDialog",["common/main/lib/util/utils","common/main/lib/component/InputField","common/main/lib/component/Window"],function(){"use strict";DE.Views.StyleTitleDialog=Common.UI.Window.extend(_.extend({options:{width:350,height:196,style:"min-width: 230px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textHeader},t||{}),this.template=['
    ','",'
    ','",'
    ',"
    "].join(""),this.options.tpl=_.template(this.template)(this.options),this.options.formats=this.options.formats||[],Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();t.inputTitle=new Common.UI.InputField({el:$("#id-dlg-style-title"),allowBlank:!1,blankError:t.txtEmpty,style:"width: 100%;",validateOnBlur:!1,validation:function(e){return!(""==e)||t.txtNotEmpty}}),e.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.options.formats.unshift({value:-1,displayValue:this.txtSameAs}),this.cmbNextStyle=new Common.UI.ComboBox({el:$("#id-dlg-style-next-par"),style:"width: 100%;",menuStyle:"width: 100%; max-height: 210px;",editable:!1,takeFocusOnClose:!0,cls:"input-group-nr",data:this.options.formats,disabled:0==this.options.formats.length}),this.cmbNextStyle.setValue(-1)},getFocusedComponents:function(){return[this.inputTitle,this.cmbNextStyle]},getDefaultFocusableComponent:function(){return this.inputTitle},getTitle:function(){return this.inputTitle.getValue()},getNextStyle:function(){var t=this.cmbNextStyle.getValue();return-1!=t?t:null},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},_handleInput:function(t){if(this.options.handler){if("ok"==t){if(!0!==this.inputTitle.checkValidate())return void this.inputTitle.focus()}this.options.handler.call(this,this,t)}this.close()},textTitle:"Title",textHeader:"Create New Style",txtEmpty:"This field is required",txtNotEmpty:"Field must not be empty",textNextStyle:"Next paragraph style",txtSameAs:"Same as created new style"},DE.Views.StyleTitleDialog||{}))}),define("documenteditor/main/app/view/PageMarginsDialog",["common/main/lib/component/Window","common/main/lib/component/MetricSpinner"],function(){"use strict";DE.Views.PageMarginsDialog=Common.UI.Window.extend(_.extend({options:{width:404,header:!0,style:"min-width: 404px;",cls:"modal-dlg",id:"window-page-margins",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
    ','
    ','",'
    ','
    ','",'
    ',"
    ",'
    ','",'
    ',"
    ","
    ",'
    ','
    ','",'
    ',"
    ",'
    ','",'
    ',"
    ","
    ",'
    ','","
    ",'
    ','
    ',"
    ","
    ",'
    ','",'
    ',"
    ",'
    ','",'
    ',"
    ","
    ",'
    ','",'
    ',"
    ","
    "].join(""),this.options.tpl=_.template(this.template)(this.options),this.spinners=[],this._noApply=!1,this.maxMarginsW=this.maxMarginsH=0,this.api=this.options.api,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.spnTop=new Common.UI.MetricSpinner({el:$("#page-margins-spin-top"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:-55.87}),this.spnTop.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_TopMargin(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnTop),this.spnBottom=new Common.UI.MetricSpinner({el:$("#page-margins-spin-bottom"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:-55.87}),this.spnBottom.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_BottomMargin(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnBottom),this.spnLeft=new Common.UI.MetricSpinner({el:$("#page-margins-spin-left"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:0}),this.spnLeft.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_LeftMargin(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnLeft),this.spnRight=new Common.UI.MetricSpinner({el:$("#page-margins-spin-right"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:0}),this.spnRight.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_RightMargin(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnRight),this.spnGutter=new Common.UI.MetricSpinner({el:$("#page-margins-spin-gutter"),step:.1,width:86,defaultUnit:"cm",value:"1 cm",maxValue:55.88,minValue:0}),this.spnGutter.on("change",_.bind(function(t,e,i){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_Gutter(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.spinners.push(this.spnGutter),this.cmbGutterPosition=new Common.UI.ComboBox({el:$("#page-margins-spin-gutter-position"),menuStyle:"min-width: 86px;",style:"width: 86px;",editable:!1,takeFocusOnClose:!0,cls:"input-group-nr",data:[{value:0,displayValue:this.textLeft},{value:1,displayValue:this.textTop}]}),this.cmbGutterPosition.on("selected",_.bind(function(t,e){this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_GutterAtTop(e.value),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.cmbOrientation=new Common.UI.ComboBox({el:$("#page-margins-cmb-orientation"),menuStyle:"min-width: 180px;",style:"width: 180px;",editable:!1,takeFocusOnClose:!0,cls:"input-group-nr",data:[{value:0,displayValue:this.textPortrait},{value:1,displayValue:this.textLandscape}]}),this.cmbOrientation.on("selected",_.bind(function(t,e){if(this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.get_Orientation()!==e.value)){this.properties.put_TopMargin(Common.Utils.Metric.fnRecalcToMM(e.value?this.spnLeft.getNumberValue():this.spnRight.getNumberValue())),this.properties.put_BottomMargin(Common.Utils.Metric.fnRecalcToMM(e.value?this.spnRight.getNumberValue():this.spnLeft.getNumberValue())),this.properties.put_LeftMargin(Common.Utils.Metric.fnRecalcToMM(e.value?this.spnBottom.getNumberValue():this.spnTop.getNumberValue())),this.properties.put_RightMargin(Common.Utils.Metric.fnRecalcToMM(e.value?this.spnTop.getNumberValue():this.spnBottom.getNumberValue()));var i=this.properties.get_H();this.properties.put_H(this.properties.get_W()),this.properties.put_W(i),this.properties.put_Orientation(e.value),this.maxMarginsH=Common.Utils.Metric.fnRecalcFromMM(this.properties.get_H()-2.6),this.maxMarginsW=Common.Utils.Metric.fnRecalcFromMM(this.properties.get_W()-12.7),this.spnTop.setMaxValue(this.maxMarginsH),this.spnBottom.setMaxValue(this.maxMarginsH),this.spnLeft.setMaxValue(this.maxMarginsW),this.spnRight.setMaxValue(this.maxMarginsW),this.spnTop.setValue(Common.Utils.Metric.fnRecalcFromMM(this.properties.get_TopMargin()),!0),this.spnBottom.setValue(Common.Utils.Metric.fnRecalcFromMM(this.properties.get_BottomMargin()),!0),this.spnLeft.setValue(Common.Utils.Metric.fnRecalcFromMM(this.properties.get_LeftMargin()),!0),this.spnRight.setValue(Common.Utils.Metric.fnRecalcFromMM(this.properties.get_RightMargin()),!0),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties)}},this)),this.cmbMultiplePages=new Common.UI.ComboBox({el:$("#page-margins-cmb-multiple-pages"),menuStyle:"min-width: 180px;",style:"width: 180px;",editable:!1,takeFocusOnClose:!0,cls:"input-group-nr",data:[{value:0,displayValue:this.textNormal},{value:1,displayValue:this.textMirrorMargins}]}),this.cmbMultiplePages.on("selected",_.bind(function(t,e){0===e.value?(this.window.find("#margin-left-label").html(this.textLeft),this.window.find("#margin-right-label").html(this.textRight),this.cmbGutterPosition.setDisabled(!1)):(this.window.find("#margin-left-label").html(this.textInside),this.window.find("#margin-right-label").html(this.textOutside),this.cmbGutterPosition.setValue(0),this.cmbGutterPosition.setDisabled(!0)),this.api&&(this.properties=this.properties?this.properties:new Asc.CDocumentSectionProps,this.properties.put_MirrorMargins(e.value),this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties))},this)),this.window=this.getChild(),this.window.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.updateMetricUnit()},getFocusedComponents:function(){return[this.spnTop,this.spnBottom,this.spnLeft,this.spnRight,this.spnGutter,this.cmbGutterPosition,this.cmbOrientation,this.cmbMultiplePages]},getDefaultFocusableComponent:function(){return this.spnTop},_handleInput:function(t){if(this.options.handler){if("ok"==t){var e=null;if(this.spnLeft.getNumberValue()+this.spnRight.getNumberValue()+(this.cmbGutterPosition.getValue()?0:this.spnGutter.getNumberValue())>this.maxMarginsW?e=this.txtMarginsW:Math.abs(this.spnTop.getNumberValue()+this.spnBottom.getNumberValue()+(this.cmbGutterPosition.getValue()?this.spnGutter.getNumberValue():0))>this.maxMarginsH&&(e=this.txtMarginsH),e)return void Common.UI.warning({title:this.notcriticalErrorTitle,msg:e})}this.options.handler.call(this,this,t)}this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},setSettings:function(t){if(t){this.properties=t,this.maxMarginsH=Common.Utils.Metric.fnRecalcFromMM(t.get_H()-2.6),this.maxMarginsW=Common.Utils.Metric.fnRecalcFromMM(t.get_W()-12.7),this.spnTop.setMaxValue(this.maxMarginsH),this.spnBottom.setMaxValue(this.maxMarginsH),this.spnLeft.setMaxValue(this.maxMarginsW),this.spnRight.setMaxValue(this.maxMarginsW),this.spnTop.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_TopMargin()),!0),this.spnBottom.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_BottomMargin()),!0),this.spnLeft.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_LeftMargin()),!0),this.spnRight.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_RightMargin()),!0),this.cmbOrientation.setValue(t.get_Orientation()),this.spnGutter.setValue(Common.Utils.Metric.fnRecalcFromMM(t.get_Gutter()),!0),this.cmbGutterPosition.setValue(t.get_GutterAtTop()?1:0);var e=t.get_MirrorMargins();this.cmbMultiplePages.setValue(e?1:0),e&&(this.window.find("#margin-left-label").html(this.textInside),this.window.find("#margin-right-label").html(this.textOutside),this.cmbGutterPosition.setValue(0)),this.cmbGutterPosition.setDisabled(e),this.api&&this.api.SetDrawImagePreviewMargins("page-margins-preview",this.properties)}},getSettings:function(){var t=new Asc.CDocumentSectionProps;return t.put_TopMargin(Common.Utils.Metric.fnRecalcToMM(this.spnTop.getNumberValue())),t.put_BottomMargin(Common.Utils.Metric.fnRecalcToMM(this.spnBottom.getNumberValue())),t.put_LeftMargin(Common.Utils.Metric.fnRecalcToMM(this.spnLeft.getNumberValue())),t.put_RightMargin(Common.Utils.Metric.fnRecalcToMM(this.spnRight.getNumberValue())),t.put_Orientation(this.cmbOrientation.getValue()),t.put_Gutter(Common.Utils.Metric.fnRecalcToMM(this.spnGutter.getNumberValue())),t.put_GutterAtTop(!!this.cmbGutterPosition.getValue()),t.put_MirrorMargins(!!this.cmbMultiplePages.getValue()),t.put_H(this.properties.get_H()),t.put_W(this.properties.get_W()),t},updateMetricUnit:function(){if(this.spinners)for(var t=0;t','',"",'","","",'","","","
    ','",'
    ',"
    ','",'
    ',"
    ",'",'
    ',"
    ","",'
    '].join(""),this.options.tpl=_.template(this.template)(this.options),this.spinners=[],this._noApply=!1,this.isOrientPortrait=!0,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.spnWidth=new Common.UI.MetricSpinner({el:$("#page-size-spin-width"),step:.1,width:86,defaultUnit:"cm",value:"10 cm",maxValue:118.9,minValue:0}),this.spinners.push(this.spnWidth),this.spnWidth.on("change",_.bind(function(t,e,i,n){!this._noApply&&this.cmbPreset.getValue()>-1&&this.cmbPreset.setValue(-1)},this)),this.spnHeight=new Common.UI.MetricSpinner({el:$("#page-size-spin-height"),step:.1,width:86,defaultUnit:"cm",value:"20 cm",maxValue:118.9,minValue:0}),this.spinners.push(this.spnHeight),this.spnHeight.on("change",_.bind(function(t,e,i,n){!this._noApply&&this.cmbPreset.getValue()>-1&&this.cmbPreset.setValue(-1)},this)),this.cmbPreset=new Common.UI.ComboBox({el:$("#page-size-combo-preset"),cls:"input-group-nr",menuStyle:"min-width: 183px;max-height: 208px;",editable:!1,takeFocusOnClose:!0,scrollAlwaysVisible:!0,data:[{value:0,displayValue:"US Letter",size:[215.9,279.4]},{value:1,displayValue:"US Legal",size:[215.9,355.6]},{value:2,displayValue:"A4",size:[210,297]},{value:3,displayValue:"A5",size:[148,210]},{value:4,displayValue:"B5",size:[176,250]},{value:5,displayValue:"Envelope #10",size:[104.8,241.3]},{value:6,displayValue:"Envelope DL",size:[110,220]},{value:7,displayValue:"Tabloid",size:[279.4,431.8]},{value:8,displayValue:"A3",size:[297,420]},{value:9,displayValue:"Tabloid Oversize",size:[304.8,457.1]},{value:10,displayValue:"ROC 16K",size:[196.8,273]},{value:11,displayValue:"Envelope Choukei 3",size:[119.9,234.9]},{value:12,displayValue:"Super B/A3",size:[330.2,482.5]},{value:13,displayValue:"A0",size:[841,1189]},{value:14,displayValue:"A1",size:[594,841]},{value:16,displayValue:"A2",size:[420,594]},{value:17,displayValue:"A6",size:[105,148]},{value:-1,displayValue:this.txtCustom,size:[]}]}),this.cmbPreset.setValue(-1),this.cmbPreset.on("selected",_.bind(function(t,e){this._noApply=!0,e.value<0||(this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(this.isOrientPortrait?e.size[0]:e.size[1]),!0),this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(this.isOrientPortrait?e.size[1]:e.size[0]),!0)),this._noApply=!1},this)),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.updateMetricUnit()},getFocusedComponents:function(){return[this.cmbPreset,this.spnWidth,this.spnHeight]},getDefaultFocusableComponent:function(){return this.cmbPreset},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},setSettings:function(t){if(t){this.isOrientPortrait=t.get_W()1&&(!e||3==e),!0),this.toolbar.mniAlignToMargin.setChecked(t<2&&!e||2==e,!0),this.toolbar.mniAlignToPage.setChecked(1==e,!0),this.toolbar.mniDistribHor.setDisabled(t<3&&this.toolbar.mniAlignObjects.isChecked()),this.toolbar.mniDistribVert.setDisabled(t<3&&this.toolbar.mniAlignObjects.isChecked())},onClickMenuAlign:function(t,e,i){ +var n=this.toolbar.mniAlignToPage.isChecked()?Asc.c_oAscObjectsAlignType.Page:this.toolbar.mniAlignToMargin.isChecked()?Asc.c_oAscObjectsAlignType.Margin:Asc.c_oAscObjectsAlignType.Selected;e.value>-1&&e.value<6?(this.api.put_ShapesAlign(e.value,n),Common.component.Analytics.trackEvent("ToolBar","Shape Align")):6==e.value?(this.api.DistributeHorizontally(n),Common.component.Analytics.trackEvent("ToolBar","Distribute")):7==e.value&&(this.api.DistributeVertically(n),Common.component.Analytics.trackEvent("ToolBar","Distribute")),this.toolbar.fireEvent("editcomplete",this.toolbar)},onClickMenuWrapping:function(e,i,n){var o=new Asc.asc_CImgProperty;if(o.put_WrappingStyle(i.options.wrapType),t.get_WrappingStyle()===Asc.c_oAscWrapStyle2.Inline&&i.options.wrapType!==Asc.c_oAscWrapStyle2.Inline){o.put_PositionH(new Asc.CImagePositionH),o.get_PositionH().put_UseAlign(!1),o.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var s=t.get_Value_X(Asc.c_oAscRelativeFromH.Column);o.get_PositionH().put_Value(s),o.put_PositionV(new Asc.CImagePositionV),o.get_PositionV().put_UseAlign(!1),o.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),s=t.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),o.get_PositionV().put_Value(s)}this.api.ImgApply(o),this.toolbar.fireEvent("editcomplete",this.toolbar)},onClickMenuGroup:function(t,e,i){var n=new Asc.asc_CImgProperty;n.put_Group(e.options.groupval),this.api.ImgApply(n),this.toolbar.fireEvent("editcomplete",this.toolbar)},onClickMenuForward:function(t,e,i){var n=new Asc.asc_CImgProperty;"forward"==t?n.put_ChangeLevel(Asc.c_oAscChangeLevel.BringForward):"backward"==t?n.put_ChangeLevel(Asc.c_oAscChangeLevel.BringBackward):n.put_ChangeLevel(e.options.valign),this.api.ImgApply(n),this.toolbar.fireEvent("editcomplete",this.toolbar)}}}())}),define("documenteditor/main/app/view/CustomColumnsDialog",["common/main/lib/component/Window","common/main/lib/component/MetricSpinner","common/main/lib/component/CheckBox"],function(){"use strict";DE.Views.CustomColumnsDialog=Common.UI.Window.extend(_.extend({options:{width:300,header:!0,style:"min-width: 216px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
    ','
    ','
    ',"
    ",'
    ','
    ',"
    ",'
    ','
    ',"
    ","
    ",'
    '].join(""),this.options.tpl=_.template(this.template)(this.options),this.spinners=[],this.totalWidth=558.7,this._noApply=!1,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this;this.spnColumns=new Common.UI.MetricSpinner({el:$("#custom-columns-spin-num"),step:1,allowDecimal:!1,width:100,defaultUnit:"",value:"1",maxValue:12,minValue:1}),this.spnColumns.on("change",function(e,i,n,o){var s=Common.Utils.Metric.fnRecalcToMM(t.spnSpacing.getNumberValue()),a=t.spnColumns.getNumberValue();t.chSeparator.setDisabled(a<2),t.spnSpacing.setDisabled(a<2),a<2&&(a=2);var r=parseFloat(((t.totalWidth-12.7*a)/(a-1)).toFixed(1));t.spnSpacing.setMaxValue(Common.Utils.Metric.fnRecalcFromMM(r)),s>r&&t.spnSpacing.setValue(Common.Utils.Metric.fnRecalcFromMM(r),!0)}),this.spnSpacing=new Common.UI.MetricSpinner({el:$("#custom-columns-spin-spacing"),step:.1,width:100,defaultUnit:"cm",value:"0 cm",maxValue:40.64,minValue:0}),this.spinners.push(this.spnSpacing),this.chSeparator=new Common.UI.CheckBox({el:$("#custom-columns-separator"),labelText:this.textSeparator}),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.updateMetricUnit()},getFocusedComponents:function(){return[this.spnColumns,this.spnSpacing]},getDefaultFocusableComponent:function(){return this.spnColumns},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(){return this._handleInput("ok"),!1},setSettings:function(t){if(t){var e=t.get_EqualWidth(),i=e?t.get_Num():t.get_ColsCount(),n=e?t.get_Space():i>1?t.get_Col(0).get_Space():12.5;this.chSeparator.setValue(t.get_Sep());var o=t.get_TotalWidth(),s=parseInt((o+.1)/(12.7+.1));this.spnColumns.setMaxValue(s),this.spnColumns.setValue(i,!0),this.chSeparator.setDisabled(i<2),this.spnSpacing.setDisabled(i<2),i<2&&(i=2),i>s&&(i=s);var a=parseFloat(((o-12.7*i)/(i-1)).toFixed(1));this.spnSpacing.setMaxValue(Common.Utils.Metric.fnRecalcFromMM(a)),this.spnSpacing.setValue(Common.Utils.Metric.fnRecalcFromMM(n),!0),this.totalWidth=o}},getSettings:function(){var t=new Asc.CDocumentColumnsProps;return t.put_EqualWidth(!0),t.put_Num(this.spnColumns.getNumberValue()),t.put_Space(Common.Utils.Metric.fnRecalcToMM(this.spnSpacing.getNumberValue())),t.put_Sep("checked"==this.chSeparator.getValue()),t},updateMetricUnit:function(){if(this.spinners)for(var t=0;t\n \n
    \n \n \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n \n
    \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n\n'}),define("documenteditor/main/app/view/WatermarkSettingsDialog",["text!documenteditor/main/app/template/WatermarkSettings.template","common/main/lib/util/utils","common/main/lib/component/RadioBox","common/main/lib/component/InputField","common/main/lib/view/AdvancedSettingsWindow"],function(t){"use strict";DE.Views.WatermarkText=new function(){var t;return{get:function(){return t},load:function(e){t=[],Common.Utils.loadConfig("resources/watermark/wm-text.json",function(i){for(var n in i){var o=Common.util.LanguageInfo.getLocalLanguageCode(n);o&&t.push({code:o,name:Common.util.LanguageInfo.getLocalLanguageName(o)[1],shortname:Common.util.LanguageInfo.getLocalLanguageName(o)[0],text:i[n]})}t.sort(function(t,e){return t.shortnamee.shortname?1:0}),e&&e(t)})}}},DE.Views.WatermarkSettingsDialog=Common.Views.AdvancedSettingsWindow.extend(_.extend({options:{contentWidth:400,height:442},initialize:function(e){var i=this;_.extend(this.options,{title:this.textTitle,template:_.template(['
    ','
    ','
    ',t,"
    ","
    ","
    "].join(""))({scope:this})},e),this.handler=e.handler,this.props=e.props,this.fontStore=e.fontStore,this.api=e.api,this.storage=!!e.storage,this.textControls=[],this.imageControls=[],this.fontName="Arial",this.text="",this.isAutoColor=!1,this.isImageLoaded=!1;var n=e.lang||"en",o=Common.util.LanguageInfo.getLocalLanguageCode(n);this.lang=o?{value:n,displayValue:Common.util.LanguageInfo.getLocalLanguageName(o)[1],default:!0}:{value:"en",displayValue:"English",default:!0},Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this,this.options)},render:function(){Common.Views.AdvancedSettingsWindow.prototype.render.call(this);var t=this;this.radioNone=new Common.UI.RadioBox({el:$("#watermark-radio-none"),name:"asc-radio-watermark-type",labelText:this.textNone,checked:!1}),this.radioNone.on("change",_.bind(function(t,e,i){e&&(this.props.put_Type(Asc.c_oAscWatermarkType.None),this.disableControls(Asc.c_oAscWatermarkType.None))},this)),this.radioImage=new Common.UI.RadioBox({el:$("#watermark-radio-image"),name:"asc-radio-watermark-type",labelText:this.textImageW,checked:!1}),this.radioImage.on("change",_.bind(function(t,e,i){e&&(this.props.put_Type(Asc.c_oAscWatermarkType.Image),this.disableControls(Asc.c_oAscWatermarkType.Image),this.focusControls())},this)),this.radioText=new Common.UI.RadioBox({el:$("#watermark-radio-text"),name:"asc-radio-watermark-type",labelText:this.textTextW,checked:!0}),this.radioText.on("change",_.bind(function(t,e,i){e&&(this.props.put_Type(Asc.c_oAscWatermarkType.Text),this.disableControls(Asc.c_oAscWatermarkType.Text),this.focusControls())},this)),this.btnSelectImage=new Common.UI.Button({parentEl:$("#watermark-select-image"),cls:"btn-text-menu-default",caption:this.textSelect,style:"width: 142px;",menu:new Common.UI.Menu({style:"min-width: 142px;",maxHeight:200,additionalAlign:this.menuAddAlign,items:[{caption:this.textFromFile,value:0},{cls:"cp-from-url",caption:this.textFromUrl,value:1},{caption:this.textFromStorage,value:2}]})}),this.imageControls.push(this.btnSelectImage),this.btnSelectImage.menu.on("item:click",_.bind(this.onImageSelect,this)),this.btnSelectImage.menu.items[2].setVisible(this.storage),this._arrScale=[{displayValue:this.textAuto,value:-1},{displayValue:"500%",value:500},{displayValue:"200%",value:200},{displayValue:"150%",value:150},{displayValue:"100%",value:100},{displayValue:"50%",value:50}],this.cmbScale=new Common.UI.ComboBox({el:$("#watermark-combo-scale"),cls:"input-group-nr",menuStyle:"min-width: 142px;",data:this._arrScale,takeFocusOnClose:!0}).on("selected",_.bind(function(t,e){},this)),this.cmbScale.setValue(this._arrScale[0].value),this.imageControls.push(this.cmbScale),this.cmbLang=new Common.UI.ComboBox({el:$("#watermark-combo-lang"),cls:"input-group-nr",editable:!1,menuStyle:"min-width: 100%;max-height: 210px;",scrollAlwaysVisible:!0,data:[],takeFocusOnClose:!0}).on("selected",_.bind(this.onSelectLang,this)),this.cmbLang.setValue(Common.util.LanguageInfo.getLocalLanguageName(9)[1]),this.textControls.push(this.cmbLang),this.cmbText=new Common.UI.ComboBox({el:$("#watermark-combo-text"),cls:"input-group-nr",menuStyle:"min-width: 100%;max-height: 210px;",scrollAlwaysVisible:!0,displayField:"value",data:[{value:"ASAP"},{value:"CONFIDENTIAL"},{value:"COPY"},{value:"DO NOT COPY"},{value:"DRAFT"},{value:"ORIGINAL"},{value:"PERSONAL"},{value:"SAMPLE"},{value:"TOP SECRET"},{value:"URGENT"}],takeFocusOnClose:!0}).on("selected",_.bind(function(t,e){},this)),this.cmbText.setValue(this.cmbText.options.data[0].value),this.textControls.push(this.cmbText),this.cmbFonts=new Common.UI.ComboBoxFonts({el:$("#watermark-fonts"),cls:"input-group-nr",style:"width: 142px;",menuCls:"scrollable-menu",menuStyle:"min-width: 100%;max-height: 270px;",store:new Common.Collections.Fonts,recent:0,hint:this.tipFontName,takeFocusOnClose:!0}).on("selected",_.bind(function(t,e){this.fontName=e.name},this)),this.textControls.push(this.cmbFonts);var e=[{value:-1,displayValue:this.textAuto},{value:36,displayValue:"36"},{value:40,displayValue:"40"},{value:44,displayValue:"44"},{value:48,displayValue:"48"},{value:54,displayValue:"54"},{value:60,displayValue:"60"},{value:66,displayValue:"66"},{value:72,displayValue:"72"},{value:80,displayValue:"80"},{value:90,displayValue:"90"},{value:96,displayValue:"96"},{value:105,displayValue:"105"},{value:120,displayValue:"120"},{value:144,displayValue:"144"}];this.cmbFontSize=new Common.UI.ComboBox({el:$("#watermark-font-size"),cls:"input-group-nr",style:"width: 55px;",menuCls:"scrollable-menu",menuStyle:"min-width: 55px;max-height: 270px;",hint:this.tipFontSize,data:e,takeFocusOnClose:!0}),this.cmbFontSize.setValue(-1),this.textControls.push(this.cmbFontSize),this.btnBold=new Common.UI.Button({parentEl:$("#watermark-bold"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-bold",enableToggle:!0,hint:this.textBold}),this.textControls.push(this.btnBold),this.btnItalic=new Common.UI.Button({parentEl:$("#watermark-italic"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-italic",enableToggle:!0,hint:this.textItalic}),this.textControls.push(this.btnItalic),this.btnUnderline=new Common.UI.Button({parentEl:$("#watermark-underline"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-underline",enableToggle:!0,hint:this.textUnderline}),this.textControls.push(this.btnUnderline),this.btnStrikeout=new Common.UI.Button({parentEl:$("#watermark-strikeout"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-strikeout",enableToggle:!0,hint:this.textStrikeout}),this.textControls.push(this.btnStrikeout);this.btnTextColor=new Common.UI.Button({parentEl:$("#watermark-textcolor"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-fontcolor",hint:this.textColor,menu:new Common.UI.Menu({cls:"shifted-left",items:[{id:"watermark-auto-color",caption:this.textAuto,template:_.template('<%= caption %>')},{caption:"--"},{template:_.template('
    ')},{template:_.template(''+this.textNewColor+"")}]})}),this.mnuTextColorPicker=function(e,i){if(e&&e.cmpEl){e.currentColor="#c0c0c0";var n=$('
    ');$("button:first-child",e.cmpEl).append(n),n.css("background-color",e.currentColor);var o=new Common.UI.ThemeColorPalette({el:$(i)})}return e.menu.cmpEl.on("click",i+"-new",_.bind(function(){o.addNewColor("object"==typeof e.color?e.color.color:e.color)},t)),o.on("select",_.bind(t.onColorSelect,t)),o}(this.btnTextColor,"#watermark-menu-textcolor"),$("#watermark-auto-color").on("click",_.bind(this.onAutoColor,this)),this.textControls.push(this.btnTextColor),this.chTransparency=new Common.UI.CheckBox({el:$("#watermark-chb-transparency"),labelText:this.textTransparency,value:!0}),this.textControls.push(this.chTransparency),this.radioDiag=new Common.UI.RadioBox({el:$("#watermark-radio-diag"),name:"asc-radio-watermark-layout",labelText:this.textDiagonal,checked:!0}),this.textControls.push(this.radioDiag),this.radioHor=new Common.UI.RadioBox({el:$("#watermark-radio-hor"),name:"asc-radio-watermark-layout",labelText:this.textHor}),this.textControls.push(this.radioHor),this.btnOk=new Common.UI.Button({el:this.$window.find(".primary"),disabled:!0}),this.afterRender()},getFocusedComponents:function(){return[this.cmbLang,this.cmbText,this.cmbFonts,this.cmbFontSize,this.cmbScale]},getDefaultFocusableComponent:function(){return this.cmbLang.isDisabled()?this.cmbScale.isDisabled()?void 0:this.cmbScale:this.cmbLang},focusControls:function(){var t=this.getDefaultFocusableComponent();t&&setTimeout(function(){t.focus()},10)},onColorSelect:function(t,e){var i=this.btnTextColor.menu.$el.find("#watermark-auto-color > a");i.hasClass("selected")&&i.removeClass("selected"),this.isAutoColor=!1;var n="object"==typeof e?e.color:e;this.btnTextColor.currentColor=e,$(".btn-color-value-line",this.btnTextColor.cmpEl).css("background-color","#"+n)},updateThemeColors:function(){this.mnuTextColorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors())},addNewColor:function(t,e){t.addNewColor("object"==typeof e.color?e.color.color:e.color)},onAutoColor:function(t){var e=this.btnTextColor.menu.$el.find("#watermark-auto-color > a");!e.hasClass("selected")&&e.addClass("selected"),this.isAutoColor=!0;this.btnTextColor.currentColor="000",$(".btn-color-value-line",this.btnTextColor.cmpEl).css("background-color","#000"),this.mnuTextColorPicker.clearSelection()},afterRender:function(){this.cmbFonts.fillFonts(this.fontStore),this.cmbFonts.selectRecord(this.fontStore.findWhere({name:this.fontName})),this.updateThemeColors(),this._setDefaults(this.props);var t=this,e=function(){t.isImageLoaded=!0,t.btnOk.setDisabled(!1)};this.api.asc_registerCallback("asc_onWatermarkImageLoaded",e);var i=function(e){e&&e.url&&"watermark"==e.c&&t.props.put_ImageUrl(e.url,e.token)};Common.NotificationCenter.on("storage:image-insert",i),this.on("close",function(n){t.api.asc_unregisterCallback("asc_onWatermarkImageLoaded",e),Common.NotificationCenter.off("storage:image-insert",i)})},loadLanguages:function(){var t=this,e=!1,i=function(i){var n=[];if(t.languages=i,t.languages&&t.languages.forEach(function(t){n.push({displayValue:t.name,value:t.shortname,wmtext:t.text})}),n.length){t.cmbLang.setData(n);var o=t.loadWMText(t.lang.value);o&&t.lang.default?t.cmbLang.setValue(o):t.cmbLang.setValue(t.lang.displayValue),t.cmbLang.setDisabled(!t.radioText.getValue()),t.text&&t.cmbText.setValue(t.text)}else t.cmbLang.setDisabled(!0);e&&t.focusControls()},n=DE.Views.WatermarkText.get();e=!n,n?i(n):DE.Views.WatermarkText.load(i)},onSelectLang:function(t,e){if(e){var i=[];e.wmtext.forEach(function(t){i.push({value:t})}),this.lang=e,i.length>0&&(this.cmbText.setData(i),this.cmbText.setValue(i[0].value))}},loadWMText:function(t){if(t){var e=[],i=this.cmbLang.store.findWhere({value:t});return i||(i=this.cmbLang.store.findWhere({value:t.split(/[\-\_]/)[0]})),i||(i=this.cmbLang.store.findWhere({value:"en"})),i||(i=this.cmbLang.store.at(0)),i&&i.get("wmtext").forEach(function(t){e.push({value:t})}),e.length>0&&(this.cmbText.setData(e),this.cmbText.setValue(e[0].value)),i?i.get("displayValue"):null}},onImageSelect:function(t,e){if(1==e.value){var i=this;new Common.Views.ImageFromUrlDialog({handler:function(t,e){if("ok"==t){var n=e.replace(/ /g,"");_.isEmpty(n)||i.props.put_ImageUrl(n)}}}).show()}else 2==e.value?Common.NotificationCenter.trigger("storage:image-load","watermark"):this.props.showFileDialog()},_setDefaults:function(t){if(this.loadLanguages(),t){t.put_DivId("watermark-texture-img"),t.put_Api(this.api);var e,i=t.get_Type();if(i==Asc.c_oAscWatermarkType.None)this.radioNone.setValue(!0,!0);else if(i==Asc.c_oAscWatermarkType.Image)this.radioImage.setValue(!0,!0),this.isImageLoaded=!!t.get_ImageUrl(),e=t.get_Scale()||-1,this.cmbScale.setValue(e<0?-1:Math.round(100*e),Math.round(100*e)+" %");else{if(this.radioText.setValue(!0,!0),!t.get_IsDiagonal()&&this.radioHor.setValue(!0),this.chTransparency.setValue(t.get_Opacity()<255),e=t.get_TextPr()){var n=Common.util.LanguageInfo.getLocalLanguageName(e.get_Lang());this.lang={value:n[0],displayValue:n[1]},this.cmbLang.setValue(n[1]),this.loadWMText(n[0]);var o=e.get_FontFamily().get_Name();if(o){var s=this.cmbFonts.store.findWhere({name:o});this.fontName=s?s.get("name"):o,this.cmbFonts.setValue(this.fontName)}this.cmbFontSize.setValue(e.get_FontSize()),this.btnBold.toggle(e.get_Bold()),this.btnItalic.toggle(e.get_Italic()),this.btnUnderline.toggle(e.get_Underline()),this.btnStrikeout.toggle(e.get_Strikeout());var a=e.get_Color(),r=this.btnTextColor.menu.$el.find("#watermark-auto-color > a"),l="c0c0c0";if(a.get_auto())l="000",this.isAutoColor=!0,this.mnuTextColorPicker.clearSelection(),!r.hasClass("selected")&&r.addClass("selected");else if(r.hasClass("selected")&&r.removeClass("selected"),a&&(l=a.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?{color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b()),effectValue:a.get_value()}:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b())),"object"==typeof l){for(var c=!1,d=0;d<10;d++)if(Common.Utils.ThemeColor.ThemeValues[d]==l.effectValue){this.mnuTextColorPicker.select(l,!0),c=!0;break}c||this.mnuTextColorPicker.clearSelection()}else this.mnuTextColorPicker.select(l,!0);this.btnTextColor.currentColor=l,$(".btn-color-value-line",this.btnTextColor.cmpEl).css("background-color","#"+("object"==typeof l?l.color:l))}e=t.get_Text(),e&&this.cmbText.setValue(e),this.text=e||""}this.disableControls(i)}},getSettings:function(){var t=this.props,e=this.props.get_Type();if(e==Asc.c_oAscWatermarkType.Image)e=parseInt(this.cmbScale.getValue()),isNaN(e)&&(e=-1),t.put_Scale(e<0?e:e/100);else if(t.put_Text(this.cmbText.getValue()),t.put_IsDiagonal(this.radioDiag.getValue()),t.put_Opacity("checked"==this.chTransparency.getValue()?128:255),e=t.get_TextPr()||new Asc.CTextProp){e.put_FontSize(Math.min(this.cmbFontSize.getValue(),1638));var i=new AscCommon.asc_CTextFontFamily;i.put_Name(this.fontName),i.put_Index(-1),e.put_FontFamily(i),e.put_Bold(this.btnBold.pressed),e.put_Italic(this.btnItalic.pressed),e.put_Underline(this.btnUnderline.pressed),e.put_Strikeout(this.btnStrikeout.pressed),e.put_Lang(parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.lang.value)));var n=new Asc.asc_CColor;this.isAutoColor?n.put_auto(!0):n=Common.Utils.ThemeColor.getRgbColor(this.btnTextColor.currentColor),e.put_Color(n),t.put_TextPr(e)}return this.props},disableControls:function(t){var e=t!=Asc.c_oAscWatermarkType.Image;_.each(this.imageControls,function(t){t.setDisabled(e)}),e=t!=Asc.c_oAscWatermarkType.Text,_.each(this.textControls,function(t){t.setDisabled(e)}),this.cmbLang.setDisabled(e||!this.languages||this.languages.length<1),this.btnOk.setDisabled(t==Asc.c_oAscWatermarkType.Image&&!this.isImageLoaded)},onDlgBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(){return this._handleInput("ok"),!1},_handleInput:function(t){if(this.handler){if("ok"==t&&this.btnOk.isDisabled())return;this.handler.call(this,t,this.getSettings())}this.close()},textTitle:"Watermark Settings",textNone:"None",textImageW:"Image watermark",textTextW:"Text watermark",textFromUrl:"From URL",textFromFile:"From File",textScale:"Scale",textAuto:"Auto",textText:"Text",textFont:"Font",tipFontName:"Font Name",tipFontSize:"Font Size",textBold:"Bold",textItalic:"Italic",textUnderline:"Underline",textStrikeout:"Strikeout",textTransparency:"Semitransparent",textLayout:"Layout",textDiagonal:"Diagonal",textHor:"Horizontal",textColor:"Text color",textNewColor:"Add New Custom Color",textLanguage:"Language",textFromStorage:"From Storage",textSelect:"Select Image"},DE.Views.WatermarkSettingsDialog||{}))}),void 0===Common)var Common={};if(define("documenteditor/main/app/view/ListSettingsDialog",["common/main/lib/component/Window","common/main/lib/component/MetricSpinner","common/main/lib/component/ThemeColorPalette","common/main/lib/component/ColorButton","common/main/lib/component/ComboBox","common/main/lib/view/SymbolTableDialog"],function(){"use strict";DE.Views.ListSettingsDialog=Common.UI.Window.extend(_.extend({options:{type:0,width:300,height:422,style:"min-width: 240px;",cls:"modal-dlg",split:!1,buttons:["ok","cancel"]},initialize:function(t){this.type=t.type||0,_.extend(this.options,{title:this.txtTitle,height:2==this.type?376:422,width:2==this.type?430:300},t||{}),this.template=['
    ',"<% if (type == 2) { %>",'',"",'",'",'",'","","
    ','",'
    ',"
    ','",'
    ',"
    ','",'
    ',"
    ','",'
    ',"
    ","<% } else {%>",'',"",'",'","","",'",'","","
    ',"<% if (type == 0) { %>",'",'","<% } else { %>",'",'
    ',"<% } %>","
    ','",'
    ',"
    ','",'
    ',"
    ','",'
    ',"
    ","<% } %>",'',"",'","","","
    ","",'
    ',"
    ","
    "].join(""),this.props=t.props,this.level=t.level||0,this.api=t.api,this.options.tpl=_.template(this.template)(this.options),this.levels=[],Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();e.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.btnColor=new Common.UI.ColorButton({parentEl:e.find("#id-dlg-bullet-color"),additionalItems:[{id:"id-dlg-bullet-text-color",caption:this.txtLikeText,checkable:!0,toggleGroup:"list-settings-color",style:"padding-left: 20px;"},{id:"id-dlg-bullet-auto-color",caption:this.textAuto,checkable:!0,toggleGroup:"list-settings-color",style:"padding-left: 20px;"},{caption:"--"}],additionalAlign:this.menuAddAlign}),this.btnColor.on("color:select",_.bind(this.onColorsSelect,this)),this.btnColor.menu.items[0].on("toggle",_.bind(this.onLikeTextColor,this)),this.btnColor.menu.items[1].on("toggle",_.bind(this.onAutoColor,this)),this.colors=this.btnColor.getPicker(),this.btnEdit=new Common.UI.Button({el:e.find("#id-dlg-bullet-font")}),this.btnEdit.on("click",_.bind(this.onEditBullet,this));var i=["<% _.each(items, function(item) { %>",'
  • ','<%= item.displayValue %><% if (item.value === Asc.c_oAscNumberingFormat.Bullet) { %><%=item.symbol%><% } %>',"
  • ","<% }); %>"],n=['
    ','
    ','
    ','','","
    "]);this.cmbFormat=new Common.UI.ComboBoxCustom({el:e.find("#id-dlg-numbering-format"),menuStyle:"min-width: 100%;max-height: 183px;",style:2==this.type?"width: 107px;":"width: 129px;",editable:!1,template:_.template(n.join("")),itemsTemplate:_.template(i.join("")),takeFocusOnClose:!0,data:[{displayValue:this.txtNone,value:Asc.c_oAscNumberingFormat.None},{displayValue:"1, 2, 3,...",value:Asc.c_oAscNumberingFormat.Decimal},{displayValue:"a, b, c,...",value:Asc.c_oAscNumberingFormat.LowerLetter},{displayValue:"A, B, C,...",value:Asc.c_oAscNumberingFormat.UpperLetter},{displayValue:"i, ii, iii,...",value:Asc.c_oAscNumberingFormat.LowerRoman},{displayValue:"I, II, III,...",value:Asc.c_oAscNumberingFormat.UpperRoman}],updateFormControl:function(t){var e=$(this.el).find(".form-control");t?t.get("value")==Asc.c_oAscNumberingFormat.Bullet?e[0].innerHTML=t.get("displayValue")+''+t.get("symbol")+"":e[0].innerHTML=t.get("displayValue"):e[0].innerHTML=""}}),this.cmbFormat.on("selected",_.bind(function(e,i){if(this._changedProps)if(-1==i.value){var n=function(i){var n=t._changedProps.get_Format();if(n==Asc.c_oAscNumberingFormat.Bullet){ +var o=e.store;o.findWhere({value:Asc.c_oAscNumberingFormat.Bullet,symbol:t.bulletProps.symbol,font:t.bulletProps.font})||o.add({displayValue:t.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:t.bulletProps.symbol,font:t.bulletProps.font},{at:o.length-1}),e.setData(o.models),e.selectRecord(e.store.findWhere({value:Asc.c_oAscNumberingFormat.Bullet,symbol:t.bulletProps.symbol,font:t.bulletProps.font}))}else e.setValue(n||"")};this.addNewBullet(n)}else{var o=this._changedProps.get_Format();this._changedProps.put_Format(i.value),i.value==Asc.c_oAscNumberingFormat.Bullet?(this.bulletProps.font=i.font,this.bulletProps.symbol=i.symbol,this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_FontFamily(this.bulletProps.font),this._changedProps.put_Text([new Asc.CAscNumberingLvlText]),this._changedProps.get_Text()[0].put_Value(this.bulletProps.symbol)):i.value!=Asc.c_oAscNumberingFormat.None&&o!=Asc.c_oAscNumberingFormat.Bullet||(this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_FontFamily(void 0),this._changedProps.put_Text([new Asc.CAscNumberingLvlText]),this._changedProps.get_Text()[0].put_Type(Asc.c_oAscNumberingLvlTextType.Num),this._changedProps.get_Text()[0].put_Value(this.level))}this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)},this)),this.cmbAlign=new Common.UI.ComboBox({el:e.find("#id-dlg-bullet-align"),menuStyle:"min-width: 100%;",editable:!1,cls:"input-group-nr",data:[{value:AscCommon.align_Left,displayValue:this.textLeft},{value:AscCommon.align_Center,displayValue:this.textCenter},{value:AscCommon.align_Right,displayValue:this.textRight}],takeFocusOnClose:!0}),this.cmbAlign.on("selected",_.bind(function(t,e){this._changedProps&&this._changedProps.put_Align(e.value),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)},this)),this.cmbSize=new Common.UI.ComboBox({el:e.find("#id-dlg-bullet-size"),menuStyle:"min-width: 100%;max-height: 183px;",editable:!1,cls:"input-group-nr",data:[{value:-1,displayValue:this.txtLikeText},{value:8,displayValue:"8"},{value:9,displayValue:"9"},{value:10,displayValue:"10"},{value:11,displayValue:"11"},{value:12,displayValue:"12"},{value:14,displayValue:"14"},{value:16,displayValue:"16"},{value:18,displayValue:"18"},{value:20,displayValue:"20"},{value:22,displayValue:"22"},{value:24,displayValue:"24"},{value:26,displayValue:"26"},{value:28,displayValue:"28"},{value:36,displayValue:"36"},{value:48,displayValue:"48"},{value:72,displayValue:"72"},{value:96,displayValue:"96"}],takeFocusOnClose:!0}),this.cmbSize.on("selected",_.bind(function(t,e){this._changedProps&&(this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_FontSize(e.value>0?e.value:void 0)),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)},this));for(var o=[],s=0;s<9;s++)o.push({value:s});this.levelsList=new Common.UI.ListView({el:$("#levels-list",this.$window),store:new Common.UI.DataViewStore(o),tabindex:1,itemTemplate:_.template('
    <%= (value+1) %>
    ')}),this.levelsList.on("item:select",_.bind(this.onSelectLevel,this)),this.afterRender()},getFocusedComponents:function(){return[this.cmbFormat,this.cmbAlign,this.cmbSize,{cmp:this.levelsList,selector:".listview"}]},getDefaultFocusableComponent:function(){return this.type>0?this.cmbFormat:this.cmbAlign},afterRender:function(){this.updateThemeColors(),this._setDefaults(this.props);var t=this,e=function(e){t.levelsList.selectByIndex(e)};this.api.asc_registerCallback("asc_onPreviewLevelChange",e),this.on("close",function(i){t.api.asc_unregisterCallback("asc_onPreviewLevelChange",e)})},updateThemeColors:function(){this.colors.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors())},onAutoColor:function(t,e){if(e){var i=Common.Utils.ThemeColor.getHexColor(0,0,0);if(this.btnColor.setColor(i),this.colors.clearSelection(),this._changedProps){this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr);var i=new Asc.asc_CColor;i.put_auto(!0),this._changedProps.get_TextPr().put_Color(i)}this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)}},onLikeTextColor:function(t,e){if(e){var i=Common.Utils.ThemeColor.getHexColor(255,255,255);this.btnColor.setColor(i),this.colors.clearSelection(),this._changedProps&&(this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_Color(void 0)),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)}},onColorsSelect:function(t,e){this._changedProps&&(this._changedProps.get_TextPr()||this._changedProps.put_TextPr(new AscCommonWord.CTextPr),this._changedProps.get_TextPr().put_Color(Common.Utils.ThemeColor.getRgbColor(e))),this.btnColor.menu.items[0].setChecked(!1,!0),this.btnColor.menu.items[1].setChecked(!1,!0),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)},onEditBullet:function(t){this.addNewBullet()},addNewBullet:function(t){var e=this,i=e.bulletProps,n=function(n,o,s){"ok"==o&&(i.changed=!0,i.code=s.code,i.font=s.font,i.symbol=s.symbol,e._changedProps&&(e._changedProps.put_Format(Asc.c_oAscNumberingFormat.Bullet),e._changedProps.get_TextPr()||e._changedProps.put_TextPr(new AscCommonWord.CTextPr),e._changedProps.get_TextPr().put_FontFamily(i.font),e._changedProps.put_Text([new Asc.CAscNumberingLvlText]),e._changedProps.get_Text()[0].put_Value(i.symbol),e.api&&e.api.SetDrawImagePreviewBullet("bulleted-list-preview",e.props,e.level,2==e.type))),t&&t.call(e,o)},o=new Common.Views.SymbolTableDialog({api:e.options.api,lang:e.options.interfaceLang,modal:!0,type:0,font:i.font,symbol:i.symbol,handler:n});o.show(),o.on("symbol:dblclick",n)},_handleInput:function(t){if(this.options.handler){for(var e=[],i=[],n=0;n<9;n++)this.levels[n]&&(e.push(this.levels[n]),i.push(n));this.options.handler.call(this,t,{props:1==e.length?e[0]:e,num:1==i.length?i[0]:i})}this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},_setDefaults:function(t){if(this.bulletProps={},t){var e=t.get_Lvl(this.level);if(this.level<0&&(this.level=0),this.levels[this.level]=e||new Asc.CAscNumberingLvl(this.level),2==this.type){var i=this.cmbFormat.store;i.push([{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"·",font:"Symbol"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"o",font:"Courier New"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"§",font:"Wingdings"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"v",font:"Wingdings"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"Ø",font:"Wingdings"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"ü",font:"Wingdings"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"¨",font:"Symbol"},{displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:"–",font:"Arial"},{displayValue:this.txtNewBullet,value:-1}]),this.cmbFormat.setData(i.models),this.levelsList.selectByIndex(this.level)}else this.fillLevelProps(this.levels[this.level])}this._changedProps=this.levels[this.level]},onSelectLevel:function(t,e,i){this.level=i.get("value"),void 0===this.levels[this.level]&&(this.levels[this.level]=this.props.get_Lvl(this.level)),this.fillLevelProps(this.levels[this.level]),this._changedProps=this.levels[this.level]},fillLevelProps:function(t){if(t){this.cmbAlign.setValue(void 0!==t.get_Align()?t.get_Align():"");var e=t.get_Format(),i=t.get_TextPr(),n=t.get_Text();if(n&&e==Asc.c_oAscNumberingFormat.Bullet&&(this.bulletProps.symbol=n[0].get_Value()),i){this.cmbSize.setValue(i.get_FontSize()||-1),this.bulletProps.font=i.get_FontFamily();var o=i.get_Color();if(this.btnColor.menu.items[0].setChecked(void 0===o,!0),this.btnColor.menu.items[1].setChecked(!!o&&o.get_auto(),!0),o&&!o.get_auto())if("object"==typeof o){for(var s=!1,a=0;a<10;a++)if(Common.Utils.ThemeColor.ThemeValues[a]==o.effectValue){this.colors.select(o,!0),s=!0;break}s||this.colors.clearSelection(),o=Common.Utils.ThemeColor.getHexColor(o.get_r(),o.get_g(),o.get_b())}else this.colors.select(o,!0);else this.colors.clearSelection(),o=o&&o.get_auto()?"000000":"ffffff";this.btnColor.setColor(o)}this.type>0&&(e==Asc.c_oAscNumberingFormat.Bullet?(this.cmbFormat.store.findWhere({value:Asc.c_oAscNumberingFormat.Bullet,symbol:this.bulletProps.symbol,font:this.bulletProps.font})||this.cmbFormat.store.add({displayValue:this.txtSymbol+": ",value:Asc.c_oAscNumberingFormat.Bullet,symbol:this.bulletProps.symbol,font:this.bulletProps.font},{at:this.cmbFormat.store.length-1}),this.cmbFormat.setData(this.cmbFormat.store.models),this.cmbFormat.selectRecord(this.cmbFormat.store.findWhere({value:Asc.c_oAscNumberingFormat.Bullet,symbol:this.bulletProps.symbol,font:this.bulletProps.font}))):this.cmbFormat.setValue(void 0!==e?e:"")),this.api&&this.api.SetDrawImagePreviewBullet("bulleted-list-preview",this.props,this.level,2==this.type)}},txtTitle:"List Settings",txtSize:"Size",txtColor:"Color",txtBullet:"Bullet",txtFont:"Font and Symbol",txtAlign:"Alignment",textLeft:"Left",textCenter:"Center",textRight:"Right",textAuto:"Automatic",textPreview:"Preview",txtType:"Type",txtLikeText:"Like a text",textLevel:"Level",txtNone:"None",txtNewBullet:"New bullet",txtSymbol:"Symbol"},DE.Views.ListSettingsDialog||{}))}),define("documenteditor/main/app/view/DateTimeDialog",["common/main/lib/component/Window","common/main/lib/component/ComboBox","common/main/lib/component/ListView"],function(){"use strict";DE.Views.DateTimeDialog=Common.UI.Window.extend(_.extend({options:{width:350,style:"min-width: 230px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.txtTitle},t||{}),this.template=['
    ','
    ','","
    ",'
    ','
    ','","
    ",'
    ','
    ','
    ','","
    ","
    "].join(""),this.options.tpl=_.template(this.template)(this.options),this.api=this.options.api,this.lang=this.options.lang,this.handler=this.options.handler,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=[{value:1068},{value:1026},{value:1029},{value:1031},{value:2055},{value:1032},{value:3081},{value:2057},{value:1033},{value:3082},{value:2058},{value:1035},{value:1036},{value:1040},{value:1041},{value:1042},{value:1062},{value:1043},{value:1045},{value:1046},{value:2070},{value:1049},{value:1051},{value:1060},{value:2077},{value:1053},{value:1055},{value:1058},{value:1066},{value:2052}];t.forEach(function(t){var e=Common.util.LanguageInfo.getLocalLanguageName(t.value);t.displayValue=e[1],t.langName=e[0]}),this.cmbLang=new Common.UI.ComboBox({el:$("#datetime-dlg-lang"),menuStyle:"min-width: 100%; max-height: 185px;",cls:"input-group-nr",editable:!1,takeFocusOnClose:!0,data:t,search:!0,scrollAlwaysVisible:!0}),this.cmbLang.setValue(1033),this.cmbLang.on("selected",_.bind(function(t,e){this.updateFormats(e.value)},this)),this.chUpdate=new Common.UI.CheckBox({el:$("#datetime-dlg-update"),labelText:this.textUpdate}),this.chUpdate.on("change",_.bind(function(t,e,i,n){this.onSelectFormat(this.listFormats,null,this.listFormats.getSelectedRec())},this)),this.listFormats=new Common.UI.ListView({el:$("#datetime-dlg-format"),store:new Common.UI.DataViewStore,tabindex:1,scrollAlwaysVisible:!0}),this.listFormats.on("item:select",_.bind(this.onSelectFormat,this)),this.listFormats.on("item:dblclick",_.bind(this.onDblClickFormat,this)),this.listFormats.on("entervalue",_.bind(this.onPrimary,this)),this.btnDefault=new Common.UI.Button({el:$("#datetime-dlg-default")}),this.btnDefault.on("click",_.bind(function(t,e){var i=this.listFormats.getSelectedRec();Common.UI.warning({msg:Common.Utils.String.format(this.confirmDefault,Common.util.LanguageInfo.getLocalLanguageName(this.cmbLang.getValue())[1],i?i.get("value"):""),buttons:["yes","no"],primary:"yes",callback:_.bind(function(t){if("yes"==t){this.defaultFormats[this.cmbLang.getValue()]=i?i.get("format"):"";var e=[];for(var n in this.defaultFormats)n&&e.push({lang:n,format:this.defaultFormats[n]});var o=JSON.stringify(e);Common.localStorage.setItem("de-settings-datetime-default",o),Common.Utils.InternalSettings.set("de-settings-datetime-default",o)}},this)})},this)),this.$window.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.afterRender()},afterRender:function(){var t=this,e=Common.Utils.InternalSettings.get("de-settings-datetime-default"),i=e?JSON.parse(e):[];this.defaultFormats=[],i.forEach(function(e){e.lang&&(t.defaultFormats[parseInt(e.lang)]=e.format)}),this._setDefaults()},getFocusedComponents:function(){return[this.cmbLang,{cmp:this.listFormats,selector:".listview"}]},getDefaultFocusableComponent:function(){return this.cmbLang},_setDefaults:function(){if(this.props=new Asc.CAscDateTime,this.lang){var t=this.cmbLang.store.findWhere({value:this.lang});t=t?t.get("value"):1033,this.cmbLang.setValue(t)}this.updateFormats(this.cmbLang.getValue())},getSettings:function(){return this.props},updateFormats:function(t){this.props.put_Lang(t);for(var e=this.props.get_FormatsExamples(),i=[],n=this.listFormats.store,o=0,s=e.length;o','
    ','
    ','
    ','
    ','
    ',"
    ",'
    ",'
    ','
    ','
    ','
    ',"
    ',"
    ",""].join(""),this.options.tpl=_.template(this.template)(this.options),this.spinners=[],this._noApply=!1,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.chAddLineNumbering=new Common.UI.CheckBox({el:$("#line-numbers-add-line-numbering"),labelText:this.textAddLineNumbering}).on("change",_.bind(function(t,e,i,n){var o="checked"!==t.getValue();this.spnStartAt.setDisabled(o),this.spnFromText.setDisabled(o),this.spnCountBy.setDisabled(o),this.rbRestartEachPage.setDisabled(o),this.rbRestartEachSection.setDisabled(o),this.rbContinuous.setDisabled(o)},this)),this.spnStartAt=new Common.UI.MetricSpinner({el:$("#line-numbers-start-at"),step:1,width:80,defaultUnit:"",value:1,maxValue:32767,minValue:1,disabled:!0}),this.spnFromText=new Common.UI.MetricSpinner({el:$("#line-numbers-from-text"),step:.1,width:80,defaultUnit:"cm",value:"Auto",autoText:this.txtAutoText,maxValue:55.87,minValue:.1,allowAuto:!0,disabled:!0}),this.spinners.push(this.spnFromText),this.spnCountBy=new Common.UI.MetricSpinner({el:$("#line-numbers-count-by"),step:1,width:80,defaultUnit:"",value:1,maxValue:100,minValue:1,disabled:!0}),this.rbRestartEachPage=new Common.UI.RadioBox({el:$("#line-numbers-restart-each-page"),labelText:this.textRestartEachPage,name:"asc-radio-line-numbers",disabled:!0,checked:!0}),this.rbRestartEachSection=new Common.UI.RadioBox({el:$("#line-numbers-restart-each-section"),labelText:this.textRestartEachSection,name:"asc-radio-line-numbers",disabled:!0}),this.rbContinuous=new Common.UI.RadioBox({el:$("#line-numbers-continuous"),labelText:this.textContinuous,name:"asc-radio-line-numbers",disabled:!0}),this.cmbApply=new Common.UI.ComboBox({el:$("#line-numbers-combo-apply"),cls:"input-group-nr",menuStyle:"min-width: 150px;",editable:!1,data:[{displayValue:this.textSection,value:Asc.c_oAscSectionApplyType.Current},{displayValue:this.textForward,value:Asc.c_oAscSectionApplyType.ToEnd},{displayValue:this.textDocument,value:Asc.c_oAscSectionApplyType.All}]}),this.cmbApply.setValue(this.options.applyTo),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.updateMetricUnit()},afterRender:function(){},setSettings:function(t){if(t){var e=t.get_Restart();switch(this.chAddLineNumbering.setValue(!0),e){case Asc.c_oAscLineNumberRestartType.Continuous:this.rbContinuous.setValue(!0,!0);break;case Asc.c_oAscLineNumberRestartType.NewPage:this.rbRestartEachPage.setValue(!0,!0);break;case Asc.c_oAscLineNumberRestartType.NewSection:this.rbRestartEachSection.setValue(!0,!0)}this.spnStartAt.setValue(null!==t.get_Start()&&void 0!==t.get_Start()?t.get_Start():"",!0),this.spnFromText.setValue(null!==t.get_Distance()&&void 0!==t.get_Distance()?Common.Utils.Metric.fnRecalcFromMM(25.4*t.get_Distance()/20/72):-1,!0),this.spnCountBy.setValue(null!==t.get_CountBy()&&void 0!==t.get_CountBy()?t.get_CountBy():"",!0)}else this.chAddLineNumbering.setValue(!1)},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(){return this._handleInput("ok"),!1},getSettings:function(){var t;if("checked"===this.chAddLineNumbering.getValue()){t=new Asc.CSectionLnNumType,this.rbContinuous.getValue()?t.put_Restart(Asc.c_oAscLineNumberRestartType.Continuous):this.rbRestartEachPage.getValue()?t.put_Restart(Asc.c_oAscLineNumberRestartType.NewPage):this.rbRestartEachSection.getValue()&&t.put_Restart(Asc.c_oAscLineNumberRestartType.NewSection),t.put_Start(""!==this.spnStartAt.getValue()?this.spnStartAt.getNumberValue():void 0);var e=this.spnFromText.getNumberValue();t.put_Distance(e<0?null:parseInt(72*Common.Utils.Metric.fnRecalcToMM(e)*20/25.4)),t.put_CountBy(""!==this.spnCountBy.getValue()?this.spnCountBy.getNumberValue():void 0)}return{props:t,type:this.cmbApply.getValue()}},updateMetricUnit:function(){if(this.spinners)for(var t=0;t0?this.toolbar.mnuMarkersPicker.selectByIndex(this._state.bullets.subtype,!0):this.toolbar.mnuMarkersPicker.deselectAll(!0),this.toolbar.mnuMultilevelPicker.deselectAll(!0),this.toolbar.mnuMarkerSettings&&this.toolbar.mnuMarkerSettings.setDisabled(this._state.bullets.subtype<0),this.toolbar.mnuMultilevelSettings&&this.toolbar.mnuMultilevelSettings.setDisabled(this._state.bullets.subtype<0);break;case 1:var i;switch(this._state.bullets.subtype){case 1:i=4;break;case 2:i=5;break;case 3:i=6;break;case 4:i=1;break;case 5:i=2;break;case 6:i=3;break;case 7:i=7}this.toolbar.btnNumbers.toggle(!0,!0),void 0!==i?this.toolbar.mnuNumbersPicker.selectByIndex(i,!0):this.toolbar.mnuNumbersPicker.deselectAll(!0),this.toolbar.mnuMultilevelPicker.deselectAll(!0),this.toolbar.mnuNumberSettings&&this.toolbar.mnuNumberSettings.setDisabled(0==i),this.toolbar.mnuMultilevelSettings&&this.toolbar.mnuMultilevelSettings.setDisabled(0==i);break;case 2:this.toolbar.btnMultilevels.toggle(!0,!0),this.toolbar.mnuMultilevelPicker.selectByIndex(this._state.bullets.subtype,!0)}},onApiParagraphAlign:function(t){if(this._state.pralign!==t){this._state.pralign=t;var e=this.toolbar;switch(t){case 0:2,"btn-align-right";break;case 1:0,"btn-align-left";break;case 2:1,"btn-align-center";break;case 3:3,"btn-align-just";break;default:-255,"btn-align-left"}if(null===t||void 0===t)return e.btnAlignRight.toggle(!1,!0),e.btnAlignLeft.toggle(!1,!0),e.btnAlignCenter.toggle(!1,!0),void e.btnAlignJust.toggle(!1,!0);e.btnAlignRight.toggle(0===t,!0),e.btnAlignLeft.toggle(1===t,!0),e.btnAlignCenter.toggle(2===t,!0),e.btnAlignJust.toggle(3===t,!0)}},onApiLineSpacing:function(t){var e=null===t.get_Line()||null===t.get_LineRule()||1!=t.get_LineRule()?-1:t.get_Line();if(this._state.linespace!==e){if(this._state.linespace=e,_.each(this.toolbar.mnuLineSpace.items,function(t){t.setChecked(!1,!0)}),e<0)return;Math.abs(e-1)<1e-4?this.toolbar.mnuLineSpace.items[0].setChecked(!0,!0):Math.abs(e-1.15)<1e-4?this.toolbar.mnuLineSpace.items[1].setChecked(!0,!0):Math.abs(e-1.5)<1e-4?this.toolbar.mnuLineSpace.items[2].setChecked(!0,!0):Math.abs(e-2)<1e-4?this.toolbar.mnuLineSpace.items[3].setChecked(!0,!0):Math.abs(e-2.5)<1e-4?this.toolbar.mnuLineSpace.items[4].setChecked(!0,!0):Math.abs(e-3)<1e-4&&this.toolbar.mnuLineSpace.items[5].setChecked(!0,!0)}},onApiPageSize:function(t,e){if(void 0!==this._state.pgorient){var i=this._state.pgorient?t:e,n=this._state.pgorient?e:t;(Math.abs(this._state.pgsize[0]-t)>.1||Math.abs(this._state.pgsize[1]-e)>.1)&&(this._state.pgsize=[t,e],this.toolbar.mnuPageSize&&(this.toolbar.mnuPageSize.clearAll(),_.each(this.toolbar.mnuPageSize.items,function(t){if(t.value&&"object"==typeof t.value&&Math.abs(t.value[0]-i)<.1&&Math.abs(t.value[1]-n)<.1)return t.setChecked(!0),!1},this)))}},onSectionProps:function(t){if(t){var e=t.get_LeftMargin(),i=t.get_TopMargin(),n=t.get_RightMargin(),o=t.get_BottomMargin();(!this._state.pgmargins||Math.abs(this._state.pgmargins[0]-i)>.1||Math.abs(this._state.pgmargins[1]-e)>.1||Math.abs(this._state.pgmargins[2]-o)>.1||Math.abs(this._state.pgmargins[3]-n)>.1)&&(this._state.pgmargins=[i,e,o,n],this.toolbar.btnPageMargins.menu&&(this.toolbar.btnPageMargins.menu.clearAll(),_.each(this.toolbar.btnPageMargins.menu.items,function(t){if(t.value&&"object"==typeof t.value&&Math.abs(t.value[0]-i)<.1&&Math.abs(t.value[1]-e)<.1&&Math.abs(t.value[2]-o)<.1&&Math.abs(t.value[3]-n)<.1)return t.setChecked(!0),!1},this)))}},onShowParaMarks:function(t){this.toolbar.mnuNonPrinting.items[0].setChecked(t,!0),this.toolbar.btnShowHidenChars.toggle(t,!0),Common.localStorage.setItem("de-show-hiddenchars",t)},onApiFocusObjectRestrictedEdit:function(t){if(this.editMode){for(var e,i=-1,n=!1,o=!1,s=!1,a=!1,r=void 0;++i0&&this.btnsComment.setDisabled(p)}},onApiFocusObject:function(t){if(this.editMode){for(var e,i,n,o=-1,s=!1,a=!1,r=!1,l=!1,c=!1,d=void 0,h=!0,p=void 0,m=this.toolbar,u=!1,g=!1,b=!1,f=!1,C=!1,v=!1,y=!1;++o0&&this.btnsComment.setDisabled(k),m.btnWatermark.setDisabled(a),p&&(this._state.suppress_num=!!p.get_SuppressLineNumbers()),this._state.in_equation=b}},onApiStyleChange:function(t){this.toolbar.btnCopyStyle.toggle(t,!0),this.modeAlwaysSetStyle=!1},onTableDraw:function(t){this.toolbar.mnuInsertTable&&this.toolbar.mnuInsertTable.items[2].setChecked(!!t,!0)},onTableErase:function(t){this.toolbar.mnuInsertTable&&this.toolbar.mnuInsertTable.items[3].setChecked(!!t,!0)},onApiParagraphStyleChange:function(t){if(this._state.prstyle!=t){var e=this.toolbar.listStyles;if(e.rendered){e.suspendEvents();var i=e.menuPicker.store.findWhere({title:t});this._state.prstyle=e.menuPicker.store.length>0||window.styles_loaded?t:void 0,e.menuPicker.selectRecord(i),e.resumeEvents()}}},onApiPageOrient:function(t){this._state.pgorient!==t&&(this.toolbar.btnPageOrient.menu.items[t?0:1].setChecked(!0),this._state.pgorient=t)},onApiLockDocumentProps:function(){!0!==this._state.lock_doc&&(this.toolbar.btnPageOrient.setDisabled(!0),this.toolbar.btnPageSize.setDisabled(!0),this.toolbar.btnPageMargins.setDisabled(!0),this._state.activated&&(this._state.lock_doc=!0))},onApiUnLockDocumentProps:function(){!1!==this._state.lock_doc&&(this.toolbar.btnPageOrient.setDisabled(!1),this.toolbar.btnPageSize.setDisabled(!1),this.toolbar.btnPageMargins.setDisabled(!1),this._state.activated&&(this._state.lock_doc=!1))},onApiLockDocumentSchema:function(){this.toolbar.btnColorSchemas.setDisabled(!0)},onApiUnLockDocumentSchema:function(){this.toolbar.btnColorSchemas.setDisabled(!1)},onApiLockHeaderFooters:function(){this.toolbar.mnuPageNumberPosPicker.setDisabled(!0),this.toolbar.mnuInsertPageNum.setDisabled(this.toolbar.mnuPageNumCurrentPos.isDisabled())},onApiUnLockHeaderFooters:function(){this.toolbar.mnuPageNumberPosPicker.setDisabled(!1),this.toolbar.mnuInsertPageNum.setDisabled(!1)},onApiZoomChange:function(t,e){},onApiStartHighlight:function(t){this.toolbar.btnHighlightColor.toggle(t,!0)},onApiHighlightColor:function(t){var e=this.api.get_TextProps().get_TextPr();e&&(t=e.get_HighLight(),-1==t?-1!=this._state.clrhighlight&&(this.toolbar.mnuHighlightTransparent.setChecked(!0,!0),this.toolbar.mnuHighlightColorPicker.cmpEl&&(this._state.clrhighlight=-1,this.toolbar.mnuHighlightColorPicker.select(null,!0))):null!==t?this._state.clrhighlight!=t.get_hex().toUpperCase()&&(this.toolbar.mnuHighlightTransparent.setChecked(!1),this._state.clrhighlight=t.get_hex().toUpperCase(),_.contains(this.toolbar.mnuHighlightColorPicker.colors,this._state.clrhighlight)&&this.toolbar.mnuHighlightColorPicker.select(this._state.clrhighlight,!0)):this._state.clrhighlight!==t&&(this.toolbar.mnuHighlightTransparent.setChecked(!1,!0),this.toolbar.mnuHighlightColorPicker.select(null,!0),this._state.clrhighlight=t))},onApiInitEditorStyles:function(t){this._onInitEditorStyles(t)},onChangeSdtGlobalSettings:function(){var t=this.api.asc_GetGlobalContentControlShowHighlight();if(this.toolbar.mnuNoControlsColor&&this.toolbar.mnuNoControlsColor.setChecked(!t,!0),this.toolbar.mnuControlsColorPicker&&this.toolbar.mnuControlsColorPicker.clearSelection(),t){var e=this.api.asc_GetGlobalContentControlHighlightColor();e&&(e=Common.Utils.ThemeColor.getHexColor(e.get_r(),e.get_g(),e.get_b()),this.toolbar.mnuControlsColorPicker&&this.toolbar.mnuControlsColorPicker.selectByRGB(e,!0))}},onNewDocument:function(t,e){this.api&&this.api.OpenNewDocument(),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","New Document")},onOpenDocument:function(t,e){this.api&&this.api.LoadDocumentFromDisk(),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Open Document")},onPrint:function(t){this.api&&this.api.asc_Print(new Asc.asc_CDownloadOptions(null,Common.Utils.isChrome||Common.Utils.isSafari||Common.Utils.isOpera)),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("Print"),Common.component.Analytics.trackEvent("ToolBar","Print")},onSave:function(t){var e=this.toolbar;if(this.api){var i=this.api.asc_isDocumentCanSave(),n=e.btnCollabChanges&&e.btnCollabChanges.cmpEl.hasClass("notify");if(!i&&!n&&!e.mode.forcesave)return;this.api.asc_Save()}e.btnSave.setDisabled(!e.mode.forcesave),Common.NotificationCenter.trigger("edit:complete",e),Common.component.Analytics.trackEvent("Save"),Common.component.Analytics.trackEvent("ToolBar","Save")},onBtnChangeState:function(t){if(/\:disabled$/.test(t)){var e=arguments[2];this.toolbar.fireEvent(t,[e])}},onUndo:function(t,e){this.api&&this.api.Undo(),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Undo")},onRedo:function(t,e){this.api&&this.api.Redo(),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Redo")},onCopyPaste:function(t,e){var i=this;if(i.api){(t?i.api.Copy():i.api.Paste())?Common.component.Analytics.trackEvent("ToolBar","Copy Warning"):Common.localStorage.getBool("de-hide-copywarning")||new Common.Views.CopyWarningDialog({handler:function(t){t&&Common.localStorage.setItem("de-hide-copywarning",1),Common.NotificationCenter.trigger("edit:complete",i.toolbar)}}).show()}Common.NotificationCenter.trigger("edit:complete",i.toolbar)},onIncrease:function(t){this.api&&this.api.FontSizeIn(),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Font Size")},onDecrease:function(t){this.api&&this.api.FontSizeOut(),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Font Size")},onBold:function(t,e){this._state.bold=void 0,this.api&&this.api.put_TextPrBold(t.pressed),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Bold")},onItalic:function(t,e){this._state.italic=void 0,this.api&&this.api.put_TextPrItalic(t.pressed),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Italic")},onUnderline:function(t,e){this._state.underline=void 0,this.api&&this.api.put_TextPrUnderline(t.pressed),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Underline")},onStrikeout:function(t,e){this._state.strike=void 0,this.api&&this.api.put_TextPrStrikeout(t.pressed),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Strikeout")},onSuperscript:function(t,e){this.toolbar.btnSubscript.pressed||(this._state.valign=void 0,this.api&&this.api.put_TextPrBaseline(t.pressed?1:0),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Superscript"))},onSubscript:function(t,e){this.toolbar.btnSuperscript.pressed||(this._state.valign=void 0,this.api&&this.api.put_TextPrBaseline(t.pressed?2:0),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Subscript"))},onDecOffset:function(t,e){this.api&&this.api.DecreaseIndent(),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Indent")},onIncOffset:function(t,e){this.api&&this.api.IncreaseIndent(),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Indent")},onHorizontalAlign:function(t,e,i){this._state.pralign=void 0,this.api&&this.api.put_PrAlign(t),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Align")},onMarkers:function(t,e){var i={data:{type:0,subtype:t.pressed?0:-1}};this.onSelectBullets(null,null,null,i),Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onNumbers:function(t,e){var i={data:{type:1,subtype:t.pressed?0:-1}};this.onSelectBullets(null,null,null,i),Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onComboBlur:function(){Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onFontNameSelect:function(t,e){this.api&&(e.isNewFont?!Common.Utils.ModalWindow.isVisible()&&Common.UI.warning({width:500,closable:!1,msg:this.confirmAddFontName,buttons:["yes","no"],primary:"yes",callback:_.bind(function(t){"yes"==t?(this.api.put_TextPrFontName(e.name),Common.component.Analytics.trackEvent("ToolBar","Font Name")):this.toolbar.cmbFontName.setValue(this.api.get_TextProps().get_TextPr().get_FontFamily().get_Name()),Common.NotificationCenter.trigger("edit:complete",this.toolbar)},this)}):(this.api.put_TextPrFontName(e.name),Common.component.Analytics.trackEvent("ToolBar","Font Name"))),Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onComboOpen:function(t,e){_.delay(function(){var i=$("input",e.cmpEl).select();t?i.focus():e.isMenuOpen()||i.one("mouseup",function(t){t.preventDefault()})},10)},onFontSizeSelect:function(t,e){this._state.fontsize=void 0,this.api&&this.api.put_TextPrFontSize(e.value),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Font Size")},onFontSizeChanged:function(t,e,i,n){var o;if(t){if(!e.store.findWhere({displayValue:i.value})&&!(o=/^\+?(\d*(\.|,)?\d+)$|^\+?(\d+(\.|,)?\d*)$/.exec(i.value)))return o=this._getApiTextSize(),Common.UI.warning({msg:this.textFontSizeErr,callback:function(){_.defer(function(t){$("input",e.cmpEl).focus()})}}),e.setRawValue(o),n.preventDefault(),!1}else o=Common.Utils.String.parseFloat(i.value),o=o>300?300:o<1?1:Math.floor(2*(o+.4))/2,e.setRawValue(o),this._state.fontsize=void 0,this.api&&this.api.put_TextPrFontSize(o),Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onSelectBullets:function(t,e,i,n){var o={};if(_.isFunction(n.toJSON)){if(!n.get("selected"))return;o=n.toJSON()}else o=n;t&&t.toggle(o.data.subtype>-1,!0),this._state.bullets.type=void 0,this._state.bullets.subtype=void 0,this.api&&this.api.put_ListType(o.data.type,o.data.subtype),Common.component.Analytics.trackEvent("ToolBar","List Type"),Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onMarkerSettingsClick:function(t){var e=this,i=e.api.asc_GetCurrentNumberingId(),n=e.api.asc_GetCurrentNumberingLvl(),o=null!==i?e.api.asc_GetNumberingPr(i):null;o&&new DE.Views.ListSettingsDialog({api:e.api,props:o,level:n,type:t,interfaceLang:e.mode.lang,handler:function(t,n){"ok"==t&&e.api&&e.api.asc_ChangeNumberingLvl(i,n.props,n.num),Common.NotificationCenter.trigger("edit:complete",e.toolbar)}}).show()},onLineSpaceToggle:function(t,e,i,n){i&&(this._state.linespace=void 0,this.api&&this.api.put_PrLineSpacing(c_paragraphLinerule.LINERULE_AUTO,e.value),Common.component.Analytics.trackEvent("ToolBar","Line Spacing"),Common.NotificationCenter.trigger("edit:complete",this.toolbar))},onMenuNonPrintingToggle:function(t,e,i,n){var o=this;"characters"===e.value?(Common.localStorage.setItem("de-show-hiddenchars",i),o.toolbar.btnShowHidenChars.toggle(i,!0),o.api&&o.api.put_ShowParaMarks(i),Common.NotificationCenter.trigger("edit:complete",o),Common.component.Analytics.trackEvent("ToolBar","Hidden Characters")):"table"===e.value&&(Common.localStorage.setItem("de-show-tableline",i),o.api&&o.api.put_ShowTableEmptyLine(i),Common.NotificationCenter.trigger("edit:complete",o))},onNonPrintingToggle:function(t,e){var i=this;e?(i.toolbar.mnuNonPrinting.items[0].setChecked(!0,!0),Common.component.Analytics.trackEvent("ToolBar","Hidden Characters")):i.toolbar.mnuNonPrinting.items[0].setChecked(!1,!0),i.api&&i.api.put_ShowParaMarks(e),Common.localStorage.setItem("de-show-hiddenchars",e),Common.NotificationCenter.trigger("edit:complete",i)},onClickPageBreak:function(t,e){"column"===t?(this.api.put_AddColumnBreak(),Common.component.Analytics.trackEvent("ToolBar","Column Break")):"page"==t?(this.api.put_AddPageBreak(),Common.component.Analytics.trackEvent("ToolBar","Page Break")):(this.api.add_SectionBreak(t),Common.component.Analytics.trackEvent("ToolBar","Section Break")),Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onTablePickerSelect:function(t,e,i,n){this.api&&(this.toolbar.fireEvent("inserttable",this.toolbar),this.api.put_Table(e,i)),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Table")},onInsertTableClick:function(t,e,i){if("custom"===e.value){var n=this;new Common.Views.InsertTableDialog({handler:function(t,e){"ok"==t&&(n.api&&(n.toolbar.fireEvent("inserttable",n.toolbar),n.api.put_Table(e.columns,e.rows)),Common.component.Analytics.trackEvent("ToolBar","Table")),Common.NotificationCenter.trigger("edit:complete",n.toolbar)}}).show()}else"draw"==e.value?(e.isChecked()&&t.items[3].setChecked(!1,!0),this.api.SetTableDrawMode(e.isChecked())):"erase"==e.value&&(e.isChecked()&&t.items[2].setChecked(!1,!0),this.api.SetTableEraseMode(e.isChecked()))},onInsertImageClick:function(t,e,i){var n=this;"file"===e.value?(this.toolbar.fireEvent("insertimage",this.toolbar),this.api&&this.api.asc_addImage(),Common.NotificationCenter.trigger("edit:complete",n.toolbar),Common.component.Analytics.trackEvent("ToolBar","Image")):"url"===e.value?new Common.Views.ImageFromUrlDialog({handler:function(t,e){if("ok"==t){if(n.api){var i=e.replace(/ /g,"");_.isEmpty(i)?Common.UI.warning({msg:this.textEmptyImgUrl}):(n.toolbar.fireEvent("insertimage",n.toolbar),n.api.AddImageUrl(i),Common.component.Analytics.trackEvent("ToolBar","Image"))}Common.NotificationCenter.trigger("edit:complete",n.toolbar)}}}).show():"storage"===e.value&&Common.NotificationCenter.trigger("storage:image-load","add")},openImageFromStorage:function(t){var e=this;this.toolbar.mode.canRequestInsertImage?Common.Gateway.requestInsertImage(t):new Common.Views.SelectFileDlg({fileChoiceUrl:this.toolbar.mode.fileChoiceUrl.replace("{fileExt}","").replace("{documentType}","ImagesOnly")}).on("selectfile",function(i,n){n&&(n.c=t),e.insertImage(n)}).show()},insertImageFromStorage:function(t){!t||!t.url||t.c&&"add"!=t.c||(this.toolbar.fireEvent("insertimage",this.toolbar),this.api.AddImageUrl(t.url,void 0,t.token),Common.component.Analytics.trackEvent("ToolBar","Image"))},insertImage:function(t){Common.NotificationCenter.trigger("storage:image-insert",t)},onBtnInsertTextClick:function(t,e){this.api&&this._addAutoshape(t.pressed,"textRect"),this.toolbar.btnInsertShape.pressed&&this.toolbar.btnInsertShape.toggle(!1,!0),Common.NotificationCenter.trigger("edit:complete",this.toolbar,this.toolbar.btnInsertShape),Common.component.Analytics.trackEvent("ToolBar","Add Text")},onInsertShapeHide:function(t,e){this.toolbar.btnInsertShape.pressed&&!this._isAddingShape&&this.toolbar.btnInsertShape.toggle(!1,!0),this._isAddingShape=!1,Common.NotificationCenter.trigger("edit:complete",this.toolbar,this.toolbar.btnInsertShape)},onPageOrientSelect:function(t,e){this._state.pgorient=void 0,this.api&&e.checked&&this.api.change_PageOrient(e.value),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Page Orientation")},onClearStyleClick:function(t,e){this.api&&this.api.ClearFormating(),Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onCopyStyleToggle:function(t,e,i){this.api&&this.api.SetPaintFormat(e?1:0),Common.NotificationCenter.trigger("edit:complete",this.toolbar),this.modeAlwaysSetStyle=e},onPageSizeClick:function(t,e,i){if(this.api&&i){if(this._state.pgsize=[0,0],"advanced"!==e.value)this.api.change_DocSize(e.value[0],e.value[1]);else{var n,o,s=this;n=new DE.Views.PageSizeDialog({handler:function(t,e){"ok"==e&&(o=t.getSettings(),s.api.change_DocSize(o[0],o[1]),Common.NotificationCenter.trigger("edit:complete",s.toolbar))}}),n.show(),n.setSettings(s.api.asc_GetSectionProps())}Common.component.Analytics.trackEvent("ToolBar","Page Size")} Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onPageMarginsSelect:function(t,e){if(this.api){if(this._state.pgmargins=void 0,"advanced"!==e.value){var i=this.api.asc_GetSectionProps(),n=null,o=this;if(e.value[1]+e.value[3]>parseFloat(i.get_W().toFixed(4))-12.7?n=this.txtMarginsW:e.value[0]+e.value[2]>parseFloat(i.get_H().toFixed(4))-2.6&&(n=this.txtMarginsH),n)return Common.UI.warning({title:this.notcriticalErrorTitle,msg:n,callback:function(){Common.NotificationCenter.trigger("edit:complete",o.toolbar)}}),void this.onSectionProps(i);var s=new Asc.CDocumentSectionProps;s.put_TopMargin(e.value[0]),s.put_LeftMargin(e.value[1]),s.put_BottomMargin(e.value[2]),s.put_RightMargin(e.value[3]),this.api.asc_SetSectionProps(s)}else{var a,s,o=this;a=new DE.Views.PageMarginsDialog({api:o.api,handler:function(t,e){if("ok"==e){s=t.getSettings();var i=o.toolbar.btnPageMargins.menu.items[0];i.setVisible(!0),i.setChecked(!0),i.options.value=i.value=[s.get_TopMargin(),s.get_LeftMargin(),s.get_BottomMargin(),s.get_RightMargin()],$(i.el).html(i.template({id:Common.UI.getId(),caption:i.caption,options:i.options})),Common.localStorage.setItem("de-pgmargins-top",s.get_TopMargin()),Common.localStorage.setItem("de-pgmargins-left",s.get_LeftMargin()),Common.localStorage.setItem("de-pgmargins-bottom",s.get_BottomMargin()),Common.localStorage.setItem("de-pgmargins-right",s.get_RightMargin()),o.api.asc_SetSectionProps(s),Common.NotificationCenter.trigger("edit:complete",o.toolbar)}}}),a.show(),a.setSettings(o.api.asc_GetSectionProps())}Common.component.Analytics.trackEvent("ToolBar","Page Margins")}Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onLineNumbersSelect:function(t,e){if(!_.isUndefined(e.value)){switch(e.value){case 0:this.api.asc_SetLineNumbersProps(Asc.c_oAscSectionApplyType.Current,null);break;case 1:case 2:case 3:if(this._state.linenum=void 0,this.api&&e.checked){var i=new Asc.CSectionLnNumType;i.put_Restart(1==e.value?Asc.c_oAscLineNumberRestartType.Continuous:2==e.value?Asc.c_oAscLineNumberRestartType.NewPage:Asc.c_oAscLineNumberRestartType.NewSection),!!this.api.asc_GetLineNumbersProps()&&i.put_CountBy(void 0),this.api.asc_SetLineNumbersProps(Asc.c_oAscSectionApplyType.Current,i)}break;case 4:this.api&&this.api.asc_SetParagraphSuppressLineNumbers(e.checked);break;case 5:var n,o=this;n=new DE.Views.LineNumbersDialog({applyTo:o._state.linenum_apply,handler:function(t,e){if("ok"==e){var i=t.getSettings();o.api.asc_SetLineNumbersProps(i.type,i.props),o._state.linenum_apply=i.type,Common.NotificationCenter.trigger("edit:complete",o.toolbar)}}}),n.show(),n.setSettings(o.api.asc_GetLineNumbersProps())}Common.NotificationCenter.trigger("edit:complete",this.toolbar)}},onLineNumbersProps:function(t){var e=0;if(t)switch(t.get_Restart()){case Asc.c_oAscLineNumberRestartType.Continuous:e=1;break;case Asc.c_oAscLineNumberRestartType.NewPage:e=2;break;case Asc.c_oAscLineNumberRestartType.NewSection:e=3}this._state.linenum!==e&&(this.toolbar.btnLineNumbers.menu.items[e].setChecked(!0),this._state.linenum=e)},onLineNumbersShow:function(t){t.items[4].setChecked(this._state.suppress_num)},onColorSchemaClick:function(t,e){this.api&&(this.api.asc_ChangeColorSchemeByIdx(e.value),Common.component.Analytics.trackEvent("ToolBar","Color Scheme")),Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onColorSchemaShow:function(t){if(this.api){var e=this.api.asc_GetCurrentColorSchemeIndex(),i=_.find(t.items,function(t){return t.value==e});i?i.setChecked(!0):t.clearAll()}},onDropCapSelect:function(t,e){if(!_.isUndefined(e.value)){if(this._state.dropcap=void 0,this.api&&e.checked)if(e.value===Asc.c_oAscDropCap.None)this.api.removeDropcap(!0);else for(var i=this.api.getSelectedElements(),n=-1;++n=0?this.api.asc_AddContentControlPicture(a):e.value.indexOf("checkbox")>=0||e.value.indexOf("radiobox")>=0?(r&&(s=new AscCommon.CSdtCheckBoxPr,e.value.indexOf("radiobox")>=0&&s.put_GroupKey("Group 1")),this.api.asc_AddContentControlCheckBox(s,a)):"date"==e.value?this.api.asc_AddContentControlDatePicker():e.value.indexOf("combobox")>=0||e.value.indexOf("dropdown")>=0?this.api.asc_AddContentControlList(e.value.indexOf("combobox")>=0,s,a):"new-field"==e.value&&(s=new AscCommon.CSdtTextFormPr,this.api.asc_AddContentControlTextForm(s,a)),Common.component.Analytics.trackEvent("ToolBar","Add Content Control")}Common.NotificationCenter.trigger("edit:complete",this.toolbar)}},onNewControlsColor:function(t,e){this.toolbar.mnuControlsColorPicker.addNewColor()},onNoControlsColor:function(t){t.isChecked()?this.api.asc_SetGlobalContentControlShowHighlight(!1):this.api.asc_SetGlobalContentControlShowHighlight(!0,220,220,220)},onSelectControlsColor:function(t,e){var i=Common.Utils.ThemeColor.getRgbColor(e);this.api&&this.api.asc_SetGlobalContentControlShowHighlight(!0,i.get_r(),i.get_g(),i.get_b()),Common.component.Analytics.trackEvent("ToolBar","Content Controls Color")},onColumnsSelect:function(t,e){if(!_.isUndefined(e.value)){if(this._state.columns=void 0,this.api)if("advanced"==e.value){var i,n=this;i=new DE.Views.CustomColumnsDialog({handler:function(t,e){"ok"==e&&(o=t.getSettings(),n.api.asc_SetColumnsProps(o),Common.NotificationCenter.trigger("edit:complete",n.toolbar))}}),i.show(),i.setSettings(n.api.asc_GetColumnsProps())}else if(e.checked){var o=new Asc.CDocumentColumnsProps,s=e.value;if(o.put_EqualWidth(s<3),s<3)o.put_Num(s+1),o.put_Space(12.5);else{var a=this.api.asc_GetColumnsProps().get_TotalWidth(),r=(a-25)/3,l=a-12.5-r;o.put_ColByValue(0,3==s?r:l,12.5),o.put_ColByValue(1,3==s?l:r,0)}this.api.asc_SetColumnsProps(o)}Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Insert Columns")}},onColumnsProps:function(t){if(t){var e=t.get_EqualWidth(),i=e?t.get_Num():t.get_ColsCount(),n=-1;if(e&&i<4&&(1==i||Math.abs(t.get_Space()-12.5)<.1))n=i-1;else if(!e&&2==i){var o=t.get_Col(0).get_W(),s=t.get_Col(0).get_Space(),a=t.get_Col(1).get_W(),r=t.get_TotalWidth();if(Math.abs(s-12.5)<.1){var l=(r-2*s)/3;oa&&Math.abs(a-l)<.1&&(n=4)}}if(this._state.columns===n)return;n<0?this.toolbar.btnColumns.menu.clearAll():this.toolbar.btnColumns.menu.items[n].setChecked(!0),this._state.columns=n}},onSelectChart:function(t){var e=this,i=!1,n=e.api.getSelectedElements();if(n&&_.isArray(n))for(var o=0;o-1,fontStore:i.fontstore,handler:function(t,e){"ok"==t&&i.api.asc_SetWatermarkProps(e),Common.NotificationCenter.trigger("edit:complete",i.toolbar)}}).show()}Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Edit "+e.value)}},onListStyleSelect:function(t,e){this._state.prstyle=void 0,this.api&&this.api.put_Style(e.get("title")),Common.NotificationCenter.trigger("edit:complete",this.toolbar),Common.component.Analytics.trackEvent("ToolBar","Style")},onListStyleBeforeHide:function(t,e){this.toolbar.listStyles.isStylesNotClosable=!1},onListStyleContextMenu:function(t,e,i){if(this.toolbar.mode.canEditStyles){var n,o=this.toolbar.styleMenu,s=this.api,a=!0,r=!0;_.each(window.styles.get_MergedStyles(),function(t){s.asc_IsStyleDefault(t.get_Name())?s.asc_IsDefaultStyleChanged(t.get_Name())&&(r=!1):a=!1}),o.items[3].setDisabled(r),o.items[4].setDisabled(a);var l=this.toolbar.$el.offset(),c=i.clientY*Common.Utils.zoom();if($("#header-container").is(":visible")&&(c-=$("#header-container").height()),n=[i.clientX*Common.Utils.zoom(),c-l.top],void 0!=e){var d=this.api.asc_IsStyleDefault(e.get("title"));o.items[0].setVisible(!0),o.items[1].setVisible(!d),o.items[2].setVisible(d),o.items[3].setVisible(d),o.items[4].setVisible(!d),o.items[2].setDisabled(!this.api.asc_IsDefaultStyleChanged(e.get("title")));for(var h in o.items)o.items[h].styleTitle=e.get("title");var p=s.getSelectedElements(),m=!1;if(p&&_.isArray(p))for(var h=0;h',o.id),$(this.toolbar.el).append(u)),o.render(u),o.cmpEl.attr({tabindex:"-1"})),u.css({left:n[0],top:n[1]});var g=$(o.el);g.trigger($.Event("show.bs.dropdown")),g.trigger($.Event("hide.bs.dropdown")),o.isVisible()&&$(o).toggleClass("open").trigger("shown.bs.dropdown"),this.toolbar.listStyles.isStylesNotClosable=!0,o.show()}}},onSaveStyle:function(t){window.styles_loaded=!1;var e,i=this;if(i.api){var n=function(e,n){if("ok"==n){var o=e.getTitle(),s=e.getNextStyle(),a=t.get_Link();i._state.prstyle=o,t.put_Name(o),a.put_Name(o+"_character"),t.put_Next(s?s.asc_getName():null),i.api.asc_AddNewStyle(t)}Common.NotificationCenter.trigger("edit:complete",i.toolbar)},o=[],s=i.getApplication().getController("Main");_.each(window.styles.get_MergedStyles(),function(t){o.push({value:t,displayValue:s.translationTable[t.get_Name()]||t.get_Name()})}),e=new DE.Views.StyleTitleDialog({handler:n,formats:o}),e.show()}Common.component.Analytics.trackEvent("ToolBar","Save as Style")},onMenuSaveStyle:function(t,e){var i=this;i.api&&!i.toolbar.listStylesAdditionalMenuItem.isDisabled()&&i.onSaveStyle(i.api.asc_GetStyleFromFormatting())},onUpdateStyle:function(t){this.api&&(t.put_Name(this._state.prstyle),this.api.asc_AddNewStyle(t))},_clearBullets:function(){this.toolbar.btnMarkers.toggle(!1,!0),this.toolbar.btnNumbers.toggle(!1,!0),this.toolbar.btnMultilevels.toggle(!1,!0),this.toolbar.mnuMarkersPicker.selectByIndex(0,!0),this.toolbar.mnuNumbersPicker.selectByIndex(0,!0),this.toolbar.mnuMultilevelPicker.selectByIndex(0,!0),this.toolbar.mnuMarkerSettings&&this.toolbar.mnuMarkerSettings.setDisabled(!0),this.toolbar.mnuNumberSettings&&this.toolbar.mnuNumberSettings.setDisabled(!0),this.toolbar.mnuMultilevelSettings&&this.toolbar.mnuMultilevelSettings.setDisabled(!0)},_getApiTextSize:function(){var t=12,e=this.api.get_TextProps();return e&&e.get_TextPr&&(t=e.get_TextPr().get_FontSize()),t},onNewFontColor:function(t,e){this.toolbar.mnuFontColorPicker.addNewColor()},onAutoFontColor:function(t){this._state.clrtext=this._state.clrtext_asccolor=void 0;var e=new Asc.asc_CColor;e.put_auto(!0),this.api.put_TextColor(e),this.toolbar.btnFontColor.currentColor={color:e,isAuto:!0},$(".btn-color-value-line",this.toolbar.btnFontColor.cmpEl).css("background-color","#000"),this.toolbar.mnuFontColorPicker.clearSelection(),this.toolbar.mnuFontColorPicker.currentColor={color:e,isAuto:!0}},onNewParagraphColor:function(t,e){this.toolbar.mnuParagraphColorPicker.addNewColor()},onSelectHighlightColor:function(t,e){this._setMarkerColor(e,"menu")},onSelectFontColor:function(t,e){this._state.clrtext=this._state.clrtext_asccolor=void 0;var i="object"==typeof e?e.isAuto?"#000":e.color:e;this.toolbar.btnFontColor.currentColor=e,$(".btn-color-value-line",this.toolbar.btnFontColor.cmpEl).css("background-color","#"+i),this.toolbar.mnuFontColorPicker.currentColor=e,this.api&&this.api.put_TextColor(e.isAuto?e.color:Common.Utils.ThemeColor.getRgbColor(e)),Common.component.Analytics.trackEvent("ToolBar","Text Color")},onParagraphColorPickerSelect:function(t,e){this._state.clrback=this._state.clrshd_asccolor=void 0;var i="object"==typeof e?e.color:e;this.toolbar.btnParagraphColor.currentColor=e,$(".btn-color-value-line",this.toolbar.btnParagraphColor.cmpEl).css("background-color","transparent"!=e?"#"+i:i),this.toolbar.mnuParagraphColorPicker.currentColor=e,this.api&&("transparent"==e?this.api.put_ParagraphShade(!1):this.api.put_ParagraphShade(!0,Common.Utils.ThemeColor.getRgbColor(e))),Common.NotificationCenter.trigger("edit:complete",this)},onBtnHighlightColor:function(t){t.pressed?(this._setMarkerColor(t.currentColor),Common.component.Analytics.trackEvent("ToolBar","Highlight Color")):this.api.SetMarkerFormat(!1)},onBtnFontColor:function(){this.toolbar.mnuFontColorPicker.trigger("select",this.toolbar.mnuFontColorPicker,this.toolbar.mnuFontColorPicker.currentColor)},onBtnParagraphColor:function(){this.toolbar.mnuParagraphColorPicker.trigger("select",this.toolbar.mnuParagraphColorPicker,this.toolbar.mnuParagraphColorPicker.currentColor)},onHighlightTransparentClick:function(t,e){this._setMarkerColor("transparent","menu"),t.setChecked(!0,!0),this.toolbar.btnHighlightColor.currentColor="transparent",$(".btn-color-value-line",this.toolbar.btnHighlightColor.cmpEl).css("background-color","transparent")},onParagraphColor:function(t){var e,i=this.toolbar.mnuParagraphColorPicker;if(null!==t&&void 0!==t&&t.get_Value()===Asc.c_oAscShdClear){var n=t.get_Color();e=n?n.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?{color:Common.Utils.ThemeColor.getHexColor(n.get_r(),n.get_g(),n.get_b()),effectValue:n.get_value()}:Common.Utils.ThemeColor.getHexColor(n.get_r(),n.get_g(),n.get_b()):"transparent"}else e="transparent";var o=typeof e;if(o!==typeof this._state.clrback||"object"==o&&(e.effectValue!==this._state.clrback.effectValue||this._state.clrback.color.indexOf(e.color)<0)||"object"!=o&&this._state.clrback.indexOf(e)<0){if("object"==typeof e){for(var s=!1,a=0;a<10;a++)if(Common.Utils.ThemeColor.ThemeValues[a]==e.effectValue){i.select(e,!0),s=!0;break}s||i.clearSelection()}else i.select(e,!0);this._state.clrback=e}this._state.clrshd_asccolor=t},onApiTextColor:function(t){if(t.get_auto()){if("auto"!==this._state.clrtext){this.toolbar.mnuFontColorPicker.clearSelection();var e=this.toolbar.btnFontColor.menu.$el.find("#id-toolbar-menu-auto-fontcolor > a");!e.hasClass("selected")&&e.addClass("selected"),this._state.clrtext="auto"}}else{var i,n=this.toolbar.mnuFontColorPicker;t&&(i=t.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?{color:Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()),effectValue:t.get_value()}:Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()));var o=typeof i,s=typeof this._state.clrtext;if("auto"==this._state.clrtext||o!==s||"object"==o&&(i.effectValue!==this._state.clrtext.effectValue||this._state.clrtext.color.indexOf(i.color)<0)||"object"!=o&&this._state.clrtext.indexOf(i)<0){var e=this.toolbar.btnFontColor.menu.$el.find("#id-toolbar-menu-auto-fontcolor > a");if(e.hasClass("selected")&&e.removeClass("selected"),"object"==typeof i){for(var a=!1,r=0;r<10;r++)if(Common.Utils.ThemeColor.ThemeValues[r]==i.effectValue){n.select(i,!0),a=!0;break}a||n.clearSelection()}else n.select(i,!0);this._state.clrtext=i}}this._state.clrtext_asccolor=t},onApiAutoShapes:function(){var t=this,e=function(i){t.fillAutoShapes(),i.off("show:before",e)};t.toolbar.btnInsertShape.menu.on("show:before",e)},fillAutoShapes:function(){var t=this,e=this.getApplication().getCollection("ShapeGroups"),i=function(n){for(var o=0;o')}).on("item:click",function(e,i,n,o){t.api&&(n&&(t._addAutoshape(!0,n.get("data").shapeType),t._isAddingShape=!0),t.toolbar.btnInsertText.pressed&&t.toolbar.btnInsertText.toggle(!1,!0),"click"!==o.type&&t.toolbar.btnInsertShape.menu.hide(),Common.NotificationCenter.trigger("edit:complete",t.toolbar,t.toolbar.btnInsertShape),Common.component.Analytics.trackEvent("ToolBar","Add Shape"))})}n.off("show:after",i)};t.toolbar.btnInsertShape.menu.on("show:after",i);for(var n=0;n')}]})});t.toolbar.btnInsertShape.menu.addItem(s)}},fillEquations:function(){if(this.toolbar.btnInsertEquation.rendered&&!(this.toolbar.btnInsertEquation.menu.items.length>0)){var t=this,e=this.getApplication().getCollection("EquationGroups");t.toolbar.btnInsertEquation.menu.removeAll();var i=function(n){for(var o=0;o
    ')}).on("item:click",function(e,i,n,o){t.api&&(n&&t.api.asc_AddMath(n.get("data").equationType),t.toolbar.btnInsertText.pressed&&t.toolbar.btnInsertText.toggle(!1,!0),t.toolbar.btnInsertShape.pressed&&t.toolbar.btnInsertShape.toggle(!1,!0),"click"!==o.type&&t.toolbar.btnInsertEquation.menu.hide(),Common.NotificationCenter.trigger("edit:complete",t.toolbar,t.toolbar.btnInsertEquation),Common.component.Analytics.trackEvent("ToolBar","Add Equation"))})}n.off("show:after",i)};t.toolbar.btnInsertEquation.menu.on("show:after",i);for(var n=0;n')}]})});t.toolbar.btnInsertEquation.menu.addItem(s)}}},onInsertEquationClick:function(){this.api&&!this._state.in_equation&&(this.api.asc_AddMath(),Common.component.Analytics.trackEvent("ToolBar","Add Equation")),Common.NotificationCenter.trigger("edit:complete",this.toolbar,this.toolbar.btnInsertEquation)},onInsertSymbolClick:function(){if((!this.dlgSymbolTable||!this.dlgSymbolTable.isVisible())&&this.api){var t=this,e=t.api.asc_GetSelectedText();t.dlgSymbolTable=new Common.Views.SymbolTableDialog({api:t.api,lang:t.mode.lang,modal:!1,type:1,special:!0,showShortcutKey:!0,font:e&&e.length>0?this.api.get_TextProps().get_TextPr().get_FontFamily().get_Name():void 0,symbol:e&&e.length>0?e.charAt(0):void 0,buttons:[{value:"ok",caption:this.textInsert},"close"],handler:function(e,i,n){"ok"==i?t.api.asc_insertSymbol(n.font?n.font:t.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(),n.code,n.special):Common.NotificationCenter.trigger("edit:complete",t.toolbar)}}),t.dlgSymbolTable.show(),t.dlgSymbolTable.on("symbol:dblclick",function(e,i,n){t.api.asc_insertSymbol(n.font?n.font:t.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(),n.code,n.special)})}},onApiMathTypes:function(t){this._equationTemp=t;var e=this,i=function(t){e.onMathTypes(e._equationTemp),e.toolbar.btnInsertEquation.menu.off("show:before",i)};e.toolbar.btnInsertEquation.menu.on("show:before",i)},onMathTypes:function(t){var e=[],i=this.getCollection("EquationGroups");i.reset();var n={};n[Common.define.c_oAscMathMainType.Symbol]=[this.textSymbols,11],n[Common.define.c_oAscMathMainType.Fraction]=[this.textFraction,4],n[Common.define.c_oAscMathMainType.Script]=[this.textScript,4],n[Common.define.c_oAscMathMainType.Radical]=[this.textRadical,4],n[Common.define.c_oAscMathMainType.Integral]=[this.textIntegral,3,!0],n[Common.define.c_oAscMathMainType.LargeOperator]=[this.textLargeOperator,5,!0],n[Common.define.c_oAscMathMainType.Bracket]=[this.textBracket,4,!0],n[Common.define.c_oAscMathMainType.Function]=[this.textFunction,3,!0],n[Common.define.c_oAscMathMainType.Accent]=[this.textAccent,4],n[Common.define.c_oAscMathMainType.LimitLog]=[this.textLimitAndLog,3],n[Common.define.c_oAscMathMainType.Operator]=[this.textOperator,4],n[Common.define.c_oAscMathMainType.Matrix]=[this.textMatrix,4,!0];var o={},s="",a="";for(s in Common.define.c_oAscMathType)if(Common.define.c_oAscMathType.hasOwnProperty(s)){var r=s.split("_");a=2==r.length&&"Symbol"==r[0]?"txt"+r[0]+"_"+r[1].toLocaleLowerCase():"txt"+s,o[Common.define.c_oAscMathType[s]]=this[a]}var l,c,d=0,h=0,p=0,m=0,u=0,g=null,b=null,f=null;if(t&&(c=t.get_Data(),h=c.length)){for(var C=0;C0&&i.rendered){var s;e._state.prstyle&&(s=i.menuPicker.store.findWhere({title:e._state.prstyle})),i.fillComboView(s||i.menuPicker.store.at(0),!0),Common.NotificationCenter.trigger("edit:complete",this)}else i.rendered&&i.clearComboView();window.styles_loaded=!0},onHomeOpen:function(){var t=this.toolbar.listStyles;if(t&&t.needFillComboView&&t.menuPicker.store.length>0&&t.rendered){var e;this._state.prstyle&&(e=t.menuPicker.store.findWhere({title:this._state.prstyle})),t.fillComboView(e||t.menuPicker.store.at(0),!0)}},_setMarkerColor:function(t,e){var i=this;if("menu"===e&&(i.toolbar.mnuHighlightTransparent.setChecked(!1),i.toolbar.btnHighlightColor.currentColor=t,$(".btn-color-value-line",i.toolbar.btnHighlightColor.cmpEl).css("background-color","#"+t),i.toolbar.btnHighlightColor.toggle(!0,!0)),"transparent"==(t=t||"transparent"))i.api.SetMarkerFormat(!0,!1);else{var n=t[0]+t[1],o=t[2]+t[3],s=t[4]+t[5];i.api.SetMarkerFormat(!0,!0,parseInt(n,16),parseInt(o,16),parseInt(s,16))}Common.NotificationCenter.trigger("edit:complete",i.toolbar,i.toolbar.btnHighlightColor),Common.component.Analytics.trackEvent("ToolBar","Highlight Color")},onHideMenus:function(t){Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onSetupCopyStyleButton:function(){this.modeAlwaysSetStyle=!1;var t=this;Common.NotificationCenter.on({"edit:complete":function(){t.api&&t.modeAlwaysSetStyle&&(t.api.SetPaintFormat(AscCommon.c_oAscFormatPainterState.kOff),t.toolbar.btnCopyStyle.toggle(!1,!0),t.modeAlwaysSetStyle=!1)}}),$(t.toolbar.btnCopyStyle.cmpEl).dblclick(function(){t.api&&(t.modeAlwaysSetStyle=!0,t.toolbar.btnCopyStyle.toggle(!0,!0),t.api.SetPaintFormat(AscCommon.c_oAscFormatPainterState.kMultiple))})},onApiCoAuthoringDisconnect:function(t){this.mode.isEdit&&this.toolbar.setMode({isDisconnected:!0,enableDownload:!!t}),this.editMode=!1,this.DisableToolbar(!0,!0)},DisableToolbar:function(t,e,i,n){void 0!==e&&(this.editMode=!e),t=t||!this.editMode;var o=$(".toolbar-mask"),s=$(".toolbar-group-mask"),a=i||n?s:o;if(!(t&&a.length>0||!t&&0==a.length)){var r=this.toolbar;t?a=i?$("
    ").appendTo(r.$el.find(".toolbar section.panel .group:not(.no-mask):not(.no-group-mask.review)")):n?$("
    ").appendTo(r.$el.find(".toolbar section.panel .group:not(.no-mask):not(.no-group-mask.form-view)")):$("
    ").appendTo(r.$el.find(".toolbar")):a.remove(),$(".no-group-mask").each(function(e,o){var s=$(o);s.find(".toolbar-group-mask").length>0?s.css("opacity",.4):s.css("opacity",i||n||!t?1:.4)}),t=t||(i||n?o.length>0:s.length>0),r.$el.find(".toolbar").toggleClass("masked",t),r.synchTooltip&&r.synchTooltip.hide(),r._state.previewmode=i&&t,i&&(r._state.previewmode&&r.btnSave&&r.btnSave.setDisabled(!0),r.needShowSynchTip&&(r.needShowSynchTip=!1,r.onCollaborativeChanges())),t?Common.util.Shortcuts.suspendEvents("alt+h"):Common.util.Shortcuts.resumeEvents("alt+h")}},onSelectRecepientsClick:function(){if(!this._mailMergeDlg)if(this.toolbar.mode.canRequestMailMergeRecipients)Common.Gateway.requestMailMergeRecipients();else{var t=this ;t._mailMergeDlg=new Common.Views.SelectFileDlg({fileChoiceUrl:this.toolbar.mode.fileChoiceUrl.replace("{fileExt}","xlsx").replace("{documentType}","")}),t._mailMergeDlg.on("selectfile",function(e,i){t.setMailMergeRecipients(i)}).on("close",function(e){t._mailMergeDlg=void 0}),t._mailMergeDlg.show()}},setMailMergeRecipients:function(t){this.api.asc_StartMailMerge(t),this.mergeEditor||(this.mergeEditor=this.getApplication().getController("Common.Controllers.ExternalMergeEditor").getView("Common.Views.ExternalMergeEditor")),this.mergeEditor&&this.mergeEditor.setEditMode(!1)},createDelayedElements:function(){this.toolbar.createDelayedElements(),this.attachUIEvents(this.toolbar)},onAppShowed:function(t){var e=this,i=!t.isEdit;t.isEdit&&(Common.localStorage.itemExists("de-compact-toolbar")?i=Common.localStorage.getBool("de-compact-toolbar"):t.customization&&t.customization.compactToolbar&&(i=!0)),e.toolbar.render(_.extend({isCompactView:i},t));var n={action:"review",caption:e.toolbar.textTabCollaboration},o=e.application.getController("Common.Controllers.ReviewChanges").createToolbarPanel();if(o&&e.toolbar.addTab(n,o,5),t.isEdit){if(e.toolbar.setMode(t),e.toolbar.btnSave.on("disabled",_.bind(e.onBtnChangeState,e,"save:disabled")),!t.customization||!t.customization.compactHeader){e.toolbar.btnPrint.$el.parents(".group").hide().next().hide();var s=e.toolbar.btnUndo.$el.hide().next().hide().parent();e.toolbar.btnPaste.$el.detach().appendTo(s),e.toolbar.btnCopy.$el.removeClass("split")}t.isDesktopApp&&t.canProtect&&(n={action:"protect",caption:e.toolbar.textTabProtect},(o=e.getApplication().getController("Common.Controllers.Protection").createToolbarPanel())&&e.toolbar.addTab(n,o,6));var a=e.getApplication().getController("Links");if(a.setApi(e.api).setConfig({toolbar:e}),Array.prototype.push.apply(e.toolbar.toolbarControls,a.getView("Links").getButtons()),t.canFeatureContentControl){if(t.canFeatureForms){n={caption:e.textTabForms,action:"forms"};var r=e.getApplication().getController("FormsTab");r.setApi(e.api).setConfig({toolbar:e}),e.toolbar.addTab(n,o,4),e.toolbar.setVisible("forms",!0),Array.prototype.push.apply(e.toolbar.toolbarControls,r.getView("FormsTab").getButtons())}e.onChangeSdtGlobalSettings()}}},onAppReady:function(t){var e=this;if(e.appOptions=t,t.canCoAuthoring&&t.canComments&&(this.btnsComment=Common.Utils.injectButtons(this.toolbar.$el.find(".slot-comment"),"tlbtn-addcomment-","toolbar__icon btn-menu-comments",this.toolbar.capBtnComment),this.btnsComment.length)){var i=DE.getController("Common.Controllers.Comments").getView();this.btnsComment.forEach(function(t){t.updateHint(i.textHintAddComment),t.on("click",function(t,e){Common.NotificationCenter.trigger("app:comment:add","toolbar")}),t.cmpEl.closest("#review-changes-panel").length>0&&t.setCaption(e.toolbar.capBtnAddComment)},this)}new Promise(function(t){t()}).then(function(){t.isEdit&&(e.controllers.pageLayout=new DE.Controllers.PageLayout({id:"ImageLayout",application:e.getApplication()}),e.controllers.pageLayout.onLaunch(e.toolbar).setApi(e.api).onAppReady(t))})},getView:function(t){return t?Backbone.Controller.prototype.getView.apply(this,arguments):this.toolbar},onFileMenu:function(t){"show"==t?this.toolbar.isTabActive("file")||this.toolbar.setTab("file"):this.toolbar.isTabActive("file")&&this.toolbar.setTab()},onTextLanguage:function(t){this._state.lang=t},onInsDateTimeClick:function(){var t=this;new DE.Views.DateTimeDialog({api:this.api,lang:this._state.lang,handler:function(e,i){"ok"==e&&t.api&&t.api.asc_addDateTime(i),Common.NotificationCenter.trigger("edit:complete",t.toolbar)}}).show()},textEmptyImgUrl:"You need to specify image URL.",textWarning:"Warning",textFontSizeErr:"The entered value is incorrect.
    Please enter a numeric value between 1 and 300",textSymbols:"Symbols",textFraction:"Fraction",textScript:"Script",textRadical:"Radical",textIntegral:"Integral",textLargeOperator:"Large Operator",textBracket:"Bracket",textFunction:"Function",textAccent:"Accent",textLimitAndLog:"Limit And Log",textOperator:"Operator",textMatrix:"Matrix",txtSymbol_pm:"Plus Minus",txtSymbol_infinity:"Infinity",txtSymbol_equals:"Equal",txtSymbol_neq:"Not Equal To",txtSymbol_about:"Approximately",txtSymbol_times:"Multiplication Sign",txtSymbol_div:"Division Sign",txtSymbol_factorial:"Factorial",txtSymbol_propto:"Proportional To",txtSymbol_less:"Less Than",txtSymbol_ll:"Much Less Than",txtSymbol_greater:"Greater Than",txtSymbol_gg:"Much Greater Than",txtSymbol_leq:"Less Than or Equal To",txtSymbol_geq:"Greater Than or Equal To",txtSymbol_mp:"Minus Plus",txtSymbol_cong:"Approximately Equal To",txtSymbol_approx:"Almost Equal To",txtSymbol_equiv:"Identical To",txtSymbol_forall:"For All",txtSymbol_additional:"Complement",txtSymbol_partial:"Partial Differential",txtSymbol_sqrt:"Radical Sign",txtSymbol_cbrt:"Cube Root",txtSymbol_qdrt:"Fourth Root",txtSymbol_cup:"Union",txtSymbol_cap:"Intersection",txtSymbol_emptyset:"Empty Set",txtSymbol_percent:"Percentage",txtSymbol_degree:"Degrees",txtSymbol_fahrenheit:"Degrees Fahrenheit",txtSymbol_celsius:"Degrees Celsius",txtSymbol_inc:"Increment",txtSymbol_nabla:"Nabla",txtSymbol_exists:"There Exist",txtSymbol_notexists:"There Does Not Exist",txtSymbol_in:"Element Of",txtSymbol_ni:"Contains as Member",txtSymbol_leftarrow:"Left Arrow",txtSymbol_uparrow:"Up Arrow",txtSymbol_rightarrow:"Right Arrow",txtSymbol_downarrow:"Down Arrow",txtSymbol_leftrightarrow:"Left-Right Arrow",txtSymbol_therefore:"Therefore",txtSymbol_plus:"Plus",txtSymbol_minus:"Minus",txtSymbol_not:"Not Sign",txtSymbol_ast:"Asterisk Operator",txtSymbol_bullet:"Bulet Operator",txtSymbol_vdots:"Vertical Ellipsis",txtSymbol_cdots:"Midline Horizontal Ellipsis",txtSymbol_rddots:"Up Right Diagonal Ellipsis",txtSymbol_ddots:"Down Right Diagonal Ellipsis",txtSymbol_aleph:"Alef",txtSymbol_beth:"Bet",txtSymbol_qed:"End of Proof",txtSymbol_alpha:"Alpha",txtSymbol_beta:"Beta",txtSymbol_gamma:"Gamma",txtSymbol_delta:"Delta",txtSymbol_varepsilon:"Epsilon Variant",txtSymbol_epsilon:"Epsilon",txtSymbol_zeta:"Zeta",txtSymbol_eta:"Eta",txtSymbol_theta:"Theta",txtSymbol_vartheta:"Theta Variant",txtSymbol_iota:"Iota",txtSymbol_kappa:"Kappa",txtSymbol_lambda:"Lambda",txtSymbol_mu:"Mu",txtSymbol_nu:"Nu",txtSymbol_xsi:"Xi",txtSymbol_o:"Omicron",txtSymbol_pi:"Pi",txtSymbol_varpi:"Pi Variant",txtSymbol_rho:"Rho",txtSymbol_varrho:"Rho Variant",txtSymbol_sigma:"Sigma",txtSymbol_varsigma:"Sigma Variant",txtSymbol_tau:"Tau",txtSymbol_upsilon:"Upsilon",txtSymbol_varphi:"Phi Variant",txtSymbol_phi:"Phi",txtSymbol_chi:"Chi",txtSymbol_psi:"Psi",txtSymbol_omega:"Omega",txtFractionVertical:"Stacked Fraction",txtFractionDiagonal:"Skewed Fraction",txtFractionHorizontal:"Linear Fraction",txtFractionSmall:"Small Fraction",txtFractionDifferential_1:"Differential",txtFractionDifferential_2:"Differential",txtFractionDifferential_3:"Differential",txtFractionDifferential_4:"Differential",txtFractionPi_2:"Pi Over 2",txtScriptSup:"Superscript",txtScriptSub:"Subscript",txtScriptSubSup:"Subscript-Superscript",txtScriptSubSupLeft:"Left Subscript-Superscript",txtScriptCustom_1:"Script",txtScriptCustom_2:"Script",txtScriptCustom_3:"Script",txtScriptCustom_4:"Script",txtRadicalSqrt:"Square Root",txtRadicalRoot_n:"Radical With Degree",txtRadicalRoot_2:"Square Root With Degree",txtRadicalRoot_3:"Cubic Root",txtRadicalCustom_1:"Radical",txtRadicalCustom_2:"Radical",txtIntegral:"Integral",txtIntegralSubSup:"Integral",txtIntegralCenterSubSup:"Integral",txtIntegralDouble:"Double Integral",txtIntegralDoubleSubSup:"Double Integral",txtIntegralDoubleCenterSubSup:"Double Integral",txtIntegralTriple:"Triple Integral",txtIntegralTripleSubSup:"Triple Integral",txtIntegralTripleCenterSubSup:"Triple Integral",txtIntegralOriented:"Contour Integral",txtIntegralOrientedSubSup:"Contour Integral",txtIntegralOrientedCenterSubSup:"Contour Integral",txtIntegralOrientedDouble:"Surface Integral",txtIntegralOrientedDoubleSubSup:"Surface Integral",txtIntegralOrientedDoubleCenterSubSup:"Surface Integral",txtIntegralOrientedTriple:"Volume Integral",txtIntegralOrientedTripleSubSup:"Volume Integral",txtIntegralOrientedTripleCenterSubSup:"Volume Integral",txtIntegral_dx:"Differential x",txtIntegral_dy:"Differential y",txtIntegral_dtheta:"Differential theta",txtLargeOperator_Sum:"Summation",txtLargeOperator_Sum_CenterSubSup:"Summation",txtLargeOperator_Sum_SubSup:"Summation",txtLargeOperator_Sum_CenterSub:"Summation",txtLargeOperator_Sum_Sub:"Summation",txtLargeOperator_Prod:"Product",txtLargeOperator_Prod_CenterSubSup:"Product",txtLargeOperator_Prod_SubSup:"Product",txtLargeOperator_Prod_CenterSub:"Product",txtLargeOperator_Prod_Sub:"Product",txtLargeOperator_CoProd:"Co-Product",txtLargeOperator_CoProd_CenterSubSup:"Co-Product",txtLargeOperator_CoProd_SubSup:"Co-Product",txtLargeOperator_CoProd_CenterSub:"Co-Product",txtLargeOperator_CoProd_Sub:"Co-Product",txtLargeOperator_Union:"Union",txtLargeOperator_Union_CenterSubSup:"Union",txtLargeOperator_Union_SubSup:"Union",txtLargeOperator_Union_CenterSub:"Union",txtLargeOperator_Union_Sub:"Union",txtLargeOperator_Intersection:"Intersection",txtLargeOperator_Intersection_CenterSubSup:"Intersection",txtLargeOperator_Intersection_SubSup:"Intersection",txtLargeOperator_Intersection_CenterSub:"Intersection",txtLargeOperator_Intersection_Sub:"Intersection",txtLargeOperator_Disjunction:"Vee",txtLargeOperator_Disjunction_CenterSubSup:"Vee",txtLargeOperator_Disjunction_SubSup:"Vee",txtLargeOperator_Disjunction_CenterSub:"Vee",txtLargeOperator_Disjunction_Sub:"Vee",txtLargeOperator_Conjunction:"Wedge",txtLargeOperator_Conjunction_CenterSubSup:"Wedge",txtLargeOperator_Conjunction_SubSup:"Wedge",txtLargeOperator_Conjunction_CenterSub:"Wedge",txtLargeOperator_Conjunction_Sub:"Wedge",txtLargeOperator_Custom_1:"Summation",txtLargeOperator_Custom_2:"Summation",txtLargeOperator_Custom_3:"Summation",txtLargeOperator_Custom_4:"Product",txtLargeOperator_Custom_5:"Union",txtBracket_Round:"Brackets",txtBracket_Square:"Brackets",txtBracket_Curve:"Brackets",txtBracket_Angle:"Brackets",txtBracket_LowLim:"Brackets",txtBracket_UppLim:"Brackets",txtBracket_Line:"Brackets",txtBracket_LineDouble:"Brackets",txtBracket_Square_OpenOpen:"Brackets",txtBracket_Square_CloseClose:"Brackets",txtBracket_Square_CloseOpen:"Brackets",txtBracket_SquareDouble:"Brackets",txtBracket_Round_Delimiter_2:"Brackets with Separators",txtBracket_Curve_Delimiter_2:"Brackets with Separators",txtBracket_Angle_Delimiter_2:"Brackets with Separators",txtBracket_Angle_Delimiter_3:"Brackets with Separators",txtBracket_Round_OpenNone:"Single Bracket",txtBracket_Round_NoneOpen:"Single Bracket",txtBracket_Square_OpenNone:"Single Bracket",txtBracket_Square_NoneOpen:"Single Bracket",txtBracket_Curve_OpenNone:"Single Bracket",txtBracket_Curve_NoneOpen:"Single Bracket",txtBracket_Angle_OpenNone:"Single Bracket",txtBracket_Angle_NoneOpen:"Single Bracket",txtBracket_LowLim_OpenNone:"Single Bracket",txtBracket_LowLim_NoneNone:"Single Bracket",txtBracket_UppLim_OpenNone:"Single Bracket",txtBracket_UppLim_NoneOpen:"Single Bracket",txtBracket_Line_OpenNone:"Single Bracket",txtBracket_Line_NoneOpen:"Single Bracket",txtBracket_LineDouble_OpenNone:"Single Bracket",txtBracket_LineDouble_NoneOpen:"Single Bracket",txtBracket_SquareDouble_OpenNone:"Single Bracket",txtBracket_SquareDouble_NoneOpen:"Single Bracket",txtBracket_Custom_1:"Case (Two Conditions)",txtBracket_Custom_2:"Cases (Three Conditions)",txtBracket_Custom_3:"Stack Object",txtBracket_Custom_4:"Stack Object",txtBracket_Custom_5:"Cases Example",txtBracket_Custom_6:"Binomial Coefficient",txtBracket_Custom_7:"Binomial Coefficient",txtFunction_Sin:"Sine Function",txtFunction_Cos:"Cosine Function",txtFunction_Tan:"Tangent Function",txtFunction_Csc:"Cosecant Function",txtFunction_Sec:"Secant Function",txtFunction_Cot:"Cotangent Function",txtFunction_1_Sin:"Inverse Sine Function",txtFunction_1_Cos:"Inverse Cosine Function",txtFunction_1_Tan:"Inverse Tangent Function",txtFunction_1_Csc:"Inverse Cosecant Function",txtFunction_1_Sec:"Inverse Secant Function",txtFunction_1_Cot:"Inverse Cotangent Function",txtFunction_Sinh:"Hyperbolic Sine Function",txtFunction_Cosh:"Hyperbolic Cosine Function",txtFunction_Tanh:"Hyperbolic Tangent Function",txtFunction_Csch:"Hyperbolic Cosecant Function",txtFunction_Sech:"Hyperbolic Secant Function",txtFunction_Coth:"Hyperbolic Cotangent Function",txtFunction_1_Sinh:"Hyperbolic Inverse Sine Function",txtFunction_1_Cosh:"Hyperbolic Inverse Cosine Function",txtFunction_1_Tanh:"Hyperbolic Inverse Tangent Function",txtFunction_1_Csch:"Hyperbolic Inverse Cosecant Function",txtFunction_1_Sech:"Hyperbolic Inverse Secant Function",txtFunction_1_Coth:"Hyperbolic Inverse Cotangent Function",txtFunction_Custom_1:"Sine theta",txtFunction_Custom_2:"Cos 2x",txtFunction_Custom_3:"Tangent formula",txtAccent_Dot:"Dot",txtAccent_DDot:"Double Dot",txtAccent_DDDot:"Triple Dot",txtAccent_Hat:"Hat",txtAccent_Check:"Check",txtAccent_Accent:"Acute",txtAccent_Grave:"Grave",txtAccent_Smile:"Breve",txtAccent_Tilde:"Tilde",txtAccent_Bar:"Bar",txtAccent_DoubleBar:"Double Overbar",txtAccent_CurveBracketTop:"Overbrace",txtAccent_CurveBracketBot:"Underbrace",txtAccent_GroupTop:"Grouping Character Above",txtAccent_GroupBot:"Grouping Character Below",txtAccent_ArrowL:"Leftwards Arrow Above",txtAccent_ArrowR:"Rightwards Arrow Above",txtAccent_ArrowD:"Right-Left Arrow Above",txtAccent_HarpoonL:"Leftwards Harpoon Above",txtAccent_HarpoonR:"Rightwards Harpoon Above",txtAccent_BorderBox:"Boxed Formula (With Placeholder)",txtAccent_BorderBoxCustom:"Boxed Formula (Example)",txtAccent_BarTop:"Overbar",txtAccent_BarBot:"Underbar",txtAccent_Custom_1:"Vector A",txtAccent_Custom_2:"ABC With Overbar",txtAccent_Custom_3:"x XOR y With Overbar",txtLimitLog_LogBase:"Logarithm",txtLimitLog_Log:"Logarithm",txtLimitLog_Lim:"Limit",txtLimitLog_Min:"Minimum",txtLimitLog_Max:"Maximum",txtLimitLog_Ln:"Natural Logarithm",txtLimitLog_Custom_1:"Limit Example",txtLimitLog_Custom_2:"Maximum Example",txtOperator_ColonEquals:"Colon Equal",txtOperator_EqualsEquals:"Equal Equal",txtOperator_PlusEquals:"Plus Equal",txtOperator_MinusEquals:"Minus Equal",txtOperator_Definition:"Equal to By Definition",txtOperator_UnitOfMeasure:"Measured By",txtOperator_DeltaEquals:"Delta Equal To",txtOperator_ArrowL_Top:"Leftwards Arrow Above",txtOperator_ArrowR_Top:"Rightwards Arrow Above",txtOperator_ArrowL_Bot:"Leftwards Arrow Below",txtOperator_ArrowR_Bot:"Rightwards Arrow Below",txtOperator_DoubleArrowL_Top:"Leftwards Arrow Above",txtOperator_DoubleArrowR_Top:"Rightwards Arrow Above",txtOperator_DoubleArrowL_Bot:"Leftwards Arrow Below",txtOperator_DoubleArrowR_Bot:"Rightwards Arrow Below",txtOperator_ArrowD_Top:"Right-Left Arrow Above",txtOperator_ArrowD_Bot:"Right-Left Arrow Above",txtOperator_DoubleArrowD_Top:"Right-Left Arrow Below",txtOperator_DoubleArrowD_Bot:"Right-Left Arrow Below",txtOperator_Custom_1:"Yileds",txtOperator_Custom_2:"Delta Yields",txtMatrix_1_2:"1x2 Empty Matrix",txtMatrix_2_1:"2x1 Empty Matrix",txtMatrix_1_3:"1x3 Empty Matrix",txtMatrix_3_1:"3x1 Empty Matrix",txtMatrix_2_2:"2x2 Empty Matrix",txtMatrix_2_3:"2x3 Empty Matrix",txtMatrix_3_2:"3x2 Empty Matrix",txtMatrix_3_3:"3x3 Empty Matrix",txtMatrix_Dots_Center:"Midline Dots",txtMatrix_Dots_Baseline:"Baseline Dots",txtMatrix_Dots_Vertical:"Vertical Dots",txtMatrix_Dots_Diagonal:"Diagonal Dots",txtMatrix_Identity_2:"2x2 Identity Matrix",txtMatrix_Identity_2_NoZeros:"3x3 Identity Matrix",txtMatrix_Identity_3:"3x3 Identity Matrix",txtMatrix_Identity_3_NoZeros:"3x3 Identity Matrix",txtMatrix_2_2_RoundBracket:"Empty Matrix with Brackets",txtMatrix_2_2_SquareBracket:"Empty Matrix with Brackets",txtMatrix_2_2_LineBracket:"Empty Matrix with Brackets",txtMatrix_2_2_DLineBracket:"Empty Matrix with Brackets",txtMatrix_Flat_Round:"Sparse Matrix",txtMatrix_Flat_Square:"Sparse Matrix",confirmAddFontName:"The font you are going to save is not available on the current device.
    The text style will be displayed using one of the device fonts, the saved font will be used when it is available.
    Do you want to continue?",notcriticalErrorTitle:"Warning",txtMarginsW:"Left and right margins are too high for a given page wight",txtMarginsH:"Top and bottom margins are too high for a given page height",textInsert:"Insert",textTabForms:"Forms"},DE.Controllers.Toolbar||{}))}),define("text!documenteditor/main/app/template/StatusBar.template",[],function(){return'\r\n
    \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n'}),define("documenteditor/main/app/model/Pages",["underscore","backbone"],function(t,e){"use strict";DE.Models=DE.Models||{},DE.Models.Pages=e.Model.extend({defaults:{current:0,count:0}})}),define("documenteditor/main/app/view/Statusbar",["text!documenteditor/main/app/template/StatusBar.template","jquery","underscore","backbone","tip","common/main/lib/component/Menu","common/main/lib/component/Window","documenteditor/main/app/model/Pages"],function(t,e,i,n){"use strict";function o(t){this.pages.set("count",t)}function s(t){this.pages.set("current",t+1)}function a(t,i,n){e(".statusbar #label-pages",this.$el).text(Common.Utils.String.format(this.pageIndexText,t.get("current"),t.get("count")))}function r(t,e){t.$el.parent().find("#status-label-lang").text(e.caption),this.langMenu.prevTip=e.value.value,this.fireEvent("langchanged",[this,e.value.code,e.caption])}function l(t){var e=this;e.btnZoomToPage.updateHint(e.tipFitPage),e.btnZoomToWidth.updateHint(e.tipFitWidth),e.btnZoomDown.updateHint(e.tipZoomOut+Common.Utils.String.platformKey("Ctrl+-")),e.btnZoomUp.updateHint(e.tipZoomIn+Common.Utils.String.platformKey("Ctrl++")),e.btnLanguage&&e.btnLanguage.cmpEl&&(e.btnLanguage.updateHint(e.tipSetLang),e.btnLanguage.cmpEl.on({"show.bs.dropdown":function(){i.defer(function(){e.btnLanguage.cmpEl.find("ul").focus()},100)},"hide.bs.dropdown":function(){i.defer(function(){e.api.asc_enableKeyEvents(!0)},100)},click:function(t){if(e.btnLanguage.isDisabled())return!1}}),e.langMenu.on("item:click",i.bind(r,this))),e.cntZoom.updateHint(e.tipZoomFactor),e.cntZoom.cmpEl.on({"show.bs.dropdown":function(){i.defer(function(){e.cntZoom.cmpEl.find("ul").focus()},100)},"hide.bs.dropdown":function(){i.defer(function(){e.api.asc_enableKeyEvents(!0)},100)}}),e.txtGoToPage.on({"keypress:after":function(t,i){if(i.keyCode===Common.UI.Keys.RETURN){var n=e.$el.find("#status-goto-box"),o=n.find("input[type=text]"),s=parseInt(o.val());return!s||s-- >e.pages.get("count")||s<0?(o.select(),!1):(n.focus(),n.parent().removeClass("open"),e.api.goToPage(s),e.api.asc_enableKeyEvents(!0),!1)}},"keyup:after":function(t,i){if(i.keyCode===Common.UI.Keys.ESC){var n=e.$el.find("#status-goto-box");return n.focus(),n.parent().removeClass("open"),e.api.asc_enableKeyEvents(!0),!1}}});var n=e.$el.find("#status-goto-box");n.on("click",function(){return!1}),n.parent().on({"show.bs.dropdown":function(){e.txtGoToPage.setValue(e.api.getCurrentPage()+1),e.txtGoToPage.checkValidate();var t=e.txtGoToPage.$el.find("input");i.defer(function(){t.focus().select()},100)},"hide.bs.dropdown":function(){var t=e.$el.find("#status-goto-box");e.api&&t&&(t.focus(),t.parent().removeClass("open"),e.api.asc_enableKeyEvents(!0))}}),e.zoomMenu.on("item:click",function(t,i){e.fireEvent("zoom:value",[i.value])})}i.template("Page <%= current %> of <%= count %>");DE.Views.Statusbar=n.View.extend(i.extend({el:"#statusbar",template:i.template(t),events:{},api:void 0,pages:void 0,initialize:function(t){i.extend(this,t),this.pages=new DE.Models.Pages({current:1,count:1}),this.pages.on("change",i.bind(a,this)),this.state={};var n=this;this.$layout=e(this.template({textGotoPage:this.goToPageText,textPageNumber:Common.Utils.String.format(this.pageIndexText,1,1)})),this.btnZoomToPage=new Common.UI.Button({hintAnchor:"top",toggleGroup:"status-zoom",enableToggle:!0}),this.btnZoomToWidth=new Common.UI.Button({hintAnchor:"top",toggleGroup:"status-zoom",enableToggle:!0}),this.cntZoom=new Common.UI.Button({hintAnchor:"top"}),this.btnZoomDown=new Common.UI.Button({hintAnchor:"top"}),this.btnZoomUp=new Common.UI.Button({hintAnchor:"top-right"}),this.btnLanguage=new Common.UI.Button({hintAnchor:"top-left",disabled:!0}),this.langMenu=new Common.UI.MenuSimple({cls:"lang-menu",style:"margin-top:-5px;",restoreHeight:285,itemTemplate:i.template(['','',"<%= caption %>",""].join("")),menuAlign:"bl-tl",search:!0}),this.zoomMenu=new Common.UI.Menu({style:"margin-top:-5px;",menuAlign:"bl-tl",items:[{caption:"50%",value:50},{caption:"75%",value:75},{caption:"100%",value:100},{caption:"125%",value:125},{caption:"150%",value:150},{caption:"175%",value:175},{caption:"200%",value:200}]}),this.txtGoToPage=new Common.UI.InputField({allowBlank:!0,validateOnChange:!0,style:"width: 60px;",maskExp:/[0-9]/,validation:function(t){return!!(/(^[0-9]+$)/.test(t)&&void 0!==(t=parseInt(t))&&t>0&&t<=n.pages.get("count"))||n.txtPageNumInvalid}});var o=new Promise(function(t,e){t()});Common.NotificationCenter.on("app:ready",function(t){o.then(l.bind(this,t))}.bind(this))},render:function(t){function i(t,e){t.setElement(e,!1),t.render()}var n=this;if(this.fireEvent("render:before",[this.$layout]),i(n.btnZoomToPage,e("#btn-zoom-topage",n.$layout)),i(n.btnZoomToWidth,e("#btn-zoom-towidth",n.$layout)),i(n.cntZoom,e(".cnt-zoom",n.$layout)),i(n.btnZoomDown,e("#btn-zoom-down",n.$layout)),i(n.btnZoomUp,e("#btn-zoom-up",n.$layout)),i(n.txtGoToPage,e("#status-goto-page",n.$layout)),!t||t.isEdit){var o=e(".cnt-lang",n.$layout);i(n.btnLanguage,o),n.langMenu.render(o),n.langMenu.cmpEl.attr({tabindex:-1}),n.langMenu.prevTip="en"}return n.zoomMenu.render(e(".cnt-zoom",n.$layout)),n.zoomMenu.cmpEl.attr({tabindex:-1}),this.$el.html(n.$layout),this.fireEvent("render:after",[this]),this},setApi:function(t){return this.api=t,this.api&&(this.api.asc_registerCallback("asc_onCountPages",i.bind(o,this)),this.api.asc_registerCallback("asc_onCurrentPage",i.bind(s,this)),Common.NotificationCenter.on("api:disconnect",i.bind(this.onApiCoAuthoringDisconnect,this))),this},setMode:function(t){this.mode=t},setVisible:function(t){t?this.show():this.hide()},reloadLanguages:function(t){var e=[],n=this.langMenu.saved;i.each(t,function(t){e.push({caption:t.displayValue,value:{value:t.value,code:t.code},checkable:!0,checked:n==t.displayValue,spellcheck:t.spellcheck})}),this.langMenu.resetItems(e),this.langMenu.items.length>0&&this.btnLanguage.setDisabled(!!this.mode.isDisconnected)},setLanguage:function(t){if(this.langMenu.prevTip!=t.value&&void 0!==t.code){e(this.langMenu.el.parentNode,this.$el).find("#status-label-lang").text(t.displayValue),this.langMenu.prevTip=t.value;var n=i.find(this.langMenu.items,function(e){return e.caption==t.displayValue});n?this.langMenu.setChecked(this.langMenu.items.indexOf(n),!0):(this.langMenu.saved=t.displayValue,this.langMenu.clearAll())}},showStatusMessage:function(t){e(".statusbar #label-action").text(t)},clearStatusMessage:function(){e(".statusbar #label-action").text("")},SetDisabled:function(t){var e=this.langMenu.items.length>0;this.btnLanguage.setDisabled(t||!e)},onApiCoAuthoringDisconnect:function(){this.setMode({isDisconnected:!0}),this.SetDisabled(!0)},pageIndexText:"Page {0} of {1}",goToPageText:"Go to Page",tipFitPage:"Fit to Page",tipFitWidth:"Fit to Width",tipZoomIn:"Zoom In",tipZoomOut:"Zoom Out",tipZoomFactor:"Magnification",tipSetLang:"Set Text Language",txtPageNumInvalid:"Page number invalid",textTrackChanges:"Track Changes",textChangesPanel:"Changes panel"},DE.Views.Statusbar||{}))}),void 0===Common)var Common={};if(Common.util=Common.util||{},Common.util.LanguageInfo=new function(){var t={54:["af","Afrikaans"],1078:["af-ZA","Afrikaans (Suid Afrika)","Afrikaans (South Africa)"],28:["sq","Shqipe"],1052:["sq-AL","Shqipe (Shqipëria)","Albanian (Albania)"],132:["gsw","Elsässisch"],1156:["gsw-FR","Elsässisch (Frànkrisch)","Alsatian (France)"],94:["am","አማርኛ"],1118:["am-ET","አማርኛ (ኢትዮጵያ)","Amharic (Ethiopia)"],1:["ar","العربية‏"],5121:["ar-DZ","العربية (الجزائر)‏","Arabic (Algeria)"],15361:["ar-BH","العربية (البحرين)‏","Arabic (Bahrain)"],3073:["ar-EG","العربية (مصر)‏","Arabic (Egypt)"],2049:["ar-IQ","العربية (العراق)‏","Arabic (Iraq)"],11265:["ar-JO","العربية (الأردن)‏","Arabic (Jordan)"],13313:["ar-KW","العربية (الكويت)‏","Arabic (Kuwait)"],12289:["ar-LB","العربية (لبنان)‏","Arabic (Lebanon)"],4097:["ar-LY","العربية (ليبيا)‏","Arabic (Libya)"],6145:["ar-MA","العربية (المملكة المغربية)‏","Arabic (Morocco)"],8193:["ar-OM","العربية (عمان)‏","Arabic (Oman)"],16385:["ar-QA","العربية (قطر)‏","Arabic (Qatar)"],1025:["ar-SA","العربية (المملكة العربية السعودية)‏","Arabic (Saudi Arabia)"],10241:["ar-SY","العربية (سوريا)‏","Arabic (Syria)"],7169:["ar-TN","العربية (تونس)‏","Arabic (Tunisia)"],14337:["ar-AE","العربية (الإمارات العربية المتحدة)‏","Arabic (U.A.E.)"],9217:["ar-YE","العربية (اليمن)‏","Arabic (Yemen)"],43:["hy","Հայերեն"],1067:["hy-AM","Հայերեն (Հայաստան)","Armenian (Armenia)"],77:["as","অসমীয়া"],1101:["as-IN","অসমীয়া (ভাৰত)","Assamese (India)"],44:["az","Azərbaycan­ılı"],29740:["az-Cyrl","Азәрбајҹан дили"],2092:["az-Cyrl-AZ","Азәрбајҹан (Азәрбајҹан)","Azeri (Cyrillic, Azerbaijan)"],30764:["az-Latn","Azərbaycan­ılı"],1068:["az-Latn-AZ","Azərbaycan­ılı (Azərbaycan)","Azeri (Latin, Azerbaijan)"],109:["ba","Башҡорт"],1133:["ba-RU","Башҡорт (Россия)","Bashkir (Russia)"],45:["eu","Euskara"],1069:["eu-ES","Euskara (Euskara)","Basque (Basque)"],35:["be","Беларускі"],1059:["be-BY","Беларускі (Беларусь)","Belarusian (Belarus)"],69:["bn","বাংলা"],2117:["bn-BD","বাংলা (বাংলাদেশ)","Bengali (Bangladesh)"],1093:["bn-IN","বাংলা (ভারত)","Bengali (India)"],30746:["bs","bosanski"],25626:["bs-Cyrl","Босански (Ћирилица)"],8218:["bs-Cyrl-BA","Босански (Босна и Херцеговина)","Bosnian (Cyrillic) (Bosnia and Herzegovina)"],26650:["bs-Latn","Bosanski (Latinica)"],5146:["bs-Latn-BA","Bosanski (Bosna i Hercegovina)","Bosnian (Latin) (Bosnia and Herzegovina)"],126:["br","Brezhoneg"],1150:["br-FR","Brezhoneg (Frañs)","Breton (France)"],2:["bg","Български"],1026:["bg-BG","Български (България)","Bulgarian (Bulgaria)"],3:["ca","Català"],1027:["ca-ES","Català (Català)","Catalan (Catalan)"],2051:["ca-ES-valencia","Català (Valencià)","Catalan (Valencia)"],30724:["zh","中文"],4:["zh-Hans","中文(简体)","Chinese (Simplified)"],2052:["zh-CN","中文(中华人民共和国)","Chinese (People's Republic of China)"],4100:["zh-SG","中文(新加坡)","Chinese (Simplified, Singapore)"],31748:["zh-Hant","中文(繁體)","Chinese (Traditional)"],3076:["zh-HK","中文(香港特別行政區)","Chinese (Traditional, Hong Kong S.A.R.)"],5124:["zh-MO","中文(澳門特別行政區)","Chinese (Traditional, Macao S.A.R.)"],1028:["zh-TW","中文(台灣)","Chinese (Traditional, Taiwan)"],131:["co","Corsu"],1155:["co-FR","Corsu (France)","Corsican (France)"],26:["hr","Hrvatski"],1050:["hr-HR","Hrvatski (Hrvatska)","Croatian (Croatia)"],4122:["hr-BA","Hrvatski (Bosna i Hercegovina)","Croatian (Bosnia and Herzegovina)"],5:["cs","Čeština"],1029:["cs-CZ","Čeština (Česká republika)","Czech (Czech Republic)"],6:["da","Dansk"],1030:["da-DK","Dansk (Danmark)","Danish (Denmark)"],140:["prs","درى‏"],1164:["prs-AF","درى (افغانستان)‏","Dari (Afghanistan)"],101:["dv","ދިވެހިބަސް‏"],1125:["dv-MV","ދިވެހިބަސް (ދިވެހި ރާއްޖެ)‏","Divehi (Maldives)"],19:["nl","Nederlands"],2067:["nl-BE","Nederlands (België)","Dutch (Belgium)"],1043:["nl-NL","Nederlands (Nederland)","Dutch (Netherlands)"],9:["en","English"],3081:["en-AU","English (Australia)","English (Australia)"],10249:["en-BZ","English (Belize)","English (Belize)"],4105:["en-CA","English (Canada)","English (Canada)"],9225:["en-029","English (Caribbean)","English (Caribbean)"],16393:["en-IN","English (India)","English (India)"],6153:["en-IE","English (Ireland)","English (Ireland)"],8201:["en-JM","English (Jamaica)","English (Jamaica)"],17417:["en-MY","English (Malaysia)","English (Malaysia)"],5129:["en-NZ","English (New Zealand)","English (New Zealand)"],13321:["en-PH","English (Philippines)","English (Philippines)"],18441:["en-SG","English (Singapore)","English (Singapore)"],7177:["en-ZA","English (South Africa)","English (South Africa)"],11273:["en-TT","English (Trinidad y Tobago)","English (Trinidad y Tobago)"],2057:["en-GB","English (United Kingdom)","English (United Kingdom)"],1033:["en-US","English (United States)","English (United States)"],12297:["en-ZW","English (Zimbabwe)","English (Zimbabwe)"],15369:["en-HK","English (Hong Kong)","English (Hong Kong)"],14345:["en-ID","English (Indonesia)","English (Indonesia)"],37:["et","Eesti"],1061:["et-EE","Eesti (Eesti)","Estonian (Estonia)"],56:["fo","Føroyskt"],1080:["fo-FO","Føroyskt (Føroyar)","Faroese (Faroe Islands)"],100:["fil","Filipino"],1124:["fil-PH","Filipino (Pilipinas)","Filipino (Philippines)"],11:["fi","Suomi"],1035:["fi-FI","Suomi (Suomi)","Finnish (Finland)"],12:["fr","Français"],2060:["fr-BE","Français (Belgique)","French (Belgium)"],3084:["fr-CA","Français (Canada)","French (Canada)"],1036:["fr-FR","Français (France)","French (France)"],5132:["fr-LU","Français (Luxembourg)","French (Luxembourg)"],6156:["fr-MC","Français (Principauté de Monaco)","French (Principality of Monaco)"],4108:["fr-CH","Français (Suisse)","French (Switzerland)"],15372:["fr-HT","Français (Haïti)","French (Haiti)"],9228:["fr-CG","Français (Congo-Brazzaville)","French (Congo)"],12300:["fr-CI","Français (Côte d’Ivoire)","French (Cote d'Ivoire)"],11276:["fr-CM","Français (Cameroun)","French (Cameroon)"],14348:["fr-MA","Français (Maroc)","French (Morocco)"], @@ -51,17 +51,17 @@ Common.Utils.InternalSettings.set("de-settings-label-position",this.cmbPosition. ;"promote"==e.value?this._navigationObject.promote(i):"demote"==e.value?this._navigationObject.demote(i):"before"==e.value?this._navigationObject.insertHeader(i,!0):"after"==e.value?this._navigationObject.insertHeader(i,!1):"new"==e.value?this._navigationObject.insertSubHeader(i):"select"==e.value?this._navigationObject.selectContent(i):"expand"==e.value?this.panelNavigation.viewNavigationList.expandAll():"collapse"==e.value&&this.panelNavigation.viewNavigationList.collapseAll()}},onMenuLevelsItemClick:function(t,e){this.panelNavigation.viewNavigationList.expandToLevel(e.value-1)},SetDisabled:function(t){this._isDisabled=t},txtBeginning:"Beginning of document",txtGotoBeginning:"Go to the beginning of the document"},DE.Controllers.Navigation||{}))}),define("text!documenteditor/main/app/template/RightMenu.template",[],function(){return'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n
    \n
    '}),define("text!documenteditor/main/app/template/ParagraphSettings.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    '}),define("documenteditor/main/app/view/ParagraphSettings",["text!documenteditor/main/app/template/ParagraphSettings.template","jquery","underscore","backbone","common/main/lib/component/ComboBox","common/main/lib/component/MetricSpinner","common/main/lib/component/CheckBox","common/main/lib/component/ThemeColorPalette","common/main/lib/component/ColorButton","documenteditor/main/app/view/ParagraphSettingsAdvanced"],function(t,e,i,n){"use strict";DE.Views.ParagraphSettings=n.View.extend(i.extend({el:"#id-paragraph-settings",template:i.template(t),events:{},options:{alias:"ParagraphSettings"},initialize:function(){this._initSettings=!0,this._state={LineRuleIdx:null,LineHeight:null,LineSpacingBefore:null,LineSpacingAfter:null,AddInterval:!1,BackColor:"#000000",DisabledControls:!0,HideTextOnlySettings:!1},this.spinners=[],this.lockedControls=[],this._locked=!0,this.isChart=!1,this._arrLineRule=[{displayValue:this.textAtLeast,defaultValue:5,value:c_paragraphLinerule.LINERULE_LEAST,minValue:.03,step:.01,defaultUnit:"cm"},{displayValue:this.textAuto,defaultValue:1,value:c_paragraphLinerule.LINERULE_AUTO,minValue:.5,step:.01,defaultUnit:""},{displayValue:this.textExact,defaultValue:5,value:c_paragraphLinerule.LINERULE_EXACT,minValue:.03,step:.01,defaultUnit:"cm"}],this.render()},render:function(){var t=e(this.template({scope:this})),i=this;this.cmbLineRule=new Common.UI.ComboBox({el:t.findById("#paragraph-combo-line-rule"),cls:"input-group-nr",menuStyle:"min-width: 85px;",editable:!1,data:this._arrLineRule,disabled:this._locked}),this.cmbLineRule.setValue(""),this.lockedControls.push(this.cmbLineRule),this.numLineHeight=new Common.UI.MetricSpinner({el:t.findById("#paragraph-spin-line-height"),step:.01,width:85,value:"",defaultUnit:"",maxValue:132,minValue:.5,disabled:this._locked}),this.lockedControls.push(this.numLineHeight),this.numSpacingBefore=new Common.UI.MetricSpinner({el:t.findById("#paragraph-spin-spacing-before"),step:.1,width:85,value:"",defaultUnit:"cm",maxValue:55.88,minValue:0,allowAuto:!0,autoText:this.txtAutoText,disabled:this._locked}),this.spinners.push(this.numSpacingBefore),this.lockedControls.push(this.numSpacingBefore),this.numSpacingAfter=new Common.UI.MetricSpinner({el:t.findById("#paragraph-spin-spacing-after"),step:.1,width:85,value:"",defaultUnit:"cm",maxValue:55.88,minValue:0,allowAuto:!0,autoText:this.txtAutoText,disabled:this._locked}),this.spinners.push(this.numSpacingAfter),this.lockedControls.push(this.numSpacingAfter),this.chAddInterval=new Common.UI.CheckBox({el:t.findById("#paragraph-checkbox-add-interval"),labelText:this.strSomeParagraphSpace,disabled:this._locked}),this.lockedControls.push(this.chAddInterval),this.btnColor=new Common.UI.ColorButton({parentEl:t.findById("#paragraph-color-btn"),disabled:this._locked,transparent:!0,menu:!0}),this.lockedControls.push(this.btnColor),this.numLineHeight.on("change",this.onNumLineHeightChange.bind(this)),this.numSpacingBefore.on("change",this.onNumSpacingBeforeChange.bind(this)),this.numSpacingAfter.on("change",this.onNumSpacingAfterChange.bind(this)),this.numLineHeight.on("inputleave",function(){i.fireEvent("editcomplete",i)}),this.numSpacingBefore.on("inputleave",function(){i.fireEvent("editcomplete",i)}),this.numSpacingAfter.on("inputleave",function(){i.fireEvent("editcomplete",i)}),this.chAddInterval.on("change",this.onAddIntervalChange.bind(this)),this.cmbLineRule.on("selected",this.onLineRuleSelect.bind(this)),this.cmbLineRule.on("hide:after",this.onHideMenus.bind(this)),this.btnColor.on("color:select",this.onColorPickerSelect.bind(this)),this.linkAdvanced=t.findById("#paragraph-advanced-link"),this.linkAdvanced.toggleClass("disabled",this._locked),this.$el.on("click","#paragraph-advanced-link",this.openAdvancedSettings.bind(this)),this.$el.html(t),this.TextOnlySettings=e(".text-only",this.$el),this.rendered=!0},setApi:function(t){return this.api=t,this.api&&this.api.asc_registerCallback("asc_onParaSpacingLine",i.bind(this._onLineSpacing,this)),this},onNumLineHeightChange:function(t,e,i,n){if(""!==this.cmbLineRule.getRawValue()){c_paragraphLinerule.LINERULE_AUTO;this.api&&this.api.put_PrLineSpacing(this.cmbLineRule.getValue(),this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO?t.getNumberValue():Common.Utils.Metric.fnRecalcToMM(t.getNumberValue()))}},onNumSpacingBeforeChange:function(t,e,i,n){if(this.api){var o=t.getNumberValue();this._state.LineSpacingBefore=o<0?-1:Common.Utils.Metric.fnRecalcToMM(o),this.api.put_LineSpacingBeforeAfter(0,this._state.LineSpacingBefore)}},onNumSpacingAfterChange:function(t,e,i,n){if(this.api){var o=t.getNumberValue();this._state.LineSpacingAfter=o<0?-1:Common.Utils.Metric.fnRecalcToMM(o),this.api.put_LineSpacingBeforeAfter(1,this._state.LineSpacingAfter)}},onAddIntervalChange:function(t,e,i,n){this.api&&this.api.put_AddSpaceBetweenPrg("checked"==t.getValue()),this.fireEvent("editcomplete",this)},onLineRuleSelect:function(t,e){this.api&&this.api.put_PrLineSpacing(e.value,e.defaultValue),this.numLineHeight.setDefaultUnit(this._arrLineRule[e.value].defaultUnit),this.numLineHeight.setMinValue(this._arrLineRule[e.value].minValue),this.numLineHeight.setStep(this._arrLineRule[e.value].step),this.fireEvent("editcomplete",this)},_onLineSpacing:function(t){var e=t.get_LineRule(),i=t.get_Line();if(this._state.LineRuleIdx!==e&&(this.cmbLineRule.setValue(null!==e?this._arrLineRule[e].value:""),this.numLineHeight.setMinValue(this._arrLineRule[null!==e?e:1].minValue),this.numLineHeight.setDefaultUnit(this._arrLineRule[null!==e?e:1].defaultUnit),this.numLineHeight.setStep(this._arrLineRule[null!==e?e:1].step),this._state.LineRuleIdx=e),Math.abs(this._state.LineHeight-i)>.001||(null===this._state.LineHeight||null===i)&&this._state.LineHeight!==i){var n="";e==c_paragraphLinerule.LINERULE_AUTO?n=i:null!==e&&null!==i&&(n=Common.Utils.Metric.fnRecalcFromMM(i)),this.numLineHeight.setValue(null!==n?n:"",!0),this._state.LineHeight=i}},onColorPickerSelect:function(t,e){this.BackColor=e,this._state.BackColor=this.BackColor,this.api&&("transparent"==e?this.api.put_ParagraphShade(!1):this.api.put_ParagraphShade(!0,Common.Utils.ThemeColor.getRgbColor(e))),this.fireEvent("editcomplete",this)},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedElements(),this.disableControls(this._locked),this.hideTextOnlySettings(this.isChart),t){var e={Line:t.get_Spacing().get_Line(),Before:t.get_Spacing().get_Before(),After:t.get_Spacing().get_After(),LineRule:t.get_Spacing().get_LineRule()},i={ContextualSpacing:t.get_ContextualSpacing()};if(this._state.LineRuleIdx!==e.LineRule&&(this.cmbLineRule.setValue(null!==e.LineRule?this._arrLineRule[e.LineRule].value:""),this.numLineHeight.setMinValue(this._arrLineRule[null!==e.LineRule?e.LineRule:1].minValue),this.numLineHeight.setDefaultUnit(this._arrLineRule[null!==e.LineRule?e.LineRule:1].defaultUnit),this.numLineHeight.setStep(this._arrLineRule[null!==e.LineRule?e.LineRule:1].step),this._state.LineRuleIdx=e.LineRule),Math.abs(this._state.LineHeight-e.Line)>.001||(null===this._state.LineHeight||null===e.Line)&&this._state.LineHeight!==e.Line){var n="";e.LineRule==c_paragraphLinerule.LINERULE_AUTO?n=e.Line:null!==e.LineRule&&null!==e.Line&&(n=Common.Utils.Metric.fnRecalcFromMM(e.Line)),this.numLineHeight.setValue(null!==n?n:"",!0),this._state.LineHeight=e.Line}(Math.abs(this._state.LineSpacingBefore-e.Before)>.001||(null===this._state.LineSpacingBefore||null===e.Before)&&this._state.LineSpacingBefore!==e.Before)&&(this.numSpacingBefore.setValue(null!==e.Before?e.Before<0?e.Before:Common.Utils.Metric.fnRecalcFromMM(e.Before):"",!0),this._state.LineSpacingBefore=e.Before),(Math.abs(this._state.LineSpacingAfter-e.After)>.001||(null===this._state.LineSpacingAfter||null===e.After)&&this._state.LineSpacingAfter!==e.After)&&(this.numSpacingAfter.setValue(null!==e.After?e.After<0?e.After:Common.Utils.Metric.fnRecalcFromMM(e.After):"",!0),this._state.LineSpacingAfter=e.After),this._state.AddInterval!==i.ContextualSpacing&&(this.chAddInterval.setValue(null!==i.ContextualSpacing&&void 0!==i.ContextualSpacing?i.ContextualSpacing:"indeterminate",!0),this._state.AddInterval=i.ContextualSpacing);var o=t.get_Shade();if(null!==o&&void 0!==o&&o.get_Value()===Asc.c_oAscShdClear){var s=o.get_Color();s?s.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.BackColor={color:Common.Utils.ThemeColor.getHexColor(s.get_r(),s.get_g(),s.get_b()),effectValue:s.get_value()}:this.BackColor=Common.Utils.ThemeColor.getHexColor(s.get_r(),s.get_g(),s.get_b()):this.BackColor="transparent"}else this.BackColor="transparent";var a=typeof this.BackColor;if(a!==typeof this._state.BackColor||"object"==a&&(this.BackColor.effectValue!==this._state.BackColor.effectValue||this._state.BackColor.color.indexOf(this.BackColor.color)<0)||"object"!=a&&this._state.BackColor.indexOf(this.BackColor)<0){if(this.btnColor.setColor(this.BackColor),"object"==typeof this.BackColor){for(var r=!1,l=0;l<10;l++)if(Common.Utils.ThemeColor.ThemeValues[l]==this.BackColor.effectValue){this.mnuColorPicker.select(this.BackColor,!0),r=!0;break}r||this.mnuColorPicker.clearSelection()}else this.mnuColorPicker.select(this.BackColor,!0);this._state.BackColor=this.BackColor}}},updateMetricUnit:function(){if(this.spinners)for(var t=0;t0)for(var n,o,s=i.length-1;s>=0;s--)if(n=i[s].get_ObjectType(),o=i[s].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Paragraph==n){new DE.Views.ParagraphSettingsAdvanced({tableStylerRows:2,tableStylerColumns:1,paragraphProps:o,borderProps:e.borderAdvancedProps,isChart:e.isChart,api:e.api,handler:function(t,i){"ok"==t&&e.api&&(e.borderAdvancedProps=i.borderProps,e.api.paraApply(i.paragraphProps)),e.fireEvent("editcomplete",e)}}).show();break}}}},UpdateThemeColors:function(){this.mnuColorPicker||(this.btnColor.setMenu(),this.mnuColorPicker=this.btnColor.getPicker()),this.mnuColorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors())},onHideMenus:function(t,e,i){i||this.fireEvent("editcomplete",this)},setLocked:function(t){this._locked=t},disableControls:function(t){this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.linkAdvanced.toggleClass("disabled",t))},hideTextOnlySettings:function(t){this._state.HideTextOnlySettings!==t&&(this._state.HideTextOnlySettings=t,this.TextOnlySettings.toggleClass("hidden",1==t))},strParagraphSpacing:"Paragraph Spacing",strSomeParagraphSpace:"Don't add interval between paragraphs of the same style",strLineHeight:"Line Spacing",strSpacingBefore:"Before",strSpacingAfter:"After",textAuto:"Multiple",textAtLeast:"At least",textExact:"Exactly",textAdvanced:"Show advanced settings",textAt:"At",txtAutoText:"Auto",textBackColor:"Background color"},DE.Views.ParagraphSettings||{}))}),define("text!documenteditor/main/app/template/HeaderFooterSettings.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    '}),define("documenteditor/main/app/view/HeaderFooterSettings",["text!documenteditor/main/app/template/HeaderFooterSettings.template","jquery","underscore","backbone","common/main/lib/component/Button","common/main/lib/component/MetricSpinner","common/main/lib/component/CheckBox","common/main/lib/component/RadioBox"],function(t,e,i,n){"use strict";DE.Views.HeaderFooterSettings=n.View.extend(i.extend({el:"#id-header-settings",template:i.template(t),events:{},options:{alias:"HeaderFooterSettings"},initialize:function(){this._initSettings=!0,this._state={PositionType:c_pageNumPosition.PAGE_NUM_POSITION_TOP,Position:12.5,DiffFirst:!1,DiffOdd:!1,SameAs:!1,DisabledControls:!1,Numbering:void 0},this.spinners=[],this.lockedControls=[],this._locked=!1,this.render()},render:function(){(this.$el||e(this.el)).html(this.template({scope:this}))},setApi:function(t){return this.api=t,this},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedElements(),this.disableControls(this._locked),t){var e=t.get_Type();this._state.PositionType!==e&&(e==c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM?this.lblPosition[0].innerHTML=this.textHeaderFromBottom:this.lblPosition[0].innerHTML=this.textHeaderFromTop,this._state.PositionType=e),e=t.get_Position(),Math.abs(this._state.Position-e)>.001&&(this.numPosition.setValue(Common.Utils.Metric.fnRecalcFromMM(e),!0),this._state.Position=e),e=t.get_DifferentFirst(),this._state.DiffFirst!==e&&(this.chDiffFirst.setValue(e,!0),this._state.DiffFirst=e),e=t.get_DifferentEvenOdd(),this._state.DiffOdd!==e&&(this.chDiffOdd.setValue(e,!0),this._state.DiffOdd=e),e=t.get_LinkToPrevious(),this._state.SameAs!==e&&(this.chSameAs.setDisabled(null===e||this._locked),this.chSameAs.setValue(1==e,!0),this._state.SameAs=e),e=t.get_StartPageNumber(),this._state.Numbering!==e&&null!==e&&(e<0?this.radioPrev.setValue(!0,!0):(this.radioFrom.setValue(!0,!0),this.numFrom.setValue(e,!0)),this._state.Numbering=e)}},onBtnPositionClick:function(t,e){this.api&&this.api.put_PageNum(t.options.posWhere,t.options.posAlign),this.fireEvent("editcomplete",this)},onNumPositionChange:function(t,e,i,n){this.api&&this.api.put_HeadersAndFootersDistance(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue()))},onDiffFirstChange:function(t,e,i,n){this.api&&this.api.HeadersAndFooters_DifferentFirstPage("checked"==t.getValue()),this.fireEvent("editcomplete",this)},onDiffOddChange:function(t,e,i,n){this.api&&this.api.HeadersAndFooters_DifferentOddandEvenPage("checked"==t.getValue()),this.fireEvent("editcomplete",this)},onSameAsChange:function(t,e,i,n){this.api&&this.api.HeadersAndFooters_LinkToPrevious("checked"==t.getValue()),this.fireEvent("editcomplete",this)},onInsertCurrentClick:function(){this.api&&this.api.put_PageNum(-1),this.fireEvent("editcomplete",this)},onRadioPrev:function(t,e,i){e&&this.api&&this.api.asc_SetSectionStartPage(-1),this.fireEvent("editcomplete",this)},onRadioFrom:function(t,e,n){e&&this.api&&(i.isEmpty(this.numFrom.getValue())&&this.numFrom.setValue(1,!0),this.api.asc_SetSectionStartPage(this.numFrom.getNumberValue())),this.fireEvent("editcomplete",this)},onNumFromChange:function(t,e,i,n){this.api&&(this.radioFrom.setValue(!0,!0),this.api.asc_SetSectionStartPage(t.getNumberValue()))},updateMetricUnit:function(){if(this.spinners){for(var t=0;t\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n'}),define("text!documenteditor/main/app/template/ImageSettingsAdvanced.template",[],function(){return'
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    '}),define("documenteditor/main/app/view/ImageSettingsAdvanced",["text!documenteditor/main/app/template/ImageSettingsAdvanced.template","common/main/lib/view/AdvancedSettingsWindow","common/main/lib/component/ComboBox","common/main/lib/component/MetricSpinner","common/main/lib/component/CheckBox","common/main/lib/component/RadioBox"],function(t){"use strict";DE.Views.ImageSettingsAdvanced=Common.Views.AdvancedSettingsWindow.extend(_.extend({options:{contentWidth:340,height:485,toggleGroup:"image-adv-settings-group",sizeOriginal:{width:0,height:0},sizeMax:{width:55.88,height:55.88},properties:null,storageName:"de-img-settings-adv-category"},initialize:function(e){_.extend(this.options,{title:this.textTitle,items:[{panelId:"id-adv-image-width",panelCaption:this.textSize},{panelId:"id-adv-shape-size",panelCaption:this.textSize},{panelId:"id-adv-image-rotate",panelCaption:this.textRotation},{panelId:"id-adv-image-wrap",panelCaption:this.textBtnWrap},{panelId:"id-adv-image-position",panelCaption:this.textPosition},{panelId:"id-adv-image-shape",panelCaption:this.textWeightArrows},{panelId:"id-adv-image-margins",panelCaption:this.textTextBox},{panelId:"id-adv-image-alttext",panelCaption:this.textAlt}],contentTemplate:_.template(t)({scope:this})},e),Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this,this.options),this.spinners=[],this._state={HAlignType:Asc.c_oAscAlignH.Left,HAlignFrom:Asc.c_oAscRelativeFromH.Character,HPositionFrom:Asc.c_oAscRelativeFromH.Character,HPositionPcFrom:Asc.c_oAscRelativeFromH.Page,ShapeWidthPcFrom:Asc.c_oAscRelativeFromH.Margin,VAlignType:Asc.c_oAscAlignV.Top,VAlignFrom:Asc.c_oAscRelativeFromV.Paragraph,VPositionFrom:Asc.c_oAscRelativeFromV.Paragraph,VPositionPcFrom:Asc.c_oAscRelativeFromV.Page,ShapeHeightPcFrom:Asc.c_oAscRelativeFromV.Margin,spnXChanged:!1,spnYChanged:!1,spnXPcChanged:!1,spnYPcChanged:!1},this._objectType=Asc.c_oAscTypeSelectElement.Image,this.Margins=void 0,this._nRatio=1,this._originalProps=this.options.imageProps,this.sectionProps=this.options.sectionProps,this.pageWidth=this.options.sectionProps?this.options.sectionProps.get_W():210,this.pageHeight=this.options.sectionProps?this.options.sectionProps.get_H():297,this.api=this.options.api,this._changedProps=null,this._changedShapeProps=null},render:function(){Common.Views.AdvancedSettingsWindow.prototype.render.call(this);var t=this;this.spnWidth=new Common.UI.MetricSpinner({el:$("#image-advanced-spin-width"),step:.1,width:80,defaultUnit:"cm",value:"3 cm",maxValue:55.88,minValue:0}),this.spnWidth.on("change",_.bind(function(t,e,i,n){if(this.btnRatio.pressed){var o=t.getNumberValue(),s=o/this._nRatio;s>this.sizeMax.height&&(s=this.sizeMax.height,o=s*this._nRatio,this.spnWidth.setValue(o,!0)),this.spnHeight.setValue(s,!0)}this._changedProps&&(this._changedProps.put_Width(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this._changedProps.put_Height(Common.Utils.Metric.fnRecalcToMM(this.spnHeight.getNumberValue())),this._changedProps.put_ResetCrop(!1))},this)),this.spinners.push(this.spnWidth),this.spnHeight=new Common.UI.MetricSpinner({el:$("#image-advanced-spin-height"),step:.1,width:80,defaultUnit:"cm",value:"3 cm",maxValue:55.88,minValue:0}),this.spnHeight.on("change",_.bind(function(t,e,i,n){var o=t.getNumberValue(),s=null;this.btnRatio.pressed&&(s=o*this._nRatio,s>this.sizeMax.width&&(s=this.sizeMax.width,o=s/this._nRatio,this.spnHeight.setValue(o,!0)),this.spnWidth.setValue(s,!0)),this._changedProps&&(this._changedProps.put_Height(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this._changedProps.put_Width(Common.Utils.Metric.fnRecalcToMM(this.spnWidth.getNumberValue())),this._changedProps.put_ResetCrop(!1))},this)),this.spinners.push(this.spnHeight),this.btnOriginalSize=new Common.UI.Button({el:$("#image-advanced-button-original-size")}),this.btnOriginalSize.on("click",_.bind(function(t,e){this.spnWidth.setValue(this.sizeOriginal.width,!0),this.spnHeight.setValue(this.sizeOriginal.height,!0),this._nRatio=this.sizeOriginal.width/this.sizeOriginal.height,this._changedProps&&(this._changedProps.put_Height(Common.Utils.Metric.fnRecalcToMM(this.spnHeight.getNumberValue())),this._changedProps.put_Width(Common.Utils.Metric.fnRecalcToMM(this.spnWidth.getNumberValue())),this._changedProps.put_ResetCrop(!0))},this)),this.btnRatio=new Common.UI.Button({parentEl:$("#image-advanced-button-ratio"),cls:"btn-toolbar",iconCls:"toolbar__icon advanced-btn-ratio",style:"margin-bottom: 1px;",enableToggle:!0,hint:this.textKeepRatio}),this.btnRatio.on("click",_.bind(function(t,e){t.pressed&&this.spnHeight.getNumberValue()>0&&(this._nRatio=this.spnWidth.getNumberValue()/this.spnHeight.getNumberValue()),this._changedProps&&this._changedProps.asc_putLockAspect(t.pressed)},this)),this.radioHSize=new Common.UI.RadioBox({el:$("#shape-radio-hsize"),name:"asc-radio-width",checked:!0}),this.radioHSize.on("change",_.bind(this.onRadioHSizeChange,this)),this.radioHSizePc=new Common.UI.RadioBox({el:$("#shape-radio-hsizepc"),name:"asc-radio-width"}),this.radioHSizePc.on("change",_.bind(this.onRadioHSizePcChange,this)),this.radioVSize=new Common.UI.RadioBox({el:$("#shape-radio-vsize"),name:"asc-radio-height",checked:!0}),this.radioVSize.on("change",_.bind(this.onRadioVSizeChange,this)),this.radioVSizePc=new Common.UI.RadioBox({el:$("#shape-radio-vsizepc"),name:"asc-radio-height"}),this.radioVSizePc.on("change",_.bind(this.onRadioVSizePcChange,this)),this.chRatio=new Common.UI.CheckBox({el:$("#shape-checkbox-ratio"),labelText:this.textAspectRatio}),this.chRatio.on("change",_.bind(function(t,e,i,n){"checked"==t.getValue()&&this.spnShapeHeight.getNumberValue()>0&&(this._nRatio=this.spnShapeWidth.getNumberValue()/this.spnShapeHeight.getNumberValue()),this._changedProps&&this._changedProps.asc_putLockAspect("checked"==t.getValue())},this)),this.spnShapeWidth=new Common.UI.MetricSpinner({el:$("#shape-advanced-spin-width"),step:.1,width:80,defaultUnit:"cm",value:"3 cm",maxValue:55.88,minValue:0}),this.spnShapeWidth.on("change",_.bind(function(t,e,i,n){if("checked"==this.chRatio.getValue()&&!this.chRatio.isDisabled()){var o=t.getNumberValue(),s=o/this._nRatio;s>this.sizeMax.height&&(s=this.sizeMax.height,o=s*this._nRatio,this.spnShapeWidth.setValue(o,!0)),this.spnShapeHeight.setValue(s,!0)}this._changedProps&&(this._changedProps.put_Width(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.fillShapeHeight())},this)),this.spinners.push(this.spnShapeWidth),this.spnShapeHeight=new Common.UI.MetricSpinner({el:$("#shape-advanced-spin-height"),step:.1,width:80,defaultUnit:"cm",value:"3 cm",maxValue:55.88,minValue:0}),this.spnShapeHeight.on("change",_.bind(function(t,e,i,n){var o=t.getNumberValue(),s=null;"checked"!=this.chRatio.getValue()||this.chRatio.isDisabled()||(s=o*this._nRatio,s>this.sizeMax.width&&(s=this.sizeMax.width,o=s/this._nRatio,this.spnShapeHeight.setValue(o,!0)),this.spnShapeWidth.setValue(s,!0)),this._changedProps&&(this._changedProps.put_Height(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this.fillShapeWidth())},this)),this.spinners.push(this.spnShapeHeight),this.spnShapeWidthPc=new Common.UI.MetricSpinner({el:$("#shape-advanced-spin-width-rel"),disabled:!0,step:1,width:80,defaultUnit:"%",value:"1 %",maxValue:1e3,minValue:1}),this.spnShapeWidthPc.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_SizeRelH()&&void 0!==this._changedProps.get_SizeRelH()||this._changedProps.put_SizeRelH(new Asc.CImagePositionH),this._changedProps.get_SizeRelH().put_Value(t.getNumberValue()),this._changedProps.get_SizeRelH().put_RelativeFrom(this._state.ShapeWidthPcFrom),this.fillShapeHeight())},this)),this.spnShapeHeightPc=new Common.UI.MetricSpinner({el:$("#shape-advanced-spin-height-rel"),disabled:!0,step:1,width:80,defaultUnit:"%",value:"1 %",maxValue:1e3,minValue:1}),this.spnShapeHeightPc.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_SizeRelV()&&void 0!==this._changedProps.get_SizeRelV()||this._changedProps.put_SizeRelV(new Asc.CImagePositionV),this._changedProps.get_SizeRelV().put_Value(t.getNumberValue()),this._changedProps.get_SizeRelV().put_RelativeFrom(this._state.ShapeHeightPcFrom),this.fillShapeWidth())},this)),this._arrHRelativePc=[{displayValue:this.textLeftMargin,value:Asc.c_oAscRelativeFromH.LeftMargin,size:this.sectionProps.get_LeftMargin()},{displayValue:this.textMargin,value:Asc.c_oAscRelativeFromH.Margin,size:this.sectionProps.get_W()-this.sectionProps.get_LeftMargin()-this.sectionProps.get_RightMargin()},{displayValue:this.textPage,value:Asc.c_oAscRelativeFromH.Page,size:this.sectionProps.get_W()},{displayValue:this.textRightMargin,value:Asc.c_oAscRelativeFromH.RightMargin,size:this.sectionProps.get_RightMargin()}],this.cmbWidthPc=new Common.UI.ComboBox({el:$("#shape-combo-width-rel"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrHRelativePc,takeFocusOnClose:!0}),this.cmbWidthPc.setDisabled(!0),this.cmbWidthPc.setValue(this._state.ShapeWidthPcFrom),this.cmbWidthPc.on("selected",_.bind(this.onCmbWidthPcSelect,this)),this._arrVRelativePc=[{displayValue:this.textMargin,value:Asc.c_oAscRelativeFromV.Margin,size:this.sectionProps.get_H()-this.sectionProps.get_TopMargin()-this.sectionProps.get_BottomMargin()},{displayValue:this.textBottomMargin,value:Asc.c_oAscRelativeFromV.BottomMargin,size:this.sectionProps.get_BottomMargin()},{displayValue:this.textPage,value:Asc.c_oAscRelativeFromV.Page,size:this.sectionProps.get_H()},{displayValue:this.textTopMargin,value:Asc.c_oAscRelativeFromV.TopMargin,size:this.sectionProps.get_TopMargin()}],this.cmbHeightPc=new Common.UI.ComboBox({el:$("#shape-combo-height-rel"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrVRelativePc,takeFocusOnClose:!0}),this.cmbHeightPc.setDisabled(!0),this.cmbHeightPc.setValue(this._state.ShapeHeightPcFrom),this.cmbHeightPc.on("selected",_.bind(this.onCmbHeightPcSelect,this)),this.spnAngle=new Common.UI.MetricSpinner({el:$("#image-advanced-spin-angle"),step:1,width:80,defaultUnit:"°",value:"0 °",maxValue:3600,minValue:-3600}),this.chFlipHor=new Common.UI.CheckBox({el:$("#image-advanced-checkbox-hor"),labelText:this.textHorizontally}),this.chFlipVert=new Common.UI.CheckBox({el:$("#image-advanced-checkbox-vert"),labelText:this.textVertically}),this.btnWrapInline=new Common.UI.Button({parentEl:$("#image-advanced-button-wrap-inline"),cls:"btn-options huge-1",iconCls:"icon-advanced-wrap btn-wrap-inline", posId:Asc.c_oAscWrapStyle2.Inline,hint:this.textWrapInlineTooltip,enableToggle:!0,allowDepress:!1,toggleGroup:"imgAdvWrapGroup"}),this.btnWrapInline.on("click",_.bind(this.onBtnWrapClick,this)),this.btnWrapSquare=new Common.UI.Button({parentEl:$("#image-advanced-button-wrap-square"),cls:"btn-options huge-1",iconCls:"icon-advanced-wrap btn-wrap-square",posId:Asc.c_oAscWrapStyle2.Square,hint:this.textWrapSquareTooltip,enableToggle:!0,allowDepress:!1,toggleGroup:"imgAdvWrapGroup"}),this.btnWrapSquare.on("click",_.bind(this.onBtnWrapClick,this)),this.btnWrapTight=new Common.UI.Button({parentEl:$("#image-advanced-button-wrap-tight"),cls:"btn-options huge-1",iconCls:"icon-advanced-wrap btn-wrap-tight",posId:Asc.c_oAscWrapStyle2.Tight,hint:this.textWrapTightTooltip,enableToggle:!0,allowDepress:!1,toggleGroup:"imgAdvWrapGroup"}),this.btnWrapTight.on("click",_.bind(this.onBtnWrapClick,this)),this.btnWrapThrough=new Common.UI.Button({parentEl:$("#image-advanced-button-wrap-through"),cls:"btn-options huge-1",iconCls:"icon-advanced-wrap btn-wrap-through",posId:Asc.c_oAscWrapStyle2.Through,hint:this.textWrapThroughTooltip,enableToggle:!0,allowDepress:!1,toggleGroup:"imgAdvWrapGroup"}),this.btnWrapThrough.on("click",_.bind(this.onBtnWrapClick,this)),this.btnWrapTopBottom=new Common.UI.Button({parentEl:$("#image-advanced-button-wrap-topbottom"),cls:"btn-options huge-1",iconCls:"icon-advanced-wrap btn-wrap-topbottom",posId:Asc.c_oAscWrapStyle2.TopAndBottom,hint:this.textWrapTopbottomTooltip,enableToggle:!0,allowDepress:!1,toggleGroup:"imgAdvWrapGroup"}),this.btnWrapTopBottom.on("click",_.bind(this.onBtnWrapClick,this)),this.btnWrapBehind=new Common.UI.Button({parentEl:$("#image-advanced-button-wrap-behind"),cls:"btn-options huge-1",iconCls:"icon-advanced-wrap btn-wrap-behind",posId:Asc.c_oAscWrapStyle2.Behind,hint:this.textWrapBehindTooltip,enableToggle:!0,allowDepress:!1,toggleGroup:"imgAdvWrapGroup"}),this.btnWrapBehind.on("click",_.bind(this.onBtnWrapClick,this)),this.btnWrapInFront=new Common.UI.Button({parentEl:$("#image-advanced-button-wrap-infront"),cls:"btn-options huge-1",iconCls:"icon-advanced-wrap btn-wrap-infront",posId:Asc.c_oAscWrapStyle2.InFront,hint:this.textWrapInFrontTooltip,enableToggle:!0,allowDepress:!1,toggleGroup:"imgAdvWrapGroup"}),this.btnWrapInFront.on("click",_.bind(this.onBtnWrapClick,this)),this.spnTop=new Common.UI.MetricSpinner({el:$("#image-advanced-distance-top"),step:.1,width:85,defaultUnit:"cm",value:"0 cm",maxValue:55.87,minValue:0}),this.spnTop.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_Paddings()&&void 0!==this._changedProps.get_Paddings()||this._changedProps.put_Paddings(new Asc.asc_CPaddings),this._changedProps.get_Paddings().put_Top(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())))},this)),this.spinners.push(this.spnTop),this.spnBottom=new Common.UI.MetricSpinner({el:$("#image-advanced-distance-bottom"),step:.1,width:85,defaultUnit:"cm",value:"0 cm",maxValue:55.87,minValue:0}),this.spnBottom.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_Paddings()&&void 0!==this._changedProps.get_Paddings()||this._changedProps.put_Paddings(new Asc.asc_CPaddings),this._changedProps.get_Paddings().put_Bottom(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())))},this)),this.spinners.push(this.spnBottom),this.spnLeft=new Common.UI.MetricSpinner({el:$("#image-advanced-distance-left"),step:.1,width:85,defaultUnit:"cm",value:"0.32 cm",maxValue:55.87,minValue:0}),this.spnLeft.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_Paddings()&&void 0!==this._changedProps.get_Paddings()||this._changedProps.put_Paddings(new Asc.asc_CPaddings),this._changedProps.get_Paddings().put_Left(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())))},this)),this.spinners.push(this.spnLeft),this.spnRight=new Common.UI.MetricSpinner({el:$("#image-advanced-distance-right"),step:.1,width:85,defaultUnit:"cm",value:"0.32 cm",maxValue:55.87,minValue:0}),this.spnRight.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_Paddings()&&void 0!==this._changedProps.get_Paddings()||this._changedProps.put_Paddings(new Asc.asc_CPaddings),this._changedProps.get_Paddings().put_Right(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())))},this)),this.spinners.push(this.spnRight),this.spnX=new Common.UI.MetricSpinner({el:$("#image-spin-x"),step:.1,width:115,disabled:!0,defaultUnit:"cm",defaultValue:0,value:"0 cm",maxValue:55.87,minValue:-55.87}),this.spnX.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_PositionH()&&void 0!==this._changedProps.get_PositionH()||this._changedProps.put_PositionH(new Asc.CImagePositionH),this._changedProps.get_PositionH().put_UseAlign(!1),this._changedProps.get_PositionH().put_Percent(!1),this._changedProps.get_PositionH().put_RelativeFrom(this._state.HPositionFrom),this._changedProps.get_PositionH().put_Value(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this._state.spnXChanged=!0)},this)),this.spinners.push(this.spnX),this.spnY=new Common.UI.MetricSpinner({el:$("#image-spin-y"),step:.1,width:115,disabled:!0,defaultUnit:"cm",defaultValue:0,value:"0 cm",maxValue:55.87,minValue:-55.87}),this.spnY.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_PositionV()&&void 0!==this._changedProps.get_PositionV()||this._changedProps.put_PositionV(new Asc.CImagePositionV),this._changedProps.get_PositionV().put_UseAlign(!1),this._changedProps.get_PositionV().put_Percent(!1),this._changedProps.get_PositionV().put_RelativeFrom(this._state.VPositionFrom),this._changedProps.get_PositionV().put_Value(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())),this._state.spnYChanged=!0)},this)),this.spinners.push(this.spnY),this._arrHAlign=[{displayValue:this.textLeft,value:Asc.c_oAscAlignH.Left},{displayValue:this.textCenter,value:Asc.c_oAscAlignH.Center},{displayValue:this.textRight,value:Asc.c_oAscAlignH.Right}],this.cmbHAlign=new Common.UI.ComboBox({el:$("#image-combo-halign"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrHAlign,takeFocusOnClose:!0}),this.cmbHAlign.setValue(this._state.HAlignType),this.cmbHAlign.on("selected",_.bind(this.onHAlignSelect,this)),this._arrHRelative=[{displayValue:this.textCharacter,value:Asc.c_oAscRelativeFromH.Character},{displayValue:this.textColumn,value:Asc.c_oAscRelativeFromH.Column},{displayValue:this.textLeftMargin,value:Asc.c_oAscRelativeFromH.LeftMargin},{displayValue:this.textMargin,value:Asc.c_oAscRelativeFromH.Margin},{displayValue:this.textPage,value:Asc.c_oAscRelativeFromH.Page},{displayValue:this.textRightMargin,value:Asc.c_oAscRelativeFromH.RightMargin}],this.cmbHRelative=new Common.UI.ComboBox({el:$("#image-combo-hrelative"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrHRelative,takeFocusOnClose:!0}),this.cmbHRelative.setValue(this._state.HAlignFrom),this.cmbHRelative.on("selected",_.bind(this.onHRelativeSelect,this)),this.cmbHPosition=new Common.UI.ComboBox({el:$("#image-combo-hposition"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrHRelative,takeFocusOnClose:!0}),this.cmbHPosition.setDisabled(!0),this.cmbHPosition.setValue(this._state.HPositionFrom),this.cmbHPosition.on("selected",_.bind(this.onHPositionSelect,this)),this.spnXPc=new Common.UI.MetricSpinner({el:$("#image-spin-xpc"),step:1,width:115,disabled:!0,defaultUnit:"%",defaultValue:0,value:"0 %",maxValue:1e3,minValue:-1e3}),this.spnXPc.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_PositionH()&&void 0!==this._changedProps.get_PositionH()||this._changedProps.put_PositionH(new Asc.CImagePositionH),this._changedProps.get_PositionH().put_UseAlign(!1),this._changedProps.get_PositionH().put_Percent(!0),this._changedProps.get_PositionH().put_RelativeFrom(this._state.HPositionPcFrom),this._changedProps.get_PositionH().put_Value(t.getNumberValue()),this._state.spnXPcChanged=!0)},this)),this.cmbHPositionPc=new Common.UI.ComboBox({el:$("#image-combo-hpositionpc"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrHRelativePc,takeFocusOnClose:!0}),this.cmbHPositionPc.setDisabled(!0),this.cmbHPositionPc.setValue(this._state.HPositionPcFrom),this.cmbHPositionPc.on("selected",_.bind(this.onHPositionPcSelect,this)),this._arrVAlign=[{displayValue:this.textTop,value:Asc.c_oAscAlignV.Top},{displayValue:this.textCenter,value:Asc.c_oAscAlignV.Center},{displayValue:this.textBottom,value:Asc.c_oAscAlignV.Bottom}],this.cmbVAlign=new Common.UI.ComboBox({el:$("#image-combo-valign"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrVAlign,takeFocusOnClose:!0}),this.cmbVAlign.setValue(this._state.VAlignType),this.cmbVAlign.on("selected",_.bind(this.onVAlignSelect,this)),this._arrVRelative=[{displayValue:this.textLine,value:Asc.c_oAscRelativeFromV.Line},{displayValue:this.textMargin,value:Asc.c_oAscRelativeFromV.Margin},{displayValue:this.textBottomMargin,value:Asc.c_oAscRelativeFromV.BottomMargin},{displayValue:this.textParagraph,value:Asc.c_oAscRelativeFromV.Paragraph},{displayValue:this.textPage,value:Asc.c_oAscRelativeFromV.Page},{displayValue:this.textTopMargin,value:Asc.c_oAscRelativeFromV.TopMargin}],this.cmbVRelative=new Common.UI.ComboBox({el:$("#image-combo-vrelative"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrVRelative,takeFocusOnClose:!0}),this.cmbVRelative.setValue(this._state.VAlignFrom),this.cmbVRelative.on("selected",_.bind(this.onVRelativeSelect,this)),this.cmbVPosition=new Common.UI.ComboBox({el:$("#image-combo-vposition"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrVRelative,takeFocusOnClose:!0}),this.cmbVPosition.setDisabled(!0),this.cmbVPosition.setValue(this._state.VPositionFrom),this.cmbVPosition.on("selected",_.bind(this.onVPositionSelect,this)),this.spnYPc=new Common.UI.MetricSpinner({el:$("#image-spin-ypc"),step:1,width:115,disabled:!0,defaultUnit:"%",defaultValue:0,value:"0 %",maxValue:1e3,minValue:-1e3}),this.spnYPc.on("change",_.bind(function(t,e,i,n){this._changedProps&&(null!==this._changedProps.get_PositionV()&&void 0!==this._changedProps.get_PositionV()||this._changedProps.put_PositionV(new Asc.CImagePositionV),this._changedProps.get_PositionV().put_UseAlign(!1),this._changedProps.get_PositionV().put_Percent(!0),this._changedProps.get_PositionV().put_RelativeFrom(this._state.VPositionPcFrom),this._changedProps.get_PositionV().put_Value(t.getNumberValue()),this._state.spnYPcChanged=!0)},this)),this.cmbVPositionPc=new Common.UI.ComboBox({el:$("#image-combo-vpositionpc"),cls:"input-group-nr",menuStyle:"min-width: 115px;",editable:!1,data:this._arrVRelativePc,takeFocusOnClose:!0}),this.cmbVPositionPc.setDisabled(!0),this.cmbVPositionPc.setValue(this._state.VPositionPcFrom),this.cmbVPositionPc.on("selected",_.bind(this.onVPositionPcSelect,this)),this.radioHAlign=new Common.UI.RadioBox({el:$("#image-radio-halign"),name:"asc-radio-horizontal",checked:!0}),this.radioHAlign.on("change",_.bind(this.onRadioHAlignChange,this)),this.radioHPosition=new Common.UI.RadioBox({el:$("#image-radio-hposition"),name:"asc-radio-horizontal"}),this.radioHPosition.on("change",_.bind(this.onRadioHPositionChange,this)),this.radioHPositionPc=new Common.UI.RadioBox({el:$("#image-radio-hpositionpc"),name:"asc-radio-horizontal"}),this.radioHPositionPc.on("change",_.bind(this.onRadioHPositionPcChange,this)),this.radioVAlign=new Common.UI.RadioBox({el:$("#image-radio-valign"),name:"asc-radio-vertical",checked:!0}),this.radioVAlign.on("change",_.bind(this.onRadioVAlignChange,this)),this.radioVPosition=new Common.UI.RadioBox({el:$("#image-radio-vposition"),name:"asc-radio-vertical"}),this.radioVPosition.on("change",_.bind(this.onRadioVPositionChange,this)),this.radioVPositionPc=new Common.UI.RadioBox({el:$("#image-radio-vpositionpc"),name:"asc-radio-vertical"}),this.radioVPositionPc.on("change",_.bind(this.onRadioVPositionPcChange,this)),this.chMove=new Common.UI.CheckBox({el:$("#image-checkbox-move"),labelText:this.textMove}),this.chMove.on("change",_.bind(function(t,e,i,n){if(this._changedProps){var o=this._arrVRelative["checked"==t.getValue()?3:4].value;if(this.cmbVRelative.isDisabled()){this.cmbVPosition.setValue(o);var s=this.cmbVPosition.getSelectedRecord();s&&this.onVPositionSelect(this.cmbVPosition,s)}else{this.cmbVRelative.setValue(o);var s=this.cmbVRelative.getSelectedRecord();s&&this.onVRelativeSelect(this.cmbVRelative,s)}}},this)),this.chOverlap=new Common.UI.CheckBox({el:$("#image-checkbox-overlap"),labelText:this.textOverlap}),this.chOverlap.on("change",_.bind(function(t,e,i,n){this._changedProps&&this._changedProps.put_AllowOverlap("checked"==t.getValue())},this)),this.spnMarginTop=new Common.UI.MetricSpinner({el:$("#image-margin-top"),step:.1,width:100,defaultUnit:"cm",value:"0 cm",maxValue:55.87,minValue:0}),this.spnMarginTop.on("change",_.bind(function(t,e,i,n){this._changedProps&&(void 0===this.Margins&&(this.Margins=new Asc.asc_CPaddings),this.Margins.put_Top(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())))},this)),this.spinners.push(this.spnMarginTop),this.spnMarginBottom=new Common.UI.MetricSpinner({el:$("#image-margin-bottom"),step:.1,width:100,defaultUnit:"cm",value:"0 cm",maxValue:55.87,minValue:0}),this.spnMarginBottom.on("change",_.bind(function(t,e,i,n){this._changedProps&&(void 0===this.Margins&&(this.Margins=new Asc.asc_CPaddings),this.Margins.put_Bottom(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())))},this)),this.spinners.push(this.spnMarginBottom),this.spnMarginLeft=new Common.UI.MetricSpinner({el:$("#image-margin-left"),step:.1,width:100,defaultUnit:"cm",value:"0.19 cm",maxValue:9.34,minValue:0}),this.spnMarginLeft.on("change",_.bind(function(t,e,i,n){this._changedProps&&(void 0===this.Margins&&(this.Margins=new Asc.asc_CPaddings),this.Margins.put_Left(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())))},this)),this.spinners.push(this.spnMarginLeft),this.spnMarginRight=new Common.UI.MetricSpinner({el:$("#image-margin-right"),step:.1,width:100,defaultUnit:"cm",value:"0.19 cm",maxValue:9.34,minValue:0}),this.spnMarginRight.on("change",_.bind(function(t,e,i,n){this._changedProps&&(void 0===this.Margins&&(this.Margins=new Asc.asc_CPaddings),this.Margins.put_Right(Common.Utils.Metric.fnRecalcToMM(t.getNumberValue())))},this)),this.spinners.push(this.spnMarginRight),this.chAutofit=new Common.UI.CheckBox({el:$("#shape-checkbox-autofit"),labelText:this.textResizeFit}),this.chAutofit.on("change",_.bind(function(t,e,i,n){this._changedShapeProps&&this._changedShapeProps.asc_putTextFitType("checked"==t.getValue()?AscFormat.text_fit_Auto:AscFormat.text_fit_No)},this)),this._arrCapType=[{displayValue:this.textFlat,value:Asc.c_oAscLineCapType.Flat},{displayValue:this.textRound,value:Asc.c_oAscLineCapType.Round},{displayValue:this.textSquare,value:Asc.c_oAscLineCapType.Square}],this.cmbCapType=new Common.UI.ComboBox({el:$("#shape-advanced-cap-type"),cls:"input-group-nr",menuStyle:"min-width: 100px;",editable:!1,data:this._arrCapType,takeFocusOnClose:!0}),this.cmbCapType.setValue(Asc.c_oAscLineCapType.Flat),this.cmbCapType.on("selected",_.bind(function(t,e){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_linecap(e.value))},this)),this._arrJoinType=[{displayValue:this.textRound,value:Asc.c_oAscLineJoinType.Round},{displayValue:this.textBevel,value:Asc.c_oAscLineJoinType.Bevel},{displayValue:this.textMiter,value:Asc.c_oAscLineJoinType.Miter}],this.cmbJoinType=new Common.UI.ComboBox({el:$("#shape-advanced-join-type"),cls:"input-group-nr",menuStyle:"min-width: 100px;",editable:!1,data:this._arrJoinType,takeFocusOnClose:!0}),this.cmbJoinType.setValue(Asc.c_oAscLineJoinType.Round),this.cmbJoinType.on("selected",_.bind(function(t,e){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_linejoin(e.value))},this));for(var e=[],i=[],n=0;n<6;n++)e.push({value:n,offsetx:80*n+10,offsety:0});for(e[0].type=Asc.c_oAscLineBeginType.None,e[1].type=Asc.c_oAscLineBeginType.Triangle,e[2].type=Asc.c_oAscLineBeginType.Arrow,e[3].type=Asc.c_oAscLineBeginType.Stealth,e[4].type=Asc.c_oAscLineBeginType.Diamond,e[5].type=Asc.c_oAscLineBeginType.Oval,n=0;n<9;n++)i.push({value:n,offsetx:90,offsety:20*(n+1)});for(i[0].type=Asc.c_oAscLineBeginSize.small_small,i[1].type=Asc.c_oAscLineBeginSize.small_mid,i[2].type=Asc.c_oAscLineBeginSize.small_large,i[3].type=Asc.c_oAscLineBeginSize.mid_small,i[4].type=Asc.c_oAscLineBeginSize.mid_mid,i[5].type=Asc.c_oAscLineBeginSize.mid_large,i[6].type=Asc.c_oAscLineBeginSize.large_small,i[7].type=Asc.c_oAscLineBeginSize.large_mid,i[8].type=Asc.c_oAscLineBeginSize.large_large,this.btnBeginStyle=new Common.UI.ComboBox({el:$("#shape-advanced-begin-style"),template:_.template(['"].join(""))}),this.btnBeginStyleMenu=new Common.UI.Menu({style:"min-width: 105px;",additionalAlign:this.menuAddAlign,items:[{template:_.template('
    ')}]}).render($("#shape-advanced-begin-style")),this.mnuBeginStylePicker=new Common.UI.DataView({el:$("#shape-advanced-menu-begin-style"),parentMenu:this.btnBeginStyleMenu,store:new Common.UI.DataViewStore(e),itemTemplate:_.template('
    ')}),this.mnuBeginStylePicker.on("item:click",_.bind(this.onSelectBeginStyle,this)),this._selectStyleItem(this.btnBeginStyle,null),this.btnBeginSize=new Common.UI.ComboBox({el:$("#shape-advanced-begin-size"),template:_.template(['"].join(""))}),this.btnBeginSizeMenu=new Common.UI.Menu({style:"min-width: 160px;",additionalAlign:this.menuAddAlign,items:[{template:_.template('
    ')}]}).render($("#shape-advanced-begin-size")),this.mnuBeginSizePicker=new Common.UI.DataView({el:$("#shape-advanced-menu-begin-size"),parentMenu:this.btnBeginSizeMenu,store:new Common.UI.DataViewStore(i),itemTemplate:_.template('
    ')}),this.mnuBeginSizePicker.on("item:click",_.bind(this.onSelectBeginSize,this)),this._selectStyleItem(this.btnBeginSize,null),n=0;n','
    ','
    ','',"
    "].join(""))}),this.btnEndStyleMenu=new Common.UI.Menu({style:"min-width: 105px;",additionalAlign:this.menuAddAlign,items:[{template:_.template('
    ')}]}).render($("#shape-advanced-end-style")),this.mnuEndStylePicker=new Common.UI.DataView({el:$("#shape-advanced-menu-end-style"),parentMenu:this.btnEndStyleMenu,store:new Common.UI.DataViewStore(e),itemTemplate:_.template('
    ')}),this.mnuEndStylePicker.on("item:click",_.bind(this.onSelectEndStyle,this)),this._selectStyleItem(this.btnEndStyle,null),this.btnEndSize=new Common.UI.ComboBox({el:$("#shape-advanced-end-size"),template:_.template(['"].join(""))}),this.btnEndSizeMenu=new Common.UI.Menu({style:"min-width: 160px;",additionalAlign:this.menuAddAlign,items:[{template:_.template('
    ')}]}).render($("#shape-advanced-end-size")),this.mnuEndSizePicker=new Common.UI.DataView({el:$("#shape-advanced-menu-end-size"),parentMenu:this.btnEndSizeMenu,store:new Common.UI.DataViewStore(i),itemTemplate:_.template('
    ')}),this.mnuEndSizePicker.on("item:click",_.bind(this.onSelectEndSize,this)),this._selectStyleItem(this.btnEndSize,null),this.inputAltTitle=new Common.UI.InputField({el:$("#image-advanced-alt-title"),allowBlank:!0,validateOnBlur:!1,style:"width: 100%;"}).on("changed:after",function(){t.isAltTitleChanged=!0}),this.textareaAltDescription=this.$window.find("textarea"),this.textareaAltDescription.keydown(function(e){e.keyCode==Common.UI.Keys.RETURN&&e.stopPropagation(),t.isAltDescChanged=!0}),this.afterRender()},getFocusedComponents:function(){return[this.spnWidth,this.spnHeight,this.spnShapeWidth,this.spnShapeWidthPc,this.cmbWidthPc,this.spnShapeHeight,this.spnShapeHeightPc,this.cmbHeightPc,this.spnAngle,this.spnTop,this.spnLeft,this.spnBottom,this.spnRight,this.cmbHAlign,this.cmbHRelative,this.spnX,this.cmbHPosition,this.spnXPc,this.cmbHPositionPc,this.cmbVAlign,this.cmbVRelative,this.spnY,this.cmbVPosition,this.spnYPc,this.cmbVPositionPc,this.cmbCapType,this.cmbJoinType,this.spnMarginTop,this.spnMarginLeft,this.spnMarginBottom,this.spnMarginRight,this.inputAltTitle,this.textareaAltDescription]},onCategoryClick:function(t,e){Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this,t,e);var i=this;setTimeout(function(){switch(e){case 0:i.spnWidth.focus();break;case 1:i.spnShapeWidth.focus();break;case 2:i.spnAngle.focus();break;case 3:i.spnTop.focus();break;case 4:i.cmbHAlign.isDisabled()?i.spnX.isDisabled()?i.spnXPc.focus():i.spnX.focus():i.cmbHAlign.focus();break;case 5:i.cmbCapType.focus();break;case 6:i.spnMarginTop.focus();break;case 7:i.inputAltTitle.focus()}},10)},afterRender:function(){if(this.updateMetricUnit(),this._setDefaults(this._originalProps),this.btnsCategory[this._objectType==Asc.c_oAscTypeSelectElement.Shape?0:1].setVisible(!1),this.storageName){var t=Common.localStorage.getItem(this.storageName);this.setActiveCategory(null!==t?parseInt(t):0)}},_setDefaults:function(t){if(t){this._objectType=Asc.c_oAscTypeSelectElement.Image;var e=t.get_WrappingStyle();if(t.get_CanBeFlow()){switch(e){case Asc.c_oAscWrapStyle2.Inline:this.btnWrapInline.toggle(!0);break;case Asc.c_oAscWrapStyle2.Square:this.btnWrapSquare.toggle(!0);break;case Asc.c_oAscWrapStyle2.Tight:this.btnWrapTight.toggle(!0);break;case Asc.c_oAscWrapStyle2.Through:this.btnWrapThrough.toggle(!0);break;case Asc.c_oAscWrapStyle2.TopAndBottom:this.btnWrapTopBottom.toggle(!0);break;case Asc.c_oAscWrapStyle2.Behind:this.btnWrapBehind.toggle(!0);break;case Asc.c_oAscWrapStyle2.InFront:this.btnWrapInFront.toggle(!0);break;default:this.btnWrapInline.toggle(!1),this.btnWrapSquare.toggle(!1),this.btnWrapTight.toggle(!1),this.btnWrapThrough.toggle(!1),this.btnWrapTopBottom.toggle(!1),this.btnWrapBehind.toggle(!1),this.btnWrapInFront.toggle(!1)}this._DisableElem(e)}else this.btnWrapInline.toggle(!0),this.btnWrapSquare.setDisabled(!0),this.btnWrapTight.setDisabled(!0),this.btnWrapThrough.setDisabled(!0),this.btnWrapTopBottom.setDisabled(!0),this.btnWrapBehind.setDisabled(!0),this.btnWrapInFront.setDisabled(!0),this._DisableElem(Asc.c_oAscWrapStyle2.Inline);if(t.get_Paddings()){var i={Top:t.get_Paddings().get_Top(),Right:t.get_Paddings().get_Right(),Bottom:t.get_Paddings().get_Bottom(),Left:t.get_Paddings().get_Left()};null!==i.Top&&void 0!==i.Top&&this.spnTop.setValue(Common.Utils.Metric.fnRecalcFromMM(i.Top),!0),null!==i.Left&&void 0!==i.Left&&this.spnLeft.setValue(Common.Utils.Metric.fnRecalcFromMM(i.Left),!0),null!==i.Bottom&&void 0!==i.Bottom&&this.spnBottom.setValue(Common.Utils.Metric.fnRecalcFromMM(i.Bottom),!0),null!==i.Right&&void 0!==i.Right&&this.spnRight.setValue(Common.Utils.Metric.fnRecalcFromMM(i.Right),!0)}var n=t.get_PositionH();if(n)if(n.get_UseAlign()){e=n.get_Align();for(var o=0;o0&&(this._nRatio=t.get_Width()/t.get_Height());var s=t.get_ShapeProperties(),a=t.get_ChartProperties(),r=t.asc_getPluginGuid();this.btnOriginalSize.setVisible(!(s||a)),this.btnOriginalSize.setDisabled(null===t.get_ImageUrl()||void 0===t.get_ImageUrl()),this.btnsCategory[5].setVisible(null!==s&&!s.get_FromChart()),this.btnsCategory[6].setVisible(null!==s&&!s.get_FromChart()),this.btnsCategory[2].setVisible(!a&&(null===r||void 0===r));var l=this.api&&this.api.asc_IsContentControl()?this.api.asc_GetContentControlProperties():null;if(this.btnsCategory[3].setDisabled(t.get_FromGroup()||!!l&&l.get_SpecificType()==Asc.c_oAscContentControlSpecificType.Picture),s){this._objectType=Asc.c_oAscTypeSelectElement.Shape,this._setShapeDefaults(s),this.setTitle(this.textTitleShape),e=t.asc_getLockAspect(),this.chRatio.setValue(e),this.spnShapeWidth.setMaxValue(this.sizeMax.width),this.spnShapeHeight.setMaxValue(this.sizeMax.height);var c=t.get_SizeRelH();if(c){for(this.radioHSizePc.setValue(!0),this.spnShapeWidthPc.setValue(c.get_Value()),e=c.get_RelativeFrom(),o=0;o0?(e.store.each(function(t){t.set({offsetx:80*i.get("value")+10})},this),t.setDisabled(!1),null!==n?(e.selectByIndex(n,!0),this._selectStyleItem(t,e.store.at(n))):this._selectStyleItem(t,null)):(this._selectStyleItem(t,null),t.setDisabled(!0))},_selectStyleItem:function(t,e){$(t.el).find(".form-control").css("background-position",(e?20-e.get("offsetx")+"px":"0")+" "+(e?"-"+e.get("offsety")+"px":"-30px"))},onSelectBeginStyle:function(t,e,i,n){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_linebeginstyle(i.get("type"))),null!==this._beginSizeIdx&&void 0!==this._beginSizeIdx||(this._beginSizeIdx=4),this._updateSizeArr(this.btnBeginSize,this.mnuBeginSizePicker,i,this._beginSizeIdx),this._selectStyleItem(this.btnBeginStyle,i)},onSelectBeginSize:function(t,e,i,n){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_linebeginsize(i.get("type"))),this._beginSizeIdx=i.get("value"),this._selectStyleItem(this.btnBeginSize,i)},onSelectEndStyle:function(t,e,i,n){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_lineendstyle(i.get("type"))),null!==this._endSizeIdx&&void 0!==this._endSizeIdx||(this._endSizeIdx=4),this._updateSizeArr(this.btnEndSize,this.mnuEndSizePicker,i,this._endSizeIdx),this._selectStyleItem(this.btnEndStyle,i)},onSelectEndSize:function(t,e,i,n){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_lineendsize(i.get("type"))),this._endSizeIdx=i.get("value"),this._selectStyleItem(this.btnEndSize,i)},textTop:"Top",textLeft:"Left",textBottom:"Bottom",textRight:"Right",textOriginalSize:"Actual Size",textPosition:"Position",textDistance:"Distance From Text",textSize:"Size",textWrap:"Wrapping Style",textWidth:"Width",textHeight:"Height",textWrapInlineTooltip:"Inline",textWrapSquareTooltip:"Square",textWrapTightTooltip:"Tight",textWrapThroughTooltip:"Through",textWrapTopbottomTooltip:"Top and Bottom",textWrapBehindTooltip:"Behind",textWrapInFrontTooltip:"In Front",textTitle:"Image - Advanced Settings",textKeepRatio:"Constant Proportions",textBtnWrap:"Text Wrapping",textCenter:"Center",textCharacter:"Character",textColumn:"Column",textLeftMargin:"Left Margin",textMargin:"Margin",textPage:"Page",textRightMargin:"Right Margin",textLine:"Line",textBottomMargin:"Bottom Margin",textParagraph:"Paragraph",textTopMargin:"Top Margin",textHorizontal:"Horizontal",textVertical:"Vertical",textAlignment:"Alignment",textRelative:"relative to",textRightOf:"to the right Of",textBelow:"below",textOverlap:"Allow overlap",textMove:"Move object with text",textOptions:"Options",textShape:"Shape Settings",textTitleShape:"Shape - Advanced Settings",textTitleChart:"Chart - Advanced Settings",strMargins:"Text Padding",textRound:"Round",textMiter:"Miter",textSquare:"Square",textFlat:"Flat",textBevel:"Bevel",textArrows:"Arrows",textLineStyle:"Line Style",textCapType:"Cap Type",textJoinType:"Join Type",textBeginStyle:"Begin Style",textBeginSize:"Begin Size",textEndStyle:"End Style",textEndSize:"End Size",textPositionPc:"Relative position",textAspectRatio:"Lock aspect ratio",textAbsoluteWH:"Absolute",textRelativeWH:"Relative",textAlt:"Alternative Text",textAltTitle:"Title",textAltDescription:"Description",textAltTip:"The alternative text-based representation of the visual object information, which will be read to the people with vision or cognitive impairments to help them better understand what information there is in the image, autoshape, chart or table.",textWeightArrows:"Weights & Arrows",textRotation:"Rotation",textAngle:"Angle",textFlipped:"Flipped",textHorizontally:"Horizontally",textVertically:"Vertically",textTextBox:"Text Box",textAutofit:"AutoFit",textResizeFit:"Resize shape to fit text"},DE.Views.ImageSettingsAdvanced||{}))}),define("documenteditor/main/app/view/ImageSettings",["text!documenteditor/main/app/template/ImageSettings.template","jquery","underscore","backbone","common/main/lib/component/Button","common/main/lib/view/ImageFromUrlDialog","documenteditor/main/app/view/ImageSettingsAdvanced"],function(t,e,i,n){"use strict";DE.Views.ImageSettings=n.View.extend(i.extend({el:"#id-image-settings",template:i.template(t),events:{},options:{alias:"ImageSettings"},initialize:function(){this._initSettings=!0,this._state={WrappingStyle:Asc.c_oAscWrapStyle2.Inline,CanBeFlow:!0,Width:0,Height:0,FromGroup:!1,DisabledControls:!1,isOleObject:!1,cropMode:!1,isPictureControl:!1},this.lockedControls=[],this._locked=!1,this._originalProps=null,this.render()},render:function(){var t=this.$el||e(this.el);t.html(this.template({scope:this})),this.labelWidth=t.find("#image-label-width"),this.labelHeight=t.find("#image-label-height")},setApi:function(t){return this.api=t,this.api&&(this.api.asc_registerCallback("asc_onImgWrapStyleChanged",i.bind(this._ImgWrapStyleChanged,this)),this.api.asc_registerCallback("asc_ChangeCropState",i.bind(this._changeCropState,this))),Common.NotificationCenter.on("storage:image-insert",i.bind(this.insertImageFromStorage,this)),this},setMode:function(t){this.mode=t},updateMetricUnit:function(){var t=Common.Utils.Metric.fnRecalcFromMM(this._state.Width);this.labelWidth[0].innerHTML=this.textWidth+": "+t.toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName(),t=Common.Utils.Metric.fnRecalcFromMM(this._state.Height),this.labelHeight[0].innerHTML=this.textHeight+": "+t.toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()},createDelayedControls:function(){var t=this,n=[{offsetx:0,data:Asc.c_oAscWrapStyle2.Inline,tip:this.txtInline,selected:!0},{offsetx:50,data:Asc.c_oAscWrapStyle2.Square,tip:this.txtSquare},{offsetx:100,data:Asc.c_oAscWrapStyle2.Tight,tip:this.txtTight},{offsetx:150,data:Asc.c_oAscWrapStyle2.Through,tip:this.txtThrough},{offsetx:200,data:Asc.c_oAscWrapStyle2.TopAndBottom,tip:this.txtTopAndBottom},{offsetx:250,data:Asc.c_oAscWrapStyle2.InFront,tip:this.txtInFront},{offsetx:300,data:Asc.c_oAscWrapStyle2.Behind,tip:this.txtBehind}];this.cmbWrapType=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,store:new Common.UI.DataViewStore(n),cls:"combo-chart-style"}),this.cmbWrapType.menuPicker.itemTemplate=this.cmbWrapType.fieldPicker.itemTemplate=i.template(['
    ','',"
    "].join("")),this.cmbWrapType.render(e("#image-combo-wrap")),this.cmbWrapType.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbWrapType.on("click",i.bind(this.onSelectWrap,this)),this.cmbWrapType.openButton.menu.on("show:after",function(){t.cmbWrapType.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbWrapType),this.btnOriginalSize=new Common.UI.Button({el:e("#image-button-original-size")}),this.lockedControls.push(this.btnOriginalSize),this.btnFitMargins=new Common.UI.Button({el:e("#image-button-fit-margins")}),this.lockedControls.push(this.btnFitMargins);var o=Math.max(this.btnOriginalSize.cmpEl.width(),this.btnFitMargins.cmpEl.width());this.btnOriginalSize.cmpEl.width(o),this.btnFitMargins.cmpEl.width(o),this.btnEditObject=new Common.UI.Button({el:e("#image-button-edit-object")}),this.lockedControls.push(this.btnEditObject),this.btnOriginalSize.on("click",i.bind(this.setOriginalSize,this)),this.btnEditObject.on("click",i.bind(function(t){this.api&&this.api.asc_startEditCurrentOleObject(),this.fireEvent("editcomplete",this)},this)),this.btnFitMargins.on("click",i.bind(this.setFitMargins,this)),this.btnRotate270=new Common.UI.Button({parentEl:e("#image-button-270",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-rotate-270",value:0,hint:this.textHint270}),this.btnRotate270.on("click",i.bind(this.onBtnRotateClick,this)),this.lockedControls.push(this.btnRotate270),this.btnRotate90=new Common.UI.Button({parentEl:e("#image-button-90",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-rotate-90",value:1,hint:this.textHint90}),this.btnRotate90.on("click",i.bind(this.onBtnRotateClick,this)),this.lockedControls.push(this.btnRotate90),this.btnFlipV=new Common.UI.Button({parentEl:e("#image-button-flipv",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-flip-vert",value:0,hint:this.textHintFlipV}),this.btnFlipV.on("click",i.bind(this.onBtnFlipClick,this)),this.lockedControls.push(this.btnFlipV),this.btnFlipH=new Common.UI.Button({parentEl:e("#image-button-fliph",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-flip-hor",value:1,hint:this.textHintFlipH}),this.btnFlipH.on("click",i.bind(this.onBtnFlipClick,this)),this.lockedControls.push(this.btnFlipH);var o=this.btnOriginalSize.cmpEl.outerWidth();this.btnCrop=new Common.UI.Button({parentEl:e("#image-button-crop"),cls:"btn-text-split-default",caption:this.textCrop,split:!0,enableToggle:!0,allowDepress:!0,pressed:this._state.cropMode,width:o,menu:new Common.UI.Menu({style:"min-width:"+o+"px;",items:[{caption:this.textCrop,checkable:!0,allowDepress:!0,checked:this._state.cropMode,value:0},{caption:this.textCropFill,value:1},{caption:this.textCropFit,value:2}]})}),this.btnCrop.on("click",i.bind(this.onCrop,this)),this.btnCrop.menu.on("item:click",i.bind(this.onCropMenu,this)),this.lockedControls.push(this.btnCrop),this.btnSelectImage=new Common.UI.Button({parentEl:e("#image-button-replace"),cls:"btn-text-menu-default",caption:this.textInsert,style:"width:100%;",menu:new Common.UI.Menu({style:"min-width: 194px;",maxHeight:200,items:[{caption:this.textFromFile,value:0},{caption:this.textFromUrl,value:1},{caption:this.textFromStorage,value:2}]})}),this.lockedControls.push(this.btnSelectImage),this.btnSelectImage.menu.on("item:click",i.bind(this.onImageSelect,this)),this.btnSelectImage.menu.items[2].setVisible(this.mode.canRequestInsertImage||this.mode.fileChoiceUrl&&this.mode.fileChoiceUrl.indexOf("{documentType}")>-1),this.linkAdvanced=e("#image-advanced-link"),e(this.el).on("click","#image-advanced-link",i.bind(this.openAdvancedSettings,this))},_changeCropState:function(t){this._state.cropMode=t,this.btnCrop&&(this.btnCrop.toggle(t,!0),this.btnCrop.menu.items[0].setChecked(t,!0))},createDelayedElements:function(){this.createDelayedControls(),this.updateMetricUnit(),this._initSettings=!1},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedElements(),this.disableControls(this._locked),t){this._originalProps=new Asc.asc_CImgProperty(t);var e=t.get_WrappingStyle();if(this._state.WrappingStyle!==e){this.cmbWrapType.suspendEvents();var i=this.cmbWrapType.menuPicker.store.findWhere({data:e});this.cmbWrapType.menuPicker.selectRecord(i),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=e}e=t.get_CanBeFlow()&&!this._locked;var n=t.get_FromGroup()||this._locked,o=this.api.asc_IsContentControl()?this.api.asc_GetContentControlProperties():null,s=!!o&&o.get_SpecificType()==Asc.c_oAscContentControlSpecificType.Picture||this._locked;this._state.CanBeFlow===e&&this._state.FromGroup===n&&this._state.isPictureControl===s||(this.cmbWrapType.setDisabled(!e||n||s),this._state.CanBeFlow=e,this._state.FromGroup=n,this._state.isPictureControl=s),e=t.get_Width(),Math.abs(this._state.Width-e)>.001&&(this.labelWidth[0].innerHTML=this.textWidth+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName(),this._state.Width=e),e=t.get_Height(),Math.abs(this._state.Height-e)>.001&&(this.labelHeight[0].innerHTML=this.textHeight+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName(),this._state.Height=e),this.btnOriginalSize.setDisabled(null===t.get_ImageUrl()||void 0===t.get_ImageUrl()||this._locked);var a=t.asc_getPluginGuid();if(e=null!==a&&void 0!==a,this._state.isOleObject!==e&&(this.btnSelectImage.setVisible(!e),this.btnEditObject.setVisible(e),this.btnRotate270.setDisabled(e),this.btnRotate90.setDisabled(e),this.btnFlipV.setDisabled(e),this.btnFlipH.setDisabled(e),this._state.isOleObject=e),this._state.isOleObject){var r=DE.getCollection("Common.Collections.Plugins").findWhere({guid:a});this.btnEditObject.setDisabled(null===r||void 0===r||this._locked)}else this.btnSelectImage.setDisabled(null===a||this._locked)}},_ImgWrapStyleChanged:function(t){if(this.cmbWrapType&&this._state.WrappingStyle!==t){this.cmbWrapType.suspendEvents();var e=this.cmbWrapType.menuPicker.store.findWhere({data:t});this.cmbWrapType.menuPicker.selectRecord(e),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=t}},onSelectWrap:function(t,e){if(this.api){var i=new Asc.asc_CImgProperty,n=e.get("data");if(i.put_WrappingStyle(n),this._state.WrappingStyle===Asc.c_oAscWrapStyle2.Inline&&n!==Asc.c_oAscWrapStyle2.Inline){i.put_PositionH(new Asc.CImagePositionH),i.get_PositionH().put_UseAlign(!1),i.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var o=this._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column);i.get_PositionH().put_Value(o),i.put_PositionV(new Asc.CImagePositionV),i.get_PositionV().put_UseAlign(!1),i.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),o=this._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),i.get_PositionV().put_Value(o)}this.api.ImgApply(i)}this.fireEvent("editcomplete",this)},setOriginalSize:function(){if(this.api){var t=this.api.get_OriginalSizeImage(),e=t.get_ImageWidth(),i=t.get_ImageHeight();this.labelWidth[0].innerHTML=this.textWidth+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName(),this.labelHeight[0].innerHTML=this.textHeight+": "+Common.Utils.Metric.fnRecalcFromMM(i).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName();var n=new Asc.asc_CImgProperty;n.put_Width(e),n.put_Height(i),n.put_ResetCrop(!0),this.api.ImgApply(n),this.fireEvent("editcomplete",this)}},setFitMargins:function(){if(this.api){var t,e,i=this.api.asc_GetSectionProps(),n=this._state.Height>0?this._state.Width/this._state.Height:1,o=this.api.asc_GetCurrentColumnWidth?this.api.asc_GetCurrentColumnWidth():i.get_W()-i.get_LeftMargin()-i.get_RightMargin(),s=i.get_H()-i.get_TopMargin()-i.get_BottomMargin(),a=o/s;n>a?(t=o,e=t/n):n=1){var l=new Asc.CImagePositionH;l.put_UseAlign(!0),l.put_Percent(!1),l.put_RelativeFrom(Asc.c_oAscRelativeFromH.Margin),l.put_Align(Asc.c_oAscAlignH.Left),r.put_PositionH(l)}n<=1&&(l=new Asc.CImagePositionV, -l.put_UseAlign(!0),l.put_Percent(!1),l.put_RelativeFrom(Asc.c_oAscRelativeFromV.Margin),l.put_Align(Asc.c_oAscAlignV.Top),r.put_PositionV(l))}this.api.ImgApply(r),this.fireEvent("editcomplete",this)}},setImageUrl:function(t,e){var i=new Asc.asc_CImgProperty;i.put_ImageUrl(t,e),this.api.ImgApply(i)},insertImageFromStorage:function(t){t&&t.url&&"change"==t.c&&this.setImageUrl(t.url,t.token)},onImageSelect:function(t,e){if(1==e.value){var n=this;new Common.Views.ImageFromUrlDialog({handler:function(t,e){if("ok"==t&&n.api){var o=e.replace(/ /g,"");i.isEmpty(o)||n.setImageUrl(o)}n.fireEvent("editcomplete",n)}}).show()}else if(2==e.value)Common.NotificationCenter.trigger("storage:image-load","change");else{if(this._isFromFile)return;this._isFromFile=!0,this.api&&this.api.ChangeImageFromFile(),this.fireEvent("editcomplete",this),this._isFromFile=!1}},onBtnRotateClick:function(t){var e=new Asc.asc_CImgProperty;e.asc_putRotAdd(3.14159265358979*(1==t.options.value?90:270)/180),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onBtnFlipClick:function(t){var e=new Asc.asc_CImgProperty;1==t.options.value?e.asc_putFlipHInvert(!0):e.asc_putFlipVInvert(!0),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onCrop:function(t,e){this.api&&(t.pressed?this.api.asc_startEditCrop():this.api.asc_endEditCrop()),this.fireEvent("editcomplete",this)},onCropMenu:function(t,e){this.api&&(1==e.value?this.api.asc_cropFill():2==e.value?this.api.asc_cropFit():e.checked?this.api.asc_startEditCrop():this.api.asc_endEditCrop()),this.fireEvent("editcomplete",this)},openAdvancedSettings:function(t){if(!this.linkAdvanced.hasClass("disabled")){var e=this;if(e.api&&!this._locked){var i=e.api.getSelectedElements();if(i&&i.length>0)for(var n,o,s=i.length-1;s>=0;s--)if(n=i[s].get_ObjectType(),o=i[s].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Image==n){var a;e.btnOriginalSize.isDisabled()||(a=e.api.get_OriginalSizeImage())&&(a={width:a.get_ImageWidth(),height:a.get_ImageHeight()}),new DE.Views.ImageSettingsAdvanced({imageProps:o,sizeOriginal:a,api:e.api,sectionProps:e.api.asc_GetSectionProps(),handler:function(t,i){"ok"==t&&e.api&&e.api.ImgApply(i.imageProps),e.fireEvent("editcomplete",e)}}).show();break}}}},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||(this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.linkAdvanced.toggleClass("disabled",t)),this.btnCrop.setDisabled(t||!this.api.asc_canEditCrop()))},textSize:"Size",textWrap:"Wraping Style",textWidth:"Width",textHeight:"Height",textOriginalSize:"Actual Size",textInsert:"Replace Image",textFromUrl:"From URL",textFromFile:"From File",textAdvanced:"Show advanced settings",txtInline:"Inline",txtSquare:"Square",txtTight:"Tight",txtThrough:"Through",txtTopAndBottom:"Top and bottom",txtBehind:"Behind",txtInFront:"In front",textEditObject:"Edit Object",textEdit:"Edit",textFitMargins:"Fit to Margin",textRotation:"Rotation",textRotate90:"Rotate 90°",textFlip:"Flip",textHint270:"Rotate 90° Counterclockwise",textHint90:"Rotate 90° Clockwise",textHintFlipV:"Flip Vertically",textHintFlipH:"Flip Horizontally",textCrop:"Crop",textCropFill:"Fill",textCropFit:"Fit",textFromStorage:"From Storage"},DE.Views.ImageSettings||{}))}),define("text!documenteditor/main/app/template/ChartSettings.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    '}),define("documenteditor/main/app/view/ChartSettings",["text!documenteditor/main/app/template/ChartSettings.template","jquery","underscore","backbone","common/main/lib/component/Button","common/main/lib/component/ComboDataView","documenteditor/main/app/view/ImageSettingsAdvanced"],function(t,e,i,n){"use strict";DE.Views.ChartSettings=n.View.extend(i.extend({el:"#id-chart-settings",template:i.template(t),events:{},options:{alias:"ChartSettings"},initialize:function(){this._initSettings=!0,this._state={WrappingStyle:Asc.c_oAscWrapStyle2.Inline,CanBeFlow:!0,Width:0,Height:0,FromGroup:!1,ChartStyle:1,ChartType:-1,SeveralCharts:!1,DisabledControls:!1},this.lockedControls=[],this._locked=!1,this._noApply=!1,this._originalProps=null,this.render()},render:function(){var t=this.$el||e(this.el);t.html(this.template({scope:this})),this.labelWidth=t.find("#chart-label-width"),this.labelHeight=t.find("#chart-label-height")},setApi:function(t){return this.api=t,this.api&&(this.api.asc_registerCallback("asc_onImgWrapStyleChanged",i.bind(this._ChartWrapStyleChanged,this)),this.api.asc_registerCallback("asc_onUpdateChartStyles",i.bind(this._onUpdateChartStyles,this))),this},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedElements(),this.disableControls(this._locked),t&&t.get_ChartProperties()){this._originalProps=new Asc.asc_CImgProperty(t),this._noApply=!0;var e=t.get_WrappingStyle();if(this._state.WrappingStyle!==e){this.cmbWrapType.suspendEvents();var i=this.cmbWrapType.menuPicker.store.findWhere({data:e});this.cmbWrapType.menuPicker.selectRecord(i),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=e}if(this.chartProps=t.get_ChartProperties(),e=t.get_SeveralCharts()||this._locked,this._state.SeveralCharts!==e&&(this.btnEditData.setDisabled(e),this._state.SeveralCharts=e),e=t.get_SeveralChartTypes(),this._state.SeveralCharts&&e)this.btnChartType.setIconCls("svgicon"),this._state.ChartType=null;else{var n=this.chartProps.getType();if(this._state.ChartType!==n){var o=this.mnuChartTypePicker.store.findWhere({type:n});this.mnuChartTypePicker.selectRecord(o,!0),o?this.btnChartType.setIconCls("svgicon chart-"+o.get("iconCls")):this.btnChartType.setIconCls("svgicon"),this.updateChartStyles(this.api.asc_getChartPreviews(n)),this._state.ChartType=n}}if(e=t.get_SeveralChartStyles(),this._state.SeveralCharts&&e)this.cmbChartStyle.fieldPicker.deselectAll(),this.cmbChartStyle.menuPicker.deselectAll(),this._state.ChartStyle=null;else if(e=this.chartProps.getStyle(),this._state.ChartStyle!==e||this._isChartStylesChanged){this.cmbChartStyle.suspendEvents();var i=this.cmbChartStyle.menuPicker.store.findWhere({data:e});this.cmbChartStyle.menuPicker.selectRecord(i),this.cmbChartStyle.resumeEvents(),this._isChartStylesChanged&&(i?this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(),!0):this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0),!0)),this._state.ChartStyle=e}this._isChartStylesChanged=!1,this._noApply=!1,e=t.get_CanBeFlow()&&!this._locked;var s=t.get_FromGroup()||this._locked;this._state.CanBeFlow===e&&this._state.FromGroup===s||(this.cmbWrapType.setDisabled(!e||s),this._state.CanBeFlow=e,this._state.FromGroup=s),e=t.get_Width(),Math.abs(this._state.Width-e)>.001&&(this.labelWidth[0].innerHTML=this.textWidth+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(1)+" "+Common.Utils.Metric.getCurrentMetricName(),this._state.Width=e),e=t.get_Height(),Math.abs(this._state.Height-e)>.001&&(this.labelHeight[0].innerHTML=this.textHeight+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(1)+" "+Common.Utils.Metric.getCurrentMetricName(),this._state.Height=e)}},updateMetricUnit:function(){var t=Common.Utils.Metric.fnRecalcFromMM(this._state.Width);this.labelWidth[0].innerHTML=this.textWidth+": "+t.toFixed(1)+" "+Common.Utils.Metric.getCurrentMetricName(),t=Common.Utils.Metric.fnRecalcFromMM(this._state.Height),this.labelHeight[0].innerHTML=this.textHeight+": "+t.toFixed(1)+" "+Common.Utils.Metric.getCurrentMetricName()},createDelayedControls:function(){var t=this,n=[{offsetx:0,data:Asc.c_oAscWrapStyle2.Inline,tip:this.txtInline,selected:!0},{offsetx:50,data:Asc.c_oAscWrapStyle2.Square,tip:this.txtSquare},{offsetx:100,data:Asc.c_oAscWrapStyle2.Tight,tip:this.txtTight},{offsetx:150,data:Asc.c_oAscWrapStyle2.Through,tip:this.txtThrough},{offsetx:200,data:Asc.c_oAscWrapStyle2.TopAndBottom,tip:this.txtTopAndBottom},{offsetx:250,data:Asc.c_oAscWrapStyle2.InFront,tip:this.txtInFront},{offsetx:300,data:Asc.c_oAscWrapStyle2.Behind,tip:this.txtBehind}];this.cmbWrapType=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,store:new Common.UI.DataViewStore(n),cls:"combo-chart-style"}),this.cmbWrapType.menuPicker.itemTemplate=this.cmbWrapType.fieldPicker.itemTemplate=i.template(['
    ','',"
    "].join("")),this.cmbWrapType.render(e("#chart-combo-wrap")),this.cmbWrapType.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbWrapType.on("click",i.bind(this.onSelectWrap,this)),this.cmbWrapType.openButton.menu.on("show:after",function(){t.cmbWrapType.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbWrapType),this.btnChartType=new Common.UI.Button({cls:"btn-large-dataview",iconCls:"svgicon chart-column-normal",menu:new Common.UI.Menu({style:"width: 364px; padding-top: 12px;",items:[{template:i.template('')}]})}),this.btnChartType.on("render:after",function(n){t.mnuChartTypePicker=new Common.UI.DataView({el:e("#id-chart-menu-type"),parentMenu:n.menu,restoreHeight:421,groups:new Common.UI.DataViewGroupStore(Common.define.chartData.getChartGroupData()),store:new Common.UI.DataViewStore(Common.define.chartData.getChartData()),itemTemplate:i.template('
    ')})}),this.btnChartType.render(e("#chart-button-type")),this.mnuChartTypePicker.on("item:click",i.bind(this.onSelectType,this,this.btnChartType)),this.lockedControls.push(this.btnChartType),this.btnEditData=new Common.UI.Button({el:e("#chart-button-edit-data")}),this.lockedControls.push(this.btnEditData),this.btnEditData.on("click",i.bind(this.setEditData,this)),this.linkAdvanced=e("#chart-advanced-link"),e(this.el).on("click","#chart-advanced-link",i.bind(this.openAdvancedSettings,this))},createDelayedElements:function(){this.createDelayedControls(),this.updateMetricUnit(),this._initSettings=!1},_ChartWrapStyleChanged:function(t){if(this.cmbWrapType&&this._state.WrappingStyle!==t){this.cmbWrapType.suspendEvents();var e=this.cmbWrapType.menuPicker.store.findWhere({data:t});this.cmbWrapType.menuPicker.selectRecord(e),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=t}},onSelectWrap:function(t,e){if(this.api){var i=new Asc.asc_CImgProperty,n=e.get("data");if(i.put_WrappingStyle(n),this._state.WrappingStyle===Asc.c_oAscWrapStyle2.Inline&&n!==Asc.c_oAscWrapStyle2.Inline){i.put_PositionH(new Asc.CImagePositionH),i.get_PositionH().put_UseAlign(!1),i.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var o=this._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column);i.get_PositionH().put_Value(o),i.put_PositionV(new Asc.CImagePositionV),i.get_PositionV().put_UseAlign(!1),i.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),o=this._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),i.get_PositionV().put_Value(o)}this.api.ImgApply(i)}this.fireEvent("editcomplete",this)},setEditData:function(){var t=DE.getController("Common.Controllers.ExternalDiagramEditor").getView("Common.Views.ExternalDiagramEditor");if(t){t.setEditMode(!0),t.show();var e=this.api.asc_getChartObject();e&&t.setChartData(new Asc.asc_CChartBinary(e))}},openAdvancedSettings:function(t){if(!this.linkAdvanced.hasClass("disabled")){var e=this;if(e.api&&!this._locked){var i=e.api.getSelectedElements();if(i&&i.length>0)for(var n,o,s=i.length-1;s>=0;s--)if(n=i[s].get_ObjectType(),o=i[s].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Image==n){new DE.Views.ImageSettingsAdvanced({imageProps:o,sectionProps:e.api.asc_GetSectionProps(),handler:function(t,i){"ok"==t&&e.api&&e.api.ImgApply(i.imageProps),e.fireEvent("editcomplete",e)}}).show();break}}}},onSelectType:function(t,e,n,o){if(!this._noApply){var s={};if(i.isFunction(o.toJSON)){if(!o.get("selected"))return;s=o.toJSON()}else s=o;if(this.btnChartType.setIconCls("svgicon chart-"+s.iconCls),this._state.ChartType=-1,this.api&&!this._noApply&&this.chartProps){var a=new Asc.asc_CImgProperty;this.chartProps.changeType(s.type),a.put_ChartProperties(this.chartProps),this.api.ImgApply(a)}this.fireEvent("editcomplete",this)}},onSelectStyle:function(t,e){if(!this._noApply){if(this.api&&!this._noApply&&this.chartProps){var i=new Asc.asc_CImgProperty;this.chartProps.putStyle(e.get("data")),i.put_ChartProperties(this.chartProps),this.api.ImgApply(i)}this.fireEvent("editcomplete",this)}},_onUpdateChartStyles:function(){this.api&&null!==this._state.ChartType&&this._state.ChartType>-1&&this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType))},updateChartStyles:function(t){var n=this;if(this._isChartStylesChanged=!0,this.cmbChartStyle||(this.cmbChartStyle=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:270,enableKeyEvents:!0,cls:"combo-chart-style"}),this.cmbChartStyle.render(e("#chart-combo-style")),this.cmbChartStyle.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbChartStyle.on("click",i.bind(this.onSelectStyle,this)),this.cmbChartStyle.openButton.menu.on("show:after",function(){n.cmbChartStyle.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbChartStyle)),t&&t.length>0){var o=this.cmbChartStyle.menuPicker.store;if(o){var s=o.length;if(s>0&&s==t.length){var a=o.models;i.each(t,function(t,e){a[e].set("imageUrl",t.asc_getImage())})}else{var r=[];i.each(t,function(t,e){r.push({imageUrl:t.asc_getImage(),data:t.asc_getName(),tip:n.textStyle+" "+t.asc_getName()})}),o.reset(r,{silent:!1})}}}else this.cmbChartStyle.menuPicker.store.reset(),this.cmbChartStyle.clearComboView();this.cmbChartStyle.setDisabled(!t||t.length<1||this._locked)},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.linkAdvanced.toggleClass("disabled",t))},textSize:"Size",textWrap:"Wrapping Style",textWidth:"Width",textHeight:"Height",textAdvanced:"Show advanced settings",txtInline:"Inline",txtSquare:"Square",txtTight:"Tight",txtThrough:"Through",txtTopAndBottom:"Top and bottom",txtBehind:"Behind",txtInFront:"In front",textEditData:"Edit Data",textChartType:"Change Chart Type",textStyle:"Style"},DE.Views.ChartSettings||{}))}),define("text!documenteditor/main/app/template/TableSettings.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    '}),void 0===Common)var Common={};if(define("common/main/lib/component/ComboBorderSize",["common/main/lib/component/ComboBox"],function(){"use strict";Common.UI.BordersModel=Backbone.Model.extend({defaults:function(){return{value:null,displayValue:null,pxValue:null,id:Common.UI.getId(),offsety:void 0}}}),Common.UI.BordersStore=Backbone.Collection.extend({model:Common.UI.BordersModel}),Common.UI.ComboBorderSize=Common.UI.ComboBox.extend(_.extend({template:_.template(['
    ','
    ','
    ','','","
    "].join("")),initialize:function(t){var e=Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt),i=[{displayValue:"0.5 "+e,value:.5,pxValue:.5,offsety:0},{displayValue:"1 "+e,value:1,pxValue:1,offsety:20},{displayValue:"1.5 "+e,value:1.5,pxValue:2,offsety:40},{displayValue:"2.25 "+e,value:2.25,pxValue:3,offsety:60},{displayValue:"3 "+e,value:3,pxValue:4,offsety:80},{displayValue:"4.5 "+e,value:4.5,pxValue:5,offsety:100},{displayValue:"6 "+e,value:6,pxValue:6,offsety:120}];!1!==t.allowNoBorders&&i.unshift({displayValue:this.txtNoBorders,value:0,pxValue:0}),Common.UI.ComboBox.prototype.initialize.call(this,_.extend({editable:!1,store:new Common.UI.BordersStore,data:i,menuStyle:"min-width: 160px;"},t))},render:function(t){return Common.UI.ComboBox.prototype.render.call(this,t),this},itemClicked:function(t){var e=$(t.currentTarget).parent();this._selectedItem=this.store.findWhere({id:e.attr("id")}),this._selectedItem&&($(".selected",$(this.el)).removeClass("selected"),e.addClass("selected"),this.updateFormControl(this._selectedItem),this.trigger("selected",this,_.extend({},this._selectedItem.toJSON()),t),t.preventDefault())},updateFormControl:function(t){var e=$(this.el).find(".form-control");t.get("value")>0?(e[0].innerHTML="",e.removeClass("text").addClass("image"),e.css("background-position","10px -"+t.get("offsety")+"px")):(e[0].innerHTML=this.txtNoBorders,e.removeClass("image").addClass("text"))},setValue:function(t){if(this._selectedItem=null===t||void 0===t?void 0:_.find(this.store.models,function(e){if(te.attributes.value-.01)return!0}),$(".selected",$(this.el)).removeClass("selected"),this._selectedItem)this.updateFormControl(this._selectedItem),$("#"+this._selectedItem.get("id"),$(this.el)).addClass("selected");else{var e=$(this.el).find(".form-control");e[0].innerHTML="",e.removeClass("image").addClass("text")}},txtNoBorders:"No Borders"},Common.UI.ComboBorderSize||{})),Common.UI.ComboBorderSizeEditable=Common.UI.ComboBox.extend(_.extend({template:_.template(['','','','",""].join("")),initialize:function(t){this.txtNoBorders=t.txtNoBorders||this.txtNoBorders;var e=Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt),i=[{displayValue:"0.5 "+e,value:.5,pxValue:.5,offsety:0},{displayValue:"1 "+e,value:1,pxValue:1,offsety:20},{displayValue:"1.5 "+e,value:1.5,pxValue:2,offsety:40},{displayValue:"2.25 "+e,value:2.25,pxValue:3,offsety:60},{displayValue:"3 "+e,value:3,pxValue:4,offsety:80},{displayValue:"4.5 "+e,value:4.5,pxValue:5,offsety:100},{displayValue:"6 "+e,value:6,pxValue:6,offsety:120}];!1!==t.allowNoBorders&&i.unshift({displayValue:this.txtNoBorders,value:0,pxValue:0}),Common.UI.ComboBox.prototype.initialize.call(this,_.extend({editable:!0,store:new Common.UI.BordersStore,data:i,menuStyle:"min-width: 160px;"},t))},render:function(t){return Common.UI.ComboBox.prototype.render.call(this,t),this},txtNoBorders:"No Borders"},Common.UI.ComboBorderSizeEditable||{})),Common.UI.ComboBorderType=Common.UI.ComboBorderSize.extend(_.extend({template:_.template(['
    ','
    ','
    ','','","
    "].join("")),initialize:function(t){Common.UI.ComboBorderSize.prototype.initialize.call(this,_.extend({store:new Common.UI.BordersStore,data:[{value:Asc.c_oDashType.solid,offsety:140},{value:Asc.c_oDashType.sysDot,offsety:160},{value:Asc.c_oDashType.sysDash,offsety:180},{value:Asc.c_oDashType.dash,offsety:200},{value:Asc.c_oDashType.dashDot,offsety:220},{value:Asc.c_oDashType.lgDash,offsety:240},{value:Asc.c_oDashType.lgDashDot,offsety:260},{value:Asc.c_oDashType.lgDashDotDot,offsety:280}]},t))},render:function(t){return Common.UI.ComboBorderSize.prototype.render.call(this,t),this},updateFormControl:function(t){var e=$(this.el).find(".form-control");e[0].innerHTML="",e.removeClass("text").addClass("image"),e.css("background-position","10px -"+t.get("offsety")+"px")}},Common.UI.ComboBorderType||{})),Common.UI.ComboBoxColor=Common.UI.ComboBox.extend(_.extend({template:_.template(['
    ','
    ','
    ',"
    ",'','","
    "].join("")),itemClicked:function(t){var e=$(t.currentTarget).parent();this._selectedItem=this.store.findWhere({id:e.attr("id")}),this._selectedItem&&($(".selected",$(this.el)).removeClass("selected"),e.addClass("selected"),this.updateFormControl(this._selectedItem),this.trigger("selected",this,_.extend({},this._selectedItem.toJSON()),t),t.preventDefault())},updateFormControl:function(t){var e=$(this.el).find(".form-control > div") -;-1!=t.get("value")?(e[0].innerHTML="",e.css({background:"#"+t.get("value"),"margin-top":"0"})):(e[0].innerHTML=t.get("displayValue"),e.css({background:"","margin-top":"1px"}))},setValue:function(t){var e;if(this._selectedItem=this.store.findWhere((e={},e[this.valueField]=t,e)),$(".selected",$(this.el)).removeClass("selected"),this._selectedItem)this.updateFormControl(this._selectedItem),$("#"+this._selectedItem.get("id"),$(this.el)).addClass("selected");else{var i=$(this.el).find(".form-control > div");i[0].innerHTML="",i.css("background","")}},onResetItems:function(){this.itemsTemplate?$(this.el).find("ul").html($(this.itemsTemplate({items:this.store.toJSON(),scope:this}))):$(this.el).find("ul").html(_.template(["<% _.each(items, function(item) { %>","<% if (item.value==-1) { %>",'
  • <%= scope.getDisplayValue(item) %>
  • ',"<% } else { %>",'
  • ','
    ',"
  • ","<% } %>","<% }); %>"].join(""))({items:this.store.toJSON(),scope:this})),_.isUndefined(this.scroller)||(this.scroller.destroy(),delete this.scroller),this.scroller=new Common.UI.Scroller(_.extend({el:$(".dropdown-menu",this.cmpEl),minScrollbarLength:40,includePadding:!0,wheelSpeed:10,alwaysVisibleY:this.scrollAlwaysVisible},this.options.scroller))}},Common.UI.ComboBoxColor||{}))}),define("documenteditor/main/app/view/TableFormulaDialog",["common/main/lib/component/InputField","common/main/lib/component/Window"],function(){"use strict";DE.Views.TableFormulaDialog=Common.UI.Window.extend(_.extend({options:{width:300,style:"min-width: 230px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
    ','
    ',"","
    ",'
    ','
    ',"","
    ",'
    ','
    ','
    ','
    ',"
    ","
    "].join(""),this.options.tpl=_.template(this.template)(this.options),this.bookmarks=this.options.bookmarks,this.api=this.options.api,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();this.inputFormula=new Common.UI.InputField({el:$("#id-dlg-formula-formula"),allowBlank:!0,validateOnChange:!0,style:"width: 100%;"}).on("changing",_.bind(this.checkFormulaInput,this)),this.cmbFormat=new Common.UI.ComboBox({el:$("#id-dlg-formula-format"),cls:"input-group-nr",menuStyle:"min-width: 100%; max-height: 200px;",takeFocusOnClose:!0}),this.cmbFunction=new Common.UI.ComboBox({el:$("#id-dlg-formula-function"),cls:"input-group-nr",menuStyle:"min-width: 100%; max-height: 150px;",editable:!1,takeFocusOnClose:!0,scrollAlwaysVisible:!0,data:[{displayValue:"ABS",value:1},{displayValue:"AND",value:1},{displayValue:"AVERAGE",value:1},{displayValue:"COUNT",value:1},{displayValue:"DEFINED",value:1},{displayValue:"FALSE",value:0},{displayValue:"IF",value:1},{displayValue:"INT",value:1},{displayValue:"MAX",value:1},{displayValue:"MIN",value:1},{displayValue:"MOD",value:1},{displayValue:"NOT",value:1},{displayValue:"OR",value:1},{displayValue:"PRODUCT",value:1},{displayValue:"ROUND",value:1},{displayValue:"SIGN",value:1},{displayValue:"SUM",value:1},{displayValue:"TRUE",value:0}]}),this.cmbFunction.on("selected",_.bind(function(e,i){e.setValue(this.textInsertFunction);var n=t.inputFormula._input,o=n[0].selectionEnd;n.val(n.val().substring(0,o)+i.displayValue+(i.value?"()":"")+n.val().substring(o)),n.focus(),n[0].selectionStart=n[0].selectionEnd=o+i.displayValue.length+i.value,this.btnOk.setDisabled(!1)},this)),this.cmbFunction.setValue(this.textInsertFunction),this.cmbBookmark=new Common.UI.ComboBox({el:$("#id-dlg-formula-bookmark"),cls:"input-group-nr",menuStyle:"min-width: 100%; max-height: 150px;",editable:!1,takeFocusOnClose:!0}),this.cmbBookmark.on("selected",_.bind(function(e,i){e.setValue(this.textBookmark);var n=t.inputFormula._input,o=n[0].selectionEnd;n.val(n.val().substring(0,o)+i.displayValue+n.val().substring(o)),n.focus(),n[0].selectionStart=n[0].selectionEnd=o+i.displayValue.length,this.btnOk.setDisabled(!1)},this)),this.cmbBookmark.setValue(this.textBookmark),t.btnOk=new Common.UI.Button({el:e.find(".primary")}),e.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.afterRender()},getFocusedComponents:function(){return[this.inputFormula,this.cmbFormat,this.cmbFunction,this.cmbBookmark]},getDefaultFocusableComponent:function(){return this.inputFormula},onSelectItem:function(t,e,i,n){this.btnOk.setDisabled(0==i.get("level")&&i.get("index")>0)},afterRender:function(){this.refreshBookmarks(),this._setDefaults()},_setDefaults:function(){var t=[];_.each(this.api.asc_GetTableFormulaFormats(),function(e){t.push({value:e,displayValue:e})}),this.cmbFormat.setData(t);var e=this.api.asc_ParseTableFormulaInstrLine(this.api.asc_GetTableFormula());this.inputFormula.setValue(e[0]),this.cmbFormat.setValue(e[1]),this.checkFormulaInput(this.inputFormula,this.inputFormula.getValue())},refreshBookmarks:function(){var t=[];if(this.bookmarks){for(var e=this.bookmarks.asc_GetCount(),i=0;i.001)&&(this.numWidth.setValue(null!==e&&void 0!==e?Common.Utils.Metric.fnRecalcFromMM(e):"",!0),this._state.Width=e),e=t.get_RowHeight(),((void 0===this._state.Height||void 0===e)&&this._state.Height!==e||Math.abs(this._state.Height-e)>.001)&&(this.numHeight.setValue(null!==e&&void 0!==e?Common.Utils.Metric.fnRecalcFromMM(e):"",!0),this._state.Height=e),e=t.get_TableStyle(),this._state.TemplateId!==e||this._isTemplatesChanged){var i=this.mnuTableTemplatePicker.store.findWhere({templateId:e});i||(i=this.mnuTableTemplatePicker.store.at(0)),this.btnTableTemplate.suspendEvents(),this.mnuTableTemplatePicker.selectRecord(i,!0),this.btnTableTemplate.resumeEvents(),this.$el.find(".icon-template-table").css({"background-image":"url("+i.get("imageUrl")+")",height:"52px",width:"72px","background-position":"center","background-size":"cover"}),this._state.TemplateId=e}this._isTemplatesChanged=!1;var n=t.get_TableLook();n&&(e=n.get_FirstRow(),this._state.CheckHeader!==e&&(this.chHeader.setValue(e,!0),this._state.CheckHeader=e,this._originalLook.put_FirstRow(e)),e=n.get_LastRow(),this._state.CheckTotal!==e&&(this.chTotal.setValue(e,!0),this._state.CheckTotal=e,this._originalLook.put_LastRow(e)),e=n.get_BandHor(),this._state.CheckBanded!==e&&(this.chBanded.setValue(e,!0),this._state.CheckBanded=e,this._originalLook.put_BandHor(e)),e=n.get_FirstCol(),this._state.CheckFirst!==e&&(this.chFirst.setValue(e,!0),this._state.CheckFirst=e,this._originalLook.put_FirstCol(e)),e=n.get_LastCol(),this._state.CheckLast!==e&&(this.chLast.setValue(e,!0),this._state.CheckLast=e,this._originalLook.put_LastCol(e)),e=n.get_BandVer(),this._state.CheckColBanded!==e&&(this.chColBanded.setValue(e,!0),this._state.CheckColBanded=e,this._originalLook.put_BandVer(e)));var o=t.get_CellsBackground();if(o)if(0==o.get_Value()){var s=o.get_Color();s?s.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.CellColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(s.get_r(),s.get_g(),s.get_b()),effectValue:s.get_value()}}:this.CellColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(s.get_r(),s.get_g(),s.get_b())}:this.CellColor={Value:1,Color:"transparent"}}else this.CellColor={Value:1,Color:"transparent"};else this.CellColor={Value:0,Color:"transparent"};var a=typeof this.CellColor.Color;if(a!==typeof this._state.BackColor||"object"==a&&(this.CellColor.Color.effectValue!==this._state.BackColor.effectValue||this._state.BackColor.color.indexOf(this.CellColor.Color.color)<0)||"object"!=a&&this._state.BackColor.indexOf(this.CellColor.Color)<0){if(this.btnBackColor.setColor(this.CellColor.Color),"object"==typeof this.CellColor.Color){for(var r=!1,l=0;l<10;l++)if(Common.Utils.ThemeColor.ThemeValues[l]==this.CellColor.Color.effectValue){this.colorsBack.select(this.CellColor.Color,!0),r=!0;break}r||this.colorsBack.clearSelection()}else this.colorsBack.select(this.CellColor.Color,!0);this._state.BackColor=this.CellColor.Color}e=t.get_RowsInHeader(),this._state.RepeatRow!==e&&(this.chRepeatRow.setValue(!!e,!0),this.chRepeatRow.setDisabled(null===e),this._state.RepeatRow=e)}},updateMetricUnit:function(){if(this.spinners){for(var t=0;t-1||!i)&&(null!==e.get_Left()&&void 0!==e.get_Left()||e.put_Left(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_Left(),i)),(t.indexOf("t")>-1||!i)&&(null!==e.get_Top()&&void 0!==e.get_Top()||e.put_Top(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_Top(),i)),(t.indexOf("r")>-1||!i)&&(null!==e.get_Right()&&void 0!==e.get_Right()||e.put_Right(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_Right(),i)),(t.indexOf("b")>-1||!i)&&(null!==e.get_Bottom()&&void 0!==e.get_Bottom()||e.put_Bottom(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_Bottom(),i)),(t.indexOf("c")>-1||!i)&&(null!==e.get_InsideV()&&void 0!==e.get_InsideV()||e.put_InsideV(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_InsideV(),i)),(t.indexOf("m")>-1||!i)&&(null!==e.get_InsideH()&&void 0!==e.get_InsideH()||e.put_InsideH(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_InsideH(),i))},_UpdateBorderStyle:function(t,e){if(null==t&&(t=new Asc.asc_CTextBorder),e&&this.BorderSize>0){var i=parseFloat(this.BorderSize);t.put_Value(1),t.put_Size(25.4*i/72);var n=Common.Utils.ThemeColor.getRgbColor(this.btnBorderColor.color);t.put_Color(n)}else t.put_Value(0)},UpdateThemeColors:function(){this._initSettings||(this.btnBackColor||(this.btnBorderColor=new Common.UI.ColorButton({parentEl:e("#table-border-color-btn"),color:"000000"}),this.lockedControls.push(this.btnBorderColor),this.borderColor=this.btnBorderColor.getPicker(),this.btnBackColor=new Common.UI.ColorButton({parentEl:e("#table-back-color-btn"),transparent:!0}),this.lockedControls.push(this.btnBackColor),this.colorsBack=this.btnBackColor.getPicker(),this.btnBackColor.on("color:select",i.bind(this.onColorsBackSelect,this))),this.colorsBack.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.borderColor.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.btnBorderColor.setColor(this.borderColor.getColor()))},_onInitTemplates:function(t){var n=this;this._isTemplatesChanged=!0,this.btnTableTemplate||(this.btnTableTemplate=new Common.UI.Button({cls:"btn-large-dataview template-table",iconCls:"icon-template-table",menu:new Common.UI.Menu({style:"width: 575px;",items:[{template:i.template('')}]})}),this.btnTableTemplate.on("render:after",function(t){n.mnuTableTemplatePicker=new Common.UI.DataView({el:e("#id-table-menu-template"),parentMenu:t.menu,restoreHeight:350,groups:new Common.UI.DataViewGroupStore,store:new Common.UI.DataViewStore,itemTemplate:i.template('
    '),style:"max-height: 350px;"})}),this.btnTableTemplate.render(e("#table-btn-template")),this.lockedControls.push(this.btnTableTemplate),this.mnuTableTemplatePicker.on("item:click",i.bind(this.onTableTemplateSelect,this,this.btnTableTemplate)));var o=n.mnuTableTemplatePicker.store.length;if(o>0&&o==t.length){var s=n.mnuTableTemplatePicker.dataViewItems;s&&i.each(t,function(t,i){var n=t.asc_getImage();s[i].model.set("imageUrl",n,{silent:!0}),e(s[i].el).find("img").attr("src",n)})}else{var a=[];i.each(t,function(t){var e=t.asc_getDisplayName();0==t.asc_getType()&&["Table Grid","Plain Table","Grid Table","List Table","Light","Dark","Colorful","Accent"].forEach(function(t){var i="txtTable_"+t.replace(" ","");n[i]&&(e=e.replace(t,n[i]))}),a.push({imageUrl:t.asc_getImage(),id:Common.UI.getId(),templateId:t.asc_getId(),tip:e})}),n.mnuTableTemplatePicker.store.reset(a)}},openAdvancedSettings:function(t){if(!this.linkAdvanced.hasClass("disabled")){var e=this;if(e.api&&!this._locked){var i=e.api.getSelectedElements();if(i&&i.length>0)for(var n,o,s=i.length-1;s>=0;s--)if(n=i[s].get_ObjectType(),o=i[s].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Table==n){new DE.Views.TableSettingsAdvanced({tableStylerRows:null===o.get_CellBorders().get_InsideH()&&1==o.get_CellSelect()?1:2,tableStylerColumns:null===o.get_CellBorders().get_InsideV()&&1==o.get_CellSelect()?1:2,tableProps:o,borderProps:e.borderAdvancedProps,sectionProps:e.api.asc_GetSectionProps(),handler:function(t,i){"ok"==t&&e.api&&(e.borderAdvancedProps=i.borderProps,e.api.tblApply(i.tableProps)),e.fireEvent("editcomplete",e)}}).show();break}}}},onAddFormula:function(t){var e=this;e.api&&!this._locked&&new DE.Views.TableFormulaDialog({api:e.api,bookmarks:e.api.asc_GetBookmarksManager(),handler:function(t,i){"ok"==t&&e.api&&e.api.asc_AddTableFormula(i),e.fireEvent("editcomplete",e)}}).show()},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.linkAdvanced.toggleClass("disabled",t))},textBorders:"Border's Style",textBorderColor:"Color",textBackColor:"Background color",textEdit:"Rows & Columns",selectRowText:"Select Row",selectColumnText:"Select Column",selectCellText:"Select Cell",selectTableText:"Select Table",insertRowAboveText:"Insert Row Above",insertRowBelowText:"Insert Row Below",insertColumnLeftText:"Insert Column Left",insertColumnRightText:"Insert Column Right",deleteRowText:"Delete Row",deleteColumnText:"Delete Column",deleteTableText:"Delete Table",mergeCellsText:"Merge Cells",splitCellsText:"Split Cell...",splitCellTitleText:"Split Cell",textSelectBorders:"Select borders that you want to change",textAdvanced:"Show advanced settings",txtNoBorders:"No borders",textTemplate:"Select From Template",textRows:"Rows",textColumns:"Columns",textHeader:"Header",textTotal:"Total",textBanded:"Banded",textFirst:"First",textLast:"Last",textEmptyTemplate:"No templates",strRepeatRow:"Repeat as header row at the top of each page",tipTop:"Set Outer Top Border Only",tipLeft:"Set Outer Left Border Only",tipBottom:"Set Outer Bottom Border Only",tipRight:"Set Outer Right Border Only",tipAll:"Set Outer Border and All Inner Lines",tipNone:"Set No Borders",tipInner:"Set Inner Lines Only",tipInnerVert:"Set Vertical Inner Lines Only",tipInnerHor:"Set Horizontal Inner Lines Only",tipOuter:"Set Outer Border Only",textCellSize:"Rows & Columns Size",textHeight:"Height",textWidth:"Width",textDistributeRows:"Distribute rows",textDistributeCols:"Distribute columns",textAddFormula:"Add formula",txtTable_TableGrid:"Table Grid",txtTable_PlainTable:"Plain Table",txtTable_GridTable:"Grid Table",txtTable_ListTable:"List Table",txtTable_Light:"Light",txtTable_Dark:"Dark",txtTable_Colorful:"Colorful",txtTable_Accent:"Accent"},DE.Views.TableSettings||{}))}),define("text!documenteditor/main/app/template/ShapeSettings.template",[],function(){ +t.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),e=this._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),t.get_PositionV().put_Value(e))}return this._objectType!=Asc.c_oAscTypeSelectElement.Chart&&(t.asc_putRot(3.14159265358979*this.spnAngle.getNumberValue()/180),t.asc_putFlipH("checked"==this.chFlipHor.getValue()),t.asc_putFlipV("checked"==this.chFlipVert.getValue())),this.isAltTitleChanged&&t.asc_putTitle(this.inputAltTitle.getValue()),this.isAltDescChanged&&t.asc_putDescription(this.textareaAltDescription.val()),{imageProps:t}},_setShapeDefaults:function(t){if(t){var e=t.get_stroke();if(e){for(var i=e.get_linejoin(),n=0;n0?(e.store.each(function(t){t.set({offsetx:80*i.get("value")+10})},this),t.setDisabled(!1),null!==n?(e.selectByIndex(n,!0),this._selectStyleItem(t,e.store.at(n))):this._selectStyleItem(t,null)):(this._selectStyleItem(t,null),t.setDisabled(!0))},_selectStyleItem:function(t,e){$(t.el).find(".form-control").css("background-position",(e?20-e.get("offsetx")+"px":"0")+" "+(e?"-"+e.get("offsety")+"px":"-30px"))},onSelectBeginStyle:function(t,e,i,n){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_linebeginstyle(i.get("type"))),null!==this._beginSizeIdx&&void 0!==this._beginSizeIdx||(this._beginSizeIdx=4),this._updateSizeArr(this.btnBeginSize,this.mnuBeginSizePicker,i,this._beginSizeIdx),this._selectStyleItem(this.btnBeginStyle,i)},onSelectBeginSize:function(t,e,i,n){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_linebeginsize(i.get("type"))),this._beginSizeIdx=i.get("value"),this._selectStyleItem(this.btnBeginSize,i)},onSelectEndStyle:function(t,e,i,n){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_lineendstyle(i.get("type"))),null!==this._endSizeIdx&&void 0!==this._endSizeIdx||(this._endSizeIdx=4),this._updateSizeArr(this.btnEndSize,this.mnuEndSizePicker,i,this._endSizeIdx),this._selectStyleItem(this.btnEndStyle,i)},onSelectEndSize:function(t,e,i,n){this._changedShapeProps&&(null===this._changedShapeProps.get_stroke()&&this._changedShapeProps.put_stroke(new Asc.asc_CStroke),this._changedShapeProps.get_stroke().put_lineendsize(i.get("type"))),this._endSizeIdx=i.get("value"),this._selectStyleItem(this.btnEndSize,i)},textTop:"Top",textLeft:"Left",textBottom:"Bottom",textRight:"Right",textOriginalSize:"Actual Size",textPosition:"Position",textDistance:"Distance From Text",textSize:"Size",textWrap:"Wrapping Style",textWidth:"Width",textHeight:"Height",textWrapInlineTooltip:"Inline",textWrapSquareTooltip:"Square",textWrapTightTooltip:"Tight",textWrapThroughTooltip:"Through",textWrapTopbottomTooltip:"Top and Bottom",textWrapBehindTooltip:"Behind",textWrapInFrontTooltip:"In Front",textTitle:"Image - Advanced Settings",textKeepRatio:"Constant Proportions",textBtnWrap:"Text Wrapping",textCenter:"Center",textCharacter:"Character",textColumn:"Column",textLeftMargin:"Left Margin",textMargin:"Margin",textPage:"Page",textRightMargin:"Right Margin",textLine:"Line",textBottomMargin:"Bottom Margin",textParagraph:"Paragraph",textTopMargin:"Top Margin",textHorizontal:"Horizontal",textVertical:"Vertical",textAlignment:"Alignment",textRelative:"relative to",textRightOf:"to the right Of",textBelow:"below",textOverlap:"Allow overlap",textMove:"Move object with text",textOptions:"Options",textShape:"Shape Settings",textTitleShape:"Shape - Advanced Settings",textTitleChart:"Chart - Advanced Settings",strMargins:"Text Padding",textRound:"Round",textMiter:"Miter",textSquare:"Square",textFlat:"Flat",textBevel:"Bevel",textArrows:"Arrows",textLineStyle:"Line Style",textCapType:"Cap Type",textJoinType:"Join Type",textBeginStyle:"Begin Style",textBeginSize:"Begin Size",textEndStyle:"End Style",textEndSize:"End Size",textPositionPc:"Relative position",textAspectRatio:"Lock aspect ratio",textAbsoluteWH:"Absolute",textRelativeWH:"Relative",textAlt:"Alternative Text",textAltTitle:"Title",textAltDescription:"Description",textAltTip:"The alternative text-based representation of the visual object information, which will be read to the people with vision or cognitive impairments to help them better understand what information there is in the image, autoshape, chart or table.",textWeightArrows:"Weights & Arrows",textRotation:"Rotation",textAngle:"Angle",textFlipped:"Flipped",textHorizontally:"Horizontally",textVertically:"Vertically",textTextBox:"Text Box",textAutofit:"AutoFit",textResizeFit:"Resize shape to fit text"},DE.Views.ImageSettingsAdvanced||{}))}),define("documenteditor/main/app/view/ImageSettings",["text!documenteditor/main/app/template/ImageSettings.template","jquery","underscore","backbone","common/main/lib/component/Button","common/main/lib/view/ImageFromUrlDialog","documenteditor/main/app/view/ImageSettingsAdvanced"],function(t,e,i,n){"use strict";DE.Views.ImageSettings=n.View.extend(i.extend({el:"#id-image-settings",template:i.template(t),events:{},options:{alias:"ImageSettings"},initialize:function(){this._initSettings=!0,this._state={WrappingStyle:Asc.c_oAscWrapStyle2.Inline,CanBeFlow:!0,Width:0,Height:0,FromGroup:!1,DisabledControls:!1,isOleObject:!1,cropMode:!1,isPictureControl:!1},this.lockedControls=[],this._locked=!1,this._originalProps=null,this.render()},render:function(){var t=this.$el||e(this.el);t.html(this.template({scope:this})),this.labelWidth=t.find("#image-label-width"),this.labelHeight=t.find("#image-label-height")},setApi:function(t){return this.api=t,this.api&&(this.api.asc_registerCallback("asc_onImgWrapStyleChanged",i.bind(this._ImgWrapStyleChanged,this)),this.api.asc_registerCallback("asc_ChangeCropState",i.bind(this._changeCropState,this))),Common.NotificationCenter.on("storage:image-insert",i.bind(this.insertImageFromStorage,this)),this},setMode:function(t){this.mode=t},updateMetricUnit:function(){var t=Common.Utils.Metric.fnRecalcFromMM(this._state.Width);this.labelWidth[0].innerHTML=this.textWidth+": "+t.toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName(),t=Common.Utils.Metric.fnRecalcFromMM(this._state.Height),this.labelHeight[0].innerHTML=this.textHeight+": "+t.toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()},createDelayedControls:function(){var t=this,n=[{offsetx:0,data:Asc.c_oAscWrapStyle2.Inline,tip:this.txtInline,selected:!0},{offsetx:50,data:Asc.c_oAscWrapStyle2.Square,tip:this.txtSquare},{offsetx:100,data:Asc.c_oAscWrapStyle2.Tight,tip:this.txtTight},{offsetx:150,data:Asc.c_oAscWrapStyle2.Through,tip:this.txtThrough},{offsetx:200,data:Asc.c_oAscWrapStyle2.TopAndBottom,tip:this.txtTopAndBottom},{offsetx:250,data:Asc.c_oAscWrapStyle2.InFront,tip:this.txtInFront},{offsetx:300,data:Asc.c_oAscWrapStyle2.Behind,tip:this.txtBehind}];this.cmbWrapType=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,store:new Common.UI.DataViewStore(n),cls:"combo-chart-style"}),this.cmbWrapType.menuPicker.itemTemplate=this.cmbWrapType.fieldPicker.itemTemplate=i.template(['
    ','',"
    "].join("")),this.cmbWrapType.render(e("#image-combo-wrap")),this.cmbWrapType.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbWrapType.on("click",i.bind(this.onSelectWrap,this)),this.cmbWrapType.openButton.menu.on("show:after",function(){t.cmbWrapType.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbWrapType),this.btnOriginalSize=new Common.UI.Button({el:e("#image-button-original-size")}),this.lockedControls.push(this.btnOriginalSize),this.btnFitMargins=new Common.UI.Button({el:e("#image-button-fit-margins")}),this.lockedControls.push(this.btnFitMargins);var o=Math.max(this.btnOriginalSize.cmpEl.width(),this.btnFitMargins.cmpEl.width());this.btnOriginalSize.cmpEl.width(o),this.btnFitMargins.cmpEl.width(o),this.btnEditObject=new Common.UI.Button({el:e("#image-button-edit-object")}),this.lockedControls.push(this.btnEditObject),this.btnOriginalSize.on("click",i.bind(this.setOriginalSize,this)),this.btnEditObject.on("click",i.bind(function(t){this.api&&this.api.asc_startEditCurrentOleObject(),this.fireEvent("editcomplete",this)},this)),this.btnFitMargins.on("click",i.bind(this.setFitMargins,this)),this.btnRotate270=new Common.UI.Button({parentEl:e("#image-button-270",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-rotate-270",value:0,hint:this.textHint270}),this.btnRotate270.on("click",i.bind(this.onBtnRotateClick,this)),this.lockedControls.push(this.btnRotate270),this.btnRotate90=new Common.UI.Button({parentEl:e("#image-button-90",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-rotate-90",value:1,hint:this.textHint90}),this.btnRotate90.on("click",i.bind(this.onBtnRotateClick,this)),this.lockedControls.push(this.btnRotate90),this.btnFlipV=new Common.UI.Button({parentEl:e("#image-button-flipv",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-flip-vert",value:0,hint:this.textHintFlipV}),this.btnFlipV.on("click",i.bind(this.onBtnFlipClick,this)),this.lockedControls.push(this.btnFlipV),this.btnFlipH=new Common.UI.Button({parentEl:e("#image-button-fliph",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-flip-hor",value:1,hint:this.textHintFlipH}),this.btnFlipH.on("click",i.bind(this.onBtnFlipClick,this)),this.lockedControls.push(this.btnFlipH);var o=this.btnOriginalSize.cmpEl.outerWidth();this.btnCrop=new Common.UI.Button({parentEl:e("#image-button-crop"),cls:"btn-text-split-default",caption:this.textCrop,split:!0,enableToggle:!0,allowDepress:!0,pressed:this._state.cropMode,width:o,menu:new Common.UI.Menu({style:"min-width:"+o+"px;",items:[{caption:this.textCrop,checkable:!0,allowDepress:!0,checked:this._state.cropMode,value:0},{caption:this.textCropFill,value:1},{caption:this.textCropFit,value:2}]})}),this.btnCrop.on("click",i.bind(this.onCrop,this)),this.btnCrop.menu.on("item:click",i.bind(this.onCropMenu,this)),this.lockedControls.push(this.btnCrop),this.btnSelectImage=new Common.UI.Button({parentEl:e("#image-button-replace"),cls:"btn-text-menu-default",caption:this.textInsert,style:"width:100%;",menu:new Common.UI.Menu({style:"min-width: 194px;",maxHeight:200,items:[{caption:this.textFromFile,value:0},{cls:"cp-from-url",caption:this.textFromUrl,value:1},{caption:this.textFromStorage,value:2}]})}),this.lockedControls.push(this.btnSelectImage),this.btnSelectImage.menu.on("item:click",i.bind(this.onImageSelect,this)),this.btnSelectImage.menu.items[2].setVisible(this.mode.canRequestInsertImage||this.mode.fileChoiceUrl&&this.mode.fileChoiceUrl.indexOf("{documentType}")>-1),this.linkAdvanced=e("#image-advanced-link"),e(this.el).on("click","#image-advanced-link",i.bind(this.openAdvancedSettings,this))},_changeCropState:function(t){this._state.cropMode=t,this.btnCrop&&(this.btnCrop.toggle(t,!0),this.btnCrop.menu.items[0].setChecked(t,!0))},createDelayedElements:function(){this.createDelayedControls(),this.updateMetricUnit(),this._initSettings=!1},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedElements(),this.disableControls(this._locked),t){this._originalProps=new Asc.asc_CImgProperty(t);var e=t.get_WrappingStyle();if(this._state.WrappingStyle!==e){this.cmbWrapType.suspendEvents();var i=this.cmbWrapType.menuPicker.store.findWhere({data:e});this.cmbWrapType.menuPicker.selectRecord(i),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=e}e=t.get_CanBeFlow()&&!this._locked;var n=t.get_FromGroup()||this._locked,o=this.api.asc_IsContentControl()?this.api.asc_GetContentControlProperties():null,s=!!o&&o.get_SpecificType()==Asc.c_oAscContentControlSpecificType.Picture||this._locked;this._state.CanBeFlow===e&&this._state.FromGroup===n&&this._state.isPictureControl===s||(this.cmbWrapType.setDisabled(!e||n||s),this._state.CanBeFlow=e,this._state.FromGroup=n,this._state.isPictureControl=s),e=t.get_Width(),Math.abs(this._state.Width-e)>.001&&(this.labelWidth[0].innerHTML=this.textWidth+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName(),this._state.Width=e),e=t.get_Height(),Math.abs(this._state.Height-e)>.001&&(this.labelHeight[0].innerHTML=this.textHeight+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName(),this._state.Height=e),this.btnOriginalSize.setDisabled(null===t.get_ImageUrl()||void 0===t.get_ImageUrl()||this._locked);var a=t.asc_getPluginGuid();if(e=null!==a&&void 0!==a,this._state.isOleObject!==e&&(this.btnSelectImage.setVisible(!e),this.btnEditObject.setVisible(e),this.btnRotate270.setDisabled(e),this.btnRotate90.setDisabled(e),this.btnFlipV.setDisabled(e),this.btnFlipH.setDisabled(e),this._state.isOleObject=e),this._state.isOleObject){var r=DE.getCollection("Common.Collections.Plugins").findWhere({guid:a});this.btnEditObject.setDisabled(null===r||void 0===r||this._locked)}else this.btnSelectImage.setDisabled(null===a||this._locked)}},_ImgWrapStyleChanged:function(t){if(this.cmbWrapType&&this._state.WrappingStyle!==t){this.cmbWrapType.suspendEvents();var e=this.cmbWrapType.menuPicker.store.findWhere({data:t});this.cmbWrapType.menuPicker.selectRecord(e),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=t}},onSelectWrap:function(t,e){if(this.api){var i=new Asc.asc_CImgProperty,n=e.get("data");if(i.put_WrappingStyle(n),this._state.WrappingStyle===Asc.c_oAscWrapStyle2.Inline&&n!==Asc.c_oAscWrapStyle2.Inline){i.put_PositionH(new Asc.CImagePositionH),i.get_PositionH().put_UseAlign(!1),i.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var o=this._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column);i.get_PositionH().put_Value(o),i.put_PositionV(new Asc.CImagePositionV),i.get_PositionV().put_UseAlign(!1),i.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),o=this._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),i.get_PositionV().put_Value(o)}this.api.ImgApply(i)}this.fireEvent("editcomplete",this)},setOriginalSize:function(){if(this.api){var t=this.api.get_OriginalSizeImage(),e=t.get_ImageWidth(),i=t.get_ImageHeight();this.labelWidth[0].innerHTML=this.textWidth+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName(),this.labelHeight[0].innerHTML=this.textHeight+": "+Common.Utils.Metric.fnRecalcFromMM(i).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName();var n=new Asc.asc_CImgProperty;n.put_Width(e),n.put_Height(i),n.put_ResetCrop(!0),this.api.ImgApply(n),this.fireEvent("editcomplete",this)}},setFitMargins:function(){if(this.api){var t,e,i=this.api.asc_GetSectionProps(),n=this._state.Height>0?this._state.Width/this._state.Height:1,o=this.api.asc_GetCurrentColumnWidth?this.api.asc_GetCurrentColumnWidth():i.get_W()-i.get_LeftMargin()-i.get_RightMargin(),s=i.get_H()-i.get_TopMargin()-i.get_BottomMargin(),a=o/s;n>a?(t=o,e=t/n):n=1){var l=new Asc.CImagePositionH;l.put_UseAlign(!0),l.put_Percent(!1),l.put_RelativeFrom(Asc.c_oAscRelativeFromH.Margin),l.put_Align(Asc.c_oAscAlignH.Left),r.put_PositionH(l)} +n<=1&&(l=new Asc.CImagePositionV,l.put_UseAlign(!0),l.put_Percent(!1),l.put_RelativeFrom(Asc.c_oAscRelativeFromV.Margin),l.put_Align(Asc.c_oAscAlignV.Top),r.put_PositionV(l))}this.api.ImgApply(r),this.fireEvent("editcomplete",this)}},setImageUrl:function(t,e){var i=new Asc.asc_CImgProperty;i.put_ImageUrl(t,e),this.api.ImgApply(i)},insertImageFromStorage:function(t){t&&t.url&&"change"==t.c&&this.setImageUrl(t.url,t.token)},onImageSelect:function(t,e){if(1==e.value){var n=this;new Common.Views.ImageFromUrlDialog({handler:function(t,e){if("ok"==t&&n.api){var o=e.replace(/ /g,"");i.isEmpty(o)||n.setImageUrl(o)}n.fireEvent("editcomplete",n)}}).show()}else if(2==e.value)Common.NotificationCenter.trigger("storage:image-load","change");else{if(this._isFromFile)return;this._isFromFile=!0,this.api&&this.api.ChangeImageFromFile(),this.fireEvent("editcomplete",this),this._isFromFile=!1}},onBtnRotateClick:function(t){var e=new Asc.asc_CImgProperty;e.asc_putRotAdd(3.14159265358979*(1==t.options.value?90:270)/180),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onBtnFlipClick:function(t){var e=new Asc.asc_CImgProperty;1==t.options.value?e.asc_putFlipHInvert(!0):e.asc_putFlipVInvert(!0),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onCrop:function(t,e){this.api&&(t.pressed?this.api.asc_startEditCrop():this.api.asc_endEditCrop()),this.fireEvent("editcomplete",this)},onCropMenu:function(t,e){this.api&&(1==e.value?this.api.asc_cropFill():2==e.value?this.api.asc_cropFit():e.checked?this.api.asc_startEditCrop():this.api.asc_endEditCrop()),this.fireEvent("editcomplete",this)},openAdvancedSettings:function(t){if(!this.linkAdvanced.hasClass("disabled")){var e=this;if(e.api&&!this._locked){var i=e.api.getSelectedElements();if(i&&i.length>0)for(var n,o,s=i.length-1;s>=0;s--)if(n=i[s].get_ObjectType(),o=i[s].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Image==n){var a;e.btnOriginalSize.isDisabled()||(a=e.api.get_OriginalSizeImage())&&(a={width:a.get_ImageWidth(),height:a.get_ImageHeight()}),new DE.Views.ImageSettingsAdvanced({imageProps:o,sizeOriginal:a,api:e.api,sectionProps:e.api.asc_GetSectionProps(),handler:function(t,i){"ok"==t&&e.api&&e.api.ImgApply(i.imageProps),e.fireEvent("editcomplete",e)}}).show();break}}}},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||(this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.linkAdvanced.toggleClass("disabled",t)),this.btnCrop.setDisabled(t||!this.api.asc_canEditCrop()))},textSize:"Size",textWrap:"Wraping Style",textWidth:"Width",textHeight:"Height",textOriginalSize:"Actual Size",textInsert:"Replace Image",textFromUrl:"From URL",textFromFile:"From File",textAdvanced:"Show advanced settings",txtInline:"Inline",txtSquare:"Square",txtTight:"Tight",txtThrough:"Through",txtTopAndBottom:"Top and bottom",txtBehind:"Behind",txtInFront:"In front",textEditObject:"Edit Object",textEdit:"Edit",textFitMargins:"Fit to Margin",textRotation:"Rotation",textRotate90:"Rotate 90°",textFlip:"Flip",textHint270:"Rotate 90° Counterclockwise",textHint90:"Rotate 90° Clockwise",textHintFlipV:"Flip Vertically",textHintFlipH:"Flip Horizontally",textCrop:"Crop",textCropFill:"Fill",textCropFit:"Fit",textFromStorage:"From Storage"},DE.Views.ImageSettings||{}))}),define("text!documenteditor/main/app/template/ChartSettings.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    '}),define("documenteditor/main/app/view/ChartSettings",["text!documenteditor/main/app/template/ChartSettings.template","jquery","underscore","backbone","common/main/lib/component/Button","common/main/lib/component/ComboDataView","documenteditor/main/app/view/ImageSettingsAdvanced"],function(t,e,i,n){"use strict";DE.Views.ChartSettings=n.View.extend(i.extend({el:"#id-chart-settings",template:i.template(t),events:{},options:{alias:"ChartSettings"},initialize:function(){this._initSettings=!0,this._state={WrappingStyle:Asc.c_oAscWrapStyle2.Inline,CanBeFlow:!0,Width:0,Height:0,FromGroup:!1,ChartStyle:1,ChartType:-1,SeveralCharts:!1,DisabledControls:!1},this.lockedControls=[],this._locked=!1,this._noApply=!1,this._originalProps=null,this.render()},render:function(){var t=this.$el||e(this.el);t.html(this.template({scope:this})),this.labelWidth=t.find("#chart-label-width"),this.labelHeight=t.find("#chart-label-height")},setApi:function(t){return this.api=t,this.api&&(this.api.asc_registerCallback("asc_onImgWrapStyleChanged",i.bind(this._ChartWrapStyleChanged,this)),this.api.asc_registerCallback("asc_onUpdateChartStyles",i.bind(this._onUpdateChartStyles,this))),this},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedElements(),this.disableControls(this._locked),t&&t.get_ChartProperties()){this._originalProps=new Asc.asc_CImgProperty(t),this._noApply=!0;var e=t.get_WrappingStyle();if(this._state.WrappingStyle!==e){this.cmbWrapType.suspendEvents();var i=this.cmbWrapType.menuPicker.store.findWhere({data:e});this.cmbWrapType.menuPicker.selectRecord(i),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=e}if(this.chartProps=t.get_ChartProperties(),e=t.get_SeveralCharts()||this._locked,this._state.SeveralCharts!==e&&(this.btnEditData.setDisabled(e),this._state.SeveralCharts=e),e=t.get_SeveralChartTypes(),this._state.SeveralCharts&&e)this.btnChartType.setIconCls("svgicon"),this._state.ChartType=null;else{var n=this.chartProps.getType();if(this._state.ChartType!==n){var o=this.mnuChartTypePicker.store.findWhere({type:n});this.mnuChartTypePicker.selectRecord(o,!0),o?this.btnChartType.setIconCls("svgicon chart-"+o.get("iconCls")):this.btnChartType.setIconCls("svgicon"),this.updateChartStyles(this.api.asc_getChartPreviews(n)),this._state.ChartType=n}}if(e=t.get_SeveralChartStyles(),this._state.SeveralCharts&&e)this.cmbChartStyle.fieldPicker.deselectAll(),this.cmbChartStyle.menuPicker.deselectAll(),this._state.ChartStyle=null;else if(e=this.chartProps.getStyle(),this._state.ChartStyle!==e||this._isChartStylesChanged){this.cmbChartStyle.suspendEvents();var i=this.cmbChartStyle.menuPicker.store.findWhere({data:e});this.cmbChartStyle.menuPicker.selectRecord(i),this.cmbChartStyle.resumeEvents(),this._isChartStylesChanged&&(i?this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(),!0):this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0),!0)),this._state.ChartStyle=e}this._isChartStylesChanged=!1,this._noApply=!1,e=t.get_CanBeFlow()&&!this._locked;var s=t.get_FromGroup()||this._locked;this._state.CanBeFlow===e&&this._state.FromGroup===s||(this.cmbWrapType.setDisabled(!e||s),this._state.CanBeFlow=e,this._state.FromGroup=s),e=t.get_Width(),Math.abs(this._state.Width-e)>.001&&(this.labelWidth[0].innerHTML=this.textWidth+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(1)+" "+Common.Utils.Metric.getCurrentMetricName(),this._state.Width=e),e=t.get_Height(),Math.abs(this._state.Height-e)>.001&&(this.labelHeight[0].innerHTML=this.textHeight+": "+Common.Utils.Metric.fnRecalcFromMM(e).toFixed(1)+" "+Common.Utils.Metric.getCurrentMetricName(),this._state.Height=e)}},updateMetricUnit:function(){var t=Common.Utils.Metric.fnRecalcFromMM(this._state.Width);this.labelWidth[0].innerHTML=this.textWidth+": "+t.toFixed(1)+" "+Common.Utils.Metric.getCurrentMetricName(),t=Common.Utils.Metric.fnRecalcFromMM(this._state.Height),this.labelHeight[0].innerHTML=this.textHeight+": "+t.toFixed(1)+" "+Common.Utils.Metric.getCurrentMetricName()},createDelayedControls:function(){var t=this,n=[{offsetx:0,data:Asc.c_oAscWrapStyle2.Inline,tip:this.txtInline,selected:!0},{offsetx:50,data:Asc.c_oAscWrapStyle2.Square,tip:this.txtSquare},{offsetx:100,data:Asc.c_oAscWrapStyle2.Tight,tip:this.txtTight},{offsetx:150,data:Asc.c_oAscWrapStyle2.Through,tip:this.txtThrough},{offsetx:200,data:Asc.c_oAscWrapStyle2.TopAndBottom,tip:this.txtTopAndBottom},{offsetx:250,data:Asc.c_oAscWrapStyle2.InFront,tip:this.txtInFront},{offsetx:300,data:Asc.c_oAscWrapStyle2.Behind,tip:this.txtBehind}];this.cmbWrapType=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,store:new Common.UI.DataViewStore(n),cls:"combo-chart-style"}),this.cmbWrapType.menuPicker.itemTemplate=this.cmbWrapType.fieldPicker.itemTemplate=i.template(['
    ','',"
    "].join("")),this.cmbWrapType.render(e("#chart-combo-wrap")),this.cmbWrapType.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbWrapType.on("click",i.bind(this.onSelectWrap,this)),this.cmbWrapType.openButton.menu.on("show:after",function(){t.cmbWrapType.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbWrapType),this.btnChartType=new Common.UI.Button({cls:"btn-large-dataview",iconCls:"svgicon chart-column-normal",menu:new Common.UI.Menu({style:"width: 364px; padding-top: 12px;",items:[{template:i.template('')}]})}),this.btnChartType.on("render:after",function(n){t.mnuChartTypePicker=new Common.UI.DataView({el:e("#id-chart-menu-type"),parentMenu:n.menu,restoreHeight:421,groups:new Common.UI.DataViewGroupStore(Common.define.chartData.getChartGroupData()),store:new Common.UI.DataViewStore(Common.define.chartData.getChartData()),itemTemplate:i.template('
    ')})}),this.btnChartType.render(e("#chart-button-type")),this.mnuChartTypePicker.on("item:click",i.bind(this.onSelectType,this,this.btnChartType)),this.lockedControls.push(this.btnChartType),this.btnEditData=new Common.UI.Button({el:e("#chart-button-edit-data")}),this.lockedControls.push(this.btnEditData),this.btnEditData.on("click",i.bind(this.setEditData,this)),this.linkAdvanced=e("#chart-advanced-link"),e(this.el).on("click","#chart-advanced-link",i.bind(this.openAdvancedSettings,this))},createDelayedElements:function(){this.createDelayedControls(),this.updateMetricUnit(),this._initSettings=!1},_ChartWrapStyleChanged:function(t){if(this.cmbWrapType&&this._state.WrappingStyle!==t){this.cmbWrapType.suspendEvents();var e=this.cmbWrapType.menuPicker.store.findWhere({data:t});this.cmbWrapType.menuPicker.selectRecord(e),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=t}},onSelectWrap:function(t,e){if(this.api){var i=new Asc.asc_CImgProperty,n=e.get("data");if(i.put_WrappingStyle(n),this._state.WrappingStyle===Asc.c_oAscWrapStyle2.Inline&&n!==Asc.c_oAscWrapStyle2.Inline){i.put_PositionH(new Asc.CImagePositionH),i.get_PositionH().put_UseAlign(!1),i.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var o=this._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column);i.get_PositionH().put_Value(o),i.put_PositionV(new Asc.CImagePositionV),i.get_PositionV().put_UseAlign(!1),i.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),o=this._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),i.get_PositionV().put_Value(o)}this.api.ImgApply(i)}this.fireEvent("editcomplete",this)},setEditData:function(){var t=DE.getController("Common.Controllers.ExternalDiagramEditor").getView("Common.Views.ExternalDiagramEditor");if(t){t.setEditMode(!0),t.show();var e=this.api.asc_getChartObject();e&&t.setChartData(new Asc.asc_CChartBinary(e))}},openAdvancedSettings:function(t){if(!this.linkAdvanced.hasClass("disabled")){var e=this;if(e.api&&!this._locked){var i=e.api.getSelectedElements();if(i&&i.length>0)for(var n,o,s=i.length-1;s>=0;s--)if(n=i[s].get_ObjectType(),o=i[s].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Image==n){new DE.Views.ImageSettingsAdvanced({imageProps:o,sectionProps:e.api.asc_GetSectionProps(),handler:function(t,i){"ok"==t&&e.api&&e.api.ImgApply(i.imageProps),e.fireEvent("editcomplete",e)}}).show();break}}}},onSelectType:function(t,e,n,o){if(!this._noApply){var s={};if(i.isFunction(o.toJSON)){if(!o.get("selected"))return;s=o.toJSON()}else s=o;if(this.btnChartType.setIconCls("svgicon chart-"+s.iconCls),this._state.ChartType=-1,this.api&&!this._noApply&&this.chartProps){var a=new Asc.asc_CImgProperty;this.chartProps.changeType(s.type),a.put_ChartProperties(this.chartProps),this.api.ImgApply(a)}this.fireEvent("editcomplete",this)}},onSelectStyle:function(t,e){if(!this._noApply){if(this.api&&!this._noApply&&this.chartProps){var i=new Asc.asc_CImgProperty;this.chartProps.putStyle(e.get("data")),i.put_ChartProperties(this.chartProps),this.api.ImgApply(i)}this.fireEvent("editcomplete",this)}},_onUpdateChartStyles:function(){this.api&&null!==this._state.ChartType&&this._state.ChartType>-1&&this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType))},updateChartStyles:function(t){var n=this;if(this._isChartStylesChanged=!0,this.cmbChartStyle||(this.cmbChartStyle=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:270,enableKeyEvents:!0,cls:"combo-chart-style"}),this.cmbChartStyle.render(e("#chart-combo-style")),this.cmbChartStyle.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbChartStyle.on("click",i.bind(this.onSelectStyle,this)),this.cmbChartStyle.openButton.menu.on("show:after",function(){n.cmbChartStyle.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbChartStyle)),t&&t.length>0){var o=this.cmbChartStyle.menuPicker.store;if(o){var s=o.length;if(s>0&&s==t.length){var a=o.models;i.each(t,function(t,e){a[e].set("imageUrl",t.asc_getImage())})}else{var r=[];i.each(t,function(t,e){r.push({imageUrl:t.asc_getImage(),data:t.asc_getName(),tip:n.textStyle+" "+t.asc_getName()})}),o.reset(r,{silent:!1})}}}else this.cmbChartStyle.menuPicker.store.reset(),this.cmbChartStyle.clearComboView();this.cmbChartStyle.setDisabled(!t||t.length<1||this._locked)},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.linkAdvanced.toggleClass("disabled",t))},textSize:"Size",textWrap:"Wrapping Style",textWidth:"Width",textHeight:"Height",textAdvanced:"Show advanced settings",txtInline:"Inline",txtSquare:"Square",txtTight:"Tight",txtThrough:"Through",txtTopAndBottom:"Top and bottom",txtBehind:"Behind",txtInFront:"In front",textEditData:"Edit Data",textChartType:"Change Chart Type",textStyle:"Style"},DE.Views.ChartSettings||{}))}),define("text!documenteditor/main/app/template/TableSettings.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    '}),void 0===Common)var Common={};if(define("common/main/lib/component/ComboBorderSize",["common/main/lib/component/ComboBox"],function(){"use strict";Common.UI.BordersModel=Backbone.Model.extend({defaults:function(){return{value:null,displayValue:null,pxValue:null,id:Common.UI.getId(),offsety:void 0}}}),Common.UI.BordersStore=Backbone.Collection.extend({model:Common.UI.BordersModel}),Common.UI.ComboBorderSize=Common.UI.ComboBox.extend(_.extend({template:_.template(['
    ','
    ','
    ','','","
    "].join("")),initialize:function(t){var e=Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt),i=[{displayValue:"0.5 "+e,value:.5,pxValue:.5,offsety:0},{displayValue:"1 "+e,value:1,pxValue:1,offsety:20},{displayValue:"1.5 "+e,value:1.5,pxValue:2,offsety:40},{displayValue:"2.25 "+e,value:2.25,pxValue:3,offsety:60},{displayValue:"3 "+e,value:3,pxValue:4,offsety:80},{displayValue:"4.5 "+e,value:4.5,pxValue:5,offsety:100},{displayValue:"6 "+e,value:6,pxValue:6,offsety:120}];!1!==t.allowNoBorders&&i.unshift({displayValue:this.txtNoBorders,value:0,pxValue:0}),Common.UI.ComboBox.prototype.initialize.call(this,_.extend({editable:!1,store:new Common.UI.BordersStore,data:i,menuStyle:"min-width: 160px;"},t))},render:function(t){return Common.UI.ComboBox.prototype.render.call(this,t),this},itemClicked:function(t){var e=$(t.currentTarget).parent();this._selectedItem=this.store.findWhere({id:e.attr("id")}),this._selectedItem&&($(".selected",$(this.el)).removeClass("selected"),e.addClass("selected"),this.updateFormControl(this._selectedItem),this.trigger("selected",this,_.extend({},this._selectedItem.toJSON()),t),t.preventDefault())},updateFormControl:function(t){var e=$(this.el).find(".form-control");t.get("value")>0?(e[0].innerHTML="",e.removeClass("text").addClass("image"),e.css("background-position","10px -"+t.get("offsety")+"px")):(e[0].innerHTML=this.txtNoBorders,e.removeClass("image").addClass("text"))},setValue:function(t){if(this._selectedItem=null===t||void 0===t?void 0:_.find(this.store.models,function(e){if(te.attributes.value-.01)return!0}),$(".selected",$(this.el)).removeClass("selected"),this._selectedItem)this.updateFormControl(this._selectedItem),$("#"+this._selectedItem.get("id"),$(this.el)).addClass("selected");else{var e=$(this.el).find(".form-control");e[0].innerHTML="",e.removeClass("image").addClass("text")}},txtNoBorders:"No Borders"},Common.UI.ComboBorderSize||{})),Common.UI.ComboBorderSizeEditable=Common.UI.ComboBox.extend(_.extend({template:_.template(['','','','",""].join("")),initialize:function(t){this.txtNoBorders=t.txtNoBorders||this.txtNoBorders;var e=Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt),i=[{displayValue:"0.5 "+e,value:.5,pxValue:.5,offsety:0},{displayValue:"1 "+e,value:1,pxValue:1,offsety:20},{displayValue:"1.5 "+e,value:1.5,pxValue:2,offsety:40},{displayValue:"2.25 "+e,value:2.25,pxValue:3,offsety:60},{displayValue:"3 "+e,value:3,pxValue:4,offsety:80},{displayValue:"4.5 "+e,value:4.5,pxValue:5,offsety:100},{displayValue:"6 "+e,value:6,pxValue:6,offsety:120}];!1!==t.allowNoBorders&&i.unshift({displayValue:this.txtNoBorders,value:0,pxValue:0}),Common.UI.ComboBox.prototype.initialize.call(this,_.extend({editable:!0,store:new Common.UI.BordersStore,data:i,menuStyle:"min-width: 160px;"},t))},render:function(t){return Common.UI.ComboBox.prototype.render.call(this,t),this},txtNoBorders:"No Borders"},Common.UI.ComboBorderSizeEditable||{})),Common.UI.ComboBorderType=Common.UI.ComboBorderSize.extend(_.extend({template:_.template(['
    ','
    ','
    ','','","
    "].join("")),initialize:function(t){Common.UI.ComboBorderSize.prototype.initialize.call(this,_.extend({store:new Common.UI.BordersStore,data:[{value:Asc.c_oDashType.solid,offsety:140},{value:Asc.c_oDashType.sysDot,offsety:160},{value:Asc.c_oDashType.sysDash,offsety:180},{value:Asc.c_oDashType.dash,offsety:200},{value:Asc.c_oDashType.dashDot,offsety:220},{value:Asc.c_oDashType.lgDash,offsety:240},{value:Asc.c_oDashType.lgDashDot,offsety:260},{value:Asc.c_oDashType.lgDashDotDot,offsety:280}]},t))},render:function(t){return Common.UI.ComboBorderSize.prototype.render.call(this,t),this},updateFormControl:function(t){var e=$(this.el).find(".form-control");e[0].innerHTML="",e.removeClass("text").addClass("image"),e.css("background-position","10px -"+t.get("offsety")+"px")}},Common.UI.ComboBorderType||{})),Common.UI.ComboBoxColor=Common.UI.ComboBox.extend(_.extend({template:_.template(['
    ','
    ','
    ',"
    ",'','","
    "].join("")),itemClicked:function(t){var e=$(t.currentTarget).parent();this._selectedItem=this.store.findWhere({id:e.attr("id")}),this._selectedItem&&($(".selected",$(this.el)).removeClass("selected"),e.addClass("selected"),this.updateFormControl(this._selectedItem),this.trigger("selected",this,_.extend({},this._selectedItem.toJSON()),t),t.preventDefault())},updateFormControl:function(t){ +var e=$(this.el).find(".form-control > div");-1!=t.get("value")?(e[0].innerHTML="",e.css({background:"#"+t.get("value"),"margin-top":"0"})):(e[0].innerHTML=t.get("displayValue"),e.css({background:"","margin-top":"1px"}))},setValue:function(t){var e;if(this._selectedItem=this.store.findWhere((e={},e[this.valueField]=t,e)),$(".selected",$(this.el)).removeClass("selected"),this._selectedItem)this.updateFormControl(this._selectedItem),$("#"+this._selectedItem.get("id"),$(this.el)).addClass("selected");else{var i=$(this.el).find(".form-control > div");i[0].innerHTML="",i.css("background","")}},onResetItems:function(){this.itemsTemplate?$(this.el).find("ul").html($(this.itemsTemplate({items:this.store.toJSON(),scope:this}))):$(this.el).find("ul").html(_.template(["<% _.each(items, function(item) { %>","<% if (item.value==-1) { %>",'
  • <%= scope.getDisplayValue(item) %>
  • ',"<% } else { %>",'
  • ','
    ',"
  • ","<% } %>","<% }); %>"].join(""))({items:this.store.toJSON(),scope:this})),_.isUndefined(this.scroller)||(this.scroller.destroy(),delete this.scroller),this.scroller=new Common.UI.Scroller(_.extend({el:$(".dropdown-menu",this.cmpEl),minScrollbarLength:40,includePadding:!0,wheelSpeed:10,alwaysVisibleY:this.scrollAlwaysVisible},this.options.scroller))}},Common.UI.ComboBoxColor||{}))}),define("documenteditor/main/app/view/TableFormulaDialog",["common/main/lib/component/InputField","common/main/lib/component/Window"],function(){"use strict";DE.Views.TableFormulaDialog=Common.UI.Window.extend(_.extend({options:{width:300,style:"min-width: 230px;",cls:"modal-dlg",buttons:["ok","cancel"]},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
    ','
    ',"","
    ",'
    ','
    ',"","
    ",'
    ','
    ','
    ','
    ',"
    ","
    "].join(""),this.options.tpl=_.template(this.template)(this.options),this.bookmarks=this.options.bookmarks,this.api=this.options.api,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();this.inputFormula=new Common.UI.InputField({el:$("#id-dlg-formula-formula"),allowBlank:!0,validateOnChange:!0,style:"width: 100%;"}).on("changing",_.bind(this.checkFormulaInput,this)),this.cmbFormat=new Common.UI.ComboBox({el:$("#id-dlg-formula-format"),cls:"input-group-nr",menuStyle:"min-width: 100%; max-height: 200px;",takeFocusOnClose:!0}),this.cmbFunction=new Common.UI.ComboBox({el:$("#id-dlg-formula-function"),cls:"input-group-nr",menuStyle:"min-width: 100%; max-height: 150px;",editable:!1,takeFocusOnClose:!0,scrollAlwaysVisible:!0,data:[{displayValue:"ABS",value:1},{displayValue:"AND",value:1},{displayValue:"AVERAGE",value:1},{displayValue:"COUNT",value:1},{displayValue:"DEFINED",value:1},{displayValue:"FALSE",value:0},{displayValue:"IF",value:1},{displayValue:"INT",value:1},{displayValue:"MAX",value:1},{displayValue:"MIN",value:1},{displayValue:"MOD",value:1},{displayValue:"NOT",value:1},{displayValue:"OR",value:1},{displayValue:"PRODUCT",value:1},{displayValue:"ROUND",value:1},{displayValue:"SIGN",value:1},{displayValue:"SUM",value:1},{displayValue:"TRUE",value:0}]}),this.cmbFunction.on("selected",_.bind(function(e,i){e.setValue(this.textInsertFunction);var n=t.inputFormula._input,o=n[0].selectionEnd;n.val(n.val().substring(0,o)+i.displayValue+(i.value?"()":"")+n.val().substring(o)),n.focus(),n[0].selectionStart=n[0].selectionEnd=o+i.displayValue.length+i.value,this.btnOk.setDisabled(!1)},this)),this.cmbFunction.setValue(this.textInsertFunction),this.cmbBookmark=new Common.UI.ComboBox({el:$("#id-dlg-formula-bookmark"),cls:"input-group-nr",menuStyle:"min-width: 100%; max-height: 150px;",editable:!1,takeFocusOnClose:!0}),this.cmbBookmark.on("selected",_.bind(function(e,i){e.setValue(this.textBookmark);var n=t.inputFormula._input,o=n[0].selectionEnd;n.val(n.val().substring(0,o)+i.displayValue+n.val().substring(o)),n.focus(),n[0].selectionStart=n[0].selectionEnd=o+i.displayValue.length,this.btnOk.setDisabled(!1)},this)),this.cmbBookmark.setValue(this.textBookmark),t.btnOk=new Common.UI.Button({el:e.find(".primary")}),e.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.afterRender()},getFocusedComponents:function(){return[this.inputFormula,this.cmbFormat,this.cmbFunction,this.cmbBookmark]},getDefaultFocusableComponent:function(){return this.inputFormula},onSelectItem:function(t,e,i,n){this.btnOk.setDisabled(0==i.get("level")&&i.get("index")>0)},afterRender:function(){this.refreshBookmarks(),this._setDefaults()},_setDefaults:function(){var t=[];_.each(this.api.asc_GetTableFormulaFormats(),function(e){t.push({value:e,displayValue:e})}),this.cmbFormat.setData(t);var e=this.api.asc_ParseTableFormulaInstrLine(this.api.asc_GetTableFormula());this.inputFormula.setValue(e[0]),this.cmbFormat.setValue(e[1]),this.checkFormulaInput(this.inputFormula,this.inputFormula.getValue())},refreshBookmarks:function(){var t=[];if(this.bookmarks){for(var e=this.bookmarks.asc_GetCount(),i=0;i.001)&&(this.numWidth.setValue(null!==e&&void 0!==e?Common.Utils.Metric.fnRecalcFromMM(e):"",!0),this._state.Width=e),e=t.get_RowHeight(),((void 0===this._state.Height||void 0===e)&&this._state.Height!==e||Math.abs(this._state.Height-e)>.001)&&(this.numHeight.setValue(null!==e&&void 0!==e?Common.Utils.Metric.fnRecalcFromMM(e):"",!0),this._state.Height=e),e=t.get_TableStyle(),this._state.TemplateId!==e||this._isTemplatesChanged){var i=this.mnuTableTemplatePicker.store.findWhere({templateId:e});i||(i=this.mnuTableTemplatePicker.store.at(0)),this.btnTableTemplate.suspendEvents(),this.mnuTableTemplatePicker.selectRecord(i,!0),this.btnTableTemplate.resumeEvents(),this.$el.find(".icon-template-table").css({"background-image":"url("+i.get("imageUrl")+")",height:"52px",width:"72px","background-position":"center","background-size":"cover"}),this._state.TemplateId=e}this._isTemplatesChanged=!1;var n=t.get_TableLook();n&&(e=n.get_FirstRow(),this._state.CheckHeader!==e&&(this.chHeader.setValue(e,!0),this._state.CheckHeader=e,this._originalLook.put_FirstRow(e)),e=n.get_LastRow(),this._state.CheckTotal!==e&&(this.chTotal.setValue(e,!0),this._state.CheckTotal=e,this._originalLook.put_LastRow(e)),e=n.get_BandHor(),this._state.CheckBanded!==e&&(this.chBanded.setValue(e,!0),this._state.CheckBanded=e,this._originalLook.put_BandHor(e)),e=n.get_FirstCol(),this._state.CheckFirst!==e&&(this.chFirst.setValue(e,!0),this._state.CheckFirst=e,this._originalLook.put_FirstCol(e)),e=n.get_LastCol(),this._state.CheckLast!==e&&(this.chLast.setValue(e,!0),this._state.CheckLast=e,this._originalLook.put_LastCol(e)),e=n.get_BandVer(),this._state.CheckColBanded!==e&&(this.chColBanded.setValue(e,!0),this._state.CheckColBanded=e,this._originalLook.put_BandVer(e)));var o=t.get_CellsBackground();if(o)if(0==o.get_Value()){var s=o.get_Color();s?s.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.CellColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(s.get_r(),s.get_g(),s.get_b()),effectValue:s.get_value()}}:this.CellColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(s.get_r(),s.get_g(),s.get_b())}:this.CellColor={Value:1,Color:"transparent"}}else this.CellColor={Value:1,Color:"transparent"};else this.CellColor={Value:0,Color:"transparent"};var a=typeof this.CellColor.Color;if(a!==typeof this._state.BackColor||"object"==a&&(this.CellColor.Color.effectValue!==this._state.BackColor.effectValue||this._state.BackColor.color.indexOf(this.CellColor.Color.color)<0)||"object"!=a&&this._state.BackColor.indexOf(this.CellColor.Color)<0){if(this.btnBackColor.setColor(this.CellColor.Color),"object"==typeof this.CellColor.Color){for(var r=!1,l=0;l<10;l++)if(Common.Utils.ThemeColor.ThemeValues[l]==this.CellColor.Color.effectValue){this.colorsBack.select(this.CellColor.Color,!0),r=!0;break}r||this.colorsBack.clearSelection()}else this.colorsBack.select(this.CellColor.Color,!0);this._state.BackColor=this.CellColor.Color}e=t.get_RowsInHeader(),this._state.RepeatRow!==e&&(this.chRepeatRow.setValue(!!e,!0),this.chRepeatRow.setDisabled(null===e),this._state.RepeatRow=e)}},updateMetricUnit:function(){if(this.spinners){for(var t=0;t-1||!i)&&(null!==e.get_Left()&&void 0!==e.get_Left()||e.put_Left(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_Left(),i)),(t.indexOf("t")>-1||!i)&&(null!==e.get_Top()&&void 0!==e.get_Top()||e.put_Top(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_Top(),i)),(t.indexOf("r")>-1||!i)&&(null!==e.get_Right()&&void 0!==e.get_Right()||e.put_Right(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_Right(),i)),(t.indexOf("b")>-1||!i)&&(null!==e.get_Bottom()&&void 0!==e.get_Bottom()||e.put_Bottom(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_Bottom(),i)),(t.indexOf("c")>-1||!i)&&(null!==e.get_InsideV()&&void 0!==e.get_InsideV()||e.put_InsideV(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_InsideV(),i)),(t.indexOf("m")>-1||!i)&&(null!==e.get_InsideH()&&void 0!==e.get_InsideH()||e.put_InsideH(new Asc.asc_CTextBorder),this._UpdateBorderStyle(e.get_InsideH(),i))},_UpdateBorderStyle:function(t,e){if(null==t&&(t=new Asc.asc_CTextBorder),e&&this.BorderSize>0){var i=parseFloat(this.BorderSize);t.put_Value(1),t.put_Size(25.4*i/72);var n=Common.Utils.ThemeColor.getRgbColor(this.btnBorderColor.color);t.put_Color(n)}else t.put_Value(0)},UpdateThemeColors:function(){this._initSettings||(this.btnBackColor||(this.btnBorderColor=new Common.UI.ColorButton({parentEl:e("#table-border-color-btn"),color:"000000"}),this.lockedControls.push(this.btnBorderColor),this.borderColor=this.btnBorderColor.getPicker(),this.btnBackColor=new Common.UI.ColorButton({parentEl:e("#table-back-color-btn"),transparent:!0}),this.lockedControls.push(this.btnBackColor),this.colorsBack=this.btnBackColor.getPicker(),this.btnBackColor.on("color:select",i.bind(this.onColorsBackSelect,this))),this.colorsBack.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.borderColor.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.btnBorderColor.setColor(this.borderColor.getColor()))},_onInitTemplates:function(t){var n=this;this._isTemplatesChanged=!0,this.btnTableTemplate||(this.btnTableTemplate=new Common.UI.Button({cls:"btn-large-dataview template-table",iconCls:"icon-template-table",menu:new Common.UI.Menu({style:"width: 575px;",items:[{template:i.template('')}]})}),this.btnTableTemplate.on("render:after",function(t){n.mnuTableTemplatePicker=new Common.UI.DataView({el:e("#id-table-menu-template"),parentMenu:t.menu,restoreHeight:350,groups:new Common.UI.DataViewGroupStore,store:new Common.UI.DataViewStore,itemTemplate:i.template('
    '),style:"max-height: 350px;"})}),this.btnTableTemplate.render(e("#table-btn-template")),this.lockedControls.push(this.btnTableTemplate),this.mnuTableTemplatePicker.on("item:click",i.bind(this.onTableTemplateSelect,this,this.btnTableTemplate)));var o=n.mnuTableTemplatePicker.store.length;if(o>0&&o==t.length){var s=n.mnuTableTemplatePicker.dataViewItems;s&&i.each(t,function(t,i){var n=t.asc_getImage();s[i].model.set("imageUrl",n,{silent:!0}),e(s[i].el).find("img").attr("src",n)})}else{var a=[];i.each(t,function(t){var e=t.asc_getDisplayName();0==t.asc_getType()&&["Table Grid","Plain Table","Grid Table","List Table","Light","Dark","Colorful","Accent"].forEach(function(t){var i="txtTable_"+t.replace(" ","");n[i]&&(e=e.replace(t,n[i]))}),a.push({imageUrl:t.asc_getImage(),id:Common.UI.getId(),templateId:t.asc_getId(),tip:e})}),n.mnuTableTemplatePicker.store.reset(a)}},openAdvancedSettings:function(t){if(!this.linkAdvanced.hasClass("disabled")){var e=this;if(e.api&&!this._locked){var i=e.api.getSelectedElements();if(i&&i.length>0)for(var n,o,s=i.length-1;s>=0;s--)if(n=i[s].get_ObjectType(),o=i[s].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Table==n){new DE.Views.TableSettingsAdvanced({tableStylerRows:null===o.get_CellBorders().get_InsideH()&&1==o.get_CellSelect()?1:2,tableStylerColumns:null===o.get_CellBorders().get_InsideV()&&1==o.get_CellSelect()?1:2,tableProps:o,borderProps:e.borderAdvancedProps,sectionProps:e.api.asc_GetSectionProps(),handler:function(t,i){"ok"==t&&e.api&&(e.borderAdvancedProps=i.borderProps,e.api.tblApply(i.tableProps)),e.fireEvent("editcomplete",e)}}).show();break}}}},onAddFormula:function(t){var e=this;e.api&&!this._locked&&new DE.Views.TableFormulaDialog({api:e.api,bookmarks:e.api.asc_GetBookmarksManager(),handler:function(t,i){"ok"==t&&e.api&&e.api.asc_AddTableFormula(i),e.fireEvent("editcomplete",e)}}).show()},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.linkAdvanced.toggleClass("disabled",t))},textBorders:"Border's Style",textBorderColor:"Color",textBackColor:"Background color",textEdit:"Rows & Columns",selectRowText:"Select Row",selectColumnText:"Select Column",selectCellText:"Select Cell",selectTableText:"Select Table",insertRowAboveText:"Insert Row Above",insertRowBelowText:"Insert Row Below",insertColumnLeftText:"Insert Column Left",insertColumnRightText:"Insert Column Right",deleteRowText:"Delete Row",deleteColumnText:"Delete Column",deleteTableText:"Delete Table",mergeCellsText:"Merge Cells",splitCellsText:"Split Cell...",splitCellTitleText:"Split Cell",textSelectBorders:"Select borders that you want to change",textAdvanced:"Show advanced settings",txtNoBorders:"No borders",textTemplate:"Select From Template",textRows:"Rows",textColumns:"Columns",textHeader:"Header",textTotal:"Total",textBanded:"Banded",textFirst:"First",textLast:"Last",textEmptyTemplate:"No templates",strRepeatRow:"Repeat as header row at the top of each page",tipTop:"Set Outer Top Border Only",tipLeft:"Set Outer Left Border Only",tipBottom:"Set Outer Bottom Border Only",tipRight:"Set Outer Right Border Only",tipAll:"Set Outer Border and All Inner Lines",tipNone:"Set No Borders",tipInner:"Set Inner Lines Only",tipInnerVert:"Set Vertical Inner Lines Only",tipInnerHor:"Set Horizontal Inner Lines Only",tipOuter:"Set Outer Border Only",textCellSize:"Rows & Columns Size",textHeight:"Height",textWidth:"Width",textDistributeRows:"Distribute rows",textDistributeCols:"Distribute columns",textAddFormula:"Add formula",txtTable_TableGrid:"Table Grid",txtTable_PlainTable:"Plain Table",txtTable_GridTable:"Grid Table",txtTable_ListTable:"List Table",txtTable_Light:"Light",txtTable_Dark:"Dark",txtTable_Colorful:"Colorful",txtTable_Accent:"Accent"},DE.Views.TableSettings||{}))}),define("text!documenteditor/main/app/template/ShapeSettings.template",[],function(){ return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    '}),void 0===Common)var Common={};if(define("common/main/lib/component/Slider",["common/main/lib/component/BaseView","underscore"],function(t,e){"use strict";Common.UI.SingleSlider=Common.UI.BaseView.extend({options:{width:100,minValue:0,maxValue:100,step:1,value:100,enableKeyEvents:!1},disabled:!1,template:e.template(['
    ','
    ','
    ','
    ','
    ',"
    ",'
    ',"<% if (this.options.enableKeyEvents) { %>",'',"<% } %>","
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;e.width=e.options.width,e.minValue=e.options.minValue,e.maxValue=e.options.maxValue,e.delta=100/(e.maxValue-e.minValue),e.step=e.options.step,e.options.el&&e.render(),this.setValue(e.options.value)},render:function(t){var i=this;i.rendered?this.cmpEl=i.$el:(this.cmpEl=$(this.template({})),t?(this.setElement(t,!1),t.html(this.cmpEl)):i.$el.html(this.cmpEl)),this.cmpEl.find(".track-center").width(i.options.width-14),this.cmpEl.width(i.options.width),this.thumb=this.cmpEl.find(".thumb");var n,o=function(t){t.preventDefault(),t.stopPropagation();var e=Math.max(0,Math.min(100,Math.round((t.pageX*Common.Utils.zoom()-i.cmpEl.offset().left-i._dragstart)/i.width*100)));i.setThumbPosition(e),i.lastValue=i.value,i.value=e/i.delta+i.minValue,i.thumb.removeClass("active"),$(document).off("mouseup",o),$(document).off("mousemove",s),i._dragstart=void 0,i.trigger("changecomplete",i,i.value,i.lastValue)},s=function(t){if(!i.disabled&&void 0!==i._dragstart){t.preventDefault(),t.stopPropagation();var e=Math.max(0,Math.min(100,Math.round((t.pageX*Common.Utils.zoom()-i.cmpEl.offset().left-i._dragstart)/i.width*100)));i.setThumbPosition(e),i.lastValue=i.value,i.value=e/i.delta+i.minValue,Math.abs(i.value-i.lastValue)>.001&&i.trigger("change",i,i.value,i.lastValue)}},a=function(t){i.disabled||(i._dragstart=t.pageX*Common.Utils.zoom()-i.thumb.offset().left-7,i.thumb.addClass("active"),$(document).on("mouseup",o),$(document).on("mousemove",s),i.options.enableKeyEvents&&setTimeout(function(){i.input.focus()},10))},r=function(t){if(!i.disabled){var e=Math.max(0,Math.min(100,Math.round((t.pageX*Common.Utils.zoom()-i.cmpEl.offset().left)/i.width*100)));i.setThumbPosition(e),i.lastValue=i.value,i.value=e/i.delta+i.minValue,i.trigger("change",i,i.value,i.lastValue),i.trigger("changecomplete",i,i.value,i.lastValue)}},l=function(t){i.lastValue=i.value,i.value=Math.max(i.minValue,Math.min(i.maxValue,i.value+(t?i.step:-i.step))),i.setThumbPosition(Math.round((i.value-i.minValue)*i.delta)),i.trigger("change",i,i.value,i.lastValue)},c=function(t){i.disabled||t.keyCode!=Common.UI.Keys.UP&&t.keyCode!=Common.UI.Keys.DOWN&&t.keyCode!=Common.UI.Keys.LEFT&&t.keyCode!=Common.UI.Keys.RIGHT||(t.preventDefault(),t.stopPropagation(),h.off("keydown","input",c),n=setInterval(e.bind(l,i,t.keyCode==Common.UI.Keys.UP||t.keyCode==Common.UI.Keys.RIGHT),100))},d=function(t){i.disabled||(t.keyCode==Common.UI.Keys.UP||t.keyCode==Common.UI.Keys.DOWN||Common.UI.Keys.LEFT||Common.UI.Keys.RIGHT)&&(t.stopPropagation(),t.preventDefault(),clearInterval(n),l(t.keyCode==Common.UI.Keys.UP||t.keyCode==Common.UI.Keys.RIGHT),h.on("keydown","input",c),i.trigger("changecomplete",i,i.value,i.lastValue))};if(!i.rendered){var h=i.cmpEl;h.on("mousedown",".thumb",a),h.on("mousedown",".track",r),this.options.enableKeyEvents&&(h.on("keydown","input",c),h.on("keyup","input",d))}return i.rendered=!0,this},setThumbPosition:function(t){this.thumb.css({left:t+"%"})},setValue:function(t){this.lastValue=this.value,this.value=Math.max(this.minValue,Math.min(this.maxValue,t)),this.setThumbPosition(Math.round((t-this.minValue)*this.delta))},getValue:function(){return this.value},setDisabled:function(t){t!==this.disabled&&this.cmpEl.toggleClass("disabled",t),this.disabled=t}}),Common.UI.MultiSlider=Common.UI.BaseView.extend({options:{width:100,minValue:0,maxValue:100,values:[0,100],thumbTemplate:'
    '},disabled:!1,template:e.template(['
    ','
    ','
    ','
    ','
    ',"
    ","<% _.each(items, function(item) { %>","<%= thumbTemplate %>","<% }); %>","
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;e.width=e.options.width,e.minValue=e.options.minValue,e.maxValue=e.options.maxValue,e.delta=100/(e.maxValue-e.minValue),e.thumbs=[],e.options.el&&e.render()},render:function(t){var i=this;i.rendered?this.cmpEl=this.$el:(this.cmpEl=$(this.template({items:this.options.values,thumbTemplate:this.options.thumbTemplate})),t?(this.setElement(t,!1),t.html(this.cmpEl)):this.$el.html(this.cmpEl));var n=this.cmpEl;n.find(".track-center").width(i.options.width-14),n.width(i.options.width);var o=function(t){t.preventDefault(),t.stopPropagation();var n=t.data.index,o=i.thumbs[n].value,s=n-1<0?0:i.thumbs[n-1].position,a=n+1a,c=Math.max(0,Math.min(100,r)),d=c/i.delta+i.minValue;if(i.isRemoveThumb){if(i.thumbs.length<3)return $(document).off("mouseup",i.binding.onMouseUp),$(document).off("mousemove",i.binding.onMouseMove),void(i._dragstart=void 0);i.trigger("removethumb",i,e.findIndex(i.thumbs,{index:n})),i.trigger("change",i,d,o),i.trigger("changecomplete",i,d,o)}else i.setThumbPosition(n,c),i.thumbs[n].value=d,l&&i.sortThumbs();$(document).off("mouseup",i.binding.onMouseUp),$(document).off("mousemove",i.binding.onMouseMove),i._dragstart=void 0,!i.isRemoveThumb&&i.trigger("changecomplete",i,d,o),i.isRemoveThumb=void 0},s=function(t){if(!i.disabled&&void 0!==i._dragstart){t.preventDefault(),t.stopPropagation();var e=t.data.index,n=i.thumbs[e].value,o=e-1<0?0:i.thumbs[e-1].position,s=e+1s,l=Math.max(0,Math.min(100,a)),c=l/i.delta+i.minValue;i.setThumbPosition(e,l),i.thumbs[e].value=c,r&&i.sortThumbs();var d=t.pageY*Common.Utils.zoom()-i.cmpEl.offset().top;i.isRemoveThumb=d>i.cmpEl.height()||d<0,i.setRemoveThumb(e,i.isRemoveThumb),Math.abs(c-n)>.001&&i.trigger("change",i,c,n)}},a=function(t){if(!i.disabled){var n=t.data.index,o=i.thumbs[n].thumb;i._dragstart=t.pageX*Common.Utils.zoom()-o.offset().left-o.width()/2,i.setActiveThumb(n),e.each(i.thumbs,function(t,e){n==e?t.thumb.css("z-index",500):t.thumb.css("z-index","")}),$(document).on("mouseup",null,t.data,i.binding.onMouseUp),$(document).on("mousemove",null,t.data,i.binding.onMouseMove)}},r=function(t){if(!(i.disabled||!e.isUndefined(i._dragstart)||i.thumbs.length>9)){var n=Math.max(0,Math.min(100,Math.round((t.pageX*Common.Utils.zoom()-i.cmpEl.offset().left)/i.width*100))),o=l(n),s=(i.thumbs[o].colorValue,i.thumbs[o].value,n/i.delta+i.minValue);i.addThumb();var a=i.thumbs.length-1;i.setThumbPosition(a,n),i.thumbs[a].value=s,i.trigger("addthumb",i,a,n),i.trigger("change",i),i.trigger("changecomplete",i)}},l=function(t){for(var e,n=100,o=0,s=i.thumbs.length,a=0;ar.position)continue;o=a,n=e}return o};return this.binding={onMouseUp:e.bind(o,this),onMouseMove:e.bind(s,this),onMouseDown:e.bind(a,this)},this.$thumbs=n.find(".thumb"),e.each(this.$thumbs,function(t,e){var n=$(t);i.thumbs.push({thumb:n,index:e}),i.setValue(e,i.options.values[e]),n.on("mousedown",null,i.thumbs[e],i.binding.onMouseDown)}),i.setActiveThumb(0,!0),i.rendered||n.on("mouseup",".track",r),i.rendered=!0,this},setActiveThumb:function(t,e){this.currentThumb=t,this.$thumbs=this.cmpEl.find(".thumb"),this.$thumbs.removeClass("active"),this.thumbs[t].thumb.addClass("active"),!0!==e&&this.trigger("thumbclick",this,t)},setRemoveThumb:function(t,i){-1!==e.findIndex(this.thumbs,{index:t})&&(i&&this.thumbs.length>2?this.$el.find(".active").addClass("remove"):this.$el.find(".remove").removeClass("remove"))},setThumbPosition:function(t,e){this.thumbs[t].position=e,this.thumbs[t].thumb.css({left:e+"%"})},setValue:function(t,e){this.thumbs[t].value=Math.max(this.minValue,Math.min(this.maxValue,e)),this.setThumbPosition(t,Math.round((e-this.minValue)*this.delta))},getValue:function(t){return this.thumbs[t].value},getValues:function(){var t=[];return e.each(this.thumbs,function(e){t.push(e.value)}),t},setDisabled:function(t){t!==this.disabled&&this.cmpEl.toggleClass("disabled",t),this.disabled=t},sortThumbs:function(){this.thumbs.sort(function(t,e){return t.position-e.position});var t=[];return e.each(this.thumbs,function(e,i){t.push(e.index),e.index=i}),t},setThumbs:function(t){var e=this.thumbs.length;if(e!=t)for(var i=0;i0&&this.setValue(i,this.getValue(i-1)),e.on("mousedown",null,this.thumbs[i],this.binding.onMouseDown)},removeThumb:function(t){void 0===t&&(t=this.thumbs.length-1),t>0&&(this.thumbs[t].thumb.remove(),this.thumbs.splice(t,1))}})}),void 0===Common)var Common={};if(define("common/main/lib/component/MultiSliderGradient",["common/main/lib/component/Slider","underscore"],function(t,e){"use strict";Common.UI.MultiSliderGradient=Common.UI.MultiSlider.extend({options:{width:100,minValue:0,maxValue:100,values:[0,100],colorValues:["#000000","#ffffff"],currentThumb:0,thumbTemplate:'
    '},disabled:!1,template:e.template(['
    ','
    ',"<% _.each(items, function(item) { %>","<%= thumbTemplate %>","<% }); %>","
    "].join("")),initialize:function(t){this.styleStr={},Common.UI.MultiSlider.prototype.initialize.call(this,t)},render:function(t){Common.UI.MultiSlider.prototype.render.call(this,t);var i=this;i.trackEl=i.cmpEl.find(".track");for(var n=0;n div"),i.setColorValue(i.options.colorValues[n],n);i.changeSliderStyle(),i.changeGradientStyle(),i.on("change",e.bind(i.changeGradientStyle,i))},setColorValue:function(t,e){var i=void 0!==e?e:this.currentThumb;this.thumbs[i].colorValue=t,this.thumbs[i].thumbcolor.css("background-color",t),this.changeGradientStyle()},getColorValue:function(t){var e=void 0!==t?t:this.currentThumb;return this.thumbs[e].colorValue},setValue:function(t,e){Common.UI.MultiSlider.prototype.setValue.call(this,t,e),this.changeGradientStyle()},getColorValues:function(){var t=[];return e.each(this.thumbs,function(e){t.push(e.colorValue)}),t},changeGradientStyle:function(){if(this.rendered){var t;this.styleStr.specific&&(t=Common.Utils.String.format(this.styleStr.specific,this.getColorValues().concat(this.getValues())),this.trackEl.css("background",t)),Common.Utils.isIE&&(t=Common.Utils.String.format("progid:DXImageTransform.Microsoft.gradient( startColorstr={0}, endColorstr={1},GradientType=1 )",this.getColorValue(0),this.getColorValue(this.thumbs.length-1)),this.trackEl.css("filter",t)),this.styleStr.common&&(t=Common.Utils.String.format(this.styleStr.common,this.getColorValues().concat(this.getValues())),this.trackEl.css("background",t))}},sortThumbs:function(){var t=Common.UI.MultiSlider.prototype.sortThumbs.call(this);return this.trigger("sortthumbs",this,t),t},findLeftThumb:function(t){for(var e,i=this,n=100,o=0,s=this.thumbs.length,a=0;a0&&e<=n){var r=i.thumbs[a+1],l=i.thumbs[a-1];if(void 0!==l&&tr.position)continue;o=a,n=e}return o},calculationNewColor:function(t,e,i){var n=i?i/100:.5,o=1-n,s=Common.Utils.ThemeColor.getRgbColor(t),a=Common.Utils.ThemeColor.getRgbColor(e),r=[Math.round(s.get_r()*o+a.get_r()*n),Math.round(s.get_g()*o+a.get_g()*n),Math.round(s.get_b()*o+a.get_b()*n)];return Common.Utils.ThemeColor.getHexColor(r[0],r[1],r[2])},addThumb:function(){Common.UI.MultiSlider.prototype.addThumb.call(this);var t=this,e=t.thumbs.length-1;t.thumbs[e].thumb.on("dblclick",null,function(){t.trigger("thumbdblclick",t)}),t.thumbs[e].thumbcolor=t.thumbs[e].thumb.find("> div"),e>0&&this.setColorValue(this.getColorValue(e-1),e),t.changeSliderStyle()},addNewThumb:function(t,i,n){var o,s=this,a=this.findLeftThumb(i),t=t;if(e.isUndefined(n)){var r=100*(i-this.thumbs[a].value)/(this.thumbs[a+1].value-this.thumbs[a].value);o=r<0?this.thumbs[a].colorValue:this.calculationNewColor(this.thumbs[a].colorValue,this.thumbs[a===t-1?a:a+1].colorValue,r)}else{this.addThumb(),t=this.thumbs.length-1,o=this.calculationNewColor(this.thumbs[a].colorValue,this.thumbs[a===t-1?a:a+1].colorValue),this.setThumbPosition(t,i);var l=i/this.delta+this.minValue;this.thumbs[t].value=l}return s.thumbs[t].thumbcolor=s.thumbs[t].thumb.find("> div"),t>0&&this.setColorValue("#"+o,t),s.sortThumbs(),s.changeSliderStyle(),s.changeGradientStyle(),o},removeThumb:function(t){void 0===t&&(t=this.thumbs.length-1),this.thumbs.length>2&&(this.thumbs[t].thumb.remove(),this.thumbs.splice(t,1),this.sortThumbs(),this.changeSliderStyle())},changeSliderStyle:function(){this.styleStr={specific:"",common:"linear-gradient(to right"},Common.Utils.isChrome&&Common.Utils.chromeVersion<10||Common.Utils.isSafari&&Common.Utils.safariVersion<5.1?this.styleStr.specific="-webkit-gradient(linear, left top, right top":Common.Utils.isChrome||Common.Utils.isSafari?this.styleStr.specific="-webkit-linear-gradient(left":Common.Utils.isGecko?this.styleStr.specific="-moz-linear-gradient(left":Common.Utils.isOpera&&Common.Utils.operaVersion>11?this.styleStr.specific="-o-linear-gradient(left":Common.Utils.isIE&&(this.styleStr.specific="-ms-linear-gradient(left");for(var t=0;t=0?this.btnDirection.setIconCls("item-gradient "+this._viewDataRadial[this.GradRadialDirectionIdx].iconcls):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(0,!0),this.numGradientAngle.setDisabled(!0));if(this.api&&!this._noApply){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad),n.get_fill().put_grad_type(this.GradFillType),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),i.put_fill(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onSelectGradient:function(t,e,n,o){if(!this._noApply){var s={};if(i.isFunction(o.toJSON)){if(!o.get("selected"))return;s=o.toJSON()}else s=o;if(this.btnDirection.setIconCls("item-gradient "+s.iconcls),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR?this.GradLinearDirectionType=s.type:this.GradRadialDirectionIdx=0,this.api&&this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){this.numGradientAngle.setValue(s.type,!0);var a=new Asc.asc_CShapeProperty,r=new Asc.asc_CShapeFill;r.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),r.put_fill(new Asc.asc_CFillGrad),r.get_fill().put_grad_type(this.GradFillType),r.get_fill().put_linear_angle(6e4*s.type),r.get_fill().put_linear_scale(!0),a.put_fill(r),this.imgprops.put_ShapeProperties(a),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)}},onColorsGradientSelect:function(t,e){if(this.GradColor.colors[this.GradColor.currentIdx]=e,this.sldrGradient.setColorValue(Common.Utils.String.format("#{0}","object"==typeof e?e.color:e)),this.api&&!this._noApply){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad),n.get_fill().put_grad_type(this.GradFillType);var o=[];this.GradColor.colors.forEach(function(t){o.push(Common.Utils.ThemeColor.getRgbColor(t))}),n.get_fill().put_colors(o),this.OriginalFillType!==Asc.c_oAscFill.FILL_TYPE_GRAD&&(this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),o=[],this.GradColor.values.forEach(function(t){o.push(1e3*t)}),n.get_fill().put_positions(o)),i.put_fill(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onGradientChange:function(t,e,n){this.GradColor.values=t.getValues(),this.spnGradPosition.setValue(this.GradColor.values[this.GradColor.currentIdx],!0),this._sliderChanged=!0,this.api&&!this._noApply&&this._sendUndoPoint&&(this.api.setStartPointHistory(),this._sendUndoPoint=!1,this.updateslider=setInterval(i.bind(this._gradientApplyFunc,this),100))},onGradientChangeComplete:function(t,e,i){clearInterval(this.updateslider),this._sliderChanged=!0,this._sendUndoPoint||(this.api.setEndPointHistory(),this._gradientApplyFunc()),this._sendUndoPoint=!0},_gradientApplyFunc:function(){if(this._sliderChanged){var t=new Asc.asc_CShapeProperty,e=new Asc.asc_CShapeFill;e.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),e.put_fill(new Asc.asc_CFillGrad),e.get_fill().put_grad_type(this.GradFillType);var i=[];this.GradColor.values.forEach(function(t){i.push(1e3*t)}),e.get_fill().put_positions(i),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(e.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),e.get_fill().put_linear_scale(!0)),i=[],this.GradColor.colors.forEach(function(t){i.push(Common.Utils.ThemeColor.getRgbColor(t))}),e.get_fill().put_colors(i),t.put_fill(e),this.imgprops.put_ShapeProperties(t),this.api.ImgApply(this.imgprops),this._sliderChanged=!1}},applyBorderSize:function(t){if(t=Common.Utils.String.parseFloat(t),t=isNaN(t)?0:Math.max(0,Math.min(1584,t)),this.BorderSize=t,this.api&&!this._noApply){var e=new Asc.asc_CShapeProperty,i=new Asc.asc_CStroke;this.BorderSize<1e-5?(i.put_type(Asc.c_oAscStrokeType.STROKE_NONE),this._state.StrokeType=this._state.StrokeWidth=-1):(i.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),"transparent"==this.BorderColor.Color||"transparent"==this.BorderColor.Color.color?i.put_color(Common.Utils.ThemeColor.getRgbColor({color:"000000",effectId:29})):this._state.StrokeType!=Asc.c_oAscStrokeType.STROKE_NONE&&null!==this._state.StrokeType||i.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(this.BorderColor.Color))),i.asc_putPrstDash(this.BorderType),i.put_width(this._pt2mm(this.BorderSize))),e.put_stroke(i),this.imgprops.put_ShapeProperties(e),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onComboBlur:function(){this.fireEvent("editcomplete",this)},onBorderSizeChanged:function(t,e,n,o){var s=this;if(t){var a=parseFloat(n.value);(!new RegExp("^\\s*(\\d*(\\.|,)?\\d+)\\s*("+s.txtPt+")?\\s*$").exec(n.value)||a<0||a>1584)&&(this._state.StrokeType=this._state.StrokeWidth=-1,Common.UI.error({msg:this.textBorderSizeErr,callback:function(){i.defer(function(t){s.fireEvent("editcomplete",s)})}}))}else this.applyBorderSize(n.value)},onBorderSizeSelect:function(t,e){this.applyBorderSize(e.value)},onBorderTypeSelect:function(t,e){if(this.BorderType=e.value,this.api&&!this._noApply){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CStroke;this.BorderSize<1e-5?n.put_type(Asc.c_oAscStrokeType.STROKE_NONE):(n.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),n.put_color(Common.Utils.ThemeColor.getRgbColor(this.BorderColor.Color)),n.put_width(this._pt2mm(this.BorderSize)),n.asc_putPrstDash(this.BorderType)),i.put_stroke(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onColorsBorderSelect:function(t,e){if(this.BorderColor={Value:1,Color:e},this.api&&this.BorderSize>0&&!this._noApply){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CStroke;this.BorderSize<1e-5?n.put_type(Asc.c_oAscStrokeType.STROKE_NONE):(n.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),n.put_color(Common.Utils.ThemeColor.getRgbColor(this.BorderColor.Color)),n.put_width(this._pt2mm(this.BorderSize)),n.asc_putPrstDash(this.BorderType)),i.put_stroke(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},_ImgWrapStyleChanged:function(t){if(this.cmbWrapType&&this._state.WrappingStyle!==t){this.cmbWrapType.suspendEvents();var e=this.cmbWrapType.menuPicker.store.findWhere({data:t});this.cmbWrapType.menuPicker.selectRecord(e),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=t}},onSelectWrap:function(t,e){if(this.api){var i=new Asc.asc_CImgProperty,n=e.get("data");if(i.put_WrappingStyle(n),this._state.WrappingStyle===Asc.c_oAscWrapStyle2.Inline&&n!==Asc.c_oAscWrapStyle2.Inline){i.put_PositionH(new Asc.CImagePositionH),i.get_PositionH().put_UseAlign(!1),i.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var o=this._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column);i.get_PositionH().put_Value(o),i.put_PositionV(new Asc.CImagePositionV),i.get_PositionV().put_UseAlign(!1),i.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),o=this._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),i.get_PositionV().put_Value(o)}this.api.ImgApply(i)}this.fireEvent("editcomplete",this)},setImageUrl:function(t,e){if(null!==this.BlipFillType){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_BLIP),n.put_fill(new Asc.asc_CFillBlip),n.get_fill().put_type(this.BlipFillType),n.get_fill().put_url(t,e),i.put_fill(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}},insertImageFromStorage:function(t){t&&t.url&&"fill"==t.c&&this.setImageUrl(t.url,t.token)},onImageSelect:function(t,e){if(1==e.value){var n=this;new Common.Views.ImageFromUrlDialog({handler:function(t,e){if("ok"==t&&n.api){var o=e.replace(/ /g,"");i.isEmpty(o)||n.setImageUrl(o)}n.fireEvent("editcomplete",n)}}).show()}else 2==e.value?Common.NotificationCenter.trigger("storage:image-load","fill"):(this.api&&this.api.ChangeShapeImageFromFile(this.BlipFillType),this.fireEvent("editcomplete",this))},openAdvancedSettings:function(t){if(!this.linkAdvanced.hasClass("disabled")){var e=this;if(e.api&&!this._locked){var i=e.api.getSelectedElements();if(i&&i.length>0)for(var n,o,s=i.length-1;s>=0;s--)if(n=i[s].get_ObjectType(),o=i[s].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Image==n){new DE.Views.ImageSettingsAdvanced({imageProps:o,sectionProps:e.api.asc_GetSectionProps(),handler:function(t,i){"ok"==t&&e.api&&e.api.ImgApply(i.imageProps),e.fireEvent("editcomplete",e)}}).show();break}}}},ChangeSettings:function(t){if(null==this.imgprops?this.imgprops=new Asc.asc_CImgProperty:this.imgprops.put_ImageUrl(null),this._initSettings&&this.createDelayedElements(),t&&t.get_ShapeProperties()){var n=t.get_ShapeProperties(),o=n.asc_getType();this._originalProps=new Asc.asc_CImgProperty(t),this._noApply=!0,this.disableControls(this._locked,!n.get_CanFill()),this.hideShapeOnlySettings(n.get_FromChart()||n.get_FromImage());var s=n.get_FromChart()||"line"==o||"bentConnector2"==o||"bentConnector3"==o||"bentConnector4"==o||"bentConnector5"==o||"curvedConnector2"==o||"curvedConnector3"==o||"curvedConnector4"==o||"curvedConnector5"==o||"straightConnector1"==o;this.hideChangeTypeSettings(s),this._state.isFromImage=!!n.get_FromImage(),!s&&this.btnChangeShape.menu.items.length&&(this.btnChangeShape.menu.items[0].setVisible(n.get_FromImage()),this.btnChangeShape.menu.items[1].setVisible(!n.get_FromImage()));var a=t.get_WrappingStyle();if(this._state.WrappingStyle!==a){this.cmbWrapType.suspendEvents();var r=this.cmbWrapType.menuPicker.store.findWhere({data:a});this.cmbWrapType.menuPicker.selectRecord(r),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=a}a=t.get_CanBeFlow()&&!this._locked;var l=t.get_FromGroup()||this._locked;this._state.CanBeFlow===a&&this._state.FromGroup===l||(this.cmbWrapType.setDisabled(!a||l),this._state.CanBeFlow=a,this._state.FromGroup=l);var r=null,c=n.get_fill(),d=c.get_type(),h=null,p=c.get_transparent();if((Math.abs(this._state.Transparency-p)>.001||Math.abs(this.numTransparency.getNumberValue()-p)>.001||(null===this._state.Transparency||null===p)&&(this._state.Transparency!==p||this.numTransparency.getNumberValue()!==p))&&(void 0!==p&&(this.sldrTransparency.setValue(null===p?100:p/255*100,!0),this.numTransparency.setValue(this.sldrTransparency.getValue(),!0)),this._state.Transparency=p),null===c||null===d)this.OriginalFillType=null;else if(d==Asc.c_oAscFill.FILL_TYPE_NOFILL)this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_NOFILL;else if(d==Asc.c_oAscFill.FILL_TYPE_SOLID)c=c.get_fill(),h=c.get_color(),h?h.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.ShapeColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b()),effectValue:h.get_value()}}:this.ShapeColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b())}:this.ShapeColor={Value:0,Color:"transparent"},this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_SOLID,this.FGColor="transparent"!==this.ShapeColor.Color?{Value:1,Color:Common.Utils.ThemeColor.colorValue2EffectId(this.ShapeColor.Color)}:{Value:1,Color:"000000"},this.BGColor={Value:1,Color:"ffffff"},this.GradColor.colors[0]="transparent"!==this.ShapeColor.Color?Common.Utils.ThemeColor.colorValue2EffectId(this.ShapeColor.Color):"000000",this.GradColor.colors[this.GradColor.colors.length-1]="ffffff";else if(d==Asc.c_oAscFill.FILL_TYPE_BLIP)c=c.get_fill(),this.BlipFillType=c.get_type(),this._state.BlipFillType!==this.BlipFillType&&(this.BlipFillType==Asc.c_oAscFillBlipType.STRETCH||this.BlipFillType==Asc.c_oAscFillBlipType.TILE?this.cmbFillType.setValue(this.BlipFillType):this.cmbFillType.setValue(""),this._state.BlipFillType=this.BlipFillType),this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_BLIP;else if(d==Asc.c_oAscFill.FILL_TYPE_PATT){if(c=c.get_fill(),this.PatternFillType=c.get_pattern_type(),this._state.PatternFillType!==this.PatternFillType){this.cmbPattern.suspendEvents();var r=this.cmbPattern.menuPicker.store.findWhere({type:this.PatternFillType});this.cmbPattern.menuPicker.selectRecord(r),this.cmbPattern.resumeEvents(),this._state.PatternFillType=this.PatternFillType}h=c.get_color_fg(),h?h.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.FGColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b()),effectValue:h.get_value()}}:this.FGColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b())}:this.FGColor={Value:1,Color:"000000"},h=c.get_color_bg(),h?h.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.BGColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b()),effectValue:h.get_value()}}:this.BGColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b())}:this.BGColor={Value:1,Color:"ffffff"},this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_PATT,this.ShapeColor={Value:1,Color:Common.Utils.ThemeColor.colorValue2EffectId(this.FGColor.Color)},this.GradColor.colors[0]=Common.Utils.ThemeColor.colorValue2EffectId(this.FGColor.Color),this.GradColor.colors[this.GradColor.colors.length-1]="ffffff"}else if(d==Asc.c_oAscFill.FILL_TYPE_GRAD){c=c.get_fill();var m=c.get_grad_type();if(this._state.GradFillType===m&&this.GradFillType===m||(this.GradFillType=m,r=void 0,this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR||this.GradFillType==Asc.c_oAscFillGradType.GRAD_PATH?(this.cmbGradType.setValue(this.GradFillType),r=this.cmbGradType.store.findWhere({value:this.GradFillType}),this.onGradTypeSelect(this.cmbGradType,r.attributes)):(this.cmbGradType.setValue(""),this.btnDirection.setIconCls("")),this._state.GradFillType=this.GradFillType),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){var a=Math.floor(c.get_linear_angle()/6e4);if(Math.abs(this.GradLinearDirectionType-a)>.001){this.GradLinearDirectionType=a;var u=this.mnuDirectionPicker.store.findWhere({type:a});this.mnuDirectionPicker.selectRecord(u,!0),u?this.btnDirection.setIconCls("item-gradient "+u.get("iconcls")):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(a,!0)}}else this.numGradientAngle.setValue(0,!0);var g=this,b=c.get_colors(),f=c.get_positions(),C=b?b.length:this.GradColor.colors.length;this.sldrGradient.setThumbs(C),this.GradColor.colors.length>C&&(this.GradColor.colors.splice(C,this.GradColor.colors.length-C),this.GradColor.values.splice(C,this.GradColor.colors.length-C),this.GradColor.currentIdx=0),b&&b.forEach(function(t,e){t?t.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?(g.GradColor.colors[e]={color:Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()),effectValue:t.get_value()},Common.Utils.ThemeColor.colorValue2EffectId(g.GradColor.colors[e])):g.GradColor.colors[e]=Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()):g.GradColor.colors[e]="000000";var i=f[e];null!==i&&(i/=1e3,g.GradColor.values[e]=i)});for(var v=0;v=this.GradColor.colors.length)&&(g.GradColor.currentIdx=0),g.sldrGradient.setActiveThumb(g.GradColor.currentIdx),this.spnGradPosition.setValue(this.GradColor.values[this.GradColor.currentIdx]),this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_GRAD,this.FGColor={Value:1,Color:this.GradColor.colors[0]},this.BGColor={Value:1,Color:"ffffff"},this.ShapeColor={Value:1,Color:this.GradColor.colors[0]}}this._state.FillType!==this.OriginalFillType&&(this.cmbFillSrc.setValue(null===this.OriginalFillType?"":this.OriginalFillType),this._state.FillType=this.OriginalFillType,this.ShowHideElem(this.OriginalFillType)),e(this.btnTexture.el).find(".form-control").prop("innerHTML",this.textSelectTexture);var _=typeof this.ShapeColor.Color,y=typeof this._state.ShapeColor;if(_!==y||"object"==_&&(this.ShapeColor.Color.effectValue!==this._state.ShapeColor.effectValue||this._state.ShapeColor.color.indexOf(this.ShapeColor.Color.color)<0)||"object"!=_&&this._state.ShapeColor.indexOf(this.ShapeColor.Color)<0){if(this.btnBackColor.setColor(this.ShapeColor.Color),"object"==typeof this.ShapeColor.Color){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==this.ShapeColor.Color.effectValue){this.colorsBack.select(this.ShapeColor.Color,!0),w=!0;break}w||this.colorsBack.clearSelection()}else this.colorsBack.select(this.ShapeColor.Color,!0);this._state.ShapeColor=this.ShapeColor.Color}var S,A=n.get_stroke(),k=A.get_type(),T="transparent"==this._state.StrokeColor&&"transparent"!==this.BorderColor.Color;if(A?(k==Asc.c_oAscStrokeType.STROKE_COLOR?(h=A.get_color(),h?h.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.BorderColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b()),effectValue:h.get_value()}}:this.BorderColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b())}:this.BorderColor={Value:1,Color:"transparent"}):this.BorderColor={Value:1,Color:"transparent"},S=A.asc_getPrstDash()):(k=null,this.BorderColor={Value:0,Color:"transparent"}),_=typeof this.BorderColor.Color,y=typeof this._state.StrokeColor,T||_!==y||"object"==_&&(this.BorderColor.Color.effectValue!==this._state.StrokeColor.effectValue||this._state.StrokeColor.color.indexOf(this.BorderColor.Color.color)<0)||"object"!=_&&(this._state.StrokeColor.indexOf(this.BorderColor.Color)<0||"object"==typeof this.btnBorderColor.color)){if(this.btnBorderColor.setColor(this.BorderColor.Color),"object"==typeof this.BorderColor.Color){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==this.BorderColor.Color.effectValue){this.colorsBorder.select(this.BorderColor.Color,!0),w=!0;break}w||this.colorsBorder.clearSelection()}else this.colorsBorder.select(this.BorderColor.Color,!0);this._state.StrokeColor=this.BorderColor.Color}if(this._state.StrokeType!==k||k==Asc.c_oAscStrokeType.STROKE_COLOR){if(k==Asc.c_oAscStrokeType.STROKE_COLOR){var I=A.get_width(),P=Math.abs(this._state.StrokeWidth-I)<1e-5&&!new RegExp(this.txtPt+"\\s*$").test(this.cmbBorderSize.getRawValue());if(Math.abs(this._state.StrokeWidth-I)>1e-5||P||(null===this._state.StrokeWidth||null===I)&&this._state.StrokeWidth!==I){this._state.StrokeWidth=I,null!==I&&(I=this._mm2pt(I));var M=null===I?I:i.find(this.cmbBorderSize.store.models,function(t){if(It.attributes.value-1e-5)return!0});M?this.cmbBorderSize.selectRecord(M):this.cmbBorderSize.setValue(null!==I?parseFloat(I.toFixed(2))+" "+this.txtPt:""),this.BorderSize=I}}else k==Asc.c_oAscStrokeType.STROKE_NONE?(this._state.StrokeWidth=0,this.BorderSize=this.cmbBorderSize.store.at(0).get("value"),this.cmbBorderSize.setValue(this.BorderSize)):(this._state.StrokeWidth=null,this.BorderSize=-1,this.cmbBorderSize.setValue(null));this._state.StrokeType=k}if(this._state.StrokeBorderType!==S&&(this.BorderType=this._state.StrokeBorderType=S,this.cmbBorderType.setValue(S)),_=typeof this.FGColor.Color,y=typeof this._state.FGColor,_!==y||"object"==_&&(this.FGColor.Color.effectValue!==this._state.FGColor.effectValue||this._state.FGColor.color.indexOf(this.FGColor.Color.color)<0)||"object"!=_&&this._state.FGColor.indexOf(this.FGColor.Color)<0){if(this.btnFGColor.setColor(this.FGColor.Color),"object"==typeof this.FGColor.Color){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==this.FGColor.Color.effectValue){this.colorsFG.select(this.FGColor.Color,!0),w=!0;break}w||this.colorsFG.clearSelection()}else this.colorsFG.select(this.FGColor.Color,!0);this._state.FGColor=this.FGColor.Color}if(_=typeof this.BGColor.Color,y=typeof this._state.BGColor,_!==y||"object"==_&&(this.BGColor.Color.effectValue!==this._state.BGColor.effectValue||this._state.BGColor.color.indexOf(this.BGColor.Color.color)<0)||"object"!=_&&this._state.BGColor.indexOf(this.BGColor.Color)<0){if(this.btnBGColor.setColor(this.BGColor.Color),"object"==typeof this.BGColor.Color){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==this.BGColor.Color.effectValue){this.colorsBG.select(this.BGColor.Color,!0),w=!0;break}w||this.colorsBG.clearSelection()}else this.colorsBG.select(this.BGColor.Color,!0);this._state.BGColor=this.BGColor.Color}if(h=this.GradColor.colors[this.GradColor.currentIdx],_=typeof h,y=typeof this._state.GradColor,_!==y||"object"==_&&(h.effectValue!==this._state.GradColor.effectValue||this._state.GradColor.color.indexOf(h.color)<0)||"object"!=_&&this._state.GradColor.indexOf(h)<0){if(this.btnGradColor.setColor(h),"object"==typeof h){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==h.effectValue){this.colorsGrad.select(h,!0),w=!0;break}w||this.colorsGrad.clearSelection()}else this.colorsGrad.select(h,!0);this._state.GradColor=h}this.chShadow.setValue(!!n.asc_getShadow(),!0),this._noApply=!1}},createDelayedControls:function(){var t=this;this._arrFillSrc=[{displayValue:this.textColor,value:Asc.c_oAscFill.FILL_TYPE_SOLID},{displayValue:this.textGradientFill,value:Asc.c_oAscFill.FILL_TYPE_GRAD},{displayValue:this.textImageTexture,value:Asc.c_oAscFill.FILL_TYPE_BLIP},{displayValue:this.textPatternFill,value:Asc.c_oAscFill.FILL_TYPE_PATT},{displayValue:this.textNoFill,value:Asc.c_oAscFill.FILL_TYPE_NOFILL}],this.cmbFillSrc=new Common.UI.ComboBox({el:e("#shape-combo-fill-src"),cls:"input-group-nr",style:"width: 100%;",menuStyle:"min-width: 100%;",editable:!1,data:this._arrFillSrc}),this.cmbFillSrc.setValue(this._arrFillSrc[0].value),this.cmbFillSrc.on("selected",i.bind(this.onFillSrcSelect,this)),this.fillControls.push(this.cmbFillSrc),this.cmbPattern=new Common.UI.ComboDataView({itemWidth:28,itemHeight:28,menuMaxHeight:300,enableKeyEvents:!0,cls:"combo-pattern"}),this.cmbPattern.menuPicker.itemTemplate=this.cmbPattern.fieldPicker.itemTemplate=i.template(['
    ','',"
    "].join("")),this.cmbPattern.render(e("#shape-combo-pattern")),this.cmbPattern.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbPattern.on("click",i.bind(this.onPatternSelect,this)),this.cmbPattern.openButton.menu.on("show:after",function(){t.cmbPattern.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.fillControls.push(this.cmbPattern),this.btnSelectImage=new Common.UI.Button({parentEl:e("#shape-button-replace"),cls:"btn-text-menu-default",caption:this.textSelectImage,style:"width:100%;",menu:new Common.UI.Menu({style:"min-width: 194px;",maxHeight:200,items:[{caption:this.textFromFile,value:0},{caption:this.textFromUrl,value:1},{caption:this.textFromStorage,value:2}]})}),this.fillControls.push(this.btnSelectImage),this.btnSelectImage.menu.on("item:click",i.bind(this.onImageSelect,this)),this.btnSelectImage.menu.items[2].setVisible(this.mode.canRequestInsertImage||this.mode.fileChoiceUrl&&this.mode.fileChoiceUrl.indexOf("{documentType}")>-1),this._arrFillType=[{displayValue:this.textStretch,value:Asc.c_oAscFillBlipType.STRETCH},{displayValue:this.textTile,value:Asc.c_oAscFillBlipType.TILE}],this.cmbFillType=new Common.UI.ComboBox({el:e("#shape-combo-fill-type"),cls:"input-group-nr",menuStyle:"min-width: 90px;",editable:!1,data:this._arrFillType}),this.cmbFillType.setValue(this._arrFillType[0].value),this.cmbFillType.on("selected",i.bind(this.onFillTypeSelect,this)),this.fillControls.push(this.cmbFillType),this.numTransparency=new Common.UI.MetricSpinner({el:e("#shape-spin-transparency"),step:1,width:62,value:"100 %",defaultUnit:"%",maxValue:100,minValue:0}),this.numTransparency.on("change",i.bind(this.onNumTransparencyChange,this)),this.numTransparency.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.fillControls.push(this.numTransparency),this.sldrTransparency=new Common.UI.SingleSlider({el:e("#shape-slider-transparency"),width:75,minValue:0,maxValue:100,value:100}),this.sldrTransparency.on("change",i.bind(this.onTransparencyChange,this)),this.sldrTransparency.on("changecomplete",i.bind(this.onTransparencyChangeComplete,this)),this.fillControls.push(this.sldrTransparency),this.lblTransparencyStart=e(this.el).find("#shape-lbl-transparency-start"),this.lblTransparencyEnd=e(this.el).find("#shape-lbl-transparency-end"),this._arrGradType=[{displayValue:this.textLinear,value:Asc.c_oAscFillGradType.GRAD_LINEAR},{displayValue:this.textRadial,value:Asc.c_oAscFillGradType.GRAD_PATH}],this.cmbGradType=new Common.UI.ComboBox({el:e("#shape-combo-grad-type"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrGradType}),this.cmbGradType.setValue(this._arrGradType[0].value),this.cmbGradType.on("selected",i.bind(this.onGradTypeSelect,this)),this.fillControls.push(this.cmbGradType),this._viewDataLinear=[{offsetx:0,offsety:0,type:45,subtype:-1,iconcls:"gradient-left-top"},{offsetx:50,offsety:0,type:90,subtype:4,iconcls:"gradient-top"},{offsetx:100,offsety:0,type:135,subtype:5,iconcls:"gradient-right-top"},{offsetx:0,offsety:50,type:0,subtype:6,iconcls:"gradient-left",cls:"item-gradient-separator",selected:!0},{offsetx:100,offsety:50,type:180,subtype:1,iconcls:"gradient-right"},{offsetx:0,offsety:100,type:315,subtype:2,iconcls:"gradient-left-bottom"},{offsetx:50,offsety:100,type:270,subtype:3,iconcls:"gradient-bottom"},{offsetx:100,offsety:100,type:225,subtype:7,iconcls:"gradient-right-bottom"}],this._viewDataRadial=[{offsetx:100,offsety:150,type:2,subtype:5,iconcls:"gradient-radial-center"}],this.btnDirection=new Common.UI.Button({cls:"btn-large-dataview",iconCls:"item-gradient gradient-left",menu:new Common.UI.Menu({style:"min-width: 60px;",menuAlign:"tr-br",items:[{template:i.template('
    ')}]})}),this.btnDirection.on("render:after",function(n){t.mnuDirectionPicker=new Common.UI.DataView({el:e("#id-shape-menu-direction"),parentMenu:n.menu,restoreHeight:174,allowScrollbar:!1,store:new Common.UI.DataViewStore(t._viewDataLinear),itemTemplate:i.template('
    ')})}),this.btnDirection.render(e("#shape-button-direction")),this.mnuDirectionPicker.on("item:click",i.bind(this.onSelectGradient,this,this.btnDirection)),this.fillControls.push(this.btnDirection),this.sldrGradient=new Common.UI.MultiSliderGradient({el:e("#shape-slider-gradient"),width:192,minValue:0,maxValue:100,values:[0,100]}),this.sldrGradient.on("change",i.bind(this.onGradientChange,this)),this.sldrGradient.on("changecomplete",i.bind(this.onGradientChangeComplete,this)),this.sldrGradient.on("thumbclick",function(e,i){t.GradColor.currentIdx=i;var n=t.GradColor.colors[t.GradColor.currentIdx];t.btnGradColor.setColor(n),t.colorsGrad.select(n,!1);var o=t.GradColor.values[t.GradColor.currentIdx];t.spnGradPosition.setValue(o,!0)}),this.sldrGradient.on("thumbdblclick",function(e){t.btnGradColor.cmpEl.find("button").dropdown("toggle")}),this.sldrGradient.on("sortthumbs",function(e,n){var o,s=[];i.each(n,function(e,i){s.push(t.GradColor.colors[e]), -t.GradColor.currentIdx==e&&(o=i)}),t.OriginalFillType=null,t.GradColor.colors=s,t.GradColor.currentIdx=o}),this.sldrGradient.on("addthumb",function(e,i,n){t.GradColor.colors[i]=t.GradColor.colors[t.GradColor.currentIdx],t.GradColor.currentIdx=i;var o=t.sldrGradient.addNewThumb(i,n);t.GradColor.colors[t.GradColor.currentIdx]=o}),this.sldrGradient.on("removethumb",function(e,n){if(t.sldrGradient.removeThumb(n),t.GradColor.values.splice(n,1),t.sldrGradient.changeGradientStyle(),i.isUndefined(t.GradColor.currentIdx)||t.GradColor.currentIdx>=t.GradColor.colors.length){var o=n>0?n-1:n;o=0===o&&t.GradColor.values.length>2?t.GradColor.values.length-2:o,t.GradColor.currentIdx=o}t.sldrGradient.setActiveThumb(t.GradColor.currentIdx)}),this.fillControls.push(this.sldrGradient),this.spnGradPosition=new Common.UI.MetricSpinner({el:e("#shape-gradient-position"),step:1,width:60,defaultUnit:"%",value:"50 %",allowDecimal:!1,maxValue:100,minValue:0,disabled:this._locked}),this.fillControls.push(this.spnGradPosition),this.spnGradPosition.on("change",i.bind(this.onPositionChange,this)),this.spnGradPosition.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.btnAddGradientStep=new Common.UI.Button({parentEl:e("#shape-gradient-add-step"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-add-breakpoint",disabled:this._locked,hint:this.tipAddGradientPoint}),this.btnAddGradientStep.on("click",i.bind(this.onAddGradientStep,this)),this.fillControls.push(this.btnAddGradientStep),this.btnRemoveGradientStep=new Common.UI.Button({parentEl:e("#shape-gradient-remove-step"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-remove-breakpoint",disabled:this._locked,hint:this.tipRemoveGradientPoint}),this.btnRemoveGradientStep.on("click",i.bind(this.onRemoveGradientStep,this)),this.fillControls.push(this.btnRemoveGradientStep),this.numGradientAngle=new Common.UI.MetricSpinner({el:e("#shape-spin-gradient-angle"),step:10,width:60,defaultUnit:"°",value:"0 °",allowDecimal:!0,maxValue:359.9,minValue:0,disabled:this._locked}),this.fillControls.push(this.numGradientAngle),this.numGradientAngle.on("change",i.bind(this.onGradientAngleChange,this)),this.numGradientAngle.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.cmbBorderSize=new Common.UI.ComboBorderSizeEditable({el:e("#shape-combo-border-size"),style:"width: 93px;",txtNoBorders:this.txtNoBorders}).on("selected",i.bind(this.onBorderSizeSelect,this)).on("changed:before",i.bind(this.onBorderSizeChanged,this,!0)).on("changed:after",i.bind(this.onBorderSizeChanged,this,!1)).on("combo:blur",i.bind(this.onComboBlur,this,!1)),this.BorderSize=this.cmbBorderSize.store.at(2).get("value"),this.cmbBorderSize.setValue(this.BorderSize),this.lockedControls.push(this.cmbBorderSize),this.cmbBorderType=new Common.UI.ComboBorderType({el:e("#shape-combo-border-type"),style:"width: 93px;",menuStyle:"min-width: 93px;"}).on("selected",i.bind(this.onBorderTypeSelect,this)).on("combo:blur",i.bind(this.onComboBlur,this,!1)),this.BorderType=Asc.c_oDashType.solid,this.cmbBorderType.setValue(this.BorderType),this.lockedControls.push(this.cmbBorderType),this.btnRotate270=new Common.UI.Button({parentEl:e("#shape-button-270",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-rotate-270",value:0,hint:this.textHint270}),this.btnRotate270.on("click",i.bind(this.onBtnRotateClick,this)),this.lockedControls.push(this.btnRotate270),this.btnRotate90=new Common.UI.Button({parentEl:e("#shape-button-90",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-rotate-90",value:1,hint:this.textHint90}),this.btnRotate90.on("click",i.bind(this.onBtnRotateClick,this)),this.lockedControls.push(this.btnRotate90),this.btnFlipV=new Common.UI.Button({parentEl:e("#shape-button-flipv",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-flip-vert",value:0,hint:this.textHintFlipV}),this.btnFlipV.on("click",i.bind(this.onBtnFlipClick,this)),this.lockedControls.push(this.btnFlipV),this.btnFlipH=new Common.UI.Button({parentEl:e("#shape-button-fliph",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-flip-hor",value:1,hint:this.textHintFlipH}),this.btnFlipH.on("click",i.bind(this.onBtnFlipClick,this)),this.lockedControls.push(this.btnFlipH);var n=[{offsetx:0,data:Asc.c_oAscWrapStyle2.Inline,tip:this.txtInline,selected:!0},{offsetx:50,data:Asc.c_oAscWrapStyle2.Square,tip:this.txtSquare},{offsetx:100,data:Asc.c_oAscWrapStyle2.Tight,tip:this.txtTight},{offsetx:150,data:Asc.c_oAscWrapStyle2.Through,tip:this.txtThrough},{offsetx:200,data:Asc.c_oAscWrapStyle2.TopAndBottom,tip:this.txtTopAndBottom},{offsetx:250,data:Asc.c_oAscWrapStyle2.InFront,tip:this.txtInFront},{offsetx:300,data:Asc.c_oAscWrapStyle2.Behind,tip:this.txtBehind}];this.cmbWrapType=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,store:new Common.UI.DataViewStore(n),cls:"combo-chart-style"}),this.cmbWrapType.menuPicker.itemTemplate=this.cmbWrapType.fieldPicker.itemTemplate=i.template(['
    ','',"
    "].join("")),this.cmbWrapType.render(e("#shape-combo-wrap")),this.cmbWrapType.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbWrapType.on("click",i.bind(this.onSelectWrap,this)),this.cmbWrapType.openButton.menu.on("show:after",function(){t.cmbWrapType.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbWrapType),this.btnChangeShape=new Common.UI.Button({parentEl:e("#shape-btn-change"),cls:"btn-icon-default",iconCls:"btn-change-shape",menu:new Common.UI.Menu({menuAlign:"tr-br",cls:"menu-shapes",items:[]})}),this.lockedControls.push(this.btnChangeShape),this.chShadow=new Common.UI.CheckBox({el:e("#shape-checkbox-shadow"),labelText:this.strShadow}),this.chShadow.on("change",i.bind(this.onCheckShadow,this)),this.lockedControls.push(this.chShadow),this.linkAdvanced=e("#shape-advanced-link"),e(this.el).on("click","#shape-advanced-link",i.bind(this.openAdvancedSettings,this))},createDelayedElements:function(){this._initSettings=!1,this.createDelayedControls();var t=[0,1,3,2,4,53,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,23,24,25,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,49,50,51,52];this.patternViewData=[];for(var e=0;e<13;e++)for(var i=0;i<4;i++){var n=4*e+i;this.patternViewData[n]={offsetx:28*i,offsety:28*e,type:t[n]}}this.patternViewData.splice(this.patternViewData.length-2,2);for(var e=0;e0&&(this.cmbPattern.fillComboView(this.cmbPattern.menuPicker.store.at(0),!0),this.PatternFillType=this.patternViewData[0].type),this.onInitStandartTextures(),this.onApiAutoShapes(),this.UpdateThemeColors()},onInitStandartTextures:function(t){var n=this;if(t&&t.length>0&&(n._texturearray=[],i.each(t,function(t){n._texturearray.push({imageUrl:t.get_image(),name:n.textureNames[t.get_id()],type:t.get_id(),selected:!1})})),n._texturearray&&!(n._texturearray.length<1)&&!this._initSettings&&!this.btnTexture){this.btnTexture=new Common.UI.ComboBox({el:e("#shape-combo-fill-texture"),template:i.template(['"].join(""))}),this.textureMenu=new Common.UI.Menu({items:[{template:i.template('
    ')}]}),this.textureMenu.render(e("#shape-combo-fill-texture")),this.fillControls.push(this.btnTexture);var o=function(t){new Common.UI.DataView({el:e("#id-shape-menu-texture"),restoreHeight:174,parentMenu:t,showLast:!1,store:new Common.UI.DataViewStore(n._texturearray||[]),itemTemplate:i.template('
    ')}).on("item:click",i.bind(n.onSelectTexture,n)),t.off("show:before",o)};this.textureMenu.on("show:before",o)}},onSelectTexture:function(t,i,n){if(this._fromTextureCmb=!0,this.cmbFillType.setValue(this._arrFillType[1].value),this._fromTextureCmb=!1,this.api){var o=new Asc.asc_CShapeProperty,s=new Asc.asc_CShapeFill;s.put_type(Asc.c_oAscFill.FILL_TYPE_BLIP),s.put_fill(new Asc.asc_CFillBlip),s.get_fill().put_type(Asc.c_oAscFillBlipType.TILE),s.get_fill().put_texture_id(n.get("type")),o.put_fill(s),this.imgprops.put_ShapeProperties(o),this.api.ImgApply(this.imgprops)}e(this.btnTexture.el).find(".form-control").prop("innerHTML",n.get("name")),this.fireEvent("editcomplete",this)},onBtnRotateClick:function(t){var e=new Asc.asc_CImgProperty;e.asc_putRotAdd(3.14159265358979*(1==t.options.value?90:270)/180),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onBtnFlipClick:function(t){var e=new Asc.asc_CImgProperty;1==t.options.value?e.asc_putFlipHInvert(!0):e.asc_putFlipVInvert(!0),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onCheckShadow:function(t,e,i,n){if(this.api){var o=new Asc.asc_CShapeProperty;o.asc_putShadow("checked"==t.getValue()?new Asc.asc_CShadowProperty:null),this.imgprops.put_ShapeProperties(o),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onApiAutoShapes:function(){var t=this,e=function(i){t.fillAutoShapes(),i.off("show:before",e)};t.btnChangeShape.menu.on("show:before",e)},fillAutoShapes:function(){var t=this,n=this.application.getCollection("ShapeGroups"),o=n.length,s=function(a){for(var r=-1;r0;r++){var l=n.at(r>-1?r:0).get("groupStore");r<0&&(l=l.clone(),l.shift());new Common.UI.DataViewSimple({el:e("#id-shape-menu-shapegroup"+(r+1),a.items[r+1].$el),store:l,parentMenu:a.items[r+1].menu,itemTemplate:i.template('
    ')}).on("item:click",function(e,i,n,o){t.api&&(t.api.ChangeShapeType(n.get("data").shapeType),t.fireEvent("editcomplete",t)),"click"!==o.type&&t.btnChangeShape.menu.hide()})}a.off("show:after",s)};t.btnChangeShape.menu.on("show:after",s);for(var a=-1;a0;a++){var r=n.at(a>-1?a:a+1),l=new Common.UI.MenuItem({caption:r.get("groupName"),menu:new Common.UI.Menu({menuAlign:"tr-tl",items:[{template:i.template('')}]})});t.btnChangeShape.menu.addItem(l)}t.btnChangeShape.menu.items[0].setVisible(t._state.isFromImage),t.btnChangeShape.menu.items[1].setVisible(!t._state.isFromImage)},UpdateThemeColors:function(){this._initSettings||(this.btnBackColor||(this.btnBackColor=new Common.UI.ColorButton({parentEl:e("#shape-back-color-btn"),transparent:!0,color:"transparent"}),this.fillControls.push(this.btnBackColor),this.colorsBack=this.btnBackColor.getPicker(),this.btnBackColor.on("color:select",i.bind(this.onColorsBackSelect,this)),this.btnFGColor=new Common.UI.ColorButton({parentEl:e("#shape-foreground-color-btn"),color:"000000"}),this.fillControls.push(this.btnFGColor),this.colorsFG=this.btnFGColor.getPicker(),this.btnFGColor.on("color:select",i.bind(this.onColorsFGSelect,this)),this.btnBGColor=new Common.UI.ColorButton({parentEl:e("#shape-background-color-btn"),color:"ffffff"}),this.fillControls.push(this.btnBGColor),this.colorsBG=this.btnBGColor.getPicker(),this.btnBGColor.on("color:select",i.bind(this.onColorsBGSelect,this)),this.btnGradColor=new Common.UI.ColorButton({parentEl:e("#shape-gradient-color-btn"),color:"000000"}),this.fillControls.push(this.btnGradColor),this.colorsGrad=this.btnGradColor.getPicker(),this.btnGradColor.on("color:select",i.bind(this.onColorsGradientSelect,this)),this.btnBorderColor=new Common.UI.ColorButton({parentEl:e("#shape-border-color-btn"),color:"000000"}),this.lockedControls.push(this.btnBorderColor),this.colorsBorder=this.btnBorderColor.getPicker(),this.btnBorderColor.on("color:select",i.bind(this.onColorsBorderSelect,this))),this.colorsBorder.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsBack.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsFG.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsBG.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsGrad.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()))},_pt2mm:function(t){return 25.4*t/72},_mm2pt:function(t){return 72*t/25.4},disableFillPanels:function(t){this._state.DisabledFillPanels!==t&&(this._state.DisabledFillPanels=t,i.each(this.fillControls,function(e){e.setDisabled(t)}),this.lblTransparencyStart.toggleClass("disabled",t),this.lblTransparencyEnd.toggleClass("disabled",t),this.numGradientAngle.setDisabled(t||this.GradFillType!==Asc.c_oAscFillGradType.GRAD_LINEAR))},ShowHideElem:function(t){this.FillColorContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_SOLID),this.FillImageContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_BLIP),this.FillPatternContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_PATT),this.FillGradientContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_GRAD),this.TransparencyContainer.toggleClass("settings-hidden",t===Asc.c_oAscFill.FILL_TYPE_NOFILL||null===t)},setLocked:function(t){this._locked=t},disableControls:function(t,e){this._initSettings||(this.disableFillPanels(t||e),this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.linkAdvanced.toggleClass("disabled",t)))},hideShapeOnlySettings:function(t){this._state.HideShapeOnlySettings!==t&&(this._state.HideShapeOnlySettings=t,this.ShapeOnlySettings.toggleClass("hidden",1==t))},hideChangeTypeSettings:function(t){this._state.HideChangeTypeSettings!==t&&(this._state.HideChangeTypeSettings=t,this.CanChangeType.toggleClass("hidden",1==t))},onPositionChange:function(t){var e=t.getNumberValue(),i=this.GradColor.currentIdx-1<0?0:this.GradColor.values[this.GradColor.currentIdx-1],n=this.GradColor.currentIdx+1n;if(this.api){this.GradColor.values[this.GradColor.currentIdx]=e;var s=new Asc.asc_CShapeProperty,a=new Asc.asc_CShapeFill;a.asc_putType(Asc.c_oAscFill.FILL_TYPE_GRAD),a.asc_putFill(new Asc.asc_CFillGrad),a.asc_getFill().asc_putGradType(this.GradFillType);var r=[];this.GradColor.values.forEach(function(t){r.push(1e3*t)}),a.asc_getFill().asc_putPositions(r),s.asc_putFill(a),this.imgprops.put_ShapeProperties(s),this.api.ImgApply(this.imgprops),o&&(this.sldrGradient.sortThumbs(),this.sldrGradient.trigger("change",this.sldrGradient),this.sldrGradient.trigger("changecomplete",this.sldrGradient))}},onAddGradientStep:function(){if(!(this.GradColor.colors.length>9)){var t=this.GradColor.currentIdx,e=(this.GradColor.values[t]+this.GradColor.values[t=this.GradColor.colors.length){var e=t>0?t-1:t;e=0===e&&this.GradColor.values.length>2?this.GradColor.values.length-2:e,this.GradColor.currentIdx=e}this.sldrGradient.setActiveThumb(this.GradColor.currentIdx),this.sldrGradient.trigger("change",this.sldrGradient),this.sldrGradient.trigger("changecomplete",this.sldrGradient)}},onGradientAngleChange:function(t,e,i,n){if(this.api&&!this._noApply){var o=new Asc.asc_CShapeProperty,s=new Asc.asc_CShapeFill;s.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),s.put_fill(new Asc.asc_CFillGrad),s.get_fill().put_grad_type(this.GradFillType),s.get_fill().put_linear_angle(6e4*t.getNumberValue()),s.get_fill().put_linear_scale(!0),o.put_fill(s),this.imgprops.put_ShapeProperties(o),this.api.ImgApply(this.imgprops)}},txtNoBorders:"No Line",strStroke:"Stroke",strColor:"Color",strSize:"Size",strChange:"Change Autoshape",strFill:"Fill",textColor:"Color Fill",textImageTexture:"Picture or Texture",textTexture:"From Texture",textFromUrl:"From URL",textFromFile:"From File",textStretch:"Stretch",textTile:"Tile",txtCanvas:"Canvas",txtCarton:"Carton",txtDarkFabric:"Dark Fabric",txtGrain:"Grain",txtGranite:"Granite",txtGreyPaper:"Grey Paper",txtKnit:"Knit",txtLeather:"Leather",txtBrownPaper:"Brown Paper",txtPapyrus:"Papyrus",txtWood:"Wood",textAdvanced:"Show advanced settings",strTransparency:"Opacity",textNoFill:"No Fill",textSelectTexture:"Select",textGradientFill:"Gradient Fill",textPatternFill:"Pattern",strBackground:"Background color",strForeground:"Foreground color",strPattern:"Pattern",textEmptyPattern:"No Pattern",textLinear:"Linear",textRadial:"Radial",textDirection:"Direction",textStyle:"Style",textGradient:"Gradient Points",textWrap:"Wraping Style",txtInline:"Inline",txtSquare:"Square",txtTight:"Tight",txtThrough:"Through",txtTopAndBottom:"Top and bottom",txtBehind:"Behind",txtInFront:"In front",textBorderSizeErr:"The entered value is incorrect.
    Please enter a value between 0 pt and 1584 pt.",strType:"Type",textRotation:"Rotation",textRotate90:"Rotate 90°",textFlip:"Flip",textHint270:"Rotate 90° Counterclockwise",textHint90:"Rotate 90° Clockwise",textHintFlipV:"Flip Vertically",textHintFlipH:"Flip Horizontally",strShadow:"Show shadow",textFromStorage:"From Storage",textSelectImage:"Select Picture",textPosition:"Position",tipAddGradientPoint:"Add gradient point",tipRemoveGradientPoint:"Remove gradient point",textAngle:"Angle"},DE.Views.ShapeSettings||{}))}),define("text!documenteditor/main/app/template/MailMerge.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n\r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n
    '}),void 0===Common)var Common={};if(define("common/main/lib/component/Switcher",["common/main/lib/component/BaseView","underscore"],function(t,e){"use strict";Common.UI.Switcher=Common.UI.BaseView.extend({options:{width:25,thumbWidth:13,value:!1},disabled:!1,template:e.template(['
    ','
    ','
    ','
    ',"
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;e.width=e.options.width,e.thumbWidth=e.options.thumbWidth,e.delta=(e.width-e.thumbWidth-2)/2,e.options.el&&e.render(),this.setValue(e.options.value)},render:function(t){var e=this;e.rendered?this.cmpEl=this.$el:(this.cmpEl=$(this.template({})),t?(this.setElement(t,!1),t.html(this.cmpEl)):this.$el.html(this.cmpEl)),this.thumb=this.cmpEl.find(".thumb"),this.cmpEl.width(e.width),this.thumb.width(e.thumbWidth),this.cmpEl.find(".sw-left").width(e.width/2),this.cmpEl.find(".sw-right").width(e.width/2);var i=function(t){if(!e.disabled){t.preventDefault(),t.stopPropagation(),$(document).off("mouseup.switcher",i),$(document).off("mousemove.switcher",n);var o=Math.round(t.pageX*Common.Utils.zoom()-e._dragstart);e.value=e.value?o>-e.delta:o>e.delta,e.cmpEl.toggleClass("on",e.value),e.thumb.css({left:"",right:""}),e.trigger("change",e,e.value),e._dragstart=void 0}},n=function(t){if(!e.disabled&&void 0!==e._dragstart){t.preventDefault(),t.stopPropagation();var i=Math.round(t.pageX*Common.Utils.zoom()-e._dragstart);e.value?e.thumb.css({right:i<1?Math.min(e.width-e.thumbWidth-2,-i):0,left:"auto"}):e.thumb.css({left:i>-1?Math.min(e.width-e.thumbWidth-2,i):0,right:"auto"}),e._isMouseMove||(e._isMouseMove=Math.abs(i)>0)}},o=function(t){e.disabled||(e._dragstart=t.pageX*Common.Utils.zoom(),e._isMouseMove=!1,$(document).on("mouseup.switcher",i),$(document).on("mousemove.switcher",n))},s=function(t){if(e.disabled||e._isMouseMove)return void(e._isMouseMove=!1);e.value=!e.value,e.cmpEl.toggleClass("on",e.value),e.trigger("change",e,e.value)};if(!e.rendered){var a=e.cmpEl;a.on("mousedown",".thumb",o),a.on("click",s)}return e.rendered=!0,this},setThumbPosition:function(t){var e=this.value?t<-this.delta:t>this.delta;this.thumb.css(e?{right:0,left:"auto"}:{left:0,right:"auto"})},setValue:function(t){this.value=!0===t,this.cmpEl.toggleClass("on",this.value)},getValue:function(){return this.value},setDisabled:function(t){t!==this.disabled&&this.cmpEl.toggleClass("disabled",t),this.disabled=t},isDisabled:function(){return this.disabled}})}),define("common/main/lib/view/SaveAsDlg",["common/main/lib/component/Window","common/main/lib/component/LoadMask"],function(){"use strict";Common.Views.SaveAsDlg=Common.UI.Window.extend(_.extend({initialize:function(t){var e={};_.extend(e,{title:this.textTitle,width:420,height:681,header:!0},t),this.template=['
    '].join(""),e.tpl=_.template(this.template)(e),this.saveFolderUrl=t.saveFolderUrl||"",this.saveFileUrl=t.saveFileUrl||"",this.defFileName=t.defFileName||"",this.saveFolderUrl=this.saveFolderUrl.replace("{title}",encodeURIComponent(this.defFileName)).replace("{fileuri}",encodeURIComponent(this.saveFileUrl)),Common.UI.Window.prototype.initialize.call(this,e)},render:function(){Common.UI.Window.prototype.render.call(this),this.$window.find("> .body").css({height:"auto",overflow:"hidden"});var t=document.createElement("iframe");t.width="100%",t.height=645,t.align="top",t.frameBorder=0,t.scrolling="no",t.onload=_.bind(this._onLoad,this),$("#id-saveas-folder-placeholder").append(t),this.loadMask=new Common.UI.LoadMask({owner:$("#id-saveas-folder-placeholder")}),this.loadMask.setTitle(this.textLoading),this.loadMask.show(),t.src=this.saveFolderUrl;var e=this;this._eventfunc=function(t){e._onWindowMessage(t)},this._bindWindowEvents.call(this),this.on("close",function(t){e._unbindWindowEvents()})},_bindWindowEvents:function(){window.addEventListener?window.addEventListener("message",this._eventfunc,!1):window.attachEvent&&window.attachEvent("onmessage",this._eventfunc)},_unbindWindowEvents:function(){window.removeEventListener?window.removeEventListener("message",this._eventfunc):window.detachEvent&&window.detachEvent("onmessage",this._eventfunc)},_onWindowMessage:function(t){if(t&&window.JSON)try{this._onMessage.call(this,window.JSON.parse(t.data))}catch(t){}},_onMessage:function(t){t&&"onlyoffice"==t.Referer&&(_.isEmpty(t.error)?_.isEmpty(t.message)||Common.NotificationCenter.trigger("showmessage",{msg:t.message}):this.trigger("saveaserror",this,t.error),Common.NotificationCenter.trigger("window:close",this))},_onLoad:function(){this.loadMask&&this.loadMask.hide()},textTitle:"Folder for save",textLoading:"Loading"},Common.Views.SaveAsDlg||{}))}),define("text!documenteditor/main/app/template/MailMergeEmailDlg.template",[],function(){return'
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    '}),define("documenteditor/main/app/view/MailMergeEmailDlg",["text!documenteditor/main/app/template/MailMergeEmailDlg.template","common/main/lib/view/AdvancedSettingsWindow","common/main/lib/component/ComboBox","common/main/lib/component/InputField"],function(t){"use strict";DE.Views.MailMergeEmailDlg=Common.Views.AdvancedSettingsWindow.extend(_.extend({options:{alias:"MailMergeEmail",contentWidth:500,height:435},initialize:function(e){_.extend(this.options,{title:this.textTitle,template:['
    ','
    '+_.template(t)({scope:this})+"
    ","
    ",'
    '].join("")},e),Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this,this.options)},render:function(){Common.Views.AdvancedSettingsWindow.prototype.render.call(this);var t=this;this._arrFrom=[],this.cmbFrom=new Common.UI.ComboBox({el:$("#merge-email-dlg-from"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrFrom}),this._arrTo=[],this.cmbTo=new Common.UI.ComboBox({el:$("#merge-email-dlg-to"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrTo}),this.inputSubject=new Common.UI.InputField({el:$("#merge-email-dlg-subject"),allowBlank:!0,validateOnBlur:!1,placeHolder:this.subjectPlaceholder,style:"width: 100%;"}),this._arrFormat=[{displayValue:this.textHTML,value:Asc.c_oAscFileType.HTML},{displayValue:this.textAttachDocx,value:Asc.c_oAscFileType.DOCX},{displayValue:this.textAttachPdf,value:Asc.c_oAscFileType.PDF}],this.cmbFormat=new Common.UI.ComboBox({el:$("#merge-email-dlg-format"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrFormat}),this.cmbFormat.setValue(Asc.c_oAscFileType.HTML),this.cmbFormat.on("selected",_.bind(this.onCmbFormatSelect,this)),this.inputFileName=new Common.UI.InputField({el:$("#merge-email-dlg-filename"),allowBlank:!0,validateOnBlur:!1,disabled:!0,placeHolder:this.filePlaceholder,style:"width: 100%;"}),this.textareaMessage=this.$window.find("textarea"), -this.lblFileName=$("#merge-email-dlg-lbl-filename"),this.lblMessage=$("#merge-email-dlg-lbl-message"),this._eventfunc=function(e){t._onWindowMessage(e)},this.mergeProps=this.options.props,this.mergedFileUrl=this.options.mergedFileUrl||"",this.afterRender()},_bindWindowEvents:function(){window.addEventListener?window.addEventListener("message",this._eventfunc,!1):window.attachEvent&&window.attachEvent("onmessage",this._eventfunc)},_unbindWindowEvents:function(){window.removeEventListener?window.removeEventListener("message",this._eventfunc):window.detachEvent&&window.detachEvent("onmessage",this._eventfunc)},_onWindowMessage:function(t){if(t&&window.JSON)try{this._onMessage.call(this,window.JSON.parse(t.data))}catch(t){}},_onMessage:function(t){t&&t.Referer},afterRender:function(){this._setDefaults(this.mergeProps)},getSettings:function(){var t=this.inputFileName.getValue(),e=this.cmbFormat.getValue();if(e!==Asc.c_oAscFileType.HTML){_.isEmpty(t)&&(t="attach");var i=t.lastIndexOf("."),n=i>0?t.substring(i,t.length).toLowerCase():"";e==Asc.c_oAscFileType.PDF&&".pdf"!==n?t+=".pdf":e==Asc.c_oAscFileType.DOCX&&".docx"!==n&&(t+=".docx")}return{from:this.cmbFrom.getValue(),to:this.cmbTo.getValue(),subject:this.inputSubject.getValue(),mailFormat:e,fileName:t,message:this.textareaMessage.val()}},_setDefaults:function(t){if(t){if(t.fieldsList){var e=[];_.each(t.fieldsList,function(t,i){e.push({displayValue:"<"+t+">",value:t})}),this.cmbTo.setData(e),e.length>0&&this.cmbTo.setValue(e[0].value)}if(t.emailAddresses){var e=[];_.each(t.emailAddresses,function(t,i){e.push({displayValue:t,value:t})}),this.cmbFrom.setData(e),e.length>0&&this.cmbFrom.setValue(e[0].value)}}},onPrimary:function(){return!0},onDlgBtnClick:function(t){var e=t.currentTarget.attributes.result.value;"ok"==e&&this.handler&&this.handler.call(this,e,"ok"==e?this.getSettings():void 0),this.close()},onCmbFormatSelect:function(t,e){var i=e.value==Asc.c_oAscFileType.HTML;this.inputFileName.setDisabled(i),this.lblFileName.toggleClass("disabled",i),i?this.textareaMessage.attr("disabled","disabled"):this.textareaMessage.removeAttr("disabled"),this.textareaMessage.toggleClass("disabled",i),this.lblMessage.toggleClass("disabled",i)},textTitle:"Send to E-mail",textFrom:"From",textTo:"To",textSubject:"Subject Line",textFormat:"Mail format",textFileName:"File name",textMessage:"Message",textHTML:"HTML",textAttachDocx:"Attach as DOCX",textAttachPdf:"Attach as PDF",subjectPlaceholder:"Theme",filePlaceholder:"PDF",textWarning:"Warning!",textWarningMsg:"Please note that mailing cannot be stopped once your click the 'Send' button."},DE.Views.MailMergeEmailDlg||{}))}),define("documenteditor/main/app/view/MailMergeSettings",["text!documenteditor/main/app/template/MailMerge.template","jquery","underscore","backbone","common/main/lib/component/Button","common/main/lib/component/Switcher","common/main/lib/view/SaveAsDlg","common/main/lib/view/SelectFileDlg","documenteditor/main/app/view/MailMergeEmailDlg"],function(t,e,i,n){"use strict";DE.enumLockMM={lostConnect:"disconnect",preview:"preview",coAuth:"co-auth",noFields:"no-fields",noRecipients:"no-recipients",radioAllCurr:"radio-all-curr"},DE.Views.MailMergeSettings=n.View.extend(i.extend({el:"#id-mail-merge-settings",template:i.template(t),events:{},options:{alias:"MailMergeSettings"},initialize:function(){DE.enumLockMM;this._initSettings=!0,this._state={recipientsCount:0,fieldsList:[]},this._locked=!1,this.emptyDBControls=[],this._noApply=!1,this._originalProps=null,this.defFileName="",this.emailAddresses=void 0,this.mergeMailData=void 0,this.render()},render:function(){this.$el.html(this.template({scope:this}))},setApi:function(t){return this.api=t,this.api&&(this.api.asc_registerCallback("asc_onPreviewMailMergeResult",i.bind(this.onPreviewMailMergeResult,this)),this.api.asc_registerCallback("asc_onEndPreviewMailMergeResult",i.bind(this.onEndPreviewMailMergeResult,this)),this.api.asc_registerCallback("asc_onStartMailMerge",i.bind(this.onStartMailMerge,this)),this.api.asc_registerCallback("asc_onSaveMailMerge",i.bind(this.onSaveMailMerge,this)),this.api.asc_registerCallback("asc_onEndAction",i.bind(this.onLongActionEnd,this)),Common.Gateway.on("setemailaddresses",i.bind(this.onSetEmailAddresses,this)),Common.Gateway.on("processmailmerge",i.bind(this.onProcessMailMerge,this))),this},createDelayedControls:function(){var t=this,n=DE.enumLockMM;this.btnInsField=new Common.UI.Button({parentEl:e("#mmerge-btn-ins-field",t.$el),cls:"btn-text-menu-default",caption:this.textInsertField,style:"width: 100%;",lock:[n.noFields,n.preview,n.coAuth,n.lostConnect],menu:new Common.UI.Menu({style:"min-width: 190px;max-width: 400px;",maxHeight:200,items:[]})}),this.txtFieldNum=new Common.UI.InputField({el:e("#mmerge-field-num",t.$el),allowBlank:!0,validateOnChange:!1,style:"width: 80px; vertical-align: middle;",maskExp:/[0-9]/,value:1,validation:function(e){return/(^[0-9]+$)/.test(e)?(e=parseInt(e),void 0===e||null===e||e<1?t.txtFieldNum.setValue(1):e>t._state.recipientsCount&&t.txtFieldNum.setValue(t._state.recipientsCount)):t.txtFieldNum.setValue(1),!0},lock:[n.noRecipients,n.lostConnect]}).on("changed:after",function(e,i,n,o){var s=parseInt(t.txtFieldNum.getValue());s!==parseInt(n)&&(t.api.asc_PreviewMailMergeResult(s-1),t.fireEvent("editcomplete",t))}),this.emptyDBControls.push(this.txtFieldNum),this.btnEditData=new Common.UI.Button({el:t.$el.find("#mmerge-button-edit-data"),lock:[n.preview,n.lostConnect]}),this.btnEditData.on("click",i.bind(this.onEditData,this)),this.lblAddRecipients=e("#mmerge-lbl-add-recipients"),this.chHighlight=new Common.UI.Switcher({el:t.$el.find("#mmerge-switcher-highlight"),lock:[n.noFields,n.lostConnect]}),this.chHighlight.on("change",i.bind(this.onCheckHighlightChange,this)),this.chPreview=new Common.UI.Switcher({el:t.$el.find("#mmerge-switcher-preview"),lock:[n.noRecipients,n.lostConnect]}),this.chPreview.on("change",i.bind(this.onCheckPreviewChange,this)),this.emptyDBControls.push(this.chPreview),this.btnFirst=new Common.UI.Button({parentEl:e("#mmerge-button-first",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-firstitem",disabled:!0,value:0,hint:this.txtFirst,lock:[n.noRecipients,n.lostConnect]}),this.btnFirst.on("click",i.bind(this.onBtnPreviewFieldClick,this)),this.emptyDBControls.push(this.btnFirst),this.btnPrev=new Common.UI.Button({parentEl:e("#mmerge-button-prev",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-previtem",disabled:!0,value:1,hint:this.txtPrev,lock:[n.noRecipients,n.lostConnect]}),this.btnPrev.on("click",i.bind(this.onBtnPreviewFieldClick,this)),this.emptyDBControls.push(this.btnPrev),this.btnNext=new Common.UI.Button({parentEl:e("#mmerge-button-next",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-nextitem",value:2,hint:this.txtNext,lock:[n.noRecipients,n.lostConnect]}),this.btnNext.on("click",i.bind(this.onBtnPreviewFieldClick,this)),this.emptyDBControls.push(this.btnNext),this.btnLast=new Common.UI.Button({parentEl:e("#mmerge-button-last",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-lastitem",value:3,hint:this.txtLast,lock:[n.noRecipients,n.lostConnect]}),this.btnLast.on("click",i.bind(this.onBtnPreviewFieldClick,this)),this.emptyDBControls.push(this.btnLast),this._arrMergeSrc=[{displayValue:this.textPdf,value:Asc.c_oAscFileType.PDF},{displayValue:this.textDocx,value:Asc.c_oAscFileType.DOCX},{displayValue:this.textEmail,value:Asc.c_oAscFileType.HTML}],this.cmbMergeTo=new Common.UI.ComboBox({el:e("#mmerge-combo-merge-to",t.$el),cls:"input-group-nr",style:"width: 100%;",menuStyle:"min-width: 190px;",editable:!1,data:this._arrMergeSrc,lock:[n.noRecipients,n.lostConnect]}),this.cmbMergeTo.setValue(this._arrMergeSrc[0].value),this.cmbMergeTo.on("selected",i.bind(this.onCmbMergeToSelect,this)),this.emptyDBControls.push(this.cmbMergeTo),this.radioAll=new Common.UI.RadioBox({el:e("#mmerge-radio-all",t.$el),labelText:this.textAll,name:"asc-radio-merge",checked:!0,lock:[n.noRecipients,n.lostConnect]}).on("change",i.bind(this.onRadioAllCurrent,this)),this.emptyDBControls.push(this.radioAll),this.radioCurrent=new Common.UI.RadioBox({el:e("#mmerge-radio-current",t.$el),labelText:this.textCurrent,name:"asc-radio-merge",lock:[n.noRecipients,n.lostConnect]}).on("change",i.bind(this.onRadioAllCurrent,this)),this.emptyDBControls.push(this.radioCurrent),this.radioFromTo=new Common.UI.RadioBox({el:e("#mmerge-radio-from-to",t.$el),labelText:this.textFrom,name:"asc-radio-merge",lock:[n.noRecipients,n.lostConnect]}).on("change",i.bind(this.onRadioFromToChange,this)),this.emptyDBControls.push(this.radioFromTo),this.txtFieldFrom=new Common.UI.InputField({el:e("#mmerge-field-from",t.$el),allowBlank:!0,validateOnChange:!1,style:"width: 50px;",maskExp:/[0-9]/,value:0,disabled:!0,lock:[n.radioAllCurr,n.noRecipients,n.lostConnect],validation:function(e){/(^[0-9]+$)/.test(e)?(e=parseInt(e),void 0===e||null===e||e<1?t.txtFieldFrom.setValue(1):e>t._state.recipientsCount&&t.txtFieldFrom.setValue(t._state.recipientsCount)):t.txtFieldFrom.setValue(1),e=parseInt(t.txtFieldFrom.getValue());var i=Math.min(t._state.recipientsCount,e+99);if(parseInt(t.txtFieldTo.getValue())>i&&t.txtFieldTo.setValue(i),t._checkFromToValues){if(e>parseInt(t.txtFieldTo.getValue()))return t.txtFromToError;t._checkFromToValues=!1,t.txtFieldTo.checkValidate()}return!0}}),this.emptyDBControls.push(this.txtFieldFrom),this.txtFieldTo=new Common.UI.InputField({el:e("#mmerge-field-to",t.$el),allowBlank:!0,validateOnChange:!1,style:"width: 50px;",maskExp:/[0-9]/,value:0,disabled:!0,lock:[n.radioAllCurr,n.noRecipients,n.lostConnect],validation:function(e){if(/(^[0-9]+$)/.test(e))if(void 0===(e=parseInt(e))||null===e||e<1)t.txtFieldTo.setValue(1);else{var i=Math.min(t._state.recipientsCount,parseInt(t.txtFieldFrom.getValue())+99);e>i&&t.txtFieldTo.setValue(i)}else t.txtFieldTo.setValue(1);if(t._checkFromToValues){if(parseInt(t.txtFieldFrom.getValue())>parseInt(t.txtFieldTo.getValue()))return t.txtFromToError;t._checkFromToValues=!1,t.txtFieldFrom.checkValidate()}return!0}}),this.txtFieldTo.on("changed:after",function(){t._isToChanged=!0}),this.emptyDBControls.push(this.txtFieldTo),this.onRadioAllCurrent(this.radioAll,!0),this.btnDownload=new Common.UI.Button({el:e("#mmerge-button-download",t.$el),lock:[n.noRecipients,n.lostConnect]}).on("click",i.bind(this.onDownloadClick,this,!0)),this.emptyDBControls.push(this.btnDownload),this.btnPortal=new Common.UI.Button({el:e("#mmerge-button-portal",t.$el),lock:[n.noRecipients,n.lostConnect]}).on("click",i.bind(this.onDownloadClick,this,!1)),this.btnMerge=new Common.UI.Button({el:e("#mmerge-button-merge",t.$el),lock:[n.noRecipients,n.lostConnect]}).on("click",i.bind(this.onMergeClick,this,!1)),this.emptyDBControls.push(this.btnMerge),this.linkReadMore=e("#mmerge-readmore-link",this.$el),this.$el.on("click","#mmerge-readmore-link",i.bind(this.openHelp,this)),this.mode&&(this.mode.canRequestSaveAs||this.mode.mergeFolderUrl||this.btnPortal.setVisible(!1),this.mode.canSendEmailAddresses||(this._arrMergeSrc.pop(),this.cmbMergeTo.setData(this._arrMergeSrc),this.cmbMergeTo.setValue(this._arrMergeSrc[0].value))),this._initSettings=!1},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedControls(),this.disableInsertControls(this._locked),t){var e=this;this._state.recipientsCount=t.recipientsCount,this._state.fieldsList=t.fieldsList?t.fieldsList:[],this.btnInsField.menu.items.length<1&&i.each(this._state.fieldsList,function(t,i){var n=new Common.UI.MenuItem({caption:"«"+t+"»",field:t}).on("click",function(t,i){e.api&&(e.api.asc_AddMailMergeField(t.options.field),e.fireEvent("editcomplete",e))});e.btnInsField.menu.addItem(n)});var n=parseInt(this.txtFieldFrom.getValue());n=isNaN(n)?0:n-1,(n<0||n>this._state.recipientsCount-1)&&(n=0);var o=this._isToChanged?parseInt(this.txtFieldTo.getValue()):this._state.recipientsCount;o=isNaN(o)?0:o-1,(o<0||o>this._state.recipientsCount-1)&&(o=Math.max(this._state.recipientsCount-1,0)),n>o&&(n=0,o=this._state.recipientsCount-1),this.txtFieldFrom.setValue(n+1),this.txtFieldTo.setValue(Math.min(o+1,n+100));var s=parseInt(this.txtFieldNum.getValue());s=isNaN(s)?0:s-1,s<0&&(s=0),s>this._state.recipientsCount-1&&(s=this._state.recipientsCount-1),this.lockControls(DE.enumLockMM.noRecipients,this._state.recipientsCount<1,{array:this.mode.canRequestSaveAs||this.mode.mergeFolderUrl?[this.btnPortal]:[],merge:!0}),this.lockControls(DE.enumLockMM.noFields,this._state.fieldsList.length<1,{array:[this.btnInsField,this.chHighlight]}),this.lblAddRecipients[this._state.fieldsList.length<1?"show":"hide"](),this.disableFieldBtns(s)}},onEditData:function(){var t=DE.getController("Common.Controllers.ExternalMergeEditor").getView("Common.Views.ExternalMergeEditor");if(t){t.show();var e=this.api.asc_getMailMergeData();e&&t.setMergeData(e)}},onCheckHighlightChange:function(t,e,i){this.api&&this.api.asc_SetHighlightMailMergeFields(t.getValue()),this.fireEvent("editcomplete",this)},onCheckPreviewChange:function(t,e,i){var n=t.getValue(),o=parseInt(this.txtFieldNum.getValue());this.api&&(n?this.api.asc_PreviewMailMergeResult(isNaN(o)?0:o-1):this.api.asc_EndPreviewMailMergeResult()),this.fireEvent("editcomplete",this)},onRadioFromToChange:function(t,e,i){e&&this.lockControls(DE.enumLockMM.radioAllCurr,!1,{array:[this.txtFieldFrom,this.txtFieldTo]})},onRadioAllCurrent:function(t,e,i){e&&this.lockControls(DE.enumLockMM.radioAllCurr,!0,{array:[this.txtFieldFrom,this.txtFieldTo]})},checkFromToValues:function(){this._checkFromToValues=!0;var t=this.txtFieldFrom.checkValidate(),e=this.txtFieldTo.checkValidate();return!0!==t||!0!==e?(this.txtFieldTo.cmpEl.find("input").focus(),!1):(this._checkFromToValues=!1,!0)},onDownloadClick:function(t,n,o){if(this.api){var s=0,a=Math.min(Math.max(this._state.recipientsCount-1,0),99);if(this.radioCurrent.getValue())s=a=parseInt(this.txtFieldNum.getValue())-1;else if(this.radioFromTo.getValue()){if(!this.checkFromToValues())return;s=parseInt(this.txtFieldFrom.getValue())-1,a=parseInt(this.txtFieldTo.getValue())-1,a=Math.min(a,s+99),this.txtFieldTo.setValue(a+1)}if(this.api.asc_DownloadAsMailMerge(this.cmbMergeTo.getValue(),s,a,t)){if(!t){var r=DE.getController("Main");r.loadMask||(r.loadMask=new Common.UI.LoadMask({owner:e("#viewport")})),r.loadMask.setTitle(this.downloadMergeTitle),r.loadMask.show()}}else{var l={closable:!1,title:this.notcriticalErrorTitle,msg:this.errorMailMergeSaveFile,iconCls:"warn",buttons:["ok"],callback:i.bind(function(t){this.fireEvent("editcomplete",this)},this)};Common.UI.alert(l)}}},onSaveMailMerge:function(t){var e=DE.getController("Main").loadMask;if(e&&e.hide(),!this._mailMergeDlg){var i=this;if(this.cmbMergeTo.getValue()!=Asc.c_oAscFileType.HTML){var n=i.defFileName+(this.cmbMergeTo.getValue()==Asc.c_oAscFileType.PDF?".pdf":".docx");i.mode.canRequestSaveAs?Common.Gateway.requestSaveAs(t,n):(i._mailMergeDlg=new Common.Views.SaveAsDlg({saveFolderUrl:i.mode.mergeFolderUrl,saveFileUrl:t,defFileName:n}),i._mailMergeDlg.on("saveasfolder",function(t,e){}).on("saveaserror",function(t,e){var n={closable:!1,title:i.notcriticalErrorTitle,msg:e,iconCls:"warn",buttons:["ok"],callback:function(t){i.fireEvent("editcomplete",i)}};Common.UI.alert(n)}).on("close",function(t){i._mailMergeDlg=void 0}),i._mailMergeDlg.show())}}},onMergeClick:function(t,i,n){var o=0,s=Math.min(Math.max(this._state.recipientsCount-1,0),99);if(this.radioFromTo.getValue()){if(!this.checkFromToValues())return;o=parseInt(this.txtFieldFrom.getValue())-1,s=parseInt(this.txtFieldTo.getValue())-1,s=Math.min(s,o+99),this.txtFieldTo.setValue(s+1)}if(void 0==this.emailAddresses){var a=DE.getController("Main");a.loadMask||(a.loadMask=new Common.UI.LoadMask({owner:e("#viewport")})),a.loadMask.setTitle(this.requestMailsTitle),a.loadMask.show(),Common.Gateway.requestEmailAddresses()}else this.showMergeMailDlg()},onSetEmailAddresses:function(t){var e=DE.getController("Main").loadMask;if(e&&e.hide(),t&&t.data)if(t.data.error){var n={width:500,closable:!1,title:this.notcriticalErrorTitle,msg:t.data.error,iconCls:"warn",buttons:i.isEmpty(t.data.createEmailAccountUrl)?["ok"]:["custom","cancel"],primary:i.isEmpty(t.data.createEmailAccountUrl)?["ok"]:"custom",customButtonText:this.textGoToMail,callback:i.bind(function(e){"custom"==e&&window.open(t.data.createEmailAccountUrl,"_blank"),this.fireEvent("editcomplete",this)},this)};Common.UI.alert(n)}else this.emailAddresses=t.data.emailAddresses,this.showMergeMailDlg()},showMergeMailDlg:function(){if(!this._mailMergeDlg){var t=this;t._mailMergeDlg=new DE.Views.MailMergeEmailDlg({props:{fieldsList:this._state.fieldsList,emailAddresses:this.emailAddresses},handler:function(i,n){if("ok"==i){t.mergeMailData=n;var o=DE.getController("Main");o.loadMask||(o.loadMask=new Common.UI.LoadMask({owner:e("#viewport")})),o.loadMask.setTitle(t.downloadMergeTitle),o.loadMask.show(),Common.Gateway.requestStartMailMerge()}t.fireEvent("editcomplete",t)}}),t._mailMergeDlg.on("close",function(e){t._mailMergeDlg=void 0}),t._mailMergeDlg.show()}},onProcessMailMerge:function(t){var e=DE.getController("Main").loadMask;if(e&&e.hide(),t)if(t.enabled)this.sendMergeDataByEmail();else{var n={closable:!1,title:this.notcriticalErrorTitle,msg:i.isEmpty(t.message)?this.warnProcessMailMerge:t.message,iconCls:"warn",buttons:["ok"],callback:i.bind(function(t){this.fireEvent("editcomplete",this)},this)};Common.UI.alert(n)}},sendMergeDataByEmail:function(){if(this.api){var t=0,e=Math.min(Math.max(this._state.recipientsCount-1,0),99);this.radioCurrent.getValue()?t=e=parseInt(this.txtFieldNum.getValue())-1:this.radioFromTo.getValue()&&(t=parseInt(this.txtFieldFrom.getValue())-1,e=parseInt(this.txtFieldTo.getValue())-1);var i=new Asc.CMailMergeSendData;i.put_RecordFrom(t),i.put_RecordTo(e),i.put_From(this.mergeMailData.from),i.put_To(this.mergeMailData.to),i.put_Subject(this.mergeMailData.subject),i.put_MailFormat(this.mergeMailData.mailFormat),this.mergeMailData.mailFormat!==Asc.c_oAscFileType.HTML&&(i.put_FileName(this.mergeMailData.fileName),i.put_Message(this.mergeMailData.message)),this.api.asc_sendMailMergeData(i),this.fireEvent("editcomplete",this)}},onLongActionEnd:function(t,e){e==Asc.c_oAscAsyncAction.SendMailMerge&&Common.UI.info({closable:!1,width:500,msg:this.textSendMsg,iconCls:"info",buttons:["ok"],callback:i.bind(function(t){this.fireEvent("editcomplete",this)},this)})},onBtnPreviewFieldClick:function(t,e){var i=parseInt(this.txtFieldNum.getValue());switch(i=isNaN(i)?0:i-1,t.options.value){case 0:i=0;break;case 1:i--;break;case 2:i++;break;case 3:i=this._state.recipientsCount-1}i<0&&(i=0),i>this._state.recipientsCount-1&&(i=this._state.recipientsCount-1),this.api.asc_PreviewMailMergeResult(i),this.fireEvent("editcomplete",this)},disableFieldBtns:function(t){var e=this._state.recipientsCount<1||!this.chPreview.getValue(),i=e||t<1;this.btnFirst.isDisabled()!==i&&this.btnFirst.setDisabled(i),this.btnPrev.isDisabled()!==i&&this.btnPrev.setDisabled(i),i=e||t>this._state.recipientsCount-2,this.btnLast.isDisabled()!==i&&this.btnLast.setDisabled(i),this.btnNext.isDisabled()!==i&&this.btnNext.setDisabled(i),i=e||t<0,this.txtFieldNum.isDisabled()!==i&&this.txtFieldNum.setDisabled(i),t>=0&&this.txtFieldNum.setValue(t+1)},onPreviewMailMergeResult:function(t){this.chPreview.getValue()||this.chPreview.setValue(!0),this.disableFieldBtns(t),this.disableEditing(!0)},onEndPreviewMailMergeResult:function(){this.chPreview.getValue()&&this.chPreview.setValue(!1),this.disableFieldBtns(-1),this.disableEditing(!1)},onStartMailMerge:function(){this.btnInsField&&this.btnInsField.menu.removeAll(),this.txtFieldNum&&this.txtFieldNum.setValue(1),this.ChangeSettings({recipientsCount:this.api.asc_GetReceptionsCount(),fieldsList:this.api.asc_GetMailMergeFieldsNameList()})},onCmbMergeToSelect:function(t,e){var i=e.value==Asc.c_oAscFileType.HTML;this.btnMerge.setVisible(i),this.btnPortal.setVisible(!i&&(this.mode.canRequestSaveAs||this.mode.mergeFolderUrl)),this.btnDownload.setVisible(!i)},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||this.lockControls(DE.enumLockMM.lostConnect,t,{array:i.union([this.btnEditData,this.btnInsField,this.chHighlight],this.mode.canRequestSaveAs||this.mode.mergeFolderUrl?[this.btnPortal]:[]),merge:!0})},disableInsertControls:function(t){this.lockControls(DE.enumLockMM.coAuth,t,{array:[this.btnInsField]})},setMode:function(t){this.mode=t},disableEditing:function(t){DE.getController("Toolbar").DisableToolbar(t,t),DE.getController("RightMenu").SetDisabled(t,!0),DE.getController("Statusbar").getView("Statusbar").SetDisabled(t),DE.getController("Common.Controllers.ReviewChanges").SetDisabled(t),DE.getController("DocumentHolder").getView().SetDisabled(t),DE.getController("Navigation")&&DE.getController("Navigation").SetDisabled(t);var e=DE.getController("Common.Controllers.Comments");e&&e.setPreviewMode(t),DE.getController("LeftMenu").setPreviewMode(t),this.lockControls(DE.enumLockMM.preview,t,{array:[this.btnInsField,this.btnEditData]})},setDocumentName:function(t){this.defFileName=t||this.txtUntitled;var e=this.defFileName.lastIndexOf(".");e>0&&(this.defFileName=this.defFileName.substring(0,e))},openHelp:function(t){DE.getController("LeftMenu").getView("LeftMenu").showMenu("file:help","UsageInstructions/UseMailMerge.htm")},disablePreviewMode:function(){this.api&&this.chPreview&&this.chPreview.getValue()&&this.api.asc_EndPreviewMailMergeResult()},lockControls:function(t,e,i){Common.Utils.lockControls(t,e,i,this.emptyDBControls)},textDataSource:"Data Source",textEditData:"Edit recipients list",textInsertField:"Insert Merge Field",textHighlight:"Highlight merge fields",textPreview:"Preview results",textPdf:"PDF",textDocx:"Docx",textEmail:"E-mail",txtFirst:"To first field",txtPrev:"To previous field",txtNext:"To next field",txtLast:"To last field",textMergeTo:"Merge to",textAll:"All records",textCurrent:"Current record",textFrom:"From",textTo:"To",textDownload:"Download",textPortal:"Save",errorMailMergeSaveFile:"Merge failed.",downloadMergeTitle:"Merging",requestMailsTitle:"Requesting e-mails",textMerge:"Merge",sendTitle:"Send e-mail",textSendMsg:"All mail messages are ready and will be sent out within some time.
    The speed of mailing depends on your mail service.
    You can continue working with document or close it. After the operation is over the notification will be sent to your registration email address.",notcriticalErrorTitle:"Warning",warnProcessMailMerge:"Starting merge failed",txtUntitled:"Untitled",textMaxRecepients:"Max 100 recipients.",textReadMore:"Read more",txtFromToError:'"From" value must be less than "To" value',textMergeFields:"Merge Fields",textGoToMail:"Go to Mail",textAddRecipients:"Add some recipients to the list first"},DE.Views.MailMergeSettings||{}))}),define("text!documenteditor/main/app/template/TextArtSettings.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    '}),define("documenteditor/main/app/view/TextArtSettings",["text!documenteditor/main/app/template/TextArtSettings.template","jquery","underscore","backbone","common/main/lib/component/ComboBox","common/main/lib/component/ComboBorderSize","common/main/lib/component/MetricSpinner","common/main/lib/component/ThemeColorPalette","common/main/lib/component/ColorButton","common/main/lib/component/ComboDataView","common/main/lib/component/Slider","common/main/lib/component/MultiSliderGradient"],function(t,e,i,n){"use strict";DE.Views.TextArtSettings=n.View.extend(i.extend({el:"#id-textart-settings",template:i.template(t),events:{},options:{alias:"TextArtSettings"},initialize:function(){this._initSettings=!0,this._noApply=!0,this.imgprops=null,this.shapeprops=null,this._sendUndoPoint=!0,this._sliderChanged=!1,this.txtPt=Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt),this._state={Transparency:null,FillType:Asc.c_oAscFill.FILL_TYPE_SOLID,ShapeColor:"transparent",StrokeType:Asc.c_oAscStrokeType.STROKE_COLOR,StrokeWidth:this._pt2mm(1),StrokeColor:"000000",StrokeBorderType:Asc.c_oDashType.solid,GradColor:"000000",GradFillType:Asc.c_oAscFillGradType.GRAD_LINEAR,FormId:null,DisabledControls:!1},this.lockedControls=[],this._locked=!1,this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_SOLID,this.ShapeColor={Value:1,Color:"transparent"},this.GradFillType=Asc.c_oAscFillGradType.GRAD_LINEAR,this.GradColor={values:[0,100],colors:["000000","ffffff"],currentIdx:0},this.GradRadialDirectionIdx=0,this.GradLinearDirectionType=0,this.BorderColor={Value:1,Color:"transparent"},this.BorderSize=0,this.BorderType=Asc.c_oDashType.solid,DE.getCollection("Common.Collections.TextArt").bind({reset:this.fillTextArt.bind(this)}),this.render()},render:function(){(this.$el||e(this.el)).html(this.template({scope:this})),this.FillColorContainer=e("#textart-panel-color-fill"),this.FillGradientContainer=e("#textart-panel-gradient-fill"),this.TransparencyContainer=e("#textart-panel-transparent-fill")},setApi:function(t){return this.api=t,this},onFillSrcSelect:function(t,e){switch(this.ShowHideElem(e.value),e.value){case Asc.c_oAscFill.FILL_TYPE_SOLID:if(this._state.FillType=Asc.c_oAscFill.FILL_TYPE_SOLID,!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_SOLID),n.put_fill(new Asc.asc_CFillSolid),n.get_fill().put_color(Common.Utils.ThemeColor.getRgbColor("transparent"==this.ShapeColor.Color?{color:"4f81bd",effectId:24}:this.ShapeColor.Color)),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}break;case Asc.c_oAscFill.FILL_TYPE_GRAD:if(this._state.FillType=Asc.c_oAscFill.FILL_TYPE_GRAD,!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;if(n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad),n.get_fill().put_grad_type(this.GradFillType), -this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),this.OriginalFillType!==Asc.c_oAscFill.FILL_TYPE_GRAD){this.GradColor.values=[0,100],this.GradColor.colors=[this.GradColor.colors[0],this.GradColor.colors[this.GradColor.colors.length-1]],this.GradColor.currentIdx=0;var o=Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[0]).get_color().get_hex(),s=Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[1]).get_color().get_hex();o="ffffff"===o&&"ffffff"===s?{color:"4f81bd",effectId:24}:this.GradColor.colors[0],n.get_fill().put_positions([1e3*this.GradColor.values[0],1e3*this.GradColor.values[1]]),n.get_fill().put_colors([Common.Utils.ThemeColor.getRgbColor(o),Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[1])])}i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}break;case Asc.c_oAscFill.FILL_TYPE_NOFILL:if(this._state.FillType=Asc.c_oAscFill.FILL_TYPE_NOFILL,!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_NOFILL),n.put_fill(null),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}}this.fireEvent("editcomplete",this)},onColorsBackSelect:function(t,e){if(this.ShapeColor={Value:1,Color:e},this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;"transparent"==this.ShapeColor.Color?(n.put_type(Asc.c_oAscFill.FILL_TYPE_NOFILL),n.put_fill(null)):(n.put_type(Asc.c_oAscFill.FILL_TYPE_SOLID),n.put_fill(new Asc.asc_CFillSolid),n.get_fill().put_color(Common.Utils.ThemeColor.getRgbColor(this.ShapeColor.Color))),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onNumTransparencyChange:function(t,e,i,n){if(this.sldrTransparency.setValue(t.getNumberValue(),!0),this.api){var o=t.getNumberValue(),s=new Asc.asc_TextArtProperties,a=new Asc.asc_CShapeFill;a.put_transparent(2.55*o),s.asc_putFill(a),this.shapeprops.put_TextArtProperties(s),this.api.ImgApply(this.imgprops)}},onTransparencyChange:function(t,e,n){this._sliderChanged=e,this.numTransparency.setValue(e,!0),this._sendUndoPoint&&(this.api.setStartPointHistory(),this._sendUndoPoint=!1,this.updateslider=setInterval(i.bind(this._transparencyApplyFunc,this),100))},onTransparencyChangeComplete:function(t,e,i){clearInterval(this.updateslider),this._sliderChanged=e,this._sendUndoPoint||(this.api.setEndPointHistory(),this._transparencyApplyFunc()),this._sendUndoPoint=!0},_transparencyApplyFunc:function(){if(void 0!==this._sliderChanged){var t=new Asc.asc_TextArtProperties,e=new Asc.asc_CShapeFill;e.put_transparent(2.55*this._sliderChanged),t.asc_putFill(e),this.shapeprops.put_TextArtProperties(t),this.api.ImgApply(this.imgprops),this._sliderChanged=void 0}},onGradTypeSelect:function(t,e){if(this.GradFillType=e.value,this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){this.mnuDirectionPicker.store.reset(this._viewDataLinear),this.mnuDirectionPicker.cmpEl.width(175),this.mnuDirectionPicker.restoreHeight=174;var e=this.mnuDirectionPicker.store.findWhere({type:this.GradLinearDirectionType});this.mnuDirectionPicker.selectRecord(e,!0),e?this.btnDirection.setIconCls("item-gradient "+e.get("iconcls")):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(this.GradLinearDirectionType,!0),this.numGradientAngle.setDisabled(this._locked)}else this.GradFillType==Asc.c_oAscFillGradType.GRAD_PATH&&(this.mnuDirectionPicker.store.reset(this._viewDataRadial),this.mnuDirectionPicker.cmpEl.width(60),this.mnuDirectionPicker.restoreHeight=58,this.mnuDirectionPicker.selectByIndex(this.GradRadialDirectionIdx,!0),this.GradRadialDirectionIdx>=0?this.btnDirection.setIconCls("item-gradient "+this._viewDataRadial[this.GradRadialDirectionIdx].iconcls):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(0,!0),this.numGradientAngle.setDisabled(!0));if(this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad),n.get_fill().put_grad_type(this.GradFillType),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onSelectGradient:function(t,e,n,o){if(!this._noApply){var s={};if(i.isFunction(o.toJSON)){if(!o.get("selected"))return;s=o.toJSON()}else s=o;if(this.btnDirection.setIconCls("item-gradient "+s.iconcls),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR?this.GradLinearDirectionType=s.type:this.GradRadialDirectionIdx=0,this.api&&this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){this.numGradientAngle.setValue(s.type,!0);var a=new Asc.asc_TextArtProperties,r=new Asc.asc_CShapeFill;r.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),r.put_fill(new Asc.asc_CFillGrad),r.get_fill().put_grad_type(this.GradFillType),r.get_fill().put_linear_angle(6e4*s.type),r.get_fill().put_linear_scale(!0),a.asc_putFill(r),this.shapeprops.put_TextArtProperties(a),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)}},onColorsGradientSelect:function(t,e){if(this.GradColor.colors[this.GradColor.currentIdx]=e,this.sldrGradient.setColorValue(Common.Utils.String.format("#{0}","object"==typeof e?e.color:e)),this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad),n.get_fill().put_grad_type(this.GradFillType);var o=[];this.GradColor.colors.forEach(function(t){o.push(Common.Utils.ThemeColor.getRgbColor(t))}),n.get_fill().put_colors(o),this.OriginalFillType!==Asc.c_oAscFill.FILL_TYPE_GRAD&&(this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),o=[],this.GradColor.values.forEach(function(t){o.push(1e3*t)}),n.get_fill().put_positions(o)),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onGradientChange:function(t,e,n){this.GradColor.values=t.getValues(),this.spnGradPosition.setValue(this.GradColor.values[this.GradColor.currentIdx],!0),this._sliderChanged=!0,this.api&&!this._noApply&&this._sendUndoPoint&&(this.api.setStartPointHistory(),this._sendUndoPoint=!1,this.updateslider=setInterval(i.bind(this._gradientApplyFunc,this),100))},onGradientChangeComplete:function(t,e,i){clearInterval(this.updateslider),this._sliderChanged=!0,this._sendUndoPoint||(this.api.setEndPointHistory(),this._gradientApplyFunc()),this._sendUndoPoint=!0},_gradientApplyFunc:function(){if(this._sliderChanged){var t=new Asc.asc_TextArtProperties,e=new Asc.asc_CShapeFill;e.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),e.put_fill(new Asc.asc_CFillGrad),e.get_fill().put_grad_type(this.GradFillType);var i=[];this.GradColor.values.forEach(function(t){i.push(1e3*t)}),e.get_fill().put_positions(i),this.OriginalFillType!==Asc.c_oAscFill.FILL_TYPE_GRAD&&(this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(e.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),e.get_fill().put_linear_scale(!0)),i=[],this.GradColor.colors.forEach(function(t){i.push(Common.Utils.ThemeColor.getRgbColor(t))}),e.get_fill().put_colors(i)),t.asc_putFill(e),this.shapeprops.put_TextArtProperties(t),this.api.ImgApply(this.imgprops),this._sliderChanged=!1}},applyBorderSize:function(t){if(t=Common.Utils.String.parseFloat(t),t=isNaN(t)?0:Math.max(0,Math.min(1584,t)),this.BorderSize=t,this.api&&!this._noApply){var e=new Asc.asc_TextArtProperties,i=new Asc.asc_CStroke;this.BorderSize<1e-5?(i.put_type(Asc.c_oAscStrokeType.STROKE_NONE),this._state.StrokeType=this._state.StrokeWidth=-1):(i.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),"transparent"==this.BorderColor.Color||"transparent"==this.BorderColor.Color.color?i.put_color(Common.Utils.ThemeColor.getRgbColor({color:"000000",effectId:29})):this._state.StrokeType!=Asc.c_oAscStrokeType.STROKE_NONE&&null!==this._state.StrokeType||i.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(this.BorderColor.Color))),i.asc_putPrstDash(this.BorderType),i.put_width(this._pt2mm(this.BorderSize))),e.asc_putLine(i),this.shapeprops.put_TextArtProperties(e),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onComboBlur:function(){this.fireEvent("editcomplete",this)},onBorderSizeChanged:function(t,e,n,o){var s=this;if(t){var a=parseFloat(n.value);(!new RegExp("^\\s*(\\d*(\\.|,)?\\d+)\\s*("+s.txtPt+")?\\s*$").exec(n.value)||a<0||a>1584)&&(this._state.StrokeType=this._state.StrokeWidth=-1,Common.UI.error({msg:this.textBorderSizeErr,callback:function(){i.defer(function(t){s.fireEvent("editcomplete",s)})}}))}else this.applyBorderSize(n.value)},onBorderSizeSelect:function(t,e){this.applyBorderSize(e.value)},onBorderTypeSelect:function(t,e){if(this.BorderType=e.value,this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CStroke;this.BorderSize<1e-5?n.put_type(Asc.c_oAscStrokeType.STROKE_NONE):(n.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),n.put_color(Common.Utils.ThemeColor.getRgbColor(this.BorderColor.Color)),n.put_width(this._pt2mm(this.BorderSize)),n.asc_putPrstDash(this.BorderType)),i.asc_putLine(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onColorsBorderSelect:function(t,e){if(this.BorderColor={Value:1,Color:e},this.api&&this.BorderSize>0&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CStroke;this.BorderSize<1e-5?n.put_type(Asc.c_oAscStrokeType.STROKE_NONE):(n.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),n.put_color(Common.Utils.ThemeColor.getRgbColor(this.BorderColor.Color)),n.put_width(this._pt2mm(this.BorderSize)),n.asc_putPrstDash(this.BorderType)),i.asc_putLine(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},ChangeSettings:function(t){if(null==this.imgprops?(this.imgprops=new Asc.asc_CImgProperty,this.imgprops.put_ShapeProperties(new Asc.asc_CShapeProperty),this.shapeprops=this.imgprops.get_ShapeProperties()):this.imgprops.put_ImageUrl(null),this._initSettings&&this.createDelayedElements(),t&&t.get_ShapeProperties()&&t.get_ShapeProperties().get_TextArtProperties()){var e=t.get_ShapeProperties().get_TextArtProperties();this._noApply=!0,this.disableControls(this._locked);var n=null,o=e.asc_getFill(),s=o?o.get_type():null,a=null;if(o){var r=o.get_transparent();(Math.abs(this._state.Transparency-r)>.001||Math.abs(this.numTransparency.getNumberValue()-r)>.001||(null===this._state.Transparency||null===r)&&(this._state.Transparency!==r||this.numTransparency.getNumberValue()!==r))&&(void 0!==r&&(this.sldrTransparency.setValue(null===r?100:r/255*100,!0),this.numTransparency.setValue(this.sldrTransparency.getValue(),!0)),this._state.Transparency=r)}if(null===o||void 0===o||null===s)this.OriginalFillType=null;else if(s==Asc.c_oAscFill.FILL_TYPE_NOFILL)this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_NOFILL;else if(s==Asc.c_oAscFill.FILL_TYPE_SOLID)o=o.get_fill(),a=o.get_color(),a?a.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.ShapeColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b()),effectValue:a.get_value()}}:this.ShapeColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b())}:this.ShapeColor={Value:0,Color:"transparent"},this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_SOLID,this.GradColor.colors[0]="transparent"!==this.ShapeColor.Color?Common.Utils.ThemeColor.colorValue2EffectId(this.ShapeColor.Color):"000000",this.GradColor.colors[this.GradColor.colors.length-1]="ffffff";else if(s==Asc.c_oAscFill.FILL_TYPE_GRAD){o=o.get_fill();var l=o.get_grad_type();if(this._state.GradFillType===l&&this.GradFillType===l||(this.GradFillType=l,n=void 0,this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR||this.GradFillType==Asc.c_oAscFillGradType.GRAD_PATH?(this.cmbGradType.setValue(this.GradFillType),n=this.cmbGradType.store.findWhere({value:this.GradFillType}),this.onGradTypeSelect(this.cmbGradType,n.attributes)):(this.cmbGradType.setValue(""),this.btnDirection.setIconCls("")),this._state.GradFillType=this.GradFillType),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){var c=Math.floor(o.get_linear_angle()/6e4);if(Math.abs(this.GradLinearDirectionType-c)>.001){this.GradLinearDirectionType=c;var d=this.mnuDirectionPicker.store.findWhere({type:c});this.mnuDirectionPicker.selectRecord(d,!0),d?this.btnDirection.setIconCls("item-gradient "+d.get("iconcls")):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(c,!0)}}else this.numGradientAngle.setValue(0,!0);var h=this,p=o.get_colors(),m=o.get_positions(),u=p?p.length:this.GradColor.colors.length;this.sldrGradient.setThumbs(u),this.GradColor.colors.length>u&&(this.GradColor.colors.splice(u,this.GradColor.colors.length-u),this.GradColor.values.splice(u,this.GradColor.colors.length-u),this.GradColor.currentIdx=0),p&&p.forEach(function(t,e){t?t.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?(h.GradColor.colors[e]={color:Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()),effectValue:t.get_value()},Common.Utils.ThemeColor.colorValue2EffectId(h.GradColor.colors[e])):h.GradColor.colors[e]=Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()):h.GradColor.colors[e]="000000";var i=m[e];null!==i&&(i/=1e3,h.GradColor.values[e]=i)});for(var g=0;g=this.GradColor.colors.length)&&(h.GradColor.currentIdx=0),h.sldrGradient.setActiveThumb(h.GradColor.currentIdx),this.spnGradPosition.setValue(this.GradColor.values[this.GradColor.currentIdx]),this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_GRAD,this.ShapeColor={Value:1,Color:this.GradColor.colors[0]}}this._state.FillType!==this.OriginalFillType&&(this.cmbFillSrc.setValue(null===this.OriginalFillType?"":this.OriginalFillType),this._state.FillType=this.OriginalFillType,this.ShowHideElem(this.OriginalFillType));var b=typeof this.ShapeColor.Color,f=typeof this._state.ShapeColor;if(b!==f||"object"==b&&(this.ShapeColor.Color.effectValue!==this._state.ShapeColor.effectValue||this._state.ShapeColor.color.indexOf(this.ShapeColor.Color.color)<0)||"object"!=b&&this._state.ShapeColor.indexOf(this.ShapeColor.Color)<0){if(this.btnBackColor.setColor(this.ShapeColor.Color),"object"==typeof this.ShapeColor.Color){for(var C=!1,v=0;v<10;v++)if(Common.Utils.ThemeColor.ThemeValues[v]==this.ShapeColor.Color.effectValue){this.colorsBack.select(this.ShapeColor.Color,!0),C=!0;break}C||this.colorsBack.clearSelection()}else this.colorsBack.select(this.ShapeColor.Color,!0);this._state.ShapeColor=this.ShapeColor.Color}var _,y=e.asc_getLine(),w=y?y.get_type():null,x="transparent"==this._state.StrokeColor&&"transparent"!==this.BorderColor.Color;if(y?(w==Asc.c_oAscStrokeType.STROKE_COLOR?(a=y.get_color(),a?a.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.BorderColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b()),effectValue:a.get_value()}}:this.BorderColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b())}:this.BorderColor={Value:1,Color:"transparent"}):this.BorderColor={Value:1,Color:"transparent"},_=y.asc_getPrstDash()):this.BorderColor={Value:0,Color:"transparent"},b=typeof this.BorderColor.Color,f=typeof this._state.StrokeColor,x||b!==f||"object"==b&&(this.BorderColor.Color.effectValue!==this._state.StrokeColor.effectValue||this._state.StrokeColor.color.indexOf(this.BorderColor.Color.color)<0)||"object"!=b&&(this._state.StrokeColor.indexOf(this.BorderColor.Color)<0||"object"==typeof this.btnBorderColor.color)){if(this.btnBorderColor.setColor(this.BorderColor.Color),"object"==typeof this.BorderColor.Color){for(var C=!1,v=0;v<10;v++)if(Common.Utils.ThemeColor.ThemeValues[v]==this.BorderColor.Color.effectValue){this.colorsBorder.select(this.BorderColor.Color,!0),C=!0;break}C||this.colorsBorder.clearSelection()}else this.colorsBorder.select(this.BorderColor.Color,!0);this._state.StrokeColor=this.BorderColor.Color}if(this._state.StrokeType!==w||w==Asc.c_oAscStrokeType.STROKE_COLOR){if(w==Asc.c_oAscStrokeType.STROKE_COLOR){var S=y.get_width(),A=Math.abs(this._state.StrokeWidth-S)<1e-5&&!new RegExp(this.txtPt+"\\s*$").test(this.cmbBorderSize.getRawValue());if(Math.abs(this._state.StrokeWidth-S)>1e-5||A||(null===this._state.StrokeWidth||null===S)&&this._state.StrokeWidth!==S){this._state.StrokeWidth=S,null!==S&&(S=this._mm2pt(S));var k=null===S?S:i.find(this.cmbBorderSize.store.models,function(t){if(St.attributes.value-1e-5)return!0});k?this.cmbBorderSize.selectRecord(k):this.cmbBorderSize.setValue(null!==S?parseFloat(S.toFixed(2))+" "+this.txtPt:""),this.BorderSize=S}}else w==Asc.c_oAscStrokeType.STROKE_NONE?(this._state.StrokeWidth=0,this.BorderSize=this.cmbBorderSize.store.at(0).get("value"),this.cmbBorderSize.setValue(this.BorderSize)):(this._state.StrokeWidth=null,this.BorderSize=-1,this.cmbBorderSize.setValue(null));this._state.StrokeType=w}if(this._state.StrokeBorderType!==_&&(this.BorderType=this._state.StrokeBorderType=_,this.cmbBorderType.setValue(_)),a=this.GradColor.colors[this.GradColor.currentIdx],b=typeof a,f=typeof this._state.GradColor,b!==f||"object"==b&&(a.effectValue!==this._state.GradColor.effectValue||this._state.GradColor.color.indexOf(a.color)<0)||"object"!=b&&this._state.GradColor.indexOf(a)<0){if(this.btnGradColor.setColor(a),"object"==typeof a){for(var C=!1,v=0;v<10;v++)if(Common.Utils.ThemeColor.ThemeValues[v]==a.effectValue){this.colorsGrad.select(a,!0),C=!0;break}C||this.colorsGrad.clearSelection()}else this.colorsGrad.select(a,!0);this._state.GradColor=a}var T=e.asc_getForm();if(this._state.FormId!==T){this.cmbTransform.suspendEvents();var n=this.cmbTransform.menuPicker.store.findWhere({type:T});this.cmbTransform.menuPicker.selectRecord(n),this.cmbTransform.resumeEvents(),this._state.FormId=T}this._noApply=!1}},createDelayedControls:function(){var t=this;this._arrFillSrc=[{displayValue:this.textColor,value:Asc.c_oAscFill.FILL_TYPE_SOLID},{displayValue:this.textGradientFill,value:Asc.c_oAscFill.FILL_TYPE_GRAD},{displayValue:this.textNoFill,value:Asc.c_oAscFill.FILL_TYPE_NOFILL}],this.cmbFillSrc=new Common.UI.ComboBox({el:e("#textart-combo-fill-src"),cls:"input-group-nr",style:"width: 100%;",menuStyle:"min-width: 100%;",editable:!1,data:this._arrFillSrc}),this.cmbFillSrc.setValue(this._arrFillSrc[0].value),this.cmbFillSrc.on("selected",i.bind(this.onFillSrcSelect,this)),this.lockedControls.push(this.cmbFillSrc),this.numTransparency=new Common.UI.MetricSpinner({el:e("#textart-spin-transparency"),step:1,width:62,value:"100 %",defaultUnit:"%",maxValue:100,minValue:0}),this.numTransparency.on("change",i.bind(this.onNumTransparencyChange,this)),this.numTransparency.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.lockedControls.push(this.numTransparency),this.sldrTransparency=new Common.UI.SingleSlider({el:e("#textart-slider-transparency"),width:75,minValue:0,maxValue:100,value:100}),this.sldrTransparency.on("change",i.bind(this.onTransparencyChange,this)),this.sldrTransparency.on("changecomplete",i.bind(this.onTransparencyChangeComplete,this)),this.lockedControls.push(this.sldrTransparency),this.lblTransparencyStart=e(this.el).find("#textart-lbl-transparency-start"),this.lblTransparencyEnd=e(this.el).find("#textart-lbl-transparency-end"),this._arrGradType=[{displayValue:this.textLinear,value:Asc.c_oAscFillGradType.GRAD_LINEAR},{displayValue:this.textRadial,value:Asc.c_oAscFillGradType.GRAD_PATH}],this.cmbGradType=new Common.UI.ComboBox({el:e("#textart-combo-grad-type"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrGradType}),this.cmbGradType.setValue(this._arrGradType[0].value),this.cmbGradType.on("selected",i.bind(this.onGradTypeSelect,this)),this.lockedControls.push(this.cmbGradType),this._viewDataLinear=[{offsetx:0,offsety:0,type:45,subtype:-1,iconcls:"gradient-left-top"},{offsetx:50,offsety:0,type:90,subtype:4,iconcls:"gradient-top"},{offsetx:100,offsety:0,type:135,subtype:5,iconcls:"gradient-right-top"},{offsetx:0,offsety:50,type:0,subtype:6,iconcls:"gradient-left",cls:"item-gradient-separator",selected:!0},{offsetx:100,offsety:50,type:180,subtype:1,iconcls:"gradient-right"},{offsetx:0,offsety:100,type:315,subtype:2,iconcls:"gradient-left-bottom"},{offsetx:50,offsety:100,type:270,subtype:3,iconcls:"gradient-bottom"},{offsetx:100,offsety:100,type:225,subtype:7,iconcls:"gradient-right-bottom"}],this._viewDataRadial=[{offsetx:100,offsety:150,type:2,subtype:5,iconcls:"gradient-radial-center"}],this.btnDirection=new Common.UI.Button({cls:"btn-large-dataview",iconCls:"item-gradient gradient-left",menu:new Common.UI.Menu({style:"min-width: 60px;",menuAlign:"tr-br",items:[{template:i.template('
    ')}]})}),this.btnDirection.on("render:after",function(n){t.mnuDirectionPicker=new Common.UI.DataView({el:e("#id-textart-menu-direction"),parentMenu:n.menu,restoreHeight:174,store:new Common.UI.DataViewStore(t._viewDataLinear),itemTemplate:i.template('
    ')})}),this.btnDirection.render(e("#textart-button-direction")),this.mnuDirectionPicker.on("item:click",i.bind(this.onSelectGradient,this,this.btnDirection)),this.lockedControls.push(this.btnDirection),this.sldrGradient=new Common.UI.MultiSliderGradient({el:e("#textart-slider-gradient"),width:192,minValue:0,maxValue:100,values:[0,100]}),this.sldrGradient.on("change",i.bind(this.onGradientChange,this)),this.sldrGradient.on("changecomplete",i.bind(this.onGradientChangeComplete,this)),this.sldrGradient.on("thumbclick",function(e,i){t.GradColor.currentIdx=i;var n=t.GradColor.colors[t.GradColor.currentIdx];t.btnGradColor.setColor(n),t.colorsGrad.select(n,!1);var o=t.GradColor.values[t.GradColor.currentIdx];t.spnGradPosition.setValue(o,!0)}),this.sldrGradient.on("thumbdblclick",function(e){t.btnGradColor.cmpEl.find("button").dropdown("toggle")}),this.sldrGradient.on("sortthumbs",function(e,n){var o,s=[];i.each(n,function(e,i){s.push(t.GradColor.colors[e]),t.GradColor.currentIdx==e&&(o=i)}),t.OriginalFillType=null,t.GradColor.colors=s,t.GradColor.currentIdx=o}),this.sldrGradient.on("addthumb",function(e,i,n){t.GradColor.colors[i]=t.GradColor.colors[t.GradColor.currentIdx],t.GradColor.currentIdx=i;var o=t.sldrGradient.addNewThumb(i,n);t.GradColor.colors[t.GradColor.currentIdx]=o}),this.sldrGradient.on("removethumb",function(e,n){if(t.sldrGradient.removeThumb(n),t.GradColor.values.splice(n,1),t.sldrGradient.changeGradientStyle(),i.isUndefined(t.GradColor.currentIdx)||t.GradColor.currentIdx>=t.GradColor.colors.length){var o=n>0?n-1:n;o=0===o&&t.GradColor.values.length>2?t.GradColor.values.length-2:o,t.GradColor.currentIdx=o}t.sldrGradient.setActiveThumb(t.GradColor.currentIdx)}),this.lockedControls.push(this.sldrGradient),this.spnGradPosition=new Common.UI.MetricSpinner({el:e("#textart-gradient-position"),step:1,width:60,defaultUnit:"%",value:"50 %",allowDecimal:!1,maxValue:100,minValue:0,disabled:this._locked}),this.lockedControls.push(this.spnGradPosition),this.spnGradPosition.on("change",i.bind(this.onPositionChange,this)),this.spnGradPosition.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.btnAddGradientStep=new Common.UI.Button({parentEl:e("#textart-gradient-add-step"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-add-breakpoint",disabled:this._locked,hint:this.tipAddGradientPoint}),this.btnAddGradientStep.on("click",i.bind(this.onAddGradientStep,this)),this.lockedControls.push(this.btnAddGradientStep),this.btnRemoveGradientStep=new Common.UI.Button({parentEl:e("#textart-gradient-remove-step"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-remove-breakpoint",disabled:this._locked,hint:this.tipRemoveGradientPoint}),this.btnRemoveGradientStep.on("click",i.bind(this.onRemoveGradientStep,this)),this.lockedControls.push(this.btnRemoveGradientStep),this.numGradientAngle=new Common.UI.MetricSpinner({el:e("#textart-spin-gradient-angle"),step:10,width:60,defaultUnit:"°",value:"0 °",allowDecimal:!0,maxValue:359.9,minValue:0,disabled:this._locked}),this.lockedControls.push(this.numGradientAngle),this.numGradientAngle.on("change",i.bind(this.onGradientAngleChange,this)),this.numGradientAngle.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.cmbBorderSize=new Common.UI.ComboBorderSizeEditable({el:e("#textart-combo-border-size"),style:"width: 93px;",txtNoBorders:this.txtNoBorders}).on("selected",i.bind(this.onBorderSizeSelect,this)).on("changed:before",i.bind(this.onBorderSizeChanged,this,!0)).on("changed:after",i.bind(this.onBorderSizeChanged,this,!1)).on("combo:blur",i.bind(this.onComboBlur,this,!1)),this.BorderSize=this.cmbBorderSize.store.at(2).get("value"),this.cmbBorderSize.setValue(this.BorderSize),this.lockedControls.push(this.cmbBorderSize),this.cmbBorderType=new Common.UI.ComboBorderType({el:e("#textart-combo-border-type"),style:"width: 93px;",menuStyle:"min-width: 93px;"}).on("selected",i.bind(this.onBorderTypeSelect,this)).on("combo:blur",i.bind(this.onComboBlur,this,!1)),this.BorderType=Asc.c_oDashType.solid,this.cmbBorderType.setValue(this.BorderType),this.lockedControls.push(this.cmbBorderType),this.cmbTransform=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,cls:"combo-textart"}),this.cmbTransform.render(e("#textart-combo-transform")),this.cmbTransform.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbTransform.on("click",i.bind(this.onTransformSelect,this)),this.cmbTransform.openButton.menu.on("show:after",function(){t.cmbTransform.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbTransform)},createDelayedElements:function(){this._initSettings=!1,this.createDelayedControls(),this.UpdateThemeColors(),this.fillTransform(this.api.asc_getPropertyEditorTextArts()),this.fillTextArt()},fillTextArt:function(){if(!this._initSettings){var t=this;this.cmbTextArt||(this.cmbTextArt=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,showLast:!1,cls:"combo-textart"}),this.cmbTextArt.render(e("#textart-combo-template")),this.cmbTextArt.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbTextArt.on("click",i.bind(this.onTextArtSelect,this)),this.cmbTextArt.openButton.menu.on("show:after",function(){t.cmbTextArt.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbTextArt));var n=this.application.getCollection("Common.Collections.TextArt").models,o=this.cmbTextArt.menuPicker.store.length;if(n.length<1)return void DE.getController("Main").fillTextArt(this.api.asc_getTextArtPreviews());if(o>0&&o==n.length){var s=this.cmbTextArt.menuPicker.store.models;i.each(n,function(t,e){s[e].set("imageUrl",t.get("imageUrl"))})}else this.cmbTextArt.menuPicker.store.reset(n),this.cmbTextArt.menuPicker.store.length>0&&this.cmbTextArt.fillComboView(this.cmbTextArt.menuPicker.store.at(0))}},onTextArtSelect:function(t,e){if(this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties;i.asc_putStyle(e.get("data")),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},fillTransform:function(t){if(t&&t.length>1&&t[1]){for(var e=[],n=t[1],o=0;o0&&i.each(s,function(t){e.push({imageUrl:t.Image,type:t.Type,selected:!1})})}this.cmbTransform.menuPicker.store.add(e),this.cmbTransform.menuPicker.store.length>0&&this.cmbTransform.fillComboView(this.cmbTransform.menuPicker.store.at(0),!0)}},onTransformSelect:function(t,e){if(this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties;i.asc_putForm(e.get("type")),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},UpdateThemeColors:function(){this._initSettings||(this.btnBackColor||(this.btnBorderColor=new Common.UI.ColorButton({parentEl:e("#textart-border-color-btn"),color:"000000"}),this.lockedControls.push(this.btnBorderColor),this.colorsBorder=this.btnBorderColor.getPicker(),this.btnBorderColor.on("color:select",i.bind(this.onColorsBorderSelect,this)),this.btnGradColor=new Common.UI.ColorButton({parentEl:e("#textart-gradient-color-btn"),color:"000000"}),this.lockedControls.push(this.btnGradColor),this.colorsGrad=this.btnGradColor.getPicker(),this.btnGradColor.on("color:select",i.bind(this.onColorsGradientSelect,this)),this.btnBackColor=new Common.UI.ColorButton({parentEl:e("#textart-back-color-btn"),transparent:!0,color:"transparent"}),this.lockedControls.push(this.btnBackColor),this.colorsBack=this.btnBackColor.getPicker(),this.btnBackColor.on("color:select",i.bind(this.onColorsBackSelect,this))),this.colorsBorder.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsBack.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsGrad.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()))},_pt2mm:function(t){return 25.4*t/72},_mm2pt:function(t){return 72*t/25.4},ShowHideElem:function(t){this.FillColorContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_SOLID),this.FillGradientContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_GRAD),this.TransparencyContainer.toggleClass("settings-hidden",t===Asc.c_oAscFill.FILL_TYPE_NOFILL||null===t)},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.numGradientAngle.setDisabled(t||this.GradFillType!==Asc.c_oAscFillGradType.GRAD_LINEAR))},onPositionChange:function(t){var e=t.getNumberValue(),i=this.GradColor.currentIdx-1<0?0:this.GradColor.values[this.GradColor.currentIdx-1],n=this.GradColor.currentIdx+1n;if(this.api){this.GradColor.values[this.GradColor.currentIdx]=e;var s=new Asc.asc_TextArtProperties,a=new Asc.asc_CShapeFill;a.asc_putType(Asc.c_oAscFill.FILL_TYPE_GRAD),a.asc_putFill(new Asc.asc_CFillGrad),a.asc_getFill().asc_putGradType(this.GradFillType);var r=[];this.GradColor.values.forEach(function(t){r.push(1e3*t)}),a.asc_getFill().asc_putPositions(r),s.asc_putFill(a),this.shapeprops.put_TextArtProperties(s),this.api.ImgApply(this.imgprops),o&&(this.sldrGradient.sortThumbs(),this.sldrGradient.trigger("change",this.sldrGradient),this.sldrGradient.trigger("changecomplete",this.sldrGradient))}},onAddGradientStep:function(){if(!(this.GradColor.colors.length>9)){var t=this.GradColor.currentIdx,e=(this.GradColor.values[t]+this.GradColor.values[t=this.GradColor.colors.length){var e=t>0?t-1:t;e=0===e&&this.GradColor.values.length>2?this.GradColor.values.length-2:e,this.GradColor.currentIdx=e}this.sldrGradient.setActiveThumb(this.GradColor.currentIdx),this.sldrGradient.trigger("change",this.sldrGradient),this.sldrGradient.trigger("changecomplete",this.sldrGradient)}},onGradientAngleChange:function(t,e,i,n){if(this.api&&!this._noApply){var o=new Asc.asc_TextArtProperties,s=new Asc.asc_CShapeFill;s.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),s.put_fill(new Asc.asc_CFillGrad),s.get_fill().put_grad_type(this.GradFillType),s.get_fill().put_linear_angle(6e4*t.getNumberValue()),s.get_fill().put_linear_scale(!0),o.asc_putFill(s),this.shapeprops.put_TextArtProperties(o),this.api.ImgApply(this.imgprops)}},txtNoBorders:"No Line",strStroke:"Stroke",strColor:"Color",strSize:"Size",strFill:"Fill",textColor:"Color Fill",strTransparency:"Opacity",textNoFill:"No Fill",textSelectTexture:"Select",textGradientFill:"Gradient Fill",textLinear:"Linear",textRadial:"Radial",textDirection:"Direction",textStyle:"Style",textGradient:"Gradient Points",textBorderSizeErr:"The entered value is incorrect.
    Please enter a value between 0 pt and 1584 pt.",textTransform:"Transform",textTemplate:"Template",strType:"Type",textPosition:"Position",tipAddGradientPoint:"Add gradient point",tipRemoveGradientPoint:"Remove gradient point",textAngle:"Angle"},DE.Views.TextArtSettings||{}))}),define("text!documenteditor/main/app/template/SignatureSettings.template",[],function(){return'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    '}),define("documenteditor/main/app/view/SignatureSettings",["text!documenteditor/main/app/template/SignatureSettings.template","jquery","underscore","backbone","common/main/lib/component/Button"],function(t,e,i,n){"use strict";DE.Views.SignatureSettings=n.View.extend(i.extend({el:"#id-signature-settings",template:i.template(t),events:{},options:{alias:"SignatureSettings"},initialize:function(){this._state={DisabledEditing:!1,ready:!1,hasValid:!1,hasInvalid:!1,hasRequested:!1,tip:void 0},this._locked=!1,this.render()},render:function(){this.$el.html(this.template({scope:this}));var t=DE.getController("Common.Controllers.Protection").getView();this.btnAddInvisibleSign=t.getButton("signature"),this.btnAddInvisibleSign.render(this.$el.find("#signature-invisible-sign")),this.viewRequestedList=new Common.UI.DataView({el:e("#signature-requested-sign"),enableKeyEvents:!1,itemTemplate:i.template(['
    ','
    ','
    <%= Common.Utils.String.htmlEncode(name) %>
    ',"
    "].join(""))}),this.viewValidList=new Common.UI.DataView({el:e("#signature-valid-sign"),enableKeyEvents:!1,itemTemplate:i.template(['
    ','
    nomargin<% } %>">
    ','
    <%= Common.Utils.String.htmlEncode(name) %>
    ','
    <%= Common.Utils.String.htmlEncode(date) %>
    ',"
    "].join(""))}),this.viewInvalidList=new Common.UI.DataView({el:e("#signature-invalid-sign"),enableKeyEvents:!1,itemTemplate:i.template(['
    ','
    nomargin<% } %>">
    ','
    <%= Common.Utils.String.htmlEncode(name) %>
    ','
    <%= Common.Utils.String.htmlEncode(date) %>
    ',"
    "].join(""))}),this.viewRequestedList.on("item:click",i.bind(this.onSelectSignature,this)),this.viewValidList.on("item:click",i.bind(this.onSelectSignature,this)),this.viewInvalidList.on("item:click",i.bind(this.onSelectSignature,this)),this.viewRequestedList.on("item:contextmenu",i.bind(this.onItemContextMenu,this)),this.viewValidList.on("item:contextmenu",i.bind(this.onItemContextMenu,this)),this.viewInvalidList.on("item:contextmenu",i.bind(this.onItemContextMenu,this)),this.signatureMenu=new Common.UI.Menu({menuAlign:"tr-br",items:[{caption:this.strSign,value:0},{caption:this.strDetails,value:1},{caption:this.strSetup,value:2},{caption:this.strDelete,value:3}]}),this.signatureMenu.on("item:click",i.bind(this.onMenuSignatureClick,this))},setApi:function(t){return this.api=t,this.api&&this.api.asc_registerCallback("asc_onUpdateSignatures",i.bind(this.onApiUpdateSignatures,this)),Common.NotificationCenter.on("document:ready",i.bind(this.onDocumentReady,this)),this},ChangeSettings:function(t){this._state.hasRequested||this._state.hasValid||this._state.hasInvalid||this.updateSignatures(this.api.asc_getSignatures(),this.api.asc_getRequestSignatures())},setLocked:function(t){this._locked=t},setMode:function(t){this.mode=t},onApiUpdateSignatures:function(t,e){this._state.ready&&(this.updateSignatures(t,e),this.showSignatureTooltip(this._state.hasValid,this._state.hasInvalid))},updateSignatures:function(t,e){var n=this,o=[],s=[],a=[],r=1;i.each(e,function(t,e){var i=t.asc_getSigner1();o.push({name:""!==i?i:n.strSigner+" "+r++,guid:t.asc_getGuid(),requested:!0})}),i.each(t,function(t,e){var n=t.asc_getDate(),o={name:t.asc_getSigner1(),certificateId:t.asc_getId(),guid:t.asc_getGuid(),date:i.isEmpty(n)?"":new Date(n).toLocaleString(),invisible:!t.asc_getVisible()};0==t.asc_getValid()?s.push(o):a.push(o)}),n._state.hasValid=s.length>0,n._state.hasInvalid=a.length>0,n._state.hasRequested=o.length>0,this.viewRequestedList.store.reset(o),this.viewValidList.store.reset(s),this.viewInvalidList.store.reset(a),this.$el.find(".requested").toggleClass("hidden",!n._state.hasRequested),this.$el.find(".valid").toggleClass("hidden",!n._state.hasValid),this.$el.find(".invalid").toggleClass("hidden",!n._state.hasInvalid),n.disableEditing(n._state.hasValid||n._state.hasInvalid)},onItemContextMenu:function(t,n,o,s){var a=this.signatureMenu;a.isVisible()&&a.hide();var r=e(this.el).offset(),l=[s.clientX*Common.Utils.zoom()-r.left+5,s.clientY*Common.Utils.zoom()-r.top+5];this.showSignatureMenu(o,l),a.menuAlign="tl-bl",a.menuAlignEl=null,a.setOffset(15,5),a.show(),i.delay(function(){a.cmpEl.focus()},10)},onSelectSignature:function(t,n,o,s){if(o){var a=e(s.target);if(a&&a.hasClass("caret")){var r=this.signatureMenu;if(r.isVisible())return void r.hide();var l=e(s.currentTarget),c=l.offset(),d=e(this.el).offset(),h=[c.left-d.left+l.width(),c.top-d.top+l.height()/2];this.showSignatureMenu(o,h),r.menuAlign="tr-br",r.menuAlignEl=l,r.setOffset(-20,-l.height()/2+3),r.show(),i.delay(function(){r.cmpEl.focus()},10),s.stopPropagation(),s.preventDefault()}else this.api.asc_gotoSignature(o.get("guid"))}},showSignatureMenu:function(t,i){this.api.asc_gotoSignature(t.get("guid"));var n=this.signatureMenu,o=e(this.el),s=o.find("#menu-signature-container");n.rendered||(s.length<1&&(s=e('',n.id),o.append(s)),n.render(s),n.cmpEl.attr({tabindex:"-1"}),n.on({"show:after":function(t){t&&t.menuAlignEl&&t.menuAlignEl.toggleClass("over",!0)},"hide:after":function(t){t&&t.menuAlignEl&&t.menuAlignEl.toggleClass("over",!1)}}));var a=t.get("requested"),r=this._state.hasValid||this._state.hasInvalid;n.items[0].setVisible(a),n.items[1].setVisible(!a),n.items[2].setVisible(a||!t.get("invisible")),n.items[3].setVisible(!a),n.items[0].setDisabled(this._locked),n.items[3].setDisabled(this._locked),n.items[1].cmpEl.attr("data-value",t.get("certificateId")),n.items[2].cmpEl.attr("data-value",r?1:0),n.cmpEl.attr("data-value",t.get("guid")),s.css({left:i[0],top:i[1]})},onMenuSignatureClick:function(t,e){var i=t.cmpEl.attr("data-value");switch(e.value){case 0:Common.NotificationCenter.trigger("protect:sign",i);break;case 1:this.api.asc_ViewCertificate(e.cmpEl.attr("data-value"));break;case 2:Common.NotificationCenter.trigger("protect:signature","visible",!!parseInt(e.cmpEl.attr("data-value")),i);break;case 3:this.api.asc_RemoveSignature(i)}},onDocumentReady:function(){this._state.ready=!0,this.updateSignatures(this.api.asc_getSignatures(),this.api.asc_getRequestSignatures()),this.showSignatureTooltip(this._state.hasValid,this._state.hasInvalid,this._state.hasRequested)},showSignatureTooltip:function(t,e,i){var n=this,o=n._state.tip;if(!t&&!e&&!i)return void(o&&o.isVisible()&&(o.close(),n._state.tip=void 0));var s=t||e,a=e?n.txtSignedInvalid:t?n.txtSigned:"";i&&(a=n.txtRequestedSignatures+"

    "+a),o&&o.isVisible()&&(a!==o.text||s!==o.showLink)&&(o.close(),n._state.tip=void 0),n._state.tip||(o=new Common.UI.SynchronizeTip({target:DE.getController("RightMenu").getView("RightMenu").btnSignature.btnEl,text:a,showLink:s,textLink:this.txtContinueEditing,placement:"left"}),o.on({dontshowclick:function(){Common.UI.warning({title:n.notcriticalErrorTitle,msg:n.txtEditWarning,buttons:["ok","cancel"],primary:"ok",callback:function(t){"ok"==t&&(o.close(),n._state.tip=void 0,n.api.asc_RemoveAllSignatures())}})},closeclick:function(){o.close(),n._state.tip=void 0}}),n._state.tip=o,o.show())},disableEditing:function(t){if(this._state.DisabledEditing!=t){this._state.DisabledEditing=t;var e=DE.getController("RightMenu");t&&"id-signature-settings"!==e.rightmenu.GetActivePane()&&e.rightmenu.clearSelection(),e.SetDisabled(t,!1,!0),DE.getController("Toolbar").DisableToolbar(t,t),DE.getController("Statusbar").getView("Statusbar").SetDisabled(t),DE.getController("Common.Controllers.ReviewChanges").SetDisabled(t),DE.getController("DocumentHolder").getView().SetDisabled(t,!0),DE.getController("Navigation")&&DE.getController("Navigation").SetDisabled(t),DE.getController("LeftMenu").setPreviewMode(t);var i=DE.getController("Common.Controllers.Comments");i&&i.setPreviewMode(t)}},strSignature:"Signature",strRequested:"Requested signatures",strValid:"Valid signatures",strInvalid:"Invalid signatures",strSign:"Sign",strDetails:"Signature Details",strSetup:"Signature Setup",txtSigned:"Valid signatures has been added to the document. The document is protected from editing.",txtSignedInvalid:"Some of the digital signatures in document are invalid or could not be verified. The document is protected from editing.",txtRequestedSignatures:"This document needs to be signed.",txtContinueEditing:"Edit anyway",notcriticalErrorTitle:"Warning",txtEditWarning:"Editing will remove the signatures from the document.
    Are you sure you want to continue?",strDelete:"Remove Signature",strSigner:"Signer"},DE.Views.SignatureSettings||{}))}),define("text!documenteditor/main/app/template/FormSettings.template",[],function(){return'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n \n
    \n
    \n \n \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n\n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n \n \n \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    '}),void 0===Common)var Common={};define("common/main/lib/component/TextareaField",["common/main/lib/component/BaseView","common/main/lib/component/Tooltip"],function(){"use strict";Common.UI.TextareaField=Common.UI.BaseView.extend(function(){return{options:{id:null,cls:"",style:"",value:"",maxlength:void 0,placeHolder:"",spellcheck:!1,disabled:!1},template:_.template(['
    ',"","
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.id=e.options.id||Common.UI.getId(),this.cls=e.options.cls,this.style=e.options.style,this.value=e.options.value,this.placeHolder=e.options.placeHolder,this.template=e.options.template||e.template,this.disabled=e.options.disabled,this.spellcheck=e.options.spellcheck,this.maxLength=e.options.maxLength,e.rendered=e.options.rendered||!1,e.options.el&&e.render()},render:function(t){var e=this;if(e.rendered?this.cmpEl=this.$el:(this.cmpEl=$(this.template({id:this.id,cls:this.cls,style:this.style,placeHolder:this.placeHolder,spellcheck:this.spellcheck,scope:e})),t?(this.setElement(t,!1),t.html(this.cmpEl)):this.$el.html(this.cmpEl)),!e.rendered){this.cmpEl;this._input=this.cmpEl.find("textarea").addBack().filter("textarea"),this._input.on("blur",_.bind(this.onInputChanged,this)),this._input.on("keydown",_.bind(this.onKeyDown,this)),this.maxLength&&this._input.attr("maxlength",this.maxLength),this.disabled&&this.setDisabled(this.disabled)}return e.rendered=!0,this},_doChange:function(t,e){if(!e||!e.synthetic){var i=$(t.target).val(),n=this.value;this.trigger("changed:before",this,i,n,t),t.isDefaultPrevented()||(this.value=i,this.trigger("changed:after",this,i,n,t))}},onInputChanged:function(t,e){this._doChange(t,e)},onKeyDown:function(t){this.trigger("keydown:before",this,t),t.isDefaultPrevented()||(t.keyCode===Common.UI.Keys.RETURN&&t.stopPropagation(),t.keyCode==Common.UI.Keys.ESC&&this.setValue(this.value),t.keyCode==Common.UI.Keys.ESC&&this.trigger("inputleave",this))},setDisabled:function(t){this.disabled=t,$(this.el).toggleClass("disabled",t),t?this._input.attr("disabled",!0):this._input.removeAttr("disabled")},isDisabled:function(){return this.disabled},setValue:function(t){this.value=t,this.rendered&&this._input.val(t)},getValue:function(){return this.value},focus:function(){this._input.focus()}}}())}),define("documenteditor/main/app/view/FormSettings",["text!documenteditor/main/app/template/FormSettings.template","jquery","underscore","backbone","common/main/lib/component/ComboBox","common/main/lib/component/MetricSpinner","common/main/lib/component/TextareaField","common/main/lib/component/CheckBox","common/main/lib/view/ImageFromUrlDialog"],function(t,e,i,n){"use strict";DE.Views.FormSettings=n.View.extend(i.extend({el:"#id-form-settings",template:i.template(t),events:{},options:{alias:"FormSettings"},initialize:function(){this._initSettings=!0,this._state={DisabledControls:void 0,LockDelete:void 0},this.spinners=[],this.lockedControls=[],this.internalId=null,this._locked=!0,this._originalTextFormProps=null,this._originalFormProps=null,this._originalProps=null,this.render()},render:function(){var t=this.$el||e(this.el);t.html(this.template({scope:this})),this.TextOnlySettings=t.find(".form-textfield"),this.PlaceholderSettings=t.find(".form-placeholder"),this.KeySettings=t.find(".form-keyfield"),this.KeySettingsTd=this.KeySettings.find("td"),this.CheckOnlySettings=t.find(".form-checkbox"),this.RadioOnlySettings=t.find(".form-radiobox"),this.ListOnlySettings=t.find(".form-list"),this.ImageOnlySettings=t.find(".form-image"),this.ConnectedSettings=t.find(".form-connected")},createDelayedElements:function(){this._initSettings=!1;var t=this.$el||e(this.el),n=this;this.labelFormName=t.findById("#form-settings-name"),this.labelConnectedFields=t.findById("#form-settings-connected"),t.findById("#form-settings-disconnect").on("click",i.bind(this.onDisconnect,this)),this.cmbKey=new Common.UI.ComboBox({el:t.findById("#form-combo-key"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!0,data:[]}),this.cmbKey.setValue(""),this.lockedControls.push(this.cmbKey),this.cmbKey.on("selected",this.onKeyChanged.bind(this)),this.cmbKey.on("changed:after",this.onKeyChanged.bind(this)),this.cmbKey.on("hide:after",this.onHideMenus.bind(this)),this.txtPlaceholder=new Common.UI.InputField({el:t.findById("#form-txt-pholder"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",value:""}),this.lockedControls.push(this.txtPlaceholder),this.txtPlaceholder.on("changed:after",this.onPlaceholderChanged.bind(this)),this.txtPlaceholder.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.textareaHelp=new Common.UI.TextareaField({el:t.findById("#form-txt-help"),style:"width: 100%; height: 60px;",value:""}),this.lockedControls.push(this.textareaHelp),this.textareaHelp.on("changed:after",this.onHelpChanged.bind(this)),this.textareaHelp.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.chMaxChars=new Common.UI.CheckBox({el:t.findById("#form-chb-max-chars"),labelText:this.textMaxChars}),this.chMaxChars.on("change",this.onChMaxCharsChanged.bind(this)),this.lockedControls.push(this.chMaxChars),this.spnMaxChars=new Common.UI.MetricSpinner({el:t.findById("#form-spin-max-chars"),step:1,width:45,defaultUnit:"",value:"10",maxValue:1e6,minValue:1}),this.lockedControls.push(this.spnMaxChars),this.spnMaxChars.on("change",this.onMaxCharsChange.bind(this)),this.spnMaxChars.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.chComb=new Common.UI.CheckBox({el:t.findById("#form-chb-comb"),labelText:this.textComb}),this.chComb.on("change",this.onChCombChanged.bind(this)),this.lockedControls.push(this.chComb),this.spnWidth=new Common.UI.MetricSpinner({el:t.findById("#form-spin-width"),step:.1,width:64,defaultUnit:"cm",value:"Auto",allowAuto:!0,maxValue:55.88,minValue:.1}),this.lockedControls.push(this.spnWidth),this.spinners.push(this.spnWidth),this.spnWidth.on("change",this.onWidthChange.bind(this)),this.spnWidth.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.cmbGroupKey=new Common.UI.ComboBox({el:t.findById("#form-combo-group-key"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!0,data:[]}),this.cmbGroupKey.setValue(""),this.lockedControls.push(this.cmbGroupKey),this.cmbGroupKey.on("selected",this.onGroupKeyChanged.bind(this)),this.cmbGroupKey.on("changed:after",this.onGroupKeyChanged.bind(this)),this.cmbGroupKey.on("hide:after",this.onHideMenus.bind(this)),this.txtNewValue=new Common.UI.InputField({el:t.findById("#form-txt-new-value"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",value:""}),this.lockedControls.push(this.txtNewValue),this.txtNewValue.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.txtNewValue._input.on("keydown",i.bind(this.onNewValueKeydown,this)),this.list=new Common.UI.ListView({el:t.findById("#form-list-list"),store:new Common.UI.DataViewStore,emptyText:"",template:i.template(['
    '].join("")),itemTemplate:i.template(['
    ','
    <%= name %>
    ',"
    "].join(""))}),this.list.on("item:select",i.bind(this.onSelectItem,this)),this.lockedControls.push(this.list),this.btnListAdd=new Common.UI.Button({parentEl:t.findById("#form-list-add"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-zoomup",hint:this.textTipAdd}),this.btnListAdd.on("click",i.bind(this.onAddItem,this)),this.lockedControls.push(this.btnListAdd),this.btnListDelete=new Common.UI.Button({parentEl:t.findById("#form-list-delete"),cls:"btn-toolbar",iconCls:"toolbar__icon cc-remove",hint:this.textTipDelete}),this.btnListDelete.on("click",i.bind(this.onDeleteItem,this)),this.lockedControls.push(this.btnListDelete),this.btnListUp=new Common.UI.Button({parentEl:t.findById("#form-list-up"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-arrow-up",hint:this.textTipUp}),this.btnListUp.on("click",i.bind(this.onMoveItem,this,!0)),this.lockedControls.push(this.btnListUp),this.btnListDown=new Common.UI.Button({parentEl:t.findById("#form-list-down"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-arrow-down",hint:this.textTipDown}),this.btnListDown.on("click",i.bind(this.onMoveItem,this,!1)),this.lockedControls.push(this.btnListDown),this.btnSelectImage=new Common.UI.Button({parentEl:e("#form-button-replace"),cls:"btn-text-menu-default",caption:this.textSelectImage,style:"width:100%;",menu:new Common.UI.Menu({style:"min-width: 194px;",maxHeight:200,items:[{caption:this.textFromFile,value:0},{caption:this.textFromUrl,value:1},{caption:this.textFromStorage,value:2}]})}),this.lockedControls.push(this.btnSelectImage),this.btnSelectImage.menu.on("item:click",i.bind(this.onImageSelect,this)),this.btnSelectImage.menu.items[2].setVisible(this.mode.canRequestInsertImage||this.mode.fileChoiceUrl&&this.mode.fileChoiceUrl.indexOf("{documentType}")>-1),this.btnRemForm=new Common.UI.Button({parentEl:t.findById("#form-btn-delete"),cls:"btn-toolbar",iconCls:"toolbar__icon cc-remove",caption:this.textDelete,style:"text-align: left;"}),this.btnRemForm.on("click",i.bind(function(t){this.api.asc_RemoveContentControl(this._state.id)},this)),this.lockedControls.push(this.btnRemForm),this.btnLockForm=new Common.UI.Button({parentEl:t.findById("#form-btn-lock"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-lock",caption:this.textLock,style:"text-align: left;"}),this.btnLockForm.on("click",i.bind(function(t){if(this.api&&!this._noApply){var e=this._originalProps||new AscCommon.CContentControlPr;e.put_Lock(this._state.LockDelete?Asc.c_oAscSdtLockType.Unlocked:Asc.c_oAscSdtLockType.SdtLocked),this.api.asc_SetContentControlProperties(e,this.internalId)}},this)),this.updateMetricUnit(),this.UpdateThemeColors()},setApi:function(t){return this.api=t,this.api,this},setMode:function(t){this.mode=t},onKeyChanged:function(t,e){if(this.api&&!this._noApply){var i=this._originalProps||new AscCommon.CContentControlPr,n=this._originalFormProps||new AscCommon.CSdtFormPr;n.put_Key(e.value),i.put_FormPr(n),this.api.asc_SetContentControlProperties(i,this.internalId),this.fireEvent("editcomplete",this)}},onPlaceholderChanged:function(t,e,i,n){if(this.api&&!this._noApply&&e!==i){var o=this._originalProps||new AscCommon.CContentControlPr;o.put_PlaceholderText(e||" "),this.api.asc_SetContentControlProperties(o,this.internalId),n.relatedTarget&&("input"==n.relatedTarget.localName||"textarea"==n.relatedTarget.localName)&&/form-control/.test(n.relatedTarget.className)||this.fireEvent("editcomplete",this)}},onHelpChanged:function(t,e,i,n){if(this.api&&!this._noApply&&e!==i){var o=this._originalProps||new AscCommon.CContentControlPr,s=this._originalFormProps||new AscCommon.CSdtFormPr;s.put_HelpText(e),o.put_FormPr(s),this.api.asc_SetContentControlProperties(o,this.internalId),n.relatedTarget&&("input"==n.relatedTarget.localName||"textarea"==n.relatedTarget.localName)&&/form-control/.test(n.relatedTarget.className)||this.fireEvent("editcomplete",this)}},onChMaxCharsChanged:function(t,e,i,n){var o="checked"==t.getValue();if(this.spnMaxChars.setDisabled(!o),o||(this.chComb.setValue(!1,!0),this.spnWidth.setDisabled(!0)),this.api&&!this._noApply){var s=this._originalProps||new AscCommon.CContentControlPr,a=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;!o&&a.put_Comb(o),a.put_MaxCharacters(o?this.spnMaxChars.getNumberValue()||10:o),s.put_TextFormPr(a),this.api.asc_SetContentControlProperties(s,this.internalId),this.fireEvent("editcomplete",this)}},onMaxCharsChange:function(t,e,i,n){if(this.api&&!this._noApply){var o=this._originalProps||new AscCommon.CContentControlPr,s=this._originalTextFormProps||new AscCommon.CSdtTextFormPr,a="checked"==this.chMaxChars.getValue()||"checked"==this.chComb.getValue();s.put_MaxCharacters(a?t.getNumberValue()||10:a),o.put_TextFormPr(s),this.api.asc_SetContentControlProperties(o,this.internalId),this.fireEvent("editcomplete",this)}},onChCombChanged:function(t,e,i,n){var o="checked"==t.getValue();if(o&&(this.chMaxChars.setValue(!0,!0),this.spnMaxChars.setDisabled(!1)),this.spnWidth.setDisabled(!o),this.api&&!this._noApply){var s=this._originalProps||new AscCommon.CContentControlPr,a=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;if(a.put_Comb(o),o)if(a.put_MaxCharacters(this.spnMaxChars.getNumberValue()||10),this.spnWidth.getValue()){var r=this.spnWidth.getNumberValue();a.put_Width(r<=0?0:parseInt(72*Common.Utils.Metric.fnRecalcToMM(r)*20/25.4+.1))}else a.put_Width(0);s.put_TextFormPr(a),this.api.asc_SetContentControlProperties(s,this.internalId),this.fireEvent("editcomplete",this)}},onWidthChange:function(t,e,i,n){if(this.api&&!this._noApply){var o=this._originalProps||new AscCommon.CContentControlPr,s=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;if(this.spnWidth.getValue()){var a=this.spnWidth.getNumberValue();s.put_Width(a<=0?0:parseInt(72*Common.Utils.Metric.fnRecalcToMM(a)*20/25.4+.1))}else s.put_Width(0);o.put_TextFormPr(s),this.api.asc_SetContentControlProperties(o,this.internalId),this.fireEvent("editcomplete",this)}},onGroupKeyChanged:function(t,e){if(this.api&&!this._noApply){var i=this._originalProps||new AscCommon.CContentControlPr,n=this._originalCheckProps||new AscCommon.CSdtCheckBoxPr;n.put_GroupKey(e.value),i.put_CheckBoxPr(n),this.api.asc_SetContentControlProperties(i,this.internalId),this.fireEvent("editcomplete",this)}},fillListProps:function(){if(this.api&&!this._noApply){var t=this._originalProps||new AscCommon.CContentControlPr,e=this._originalListProps||new AscCommon.CSdtComboBoxPr;e.clear(),this.list.store.each(function(t,i){e.add_Item(t.get("name"),t.get("value"))}),this.type==Asc.c_oAscContentControlSpecificType.ComboBox?t.put_ComboBoxPr(e):t.put_DropDownListPr(e),this.api.asc_SetContentControlProperties(t,this.internalId)}},onNewValueKeydown:function(t){this.api&&!this._noApply&&t.keyCode==Common.UI.Keys.RETURN&&this.onAddItem()},onAddItem:function(){var t=this.list.store,e=this.txtNewValue.getValue();if(""!==e){t.findWhere({value:e})||(t.add({value:e,name:e}),this._state.listValue=e,this._state.listIndex=void 0,this.fillListProps())}this.fireEvent("editcomplete",this)},onDeleteItem:function(t,e){var i=this.list.getSelectedRec();if(i){var n=this.list.store;this._state.listIndex=n.indexOf(i),this._state.listValue=void 0,n.remove(i),this.fillListProps()}this.fireEvent("editcomplete",this)},onMoveItem:function(t){var e=this.list.store,i=e.length,n=this.list.getSelectedRec();if(n){var o=e.indexOf(n);e.add(e.remove(n),{at:t?Math.max(0,o-1):Math.min(i-1,o+1)}),this.fillListProps()}this.fireEvent("editcomplete",this)},setImageUrl:function(t,e){this.api.asc_SetContentControlPictureUrl(t,this.internalId,e)},insertImageFromStorage:function(t){t&&t.url&&"control"==t.c&&this.setImageUrl(t.url,t.token)},onImageSelect:function(t,e){if(1==e.value){var n=this;new Common.Views.ImageFromUrlDialog({handler:function(t,e){if("ok"==t&&n.api){var o=e.replace(/ /g,"");i.isEmpty(o)||n.setImageUrl(o)}n.fireEvent("editcomplete",n)}}).show()}else if(2==e.value)Common.NotificationCenter.trigger("storage:image-load","control");else{if(this._isFromFile)return;this._isFromFile=!0,this.api&&this.api.asc_addImage(this._originalProps),this.fireEvent("editcomplete",this),this._isFromFile=!1}},onColorPickerSelect:function(t,e){if(this.BorderColor=e,this._state.BorderColor=void 0,this.api&&!this._noApply){var i=this._originalProps||new AscCommon.CContentControlPr,n=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;if("transparent"==e)n.put_CombBorder();else{var o=n.get_CombBorder();o||(o=new Asc.asc_CTextBorder),o.put_Value(1),o.put_Color(Common.Utils.ThemeColor.getRgbColor(e)), -n.put_CombBorder(o)}i.put_TextFormPr(n),this.api.asc_SetContentControlProperties(i,this.internalId),this.fireEvent("editcomplete",this)}},onNoBorderClick:function(t){if(this.BorderColor="transparent",this._state.BorderColor=void 0,this.api&&!this._noApply){var e=this._originalProps||new AscCommon.CContentControlPr,i=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;i.put_CombBorder(),e.put_TextFormPr(i),this.api.asc_SetContentControlProperties(e,this.internalId),this.fireEvent("editcomplete",this)}},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedElements(),t){this._originalProps=t,this._noApply=!0,this.internalId=t.get_InternalId();var e=t.get_PlaceholderText();this._state.placeholder!==e&&(this.txtPlaceholder.setValue(e||""),this._state.placeholder=e),e=t.get_Lock(),void 0===e&&(e=Asc.c_oAscSdtLockType.Unlocked),this._state.LockDelete!==(e==Asc.c_oAscSdtLockType.SdtContentLocked||e==Asc.c_oAscSdtLockType.SdtLocked)&&(this._state.LockDelete=e==Asc.c_oAscSdtLockType.SdtContentLocked||e==Asc.c_oAscSdtLockType.SdtLocked,this.btnLockForm.setCaption(this._state.LockDelete?this.textUnlock:this.textLock)),this.disableControls(this._locked);var n,o=t.get_SpecificType(),s=!1;if(o==Asc.c_oAscContentControlSpecificType.ComboBox||o==Asc.c_oAscContentControlSpecificType.DropDownList){if(this.labelFormName.text(o==Asc.c_oAscContentControlSpecificType.ComboBox?this.textCombobox:this.textDropDown),n=o==Asc.c_oAscContentControlSpecificType.ComboBox?t.get_ComboBoxPr():t.get_DropDownListPr()){this._originalListProps=n;for(var a=n.get_ItemsCount(),r=[],l=0;l0&&this._state.internalId===this.internalId&&(void 0!==this._state.listValue||void 0!==this._state.listIndex)&&(void 0!==this._state.listIndex&&this._state.listIndex>=this.list.store.length&&(this._state.listIndex=this.list.store.length-1),c=void 0!==this._state.listValue?this.list.store.findWhere({value:this._state.listValue}):this.list.store.at(this._state.listIndex)),c?(this.list.selectRecord(c),this.list.scrollToRecord(c)):(this.txtNewValue.setValue(""),this._state.listValue=this._state.listIndex=void 0)}this.disableListButtons()}else o==Asc.c_oAscContentControlSpecificType.CheckBox&&(n=t.get_CheckBoxPr(),this._originalCheckProps=n);var d=t.get_FormPr();if(d){this._originalFormProps=d;var h=[];if(o==Asc.c_oAscContentControlSpecificType.CheckBox?h=this.api.asc_GetCheckBoxFormKeys():o==Asc.c_oAscContentControlSpecificType.Picture?(h=this.api.asc_GetPictureFormKeys(),this.labelFormName.text(this.textImage)):h=this.api.asc_GetTextFormKeys(),!this._state.arrKey||this._state.arrKey.length!==h.length||i.difference(this._state.arrKey,h).length>0){var r=[];h.forEach(function(t){r.push({displayValue:t,value:t})}),this.cmbKey.setData(r),this._state.arrKey=h}if(e=d.get_Key(),this._state.Key!==e&&(this.cmbKey.setValue(e||""),this._state.Key=e),e&&(e=this.api.asc_GetFormsCountByKey(e),s=e>1),s&&this.labelConnectedFields.text(this.textConnected+": "+e),e=d.get_HelpText(),this._state.help!==e&&(this.textareaHelp.setValue(e||""),this._state.help=e),o==Asc.c_oAscContentControlSpecificType.CheckBox&&n){e=n.get_GroupKey();var p="string"!=typeof e;if(!p){if(h=this.api.asc_GetRadioButtonGroupKeys(),!this._state.arrGroupKey||this._state.arrGroupKey.length!==h.length||i.difference(this._state.arrGroupKey,h).length>0){var r=[];h.forEach(function(t){r.push({displayValue:t,value:t})}),this.cmbGroupKey.setData(r),this._state.arrGroupKey=h}this._state.groupKey!==e&&(this.cmbGroupKey.setValue(e||""),this._state.groupKey=e)}this.labelFormName.text(p?this.textCheckbox:this.textRadiobox)}}var m=t.get_TextFormPr();if(m){this._originalTextFormProps=m,this.labelFormName.text(this.textField),e=m.get_Comb(),this._state.Comb!==e&&(this.chComb.setValue(!!e,!0),this._state.Comb=e),this.btnColor.setDisabled(!e),this.spnWidth.setDisabled(!e),e=m.get_Width(),((void 0===e||void 0===this._state.Width)&&this._state.Width!==e||Math.abs(this._state.Width-e)>.1)&&(this.spnWidth.setValue(0!==e&&void 0!==e?Common.Utils.Metric.fnRecalcFromMM(25.4*e/20/72):-1,!0),this._state.Width=e),e=this.api.asc_GetTextFormAutoWidth(),(this._state.WidthPlaceholder!==e||Math.abs(this._state.WidthPlaceholder-e)>.01)&&(this.spnWidth.setDefaultValue(void 0!==e&&null!==e?Common.Utils.Metric.fnRecalcFromMM(e):this.spnWidth.options.minValue),this._state.WidthPlaceholder=e),e=m.get_MaxCharacters(),this.chMaxChars.setValue(e&&e>=0),this.spnMaxChars.setDisabled(!e||e<0),((void 0===e||void 0===this._state.MaxChars)&&this._state.MaxChars!==e||Math.abs(this._state.MaxChars-e)>.1)&&(this.spnMaxChars.setValue(e&&e>=0?e:10,!0),this._state.MaxChars=e);var u=m.get_CombBorder();if(u){var g=u.get_Color();g?g.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.BorderColor={color:Common.Utils.ThemeColor.getHexColor(g.get_r(),g.get_g(),g.get_b()),effectValue:g.get_value()}:this.BorderColor=Common.Utils.ThemeColor.getHexColor(g.get_r(),g.get_g(),g.get_b()):this.BorderColor="transparent"}else this.BorderColor="transparent";var b=typeof this.BorderColor;(b!==typeof this._state.BorderColor||"object"==b&&(this.BorderColor.effectValue!==this._state.BorderColor.effectValue||this._state.BorderColor.color.indexOf(this.BorderColor.color)<0)||"object"!=b&&this._state.BorderColor.indexOf(this.BorderColor)<0)&&(this.btnColor.setColor(this.BorderColor),this.mnuColorPicker.clearSelection(),this.mnuNoBorder.setChecked("transparent"==this.BorderColor,!0),"transparent"!=this.BorderColor&&this.mnuColorPicker.selectByRGB("object"==typeof this.BorderColor?this.BorderColor.color:this.BorderColor,!0),this._state.BorderColor=this.BorderColor)}this._noApply=!1,this.KeySettingsTd.toggleClass("padding-small",!s),this.ConnectedSettings.toggleClass("hidden",!s),this.type===o&&o!=Asc.c_oAscContentControlSpecificType.CheckBox||this.showHideControls(o,m,n),this.type=o,this._state.internalId=this.internalId}},updateMetricUnit:function(){if(this.spinners){for(var t=0;t .active").removeClass("active"),n.addClass("active"),this.scroller&&this.scroller.scrollTop(0)):(o.css("display","none"),e(this.el).width(SCALE_MIN),this.minimizedMode=!0,Common.localStorage.setItem("de-hide-right-settings",1)),this.fireEvent("rightmenuclick",[this,t.options.asctype,this.minimizedMode,i])},SetActivePane:function(t,e){if(!(this.minimizedMode&&!0!==e||void 0===this._settings[t]))if(this.minimizedMode)this._settings[t].btn.toggle(!0,!1),this._settings[t].btn.trigger("click",this._settings[t].btn);else{var i=this.$el.find("#"+this._settings[t].panel);i.hasClass("active")||(i.parent().find("> .active").removeClass("active"),i.addClass("active"),this.scroller&&(this.scroller.update(),this.scroller.scrollTop(0))),this._settings[t].btn.isActive()||this._settings[t].btn.toggle(!0,!1)}},GetActivePane:function(){return this.minimizedMode?null:this.$el.find(".settings-panel.active")[0].id},clearSelection:function(){this.mergeSettings&&this.mergeSettings.disablePreviewMode();var t=e(".right-panel");t.find("> .active").removeClass("active"),this._settings.forEach(function(t){t.btn.isActive()&&t.btn.toggle(!1,!0)}),t.css("display","none"),e(this.el).width(SCALE_MIN),this.minimizedMode=!0,Common.NotificationCenter.trigger("layout:changed","rightmenu")},txtParagraphSettings:"Paragraph Settings",txtImageSettings:"Image Settings",txtTableSettings:"Table Settings",txtHeaderFooterSettings:"Header and Footer Settings",txtShapeSettings:"Shape Settings",txtTextArtSettings:"Text Art Settings",txtChartSettings:"Chart Settings",txtMailMergeSettings:"Mail Merge Settings",txtSignatureSettings:"Signature Settings",txtFormSettings:"Form Settings"},DE.Views.RightMenu||{}))}),define("documenteditor/main/app/controller/RightMenu",["core","documenteditor/main/app/view/RightMenu"],function(){"use strict";DE.Controllers.RightMenu=Backbone.Controller.extend({models:[],collections:[],views:["RightMenu"],initialize:function(){this.editMode=!0,this._initSettings=!0,this.addListeners({RightMenu:{rightmenuclick:this.onRightMenuClick}}),Common.Utils.InternalSettings.set("de-rightpanel-active-form",1)},onLaunch:function(){this.rightmenu=this.createView("RightMenu"),this.rightmenu.on("render:after",_.bind(this.onRightMenuAfterRender,this))},onRightMenuAfterRender:function(t){t.shapeSettings.application=t.textartSettings.application=this.getApplication(),this._settings=[],this._settings[Common.Utils.documentSettingsType.Paragraph]={panelId:"id-paragraph-settings",panel:t.paragraphSettings,btn:t.btnText,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.Table]={panelId:"id-table-settings",panel:t.tableSettings,btn:t.btnTable,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.Image]={panelId:"id-image-settings",panel:t.imageSettings,btn:t.btnImage,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.Header]={panelId:"id-header-settings",panel:t.headerSettings,btn:t.btnHeaderFooter,hidden:1,locked:!1,needShow:!0},this._settings[Common.Utils.documentSettingsType.Shape]={panelId:"id-shape-settings",panel:t.shapeSettings,btn:t.btnShape,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.TextArt]={panelId:"id-textart-settings",panel:t.textartSettings,btn:t.btnTextArt,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.Chart]={panelId:"id-chart-settings",panel:t.chartSettings,btn:t.btnChart,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.MailMerge]={panelId:"id-mail-merge-settings",panel:t.mergeSettings,btn:t.btnMailMerge,hidden:1,props:{},locked:!1},this._settings[Common.Utils.documentSettingsType.Signature]={panelId:"id-signature-settings",panel:t.signatureSettings,btn:t.btnSignature,hidden:1,props:{},locked:!1},this._settings[Common.Utils.documentSettingsType.Form]={panelId:"id-form-settings",panel:t.formSettings,btn:t.btnForm,hidden:1,props:{},locked:!1}},setApi:function(t){this.api=t,this.api.asc_registerCallback("asc_onUpdateSignatures",_.bind(this.onApiUpdateSignatures,this)),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onCoAuthoringDisconnect,this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this))},setMode:function(t){this.editMode=t.isEdit},onRightMenuClick:function(t,e,i,n){if(!i&&this.editMode){n&&(this._settings[Common.Utils.documentSettingsType.Form].hidden||(e==Common.Utils.documentSettingsType.Form?(this._settings[Common.Utils.documentSettingsType.Paragraph].hidden||Common.Utils.InternalSettings.set("de-rightpanel-active-para",0),this._settings[Common.Utils.documentSettingsType.Image].hidden||Common.Utils.InternalSettings.set("de-rightpanel-active-image",0),this._settings[Common.Utils.documentSettingsType.Shape].hidden||Common.Utils.InternalSettings.set("de-rightpanel-active-shape",0)):e==Common.Utils.documentSettingsType.Paragraph?Common.Utils.InternalSettings.set("de-rightpanel-active-para",2):e==Common.Utils.documentSettingsType.Image?(Common.Utils.InternalSettings.set("de-rightpanel-active-image",2),Common.Utils.InternalSettings.set("de-rightpanel-active-shape",0)):e==Common.Utils.documentSettingsType.Shape&&(Common.Utils.InternalSettings.set("de-rightpanel-active-shape",2),Common.Utils.InternalSettings.set("de-rightpanel-active-image",0))));var o=this._settings[e].panel,s=this._settings[e].props;s&&o&&o.ChangeSettings.call(o,e==Common.Utils.documentSettingsType.MailMerge||e==Common.Utils.documentSettingsType.Signature?void 0:s)}else i&&e==Common.Utils.documentSettingsType.MailMerge&&this.rightmenu.mergeSettings.disablePreviewMode();Common.NotificationCenter.trigger("layout:changed","rightmenu"),this.rightmenu.fireEvent("editcomplete",this.rightmenu)},onFocusObject:function(t){if(this.editMode){var e=!!this._initSettings&&!Common.localStorage.getBool("de-hide-right-settings",this.rightmenu.defaultHideRightMenu);this._initSettings=!1;for(var i=!1,n=!1,o=0;o=this._settings.length||void 0===this._settings[d])){var h=t[o].get_ObjectValue();if(d==Common.Utils.documentSettingsType.Image){var p=a?a.get_Lock():Asc.c_oAscSdtLockType.Unlocked;l=p==Asc.c_oAscSdtLockType.SdtContentLocked||p==Asc.c_oAscSdtLockType.ContentLocked,null!==h.get_ChartProperties()?(s=!0,d=Common.Utils.documentSettingsType.Chart):null!==h.get_ShapeProperties()&&(s=h.get_ShapeProperties().get_FromChart(),d=Common.Utils.documentSettingsType.Shape,h.get_ShapeProperties().asc_getTextArtProperties()&&(this._settings[Common.Utils.documentSettingsType.TextArt].props=h,this._settings[Common.Utils.documentSettingsType.TextArt].hidden=0,this._settings[Common.Utils.documentSettingsType.TextArt].locked=h.get_Locked()||l)),r=r||h.get_Locked()}else d==Common.Utils.documentSettingsType.Paragraph&&(this._settings[d].panel.isChart=s,i=h.get_CanAddTable(),r=r||h.get_Locked());this._settings[d].props=h,this._settings[d].hidden=0,this._settings[d].locked=h.get_Locked()||l,this._settings[Common.Utils.documentSettingsType.MailMerge].locked||(this._settings[Common.Utils.documentSettingsType.MailMerge].locked=h.get_Locked()),this._settings[Common.Utils.documentSettingsType.Signature].locked||(this._settings[Common.Utils.documentSettingsType.Signature].locked=h.get_Locked())}}if(a&&a.get_FormPr()&&this.rightmenu.formSettings){var m=a.get_SpecificType();m!=Asc.c_oAscContentControlSpecificType.CheckBox&&m!=Asc.c_oAscContentControlSpecificType.Picture&&m!=Asc.c_oAscContentControlSpecificType.ComboBox&&m!=Asc.c_oAscContentControlSpecificType.DropDownList&&m!=Asc.c_oAscContentControlSpecificType.None||(d=Common.Utils.documentSettingsType.Form,this._settings[d].props=a,this._settings[d].locked=r,this._settings[d].hidden=0)}if(this._settings[Common.Utils.documentSettingsType.Header].locked)for(o=0;oy&&x>_?Common.Utils.documentSettingsType.Form:y>x&&y>_?Common.Utils.documentSettingsType.Shape:Common.Utils.documentSettingsType.Image):b=x>w?Common.Utils.documentSettingsType.Form:Common.Utils.documentSettingsType.Paragraph}b>-1?v=b:g>=0&&u<0?v=g:u>=0?v=u:this._settings[Common.Utils.documentSettingsType.MailMerge].hidden||(v=Common.Utils.documentSettingsType.MailMerge),void 0==v&&e&&g>=0&&(v=g),void 0!==v&&(this.rightmenu.SetActivePane(v,e),v!=Common.Utils.documentSettingsType.MailMerge&&v!=Common.Utils.documentSettingsType.Signature?this._settings[v].panel.ChangeSettings.call(this._settings[v].panel,this._settings[v].props):this._settings[v].panel.ChangeSettings.call(this._settings[v].panel))}this._settings[Common.Utils.documentSettingsType.Image].needShow=!1,this._settings[Common.Utils.documentSettingsType.Chart].needShow=!1}},onCoAuthoringDisconnect:function(){this.SetDisabled(!0,!1)},onInsertTable:function(){this._settings[Common.Utils.documentSettingsType.Table].needShow=!0},onInsertImage:function(){this._settings[Common.Utils.documentSettingsType.Image].needShow=!0},onInsertChart:function(){this._settings[Common.Utils.documentSettingsType.Chart].needShow=!0},onInsertShape:function(){this._settings[Common.Utils.documentSettingsType.Shape].needShow=!0},onInsertTextArt:function(){this._settings[Common.Utils.documentSettingsType.TextArt].needShow=!0},onInsertControl:function(){this._settings[Common.Utils.documentSettingsType.Form]&&(this._settings[Common.Utils.documentSettingsType.Form].needShow=!0)},UpdateThemeColors:function(){this.rightmenu.paragraphSettings.UpdateThemeColors(),this.rightmenu.tableSettings.UpdateThemeColors(),this.rightmenu.shapeSettings.UpdateThemeColors(),this.rightmenu.textartSettings.UpdateThemeColors()},updateMetricUnit:function(){this.rightmenu.headerSettings.updateMetricUnit(),this.rightmenu.paragraphSettings.updateMetricUnit(),this.rightmenu.chartSettings.updateMetricUnit(),this.rightmenu.imageSettings.updateMetricUnit(),this.rightmenu.tableSettings.updateMetricUnit(),this.rightmenu.formSettings&&this.rightmenu.formSettings.updateMetricUnit()},createDelayedElements:function(){if(this.api&&(this.api.asc_registerCallback("asc_onFocusObject",_.bind(this.onFocusObject,this)),this.api.asc_registerCallback("asc_doubleClickOnObject",_.bind(this.onDoubleClickOnObject,this)),this.rightmenu.mergeSettings&&(this.rightmenu.mergeSettings.setDocumentName(this.getApplication().getController("Viewport").getView("Common.Views.Header").getDocumentCaption()),this.api.asc_registerCallback("asc_onStartMailMerge",_.bind(this.onStartMailMerge,this))),this.api.asc_registerCallback("asc_onError",_.bind(this.onError,this))),this.editMode&&this.api){var t=this.api.getSelectedElements();t.length>0&&this.onFocusObject(t)}},onDoubleClickOnObject:function(t){if(this.editMode){var e=t.get_ObjectType(),i=this.getDocumentSettingsType(e);if(!(void 0===i||i>=this._settings.length||void 0===this._settings[i])){var n=t.get_ObjectValue();i==Common.Utils.documentSettingsType.Image&&(null!==n.get_ChartProperties()?i=Common.Utils.documentSettingsType.Chart:null!==n.get_ShapeProperties()&&(i=Common.Utils.documentSettingsType.Shape)),i!==Common.Utils.documentSettingsType.Paragraph&&(this.rightmenu.SetActivePane(i,!0),this._settings[i].panel.ChangeSettings.call(this._settings[i].panel,this._settings[i].props))}}},onStartMailMerge:function(){var t=Common.Utils.documentSettingsType.MailMerge;this._settings[t].hidden=0,this._settings[t].btn.setDisabled(!1),this.rightmenu.SetActivePane(t,!0),this._settings[t].panel.setLocked(this._settings[t].locked),this._settings[t].panel.ChangeSettings.call(this._settings[t].panel)},onError:function(t,e,i){if(t==Asc.c_oAscError.ID.MailMergeLoadFile){this._settings[Common.Utils.documentSettingsType.MailMerge].hidden=1,this._settings[Common.Utils.documentSettingsType.MailMerge].btn.setDisabled(!0);var n=this.api.getSelectedElements();n.length>0&&this.onFocusObject(n)}},onApiUpdateSignatures:function(t,e){ -if(this.rightmenu.signatureSettings){var i=(!t||t.length<1)&&(!e||e.length<1),n=Common.Utils.documentSettingsType.Signature;this._settings[n].hidden=i?1:0,this._settings[n].btn.setDisabled(i),this._settings[n].panel.setLocked(this._settings[n].locked)}},SetDisabled:function(t,e,i){if(this.setMode({isEdit:!t}),this.rightmenu&&this.rightmenu.paragraphSettings)if(this.rightmenu.paragraphSettings.disableControls(t),this.rightmenu.shapeSettings.disableControls(t),this.rightmenu.textartSettings.disableControls(t),this.rightmenu.headerSettings.disableControls(t),this.rightmenu.tableSettings.disableControls(t),this.rightmenu.imageSettings.disableControls(t),this.rightmenu.formSettings&&this.rightmenu.formSettings.disableControls(t),!e&&this.rightmenu.mergeSettings&&(this.rightmenu.mergeSettings.disableControls(t),t&&this.rightmenu.btnMailMerge.setDisabled(t)),this.rightmenu.chartSettings.disableControls(t),!i&&this.rightmenu.signatureSettings&&this.rightmenu.btnSignature.setDisabled(t),t)this.rightmenu.btnText.setDisabled(t),this.rightmenu.btnTable.setDisabled(t),this.rightmenu.btnImage.setDisabled(t),this.rightmenu.btnHeaderFooter.setDisabled(t),this.rightmenu.btnShape.setDisabled(t),this.rightmenu.btnTextArt.setDisabled(t),this.rightmenu.btnChart.setDisabled(t),this.rightmenu.btnForm&&this.rightmenu.btnForm.setDisabled(t);else{var n=this.api.getSelectedElements();n.length>0&&this.onFocusObject(n)}},getDocumentSettingsType:function(t){switch(t){case Asc.c_oAscTypeSelectElement.Paragraph:return Common.Utils.documentSettingsType.Paragraph;case Asc.c_oAscTypeSelectElement.Table:return Common.Utils.documentSettingsType.Table;case Asc.c_oAscTypeSelectElement.Image:return Common.Utils.documentSettingsType.Image;case Asc.c_oAscTypeSelectElement.Header:return Common.Utils.documentSettingsType.Header}}})}),function(t){function e(t,e){for(var i=t.length;i--;)if(t[i]===e)return i;return-1}function i(t,e){if(t.length!=e.length)return!1;for(var i=0;i0;for(s in A)(!A[s]&&e(o.mods,+s)>-1||A[s]&&-1==e(o.mods,+s))&&(l=!1);(0!=o.mods.length||A[16]||A[18]||A[17]||A[91])&&!l||(!0===x||o.locked||!1===o.method(t,o))&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0))}}function s(t){var i,n=t.keyCode,o=e(M,n);if(o>=0&&M.splice(o,1),93!=n&&224!=n||(n=91),n in A){A[n]=!1;for(i in T)T[i]==n&&(r[i]=!1)}}function a(){for(w in A)A[w]=!1;for(w in T)r[w]=!1}function r(t,e,i){var n,o;n=g(t),void 0===i&&(i=e,e="all");for(var s=0;s1&&(o=b(t),t=[t[t.length-1]]),t=t[0],t=P(t),t in S||(S[t]=[]),S[t].push({shortcut:n[s],scope:e,method:i,key:n[s],mods:o})}function l(t,e){var n,o,s,a,r,l=[];for(n=g(t),a=0;a1&&(l=b(o),t=o[o.length-1]),t=P(t),void 0===e&&(e=m()),!S[t])return;for(s in S[t])r=S[t][s],r.scope===e&&i(r.mods,l)&&(S[t][s]={})}}function c(t){return"string"==typeof t&&(t=P(t)),-1!=e(M,t)}function d(){return M.slice(0)}function h(t){var e=(t.target||t.srcElement).tagName;return!("INPUT"==e||"SELECT"==e||"TEXTAREA"==e)}function p(t){k=t||"all"}function m(){return k||"all"}function u(t){var e,i,n;for(e in S)for(i=S[e],n=0;n1&&(l=b(s),t=s[s.length-1]),t=P(t),void 0===e&&(e=m()),S[t])for(a in S[t])r=S[t][a],r.scope===e&&i(r.mods,l)&&(S[t][a][n]=o)}function _(t,e){t?v(t,e,"locked",!0):x=!0}function y(t,e){t?v(t,e,"locked",!1):x=!1}var w,x,S={},A={16:!1,18:!1,17:!1,91:!1},k="all",T={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,command:91},I={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,home:36,end:35,pageup:33,pagedown:34,",":188,".":190,"/":191,"`":192,"-":189,"=":187,";":186,"'":222,"[":219,"]":221,"\\":220,"ff-":173,"ff=":61},P=function(t){return I[t]||t.toUpperCase().charCodeAt(0)},M=[];for(w=1;w<20;w++)I["f"+w]=111+w;var E={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey"};for(w in T)r[w]=!1;f(document,"keydown",function(t){o(t)}),f(document,"keyup",s),f(window,"focus",a);var U=t.key;t.key=r,t.key.setScope=p,t.key.getScope=m,t.key.deleteScope=u,t.key.filter=h,t.key.isPressed=c,t.key.getPressedKeyCodes=d,t.key.noConflict=C,t.key.unbind=l,t.key.suspend=_,t.key.resume=y,"undefined"!=typeof module&&(module.exports=key)}(this),define("keymaster",function(){}),void 0===Common)var Common={};if(Common.util=Common.util||{},define("common/main/lib/util/Shortcuts",["backbone","keymaster"],function(t){"use strict";var e=function(t){return this.cid=_.uniqueId("shortcuts"),this.initialize.apply(this,arguments),this};_.extend(e.prototype,t.Events,{initialize:function(){window.key.filter=function(t){return!0},Common.NotificationCenter.on({"modal:show":function(t){window.key.suspend()},"modal:close":function(t,e){e&&window.key.resume()},"modal:hide":function(t,e){e&&window.key.resume()}})},delegateShortcuts:function(t){if(t&&t.shortcuts){this.removeShortcuts(t);var e,i,n,o,s,a,r=[];for(s in t.shortcuts){if(e=t.shortcuts[s],_.isFunction(e))n=e;else if(!(n=t[e]))throw new Error("Method "+e+" does not exist");i=s.match(/^(\S+)\s*(.*)$/),a=i[1],o=i[2].length?i[2]:"all",n=_.bind(n,this),r.push(window.key(a,o,n))}}},removeShortcuts:function(t){if(t&&t.shortcuts){var e,i,n,o;for(n in t.shortcuts)e=n.match(/^(\S+)\s*(.*)$/),o=e[1],i=e[2].length?e[2]:"all",window.key.unbind(o,i)}},suspendEvents:function(t,e){window.key.suspend(t,e)},resumeEvents:function(t,e){window.key.resume(t,e)}}),e.extend=t.View.extend,Common.util.Shortcuts=new e}),define("documenteditor/main/app/controller/LeftMenu",["core","common/main/lib/util/Shortcuts","common/main/lib/view/SaveAsDlg","documenteditor/main/app/view/LeftMenu","documenteditor/main/app/view/FileMenu"],function(){"use strict";DE.Controllers.LeftMenu=Backbone.Controller.extend(_.extend({views:["LeftMenu","FileMenu"],initialize:function(){this.addListeners({"Common.Views.Chat":{hide:_.bind(this.onHideChat,this)},"Common.Views.Header":{"file:settings":_.bind(this.clickToolbarSettings,this),"history:show":function(){this.leftMenu.panelHistory.isVisible()||this.clickMenuFileItem("header","history")}.bind(this)},"Common.Views.About":{show:_.bind(this.aboutShowHide,this,!1),hide:_.bind(this.aboutShowHide,this,!0)},"Common.Views.Plugins":{"plugin:open":_.bind(this.onPluginOpen,this),hide:_.bind(this.onHidePlugins,this)},LeftMenu:{"comments:show":_.bind(this.commentsShowHide,this,"show"),"comments:hide":_.bind(this.commentsShowHide,this,"hide")},FileMenu:{"menu:hide":_.bind(this.menuFilesShowHide,this,"hide"),"menu:show":_.bind(this.menuFilesShowHide,this,"show"),"item:click":_.bind(this.clickMenuFileItem,this),"saveas:format":_.bind(this.clickSaveAsFormat,this),"savecopy:format":_.bind(this.clickSaveCopyAsFormat,this),"settings:apply":_.bind(this.applySettings,this),"create:new":_.bind(this.onCreateNew,this),"recent:open":_.bind(this.onOpenRecent,this)},Toolbar:{"file:settings":_.bind(this.clickToolbarSettings,this),"file:open":this.clickToolbarTab.bind(this,"file"),"file:close":this.clickToolbarTab.bind(this,"other"),"save:disabled":this.changeToolbarSaveState.bind(this)},SearchDialog:{hide:_.bind(this.onSearchDlgHide,this),"search:back":_.bind(this.onQuerySearch,this,"back"),"search:next":_.bind(this.onQuerySearch,this,"next"),"search:replace":_.bind(this.onQueryReplace,this),"search:replaceall":_.bind(this.onQueryReplaceAll,this),"search:highlight":_.bind(this.onSearchHighlight,this)},"Common.Views.ReviewChanges":{"collaboration:chat":_.bind(this.onShowHideChat,this)}}),Common.NotificationCenter.on("leftmenu:change",_.bind(this.onMenuChange,this)),Common.NotificationCenter.on("app:comment:add",_.bind(this.onAppAddComment,this)),Common.NotificationCenter.on("collaboration:history",_.bind(function(){this.leftMenu.panelHistory.isVisible()||this.clickMenuFileItem(null,"history")},this))},onLaunch:function(){this.leftMenu=this.createView("LeftMenu").render(),this.leftMenu.btnSearch.on("toggle",_.bind(this.onMenuSearch,this)),Common.util.Shortcuts.delegateShortcuts({shortcuts:{"command+shift+s,ctrl+shift+s":_.bind(this.onShortcut,this,"save"),"command+f,ctrl+f":_.bind(this.onShortcut,this,"search"),"ctrl+h":_.bind(this.onShortcut,this,"replace"),"alt+f":_.bind(this.onShortcut,this,"file"),esc:_.bind(this.onShortcut,this,"escape"),"alt+q":_.bind(this.onShortcut,this,"chat"),"command+shift+h,ctrl+shift+h":_.bind(this.onShortcut,this,"comments"),f1:_.bind(this.onShortcut,this,"help")}}),Common.util.Shortcuts.suspendEvents()},setApi:function(t){if(this.api=t,this.api.asc_registerCallback("asc_onReplaceAll",_.bind(this.onApiTextReplaced,this)),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onApiServerDisconnect,this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onApiServerDisconnect,this)),this.api.asc_registerCallback("asc_onDownloadUrl",_.bind(this.onDownloadUrl,this)),this.mode.canCoAuthoring&&(this.mode.canChat&&this.api.asc_registerCallback("asc_onCoAuthoringChatReceiveMessage",_.bind(this.onApiChatMessage,this)),this.mode.canComments)){this.api.asc_registerCallback("asc_onAddComment",_.bind(this.onApiAddComment,this)),this.api.asc_registerCallback("asc_onAddComments",_.bind(this.onApiAddComments,this));for(var e=this.getApplication().getCollection("Common.Collections.Comments"),i=Common.Utils.InternalSettings.get("de-settings-resolvedcomment"),n=0;n0&&(i=i.substring(0,n)+this.isFromFileDownloadAs)}e.mode.canRequestSaveAs?Common.Gateway.requestSaveAs(t,i):(e._saveCopyDlg=new Common.Views.SaveAsDlg({saveFolderUrl:e.mode.saveAsUrl,saveFileUrl:t,defFileName:i}),e._saveCopyDlg.on("saveaserror",function(t,i){var n={closable:!1,title:e.notcriticalErrorTitle,msg:i,iconCls:"warn",buttons:["ok"],callback:function(t){Common.NotificationCenter.trigger("edit:complete",e)}};Common.UI.alert(n)}).on("close",function(t){e._saveCopyDlg=void 0}),e._saveCopyDlg.show())}this.isFromFileDownloadAs=!1},applySettings:function(t){var e;if(e=Common.localStorage.getBool("de-settings-inputmode"),Common.Utils.InternalSettings.set("de-settings-inputmode",e),this.api.SetTextBoxInputMode(e),this.mode.isEdit&&!this.mode.isOffline&&this.mode.canCoAuthoring){var i=Common.localStorage.getBool("de-settings-coauthmode",!0);switch(Common.Utils.InternalSettings.set("de-settings-coauthmode",i),this.api.asc_SetFastCollaborative(i),e=Common.localStorage.getItem(i?"de-settings-showchanges-fast":"de-settings-showchanges-strict"),Common.Utils.InternalSettings.set(i?"de-settings-showchanges-fast":"de-settings-showchanges-strict",e),e){case"all":e=Asc.c_oAscCollaborativeMarksShowType.All;break;case"none":e=Asc.c_oAscCollaborativeMarksShowType.None;break;case"last":e=Asc.c_oAscCollaborativeMarksShowType.LastChanges;break;default:e=i?Asc.c_oAscCollaborativeMarksShowType.None:Asc.c_oAscCollaborativeMarksShowType.LastChanges}this.api.SetCollaborativeMarksShowType(e)}e=Common.localStorage.getBool("de-settings-livecomment",!0),Common.Utils.InternalSettings.set("de-settings-livecomment",e);var n=Common.localStorage.getBool("de-settings-resolvedcomment");switch(Common.Utils.InternalSettings.set("de-settings-resolvedcomment",n),this.mode.canViewComments&&this.leftMenu.panelComments.isVisible()&&(e=n=!0),e?this.api.asc_showComments(n):this.api.asc_hideComments(),this.getApplication().getController("Common.Controllers.ReviewChanges").commentsShowHide(e?"show":"hide"),e=Common.localStorage.getBool("de-settings-cachemode",!0),Common.Utils.InternalSettings.set("de-settings-cachemode",e),this.api.asc_setDefaultBlitMode(e),e=Common.localStorage.getItem("de-settings-fontrender"),Common.Utils.InternalSettings.set("de-settings-fontrender",e),e){case"1":this.api.SetFontRenderingMode(1);break;case"2":this.api.SetFontRenderingMode(2);break;case"0":this.api.SetFontRenderingMode(3)}this.mode.isEdit&&(e=parseInt(Common.localStorage.getItem("de-settings-autosave")),Common.Utils.InternalSettings.set("de-settings-autosave",e),this.api.asc_setAutoSaveGap(e),e=Common.localStorage.getBool("de-settings-spellcheck",!0),Common.Utils.InternalSettings.set("de-settings-spellcheck",e),this.api.asc_setSpellCheck(e),e=parseInt(Common.localStorage.getItem("de-settings-paste-button")),Common.Utils.InternalSettings.set("de-settings-paste-button",e),this.api.asc_setVisiblePasteButton(!!e)),this.api.put_ShowSnapLines(Common.Utils.InternalSettings.get("de-settings-showsnaplines")),t.hide()},onCreateNew:function(t,e){if(!Common.Controllers.Desktop.process("create:new"))if(this.mode.canRequestCreateNew)Common.Gateway.requestCreateNew();else{var i=window.open("blank"==e?this.mode.createUrl:e,"_blank");i&&i.focus()}t&&t.hide()},onOpenRecent:function(t,e){t&&t.hide();var i=window.open(e);i&&i.focus(),Common.component.Analytics.trackEvent("Open Recent")},clickToolbarSettings:function(t){this.leftMenu.showMenu("file:opts")},clickToolbarTab:function(t,e){"file"==t?this.leftMenu.showMenu("file"):this.leftMenu.menuFile.hide()},changeToolbarSaveState:function(t){var e=this.leftMenu.menuFile.getButton("save");e&&e.setDisabled(t)},onHideChat:function(){$(this.leftMenu.btnChat.el).blur(),Common.NotificationCenter.trigger("layout:changed","leftmenu")},onHidePlugins:function(){Common.NotificationCenter.trigger("layout:changed","leftmenu")},onQuerySearch:function(t,e,i){if(i.textsearch&&i.textsearch.length&&!this.api.asc_findText(i.textsearch,"back"!=t,i.matchcase,i.matchword)){var n=this;Common.UI.info({msg:this.textNoTextFound,callback:function(){n.dlgSearch.focus()}})}},onQueryReplace:function(t,e){if(!_.isEmpty(e.textsearch)&&!this.api.asc_replaceText(e.textsearch,e.textreplace,!1,e.matchcase,e.matchword)){var i=this;Common.UI.info({msg:this.textNoTextFound,callback:function(){i.dlgSearch.focus()}})}},onQueryReplaceAll:function(t,e){_.isEmpty(e.textsearch)||this.api.asc_replaceText(e.textsearch,e.textreplace,!0,e.matchcase,e.matchword)},onSearchHighlight:function(t,e){this.api.asc_selectSearchingResults(e)},showSearchDlg:function(t,e){if(this.dlgSearch||(this.dlgSearch=new Common.UI.SearchDialog({matchcase:!0,markresult:{applied:!0}})),t){var i=this.mode.isEdit&&!this.viewmode?e||void 0:"no-replace";this.dlgSearch.isVisible()?(this.dlgSearch.setMode(i),this.dlgSearch.setSearchText(this.api.asc_GetSelectedText()),this.dlgSearch.focus()):this.dlgSearch.show(i,this.api.asc_GetSelectedText())}else this.dlgSearch.hide()},onMenuSearch:function(t,e){this.showSearchDlg(e)},onSearchDlgHide:function(){this.leftMenu.btnSearch.toggle(!1,!0),this.api.asc_selectSearchingResults(!1),$(this.leftMenu.btnSearch.el).blur(),this.api.asc_enableKeyEvents(!0)},onApiTextReplaced:function(t,e){t?t-e>0?Common.UI.warning({msg:Common.Utils.String.format(this.textReplaceSkipped,t-e)}):Common.UI.info({msg:Common.Utils.String.format(this.textReplaceSuccess,e)}):Common.UI.info({msg:this.textNoTextFound})},onApiServerDisconnect:function(t){this.mode.isEdit=!1,this.leftMenu.close(),this.leftMenu.btnComments.setDisabled(!0),this.leftMenu.btnChat.setDisabled(!0),this.leftMenu.btnPlugins.setDisabled(!0),this.leftMenu.btnNavigation.setDisabled(!0),this.leftMenu.getMenu("file").setMode({isDisconnected:!0,enableDownload:!!t}),this.dlgSearch&&(this.leftMenu.btnSearch.toggle(!1,!0),this.dlgSearch.hide())},setPreviewMode:function(t){this.viewmode!==t&&(this.viewmode=t,this.dlgSearch&&this.dlgSearch.setMode(this.viewmode?"no-replace":"search"))},SetDisabled:function(t,e){this.mode.isEdit=!t,t&&this.leftMenu.close(),this.leftMenu.btnComments.setDisabled(t);var i=this.getApplication().getController("Common.Controllers.Comments");i&&i.setPreviewMode(t),this.setPreviewMode(t),this.leftMenu.btnChat.setDisabled(t),this.leftMenu.btnPlugins.setDisabled(t),this.leftMenu.btnNavigation.setDisabled(t),e&&this.leftMenu.getMenu("file").SetDisabled(t)},onApiChatMessage:function(){this.leftMenu.markCoauthOptions("chat")},onApiAddComment:function(t,e){var i=Common.Utils.InternalSettings.get("de-settings-resolvedcomment");!e||e.asc_getUserId()===this.mode.user.id||!i&&e.asc_getSolved()||this.leftMenu.markCoauthOptions("comments")},onApiAddComments:function(t){for(var e=Common.Utils.InternalSettings.get("de-settings-resolvedcomment"),i=0;i [data-toggle="dropdown"]');if(n.length)return $.fn.dropdown.Constructor.prototype.keydown.call(n[0],e),!1;if(this.mode.canPlugins&&this.leftMenu.panelPlugins&&(n=this.leftMenu.panelPlugins.$el.find('#menu-plugin-container.open > [data-toggle="dropdown"]'),n.length))return $.fn.dropdown.Constructor.prototype.keydown.call(n[0],e),!1;if(this.leftMenu.btnAbout.pressed||this.leftMenu.btnPlugins.pressed||$(e.target).parents("#left-menu").length)return this.leftMenu.close(),Common.NotificationCenter.trigger("layout:changed","leftmenu"),!1;break;case"chat":return this.mode.canCoAuthoring&&this.mode.canChat&&!this.mode.isLightVersion&&(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("chat")),!1;case"comments":return this.mode.canCoAuthoring&&this.mode.canViewComments&&!this.mode.isLightVersion&&(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("comments"),this.getApplication().getController("Common.Controllers.Comments").onAfterShow()),!1}},onPluginOpen:function(t,e,i){"onboard"==e&&("open"==i?(this.leftMenu.close(),this.leftMenu.panelPlugins.show(),this.leftMenu.onBtnMenuClick({pressed:!0,options:{action:"plugins"}}),this.leftMenu._state.pluginIsRunning=!0):(this.leftMenu._state.pluginIsRunning=!1,this.leftMenu.close()))},showHistory:function(){var t=DE.getController("Main");t.loadMask||(t.loadMask=new Common.UI.LoadMask({owner:$("#viewport")})),t.loadMask.setTitle(this.textLoadHistory),t.loadMask.show(),Common.Gateway.requestHistory()},onShowHideChat:function(t){this.mode.canCoAuthoring&&this.mode.canChat&&!this.mode.isLightVersion&&(t?(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("chat")):(this.leftMenu.btnChat.toggle(!1,!0),this.leftMenu.onBtnMenuClick(this.leftMenu.btnChat)))},textNoTextFound:"Text not found",newDocumentTitle:"Unnamed document",requestEditRightsText:"Requesting editing rights...",textReplaceSuccess:"Search has been done. {0} occurrences have been replaced",textReplaceSkipped:"The replacement has been made. {0} occurrences were skipped.",textLoadHistory:"Loading version history...",notcriticalErrorTitle:"Warning",leavePageText:"All unsaved changes in this document will be lost.
    Click 'Cancel' then 'Save' to save them. Click 'OK' to discard all the unsaved changes.",warnDownloadAs:"If you continue saving in this format all features except the text will be lost.
    Are you sure you want to continue?",warnDownloadAsRTF:"If you continue saving in this format some of the formatting might be lost.
    Are you sure you want to continue?",txtUntitled:"Untitled",txtCompatible:"The document will be saved to the new format. It will allow to use all the editor features, but might affect the document layout.
    Use the 'Compatibility' option of the advanced settings if you want to make the files compatible with older MS Word versions."},DE.Controllers.LeftMenu||{}))}),void 0===Common)var Common={};if(Common.IrregularStack=function(t){var e=[],i=function(t,e){return"object"==typeof t&&"object"==typeof e&&window.JSON?window.JSON.stringify(t)===window.JSON.stringify(e):t===e};t=t||{};var n=t.strongCompare||i,o=t.weakCompare||i,s=function(t,i){for(var n=e.length-1;n>=0;n--)if(i(e[n],t))return n;return-1};return{push:function(t){e.push(t)},pop:function(t){var i=s(t,n);if(-1!=i)return e.splice(i,1)[0]},get:function(t){var i=s(t,o);if(-1!=i)return e[i]},exist:function(t){return!(s(t,n)<0)}}},define("irregularstack",function(){}),void 0===Common)var Common={};if(Common.Controllers=Common.Controllers||{},define("common/main/lib/controller/Fonts",["core","common/main/lib/collection/Fonts"],function(){"use strict";Common.Controllers.Fonts=Backbone.Controller.extend(function(){function t(t,e){for(var i,n=e.get("type")==o,s=-1,a=t.length,r=e.get("name");!n&&++s=0?this.btnDirection.setIconCls("item-gradient "+this._viewDataRadial[this.GradRadialDirectionIdx].iconcls):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(0,!0),this.numGradientAngle.setDisabled(!0));if(this.api&&!this._noApply){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad),n.get_fill().put_grad_type(this.GradFillType),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),i.put_fill(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onSelectGradient:function(t,e,n,o){if(!this._noApply){var s={};if(i.isFunction(o.toJSON)){if(!o.get("selected"))return;s=o.toJSON()}else s=o;if(this.btnDirection.setIconCls("item-gradient "+s.iconcls),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR?this.GradLinearDirectionType=s.type:this.GradRadialDirectionIdx=0,this.api&&this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){this.numGradientAngle.setValue(s.type,!0);var a=new Asc.asc_CShapeProperty,r=new Asc.asc_CShapeFill;r.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),r.put_fill(new Asc.asc_CFillGrad),r.get_fill().put_grad_type(this.GradFillType),r.get_fill().put_linear_angle(6e4*s.type),r.get_fill().put_linear_scale(!0),a.put_fill(r),this.imgprops.put_ShapeProperties(a),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)}},onColorsGradientSelect:function(t,e){if(this.GradColor.colors[this.GradColor.currentIdx]=e,this.sldrGradient.setColorValue(Common.Utils.String.format("#{0}","object"==typeof e?e.color:e)),this.api&&!this._noApply){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad),n.get_fill().put_grad_type(this.GradFillType);var o=[];this.GradColor.colors.forEach(function(t){o.push(Common.Utils.ThemeColor.getRgbColor(t))}),n.get_fill().put_colors(o),this.OriginalFillType!==Asc.c_oAscFill.FILL_TYPE_GRAD&&(this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),o=[],this.GradColor.values.forEach(function(t){o.push(1e3*t)}),n.get_fill().put_positions(o)),i.put_fill(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onGradientChange:function(t,e,n){this.GradColor.values=t.getValues(),this.spnGradPosition.setValue(this.GradColor.values[this.GradColor.currentIdx],!0),this._sliderChanged=!0,this.api&&!this._noApply&&this._sendUndoPoint&&(this.api.setStartPointHistory(),this._sendUndoPoint=!1,this.updateslider=setInterval(i.bind(this._gradientApplyFunc,this),100))},onGradientChangeComplete:function(t,e,i){clearInterval(this.updateslider),this._sliderChanged=!0,this._sendUndoPoint||(this.api.setEndPointHistory(),this._gradientApplyFunc()),this._sendUndoPoint=!0},_gradientApplyFunc:function(){if(this._sliderChanged){var t=new Asc.asc_CShapeProperty,e=new Asc.asc_CShapeFill;e.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),e.put_fill(new Asc.asc_CFillGrad),e.get_fill().put_grad_type(this.GradFillType);var i=[];this.GradColor.values.forEach(function(t){i.push(1e3*t)}),e.get_fill().put_positions(i),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(e.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),e.get_fill().put_linear_scale(!0)),i=[],this.GradColor.colors.forEach(function(t){i.push(Common.Utils.ThemeColor.getRgbColor(t))}),e.get_fill().put_colors(i),t.put_fill(e),this.imgprops.put_ShapeProperties(t),this.api.ImgApply(this.imgprops),this._sliderChanged=!1}},applyBorderSize:function(t){if(t=Common.Utils.String.parseFloat(t),t=isNaN(t)?0:Math.max(0,Math.min(1584,t)),this.BorderSize=t,this.api&&!this._noApply){var e=new Asc.asc_CShapeProperty,i=new Asc.asc_CStroke;this.BorderSize<1e-5?(i.put_type(Asc.c_oAscStrokeType.STROKE_NONE),this._state.StrokeType=this._state.StrokeWidth=-1):(i.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),"transparent"==this.BorderColor.Color||"transparent"==this.BorderColor.Color.color?i.put_color(Common.Utils.ThemeColor.getRgbColor({color:"000000",effectId:29})):this._state.StrokeType!=Asc.c_oAscStrokeType.STROKE_NONE&&null!==this._state.StrokeType||i.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(this.BorderColor.Color))),i.asc_putPrstDash(this.BorderType),i.put_width(this._pt2mm(this.BorderSize))),e.put_stroke(i),this.imgprops.put_ShapeProperties(e),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onComboBlur:function(){this.fireEvent("editcomplete",this)},onBorderSizeChanged:function(t,e,n,o){var s=this;if(t){var a=parseFloat(n.value);(!new RegExp("^\\s*(\\d*(\\.|,)?\\d+)\\s*("+s.txtPt+")?\\s*$").exec(n.value)||a<0||a>1584)&&(this._state.StrokeType=this._state.StrokeWidth=-1,Common.UI.error({msg:this.textBorderSizeErr,callback:function(){i.defer(function(t){s.fireEvent("editcomplete",s)})}}))}else this.applyBorderSize(n.value)},onBorderSizeSelect:function(t,e){this.applyBorderSize(e.value)},onBorderTypeSelect:function(t,e){if(this.BorderType=e.value,this.api&&!this._noApply){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CStroke;this.BorderSize<1e-5?n.put_type(Asc.c_oAscStrokeType.STROKE_NONE):(n.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),n.put_color(Common.Utils.ThemeColor.getRgbColor(this.BorderColor.Color)),n.put_width(this._pt2mm(this.BorderSize)),n.asc_putPrstDash(this.BorderType)),i.put_stroke(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onColorsBorderSelect:function(t,e){if(this.BorderColor={Value:1,Color:e},this.api&&this.BorderSize>0&&!this._noApply){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CStroke;this.BorderSize<1e-5?n.put_type(Asc.c_oAscStrokeType.STROKE_NONE):(n.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),n.put_color(Common.Utils.ThemeColor.getRgbColor(this.BorderColor.Color)),n.put_width(this._pt2mm(this.BorderSize)),n.asc_putPrstDash(this.BorderType)),i.put_stroke(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},_ImgWrapStyleChanged:function(t){if(this.cmbWrapType&&this._state.WrappingStyle!==t){this.cmbWrapType.suspendEvents();var e=this.cmbWrapType.menuPicker.store.findWhere({data:t});this.cmbWrapType.menuPicker.selectRecord(e),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=t}},onSelectWrap:function(t,e){if(this.api){var i=new Asc.asc_CImgProperty,n=e.get("data");if(i.put_WrappingStyle(n),this._state.WrappingStyle===Asc.c_oAscWrapStyle2.Inline&&n!==Asc.c_oAscWrapStyle2.Inline){i.put_PositionH(new Asc.CImagePositionH),i.get_PositionH().put_UseAlign(!1),i.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);var o=this._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column);i.get_PositionH().put_Value(o),i.put_PositionV(new Asc.CImagePositionV),i.get_PositionV().put_UseAlign(!1),i.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph),o=this._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph),i.get_PositionV().put_Value(o)}this.api.ImgApply(i)}this.fireEvent("editcomplete",this)},setImageUrl:function(t,e){if(null!==this.BlipFillType){var i=new Asc.asc_CShapeProperty,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_BLIP),n.put_fill(new Asc.asc_CFillBlip),n.get_fill().put_type(this.BlipFillType),n.get_fill().put_url(t,e),i.put_fill(n),this.imgprops.put_ShapeProperties(i),this.api.ImgApply(this.imgprops)}},insertImageFromStorage:function(t){t&&t.url&&"fill"==t.c&&this.setImageUrl(t.url,t.token)},onImageSelect:function(t,e){if(1==e.value){var n=this;new Common.Views.ImageFromUrlDialog({handler:function(t,e){if("ok"==t&&n.api){var o=e.replace(/ /g,"");i.isEmpty(o)||n.setImageUrl(o)}n.fireEvent("editcomplete",n)}}).show()}else 2==e.value?Common.NotificationCenter.trigger("storage:image-load","fill"):(this.api&&this.api.ChangeShapeImageFromFile(this.BlipFillType),this.fireEvent("editcomplete",this))},openAdvancedSettings:function(t){if(!this.linkAdvanced.hasClass("disabled")){var e=this;if(e.api&&!this._locked){var i=e.api.getSelectedElements();if(i&&i.length>0)for(var n,o,s=i.length-1;s>=0;s--)if(n=i[s].get_ObjectType(),o=i[s].get_ObjectValue(),Asc.c_oAscTypeSelectElement.Image==n){new DE.Views.ImageSettingsAdvanced({imageProps:o,sectionProps:e.api.asc_GetSectionProps(),handler:function(t,i){"ok"==t&&e.api&&e.api.ImgApply(i.imageProps),e.fireEvent("editcomplete",e)}}).show();break}}}},ChangeSettings:function(t){if(null==this.imgprops?this.imgprops=new Asc.asc_CImgProperty:this.imgprops.put_ImageUrl(null),this._initSettings&&this.createDelayedElements(),t&&t.get_ShapeProperties()){var n=t.get_ShapeProperties(),o=n.asc_getType();this._originalProps=new Asc.asc_CImgProperty(t),this._noApply=!0,this.disableControls(this._locked,!n.get_CanFill()),this.hideShapeOnlySettings(n.get_FromChart()||n.get_FromImage());var s=n.get_FromChart()||"line"==o||"bentConnector2"==o||"bentConnector3"==o||"bentConnector4"==o||"bentConnector5"==o||"curvedConnector2"==o||"curvedConnector3"==o||"curvedConnector4"==o||"curvedConnector5"==o||"straightConnector1"==o;this.hideChangeTypeSettings(s),this._state.isFromImage=!!n.get_FromImage(),!s&&this.btnChangeShape.menu.items.length&&(this.btnChangeShape.menu.items[0].setVisible(n.get_FromImage()),this.btnChangeShape.menu.items[1].setVisible(!n.get_FromImage()));var a=t.get_WrappingStyle();if(this._state.WrappingStyle!==a){this.cmbWrapType.suspendEvents();var r=this.cmbWrapType.menuPicker.store.findWhere({data:a});this.cmbWrapType.menuPicker.selectRecord(r),this.cmbWrapType.resumeEvents(),this._state.WrappingStyle=a}a=t.get_CanBeFlow()&&!this._locked;var l=t.get_FromGroup()||this._locked;this._state.CanBeFlow===a&&this._state.FromGroup===l||(this.cmbWrapType.setDisabled(!a||l),this._state.CanBeFlow=a,this._state.FromGroup=l);var r=null,c=n.get_fill(),d=c.get_type(),h=null,p=c.get_transparent();if((Math.abs(this._state.Transparency-p)>.001||Math.abs(this.numTransparency.getNumberValue()-p)>.001||(null===this._state.Transparency||null===p)&&(this._state.Transparency!==p||this.numTransparency.getNumberValue()!==p))&&(void 0!==p&&(this.sldrTransparency.setValue(null===p?100:p/255*100,!0),this.numTransparency.setValue(this.sldrTransparency.getValue(),!0)),this._state.Transparency=p),null===c||null===d)this.OriginalFillType=null;else if(d==Asc.c_oAscFill.FILL_TYPE_NOFILL)this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_NOFILL;else if(d==Asc.c_oAscFill.FILL_TYPE_SOLID)c=c.get_fill(),h=c.get_color(),h?h.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.ShapeColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b()),effectValue:h.get_value()}}:this.ShapeColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b())}:this.ShapeColor={Value:0,Color:"transparent"},this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_SOLID,this.FGColor="transparent"!==this.ShapeColor.Color?{Value:1,Color:Common.Utils.ThemeColor.colorValue2EffectId(this.ShapeColor.Color)}:{Value:1,Color:"000000"},this.BGColor={Value:1,Color:"ffffff"},this.GradColor.colors[0]="transparent"!==this.ShapeColor.Color?Common.Utils.ThemeColor.colorValue2EffectId(this.ShapeColor.Color):"000000",this.GradColor.colors[this.GradColor.colors.length-1]="ffffff";else if(d==Asc.c_oAscFill.FILL_TYPE_BLIP)c=c.get_fill(),this.BlipFillType=c.get_type(),this._state.BlipFillType!==this.BlipFillType&&(this.BlipFillType==Asc.c_oAscFillBlipType.STRETCH||this.BlipFillType==Asc.c_oAscFillBlipType.TILE?this.cmbFillType.setValue(this.BlipFillType):this.cmbFillType.setValue(""),this._state.BlipFillType=this.BlipFillType),this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_BLIP;else if(d==Asc.c_oAscFill.FILL_TYPE_PATT){if(c=c.get_fill(),this.PatternFillType=c.get_pattern_type(),this._state.PatternFillType!==this.PatternFillType){this.cmbPattern.suspendEvents();var r=this.cmbPattern.menuPicker.store.findWhere({type:this.PatternFillType});this.cmbPattern.menuPicker.selectRecord(r),this.cmbPattern.resumeEvents(),this._state.PatternFillType=this.PatternFillType}h=c.get_color_fg(),h?h.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.FGColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b()),effectValue:h.get_value()}}:this.FGColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b())}:this.FGColor={Value:1,Color:"000000"},h=c.get_color_bg(),h?h.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.BGColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b()),effectValue:h.get_value()}}:this.BGColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b())}:this.BGColor={Value:1,Color:"ffffff"},this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_PATT,this.ShapeColor={Value:1,Color:Common.Utils.ThemeColor.colorValue2EffectId(this.FGColor.Color)},this.GradColor.colors[0]=Common.Utils.ThemeColor.colorValue2EffectId(this.FGColor.Color),this.GradColor.colors[this.GradColor.colors.length-1]="ffffff"}else if(d==Asc.c_oAscFill.FILL_TYPE_GRAD){c=c.get_fill();var m=c.get_grad_type();if(this._state.GradFillType===m&&this.GradFillType===m||(this.GradFillType=m,r=void 0,this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR||this.GradFillType==Asc.c_oAscFillGradType.GRAD_PATH?(this.cmbGradType.setValue(this.GradFillType),r=this.cmbGradType.store.findWhere({value:this.GradFillType}),this.onGradTypeSelect(this.cmbGradType,r.attributes)):(this.cmbGradType.setValue(""),this.btnDirection.setIconCls("")),this._state.GradFillType=this.GradFillType),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){var a=Math.floor(c.get_linear_angle()/6e4);if(Math.abs(this.GradLinearDirectionType-a)>.001){this.GradLinearDirectionType=a;var u=this.mnuDirectionPicker.store.findWhere({type:a});this.mnuDirectionPicker.selectRecord(u,!0),u?this.btnDirection.setIconCls("item-gradient "+u.get("iconcls")):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(a,!0)}}else this.numGradientAngle.setValue(0,!0);var g=this,b=c.get_colors(),f=c.get_positions(),C=b?b.length:this.GradColor.colors.length;this.sldrGradient.setThumbs(C),this.GradColor.colors.length>C&&(this.GradColor.colors.splice(C,this.GradColor.colors.length-C),this.GradColor.values.splice(C,this.GradColor.colors.length-C),this.GradColor.currentIdx=0),b&&b.forEach(function(t,e){t?t.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?(g.GradColor.colors[e]={color:Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()),effectValue:t.get_value()},Common.Utils.ThemeColor.colorValue2EffectId(g.GradColor.colors[e])):g.GradColor.colors[e]=Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()):g.GradColor.colors[e]="000000";var i=f[e];null!==i&&(i/=1e3,g.GradColor.values[e]=i)});for(var v=0;v=this.GradColor.colors.length)&&(g.GradColor.currentIdx=0),g.sldrGradient.setActiveThumb(g.GradColor.currentIdx),this.spnGradPosition.setValue(this.GradColor.values[this.GradColor.currentIdx]),this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_GRAD,this.FGColor={Value:1,Color:this.GradColor.colors[0]},this.BGColor={Value:1,Color:"ffffff"},this.ShapeColor={Value:1,Color:this.GradColor.colors[0]}}this._state.FillType!==this.OriginalFillType&&(this.cmbFillSrc.setValue(null===this.OriginalFillType?"":this.OriginalFillType),this._state.FillType=this.OriginalFillType,this.ShowHideElem(this.OriginalFillType)),e(this.btnTexture.el).find(".form-control").prop("innerHTML",this.textSelectTexture);var _=typeof this.ShapeColor.Color,y=typeof this._state.ShapeColor;if(_!==y||"object"==_&&(this.ShapeColor.Color.effectValue!==this._state.ShapeColor.effectValue||this._state.ShapeColor.color.indexOf(this.ShapeColor.Color.color)<0)||"object"!=_&&this._state.ShapeColor.indexOf(this.ShapeColor.Color)<0){if(this.btnBackColor.setColor(this.ShapeColor.Color),"object"==typeof this.ShapeColor.Color){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==this.ShapeColor.Color.effectValue){this.colorsBack.select(this.ShapeColor.Color,!0),w=!0;break}w||this.colorsBack.clearSelection()}else this.colorsBack.select(this.ShapeColor.Color,!0);this._state.ShapeColor=this.ShapeColor.Color}var S,A=n.get_stroke(),k=A.get_type(),T="transparent"==this._state.StrokeColor&&"transparent"!==this.BorderColor.Color;if(A?(k==Asc.c_oAscStrokeType.STROKE_COLOR?(h=A.get_color(),h?h.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.BorderColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b()),effectValue:h.get_value()}}:this.BorderColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(h.get_r(),h.get_g(),h.get_b())}:this.BorderColor={Value:1,Color:"transparent"}):this.BorderColor={Value:1,Color:"transparent"},S=A.asc_getPrstDash()):(k=null,this.BorderColor={Value:0,Color:"transparent"}),_=typeof this.BorderColor.Color,y=typeof this._state.StrokeColor,T||_!==y||"object"==_&&(this.BorderColor.Color.effectValue!==this._state.StrokeColor.effectValue||this._state.StrokeColor.color.indexOf(this.BorderColor.Color.color)<0)||"object"!=_&&(this._state.StrokeColor.indexOf(this.BorderColor.Color)<0||"object"==typeof this.btnBorderColor.color)){if(this.btnBorderColor.setColor(this.BorderColor.Color),"object"==typeof this.BorderColor.Color){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==this.BorderColor.Color.effectValue){this.colorsBorder.select(this.BorderColor.Color,!0),w=!0;break}w||this.colorsBorder.clearSelection()}else this.colorsBorder.select(this.BorderColor.Color,!0);this._state.StrokeColor=this.BorderColor.Color}if(this._state.StrokeType!==k||k==Asc.c_oAscStrokeType.STROKE_COLOR){if(k==Asc.c_oAscStrokeType.STROKE_COLOR){var I=A.get_width(),P=Math.abs(this._state.StrokeWidth-I)<1e-5&&!new RegExp(this.txtPt+"\\s*$").test(this.cmbBorderSize.getRawValue());if(Math.abs(this._state.StrokeWidth-I)>1e-5||P||(null===this._state.StrokeWidth||null===I)&&this._state.StrokeWidth!==I){this._state.StrokeWidth=I,null!==I&&(I=this._mm2pt(I));var M=null===I?I:i.find(this.cmbBorderSize.store.models,function(t){if(It.attributes.value-1e-5)return!0});M?this.cmbBorderSize.selectRecord(M):this.cmbBorderSize.setValue(null!==I?parseFloat(I.toFixed(2))+" "+this.txtPt:""),this.BorderSize=I}}else k==Asc.c_oAscStrokeType.STROKE_NONE?(this._state.StrokeWidth=0,this.BorderSize=this.cmbBorderSize.store.at(0).get("value"),this.cmbBorderSize.setValue(this.BorderSize)):(this._state.StrokeWidth=null,this.BorderSize=-1,this.cmbBorderSize.setValue(null));this._state.StrokeType=k}if(this._state.StrokeBorderType!==S&&(this.BorderType=this._state.StrokeBorderType=S,this.cmbBorderType.setValue(S)),_=typeof this.FGColor.Color,y=typeof this._state.FGColor,_!==y||"object"==_&&(this.FGColor.Color.effectValue!==this._state.FGColor.effectValue||this._state.FGColor.color.indexOf(this.FGColor.Color.color)<0)||"object"!=_&&this._state.FGColor.indexOf(this.FGColor.Color)<0){if(this.btnFGColor.setColor(this.FGColor.Color),"object"==typeof this.FGColor.Color){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==this.FGColor.Color.effectValue){this.colorsFG.select(this.FGColor.Color,!0),w=!0;break}w||this.colorsFG.clearSelection()}else this.colorsFG.select(this.FGColor.Color,!0);this._state.FGColor=this.FGColor.Color}if(_=typeof this.BGColor.Color,y=typeof this._state.BGColor,_!==y||"object"==_&&(this.BGColor.Color.effectValue!==this._state.BGColor.effectValue||this._state.BGColor.color.indexOf(this.BGColor.Color.color)<0)||"object"!=_&&this._state.BGColor.indexOf(this.BGColor.Color)<0){if(this.btnBGColor.setColor(this.BGColor.Color),"object"==typeof this.BGColor.Color){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==this.BGColor.Color.effectValue){this.colorsBG.select(this.BGColor.Color,!0),w=!0;break}w||this.colorsBG.clearSelection()}else this.colorsBG.select(this.BGColor.Color,!0);this._state.BGColor=this.BGColor.Color}if(h=this.GradColor.colors[this.GradColor.currentIdx],_=typeof h,y=typeof this._state.GradColor,_!==y||"object"==_&&(h.effectValue!==this._state.GradColor.effectValue||this._state.GradColor.color.indexOf(h.color)<0)||"object"!=_&&this._state.GradColor.indexOf(h)<0){if(this.btnGradColor.setColor(h),"object"==typeof h){for(var w=!1,x=0;x<10;x++)if(Common.Utils.ThemeColor.ThemeValues[x]==h.effectValue){this.colorsGrad.select(h,!0),w=!0;break}w||this.colorsGrad.clearSelection()}else this.colorsGrad.select(h,!0);this._state.GradColor=h}this.chShadow.setValue(!!n.asc_getShadow(),!0),this._noApply=!1}},createDelayedControls:function(){var t=this;this._arrFillSrc=[{displayValue:this.textColor,value:Asc.c_oAscFill.FILL_TYPE_SOLID},{displayValue:this.textGradientFill,value:Asc.c_oAscFill.FILL_TYPE_GRAD},{displayValue:this.textImageTexture,value:Asc.c_oAscFill.FILL_TYPE_BLIP},{displayValue:this.textPatternFill,value:Asc.c_oAscFill.FILL_TYPE_PATT},{displayValue:this.textNoFill,value:Asc.c_oAscFill.FILL_TYPE_NOFILL}],this.cmbFillSrc=new Common.UI.ComboBox({el:e("#shape-combo-fill-src"),cls:"input-group-nr",style:"width: 100%;",menuStyle:"min-width: 100%;",editable:!1,data:this._arrFillSrc}),this.cmbFillSrc.setValue(this._arrFillSrc[0].value),this.cmbFillSrc.on("selected",i.bind(this.onFillSrcSelect,this)),this.fillControls.push(this.cmbFillSrc),this.cmbPattern=new Common.UI.ComboDataView({itemWidth:28,itemHeight:28,menuMaxHeight:300,enableKeyEvents:!0,cls:"combo-pattern"}),this.cmbPattern.menuPicker.itemTemplate=this.cmbPattern.fieldPicker.itemTemplate=i.template(['
    ','',"
    "].join("")),this.cmbPattern.render(e("#shape-combo-pattern")),this.cmbPattern.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbPattern.on("click",i.bind(this.onPatternSelect,this)),this.cmbPattern.openButton.menu.on("show:after",function(){t.cmbPattern.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.fillControls.push(this.cmbPattern),this.btnSelectImage=new Common.UI.Button({parentEl:e("#shape-button-replace"),cls:"btn-text-menu-default",caption:this.textSelectImage,style:"width:100%;",menu:new Common.UI.Menu({style:"min-width: 194px;",maxHeight:200,items:[{caption:this.textFromFile,value:0},{cls:"cp-from-url",caption:this.textFromUrl,value:1},{caption:this.textFromStorage,value:2}]})}),this.fillControls.push(this.btnSelectImage),this.btnSelectImage.menu.on("item:click",i.bind(this.onImageSelect,this)),this.btnSelectImage.menu.items[2].setVisible(this.mode.canRequestInsertImage||this.mode.fileChoiceUrl&&this.mode.fileChoiceUrl.indexOf("{documentType}")>-1),this._arrFillType=[{displayValue:this.textStretch,value:Asc.c_oAscFillBlipType.STRETCH},{displayValue:this.textTile,value:Asc.c_oAscFillBlipType.TILE}],this.cmbFillType=new Common.UI.ComboBox({el:e("#shape-combo-fill-type"),cls:"input-group-nr",menuStyle:"min-width: 90px;",editable:!1,data:this._arrFillType}),this.cmbFillType.setValue(this._arrFillType[0].value),this.cmbFillType.on("selected",i.bind(this.onFillTypeSelect,this)),this.fillControls.push(this.cmbFillType),this.numTransparency=new Common.UI.MetricSpinner({el:e("#shape-spin-transparency"),step:1,width:62,value:"100 %",defaultUnit:"%",maxValue:100,minValue:0}),this.numTransparency.on("change",i.bind(this.onNumTransparencyChange,this)),this.numTransparency.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.fillControls.push(this.numTransparency),this.sldrTransparency=new Common.UI.SingleSlider({el:e("#shape-slider-transparency"),width:75,minValue:0,maxValue:100,value:100}),this.sldrTransparency.on("change",i.bind(this.onTransparencyChange,this)),this.sldrTransparency.on("changecomplete",i.bind(this.onTransparencyChangeComplete,this)),this.fillControls.push(this.sldrTransparency),this.lblTransparencyStart=e(this.el).find("#shape-lbl-transparency-start"),this.lblTransparencyEnd=e(this.el).find("#shape-lbl-transparency-end"),this._arrGradType=[{displayValue:this.textLinear,value:Asc.c_oAscFillGradType.GRAD_LINEAR},{displayValue:this.textRadial,value:Asc.c_oAscFillGradType.GRAD_PATH}],this.cmbGradType=new Common.UI.ComboBox({el:e("#shape-combo-grad-type"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrGradType}),this.cmbGradType.setValue(this._arrGradType[0].value),this.cmbGradType.on("selected",i.bind(this.onGradTypeSelect,this)),this.fillControls.push(this.cmbGradType),this._viewDataLinear=[{offsetx:0,offsety:0,type:45,subtype:-1,iconcls:"gradient-left-top"},{offsetx:50,offsety:0,type:90,subtype:4,iconcls:"gradient-top"},{offsetx:100,offsety:0,type:135,subtype:5,iconcls:"gradient-right-top"},{offsetx:0,offsety:50,type:0,subtype:6,iconcls:"gradient-left",cls:"item-gradient-separator",selected:!0},{offsetx:100,offsety:50,type:180,subtype:1,iconcls:"gradient-right"},{offsetx:0,offsety:100,type:315,subtype:2,iconcls:"gradient-left-bottom"},{offsetx:50,offsety:100,type:270,subtype:3,iconcls:"gradient-bottom"},{offsetx:100,offsety:100,type:225,subtype:7,iconcls:"gradient-right-bottom"}],this._viewDataRadial=[{offsetx:100,offsety:150,type:2,subtype:5,iconcls:"gradient-radial-center"}],this.btnDirection=new Common.UI.Button({cls:"btn-large-dataview",iconCls:"item-gradient gradient-left",menu:new Common.UI.Menu({style:"min-width: 60px;",menuAlign:"tr-br",items:[{template:i.template('
    ')}]})}),this.btnDirection.on("render:after",function(n){t.mnuDirectionPicker=new Common.UI.DataView({el:e("#id-shape-menu-direction"),parentMenu:n.menu,restoreHeight:174,allowScrollbar:!1,store:new Common.UI.DataViewStore(t._viewDataLinear),itemTemplate:i.template('
    ')})}),this.btnDirection.render(e("#shape-button-direction")),this.mnuDirectionPicker.on("item:click",i.bind(this.onSelectGradient,this,this.btnDirection)),this.fillControls.push(this.btnDirection),this.sldrGradient=new Common.UI.MultiSliderGradient({el:e("#shape-slider-gradient"),width:192,minValue:0,maxValue:100,values:[0,100]}),this.sldrGradient.on("change",i.bind(this.onGradientChange,this)),this.sldrGradient.on("changecomplete",i.bind(this.onGradientChangeComplete,this)),this.sldrGradient.on("thumbclick",function(e,i){t.GradColor.currentIdx=i;var n=t.GradColor.colors[t.GradColor.currentIdx];t.btnGradColor.setColor(n),t.colorsGrad.select(n,!1);var o=t.GradColor.values[t.GradColor.currentIdx];t.spnGradPosition.setValue(o,!0)}),this.sldrGradient.on("thumbdblclick",function(e){t.btnGradColor.cmpEl.find("button").dropdown("toggle")}),this.sldrGradient.on("sortthumbs",function(e,n){var o,s=[];i.each(n,function(e,i){ +s.push(t.GradColor.colors[e]),t.GradColor.currentIdx==e&&(o=i)}),t.OriginalFillType=null,t.GradColor.colors=s,t.GradColor.currentIdx=o}),this.sldrGradient.on("addthumb",function(e,i,n){t.GradColor.colors[i]=t.GradColor.colors[t.GradColor.currentIdx],t.GradColor.currentIdx=i;var o=t.sldrGradient.addNewThumb(i,n);t.GradColor.colors[t.GradColor.currentIdx]=o}),this.sldrGradient.on("removethumb",function(e,n){if(t.sldrGradient.removeThumb(n),t.GradColor.values.splice(n,1),t.sldrGradient.changeGradientStyle(),i.isUndefined(t.GradColor.currentIdx)||t.GradColor.currentIdx>=t.GradColor.colors.length){var o=n>0?n-1:n;o=0===o&&t.GradColor.values.length>2?t.GradColor.values.length-2:o,t.GradColor.currentIdx=o}t.sldrGradient.setActiveThumb(t.GradColor.currentIdx)}),this.fillControls.push(this.sldrGradient),this.spnGradPosition=new Common.UI.MetricSpinner({el:e("#shape-gradient-position"),step:1,width:60,defaultUnit:"%",value:"50 %",allowDecimal:!1,maxValue:100,minValue:0,disabled:this._locked}),this.fillControls.push(this.spnGradPosition),this.spnGradPosition.on("change",i.bind(this.onPositionChange,this)),this.spnGradPosition.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.btnAddGradientStep=new Common.UI.Button({parentEl:e("#shape-gradient-add-step"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-add-breakpoint",disabled:this._locked,hint:this.tipAddGradientPoint}),this.btnAddGradientStep.on("click",i.bind(this.onAddGradientStep,this)),this.fillControls.push(this.btnAddGradientStep),this.btnRemoveGradientStep=new Common.UI.Button({parentEl:e("#shape-gradient-remove-step"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-remove-breakpoint",disabled:this._locked,hint:this.tipRemoveGradientPoint}),this.btnRemoveGradientStep.on("click",i.bind(this.onRemoveGradientStep,this)),this.fillControls.push(this.btnRemoveGradientStep),this.numGradientAngle=new Common.UI.MetricSpinner({el:e("#shape-spin-gradient-angle"),step:10,width:60,defaultUnit:"°",value:"0 °",allowDecimal:!0,maxValue:359.9,minValue:0,disabled:this._locked}),this.fillControls.push(this.numGradientAngle),this.numGradientAngle.on("change",i.bind(this.onGradientAngleChange,this)),this.numGradientAngle.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.cmbBorderSize=new Common.UI.ComboBorderSizeEditable({el:e("#shape-combo-border-size"),style:"width: 93px;",txtNoBorders:this.txtNoBorders}).on("selected",i.bind(this.onBorderSizeSelect,this)).on("changed:before",i.bind(this.onBorderSizeChanged,this,!0)).on("changed:after",i.bind(this.onBorderSizeChanged,this,!1)).on("combo:blur",i.bind(this.onComboBlur,this,!1)),this.BorderSize=this.cmbBorderSize.store.at(2).get("value"),this.cmbBorderSize.setValue(this.BorderSize),this.lockedControls.push(this.cmbBorderSize),this.cmbBorderType=new Common.UI.ComboBorderType({el:e("#shape-combo-border-type"),style:"width: 93px;",menuStyle:"min-width: 93px;"}).on("selected",i.bind(this.onBorderTypeSelect,this)).on("combo:blur",i.bind(this.onComboBlur,this,!1)),this.BorderType=Asc.c_oDashType.solid,this.cmbBorderType.setValue(this.BorderType),this.lockedControls.push(this.cmbBorderType),this.btnRotate270=new Common.UI.Button({parentEl:e("#shape-button-270",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-rotate-270",value:0,hint:this.textHint270}),this.btnRotate270.on("click",i.bind(this.onBtnRotateClick,this)),this.lockedControls.push(this.btnRotate270),this.btnRotate90=new Common.UI.Button({parentEl:e("#shape-button-90",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-rotate-90",value:1,hint:this.textHint90}),this.btnRotate90.on("click",i.bind(this.onBtnRotateClick,this)),this.lockedControls.push(this.btnRotate90),this.btnFlipV=new Common.UI.Button({parentEl:e("#shape-button-flipv",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-flip-vert",value:0,hint:this.textHintFlipV}),this.btnFlipV.on("click",i.bind(this.onBtnFlipClick,this)),this.lockedControls.push(this.btnFlipV),this.btnFlipH=new Common.UI.Button({parentEl:e("#shape-button-fliph",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-flip-hor",value:1,hint:this.textHintFlipH}),this.btnFlipH.on("click",i.bind(this.onBtnFlipClick,this)),this.lockedControls.push(this.btnFlipH);var n=[{offsetx:0,data:Asc.c_oAscWrapStyle2.Inline,tip:this.txtInline,selected:!0},{offsetx:50,data:Asc.c_oAscWrapStyle2.Square,tip:this.txtSquare},{offsetx:100,data:Asc.c_oAscWrapStyle2.Tight,tip:this.txtTight},{offsetx:150,data:Asc.c_oAscWrapStyle2.Through,tip:this.txtThrough},{offsetx:200,data:Asc.c_oAscWrapStyle2.TopAndBottom,tip:this.txtTopAndBottom},{offsetx:250,data:Asc.c_oAscWrapStyle2.InFront,tip:this.txtInFront},{offsetx:300,data:Asc.c_oAscWrapStyle2.Behind,tip:this.txtBehind}];this.cmbWrapType=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,store:new Common.UI.DataViewStore(n),cls:"combo-chart-style"}),this.cmbWrapType.menuPicker.itemTemplate=this.cmbWrapType.fieldPicker.itemTemplate=i.template(['
    ','',"
    "].join("")),this.cmbWrapType.render(e("#shape-combo-wrap")),this.cmbWrapType.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbWrapType.on("click",i.bind(this.onSelectWrap,this)),this.cmbWrapType.openButton.menu.on("show:after",function(){t.cmbWrapType.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbWrapType),this.btnChangeShape=new Common.UI.Button({parentEl:e("#shape-btn-change"),cls:"btn-icon-default",iconCls:"btn-change-shape",menu:new Common.UI.Menu({menuAlign:"tr-br",cls:"menu-shapes",items:[]})}),this.lockedControls.push(this.btnChangeShape),this.chShadow=new Common.UI.CheckBox({el:e("#shape-checkbox-shadow"),labelText:this.strShadow}),this.chShadow.on("change",i.bind(this.onCheckShadow,this)),this.lockedControls.push(this.chShadow),this.linkAdvanced=e("#shape-advanced-link"),e(this.el).on("click","#shape-advanced-link",i.bind(this.openAdvancedSettings,this))},createDelayedElements:function(){this._initSettings=!1,this.createDelayedControls();var t=[0,1,3,2,4,53,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,23,24,25,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,49,50,51,52];this.patternViewData=[];for(var e=0;e<13;e++)for(var i=0;i<4;i++){var n=4*e+i;this.patternViewData[n]={offsetx:28*i,offsety:28*e,type:t[n]}}this.patternViewData.splice(this.patternViewData.length-2,2);for(var e=0;e0&&(this.cmbPattern.fillComboView(this.cmbPattern.menuPicker.store.at(0),!0),this.PatternFillType=this.patternViewData[0].type),this.onInitStandartTextures(),this.onApiAutoShapes(),this.UpdateThemeColors()},onInitStandartTextures:function(t){var n=this;if(t&&t.length>0&&(n._texturearray=[],i.each(t,function(t){n._texturearray.push({imageUrl:t.get_image(),name:n.textureNames[t.get_id()],type:t.get_id(),selected:!1})})),n._texturearray&&!(n._texturearray.length<1)&&!this._initSettings&&!this.btnTexture){this.btnTexture=new Common.UI.ComboBox({el:e("#shape-combo-fill-texture"),template:i.template(['"].join(""))}),this.textureMenu=new Common.UI.Menu({items:[{template:i.template('
    ')}]}),this.textureMenu.render(e("#shape-combo-fill-texture")),this.fillControls.push(this.btnTexture);var o=function(t){new Common.UI.DataView({el:e("#id-shape-menu-texture"),restoreHeight:174,parentMenu:t,showLast:!1,store:new Common.UI.DataViewStore(n._texturearray||[]),itemTemplate:i.template('
    ')}).on("item:click",i.bind(n.onSelectTexture,n)),t.off("show:before",o)};this.textureMenu.on("show:before",o)}},onSelectTexture:function(t,i,n){if(this._fromTextureCmb=!0,this.cmbFillType.setValue(this._arrFillType[1].value),this._fromTextureCmb=!1,this.api){var o=new Asc.asc_CShapeProperty,s=new Asc.asc_CShapeFill;s.put_type(Asc.c_oAscFill.FILL_TYPE_BLIP),s.put_fill(new Asc.asc_CFillBlip),s.get_fill().put_type(Asc.c_oAscFillBlipType.TILE),s.get_fill().put_texture_id(n.get("type")),o.put_fill(s),this.imgprops.put_ShapeProperties(o),this.api.ImgApply(this.imgprops)}e(this.btnTexture.el).find(".form-control").prop("innerHTML",n.get("name")),this.fireEvent("editcomplete",this)},onBtnRotateClick:function(t){var e=new Asc.asc_CImgProperty;e.asc_putRotAdd(3.14159265358979*(1==t.options.value?90:270)/180),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onBtnFlipClick:function(t){var e=new Asc.asc_CImgProperty;1==t.options.value?e.asc_putFlipHInvert(!0):e.asc_putFlipVInvert(!0),this.api.ImgApply(e),this.fireEvent("editcomplete",this)},onCheckShadow:function(t,e,i,n){if(this.api){var o=new Asc.asc_CShapeProperty;o.asc_putShadow("checked"==t.getValue()?new Asc.asc_CShadowProperty:null),this.imgprops.put_ShapeProperties(o),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onApiAutoShapes:function(){var t=this,e=function(i){t.fillAutoShapes(),i.off("show:before",e)};t.btnChangeShape.menu.on("show:before",e)},fillAutoShapes:function(){var t=this,n=this.application.getCollection("ShapeGroups"),o=n.length,s=function(a){for(var r=-1;r0;r++){var l=n.at(r>-1?r:0).get("groupStore");r<0&&(l=l.clone(),l.shift());new Common.UI.DataViewSimple({el:e("#id-shape-menu-shapegroup"+(r+1),a.items[r+1].$el),store:l,parentMenu:a.items[r+1].menu,itemTemplate:i.template('
    ')}).on("item:click",function(e,i,n,o){t.api&&(t.api.ChangeShapeType(n.get("data").shapeType),t.fireEvent("editcomplete",t)),"click"!==o.type&&t.btnChangeShape.menu.hide()})}a.off("show:after",s)};t.btnChangeShape.menu.on("show:after",s);for(var a=-1;a0;a++){var r=n.at(a>-1?a:a+1),l=new Common.UI.MenuItem({caption:r.get("groupName"),menu:new Common.UI.Menu({menuAlign:"tr-tl",items:[{template:i.template('')}]})});t.btnChangeShape.menu.addItem(l)}t.btnChangeShape.menu.items[0].setVisible(t._state.isFromImage),t.btnChangeShape.menu.items[1].setVisible(!t._state.isFromImage)},UpdateThemeColors:function(){this._initSettings||(this.btnBackColor||(this.btnBackColor=new Common.UI.ColorButton({parentEl:e("#shape-back-color-btn"),transparent:!0,color:"transparent"}),this.fillControls.push(this.btnBackColor),this.colorsBack=this.btnBackColor.getPicker(),this.btnBackColor.on("color:select",i.bind(this.onColorsBackSelect,this)),this.btnFGColor=new Common.UI.ColorButton({parentEl:e("#shape-foreground-color-btn"),color:"000000"}),this.fillControls.push(this.btnFGColor),this.colorsFG=this.btnFGColor.getPicker(),this.btnFGColor.on("color:select",i.bind(this.onColorsFGSelect,this)),this.btnBGColor=new Common.UI.ColorButton({parentEl:e("#shape-background-color-btn"),color:"ffffff"}),this.fillControls.push(this.btnBGColor),this.colorsBG=this.btnBGColor.getPicker(),this.btnBGColor.on("color:select",i.bind(this.onColorsBGSelect,this)),this.btnGradColor=new Common.UI.ColorButton({parentEl:e("#shape-gradient-color-btn"),color:"000000"}),this.fillControls.push(this.btnGradColor),this.colorsGrad=this.btnGradColor.getPicker(),this.btnGradColor.on("color:select",i.bind(this.onColorsGradientSelect,this)),this.btnBorderColor=new Common.UI.ColorButton({parentEl:e("#shape-border-color-btn"),color:"000000"}),this.lockedControls.push(this.btnBorderColor),this.colorsBorder=this.btnBorderColor.getPicker(),this.btnBorderColor.on("color:select",i.bind(this.onColorsBorderSelect,this))),this.colorsBorder.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsBack.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsFG.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsBG.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsGrad.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()))},_pt2mm:function(t){return 25.4*t/72},_mm2pt:function(t){return 72*t/25.4},disableFillPanels:function(t){this._state.DisabledFillPanels!==t&&(this._state.DisabledFillPanels=t,i.each(this.fillControls,function(e){e.setDisabled(t)}),this.lblTransparencyStart.toggleClass("disabled",t),this.lblTransparencyEnd.toggleClass("disabled",t),this.numGradientAngle.setDisabled(t||this.GradFillType!==Asc.c_oAscFillGradType.GRAD_LINEAR))},ShowHideElem:function(t){this.FillColorContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_SOLID),this.FillImageContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_BLIP),this.FillPatternContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_PATT),this.FillGradientContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_GRAD),this.TransparencyContainer.toggleClass("settings-hidden",t===Asc.c_oAscFill.FILL_TYPE_NOFILL||null===t)},setLocked:function(t){this._locked=t},disableControls:function(t,e){this._initSettings||(this.disableFillPanels(t||e),this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.linkAdvanced.toggleClass("disabled",t)))},hideShapeOnlySettings:function(t){this._state.HideShapeOnlySettings!==t&&(this._state.HideShapeOnlySettings=t,this.ShapeOnlySettings.toggleClass("hidden",1==t))},hideChangeTypeSettings:function(t){this._state.HideChangeTypeSettings!==t&&(this._state.HideChangeTypeSettings=t,this.CanChangeType.toggleClass("hidden",1==t))},onPositionChange:function(t){var e=t.getNumberValue(),i=this.GradColor.currentIdx-1<0?0:this.GradColor.values[this.GradColor.currentIdx-1],n=this.GradColor.currentIdx+1n;if(this.api){this.GradColor.values[this.GradColor.currentIdx]=e;var s=new Asc.asc_CShapeProperty,a=new Asc.asc_CShapeFill;a.asc_putType(Asc.c_oAscFill.FILL_TYPE_GRAD),a.asc_putFill(new Asc.asc_CFillGrad),a.asc_getFill().asc_putGradType(this.GradFillType);var r=[];this.GradColor.values.forEach(function(t){r.push(1e3*t)}),a.asc_getFill().asc_putPositions(r),s.asc_putFill(a),this.imgprops.put_ShapeProperties(s),this.api.ImgApply(this.imgprops),o&&(this.sldrGradient.sortThumbs(),this.sldrGradient.trigger("change",this.sldrGradient),this.sldrGradient.trigger("changecomplete",this.sldrGradient))}},onAddGradientStep:function(){if(!(this.GradColor.colors.length>9)){var t=this.GradColor.currentIdx,e=(this.GradColor.values[t]+this.GradColor.values[t=this.GradColor.colors.length){var e=t>0?t-1:t;e=0===e&&this.GradColor.values.length>2?this.GradColor.values.length-2:e,this.GradColor.currentIdx=e}this.sldrGradient.setActiveThumb(this.GradColor.currentIdx),this.sldrGradient.trigger("change",this.sldrGradient),this.sldrGradient.trigger("changecomplete",this.sldrGradient)}},onGradientAngleChange:function(t,e,i,n){if(this.api&&!this._noApply){var o=new Asc.asc_CShapeProperty,s=new Asc.asc_CShapeFill;s.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),s.put_fill(new Asc.asc_CFillGrad),s.get_fill().put_grad_type(this.GradFillType),s.get_fill().put_linear_angle(6e4*t.getNumberValue()),s.get_fill().put_linear_scale(!0),o.put_fill(s),this.imgprops.put_ShapeProperties(o),this.api.ImgApply(this.imgprops)}},txtNoBorders:"No Line",strStroke:"Stroke",strColor:"Color",strSize:"Size",strChange:"Change Autoshape",strFill:"Fill",textColor:"Color Fill",textImageTexture:"Picture or Texture",textTexture:"From Texture",textFromUrl:"From URL",textFromFile:"From File",textStretch:"Stretch",textTile:"Tile",txtCanvas:"Canvas",txtCarton:"Carton",txtDarkFabric:"Dark Fabric",txtGrain:"Grain",txtGranite:"Granite",txtGreyPaper:"Grey Paper",txtKnit:"Knit",txtLeather:"Leather",txtBrownPaper:"Brown Paper",txtPapyrus:"Papyrus",txtWood:"Wood",textAdvanced:"Show advanced settings",strTransparency:"Opacity",textNoFill:"No Fill",textSelectTexture:"Select",textGradientFill:"Gradient Fill",textPatternFill:"Pattern",strBackground:"Background color",strForeground:"Foreground color",strPattern:"Pattern",textEmptyPattern:"No Pattern",textLinear:"Linear",textRadial:"Radial",textDirection:"Direction",textStyle:"Style",textGradient:"Gradient Points",textWrap:"Wraping Style",txtInline:"Inline",txtSquare:"Square",txtTight:"Tight",txtThrough:"Through",txtTopAndBottom:"Top and bottom",txtBehind:"Behind",txtInFront:"In front",textBorderSizeErr:"The entered value is incorrect.
    Please enter a value between 0 pt and 1584 pt.",strType:"Type",textRotation:"Rotation",textRotate90:"Rotate 90°",textFlip:"Flip",textHint270:"Rotate 90° Counterclockwise",textHint90:"Rotate 90° Clockwise",textHintFlipV:"Flip Vertically",textHintFlipH:"Flip Horizontally",strShadow:"Show shadow",textFromStorage:"From Storage",textSelectImage:"Select Picture",textPosition:"Position",tipAddGradientPoint:"Add gradient point",tipRemoveGradientPoint:"Remove gradient point",textAngle:"Angle"},DE.Views.ShapeSettings||{}))}),define("text!documenteditor/main/app/template/MailMerge.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n\r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n \r\n \r\n \r\n
    '}),void 0===Common)var Common={};if(define("common/main/lib/component/Switcher",["common/main/lib/component/BaseView","underscore"],function(t,e){"use strict";Common.UI.Switcher=Common.UI.BaseView.extend({options:{width:25,thumbWidth:13,value:!1},disabled:!1,template:e.template(['
    ','
    ','
    ','
    ',"
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;e.width=e.options.width,e.thumbWidth=e.options.thumbWidth,e.delta=(e.width-e.thumbWidth-2)/2,e.options.el&&e.render(),this.setValue(e.options.value)},render:function(t){var e=this;e.rendered?this.cmpEl=this.$el:(this.cmpEl=$(this.template({})),t?(this.setElement(t,!1),t.html(this.cmpEl)):this.$el.html(this.cmpEl)),this.thumb=this.cmpEl.find(".thumb"),this.cmpEl.width(e.width),this.thumb.width(e.thumbWidth),this.cmpEl.find(".sw-left").width(e.width/2),this.cmpEl.find(".sw-right").width(e.width/2);var i=function(t){if(!e.disabled){t.preventDefault(),t.stopPropagation(),$(document).off("mouseup.switcher",i),$(document).off("mousemove.switcher",n);var o=Math.round(t.pageX*Common.Utils.zoom()-e._dragstart);e.value=e.value?o>-e.delta:o>e.delta,e.cmpEl.toggleClass("on",e.value),e.thumb.css({left:"",right:""}),e.trigger("change",e,e.value),e._dragstart=void 0}},n=function(t){if(!e.disabled&&void 0!==e._dragstart){t.preventDefault(),t.stopPropagation();var i=Math.round(t.pageX*Common.Utils.zoom()-e._dragstart);e.value?e.thumb.css({right:i<1?Math.min(e.width-e.thumbWidth-2,-i):0,left:"auto"}):e.thumb.css({left:i>-1?Math.min(e.width-e.thumbWidth-2,i):0,right:"auto"}),e._isMouseMove||(e._isMouseMove=Math.abs(i)>0)}},o=function(t){e.disabled||(e._dragstart=t.pageX*Common.Utils.zoom(),e._isMouseMove=!1,$(document).on("mouseup.switcher",i),$(document).on("mousemove.switcher",n))},s=function(t){if(e.disabled||e._isMouseMove)return void(e._isMouseMove=!1);e.value=!e.value,e.cmpEl.toggleClass("on",e.value),e.trigger("change",e,e.value)};if(!e.rendered){var a=e.cmpEl;a.on("mousedown",".thumb",o),a.on("click",s)}return e.rendered=!0,this},setThumbPosition:function(t){var e=this.value?t<-this.delta:t>this.delta;this.thumb.css(e?{right:0,left:"auto"}:{left:0,right:"auto"})},setValue:function(t){this.value=!0===t,this.cmpEl.toggleClass("on",this.value)},getValue:function(){return this.value},setDisabled:function(t){t!==this.disabled&&this.cmpEl.toggleClass("disabled",t),this.disabled=t},isDisabled:function(){return this.disabled}})}),define("common/main/lib/view/SaveAsDlg",["common/main/lib/component/Window","common/main/lib/component/LoadMask"],function(){"use strict";Common.Views.SaveAsDlg=Common.UI.Window.extend(_.extend({initialize:function(t){var e={};_.extend(e,{title:this.textTitle,width:420,height:681,header:!0},t),this.template=['
    '].join(""),e.tpl=_.template(this.template)(e),this.saveFolderUrl=t.saveFolderUrl||"",this.saveFileUrl=t.saveFileUrl||"",this.defFileName=t.defFileName||"",this.saveFolderUrl=this.saveFolderUrl.replace("{title}",encodeURIComponent(this.defFileName)).replace("{fileuri}",encodeURIComponent(this.saveFileUrl)),Common.UI.Window.prototype.initialize.call(this,e)},render:function(){Common.UI.Window.prototype.render.call(this),this.$window.find("> .body").css({height:"auto",overflow:"hidden"});var t=document.createElement("iframe");t.width="100%",t.height=645,t.align="top",t.frameBorder=0,t.scrolling="no",t.onload=_.bind(this._onLoad,this),$("#id-saveas-folder-placeholder").append(t),this.loadMask=new Common.UI.LoadMask({owner:$("#id-saveas-folder-placeholder")}),this.loadMask.setTitle(this.textLoading),this.loadMask.show(),t.src=this.saveFolderUrl;var e=this;this._eventfunc=function(t){e._onWindowMessage(t)},this._bindWindowEvents.call(this),this.on("close",function(t){e._unbindWindowEvents()})},_bindWindowEvents:function(){window.addEventListener?window.addEventListener("message",this._eventfunc,!1):window.attachEvent&&window.attachEvent("onmessage",this._eventfunc)},_unbindWindowEvents:function(){window.removeEventListener?window.removeEventListener("message",this._eventfunc):window.detachEvent&&window.detachEvent("onmessage",this._eventfunc)},_onWindowMessage:function(t){if(t&&window.JSON)try{this._onMessage.call(this,window.JSON.parse(t.data))}catch(t){}},_onMessage:function(t){t&&"onlyoffice"==t.Referer&&(_.isEmpty(t.error)?_.isEmpty(t.message)||Common.NotificationCenter.trigger("showmessage",{msg:t.message}):this.trigger("saveaserror",this,t.error),Common.NotificationCenter.trigger("window:close",this))},_onLoad:function(){this.loadMask&&this.loadMask.hide()},textTitle:"Folder for save",textLoading:"Loading"},Common.Views.SaveAsDlg||{}))}),define("text!documenteditor/main/app/template/MailMergeEmailDlg.template",[],function(){return'
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n
    '}),define("documenteditor/main/app/view/MailMergeEmailDlg",["text!documenteditor/main/app/template/MailMergeEmailDlg.template","common/main/lib/view/AdvancedSettingsWindow","common/main/lib/component/ComboBox","common/main/lib/component/InputField"],function(t){"use strict";DE.Views.MailMergeEmailDlg=Common.Views.AdvancedSettingsWindow.extend(_.extend({options:{alias:"MailMergeEmail",contentWidth:500,height:435},initialize:function(e){_.extend(this.options,{title:this.textTitle,template:['
    ','
    '+_.template(t)({scope:this})+"
    ","
    ",'
    '].join("")},e),Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this,this.options)},render:function(){Common.Views.AdvancedSettingsWindow.prototype.render.call(this);var t=this;this._arrFrom=[],this.cmbFrom=new Common.UI.ComboBox({el:$("#merge-email-dlg-from"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrFrom}),this._arrTo=[],this.cmbTo=new Common.UI.ComboBox({el:$("#merge-email-dlg-to"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrTo}),this.inputSubject=new Common.UI.InputField({el:$("#merge-email-dlg-subject"),allowBlank:!0,validateOnBlur:!1,placeHolder:this.subjectPlaceholder,style:"width: 100%;"}),this._arrFormat=[{displayValue:this.textHTML,value:Asc.c_oAscFileType.HTML},{displayValue:this.textAttachDocx,value:Asc.c_oAscFileType.DOCX},{displayValue:this.textAttachPdf,value:Asc.c_oAscFileType.PDF}],this.cmbFormat=new Common.UI.ComboBox({el:$("#merge-email-dlg-format"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrFormat}),this.cmbFormat.setValue(Asc.c_oAscFileType.HTML),this.cmbFormat.on("selected",_.bind(this.onCmbFormatSelect,this)),this.inputFileName=new Common.UI.InputField({el:$("#merge-email-dlg-filename"),allowBlank:!0,validateOnBlur:!1,disabled:!0,placeHolder:this.filePlaceholder,style:"width: 100%;"}), +this.textareaMessage=this.$window.find("textarea"),this.lblFileName=$("#merge-email-dlg-lbl-filename"),this.lblMessage=$("#merge-email-dlg-lbl-message"),this._eventfunc=function(e){t._onWindowMessage(e)},this.mergeProps=this.options.props,this.mergedFileUrl=this.options.mergedFileUrl||"",this.afterRender()},_bindWindowEvents:function(){window.addEventListener?window.addEventListener("message",this._eventfunc,!1):window.attachEvent&&window.attachEvent("onmessage",this._eventfunc)},_unbindWindowEvents:function(){window.removeEventListener?window.removeEventListener("message",this._eventfunc):window.detachEvent&&window.detachEvent("onmessage",this._eventfunc)},_onWindowMessage:function(t){if(t&&window.JSON)try{this._onMessage.call(this,window.JSON.parse(t.data))}catch(t){}},_onMessage:function(t){t&&t.Referer},afterRender:function(){this._setDefaults(this.mergeProps)},getSettings:function(){var t=this.inputFileName.getValue(),e=this.cmbFormat.getValue();if(e!==Asc.c_oAscFileType.HTML){_.isEmpty(t)&&(t="attach");var i=t.lastIndexOf("."),n=i>0?t.substring(i,t.length).toLowerCase():"";e==Asc.c_oAscFileType.PDF&&".pdf"!==n?t+=".pdf":e==Asc.c_oAscFileType.DOCX&&".docx"!==n&&(t+=".docx")}return{from:this.cmbFrom.getValue(),to:this.cmbTo.getValue(),subject:this.inputSubject.getValue(),mailFormat:e,fileName:t,message:this.textareaMessage.val()}},_setDefaults:function(t){if(t){if(t.fieldsList){var e=[];_.each(t.fieldsList,function(t,i){e.push({displayValue:"<"+t+">",value:t})}),this.cmbTo.setData(e),e.length>0&&this.cmbTo.setValue(e[0].value)}if(t.emailAddresses){var e=[];_.each(t.emailAddresses,function(t,i){e.push({displayValue:t,value:t})}),this.cmbFrom.setData(e),e.length>0&&this.cmbFrom.setValue(e[0].value)}}},onPrimary:function(){return!0},onDlgBtnClick:function(t){var e=t.currentTarget.attributes.result.value;"ok"==e&&this.handler&&this.handler.call(this,e,"ok"==e?this.getSettings():void 0),this.close()},onCmbFormatSelect:function(t,e){var i=e.value==Asc.c_oAscFileType.HTML;this.inputFileName.setDisabled(i),this.lblFileName.toggleClass("disabled",i),i?this.textareaMessage.attr("disabled","disabled"):this.textareaMessage.removeAttr("disabled"),this.textareaMessage.toggleClass("disabled",i),this.lblMessage.toggleClass("disabled",i)},textTitle:"Send to E-mail",textFrom:"From",textTo:"To",textSubject:"Subject Line",textFormat:"Mail format",textFileName:"File name",textMessage:"Message",textHTML:"HTML",textAttachDocx:"Attach as DOCX",textAttachPdf:"Attach as PDF",subjectPlaceholder:"Theme",filePlaceholder:"PDF",textWarning:"Warning!",textWarningMsg:"Please note that mailing cannot be stopped once your click the 'Send' button."},DE.Views.MailMergeEmailDlg||{}))}),define("documenteditor/main/app/view/MailMergeSettings",["text!documenteditor/main/app/template/MailMerge.template","jquery","underscore","backbone","common/main/lib/component/Button","common/main/lib/component/Switcher","common/main/lib/view/SaveAsDlg","common/main/lib/view/SelectFileDlg","documenteditor/main/app/view/MailMergeEmailDlg"],function(t,e,i,n){"use strict";DE.enumLockMM={lostConnect:"disconnect",preview:"preview",coAuth:"co-auth",noFields:"no-fields",noRecipients:"no-recipients",radioAllCurr:"radio-all-curr"},DE.Views.MailMergeSettings=n.View.extend(i.extend({el:"#id-mail-merge-settings",template:i.template(t),events:{},options:{alias:"MailMergeSettings"},initialize:function(){DE.enumLockMM;this._initSettings=!0,this._state={recipientsCount:0,fieldsList:[]},this._locked=!1,this.emptyDBControls=[],this._noApply=!1,this._originalProps=null,this.defFileName="",this.emailAddresses=void 0,this.mergeMailData=void 0,this.render()},render:function(){this.$el.html(this.template({scope:this}))},setApi:function(t){return this.api=t,this.api&&(this.api.asc_registerCallback("asc_onPreviewMailMergeResult",i.bind(this.onPreviewMailMergeResult,this)),this.api.asc_registerCallback("asc_onEndPreviewMailMergeResult",i.bind(this.onEndPreviewMailMergeResult,this)),this.api.asc_registerCallback("asc_onStartMailMerge",i.bind(this.onStartMailMerge,this)),this.api.asc_registerCallback("asc_onSaveMailMerge",i.bind(this.onSaveMailMerge,this)),this.api.asc_registerCallback("asc_onEndAction",i.bind(this.onLongActionEnd,this)),Common.Gateway.on("setemailaddresses",i.bind(this.onSetEmailAddresses,this)),Common.Gateway.on("processmailmerge",i.bind(this.onProcessMailMerge,this))),this},createDelayedControls:function(){var t=this,n=DE.enumLockMM;this.btnInsField=new Common.UI.Button({parentEl:e("#mmerge-btn-ins-field",t.$el),cls:"btn-text-menu-default",caption:this.textInsertField,style:"width: 100%;",lock:[n.noFields,n.preview,n.coAuth,n.lostConnect],menu:new Common.UI.Menu({style:"min-width: 190px;max-width: 400px;",maxHeight:200,items:[]})}),this.txtFieldNum=new Common.UI.InputField({el:e("#mmerge-field-num",t.$el),allowBlank:!0,validateOnChange:!1,style:"width: 80px; vertical-align: middle;",maskExp:/[0-9]/,value:1,validation:function(e){return/(^[0-9]+$)/.test(e)?(e=parseInt(e),void 0===e||null===e||e<1?t.txtFieldNum.setValue(1):e>t._state.recipientsCount&&t.txtFieldNum.setValue(t._state.recipientsCount)):t.txtFieldNum.setValue(1),!0},lock:[n.noRecipients,n.lostConnect]}).on("changed:after",function(e,i,n,o){var s=parseInt(t.txtFieldNum.getValue());s!==parseInt(n)&&(t.api.asc_PreviewMailMergeResult(s-1),t.fireEvent("editcomplete",t))}),this.emptyDBControls.push(this.txtFieldNum),this.btnEditData=new Common.UI.Button({el:t.$el.find("#mmerge-button-edit-data"),lock:[n.preview,n.lostConnect]}),this.btnEditData.on("click",i.bind(this.onEditData,this)),this.lblAddRecipients=e("#mmerge-lbl-add-recipients"),this.chHighlight=new Common.UI.Switcher({el:t.$el.find("#mmerge-switcher-highlight"),lock:[n.noFields,n.lostConnect]}),this.chHighlight.on("change",i.bind(this.onCheckHighlightChange,this)),this.chPreview=new Common.UI.Switcher({el:t.$el.find("#mmerge-switcher-preview"),lock:[n.noRecipients,n.lostConnect]}),this.chPreview.on("change",i.bind(this.onCheckPreviewChange,this)),this.emptyDBControls.push(this.chPreview),this.btnFirst=new Common.UI.Button({parentEl:e("#mmerge-button-first",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-firstitem",disabled:!0,value:0,hint:this.txtFirst,lock:[n.noRecipients,n.lostConnect]}),this.btnFirst.on("click",i.bind(this.onBtnPreviewFieldClick,this)),this.emptyDBControls.push(this.btnFirst),this.btnPrev=new Common.UI.Button({parentEl:e("#mmerge-button-prev",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-previtem",disabled:!0,value:1,hint:this.txtPrev,lock:[n.noRecipients,n.lostConnect]}),this.btnPrev.on("click",i.bind(this.onBtnPreviewFieldClick,this)),this.emptyDBControls.push(this.btnPrev),this.btnNext=new Common.UI.Button({parentEl:e("#mmerge-button-next",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-nextitem",value:2,hint:this.txtNext,lock:[n.noRecipients,n.lostConnect]}),this.btnNext.on("click",i.bind(this.onBtnPreviewFieldClick,this)),this.emptyDBControls.push(this.btnNext),this.btnLast=new Common.UI.Button({parentEl:e("#mmerge-button-last",t.$el),cls:"btn-toolbar",iconCls:"toolbar__icon btn-lastitem",value:3,hint:this.txtLast,lock:[n.noRecipients,n.lostConnect]}),this.btnLast.on("click",i.bind(this.onBtnPreviewFieldClick,this)),this.emptyDBControls.push(this.btnLast),this._arrMergeSrc=[{displayValue:this.textPdf,value:Asc.c_oAscFileType.PDF},{displayValue:this.textDocx,value:Asc.c_oAscFileType.DOCX},{displayValue:this.textEmail,value:Asc.c_oAscFileType.HTML}],this.cmbMergeTo=new Common.UI.ComboBox({el:e("#mmerge-combo-merge-to",t.$el),cls:"input-group-nr",style:"width: 100%;",menuStyle:"min-width: 190px;",editable:!1,data:this._arrMergeSrc,lock:[n.noRecipients,n.lostConnect]}),this.cmbMergeTo.setValue(this._arrMergeSrc[0].value),this.cmbMergeTo.on("selected",i.bind(this.onCmbMergeToSelect,this)),this.emptyDBControls.push(this.cmbMergeTo),this.radioAll=new Common.UI.RadioBox({el:e("#mmerge-radio-all",t.$el),labelText:this.textAll,name:"asc-radio-merge",checked:!0,lock:[n.noRecipients,n.lostConnect]}).on("change",i.bind(this.onRadioAllCurrent,this)),this.emptyDBControls.push(this.radioAll),this.radioCurrent=new Common.UI.RadioBox({el:e("#mmerge-radio-current",t.$el),labelText:this.textCurrent,name:"asc-radio-merge",lock:[n.noRecipients,n.lostConnect]}).on("change",i.bind(this.onRadioAllCurrent,this)),this.emptyDBControls.push(this.radioCurrent),this.radioFromTo=new Common.UI.RadioBox({el:e("#mmerge-radio-from-to",t.$el),labelText:this.textFrom,name:"asc-radio-merge",lock:[n.noRecipients,n.lostConnect]}).on("change",i.bind(this.onRadioFromToChange,this)),this.emptyDBControls.push(this.radioFromTo),this.txtFieldFrom=new Common.UI.InputField({el:e("#mmerge-field-from",t.$el),allowBlank:!0,validateOnChange:!1,style:"width: 50px;",maskExp:/[0-9]/,value:0,disabled:!0,lock:[n.radioAllCurr,n.noRecipients,n.lostConnect],validation:function(e){/(^[0-9]+$)/.test(e)?(e=parseInt(e),void 0===e||null===e||e<1?t.txtFieldFrom.setValue(1):e>t._state.recipientsCount&&t.txtFieldFrom.setValue(t._state.recipientsCount)):t.txtFieldFrom.setValue(1),e=parseInt(t.txtFieldFrom.getValue());var i=Math.min(t._state.recipientsCount,e+99);if(parseInt(t.txtFieldTo.getValue())>i&&t.txtFieldTo.setValue(i),t._checkFromToValues){if(e>parseInt(t.txtFieldTo.getValue()))return t.txtFromToError;t._checkFromToValues=!1,t.txtFieldTo.checkValidate()}return!0}}),this.emptyDBControls.push(this.txtFieldFrom),this.txtFieldTo=new Common.UI.InputField({el:e("#mmerge-field-to",t.$el),allowBlank:!0,validateOnChange:!1,style:"width: 50px;",maskExp:/[0-9]/,value:0,disabled:!0,lock:[n.radioAllCurr,n.noRecipients,n.lostConnect],validation:function(e){if(/(^[0-9]+$)/.test(e))if(void 0===(e=parseInt(e))||null===e||e<1)t.txtFieldTo.setValue(1);else{var i=Math.min(t._state.recipientsCount,parseInt(t.txtFieldFrom.getValue())+99);e>i&&t.txtFieldTo.setValue(i)}else t.txtFieldTo.setValue(1);if(t._checkFromToValues){if(parseInt(t.txtFieldFrom.getValue())>parseInt(t.txtFieldTo.getValue()))return t.txtFromToError;t._checkFromToValues=!1,t.txtFieldFrom.checkValidate()}return!0}}),this.txtFieldTo.on("changed:after",function(){t._isToChanged=!0}),this.emptyDBControls.push(this.txtFieldTo),this.onRadioAllCurrent(this.radioAll,!0),this.btnDownload=new Common.UI.Button({el:e("#mmerge-button-download",t.$el),lock:[n.noRecipients,n.lostConnect]}).on("click",i.bind(this.onDownloadClick,this,!0)),this.emptyDBControls.push(this.btnDownload),this.btnPortal=new Common.UI.Button({el:e("#mmerge-button-portal",t.$el),lock:[n.noRecipients,n.lostConnect]}).on("click",i.bind(this.onDownloadClick,this,!1)),this.btnMerge=new Common.UI.Button({el:e("#mmerge-button-merge",t.$el),lock:[n.noRecipients,n.lostConnect]}).on("click",i.bind(this.onMergeClick,this,!1)),this.emptyDBControls.push(this.btnMerge),this.linkReadMore=e("#mmerge-readmore-link",this.$el),this.$el.on("click","#mmerge-readmore-link",i.bind(this.openHelp,this)),this.mode&&(this.mode.canRequestSaveAs||this.mode.mergeFolderUrl||this.btnPortal.setVisible(!1),this.mode.canSendEmailAddresses||(this._arrMergeSrc.pop(),this.cmbMergeTo.setData(this._arrMergeSrc),this.cmbMergeTo.setValue(this._arrMergeSrc[0].value))),this._initSettings=!1},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedControls(),this.disableInsertControls(this._locked),t){var e=this;this._state.recipientsCount=t.recipientsCount,this._state.fieldsList=t.fieldsList?t.fieldsList:[],this.btnInsField.menu.items.length<1&&i.each(this._state.fieldsList,function(t,i){var n=new Common.UI.MenuItem({caption:"«"+t+"»",field:t}).on("click",function(t,i){e.api&&(e.api.asc_AddMailMergeField(t.options.field),e.fireEvent("editcomplete",e))});e.btnInsField.menu.addItem(n)});var n=parseInt(this.txtFieldFrom.getValue());n=isNaN(n)?0:n-1,(n<0||n>this._state.recipientsCount-1)&&(n=0);var o=this._isToChanged?parseInt(this.txtFieldTo.getValue()):this._state.recipientsCount;o=isNaN(o)?0:o-1,(o<0||o>this._state.recipientsCount-1)&&(o=Math.max(this._state.recipientsCount-1,0)),n>o&&(n=0,o=this._state.recipientsCount-1),this.txtFieldFrom.setValue(n+1),this.txtFieldTo.setValue(Math.min(o+1,n+100));var s=parseInt(this.txtFieldNum.getValue());s=isNaN(s)?0:s-1,s<0&&(s=0),s>this._state.recipientsCount-1&&(s=this._state.recipientsCount-1),this.lockControls(DE.enumLockMM.noRecipients,this._state.recipientsCount<1,{array:this.mode.canRequestSaveAs||this.mode.mergeFolderUrl?[this.btnPortal]:[],merge:!0}),this.lockControls(DE.enumLockMM.noFields,this._state.fieldsList.length<1,{array:[this.btnInsField,this.chHighlight]}),this.lblAddRecipients[this._state.fieldsList.length<1?"show":"hide"](),this.disableFieldBtns(s)}},onEditData:function(){var t=DE.getController("Common.Controllers.ExternalMergeEditor").getView("Common.Views.ExternalMergeEditor");if(t){t.show();var e=this.api.asc_getMailMergeData();e&&t.setMergeData(e)}},onCheckHighlightChange:function(t,e,i){this.api&&this.api.asc_SetHighlightMailMergeFields(t.getValue()),this.fireEvent("editcomplete",this)},onCheckPreviewChange:function(t,e,i){var n=t.getValue(),o=parseInt(this.txtFieldNum.getValue());this.api&&(n?this.api.asc_PreviewMailMergeResult(isNaN(o)?0:o-1):this.api.asc_EndPreviewMailMergeResult()),this.fireEvent("editcomplete",this)},onRadioFromToChange:function(t,e,i){e&&this.lockControls(DE.enumLockMM.radioAllCurr,!1,{array:[this.txtFieldFrom,this.txtFieldTo]})},onRadioAllCurrent:function(t,e,i){e&&this.lockControls(DE.enumLockMM.radioAllCurr,!0,{array:[this.txtFieldFrom,this.txtFieldTo]})},checkFromToValues:function(){this._checkFromToValues=!0;var t=this.txtFieldFrom.checkValidate(),e=this.txtFieldTo.checkValidate();return!0!==t||!0!==e?(this.txtFieldTo.cmpEl.find("input").focus(),!1):(this._checkFromToValues=!1,!0)},onDownloadClick:function(t,n,o){if(this.api){var s=0,a=Math.min(Math.max(this._state.recipientsCount-1,0),99);if(this.radioCurrent.getValue())s=a=parseInt(this.txtFieldNum.getValue())-1;else if(this.radioFromTo.getValue()){if(!this.checkFromToValues())return;s=parseInt(this.txtFieldFrom.getValue())-1,a=parseInt(this.txtFieldTo.getValue())-1,a=Math.min(a,s+99),this.txtFieldTo.setValue(a+1)}if(this.api.asc_DownloadAsMailMerge(this.cmbMergeTo.getValue(),s,a,t)){if(!t){var r=DE.getController("Main");r.loadMask||(r.loadMask=new Common.UI.LoadMask({owner:e("#viewport")})),r.loadMask.setTitle(this.downloadMergeTitle),r.loadMask.show()}}else{var l={closable:!1,title:this.notcriticalErrorTitle,msg:this.errorMailMergeSaveFile,iconCls:"warn",buttons:["ok"],callback:i.bind(function(t){this.fireEvent("editcomplete",this)},this)};Common.UI.alert(l)}}},onSaveMailMerge:function(t){var e=DE.getController("Main").loadMask;if(e&&e.hide(),!this._mailMergeDlg){var i=this;if(this.cmbMergeTo.getValue()!=Asc.c_oAscFileType.HTML){var n=i.defFileName+(this.cmbMergeTo.getValue()==Asc.c_oAscFileType.PDF?".pdf":".docx");i.mode.canRequestSaveAs?Common.Gateway.requestSaveAs(t,n):(i._mailMergeDlg=new Common.Views.SaveAsDlg({saveFolderUrl:i.mode.mergeFolderUrl,saveFileUrl:t,defFileName:n}),i._mailMergeDlg.on("saveasfolder",function(t,e){}).on("saveaserror",function(t,e){var n={closable:!1,title:i.notcriticalErrorTitle,msg:e,iconCls:"warn",buttons:["ok"],callback:function(t){i.fireEvent("editcomplete",i)}};Common.UI.alert(n)}).on("close",function(t){i._mailMergeDlg=void 0}),i._mailMergeDlg.show())}}},onMergeClick:function(t,i,n){var o=0,s=Math.min(Math.max(this._state.recipientsCount-1,0),99);if(this.radioFromTo.getValue()){if(!this.checkFromToValues())return;o=parseInt(this.txtFieldFrom.getValue())-1,s=parseInt(this.txtFieldTo.getValue())-1,s=Math.min(s,o+99),this.txtFieldTo.setValue(s+1)}if(void 0==this.emailAddresses){var a=DE.getController("Main");a.loadMask||(a.loadMask=new Common.UI.LoadMask({owner:e("#viewport")})),a.loadMask.setTitle(this.requestMailsTitle),a.loadMask.show(),Common.Gateway.requestEmailAddresses()}else this.showMergeMailDlg()},onSetEmailAddresses:function(t){var e=DE.getController("Main").loadMask;if(e&&e.hide(),t&&t.data)if(t.data.error){var n={width:500,closable:!1,title:this.notcriticalErrorTitle,msg:t.data.error,iconCls:"warn",buttons:i.isEmpty(t.data.createEmailAccountUrl)?["ok"]:["custom","cancel"],primary:i.isEmpty(t.data.createEmailAccountUrl)?["ok"]:"custom",customButtonText:this.textGoToMail,callback:i.bind(function(e){"custom"==e&&window.open(t.data.createEmailAccountUrl,"_blank"),this.fireEvent("editcomplete",this)},this)};Common.UI.alert(n)}else this.emailAddresses=t.data.emailAddresses,this.showMergeMailDlg()},showMergeMailDlg:function(){if(!this._mailMergeDlg){var t=this;t._mailMergeDlg=new DE.Views.MailMergeEmailDlg({props:{fieldsList:this._state.fieldsList,emailAddresses:this.emailAddresses},handler:function(i,n){if("ok"==i){t.mergeMailData=n;var o=DE.getController("Main");o.loadMask||(o.loadMask=new Common.UI.LoadMask({owner:e("#viewport")})),o.loadMask.setTitle(t.downloadMergeTitle),o.loadMask.show(),Common.Gateway.requestStartMailMerge()}t.fireEvent("editcomplete",t)}}),t._mailMergeDlg.on("close",function(e){t._mailMergeDlg=void 0}),t._mailMergeDlg.show()}},onProcessMailMerge:function(t){var e=DE.getController("Main").loadMask;if(e&&e.hide(),t)if(t.enabled)this.sendMergeDataByEmail();else{var n={closable:!1,title:this.notcriticalErrorTitle,msg:i.isEmpty(t.message)?this.warnProcessMailMerge:t.message,iconCls:"warn",buttons:["ok"],callback:i.bind(function(t){this.fireEvent("editcomplete",this)},this)};Common.UI.alert(n)}},sendMergeDataByEmail:function(){if(this.api){var t=0,e=Math.min(Math.max(this._state.recipientsCount-1,0),99);this.radioCurrent.getValue()?t=e=parseInt(this.txtFieldNum.getValue())-1:this.radioFromTo.getValue()&&(t=parseInt(this.txtFieldFrom.getValue())-1,e=parseInt(this.txtFieldTo.getValue())-1);var i=new Asc.CMailMergeSendData;i.put_RecordFrom(t),i.put_RecordTo(e),i.put_From(this.mergeMailData.from),i.put_To(this.mergeMailData.to),i.put_Subject(this.mergeMailData.subject),i.put_MailFormat(this.mergeMailData.mailFormat),this.mergeMailData.mailFormat!==Asc.c_oAscFileType.HTML&&(i.put_FileName(this.mergeMailData.fileName),i.put_Message(this.mergeMailData.message)),this.api.asc_sendMailMergeData(i),this.fireEvent("editcomplete",this)}},onLongActionEnd:function(t,e){e==Asc.c_oAscAsyncAction.SendMailMerge&&Common.UI.info({closable:!1,width:500,msg:this.textSendMsg,iconCls:"info",buttons:["ok"],callback:i.bind(function(t){this.fireEvent("editcomplete",this)},this)})},onBtnPreviewFieldClick:function(t,e){var i=parseInt(this.txtFieldNum.getValue());switch(i=isNaN(i)?0:i-1,t.options.value){case 0:i=0;break;case 1:i--;break;case 2:i++;break;case 3:i=this._state.recipientsCount-1}i<0&&(i=0),i>this._state.recipientsCount-1&&(i=this._state.recipientsCount-1),this.api.asc_PreviewMailMergeResult(i),this.fireEvent("editcomplete",this)},disableFieldBtns:function(t){var e=this._state.recipientsCount<1||!this.chPreview.getValue(),i=e||t<1;this.btnFirst.isDisabled()!==i&&this.btnFirst.setDisabled(i),this.btnPrev.isDisabled()!==i&&this.btnPrev.setDisabled(i),i=e||t>this._state.recipientsCount-2,this.btnLast.isDisabled()!==i&&this.btnLast.setDisabled(i),this.btnNext.isDisabled()!==i&&this.btnNext.setDisabled(i),i=e||t<0,this.txtFieldNum.isDisabled()!==i&&this.txtFieldNum.setDisabled(i),t>=0&&this.txtFieldNum.setValue(t+1)},onPreviewMailMergeResult:function(t){this.chPreview.getValue()||this.chPreview.setValue(!0),this.disableFieldBtns(t),this.disableEditing(!0)},onEndPreviewMailMergeResult:function(){this.chPreview.getValue()&&this.chPreview.setValue(!1),this.disableFieldBtns(-1),this.disableEditing(!1)},onStartMailMerge:function(){this.btnInsField&&this.btnInsField.menu.removeAll(),this.txtFieldNum&&this.txtFieldNum.setValue(1),this.ChangeSettings({recipientsCount:this.api.asc_GetReceptionsCount(),fieldsList:this.api.asc_GetMailMergeFieldsNameList()})},onCmbMergeToSelect:function(t,e){var i=e.value==Asc.c_oAscFileType.HTML;this.btnMerge.setVisible(i),this.btnPortal.setVisible(!i&&(this.mode.canRequestSaveAs||this.mode.mergeFolderUrl)),this.btnDownload.setVisible(!i)},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||this.lockControls(DE.enumLockMM.lostConnect,t,{array:i.union([this.btnEditData,this.btnInsField,this.chHighlight],this.mode.canRequestSaveAs||this.mode.mergeFolderUrl?[this.btnPortal]:[]),merge:!0})},disableInsertControls:function(t){this.lockControls(DE.enumLockMM.coAuth,t,{array:[this.btnInsField]})},setMode:function(t){this.mode=t},disableEditing:function(t){DE.getController("Toolbar").DisableToolbar(t,t),DE.getController("RightMenu").SetDisabled(t,!0),DE.getController("Statusbar").getView("Statusbar").SetDisabled(t),DE.getController("Common.Controllers.ReviewChanges").SetDisabled(t),DE.getController("DocumentHolder").getView().SetDisabled(t),DE.getController("Navigation")&&DE.getController("Navigation").SetDisabled(t);var e=DE.getController("Common.Controllers.Comments");e&&e.setPreviewMode(t),DE.getController("LeftMenu").setPreviewMode(t),this.lockControls(DE.enumLockMM.preview,t,{array:[this.btnInsField,this.btnEditData]})},setDocumentName:function(t){this.defFileName=t||this.txtUntitled;var e=this.defFileName.lastIndexOf(".");e>0&&(this.defFileName=this.defFileName.substring(0,e))},openHelp:function(t){DE.getController("LeftMenu").getView("LeftMenu").showMenu("file:help","UsageInstructions/UseMailMerge.htm")},disablePreviewMode:function(){this.api&&this.chPreview&&this.chPreview.getValue()&&this.api.asc_EndPreviewMailMergeResult()},lockControls:function(t,e,i){Common.Utils.lockControls(t,e,i,this.emptyDBControls)},textDataSource:"Data Source",textEditData:"Edit recipients list",textInsertField:"Insert Merge Field",textHighlight:"Highlight merge fields",textPreview:"Preview results",textPdf:"PDF",textDocx:"Docx",textEmail:"E-mail",txtFirst:"To first field",txtPrev:"To previous field",txtNext:"To next field",txtLast:"To last field",textMergeTo:"Merge to",textAll:"All records",textCurrent:"Current record",textFrom:"From",textTo:"To",textDownload:"Download",textPortal:"Save",errorMailMergeSaveFile:"Merge failed.",downloadMergeTitle:"Merging",requestMailsTitle:"Requesting e-mails",textMerge:"Merge",sendTitle:"Send e-mail",textSendMsg:"All mail messages are ready and will be sent out within some time.
    The speed of mailing depends on your mail service.
    You can continue working with document or close it. After the operation is over the notification will be sent to your registration email address.",notcriticalErrorTitle:"Warning",warnProcessMailMerge:"Starting merge failed",txtUntitled:"Untitled",textMaxRecepients:"Max 100 recipients.",textReadMore:"Read more",txtFromToError:'"From" value must be less than "To" value',textMergeFields:"Merge Fields",textGoToMail:"Go to Mail",textAddRecipients:"Add some recipients to the list first"},DE.Views.MailMergeSettings||{}))}),define("text!documenteditor/main/app/template/TextArtSettings.template",[],function(){return'\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    '}),define("documenteditor/main/app/view/TextArtSettings",["text!documenteditor/main/app/template/TextArtSettings.template","jquery","underscore","backbone","common/main/lib/component/ComboBox","common/main/lib/component/ComboBorderSize","common/main/lib/component/MetricSpinner","common/main/lib/component/ThemeColorPalette","common/main/lib/component/ColorButton","common/main/lib/component/ComboDataView","common/main/lib/component/Slider","common/main/lib/component/MultiSliderGradient"],function(t,e,i,n){"use strict";DE.Views.TextArtSettings=n.View.extend(i.extend({el:"#id-textart-settings",template:i.template(t),events:{},options:{alias:"TextArtSettings"},initialize:function(){this._initSettings=!0,this._noApply=!0,this.imgprops=null,this.shapeprops=null,this._sendUndoPoint=!0,this._sliderChanged=!1,this.txtPt=Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt),this._state={Transparency:null,FillType:Asc.c_oAscFill.FILL_TYPE_SOLID,ShapeColor:"transparent",StrokeType:Asc.c_oAscStrokeType.STROKE_COLOR,StrokeWidth:this._pt2mm(1),StrokeColor:"000000",StrokeBorderType:Asc.c_oDashType.solid,GradColor:"000000",GradFillType:Asc.c_oAscFillGradType.GRAD_LINEAR,FormId:null,DisabledControls:!1},this.lockedControls=[],this._locked=!1,this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_SOLID,this.ShapeColor={Value:1,Color:"transparent"},this.GradFillType=Asc.c_oAscFillGradType.GRAD_LINEAR,this.GradColor={values:[0,100],colors:["000000","ffffff"],currentIdx:0},this.GradRadialDirectionIdx=0,this.GradLinearDirectionType=0,this.BorderColor={Value:1,Color:"transparent"},this.BorderSize=0,this.BorderType=Asc.c_oDashType.solid,DE.getCollection("Common.Collections.TextArt").bind({reset:this.fillTextArt.bind(this)}),this.render()},render:function(){(this.$el||e(this.el)).html(this.template({scope:this})),this.FillColorContainer=e("#textart-panel-color-fill"),this.FillGradientContainer=e("#textart-panel-gradient-fill"),this.TransparencyContainer=e("#textart-panel-transparent-fill")},setApi:function(t){return this.api=t,this},onFillSrcSelect:function(t,e){switch(this.ShowHideElem(e.value),e.value){case Asc.c_oAscFill.FILL_TYPE_SOLID:if(this._state.FillType=Asc.c_oAscFill.FILL_TYPE_SOLID,!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_SOLID),n.put_fill(new Asc.asc_CFillSolid),n.get_fill().put_color(Common.Utils.ThemeColor.getRgbColor("transparent"==this.ShapeColor.Color?{color:"4f81bd",effectId:24}:this.ShapeColor.Color)),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}break;case Asc.c_oAscFill.FILL_TYPE_GRAD:if(this._state.FillType=Asc.c_oAscFill.FILL_TYPE_GRAD,!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;if(n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad), +n.get_fill().put_grad_type(this.GradFillType),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),this.OriginalFillType!==Asc.c_oAscFill.FILL_TYPE_GRAD){this.GradColor.values=[0,100],this.GradColor.colors=[this.GradColor.colors[0],this.GradColor.colors[this.GradColor.colors.length-1]],this.GradColor.currentIdx=0;var o=Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[0]).get_color().get_hex(),s=Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[1]).get_color().get_hex();o="ffffff"===o&&"ffffff"===s?{color:"4f81bd",effectId:24}:this.GradColor.colors[0],n.get_fill().put_positions([1e3*this.GradColor.values[0],1e3*this.GradColor.values[1]]),n.get_fill().put_colors([Common.Utils.ThemeColor.getRgbColor(o),Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[1])])}i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}break;case Asc.c_oAscFill.FILL_TYPE_NOFILL:if(this._state.FillType=Asc.c_oAscFill.FILL_TYPE_NOFILL,!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_NOFILL),n.put_fill(null),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}}this.fireEvent("editcomplete",this)},onColorsBackSelect:function(t,e){if(this.ShapeColor={Value:1,Color:e},this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;"transparent"==this.ShapeColor.Color?(n.put_type(Asc.c_oAscFill.FILL_TYPE_NOFILL),n.put_fill(null)):(n.put_type(Asc.c_oAscFill.FILL_TYPE_SOLID),n.put_fill(new Asc.asc_CFillSolid),n.get_fill().put_color(Common.Utils.ThemeColor.getRgbColor(this.ShapeColor.Color))),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onNumTransparencyChange:function(t,e,i,n){if(this.sldrTransparency.setValue(t.getNumberValue(),!0),this.api){var o=t.getNumberValue(),s=new Asc.asc_TextArtProperties,a=new Asc.asc_CShapeFill;a.put_transparent(2.55*o),s.asc_putFill(a),this.shapeprops.put_TextArtProperties(s),this.api.ImgApply(this.imgprops)}},onTransparencyChange:function(t,e,n){this._sliderChanged=e,this.numTransparency.setValue(e,!0),this._sendUndoPoint&&(this.api.setStartPointHistory(),this._sendUndoPoint=!1,this.updateslider=setInterval(i.bind(this._transparencyApplyFunc,this),100))},onTransparencyChangeComplete:function(t,e,i){clearInterval(this.updateslider),this._sliderChanged=e,this._sendUndoPoint||(this.api.setEndPointHistory(),this._transparencyApplyFunc()),this._sendUndoPoint=!0},_transparencyApplyFunc:function(){if(void 0!==this._sliderChanged){var t=new Asc.asc_TextArtProperties,e=new Asc.asc_CShapeFill;e.put_transparent(2.55*this._sliderChanged),t.asc_putFill(e),this.shapeprops.put_TextArtProperties(t),this.api.ImgApply(this.imgprops),this._sliderChanged=void 0}},onGradTypeSelect:function(t,e){if(this.GradFillType=e.value,this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){this.mnuDirectionPicker.store.reset(this._viewDataLinear),this.mnuDirectionPicker.cmpEl.width(175),this.mnuDirectionPicker.restoreHeight=174;var e=this.mnuDirectionPicker.store.findWhere({type:this.GradLinearDirectionType});this.mnuDirectionPicker.selectRecord(e,!0),e?this.btnDirection.setIconCls("item-gradient "+e.get("iconcls")):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(this.GradLinearDirectionType,!0),this.numGradientAngle.setDisabled(this._locked)}else this.GradFillType==Asc.c_oAscFillGradType.GRAD_PATH&&(this.mnuDirectionPicker.store.reset(this._viewDataRadial),this.mnuDirectionPicker.cmpEl.width(60),this.mnuDirectionPicker.restoreHeight=58,this.mnuDirectionPicker.selectByIndex(this.GradRadialDirectionIdx,!0),this.GradRadialDirectionIdx>=0?this.btnDirection.setIconCls("item-gradient "+this._viewDataRadial[this.GradRadialDirectionIdx].iconcls):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(0,!0),this.numGradientAngle.setDisabled(!0));if(this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad),n.get_fill().put_grad_type(this.GradFillType),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onSelectGradient:function(t,e,n,o){if(!this._noApply){var s={};if(i.isFunction(o.toJSON)){if(!o.get("selected"))return;s=o.toJSON()}else s=o;if(this.btnDirection.setIconCls("item-gradient "+s.iconcls),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR?this.GradLinearDirectionType=s.type:this.GradRadialDirectionIdx=0,this.api&&this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){this.numGradientAngle.setValue(s.type,!0);var a=new Asc.asc_TextArtProperties,r=new Asc.asc_CShapeFill;r.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),r.put_fill(new Asc.asc_CFillGrad),r.get_fill().put_grad_type(this.GradFillType),r.get_fill().put_linear_angle(6e4*s.type),r.get_fill().put_linear_scale(!0),a.asc_putFill(r),this.shapeprops.put_TextArtProperties(a),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)}},onColorsGradientSelect:function(t,e){if(this.GradColor.colors[this.GradColor.currentIdx]=e,this.sldrGradient.setColorValue(Common.Utils.String.format("#{0}","object"==typeof e?e.color:e)),this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CShapeFill;n.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),n.put_fill(new Asc.asc_CFillGrad),n.get_fill().put_grad_type(this.GradFillType);var o=[];this.GradColor.colors.forEach(function(t){o.push(Common.Utils.ThemeColor.getRgbColor(t))}),n.get_fill().put_colors(o),this.OriginalFillType!==Asc.c_oAscFill.FILL_TYPE_GRAD&&(this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(n.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),n.get_fill().put_linear_scale(!0)),o=[],this.GradColor.values.forEach(function(t){o.push(1e3*t)}),n.get_fill().put_positions(o)),i.asc_putFill(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onGradientChange:function(t,e,n){this.GradColor.values=t.getValues(),this.spnGradPosition.setValue(this.GradColor.values[this.GradColor.currentIdx],!0),this._sliderChanged=!0,this.api&&!this._noApply&&this._sendUndoPoint&&(this.api.setStartPointHistory(),this._sendUndoPoint=!1,this.updateslider=setInterval(i.bind(this._gradientApplyFunc,this),100))},onGradientChangeComplete:function(t,e,i){clearInterval(this.updateslider),this._sliderChanged=!0,this._sendUndoPoint||(this.api.setEndPointHistory(),this._gradientApplyFunc()),this._sendUndoPoint=!0},_gradientApplyFunc:function(){if(this._sliderChanged){var t=new Asc.asc_TextArtProperties,e=new Asc.asc_CShapeFill;e.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),e.put_fill(new Asc.asc_CFillGrad),e.get_fill().put_grad_type(this.GradFillType);var i=[];this.GradColor.values.forEach(function(t){i.push(1e3*t)}),e.get_fill().put_positions(i),this.OriginalFillType!==Asc.c_oAscFill.FILL_TYPE_GRAD&&(this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR&&(e.get_fill().put_linear_angle(6e4*this.GradLinearDirectionType),e.get_fill().put_linear_scale(!0)),i=[],this.GradColor.colors.forEach(function(t){i.push(Common.Utils.ThemeColor.getRgbColor(t))}),e.get_fill().put_colors(i)),t.asc_putFill(e),this.shapeprops.put_TextArtProperties(t),this.api.ImgApply(this.imgprops),this._sliderChanged=!1}},applyBorderSize:function(t){if(t=Common.Utils.String.parseFloat(t),t=isNaN(t)?0:Math.max(0,Math.min(1584,t)),this.BorderSize=t,this.api&&!this._noApply){var e=new Asc.asc_TextArtProperties,i=new Asc.asc_CStroke;this.BorderSize<1e-5?(i.put_type(Asc.c_oAscStrokeType.STROKE_NONE),this._state.StrokeType=this._state.StrokeWidth=-1):(i.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),"transparent"==this.BorderColor.Color||"transparent"==this.BorderColor.Color.color?i.put_color(Common.Utils.ThemeColor.getRgbColor({color:"000000",effectId:29})):this._state.StrokeType!=Asc.c_oAscStrokeType.STROKE_NONE&&null!==this._state.StrokeType||i.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(this.BorderColor.Color))),i.asc_putPrstDash(this.BorderType),i.put_width(this._pt2mm(this.BorderSize))),e.asc_putLine(i),this.shapeprops.put_TextArtProperties(e),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onComboBlur:function(){this.fireEvent("editcomplete",this)},onBorderSizeChanged:function(t,e,n,o){var s=this;if(t){var a=parseFloat(n.value);(!new RegExp("^\\s*(\\d*(\\.|,)?\\d+)\\s*("+s.txtPt+")?\\s*$").exec(n.value)||a<0||a>1584)&&(this._state.StrokeType=this._state.StrokeWidth=-1,Common.UI.error({msg:this.textBorderSizeErr,callback:function(){i.defer(function(t){s.fireEvent("editcomplete",s)})}}))}else this.applyBorderSize(n.value)},onBorderSizeSelect:function(t,e){this.applyBorderSize(e.value)},onBorderTypeSelect:function(t,e){if(this.BorderType=e.value,this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CStroke;this.BorderSize<1e-5?n.put_type(Asc.c_oAscStrokeType.STROKE_NONE):(n.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),n.put_color(Common.Utils.ThemeColor.getRgbColor(this.BorderColor.Color)),n.put_width(this._pt2mm(this.BorderSize)),n.asc_putPrstDash(this.BorderType)),i.asc_putLine(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},onColorsBorderSelect:function(t,e){if(this.BorderColor={Value:1,Color:e},this.api&&this.BorderSize>0&&!this._noApply){var i=new Asc.asc_TextArtProperties,n=new Asc.asc_CStroke;this.BorderSize<1e-5?n.put_type(Asc.c_oAscStrokeType.STROKE_NONE):(n.put_type(Asc.c_oAscStrokeType.STROKE_COLOR),n.put_color(Common.Utils.ThemeColor.getRgbColor(this.BorderColor.Color)),n.put_width(this._pt2mm(this.BorderSize)),n.asc_putPrstDash(this.BorderType)),i.asc_putLine(n),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},ChangeSettings:function(t){if(null==this.imgprops?(this.imgprops=new Asc.asc_CImgProperty,this.imgprops.put_ShapeProperties(new Asc.asc_CShapeProperty),this.shapeprops=this.imgprops.get_ShapeProperties()):this.imgprops.put_ImageUrl(null),this._initSettings&&this.createDelayedElements(),t&&t.get_ShapeProperties()&&t.get_ShapeProperties().get_TextArtProperties()){var e=t.get_ShapeProperties().get_TextArtProperties();this._noApply=!0,this.disableControls(this._locked);var n=null,o=e.asc_getFill(),s=o?o.get_type():null,a=null;if(o){var r=o.get_transparent();(Math.abs(this._state.Transparency-r)>.001||Math.abs(this.numTransparency.getNumberValue()-r)>.001||(null===this._state.Transparency||null===r)&&(this._state.Transparency!==r||this.numTransparency.getNumberValue()!==r))&&(void 0!==r&&(this.sldrTransparency.setValue(null===r?100:r/255*100,!0),this.numTransparency.setValue(this.sldrTransparency.getValue(),!0)),this._state.Transparency=r)}if(null===o||void 0===o||null===s)this.OriginalFillType=null;else if(s==Asc.c_oAscFill.FILL_TYPE_NOFILL)this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_NOFILL;else if(s==Asc.c_oAscFill.FILL_TYPE_SOLID)o=o.get_fill(),a=o.get_color(),a?a.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.ShapeColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b()),effectValue:a.get_value()}}:this.ShapeColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b())}:this.ShapeColor={Value:0,Color:"transparent"},this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_SOLID,this.GradColor.colors[0]="transparent"!==this.ShapeColor.Color?Common.Utils.ThemeColor.colorValue2EffectId(this.ShapeColor.Color):"000000",this.GradColor.colors[this.GradColor.colors.length-1]="ffffff";else if(s==Asc.c_oAscFill.FILL_TYPE_GRAD){o=o.get_fill();var l=o.get_grad_type();if(this._state.GradFillType===l&&this.GradFillType===l||(this.GradFillType=l,n=void 0,this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR||this.GradFillType==Asc.c_oAscFillGradType.GRAD_PATH?(this.cmbGradType.setValue(this.GradFillType),n=this.cmbGradType.store.findWhere({value:this.GradFillType}),this.onGradTypeSelect(this.cmbGradType,n.attributes)):(this.cmbGradType.setValue(""),this.btnDirection.setIconCls("")),this._state.GradFillType=this.GradFillType),this.GradFillType==Asc.c_oAscFillGradType.GRAD_LINEAR){var c=Math.floor(o.get_linear_angle()/6e4);if(Math.abs(this.GradLinearDirectionType-c)>.001){this.GradLinearDirectionType=c;var d=this.mnuDirectionPicker.store.findWhere({type:c});this.mnuDirectionPicker.selectRecord(d,!0),d?this.btnDirection.setIconCls("item-gradient "+d.get("iconcls")):this.btnDirection.setIconCls(""),this.numGradientAngle.setValue(c,!0)}}else this.numGradientAngle.setValue(0,!0);var h=this,p=o.get_colors(),m=o.get_positions(),u=p?p.length:this.GradColor.colors.length;this.sldrGradient.setThumbs(u),this.GradColor.colors.length>u&&(this.GradColor.colors.splice(u,this.GradColor.colors.length-u),this.GradColor.values.splice(u,this.GradColor.colors.length-u),this.GradColor.currentIdx=0),p&&p.forEach(function(t,e){t?t.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?(h.GradColor.colors[e]={color:Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()),effectValue:t.get_value()},Common.Utils.ThemeColor.colorValue2EffectId(h.GradColor.colors[e])):h.GradColor.colors[e]=Common.Utils.ThemeColor.getHexColor(t.get_r(),t.get_g(),t.get_b()):h.GradColor.colors[e]="000000";var i=m[e];null!==i&&(i/=1e3,h.GradColor.values[e]=i)});for(var g=0;g=this.GradColor.colors.length)&&(h.GradColor.currentIdx=0),h.sldrGradient.setActiveThumb(h.GradColor.currentIdx),this.spnGradPosition.setValue(this.GradColor.values[this.GradColor.currentIdx]),this.OriginalFillType=Asc.c_oAscFill.FILL_TYPE_GRAD,this.ShapeColor={Value:1,Color:this.GradColor.colors[0]}}this._state.FillType!==this.OriginalFillType&&(this.cmbFillSrc.setValue(null===this.OriginalFillType?"":this.OriginalFillType),this._state.FillType=this.OriginalFillType,this.ShowHideElem(this.OriginalFillType));var b=typeof this.ShapeColor.Color,f=typeof this._state.ShapeColor;if(b!==f||"object"==b&&(this.ShapeColor.Color.effectValue!==this._state.ShapeColor.effectValue||this._state.ShapeColor.color.indexOf(this.ShapeColor.Color.color)<0)||"object"!=b&&this._state.ShapeColor.indexOf(this.ShapeColor.Color)<0){if(this.btnBackColor.setColor(this.ShapeColor.Color),"object"==typeof this.ShapeColor.Color){for(var C=!1,v=0;v<10;v++)if(Common.Utils.ThemeColor.ThemeValues[v]==this.ShapeColor.Color.effectValue){this.colorsBack.select(this.ShapeColor.Color,!0),C=!0;break}C||this.colorsBack.clearSelection()}else this.colorsBack.select(this.ShapeColor.Color,!0);this._state.ShapeColor=this.ShapeColor.Color}var _,y=e.asc_getLine(),w=y?y.get_type():null,x="transparent"==this._state.StrokeColor&&"transparent"!==this.BorderColor.Color;if(y?(w==Asc.c_oAscStrokeType.STROKE_COLOR?(a=y.get_color(),a?a.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.BorderColor={Value:1,Color:{color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b()),effectValue:a.get_value()}}:this.BorderColor={Value:1,Color:Common.Utils.ThemeColor.getHexColor(a.get_r(),a.get_g(),a.get_b())}:this.BorderColor={Value:1,Color:"transparent"}):this.BorderColor={Value:1,Color:"transparent"},_=y.asc_getPrstDash()):this.BorderColor={Value:0,Color:"transparent"},b=typeof this.BorderColor.Color,f=typeof this._state.StrokeColor,x||b!==f||"object"==b&&(this.BorderColor.Color.effectValue!==this._state.StrokeColor.effectValue||this._state.StrokeColor.color.indexOf(this.BorderColor.Color.color)<0)||"object"!=b&&(this._state.StrokeColor.indexOf(this.BorderColor.Color)<0||"object"==typeof this.btnBorderColor.color)){if(this.btnBorderColor.setColor(this.BorderColor.Color),"object"==typeof this.BorderColor.Color){for(var C=!1,v=0;v<10;v++)if(Common.Utils.ThemeColor.ThemeValues[v]==this.BorderColor.Color.effectValue){this.colorsBorder.select(this.BorderColor.Color,!0),C=!0;break}C||this.colorsBorder.clearSelection()}else this.colorsBorder.select(this.BorderColor.Color,!0);this._state.StrokeColor=this.BorderColor.Color}if(this._state.StrokeType!==w||w==Asc.c_oAscStrokeType.STROKE_COLOR){if(w==Asc.c_oAscStrokeType.STROKE_COLOR){var S=y.get_width(),A=Math.abs(this._state.StrokeWidth-S)<1e-5&&!new RegExp(this.txtPt+"\\s*$").test(this.cmbBorderSize.getRawValue());if(Math.abs(this._state.StrokeWidth-S)>1e-5||A||(null===this._state.StrokeWidth||null===S)&&this._state.StrokeWidth!==S){this._state.StrokeWidth=S,null!==S&&(S=this._mm2pt(S));var k=null===S?S:i.find(this.cmbBorderSize.store.models,function(t){if(St.attributes.value-1e-5)return!0});k?this.cmbBorderSize.selectRecord(k):this.cmbBorderSize.setValue(null!==S?parseFloat(S.toFixed(2))+" "+this.txtPt:""),this.BorderSize=S}}else w==Asc.c_oAscStrokeType.STROKE_NONE?(this._state.StrokeWidth=0,this.BorderSize=this.cmbBorderSize.store.at(0).get("value"),this.cmbBorderSize.setValue(this.BorderSize)):(this._state.StrokeWidth=null,this.BorderSize=-1,this.cmbBorderSize.setValue(null));this._state.StrokeType=w}if(this._state.StrokeBorderType!==_&&(this.BorderType=this._state.StrokeBorderType=_,this.cmbBorderType.setValue(_)),a=this.GradColor.colors[this.GradColor.currentIdx],b=typeof a,f=typeof this._state.GradColor,b!==f||"object"==b&&(a.effectValue!==this._state.GradColor.effectValue||this._state.GradColor.color.indexOf(a.color)<0)||"object"!=b&&this._state.GradColor.indexOf(a)<0){if(this.btnGradColor.setColor(a),"object"==typeof a){for(var C=!1,v=0;v<10;v++)if(Common.Utils.ThemeColor.ThemeValues[v]==a.effectValue){this.colorsGrad.select(a,!0),C=!0;break}C||this.colorsGrad.clearSelection()}else this.colorsGrad.select(a,!0);this._state.GradColor=a}var T=e.asc_getForm();if(this._state.FormId!==T){this.cmbTransform.suspendEvents();var n=this.cmbTransform.menuPicker.store.findWhere({type:T});this.cmbTransform.menuPicker.selectRecord(n),this.cmbTransform.resumeEvents(),this._state.FormId=T}this._noApply=!1}},createDelayedControls:function(){var t=this;this._arrFillSrc=[{displayValue:this.textColor,value:Asc.c_oAscFill.FILL_TYPE_SOLID},{displayValue:this.textGradientFill,value:Asc.c_oAscFill.FILL_TYPE_GRAD},{displayValue:this.textNoFill,value:Asc.c_oAscFill.FILL_TYPE_NOFILL}],this.cmbFillSrc=new Common.UI.ComboBox({el:e("#textart-combo-fill-src"),cls:"input-group-nr",style:"width: 100%;",menuStyle:"min-width: 100%;",editable:!1,data:this._arrFillSrc}),this.cmbFillSrc.setValue(this._arrFillSrc[0].value),this.cmbFillSrc.on("selected",i.bind(this.onFillSrcSelect,this)),this.lockedControls.push(this.cmbFillSrc),this.numTransparency=new Common.UI.MetricSpinner({el:e("#textart-spin-transparency"),step:1,width:62,value:"100 %",defaultUnit:"%",maxValue:100,minValue:0}),this.numTransparency.on("change",i.bind(this.onNumTransparencyChange,this)),this.numTransparency.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.lockedControls.push(this.numTransparency),this.sldrTransparency=new Common.UI.SingleSlider({el:e("#textart-slider-transparency"),width:75,minValue:0,maxValue:100,value:100}),this.sldrTransparency.on("change",i.bind(this.onTransparencyChange,this)),this.sldrTransparency.on("changecomplete",i.bind(this.onTransparencyChangeComplete,this)),this.lockedControls.push(this.sldrTransparency),this.lblTransparencyStart=e(this.el).find("#textart-lbl-transparency-start"),this.lblTransparencyEnd=e(this.el).find("#textart-lbl-transparency-end"),this._arrGradType=[{displayValue:this.textLinear,value:Asc.c_oAscFillGradType.GRAD_LINEAR},{displayValue:this.textRadial,value:Asc.c_oAscFillGradType.GRAD_PATH}],this.cmbGradType=new Common.UI.ComboBox({el:e("#textart-combo-grad-type"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!1,data:this._arrGradType}),this.cmbGradType.setValue(this._arrGradType[0].value),this.cmbGradType.on("selected",i.bind(this.onGradTypeSelect,this)),this.lockedControls.push(this.cmbGradType),this._viewDataLinear=[{offsetx:0,offsety:0,type:45,subtype:-1,iconcls:"gradient-left-top"},{offsetx:50,offsety:0,type:90,subtype:4,iconcls:"gradient-top"},{offsetx:100,offsety:0,type:135,subtype:5,iconcls:"gradient-right-top"},{offsetx:0,offsety:50,type:0,subtype:6,iconcls:"gradient-left",cls:"item-gradient-separator",selected:!0},{offsetx:100,offsety:50,type:180,subtype:1,iconcls:"gradient-right"},{offsetx:0,offsety:100,type:315,subtype:2,iconcls:"gradient-left-bottom"},{offsetx:50,offsety:100,type:270,subtype:3,iconcls:"gradient-bottom"},{offsetx:100,offsety:100,type:225,subtype:7,iconcls:"gradient-right-bottom"}],this._viewDataRadial=[{offsetx:100,offsety:150,type:2,subtype:5,iconcls:"gradient-radial-center"}],this.btnDirection=new Common.UI.Button({cls:"btn-large-dataview",iconCls:"item-gradient gradient-left",menu:new Common.UI.Menu({style:"min-width: 60px;",menuAlign:"tr-br",items:[{template:i.template('
    ')}]})}),this.btnDirection.on("render:after",function(n){t.mnuDirectionPicker=new Common.UI.DataView({el:e("#id-textart-menu-direction"),parentMenu:n.menu,restoreHeight:174,store:new Common.UI.DataViewStore(t._viewDataLinear),itemTemplate:i.template('
    ')})}),this.btnDirection.render(e("#textart-button-direction")),this.mnuDirectionPicker.on("item:click",i.bind(this.onSelectGradient,this,this.btnDirection)),this.lockedControls.push(this.btnDirection),this.sldrGradient=new Common.UI.MultiSliderGradient({el:e("#textart-slider-gradient"),width:192,minValue:0,maxValue:100,values:[0,100]}),this.sldrGradient.on("change",i.bind(this.onGradientChange,this)),this.sldrGradient.on("changecomplete",i.bind(this.onGradientChangeComplete,this)),this.sldrGradient.on("thumbclick",function(e,i){t.GradColor.currentIdx=i;var n=t.GradColor.colors[t.GradColor.currentIdx];t.btnGradColor.setColor(n),t.colorsGrad.select(n,!1);var o=t.GradColor.values[t.GradColor.currentIdx];t.spnGradPosition.setValue(o,!0)}),this.sldrGradient.on("thumbdblclick",function(e){t.btnGradColor.cmpEl.find("button").dropdown("toggle")}),this.sldrGradient.on("sortthumbs",function(e,n){var o,s=[];i.each(n,function(e,i){s.push(t.GradColor.colors[e]),t.GradColor.currentIdx==e&&(o=i)}),t.OriginalFillType=null,t.GradColor.colors=s,t.GradColor.currentIdx=o}),this.sldrGradient.on("addthumb",function(e,i,n){t.GradColor.colors[i]=t.GradColor.colors[t.GradColor.currentIdx],t.GradColor.currentIdx=i;var o=t.sldrGradient.addNewThumb(i,n);t.GradColor.colors[t.GradColor.currentIdx]=o}),this.sldrGradient.on("removethumb",function(e,n){if(t.sldrGradient.removeThumb(n),t.GradColor.values.splice(n,1),t.sldrGradient.changeGradientStyle(),i.isUndefined(t.GradColor.currentIdx)||t.GradColor.currentIdx>=t.GradColor.colors.length){var o=n>0?n-1:n;o=0===o&&t.GradColor.values.length>2?t.GradColor.values.length-2:o,t.GradColor.currentIdx=o}t.sldrGradient.setActiveThumb(t.GradColor.currentIdx)}),this.lockedControls.push(this.sldrGradient),this.spnGradPosition=new Common.UI.MetricSpinner({el:e("#textart-gradient-position"),step:1,width:60,defaultUnit:"%",value:"50 %",allowDecimal:!1,maxValue:100,minValue:0,disabled:this._locked}),this.lockedControls.push(this.spnGradPosition),this.spnGradPosition.on("change",i.bind(this.onPositionChange,this)),this.spnGradPosition.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.btnAddGradientStep=new Common.UI.Button({parentEl:e("#textart-gradient-add-step"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-add-breakpoint",disabled:this._locked,hint:this.tipAddGradientPoint}),this.btnAddGradientStep.on("click",i.bind(this.onAddGradientStep,this)),this.lockedControls.push(this.btnAddGradientStep),this.btnRemoveGradientStep=new Common.UI.Button({parentEl:e("#textart-gradient-remove-step"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-remove-breakpoint",disabled:this._locked,hint:this.tipRemoveGradientPoint}),this.btnRemoveGradientStep.on("click",i.bind(this.onRemoveGradientStep,this)),this.lockedControls.push(this.btnRemoveGradientStep),this.numGradientAngle=new Common.UI.MetricSpinner({el:e("#textart-spin-gradient-angle"),step:10,width:60,defaultUnit:"°",value:"0 °",allowDecimal:!0,maxValue:359.9,minValue:0,disabled:this._locked}),this.lockedControls.push(this.numGradientAngle),this.numGradientAngle.on("change",i.bind(this.onGradientAngleChange,this)),this.numGradientAngle.on("inputleave",function(){t.fireEvent("editcomplete",t)}),this.cmbBorderSize=new Common.UI.ComboBorderSizeEditable({el:e("#textart-combo-border-size"),style:"width: 93px;",txtNoBorders:this.txtNoBorders}).on("selected",i.bind(this.onBorderSizeSelect,this)).on("changed:before",i.bind(this.onBorderSizeChanged,this,!0)).on("changed:after",i.bind(this.onBorderSizeChanged,this,!1)).on("combo:blur",i.bind(this.onComboBlur,this,!1)),this.BorderSize=this.cmbBorderSize.store.at(2).get("value"),this.cmbBorderSize.setValue(this.BorderSize),this.lockedControls.push(this.cmbBorderSize),this.cmbBorderType=new Common.UI.ComboBorderType({el:e("#textart-combo-border-type"),style:"width: 93px;",menuStyle:"min-width: 93px;"}).on("selected",i.bind(this.onBorderTypeSelect,this)).on("combo:blur",i.bind(this.onComboBlur,this,!1)),this.BorderType=Asc.c_oDashType.solid,this.cmbBorderType.setValue(this.BorderType),this.lockedControls.push(this.cmbBorderType),this.cmbTransform=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,cls:"combo-textart"}),this.cmbTransform.render(e("#textart-combo-transform")),this.cmbTransform.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbTransform.on("click",i.bind(this.onTransformSelect,this)),this.cmbTransform.openButton.menu.on("show:after",function(){t.cmbTransform.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbTransform)},createDelayedElements:function(){this._initSettings=!1,this.createDelayedControls(),this.UpdateThemeColors(),this.fillTransform(this.api.asc_getPropertyEditorTextArts()),this.fillTextArt()},fillTextArt:function(){if(!this._initSettings){var t=this;this.cmbTextArt||(this.cmbTextArt=new Common.UI.ComboDataView({itemWidth:50,itemHeight:50,menuMaxHeight:300,enableKeyEvents:!0,showLast:!1,cls:"combo-textart"}),this.cmbTextArt.render(e("#textart-combo-template")),this.cmbTextArt.openButton.menu.cmpEl.css({"min-width":178,"max-width":178}),this.cmbTextArt.on("click",i.bind(this.onTextArtSelect,this)),this.cmbTextArt.openButton.menu.on("show:after",function(){t.cmbTextArt.menuPicker.scroller.update({alwaysVisibleY:!0})}),this.lockedControls.push(this.cmbTextArt));var n=this.application.getCollection("Common.Collections.TextArt").models,o=this.cmbTextArt.menuPicker.store.length;if(n.length<1)return void DE.getController("Main").fillTextArt(this.api.asc_getTextArtPreviews());if(o>0&&o==n.length){var s=this.cmbTextArt.menuPicker.store.models;i.each(n,function(t,e){s[e].set("imageUrl",t.get("imageUrl"))})}else this.cmbTextArt.menuPicker.store.reset(n),this.cmbTextArt.menuPicker.store.length>0&&this.cmbTextArt.fillComboView(this.cmbTextArt.menuPicker.store.at(0))}},onTextArtSelect:function(t,e){if(this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties;i.asc_putStyle(e.get("data")),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},fillTransform:function(t){if(t&&t.length>1&&t[1]){for(var e=[],n=t[1],o=0;o0&&i.each(s,function(t){e.push({imageUrl:t.Image,type:t.Type,selected:!1})})}this.cmbTransform.menuPicker.store.add(e),this.cmbTransform.menuPicker.store.length>0&&this.cmbTransform.fillComboView(this.cmbTransform.menuPicker.store.at(0),!0)}},onTransformSelect:function(t,e){if(this.api&&!this._noApply){var i=new Asc.asc_TextArtProperties;i.asc_putForm(e.get("type")),this.shapeprops.put_TextArtProperties(i),this.api.ImgApply(this.imgprops)}this.fireEvent("editcomplete",this)},UpdateThemeColors:function(){this._initSettings||(this.btnBackColor||(this.btnBorderColor=new Common.UI.ColorButton({parentEl:e("#textart-border-color-btn"),color:"000000"}),this.lockedControls.push(this.btnBorderColor),this.colorsBorder=this.btnBorderColor.getPicker(),this.btnBorderColor.on("color:select",i.bind(this.onColorsBorderSelect,this)),this.btnGradColor=new Common.UI.ColorButton({parentEl:e("#textart-gradient-color-btn"),color:"000000"}),this.lockedControls.push(this.btnGradColor),this.colorsGrad=this.btnGradColor.getPicker(),this.btnGradColor.on("color:select",i.bind(this.onColorsGradientSelect,this)),this.btnBackColor=new Common.UI.ColorButton({parentEl:e("#textart-back-color-btn"),transparent:!0,color:"transparent"}),this.lockedControls.push(this.btnBackColor),this.colorsBack=this.btnBackColor.getPicker(),this.btnBackColor.on("color:select",i.bind(this.onColorsBackSelect,this))),this.colorsBorder.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsBack.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()),this.colorsGrad.updateColors(Common.Utils.ThemeColor.getEffectColors(),Common.Utils.ThemeColor.getStandartColors()))},_pt2mm:function(t){return 25.4*t/72},_mm2pt:function(t){return 72*t/25.4},ShowHideElem:function(t){this.FillColorContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_SOLID),this.FillGradientContainer.toggleClass("settings-hidden",t!==Asc.c_oAscFill.FILL_TYPE_GRAD),this.TransparencyContainer.toggleClass("settings-hidden",t===Asc.c_oAscFill.FILL_TYPE_NOFILL||null===t)},setLocked:function(t){this._locked=t},disableControls:function(t){this._initSettings||this._state.DisabledControls!==t&&(this._state.DisabledControls=t,i.each(this.lockedControls,function(e){e.setDisabled(t)}),this.numGradientAngle.setDisabled(t||this.GradFillType!==Asc.c_oAscFillGradType.GRAD_LINEAR))},onPositionChange:function(t){var e=t.getNumberValue(),i=this.GradColor.currentIdx-1<0?0:this.GradColor.values[this.GradColor.currentIdx-1],n=this.GradColor.currentIdx+1n;if(this.api){this.GradColor.values[this.GradColor.currentIdx]=e;var s=new Asc.asc_TextArtProperties,a=new Asc.asc_CShapeFill;a.asc_putType(Asc.c_oAscFill.FILL_TYPE_GRAD),a.asc_putFill(new Asc.asc_CFillGrad),a.asc_getFill().asc_putGradType(this.GradFillType);var r=[];this.GradColor.values.forEach(function(t){r.push(1e3*t)}),a.asc_getFill().asc_putPositions(r),s.asc_putFill(a),this.shapeprops.put_TextArtProperties(s),this.api.ImgApply(this.imgprops),o&&(this.sldrGradient.sortThumbs(),this.sldrGradient.trigger("change",this.sldrGradient),this.sldrGradient.trigger("changecomplete",this.sldrGradient))}},onAddGradientStep:function(){if(!(this.GradColor.colors.length>9)){var t=this.GradColor.currentIdx,e=(this.GradColor.values[t]+this.GradColor.values[t=this.GradColor.colors.length){var e=t>0?t-1:t;e=0===e&&this.GradColor.values.length>2?this.GradColor.values.length-2:e,this.GradColor.currentIdx=e}this.sldrGradient.setActiveThumb(this.GradColor.currentIdx),this.sldrGradient.trigger("change",this.sldrGradient),this.sldrGradient.trigger("changecomplete",this.sldrGradient)}},onGradientAngleChange:function(t,e,i,n){if(this.api&&!this._noApply){var o=new Asc.asc_TextArtProperties,s=new Asc.asc_CShapeFill;s.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD),s.put_fill(new Asc.asc_CFillGrad),s.get_fill().put_grad_type(this.GradFillType),s.get_fill().put_linear_angle(6e4*t.getNumberValue()),s.get_fill().put_linear_scale(!0),o.asc_putFill(s),this.shapeprops.put_TextArtProperties(o),this.api.ImgApply(this.imgprops)}},txtNoBorders:"No Line",strStroke:"Stroke",strColor:"Color",strSize:"Size",strFill:"Fill",textColor:"Color Fill",strTransparency:"Opacity",textNoFill:"No Fill",textSelectTexture:"Select",textGradientFill:"Gradient Fill",textLinear:"Linear",textRadial:"Radial",textDirection:"Direction",textStyle:"Style",textGradient:"Gradient Points",textBorderSizeErr:"The entered value is incorrect.
    Please enter a value between 0 pt and 1584 pt.",textTransform:"Transform",textTemplate:"Template",strType:"Type",textPosition:"Position",tipAddGradientPoint:"Add gradient point",tipRemoveGradientPoint:"Remove gradient point",textAngle:"Angle"},DE.Views.TextArtSettings||{}))}),define("text!documenteditor/main/app/template/SignatureSettings.template",[],function(){return'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    '}),define("documenteditor/main/app/view/SignatureSettings",["text!documenteditor/main/app/template/SignatureSettings.template","jquery","underscore","backbone","common/main/lib/component/Button"],function(t,e,i,n){"use strict";DE.Views.SignatureSettings=n.View.extend(i.extend({el:"#id-signature-settings",template:i.template(t),events:{},options:{alias:"SignatureSettings"},initialize:function(){this._state={DisabledEditing:!1,ready:!1,hasValid:!1,hasInvalid:!1,hasRequested:!1,tip:void 0},this._locked=!1,this.render()},render:function(){this.$el.html(this.template({scope:this}));var t=DE.getController("Common.Controllers.Protection").getView();this.btnAddInvisibleSign=t.getButton("signature"),this.btnAddInvisibleSign.render(this.$el.find("#signature-invisible-sign")),this.viewRequestedList=new Common.UI.DataView({el:e("#signature-requested-sign"),enableKeyEvents:!1,itemTemplate:i.template(['
    ','
    ','
    <%= Common.Utils.String.htmlEncode(name) %>
    ',"
    "].join(""))}),this.viewValidList=new Common.UI.DataView({el:e("#signature-valid-sign"),enableKeyEvents:!1,itemTemplate:i.template(['
    ','
    nomargin<% } %>">
    ','
    <%= Common.Utils.String.htmlEncode(name) %>
    ','
    <%= Common.Utils.String.htmlEncode(date) %>
    ',"
    "].join(""))}),this.viewInvalidList=new Common.UI.DataView({el:e("#signature-invalid-sign"),enableKeyEvents:!1,itemTemplate:i.template(['
    ','
    nomargin<% } %>">
    ','
    <%= Common.Utils.String.htmlEncode(name) %>
    ','
    <%= Common.Utils.String.htmlEncode(date) %>
    ',"
    "].join(""))}),this.viewRequestedList.on("item:click",i.bind(this.onSelectSignature,this)),this.viewValidList.on("item:click",i.bind(this.onSelectSignature,this)),this.viewInvalidList.on("item:click",i.bind(this.onSelectSignature,this)),this.viewRequestedList.on("item:contextmenu",i.bind(this.onItemContextMenu,this)),this.viewValidList.on("item:contextmenu",i.bind(this.onItemContextMenu,this)),this.viewInvalidList.on("item:contextmenu",i.bind(this.onItemContextMenu,this)),this.signatureMenu=new Common.UI.Menu({menuAlign:"tr-br",items:[{caption:this.strSign,value:0},{caption:this.strDetails,value:1},{caption:this.strSetup,value:2},{caption:this.strDelete,value:3}]}),this.signatureMenu.on("item:click",i.bind(this.onMenuSignatureClick,this))},setApi:function(t){return this.api=t,this.api&&this.api.asc_registerCallback("asc_onUpdateSignatures",i.bind(this.onApiUpdateSignatures,this)),Common.NotificationCenter.on("document:ready",i.bind(this.onDocumentReady,this)),this},ChangeSettings:function(t){this._state.hasRequested||this._state.hasValid||this._state.hasInvalid||this.updateSignatures(this.api.asc_getSignatures(),this.api.asc_getRequestSignatures())},setLocked:function(t){this._locked=t},setMode:function(t){this.mode=t},onApiUpdateSignatures:function(t,e){this._state.ready&&(this.updateSignatures(t,e),this.showSignatureTooltip(this._state.hasValid,this._state.hasInvalid))},updateSignatures:function(t,e){var n=this,o=[],s=[],a=[],r=1;i.each(e,function(t,e){var i=t.asc_getSigner1();o.push({name:""!==i?i:n.strSigner+" "+r++,guid:t.asc_getGuid(),requested:!0})}),i.each(t,function(t,e){var n=t.asc_getDate(),o={name:t.asc_getSigner1(),certificateId:t.asc_getId(),guid:t.asc_getGuid(),date:i.isEmpty(n)?"":new Date(n).toLocaleString(),invisible:!t.asc_getVisible()};0==t.asc_getValid()?s.push(o):a.push(o)}),n._state.hasValid=s.length>0,n._state.hasInvalid=a.length>0,n._state.hasRequested=o.length>0,this.viewRequestedList.store.reset(o),this.viewValidList.store.reset(s),this.viewInvalidList.store.reset(a),this.$el.find(".requested").toggleClass("hidden",!n._state.hasRequested),this.$el.find(".valid").toggleClass("hidden",!n._state.hasValid),this.$el.find(".invalid").toggleClass("hidden",!n._state.hasInvalid),n.disableEditing(n._state.hasValid||n._state.hasInvalid)},onItemContextMenu:function(t,n,o,s){var a=this.signatureMenu;a.isVisible()&&a.hide();var r=e(this.el).offset(),l=[s.clientX*Common.Utils.zoom()-r.left+5,s.clientY*Common.Utils.zoom()-r.top+5];this.showSignatureMenu(o,l),a.menuAlign="tl-bl",a.menuAlignEl=null,a.setOffset(15,5),a.show(),i.delay(function(){a.cmpEl.focus()},10)},onSelectSignature:function(t,n,o,s){if(o){var a=e(s.target);if(a&&a.hasClass("caret")){var r=this.signatureMenu;if(r.isVisible())return void r.hide();var l=e(s.currentTarget),c=l.offset(),d=e(this.el).offset(),h=[c.left-d.left+l.width(),c.top-d.top+l.height()/2];this.showSignatureMenu(o,h),r.menuAlign="tr-br",r.menuAlignEl=l,r.setOffset(-20,-l.height()/2+3),r.show(),i.delay(function(){r.cmpEl.focus()},10),s.stopPropagation(),s.preventDefault()}else this.api.asc_gotoSignature(o.get("guid"))}},showSignatureMenu:function(t,i){this.api.asc_gotoSignature(t.get("guid"));var n=this.signatureMenu,o=e(this.el),s=o.find("#menu-signature-container");n.rendered||(s.length<1&&(s=e('',n.id),o.append(s)),n.render(s),n.cmpEl.attr({tabindex:"-1"}),n.on({"show:after":function(t){t&&t.menuAlignEl&&t.menuAlignEl.toggleClass("over",!0)},"hide:after":function(t){t&&t.menuAlignEl&&t.menuAlignEl.toggleClass("over",!1)}}));var a=t.get("requested"),r=this._state.hasValid||this._state.hasInvalid;n.items[0].setVisible(a),n.items[1].setVisible(!a),n.items[2].setVisible(a||!t.get("invisible")),n.items[3].setVisible(!a),n.items[0].setDisabled(this._locked),n.items[3].setDisabled(this._locked),n.items[1].cmpEl.attr("data-value",t.get("certificateId")),n.items[2].cmpEl.attr("data-value",r?1:0),n.cmpEl.attr("data-value",t.get("guid")),s.css({left:i[0],top:i[1]})},onMenuSignatureClick:function(t,e){var i=t.cmpEl.attr("data-value");switch(e.value){case 0:Common.NotificationCenter.trigger("protect:sign",i);break;case 1:this.api.asc_ViewCertificate(e.cmpEl.attr("data-value"));break;case 2:Common.NotificationCenter.trigger("protect:signature","visible",!!parseInt(e.cmpEl.attr("data-value")),i);break;case 3:this.api.asc_RemoveSignature(i)}},onDocumentReady:function(){this._state.ready=!0,this.updateSignatures(this.api.asc_getSignatures(),this.api.asc_getRequestSignatures()),this.showSignatureTooltip(this._state.hasValid,this._state.hasInvalid,this._state.hasRequested)},showSignatureTooltip:function(t,e,i){var n=this,o=n._state.tip;if(!t&&!e&&!i)return void(o&&o.isVisible()&&(o.close(),n._state.tip=void 0));var s=t||e,a=e?n.txtSignedInvalid:t?n.txtSigned:"";i&&(a=n.txtRequestedSignatures+"

    "+a),o&&o.isVisible()&&(a!==o.text||s!==o.showLink)&&(o.close(),n._state.tip=void 0),n._state.tip||(o=new Common.UI.SynchronizeTip({target:DE.getController("RightMenu").getView("RightMenu").btnSignature.btnEl,text:a,showLink:s,textLink:this.txtContinueEditing,placement:"left"}),o.on({dontshowclick:function(){Common.UI.warning({title:n.notcriticalErrorTitle,msg:n.txtEditWarning,buttons:["ok","cancel"],primary:"ok",callback:function(t){"ok"==t&&(o.close(),n._state.tip=void 0,n.api.asc_RemoveAllSignatures())}})},closeclick:function(){o.close(),n._state.tip=void 0}}),n._state.tip=o,o.show())},disableEditing:function(t){if(this._state.DisabledEditing!=t){this._state.DisabledEditing=t;var e=DE.getController("RightMenu");t&&"id-signature-settings"!==e.rightmenu.GetActivePane()&&e.rightmenu.clearSelection(),e.SetDisabled(t,!1,!0),DE.getController("Toolbar").DisableToolbar(t,t),DE.getController("Statusbar").getView("Statusbar").SetDisabled(t),DE.getController("Common.Controllers.ReviewChanges").SetDisabled(t),DE.getController("DocumentHolder").getView().SetDisabled(t,!0),DE.getController("Navigation")&&DE.getController("Navigation").SetDisabled(t),DE.getController("LeftMenu").setPreviewMode(t);var i=DE.getController("Common.Controllers.Comments");i&&i.setPreviewMode(t)}},strSignature:"Signature",strRequested:"Requested signatures",strValid:"Valid signatures",strInvalid:"Invalid signatures",strSign:"Sign",strDetails:"Signature Details",strSetup:"Signature Setup",txtSigned:"Valid signatures has been added to the document. The document is protected from editing.",txtSignedInvalid:"Some of the digital signatures in document are invalid or could not be verified. The document is protected from editing.",txtRequestedSignatures:"This document needs to be signed.",txtContinueEditing:"Edit anyway",notcriticalErrorTitle:"Warning",txtEditWarning:"Editing will remove the signatures from the document.
    Are you sure you want to continue?",strDelete:"Remove Signature",strSigner:"Signer"},DE.Views.SignatureSettings||{}))}),define("text!documenteditor/main/app/template/FormSettings.template",[],function(){return'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n \n
    \n
    \n \n \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n\n \n \n \n \n \n \n \n \n \n \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n \n \n \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    '}),void 0===Common)var Common={};define("common/main/lib/component/TextareaField",["common/main/lib/component/BaseView","common/main/lib/component/Tooltip"],function(){"use strict";Common.UI.TextareaField=Common.UI.BaseView.extend(function(){return{options:{id:null,cls:"",style:"",value:"",maxlength:void 0,placeHolder:"",spellcheck:!1,disabled:!1},template:_.template(['
    ',"","
    "].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;this.id=e.options.id||Common.UI.getId(),this.cls=e.options.cls,this.style=e.options.style,this.value=e.options.value,this.placeHolder=e.options.placeHolder,this.template=e.options.template||e.template,this.disabled=e.options.disabled,this.spellcheck=e.options.spellcheck,this.maxLength=e.options.maxLength,e.rendered=e.options.rendered||!1,e.options.el&&e.render()},render:function(t){var e=this;if(e.rendered?this.cmpEl=this.$el:(this.cmpEl=$(this.template({id:this.id,cls:this.cls,style:this.style,placeHolder:this.placeHolder,spellcheck:this.spellcheck,scope:e})),t?(this.setElement(t,!1),t.html(this.cmpEl)):this.$el.html(this.cmpEl)),!e.rendered){this.cmpEl;this._input=this.cmpEl.find("textarea").addBack().filter("textarea"),this._input.on("blur",_.bind(this.onInputChanged,this)),this._input.on("keydown",_.bind(this.onKeyDown,this)),this.maxLength&&this._input.attr("maxlength",this.maxLength),this.disabled&&this.setDisabled(this.disabled)}return e.rendered=!0,this},_doChange:function(t,e){if(!e||!e.synthetic){var i=$(t.target).val(),n=this.value;this.trigger("changed:before",this,i,n,t),t.isDefaultPrevented()||(this.value=i,this.trigger("changed:after",this,i,n,t))}},onInputChanged:function(t,e){this._doChange(t,e)},onKeyDown:function(t){this.trigger("keydown:before",this,t),t.isDefaultPrevented()||(t.keyCode===Common.UI.Keys.RETURN&&t.stopPropagation(),t.keyCode==Common.UI.Keys.ESC&&this.setValue(this.value),t.keyCode==Common.UI.Keys.ESC&&this.trigger("inputleave",this))},setDisabled:function(t){this.disabled=t,$(this.el).toggleClass("disabled",t),t?this._input.attr("disabled",!0):this._input.removeAttr("disabled")},isDisabled:function(){return this.disabled},setValue:function(t){this.value=t,this.rendered&&this._input.val(t)},getValue:function(){return this.value},focus:function(){this._input.focus()}}}())}),define("documenteditor/main/app/view/FormSettings",["text!documenteditor/main/app/template/FormSettings.template","jquery","underscore","backbone","common/main/lib/component/ComboBox","common/main/lib/component/MetricSpinner","common/main/lib/component/TextareaField","common/main/lib/component/CheckBox","common/main/lib/view/ImageFromUrlDialog"],function(t,e,i,n){"use strict";DE.Views.FormSettings=n.View.extend(i.extend({el:"#id-form-settings",template:i.template(t),events:{},options:{alias:"FormSettings"},initialize:function(){this._initSettings=!0,this._state={DisabledControls:void 0,LockDelete:void 0},this.spinners=[],this.lockedControls=[],this.internalId=null,this._locked=!0,this._originalTextFormProps=null,this._originalFormProps=null,this._originalProps=null,this.render()},render:function(){var t=this.$el||e(this.el);t.html(this.template({scope:this})),this.TextOnlySettings=t.find(".form-textfield"),this.PlaceholderSettings=t.find(".form-placeholder"),this.KeySettings=t.find(".form-keyfield"),this.KeySettingsTd=this.KeySettings.find("td"),this.CheckOnlySettings=t.find(".form-checkbox"),this.RadioOnlySettings=t.find(".form-radiobox"),this.ListOnlySettings=t.find(".form-list"),this.ImageOnlySettings=t.find(".form-image"),this.ConnectedSettings=t.find(".form-connected")},createDelayedElements:function(){this._initSettings=!1;var t=this.$el||e(this.el),n=this;this.labelFormName=t.findById("#form-settings-name"),this.labelConnectedFields=t.findById("#form-settings-connected"),t.findById("#form-settings-disconnect").on("click",i.bind(this.onDisconnect,this)),this.cmbKey=new Common.UI.ComboBox({el:t.findById("#form-combo-key"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!0,data:[]}),this.cmbKey.setValue(""),this.lockedControls.push(this.cmbKey),this.cmbKey.on("selected",this.onKeyChanged.bind(this)),this.cmbKey.on("changed:after",this.onKeyChanged.bind(this)),this.cmbKey.on("hide:after",this.onHideMenus.bind(this)),this.txtPlaceholder=new Common.UI.InputField({el:t.findById("#form-txt-pholder"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",value:""}),this.lockedControls.push(this.txtPlaceholder),this.txtPlaceholder.on("changed:after",this.onPlaceholderChanged.bind(this)),this.txtPlaceholder.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.textareaHelp=new Common.UI.TextareaField({el:t.findById("#form-txt-help"),style:"width: 100%; height: 60px;",value:""}),this.lockedControls.push(this.textareaHelp),this.textareaHelp.on("changed:after",this.onHelpChanged.bind(this)),this.textareaHelp.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.chMaxChars=new Common.UI.CheckBox({el:t.findById("#form-chb-max-chars"),labelText:this.textMaxChars}),this.chMaxChars.on("change",this.onChMaxCharsChanged.bind(this)),this.lockedControls.push(this.chMaxChars),this.spnMaxChars=new Common.UI.MetricSpinner({el:t.findById("#form-spin-max-chars"),step:1,width:45,defaultUnit:"",value:"10",maxValue:1e6,minValue:1}),this.lockedControls.push(this.spnMaxChars),this.spnMaxChars.on("change",this.onMaxCharsChange.bind(this)),this.spnMaxChars.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.chComb=new Common.UI.CheckBox({el:t.findById("#form-chb-comb"),labelText:this.textComb}),this.chComb.on("change",this.onChCombChanged.bind(this)),this.lockedControls.push(this.chComb),this.spnWidth=new Common.UI.MetricSpinner({el:t.findById("#form-spin-width"),step:.1,width:64,defaultUnit:"cm",value:"Auto",allowAuto:!0,maxValue:55.88,minValue:.1}),this.lockedControls.push(this.spnWidth),this.spinners.push(this.spnWidth),this.spnWidth.on("change",this.onWidthChange.bind(this)),this.spnWidth.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.cmbGroupKey=new Common.UI.ComboBox({el:t.findById("#form-combo-group-key"),cls:"input-group-nr",menuStyle:"min-width: 100%;",editable:!0,data:[]}),this.cmbGroupKey.setValue(""),this.lockedControls.push(this.cmbGroupKey),this.cmbGroupKey.on("selected",this.onGroupKeyChanged.bind(this)),this.cmbGroupKey.on("changed:after",this.onGroupKeyChanged.bind(this)),this.cmbGroupKey.on("hide:after",this.onHideMenus.bind(this)),this.txtNewValue=new Common.UI.InputField({el:t.findById("#form-txt-new-value"),allowBlank:!0,validateOnChange:!1,validateOnBlur:!1,style:"width: 100%;",value:""}),this.lockedControls.push(this.txtNewValue),this.txtNewValue.on("inputleave",function(){n.fireEvent("editcomplete",n)}),this.txtNewValue._input.on("keydown",i.bind(this.onNewValueKeydown,this)),this.list=new Common.UI.ListView({el:t.findById("#form-list-list"),store:new Common.UI.DataViewStore,emptyText:"",template:i.template(['
    '].join("")),itemTemplate:i.template(['
    ','
    <%= name %>
    ',"
    "].join(""))}),this.list.on("item:select",i.bind(this.onSelectItem,this)),this.lockedControls.push(this.list),this.btnListAdd=new Common.UI.Button({parentEl:t.findById("#form-list-add"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-zoomup",hint:this.textTipAdd}),this.btnListAdd.on("click",i.bind(this.onAddItem,this)),this.lockedControls.push(this.btnListAdd),this.btnListDelete=new Common.UI.Button({parentEl:t.findById("#form-list-delete"),cls:"btn-toolbar",iconCls:"toolbar__icon cc-remove",hint:this.textTipDelete}),this.btnListDelete.on("click",i.bind(this.onDeleteItem,this)),this.lockedControls.push(this.btnListDelete),this.btnListUp=new Common.UI.Button({parentEl:t.findById("#form-list-up"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-arrow-up",hint:this.textTipUp}),this.btnListUp.on("click",i.bind(this.onMoveItem,this,!0)),this.lockedControls.push(this.btnListUp),this.btnListDown=new Common.UI.Button({parentEl:t.findById("#form-list-down"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-arrow-down",hint:this.textTipDown}),this.btnListDown.on("click",i.bind(this.onMoveItem,this,!1)),this.lockedControls.push(this.btnListDown),this.btnSelectImage=new Common.UI.Button({parentEl:e("#form-button-replace"),cls:"btn-text-menu-default",caption:this.textSelectImage,style:"width:100%;",menu:new Common.UI.Menu({style:"min-width: 194px;",maxHeight:200,items:[{caption:this.textFromFile,value:0},{cls:"cp-from-url",caption:this.textFromUrl,value:1},{caption:this.textFromStorage,value:2}]})}),this.lockedControls.push(this.btnSelectImage),this.btnSelectImage.menu.on("item:click",i.bind(this.onImageSelect,this)),this.btnSelectImage.menu.items[2].setVisible(this.mode.canRequestInsertImage||this.mode.fileChoiceUrl&&this.mode.fileChoiceUrl.indexOf("{documentType}")>-1),this.btnRemForm=new Common.UI.Button({parentEl:t.findById("#form-btn-delete"),cls:"btn-toolbar",iconCls:"toolbar__icon cc-remove",caption:this.textDelete,style:"text-align: left;"}),this.btnRemForm.on("click",i.bind(function(t){this.api.asc_RemoveContentControl(this._state.id)},this)),this.lockedControls.push(this.btnRemForm),this.btnLockForm=new Common.UI.Button({parentEl:t.findById("#form-btn-lock"),cls:"btn-toolbar",iconCls:"toolbar__icon btn-lock",caption:this.textLock,style:"text-align: left;"}),this.btnLockForm.on("click",i.bind(function(t){if(this.api&&!this._noApply){var e=this._originalProps||new AscCommon.CContentControlPr;e.put_Lock(this._state.LockDelete?Asc.c_oAscSdtLockType.Unlocked:Asc.c_oAscSdtLockType.SdtLocked),this.api.asc_SetContentControlProperties(e,this.internalId)}},this)),this.updateMetricUnit(),this.UpdateThemeColors()},setApi:function(t){return this.api=t,this.api,this},setMode:function(t){this.mode=t},onKeyChanged:function(t,e){if(this.api&&!this._noApply){var i=this._originalProps||new AscCommon.CContentControlPr,n=this._originalFormProps||new AscCommon.CSdtFormPr;n.put_Key(e.value),i.put_FormPr(n),this.api.asc_SetContentControlProperties(i,this.internalId),this.fireEvent("editcomplete",this)}},onPlaceholderChanged:function(t,e,i,n){if(this.api&&!this._noApply&&e!==i){var o=this._originalProps||new AscCommon.CContentControlPr;o.put_PlaceholderText(e||" "),this.api.asc_SetContentControlProperties(o,this.internalId),n.relatedTarget&&("input"==n.relatedTarget.localName||"textarea"==n.relatedTarget.localName)&&/form-control/.test(n.relatedTarget.className)||this.fireEvent("editcomplete",this)}},onHelpChanged:function(t,e,i,n){if(this.api&&!this._noApply&&e!==i){var o=this._originalProps||new AscCommon.CContentControlPr,s=this._originalFormProps||new AscCommon.CSdtFormPr;s.put_HelpText(e),o.put_FormPr(s),this.api.asc_SetContentControlProperties(o,this.internalId),n.relatedTarget&&("input"==n.relatedTarget.localName||"textarea"==n.relatedTarget.localName)&&/form-control/.test(n.relatedTarget.className)||this.fireEvent("editcomplete",this)}},onChMaxCharsChanged:function(t,e,i,n){var o="checked"==t.getValue();if(this.spnMaxChars.setDisabled(!o),o||(this.chComb.setValue(!1,!0),this.spnWidth.setDisabled(!0)),this.api&&!this._noApply){var s=this._originalProps||new AscCommon.CContentControlPr,a=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;!o&&a.put_Comb(o),a.put_MaxCharacters(o?this.spnMaxChars.getNumberValue()||10:o),s.put_TextFormPr(a),this.api.asc_SetContentControlProperties(s,this.internalId),this.fireEvent("editcomplete",this)}},onMaxCharsChange:function(t,e,i,n){if(this.api&&!this._noApply){var o=this._originalProps||new AscCommon.CContentControlPr,s=this._originalTextFormProps||new AscCommon.CSdtTextFormPr,a="checked"==this.chMaxChars.getValue()||"checked"==this.chComb.getValue();s.put_MaxCharacters(a?t.getNumberValue()||10:a),o.put_TextFormPr(s),this.api.asc_SetContentControlProperties(o,this.internalId),this.fireEvent("editcomplete",this)}},onChCombChanged:function(t,e,i,n){var o="checked"==t.getValue();if(o&&(this.chMaxChars.setValue(!0,!0),this.spnMaxChars.setDisabled(!1)),this.spnWidth.setDisabled(!o),this.api&&!this._noApply){var s=this._originalProps||new AscCommon.CContentControlPr,a=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;if(a.put_Comb(o),o)if(a.put_MaxCharacters(this.spnMaxChars.getNumberValue()||10),this.spnWidth.getValue()){var r=this.spnWidth.getNumberValue();a.put_Width(r<=0?0:parseInt(72*Common.Utils.Metric.fnRecalcToMM(r)*20/25.4+.1))}else a.put_Width(0);s.put_TextFormPr(a),this.api.asc_SetContentControlProperties(s,this.internalId),this.fireEvent("editcomplete",this)}},onWidthChange:function(t,e,i,n){if(this.api&&!this._noApply){var o=this._originalProps||new AscCommon.CContentControlPr,s=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;if(this.spnWidth.getValue()){var a=this.spnWidth.getNumberValue();s.put_Width(a<=0?0:parseInt(72*Common.Utils.Metric.fnRecalcToMM(a)*20/25.4+.1))}else s.put_Width(0);o.put_TextFormPr(s),this.api.asc_SetContentControlProperties(o,this.internalId),this.fireEvent("editcomplete",this)}},onGroupKeyChanged:function(t,e){if(this.api&&!this._noApply){var i=this._originalProps||new AscCommon.CContentControlPr,n=this._originalCheckProps||new AscCommon.CSdtCheckBoxPr;n.put_GroupKey(e.value),i.put_CheckBoxPr(n),this.api.asc_SetContentControlProperties(i,this.internalId),this.fireEvent("editcomplete",this)}},fillListProps:function(){if(this.api&&!this._noApply){var t=this._originalProps||new AscCommon.CContentControlPr,e=this._originalListProps||new AscCommon.CSdtComboBoxPr;e.clear(),this.list.store.each(function(t,i){e.add_Item(t.get("name"),t.get("value"))}),this.type==Asc.c_oAscContentControlSpecificType.ComboBox?t.put_ComboBoxPr(e):t.put_DropDownListPr(e),this.api.asc_SetContentControlProperties(t,this.internalId)}},onNewValueKeydown:function(t){this.api&&!this._noApply&&t.keyCode==Common.UI.Keys.RETURN&&this.onAddItem()},onAddItem:function(){var t=this.list.store,e=this.txtNewValue.getValue();if(""!==e){t.findWhere({value:e})||(t.add({value:e,name:e}),this._state.listValue=e,this._state.listIndex=void 0,this.fillListProps())}this.fireEvent("editcomplete",this)},onDeleteItem:function(t,e){var i=this.list.getSelectedRec();if(i){var n=this.list.store;this._state.listIndex=n.indexOf(i),this._state.listValue=void 0,n.remove(i),this.fillListProps()}this.fireEvent("editcomplete",this)},onMoveItem:function(t){var e=this.list.store,i=e.length,n=this.list.getSelectedRec();if(n){var o=e.indexOf(n);e.add(e.remove(n),{at:t?Math.max(0,o-1):Math.min(i-1,o+1)}),this.fillListProps()}this.fireEvent("editcomplete",this)},setImageUrl:function(t,e){this.api.asc_SetContentControlPictureUrl(t,this.internalId,e)},insertImageFromStorage:function(t){t&&t.url&&"control"==t.c&&this.setImageUrl(t.url,t.token)},onImageSelect:function(t,e){if(1==e.value){var n=this;new Common.Views.ImageFromUrlDialog({handler:function(t,e){if("ok"==t&&n.api){var o=e.replace(/ /g,"");i.isEmpty(o)||n.setImageUrl(o)}n.fireEvent("editcomplete",n)}}).show()}else if(2==e.value)Common.NotificationCenter.trigger("storage:image-load","control");else{if(this._isFromFile)return;this._isFromFile=!0,this.api&&this.api.asc_addImage(this._originalProps),this.fireEvent("editcomplete",this),this._isFromFile=!1}},onColorPickerSelect:function(t,e){if(this.BorderColor=e,this._state.BorderColor=void 0,this.api&&!this._noApply){var i=this._originalProps||new AscCommon.CContentControlPr,n=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;if("transparent"==e)n.put_CombBorder();else{var o=n.get_CombBorder();o||(o=new Asc.asc_CTextBorder),o.put_Value(1), +o.put_Color(Common.Utils.ThemeColor.getRgbColor(e)),n.put_CombBorder(o)}i.put_TextFormPr(n),this.api.asc_SetContentControlProperties(i,this.internalId),this.fireEvent("editcomplete",this)}},onNoBorderClick:function(t){if(this.BorderColor="transparent",this._state.BorderColor=void 0,this.api&&!this._noApply){var e=this._originalProps||new AscCommon.CContentControlPr,i=this._originalTextFormProps||new AscCommon.CSdtTextFormPr;i.put_CombBorder(),e.put_TextFormPr(i),this.api.asc_SetContentControlProperties(e,this.internalId),this.fireEvent("editcomplete",this)}},ChangeSettings:function(t){if(this._initSettings&&this.createDelayedElements(),t){this._originalProps=t,this._noApply=!0,this.internalId=t.get_InternalId();var e=t.get_PlaceholderText();this._state.placeholder!==e&&(this.txtPlaceholder.setValue(e||""),this._state.placeholder=e),e=t.get_Lock(),void 0===e&&(e=Asc.c_oAscSdtLockType.Unlocked),this._state.LockDelete!==(e==Asc.c_oAscSdtLockType.SdtContentLocked||e==Asc.c_oAscSdtLockType.SdtLocked)&&(this._state.LockDelete=e==Asc.c_oAscSdtLockType.SdtContentLocked||e==Asc.c_oAscSdtLockType.SdtLocked,this.btnLockForm.setCaption(this._state.LockDelete?this.textUnlock:this.textLock)),this.disableControls(this._locked);var n,o=t.get_SpecificType(),s=!1;if(o==Asc.c_oAscContentControlSpecificType.ComboBox||o==Asc.c_oAscContentControlSpecificType.DropDownList){if(this.labelFormName.text(o==Asc.c_oAscContentControlSpecificType.ComboBox?this.textCombobox:this.textDropDown),n=o==Asc.c_oAscContentControlSpecificType.ComboBox?t.get_ComboBoxPr():t.get_DropDownListPr()){this._originalListProps=n;for(var a=n.get_ItemsCount(),r=[],l=0;l0&&this._state.internalId===this.internalId&&(void 0!==this._state.listValue||void 0!==this._state.listIndex)&&(void 0!==this._state.listIndex&&this._state.listIndex>=this.list.store.length&&(this._state.listIndex=this.list.store.length-1),c=void 0!==this._state.listValue?this.list.store.findWhere({value:this._state.listValue}):this.list.store.at(this._state.listIndex)),c?(this.list.selectRecord(c),this.list.scrollToRecord(c)):(this.txtNewValue.setValue(""),this._state.listValue=this._state.listIndex=void 0)}this.disableListButtons()}else o==Asc.c_oAscContentControlSpecificType.CheckBox&&(n=t.get_CheckBoxPr(),this._originalCheckProps=n);var d=t.get_FormPr();if(d){this._originalFormProps=d;var h=[];if(o==Asc.c_oAscContentControlSpecificType.CheckBox?h=this.api.asc_GetCheckBoxFormKeys():o==Asc.c_oAscContentControlSpecificType.Picture?(h=this.api.asc_GetPictureFormKeys(),this.labelFormName.text(this.textImage)):h=this.api.asc_GetTextFormKeys(),!this._state.arrKey||this._state.arrKey.length!==h.length||i.difference(this._state.arrKey,h).length>0){var r=[];h.forEach(function(t){r.push({displayValue:t,value:t})}),this.cmbKey.setData(r),this._state.arrKey=h}if(e=d.get_Key(),this._state.Key!==e&&(this.cmbKey.setValue(e||""),this._state.Key=e),e&&(e=this.api.asc_GetFormsCountByKey(e),s=e>1),s&&this.labelConnectedFields.text(this.textConnected+": "+e),e=d.get_HelpText(),this._state.help!==e&&(this.textareaHelp.setValue(e||""),this._state.help=e),o==Asc.c_oAscContentControlSpecificType.CheckBox&&n){e=n.get_GroupKey();var p="string"!=typeof e;if(!p){if(h=this.api.asc_GetRadioButtonGroupKeys(),!this._state.arrGroupKey||this._state.arrGroupKey.length!==h.length||i.difference(this._state.arrGroupKey,h).length>0){var r=[];h.forEach(function(t){r.push({displayValue:t,value:t})}),this.cmbGroupKey.setData(r),this._state.arrGroupKey=h}this._state.groupKey!==e&&(this.cmbGroupKey.setValue(e||""),this._state.groupKey=e)}this.labelFormName.text(p?this.textCheckbox:this.textRadiobox)}}var m=t.get_TextFormPr();if(m){this._originalTextFormProps=m,this.labelFormName.text(this.textField),e=m.get_Comb(),this._state.Comb!==e&&(this.chComb.setValue(!!e,!0),this._state.Comb=e),this.btnColor.setDisabled(!e),this.spnWidth.setDisabled(!e),e=m.get_Width(),((void 0===e||void 0===this._state.Width)&&this._state.Width!==e||Math.abs(this._state.Width-e)>.1)&&(this.spnWidth.setValue(0!==e&&void 0!==e?Common.Utils.Metric.fnRecalcFromMM(25.4*e/20/72):-1,!0),this._state.Width=e),e=this.api.asc_GetTextFormAutoWidth(),(this._state.WidthPlaceholder!==e||Math.abs(this._state.WidthPlaceholder-e)>.01)&&(this.spnWidth.setDefaultValue(void 0!==e&&null!==e?Common.Utils.Metric.fnRecalcFromMM(e):this.spnWidth.options.minValue),this._state.WidthPlaceholder=e),e=m.get_MaxCharacters(),this.chMaxChars.setValue(e&&e>=0),this.spnMaxChars.setDisabled(!e||e<0),((void 0===e||void 0===this._state.MaxChars)&&this._state.MaxChars!==e||Math.abs(this._state.MaxChars-e)>.1)&&(this.spnMaxChars.setValue(e&&e>=0?e:10,!0),this._state.MaxChars=e);var u=m.get_CombBorder();if(u){var g=u.get_Color();g?g.get_type()==Asc.c_oAscColor.COLOR_TYPE_SCHEME?this.BorderColor={color:Common.Utils.ThemeColor.getHexColor(g.get_r(),g.get_g(),g.get_b()),effectValue:g.get_value()}:this.BorderColor=Common.Utils.ThemeColor.getHexColor(g.get_r(),g.get_g(),g.get_b()):this.BorderColor="transparent"}else this.BorderColor="transparent";var b=typeof this.BorderColor;(b!==typeof this._state.BorderColor||"object"==b&&(this.BorderColor.effectValue!==this._state.BorderColor.effectValue||this._state.BorderColor.color.indexOf(this.BorderColor.color)<0)||"object"!=b&&this._state.BorderColor.indexOf(this.BorderColor)<0)&&(this.btnColor.setColor(this.BorderColor),this.mnuColorPicker.clearSelection(),this.mnuNoBorder.setChecked("transparent"==this.BorderColor,!0),"transparent"!=this.BorderColor&&this.mnuColorPicker.selectByRGB("object"==typeof this.BorderColor?this.BorderColor.color:this.BorderColor,!0),this._state.BorderColor=this.BorderColor)}this._noApply=!1,this.KeySettingsTd.toggleClass("padding-small",!s),this.ConnectedSettings.toggleClass("hidden",!s),this.type===o&&o!=Asc.c_oAscContentControlSpecificType.CheckBox||this.showHideControls(o,m,n),this.type=o,this._state.internalId=this.internalId}},updateMetricUnit:function(){if(this.spinners){for(var t=0;t .active").removeClass("active"),n.addClass("active"),this.scroller&&this.scroller.scrollTop(0)):(o.css("display","none"),e(this.el).width(SCALE_MIN),this.minimizedMode=!0,Common.localStorage.setItem("de-hide-right-settings",1)),this.fireEvent("rightmenuclick",[this,t.options.asctype,this.minimizedMode,i])},SetActivePane:function(t,e){if(!(this.minimizedMode&&!0!==e||void 0===this._settings[t]))if(this.minimizedMode)this._settings[t].btn.toggle(!0,!1),this._settings[t].btn.trigger("click",this._settings[t].btn);else{var i=this.$el.find("#"+this._settings[t].panel);i.hasClass("active")||(i.parent().find("> .active").removeClass("active"),i.addClass("active"),this.scroller&&(this.scroller.update(),this.scroller.scrollTop(0))),this._settings[t].btn.isActive()||this._settings[t].btn.toggle(!0,!1)}},GetActivePane:function(){return this.minimizedMode?null:this.$el.find(".settings-panel.active")[0].id},clearSelection:function(){this.mergeSettings&&this.mergeSettings.disablePreviewMode();var t=e(".right-panel");t.find("> .active").removeClass("active"),this._settings.forEach(function(t){t.btn.isActive()&&t.btn.toggle(!1,!0)}),t.css("display","none"),e(this.el).width(SCALE_MIN),this.minimizedMode=!0,Common.NotificationCenter.trigger("layout:changed","rightmenu")},txtParagraphSettings:"Paragraph Settings",txtImageSettings:"Image Settings",txtTableSettings:"Table Settings",txtHeaderFooterSettings:"Header and Footer Settings",txtShapeSettings:"Shape Settings",txtTextArtSettings:"Text Art Settings",txtChartSettings:"Chart Settings",txtMailMergeSettings:"Mail Merge Settings",txtSignatureSettings:"Signature Settings",txtFormSettings:"Form Settings"},DE.Views.RightMenu||{}))}),define("documenteditor/main/app/controller/RightMenu",["core","documenteditor/main/app/view/RightMenu"],function(){"use strict";DE.Controllers.RightMenu=Backbone.Controller.extend({models:[],collections:[],views:["RightMenu"],initialize:function(){this.editMode=!0,this._initSettings=!0,this.addListeners({RightMenu:{rightmenuclick:this.onRightMenuClick}}),Common.Utils.InternalSettings.set("de-rightpanel-active-form",1)},onLaunch:function(){this.rightmenu=this.createView("RightMenu"),this.rightmenu.on("render:after",_.bind(this.onRightMenuAfterRender,this))},onRightMenuAfterRender:function(t){t.shapeSettings.application=t.textartSettings.application=this.getApplication(),this._settings=[],this._settings[Common.Utils.documentSettingsType.Paragraph]={panelId:"id-paragraph-settings",panel:t.paragraphSettings,btn:t.btnText,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.Table]={panelId:"id-table-settings",panel:t.tableSettings,btn:t.btnTable,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.Image]={panelId:"id-image-settings",panel:t.imageSettings,btn:t.btnImage,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.Header]={panelId:"id-header-settings",panel:t.headerSettings,btn:t.btnHeaderFooter,hidden:1,locked:!1,needShow:!0},this._settings[Common.Utils.documentSettingsType.Shape]={panelId:"id-shape-settings",panel:t.shapeSettings,btn:t.btnShape,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.TextArt]={panelId:"id-textart-settings",panel:t.textartSettings,btn:t.btnTextArt,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.Chart]={panelId:"id-chart-settings",panel:t.chartSettings,btn:t.btnChart,hidden:1,locked:!1},this._settings[Common.Utils.documentSettingsType.MailMerge]={panelId:"id-mail-merge-settings",panel:t.mergeSettings,btn:t.btnMailMerge,hidden:1,props:{},locked:!1},this._settings[Common.Utils.documentSettingsType.Signature]={panelId:"id-signature-settings",panel:t.signatureSettings,btn:t.btnSignature,hidden:1,props:{},locked:!1},this._settings[Common.Utils.documentSettingsType.Form]={panelId:"id-form-settings",panel:t.formSettings,btn:t.btnForm,hidden:1,props:{},locked:!1}},setApi:function(t){this.api=t,this.api.asc_registerCallback("asc_onUpdateSignatures",_.bind(this.onApiUpdateSignatures,this)),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onCoAuthoringDisconnect,this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this))},setMode:function(t){this.editMode=t.isEdit},onRightMenuClick:function(t,e,i,n){if(!i&&this.editMode){n&&(this._settings[Common.Utils.documentSettingsType.Form].hidden||(e==Common.Utils.documentSettingsType.Form?(this._settings[Common.Utils.documentSettingsType.Paragraph].hidden||Common.Utils.InternalSettings.set("de-rightpanel-active-para",0),this._settings[Common.Utils.documentSettingsType.Image].hidden||Common.Utils.InternalSettings.set("de-rightpanel-active-image",0),this._settings[Common.Utils.documentSettingsType.Shape].hidden||Common.Utils.InternalSettings.set("de-rightpanel-active-shape",0)):e==Common.Utils.documentSettingsType.Paragraph?Common.Utils.InternalSettings.set("de-rightpanel-active-para",2):e==Common.Utils.documentSettingsType.Image?(Common.Utils.InternalSettings.set("de-rightpanel-active-image",2),Common.Utils.InternalSettings.set("de-rightpanel-active-shape",0)):e==Common.Utils.documentSettingsType.Shape&&(Common.Utils.InternalSettings.set("de-rightpanel-active-shape",2),Common.Utils.InternalSettings.set("de-rightpanel-active-image",0))));var o=this._settings[e].panel,s=this._settings[e].props;s&&o&&o.ChangeSettings.call(o,e==Common.Utils.documentSettingsType.MailMerge||e==Common.Utils.documentSettingsType.Signature?void 0:s)}else i&&e==Common.Utils.documentSettingsType.MailMerge&&this.rightmenu.mergeSettings.disablePreviewMode();Common.NotificationCenter.trigger("layout:changed","rightmenu"),this.rightmenu.fireEvent("editcomplete",this.rightmenu)},onFocusObject:function(t){if(this.editMode){var e=!!this._initSettings&&!Common.localStorage.getBool("de-hide-right-settings",this.rightmenu.defaultHideRightMenu);this._initSettings=!1;for(var i=!1,n=!1,o=0;o=this._settings.length||void 0===this._settings[d])){var h=t[o].get_ObjectValue();if(d==Common.Utils.documentSettingsType.Image){var p=a?a.get_Lock():Asc.c_oAscSdtLockType.Unlocked;l=p==Asc.c_oAscSdtLockType.SdtContentLocked||p==Asc.c_oAscSdtLockType.ContentLocked,null!==h.get_ChartProperties()?(s=!0,d=Common.Utils.documentSettingsType.Chart):null!==h.get_ShapeProperties()&&(s=h.get_ShapeProperties().get_FromChart(),d=Common.Utils.documentSettingsType.Shape,h.get_ShapeProperties().asc_getTextArtProperties()&&(this._settings[Common.Utils.documentSettingsType.TextArt].props=h,this._settings[Common.Utils.documentSettingsType.TextArt].hidden=0,this._settings[Common.Utils.documentSettingsType.TextArt].locked=h.get_Locked()||l)),r=r||h.get_Locked()}else d==Common.Utils.documentSettingsType.Paragraph&&(this._settings[d].panel.isChart=s,i=h.get_CanAddTable(),r=r||h.get_Locked());this._settings[d].props=h,this._settings[d].hidden=0,this._settings[d].locked=h.get_Locked()||l,this._settings[Common.Utils.documentSettingsType.MailMerge].locked||(this._settings[Common.Utils.documentSettingsType.MailMerge].locked=h.get_Locked()),this._settings[Common.Utils.documentSettingsType.Signature].locked||(this._settings[Common.Utils.documentSettingsType.Signature].locked=h.get_Locked())}}if(a&&a.get_FormPr()&&this.rightmenu.formSettings){var m=a.get_SpecificType();m!=Asc.c_oAscContentControlSpecificType.CheckBox&&m!=Asc.c_oAscContentControlSpecificType.Picture&&m!=Asc.c_oAscContentControlSpecificType.ComboBox&&m!=Asc.c_oAscContentControlSpecificType.DropDownList&&m!=Asc.c_oAscContentControlSpecificType.None||(d=Common.Utils.documentSettingsType.Form,this._settings[d].props=a,this._settings[d].locked=r,this._settings[d].hidden=0)}if(this._settings[Common.Utils.documentSettingsType.Header].locked)for(o=0;oy&&x>_?Common.Utils.documentSettingsType.Form:y>x&&y>_?Common.Utils.documentSettingsType.Shape:Common.Utils.documentSettingsType.Image):b=x>w?Common.Utils.documentSettingsType.Form:Common.Utils.documentSettingsType.Paragraph}b>-1?v=b:g>=0&&u<0?v=g:u>=0?v=u:this._settings[Common.Utils.documentSettingsType.MailMerge].hidden||(v=Common.Utils.documentSettingsType.MailMerge),void 0==v&&e&&g>=0&&(v=g),void 0!==v&&(this.rightmenu.SetActivePane(v,e),v!=Common.Utils.documentSettingsType.MailMerge&&v!=Common.Utils.documentSettingsType.Signature?this._settings[v].panel.ChangeSettings.call(this._settings[v].panel,this._settings[v].props):this._settings[v].panel.ChangeSettings.call(this._settings[v].panel))}this._settings[Common.Utils.documentSettingsType.Image].needShow=!1,this._settings[Common.Utils.documentSettingsType.Chart].needShow=!1}},onCoAuthoringDisconnect:function(){this.SetDisabled(!0,!1)},onInsertTable:function(){this._settings[Common.Utils.documentSettingsType.Table].needShow=!0},onInsertImage:function(){this._settings[Common.Utils.documentSettingsType.Image].needShow=!0},onInsertChart:function(){this._settings[Common.Utils.documentSettingsType.Chart].needShow=!0},onInsertShape:function(){this._settings[Common.Utils.documentSettingsType.Shape].needShow=!0},onInsertTextArt:function(){this._settings[Common.Utils.documentSettingsType.TextArt].needShow=!0},onInsertControl:function(){this._settings[Common.Utils.documentSettingsType.Form]&&(this._settings[Common.Utils.documentSettingsType.Form].needShow=!0)},UpdateThemeColors:function(){this.rightmenu.paragraphSettings.UpdateThemeColors(),this.rightmenu.tableSettings.UpdateThemeColors(),this.rightmenu.shapeSettings.UpdateThemeColors(),this.rightmenu.textartSettings.UpdateThemeColors()},updateMetricUnit:function(){this.rightmenu.headerSettings.updateMetricUnit(),this.rightmenu.paragraphSettings.updateMetricUnit(),this.rightmenu.chartSettings.updateMetricUnit(),this.rightmenu.imageSettings.updateMetricUnit(),this.rightmenu.tableSettings.updateMetricUnit(),this.rightmenu.formSettings&&this.rightmenu.formSettings.updateMetricUnit()},createDelayedElements:function(){if(this.api&&(this.api.asc_registerCallback("asc_onFocusObject",_.bind(this.onFocusObject,this)),this.api.asc_registerCallback("asc_doubleClickOnObject",_.bind(this.onDoubleClickOnObject,this)),this.rightmenu.mergeSettings&&(this.rightmenu.mergeSettings.setDocumentName(this.getApplication().getController("Viewport").getView("Common.Views.Header").getDocumentCaption()),this.api.asc_registerCallback("asc_onStartMailMerge",_.bind(this.onStartMailMerge,this))),this.api.asc_registerCallback("asc_onError",_.bind(this.onError,this))),this.editMode&&this.api){var t=this.api.getSelectedElements();t.length>0&&this.onFocusObject(t)}},onDoubleClickOnObject:function(t){if(this.editMode){var e=t.get_ObjectType(),i=this.getDocumentSettingsType(e);if(!(void 0===i||i>=this._settings.length||void 0===this._settings[i])){var n=t.get_ObjectValue();i==Common.Utils.documentSettingsType.Image&&(null!==n.get_ChartProperties()?i=Common.Utils.documentSettingsType.Chart:null!==n.get_ShapeProperties()&&(i=Common.Utils.documentSettingsType.Shape)),i!==Common.Utils.documentSettingsType.Paragraph&&(this.rightmenu.SetActivePane(i,!0),this._settings[i].panel.ChangeSettings.call(this._settings[i].panel,this._settings[i].props))}}},onStartMailMerge:function(){var t=Common.Utils.documentSettingsType.MailMerge;this._settings[t].hidden=0,this._settings[t].btn.setDisabled(!1),this.rightmenu.SetActivePane(t,!0),this._settings[t].panel.setLocked(this._settings[t].locked),this._settings[t].panel.ChangeSettings.call(this._settings[t].panel)},onError:function(t,e,i){if(t==Asc.c_oAscError.ID.MailMergeLoadFile){this._settings[Common.Utils.documentSettingsType.MailMerge].hidden=1,this._settings[Common.Utils.documentSettingsType.MailMerge].btn.setDisabled(!0);var n=this.api.getSelectedElements();n.length>0&&this.onFocusObject(n)}}, +onApiUpdateSignatures:function(t,e){if(this.rightmenu.signatureSettings){var i=(!t||t.length<1)&&(!e||e.length<1),n=Common.Utils.documentSettingsType.Signature;this._settings[n].hidden=i?1:0,this._settings[n].btn.setDisabled(i),this._settings[n].panel.setLocked(this._settings[n].locked)}},SetDisabled:function(t,e,i){if(this.setMode({isEdit:!t}),this.rightmenu&&this.rightmenu.paragraphSettings)if(this.rightmenu.paragraphSettings.disableControls(t),this.rightmenu.shapeSettings.disableControls(t),this.rightmenu.textartSettings.disableControls(t),this.rightmenu.headerSettings.disableControls(t),this.rightmenu.tableSettings.disableControls(t),this.rightmenu.imageSettings.disableControls(t),this.rightmenu.formSettings&&this.rightmenu.formSettings.disableControls(t),!e&&this.rightmenu.mergeSettings&&(this.rightmenu.mergeSettings.disableControls(t),t&&this.rightmenu.btnMailMerge.setDisabled(t)),this.rightmenu.chartSettings.disableControls(t),!i&&this.rightmenu.signatureSettings&&this.rightmenu.btnSignature.setDisabled(t),t)this.rightmenu.btnText.setDisabled(t),this.rightmenu.btnTable.setDisabled(t),this.rightmenu.btnImage.setDisabled(t),this.rightmenu.btnHeaderFooter.setDisabled(t),this.rightmenu.btnShape.setDisabled(t),this.rightmenu.btnTextArt.setDisabled(t),this.rightmenu.btnChart.setDisabled(t),this.rightmenu.btnForm&&this.rightmenu.btnForm.setDisabled(t);else{var n=this.api.getSelectedElements();n.length>0&&this.onFocusObject(n)}},getDocumentSettingsType:function(t){switch(t){case Asc.c_oAscTypeSelectElement.Paragraph:return Common.Utils.documentSettingsType.Paragraph;case Asc.c_oAscTypeSelectElement.Table:return Common.Utils.documentSettingsType.Table;case Asc.c_oAscTypeSelectElement.Image:return Common.Utils.documentSettingsType.Image;case Asc.c_oAscTypeSelectElement.Header:return Common.Utils.documentSettingsType.Header}}})}),function(t){function e(t,e){for(var i=t.length;i--;)if(t[i]===e)return i;return-1}function i(t,e){if(t.length!=e.length)return!1;for(var i=0;i0;for(s in A)(!A[s]&&e(o.mods,+s)>-1||A[s]&&-1==e(o.mods,+s))&&(l=!1);(0!=o.mods.length||A[16]||A[18]||A[17]||A[91])&&!l||(!0===x||o.locked||!1===o.method(t,o))&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0))}}function s(t){var i,n=t.keyCode,o=e(M,n);if(o>=0&&M.splice(o,1),93!=n&&224!=n||(n=91),n in A){A[n]=!1;for(i in T)T[i]==n&&(r[i]=!1)}}function a(){for(w in A)A[w]=!1;for(w in T)r[w]=!1}function r(t,e,i){var n,o;n=g(t),void 0===i&&(i=e,e="all");for(var s=0;s1&&(o=b(t),t=[t[t.length-1]]),t=t[0],t=P(t),t in S||(S[t]=[]),S[t].push({shortcut:n[s],scope:e,method:i,key:n[s],mods:o})}function l(t,e){var n,o,s,a,r,l=[];for(n=g(t),a=0;a1&&(l=b(o),t=o[o.length-1]),t=P(t),void 0===e&&(e=m()),!S[t])return;for(s in S[t])r=S[t][s],r.scope===e&&i(r.mods,l)&&(S[t][s]={})}}function c(t){return"string"==typeof t&&(t=P(t)),-1!=e(M,t)}function d(){return M.slice(0)}function h(t){var e=(t.target||t.srcElement).tagName;return!("INPUT"==e||"SELECT"==e||"TEXTAREA"==e)}function p(t){k=t||"all"}function m(){return k||"all"}function u(t){var e,i,n;for(e in S)for(i=S[e],n=0;n1&&(l=b(s),t=s[s.length-1]),t=P(t),void 0===e&&(e=m()),S[t])for(a in S[t])r=S[t][a],r.scope===e&&i(r.mods,l)&&(S[t][a][n]=o)}function _(t,e){t?v(t,e,"locked",!0):x=!0}function y(t,e){t?v(t,e,"locked",!1):x=!1}var w,x,S={},A={16:!1,18:!1,17:!1,91:!1},k="all",T={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,command:91},I={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,home:36,end:35,pageup:33,pagedown:34,",":188,".":190,"/":191,"`":192,"-":189,"=":187,";":186,"'":222,"[":219,"]":221,"\\":220,"ff-":173,"ff=":61},P=function(t){return I[t]||t.toUpperCase().charCodeAt(0)},M=[];for(w=1;w<20;w++)I["f"+w]=111+w;var E={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey"};for(w in T)r[w]=!1;f(document,"keydown",function(t){o(t)}),f(document,"keyup",s),f(window,"focus",a);var U=t.key;t.key=r,t.key.setScope=p,t.key.getScope=m,t.key.deleteScope=u,t.key.filter=h,t.key.isPressed=c,t.key.getPressedKeyCodes=d,t.key.noConflict=C,t.key.unbind=l,t.key.suspend=_,t.key.resume=y,"undefined"!=typeof module&&(module.exports=key)}(this),define("keymaster",function(){}),void 0===Common)var Common={};if(Common.util=Common.util||{},define("common/main/lib/util/Shortcuts",["backbone","keymaster"],function(t){"use strict";var e=function(t){return this.cid=_.uniqueId("shortcuts"),this.initialize.apply(this,arguments),this};_.extend(e.prototype,t.Events,{initialize:function(){window.key.filter=function(t){return!0},Common.NotificationCenter.on({"modal:show":function(t){window.key.suspend()},"modal:close":function(t,e){e&&window.key.resume()},"modal:hide":function(t,e){e&&window.key.resume()}})},delegateShortcuts:function(t){if(t&&t.shortcuts){this.removeShortcuts(t);var e,i,n,o,s,a,r=[];for(s in t.shortcuts){if(e=t.shortcuts[s],_.isFunction(e))n=e;else if(!(n=t[e]))throw new Error("Method "+e+" does not exist");i=s.match(/^(\S+)\s*(.*)$/),a=i[1],o=i[2].length?i[2]:"all",n=_.bind(n,this),r.push(window.key(a,o,n))}}},removeShortcuts:function(t){if(t&&t.shortcuts){var e,i,n,o;for(n in t.shortcuts)e=n.match(/^(\S+)\s*(.*)$/),o=e[1],i=e[2].length?e[2]:"all",window.key.unbind(o,i)}},suspendEvents:function(t,e){window.key.suspend(t,e)},resumeEvents:function(t,e){window.key.resume(t,e)}}),e.extend=t.View.extend,Common.util.Shortcuts=new e}),define("documenteditor/main/app/controller/LeftMenu",["core","common/main/lib/util/Shortcuts","common/main/lib/view/SaveAsDlg","documenteditor/main/app/view/LeftMenu","documenteditor/main/app/view/FileMenu"],function(){"use strict";DE.Controllers.LeftMenu=Backbone.Controller.extend(_.extend({views:["LeftMenu","FileMenu"],initialize:function(){this.addListeners({"Common.Views.Chat":{hide:_.bind(this.onHideChat,this)},"Common.Views.Header":{"file:settings":_.bind(this.clickToolbarSettings,this),"history:show":function(){this.leftMenu.panelHistory.isVisible()||this.clickMenuFileItem("header","history")}.bind(this)},"Common.Views.About":{show:_.bind(this.aboutShowHide,this,!1),hide:_.bind(this.aboutShowHide,this,!0)},"Common.Views.Plugins":{"plugin:open":_.bind(this.onPluginOpen,this),hide:_.bind(this.onHidePlugins,this)},LeftMenu:{"comments:show":_.bind(this.commentsShowHide,this,"show"),"comments:hide":_.bind(this.commentsShowHide,this,"hide")},FileMenu:{"menu:hide":_.bind(this.menuFilesShowHide,this,"hide"),"menu:show":_.bind(this.menuFilesShowHide,this,"show"),"item:click":_.bind(this.clickMenuFileItem,this),"saveas:format":_.bind(this.clickSaveAsFormat,this),"savecopy:format":_.bind(this.clickSaveCopyAsFormat,this),"settings:apply":_.bind(this.applySettings,this),"create:new":_.bind(this.onCreateNew,this),"recent:open":_.bind(this.onOpenRecent,this)},Toolbar:{"file:settings":_.bind(this.clickToolbarSettings,this),"file:open":this.clickToolbarTab.bind(this,"file"),"file:close":this.clickToolbarTab.bind(this,"other"),"save:disabled":this.changeToolbarSaveState.bind(this)},SearchDialog:{hide:_.bind(this.onSearchDlgHide,this),"search:back":_.bind(this.onQuerySearch,this,"back"),"search:next":_.bind(this.onQuerySearch,this,"next"),"search:replace":_.bind(this.onQueryReplace,this),"search:replaceall":_.bind(this.onQueryReplaceAll,this),"search:highlight":_.bind(this.onSearchHighlight,this)},"Common.Views.ReviewChanges":{"collaboration:chat":_.bind(this.onShowHideChat,this)}}),Common.NotificationCenter.on("leftmenu:change",_.bind(this.onMenuChange,this)),Common.NotificationCenter.on("app:comment:add",_.bind(this.onAppAddComment,this)),Common.NotificationCenter.on("collaboration:history",_.bind(function(){this.leftMenu.panelHistory.isVisible()||this.clickMenuFileItem(null,"history")},this))},onLaunch:function(){this.leftMenu=this.createView("LeftMenu").render(),this.leftMenu.btnSearch.on("toggle",_.bind(this.onMenuSearch,this)),Common.util.Shortcuts.delegateShortcuts({shortcuts:{"command+shift+s,ctrl+shift+s":_.bind(this.onShortcut,this,"save"),"command+f,ctrl+f":_.bind(this.onShortcut,this,"search"),"ctrl+h":_.bind(this.onShortcut,this,"replace"),"alt+f":_.bind(this.onShortcut,this,"file"),esc:_.bind(this.onShortcut,this,"escape"),"alt+q":_.bind(this.onShortcut,this,"chat"),"command+shift+h,ctrl+shift+h":_.bind(this.onShortcut,this,"comments"),f1:_.bind(this.onShortcut,this,"help")}}),Common.util.Shortcuts.suspendEvents()},setApi:function(t){if(this.api=t,this.api.asc_registerCallback("asc_onReplaceAll",_.bind(this.onApiTextReplaced,this)),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onApiServerDisconnect,this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onApiServerDisconnect,this)),this.api.asc_registerCallback("asc_onDownloadUrl",_.bind(this.onDownloadUrl,this)),this.mode.canCoAuthoring&&(this.mode.canChat&&this.api.asc_registerCallback("asc_onCoAuthoringChatReceiveMessage",_.bind(this.onApiChatMessage,this)),this.mode.canComments)){this.api.asc_registerCallback("asc_onAddComment",_.bind(this.onApiAddComment,this)),this.api.asc_registerCallback("asc_onAddComments",_.bind(this.onApiAddComments,this));for(var e=this.getApplication().getCollection("Common.Collections.Comments"),i=Common.Utils.InternalSettings.get("de-settings-resolvedcomment"),n=0;n0&&(i=i.substring(0,n)+this.isFromFileDownloadAs)}e.mode.canRequestSaveAs?Common.Gateway.requestSaveAs(t,i):(e._saveCopyDlg=new Common.Views.SaveAsDlg({saveFolderUrl:e.mode.saveAsUrl,saveFileUrl:t,defFileName:i}),e._saveCopyDlg.on("saveaserror",function(t,i){var n={closable:!1,title:e.notcriticalErrorTitle,msg:i,iconCls:"warn",buttons:["ok"],callback:function(t){Common.NotificationCenter.trigger("edit:complete",e)}};Common.UI.alert(n)}).on("close",function(t){e._saveCopyDlg=void 0}),e._saveCopyDlg.show())}this.isFromFileDownloadAs=!1},applySettings:function(t){var e;if(e=Common.localStorage.getBool("de-settings-inputmode"),Common.Utils.InternalSettings.set("de-settings-inputmode",e),this.api.SetTextBoxInputMode(e),this.mode.isEdit&&!this.mode.isOffline&&this.mode.canCoAuthoring){var i=Common.localStorage.getBool("de-settings-coauthmode",!0);switch(Common.Utils.InternalSettings.set("de-settings-coauthmode",i),this.api.asc_SetFastCollaborative(i),e=Common.localStorage.getItem(i?"de-settings-showchanges-fast":"de-settings-showchanges-strict"),Common.Utils.InternalSettings.set(i?"de-settings-showchanges-fast":"de-settings-showchanges-strict",e),e){case"all":e=Asc.c_oAscCollaborativeMarksShowType.All;break;case"none":e=Asc.c_oAscCollaborativeMarksShowType.None;break;case"last":e=Asc.c_oAscCollaborativeMarksShowType.LastChanges;break;default:e=i?Asc.c_oAscCollaborativeMarksShowType.None:Asc.c_oAscCollaborativeMarksShowType.LastChanges}this.api.SetCollaborativeMarksShowType(e)}e=Common.localStorage.getBool("de-settings-livecomment",!0),Common.Utils.InternalSettings.set("de-settings-livecomment",e);var n=Common.localStorage.getBool("de-settings-resolvedcomment");switch(Common.Utils.InternalSettings.set("de-settings-resolvedcomment",n),this.mode.canViewComments&&this.leftMenu.panelComments.isVisible()&&(e=n=!0),e?this.api.asc_showComments(n):this.api.asc_hideComments(),this.getApplication().getController("Common.Controllers.ReviewChanges").commentsShowHide(e?"show":"hide"),e=Common.localStorage.getBool("de-settings-cachemode",!0),Common.Utils.InternalSettings.set("de-settings-cachemode",e),this.api.asc_setDefaultBlitMode(e),e=Common.localStorage.getItem("de-settings-fontrender"),Common.Utils.InternalSettings.set("de-settings-fontrender",e),e){case"1":this.api.SetFontRenderingMode(1);break;case"2":this.api.SetFontRenderingMode(2);break;case"0":this.api.SetFontRenderingMode(3)}this.mode.isEdit&&(e=parseInt(Common.localStorage.getItem("de-settings-autosave")),Common.Utils.InternalSettings.set("de-settings-autosave",e),this.api.asc_setAutoSaveGap(e),e=Common.localStorage.getBool("de-settings-spellcheck",!0),Common.Utils.InternalSettings.set("de-settings-spellcheck",e),this.api.asc_setSpellCheck(e),e=parseInt(Common.localStorage.getItem("de-settings-paste-button")),Common.Utils.InternalSettings.set("de-settings-paste-button",e),this.api.asc_setVisiblePasteButton(!!e)),this.api.put_ShowSnapLines(Common.Utils.InternalSettings.get("de-settings-showsnaplines")),t.hide()},onCreateNew:function(t,e){if(!Common.Controllers.Desktop.process("create:new"))if(this.mode.canRequestCreateNew)Common.Gateway.requestCreateNew();else{var i=window.open("blank"==e?this.mode.createUrl:e,"_blank");i&&i.focus()}t&&t.hide()},onOpenRecent:function(t,e){t&&t.hide();var i=window.open(e);i&&i.focus(),Common.component.Analytics.trackEvent("Open Recent")},clickToolbarSettings:function(t){this.leftMenu.showMenu("file:opts")},clickToolbarTab:function(t,e){"file"==t?this.leftMenu.showMenu("file"):this.leftMenu.menuFile.hide()},changeToolbarSaveState:function(t){var e=this.leftMenu.menuFile.getButton("save");e&&e.setDisabled(t)},onHideChat:function(){$(this.leftMenu.btnChat.el).blur(),Common.NotificationCenter.trigger("layout:changed","leftmenu")},onHidePlugins:function(){Common.NotificationCenter.trigger("layout:changed","leftmenu")},onQuerySearch:function(t,e,i){if(i.textsearch&&i.textsearch.length&&!this.api.asc_findText(i.textsearch,"back"!=t,i.matchcase,i.matchword)){var n=this;Common.UI.info({msg:this.textNoTextFound,callback:function(){n.dlgSearch.focus()}})}},onQueryReplace:function(t,e){if(!_.isEmpty(e.textsearch)&&!this.api.asc_replaceText(e.textsearch,e.textreplace,!1,e.matchcase,e.matchword)){var i=this;Common.UI.info({msg:this.textNoTextFound,callback:function(){i.dlgSearch.focus()}})}},onQueryReplaceAll:function(t,e){_.isEmpty(e.textsearch)||this.api.asc_replaceText(e.textsearch,e.textreplace,!0,e.matchcase,e.matchword)},onSearchHighlight:function(t,e){this.api.asc_selectSearchingResults(e)},showSearchDlg:function(t,e){if(this.dlgSearch||(this.dlgSearch=new Common.UI.SearchDialog({matchcase:!0,markresult:{applied:!0}})),t){var i=this.mode.isEdit&&!this.viewmode?e||void 0:"no-replace";this.dlgSearch.isVisible()?(this.dlgSearch.setMode(i),this.dlgSearch.setSearchText(this.api.asc_GetSelectedText()),this.dlgSearch.focus()):this.dlgSearch.show(i,this.api.asc_GetSelectedText())}else this.dlgSearch.hide()},onMenuSearch:function(t,e){this.showSearchDlg(e)},onSearchDlgHide:function(){this.leftMenu.btnSearch.toggle(!1,!0),this.api.asc_selectSearchingResults(!1),$(this.leftMenu.btnSearch.el).blur(),this.api.asc_enableKeyEvents(!0)},onApiTextReplaced:function(t,e){t?t-e>0?Common.UI.warning({msg:Common.Utils.String.format(this.textReplaceSkipped,t-e)}):Common.UI.info({msg:Common.Utils.String.format(this.textReplaceSuccess,e)}):Common.UI.info({msg:this.textNoTextFound})},onApiServerDisconnect:function(t){this.mode.isEdit=!1,this.leftMenu.close(),this.leftMenu.btnComments.setDisabled(!0),this.leftMenu.btnChat.setDisabled(!0),this.leftMenu.btnPlugins.setDisabled(!0),this.leftMenu.btnNavigation.setDisabled(!0),this.leftMenu.getMenu("file").setMode({isDisconnected:!0,enableDownload:!!t}),this.dlgSearch&&(this.leftMenu.btnSearch.toggle(!1,!0),this.dlgSearch.hide())},setPreviewMode:function(t){this.viewmode!==t&&(this.viewmode=t,this.dlgSearch&&this.dlgSearch.setMode(this.viewmode?"no-replace":"search"))},SetDisabled:function(t,e){this.mode.isEdit=!t,t&&this.leftMenu.close(),this.leftMenu.btnComments.setDisabled(t);var i=this.getApplication().getController("Common.Controllers.Comments");i&&i.setPreviewMode(t),this.setPreviewMode(t),this.leftMenu.btnChat.setDisabled(t),this.leftMenu.btnPlugins.setDisabled(t),this.leftMenu.btnNavigation.setDisabled(t),e&&this.leftMenu.getMenu("file").SetDisabled(t)},onApiChatMessage:function(){this.leftMenu.markCoauthOptions("chat")},onApiAddComment:function(t,e){var i=Common.Utils.InternalSettings.get("de-settings-resolvedcomment");!e||e.asc_getUserId()===this.mode.user.id||!i&&e.asc_getSolved()||this.leftMenu.markCoauthOptions("comments")},onApiAddComments:function(t){for(var e=Common.Utils.InternalSettings.get("de-settings-resolvedcomment"),i=0;i [data-toggle="dropdown"]');if(n.length)return $.fn.dropdown.Constructor.prototype.keydown.call(n[0],e),!1;if(this.mode.canPlugins&&this.leftMenu.panelPlugins&&(n=this.leftMenu.panelPlugins.$el.find('#menu-plugin-container.open > [data-toggle="dropdown"]'),n.length))return $.fn.dropdown.Constructor.prototype.keydown.call(n[0],e),!1;if(this.leftMenu.btnAbout.pressed||this.leftMenu.btnPlugins.pressed||$(e.target).parents("#left-menu").length)return this.leftMenu.close(),Common.NotificationCenter.trigger("layout:changed","leftmenu"),!1;break;case"chat":return this.mode.canCoAuthoring&&this.mode.canChat&&!this.mode.isLightVersion&&(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("chat")),!1;case"comments":return this.mode.canCoAuthoring&&this.mode.canViewComments&&!this.mode.isLightVersion&&(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("comments"),this.getApplication().getController("Common.Controllers.Comments").onAfterShow()),!1}},onPluginOpen:function(t,e,i){"onboard"==e&&("open"==i?(this.leftMenu.close(),this.leftMenu.panelPlugins.show(),this.leftMenu.onBtnMenuClick({pressed:!0,options:{action:"plugins"}}),this.leftMenu._state.pluginIsRunning=!0):(this.leftMenu._state.pluginIsRunning=!1,this.leftMenu.close()))},showHistory:function(){var t=DE.getController("Main");t.loadMask||(t.loadMask=new Common.UI.LoadMask({owner:$("#viewport")})),t.loadMask.setTitle(this.textLoadHistory),t.loadMask.show(),Common.Gateway.requestHistory()},onShowHideChat:function(t){this.mode.canCoAuthoring&&this.mode.canChat&&!this.mode.isLightVersion&&(t?(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("chat")):(this.leftMenu.btnChat.toggle(!1,!0),this.leftMenu.onBtnMenuClick(this.leftMenu.btnChat)))},textNoTextFound:"Text not found",newDocumentTitle:"Unnamed document",requestEditRightsText:"Requesting editing rights...",textReplaceSuccess:"Search has been done. {0} occurrences have been replaced",textReplaceSkipped:"The replacement has been made. {0} occurrences were skipped.",textLoadHistory:"Loading version history...",notcriticalErrorTitle:"Warning",leavePageText:"All unsaved changes in this document will be lost.
    Click 'Cancel' then 'Save' to save them. Click 'OK' to discard all the unsaved changes.",warnDownloadAs:"If you continue saving in this format all features except the text will be lost.
    Are you sure you want to continue?",warnDownloadAsRTF:"If you continue saving in this format some of the formatting might be lost.
    Are you sure you want to continue?",txtUntitled:"Untitled",txtCompatible:"The document will be saved to the new format. It will allow to use all the editor features, but might affect the document layout.
    Use the 'Compatibility' option of the advanced settings if you want to make the files compatible with older MS Word versions."},DE.Controllers.LeftMenu||{}))}),void 0===Common)var Common={};if(Common.IrregularStack=function(t){var e=[],i=function(t,e){return"object"==typeof t&&"object"==typeof e&&window.JSON?window.JSON.stringify(t)===window.JSON.stringify(e):t===e};t=t||{};var n=t.strongCompare||i,o=t.weakCompare||i,s=function(t,i){for(var n=e.length-1;n>=0;n--)if(i(e[n],t))return n;return-1};return{push:function(t){e.push(t)},pop:function(t){var i=s(t,n);if(-1!=i)return e.splice(i,1)[0]},get:function(t){var i=s(t,o);if(-1!=i)return e[i]},exist:function(t){return!(s(t,n)<0)}}},define("irregularstack",function(){}),void 0===Common)var Common={};if(Common.Controllers=Common.Controllers||{},define("common/main/lib/controller/Fonts",["core","common/main/lib/collection/Fonts"],function(){"use strict";Common.Controllers.Fonts=Backbone.Controller.extend(function(){function t(t,e){for(var i,n=e.get("type")==o,s=-1,a=t.length,r=e.get("name");!n&&++s','
    ',"<% if (type == Common.Utils.importTextType.DRM) { %>","<% if (warning) { %>","
    ",'
    ','
    '+("string"==typeof o.warningMsg?o.warningMsg:n.txtProtected)+"
    ",'",'
    ',"
    ","<% } else { %>","
    ",'",'
    ',"
    ","<% } %>","<% } else { %>","<% if (codepages && codepages.length>0) { %>",'
    ','","
    ",'
    ',"
    ","
    ","<% } %>","<% if (type == Common.Utils.importTextType.CSV) { %>",'
    ','","
    ",'
    ','
    ',"
    ","
    ","<% } %>","<% if (type == Common.Utils.importTextType.Paste || type == Common.Utils.importTextType.Columns) { %>",'
    ','","
    ",'
    ','
    ','","
    ","
    ","<% } %>","<% if (!!preview) { %>",'
    ','",'
    ','
    ','
    ',"
    ",'
    ',"
    ","
    ","
    ","
    ","
    ","<% } %>","<% } %>","
    ","
    ",'"].join(""),this.handler=o.handler,this.type=o.type,this.preview=o.preview,this.previewData=o.previewData,this.warning=o.warning||!1,this.closable=o.closable,this.codepages=o.codepages,this.settings=o.settings,this.api=o.api,this.validatePwd=o.validatePwd||!1,o.tpl=_.template(this.template)(o),Common.UI.Window.prototype.initialize.call(this,o)},render:function(){if(Common.UI.Window.prototype.render.call(this),this.$window){var t=this;this.closable||this.$window.find(".tool").hide(),this.$window.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.previewPanel=this.$window.find("#id-preview-data"),this.previewParent=this.previewPanel.parent(),this.previewScrolled=this.$window.find("#id-preview"),this.previewInner=this.previewScrolled.find("div:first-child"),this.type==Common.Utils.importTextType.DRM?(this.inputPwd=new Common.UI.InputField({el:$("#id-password-txt"),type:"text",validateOnBlur:!1,validation:function(e){return t.txtIncorrectPwd}}),this.$window.find("input").on("input",function(){""!==$(this).val()?"password"!==$(this).attr("type")&&$(this).attr("type","password"):$(this).attr("type","text")})):(this.initCodePages(),this.preview&&(this.previewData?this.previewCallback(this.previewData):this.updatePreview())),this.onPrimary=function(){return t._handleInput("ok"),!1}}},show:function(){if(Common.UI.Window.prototype.show.apply(this,arguments),this.type==Common.Utils.importTextType.DRM){var t=this;setTimeout(function(){t.inputPwd.cmpEl.find("input").focus(),t.validatePwd&&t.inputPwd.checkValidate()},500)}},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onToolClose:function(){this._handleInput("cancel")},_handleInput:function(t){if(this.handler)if(this.type==Common.Utils.importTextType.DRM)this.handler.call(this,t,this.inputPwd.getValue());else{var e=this.cmbEncoding&&!this.cmbEncoding.isDisabled()?this.cmbEncoding.getValue():this.settings&&this.settings.asc_getCodePage()?this.settings.asc_getCodePage():0,i=this.cmbDelimiter?this.cmbDelimiter.getValue():null,n=-1==i?this.inputDelimiter.getValue():null;-1==i&&(i=null),this.closable||this.type!=Common.Utils.importTextType.TXT||Common.localStorage.setItem("de-settings-open-encoding",e);var o=this.separatorOptions?this.separatorOptions.decimal:void 0,s=this.separatorOptions?this.separatorOptions.thousands:void 0;this.handler.call(this,t,e,i,n,o,s)}this.close()},initCodePages:function(){var t,e,i,n=[],o=[],s=0,a=0;if(this.codepages){for(n=[],t=0;t",'
  • ','
    <%= item.displayValue %>
    ','',"
  • ","<% }); %>"].join(""));this.cmbEncoding=new Common.UI.ComboBox({el:$("#id-codepages-combo",this.$window),style:"width: 100%;",menuStyle:"min-width: 100%; max-height: 200px;",cls:"input-group-nr",menuCls:"scrollable-menu",data:o,editable:!1,disabled:!0,search:!0,itemsTemplate:r}),this.cmbEncoding.setDisabled(!1);var l=this.settings&&this.settings.asc_getCodePage()?this.settings.asc_getCodePage():n[0][0];if(!this.closable&&this.type==Common.Utils.importTextType.TXT){var c=Common.localStorage.getItem("de-settings-open-encoding");c&&(l=parseInt(c))}this.cmbEncoding.setValue(l),this.preview&&this.cmbEncoding.on("selected",_.bind(this.onCmbEncodingSelect,this));var d=this.cmbEncoding.cmpEl.find("ul"),h=d.find("li:nth(0) a"),p=d.width()-parseInt(h.css("padding-left"))-parseInt(h.css("padding-right"))-50;d.find("li div").width(p)}this.type!=Common.Utils.importTextType.CSV&&this.type!=Common.Utils.importTextType.Paste&&this.type!=Common.Utils.importTextType.Columns||(this.cmbDelimiter=new Common.UI.ComboBox({el:$("#id-delimiters-combo",this.$window),style:"width: 100px;",menuStyle:"min-width: 100px;",cls:"input-group-nr",data:[{value:4,displayValue:this.txtComma},{value:2,displayValue:this.txtSemicolon},{value:3,displayValue:this.txtColon},{value:1,displayValue:this.txtTab},{value:5,displayValue:this.txtSpace},{value:-1,displayValue:this.txtOther}],editable:!1}),this.cmbDelimiter.setValue(this.settings&&this.settings.asc_getDelimiter()?this.settings.asc_getDelimiter():4),this.cmbDelimiter.on("selected",_.bind(this.onCmbDelimiterSelect,this)),this.inputDelimiter=new Common.UI.InputField({el:$("#id-delimiter-other"),style:"width: 30px;",maxLength:1,validateOnChange:!0,validateOnBlur:!1,value:this.settings&&this.settings.asc_getDelimiterChar()?this.settings.asc_getDelimiterChar():""}),this.inputDelimiter.setVisible(!1),this.preview&&this.inputDelimiter.on("changing",_.bind(this.updatePreview,this)),this.type!=Common.Utils.importTextType.Paste&&this.type!=Common.Utils.importTextType.Columns||(this.btnAdvanced=new Common.UI.Button({el:$("#id-delimiters-advanced")}),this.btnAdvanced.on("click",_.bind(this.onAdvancedClick,this))))},updatePreview:function(){var t=this.cmbEncoding&&!this.cmbEncoding.isDisabled()?this.cmbEncoding.getValue():this.settings&&this.settings.asc_getCodePage()?this.settings.asc_getCodePage():0,e=this.cmbDelimiter?this.cmbDelimiter.getValue():null,i=-1==e?this.inputDelimiter.getValue():null;switch(-1==e&&(e=null),this.type){case Common.Utils.importTextType.CSV:this.api.asc_decodeBuffer(this.preview,new Asc.asc_CTextOptions(t,e,i),_.bind(this.previewCallback,this));break;case Common.Utils.importTextType.TXT:this.api.asc_decodeBuffer(this.preview,new Asc.asc_CTextOptions(t),_.bind(this.previewCallback,this));break;case Common.Utils.importTextType.Paste:case Common.Utils.importTextType.Columns:var n=new Asc.asc_CTextOptions(t,e,i);this.separatorOptions&&(n.asc_setNumberDecimalSeparator(this.separatorOptions.decimal),n.asc_setNumberGroupSeparator(this.separatorOptions.thousands)),this.api.asc_TextImport(n,_.bind(this.previewCallback,this),this.type==Common.Utils.importTextType.Paste)}},previewCallback:function(t){t&&t.length&&(this.data=t,this.previewInner.height(17*t.length),this.scrollerY||(this.scrollerY=new Common.UI.Scroller({el:this.previewScrolled,minScrollbarLength:20,alwaysVisibleY:!0,alwaysVisibleX:!0,onChange:_.bind(function(){if(this.scrollerY){var t=this.scrollerY.getScrollTop(),e=Math.floor(t/17+.5),i=e+Math.min(6,this.data.length);i>this.data.length&&(i=this.data.length,e=this.data.length-6,t=17*e),this.previewParent.height(108),this.previewParent.css({top:t}),this.previewDataBlock(this.data.slice(e,i))}},this)})),this.scrollerY.update(),this.scrollerY.scrollTop(0))},previewDataBlock:function(t){if(_.isUndefined(this.scrollerX)||(this.scrollerX.destroy(),delete this.scrollerX),this.type==Common.Utils.importTextType.CSV||this.type==Common.Utils.importTextType.Paste||this.type==Common.Utils.importTextType.Columns){for(var e=0,i=0;ie&&(e=t[i].length);for(var n="",i=0;i';for(var o=0;o"+Common.Utils.String.htmlEncode(t[i][o])+"";for(o=t[i].length;o";n+=""}n+="
    "}else{for(var n="",i=0;i";n+="
    '+Common.Utils.String.htmlEncode(t[i])+"
    "}this.previewPanel.html(n),this.scrollerX=new Common.UI.Scroller({el:this.previewPanel,suppressScrollY:!0,alwaysVisibleX:!0,minScrollbarLength:20})},onCmbDelimiterSelect:function(t,e){this.inputDelimiter.setVisible(-1==e.value),-1==e.value&&this.inputDelimiter.cmpEl.find("input").focus(),this.preview&&this.updatePreview()},onCmbEncodingSelect:function(t,e){this.updatePreview()},onAdvancedClick:function(){if(SSE){var t=this,e=this.api.asc_getDecimalSeparator(),i=this.api.asc_getGroupSeparator();new SSE.Views.AdvancedSeparatorDialog({props:{decimal:e,thousands:i},handler:function(n,o){"ok"==n&&(t.separatorOptions={decimal:o.decimal.length>0?o.decimal:e,thousands:o.thousands.length>0?o.thousands:i})}}).show()}},txtDelimiter:"Delimiter",txtEncoding:"Encoding ",txtSpace:"Space",txtTab:"Tab",txtTitle:"Choose %1 options",txtPassword:"Password",txtTitleProtected:"Protected File",txtOther:"Other",txtIncorrectPwd:"Password is incorrect.",closeButtonText:"Close File",txtPreview:"Preview",txtComma:"Comma",txtColon:"Colon",txtSemicolon:"Semicolon",txtProtected:"Once you enter the password and open the file, the current password to the file will be reset.",txtAdvanced:"Advanced",txtOpenFile:"Enter a password to open the file"},Common.Views.OpenDialog||{}))}),define("common/main/lib/util/LocalStorage",["gateway"],function(){Common.localStorage=new function(){var t,e,i={},n=function(t){"localstorage"==t.type&&(i=t.keys)};Common.Gateway.on("internalcommand",n);var o=function(){h||Common.Gateway.internalMessage("localstorage",{cmd:"get",keys:e})},s=function(){h||Common.Gateway.internalMessage("localstorage",{cmd:"set",keys:i})},a=function(t,e,n){if(h)try{localStorage.setItem(t,e)}catch(t){}else i[t]=e,!0===n&&Common.Gateway.internalMessage("localstorage",{cmd:"set",keys:{name:e}})},r=function(t,e,i){a(t,e?1:0,i)},l=function(t){return h?localStorage.getItem(t):void 0===i[t]?null:i[t]},c=function(t,e){var i=l(t);return e=e||!1,null!==i?0!=parseInt(i):e},d=function(t){return null!==l(t)};try{var h=!!window.localStorage}catch(t){h=!1}return{getId:function(){return t},setId:function(e){t=e},getItem:l,getBool:c,setBool:r,setItem:a,setKeysFilter:function(t){e=t},getKeysFilter:function(){return e},itemExists:d,sync:o,save:s}}}),define("documenteditor/main/app/model/ShapeGroup",["backbone"],function(t){"use strict";DE.Models=DE.Models||{},DE.Models.ShapeModel=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),imageUrl:null,data:null}}}),DE.Models.ShapeGroup=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),groupName:null,groupId:null,groupStore:null}}})}),define("documenteditor/main/app/collection/ShapeGroups",["backbone","documenteditor/main/app/model/ShapeGroup"],function(t){"use strict";if(void 0===e)var e={};e.Collections=e.Collections||{},DE.Collections=DE.Collections||{},DE.Collections.ShapeGroups=t.Collection.extend({model:DE.Models.ShapeGroup})}),define("documenteditor/main/app/model/EquationGroup",["backbone"],function(t){"use strict";DE.Models=DE.Models||{},DE.Models.EquationModel=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),data:null,width:0,height:0,posX:0,posY:0}}}),DE.Models.EquationGroup=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),groupName:null,groupId:null,groupStore:null}}})}),define("documenteditor/main/app/collection/EquationGroups",["backbone","documenteditor/main/app/model/EquationGroup"],function(t){"use strict";DE.Collections=DE.Collections||{},DE.Collections.EquationGroups=t.Collection.extend({model:DE.Models.EquationGroup})}),define("documenteditor/main/app/controller/Main",["core","irregularstack","common/main/lib/component/Window","common/main/lib/component/LoadMask","common/main/lib/component/Tooltip","common/main/lib/controller/Fonts","common/main/lib/collection/TextArt","common/main/lib/view/OpenDialog","common/main/lib/util/LocalStorage","documenteditor/main/app/collection/ShapeGroups","documenteditor/main/app/collection/EquationGroups"],function(){"use strict";DE.Controllers.Main=Backbone.Controller.extend(_.extend(function(){var appHeader,ApplyEditRights=-255,LoadingDocument=-256,mapCustomizationElements={about:"button#left-btn-about",feedback:"button#left-btn-support",goback:"#fm-btn-back > a, #header-back > div"},mapCustomizationExtElements={toolbar:"#viewport #toolbar",leftMenu:"#viewport #left-menu, #viewport #id-toolbar-full-placeholder-btn-settings, #viewport #id-toolbar-short-placeholder-btn-settings",rightMenu:"#viewport #right-menu",statusBar:"#statusbar"};return Common.localStorage.setId("text"),Common.localStorage.setKeysFilter("de-,asc.text"),Common.localStorage.sync(),{models:[],collections:["ShapeGroups","EquationGroups","Common.Collections.HistoryUsers","Common.Collections.TextArt"],views:[],initialize:function(){this.addListeners({FileMenu:{"settings:apply":_.bind(this.applySettings,this)},"Common.Views.ReviewChanges":{"settings:apply":_.bind(this.applySettings,this)}});var t=this,e=["Normal","No Spacing","Heading 1","Heading 2","Heading 3","Heading 4","Heading 5","Heading 6","Heading 7","Heading 8","Heading 9","Title","Subtitle","Quote","Intense Quote","List Paragraph","footnote text","Caption"],i={Series:this.txtSeries,"Diagram Title":this.txtDiagramTitle,"X Axis":this.txtXAxis,"Y Axis":this.txtYAxis,"Your text here":this.txtArt,"Error! Bookmark not defined.":this.txtBookmarkError,above:this.txtAbove,below:this.txtBelow,"on page ":this.txtOnPage+" ",Header:this.txtHeader,Footer:this.txtFooter," -Section ":" "+this.txtSection+" ","First Page ":this.txtFirstPage+" ","Even Page ":this.txtEvenPage+" ","Odd Page ":this.txtOddPage+" ","Same as Previous":this.txtSameAsPrev,"Current Document":this.txtCurrentDocument,"No table of contents entries found.":this.txtNoTableOfContents,"Table of Contents":this.txtTableOfContents,"Syntax Error":this.txtSyntaxError,"Missing Operator":this.txtMissOperator,"Missing Argument":this.txtMissArg,"Number Too Large To Format":this.txtTooLarge,"Zero Divide":this.txtZeroDivide,"Is Not In Table":this.txtNotInTable,"Index Too Large":this.txtIndTooLarge,"The Formula Not In Table":this.txtFormulaNotInTable,"Table Index Cannot be Zero":this.txtTableInd,"Undefined Bookmark":this.txtUndefBookmark,"Unexpected End of Formula":this.txtEndOfFormula,Hyperlink:this.txtHyperlink,"Error! Main Document Only.":this.txtMainDocOnly,"Error! Not a valid bookmark self-reference.":this.txtNotValidBookmark,"Error! No text of specified style in document.":this.txtNoText,"Choose an item.":this.txtChoose,"Enter a date.":this.txtEnterDate,"Type equation here.":this.txtTypeEquation};e.forEach(function(e){i[e]=t["txtStyle_"+e.replace(/ /g,"_")]||e}),t.translationTable=i},onLaunch:function(){var t=this;if(this.stackLongActions=new Common.IrregularStack({strongCompare:function(t,e){return t.id===e.id&&t.type===e.type},weakCompare:function(t,e){return t.type===e.type}}),this._state={isDisconnected:!1,usersCount:1,fastCoauth:!0,lostEditingRights:!1,licenseType:!1},this.languages=null,!Common.Utils.isBrowserSupported())return Common.Utils.showBrowserRestriction(),void Common.Gateway.reportError(void 0,this.unsupportedBrowserErrorText);if(window.flat_desine=!0,this.api=this.getApplication().getController("Viewport").getApi(),Common.UI.FocusManager.init(),this.api){this.api.SetDrawingFreeze(!0);var e=Common.localStorage.getBool("de-settings-cachemode",!0);switch(Common.Utils.InternalSettings.set("de-settings-cachemode",e),this.api.asc_setDefaultBlitMode(!!e),e=Common.localStorage.getItem("de-settings-fontrender"),null===e&&(e="0"),Common.Utils.InternalSettings.set("de-settings-fontrender",e),e){case"0":this.api.SetFontRenderingMode(3);break;case"1":this.api.SetFontRenderingMode(1);break;case"2":this.api.SetFontRenderingMode(2)}this.api.asc_registerCallback("asc_onError",_.bind(this.onError,this)),this.api.asc_registerCallback("asc_onDocumentContentReady",_.bind(this.onDocumentContentReady,this)),this.api.asc_registerCallback("asc_onOpenDocumentProgress",_.bind(this.onOpenDocument,this)),this.api.asc_registerCallback("asc_onDocumentUpdateVersion",_.bind(this.onUpdateVersion,this)),this.api.asc_registerCallback("asc_onServerVersion",_.bind(this.onServerVersion,this)),this.api.asc_registerCallback("asc_onAdvancedOptions",_.bind(this.onAdvancedOptions,this)),this.api.asc_registerCallback("asc_onDocumentName",_.bind(this.onDocumentName,this)),this.api.asc_registerCallback("asc_onPrintUrl",_.bind(this.onPrintUrl,this)),this.api.asc_registerCallback("asc_onMeta",_.bind(this.onMeta,this)),this.api.asc_registerCallback("asc_onSpellCheckInit",_.bind(this.loadLanguages,this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this)),Common.NotificationCenter.on("goback",_.bind(this.goBack,this)),Common.NotificationCenter.on("download:advanced",_.bind(this.onAdvancedOptions,this)),Common.NotificationCenter.on("showmessage",_.bind(this.onExternalMessage,this)),this.isShowOpenDialog=!1,this.editorConfig={},this.appOptions={},Common.Gateway.on("init",_.bind(this.loadConfig,this)),Common.Gateway.on("showmessage",_.bind(this.onExternalMessage,this)),Common.Gateway.on("opendocument",_.bind(this.loadDocument,this)),Common.Gateway.appReady(),this.getApplication().getController("Viewport").setApi(this.api),this.getApplication().getController("Statusbar").setApi(this.api),this.contComments=this.getApplication().getController("Common.Controllers.Comments"),$(document.body).on("focus","input, textarea",function(e){/area_id/.test(e.target.id)||(/msg-reply/.test(e.target.className)?(t.dontCloseDummyComment=!0,t.beforeShowDummyComment=t.beforeCloseDummyComment=!1):/textarea-control/.test(e.target.className)?t.inTextareaControl=!0:!Common.Utils.ModalWindow.isVisible()&&/form-control/.test(e.target.className)&&(t.inFormControl=!0))}),$(document.body).on("blur","input, textarea",function(e){if(!Common.Utils.ModalWindow.isVisible()){if(/form-control/.test(e.target.className)&&(t.inFormControl=!1),t.getApplication().getController("LeftMenu").getView("LeftMenu").getMenu("file").isVisible())return;if(!e.relatedTarget||!/area_id/.test(e.target.id)&&!("input"==e.target.localName&&$(e.target).parent().find(e.relatedTarget).length>0)&&!("textarea"==e.target.localName&&$(e.target).closest(".asc-window").find(".dropdown-menu").find(e.relatedTarget).length>0)&&("input"!=e.relatedTarget.localName||!/form-control/.test(e.relatedTarget.className))&&("textarea"!=e.relatedTarget.localName||/area_id/.test(e.relatedTarget.id))){if(Common.Utils.isIE&&e.originalEvent&&e.originalEvent.target&&/area_id/.test(e.originalEvent.target.id)&&e.originalEvent.target===e.originalEvent.srcElement)return;t.api.asc_enableKeyEvents(!0),t.dontCloseDummyComment&&/msg-reply/.test(e.target.className)?$(e.target).closest(".user-comment-item").find(e.relatedTarget).length<1?t.dontCloseDummyComment=t.beforeCloseDummyComment=!1:t.beforeCloseDummyComment=!0:/textarea-control/.test(e.target.className)&&(t.inTextareaControl=!1)}}}).on("dragover",function(t){var e=t.originalEvent;if(e.target&&$(e.target).closest("#editor_sdk").length<1)return e.preventDefault(),e.dataTransfer.dropEffect="none",!1}).on("dragstart",function(t){var e=t.originalEvent;if(e.target){var i=$(e.target);(i.closest(".combobox").length>0||i.closest(".dropdown-menu").length>0||i.closest(".ribtab").length>0||i.closest(".combo-dataview").length>0)&&e.preventDefault()}}).on("mouseup",function(e){t.beforeCloseDummyComment&&setTimeout(function(){t.dontCloseDummyComment=t.beforeCloseDummyComment=!1},10)}),Common.NotificationCenter.on({"modal:show":function(){Common.Utils.ModalWindow.show(),t.api.asc_enableKeyEvents(!1)},"modal:close":function(e){Common.Utils.ModalWindow.close(),Common.Utils.ModalWindow.isVisible()||t.api.asc_enableKeyEvents(!0)},"modal:hide":function(e){Common.Utils.ModalWindow.close(),Common.Utils.ModalWindow.isVisible()||t.api.asc_enableKeyEvents(!0)},"settings:unitschanged":_.bind(this.unitsChanged,this),"dataview:focus":function(t){},"dataview:blur":function(e){Common.Utils.ModalWindow.isVisible()||t.api.asc_enableKeyEvents(!0)},"menu:show":function(t){},"menu:hide":function(e,i){Common.Utils.ModalWindow.isVisible()||i||t.api.asc_enableKeyEvents(!0)},"edit:complete":_.bind(t.onEditComplete,t)}),this.initNames(),Common.util.Shortcuts.delegateShortcuts({shortcuts:{"command+s,ctrl+s,command+p,ctrl+p,command+k,ctrl+k,command+d,ctrl+d":_.bind(function(t){t.preventDefault(),t.stopPropagation()},this)}})}t.defaultTitleText="ONLYOFFICE",t.warnNoLicense=t.warnNoLicense.replace(/%1/g,"ONLYOFFICE"),t.warnNoLicenseUsers=t.warnNoLicenseUsers.replace(/%1/g,"ONLYOFFICE"),t.textNoLicenseTitle=t.textNoLicenseTitle.replace(/%1/g,"ONLYOFFICE"),t.warnLicenseExceeded=t.warnLicenseExceeded.replace(/%1/g,"ONLYOFFICE"),t.warnLicenseUsersExceeded=t.warnLicenseUsersExceeded.replace(/%1/g,"ONLYOFFICE")},loadConfig:function(t){this.editorConfig=$.extend(this.editorConfig,t.config),this.editorConfig.user=this.appOptions.user=Common.Utils.fillUserInfo(this.editorConfig.user,this.editorConfig.lang,this.textAnonymous),this.appOptions.isDesktopApp="desktop"==this.editorConfig.targetApp,this.appOptions.canCreateNew=this.editorConfig.canRequestCreateNew||!_.isEmpty(this.editorConfig.createUrl),this.appOptions.canOpenRecent=void 0!==this.editorConfig.recent&&!this.appOptions.isDesktopApp,this.appOptions.templates=this.editorConfig.templates,this.appOptions.recent=this.editorConfig.recent,this.appOptions.createUrl=this.editorConfig.createUrl,this.appOptions.canRequestCreateNew=this.editorConfig.canRequestCreateNew,this.appOptions.lang=this.editorConfig.lang,this.appOptions.location="string"==typeof this.editorConfig.location?this.editorConfig.location.toLowerCase():"",this.appOptions.sharingSettingsUrl=this.editorConfig.sharingSettingsUrl,this.appOptions.fileChoiceUrl=this.editorConfig.fileChoiceUrl,this.appOptions.mergeFolderUrl=this.editorConfig.mergeFolderUrl,this.appOptions.saveAsUrl=this.editorConfig.saveAsUrl,this.appOptions.canAnalytics=!1,this.appOptions.canRequestClose=this.editorConfig.canRequestClose,this.appOptions.customization=this.editorConfig.customization,this.appOptions.canBackToFolder=!1!==this.editorConfig.canBackToFolder&&"object"==typeof this.editorConfig.customization&&"object"==typeof this.editorConfig.customization.goback&&(!_.isEmpty(this.editorConfig.customization.goback.url)||this.editorConfig.customization.goback.requestClose&&this.appOptions.canRequestClose),this.appOptions.canBack=!0===this.appOptions.canBackToFolder,this.appOptions.canPlugins=!1,this.appOptions.canMakeActionLink=this.editorConfig.canMakeActionLink,this.appOptions.canRequestUsers=this.editorConfig.canRequestUsers,this.appOptions.canRequestSendNotify=this.editorConfig.canRequestSendNotify,this.appOptions.canRequestSaveAs=this.editorConfig.canRequestSaveAs,this.appOptions.canRequestInsertImage=this.editorConfig.canRequestInsertImage,this.appOptions.canRequestCompareFile=this.editorConfig.canRequestCompareFile,this.appOptions.canRequestMailMergeRecipients=this.editorConfig.canRequestMailMergeRecipients,this.appOptions.canRequestSharingSettings=this.editorConfig.canRequestSharingSettings,this.appOptions.compatibleFeatures="object"==typeof this.appOptions.customization&&!!this.appOptions.customization.compatibleFeatures,this.appOptions.canFeatureComparison=!!this.api.asc_isSupportFeature("comparison"),this.appOptions.canFeatureContentControl=!!this.api.asc_isSupportFeature("content-controls"),this.appOptions.canFeatureForms=!1,this.appOptions.mentionShare=!("object"==typeof this.appOptions.customization&&0==this.appOptions.customization.mentionShare),appHeader=this.getApplication().getController("Viewport").getView("Common.Views.Header"),appHeader.setCanBack(!0===this.appOptions.canBackToFolder,this.appOptions.canBackToFolder?this.editorConfig.customization.goback.text:""),this.editorConfig.lang&&this.api.asc_setLocale(this.editorConfig.lang),"us"!=this.appOptions.location&&"ca"!=this.appOptions.location||Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch),this.editorConfig.customization&&(this.editorConfig.customization.toolbarNoTabs||"desktop"!==this.editorConfig.targetApp&&(this.editorConfig.customization.loaderName||this.editorConfig.customization.loaderLogo))||($("#editor-container").css("overflow","hidden"),$("#editor-container").append('
    '+'
    '.repeat(20)+"
    "));var e=Common.localStorage.getItem("de-macros-mode");null===e?(e=this.editorConfig.customization?this.editorConfig.customization.macrosMode:"warn",e="enable"==e?1:"disable"==e?2:0):e=parseInt(e),Common.Utils.InternalSettings.set("de-macros-mode",e),Common.Controllers.Desktop.init(this.appOptions)},loadDocument:function(t){this.permissions={},this.document=t.doc;var e={};if(t.doc){this.permissions=$.extend(this.permissions,t.doc.permissions);var i=$.extend({},t.doc.permissions),n=$.extend({},t.doc.options,this.editorConfig.actionLink||{}),o=new Asc.asc_CUserInfo;o.put_Id(this.appOptions.user.id),o.put_FullName(this.appOptions.user.fullname),e=new Asc.asc_CDocInfo,e.put_Id(t.doc.key),e.put_Url(t.doc.url),e.put_Title(t.doc.title),e.put_Format(t.doc.fileType),e.put_VKey(t.doc.vkey),e.put_Options(n),e.put_UserInfo(o),e.put_CallbackUrl(this.editorConfig.callbackUrl),e.put_Token(t.doc.token),e.put_Permissions(i),e.put_EncryptedInfo(this.editorConfig.encryptionKeys);var s=!this.editorConfig.customization||!1!==this.editorConfig.customization.macros;e.asc_putIsEnabledMacroses(!!s),s=!this.editorConfig.customization||!1!==this.editorConfig.customization.plugins,e.asc_putIsEnabledPlugins(!!s);var a=/^(?:(pdf|djvu|xps))$/.exec(t.doc.fileType);a&&"string"==typeof a[1]&&(this.permissions.edit=this.permissions.review=!1)}this.api.asc_registerCallback("asc_onGetEditorPermissions",_.bind(this.onEditorPermissions,this)),this.api.asc_registerCallback("asc_onLicenseChanged",_.bind(this.onLicenseChanged,this)),this.api.asc_registerCallback("asc_onRunAutostartMacroses",_.bind(this.onRunAutostartMacroses,this)),this.api.asc_setDocInfo(e),this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl,this.editorConfig.customerId),t.doc&&appHeader.setDocumentCaption(t.doc.title)},onProcessSaveResult:function(t){this.api.asc_OnSaveEnd(t.result),t&&!1===t.result&&Common.UI.error({title:this.criticalErrorTitle,msg:_.isEmpty(t.message)?this.errorProcessSaveResult:t.message})},onProcessRightsChange:function(t){if(t&&!1===t.enabled){var e=this,i=this._state.lostEditingRights;this._state.lostEditingRights=!this._state.lostEditingRights,this.api.asc_coAuthoringDisconnect(),Common.NotificationCenter.trigger("collaboration:sharingdeny"),Common.NotificationCenter.trigger("api:disconnect"),i||Common.UI.warning({title:this.notcriticalErrorTitle,maxwidth:600,msg:_.isEmpty(t.message)?this.warnProcessRightsChange:t.message,callback:function(){e._state.lostEditingRights=!1,e.onEditComplete()}})}},onDownloadAs:function(t){if(!this.appOptions.canDownload&&!this.appOptions.canDownloadOrigin)return void Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny,this.errorAccessDeny);this._state.isFromGatewayDownloadAs=!0;var e=/^(?:(pdf|djvu|xps))$/.exec(this.document.fileType);if(e&&"string"==typeof e[1])this.api.asc_DownloadOrigin(!0);else{var i=t&&"string"==typeof t?Asc.c_oAscFileType[t.toUpperCase()]:null,n=[Asc.c_oAscFileType.TXT,Asc.c_oAscFileType.ODT,Asc.c_oAscFileType.DOCX,Asc.c_oAscFileType.HTML,Asc.c_oAscFileType.PDF,Asc.c_oAscFileType.PDFA,Asc.c_oAscFileType.DOTX,Asc.c_oAscFileType.OTT];(!i||n.indexOf(i)<0)&&(i=Asc.c_oAscFileType.DOCX),this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(i,!0))}},onProcessMouse:function(t){if("mouseup"==t.type){var e=document.getElementById("editor_sdk");if(e){var i=e.getBoundingClientRect();this.api.OnMouseUp(t.x-i.left,t.y-i.top)}}},onRefreshHistory:function(t){if(this.appOptions.canUseHistory)if(this.loadMask&&this.loadMask.hide(),t.data.error||!t.data.history){var e=this.getApplication().getCollection("Common.Collections.HistoryVersions");e&&e.size()>0&&e.each(function(t){t.set("canRestore",!1)}),Common.UI.alert({title:this.notcriticalErrorTitle,msg:t.data.error?t.data.error:this.txtErrorLoadHistory,iconCls:"warn",buttons:["ok"],callback:_.bind(function(t){this.onEditComplete()},this)})}else{this.api.asc_coAuthoringDisconnect(),appHeader.setCanRename(!1),appHeader.getButton("users")&&appHeader.getButton("users").hide(),this.getApplication().getController("LeftMenu").getView("LeftMenu").showHistory(),this.disableEditing(!0);var i=t.data.history,e=this.getApplication().getCollection("Common.Collections.HistoryVersions"),n=null;if(e){var o,s,a=[],r=-1,l=-1,c=[],d="",h=this.getApplication().getCollection("Common.Collections.HistoryUsers"),p=null,m=0;for(o=i.length-1;o>=0;o--)if(s=i[o],void 0!==s.versionGroup&&null!==s.versionGroup||(s.versionGroup=s.version),s){if(s.user||(s.user={}),d=o>0&&i[o-1]?i[o-1].key:s.key+"0",p=h.findUser(s.user.id),p||(p=new Common.Models.User({id:s.user.id,username:s.user.name,colorval:Asc.c_oAscArrUserColors[m],color:this.generateUserColor(Asc.c_oAscArrUserColors[m++])}),h.add(p)),a.push(new Common.Models.HistoryVersion({version:s.versionGroup,revision:s.version,userid:s.user.id,username:s.user.name,usercolor:p.get("color"),created:s.created,docId:s.key, markedAsVersion:r!==s.versionGroup,selected:t.data.currentVersion==s.version,canRestore:this.appOptions.canHistoryRestore&&o0){if(a[a.length-1].set("docIdPrev",d),!_.isEmpty(s.serverVersion)&&s.serverVersion==this.appOptions.buildVersion)for(a[a.length-1].set("changeid",b.length-1),a[a.length-1].set("hasChanges",b.length>1),g=b.length-2;g>=0;g--)u=b[g],p=h.findUser(u.user.id),p||(p=new Common.Models.User({id:u.user.id,username:u.user.name,colorval:Asc.c_oAscArrUserColors[m],color:this.generateUserColor(Asc.c_oAscArrUserColors[m++])}),h.add(p)),a.push(new Common.Models.HistoryVersion({version:s.versionGroup,revision:s.version,changeid:g,userid:u.user.id,username:u.user.name,usercolor:p.get("color"),created:u.created,docId:s.key,docIdPrev:d,selected:!1,canRestore:this.appOptions.canHistoryRestore&&this.appOptions.canDownload,isRevision:!1,isVisible:!0,serverVersion:s.serverVersion})),c.push(p.get("colorval"))}else 0==o&&1==i.length&&a[a.length-1].set("docId",s.key+"1")}if(c.length>0){for(c.reverse(),g=0;g0&&(n=e.at(0),n.set("selected",!0)),n&&this.getApplication().getController("Common.Controllers.History").onSelectRevision(null,null,n)}}},generateUserColor:function(t){return"#"+("000000"+t.toString(16)).substr(-6)},disableEditing:function(t){var e=this.getApplication();this.appOptions.canEdit&&"view"!==this.editorConfig.mode&&(e.getController("RightMenu").getView("RightMenu").clearSelection(),e.getController("RightMenu").SetDisabled(t,!1),e.getController("Statusbar").getView("Statusbar").SetDisabled(t)),e.getController("LeftMenu").SetDisabled(t,!0),e.getController("Toolbar").DisableToolbar(t,t),e.getController("Common.Controllers.ReviewChanges").SetDisabled(t)},goBack:function(t){if(!Common.Controllers.Desktop.process("goback"))if(this.appOptions.customization.goback.requestClose&&this.appOptions.canRequestClose)Common.Gateway.requestClose();else{var e=this.appOptions.customization.goback.url;t||!1===this.appOptions.customization.goback.blank?parent.location.href=e:window.open(e,"_blank")}},onEditComplete:function(t){var e=this.getApplication(),i=e.getController("Toolbar"),n=i.getView();if(!this.appOptions.isEdit||!n||!n.btnInsertShape.pressed&&!n.btnInsertText.pressed||_.isObject(arguments[1])&&"tlbtn-insertshape"===arguments[1].id||(this.api&&this.api.StartAddShape("",!1),n.btnInsertShape.toggle(!1,!1),n.btnInsertText.toggle(!1,!1)),this.appOptions.isEdit&&n&&n.btnHighlightColor.pressed&&(!_.isObject(arguments[1])||"id-toolbar-btn-highlight"!==arguments[1].id)&&(this.api.SetMarkerFormat(!1),n.btnHighlightColor.toggle(!1,!1)),e.getController("DocumentHolder").getView().focus(),this.api&&this.appOptions.isEdit&&!n._state.previewmode){var o=this.api.asc_isDocumentCanSave(),s=this.appOptions.forcesave,a=!!n.btnCollabChanges.rendered&&n.btnCollabChanges.cmpEl.hasClass("notify"),r=!o&&!a&&!s||this._state.isDisconnected||this._state.fastCoauth&&this._state.usersCount>1&&!s;n.btnSave.setDisabled(r)}},onLongActionBegin:function(t,e){var i={id:e,type:t};this.stackLongActions.push(i),this.setLongActionView(i)},onLongActionEnd:function(t,e){var i={id:e,type:t};if(this.stackLongActions.pop(i),appHeader&&appHeader.setDocumentCaption(this.api.asc_getDocumentName()),this.updateWindowTitle(!0),i=this.stackLongActions.get({type:Asc.c_oAscAsyncActionType.Information}))this.setLongActionView(i);else{var n=this;e!=Asc.c_oAscAsyncAction.Save&&e!=Asc.c_oAscAsyncAction.ForceSaveButton||this.appOptions.isOffline?this.getApplication().getController("Statusbar").setStatusCaption(""):this._state.fastCoauth&&this._state.usersCount>1?n._state.timerSave=setTimeout(function(){n.getApplication().getController("Statusbar").setStatusCaption(n.textChangesSaved,!1,3e3)},500):n.getApplication().getController("Statusbar").setStatusCaption(n.textChangesSaved,!1,3e3)}i=this.stackLongActions.get({type:Asc.c_oAscAsyncActionType.BlockInteraction}),i?this.setLongActionView(i):this.loadMask&&this.loadMask.hide(),this.appOptions.isEdit&&(e==Asc.c_oAscAsyncAction.Save||e==Asc.c_oAscAsyncAction.ForceSaveButton)&&(!this._state.fastCoauth||this._state.usersCount<2||this.getApplication().getController("Common.Controllers.ReviewChanges").isPreviewChangesMode())?this.synchronizeChanges():this.appOptions.isEdit&&(e==Asc.c_oAscAsyncAction.Save||e==Asc.c_oAscAsyncAction.ForceSaveButton||e==Asc.c_oAscAsyncAction.ApplyChanges)&&this._state.fastCoauth&&this.getApplication().getController("Common.Controllers.ReviewChanges").synchronizeChanges(),e==Asc.c_oAscAsyncAction.Open&&(Common.Utils.InternalSettings.get("de-settings-livecomment")?this.api.asc_showComments(Common.Utils.InternalSettings.get("de-settings-resolvedcomment")):this.api.asc_hideComments()),t!=Asc.c_oAscAsyncActionType.BlockInteraction||this.getApplication().getController("LeftMenu").dlgSearch&&this.getApplication().getController("LeftMenu").dlgSearch.isVisible()||this.getApplication().getController("Toolbar").dlgSymbolTable&&this.getApplication().getController("Toolbar").dlgSymbolTable.isVisible()||(e==Asc.c_oAscAsyncAction.LoadDocumentFonts||e==Asc.c_oAscAsyncAction.ApplyChanges||e==Asc.c_oAscAsyncAction.DownloadAs)&&(this.dontCloseDummyComment||this.inTextareaControl||Common.Utils.ModalWindow.isVisible()||this.inFormControl)||this.api.asc_enableKeyEvents(!0)},setLongActionView:function(t){var e="",i="",n=!1;switch(t.id){case Asc.c_oAscAsyncAction.Open:e=this.openTitleText,i=this.openTextText;break;case Asc.c_oAscAsyncAction.Save:case Asc.c_oAscAsyncAction.ForceSaveButton:clearTimeout(this._state.timerSave),n=!0,e=this.saveTitleText,i=this.appOptions.isOffline?"":this.saveTextText;break;case Asc.c_oAscAsyncAction.LoadDocumentFonts:e=this.loadFontsTitleText,i=this.loadFontsTextText;break;case Asc.c_oAscAsyncAction.LoadDocumentImages:e=this.loadImagesTitleText,i=this.loadImagesTextText;break;case Asc.c_oAscAsyncAction.LoadFont:e=this.loadFontTitleText,i=this.loadFontTextText;break;case Asc.c_oAscAsyncAction.LoadImage:e=this.loadImageTitleText,i=this.loadImageTextText;break;case Asc.c_oAscAsyncAction.DownloadAs:e=this.downloadTitleText,i=this.downloadTextText;break;case Asc.c_oAscAsyncAction.Print:e=this.printTitleText,i=this.printTextText;break;case Asc.c_oAscAsyncAction.UploadImage:e=this.uploadImageTitleText,i=this.uploadImageTextText;break;case Asc.c_oAscAsyncAction.ApplyChanges:e=this.applyChangesTitleText,i=this.applyChangesTextText;break;case Asc.c_oAscAsyncAction.PrepareToSave:e=this.savePreparingText,i=this.savePreparingTitle;break;case Asc.c_oAscAsyncAction.MailMergeLoadFile:e=this.mailMergeLoadFileText,i=this.mailMergeLoadFileTitle;break;case Asc.c_oAscAsyncAction.DownloadMerge:e=this.downloadMergeTitle,i=this.downloadMergeText;break;case Asc.c_oAscAsyncAction.SendMailMerge:e=this.sendMergeTitle,i=this.sendMergeText;break;case Asc.c_oAscAsyncAction.Waiting:e=this.waitText,i=this.waitText;break;case ApplyEditRights:e=this.txtEditingMode,i=this.txtEditingMode;break;case LoadingDocument:e=this.loadingDocumentTitleText,i=this.loadingDocumentTextText;break;default:"string"==typeof t.id&&(e=t.id,i=t.id)}t.type==Asc.c_oAscAsyncActionType.BlockInteraction?(this.loadMask||(this.loadMask=new Common.UI.LoadMask({owner:$("#viewport")})),this.loadMask.setTitle(e),this.isShowOpenDialog||this.loadMask.show()):this.getApplication().getController("Statusbar").setStatusCaption(i,n)},onApplyEditRights:function(t){this.getApplication().getController("Statusbar").setStatusCaption(""),t&&!t.allowed&&Common.UI.info({title:this.requestEditFailedTitleText,msg:t.message||this.requestEditFailedMessageText})},onDocumentContentReady:function(){function checkWarns(){if(!window.AscDesktopEditor){var t=[];Common.Utils.isIE9m&&t.push(me.warnBrowserIE9),t.length&&me.showTips(t)}document.removeEventListener("visibilitychange",checkWarns)}if(!this._isDocReady){this._state.openDlg&&this._state.openDlg.close();var me=this,value;me._isDocReady=!0,Common.NotificationCenter.trigger("app:ready",this.appOptions),me.api.SetDrawingFreeze(!1),me.hidePreloader(),me.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,LoadingDocument),Common.Utils.InternalSettings.set("de-settings-datetime-default",Common.localStorage.getItem("de-settings-datetime-default")),this.isLiveCommenting=Common.localStorage.getBool("de-settings-livecomment",!0),Common.Utils.InternalSettings.set("de-settings-livecomment",this.isLiveCommenting),value=Common.localStorage.getBool("de-settings-resolvedcomment"),Common.Utils.InternalSettings.set("de-settings-resolvedcomment",value),this.isLiveCommenting?this.api.asc_showComments(value):this.api.asc_hideComments(),value=Common.localStorage.getItem("de-settings-zoom"),Common.Utils.InternalSettings.set("de-settings-zoom",value);var zf=null!==value?parseInt(value):this.appOptions.customization&&this.appOptions.customization.zoom?parseInt(this.appOptions.customization.zoom):100;-1==zf?this.api.zoomFitToPage():-2==zf?this.api.zoomFitToWidth():this.api.zoom(zf>0?zf:100),value=Common.localStorage.getItem("de-show-hiddenchars"),me.api.put_ShowParaMarks(null!==value&&eval(value)),value=Common.localStorage.getItem("de-show-tableline"),me.api.put_ShowTableEmptyLine(null===value||eval(value)),value=Common.localStorage.getBool("de-settings-spellcheck",!(this.appOptions.customization&&!1===this.appOptions.customization.spellcheck)),Common.Utils.InternalSettings.set("de-settings-spellcheck",value),me.api.asc_setSpellCheck(value),value=Common.localStorage.getBool("de-settings-compatible",!1),Common.Utils.InternalSettings.set("de-settings-compatible",value),Common.Utils.InternalSettings.set("de-settings-showsnaplines",me.api.get_ShowSnapLines()),void 0!==document.hidden&&document.hidden?document.addEventListener("visibilitychange",checkWarns):checkWarns(),me.api.asc_registerCallback("asc_onStartAction",_.bind(me.onLongActionBegin,me)),me.api.asc_registerCallback("asc_onEndAction",_.bind(me.onLongActionEnd,me)),me.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(me.onCoAuthoringDisconnect,me)),me.api.asc_registerCallback("asc_onPrint",_.bind(me.onPrint,me)),appHeader.setDocumentCaption(me.api.asc_getDocumentName()),me.updateWindowTitle(!0),value=Common.localStorage.getBool("de-settings-inputmode"),Common.Utils.InternalSettings.set("de-settings-inputmode",value),me.api.SetTextBoxInputMode(value),me.appOptions.isEdit&&!me.appOptions.isOffline&&me.appOptions.canCoAuthoring?(value=Common.localStorage.getItem("de-settings-coauthmode"),null===value&&!Common.localStorage.itemExists("de-settings-autosave")&&me.appOptions.customization&&!1===me.appOptions.customization.autosave&&(value=0),me._state.fastCoauth=null===value||1==parseInt(value),me.api.asc_SetFastCollaborative(me._state.fastCoauth),value=Common.localStorage.getItem(me._state.fastCoauth?"de-settings-showchanges-fast":"de-settings-showchanges-strict"),null==value&&(value=me._state.fastCoauth?"none":"last"),me.api.SetCollaborativeMarksShowType("all"==value?Asc.c_oAscCollaborativeMarksShowType.All:"none"==value?Asc.c_oAscCollaborativeMarksShowType.None:Asc.c_oAscCollaborativeMarksShowType.LastChanges),Common.Utils.InternalSettings.set(me._state.fastCoauth?"de-settings-showchanges-fast":"de-settings-showchanges-strict",value)):!me.appOptions.isEdit&&me.appOptions.isRestrictedEdit?(me._state.fastCoauth=!0,me.api.asc_SetFastCollaborative(me._state.fastCoauth),me.api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None),me.api.asc_setAutoSaveGap(1),Common.Utils.InternalSettings.set("de-settings-autosave",1)):(me._state.fastCoauth=!1,me.api.asc_SetFastCollaborative(me._state.fastCoauth),me.api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None)),Common.Utils.InternalSettings.set("de-settings-coauthmode",me._state.fastCoauth),me.api.asc_SetPerformContentControlActionByClick(me.appOptions.isRestrictedEdit&&me.appOptions.canFillForms);var application=me.getApplication(),toolbarController=application.getController("Toolbar"),statusbarController=application.getController("Statusbar"),documentHolderController=application.getController("DocumentHolder"),fontsController=application.getController("Common.Controllers.Fonts"),rightmenuController=application.getController("RightMenu"),leftmenuController=application.getController("LeftMenu"),chatController=application.getController("Common.Controllers.Chat"),pluginsController=application.getController("Common.Controllers.Plugins"),navigationController=application.getController("Navigation");if(leftmenuController.getView("LeftMenu").getMenu("file").loadDocument({doc:me.document}),leftmenuController.setMode(me.appOptions).createDelayedElements().setApi(me.api),navigationController.setApi(me.api).setMode(this.appOptions),chatController.setApi(this.api).setMode(this.appOptions),application.getController("Common.Controllers.ExternalDiagramEditor").setApi(this.api).loadConfig({config:this.editorConfig,customization:this.editorConfig.customization}),application.getController("Common.Controllers.ExternalMergeEditor").setApi(this.api).loadConfig({config:this.editorConfig,customization:this.editorConfig.customization}),pluginsController.setApi(me.api),documentHolderController.setApi(me.api),documentHolderController.createDelayedElements(),statusbarController.createDelayedElements(),leftmenuController.getView("LeftMenu").disableMenu("all",!1),me.appOptions.canBranding&&me.getApplication().getController("LeftMenu").leftMenu.getMenu("about").setLicInfo(me.editorConfig.customization),documentHolderController.getView().setApi(me.api).on("editcomplete",_.bind(me.onEditComplete,me)),me.appOptions.isEdit){value=Common.localStorage.getItem("de-settings-autosave"),null===value&&me.appOptions.customization&&!1===me.appOptions.customization.autosave&&(value=0),value=me._state.fastCoauth||null===value?me.appOptions.canCoAuthoring?1:0:parseInt(value),Common.Utils.InternalSettings.set("de-settings-autosave",value),me.api.asc_setAutoSaveGap(value),me.appOptions.canForcesave&&(me.appOptions.forcesave=Common.localStorage.getBool("de-settings-forcesave",me.appOptions.canForcesave),Common.Utils.InternalSettings.set("de-settings-forcesave",me.appOptions.forcesave),me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave)),value=Common.localStorage.getItem("de-settings-paste-button"),null===value&&(value="1"),Common.Utils.InternalSettings.set("de-settings-paste-button",parseInt(value)),me.api.asc_setVisiblePasteButton(!!parseInt(value)),me.loadAutoCorrectSettings(),me.needToUpdateVersion&&Common.NotificationCenter.trigger("api:disconnect");var timer_sl=setInterval(function(){if(window.styles_loaded){clearInterval(timer_sl),toolbarController.createDelayedElements(),documentHolderController.getView().createDelayedElements(),me.setLanguages();var t=me.api.asc_getPropertyEditorShapes();t&&me.fillAutoShapes(t[0],t[1]),rightmenuController.createDelayedElements(),me.updateThemeColors(),toolbarController.activateControls(),me.needToUpdateVersion&&toolbarController.onApiCoAuthoringDisconnect(),me.api.UpdateInterfaceState(),Common.NotificationCenter.trigger("document:ready","main"),me.applyLicense()}},50)}else documentHolderController.getView().createDelayedElementsViewer(),Common.NotificationCenter.trigger("document:ready","main"),"view"!==me.editorConfig.mode&&me.applyLicense();var dummyClass=~~(1e6*Math.random());$(".toolbar").prepend(Common.Utils.String.format('
    ',dummyClass)),setTimeout(function(){$(Common.Utils.String.format(".toolbar .lazy-{0}",dummyClass)).remove()},10),this.appOptions.canAnalytics,Common.Gateway.on("applyeditrights",_.bind(me.onApplyEditRights,me)),Common.Gateway.on("processsaveresult",_.bind(me.onProcessSaveResult,me)),Common.Gateway.on("processrightschange",_.bind(me.onProcessRightsChange,me)),Common.Gateway.on("processmouse",_.bind(me.onProcessMouse,me)),Common.Gateway.on("refreshhistory",_.bind(me.onRefreshHistory,me)),Common.Gateway.on("downloadas",_.bind(me.onDownloadAs,me)),Common.Gateway.sendInfo({mode:me.appOptions.isEdit?"edit":"view"}),$(document).on("contextmenu",_.bind(me.onContextMenu,me)),Common.Gateway.documentReady(),$("#editor-container").css("overflow",""),$(".doc-placeholder").remove()}},onLicenseChanged:function(t){var e=t.asc_getLicenseType();void 0!==e&&this.appOptions.canEdit&&"view"!==this.editorConfig.mode&&(e===Asc.c_oLicenseResult.Connections||e===Asc.c_oLicenseResult.UsersCount||e===Asc.c_oLicenseResult.ConnectionsOS||e===Asc.c_oLicenseResult.UsersCountOS||e===Asc.c_oLicenseResult.SuccessLimit&&0!=(this.appOptions.trialMode&Asc.c_oLicenseMode.Limited))&&(this._state.licenseType=e),this._isDocReady&&this.applyLicense()},applyLicense:function(){},onOpenDocument:function(t){var e=document.getElementById("loadmask-text"),i=(t.asc_getCurrentFont()+t.asc_getCurrentImage())/(t.asc_getFontsCount()+t.asc_getImagesCount());i=this.textLoadingDocument+": "+Math.min(Math.round(100*i),100)+"%",e?e.innerHTML=i:this.loadMask&&this.loadMask.setTitle(i)},onEditorPermissions:function(t){var e=t.asc_getLicenseType();if(!this.onServerVersion(t.asc_getBuildVersion())){this.permissions.review=void 0===this.permissions.review?!1!==this.permissions.edit:this.permissions.review,t.asc_getRights()!==Asc.c_oRights.Edit&&(this.permissions.edit=this.permissions.review=!1),this.appOptions.permissionsLicense=e,this.appOptions.canAnalytics=t.asc_getIsAnalyticsEnable(),this.appOptions.canLicense=e===Asc.c_oLicenseResult.Success||e===Asc.c_oLicenseResult.SuccessLimit,this.appOptions.isLightVersion=t.asc_getIsLight(),this.appOptions.canCoAuthoring=!this.appOptions.isLightVersion,this.appOptions.isOffline=this.api.asc_isOffline(),this.appOptions.isCrypted=this.api.asc_isCrypto(),this.appOptions.isReviewOnly=!0===this.permissions.review&&!1===this.permissions.edit,this.appOptions.canRequestEditRights=this.editorConfig.canRequestEditRights,this.appOptions.canEdit=(!1!==this.permissions.edit||!0===this.permissions.review)&&(this.editorConfig.canRequestEditRights||"view"!==this.editorConfig.mode)&&(!this.appOptions.isReviewOnly||this.appOptions.canLicense),this.appOptions.isEdit=this.appOptions.canLicense&&this.appOptions.canEdit&&"view"!==this.editorConfig.mode,this.appOptions.canReview=!0===this.permissions.review&&this.appOptions.canLicense&&this.appOptions.isEdit,this.appOptions.canViewReview=!0,this.appOptions.canUseHistory=this.appOptions.canLicense&&this.editorConfig.canUseHistory&&this.appOptions.canCoAuthoring&&!this.appOptions.isOffline,this.appOptions.canHistoryClose=this.editorConfig.canHistoryClose,this.appOptions.canHistoryRestore=this.editorConfig.canHistoryRestore,this.appOptions.canUseMailMerge=this.appOptions.canLicense&&this.appOptions.canEdit&&!this.appOptions.isOffline,this.appOptions.canSendEmailAddresses=this.appOptions.canLicense&&this.editorConfig.canSendEmailAddresses&&this.appOptions.canEdit&&this.appOptions.canCoAuthoring,this.appOptions.canComments=this.appOptions.canLicense&&(void 0===this.permissions.comment?this.appOptions.isEdit:this.permissions.comment)&&"view"!==this.editorConfig.mode,this.appOptions.canComments=this.appOptions.canComments&&!("object"==typeof this.editorConfig.customization&&!1===this.editorConfig.customization.comments),this.appOptions.canViewComments=this.appOptions.canComments||!("object"==typeof this.editorConfig.customization&&!1===this.editorConfig.customization.comments),this.appOptions.canChat=this.appOptions.canLicense&&!this.appOptions.isOffline&&!("object"==typeof this.editorConfig.customization&&!1===this.editorConfig.customization.chat),this.appOptions.canEditStyles=this.appOptions.canLicense&&this.appOptions.canEdit,this.appOptions.canPrint=!1!==this.permissions.print,this.appOptions.canRename=this.editorConfig.canRename,this.appOptions.buildVersion=t.asc_getBuildVersion(),this.appOptions.canForcesave=this.appOptions.isEdit&&!this.appOptions.isOffline&&"object"==typeof this.editorConfig.customization&&!!this.editorConfig.customization.forcesave,this.appOptions.forcesave=this.appOptions.canForcesave,this.appOptions.canEditComments=this.appOptions.isOffline||!("object"==typeof this.editorConfig.customization&&this.editorConfig.customization.commentAuthorOnly),this.appOptions.trialMode=t.asc_getLicenseMode(),this.appOptions.isBeta=t.asc_getIsBeta(),this.appOptions.isSignatureSupport=this.appOptions.isEdit&&this.appOptions.isDesktopApp&&this.appOptions.isOffline&&this.api.asc_isSignaturesSupport(),this.appOptions.isPasswordSupport=this.appOptions.isEdit&&this.appOptions.isDesktopApp&&this.appOptions.isOffline&&this.api.asc_isProtectionSupport(),this.appOptions.canProtect=this.appOptions.isSignatureSupport||this.appOptions.isPasswordSupport,this.appOptions.canEditContentControl=!1!==this.permissions.modifyContentControl,this.appOptions.canHelp=!("object"==typeof this.editorConfig.customization&&!1===this.editorConfig.customization.help),this.appOptions.canFillForms=this.appOptions.canLicense&&(void 0===this.permissions.fillForms?this.appOptions.isEdit:this.permissions.fillForms)&&"view"!==this.editorConfig.mode,this.appOptions.isRestrictedEdit=!this.appOptions.isEdit&&(this.appOptions.canComments||this.appOptions.canFillForms),this.appOptions.isRestrictedEdit&&this.appOptions.canComments&&this.appOptions.canFillForms&&(this.appOptions.canComments=!1),this.appOptions.isLightVersion&&(this.appOptions.canUseHistory=this.appOptions.canReview=this.appOptions.isReviewOnly=!1),this.appOptions.canCoAuthoring||(this.appOptions.canChat=!1);var i=/^(?:(pdf|djvu|xps))$/.exec(this.document.fileType);this.appOptions.canDownloadOrigin=!1!==this.permissions.download&&i&&"string"==typeof i[1],this.appOptions.canDownload=!1!==this.permissions.download&&(!i||"string"!=typeof i[1]),this.appOptions.fileKey=this.document.key,this.appOptions.canBranding=t.asc_getCustomization(),this.appOptions.canBranding&&appHeader.setBranding(this.editorConfig.customization),this.appOptions.canUseReviewPermissions=this.appOptions.canLicense&&this.editorConfig.customization&&this.editorConfig.customization.reviewPermissions&&"object"==typeof this.editorConfig.customization.reviewPermissions,Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions),appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)),this.appOptions.canRename&&appHeader.setCanRename(!0),this.appOptions.canBrandingExt=t.asc_getCanBranding()&&("object"==typeof this.editorConfig.customization||this.editorConfig.plugins),this.getApplication().getController("Common.Controllers.Plugins").setMode(this.appOptions),this.appOptions.canComments&&Common.NotificationCenter.on("comments:cleardummy",_.bind(this.onClearDummyComment,this)),Common.NotificationCenter.on("comments:showdummy",_.bind(this.onShowDummyComment,this)),this.applyModeCommonElements(),this.applyModeEditorElements(),this.appOptions.isEdit||(Common.NotificationCenter.trigger("app:face",this.appOptions),this.hidePreloader(),this.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction,LoadingDocument)),this.api.asc_setViewMode(!this.appOptions.isEdit&&!this.appOptions.isRestrictedEdit),this.appOptions.isRestrictedEdit&&this.appOptions.canComments&&this.api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyComments),this.appOptions.isRestrictedEdit&&this.appOptions.canFillForms&&this.api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms),this.api.asc_LoadDocument()}},applyModeCommonElements:function(){window.editor_elements_prepared=!0;var t=this.getApplication(),e=t.getController("Viewport").getView("Viewport"),i=t.getController("Statusbar").getView("Statusbar"),n=t.getController("DocumentHolder").getView(),o=t.getController("Toolbar");e&&e.setMode(this.appOptions),i&&i.setMode(this.appOptions),o.setMode(this.appOptions),n.setMode(this.appOptions),this.api.asc_registerCallback("asc_onSendThemeColors",_.bind(this.onSendThemeColors,this)),this.api.asc_registerCallback("asc_onDownloadUrl",_.bind(this.onDownloadUrl,this)),this.api.asc_registerCallback("asc_onAuthParticipantsChanged",_.bind(this.onAuthParticipantsChanged,this)),this.api.asc_registerCallback("asc_onParticipantsChanged",_.bind(this.onAuthParticipantsChanged,this)),this.api.asc_registerCallback("asc_onDocumentModifiedChanged",_.bind(this.onDocumentModifiedChanged,this))},applyModeEditorElements:function(){this.contComments.setMode(this.appOptions),this.contComments.setConfig({config:this.editorConfig},this.api);var t=this,e=this.getApplication();if(e.getController("Common.Controllers.ReviewChanges").setMode(t.appOptions).setConfig({config:t.editorConfig},t.api).loadDocument({doc:t.document}),this.appOptions.isEdit||this.appOptions.isRestrictedEdit){var i=e.getController("Toolbar");if(i&&i.setApi(t.api),!this.appOptions.isEdit)return;var n=e.getController("RightMenu"),o=e.getController("Common.Controllers.Fonts");o&&o.setApi(t.api),n&&n.setApi(t.api),this.appOptions.canProtect&&e.getController("Common.Controllers.Protection").setMode(t.appOptions).setConfig({config:t.editorConfig},t.api),this.getApplication().getController("Viewport").getView("Viewport").applyEditorMode();var s=n.getView("RightMenu");s&&(s.setApi(t.api),s.on("editcomplete",_.bind(t.onEditComplete,t)),s.setMode(t.appOptions));var a=i?i.getView():null;a&&(a.setApi(t.api),a.on("editcomplete",_.bind(t.onEditComplete,t)),a.on("insertimage",_.bind(t.onInsertImage,t)),a.on("inserttable",_.bind(t.onInsertTable,t)),a.on("insertshape",_.bind(t.onInsertShape,t)),a.on("inserttextart",_.bind(t.onInsertTextArt,t)),a.on("insertchart",_.bind(t.onInsertChart,t)),a.on("insertcontrol",_.bind(t.onInsertControl,t)));var r=Common.localStorage.getItem("de-settings-unit");r=null!==r?parseInt(r):this.appOptions.customization&&this.appOptions.customization.unit?Common.Utils.Metric.c_MetricUnits[this.appOptions.customization.unit.toLocaleLowerCase()]:Common.Utils.Metric.getDefaultMetric(),void 0===r&&(r=Common.Utils.Metric.getDefaultMetric()),Common.Utils.Metric.setCurrentMetric(r),Common.Utils.InternalSettings.set("de-settings-unit",r),t.api.asc_SetDocumentUnits(r==Common.Utils.Metric.c_MetricUnits.inch?Asc.c_oAscDocumentUnits.Inch:r==Common.Utils.Metric.c_MetricUnits.pt?Asc.c_oAscDocumentUnits.Point:Asc.c_oAscDocumentUnits.Millimeter),t.api.asc_SetViewRulers(!Common.localStorage.getBool("de-hidden-rulers")),t.api.asc_registerCallback("asc_onDocumentCanSaveChanged",_.bind(t.onDocumentCanSaveChanged,t)),t.api.asc_registerCallback("asc_onCollaborativeChanges",_.bind(t.onCollaborativeChanges,t)),t.api.asc_registerCallback("asc_OnTryUndoInFastCollaborative",_.bind(t.onTryUndoInFastCollaborative,t)),t.api.asc_registerCallback("asc_onConvertEquationToMath",_.bind(t.onConvertEquationToMath,t)),t.stackLongActions.exist({id:ApplyEditRights,type:Asc.c_oAscAsyncActionType.BlockInteraction})?t.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,ApplyEditRights):this._isDocReady||(Common.NotificationCenter.trigger("app:face",t.appOptions),t.hidePreloader(),t.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction,LoadingDocument)),window.onbeforeunload=_.bind(t.onBeforeUnload,t),window.onunload=_.bind(t.onUnload,t)}},onExternalMessage:function(t){t&&t.msg&&(t.msg=t.msg.toString(),this.showTips([t.msg.charAt(0).toUpperCase()+t.msg.substring(1)]),Common.component.Analytics.trackEvent("External Error"))},onError:function(t,e,i){if(t==Asc.c_oAscError.ID.LoadingScriptError)return this.showTips([this.scriptLoadError]),void(this.tooltip&&this.tooltip.getBSTip().$tip.css("z-index",1e4));this.hidePreloader(),this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,LoadingDocument);var n={closable:!0};switch(t){case Asc.c_oAscError.ID.Unknown:n.msg=this.unknownErrorText;break;case Asc.c_oAscError.ID.ConvertationTimeout:n.msg=this.convertationTimeoutText;break;case Asc.c_oAscError.ID.ConvertationOpenError:n.msg=this.openErrorText;break;case Asc.c_oAscError.ID.ConvertationSaveError:n.msg=this.appOptions.isDesktopApp&&this.appOptions.isOffline?this.saveErrorTextDesktop:this.saveErrorText;break;case Asc.c_oAscError.ID.DownloadError:n.msg=this.downloadErrorText;break;case Asc.c_oAscError.ID.UplImageSize:n.msg=this.uploadImageSizeMessage;break;case Asc.c_oAscError.ID.UplImageExt:n.msg=this.uploadImageExtMessage;break;case Asc.c_oAscError.ID.UplImageFileCount:n.msg=this.uploadImageFileCountMessage;break;case Asc.c_oAscError.ID.UplDocumentSize:n.msg=this.uploadDocSizeMessage;break;case Asc.c_oAscError.ID.UplDocumentExt:n.msg=this.uploadDocExtMessage;break;case Asc.c_oAscError.ID.UplDocumentFileCount:n.msg=this.uploadDocFileCountMessage;break;case Asc.c_oAscError.ID.SplitCellMaxRows:n.msg=this.splitMaxRowsErrorText.replace("%1",i.get_Value());break;case Asc.c_oAscError.ID.SplitCellMaxCols:n.msg=this.splitMaxColsErrorText.replace("%1",i.get_Value());break;case Asc.c_oAscError.ID.SplitCellRowsDivider:n.msg=this.splitDividerErrorText.replace("%1",i.get_Value());break;case Asc.c_oAscError.ID.VKeyEncrypt:n.msg=this.errorToken;break;case Asc.c_oAscError.ID.KeyExpire:n.msg=this.errorTokenExpire;break;case Asc.c_oAscError.ID.UserCountExceed:n.msg=this.errorUsersExceed;break;case Asc.c_oAscError.ID.CoAuthoringDisconnect:n.msg=this.errorViewerDisconnect;break;case Asc.c_oAscError.ID.ConvertationPassword:n.msg=this.errorFilePassProtect;break;case Asc.c_oAscError.ID.StockChartError:n.msg=this.errorStockChart;break;case Asc.c_oAscError.ID.DataRangeError:n.msg=this.errorDataRange;break;case Asc.c_oAscError.ID.Database:n.msg=this.errorDatabaseConnection;break;case Asc.c_oAscError.ID.UserDrop:if(this._state.lostEditingRights)return void(this._state.lostEditingRights=!1);this._state.lostEditingRights=!0,n.msg=this.errorUserDrop,Common.NotificationCenter.trigger("collaboration:sharingdeny");break;case Asc.c_oAscError.ID.MailMergeLoadFile:n.msg=this.errorMailMergeLoadFile;break;case Asc.c_oAscError.ID.MailMergeSaveFile:n.msg=this.errorMailMergeSaveFile;break;case Asc.c_oAscError.ID.Warning:n.msg=this.errorConnectToServer,n.closable=!1;break;case Asc.c_oAscError.ID.SessionAbsolute:n.msg=this.errorSessionAbsolute;break;case Asc.c_oAscError.ID.SessionIdle:n.msg=this.errorSessionIdle;break;case Asc.c_oAscError.ID.SessionToken:n.msg=this.errorSessionToken;break;case Asc.c_oAscError.ID.AccessDeny:n.msg=this.errorAccessDeny;break;case Asc.c_oAscError.ID.UplImageUrl:n.msg=this.errorBadImageUrl;break;case Asc.c_oAscError.ID.ForceSaveButton:n.msg=this.errorForceSave;break;case Asc.c_oAscError.ID.ForceSaveTimeout:n.msg=this.errorForceSave,console.warn(n.msg);break;case Asc.c_oAscError.ID.DataEncrypted:n.msg=this.errorDataEncrypted;break;case Asc.c_oAscError.ID.EditingError:n.msg=this.appOptions.isDesktopApp&&this.appOptions.isOffline?this.errorEditingSaveas:this.errorEditingDownloadas;break;case Asc.c_oAscError.ID.MailToClientMissing:n.msg=this.errorEmailClient;break;case Asc.c_oAscError.ID.ConvertationOpenLimitError:n.msg=this.errorFileSizeExceed;break;case Asc.c_oAscError.ID.UpdateVersion:n.msg=this.errorUpdateVersionOnDisconnect,n.maxwidth=600;break;case Asc.c_oAscError.ID.DirectUrl:n.msg=this.errorDirectUrl;break;case Asc.c_oAscError.ID.CannotCompareInCoEditing:n.msg=this.errorCompare;break;default:n.msg="string"==typeof t?t:this.errorDefaultMessage.replace("%1",t)}e==Asc.c_oAscError.Level.Critical?(Common.Gateway.reportError(t,n.msg),n.title=this.criticalErrorTitle,n.iconCls="error",n.closable=!1,this.appOptions.canBackToFolder&&!this.appOptions.isDesktopApp&&"string"!=typeof t&&(n.msg+="

    "+this.criticalErrorExtText,n.callback=function(t){"ok"==t&&Common.NotificationCenter.trigger("goback",!0)}), t==Asc.c_oAscError.ID.DataEncrypted&&(this.api.asc_coAuthoringDisconnect(),Common.NotificationCenter.trigger("api:disconnect"))):(Common.Gateway.reportWarning(t,n.msg),n.title=this.notcriticalErrorTitle,n.iconCls="warn",n.buttons=["ok"],n.callback=_.bind(function(e){if(t==Asc.c_oAscError.ID.Warning&&"ok"==e&&(this.appOptions.canDownload||this.appOptions.canDownloadOrigin))Common.UI.Menu.Manager.hideAll(),this.appOptions.isDesktopApp&&this.appOptions.isOffline?this.api.asc_DownloadAs():this.appOptions.canDownload?this.getApplication().getController("LeftMenu").leftMenu.showMenu("file:saveas"):this.api.asc_DownloadOrigin();else if(t==Asc.c_oAscError.ID.SplitCellMaxRows||t==Asc.c_oAscError.ID.SplitCellMaxCols||t==Asc.c_oAscError.ID.SplitCellRowsDivider){var i=this;setTimeout(function(){new Common.Views.InsertTableDialog({split:!0,handler:function(t,e){"ok"==t&&i.api&&i.api.SplitCell(e.columns,e.rows),i.onEditComplete()}}).show()},10)}else t==Asc.c_oAscError.ID.EditingError&&(this.disableEditing(!0),Common.NotificationCenter.trigger("api:disconnect",!0));this._state.lostEditingRights=!1,this.onEditComplete()},this)),t!==Asc.c_oAscError.ID.ForceSaveTimeout&&(!Common.Utils.ModalWindow.isVisible()||$(".asc-window.modal.alert[data-value="+t+"]").length<1)&&Common.UI.alert(n).$window.attr("data-value",t),void 0!==t&&Common.component.Analytics.trackEvent("Internal Error",t.toString())},onCoAuthoringDisconnect:function(){this.getApplication().getController("Viewport").getView("Viewport").setMode({isDisconnected:!0}),appHeader.setCanRename(!1),this.appOptions.canRename=!1,this._state.isDisconnected=!0},showTips:function(t){function e(){var e=t.shift();e&&(e+="\n"+i.textCloseTip,n.setTitle(e),n.show())}var i=this;if(t.length){"object"!=typeof t&&(t=[t]),this.tooltip||(this.tooltip=new Common.UI.Tooltip({owner:this.getApplication().getController("Toolbar").getView(),hideonclick:!0,placement:"bottom",cls:"main-info",offset:30}));var n=this.tooltip;n.on("tooltip:hide",function(){setTimeout(e,300)}),e()}},updateWindowTitle:function(t){var e=this.api.isDocumentModified();if(this._state.isDocModified!==e||t){var i=this.defaultTitleText;appHeader&&!_.isEmpty(appHeader.getDocumentCaption())&&(i=appHeader.getDocumentCaption()+" - "+i),e&&(clearTimeout(this._state.timerCaption),_.isUndefined(i)||(i="* "+i)),window.document.title!=i&&(window.document.title=i),Common.Gateway.setDocumentModified(e),e&&(!this._state.fastCoauth||this._state.usersCount<2)&&this.getApplication().getController("Statusbar").setStatusCaption("",!0),this._state.isDocModified=e}},onDocumentModifiedChanged:function(){var t=this.api.asc_isDocumentCanSave();this._state.isDocModified!==t&&Common.Gateway.setDocumentModified(this.api.isDocumentModified()),this.updateWindowTitle();var e=this.getApplication().getController("Toolbar").getView();if(e&&e.btnCollabChanges&&!e._state.previewmode){var i=e.btnCollabChanges.cmpEl.hasClass("notify"),n=this.appOptions.forcesave,o=!t&&!i&&!n||this._state.isDisconnected||this._state.fastCoauth&&this._state.usersCount>1&&!n;e.btnSave.setDisabled(o)}!this.contComments.isDummyComment||this.dontCloseDummyComment||this.beforeShowDummyComment||this.contComments.clearDummyComment()},onDocumentCanSaveChanged:function(t){var e=this.getApplication().getController("Toolbar").getView();if(e&&this.api&&!e._state.previewmode){var i=e.btnCollabChanges.cmpEl.hasClass("notify"),n=this.appOptions.forcesave,o=!t&&!i&&!n||this._state.isDisconnected||this._state.fastCoauth&&this._state.usersCount>1&&!n;e.btnSave.setDisabled(o)}},onContextMenu:function(t){var e=t.target.getAttribute("data-can-copy"),i=t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement;if(i&&"false"===e||!i&&"true"!==e)return t.stopPropagation(),t.preventDefault(),!1},onBeforeUnload:function(){if(Common.localStorage.save(),this.api.isDocumentModified()){var t=this;return this.api.asc_stopSaving(),this.continueSavingTimer=window.setTimeout(function(){t.api.asc_continueSaving()},500),this.leavePageText}},onUnload:function(){this.continueSavingTimer&&clearTimeout(this.continueSavingTimer)},hidePreloader:function(){var t;this._state.customizationDone||(this._state.customizationDone=!0,this.appOptions.customization&&(this.appOptions.isDesktopApp?this.appOptions.customization.about=!1:this.appOptions.canBrandingExt||(this.appOptions.customization.about=!0)),Common.Utils.applyCustomization(this.appOptions.customization,mapCustomizationElements),this.appOptions.canBrandingExt&&(Common.Utils.applyCustomization(this.appOptions.customization,mapCustomizationExtElements),t=this.getApplication().getController("Common.Controllers.Plugins").applyUICustomization())),Common.NotificationCenter.trigger("layout:changed","main"),(t||new Promise(function(t,e){t()})).then(function(){$("#loading-mask").hide().remove(),Common.Controllers.Desktop.process("preloader:hide")})},onDownloadUrl:function(t){this._state.isFromGatewayDownloadAs&&Common.Gateway.downloadAs(t),this._state.isFromGatewayDownloadAs=!1},onUpdateVersion:function(t){var e=this;e.needToUpdateVersion=!0,e.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,LoadingDocument),Common.UI.warning({title:e.titleUpdateVersion,msg:this.errorUpdateVersion,callback:function(){_.defer(function(){Common.Gateway.updateVersion(),t&&t.call(e),e.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction,LoadingDocument)})}})},onServerVersion:function(t){return!1},onCollaborativeChanges:function(){this._state.hasCollaborativeChanges||(this._state.hasCollaborativeChanges=!0,this.appOptions.isEdit&&this.getApplication().getController("Statusbar").setStatusCaption(this.txtNeedSynchronize,!0))},synchronizeChanges:function(){this.getApplication().getController("Statusbar").synchronizeChanges(),this.getApplication().getController("Common.Controllers.ReviewChanges").synchronizeChanges(),this.getApplication().getController("DocumentHolder").getView().hideTips(),this.getApplication().getController("Toolbar").getView().synchronizeChanges(),this._state.hasCollaborativeChanges=!1},initNames:function(){this.shapeGroupNames=[this.txtBasicShapes,this.txtFiguredArrows,this.txtMath,this.txtCharts,this.txtStarsRibbons,this.txtCallouts,this.txtButtons,this.txtRectangles,this.txtLines]},fillAutoShapes:function(t,e){if(!_.isEmpty(e)&&!_.isEmpty(t)&&e.length==t.length){var i=this,n=[],o=this.getCollection("ShapeGroups");o.reset(),_.each(t,function(t,o){var s=new Backbone.Collection([],{model:DE.Models.ShapeModel}),a=[],r=e[o].length>18?7:6,l=35*Math.ceil(e[o].length/r)+3,c=30*r;_.each(e[o],function(t,e){a.push({data:{shapeType:t.Type},tip:i["txtShape_"+t.Type]||i.textShape+" "+(e+1),allowSelected:!0,selected:!1})}),s.add(a),n.push({groupName:i.shapeGroupNames[o],groupStore:s,groupWidth:c,groupHeight:l})}),o.add(n),setTimeout(function(){i.getApplication().getController("Toolbar").onApiAutoShapes()},50)}},fillTextArt:function(t){var e=[],i=this.getCollection("Common.Collections.TextArt");!t&&i.length>0&&(t=this.api.asc_getTextArtPreviews()),_.isEmpty(t)||(_.each(t,function(t,i){e.push({imageUrl:t,data:i,allowSelected:!0,selected:!1})}),i.reset(e))},updateThemeColors:function(){var t=this;setTimeout(function(){t.getApplication().getController("RightMenu").UpdateThemeColors()},50),setTimeout(function(){t.getApplication().getController("Toolbar").updateThemeColors()},50)},onSendThemeColors:function(t,e){if(Common.Utils.ThemeColor.setColors(t,e),window.styles_loaded){this.updateThemeColors();var i=this;setTimeout(function(){i.fillTextArt()},1)}},loadLanguages:function(t){var e,i=[],n=Common.util.LanguageInfo.getLanguages();for(var o in n)n.hasOwnProperty(o)&&(e=n[o],e[2]&&i.push({displayValue:e[1],value:e[0],code:parseInt(o),spellcheck:_.indexOf(t,o)>-1}));i.sort(function(t,e){return t.valuee.value?1:0}),this.languages=i,window.styles_loaded&&this.setLanguages()},setLanguages:function(){(!this.languages||this.languages.length<1)&&this.loadLanguages([]),this.languages&&this.languages.length>0&&(this.getApplication().getController("DocumentHolder").getView().setLanguages(this.languages),this.getApplication().getController("Statusbar").setLanguages(this.languages),this.getApplication().getController("Common.Controllers.ReviewChanges").setLanguages(this.languages))},onInsertTable:function(){this.getApplication().getController("RightMenu").onInsertTable()},onInsertImage:function(){this.getApplication().getController("RightMenu").onInsertImage()},onInsertChart:function(){this.getApplication().getController("RightMenu").onInsertChart()},onInsertShape:function(){this.getApplication().getController("RightMenu").onInsertShape()},onInsertTextArt:function(){this.getApplication().getController("RightMenu").onInsertTextArt()},onInsertControl:function(){this.getApplication().getController("RightMenu").onInsertControl()},unitsChanged:function(t){var e=Common.localStorage.getItem("de-settings-unit");e=null!==e?parseInt(e):Common.Utils.Metric.getDefaultMetric(),Common.Utils.Metric.setCurrentMetric(e),Common.Utils.InternalSettings.set("de-settings-unit",e),this.api.asc_SetDocumentUnits(e==Common.Utils.Metric.c_MetricUnits.inch?Asc.c_oAscDocumentUnits.Inch:e==Common.Utils.Metric.c_MetricUnits.pt?Asc.c_oAscDocumentUnits.Point:Asc.c_oAscDocumentUnits.Millimeter),this.getApplication().getController("RightMenu").updateMetricUnit(),this.getApplication().getController("Toolbar").getView().updateMetricUnit()},onAdvancedOptions:function(t,e,i,n){if(!this._state.openDlg){var o=this;t==Asc.c_oAscAdvancedOptionsID.TXT?o._state.openDlg=new Common.Views.OpenDialog({title:Common.Views.OpenDialog.prototype.txtTitle.replace("%1","TXT"),closable:2==i,type:Common.Utils.importTextType.TXT,preview:e.asc_getData(),codepages:e.asc_getCodePages(),settings:e.asc_getRecommendedSettings(),api:o.api,handler:function(e,s){o.isShowOpenDialog=!1,"ok"==e&&o&&o.api&&(2==i?(n&&n.asc_setAdvancedOptions(new Asc.asc_CTextOptions(s)),o.api.asc_DownloadAs(n)):o.api.asc_setAdvancedOptions(t,new Asc.asc_CTextOptions(s)),o.loadMask&&o.loadMask.show()),o._state.openDlg=null}}):t==Asc.c_oAscAdvancedOptionsID.DRM&&(o._state.openDlg=new Common.Views.OpenDialog({title:Common.Views.OpenDialog.prototype.txtTitleProtected,closeFile:o.appOptions.canRequestClose,type:Common.Utils.importTextType.DRM,warning:!(o.appOptions.isDesktopApp&&o.appOptions.isOffline),warningMsg:e,validatePwd:!!o._state.isDRM,handler:function(e,i){o.isShowOpenDialog=!1,"ok"==e?o.api&&(o.api.asc_setAdvancedOptions(t,new Asc.asc_CDRMAdvancedOptions(i)),o.loadMask&&o.loadMask.show()):(Common.Gateway.requestClose(),Common.Controllers.Desktop.requestClose()),o._state.openDlg=null}}),o._state.isDRM=!0),o._state.openDlg&&(this.isShowOpenDialog=!0,this.loadMask&&this.loadMask.hide(),this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,LoadingDocument),o._state.openDlg.show())}},onTryUndoInFastCollaborative:function(){Common.localStorage.getBool("de-hide-try-undoredo")||Common.UI.info({width:500,msg:this.textTryUndoRedo,iconCls:"info",buttons:["custom","cancel"],primary:"custom",customButtonText:this.textStrict,dontshow:!0,callback:_.bind(function(t,e){e&&Common.localStorage.setItem("de-hide-try-undoredo",1),"custom"==t&&(Common.localStorage.setItem("de-settings-coauthmode",0),Common.Utils.InternalSettings.set("de-settings-coauthmode",!1),this.api.asc_SetFastCollaborative(!1),this._state.fastCoauth=!1,Common.localStorage.setItem("de-settings-showchanges-strict","last"),this.api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.LastChanges),this.getApplication().getController("Common.Controllers.ReviewChanges").applySettings()),this.onEditComplete()},this)})},onAuthParticipantsChanged:function(t){var e=0;_.each(t,function(t){t.asc_getView()||e++}),this._state.usersCount=e},applySettings:function(){if(this.appOptions.isEdit&&!this.appOptions.isOffline&&this.appOptions.canCoAuthoring){var t=this._state.fastCoauth;this._state.fastCoauth=Common.localStorage.getBool("de-settings-coauthmode",!0),this._state.fastCoauth&&!t&&this.synchronizeChanges()}this.appOptions.canForcesave&&(this.appOptions.forcesave=Common.localStorage.getBool("de-settings-forcesave",this.appOptions.canForcesave),Common.Utils.InternalSettings.set("de-settings-forcesave",this.appOptions.forcesave),this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave))},onDocumentName:function(t){appHeader.setDocumentCaption(t),this.updateWindowTitle(!0)},onMeta:function(t){appHeader.setDocumentCaption(t.title),this.updateWindowTitle(!0),this.document.title=t.title;var e=this.getApplication().getController("LeftMenu").getView("LeftMenu").getMenu("file");e.loadDocument({doc:this.document}),e.panels&&e.panels.info&&e.panels.info.updateInfo(this.document),this.getApplication().getController("Common.Controllers.ReviewChanges").loadDocument({doc:this.document}),Common.Gateway.metaChange(t)},onPrint:function(){this.appOptions.canPrint&&!Common.Utils.ModalWindow.isVisible()&&(this.api&&this.api.asc_Print(new Asc.asc_CDownloadOptions(null,Common.Utils.isChrome||Common.Utils.isSafari||Common.Utils.isOpera)),Common.component.Analytics.trackEvent("Print"))},onPrintUrl:function(t){if(this.iframePrint&&(this.iframePrint.parentNode.removeChild(this.iframePrint),this.iframePrint=null),!this.iframePrint){var e=this;this.iframePrint=document.createElement("iframe"),this.iframePrint.id="id-print-frame",this.iframePrint.style.display="none",this.iframePrint.style.visibility="hidden",this.iframePrint.style.position="fixed",this.iframePrint.style.right="0",this.iframePrint.style.bottom="0",document.body.appendChild(this.iframePrint),this.iframePrint.onload=function(){try{e.iframePrint.contentWindow.focus(),e.iframePrint.contentWindow.print(),e.iframePrint.contentWindow.blur(),window.focus()}catch(t){e.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF))}}}t&&(this.iframePrint.src=t)},onClearDummyComment:function(){this.dontCloseDummyComment=!1},onShowDummyComment:function(){this.beforeShowDummyComment=!0},DisableMailMerge:function(){this.appOptions.mergeFolderUrl="";var t=this.getApplication().getController("Toolbar");t&&t.DisableMailMerge()},DisableVersionHistory:function(){this.editorConfig.canUseHistory=!1,this.appOptions.canUseHistory=!1},onConvertEquationToMath:function(t){var e,i=this,n=this.textConvertEquation+'

    '+this.textLearnMore+"";e=Common.UI.warning({width:500,msg:n,buttons:["yes","cancel"],primary:"yes",dontshow:!0,textDontShow:this.textApplyAll,callback:_.bind(function(e,i){"yes"==e&&this.api.asc_ConvertEquationToMath(t,i),this.onEditComplete()},this)}),e.$window.find("#id-equation-convert-help").on("click",function(t){e&&e.close(),i.getApplication().getController("LeftMenu").getView("LeftMenu").showMenu("file:help","UsageInstructions/InsertEquation.htm#convertequation")})},warningDocumentIsLocked:function(){var t=this,e=function(e){t.disableEditing(e);var i=t.getApplication();i.getController("DocumentHolder").getView().SetDisabled(e),i.getController("Navigation")&&i.getController("Navigation").SetDisabled(e);var n=i.getController("LeftMenu");n.leftMenu.getMenu("file").getButton("protect").setDisabled(e),n.setPreviewMode(e);var o=i.getController("Common.Controllers.Comments");o&&o.setPreviewMode(e)};Common.Utils.warningDocumentIsLocked({disablefunc:e})},onRunAutostartMacroses:function(){var t=this;if(!this.editorConfig.customization||!1!==this.editorConfig.customization.macros){var e=Common.Utils.InternalSettings.get("de-macros-mode");1==e?this.api.asc_runAutostartMacroses():0===e&&Common.UI.warning({msg:this.textHasMacros+"
    ",buttons:["yes","no"],primary:"yes",dontshow:!0,textDontShow:this.textRemember,callback:function(e,i){i&&(Common.Utils.InternalSettings.set("de-macros-mode","yes"==e?1:2),Common.localStorage.setItem("de-macros-mode","yes"==e?1:2)),"yes"==e&&setTimeout(function(){t.api.asc_runAutostartMacroses()},1)}})}},loadAutoCorrectSettings:function(){var t=this,e=Common.localStorage.getItem("de-settings-math-correct-add");Common.Utils.InternalSettings.set("de-settings-math-correct-add",e);var i=e?JSON.parse(e):[];e=Common.localStorage.getItem("de-settings-math-correct-rem"),Common.Utils.InternalSettings.set("de-settings-math-correct-rem",e);var n=e?JSON.parse(e):[];e=Common.localStorage.getBool("de-settings-math-correct-replace-type",!0),Common.Utils.InternalSettings.set("de-settings-math-correct-replace-type",e),t.api.asc_refreshOnStartAutoCorrectMathSymbols(n,i,e),e=Common.localStorage.getItem("de-settings-rec-functions-add"),Common.Utils.InternalSettings.set("de-settings-rec-functions-add",e),i=e?JSON.parse(e):[],e=Common.localStorage.getItem("de-settings-rec-functions-rem"),Common.Utils.InternalSettings.set("de-settings-rec-functions-rem",e),n=e?JSON.parse(e):[],t.api.asc_refreshOnStartAutoCorrectMathFunctions(n,i),e=Common.localStorage.getBool("de-settings-autoformat-bulleted",!0),Common.Utils.InternalSettings.set("de-settings-autoformat-bulleted",e),t.api.asc_SetAutomaticBulletedLists(e),e=Common.localStorage.getBool("de-settings-autoformat-numbered",!0),Common.Utils.InternalSettings.set("de-settings-autoformat-numbered",e),t.api.asc_SetAutomaticNumberedLists(e),e=Common.localStorage.getBool("de-settings-autoformat-smart-quotes",!0),Common.Utils.InternalSettings.set("de-settings-autoformat-smart-quotes",e),t.api.asc_SetAutoCorrectSmartQuotes(e),e=Common.localStorage.getBool("de-settings-autoformat-hyphens",!0),Common.Utils.InternalSettings.set("de-settings-autoformat-hyphens",e),t.api.asc_SetAutoCorrectHyphensWithDash(e)},leavePageText:"You have unsaved changes in this document. Click 'Stay on this Page' then 'Save' to save them. Click 'Leave this Page' to discard all the unsaved changes.",criticalErrorTitle:"Error",notcriticalErrorTitle:"Warning",errorDefaultMessage:"Error code: %1",criticalErrorExtText:'Press "OK" to back to document list.',openTitleText:"Opening Document",openTextText:"Opening document...",loadFontsTitleText:"Loading Data",loadFontsTextText:"Loading data...",loadImagesTitleText:"Loading Images",loadImagesTextText:"Loading images...",loadFontTitleText:"Loading Data",loadFontTextText:"Loading data...",loadImageTitleText:"Loading Image",loadImageTextText:"Loading image...",downloadTitleText:"Downloading Document",downloadTextText:"Downloading document...",printTitleText:"Printing Document",printTextText:"Printing document...",uploadImageTitleText:"Uploading Image",uploadImageTextText:"Uploading image...",savePreparingText:"Preparing to save",savePreparingTitle:"Preparing to save. Please wait...",uploadImageSizeMessage:"Maximum image size limit exceeded.",uploadImageExtMessage:"Unknown image format.",uploadImageFileCountMessage:"No images uploaded.",reloadButtonText:"Reload Page",unknownErrorText:"Unknown error.",convertationTimeoutText:"Convertation timeout exceeded.",downloadErrorText:"Download failed.",unsupportedBrowserErrorText:"Your browser is not supported.",splitMaxRowsErrorText:"The number of rows must be less than %1",splitMaxColsErrorText:"The number of columns must be less than %1",splitDividerErrorText:"The number of rows must be a divisor of %1",requestEditFailedTitleText:"Access denied",requestEditFailedMessageText:"Someone is editing this document right now. Please try again later.",txtNeedSynchronize:"You have an updates",textLoadingDocument:"Loading document",warnBrowserZoom:"Your browser's current zoom setting is not fully supported. Please reset to the default zoom by pressing Ctrl+0.",warnBrowserIE9:"The application has low capabilities on IE9. Use IE10 or higher",applyChangesTitleText:"Loading Data",applyChangesTextText:"Loading data...",errorKeyEncrypt:"Unknown key descriptor",errorKeyExpire:"Key descriptor expired",errorUsersExceed:"Count of users was exceed",errorCoAuthoringDisconnect:"Server connection lost. You can't edit anymore.",errorFilePassProtect:"The file is password protected and cannot be opened.",txtBasicShapes:"Basic Shapes",txtFiguredArrows:"Figured Arrows",txtMath:"Math",txtCharts:"Charts",txtStarsRibbons:"Stars & Ribbons",txtCallouts:"Callouts",txtButtons:"Buttons",txtRectangles:"Rectangles",txtLines:"Lines",txtEditingMode:"Set editing mode...",textAnonymous:"Anonymous",loadingDocumentTitleText:"Loading document",loadingDocumentTextText:"Loading document...",warnProcessRightsChange:"You have been denied the right to edit the file.",errorProcessSaveResult:"Saving is failed.",textCloseTip:"Click to close the tip.",textShape:"Shape",errorStockChart:"Incorrect row order. To build a stock chart place the data on the sheet in the following order:
    opening price, max price, min price, closing price.",errorDataRange:"Incorrect data range.",errorDatabaseConnection:"External error.
    Database connection error. Please, contact support.",titleUpdateVersion:"Version changed",errorUpdateVersion:"The file version has been changed. The page will be reloaded.",errorUserDrop:"The file cannot be accessed right now.",txtDiagramTitle:"Chart Title",txtXAxis:"X Axis",txtYAxis:"Y Axis",txtSeries:"Seria",errorMailMergeLoadFile:"Loading the document failed. Please select a different file.",mailMergeLoadFileText:"Loading Data Source...",mailMergeLoadFileTitle:"Loading Data Source",errorMailMergeSaveFile:"Merge failed.",downloadMergeText:"Downloading...",downloadMergeTitle:"Downloading",sendMergeTitle:"Sending Merge",sendMergeText:"Sending Merge...",txtArt:"Your text here",errorConnectToServer:"The document could not be saved. Please check connection settings or contact your administrator.
    When you click the 'OK' button, you will be prompted to download the document.",textTryUndoRedo:"The Undo/Redo functions are disabled for the Fast co-editing mode.
    Click the 'Strict mode' button to switch to the Strict co-editing mode to edit the file without other users interference and send your changes only after you save them. You can switch between the co-editing modes using the editor Advanced settings.",textStrict:"Strict mode",txtErrorLoadHistory:"Loading history failed",textBuyNow:"Visit website",textNoLicenseTitle:"License limit reached",textContactUs:"Contact sales",errorViewerDisconnect:"Connection is lost. You can still view the document,
    but will not be able to download or print until the connection is restored and page is reloaded.",warnLicenseExp:"Your license has expired.
    Please update your license and refresh the page.",titleLicenseExp:"License expired",openErrorText:"An error has occurred while opening the file",saveErrorText:"An error has occurred while saving the file",errorToken:"The document security token is not correctly formed.
    Please contact your Document Server administrator.",errorTokenExpire:"The document security token has expired.
    Please contact your Document Server administrator.",errorSessionAbsolute:"The document editing session has expired. Please reload the page.",errorSessionIdle:"The document has not been edited for quite a long time. Please reload the page.",errorSessionToken:"The connection to the server has been interrupted. Please reload the page.",errorAccessDeny:"You are trying to perform an action you do not have rights for.
    Please contact your Document Server administrator.",titleServerVersion:"Editor updated",errorServerVersion:"The editor version has been updated. The page will be reloaded to apply the changes.",textChangesSaved:"All changes saved",errorBadImageUrl:"Image url is incorrect",txtStyle_Normal:"Normal",txtStyle_No_Spacing:"No Spacing",txtStyle_Heading_1:"Heading 1",txtStyle_Heading_2:"Heading 2",txtStyle_Heading_3:"Heading 3",txtStyle_Heading_4:"Heading 4",txtStyle_Heading_5:"Heading 5",txtStyle_Heading_6:"Heading 6",txtStyle_Heading_7:"Heading 7",txtStyle_Heading_8:"Heading 8",txtStyle_Heading_9:"Heading 9",txtStyle_Title:"Title",txtStyle_Subtitle:"Subtitle",txtStyle_Quote:"Quote",txtStyle_Intense_Quote:"Intense Quote",txtStyle_List_Paragraph:"List Paragraph",txtStyle_footnote_text:"Footnote Text",saveTextText:"Saving document...",saveTitleText:"Saving Document",txtBookmarkError:"Error! Bookmark not defined.",txtAbove:"above",txtBelow:"below",txtOnPage:"on page",txtHeader:"Header",txtFooter:"Footer",txtSection:"-Section",txtFirstPage:"First Page",txtEvenPage:"Even Page",txtOddPage:"Odd Page",txtSameAsPrev:"Same as Previous",txtCurrentDocument:"Current Document",txtNoTableOfContents:"There are no headings in the document. Apply a heading style to the text so that it appears in the table of contents.",txtTableOfContents:"Table of Contents",errorForceSave:"An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later.",warnNoLicense:"You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only.
    Contact %1 sales team for personal upgrade terms.",warnNoLicenseUsers:"You've reached the user limit for %1 editors. Contact %1 sales team for personal upgrade terms.",warnLicenseExceeded:"You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only.
    Contact your administrator to learn more.",warnLicenseUsersExceeded:"You've reached the user limit for %1 editors. Contact your administrator to learn more.",errorDataEncrypted:"Encrypted changes have been received, they cannot be deciphered.",textClose:"Close",textPaidFeature:"Paid feature",scriptLoadError:"The connection is too slow, some of the components could not be loaded. Please reload the page.",errorEditingSaveas:"An error occurred during the work with the document.
    Use the 'Save as...' option to save the file backup copy to your computer hard drive.",errorEditingDownloadas:"An error occurred during the work with the document.
    Use the 'Download as...' option to save the file backup copy to your computer hard drive.",txtShape_textRect:"Text Box",txtShape_rect:"Rectangle",txtShape_ellipse:"Ellipse",txtShape_triangle:"Triangle",txtShape_rtTriangle:"Right Triangle",txtShape_parallelogram:"Parallelogram",txtShape_trapezoid:"Trapezoid",txtShape_diamond:"Diamond",txtShape_pentagon:"Pentagon",txtShape_hexagon:"Hexagon",txtShape_heptagon:"Heptagon",txtShape_octagon:"Octagon",txtShape_decagon:"Decagon",txtShape_dodecagon:"Dodecagon",txtShape_pie:"Pie",txtShape_chord:"Chord",txtShape_teardrop:"Teardrop",txtShape_frame:"Frame",txtShape_halfFrame:"Half Frame",txtShape_corner:"Corner",txtShape_diagStripe:"Diagonal Stripe",txtShape_plus:"Plus",txtShape_plaque:"Sign",txtShape_can:"Can",txtShape_cube:"Cube",txtShape_bevel:"Bevel",txtShape_donut:"Donut",txtShape_noSmoking:'"No" Symbol',txtShape_blockArc:"Block Arc",txtShape_foldedCorner:"Folded Corner",txtShape_smileyFace:"Smiley Face",txtShape_heart:"Heart",txtShape_lightningBolt:"Lightning Bolt",txtShape_sun:"Sun",txtShape_moon:"Moon",txtShape_cloud:"Cloud",txtShape_arc:"Arc",txtShape_bracePair:"Double Brace",txtShape_leftBracket:"Left Bracket",txtShape_rightBracket:"Right Bracket",txtShape_leftBrace:"Left Brace",txtShape_rightBrace:"Right Brace",txtShape_rightArrow:"Right Arrow",txtShape_leftArrow:"Left Arrow",txtShape_upArrow:"Up Arrow",txtShape_downArrow:"Down Arrow",txtShape_leftRightArrow:"Left Right Arrow",txtShape_upDownArrow:"Up Down Arrow",txtShape_quadArrow:"Quad Arrow",txtShape_leftRightUpArrow:"Left Right Up Arrow",txtShape_bentArrow:"Bent Arrow",txtShape_uturnArrow:"U-Turn Arrow",txtShape_leftUpArrow:"Left Up Arrow",txtShape_bentUpArrow:"Bent Up Arrow",txtShape_curvedRightArrow:"Curved Right Arrow",txtShape_curvedLeftArrow:"Curved Left Arrow",txtShape_curvedUpArrow:"Curved Up Arrow",txtShape_curvedDownArrow:"Curved Down Arrow",txtShape_stripedRightArrow:"Striped Right Arrow",txtShape_notchedRightArrow:"Notched Right Arrow",txtShape_homePlate:"Pentagon",txtShape_chevron:"Chevron",txtShape_rightArrowCallout:"Right Arrow Callout",txtShape_downArrowCallout:"Down Arrow Callout",txtShape_leftArrowCallout:"Left Arrow Callout",txtShape_upArrowCallout:"Up Arrow Callout",txtShape_leftRightArrowCallout:"Left Right Arrow Callout",txtShape_quadArrowCallout:"Quad Arrow Callout",txtShape_circularArrow:"Circular Arrow",txtShape_mathPlus:"Plus",txtShape_mathMinus:"Minus",txtShape_mathMultiply:"Multiply",txtShape_mathDivide:"Division",txtShape_mathEqual:"Equal",txtShape_mathNotEqual:"Not Equal",txtShape_flowChartProcess:"Flowchart: Process",txtShape_flowChartAlternateProcess:"Flowchart: Alternate Process",txtShape_flowChartDecision:"Flowchart: Decision",txtShape_flowChartInputOutput:"Flowchart: Data",txtShape_flowChartPredefinedProcess:"Flowchart: Predefined Process",txtShape_flowChartInternalStorage:"Flowchart: Internal Storage",txtShape_flowChartDocument:"Flowchart: Document",txtShape_flowChartMultidocument:"Flowchart: Multidocument ",txtShape_flowChartTerminator:"Flowchart: Terminator",txtShape_flowChartPreparation:"Flowchart: Preparation",txtShape_flowChartManualInput:"Flowchart: Manual Input",txtShape_flowChartManualOperation:"Flowchart: Manual Operation",txtShape_flowChartConnector:"Flowchart: Connector",txtShape_flowChartOffpageConnector:"Flowchart: Off-page Connector",txtShape_flowChartPunchedCard:"Flowchart: Card",txtShape_flowChartPunchedTape:"Flowchart: Punched Tape",txtShape_flowChartSummingJunction:"Flowchart: Summing Junction",txtShape_flowChartOr:"Flowchart: Or",txtShape_flowChartCollate:"Flowchart: Collate",txtShape_flowChartSort:"Flowchart: Sort",txtShape_flowChartExtract:"Flowchart: Extract",txtShape_flowChartMerge:"Flowchart: Merge",txtShape_flowChartOnlineStorage:"Flowchart: Stored Data",txtShape_flowChartDelay:"Flowchart: Delay",txtShape_flowChartMagneticTape:"Flowchart: Sequential Access Storage",txtShape_flowChartMagneticDisk:"Flowchart: Magnetic Disk",txtShape_flowChartMagneticDrum:"Flowchart: Direct Access Storage",txtShape_flowChartDisplay:"Flowchart: Display",txtShape_irregularSeal1:"Explosion 1",txtShape_irregularSeal2:"Explosion 2",txtShape_star4:"4-Point Star",txtShape_star5:"5-Point Star",txtShape_star6:"6-Point Star",txtShape_star7:"7-Point Star",txtShape_star8:"8-Point Star",txtShape_star10:"10-Point Star",txtShape_star12:"12-Point Star",txtShape_star16:"16-Point Star",txtShape_star24:"24-Point Star",txtShape_star32:"32-Point Star",txtShape_ribbon2:"Up Ribbon",txtShape_ribbon:"Down Ribbon",txtShape_ellipseRibbon2:"Curved Up Ribbon",txtShape_ellipseRibbon:"Curved Down Ribbon",txtShape_verticalScroll:"Vertical Scroll",txtShape_horizontalScroll:"Horizontal Scroll",txtShape_wave:"Wave",txtShape_doubleWave:"Double Wave",txtShape_wedgeRectCallout:"Rectangular Callout",txtShape_wedgeRoundRectCallout:"Rounded Rectangular Callout",txtShape_wedgeEllipseCallout:"Oval Callout",txtShape_cloudCallout:"Cloud Callout",txtShape_borderCallout1:"Line Callout 1",txtShape_borderCallout2:"Line Callout 2",txtShape_borderCallout3:"Line Callout 3",txtShape_accentCallout1:"Line Callout 1 (Accent Bar)",txtShape_accentCallout2:"Line Callout 2 (Accent Bar)",txtShape_accentCallout3:"Line Callout 3 (Accent Bar)",txtShape_callout1:"Line Callout 1 (No Border)",txtShape_callout2:"Line Callout 2 (No Border)",txtShape_callout3:"Line Callout 3 (No Border)",txtShape_accentBorderCallout1:"Line Callout 1 (Border and Accent Bar)",txtShape_accentBorderCallout2:"Line Callout 2 (Border and Accent Bar)",txtShape_accentBorderCallout3:"Line Callout 3 (Border and Accent Bar)",txtShape_actionButtonBackPrevious:"Back or Previous Button",txtShape_actionButtonForwardNext:"Forward or Next Button",txtShape_actionButtonBeginning:"Beginning Button",txtShape_actionButtonEnd:"End Button",txtShape_actionButtonHome:"Home Button",txtShape_actionButtonInformation:"Information Button",txtShape_actionButtonReturn:"Return Button",txtShape_actionButtonMovie:"Movie Button",txtShape_actionButtonDocument:"Document Button",txtShape_actionButtonSound:"Sound Button",txtShape_actionButtonHelp:"Help Button",txtShape_actionButtonBlank:"Blank Button",txtShape_roundRect:"Round Corner Rectangle", diff --git a/www/common/onlyoffice/v4/web-apps/apps/presentationeditor/main/app.js b/www/common/onlyoffice/v4/web-apps/apps/presentationeditor/main/app.js index be4ccb024..17cdc4804 100644 --- a/www/common/onlyoffice/v4/web-apps/apps/presentationeditor/main/app.js +++ b/www/common/onlyoffice/v4/web-apps/apps/presentationeditor/main/app.js @@ -13,47 +13,47 @@ this.location.replace(this.root+this.location.search+"#"+this.fragment),!0;this. return this.getTitle()||this.getContent()},i.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},i.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var n=t.fn.popover;t.fn.popover=e,t.fn.popover.Constructor=i,t.fn.popover.noConflict=function(){return t.fn.popover=n,this}}(jQuery),function(t){"use strict";function e(i,n){this.$body=t(document.body),this.$scrollElement=t(t(i).is(document.body)?window:i),this.options=t.extend({},e.DEFAULTS,n),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",t.proxy(this.process,this)),this.refresh(),this.process()}function i(i){return this.each(function(){var n=t(this),o=n.data("bs.scrollspy"),s="object"==typeof i&&i;o||n.data("bs.scrollspy",o=new e(this,s)),"string"==typeof i&&o[i]()})}e.VERSION="3.3.7",e.DEFAULTS={offset:10},e.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},e.prototype.refresh=function(){var e=this,i="offset",n=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),t.isWindow(this.$scrollElement[0])||(i="position",n=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var e=t(this),o=e.data("target")||e.attr("href"),s=/^#./.test(o)&&t(o);return s&&s.length&&s.is(":visible")&&[[s[i]().top+n,o]]||null}).sort(function(t,e){return t[0]-e[0]}).each(function(){e.offsets.push(this[0]),e.targets.push(this[1])})},e.prototype.process=function(){var t,e=this.$scrollElement.scrollTop()+this.options.offset,i=this.getScrollHeight(),n=this.options.offset+i-this.$scrollElement.height(),o=this.offsets,s=this.targets,a=this.activeTarget;if(this.scrollHeight!=i&&this.refresh(),e>=n)return a!=(t=s[s.length-1])&&this.activate(t);if(a&&e=o[t]&&(void 0===o[t+1]||e .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),e.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),l?(e[0].offsetWidth,e.addClass("in")):e.removeClass("fade"),e.parent(".dropdown-menu").length&&e.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),o&&o()}var a=n.find("> .active"),l=o&&t.support.transition&&(a.length&&a.hasClass("fade")||!!n.find("> .fade").length);a.length&&l?a.one("bsTransitionEnd",s).emulateTransitionEnd(i.TRANSITION_DURATION):s(),a.removeClass("in")};var n=t.fn.tab;t.fn.tab=e,t.fn.tab.Constructor=i,t.fn.tab.noConflict=function(){return t.fn.tab=n,this};var o=function(i){i.preventDefault(),e.call(t(this),"show")};t(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',o).on("click.bs.tab.data-api",'[data-toggle="pill"]',o)}(jQuery),function(t){"use strict";function e(e){return this.each(function(){var n=t(this),o=n.data("bs.affix"),s="object"==typeof e&&e;o||n.data("bs.affix",o=new i(this,s)),"string"==typeof e&&o[e]()})}var i=function(e,n){this.options=t.extend({},i.DEFAULTS,n),this.$target=t(this.options.target).on("scroll.bs.affix.data-api",t.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",t.proxy(this.checkPositionWithEventLoop,this)),this.$element=t(e),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};i.VERSION="3.3.7",i.RESET="affix affix-top affix-bottom",i.DEFAULTS={offset:0,target:window},i.prototype.getState=function(t,e,i,n){var o=this.$target.scrollTop(),s=this.$element.offset(),a=this.$target.height();if(null!=i&&"top"==this.affixed)return o=t-n&&"bottom"},i.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(i.RESET).addClass("affix");var t=this.$target.scrollTop(),e=this.$element.offset();return this.pinnedOffset=e.top-t},i.prototype.checkPositionWithEventLoop=function(){setTimeout(t.proxy(this.checkPosition,this),1)},i.prototype.checkPosition=function(){if(this.$element.is(":visible")){var e=this.$element.height(),n=this.options.offset,o=n.top,s=n.bottom,a=Math.max(t(document).height(),t(document.body).height());"object"!=typeof n&&(s=o=n),"function"==typeof o&&(o=n.top(this.$element)),"function"==typeof s&&(s=n.bottom(this.$element));var l=this.getState(a,e,o,s);if(this.affixed!=l){null!=this.unpin&&this.$element.css("top","");var r="affix"+(l?"-"+l:""),c=t.Event(r+".bs.affix");if(this.$element.trigger(c),c.isDefaultPrevented())return;this.affixed=l,this.unpin="bottom"==l?this.getPinnedOffset():null,this.$element.removeClass(i.RESET).addClass(r).trigger(r.replace("affix","affixed")+".bs.affix")}"bottom"==l&&this.$element.offset({top:a-e-s})}};var n=t.fn.affix;t.fn.affix=e,t.fn.affix.Constructor=i,t.fn.affix.noConflict=function(){return t.fn.affix=n,this},t(window).on("load",function(){t('[data-spy="affix"]').each(function(){var i=t(this),n=i.data();n.offset=n.offset||{},null!=n.offsetBottom&&(n.offset.bottom=n.offsetBottom),null!=n.offsetTop&&(n.offset.top=n.offsetTop),e.call(i,n)})})}(jQuery),define("bootstrap",["jquery"],function(){}),void 0===Common)var Common={};if(define("notification",["backbone"],function(t){"use strict";var e=function(){};if(_.extend(e.prototype,t.Events),void 0!==Common.NotificationCenter)throw"Native Common.NotificationCenter instance already defined.";e.extend=t.Model.extend,Common.NotificationCenter=new e}),function(){var t=function(t,e){for(var i=t.split("."),n=e||window,o=0,s=i.length;o-1?window:s)},this),n},initializeControllers:function(e){this.controllers={},_.each(e,function(e){var i=e.indexOf(".")>-1?window:this[this.allocationMap.controller],n=t(e,i),o=(e.split(".").pop(),new n({id:e,application:this}));o.views=this.getClasseRefs("view",o.views||[]),_.extend(this.models,this.getClasseRefs("model",o.models||[])),_.extend(this.collections,this.getClasseRefs("collection",o.collections||{})),this.buildCollections(),this.controllers[e]=o},this)},launchControllers:function(){_.each(this.controllers,function(t,e){t.onLaunch(this)},this)},launch:function(){},addListeners:function(t,e){this.eventbus.addListeners(t,e)},getController:function(t){return this.controllers[t]},getModel:function(t){this._modelsCache=this._modelsCache||{};var e=this._modelsCache[t],i=this.getModelConstructor(t);return!e&&i&&(e=this.createModel(t),this._modelsCache[t]=e),e||null},getModelConstructor:function(t){return this.models[t]},createModel:function(t,e){var i=this.getModelConstructor(t),n=null;return i&&(n=new i(_.extend(e||{}))),n},getCollection:function(t){this._collectionsCache=this._collectionsCache||{};var e=this._collectionsCache[t],i=this.getCollectionConstructor(t);return!e&&i&&(e=this.createCollection(t),this._collectionsCache[t]=e),e||null},getCollectionConstructor:function(t){return this.collections[t]},createCollection:function(t){var e=this.getCollectionConstructor(t),i=null;return e&&(i=new e),i},buildCollections:function(){_.each(this.collections,function(t,e){this.getCollection(e)},this)}}),void 0!==Backbone.Application)throw"Native Backbone.Application instance already defined.";Backbone.Application=e,Backbone.Application.extend=Backbone.Model.extend;var i=function(t){_.extend(this,t||{}),this.initialize.apply(this,arguments)};if(_.extend(i.prototype,{name:null,views:{},models:{},collections:{},initialize:function(t){},addListeners:function(t){this.getApplication().addListeners(t,this)},onLaunch:function(t){},getApplication:function(){return this.application},getView:function(t){return this._viewsCache[t]},getViewConstructor:function(t){return this.views[t]},createView:function(t,e){var i=this.getViewConstructor(t),n=_.extend(e||{},{alias:t});return this._viewsCache=this._viewsCache||{},this._viewsCache[t]=new i(n),this._viewsCache[t].options=_.extend({},n),this._viewsCache[t]},getModel:function(t){return this.application.getModel(t)},getModelConstructor:function(t){return this.application.getModelConstructor(t)},createModel:function(t,e){return this.application.createModel(t)},getCollection:function(t){return this.application.getCollection(t)},getCollectionConstructor:function(t){return this.application.getCollectionConstructor(t)},createCollection:function(t){return this.application.createCollection(t)},fireEvent:function(t,e,i){this.application.eventbus.fireEvent(t,e,i)},bindViewEvents:function(t,e){this.unbindViewEvents(t),e=_.isFunction(e)?e.call(this):e;for(var i in e){var n=e[i];_.isFunction(n)||(n=this[e[i]]);var o=i.match(/^(\S+)\s*(.*)$/),s=o[1],a=o[2];n=_.bind(n,this),s+=".bindViewEvents"+t.cid,t.$el.on(s,a,n)}return this},unbindViewEvents:function(t){return t.$el.off(".bindViewEvents"+t.cid),this}}),void 0!==Backbone.Controller)throw"Native Backbone.Controller instance already defined.";Backbone.Controller=i,Backbone.Controller.extend=Backbone.Model.extend;var n=function(t){var e=this;_.extend(this,t||{}),_.extend(Backbone.View.prototype,{alias:null,hidden:!1,getAlias:function(){return this.options.alias},fireEvent:function(t,i){this.trigger.apply(this,arguments),e.fireEvent(this.getAlias(),t,i)},hide:function(){this.$el.hide(),this.hidden=!0},show:function(){this.$el.show(),this.hidden=!1}})};if(_.extend(n.prototype,{pool:{},addListeners:function(t,e){this.pool[e.id]=this.pool[e.id]||{};var i=this.pool[e.id];_.isArray(t)?_.each(t,function(t){this.addListeners(t,e)},this):_.isObject(t)&&_.each(t,function(t,e){_.each(t,function(t,n){i[e]=i[e]||{},i[e][n]=i[e][n]||[],i[e][n].push(t)},this)},this)},fireEvent:function(t,e,i){var n=this.getApplication();_.each(this.pool,function(o,s){var a=o[t];if(a){var l=a[e],r=n.getController(s);_.each(l,function(t){t.apply(r,i)})}},this)},getApplication:function(){return this.application}}),void 0!==Backbone.EventBus)throw"Native Backbone.Application instance already defined.";Backbone.EventBus=n}(),define("core",["backbone","notification"],function(){}),void 0===Common)var Common={};if(Common.component=Common.component||{},Common.Analytics=Common.component.Analytics=new function(){var t;return{initialize:function(e,i){if(void 0===e)throw"Analytics: invalid id.";if(void 0===i||"[object String]"!==Object.prototype.toString.apply(i))throw"Analytics: invalid category type.";t=i,$("head").append(' + + +
    +
    + diff --git a/www/report/main.js b/www/report/main.js new file mode 100644 index 000000000..5717f7120 --- /dev/null +++ b/www/report/main.js @@ -0,0 +1,268 @@ +define([ + 'jquery', + '/api/config', + '/common/hyperscript.js', + '/customize/messages.js', + '/bower_components/nthen/index.js', + '/common/common-hash.js', + '/common/common-util.js', + '/common/cryptget.js', + '/common/cryptpad-common.js', + '/common/outer/cache-store.js', + '/common/common-interface.js', + '/bower_components/chainpad-netflux/chainpad-netflux.js', + '/bower_components/chainpad-crypto/crypto.js', + '/common/userObject.js', + + + '/bower_components/tweetnacl/nacl-fast.min.js', + 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', + 'less!/customize/src/less2/pages/page-report.less', +], function ($, ApiConfig, h, Messages, + nThen, Hash, Util, Crypt, Cryptpad, Cache, UI, CPNetflux, + Crypto, UserObject) { + var $report = $('#cp-report'); + var hash = localStorage.User_hash; + if (!hash) { + return void UI.errorLoadingScreen(Messages.mustLogin); + } + + var addReport = function (str) { + $report.append(h('div', str)); + }; + var checkCache = function (chan, cb) { + Cache.getChannelCache(chan, function (err, val) { + if (err) { + addReport('Cache error:' + err); + } else { + addReport('Cache: ' + val.c.length + ' entries'); + } + cb(); + }); + }; + var onCacheReady = function (info) { + var doc; + try { + doc = info.realtime.getUserDoc(); + JSON.parse(doc); + addReport('Cache ready success: ' + info.id + ' - Length: ' + doc.length); + } catch (e) { + addReport('Cache ready error: ' + info.id + ' - Length: ' + (doc || '').length); + } + }; + + var network; + var proxy; + nThen(function (waitFor) { + Cryptpad.makeNetwork(waitFor(function (err, _network) { + if (err) { + console.error(err); + waitFor.abort(); + return void UI.errorLoadingScreen(err); + } + network = _network; + })); + }).nThen(function (waitFor) { + addReport('BEGIN REPORT'); + var secret = Hash.getSecrets('drive', hash); + addReport('Load drive. ID: ' + secret.channel); + checkCache(secret.channel, waitFor()); + }).nThen(function (waitFor) { + Crypt.get(hash, waitFor(function (err, val) { + if (err) { + console.error(err); + addReport('Load drive error. err: ' + err); + return void waitFor.abort(); + } + try { + proxy = JSON.parse(val); + } catch (e) { + console.error(e); + addReport('Load drive error. Parse error: ' + e); + waitFor.abort(); + } + }), { network: network, onCacheReady: onCacheReady}); + }).nThen(function (waitFor) { + var drive = proxy.drive || {}; + if (!proxy.drive) { + addReport('ERROR: no drive'); + return void waitFor.abort(); + } + addReport('Load drive success.'); + addReport('Public key: '+proxy.edPublic); + addReport('Shared folders: ' + Object.keys(drive.sharedFolders || {}).join(', ')); + addReport('Teams: ' + Object.keys(proxy.teams || {}).join(', ')); + addReport('-------------------'); + + var n = nThen; + Object.keys(drive.sharedFolders || {}).forEach(function (id) { + n = n(function (w) { + var next = w(); + var obj = drive.sharedFolders[id]; + addReport('Load shared folder. ID: ' + id + '. Channel ID: '+ obj.channel); + if (obj.password) { addReport("Password protected"); } + if (!obj.href) { addReport("View only"); } + checkCache(obj.channel, function () { + var parsed = Hash.parsePadUrl(obj.href || obj.roHref); + Crypt.get(parsed.hash, function (err, val, errorObj) { + if (err) { + addReport('ERROR: ' + err); + if (err === "ERESTRICTED") { + addReport('RESTRICTED: ' + (errorObj && errorObj.message)); + } + } else { + addReport('Load shared folder: success. Size: ' + val.length); + } + addReport('-------------------'); + next(); + }, { + network: network, + password: obj.password, + onCacheReady: onCacheReady + }); + + }); + }).nThen; + }); + n(waitFor()); + }).nThen(function () { + addReport('==================='); + var n = nThen; + Object.keys(proxy.teams || {}).forEach(function (id) { + n = n(function (w) { + var next = w(); + var obj = proxy.teams[id]; + var team; + addReport('Load team. ID: ' + id + '. Channel ID: '+ obj.channel); + if (!obj.hash) { addReport("View only"); } + + var teamSecret = Hash.getSecrets('team', obj.hash || obj.roHash, obj.password); + var cryptor = UserObject.createCryptor(teamSecret.keys.secondaryKey); + + // Check team drive + nThen(function (ww) { + addReport('Team drive'); + var _next = ww(); + checkCache(obj.channel, function () { + Crypt.get(obj.hash || obj.roHash, function (err, val) { + if (err) { + addReport('ERROR: ' + err); + addReport('==================='); + next(); + ww.abort(); + } else { + addReport('Team drive success. Size: ' + val.length); + try { + team = JSON.parse(val); + } catch (e) { + addReport('PARSE ERROR: ' + e); + addReport('==================='); + next(); + ww.abort(); + } + addReport('Shared folders: ' + Object.keys(team.drive.sharedFolders || {}).join(', ')); + } + addReport('-------------------'); + _next(); + }, { + network: network, + password: obj.password, + onCacheReady: onCacheReady + }); + }); + }).nThen(function (ww) { + var _next = ww(); + var d = Util.find(obj, ['keys', 'roster']); + + var rosterKeys = d.edit ? Crypto.Team.deriveMemberKeys(d.edit, proxy) + : Crypto.Team.deriveGuestKeys(d.view || ''); + + if (d.channel !== rosterKeys.channel) { + next(); + ww.abort(); + addReport("Invalid roster keys:", d.channel, rosterKeys.channel); + return; + } + addReport('Roster channel: ' + d.channel); + checkCache(d.channel, function () { + var crypto = Crypto.Team.createEncryptor(rosterKeys); + var m = 0; + CPNetflux.start({ + lastKnownHash: d.lastKnownHash || -1, + network: network, + channel: d.channel, + crypto: crypto, + validateKey: rosterKeys.teamEdPublic, + Cache: Cache, + noChainPad: true, + onCacheReady: onCacheReady, + onChannelError: function (obj) { + addReport('ERROR:' + obj.error); + if (obj.error === "ERESTRICTED") { + addReport('RESTRICTED: ' + obj.message); + } + next(); + ww.abort(); + addReport('==================='); + return; + }, + onMessage: function () { + m++; + }, + onReady: function () { + addReport("Roster success. Length: "+m); + addReport('-------------------'); + _next(); + } + }); + }); + }).nThen(function (ww) { + var _next = ww(); + var n = nThen; + var drive = team.drive; + Object.keys(drive.sharedFolders || {}).forEach(function (id) { + n = n(function (w) { + var next = w(); + var _obj = drive.sharedFolders[id]; + addReport('Load shared folder. ID: ' + id + '. Channel ID: '+ _obj.channel); + if (_obj.password) { addReport("Password protected"); } + if (!_obj.href) { addReport("View only"); } + checkCache(_obj.channel, function () { + if (_obj.href && _obj.href.indexOf('#') === -1) { + _obj.href = cryptor.decrypt(_obj.href); + } + var parsed = Hash.parsePadUrl(_obj.href || _obj.roHref); + Crypt.get(parsed.hash, function (err, val, errorObj) { + if (err) { + addReport('ERROR: ' + err); + if (err === "ERESTRICTED") { + addReport('RESTRICTED: ' + (errorObj && errorObj.message)); + } + } else { + addReport('Load shared folder: success. Size: ' + val.length); + } + addReport('-------------------'); + next(); + }, { + network: network, + password: _obj.password, + onCacheReady: onCacheReady + }); + + }); + }).nThen; + }); + n(_next); + }).nThen(next); + + + }).nThen; + }); + n(function () { + addReport('==================='); + addReport('DONE'); + }); + }); + + +}); diff --git a/www/secureiframe/inner.js b/www/secureiframe/inner.js index 01635cbaa..1c5af4a57 100644 --- a/www/secureiframe/inner.js +++ b/www/secureiframe/inner.js @@ -89,9 +89,10 @@ define([ }; // Access modal - create['access'] = function () { + create['access'] = function (data) { require(['/common/inner/access.js'], function (Access) { Access.getAccessModal(common, { + title: data.title, onClose: function () { hideIframe(); } diff --git a/www/secureiframe/main.js b/www/secureiframe/main.js index bb7f05cca..be026194e 100644 --- a/www/secureiframe/main.js +++ b/www/secureiframe/main.js @@ -101,6 +101,7 @@ define([ origin: window.location.origin, pathname: window.location.pathname, feedbackAllowed: Utils.Feedback.state, + channel: config.data.channel, hashes: config.data.hashes, password: config.data.password, propChannels: config.data.getPropChannels(), diff --git a/www/settings/inner.js b/www/settings/inner.js index 38969f823..24e03a4cf 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -84,6 +84,7 @@ define([ 'cp-settings-pad-width', 'cp-settings-pad-spellcheck', 'cp-settings-pad-notif', + 'cp-settings-pad-openlink', ], 'code': [ // Msg.settings_cat_code 'cp-settings-code-indent-unit', @@ -95,6 +96,9 @@ define([ 'kanban': [ // Msg.settings_cat_kanban 'cp-settings-kanban-tags', ], + 'notifications': [ + 'cp-settings-notif-calendar' + ], 'subscription': { onClick: function() { var urls = common.getMetadataMgr().getPrivateData().accounts; @@ -488,41 +492,69 @@ define([ classes: 'btn-danger', multiple: true }, function() { - $button.prop('disabled', 'disabled'); - var password = $form.find('#cp-settings-delete-account').val(); - if (!password) { - return void UI.warn(Messages.error); - } - spinner.spin(); - sframeChan.query("Q_SETTINGS_DELETE_ACCOUNT", { - password: password - }, function(err, data) { - if (data && data.error) { - spinner.hide(); - $button.prop('disabled', ''); - if (data.error === 'INVALID_PASSWORD') { - return void UI.warn(Messages.drive_sfPasswordError); - } - console.error(data.error); + nThen(function (waitFor) { + $button.prop('disabled', 'disabled'); + var priv = metadataMgr.getPrivateData(); + // Check if subscriptions are enabled and you have a premium plan + if (priv.plan && priv.plan !== "custom" && ApiConfig.allowSubscriptions) { + // Also make sure upgradeURL is defined + var url = priv.accounts && priv.accounts.upgradeURL; + if (!url) { return; } + url += '#mysubs'; + var a = h('a', { href:url }, Messages.settings_deleteSubscription); + $(a).click(function (e) { + e.preventDefault(); + common.openUnsafeURL(url); + }); + UI.confirm(h('div', [ + Messages.settings_deleteWarning, h('p', a) + ]), waitFor(function (yes) { + if (!yes) { + $button.prop('disabled', ''); + waitFor.abort(); + } + }), { + ok: Messages.settings_deleteContinue, + okClass: 'btn.btn-danger', + cancelClass: 'btn.btn-primary' + }); + } + }).nThen(function () { + var password = $form.find('#cp-settings-delete-account').val(); + if (!password) { return void UI.warn(Messages.error); } - // Owned drive - if (data.state === true) { - sframeChan.query('Q_SETTINGS_LOGOUT', null, function() {}); - UI.alert(Messages.settings_deleted, function() { - common.gotoURL('/'); - }); - spinner.done(); - return; - } - // Not owned drive - var msg = h('div.cp-app-settings-delete-alert', [ - h('p', Messages.settings_deleteModal), - h('pre', JSON.stringify(data, 0, 2)) - ]); - UI.alert(msg); - spinner.hide(); - $button.prop('disabled', ''); + spinner.spin(); + sframeChan.query("Q_SETTINGS_DELETE_ACCOUNT", { + password: password + }, function(err, data) { + if (data && data.error) { + spinner.hide(); + $button.prop('disabled', ''); + if (data.error === 'INVALID_PASSWORD') { + return void UI.warn(Messages.drive_sfPasswordError); + } + console.error(data.error); + return void UI.warn(Messages.error); + } + // Owned drive + if (data.state === true) { + sframeChan.query('Q_SETTINGS_LOGOUT', null, function() {}); + UI.alert(Messages.settings_deleted, function() { + common.gotoURL('/'); + }); + spinner.done(); + return; + } + // Not owned drive + var msg = h('div.cp-app-settings-delete-alert', [ + h('p', Messages.settings_deleteModal), + h('pre', JSON.stringify(data, 0, 2)) + ]); + UI.alert(msg); + spinner.hide(); + $button.prop('disabled', ''); + }); }); }); @@ -1328,6 +1360,43 @@ define([ cb($cbox); }, true); + create['pad-openlink'] = function() { + var $div = $('
    ', { + 'class': 'cp-settings-pad-openlink cp-sidebarlayout-element' + }); + $('