From 5ec4e39413399cdc9962b47c63a8e1f6834fa372 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 9 Apr 2021 18:10:13 +0200 Subject: [PATCH 001/117] Add basic reminders --- www/common/notifications.js | 19 +++ www/common/outer/calendar.js | 172 ++++++++++++++++++---------- www/common/outer/mailbox.js | 25 ++++ www/common/sframe-common-mailbox.js | 4 +- www/common/toolbar.js | 2 +- 5 files changed, 162 insertions(+), 60 deletions(-) diff --git a/www/common/notifications.js b/www/common/notifications.js index d364bad6c..018093c2a 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -459,6 +459,25 @@ define([ } }; + Messages.reminder_minutes = "{0} will start in {1} minutes!"; // XXX + Messages.reminder_hour = "{0} will start in 1 hour!"; // XXX + handlers['REMINDER'] = function (common, data) { + var content = data.content; + var msg = content.msg.content; + var now = +new Date(); + var start = msg.start; + content.getFormatText = function () { + if ((start - now) > 600000) { + return Messages._getKey('reminder_hour', [Util.fixHTML(msg.title)]); + } + var minutes = Math.round((start - now) / 60000); + return Messages._getKey('reminder_minutes', [Util.fixHTML(msg.title), minutes]); + }; + if (!content.archived) { + content.dismissHandler = defaultDismiss(common, data); + } + }; + // NOTE: don't forget to fixHTML everything returned by "getFormatText" return { diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index e02ad1412..b3d4c707a 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -12,60 +12,6 @@ define([ ], function (Util, Hash, Constants, Realtime, Cache, Messages, nThen, Listmap, Crypto, ChainPad) { var Calendar = {}; - -/* TODO -* Calendar -{ - href, - roHref, - channel, (pinning) - title, (when created from the UI, own calendar has no title) - color -} - - -* Own drive -{ - calendars: { - uid: calendar, - uid: calendar - } -} - -* Team drive -{ - calendars: { - uid: calendar, - uid: calendar - } -} - -* Calendars are listmap -{ - content: {}, - metadata: { - title: "pewpewpew" - } -} - -ctx.calendars[channel] = { - lm: lm, - proxy: lm.proxy? - stores: [teamId, teamId, 1] -} - -* calendar app can subscribe to this module - * when a listmap changes, push an update for this calendar to subscribed tabs -* Ability to open a calendar not stored in the stores but from its URL directly -* No "userlist" visible in the UI -* No framework - - - - - -*/ - var getStore = function (ctx, id) { if (!id || id === 1) { return ctx.store; @@ -109,6 +55,15 @@ ctx.calendars[channel] = { }, ctx.clients); }; + var clearReminders = function (ctx, id) { + var calendar = ctx.calendars[id]; + if (!calendar || !calendar.reminders) { return; } + // Clear existing reminders + Object.keys(calendar.reminders).forEach(function (uid) { + if (!Array.isArray(calendar.reminders[uid])) { return; } + calendar.reminders[uid].forEach(function (to) { clearTimeout(to); }); + }); + }; var closeCalendar = function (ctx, id) { var ctxCal = ctx.calendars[id]; if (!ctxCal) { return; } @@ -116,6 +71,7 @@ ctx.calendars[channel] = { // If the calendar doesn't exist in any other team, stop it and delete it from ctx if (!ctxCal.stores.length) { ctxCal.lm.stop(); + clearReminders(ctx, id); delete ctx.calendars[id]; } }; @@ -133,12 +89,83 @@ ctx.calendars[channel] = { if (cal.title !== data.title) { cal.title = data.title; } }); }; + + var updateEventReminders = function (ctx, reminders, ev) { + var now = +new Date(); + var time10 = now + (600 * 1000); // 10 minutes from now + var time60 = now + (3600 * 1000); // 1 hour from now + var uid = ev.id; + + // Clear reminders for this event + if (Array.isArray(reminders[uid])) { + reminders[uid].forEach(function (to) { clearTimeout(to); }); + } + reminders[uid] = []; + + // No reminder for past events + if (ev.start <= now) { + delete reminders[uid]; + return; + } + + var send = function () { + console.error(ev); + ctx.store.mailbox.showMessage('reminders', { + msg: { + ctime: +new Date(), + type: "REMINDER", + content: ev + }, + hash: 'REMINDER|'+uid + }, null, function () { + }); + }; + var sendNotif = function () { ctx.Store.onReadyEvt.reg(send); }; + + if (ev.start <= time10) { + sendNotif(); + return; + } + + // It starts in more than 10 minutes: prepare the 10 minutes notification + reminders[uid].push(setTimeout(function () { + sendNotif(); + }, (ev.start - time10))); + + if (ev.start <= time60) { return; } + + // It starts in more than 1 hour: prepare the 1 hour notification + reminders[uid].push(setTimeout(function () { + sendNotif(); + }, (ev.start - time60))); + }; + var addReminders = function (ctx, id, ev) { + var calendar = ctx.calendars[id]; + if (!calendar || !calendar.reminders) { return; } + if (calendar.stores.length === 1 && calendar.stores[0] === 0) { return; } + + updateEventReminders(ctx, calendar.reminders, ev); + }; + var addInitialReminders = function (ctx, id) { + var calendar = ctx.calendars[id]; + if (!calendar || !calendar.reminders) { return; } + if (Object.keys(calendar.reminders).length) { return; } // Already initialized + + // No reminders for calendars not stored + if (calendar.stores.length === 1 && calendar.stores[0] === 0) { return; } + + // Re-add all reminders + var content = Util.find(calendar, ['proxy', 'content']); + if (!content) { return; } + Object.keys(content).forEach(function (uid) { + updateEventReminders(ctx, calendar.reminders, content[uid]); + }); + }; var openChannel = function (ctx, cfg, _cb) { var cb = Util.once(Util.mkAsync(_cb || function () {})); var teamId = cfg.storeId; var data = cfg.data; var channel = data.channel; - console.error(cfg); if (!channel) { return; } var c = ctx.calendars[channel]; @@ -193,6 +220,7 @@ ctx.calendars[channel] = { readOnly: !data.href, stores: [teamId], roStores: data.href ? [] : [teamId], + reminders: {}, hashes: {} }; @@ -232,6 +260,7 @@ ctx.calendars[channel] = { if (c.lm) { c.lm.stop(); } c.stores = []; sendUpdate(ctx, c); + clearReminders(ctx, channel); delete ctx.calendars[channel]; }; @@ -290,6 +319,7 @@ ctx.calendars[channel] = { c.cacheready = true; setTimeout(update); if (cb) { cb(null, lm.proxy); } + addInitialReminders(ctx, channel); }).on('ready', function (info) { var md = info.metadata; c.owners = md.owners || []; @@ -306,9 +336,25 @@ ctx.calendars[channel] = { } setTimeout(update); if (cb) { cb(null, lm.proxy); } + addInitialReminders(ctx, channel); }).on('change', [], function () { if (!c.ready) { return; } setTimeout(update); + }).on('change', ['content'], function (o, n, p) { + if (p.length === 2 && n && !o) { // New event + addReminders(ctx, channel, n); + } + if (p.length === 2 && !n && o) { // Deleted event + addReminders(ctx, channel, { + id: p[1], + start: 0 + }); + } + if (p.length === 3 && n && o && p[2] === 'start') { // Update event start + setTimeout(function () { + addReminders(ctx, channel, proxy.content[p[1]]); + }); + } }).on('change', ['metadata'], function () { // if title or color have changed, update our local values var md = proxy.metadata; @@ -627,6 +673,7 @@ ctx.calendars[channel] = { c.proxy.content = c.proxy.content || {}; c.proxy.content[data.id] = data; Realtime.whenRealtimeSyncs(c.lm.realtime, function () { + addReminders(ctx, id, data); sendUpdate(ctx, c); cb(); }); @@ -655,6 +702,7 @@ ctx.calendars[channel] = { ev[key] = changes[key]; }); + // Move to a different calendar? if (changes.calendarId && newC) { newC.proxy.content[data.ev.id] = Util.clone(ev); @@ -664,7 +712,10 @@ ctx.calendars[channel] = { nThen(function (waitFor) { Realtime.whenRealtimeSyncs(c.lm.realtime, waitFor()); if (newC) { Realtime.whenRealtimeSyncs(newC.lm.realtime, waitFor()); } - }).nThen(cb); + }).nThen(function () { + if (changes.start) { addReminders(ctx, id, ev); } + cb(); + }); }; var deleteEvent = function (ctx, data, cId, cb) { var id = data.calendarId; @@ -672,7 +723,12 @@ ctx.calendars[channel] = { if (!c) { return void cb({error: "ENOENT"}); } c.proxy.content = c.proxy.content || {}; delete c.proxy.content[data.id]; - Realtime.whenRealtimeSyncs(c.lm.realtime, cb); + Realtime.whenRealtimeSyncs(c.lm.realtime, function () { + addReminders(ctx, id, { + id: data.id, + start: 0 + }); + }); }; var removeClient = function (ctx, cId) { @@ -693,7 +749,7 @@ ctx.calendars[channel] = { emit: emit, onReady: Util.mkEvent(true), calendars: {}, - clients: [], + clients: [] }; initializeCalendars(ctx, waitFor(function (err) { diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index 6605a55ee..eea275093 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -174,6 +174,18 @@ proxy.mailboxes = { var dismiss = function (ctx, data, cId, cb) { var type = data.type; var hash = data.hash; + + // Reminder messages don't persist + if (/^REMINDER\|/.test(hash)) { + cb(); + delete ctx.boxes.reminders.content[hash]; + hideMessage(ctx, type, hash, ctx.clients.filter(function (clientId) { + return clientId !== cId; + })); + return; + }; + + var box = ctx.boxes[type]; if (!box) { return void cb({error: 'NOT_LOADED'}); } var m = box.data || {}; @@ -548,6 +560,10 @@ proxy.mailboxes = { initializeHistory(ctx); } + ctx.boxes.reminders = { + content: {} + }; + Object.keys(mailboxes).forEach(function (key) { if (TYPES.indexOf(key) === -1) { return; } var m = mailboxes[key]; @@ -588,6 +604,15 @@ proxy.mailboxes = { }); }; + mailbox.showMessage = function (type, msg, cId, cb) { + if (type === "reminders" && msg) { + ctx.boxes.reminders.content[msg.hash] = msg.msg; + // Hide existing messages for this event + hideMessage(ctx, type, msg.hash, ctx.clients); + } + showMessage(ctx, type, msg, cId, cb); + }; + mailbox.open = function (key, m, cb, team, opts) { if (TYPES.indexOf(key) === -1 && !team) { return; } openChannel(ctx, key, m, cb, opts); diff --git a/www/common/sframe-common-mailbox.js b/www/common/sframe-common-mailbox.js index 861ff8d53..215a4866d 100644 --- a/www/common/sframe-common-mailbox.js +++ b/www/common/sframe-common-mailbox.js @@ -65,6 +65,8 @@ define([ if (/^LOCAL\|/.test(data.content.hash)) { $(avatar).addClass('preview'); } + } else if (data.type === 'reminders') { + avatar = h('i.fa.fa-calendar.cp-broadcast.preview'); } else if (userData && typeof(userData) === "object" && userData.profile) { avatar = h('span.cp-avatar'); Common.displayAvatar($(avatar), userData.avatar, userData.displayName || userData.name); @@ -117,7 +119,7 @@ define([ // Call the onMessage handlers var isNotification = function (type) { - return type === "notifications" || /^team-/.test(type) || type === "broadcast"; + return type === "notifications" || /^team-/.test(type) || type === "broadcast" || type === "reminders"; }; var pushMessage = function (data, handler) { var todo = function (f) { diff --git a/www/common/toolbar.js b/www/common/toolbar.js index e2ad32ea6..583a9168a 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -1148,7 +1148,7 @@ MessengerUI, Messages) { $button.addClass('fa-bell'); }; - Common.mailbox.subscribe(['notifications', 'team', 'broadcast'], { + Common.mailbox.subscribe(['notifications', 'team', 'broadcast', 'reminders'], { onMessage: function (data, el) { if (el) { $(div).prepend(el); From 8ebc71cd963b3736de9ee3da0f7ac7976f186289 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 12 Apr 2021 11:19:12 +0200 Subject: [PATCH 002/117] Disable calendar notifications --- www/common/outer/calendar.js | 3 ++- www/common/outer/mailbox.js | 10 +++++++-- www/settings/inner.js | 42 ++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index b3d4c707a..07640a711 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -109,7 +109,8 @@ define([ } var send = function () { - console.error(ev); + var hide = Util.find(ctx, ['store', 'proxy', 'settings', 'general', 'calendar', 'hideNotif']); + if (hide) { console.error('hidden'); return; } ctx.store.mailbox.showMessage('reminders', { msg: { ctime: +new Date(), diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index eea275093..4c652e292 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -520,7 +520,10 @@ proxy.mailboxes = { msg: ctx.boxes[type].content[h], hash: h }; - showMessage(ctx, type, message, cId); + showMessage(ctx, type, message, cId, function (obj) { + Notify.system(undefined, obj.msg); + cb(); + }); }); }); // Subscribe to new notifications @@ -610,7 +613,10 @@ proxy.mailboxes = { // Hide existing messages for this event hideMessage(ctx, type, msg.hash, ctx.clients); } - showMessage(ctx, type, msg, cId, cb); + showMessage(ctx, type, msg, cId, function (obj) { + Notify.system(undefined, obj.msg); + if (cb) { cb(); } + }); }; mailbox.open = function (key, m, cb, team, opts) { diff --git a/www/settings/inner.js b/www/settings/inner.js index 5404d399c..338b1ccc6 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -95,6 +95,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; @@ -1566,6 +1569,43 @@ define([ cb($d); }, true); + Messages.settings_notifCalendarTitle = "Calendar notifications"; + Messages.settings_notifCalendarHint = "You can disable completely calendar notifications for incoming events."; + Messages.settings_notifCalendarCheckbox = "Enable calendar notifications"; + + makeBlock('notif-calendar', function(cb) { // Msg.settings_notifCalendarHint, .settings_notifCalendarTitle + + var $cbox = $(UI.createCheckbox('cp-settings-cache', + Messages.settings_notifCalendarCheckbox, + false, { label: { class: 'noTitle' } })); + var spinner = UI.makeSpinner($cbox); + + var $checkbox = $cbox.find('input').on('change', function() { + spinner.spin(); + var val = !$checkbox.is(':checked'); + common.setAttribute(['general', 'calendar', 'hideNotif'], val, function(e) { + if (e) { + console.error(e); + // error: restore previous value + if (val) { $checkbox.attr('checked', ''); } + else { $checkbox.attr('checked', 'checked'); } + spinner.hide(); + return void console.error(e); + } + spinner.done(); + }); + }); + + common.getAttribute(['general', 'calendar', 'hideNotif'], function(e, val) { + if (e) { return void console.error(e); } + if (!val) { + $checkbox.attr('checked', 'checked'); + } + }); + + cb($cbox[0]); + }, true); + // Settings app var createUsageButton = function() { @@ -1595,8 +1635,10 @@ define([ subscription: 'fa fa-star-o', kanban: 'cptools cptools-kanban', style: 'cptools cptools-palette', + notifications: 'fa fa-bell' }; + Messages.settings_cat_notifications = Messages.notificationsPage; var createLeftside = function() { var $categories = $('
', { 'class': 'cp-sidebarlayout-categories' }) .appendTo(APP.$leftside); From f3fd7011f831a0fdcbc06a407b799fba4dab0efd Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 12 Apr 2021 11:21:40 +0200 Subject: [PATCH 003/117] lint compliance --- www/common/outer/mailbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index 4c652e292..34af071d6 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -183,7 +183,7 @@ proxy.mailboxes = { return clientId !== cId; })); return; - }; + } var box = ctx.boxes[type]; From a6c5ddf1f3daac7427fb95bb6f64883cdabed635 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 12 Apr 2021 14:16:42 +0200 Subject: [PATCH 004/117] Remove a console log --- www/common/outer/calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 07640a711..e66db22a2 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -110,7 +110,7 @@ define([ var send = function () { var hide = Util.find(ctx, ['store', 'proxy', 'settings', 'general', 'calendar', 'hideNotif']); - if (hide) { console.error('hidden'); return; } + if (hide) { return; } ctx.store.mailbox.showMessage('reminders', { msg: { ctime: +new Date(), From e5d923e52107c5db4dcd8daa99e69447899f65b6 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 12 Apr 2021 16:38:39 +0200 Subject: [PATCH 005/117] Fix calendar notifications timeout --- www/common/outer/calendar.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index e66db22a2..016e95abb 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -128,6 +128,11 @@ define([ return; } + // setTimeout only work with 32bit timeout values. + // FIXME: call this function again in xxx days to reload these missing timeout? + if (ev.start - time10 >= 2147483647) { return; } + + // It starts in more than 10 minutes: prepare the 10 minutes notification reminders[uid].push(setTimeout(function () { sendNotif(); From 11c0b752bde01ec9f5d4bf5f20e566f3d9d0904e Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 12 Apr 2021 17:08:18 +0200 Subject: [PATCH 006/117] Add notifications for past events since our last visit --- www/common/cryptpad-common.js | 9 ++++++++- www/common/notifications.js | 22 ++++++++++++++++++++-- www/common/outer/calendar.js | 29 +++++++++++++++++++++-------- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index b639eebab..51ec09ef6 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2288,7 +2288,8 @@ define([ cache: rdyCfg.cache, noDrive: rdyCfg.noDrive, disableCache: localStorage['CRYPTPAD_STORE|disableCache'], - driveEvents: !rdyCfg.noDrive //rdyCfg.driveEvents // Boolean + driveEvents: !rdyCfg.noDrive, //rdyCfg.driveEvents // Boolean + lastVisit: Number(localStorage.lastVisit) || undefined }; common.userHash = userHash; @@ -2570,6 +2571,12 @@ define([ AppConfig.afterLogin(common, waitFor()); } }).nThen(function () { + // Last visit is used to warn you about missed events from your calendars + localStorage.lastVisit = +new Date(); + setInterval(function () { + // Bump last visit every minute + localStorage.lastVisit = +new Date(); + }, 60000); f(void 0, env); if (typeof(window.onhashchange) === 'function') { window.onhashchange(); } }); diff --git a/www/common/notifications.js b/www/common/notifications.js index 018093c2a..35ebb447c 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -459,19 +459,37 @@ define([ } }; + Messages.reminder_missed = "You missed {0} on {1}"; // XXX + Messages.reminder_inProgress = "{0} has started on {1}"; // XXX + Messages.reminder_inProgressAllDay = "{0} is happening today"; // XXX Messages.reminder_minutes = "{0} will start in {1} minutes!"; // XXX Messages.reminder_hour = "{0} will start in 1 hour!"; // XXX handlers['REMINDER'] = function (common, data) { var content = data.content; var msg = content.msg.content; + var missed = content.msg.missed; var now = +new Date(); var start = msg.start; + var title = Util.fixHTML(msg.title); content.getFormatText = function () { + // Missed events + if (start < now && missed) { + return Messages._getKey('reminder_missed', [title, new Date(start).toLocaleString()]); + } + // In progress, is all day + if (start < now && msg.isAllDay) { + return Messages._getKey('reminder_inProgressAllDay', [title]); + } + // In progress, normal event + if (start < now) { + return Messages._getKey('reminder_inProgress', [title, new Date(start).toLocaleString()]); + } + // Not started yet if ((start - now) > 600000) { - return Messages._getKey('reminder_hour', [Util.fixHTML(msg.title)]); + return Messages._getKey('reminder_hour', [title]); } var minutes = Math.round((start - now) / 60000); - return Messages._getKey('reminder_minutes', [Util.fixHTML(msg.title), minutes]); + return Messages._getKey('reminder_minutes', [title, minutes]); }; if (!content.archived) { content.dismissHandler = defaultDismiss(common, data); diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 016e95abb..2113dcc69 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -90,31 +90,43 @@ define([ }); }; - var updateEventReminders = function (ctx, reminders, ev) { + var updateEventReminders = function (ctx, reminders, ev, useLastVisit) { var now = +new Date(); var time10 = now + (600 * 1000); // 10 minutes from now var time60 = now + (3600 * 1000); // 1 hour from now var uid = ev.id; + ctx.store.data.lastVisit = 1617922639683; // XXX Friday Apr 09 + // Clear reminders for this event if (Array.isArray(reminders[uid])) { reminders[uid].forEach(function (to) { clearTimeout(to); }); } reminders[uid] = []; - // No reminder for past events - if (ev.start <= now) { + var last = ctx.store.data.lastVisit; + // XXX add a limit to make sure we don't go too far in the past? + var missed = useLastVisit && ev.start > last && ev.end <= now; + if (ev.end <= now && !missed) { + // No reminder for past events delete reminders[uid]; return; } + // XXX + // TODO + // use custom notifications per event + // if you missed a notification, show it instantly (eg: load cryptpad 45min before an event, show the 1h notification) + var send = function () { var hide = Util.find(ctx, ['store', 'proxy', 'settings', 'general', 'calendar', 'hideNotif']); if (hide) { return; } + var ctime = ev.start <= now ? ev.start : +new Date(); // Correct order for past events ctx.store.mailbox.showMessage('reminders', { msg: { - ctime: +new Date(), + ctime: ctime, type: "REMINDER", + missed: Boolean(missed), content: ev }, hash: 'REMINDER|'+uid @@ -152,7 +164,7 @@ define([ updateEventReminders(ctx, calendar.reminders, ev); }; - var addInitialReminders = function (ctx, id) { + var addInitialReminders = function (ctx, id, useLastVisit) { var calendar = ctx.calendars[id]; if (!calendar || !calendar.reminders) { return; } if (Object.keys(calendar.reminders).length) { return; } // Already initialized @@ -164,7 +176,7 @@ define([ var content = Util.find(calendar, ['proxy', 'content']); if (!content) { return; } Object.keys(content).forEach(function (uid) { - updateEventReminders(ctx, calendar.reminders, content[uid]); + updateEventReminders(ctx, calendar.reminders, content[uid], useLastVisit); }); }; var openChannel = function (ctx, cfg, _cb) { @@ -325,7 +337,7 @@ define([ c.cacheready = true; setTimeout(update); if (cb) { cb(null, lm.proxy); } - addInitialReminders(ctx, channel); + addInitialReminders(ctx, channel, cfg.lastVisitNotif); }).on('ready', function (info) { var md = info.metadata; c.owners = md.owners || []; @@ -342,7 +354,7 @@ define([ } setTimeout(update); if (cb) { cb(null, lm.proxy); } - addInitialReminders(ctx, channel); + addInitialReminders(ctx, channel, cfg.lastVisitNotif); }).on('change', [], function () { if (!c.ready) { return; } setTimeout(update); @@ -455,6 +467,7 @@ define([ decryptTeamCalendarHref(store, cal); openChannel(ctx, { storeId: storeId, + lastVisitNotif: true, data: cal }); }); From 362a439cb548ad6ebaf22dd0983b66f66bd64ba7 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 12 Apr 2021 17:55:56 +0200 Subject: [PATCH 007/117] Support custom event notifications --- www/common/notifications.js | 40 ++++++++++++++++++++++++----- www/common/outer/calendar.js | 38 ++++++++++++++------------- www/common/sframe-common-mailbox.js | 9 +++++++ 3 files changed, 63 insertions(+), 24 deletions(-) diff --git a/www/common/notifications.js b/www/common/notifications.js index 35ebb447c..f797a984b 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -460,22 +460,37 @@ define([ }; Messages.reminder_missed = "You missed {0} on {1}"; // XXX + Messages.reminder_now = "{0} is starting!"; // XXX Messages.reminder_inProgress = "{0} has started on {1}"; // XXX Messages.reminder_inProgressAllDay = "{0} is happening today"; // XXX Messages.reminder_minutes = "{0} will start in {1} minutes!"; // XXX - Messages.reminder_hour = "{0} will start in 1 hour!"; // XXX + Messages.reminder_time = "{0} will start today at {1}!"; // XXX + Messages.reminder_date = "{0} will start on {1}!"; // XXX + var getDate = function (time) { + return new Date(time).toLocaleDateString(); + }; handlers['REMINDER'] = function (common, data) { var content = data.content; var msg = content.msg.content; var missed = content.msg.missed; - var now = +new Date(); var start = msg.start; var title = Util.fixHTML(msg.title); + var i = 0; content.getFormatText = function () { + var now = +new Date(); + + // Events that have already started + var wasRefresh = content.autorefresh; + content.autorefresh = false; + // Missed events if (start < now && missed) { return Messages._getKey('reminder_missed', [title, new Date(start).toLocaleString()]); } + // Starting now + if (start < now && wasRefresh) { + return Messages._getKey('reminder_now', [title]); + } // In progress, is all day if (start < now && msg.isAllDay) { return Messages._getKey('reminder_inProgressAllDay', [title]); @@ -484,12 +499,25 @@ define([ if (start < now) { return Messages._getKey('reminder_inProgress', [title, new Date(start).toLocaleString()]); } + // Not started yet - if ((start - now) > 600000) { - return Messages._getKey('reminder_hour', [title]); + + // In less than an hour: show countdown in minutes + if ((start - now) < 3600000) { + var minutes = Math.round((start - now) / 60000); + content.autorefresh = true; + return Messages._getKey('reminder_minutes', [title, minutes]); + } + + // Not today: show full date + var nowDateStr = new Date().toLocaleDateString(); + var startDate = new Date(start); + if (nowDateStr !== startDate.toLocaleDateString()) { + return Messages._getKey('reminder_date', [title, startDate.toLocaleString()]); } - var minutes = Math.round((start - now) / 60000); - return Messages._getKey('reminder_minutes', [title, minutes]); + + // Today: show time + return Messages._getKey('reminder_time', [title, startDate.toLocaleTimeString()]); }; if (!content.archived) { content.dismissHandler = defaultDismiss(common, data); diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 2113dcc69..c23b647c3 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -96,7 +96,7 @@ define([ var time60 = now + (3600 * 1000); // 1 hour from now var uid = ev.id; - ctx.store.data.lastVisit = 1617922639683; // XXX Friday Apr 09 + //ctx.store.data.lastVisit = 1617922639683; // XXX Friday Apr 09, used to test // Clear reminders for this event if (Array.isArray(reminders[uid])) { @@ -135,27 +135,29 @@ define([ }; var sendNotif = function () { ctx.Store.onReadyEvt.reg(send); }; - if (ev.start <= time10) { - sendNotif(); - return; - } - - // setTimeout only work with 32bit timeout values. - // FIXME: call this function again in xxx days to reload these missing timeout? - if (ev.start - time10 >= 2147483647) { return; } + var notifs = [600000, 3600000]; // 10min, 60min + notifs.sort(); + notifs.some(function (delay) { + var time = now + delay; - // It starts in more than 10 minutes: prepare the 10 minutes notification - reminders[uid].push(setTimeout(function () { - sendNotif(); - }, (ev.start - time10))); + // setTimeout only work with 32bit timeout values. If the event is too far away, + // ignore this event for now + // FIXME: call this function again in xxx days to reload these missing timeout? + if (ev.start - time >= 2147483647) { return true; } - if (ev.start <= time60) { return; } + // If we're too late to send a notification, send it instantly and ignore + // all notifications that were supposed to be sent even earlier + if (ev.start <= time) { + sendNotif(); + return true; + } - // It starts in more than 1 hour: prepare the 1 hour notification - reminders[uid].push(setTimeout(function () { - sendNotif(); - }, (ev.start - time60))); + // It starts in more than "delay": prepare the notification + reminders[uid].push(setTimeout(function () { + sendNotif(); + }, (ev.start - time))); + }); }; var addReminders = function (ctx, id, ev) { var calendar = ctx.calendars[id]; diff --git a/www/common/sframe-common-mailbox.js b/www/common/sframe-common-mailbox.js index 215a4866d..7ea717d35 100644 --- a/www/common/sframe-common-mailbox.js +++ b/www/common/sframe-common-mailbox.js @@ -87,6 +87,15 @@ define([ if (typeof(data.content.getFormatText) === "function") { $(notif).find('.cp-notification-content p').html(data.content.getFormatText()); + if (data.content.autorefresh) { + var it = setInterval(function () { + if (!data.content.autorefresh) { + clearInterval(it); + return; + } + $(notif).find('.cp-notification-content p').html(data.content.getFormatText()); + }, 60000); + } } if (data.content.isClickable) { From 656ebf432e8acfe3fde81acc8a075608e1bb2077 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 13 Apr 2021 10:35:22 +0200 Subject: [PATCH 008/117] Add XXX --- www/common/notifications.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/www/common/notifications.js b/www/common/notifications.js index f797a984b..2a7f31fbf 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -483,21 +483,27 @@ define([ var wasRefresh = content.autorefresh; content.autorefresh = false; + var nowDateStr = new Date().toLocaleDateString(); + var startDate = new Date(start); + // Missed events if (start < now && missed) { - return Messages._getKey('reminder_missed', [title, new Date(start).toLocaleString()]); + return Messages._getKey('reminder_missed', [title, startDate.toLocaleString()]); } // Starting now if (start < now && wasRefresh) { return Messages._getKey('reminder_now', [title]); } // In progress, is all day + // XXX fix this... + // XXX start and end time may not matter... + // XXX and timezone? if (start < now && msg.isAllDay) { return Messages._getKey('reminder_inProgressAllDay', [title]); } // In progress, normal event if (start < now) { - return Messages._getKey('reminder_inProgress', [title, new Date(start).toLocaleString()]); + return Messages._getKey('reminder_inProgress', [title, startDate.toLocaleString()]); } // Not started yet @@ -510,8 +516,6 @@ define([ } // Not today: show full date - var nowDateStr = new Date().toLocaleDateString(); - var startDate = new Date(start); if (nowDateStr !== startDate.toLocaleDateString()) { return Messages._getKey('reminder_date', [title, startDate.toLocaleString()]); } From 95c16f5c6559b165c82a3c4225131b93b55c8019 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 13 Apr 2021 15:21:24 +0200 Subject: [PATCH 009/117] Custom reminders --- customize.dist/src/less2/include/forms.less | 2 +- www/calendar/app-calendar.less | 35 +++++ www/calendar/inner.js | 143 +++++++++++++++++++- www/common/outer/calendar.js | 7 +- www/settings/inner.js | 2 +- 5 files changed, 181 insertions(+), 8 deletions(-) diff --git a/customize.dist/src/less2/include/forms.less b/customize.dist/src/less2/include/forms.less index 969c873c7..ffe061fa3 100644 --- a/customize.dist/src/less2/include/forms.less +++ b/customize.dist/src/less2/include/forms.less @@ -122,7 +122,7 @@ &.small { line-height: initial; padding: 5px; - height: auto; + height: auto !important; } &:hover, &:not(:disabled):not(.disabled):active, &:focus { diff --git a/www/calendar/app-calendar.less b/www/calendar/app-calendar.less index bc0f47a48..daf1321a7 100644 --- a/www/calendar/app-calendar.less +++ b/www/calendar/app-calendar.less @@ -161,6 +161,41 @@ } } + .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 { + display: flex; + flex-flow: column; + .cp-notif-entry { + span:not(:last-child) { + margin-right: 20px; + } + } + } + .cp-notif-empty { + display: none; + } + .cp-calendar-notif-list:empty ~ .cp-notif-empty { + display: block; + } + .cp-calendar-notif-form { + align-items: center; + } + } + .cp-calendar-close { height: auto; line-height: initial; diff --git a/www/calendar/inner.js b/www/calendar/inner.js index 830674341..7000df482 100644 --- a/www/calendar/inner.js +++ b/www/calendar/inner.js @@ -1,5 +1,6 @@ define([ 'jquery', + 'json.sortify', '/bower_components/chainpad-crypto/crypto.js', '/common/toolbar.js', '/bower_components/nthen/index.js', @@ -26,6 +27,7 @@ define([ 'less!/calendar/app-calendar.less', ], function ( $, + JSONSortify, Crypto, Toolbar, nThen, @@ -76,6 +78,14 @@ Messages.calendar_loc = "Location"; Messages.calendar_location = "Location: {0}"; Messages.calendar_allDay = "All day"; +Messages.calendar_minutes = "Minutes"; +Messages.calendar_hours = "Hours"; +Messages.calendar_days = "Days"; + +Messages.calendar_notifications = "Reminders"; +Messages.calendar_addNotification = "Add reminder"; +Messages.calendar_noNotification = "None"; + var onCalendarsUpdate = Util.mkEvent(); var newCalendar = function (data, cb) { @@ -225,8 +235,15 @@ Messages.calendar_allDay = "All day"; })()) { getTime = undefined; } var templates = { - popupSave: function () { return Messages.settings_save; }, - popupUpdate: function() { return Messages.calendar_update; }, + // XXX find template for "xxx more" in month view + 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; + }, popupEdit: function() { return Messages.poll_edit; }, popupDelete: function() { return Messages.kanban_delete; }, popupDetailLocation: function(schedule) { @@ -490,7 +507,7 @@ Messages.calendar_allDay = "All day"; if (cal.owned) { key += Messages.calendar_deleteOwned; } - UI.confirm(Messages.calendar_deleteConfirm, function (yes) { + UI.confirm(key, function (yes) { if (!yes) { return; } deleteCalendar({ id: id, @@ -671,6 +688,7 @@ Messages.calendar_allDay = "All day"; // 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 schedule = { id: Util.uid(), @@ -681,6 +699,7 @@ Messages.calendar_allDay = "All day"; start: event.start, isAllDay: event.isAllDay, end: event.end, + reminders: reminders }; newEvent(schedule, function (err) { @@ -698,6 +717,12 @@ Messages.calendar_allDay = "All day"; 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 @@ -791,6 +816,114 @@ Messages.calendar_allDay = "All day"; }; + 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; + // XXX 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 list = []; + 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.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.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', value), + h('span', Messages['calendar_'+unit]), + 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 = { @@ -877,6 +1010,10 @@ Messages.calendar_allDay = "All day"; } 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 onCalendarEditPopup = function (el) { var $el = $(el); diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 11516e2ca..33bf7390b 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -135,10 +135,11 @@ define([ }; var sendNotif = function () { ctx.Store.onReadyEvt.reg(send); }; - var notifs = [600000, 3600000]; // 10min, 60min + var notifs = ev.reminders || []; notifs.sort(); - notifs.some(function (delay) { + notifs.some(function (delayMinutes) { + var delay = delayMinutes * 60000; var time = now + delay; // setTimeout only work with 32bit timeout values. If the event is too far away, @@ -734,7 +735,7 @@ define([ Realtime.whenRealtimeSyncs(c.lm.realtime, waitFor()); if (newC) { Realtime.whenRealtimeSyncs(newC.lm.realtime, waitFor()); } }).nThen(function () { - if (changes.start) { addReminders(ctx, id, ev); } + if (changes.start || changes.reminders) { addReminders(ctx, id, ev); } sendUpdate(ctx, c); if (newC) { sendUpdate(ctx, newC); } cb(); diff --git a/www/settings/inner.js b/www/settings/inner.js index 7152994fd..85aa27c10 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -1565,7 +1565,7 @@ define([ cb($d); }, true); - Messages.settings_notifCalendarTitle = "Calendar notifications"; + Messages.settings_notifCalendarTitle = "Calendar notifications"; // XXX Messages.settings_notifCalendarHint = "You can disable completely calendar notifications for incoming events."; Messages.settings_notifCalendarCheckbox = "Enable calendar notifications"; From 1526f933edff237a9393d4dada96ad3780e18d2a Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 13 Apr 2021 15:24:22 +0200 Subject: [PATCH 010/117] lint compliance --- www/calendar/inner.js | 1 - www/common/notifications.js | 4 ---- www/common/outer/calendar.js | 2 -- 3 files changed, 7 deletions(-) diff --git a/www/calendar/inner.js b/www/calendar/inner.js index 7000df482..881d6ee2d 100644 --- a/www/calendar/inner.js +++ b/www/calendar/inner.js @@ -844,7 +844,6 @@ Messages.calendar_noNotification = "None"; max: 60 }); var $number = $(number); - var list = []; var options = ['minutes', 'hours', 'days'].map(function (k) { return { tag: 'a', diff --git a/www/common/notifications.js b/www/common/notifications.js index 46c92a147..2c6a4b24c 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -468,16 +468,12 @@ define([ Messages.reminder_minutes = "{0} will start in {1} minutes!"; // XXX Messages.reminder_time = "{0} will start today at {1}!"; // XXX Messages.reminder_date = "{0} will start on {1}!"; // XXX - var getDate = function (time) { - return new Date(time).toLocaleDateString(); - }; handlers['REMINDER'] = function (common, data) { var content = data.content; var msg = content.msg.content; var missed = content.msg.missed; var start = msg.start; var title = Util.fixHTML(msg.title); - var i = 0; content.getFormatText = function () { var now = +new Date(); diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 33bf7390b..88ea20766 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -92,8 +92,6 @@ define([ var updateEventReminders = function (ctx, reminders, ev, useLastVisit) { var now = +new Date(); - var time10 = now + (600 * 1000); // 10 minutes from now - var time60 = now + (3600 * 1000); // 1 hour from now var uid = ev.id; //ctx.store.data.lastVisit = 1617922639683; // XXX Friday Apr 09, used to test From 70b201003c49175603e348a85817153020873fc9 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 13 Apr 2021 15:31:06 +0200 Subject: [PATCH 011/117] Fix calendar notification UI --- www/calendar/app-calendar.less | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/calendar/app-calendar.less b/www/calendar/app-calendar.less index daf1321a7..77262ce12 100644 --- a/www/calendar/app-calendar.less +++ b/www/calendar/app-calendar.less @@ -193,6 +193,9 @@ } .cp-calendar-notif-form { align-items: center; + input { + width: 100px; + } } } From 1d9a05e782446cd41286a007f8d3914297fe22c5 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 13 Apr 2021 16:46:04 +0200 Subject: [PATCH 012/117] Fix reminders --- www/common/outer/calendar.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 41fdc40bc..ed6da0531 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -754,7 +754,18 @@ define([ Realtime.whenRealtimeSyncs(c.lm.realtime, waitFor()); if (newC) { Realtime.whenRealtimeSyncs(newC.lm.realtime, waitFor()); } }).nThen(function () { - if (changes.start || changes.reminders) { addReminders(ctx, id, ev); } + if (newC) { + // Move reminders to the new calendar + addReminders(ctx, id, { + id: ev.id, + start: 0 + }); + addReminders(ctx, ev.calendarId, ev); + } else if (changes.start || changes.reminders || changes.isAllDay) { + // Update reminders + addReminders(ctx, id, ev); + } + sendUpdate(ctx, c); if (newC) { sendUpdate(ctx, newC); } cb(); From a60e1078f9eeb6c4f47f2ae43a824e94a050ace3 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 13 Apr 2021 16:54:46 +0200 Subject: [PATCH 013/117] Fix reminders for all day events --- www/common/notifications.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/www/common/notifications.js b/www/common/notifications.js index 2c6a4b24c..7a64815cc 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -483,6 +483,9 @@ define([ var nowDateStr = new Date().toLocaleDateString(); var startDate = new Date(start); + if (msg.isAllDay && msg.startDay) { + startDate = new Date(msg.startDay); + } // Missed events if (start < now && missed) { @@ -493,9 +496,6 @@ define([ return Messages._getKey('reminder_now', [title]); } // In progress, is all day - // XXX fix this... - // XXX start and end time may not matter... - // XXX and timezone? if (start < now && msg.isAllDay) { return Messages._getKey('reminder_inProgressAllDay', [title]); } @@ -506,6 +506,11 @@ define([ // Not started yet + // No precise time for allDay events + if (msg.isAllDay) { + return Messages._getKey('reminder_date', [title, startDate.toLocaleDateString()]); + } + // In less than an hour: show countdown in minutes if ((start - now) < 3600000) { var minutes = Math.round((start - now) / 60000); From 2163c5c31f1f7b2f64d2735f2b5ead2e6cff9a4f Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 13 Apr 2021 17:44:35 +0200 Subject: [PATCH 014/117] Fix allDay events notifications --- www/common/outer/calendar.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index ed6da0531..9d399f310 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -90,8 +90,9 @@ define([ }); }; - var updateEventReminders = function (ctx, reminders, ev, useLastVisit) { + var updateEventReminders = function (ctx, reminders, _ev, useLastVisit) { var now = +new Date(); + var ev = Util.clone(_ev); var uid = ev.id; //ctx.store.data.lastVisit = 1617922639683; // XXX Friday Apr 09, used to test @@ -103,6 +104,12 @@ define([ reminders[uid] = []; var last = ctx.store.data.lastVisit; + + if (ev.isAllDay) { + if (ev.startDay) { ev.start = +new Date(ev.startDay); } + if (ev.endDay) { ev.end = +new Date(ev.endDay); } + } + // XXX add a limit to make sure we don't go too far in the past? var missed = useLastVisit && ev.start > last && ev.end <= now; if (ev.end <= now && !missed) { From 867e0e8cd38209861f947c462c5a59d1a6f15a35 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 13 Apr 2021 17:45:18 +0200 Subject: [PATCH 015/117] Fix event creation --- www/common/outer/calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 9d399f310..cafa028f1 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -704,8 +704,8 @@ define([ data.startDay = startDate.getFullYear() + '-' + (startDate.getMonth()+1) + '-' + startDate.getDate(); data.endDay = endDate.getFullYear() + '-' + (endDate.getMonth()+1) + '-' + endDate.getDate(); } else { - delete ev.startDay; - delete ev.endDay; + delete data.startDay; + delete data.endDay; } c.proxy.content = c.proxy.content || {}; From a0b67cc364107bc5da4316b447343cb0fbbca0c9 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 14 Apr 2021 11:09:21 +0200 Subject: [PATCH 016/117] Fix allDay reminders notifications end time --- www/common/outer/calendar.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index cafa028f1..90d0e9c6b 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -107,7 +107,13 @@ define([ if (ev.isAllDay) { if (ev.startDay) { ev.start = +new Date(ev.startDay); } - if (ev.endDay) { ev.end = +new Date(ev.endDay); } + if (ev.endDay) { + var endDate = new Date(obj.endDay); + endDate.setHours(23); + endDate.setMinutes(59); + endDate.setSeconds(59); + obj.end = +endDate; + } } // XXX add a limit to make sure we don't go too far in the past? From 6131e89505e7d81fd1324cce0d03b17678f8d877 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 14 Apr 2021 11:42:41 +0200 Subject: [PATCH 017/117] Fix type error in reminders --- www/common/outer/calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 90d0e9c6b..0d5fa1f2d 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -108,11 +108,11 @@ define([ if (ev.isAllDay) { if (ev.startDay) { ev.start = +new Date(ev.startDay); } if (ev.endDay) { - var endDate = new Date(obj.endDay); + var endDate = new Date(ev.endDay); endDate.setHours(23); endDate.setMinutes(59); endDate.setSeconds(59); - obj.end = +endDate; + ev.end = +endDate; } } From a2d52d7026c4e737f9992cf607d90ca512027914 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 14 Apr 2021 15:47:57 +0200 Subject: [PATCH 018/117] Fix undefined notifications --- www/common/outer/mailbox.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index fa8da5712..a7269c6e5 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -501,8 +501,11 @@ proxy.mailboxes = { hash: h }; showMessage(ctx, type, message, cId, function (obj) { + if (obj.error) { return; } + // Notify only if "requiresNotif" is true + if (!message.msg || !message.msg.requiresNotif) { return; } Notify.system(undefined, obj.msg); - cb(); + delete message.msg.requiresNotif; }); }); }); @@ -590,6 +593,9 @@ proxy.mailboxes = { mailbox.showMessage = function (type, msg, cId, cb) { if (type === "reminders" && msg) { ctx.boxes.reminders.content[msg.hash] = msg.msg; + if (!ctx.clients.length) { + ctx.boxes.reminders.content[msg.hash].requiresNotif = true; + } // Hide existing messages for this event hideMessage(ctx, type, msg.hash, ctx.clients); } From 8a7f5556c44b8c00610c398229e1f8f3190ab1b4 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 15 Apr 2021 11:10:11 +0200 Subject: [PATCH 019/117] Calendar export --- www/calendar/export.js | 121 +++++++++++++++++++++++++++++++++++++++++ www/calendar/inner.js | 63 +++++++++++++++++++++ 2 files changed, 184 insertions(+) create mode 100644 www/calendar/export.js diff --git a/www/calendar/export.js b/www/calendar/export.js new file mode 100644 index 000000000..0d5921e73 --- /dev/null +++ b/www/calendar/export.js @@ -0,0 +1,121 @@ +// 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 md = userDoc.metadata; + + 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' + ]); + // XXX ACTION:EMAIL + // XXX ATTENDEE:mailto:xxx@xxx.xxx + // XXX SUMMARY:Alarm notification + }); + } + + // XXX add hidden data (from imports) + + ICS.push('END:VEVENT'); + }); + + ICS.push('END:VCALENDAR'); + + return new Blob([ ICS.join('\n') ], { type: 'text/calendar;charset=utf-8' }); + }; + + return module; +}); + + diff --git a/www/calendar/inner.js b/www/calendar/inner.js index f74f3cfaf..9986206f0 100644 --- a/www/calendar/inner.js +++ b/www/calendar/inner.js @@ -15,12 +15,14 @@ define([ '/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', @@ -41,9 +43,11 @@ define([ Messages, AppConfig, Calendar, + Export, Share, Access, Properties ) { + var SaveAs = window.saveAs; var APP = window.APP = { calendars: {} }; @@ -453,6 +457,65 @@ Messages.calendar_allDay = "All day"; return true; } }); + + if (!data.readOnly) { + options.push({ + tag: 'a', + attributes: { + 'class': 'fa fa-upload', + }, + content: h('span', Messages.importButton), + action: function (e) { + e.stopPropagation(); + 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: { From bd2cfea3d9045b998f9ce86ee6bc90a401165c6b Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 15 Apr 2021 11:11:46 +0200 Subject: [PATCH 020/117] Fix reminders order --- www/common/outer/calendar.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 0d5fa1f2d..3ae006d63 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -147,7 +147,9 @@ define([ var sendNotif = function () { ctx.Store.onReadyEvt.reg(send); }; var notifs = ev.reminders || []; - notifs.sort(); + notifs.sort(function (a, b) { + return a - b; + }); notifs.some(function (delayMinutes) { var delay = delayMinutes * 60000; From 6ced7316002cb304db2cb9f22836054d237d1406 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 15 Apr 2021 17:45:38 +0200 Subject: [PATCH 021/117] Calendar import --- www/calendar/export.js | 87 ++++++++++++++++++++++++++++++-- www/calendar/inner.js | 22 +++++++- www/common/common-ui-elements.js | 2 +- www/common/outer/calendar.js | 20 ++++++++ 4 files changed, 125 insertions(+), 6 deletions(-) diff --git a/www/calendar/export.js b/www/calendar/export.js index 0d5921e73..e470c5d33 100644 --- a/www/calendar/export.js +++ b/www/calendar/export.js @@ -99,13 +99,12 @@ define([ 'TRIGGER:'+str, 'END:VALARM' ]); - // XXX ACTION:EMAIL - // XXX ATTENDEE:mailto:xxx@xxx.xxx - // XXX SUMMARY:Alarm notification }); } - // XXX add hidden data (from imports) + if (Array.isArray(data.cp_hidden)) { + Array.prototype.push.apply(ICS, data.cp_hidden); + } ICS.push('END:VEVENT'); }); @@ -115,6 +114,86 @@ define([ 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 = {}; + + try { + var jcalData = ICAL.parse(content); + var vcalendar = new ICAL.Component(jcalData); + } catch (e) { + return void cb(e); + } + + var method = vcalendar.getFirstPropertyValue('method'); + if (method !== "PUBLISH") { return void cb('NOT_SUPPORTED'); } + + 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') { + // XXX email: maybe keep a notification in CryptPad? + hidden.push(al.toString()); + return; + } + 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/inner.js b/www/calendar/inner.js index 9986206f0..a33bff39c 100644 --- a/www/calendar/inner.js +++ b/www/calendar/inner.js @@ -107,6 +107,12 @@ Messages.calendar_allDay = "All day"; 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); } @@ -466,7 +472,21 @@ Messages.calendar_allDay = "All day"; }, content: h('span', Messages.importButton), action: function (e) { - e.stopPropagation(); + 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; } }); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 6ec1cf420..578e716e3 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -127,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) { diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index b9f25462c..bd17b37f8 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -434,6 +434,22 @@ ctx.calendars[channel] = { }); }; + var importICSCalendar = function (ctx, data, cId, cb) { + var id = data.id; + var c = ctx.calendars[id]; + if (!c || !c.proxy) { return void cb({error: "ENOENT"}); } + var json = data.json; + c.proxy.content = c.proxy.content || {}; + Object.keys(json).forEach(function (uid) { + c.proxy.content[uid] = json[uid]; + }); + + Realtime.whenRealtimeSyncs(c.lm.realtime, function () { + sendUpdate(ctx, c); + cb(); + }); + }; + var openCalendar = function (ctx, data, cId, cb) { var secret = Hash.getSecrets('calendar', data.hash, data.password); var hash = Hash.getEditHashFromKeys(secret); @@ -785,6 +801,10 @@ ctx.calendars[channel] = { if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); } return void importCalendar(ctx, data, clientId, cb); } + if (cmd === 'IMPORT_ICS') { + if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); } + return void importICSCalendar(ctx, data, clientId, cb); + } if (cmd === 'ADD') { if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); } return void addCalendar(ctx, data, clientId, cb); From bd23cf49fcbd80c9de75e819d47025a8720a1b0c Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 15 Apr 2021 17:48:42 +0200 Subject: [PATCH 022/117] Update reminders when importing a calendar --- www/common/outer/calendar.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 1bdde4724..5f39004c1 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -95,8 +95,6 @@ define([ var ev = Util.clone(_ev); var uid = ev.id; - //ctx.store.data.lastVisit = 1617922639683; // XXX Friday Apr 09, used to test - // Clear reminders for this event if (Array.isArray(reminders[uid])) { reminders[uid].forEach(function (to) { clearTimeout(to); }); @@ -124,11 +122,6 @@ define([ return; } - // XXX - // TODO - // use custom notifications per event - // if you missed a notification, show it instantly (eg: load cryptpad 45min before an event, show the 1h notification) - var send = function () { var hide = Util.find(ctx, ['store', 'proxy', 'settings', 'general', 'calendar', 'hideNotif']); if (hide) { return; } @@ -524,6 +517,7 @@ define([ c.proxy.content = c.proxy.content || {}; Object.keys(json).forEach(function (uid) { c.proxy.content[uid] = json[uid]; + addReminders(ctx, id, json[uid]); }); Realtime.whenRealtimeSyncs(c.lm.realtime, function () { From 4c39664a66640ef535094eeded4d7e49ea0da4d7 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 15 Apr 2021 17:58:37 +0200 Subject: [PATCH 023/117] Add missing file --- www/lib/ical.min.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 www/lib/ical.min.js diff --git a/www/lib/ical.min.js b/www/lib/ical.min.js new file mode 100644 index 000000000..e92401be0 --- /dev/null +++ b/www/lib/ical.min.js @@ -0,0 +1,2 @@ +"object"==typeof module?ICAL=module.exports:"object"!=typeof ICAL&&(this.ICAL={}),ICAL.foldLength=75,ICAL.newLineChar="\r\n",ICAL.helpers={updateTimezones:function(t){var e,r,n,i,a,s;if(!t||"vcalendar"!==t.name)return t;for(e=t.getAllSubcomponents(),r=[],n={},a=0;a>18&63,r=a>>12&63,n=a>>6&63,i=63&a,c[u++]=s.charAt(e)+s.charAt(r)+s.charAt(n)+s.charAt(i),o>16&255,r=s>>8&255,n=255&s,c[h++]=64==i?String.fromCharCode(e):64==a?String.fromCharCode(e,r):String.fromCharCode(e,r,n),u=this.changes.length)break}var s=this.changes[n];if(s.utcOffset-s.prevUtcOffset<0&&0=this.changes.length?this.changes.length-1:e},_ensureCoverage:function(t){if(-1==ICAL.Timezone._minimumExpansionYear){var e=ICAL.Time.now();ICAL.Timezone._minimumExpansionYear=e.year}var r=t;if(rICAL.Timezone.MAX_YEAR&&(r=ICAL.Timezone.MAX_YEAR),!this.changes.length||this.expandedUntilYeart)&&l);)n.year=l.year,n.month=l.month,n.day=l.day,n.hour=l.hour,n.minute=l.minute,n.second=l.second,n.isDate=l.isDate,ICAL.Timezone.adjust_change(n,0,0,0,-n.prevUtcOffset),r.push(n)}}else(n=s()).year=i.year,n.month=i.month,n.day=i.day,n.hour=i.hour,n.minute=i.minute,n.second=i.second,ICAL.Timezone.adjust_change(n,0,0,0,-n.prevUtcOffset),r.push(n);return r},toString:function(){return this.tznames?this.tznames:this.tzid}},ICAL.Timezone._compare_change_fn=function(t,e){return t.yeare.year?1:t.monthe.month?1:t.daye.day?1:t.houre.hour?1:t.minutee.minute?1:t.seconde.second?1:0},ICAL.Timezone.convert_time=function(t,e,r){if(t.isDate||e.tzid==r.tzid||e==ICAL.Timezone.localTimezone||r==ICAL.Timezone.localTimezone)return t.zone=r,t;var n=e.utcOffset(t);return t.adjust(0,0,0,-n),n=r.utcOffset(t),t.adjust(0,0,0,n),null},ICAL.Timezone.fromData=function(t){return(new ICAL.Timezone).fromData(t)},ICAL.Timezone.utcTimezone=ICAL.Timezone.fromData({tzid:"UTC"}),ICAL.Timezone.localTimezone=ICAL.Timezone.fromData({tzid:"floating"}),ICAL.Timezone.adjust_change=function(t,e,r,n,i){return ICAL.Time.prototype.adjust.call(t,e,r,n,i,t)},ICAL.Timezone._minimumExpansionYear=-1,ICAL.Timezone.MAX_YEAR=2035,ICAL.Timezone.EXTRA_COVERAGE=5}(),ICAL.TimezoneService=function(){var r,t={get count(){return Object.keys(r).length},reset:function(){r=Object.create(null);var t=ICAL.Timezone.utcTimezone;r.Z=t,r.UTC=t,r.GMT=t},has:function(t){return!!r[t]},get:function(t){return r[t]},register:function(t,e){if(t instanceof ICAL.Component&&"vtimezone"===t.name&&(t=(e=new ICAL.Timezone(t)).tzid),!(e instanceof ICAL.Timezone))throw new TypeError("timezone must be ICAL.Timezone or ICAL.Component");r[t]=e},remove:function(t){return delete r[t]}};return t.reset(),t}(),function(){function t(e){Object.defineProperty(ICAL.Time.prototype,e,{get:function(){return this._pendingNormalization&&(this._normalize(),this._pendingNormalization=!1),this._time[e]},set:function(t){return"isDate"===e&&t&&!this._time.isDate&&this.adjust(0,0,0,0),this._cachedUnixTime=null,this._pendingNormalization=!0,this._time[e]=t}})}ICAL.Time=function(t,e){var r=(this.wrappedJSObject=this)._time=Object.create(null);r.year=0,r.month=1,r.day=1,r.hour=0,r.minute=0,r.second=0,r.isDate=!1,this.fromData(t,e)},ICAL.Time._dowCache={},ICAL.Time._wnCache={},ICAL.Time.prototype={icalclass:"icaltime",_cachedUnixTime:null,get icaltype(){return this.isDate?"date":"date-time"},zone:null,_pendingNormalization:!1,clone:function(){return new ICAL.Time(this._time,this.zone)},reset:function(){this.fromData(ICAL.Time.epochTime),this.zone=ICAL.Timezone.utcTimezone},resetTo:function(t,e,r,n,i,a,s){this.fromData({year:t,month:e,day:r,hour:n,minute:i,second:a,zone:s})},fromJSDate:function(t,e){return t?e?(this.zone=ICAL.Timezone.utcTimezone,this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()):(this.zone=ICAL.Timezone.localTimezone,this.year=t.getFullYear(),this.month=t.getMonth()+1,this.day=t.getDate(),this.hour=t.getHours(),this.minute=t.getMinutes(),this.second=t.getSeconds()):this.reset(),this._cachedUnixTime=null,this},fromData:function(t,e){if(t)for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if("icaltype"===r)continue;this[r]=t[r]}if(e&&(this.zone=e),!t||"isDate"in t?t&&"isDate"in t&&(this.isDate=t.isDate):this.isDate=!("hour"in t),t&&"timezone"in t){var n=ICAL.TimezoneService.get(t.timezone);this.zone=n||ICAL.Timezone.localTimezone}return t&&"zone"in t&&(this.zone=t.zone),this.zone||(this.zone=ICAL.Timezone.localTimezone),this._cachedUnixTime=null,this},dayOfWeek:function(t){var e=t||ICAL.Time.SUNDAY,r=(this.year<<12)+(this.month<<8)+(this.day<<3)+e;if(r in ICAL.Time._dowCache)return ICAL.Time._dowCache[r];var n=this.day,i=this.month+(this.month<3?12:0),a=this.year-(this.month<3?1:0),s=n+a+ICAL.helpers.trunc(26*(i+1)/10)+ICAL.helpers.trunc(a/4);return s=((s+=6*ICAL.helpers.trunc(a/100)+ICAL.helpers.trunc(a/400))+7-e)%7+1,ICAL.Time._dowCache[r]=s},dayOfYear:function(){var t=ICAL.Time.isLeapYear(this.year)?1:0;return ICAL.Time.daysInYearPassedMonth[t][this.month-1]+this.day},startOfWeek:function(t){var e=t||ICAL.Time.SUNDAY,r=this.clone();return r.day-=(this.dayOfWeek()+7-e)%7,r.isDate=!0,r.hour=0,r.minute=0,r.second=0,r},endOfWeek:function(t){var e=t||ICAL.Time.SUNDAY,r=this.clone();return r.day+=(7-this.dayOfWeek()+e-ICAL.Time.SUNDAY)%7,r.isDate=!0,r.hour=0,r.minute=0,r.second=0,r},startOfMonth:function(){var t=this.clone();return t.day=1,t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t},endOfMonth:function(){var t=this.clone();return t.day=ICAL.Time.daysInMonth(t.month,t.year),t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t},startOfYear:function(){var t=this.clone();return t.day=1,t.month=1,t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t},endOfYear:function(){var t=this.clone();return t.day=31,t.month=12,t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t},startDoyWeek:function(t){var e=t||ICAL.Time.SUNDAY,r=this.dayOfWeek()-e;return r<0&&(r+=7),this.dayOfYear()-r},getDominicalLetter:function(){return ICAL.Time.getDominicalLetter(this.year)},nthWeekDay:function(t,e){var r,n=ICAL.Time.daysInMonth(this.month,this.year),i=e,a=0,s=this.clone();if(0<=i){s.day=1,0!=i&&i--,a=s.day;var o=t-s.dayOfWeek();o<0&&(o+=7),a+=o,a-=t,r=t}else{s.day=n,i++,(r=s.dayOfWeek()-t)<0&&(r+=7),r=n-r}return a+(r+=7*i)},isNthWeekDay:function(t,e){var r=this.dayOfWeek();return 0===e&&r===t||this.nthWeekDay(t,e)===this.day},weekNumber:function(t){var e,r=(this.year<<12)+(this.month<<8)+(this.day<<3)+t;if(r in ICAL.Time._wnCache)return ICAL.Time._wnCache[r];var n=this.clone();n.isDate=!0;var i=this.year;12==n.month&&25ICAL.Time.daysInYearPassedMonth[a][12])return a=ICAL.Time.isLeapYear(r)?1:0,n-=ICAL.Time.daysInYearPassedMonth[a][12],r++,ICAL.Time.fromDayOfYear(n,r);i.year=r,i.isDate=!0;for(var s=11;0<=s;s--)if(n>ICAL.Time.daysInYearPassedMonth[a][s]){i.month=s+1,i.day=n-ICAL.Time.daysInYearPassedMonth[a][s];break}return i.auto_normalize=!0,i},ICAL.Time.fromStringv2=function(t){return new ICAL.Time({year:parseInt(t.substr(0,4),10),month:parseInt(t.substr(5,2),10),day:parseInt(t.substr(8,2),10),isDate:!0})},ICAL.Time.fromDateString=function(t){return new ICAL.Time({year:ICAL.helpers.strictParseInt(t.substr(0,4)),month:ICAL.helpers.strictParseInt(t.substr(5,2)),day:ICAL.helpers.strictParseInt(t.substr(8,2)),isDate:!0})},ICAL.Time.fromDateTimeString=function(t,e){if(t.length<19)throw new Error('invalid date-time value: "'+t+'"');var r;return t[19]&&"Z"===t[19]?r="Z":e&&(r=e.getParameter("tzid")),new ICAL.Time({year:ICAL.helpers.strictParseInt(t.substr(0,4)),month:ICAL.helpers.strictParseInt(t.substr(5,2)),day:ICAL.helpers.strictParseInt(t.substr(8,2)),hour:ICAL.helpers.strictParseInt(t.substr(11,2)),minute:ICAL.helpers.strictParseInt(t.substr(14,2)),second:ICAL.helpers.strictParseInt(t.substr(17,2)),timezone:r})},ICAL.Time.fromString=function(t,e){return 10ICAL.Time.THURSDAY&&(r.day+=7),i>ICAL.Time.THURSDAY&&(r.day-=7),r.day-=n-i,r},ICAL.Time.getDominicalLetter=function(t){var e="GFEDCBA",r=(t+(t/4|0)+(t/400|0)-(t/100|0)-1)%7;return ICAL.Time.isLeapYear(t)?e[(6+r)%7]+e[r]:e[r]},ICAL.Time.epochTime=ICAL.Time.fromData({year:1970,month:1,day:1,hour:0,minute:0,second:0,isDate:!1,timezone:"Z"}),ICAL.Time._cmp_attr=function(t,e,r){return t[r]>e[r]?1:t[r] '+e);if(void 0!==r&&rs||0==this.last.day)throw new Error("Malformed values in BYDAY part")}else if(this.has_by_data("BYMONTHDAY")&&this.last.day<0){s=ICAL.Time.daysInMonth(this.last.month,this.last.year);this.last.day=s+this.last.day+1}},next:function(){var t,e=this.last?this.last.clone():null;if(this.rule.count&&this.occurrence_number>=this.rule.count||this.rule.until&&0i)){if(n<0)n=i+(n+1);else if(0===n)continue;-1===a.indexOf(n)&&a.push(n)}return a.sort(function(t,e){return t-e})},_byDayAndMonthDay:function(t){var e,r,n,i,a=this.by_data.BYDAY,s=0,o=a.length,u=0,h=this,c=this.last.day;function l(){for(i=ICAL.Time.daysInMonth(h.last.month,h.last.year),e=h.normalizeByMonthDayRules(h.last.year,h.last.month,h.by_data.BYMONTHDAY),n=e.length;e[s]<=c&&(!t||e[s]!=c)&&s=this.by_data.BYMONTHDAY.length&&(this.by_indices.BYMONTHDAY=0,this.increment_month());e=ICAL.Time.daysInMonth(this.last.month,this.last.year);(a=this.by_data.BYMONTHDAY[this.by_indices.BYMONTHDAY])<0&&(a=e+a+1),ee?t=0:this.last.day=this.by_data.BYMONTHDAY[0]}return t},next_weekday_by_week:function(){var t=0;if(0==this.next_hour())return t;if(!this.has_by_data("BYDAY"))return 1;for(;;){var e=new ICAL.Time;this.by_indices.BYDAY++,this.by_indices.BYDAY==Object.keys(this.by_data.BYDAY).length&&(this.by_indices.BYDAY=0,t=1);var r=this.by_data.BYDAY[this.by_indices.BYDAY],n=this.ruleDayOfWeek(r)[1];(n-=this.rule.wkst)<0&&(n+=7),e.year=this.last.year,e.month=this.last.month,e.day=this.last.day;var i=e.startDoyWeek(this.rule.wkst);if(!(n+i<1)||t){var a=ICAL.Time.fromDayOfYear(i+n,this.last.year);return this.last.year=a.year,this.last.month=a.month,this.last.day=a.day,t}}},next_year:function(){if(0==this.next_hour())return 0;if(++this.days_index==this.days.length)for(this.days_index=0;this.increment_year(this.rule.interval),this.expand_year_days(this.last.year),0==this.days.length;);return this._nextByYearDay(),1},_nextByYearDay:function(){var t=this.days[this.days_index],e=this.last.year;t<1&&(t+=1,e+=1);var r=ICAL.Time.fromDayOfYear(t,e);this.last.day=r.day,this.last.month=r.month},ruleDayOfWeek:function(t,e){var r=t.match(/([+-]?[0-9])?(MO|TU|WE|TH|FR|SA|SU)/);return r?[parseInt(r[1]||0,10),t=ICAL.Recur.icalDayToNumericDay(r[2],e)]:[0,0]},next_generic:function(t,e,r,n,i){var a=t in this.by_data,s=this.rule.freq==e,o=0;if(i&&0==this[i]())return o;if(a){this.by_indices[t]++;this.by_indices[t];var u=this.by_data[t];this.by_indices[t]==u.length&&(this.by_indices[t]=0,o=1),this.last[r]=u[this.by_indices[t]]}else s&&this["increment_"+r](this.rule.interval);return a&&o&&s&&this["increment_"+n](1),o},increment_monthday:function(t){for(var e=0;er&&(this.last.day-=r,this.increment_month())}},increment_month:function(){if(this.last.day=1,this.has_by_data("BYMONTH"))this.by_indices.BYMONTH++,this.by_indices.BYMONTH==this.by_data.BYMONTH.length&&(this.by_indices.BYMONTH=0,this.increment_year(1)),this.last.month=this.by_data.BYMONTH[this.by_indices.BYMONTH];else{"MONTHLY"==this.rule.freq?this.last.month+=this.rule.interval:this.last.month++,this.last.month--;var t=ICAL.helpers.trunc(this.last.month/12);this.last.month%=12,this.last.month++,0!=t&&this.increment_year(t)}},increment_year:function(t){this.last.year+=t},increment_generic:function(t,e,r,n){this.last[e]+=t;var i=ICAL.helpers.trunc(this.last[e]/r);this.last[e]%=r,0!=i&&this["increment_"+n](i)},has_by_data:function(t){return t in this.rule.parts},expand_year_days:function(t){var e=new ICAL.Time;this.days=[];var r={},n=["BYDAY","BYWEEKNO","BYMONTHDAY","BYMONTH","BYYEARDAY"];for(var i in n)if(n.hasOwnProperty(i)){var a=n[i];a in this.rule.parts&&(r[a]=this.rule.parts[a])}if("BYMONTH"in r&&"BYWEEKNO"in r){var s=1,o={};e.year=t,e.isDate=!0;for(var u=0;ue[0]?1:e[0]>t[0]?-1:0}return t.prototype={THISANDFUTURE:"THISANDFUTURE",exceptions:null,strictExceptions:!1,relateException:function(t){if(this.isRecurrenceException())throw new Error("cannot relate exception to exceptions");if(t instanceof ICAL.Component&&(t=new ICAL.Event(t)),this.strictExceptions&&t.uid!==this.uid)throw new Error("attempted to relate unrelated exception");var e=t.recurrenceId.toString();if((this.exceptions[e]=t).modifiesFuture()){var r=[t.recurrenceId.toUnixTime(),e],n=ICAL.helpers.binsearchInsert(this.rangeExceptions,r,i);this.rangeExceptions.splice(n,0,r)}},modifiesFuture:function(){return!!this.component.hasProperty("recurrence-id")&&this.component.getFirstProperty("recurrence-id").getParameter("range")===this.THISANDFUTURE},findRangeException:function(t){if(!this.rangeExceptions.length)return null;var e=t.toUnixTime(),r=ICAL.helpers.binsearchInsert(this.rangeExceptions,[e],i);if(--r<0)return null;var n=this.rangeExceptions[r];return e Date: Thu, 15 Apr 2021 18:09:11 +0200 Subject: [PATCH 024/117] Convert email notifications --- www/calendar/export.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/www/calendar/export.js b/www/calendar/export.js index e470c5d33..6019290c6 100644 --- a/www/calendar/export.js +++ b/www/calendar/export.js @@ -162,9 +162,8 @@ define([ ev.getAllSubcomponents('valarm').forEach(function (al) { var action = al.getFirstPropertyValue('action'); if (action !== 'DISPLAY') { - // XXX email: maybe keep a notification in CryptPad? + // Email notification: keep it in "hidden" and create a cryptpad notification hidden.push(al.toString()); - return; } var trigger = al.getFirstPropertyValue('trigger'); var minutes = -trigger.toSeconds() / 60; From 9b7b67c49008491a6c8ea6f51c2071d7f13c62cf Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 19 Apr 2021 11:07:35 +0200 Subject: [PATCH 025/117] Fix team calendars stored in the drive --- www/common/inner/access.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/common/inner/access.js b/www/common/inner/access.js index 52b0d0319..693b8d236 100644 --- a/www/common/inner/access.js +++ b/www/common/inner/access.js @@ -268,6 +268,9 @@ define([ return void UI.warn(text); } var isTemplate = priv.isTemplate || opts.isTemplate; + + // never store calendars in the team drive + if (opts.calendar) { return; } toAddTeams.forEach(function (obj) { sframeChan.query('Q_STORE_IN_TEAM', { href: data.href || data.rohref, From ecb674c42a8d4076ba5287a23f4ca0ff9ab1452a Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 19 Apr 2021 13:04:51 +0200 Subject: [PATCH 026/117] Fix lock issues in ooslide and oodoc --- www/common/onlyoffice/inner.js | 18 ++-------- .../onlyoffice/v4/sdkjs/word/sdk-all.js | 2 +- .../web-apps/apps/documenteditor/main/app.js | 34 +++++++++---------- .../apps/presentationeditor/main/app.js | 28 +++++++-------- .../apps/spreadsheeteditor/main/app.js | 20 +++++------ 5 files changed, 44 insertions(+), 58 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index eee9f6883..dd3c0b5fc 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -1028,7 +1028,7 @@ define([ var myId = getId(); content.locks[myId] = content.locks[myId] || {}; var b = obj.block && obj.block[0]; - if (type === "sheet") { + if (type === "sheet" || typeof(b) !== "string") { var uid = Util.uid(); content.locks[myId][uid] = msg; } else { @@ -1342,21 +1342,7 @@ define([ '#fm-btn-info { display: none !important; }' + // Author name, doc title, etc. in "File" (menu entry) '#panel-info { display: none !important; }' + // Same but content '#image-button-from-url { display: none !important; }' + // Inline image settings: replace with url - - '#asc-gen257 { display: none !important; }' + // Insert image from url - '#asc-gen1839 { display: none !important; }' + // Image context menu: replace with url - '#asc-gen5883 { display: none !important; }' + // Rightside image menu: replace with url - - '#asc-gen1211 { display: none !important; }' + // Slide Image context menu: replace with url - '#asc-gen3880 { display: none !important; }' + // Rightside slide image menu: replace with url - '#asc-gen2218 { display: none !important; }' + // Rightside slide menu: fill slide with image url - '#asc-gen849 { display: none !important; }' + // Toolbar slide: insert image from url - '#asc-gen857 { display: none !important; }' + // Toolbar slide: insert image from url (insert tab) - - '#asc-gen180 { display: none !important; }' + // Doc Insert image from url - '#asc-gen1760 { display: none !important; }' + // Doc Image context menu: replace with url - '#asc-gen3319 { display: none !important; }' + // Doc Rightside image menu: replace with url - + '.cp-from-url, #textart-button-from-url { display: none !important; }' + // Spellcheck language '.statusbar .cnt-lang { display: none !important; }' + // Spellcheck language '.statusbar #btn-doc-spell { display: none !important; }' + // Spellcheck button '#file-menu-panel .devider { display: none !important; }' + // separator in the "File" menu diff --git a/www/common/onlyoffice/v4/sdkjs/word/sdk-all.js b/www/common/onlyoffice/v4/sdkjs/word/sdk-all.js index 24e1771b0..19d3f1d2e 100644 --- a/www/common/onlyoffice/v4/sdkjs/word/sdk-all.js +++ b/www/common/onlyoffice/v4/sdkjs/word/sdk-all.js @@ -11578,7 +11578,7 @@ this.getTargetDocContent(undefined,true);if(oTargetDocContent){oState.Pos=oTarge this.clearTrackObjects();this.resetSelection(undefined,undefined,true);this.changeCurrentState(new AscFormat.NullState(this));return this.loadDocumentStateAfterLoadChanges(oState)},loadDocumentStateAfterLoadChanges:DrawingObjectsController.prototype.loadDocumentStateAfterLoadChanges,checkTrackDrawings:DrawingObjectsController.prototype.checkTrackDrawings,canChangeWrapPolygon:function(){return!this.selection.groupSelection&&!this.selection.textSelection&&!this.selection.chartSelection&&this.selectedObjects.length=== 1&&this.selectedObjects[0].canChangeWrapPolygon&&this.selectedObjects[0].canChangeWrapPolygon()&&!this.selectedObjects[0].parent.Is_Inline()},startChangeWrapPolygon:function(){if(this.canChangeWrapPolygon()){var bNeedBehindDoc=this.getCompatibilityMode()0&&$(this.el).find(".inner").addBack().filter(".inner").append('
'+this.emptyText+"
"),_.each(this.dataViewItems,function(t){this.stopListening(t),t.stopListening(t.model)},this),this.dataViewItems=[],this.store.each(this.onAddItem,this),this.allowScrollbar&&(this.scroller=new Common.UI.Scroller({el:$(this.el).find(".inner").addBack().filter(".inner"),useKeyboard:this.enableKeyEvents&&!this.handleSelect,minScrollbarLength:40,wheelSpeed:10,alwaysVisibleY:this.scrollAlwaysVisible})),this.disabled&&this.setDisabled(this.disabled),this.attachKeyEvents(),this.lastSelectedRec=null,this._layoutParams=void 0},onChangeItem:function(t,e){this.isSuspendEvents||this.trigger("item:change",this,t,e)},onRemoveItem:function(t,e){var i=t.$el.data("bs.tooltip");if(i&&(void 0===i.dontShow&&(i.dontShow=!0),i.tip().remove()),this.stopListening(t),t.stopListening(),this.store.length<1&&this.emptyText.length>0){var n=$(this.el).find(".inner").addBack().filter(".inner");n.find(".empty-text").length<=0&&n.append('
'+this.emptyText+"
")}for(var o=0;o=0&&this.dataViewItems.length>o?$(this.dataViewItems[o].el):i.find("#"+t.get("id"));if(!(s.length<=0)){var a=s.offset().top,r=$(this.dataViewItems[0].el),l=r.length>0?r[0].clientTop:0;(e||an+l+i.height())&&(this.scroller&&this.allowScrollbar?this.scroller.scrollTop(i.scrollTop()+a-n-l,0):i.scrollTop(i.scrollTop()+a-n-l))}}},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){void 0===this._layoutParams&&this.fillIndexesArray();var s=this.dataViewItems[n].topIdx,a=this.dataViewItems[n].leftIdx;if(n=void 0,e.keyCode==Common.UI.Keys.LEFT)for(;void 0===n;){if(--a<0){var o=$(t.target).closest(".dropdown-submenu.over");if(o.length>0){o.removeClass("over"),o.find("> a").focus();break}a=this._layoutParams.columns-1}n=this._layoutParams.itemsIndexes[s][a]}else if(e.keyCode==Common.UI.Keys.RIGHT)for(;void 0===n;)a++,a>this._layoutParams.columns-1&&(a=0),n=this._layoutParams.itemsIndexes[s][a];else if(e.keyCode==Common.UI.Keys.UP)for(;void 0===n;)s--,s<0&&(s=this._layoutParams.rows-1),n=this._layoutParams.itemsIndexes[s][a];else for(;void 0===n;)s++,s>this._layoutParams.rows-1&&(s=0),n=this._layoutParams.itemsIndexes[s][a]}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)},attachKeyEvents:function(){if(this.enableKeyEvents&&this.handleSelect){var t=$(this.el).find(".inner").addBack().filter(".inner");t.addClass("canfocused"),t.attr("tabindex",this.tabindex.toString()),t.on(this.parentMenu&&this.useBSKeydown?"dataview:keydown":"keydown",_.bind(this.onKeyDown,this))}},showLastSelected:function(){this.lastSelectedRec?(this.selectRecord(this.lastSelectedRec,!0),this.scrollToRecord(this.lastSelectedRec),this.lastSelectedRec=null):this.scrollToRecord(this.getSelectedRec())},setDisabled:function(t){this.disabled=t,$(this.el).find(".inner").addBack().filter(".inner").toggleClass("disabled",t)},isDisabled:function(){return this.disabled},setEmptyText:function(t){this.emptyText=t},alignPosition:function(){var t="menu"===this.parentMenu.cmpEl.attr("role")?this.parentMenu.cmpEl:this.parentMenu.cmpEl.find("[role=menu]"),e=Common.Utils.innerHeight()-10,i=$(this.el).find(".inner").addBack().filter(".inner"),n=i.parent(),o=parseInt(n.css("margin-top"))+parseInt(n.css("margin-bottom"))+parseInt(t.css("margin-top")),s=parseInt(t.css("padding-top"))+parseInt(t.css("padding-bottom")),a=t.outerHeight(),r=parseInt(t.css("top")),l={minScrollbarLength:40};this.scrollAlwaysVisible&&(l.alwaysVisibleY=this.scrollAlwaysVisible),r+a>e?(i.css("max-height",e-r-s-o+"px"),this.allowScrollbar&&this.scroller.update(l)):r+ao&&(o=l,this._layoutParams.itemsIndexes.push([]),s=this._layoutParams.itemsIndexes.length-1),this._layoutParams.itemsIndexes[s][a]=r,this.dataViewItems[r].topIdx=s,this.dataViewItems[r].leftIdx=a,this._layoutParams.columns',"<% _.each(items, function(item) { %>","<% if (!item.id) item.id = Common.UI.getId(); %>",'
data-toggle="tooltip" <% } %> ><%= itemTemplate(item) %>
',"<% }) %>","
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t);var e=this;e.template=e.options.template||e.template,e.store=e.options.store||new Common.UI.DataViewStore,e.itemTemplate=e.options.itemTemplate||null,e.handleSelect=e.options.handleSelect,e.parentMenu=e.options.parentMenu,e.enableKeyEvents=e.options.enableKeyEvents,e.useBSKeydown=e.options.useBSKeydown,e.style=e.options.style||"",e.scrollAlwaysVisible=e.options.scrollAlwaysVisible||!1,e.tabindex=e.options.tabindex||0,e.parentMenu&&(e.parentMenu.options.restoreHeight=e.options.restoreHeight>0),e.rendered=!1,"vertical"==e.options.keyMoveDirection?e.moveKeys=[Common.UI.Keys.UP,Common.UI.Keys.DOWN]:"horizontal"==e.options.keyMoveDirection?e.moveKeys=[Common.UI.Keys.LEFT,Common.UI.Keys.RIGHT]:e.moveKeys=[Common.UI.Keys.UP,Common.UI.Keys.DOWN,Common.UI.Keys.LEFT,Common.UI.Keys.RIGHT],e.options.el&&e.render()},render:function(t){var e=this;this.trigger("render:before",this),t?(this.setElement(t,!1),this.cmpEl=$(this.template({items:e.store.toJSON(),itemTemplate:e.itemTemplate,style:e.style})),t.html(this.cmpEl)):(this.cmpEl=e.$el||$(this.el),this.cmpEl.html(this.template({items:e.store.toJSON(),itemTemplate:e.itemTemplate,style:e.style})));var i=this.cmpEl.closest(".asc-window");return i.length<1&&(i=this.cmpEl.closest('[id^="menu-container-"]')),i.length>0&&(this.tipZIndex=parseInt(i.css("z-index"))+10),this.rendered||(this.parentMenu?(this.cmpEl.closest("li").css("height","100%"),this.cmpEl.css("height","100%"),this.parentMenu.on("show:after",_.bind(this.alignPosition,this)),this.parentMenu.on("show:after",_.bind(this.onAfterShowMenu,this))):this.store.length>0&&this.onAfterShowMenu(),this.enableKeyEvents&&this.parentMenu&&this.handleSelect&&(this.parentMenu.on("show:before",function(t){e.deselectAll()}),this.parentMenu.on("show:after",function(t){Common.NotificationCenter.trigger("dataview:focus"),_.delay(function(){t.cmpEl.find(".dataview").focus()},10)}).on("hide:after",function(){Common.NotificationCenter.trigger("dataview:blur")})),this.attachKeyEvents(),this.cmpEl.on("click","div.item",_.bind(e.onClickItem,e))),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el).find(".inner").addBack().filter(".inner"),useKeyboard:this.enableKeyEvents&&!this.handleSelect,minScrollbarLength:40,wheelSpeed:10,alwaysVisibleY:this.scrollAlwaysVisible})),this.rendered=!0,this.cmpEl.on("click",function(t){if(/dataview/.test(t.target.className))return!1}),this.trigger("render:after",this),this},selectRecord:function(t,e){if(this.handleSelect){if(e&&this.suspendEvents(),this.deselectAll(e),t){t.set({selected:!0});var i=_.indexOf(this.store.models,t);i>=0&&this.dataViewItems&&this.dataViewItems.length>i&&this.dataViewItems[i].el.addClass("selected")}return e&&this.resumeEvents(),t}},selectByIndex:function(t,e){if(this.store.length>0&&t>-1&&t","<% if (!item.id) item.id = Common.UI.getId(); %>",'
data-toggle="tooltip" <% } %> ><%= itemTemplate(item) %>
',"<% }) %>"].join(""));this.cmpEl&&this.cmpEl.find(".inner").html(t({items:this.store.toJSON(),itemTemplate:this.itemTemplate,style:this.style})),_.isUndefined(this.scroller)||(this.scroller.destroy(),delete this.scroller),this.scroller=new Common.UI.Scroller({el:$(this.el).find(".inner").addBack().filter(".inner"),useKeyboard:this.enableKeyEvents&&!this.handleSelect,minScrollbarLength:40,wheelSpeed:10,alwaysVisibleY:this.scrollAlwaysVisible}),!this.parentMenu&&this.store.length>0&&this.onAfterShowMenu(),this._layoutParams=void 0},setStore:function(t){t&&(this.store=t,this.onResetItems())},onClickItem:function(t){if(!this.disabled){window._event=t;var e=$(t.currentTarget).closest("div.item").index(),i=e>=0?this.store.at(e):null,n=e>=0?this.dataViewItems[e]:null;if(i&&n){i.set({selected:!0});var o=n.el.data("bs.tooltip");o&&o.tip().remove(),this.isSuspendEvents||this.trigger("item:click",this,n.el,i,t)}}},onAfterShowMenu:function(t){if(!this.dataViewItems){var e=this;this.dataViewItems=[],_.each(this.cmpEl.find("div.item"),function(t,i){var n=$(t),o=e.store.at(i);e.dataViewItems.push({el:n}),o.get("tip")&&n.tooltip({title:o.get("tip"),placement:"cursor",zIndex:e.tipZIndex})})}},scrollToRecord:function(t){if(t){var e=$(this.el).find(".inner"),i=e.offset().top,n=_.indexOf(this.store.models,t),o=n>=0&&this.dataViewItems.length>n?this.dataViewItems[n].el:e.find("#"+t.get("id"));if(!(o.length<=0)){var s=o.offset().top,a=this.dataViewItems[0].el,r=a.length>0?a[0].offsetTop:0;(si+e.height())&&(this.scroller?this.scroller.scrollTop(e.scrollTop()+s-i-r,0):e.scrollTop(e.scrollTop()+s-i-r))}}},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(e.keyCode==Common.UI.Keys.RETURN)this.selectedBeforeHideRec&&(i=this.selectedBeforeHideRec),this.trigger("item:click",this,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){void 0===this._layoutParams&&this.fillIndexesArray();var s=this.dataViewItems[n].topIdx,a=this.dataViewItems[n].leftIdx;if(n=void 0,e.keyCode==Common.UI.Keys.LEFT)for(;void 0===n;){if(--a<0){var o=$(t.target).closest(".dropdown-submenu.over");if(o.length>0){o.removeClass("over"),o.find("> a").focus();break}a=this._layoutParams.columns-1}n=this._layoutParams.itemsIndexes[s][a]}else if(e.keyCode==Common.UI.Keys.RIGHT)for(;void 0===n;)a++,a>this._layoutParams.columns-1&&(a=0),n=this._layoutParams.itemsIndexes[s][a];else if(e.keyCode==Common.UI.Keys.UP)for(;void 0===n;)s--,s<0&&(s=this._layoutParams.rows-1),n=this._layoutParams.itemsIndexes[s][a];else for(;void 0===n;)s++,s>this._layoutParams.rows-1&&(s=0),n=this._layoutParams.itemsIndexes[s][a]}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)},attachKeyEvents:function(){if(this.enableKeyEvents&&this.handleSelect){var t=$(this.el).find(".inner").addBack().filter(".inner");t.addClass("canfocused"),t.attr("tabindex",this.tabindex.toString()),t.on(this.parentMenu&&this.useBSKeydown?"dataview:keydown":"keydown",_.bind(this.onKeyDown,this))}},setDisabled:function(t){this.disabled=t,$(this.el).find(".inner").addBack().filter(".inner").toggleClass("disabled",t)},isDisabled:function(){return this.disabled},alignPosition:function(){var t="menu"===this.parentMenu.cmpEl.attr("role")?this.parentMenu.cmpEl:this.parentMenu.cmpEl.find("[role=menu]"),e=Common.Utils.innerHeight()-10,i=$(this.el).find(".inner").addBack().filter(".inner"),n=i.parent(),o=parseInt(n.css("margin-top"))+parseInt(n.css("margin-bottom"))+parseInt(t.css("margin-top")),s=parseInt(t.css("padding-top"))+parseInt(t.css("padding-bottom")),a=t.outerHeight(),r=parseInt(t.css("top")),l={minScrollbarLength:40};this.scrollAlwaysVisible&&(l.alwaysVisibleY=this.scrollAlwaysVisible),r+a>e?(i.css("max-height",e-r-s-o+"px"),this.scroller.update(l)):r+ao&&(o=c,this._layoutParams.itemsIndexes.push([]),s=this._layoutParams.itemsIndexes.length-1),this._layoutParams.itemsIndexes[s][a]=r,l.topIdx=s,l.leftIdx=a,this._layoutParams.columns')},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, @@ -33,14 +33,14 @@ return'
    \ background:"none",border:"none"}),this.btnSymbols=new Common.UI.Button({el:n.find("#symbol-table-symbols"),enableToggle:!0,toggleGroup:"hyperlink-type",allowDepress:!1,pressed:!0}),this.btnSymbols.on("click",_.bind(this.onModeClick,this,!1)),this.btnSpecial=new Common.UI.Button({el:n.find("#symbol-table-special"),enableToggle:!0,toggleGroup:"hyperlink-type",allowDepress:!1}),this.btnSpecial.on("click",_.bind(this.onModeClick,this,!0)),this.cmbFonts=new Common.UI.ComboBox({el:n.find("#symbol-table-cmb-fonts"),cls:"input-group-nr",data:e,editable:!1,search:!0,menuStyle:"min-width: 100%; max-height: 209px;"}).on("selected",function(e,n){var r=t.getRangeBySymbol(i,s);if(o=n.value,i=t.getArrRangesByFont(o),r){for(var 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"));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}).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){ +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"},{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 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 f5baa2341..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,8 +13,8 @@ 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('