diff --git a/data/core.telegram.org/constructor/decryptedMessageActionResend.html b/data/core.telegram.org/constructor/decryptedMessageActionResend.html new file mode 100644 index 0000000000..637c48fee0 --- /dev/null +++ b/data/core.telegram.org/constructor/decryptedMessageActionResend.html @@ -0,0 +1,155 @@ + + + + + decryptedMessageActionResend + + + + + + + + + + + + + +
+ +
+
+
+ +

decryptedMessageActionResend

+ +

Request for the other party in a Secret Chat to automatically resend a contiguous range of previously sent messages, as explained in Sequence number is Secret Chats.

+

+ +
+
===17===
+decryptedMessageActionResend#511110b0 start_seq_no:int end_seq_no:int = DecryptedMessageAction;

+

Parameters

+ + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
start_seq_nointout_seq_no of the first message to be resent, with correct parity
end_seq_nointout_seq_no of the last message to be resent, with same parity.
+

Type

+

DecryptedMessageAction

+

Related pages

+

Sequence numbers in Secret Chats

+ +
+ +
+
+ +
+ + + + + + diff --git a/data/core.telegram.org/constructor/messageEntityItalic.html b/data/core.telegram.org/constructor/messageEntityItalic.html new file mode 100644 index 0000000000..0f83f76fdf --- /dev/null +++ b/data/core.telegram.org/constructor/messageEntityItalic.html @@ -0,0 +1,152 @@ + + + + + messageEntityItalic + + + + + + + + + + + + + +
+ +
+
+
+ +

messageEntityItalic

+ +

Message entity representing italic text.

+

+ +
+
messageEntityItalic#826f8b60 offset:int length:int = MessageEntity;

+

Parameters

+ + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
offsetintOffset of message entity within message (in UTF-8 codepoints)
lengthintLength of message entity within message (in UTF-8 codepoints)
+

Type

+

MessageEntity

+ +
+ +
+
+ +
+ + + + + + diff --git a/data/core.telegram.org/constructor/messages.stickers b/data/core.telegram.org/constructor/messages.stickers new file mode 100644 index 0000000000..2c314429e7 --- /dev/null +++ b/data/core.telegram.org/constructor/messages.stickers @@ -0,0 +1,155 @@ + + + + + messages.stickers + + + + + + + + + + + + + +
+ +
+
+
+ +

messages.stickers

+ +

Found stickers

+

+ +
+
messages.stickers#30a6ec7e hash:long stickers:Vector<Document> = messages.Stickers;

+

Parameters

+ + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hashlongHash for pagination, for more info click here
stickersVector<Document>Stickers
+

Type

+

messages.Stickers

+

Related pages

+

Pagination in the API

+

How to fetch results from large lists of objects.

+ +
+ +
+
+ +
+ + + + + + diff --git a/data/core.telegram.org/method/account.createTheme b/data/core.telegram.org/method/account.createTheme new file mode 100644 index 0000000000..dcf4307afc --- /dev/null +++ b/data/core.telegram.org/method/account.createTheme @@ -0,0 +1,186 @@ + + + + + account.createTheme + + + + + + + + + + + + + +
+ +
+
+
+ +

account.createTheme

+ +

Create a theme

+

+ +
+
theme#a00e67d6 flags:# creator:flags.0?true default:flags.1?true for_chat:flags.5?true id:long access_hash:long slug:string title:string document:flags.2?Document settings:flags.3?Vector<ThemeSettings> emoticon:flags.6?string installs_count:flags.4?int = Theme;
+---functions---
+account.createTheme#652e4400 flags:# slug:string title:string document:flags.2?InputDocument settings:flags.3?Vector<InputThemeSettings> = Theme;

+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
flags#Flags, see TL conditional fields
slugstringUnique theme ID
titlestringTheme name
documentflags.2?InputDocumentTheme file
settingsflags.3?InputThemeSettingsTheme settings
+

Result

+

Theme

+

Possible errors

+ + + + + + + + + + + + + + + +
CodeTypeDescription
400THEME_MIME_INVALIDThe theme's MIME type is invalid.
+ +
+ +
+
+ +
+ + + + + + diff --git a/data/core.telegram.org/method/account.reportPeer b/data/core.telegram.org/method/account.reportPeer new file mode 100644 index 0000000000..5ad7fac4dc --- /dev/null +++ b/data/core.telegram.org/method/account.reportPeer @@ -0,0 +1,182 @@ + + + + + account.reportPeer + + + + + + + + + + + + + +
+ +
+
+
+ +

account.reportPeer

+ +

Report a peer for violation of telegram's Terms of Service

+

+ +
+
boolFalse#bc799737 = Bool;
+boolTrue#997275b5 = Bool;
+---functions---
+account.reportPeer#c5ba3d86 peer:InputPeer reason:ReportReason message:string = Bool;

+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
peerInputPeerThe peer to report
reasonReportReasonThe reason why this peer is being reported
messagestringComment for report moderation
+

Result

+

Bool

+

Possible errors

+ + + + + + + + + + + + + + + + + + + + +
CodeTypeDescription
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
400PEER_ID_INVALIDThe provided peer id is invalid.
+ +
+ +
+
+ +
+ + + + + + diff --git a/data/core.telegram.org/method/messages.saveRecentSticker b/data/core.telegram.org/method/messages.saveRecentSticker new file mode 100644 index 0000000000..1eeafe3454 --- /dev/null +++ b/data/core.telegram.org/method/messages.saveRecentSticker @@ -0,0 +1,182 @@ + + + + + messages.saveRecentSticker + + + + + + + + + + + + + +
+ +
+
+
+ +

messages.saveRecentSticker

+ +

Add/remove sticker from recent stickers list

+

+ +
+
boolFalse#bc799737 = Bool;
+boolTrue#997275b5 = Bool;
+---functions---
+messages.saveRecentSticker#392718f8 flags:# attached:flags.0?true id:InputDocument unsave:Bool = Bool;

+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
flags#Flags, see TL conditional fields
attachedflags.0?trueWhether to add/remove stickers recently attached to photo or video files
idInputDocumentSticker
unsaveBoolWhether to save or unsave the sticker
+

Result

+

Bool

+

Possible errors

+ + + + + + + + + + + + + + + +
CodeTypeDescription
400STICKER_ID_INVALIDThe provided sticker ID is invalid.
+ +
+ +
+
+ +
+ + + + + + diff --git a/data/core.telegram.org/type/Authorization.html b/data/core.telegram.org/type/Authorization.html new file mode 100644 index 0000000000..37e889a3e4 --- /dev/null +++ b/data/core.telegram.org/type/Authorization.html @@ -0,0 +1,162 @@ + + + + + Authorization + + + + + + + + + + + + + +
+ +
+
+
+ +

Authorization

+ +

Represents a logged-in session

+

+ +
+
authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true encrypted_requests_disabled:flags.3?true call_requests_disabled:flags.4?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization;
+
+---functions---
+
+auth.acceptLoginToken#e894ad4d token:bytes = Authorization;

+

Constructors

+ + + + + + + + + + + + + +
ConstructorDescription
authorizationLogged-in session
+

Methods

+ + + + + + + + + + + + + +
MethodDescription
auth.acceptLoginTokenLogin via QR code
+ +
+ +
+
+ +
+ + + + + + diff --git a/data/corefork.telegram.org/api/errors.html b/data/corefork.telegram.org/api/errors.html deleted file mode 100644 index a7f8aeec7d..0000000000 --- a/data/corefork.telegram.org/api/errors.html +++ /dev/null @@ -1,189 +0,0 @@ - - - - - Error handling - - - - - - - - - - - - - -
- -
-
-
- -

Error handling

- -

There will be errors when working with the API, and they must be correctly handled on the client.

-

An error is characterized by several parameters:

-

Error Code

-

Numerical value similar to HTTP status. Contains information on the type of error that occurred: for example, a data input error, privacy error, or server error. This is a required parameter.

-

Error Type

-

A string literal in the form of /[A-Z_0-9]+/, which summarizes the problem. For example, AUTH_KEY_UNREGISTERED. This is an optional parameter.

-
-

Error Constructors

-

There should be a way to handle errors that are returned in rpc_error constructors.

-

Below is a list of error codes and their meanings:

-

303 SEE_OTHER

-

The request must be repeated, but directed to a different data center.

-

Examples of Errors:

-
    -
  • FILE_MIGRATE_X: the file to be accessed is currently stored in a different data center.
  • -
  • PHONE_MIGRATE_X: the phone number a user is trying to use for authorization is associated with a different data center.
  • -
  • NETWORK_MIGRATE_X: the source IP address is associated with a different data center (for registration)
  • -
  • USER_MIGRATE_X: the user whose identity is being used to execute queries is associated with a different data center (for registration)
  • -
-

In all these cases, the error description’s string literal contains the number of the data center (instead of the X) to which the repeated query must be sent. -More information about redirects between data centers »

-

400 BAD_REQUEST

-

The query contains errors. In the event that a request was created using a form and contains user generated data, the user should be notified that the data must be corrected before the query is repeated.

-

Examples of Errors:

-
    -
  • FIRSTNAME_INVALID: The first name is invalid
  • -
  • LASTNAME_INVALID: The last name is invalid
  • -
  • PHONE_NUMBER_INVALID: The phone number is invalid
  • -
  • PHONE_CODE_HASH_EMPTY: phone_code_hash is missing
  • -
  • PHONE_CODE_EMPTY: phone_code is missing
  • -
  • PHONE_CODE_EXPIRED: The confirmation code has expired
  • -
  • API_ID_INVALID: The api_id/api_hash combination is invalid
  • -
  • PHONE_NUMBER_OCCUPIED: The phone number is already in use
  • -
  • PHONE_NUMBER_UNOCCUPIED: The phone number is not yet being used
  • -
  • USERS_TOO_FEW: Not enough users (to create a chat, for example)
  • -
  • USERS_TOO_MUCH: The maximum number of users has been exceeded (to create a chat, for example)
  • -
  • TYPE_CONSTRUCTOR_INVALID: The type constructor is invalid
  • -
  • FILE_PART_INVALID: The file part number is invalid
  • -
  • FILE_PARTS_INVALID: The number of file parts is invalid
  • -
  • FILE_PART_Х_MISSING: Part X (where X is a number) of the file is missing from storage
  • -
  • MD5_CHECKSUM_INVALID: The MD5 checksums do not match
  • -
  • PHOTO_INVALID_DIMENSIONS: The photo dimensions are invalid
  • -
  • FIELD_NAME_INVALID: The field with the name FIELD_NAME is invalid
  • -
  • FIELD_NAME_EMPTY: The field with the name FIELD_NAME is missing
  • -
  • MSG_WAIT_FAILED: A request that must be completed before processing the current request returned an error
  • -
  • MSG_WAIT_TIMEOUT: A request that must be completed before processing the current request didn't finish processing yet
  • -
-

401 UNAUTHORIZED

-

There was an unauthorized attempt to use functionality available only to authorized users.

-

Examples of Errors:

-
    -
  • AUTH_KEY_UNREGISTERED: The key is not registered in the system
  • -
  • AUTH_KEY_INVALID: The key is invalid
  • -
  • USER_DEACTIVATED: The user has been deleted/deactivated
  • -
  • SESSION_REVOKED: The authorization has been invalidated, because of the user terminating all sessions
  • -
  • SESSION_EXPIRED: The authorization has expired
  • -
  • AUTH_KEY_PERM_EMPTY: The method is unavailble for temporary authorization key, not bound to permanent
  • -
-

403 FORBIDDEN

-

Privacy violation. For example, an attempt to write a message to someone who has blacklisted the current user.

-

404 NOT_FOUND

-

An attempt to invoke a non-existent object, such as a method.

-

406 NOT_ACCEPTABLE

-

Similar to 400 BAD_REQUEST, but the app should not display any error messages to user in UI as a result of this response. The error message will be delivered via updateServiceNotification instead.

-

420 FLOOD

-

The maximum allowed number of attempts to invoke the given method with the given input parameters has been exceeded. For example, in an attempt to request a large number of text messages (SMS) for the same phone number.

-

Error Example:

-
    -
  • FLOOD_WAIT_X: A wait of X seconds is required (where X is a number)
  • -
-

500 INTERNAL

-

An internal server error occurred while a request was being processed; for example, there was a disruption while accessing a database or file storage.

-

If a client receives a 500 error, or you believe this error should not have occurred, please collect as much information as possible about the query and error and send it to the developers.

-

Other Error Codes

-

If a server returns an error with a code other than the ones listed above, it may be considered the same as a 500 error and treated as an internal server error.

- -
- -
-
- -
- - - - - - diff --git a/data/promote.telegram.org/js/promote.js b/data/promote.telegram.org/js/promote.js new file mode 100644 index 0000000000..dc8bb463d0 --- /dev/null +++ b/data/promote.telegram.org/js/promote.js @@ -0,0 +1,2007 @@ + +var Ads = { + init: function() { + Aj.onLoad(function(state) { + Ads.updateTime(Aj.ajContainer); + Ads.updateAdMessagePreviews(Aj.ajContainer); + $('.logout-link').on('click', Ads.eLogOut); + }); + Aj.onUnload(function(state) { + $('.logout-link').off('click', Ads.eLogOut); + }); + }, + checkAuth: function (e) { + if (Aj.needAuth()) { + e.preventDefault(); + return false; + } + }, + eUpdateField: function(e) { + var $fieldEl = $(this); + if (e.type == 'focus' || e.type == 'focusin') { + Ads.updateField($fieldEl, true); + } else if (e.type == 'blur' || e.type == 'focusout') { + Ads.updateField($fieldEl, false); + } else { + Ads.updateField($fieldEl); + } + }, + wrapAmount: function(value, no_currency, field_format) { + var amount_str = formatNumber(value, 2, '.', field_format ? '' : ','); + if (no_currency) { + return amount_str; + } + var currency = l('WEB_ADS_DEF_CURRENCY_SIGN', '€'); + return '' + currency + '' + amount_str; + }, + amountFieldValue: function($form, field) { + var $fieldEl = $form.field(field); + var minValue = $fieldEl.attr('data-min') || null; + var maxValue = $fieldEl.attr('data-max') || null; + var decPoint = $fieldEl.attr('data-dec-point') || '.'; + var value = $fieldEl.value(); + + var float_value = value.length ? value : '0'; + if (decPoint != '.') { + float_value.split(decPoint).join('.'); + } + float_value = parseFloat(float_value); + if (isNaN(float_value) || float_value >= 1e12) { + return false; + } + if (minValue !== null && float_value < minValue || + maxValue !== null && float_value > maxValue) { + return false; + } else { + return float_value; + } + }, + eUpdateAmountField: function(e) { + var $fieldEl = $(this); + var minValue = $fieldEl.attr('data-min') || null; + var maxValue = $fieldEl.attr('data-max') || null; + var decPoint = $fieldEl.attr('data-dec-point') || '.'; + var decimals = $fieldEl.attr('data-decimals') || 2; + var sel_dir = this.selectionDirection; + var sel_start = this.selectionStart; + var sel_end = this.selectionEnd; + var value = this.value; + var new_sel_start = sel_start; + var new_sel_end = sel_end; + var new_value = ''; + var has_decimal = false; + var chars_len = 0; + var decimal_len = 0; + for (var i = 0; i < value.length; i++) { + var char = value[i]; + if ((char == '.' || char == ',') && !has_decimal) { + if (!chars_len) { + new_value += '0'; + if (i < sel_start) new_sel_start++; + if (i < sel_end) new_sel_end++; + } + has_decimal = true; + new_value += decPoint; + } else if (char >= '0' && char <= '9' && decimal_len < decimals) { + new_value += char; + if (has_decimal) decimal_len++; + else chars_len++; + } else { + if (i < sel_start) new_sel_start--; + if (i < sel_end) new_sel_end--; + } + } + this.value = new_value; + this.setSelectionRange(new_sel_start, new_sel_end, sel_dir); + var float_value = new_value.length ? new_value : '0'; + if (decPoint != '.') { + float_value.split(decPoint).join('.'); + } + float_value = parseFloat(float_value); + var is_invalid = (isNaN(float_value) || float_value >= 1e12); + if (minValue !== null && float_value < minValue || + maxValue !== null && float_value > maxValue || + is_invalid) { + Ads.showFieldError($fieldEl); + } else { + Ads.hideFieldError($fieldEl); + } + if (e.type == 'change') { + if (new_value.length && !is_invalid) { + this.value = Ads.wrapAmount(float_value, true, true); + } + } + }, + updateField: function($fieldEl, focused) { + var $formGroup = $fieldEl.parents('.form-group'); + if (typeof focused !== 'undefined') { + $formGroup.toggleClass('field-focused', focused); + } + var $select = $fieldEl.parents('.select'); + var selectedCnt = $select.find('.selected-item').size(); + $formGroup.toggleClass('noinput', $select.hasClass('no-search') && !selectedCnt); + var hasValue = $fieldEl.value().length > 0 || selectedCnt > 0; + $formGroup.toggleClass('field-has-value', hasValue); + }, + showFieldHint: function($fieldEl, hint_text, field_invalid) { + var $formGroup = $fieldEl.parents('.form-group'); + var $hint = $formGroup.find('>.pr-form-control-hint'); + var $msg = $formGroup.find('>.pr-form-control-msg'); + if (!$msg.size() && hint_text) { + $msg = $('
'); + $formGroup.find('>.pr-form-control-wrap').after($msg); + } + $msg.toggleClass('no-hint', !$hint.text().length); + if (hint_text) { + $msg.html('
' + hint_text + '
').redraw().fadeShow(); + } else { + $msg.fadeHide(); + } + $formGroup.toggleClass('field-invalid', !!field_invalid); + }, + showFieldError: function($fieldEl, error_text, focus) { + Ads.showFieldHint($fieldEl, error_text, true); + if (focus) { + if ($fieldEl.hasClass('select')) { + $fieldEl.trigger('click'); + $fieldEl.find('.items-list').addClass('collapsed'); + $fieldEl.removeClass('open'); + } else { + $fieldEl.focusAndSelect(); + } + } + }, + hideFieldError: function($fieldEl) { + Ads.showFieldHint($fieldEl, '', false); + }, + onSelectChange: function(field, value, valueFull) { + var $fieldEl = Aj.state.$form.field(field); + Ads.hideFieldError($fieldEl); + }, + updateTime: function(context) { + $('time[datetime]', context).each(function () { + var $time = $(this), datetime = $time.attr('datetime'), title = $time.attr('title'), html = $time.html(), new_html = formatDateTime(datetime, $time.hasClass('short')); + if (html != new_html) { + $time.html(new_html); + } + if ($time.hasClass('short') && title) { + var new_title = formatDateTime(datetime); + if (title != new_title) { + $time.attr('title', new_title); + } + } + $time.removeAttr('datetime'); + }); + }, + fieldInit: function(field) { + $(field).on('focus blur keyup change input', Ads.eUpdateField); + $(field).parents('.pr-search-input-wrap').find('.pr-search-reset').on('click', Ads.eClearField); + Ads.updateField($(field)); + }, + fieldDestroy: function(field) { + $(field).off('focus blur keyup change input', Ads.eUpdateField); + $(field).parents('.pr-search-input-wrap').find('.pr-search-reset').off('click', Ads.eClearField); + }, + formInit: function(form) { + var $form = $(form); + $('.pr-form-control', $form).each(function(){ Ads.fieldInit(this); }); + $('.js-amount-input', $form).on('keyup change input', Ads.eUpdateAmountField); + $('input.checkbox,input.radio', $form).on('focus blur', Ads.eUpdateField); + $('.js-hint-tooltip', $form).on('mouseover mouseout click', Ads.eHintEvent); + $('textarea.pr-form-control', $form).initAutosize(); + $(document).on('touchstart click', Ads.eHideAllHints); + setTimeout(function(){ $form.removeClass('no-transition'); }, 100); + }, + formDestroy: function(form) { + var $form = $(form); + $('.pr-form-control', $form).each(function(){ Ads.fieldDestroy(this); }); + $('.js-amount-input', $form).off('keyup change input', Ads.eUpdateAmountField); + $('input.checkbox,input.radio', $form).off('focus blur', Ads.eUpdateField); + $('.js-hint-tooltip', $form).off('mouseover mouseout click', Ads.eHintEvent); + $('textarea.pr-form-control', $form).destroyAutosize(); + $(document).off('touchstart click', Ads.eHideAllHints); + }, + eClearField: function(e) { + var $fieldEl = $(this).parents('.pr-search-input-wrap').find('.pr-search-input'); + $fieldEl.value('').trigger('input').focus(); + }, + showHint: function($hint, delay, hide_delay) { + hide_delay = hide_delay || 0; + var show_to = $hint.data('show_to'); + var hide_to = $hint.data('hide_to'); + clearTimeout(show_to); + clearTimeout(hide_to); + show_to = setTimeout(function() { + $hint.addClass('show-hint'); + if (hide_delay > 0) { + Ads.hideHint($hint, hide_delay); + } + }, delay); + $hint.data('show_to', show_to); + }, + hideHint: function($hint, delay) { + var show_to = $hint.data('show_to'); + var hide_to = $hint.data('hide_to'); + clearTimeout(show_to); + clearTimeout(hide_to); + hide_to = setTimeout(function() { + $hint.removeClass('show-hint'); + }, delay); + $hint.data('hide_to', hide_to); + }, + eHintEvent: function(e) { + var $hint = $(this); + if (e.type == 'click') { + Ads.showHint($hint, 50, 2000); + } else if (e.type == 'mouseover') { + Ads.showHint($hint, 400); + } else if (e.type == 'mouseout') { + Ads.hideHint($hint, 100); + } + }, + eHideAllHints: function(e) { + var $closestHint = $(e.target).closest('.js-hint-tooltip'); + $('.js-hint-tooltip.show-hint').each(function() { + if (!$closestHint.filter(this).size()) { + Ads.hideHint($(this), 1); + } + }); + }, + updateTextShadow: function(footerEl, textSel, shadowedSel, add_margin) { + var textEl = footerEl.previousElementSibling; + if (textEl && $(textEl).is(textSel)) { + var text_rect = textEl.getBoundingClientRect(); + var tnode = textEl.firstChild; + while (tnode && tnode.nodeType == tnode.ELEMENT_NODE) { + tnode = tnode.firstChild; + } + $(textEl).removeClass('before_footer'); + if (tnode) { + var r = document.createRange(); + r.setStart(tnode, 0); + r.setEnd(tnode, 1); + var char_rect = r.getBoundingClientRect(); + if (Math.abs(char_rect.right - text_rect.right) > 3) { + var $infoEl = $(footerEl).find(shadowedSel); + if ($infoEl.size()) { + $(textEl).find('span.js-shadow').remove(); + var $shadowEl = $('').css('display', 'inline-block').width($infoEl.width() + (add_margin || 0)); + $(textEl).append($shadowEl).addClass('before_footer'); + } + } + } + } + }, + updateAdMessagePreviews: function(cont) { + $('.pr-review-ad-preview .tgme_widget_message_footer', cont).each(function() { + Ads.updateTextShadow(this, '.js-message_text', '.js-message_info'); + }); + }, + initSelect: function($form, field, options) { + var $selectEl = $form.field(field); + var $selectInput = $('.input', $selectEl); + options = options || {}; + $selectEl.data('selOpts', options); + Aj.onLoad(function(state) { + $selectEl.initSelect({ + multiSelect: !options.noMultiSelect, + noCloseOnSelect: false, + noCloseOnEnter: !!options.onEnter, + enterEnabled: function() { + return !!options.onEnter; + }, + prepareQuery: function(str) { + return $.trim(str).toLowerCase(); + }, + renderItem: options.renderItem, + renderSelectedItem: options.renderSelectedItem, + renderNoItems: function(q) { + return q && options.l_no_items_found ? '
' + options.l_no_items_found + '
' : ''; + }, + getData: function() { + var data = options.items; + for (var i = 0; i < data.length; i++) { + var item = data[i]; + item._values = [item.name.toLowerCase()]; + } + return data; + }, + onBlur: function(value) { + options.onEnter && options.onEnter(field, value); + }, + onEnter: function(value) { + options.onEnter && options.onEnter(field, value); + }, + onChange: function(value, valueFull) { + options.onChange && options.onChange(field, value, valueFull); + }, + onUpdate: function(value, valueFull) { + Ads.updateField($selectInput); + options.onUpdate && options.onUpdate(field, value, valueFull); + } + }); + Ads.updateField($selectInput); + }); + Aj.onUnload(function(state) { + $selectEl.destroySelect(); + }); + }, + eLogOut: function(e) { + e.preventDefault(); + e.stopImmediatePropagation(); + Aj.apiRequest('logOut', {}, function(result) { + location.reload(); + }); + return false; + } +}; + +var NewAd = { + init: function() { + var cont = Aj.ajContainer; + Aj.onLoad(function(state) { + state.$form = $('.pr-new-form', cont); + Ads.formInit(state.$form); + state.$form.on('submit', preventDefault); + cont.on('click.curPage', '.js-preview-link', NewAd.ePreviewAd); + cont.on('click.curPage', '.clear-draft-btn', NewAd.eClearDraft); + cont.on('click.curPage', '.create-new-ad-btn', NewAd.eSubmitForm); + for (var i = 0; i < state.selectList.length; i++) { + var selectData = state.selectList[i]; + if (selectData.channel_search) { + Ads.initSelect(state.$form, selectData.field, { + items: Aj.state[selectData.items_key] || [], + renderSelectedItem: function(val, item) { + return '
' + (item.photo ? '
' + item.photo + '
' : '') + '
' + item.name + '
'; + }, + l_channels_limit: selectData.limit_lang_key ? l(selectData.limit_lang_key) : '', + onEnter: NewAd.onChannelSearch, + onUpdate: NewAd.onSelectUpdate, + onChange: Ads.onSelectChange + }); + } else { + Ads.initSelect(state.$form, selectData.field, { + items: Aj.state[selectData.items_key] || [], + l_no_items_found: selectData.no_items_lang_key ? l(selectData.no_items_lang_key) : '', + onUpdate: NewAd.onSelectUpdate, + onChange: Ads.onSelectChange + }); + } + } + state.titleField = state.$form.field('title'); + state.titleField.on('change.curPage', NewAd.onTitleChange); + state.textField = state.$form.field('text'); + state.textField.on('change.curPage', NewAd.onTextChange); + state.textField.on('input.curPage', NewAd.onTextInput); + state.promoteUrlField = state.$form.field('promote_url'); + state.promoteUrlField.on('change.curPage', NewAd.onPromoteUrlChange); + state.confirmedCheckbox = state.$form.field('confirmed'); + state.confirmedCheckbox.on('change.curPage', NewAd.onConfirmedChange); + NewAd.updateAdPreview(state.$form, state.previewData); + NewAd.updateAdTargetOverview(); + setTimeout(function() { + state.titleField.focusAndSelect(); + }, 50); + Aj.onLoad(function(state) { + state.initFormData = NewAd.getFormData(state.$form); + state.initPreviewFormData = NewAd.getPreviewFormData(); + Aj.onBeforeUnload(function() { + var curPreviewFormData = NewAd.getPreviewFormData(); + if (Aj.state.initPreviewFormData != curPreviewFormData) { + return l('WEB_LEAVE_PAGE_CONFIRM_TEXT'); + } + var curFormData = NewAd.getFormData(state.$form); + if (Aj.state.initFormData != curFormData) { + return l('WEB_LEAVE_PAGE_CONFIRM_TEXT'); + } + return false; + }); + NewAd.saveDraftAuto(true); + }); + }); + Aj.onUnload(function(state) { + Ads.formDestroy(state.$form); + state.$form.off('submit', preventDefault); + state.titleField.off('.curPage'); + state.textField.off('.curPage'); + state.promoteUrlField.off('.curPage'); + state.confirmedCheckbox.off('.curPage'); + clearTimeout(state.saveDraftTo); + }); + }, + onTitleChange: function() { + Ads.hideFieldError($(this)); + }, + onConfirmedChange: function() { + $('.create-new-ad-btn', Aj.ajContainer).prop('disabled', !$(this).prop('checked')); + }, + onTextChange: function() { + var $form = $(this.form); + var textField = $form.field('text'); + Ads.hideFieldError(textField); + NewAd.adPostCheck($form); + }, + onTextInput: function() { + var textField = $(this); + var text = textField.value(); + var max_len = Aj.state.textMaxLength; + var symbols_left = max_len - text.length; + Ads.showFieldError(textField); + if (text.indexOf('\n') >= 0) { + Ads.showFieldHint(textField, l('ADS_ERROR_POST_NEW_LINES_NOT_ALLOWED'), true); + } else if (symbols_left < 0) { + Ads.showFieldHint(textField, l('ADS_ERROR_POST_MESSAGE_TOO_LONG', {max_len: Aj.state.textMaxLength}), true); + } else { + if (symbols_left <= 20) { + Ads.showFieldHint(textField, l('WEB_AD_TEXT_SYMBOLS_LEFT', {n: symbols_left})); + } else { + Ads.showFieldHint(textField, ''); + } + } + }, + onPromoteUrlChange: function() { + var $form = $(this.form); + var promoteUrlField = $form.field('promote_url'); + Ads.hideFieldError(promoteUrlField); + NewAd.adPostCheck($form); + }, + adPostCheck: function($form) { + var textField = $form.field('text'); + var promoteUrlField = $form.field('promote_url'); + var text = textField.value(); + var promote_url = promoteUrlField.value(); + var $formGroup = promoteUrlField.parents('.form-group'); + if (!text && !promote_url) { + return false; + } + var params = { + text: text, + promote_url: promote_url + }; + if (Aj.state.ownerId && Aj.state.adId) { + params.owner_id = Aj.state.ownerId; + params.ad_id = Aj.state.adId; + } + $formGroup.addClass('field-loading'); + Aj.apiRequest('checkAdPost', params, function(result) { + Ads.hideFieldError(textField); + Ads.hideFieldError(promoteUrlField); + $formGroup.removeClass('field-loading'); + if (result.promote_url) { + var new_promote_url = promoteUrlField.value(); + if (!new_promote_url || promote_url == new_promote_url) { + if (new_promote_url != result.promote_url) { + promoteUrlField.value(result.promote_url); + } + } + } + if (result.exclude_channel) { + var $excludeField = Aj.state.$form.field('exclude_channels'); + var excludeValueFull = $excludeField.data('valueFull'); + var already_excluded = false; + excludeValueFull && $.each(excludeValueFull, function(val, item) { + if (item.val == result.exclude_channel.id) { + already_excluded = true; + } else if (item._auto) { + $excludeField.trigger('deselectval', [val]); + $excludeField.data('prevval', ''); + if (Aj.state.autoExcluded) { + delete Aj.state.autoExcluded[item.val]; + } + } + }); + if (!already_excluded) { + if (!Aj.state.autoExcluded) { + Aj.state.autoExcluded = {}; + } + if (!Aj.state.autoExcluded[result.exclude_channel.id]) { + var item = { + val: result.exclude_channel.id, + name: result.exclude_channel.title, + photo: result.exclude_channel.photo, + _auto: true + }; + $excludeField.trigger('selectval', [item, true]); + $excludeField.data('prevval', ''); + Aj.state.autoExcluded[result.exclude_channel.id] = true; + } + } + } + NewAd.updateAdPreview($form, result.preview_data); + if (result.error) { + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + }); + }, + onChannelSearch: function(field, value) { + var $fieldEl = Aj.state.$form.field(field); + var $formGroup = $fieldEl.parents('.form-group'); + var prev_value = $fieldEl.data('prevval'); + if (prev_value && prev_value == value) { + return false; + } + $fieldEl.data('prevval', value); + Ads.hideFieldError($fieldEl); + if (!value) { + return false; + } + var channels_limit = Aj.state.channelItemsLimit; + if ($fieldEl.data('value').length >= channels_limit) { + var selOpts = $fieldEl.data('selOpts'); + if (selOpts.l_channels_limit) { + Ads.showFieldError($fieldEl, selOpts.l_channels_limit); + return false; + } + } + $formGroup.addClass('field-loading'); + Aj.apiRequest('searchChannel', { + query: value, + field: field + }, function(result) { + $formGroup.removeClass('field-loading'); + if (result.error) { + Ads.showFieldError($fieldEl, result.error); + return false; + } + if (result.channel) { + var item = { + val: result.channel.id, + name: result.channel.title, + photo: result.channel.photo, + username: result.channel.username + }; + $fieldEl.trigger('selectval', [item, true]); + $fieldEl.data('prevval', ''); + } + }); + }, + onSelectUpdate: function(field, value, valueFull) { + var paired_field = null; + if (field == 'topics') { + paired_field = 'exclude_topics'; + } else if (field == 'exclude_topics') { + paired_field = 'topics'; + } else if (field == 'channels') { + paired_field = 'exclude_channels'; + } else if (field == 'exclude_channels') { + paired_field = 'channels'; + } + if (!paired_field) { + NewAd.updateAdTargetOverview(); + return; + } + var $pairedField = Aj.state.$form.field(paired_field); + if ($pairedField.data('inited')) { + var paired_value = $pairedField.data('value'); + var paired_valueFull = $pairedField.data('valueFull'); + valueFull && $.each(valueFull, function(val, item) { + if (paired_valueFull[val]) { + $pairedField.trigger('deselectval', [val]); + $pairedField.data('prevval', ''); + } + }); + } + NewAd.updateAdTargetOverview(); + }, + ePreviewAd: function(e) { + e.preventDefault(); + NewAd.previewPopup(); + }, + updateAdPreview: function($form, previewData) { + var $previewPopup = Aj.state.$previewPopup; + var inPopup = $form.parents('.pr-layer-preview-ad').size() > 0; + if (inPopup) { + Aj.state.popupPreviewData = previewData; + if ($previewPopup) { + if (previewData) { + $('.js-preview-from', $previewPopup).html(previewData.from); + $('.js-preview-from', $previewPopup).attr('href', previewData.from_url); + $('.js-promote-photo', $previewPopup).html(previewData.photo); + $('.js-promote-photo-tooltip', $previewPopup).html(previewData.from); + $('.js-preview-text', $previewPopup).html(previewData.text); + $('.js-preview-button', $previewPopup).html(previewData.button); + $('.js-preview-button', $previewPopup).attr('href', previewData.button_url); + $('.js-preview-footer', $previewPopup).each(function() { + Ads.updateTextShadow(this, '.ad-msg-text', '.label', 10); + }); + } + $('.js-promote-photo', $previewPopup).parents('.pr-form-control-wrap').toggleClass('has-photo', !!previewData); + $('.js-preview', $previewPopup).toggleClass('active', !!previewData); + } + } else { + Aj.state.previewData = previewData; + if (previewData) { + $('.js-promote-photo', Aj.state.$form).html(previewData.photo); + $('.js-promote-photo-tooltip', Aj.state.$form).html(previewData.from); + } + $('.js-promote-photo', Aj.state.$form).parents('.pr-form-control-wrap').toggleClass('has-photo', !!previewData); + $('.js-preview-link', Aj.state.$form).toggleClass('inactive', !previewData); + } + }, + checkBeforePreviewPopupUnload: function(load_fn) { + var message = null; + var curPreviewFormData = NewAd.getPreviewFormData(); + if (Aj.state.initPreviewFormData != curPreviewFormData) { + message = l('WEB_LEAVE_FORM_CONFIRM_TEXT'); + } + if (message) { + var message_html = $('
').text(message).html(); + showConfirm(message_html, load_fn, l('WEB_LEAVE_PAGE', 'Leave')); + return false; + } else { + load_fn(); + return true; + } + }, + previewPopup: function() { + var state = Aj.state; + if (!state.previewData) { + return false; + } + var $previewPopup = $(''); + state.$previewPopup = $previewPopup; + var $form = state.$form; + var text = $form.field('text').value(); + var promote_url = $form.field('promote_url').value(); + + var $previewForm = $('.pr-new-form', $previewPopup); + Ads.formInit($previewForm); + $previewForm.on('submit', preventDefault); + + state.previewTextField = $previewForm.field('text'); + state.previewTextField.on('change.curPage', NewAd.onTextChange); + state.previewTextField.value(text); + state.previewTextField.on('input.curPage', NewAd.onTextInput); + state.previewPromoteUrlField = $previewForm.field('promote_url'); + state.previewPromoteUrlField.on('change.curPage', NewAd.onPromoteUrlChange); + state.previewPromoteUrlField.value(promote_url); + + NewAd.updateAdPreview($previewForm, state.previewData); + NewAd.adPostCheck($previewForm); + + var previewSave = function() { + var text = state.previewTextField.value(); + var promote_url = state.previewPromoteUrlField.value(); + $form.field('text').value(text).updateAutosize(); + $form.field('promote_url').value(promote_url); + NewAd.updateAdPreview($form, state.popupPreviewData); + NewAd.adPostCheck($form); + delete state.popupPreviewData; + delete state.$previewPopup; + state.initPreviewFormData = NewAd.getPreviewFormData(); + closePopup($previewPopup); + } + var $submitBtn = $('.submit-form-btn', $previewPopup); + $submitBtn.on('click', previewSave); + var previewCancel = function() { + closePopup($previewPopup); + } + var $cancelBtn = $('.cancel-form-btn', $previewPopup); + $cancelBtn.on('click', previewCancel); + $previewPopup.one('popup:open', function() { + $('.pr-preview-ad-message .ad-msg-date', $previewPopup).each(function() { + Ads.updateTextShadow(this, '.ad-msg-text', '.label', 10); + }); + state.previewTextField.updateAutosize(); + state.initPreviewFormData = NewAd.getPreviewFormData(); + }); + $previewPopup.one('popup:close', function() { + Ads.formDestroy($previewForm); + $previewForm.off('submit', preventDefault); + delete state.$previewPopup; + $submitBtn.off('click', previewSave); + $cancelBtn.off('click', previewCancel); + $previewPopup.remove(); + state.initPreviewFormData = NewAd.getPreviewFormData(); + }); + openPopup($previewPopup, { + closeByClickOutside: '.popup-no-close', + onBeforeClose: function($popup) { + var unloaded = NewAd.checkBeforePreviewPopupUnload(function() { + var options = $popup.data('options'); + options.onBeforeClose = null; + closePopup($popup); + }); + return unloaded; + } + }); + return $previewPopup; + }, + updateAdTargetOverview: function() { + var len = {}, lang_params = {}; + for (var i = 0; i < Aj.state.selectList.length; i++) { + var selectData = Aj.state.selectList[i]; + var field = selectData.field; + var $field = Aj.state.$form.field(field); + var value = $field.data('value') || []; + var valueFull = $field.data('valueFull') || {}; + len[field] = value.length; + if (value.length) { + var list = []; + for (var j = 0; j < value.length; j++) { + var val = value[j], valFull = valueFull[val] || {}; + list.push(valFull.username ? '' + valFull.name + '' : '' + valFull.name + ''); + } + if (list.length > 1) { + var last_item = list.pop(); + list[list.length - 1] = l('WEB_AD_TARGET_AND', {item1: list[list.length - 1], item2: last_item}); + } + lang_params[field] = list.join(', '); + } else { + lang_params[field] = ''; + } + Ads.hideFieldError($field); + } + if (!len.langs && len.topics) { + Ads.showFieldError(Aj.state.$form.field('langs'), l('ADS_ERROR_LANGUAGE_REQUIRED')); + } + var overview = ''; + if (!len.langs && !len.topics && !len.channels || + !len.langs && len.topics) { + overview += '
' + l('WEB_AD_TARGET_NOTHING') + '
'; + } else { + if (len.langs > 0) { + if (len.topics > 0) { + overview += '
' + l('WEB_AD_TARGET_TOPICS', lang_params) + '
'; + } else { + overview += '
' + l('WEB_AD_TARGET_LANGS', lang_params) + '
'; + } + } + if (len.channels > 0) { + overview += '
' + l('WEB_AD_TARGET_CHANNELS', lang_params) + '
'; + } + if (len.exclude_topics > 0) { + overview += '
' + l('WEB_AD_TARGET_EXCLUDE_TOPICS', lang_params) + '
'; + } + if (len.exclude_channels > 0) { + overview += '
' + l('WEB_AD_TARGET_EXCLUDE_CHANNELS', lang_params) + '
'; + } + } + $('.pr-target-overview', Aj.ajContainer).html(overview); + }, + getFormData: function($form) { + var form = $form.get(0); + if (!form) return false; + var values = [ + $form.field('title').value(), + $form.field('text').value(), + $form.field('promote_url').value(), + $form.field('cpm').value(), + $form.field('budget').value() + ]; + for (var i = 0; i < Aj.state.selectList.length; i++) { + var selectData = Aj.state.selectList[i]; + var vals = $form.field(selectData.field).data('value'); + values.push(vals.join(';')); + } + return values.join('|'); + }, + getPreviewFormData: function($form) { + if (Aj.state.$previewPopup) { + var $previewPopup = Aj.state.$previewPopup; + var $previewForm = $('.pr-new-form', $previewPopup); + if (!$previewForm.get(0)) return false; + var values = [ + $previewForm.field('text').value(), + $previewForm.field('promote_url').value() + ]; + return values.join('|'); + } + return false; + }, + eSubmitForm: function(e) { + e.preventDefault(); + var $form = Aj.state.$form; + var $button = $(this); + var title = $form.field('title').value(); + var text = $form.field('text').value(); + var promote_url = $form.field('promote_url').value(); + var cpm = Ads.amountFieldValue($form, 'cpm'); + var budget = Ads.amountFieldValue($form, 'budget'); + + if (!title.length) { + $form.field('title').focus(); + return false; + } + if (!text.length) { + $form.field('text').focus(); + return false; + } + if (!promote_url.length) { + $form.field('promote_url').focus(); + return false; + } + if (cpm === false) { + $form.field('cpm').focus(); + return false; + } + if (budget === false) { + $form.field('budget').focus(); + return false; + } + var params = { + owner_id: Aj.state.ownerId, + title: title, + text: text, + promote_url: promote_url, + cpm: cpm, + budget: budget + }; + for (var i = 0; i < Aj.state.selectList.length; i++) { + var selectData = Aj.state.selectList[i]; + var values = $form.field(selectData.field).data('value'); + params[selectData.field] = values.join(';'); + } + NewAd.saveDraftAuto(true); + $button.prop('disabled', true); + Aj.apiRequest('createAd', params, function(result) { + if (result.error) { + $button.prop('disabled', false); + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + Aj.state.initFormData = NewAd.getFormData($form); + NewAd.saveDraftAuto(true); + if (result.redirect_to) { + Aj.location(result.redirect_to); + } + }); + return false; + }, + eClearDraft: function(e) { + e.preventDefault(); + NewAd.clearDraft(); + }, + saveDraftAuto: function(with_delay) { + if (!with_delay) { + NewAd.saveDraft(); + } + clearTimeout(Aj.state.saveDraftTo); + Aj.state.saveDraftTo = setTimeout(NewAd.saveDraftAuto, 3000, false); + }, + saveDraft: function() { + var $form = Aj.state.$form; + var title = $form.field('title').value(); + var text = $form.field('text').value(); + var promote_url = $form.field('promote_url').value(); + var cpm = Ads.amountFieldValue($form, 'cpm'); + var budget = Ads.amountFieldValue($form, 'budget'); + + var curFormData = NewAd.getFormData($form); + if (Aj.state.initFormData == curFormData) { + return false; + } + var params = { + owner_id: Aj.state.ownerId, + title: title, + text: text, + promote_url: promote_url, + cpm: cpm, + budget: budget + }; + for (var i = 0; i < Aj.state.selectList.length; i++) { + var selectData = Aj.state.selectList[i]; + var values = $form.field(selectData.field).data('value'); + params[selectData.field] = values.join(';'); + } + Aj.apiRequest('saveAdDraft', params, function(result) { + if (result.error) { + return showAlert(result.error); + } + Aj.state.initFormData = curFormData; + NewAd.saveDraftAuto(true); + $('.pr-draft-btn-wrap').toggleClass('active', !!result.has_draft); + // $('.pr-draft-btn-wrap').addClass('saved'); + // setTimeout(function() { + // $('.pr-draft-btn-wrap').removeClass('saved'); + // }, 1500); + }); + return false; + }, + clearDraft: function(callback) { + var $form = Aj.state.$form; + $form.field('title').value(''); + $form.field('text').value(''); + $form.field('promote_url').value(''); + $form.field('cpm').value(''); + $form.field('budget').value(''); + for (var i = 0; i < Aj.state.selectList.length; i++) { + var selectData = Aj.state.selectList[i]; + var values = $form.field(selectData.field).trigger('reset'); + } + Aj.state.titleField.focusAndSelect(); + NewAd.updateAdPreview(Aj.state.$form, false); + var curFormData = NewAd.getFormData($form); + var params = { + owner_id: Aj.state.ownerId + }; + $('.pr-draft-btn-wrap').removeClass('active'); + NewAd.saveDraftAuto(true); + Aj.apiRequest('clearAdDraft', params, function(result) { + if (result.error) { + return showAlert(result.error); + } + Aj.state.initFormData = curFormData; + NewAd.saveDraftAuto(true); + callback && callback(); + }); + return false; + } +}; + +var Account = { + formFields: [ + 'full_name', + 'email', + 'phone_number', + 'country', + 'city' + ], + addFundsFormFields: [ + 'adv_type', + 'products_desc', + 'ads_language', + 'annual_budget', + 'additional_comment', + ], + init: function() { + var cont = Aj.ajContainer; + Aj.onLoad(function(state) { + state.$form = $('.account-edit-form', cont); + Ads.formInit(state.$form); + state.$form.on('submit', preventDefault); + cont.on('click.curPage', '.save-info-btn', Account.eSubmitForm); + cont.on('change.curPage', '.pr-form-control', Account.onFieldChange); + Ads.initSelect(state.$form, 'channel', { + items: Aj.state.channelItems || [], + noMultiSelect: true, + renderSelectedItem: function(val, item) { + return '
' + (item.photo ? '
' + item.photo + '
' : '') + '
' + item.name + '
'; + }, + onChange: Account.onChannelChange + }); + Aj.onLoad(function(state) { + state.initFormData = Account.getFormData(state.$form); + Aj.onBeforeUnload(function() { + var curFormData = Account.getFormData(state.$form); + if (Aj.state.initFormData != curFormData) { + return l('WEB_LEAVE_PAGE_CONFIRM_TEXT'); + } + return false; + }); + }); + }); + Aj.onUnload(function(state) { + Ads.formDestroy(state.$form); + state.$form.off('submit', preventDefault); + }); + }, + onFieldChange: function() { + if (!$(this).hasClass('js-amount-input')) { + Ads.hideFieldError($(this)); + } + }, + onChannelChange: function(field, value, valueFull) { + $accPhoto = $('.pr-account-button-wrap.current .pr-account-button-photo'); + $accTitle = $('.pr-account-button-wrap.current .pr-account-button-title'); + if (!$accPhoto.data('def-val')) { + $accPhoto.data('def-val', $accPhoto.html()); + } + if (!$accTitle.data('def-val')) { + $accTitle.data('def-val', $accTitle.html()); + } + $accPhoto.html(valueFull ? valueFull.photo : $accPhoto.data('def-val')); + $accTitle.html(valueFull ? valueFull.name : $accTitle.data('def-val')); + var $form = Aj.state.$form; + for (var i = 0; i < Account.formFields.length; i++) { + var field = Account.formFields[i]; + var value = $form.field(field).prop('disabled', !valueFull); + } + }, + getFormData: function($form) { + var form = $form.get(0); + if (!form) return false; + var values = []; + if (!Aj.state.ownerId) { + var value = $form.field('channel').data('value'); + values.push(value); + } + for (var i = 0; i < Account.formFields.length; i++) { + var field = Account.formFields[i]; + var value = $form.field(field).value(); + values.push(value); + } + return values.join('|'); + }, + eSubmitForm: function(e) { + e.preventDefault(); + var $form = Aj.state.$form; + var $button = $(this); + var params = {}; + if (Aj.state.ownerId) { + params.owner_id = Aj.state.ownerId; + } else { + params.owner_id = $form.field('channel').data('value'); + if (!params.owner_id) { + $form.field('channel').trigger('click'); + return false; + } + } + for (var i = 0; i < Account.formFields.length; i++) { + var field = Account.formFields[i]; + var value = $form.field(field).value(); + if (!value.length) { + $form.field(field).focus(); + return false; + } + params[field] = value; + } + + $button.prop('disabled', true); + Aj.apiRequest('saveAccountInfo', params, function(result) { + if (result.error) { + $button.prop('disabled', false); + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + Aj.state.initFormData = Account.getFormData($form); + if (result.redirect_to) { + Aj.location(result.redirect_to); + } + }); + return false; + }, + initAddFunds: function() { + var cont = Aj.ajContainer; + Aj.onLoad(function(state) { + state.$form = $('.add-funds-req-form', cont); + Ads.formInit(state.$form); + state.$form.on('submit', preventDefault); + cont.on('click.curPage', '.send-request-btn', Account.eSendAddFundsRequest); + cont.on('change.curPage', '.pr-form-control', Account.onFieldChange); + Ads.initSelect(state.$form, 'ads_language', { + items: Aj.state.langItems || [], + noMultiSelect: true, + l_no_items_found: l('WEB_AD_NO_LANGS_FOUND'), + onChange: Account.onFieldChange + }); + state.confirmedCheckbox = state.$form.field('confirmed'); + state.confirmedCheckbox.on('change.curPage', Account.onConfirmedChange); + Aj.onLoad(function(state) { + state.initFormData = Account.getAddFundsFormData(state.$form); + Aj.onBeforeUnload(function() { + var curFormData = Account.getAddFundsFormData(state.$form); + if (Aj.state.initFormData != curFormData) { + return l('WEB_LEAVE_PAGE_CONFIRM_TEXT'); + } + return false; + }); + }); + }); + Aj.onUnload(function(state) { + Ads.formDestroy(state.$form); + state.$form.off('submit', preventDefault); + }); + }, + onConfirmedChange: function() { + $('.send-request-btn', Aj.ajContainer).prop('disabled', !$(this).prop('checked')); + }, + getAddFundsFormData: function($form) { + var form = $form.get(0); + if (!form) return false; + var values = []; + for (var i = 0; i < Account.formFields.length; i++) { + var field = Account.formFields[i]; + var value = $form.field(field).value(); + values.push(value); + } + for (var i = 0; i < Account.addFundsFormFields.length; i++) { + var field = Account.addFundsFormFields[i]; + var value = $form.field(field).value(); + values.push(value); + } + return values.join('|'); + }, + eSendAddFundsRequest: function(e) { + e.preventDefault(); + var $form = Aj.state.$form; + var $button = $(this); + var params = { + owner_id: Aj.state.ownerId + }; + for (var i = 0; i < Account.formFields.length; i++) { + var field = Account.formFields[i]; + var value = $form.field(field).value(); + if (!value.length) { + $form.field(field).focus(); + return false; + } + params[field] = value; + } + params.adv_type = $form.field('adv_type').value(); + params.products_desc = $form.field('products_desc').value(); + if (!params.products_desc.length) { + $form.field('products_desc').focus(); + return false; + } + params.ads_language = $form.field('ads_language').data('value'); + if (!params.ads_language.length) { + $form.field('ads_language').trigger('click'); + return false; + } + params.annual_budget = Ads.amountFieldValue($form, 'annual_budget'); + if (params.annual_budget === false) { + $form.field('annual_budget').focus(); + return false; + } + params.additional_comment = $form.field('additional_comment').value(); + + $button.prop('disabled', true); + Aj.apiRequest('sendAddFundsRequest', params, function(result) { + if (result.error) { + $button.prop('disabled', false); + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + Aj.state.initFormData = Account.getAddFundsFormData($form); + if (result.redirect_to) { + Aj.location(result.redirect_to); + } + if (result.ok_msg) { + showAlert(result.ok_msg); + } + }); + return false; + } +}; + +var OwnerAds = { + init: function() { + var cont = Aj.ajContainer; + Aj.onLoad(function(state) { + state.$searchField = $('.pr-search-input'); + state.$searchResults = $('.pr-table tbody'); + Ads.fieldInit(state.$searchField); + cont.on('click.curPage', '.pr-cell-sort', OwnerAds.eSortList); + + state.$searchField.initSearch({ + $results: state.$searchResults, + emptyQueryEnabled: true, + updateOnInit: true, + resultsNotScrollable: true, + itemTagName: 'tr', + enterEnabled: function() { + return false; + }, + renderItem: function(item, query) { + var status_attrs = ' href="' + item.base_url + item.status_url + '" ' + (item.status_attrs || 'data-layer'); + var tme_link = item.tme_path ? '' + item.tme_path + '' : '' + l('WEB_ADS_NO_TME_LINK') + ''; + return '
' + tme_link + '
' + item.status + '
'; + }, + renderLoading: function() { + return '
' + l('WEB_OWNER_ADS_LOADING') + '
'; + }, + renderNoItems: function(query) { + if (Aj.state.adsListIsLoading) { + return '
' + l('WEB_OWNER_ADS_LOADING') + '
'; + } + return '
' + l('WEB_OWNER_NO_ADS') + '
'; + }, + appendToItems: function(query, result_count) { + if (Aj.state.adsListIsLoading && result_count > 0) { + return '
' + l('WEB_OWNER_ADS_LOADING') + '
'; + } + return ''; + }, + getData: function() { + return OwnerAds.getAdsList(); + } + }); + }); + Aj.onUnload(function(state) { + Ads.fieldDestroy(state.$searchField); + state.$searchField.destroySearch(); + }); + }, + formatTableDate: function(timestamp) { + var date = new Date(timestamp * 1000); + var j = date.getDate(); + var M = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][date.getMonth()]; + var y = date.getFullYear() % 100; + return j + ' ' + M + ' ' + y + ' ' + formatTime(timestamp * 1000); + }, + eSortList: function(e) { + var $sortEl = $(this); + var sortBy = $sortEl.attr('data-sort-by'); + var sortAsc = $sortEl.hasClass('sort-asc'); + if (sortBy == Aj.state.adsListSortBy) { + Aj.state.adsListSortAsc = !sortAsc; + } else { + Aj.state.adsListSortBy = sortBy; + Aj.state.adsListSortAsc = false; + } + OwnerAds.updateAdsList(); + Aj.state.$searchField.trigger('datachange'); + }, + updateAdsList: function() { + if (Aj.state.adsList) { + var sortBy = Aj.state.adsListSortBy; + var sortAsc = Aj.state.adsListSortAsc; + $('.pr-cell-sort').each(function() { + var $sortEl = $(this); + var curSortBy = $sortEl.attr('data-sort-by'); + $sortEl.toggleClass('sort-active', sortBy == curSortBy); + $sortEl.toggleClass('sort-asc', sortAsc && sortBy == curSortBy); + }); + Aj.state.adsList.sort(function(ad1, ad2) { + var v1 = sortAsc ? ad1 : ad2; + var v2 = sortAsc ? ad2 : ad1; + return (v1[sortBy] - v2[sortBy]) || (v1.date - v2.date); + }); + } + }, + processAdsList: function(result, opts) { + opts = opts || {}; + if (result.items) { + if (!Aj.state.adsList) { + Aj.state.adsList = []; + } + for (var i = 0; i < result.items.length; i++) { + var item = result.items[i]; + item.base_url = '/account/ad/' + item.ad_id; + item._values = [ + item.title.toLowerCase(), + item.tme_path.toLowerCase(), + ]; + Aj.state.adsList.push(item); + } + OwnerAds.updateAdsList(); + Aj.state.$searchField.trigger('contentchange'); + } + if (result.next_offset_id) { + opts.offset = result.next_offset_id; + OwnerAds.loadAdsList(opts); + } else { + Aj.state.adsListIsLoading = false; + Aj.state.$searchField.trigger('dataready'); + } + }, + loadAdsList: function(opts) { + opts = opts || {}; + Aj.apiRequest('getAdsList', { + owner_id: Aj.state.ownerId, + offset_id: opts.offset + }, function(result) { + if (result.error) { + if (!opts.retry) opts.retry = 1; + else opts.retry++; + setTimeout(function(){ OwnerAds.loadAdsList(opts); }, opts.retry * 1000); + } else { + if (opts.retry) { + opts.retry = 0; + } + OwnerAds.processAdsList(result, opts); + } + }); + }, + getAdsList: function() { + var _data = Aj.state.adsList; + if (_data === false) { + return false; + } else if (_data) { + return _data; + } + Aj.state.adsList = false; + Aj.state.adsListIsLoading = true; + if (Aj.state.initialAdsList) { + setTimeout(function() { + OwnerAds.processAdsList(Aj.state.initialAdsList); + }, 10); + } else { + OwnerAds.loadAdsList({offset: 0}); + } + return false; + }, + updateAd: function(ad) { + if (!Aj.state || !Aj.state.adsList) { + return; + } + var adsList = Aj.state.adsList; + for (var i = 0; i < adsList.length; i++) { + if (ad.owner_id == adsList[i].owner_id && + ad.ad_id == adsList[i].ad_id) { + ad.base_url = '/account/ad/' + ad.ad_id; + ad._values = [ + ad.title.toLowerCase(), + ad.tme_path.toLowerCase(), + ]; + adsList[i] = ad; + OwnerAds.updateAdsList(); + Aj.state.$searchField.trigger('contentchange'); + return; + } + } + } +}; + +var ReviewAds = { + init: function() { + var cont = Aj.ajContainer; + Aj.onLoad(function(state) { + state.$form = $('.pr-search-form', cont); + state.$form.on('submit', ReviewAds.onSubmit); + state.$searchField = $('.pr-search-input', cont); + Ads.fieldInit(state.$searchField); + cont.on('click.curPage', '.pr-search-reset', ReviewAds.eClearSearch); + cont.on('click.curPage', '.ad-approve-btn', ReviewAds.eApproveAd); + cont.on('click.curPage', '.ad-decline-btn', ReviewAds.eDeclineAd); + $(window).on('scroll resize', ReviewAds.onScroll); + ReviewAds.onScroll(); + }); + Aj.onUnload(function(state) { + state.$form.off('submit', ReviewAds.onSubmit); + Ads.fieldDestroy(state.$searchField); + $(window).off('scroll resize', ReviewAds.onScroll); + }); + }, + onScroll: function() { + $('.js-load-more').each(function() { + var $loadMore = $(this); + var top = $loadMore.offset().top - $(window).scrollTop(); + if (top < $(window).height() * 2) { + ReviewAds.load($loadMore); + } + }); + }, + load: function($loadMore) { + var offset = $loadMore.attr('data-offset'); + if (!offset) { + $loadMore.remove(); + } + if ($loadMore.data('loading')) { + return; + } + var params = Aj.state.filterParams; + params.offset_id = offset; + var $loadMoreBtn = $('.pr-load-more', $loadMore); + $loadMoreBtn.data('old-text', $loadMoreBtn.text()).text($loadMoreBtn.data('loading')).addClass('dots-animated'); + $loadMore.data('loading', true); + Aj.apiRequest('loadReviewedAds', params, function(result) { + $loadMore.data('loading', false); + if (result.ads_html) { + var $loadMoreCont = $loadMore.closest('.pr-review-list'); + if ($loadMoreCont.size()) { + $loadMore.remove(); + $loadMoreCont.append(result.ads_html); + Ads.updateAdMessagePreviews($loadMoreCont); + } else { + var $loadMoreBtn = $('.pr-load-more', $loadMore); + $loadMoreBtn.text($loadMoreBtn.data('old-text')).removeClass('dots-animated'); + } + ReviewAds.onScroll(); + } + }); + }, + onSubmit: function(e) { + e.preventDefault(); + var href = this.action; + if (this.query.value) { + href += href.indexOf('?') >= 0 ? '&' : '?'; + href += 'query=' + encodeURIComponent(this.query.value); + } + Aj.location(href); + }, + eClearSearch: function(e) { + Aj.state.$form.submit(); + }, + eApproveAd: function(e) { + e.preventDefault(); + var $ad = $(this).parents('.js-review-item'); + var owner_id = $ad.attr('data-owner-id'); + var ad_id = $ad.attr('data-ad-id'); + var $buttons = $ad.find('.pr-btn'); + + if ($buttons.prop('disabled')) { + return false; + } + $buttons.prop('disabled', true); + Aj.apiRequest('approveAd', { + owner_id: owner_id, + ad_id: ad_id + }, function(result) { + $buttons.prop('disabled', false); + if (result.error) { + return showAlert(result.error); + } + if (result.status_html) { + $ad.find('.js-review-ad-status').html(result.status_html); + } + if (result.buttons_html) { + $ad.find('.js-review-buttons').html(result.buttons_html); + } + }); + return false; + }, + eDeclineAd: function(e) { + e.preventDefault(); + var $ad = $(this).parents('.js-review-item'); + var owner_id = $ad.attr('data-owner-id'); + var ad_id = $ad.attr('data-ad-id'); + var $buttons = $ad.find('.pr-btn'); + var reason_id = $(this).attr('data-reason-id'); + + if ($buttons.prop('disabled')) { + return false; + } + $buttons.prop('disabled', true); + Aj.apiRequest('declineAd', { + owner_id: owner_id, + ad_id: ad_id, + reason_id: reason_id + }, function(result) { + $buttons.prop('disabled', false); + if (result.error) { + return showAlert(result.error); + } + if (result.status_html) { + $ad.find('.js-review-ad-status').html(result.status_html); + } + if (result.buttons_html) { + $ad.find('.js-review-buttons').html(result.buttons_html); + } + }); + return false; + } +}; + +var EditAd = { + init: function() { + var cont = Aj.ajContainer; + Aj.onLoad(function(state) { + state.$form = $('.pr-new-form', cont); + Ads.formInit(state.$form); + state.$form.on('submit', preventDefault); + cont.on('click.curPage', '.js-preview-link', NewAd.ePreviewAd); + cont.on('click.curPage', '.edit-ad-btn', EditAd.eSubmitForm); + cont.on('click.curPage', '.js-clone-ad-btn', EditAd.eCloneAd); + cont.on('click.curPage', '.delete-ad-btn', EditAd.deleteAd); + cont.on('click.curPage', '.pr-form-select', EditAd.eSelectPlaceholder); + state.titleField = state.$form.field('title'); + state.titleField.on('change.curPage', NewAd.onTitleChange); + state.textField = state.$form.field('text'); + state.textField.on('change.curPage', NewAd.onTextChange); + state.textField.on('input.curPage', NewAd.onTextInput); + state.promoteUrlField = state.$form.field('promote_url'); + state.promoteUrlField.on('change.curPage', NewAd.onPromoteUrlChange); + NewAd.updateAdPreview(state.$form, state.previewData); + Aj.onLoad(function(state) { + state.initFormData = EditAd.getFormData(state.$form); + state.initPreviewFormData = NewAd.getPreviewFormData(); + Aj.onBeforeUnload(function() { + var curPreviewFormData = NewAd.getPreviewFormData(); + if (Aj.state.initPreviewFormData != curPreviewFormData) { + return l('WEB_LEAVE_PAGE_CONFIRM_TEXT'); + } + var curFormData = EditAd.getFormData(state.$form); + if (Aj.state.initFormData != curFormData) { + return l('WEB_LEAVE_PAGE_CONFIRM_TEXT'); + } + return false; + }); + }); + }); + Aj.onUnload(function(state) { + Ads.formDestroy(state.$form); + state.$form.off('submit', preventDefault); + state.titleField.off('.curPage'); + state.textField.off('.curPage'); + state.promoteUrlField.off('.curPage'); + }); + }, + getFormData: function($form) { + var form = $form.get(0); + if (!form) return false; + var values = [ + $form.field('title').value(), + $form.field('text').value(), + $form.field('promote_url').value(), + $form.field('cpm').value(), + ]; + return values.join('|'); + }, + eSelectPlaceholder: function() { + Ads.showHint($('.pr-form-control-hint', this), 50, 2000); + }, + initEditTitlePopup: function() { + var cont = Aj.layer; + Aj.onLayerLoad(function(layerState) { + layerState.$form = $('.pr-popup-edit-form', cont); + Ads.formInit(layerState.$form); + layerState.titleField = layerState.$form.field('title'); + layerState.titleField.on('change.curPage', NewAd.onTitleChange); + Aj.layer.one('popup:open', function() { + layerState.titleField.focusAndSelect(true); + }); + layerState.$form.on('submit', EditAd.eSubmitEditTitlePopupForm); + cont.on('click.curLayer', '.submit-form-btn', EditAd.eSubmitEditTitlePopupForm); + }); + Aj.onLayerUnload(function(layerState) { + Ads.formDestroy(layerState.$form); + layerState.$form.off('submit', EditAd.eSubmitEditTitlePopupForm); + layerState.titleField.off('.curPage'); + }); + }, + eSubmitEditTitlePopupForm: function(e) { + e.preventDefault(); + var $form = Aj.layerState.$form; + var owner_id = $form.field('owner_id').value(); + var ad_id = $form.field('ad_id').value(); + var title = $form.field('title').value(); + if ($form.data('disabled')) { + return false; + } + if (!title.length) { + $form.field('title').focus(); + return false; + } + var params = { + owner_id: owner_id, + ad_id: ad_id, + title: title + }; + $form.data('disabled', true); + Aj.apiRequest('editAdTitle', params, function(result) { + $form.data('disabled', false); + if (result.error) { + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + closePopup(Aj.layer); + if (result.ad) { + OwnerAds.updateAd(result.ad); + } + }); + return false; + }, + initEditCPMPopup: function() { + var cont = Aj.layer; + Aj.onLayerLoad(function(layerState) { + layerState.$form = $('.pr-popup-edit-form', cont); + Ads.formInit(layerState.$form); + layerState.cpmField = layerState.$form.field('cpm'); + Aj.layer.one('popup:open', function() { + layerState.cpmField.focusAndSelect(true); + }); + layerState.$form.on('submit', EditAd.eSubmitEditCPMPopupForm); + cont.on('click.curLayer', '.submit-form-btn', EditAd.eSubmitEditCPMPopupForm); + }); + Aj.onLayerUnload(function(layerState) { + Ads.formDestroy(layerState.$form); + layerState.$form.off('submit', EditAd.eSubmitEditCPMPopupForm); + }); + }, + eSubmitEditCPMPopupForm: function(e) { + e.preventDefault(); + var $form = Aj.layerState.$form; + var owner_id = $form.field('owner_id').value(); + var ad_id = $form.field('ad_id').value(); + var cpm = Ads.amountFieldValue($form, 'cpm'); + + if ($form.data('disabled')) { + return false; + } + if (cpm === false) { + $form.field('cpm').focus(); + return false; + } + var params = { + owner_id: owner_id, + ad_id: ad_id, + cpm: cpm + }; + $form.data('disabled', true); + Aj.apiRequest('editAdCPM', params, function(result) { + $form.data('disabled', false); + if (result.error) { + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + closePopup(Aj.layer); + if (result.ad) { + OwnerAds.updateAd(result.ad); + } + }); + return false; + }, + initEditBudgetPopup: function() { + var cont = Aj.layer; + Aj.onLayerLoad(function(layerState) { + layerState.$form = $('.pr-popup-edit-form', cont); + Ads.formInit(layerState.$form); + layerState.budgetField = layerState.$form.field('budget'); + Aj.layer.one('popup:open', function() { + layerState.budgetField.focusAndSelect(true); + }); + layerState.$form.on('submit', EditAd.eSubmitEditBudgetPopupForm); + cont.on('click.curLayer', '.submit-form-btn', EditAd.eSubmitEditBudgetPopupForm); + }); + Aj.onLayerUnload(function(layerState) { + Ads.formDestroy(layerState.$form); + layerState.$form.off('submit', EditAd.eSubmitEditBudgetPopupForm); + }); + }, + eSubmitEditBudgetPopupForm: function(e) { + e.preventDefault(); + var $form = Aj.layerState.$form; + var owner_id = $form.field('owner_id').value(); + var ad_id = $form.field('ad_id').value(); + var budget = Ads.amountFieldValue($form, 'budget'); + + if ($form.data('disabled')) { + return false; + } + if (budget === false) { + $form.field('budget').focus(); + return false; + } + var params = { + owner_id: owner_id, + ad_id: ad_id, + budget: budget, + popup: 1 + }; + $form.data('disabled', true); + Aj.apiRequest('incrAdBudget', params, function(result) { + $form.data('disabled', false); + if (result.error) { + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + closePopup(Aj.layer); + if (result.ad) { + OwnerAds.updateAd(result.ad); + } + if (result.owner_budget) { + $('.js-owner_budget').html(result.owner_budget); + } + if (result.ad_budget_val) { + $('.js-ad_budget_val').value(result.ad_budget_val); + } + }); + return false; + }, + initEditStatusPopup: function() { + var cont = Aj.layer; + Aj.onLayerLoad(function(layerState) { + layerState.$form = $('.pr-popup-edit-form', cont); + Ads.formInit(layerState.$form); + layerState.$form.on('submit', EditAd.eSubmitEditStatusForm); + cont.on('click.curLayer', '.submit-form-btn', EditAd.eSubmitEditStatusForm); + }); + Aj.onLayerUnload(function(layerState) { + Ads.formDestroy(layerState.$form); + layerState.$form.off('submit', EditAd.eSubmitEditStatusForm); + }); + }, + eSubmitEditStatusForm: function(e) { + e.preventDefault(); + var $form = Aj.layerState.$form; + var owner_id = $form.field('owner_id').value(); + var ad_id = $form.field('ad_id').value(); + var active = $form.field('active').value(); + if ($form.data('disabled')) { + return false; + } + var params = { + owner_id: owner_id, + ad_id: ad_id, + active: active + }; + $form.data('disabled', true); + Aj.apiRequest('editAdStatus', params, function(result) { + $form.data('disabled', false); + if (result.error) { + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + closePopup(Aj.layer); + if (result.ad) { + OwnerAds.updateAd(result.ad); + } + }); + return false; + }, + initShareStatsPopup: function() { + var cont = Aj.layer; + Aj.onLayerLoad(function(layerState) { + layerState.$urlField = $('.js-share-url', cont); + layerState.$copyBtn = $('.js-copy-link', cont); + layerState.$revokeBtn = $('.js-revoke-link', cont); + layerState.$urlField.on('click', EditAd.eSelectUrl); + layerState.$copyBtn.on('click', EditAd.eCopyUrl); + layerState.$revokeBtn.on('click', EditAd.eRevokeUrl); + }); + Aj.onLayerUnload(function(layerState) { + layerState.$urlField.off('click', EditAd.eSelectUrl); + layerState.$copyBtn.off('click', EditAd.eCopyUrl); + layerState.$revokeBtn.off('click', EditAd.eRevokeUrl); + }); + }, + eSelectUrl: function() { + Aj.layerState.$urlField.focusAndSelectAll(); + }, + eCopyUrl: function(copy) { + Aj.layerState.$urlField.focusAndSelectAll(); + document.execCommand('copy'); + showToast(l('WEB_AD_STATS_LINK_COPIED', 'Copied.')); + }, + eRevokeUrl: function(e) { + e.preventDefault(); + var $btn = $(this); + if ($btn.data('disabled')) { + return false; + } + var params = { + owner_id: Aj.layerState.ownerId, + ad_id: Aj.layerState.adId + }; + $btn.data('disabled', true); + Aj.apiRequest('revokeStatsUrl', params, function(result) { + $btn.data('disabled', false); + if (result.error) { + return showAlert(result.error); + } + if (result.new_url) { + Aj.layerState.$urlField.value(result.new_url); + } + if (result.toast) { + showToast(result.toast); + } + }); + return false; + }, + initIncrBudget: function() { + var cont = Aj.ajContainer; + Aj.onLoad(function(state) { + state.$form = $('.pr-incr-budget-form', cont); + Ads.formInit(state.$form); + state.budgetField = state.$form.field('budget'); + state.$form.on('submit', EditAd.eSubmitIncrBudgetForm); + cont.on('click.curPage', '.submit-form-btn', EditAd.eSubmitIncrBudgetForm); + }); + Aj.onUnload(function(state) { + Ads.formDestroy(state.$form); + state.$form.off('submit', EditAd.eSubmitIncrBudgetForm); + }); + }, + eSubmitIncrBudgetForm: function(e) { + e.preventDefault(); + var $form = Aj.state.$form; + var owner_id = $form.field('owner_id').value(); + var ad_id = $form.field('ad_id').value(); + var budget = Ads.amountFieldValue($form, 'budget'); + + if ($form.data('disabled')) { + return false; + } + if (budget === false) { + $form.field('budget').focus(); + return false; + } + var params = { + owner_id: owner_id, + ad_id: ad_id, + budget: budget + }; + $form.data('disabled', true); + Aj.apiRequest('incrAdBudget', params, function(result) { + $form.data('disabled', false); + if (result.error) { + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + Aj.state.$form.reset(); + if (result.owner_budget) { + $('.js-owner_budget').html(result.owner_budget); + } + if (result.ad_budget) { + $('.js-ad_budget').html(result.ad_budget); + } + if (result.history) { + $('.js-history').html(result.history); + } + }); + return false; + }, + eSubmitForm: function(e) { + e.preventDefault(); + var $form = Aj.state.$form; + var $button = $(this); + var title = $form.field('title').value(); + var text = $form.field('text').value(); + var promote_url = $form.field('promote_url').value(); + var cpm = Ads.amountFieldValue($form, 'cpm'); + + if (!title.length) { + $form.field('title').focus(); + return false; + } + if (!text.length) { + $form.field('text').focus(); + return false; + } + if (!promote_url.length) { + $form.field('promote_url').focus(); + return false; + } + if (cpm === false) { + $form.field('cpm').focus(); + return false; + } + var params = { + owner_id: Aj.state.ownerId, + ad_id: Aj.state.adId, + title: title, + text: text, + promote_url: promote_url, + cpm: cpm + }; + $button.prop('disabled', true); + Aj.apiRequest('editAd', params, function(result) { + if (result.error) { + $button.prop('disabled', false); + if (result.field) { + var $field = $form.field(result.field); + if ($field.size()) { + Ads.showFieldError($field, result.error, true); + return false; + } + } + return showAlert(result.error); + } + Aj.state.initFormData = EditAd.getFormData($form); + if (result.redirect_to) { + Aj.location(result.redirect_to); + } + }); + return false; + }, + eCloneAd: function(e) { + e.preventDefault(); + var $button = $(this); + if ($button.prop('disabled')) { + return false; + } + var params = { + owner_id: Aj.state.ownerId, + ad_id: Aj.state.adId + }; + var onSuccess = function(result) { + $button.prop('disabled', false); + if (result.error) { + return showAlert(result.error); + } + if (result.confirm_text && result.confirm_hash) { + showConfirm(result.confirm_text, function() { + params.confirm_hash = result.confirm_hash; + $button.prop('disabled', true); + Aj.apiRequest('createDraftFromAd', params, onSuccess); + }, result.confirm_btn); + } else if (result.redirect_to) { + Aj.location(result.redirect_to); + } + }; + $button.prop('disabled', true); + Aj.apiRequest('createDraftFromAd', params, onSuccess); + return false; + }, + deletePopup: function (confirm_text, onConfirm) { + var $confirm = $(''); + var confirm = function() { + onConfirm && onConfirm($confirm); + closePopup($confirm); + } + $('.pr-layer-text', $confirm).html(confirm_text); + var $primaryBtn = $('.popup-primary-btn', $confirm); + $primaryBtn.on('click', confirm); + $confirm.one('popup:close', function() { + $primaryBtn.off('click', confirm); + $confirm.remove(); + }); + openPopup($confirm, { + closeByClickOutside: '.popup-no-close', + }); + return $confirm; + }, + deleteAd: function(e) { + e.preventDefault(); + var $button = $(this); + if ($button.prop('disabled')) { + return false; + } + var params = { + owner_id: Aj.state.ownerId, + ad_id: Aj.state.adId + }; + var onSuccess = function(result) { + $button.prop('disabled', false); + if (result.error) { + return showAlert(result.error); + } + if (result.confirm_text && result.confirm_hash) { + EditAd.deletePopup(result.confirm_text, function() { + params.confirm_hash = result.confirm_hash; + $button.prop('disabled', true); + Aj.apiRequest('deleteAd', params, onSuccess); + }); + } else if (result.redirect_to) { + Aj.location(result.redirect_to); + } + }; + $button.prop('disabled', true); + Aj.apiRequest('deleteAd', params, onSuccess); + return false; + } +}; + + + +(function(d){var c=function(a){this._options={checkOnLoad:!1,resetOnEnd:!1,loopCheckTime:50,loopMaxNumber:5,baitClass:"pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links ads-header ads-content",baitStyle:"width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;"};this._var={version:"3.2.1",bait:null,checking:!1,loop:null,loopNumber:0,event:{detected:[],notDetected:[]}};void 0!==a&&this.setOption(a);var b=this;a=function(){setTimeout(function(){!0===b._options.checkOnLoad&&(null===b._var.bait&&b._creatBait(),setTimeout(function(){b.check()},1))},1)};void 0!==d.addEventListener?d.addEventListener("load",a,!1):d.attachEvent("onload",a)};c.prototype._options=null;c.prototype._var=null;c.prototype._bait=null;c.prototype.setOption=function(a,b){if(void 0!==b){var e=a;a={};a[e]=b}for(var f in a)this._options[f]=a[f];return this};c.prototype._creatBait=function(){var a=document.createElement("div");a.setAttribute("class",this._options.baitClass);a.setAttribute("style",this._options.baitStyle);this._var.bait=d.document.body.appendChild(a);this._var.bait.offsetParent;this._var.bait.offsetHeight;this._var.bait.offsetLeft;this._var.bait.offsetTop;this._var.bait.offsetWidth;this._var.bait.clientHeight;this._var.bait.clientWidth};c.prototype._destroyBait=function(){d.document.body.removeChild(this._var.bait);this._var.bait=null};c.prototype.check=function(a){void 0===a&&(a=!0);this._var.checking=!0;null===this._var.bait&&this._creatBait();var b=this;this._var.loopNumber=0;!0===a&&(this._var.loop=setInterval(function(){b._checkBait(a)},this._options.loopCheckTime));setTimeout(function(){b._checkBait(a)},1);return!0};c.prototype._checkBait=function(a){var b=!1;null===this._var.bait&&this._creatBait();if(null!==d.document.body.getAttribute("abp")||null===this._var.bait.offsetParent||0==this._var.bait.offsetHeight||0==this._var.bait.offsetLeft||0==this._var.bait.offsetTop||0==this._var.bait.offsetWidth||0==this._var.bait.clientHeight||0==this._var.bait.clientWidth)b=!0;if(void 0!==d.getComputedStyle){var e=d.getComputedStyle(this._var.bait,null);!e||"none"!=e.getPropertyValue("display")&&"hidden"!=e.getPropertyValue("visibility")||(b=!0)}!0===a&&(this._var.loopNumber++,this._var.loopNumber>=this._options.loopMaxNumber&&this._stopLoop());if(!0===b)this._stopLoop(),this._destroyBait(),this.emitEvent(!0),!0===a&&(this._var.checking=!1);else if(null===this._var.loop||!1===a)this._destroyBait(),this.emitEvent(!1),!0===a&&(this._var.checking=!1)};c.prototype._stopLoop=function(a){clearInterval(this._var.loop);this._var.loop=null;this._var.loopNumber=0};c.prototype.emitEvent=function(a){a=this._var.event[!0===a?"detected":"notDetected"];for(var b in a)if(a.hasOwnProperty(b))a[b]();!0===this._options.resetOnEnd&&this.clearEvent();return this};c.prototype.clearEvent=function(){this._var.event.detected=[];this._var.event.notDetected=[]};c.prototype.on=function(a){this._var.event.detected.push(a);return this};d.ABC=c;void 0===d.AB&&(d.AB=new c({checkOnLoad:!0,resetOnEnd:!0}))})(window); +AB.on(function() { + openPopup(''); +}); diff --git a/data/telegram.org/faq_spam.html b/data/telegram.org/faq_spam.html new file mode 100644 index 0000000000..a7ff571d34 --- /dev/null +++ b/data/telegram.org/faq_spam.html @@ -0,0 +1,163 @@ + + + + + Spam FAQ + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+

Spam FAQ

+ +
+

This FAQ is for people whose accounts were limited after being reported for spam.
Back to the main FAQ »

+
+

+
+

Q: What happened to my account?

+

When users press the ‘Report spam’ button in a chat, they forward these messages to our team of moderators for review. If the moderators decide that the messages deserved this, the account becomes limited temporarily.

+

This means that if you have been sending unwanted messages to random strangers or posting spam in groups, you lose the ability to do so.

+

Q: So I can't send messages anymore?

+

No, it's not that bad. Limited accounts can send messages to people who have their number saved as a contact. You can also always reply to anyone who messages you first.

+

Q: Why was I reported?

+

Telegram‘s username search is not a tool for making new friends. People usually don’t like it when strangers contact them — so they will report you if they find your messages annoying. Please only contact people if you're sure that they are expecting messages from you. The same applies to adding people to unwanted groups and channels. In addition to this, group admins can also report users who post spam in their groups.

+

Naturally, all such reports are also checked by human moderators. If the messages contain spam, the account will be temporarily limited.

+

Q: What can people report me for?

+

For private messages, it really doesn‘t matter what you send, as long as the receivers find it unwelcome. It could have been a photo, an invite link or a simple ’hello‘. Please only send messages when you are sure people won’t mind getting them.

+

As a general rule, people do mind getting unsolicited advertisements, links, invite links to groups or channels, random photos and, above all, anything related to commerce or online popularity. If you send them something like this, you will be blocked — and everybody else will be happy.

+

Moderators are more lenient when it comes to messages in groups, but anyone who sends spam or unsolicited advertisments will be limited.

+

Q: What do I do now?

+

If this happened to you for the first time (and you are not an industrial scale spammer), most likely your account will be limited for a few days or so. Please wait and consider that people want a peaceful time using our messenger.

+

Repeated offences will result in longer periods of being blocked. If you keep writing unwanted messages to strangers, you may lose the ability to do so forever.

+

Q: I read all of the above, and I‘m certain that I didn’t break any rules!

+

If you are sure that the limit was wrongfully applied to your account, please contact our @SpamBot.

+

Please forgive us for the inconvenience — even the best systems, algorithms and well-trained people can make mistakes sometimes.

+

Q: I know I was wrong, please release me sooner!

+

We're sorry, but this is impossible. We value the inner peace of Telegram users too much.

+

Q: I‘ve just signed up and didn’t send any messages yet, but my account is limited.

+

Some numbers may trigger an overly harsh response from our system, either due to their previous owners‘ activities or due to them being certain virtual/VOIP numbers. We’re sorry if this resulted in your account being limited for no reason.

+

If you think this is your case, please contact @SpamBot and tell it your story.

+
+ +
+ +
+
+
+ + + + + + + diff --git a/data/themes.telegram.org/auth.html b/data/themes.telegram.org/auth.html new file mode 100644 index 0000000000..ab40afa2d9 --- /dev/null +++ b/data/themes.telegram.org/auth.html @@ -0,0 +1,163 @@ + + + + + Telegram Themes + + + + + + + + + + + + + + + + + + + +
+ +
+ Don't have Telegram yet? Try it now + +
+
+
+

Telegram Theme Editor

+

The online theme editor allows you to create and modify your existing cloud themes for every platform. Any changes will appear in the apps immediately after you save them.

+ +
+
+ + + + + + + + + + + + + diff --git a/data/tsf.telegram.org/auth.html b/data/tsf.telegram.org/auth.html new file mode 100644 index 0000000000..b43f95fdad --- /dev/null +++ b/data/tsf.telegram.org/auth.html @@ -0,0 +1,241 @@ + + + + + Telegram Support Force + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+

Telegram Support Initiative

+ +

Our users ask us tens of thousands of questions each day. We would like to answer them all — and we are looking for brilliant people from all over the world who would like to help us do this. If you are interested in joining us, please read this Telegram Support Force Manifesto — and don't miss the tiny FAQ below.

+
+ +
+ +

Harnessing the power of procrastination

+
    +
  1. Telegram is a free messaging system that is used by tens of millions of people daily. Each of our apps has an ‘Ask a question’ button. Our users press it thousands of times each day: some have questions, others just want to chat, still others are bored trolls. We think that they all deserve an answer of some kind.

    +
  2. +
  3. Robots and algorithms are good at handing out answers at scale, but they sometimes cause frustration, fundamentally lack human touch and are bad conversation partners. FAQs are a remedy for the select few that enjoy finding answers in FAQs. To be happy, humanity requires human answers.

    +
  4. +
  5. Manually answering tens of thousands of questions daily requires considerable resources. Manually answering them in style — even when assisted by algorithms and templates — requires limitless resources. But, the resources in question being humans and time, the modern world happens to have a limitless source of just such energy.

    +
  6. +
  7. This world is full of bright-minded, elegant, downright wonderful people who, like you and me, sometimes just can't get started with whatever they were supposed to be doing. And procrastinate instead. This brings countless people in any profession to hours and hours of unnecessary house-cleaning, dog-walking and web-surfing every day. Millions of hours go to waste — procrastination is as ubiquitous in the XXI century as are people who do their work behind computer screens.

    +
  8. +
  9. It is our goal to harness the power of procrastination. For user support, we rely on an army of volunteers from all over the world. They donate a fraction of their time to answer a few questions from Telegram users — every now and then, or all the time. We call this the Telegram Support Force and you are welcome to join.

    +
  10. +
  11. Answering questions may be devilishly tricky at times, so we couldn't accept everyone even if we wanted to. The Telegram Support Force needs patient, inquisitive people, who are no strangers to elegance, humor and style. Although Telegram volunteers help people from their own countries, proficiency in English is also a requirement, since the data you will be getting from us, as well as pretty much all communication inside the team, will be in English.

    +
  12. +
  13. We believe in support as an art form. Support should be fun — for people on both ends of the line. So we are looking for perfect, human and precise answers to the world's questions. Something to make them smile and to make you proud.

    +
  14. +
+

If this is something you might be interested in doing, don't hesitate to contact our @TelegramAuditions account. Please write us a few phrases in English describing how your favourite feature works (don’t copy it, let it be your hand-made text). Include a picture of a marmot if you want a better chance at convincing us that you actually read all of the above and below and, therefore, are inquisitive enough.

+

Markus Ra
@Telegram

+
+

Manifesto FAQ

+

Q: Do I need to know anything special to be eligible?

+

No, not really. But you do need to know how to learn things. And be inquisitive enough to want to learn them.

+

Q: What else is required?

+

We‘re looking for perfectionists. It’d also be nice if you loved your language and had at least a moderate affection for the people of Earth. It'd be cool if you like to read and write. And then, patience and understanding are very useful at times.

+

Q: Will the people I answer know who I am or get my number?

+

No, they will not. Unless you choose to tell them for some mysterious reason.

+

Q: What should I say when I contact you?

+

We'd love to know more about you (who you are, what you think, what you like — not a CV, no!), the languages you speak and the devices you use (mobile, desktop OS).

+

Q: How long does it take for you to reply?

+

We try not to take too long. But we sometimes do, so we apologize in advance. Sorry. Don‘t lose heart and remember that thing about patience above. We’ll get back to you as soon as we can.

+

Q: Is that thing about sending a marmot picture a joke?

+

No.

+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + diff --git a/data/tsf.telegram.org/js/jquery-ui.min.js b/data/tsf.telegram.org/js/jquery-ui.min.js new file mode 100644 index 0000000000..a47c061a05 --- /dev/null +++ b/data/tsf.telegram.org/js/jquery-ui.min.js @@ -0,0 +1,9 @@ +/*! jQuery UI - v1.11.4 - 2017-08-30 +* http://jqueryui.com +* Includes: core.js, widget.js, mouse.js, draggable.js, resizable.js, sortable.js, slider.js, effect.js, effect-slide.js +* Copyright jQuery Foundation and other contributors; Licensed MIT */ + +(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)})(function(t){function e(e,s){var n,o,a,r=e.nodeName.toLowerCase();return"area"===r?(n=e.parentNode,o=n.name,e.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap='#"+o+"']")[0],!!a&&i(a)):!1):(/^(input|select|textarea|button|object)$/.test(r)?!e.disabled:"a"===r?e.href||s:s)&&i(e)}function i(e){return t.expr.filters.visible(e)&&!t(e).parents().addBack().filter(function(){return"hidden"===t.css(this,"visibility")}).length}t.ui=t.ui||{},t.extend(t.ui,{version:"1.11.4",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),t.fn.extend({scrollParent:function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])},focusable:function(i){return e(i,!isNaN(t.attr(i,"tabindex")))},tabbable:function(i){var s=t.attr(i,"tabindex"),n=isNaN(s);return(n||s>=0)&&e(i,!n)}}),t("").outerWidth(1).jquery||t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t("").data("a-b","a").removeData("a-b").data("a-b")&&(t.fn.removeData=function(e){return function(i){return arguments.length?e.call(this,t.camelCase(i)):e.call(this)}}(t.fn.removeData)),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),t.fn.extend({focus:function(e){return function(i,s){return"number"==typeof i?this.each(function(){var e=this;setTimeout(function(){t(e).focus(),s&&s.call(e)},i)}):e.apply(this,arguments)}}(t.fn.focus),disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.bind(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(e){if(void 0!==e)return this.css("zIndex",e);if(this.length)for(var i,s,n=t(this[0]);n.length&&n[0]!==document;){if(i=n.css("position"),("absolute"===i||"relative"===i||"fixed"===i)&&(s=parseInt(n.css("zIndex"),10),!isNaN(s)&&0!==s))return s;n=n.parent()}return 0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}};var s=0,n=Array.prototype.slice;t.cleanData=function(e){return function(i){var s,n,o;for(o=0;null!=(n=i[o]);o++)try{s=t._data(n,"events"),s&&s.remove&&t(n).triggerHandler("remove")}catch(a){}e(i)}}(t.cleanData),t.widget=function(e,i,s){var n,o,a,r,l={},h=e.split(".")[0];return e=e.split(".")[1],n=h+"-"+e,s||(s=i,i=t.Widget),t.expr[":"][n.toLowerCase()]=function(e){return!!t.data(e,n)},t[h]=t[h]||{},o=t[h][e],a=t[h][e]=function(t,e){return this._createWidget?(arguments.length&&this._createWidget(t,e),void 0):new a(t,e)},t.extend(a,o,{version:s.version,_proto:t.extend({},s),_childConstructors:[]}),r=new i,r.options=t.widget.extend({},r.options),t.each(s,function(e,s){return t.isFunction(s)?(l[e]=function(){var t=function(){return i.prototype[e].apply(this,arguments)},n=function(t){return i.prototype[e].apply(this,t)};return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=n,e=s.apply(this,arguments),this._super=i,this._superApply=o,e}}(),void 0):(l[e]=s,void 0)}),a.prototype=t.widget.extend(r,{widgetEventPrefix:o?r.widgetEventPrefix||e:e},l,{constructor:a,namespace:h,widgetName:e,widgetFullName:n}),o?(t.each(o._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,a,i._proto)}),delete o._childConstructors):i._childConstructors.push(a),t.widget.bridge(e,a),a},t.widget.extend=function(e){for(var i,s,o=n.call(arguments,1),a=0,r=o.length;r>a;a++)for(i in o[a])s=o[a][i],o[a].hasOwnProperty(i)&&void 0!==s&&(e[i]=t.isPlainObject(s)?t.isPlainObject(e[i])?t.widget.extend({},e[i],s):t.widget.extend({},s):s);return e},t.widget.bridge=function(e,i){var s=i.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=n.call(arguments,1),l=this;return a?this.each(function(){var i,n=t.data(this,s);return"instance"===o?(l=n,!1):n?t.isFunction(n[o])&&"_"!==o.charAt(0)?(i=n[o].apply(n,r),i!==n&&void 0!==i?(l=i&&i.jquery?l.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,s);e?(e.option(o||{}),e._init&&e._init()):t.data(this,s,new i(o,this))})),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{disabled:!1,create:null},_createWidget:function(e,i){i=t(i||this.defaultElement||this)[0],this.element=t(i),this.uuid=s++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),i!==this&&(t.data(i,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===i&&this.destroy()}}),this.document=t(i.style?i.ownerDocument:i.document||i),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!e),e&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var l=s.match(/^([\w:-]*)\s*(.*)$/),h=l[1]+o.eventNamespace,c=l[2];c?n.delegate(c,h,r):i.bind(h,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(i).undelegate(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){t(e.currentTarget).addClass("ui-state-hover")},mouseleave:function(e){t(e.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){t(e.currentTarget).addClass("ui-state-focus")},focusout:function(e){t(e.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget;var o=!1;t(document).mouseup(function(){o=!1}),t.widget("ui.mouse",{version:"1.11.4",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.bind("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).bind("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!o){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,s=1===e.which,n="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return s&&!n&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),o=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){return this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),o=!1,!1},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.widget("ui.draggable",t.ui.mouse,{version:"1.11.4",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"===this.options.helper&&this._setPositionRelative(),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._setHandleClassName(),this._mouseInit()},_setOption:function(t,e){this._super(t,e),"handle"===t&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){return(this.helper||this.element).is(".ui-draggable-dragging")?(this.destroyOnClear=!0,void 0):(this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._removeHandleClassName(),this._mouseDestroy(),void 0)},_mouseCapture:function(e){var i=this.options;return this._blurActiveElement(e),this.helper||i.disabled||t(e.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(e),this.handle?(this._blockFrames(i.iframeFix===!0?"iframe":i.iframeFix),!0):!1)},_blockFrames:function(e){this.iframeBlocks=this.document.find(e).map(function(){var e=t(this);return t("
").css("position","absolute").appendTo(e.parent()).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).offset(e.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(e){var i=this.document[0];if(this.handleElement.is(e.target))try{i.activeElement&&"body"!==i.activeElement.nodeName.toLowerCase()&&t(i.activeElement).blur()}catch(s){}},_mouseStart:function(e){var i=this.options;return this.helper=this._createHelper(e),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),t.ui.ddmanager&&(t.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=this.helper.parents().filter(function(){return"fixed"===t(this).css("position")}).length>0,this.positionAbs=this.element.offset(),this._refreshOffsets(e),this.originalPosition=this.position=this._generatePosition(e,!1),this.originalPageX=e.pageX,this.originalPageY=e.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",e)===!1?(this._clear(),!1):(this._cacheHelperProportions(),t.ui.ddmanager&&!i.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this._normalizeRightBottom(),this._mouseDrag(e,!0),t.ui.ddmanager&&t.ui.ddmanager.dragStart(this,e),!0)},_refreshOffsets:function(t){this.offset={top:this.positionAbs.top-this.margins.top,left:this.positionAbs.left-this.margins.left,scroll:!1,parent:this._getParentOffset(),relative:this._getRelativeOffset()},this.offset.click={left:t.pageX-this.offset.left,top:t.pageY-this.offset.top}},_mouseDrag:function(e,i){if(this.hasFixedAncestor&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(e,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",e,s)===!1)return this._mouseUp({}),!1;this.position=s.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),!1},_mouseStop:function(e){var i=this,s=!1;return t.ui.ddmanager&&!this.options.dropBehaviour&&(s=t.ui.ddmanager.drop(this,e)),this.dropped&&(s=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||t.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?t(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",e)!==!1&&i._clear()}):this._trigger("stop",e)!==!1&&this._clear(),!1},_mouseUp:function(e){return this._unblockFrames(),t.ui.ddmanager&&t.ui.ddmanager.dragStop(this,e),this.handleElement.is(e.target)&&this.element.focus(),t.ui.mouse.prototype._mouseUp.call(this,e)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(e){return this.options.handle?!!t(e.target).closest(this.element.find(this.options.handle)).length:!0},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this.handleElement.addClass("ui-draggable-handle")},_removeHandleClassName:function(){this.handleElement.removeClass("ui-draggable-handle")},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper),n=s?t(i.helper.apply(this.element[0],[e])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return n.parents("body").length||n.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s&&n[0]===this.element[0]&&this._setPositionRelative(),n[0]===this.element[0]||/(fixed|absolute)/.test(n.css("position"))||n.css("position","absolute"),n},_setPositionRelative:function(){/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative")},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_isRootNode:function(t){return/(html|body)/i.test(t.tagName)||t===this.document[0]},_getParentOffset:function(){var e=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var t=this.element.position(),e=this._isRootNode(this.scrollParent[0]);return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+(e?0:this.scrollParent.scrollTop()),left:t.left-(parseInt(this.helper.css("left"),10)||0)+(e?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options,o=this.document[0];return this.relativeContainer=null,n.containment?"window"===n.containment?(this.containment=[t(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,t(window).scrollLeft()+t(window).width()-this.helperProportions.width-this.margins.left,t(window).scrollTop()+(t(window).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):"document"===n.containment?(this.containment=[0,0,t(o).width()-this.helperProportions.width-this.margins.left,(t(o).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):n.containment.constructor===Array?(this.containment=n.containment,void 0):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=t(n.containment),s=i[0],s&&(e=/(scroll|auto)/.test(i.css("overflow")),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(e?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(e?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=i),void 0):(this.containment=null,void 0)},_convertPositionTo:function(t,e){e||(e=this.position);var i="absolute"===t?1:-1,s=this._isRootNode(this.scrollParent[0]);return{top:e.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:s?0:this.offset.scroll.top)*i,left:e.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:s?0:this.offset.scroll.left)*i}},_generatePosition:function(t,e){var i,s,n,o,a=this.options,r=this._isRootNode(this.scrollParent[0]),l=t.pageX,h=t.pageY;return r&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),e&&(this.containment&&(this.relativeContainer?(s=this.relativeContainer.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,t.pageX-this.offset.click.lefti[2]&&(l=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(h=i[3]+this.offset.click.top)),a.grid&&(n=a.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/a.grid[1])*a.grid[1]:this.originalPageY,h=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-a.grid[1]:n+a.grid[1]:n,o=a.grid[0]?this.originalPageX+Math.round((l-this.originalPageX)/a.grid[0])*a.grid[0]:this.originalPageX,l=i?o-this.offset.click.left>=i[0]||o-this.offset.click.left>i[2]?o:o-this.offset.click.left>=i[0]?o-a.grid[0]:o+a.grid[0]:o),"y"===a.axis&&(l=this.originalPageX),"x"===a.axis&&(h=this.originalPageY)),{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:r?0:this.offset.scroll.top),left:l-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:r?0:this.offset.scroll.left)}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_normalizeRightBottom:function(){"y"!==this.options.axis&&"auto"!==this.helper.css("right")&&(this.helper.width(this.helper.width()),this.helper.css("right","auto")),"x"!==this.options.axis&&"auto"!==this.helper.css("bottom")&&(this.helper.height(this.helper.height()),this.helper.css("bottom","auto"))},_trigger:function(e,i,s){return s=s||this._uiHash(),t.ui.plugin.call(this,e,[i,s,this],!0),/^(drag|start|stop)/.test(e)&&(this.positionAbs=this._convertPositionTo("absolute"),s.offset=this.positionAbs),t.Widget.prototype._trigger.call(this,e,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),t.ui.plugin.add("draggable","connectToSortable",{start:function(e,i,s){var n=t.extend({},i,{item:s.element});s.sortables=[],t(s.options.connectToSortable).each(function(){var i=t(this).sortable("instance");i&&!i.options.disabled&&(s.sortables.push(i),i.refreshPositions(),i._trigger("activate",e,n))})},stop:function(e,i,s){var n=t.extend({},i,{item:s.element});s.cancelHelperRemoval=!1,t.each(s.sortables,function(){var t=this;t.isOver?(t.isOver=0,s.cancelHelperRemoval=!0,t.cancelHelperRemoval=!1,t._storedCSS={position:t.placeholder.css("position"),top:t.placeholder.css("top"),left:t.placeholder.css("left")},t._mouseStop(e),t.options.helper=t.options._helper):(t.cancelHelperRemoval=!0,t._trigger("deactivate",e,n))})},drag:function(e,i,s){t.each(s.sortables,function(){var n=!1,o=this;o.positionAbs=s.positionAbs,o.helperProportions=s.helperProportions,o.offset.click=s.offset.click,o._intersectsWith(o.containerCache)&&(n=!0,t.each(s.sortables,function(){return this.positionAbs=s.positionAbs,this.helperProportions=s.helperProportions,this.offset.click=s.offset.click,this!==o&&this._intersectsWith(this.containerCache)&&t.contains(o.element[0],this.element[0])&&(n=!1),n})),n?(o.isOver||(o.isOver=1,s._parent=i.helper.parent(),o.currentItem=i.helper.appendTo(o.element).data("ui-sortable-item",!0),o.options._helper=o.options.helper,o.options.helper=function(){return i.helper[0]},e.target=o.currentItem[0],o._mouseCapture(e,!0),o._mouseStart(e,!0,!0),o.offset.click.top=s.offset.click.top,o.offset.click.left=s.offset.click.left,o.offset.parent.left-=s.offset.parent.left-o.offset.parent.left,o.offset.parent.top-=s.offset.parent.top-o.offset.parent.top,s._trigger("toSortable",e),s.dropped=o.element,t.each(s.sortables,function(){this.refreshPositions()}),s.currentItem=s.element,o.fromOutside=s),o.currentItem&&(o._mouseDrag(e),i.position=o.position)):o.isOver&&(o.isOver=0,o.cancelHelperRemoval=!0,o.options._revert=o.options.revert,o.options.revert=!1,o._trigger("out",e,o._uiHash(o)),o._mouseStop(e,!0),o.options.revert=o.options._revert,o.options.helper=o.options._helper,o.placeholder&&o.placeholder.remove(),i.helper.appendTo(s._parent),s._refreshOffsets(e),i.position=s._generatePosition(e,!0),s._trigger("fromSortable",e),s.dropped=!1,t.each(s.sortables,function(){this.refreshPositions()}))})}}),t.ui.plugin.add("draggable","cursor",{start:function(e,i,s){var n=t("body"),o=s.options;n.css("cursor")&&(o._cursor=n.css("cursor")),n.css("cursor",o.cursor)},stop:function(e,i,s){var n=s.options;n._cursor&&t("body").css("cursor",n._cursor)}}),t.ui.plugin.add("draggable","opacity",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("opacity")&&(o._opacity=n.css("opacity")),n.css("opacity",o.opacity)},stop:function(e,i,s){var n=s.options;n._opacity&&t(i.helper).css("opacity",n._opacity)}}),t.ui.plugin.add("draggable","scroll",{start:function(t,e,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(e,i,s){var n=s.options,o=!1,a=s.scrollParentNotHidden[0],r=s.document[0];a!==r&&"HTML"!==a.tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+a.offsetHeight-e.pageY=0;d--)l=s.snapElements[d].left-s.margins.left,h=l+s.snapElements[d].width,c=s.snapElements[d].top-s.margins.top,u=c+s.snapElements[d].height,l-g>_||m>h+g||c-g>b||v>u+g||!t.contains(s.snapElements[d].item.ownerDocument,s.snapElements[d].item)?(s.snapElements[d].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=!1):("inner"!==f.snapMode&&(n=g>=Math.abs(c-b),o=g>=Math.abs(u-v),a=g>=Math.abs(l-_),r=g>=Math.abs(h-m),n&&(i.position.top=s._convertPositionTo("relative",{top:c-s.helperProportions.height,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l-s.helperProportions.width}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h}).left)),p=n||o||a||r,"outer"!==f.snapMode&&(n=g>=Math.abs(c-v),o=g>=Math.abs(u-b),a=g>=Math.abs(l-m),r=g>=Math.abs(h-_),n&&(i.position.top=s._convertPositionTo("relative",{top:c,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u-s.helperProportions.height,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h-s.helperProportions.width}).left)),!s.snapElements[d].snapping&&(n||o||a||r||p)&&s.options.snap.snap&&s.options.snap.snap.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=n||o||a||r||p)}}),t.ui.plugin.add("draggable","stack",{start:function(e,i,s){var n,o=s.options,a=t.makeArray(t(o.stack)).sort(function(e,i){return(parseInt(t(e).css("zIndex"),10)||0)-(parseInt(t(i).css("zIndex"),10)||0)});a.length&&(n=parseInt(t(a[0]).css("zIndex"),10)||0,t(a).each(function(e){t(this).css("zIndex",n+e)}),this.css("zIndex",n+a.length))}}),t.ui.plugin.add("draggable","zIndex",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("zIndex")&&(o._zIndex=n.css("zIndex")),n.css("zIndex",o.zIndex)},stop:function(e,i,s){var n=s.options;n._zIndex&&t(i.helper).css("zIndex",n._zIndex)}}),t.ui.draggable,t.widget("ui.resizable",t.ui.mouse,{version:"1.11.4",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseInt(t,10)||0 +},_isNumber:function(t){return!isNaN(parseInt(t,10))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i,s,n,o,a=this,r=this.options;if(this.element.addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!r.aspectRatio,aspectRatio:r.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:r.helper||r.ghost||r.animate?r.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=r.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),e=this.handles.split(","),this.handles={},i=0;e.length>i;i++)s=t.trim(e[i]),o="ui-resizable-"+s,n=t("
"),n.css({zIndex:r.zIndex}),"se"===s&&n.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(n);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:a._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.mouseover(function(){a.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),a.axis=n&&n[1]?n[1]:"se")}),r.autoHide&&(this._handles.hide(),t(this.element).addClass("ui-resizable-autohide").mouseenter(function(){r.disabled||(t(this).removeClass("ui-resizable-autohide"),a._handles.show())}).mouseleave(function(){r.disabled||a.resizing||(t(this).addClass("ui-resizable-autohide"),a._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),a.addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,l=this._change[o];return this._updatePrevProperties(),l?(i=l.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,l,h=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null,l=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null,h.animate||this.element.css(t.extend(a,{top:l,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!h.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidtht.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,l=this.position.top+this.size.height,h=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&h&&(t.left=r-e.minWidth),s&&h&&(t.left=r-e.maxWidth),a&&c&&(t.top=l-e.minHeight),n&&c&&(t.top=l-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseInt(s[e],10)||0,i[e]+=parseInt(n[e],10)||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
"),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,l={width:i.size.width-r,height:i.size.height-a},h=parseInt(i.element.css("left"),10)+(i.position.left-i.originalPosition.left)||null,c=parseInt(i.element.css("top"),10)+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(l,c&&h?{top:c,left:h}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseInt(i.element.css("width"),10),height:parseInt(i.element.css("height"),10),top:parseInt(i.element.css("top"),10),left:parseInt(i.element.css("left"),10)};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,l=t(this).resizable("instance"),h=l.options,c=l.element,u=h.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(l.containerElement=t(d),/document/.test(u)||u===document?(l.containerOffset={left:0,top:0},l.containerPosition={left:0,top:0},l.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=l._num(e.css("padding"+s))}),l.containerOffset=e.offset(),l.containerPosition=e.position(),l.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=l.containerOffset,n=l.containerSize.height,o=l.containerSize.width,a=l._hasScroll(d,"left")?d.scrollWidth:o,r=l._hasScroll(d)?d.scrollHeight:n,l.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,l=a.containerOffset,h=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=l),h.left<(a._helper?l.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-l.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?l.left:0),h.top<(a._helper?l.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-l.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?l.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-l.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-l.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),l=a.outerWidth()-e.sizeDiff.width,h=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseInt(e.width(),10),height:parseInt(e.height(),10),left:parseInt(e.css("left"),10),top:parseInt(e.css("top"),10)})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.options,s=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof i.ghost?i.ghost:""),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,l="number"==typeof s.grid?[s.grid,s.grid]:s.grid,h=l[0]||1,c=l[1]||1,u=Math.round((n.width-o.width)/h)*h,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,g=s.maxWidth&&p>s.maxWidth,m=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=l,_&&(p+=h),v&&(f+=c),g&&(p-=h),m&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-h)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-h>0?(i.size.width=p,i.position.left=a.left-u):(p=h-e.width,i.size.width=p,i.position.left=a.left+o.width-p))}}),t.ui.resizable,t.widget("ui.sortable",t.ui.mouse,{version:"1.11.4",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(t,e,i){return t>=e&&e+i>t},_isFloating:function(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))},_create:function(){this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.offset=this.element.offset(),this._mouseInit(),this._setHandleClassName(),this.ready=!0},_setOption:function(t,e){this._super(t,e),"handle"===t&&this._setHandleClassName()},_setHandleClassName:function(){this.element.find(".ui-sortable-handle").removeClass("ui-sortable-handle"),t.each(this.items,function(){(this.instance.options.handle?this.item.find(this.instance.options.handle):this.item).addClass("ui-sortable-handle")})},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").find(".ui-sortable-handle").removeClass("ui-sortable-handle"),this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_mouseCapture:function(e,i){var s=null,n=!1,o=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,o.widgetName+"-item")===o?(s=t(this),!1):void 0}),t.data(e.target,o.widgetName+"-item")===o&&(s=t(e.target)),s?!this.options.handle||i||(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,s){var n,o,a=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,a.cursorAt&&this._adjustOffsetFromHelper(a.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),a.containment&&this._setContainment(),a.cursor&&"auto"!==a.cursor&&(o=this.document.find("body"),this.storedCursor=o.css("cursor"),o.css("cursor",a.cursor),this.storedStylesheet=t("").appendTo(o)),a.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",a.opacity)),a.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",a.zIndex)),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!a.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,n,o,a=this.options,r=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY=0;i--)if(s=this.items[i],n=s.item[0],o=this._intersectsWithPointer(s),o&&s.instance===this.currentContainer&&n!==this.currentItem[0]&&this.placeholder[1===o?"next":"prev"]()[0]!==n&&!t.contains(this.placeholder[0],n)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],n):!0)){if(this.direction=1===o?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,n=this.placeholder.offset(),o=this.options.axis,a={};o&&"x"!==o||(a.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollLeft)),o&&"y"!==o||(a.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(a,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,o=t.left,a=o+t.width,r=t.top,l=r+t.height,h=this.offset.click.top,c=this.offset.click.left,u="x"===this.options.axis||s+h>r&&l>s+h,d="y"===this.options.axis||e+c>o&&a>e+c,p=u&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?p:e+this.helperProportions.width/2>o&&a>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>r&&l>n-this.helperProportions.height/2},_intersectsWithPointer:function(t){var e="x"===this.options.axis||this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),i="y"===this.options.axis||this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width),s=e&&i,n=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return s?this.floating?o&&"right"===o||"down"===n?2:1:n&&("down"===n?2:1):!1},_intersectsWithSides:function(t){var e=this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),i=this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),s=this._getDragVerticalDirection(),n=this._getDragHorizontalDirection();return this.floating&&n?"right"===n&&i||"left"===n&&!i:s&&("down"===s&&e||"up"===s&&!e)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this._setHandleClassName(),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){function i(){r.push(this)}var s,n,o,a,r=[],l=[],h=this._connectWith();if(h&&e)for(s=h.length-1;s>=0;s--)for(o=t(h[s],this.document[0]),n=o.length-1;n>=0;n--)a=t.data(o[n],this.widgetFullName),a&&a!==this&&!a.options.disabled&&l.push([t.isFunction(a.options.items)?a.options.items.call(a.element):t(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a]);for(l.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),s=l.length-1;s>=0;s--)l[s][0].each(i);return t(r)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;e.length>i;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,s,n,o,a,r,l,h,c=this.items,u=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],d=this._connectWith();if(d&&this.ready)for(i=d.length-1;i>=0;i--)for(n=t(d[i],this.document[0]),s=n.length-1;s>=0;s--)o=t.data(n[s],this.widgetFullName),o&&o!==this&&!o.options.disabled&&(u.push([t.isFunction(o.options.items)?o.options.items.call(o.element[0],e,{item:this.currentItem}):t(o.options.items,o.element),o]),this.containers.push(o));for(i=u.length-1;i>=0;i--)for(a=u[i][1],r=u[i][0],s=0,h=r.length;h>s;s++)l=t(r[s]),l.data(this.widgetName+"-item",a),c.push({item:l,instance:a,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.floating=this.items.length?"x"===this.options.axis||this._isFloating(this.items[0].item):!1,this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,n,o;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=n.outerWidth(),s.height=n.outerHeight()),o=n.offset(),s.left=o.left,s.top=o.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)o=this.containers[i].element.offset(),this.containers[i].containerCache.left=o.left,this.containers[i].containerCache.top=o.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,s=e.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),n=t("<"+s+">",e.document[0]).addClass(i||e.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tbody"===s?e._createTrPlaceholder(e.currentItem.find("tr").eq(0),t("",e.document[0]).appendTo(n)):"tr"===s?e._createTrPlaceholder(e.currentItem,n):"img"===s&&n.attr("src",e.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(t,n){(!i||s.forcePlaceholderSize)&&(n.height()||n.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_createTrPlaceholder:function(e,i){var s=this;e.children().each(function(){t(" ",s.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(i)})},_contactContainers:function(e){var i,s,n,o,a,r,l,h,c,u,d=null,p=null;for(i=this.containers.length-1;i>=0;i--)if(!t.contains(this.currentItem[0],this.containers[i].element[0]))if(this._intersectsWith(this.containers[i].containerCache)){if(d&&t.contains(this.containers[i].element[0],d.element[0]))continue; +d=this.containers[i],p=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",e,this._uiHash(this)),this.containers[i].containerCache.over=0);if(d)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(n=1e4,o=null,c=d.floating||this._isFloating(this.currentItem),a=c?"left":"top",r=c?"width":"height",u=c?"clientX":"clientY",s=this.items.length-1;s>=0;s--)t.contains(this.containers[p].element[0],this.items[s].item[0])&&this.items[s].item[0]!==this.currentItem[0]&&(l=this.items[s].item.offset()[a],h=!1,e[u]-l>this.items[s][r]/2&&(h=!0),n>Math.abs(e[u]-l)&&(n=Math.abs(e[u]-l),o=this.items[s],this.direction=h?"up":"down"));if(!o&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[p])return this.currentContainer.containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash()),this.currentContainer.containerCache.over=1),void 0;o?this._rearrange(e,o,null,!0):this._rearrange(e,null,this.containers[p].element,!0),this._trigger("change",e,this._uiHash()),this.containers[p]._trigger("change",e,this._uiHash(this)),this.currentContainer=this.containers[p],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1}},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===this.document[0].body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options;"parent"===n.containment&&(n.containment=this.helper[0].parentNode),("document"===n.containment||"window"===n.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,"document"===n.containment?this.document.width():this.window.width()-this.helperProportions.width-this.margins.left,("document"===n.containment?this.document.width():this.window.height()||this.document[0].body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(n.containment)||(e=t(n.containment)[0],i=t(n.containment).offset(),s="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():o?0:n.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():o?0:n.scrollLeft())*s}},_generatePosition:function(e){var i,s,n=this.options,o=e.pageX,a=e.pageY,r="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,l=/(html|body)/i.test(r[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.leftthis.containment[2]&&(o=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(a=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((a-this.originalPageY)/n.grid[1])*n.grid[1],a=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((o-this.originalPageX)/n.grid[0])*n.grid[0],o=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:a-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():l?0:r.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():l?0:r.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){function i(t,e,i){return function(s){i._trigger(t,s,e._uiHash(e))}}this.reverting=!1;var s,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(s in this._storedCSS)("auto"===this._storedCSS[s]||"static"===this._storedCSS[s])&&(this._storedCSS[s]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||n.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(n.push(function(t){this._trigger("remove",t,this._uiHash())}),n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),s=this.containers.length-1;s>=0;s--)e||n.push(i("deactivate",this,this.containers[s])),this.containers[s].containerCache.over&&(n.push(i("out",this,this.containers[s])),this.containers[s].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(s=0;n.length>s;s++)n[s].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!this.cancelHelperRemoval},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}}),t.widget("ui.slider",t.ui.mouse,{version:"1.11.4",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null,change:null,slide:null,start:null,stop:null},numPages:5,_create:function(){this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this._calculateNewMax(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"),this._refresh(),this._setOption("disabled",this.options.disabled),this._animateOff=!1},_refresh:function(){this._createRange(),this._createHandles(),this._setupEvents(),this._refreshValue()},_createHandles:function(){var e,i,s=this.options,n=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),o="",a=[];for(i=s.values&&s.values.length||1,n.length>i&&(n.slice(i).remove(),n=n.slice(0,i)),e=n.length;i>e;e++)a.push(o);this.handles=n.add(t(a.join("")).appendTo(this.element)),this.handle=this.handles.eq(0),this.handles.each(function(e){t(this).data("ui-slider-handle-index",e)})},_createRange:function(){var e=this.options,i="";e.range?(e.range===!0&&(e.values?e.values.length&&2!==e.values.length?e.values=[e.values[0],e.values[0]]:t.isArray(e.values)&&(e.values=e.values.slice(0)):e.values=[this._valueMin(),this._valueMin()]),this.range&&this.range.length?this.range.removeClass("ui-slider-range-min ui-slider-range-max").css({left:"",bottom:""}):(this.range=t("
").appendTo(this.element),i="ui-slider-range ui-widget-header ui-corner-all"),this.range.addClass(i+("min"===e.range||"max"===e.range?" ui-slider-range-"+e.range:""))):(this.range&&this.range.remove(),this.range=null)},_setupEvents:function(){this._off(this.handles),this._on(this.handles,this._handleEvents),this._hoverable(this.handles),this._focusable(this.handles)},_destroy:function(){this.handles.remove(),this.range&&this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-widget ui-widget-content ui-corner-all"),this._mouseDestroy()},_mouseCapture:function(e){var i,s,n,o,a,r,l,h,c=this,u=this.options;return u.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),i={x:e.pageX,y:e.pageY},s=this._normValueFromMouse(i),n=this._valueMax()-this._valueMin()+1,this.handles.each(function(e){var i=Math.abs(s-c.values(e));(n>i||n===i&&(e===c._lastChangedValue||c.values(e)===u.min))&&(n=i,o=t(this),a=e)}),r=this._start(e,a),r===!1?!1:(this._mouseSliding=!0,this._handleIndex=a,o.addClass("ui-state-active").focus(),l=o.offset(),h=!t(e.target).parents().addBack().is(".ui-slider-handle"),this._clickOffset=h?{left:0,top:0}:{left:e.pageX-l.left-o.width()/2,top:e.pageY-l.top-o.height()/2-(parseInt(o.css("borderTopWidth"),10)||0)-(parseInt(o.css("borderBottomWidth"),10)||0)+(parseInt(o.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(e,a,s),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(t){var e={x:t.pageX,y:t.pageY},i=this._normValueFromMouse(e);return this._slide(t,this._handleIndex,i),!1},_mouseStop:function(t){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(t,this._handleIndex),this._change(t,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(t){var e,i,s,n,o;return"horizontal"===this.orientation?(e=this.elementSize.width,i=t.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(e=this.elementSize.height,i=t.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),s=i/e,s>1&&(s=1),0>s&&(s=0),"vertical"===this.orientation&&(s=1-s),n=this._valueMax()-this._valueMin(),o=this._valueMin()+s*n,this._trimAlignValue(o)},_start:function(t,e){var i={handle:this.handles[e],value:this.value()};return this.options.values&&this.options.values.length&&(i.value=this.values(e),i.values=this.values()),this._trigger("start",t,i)},_slide:function(t,e,i){var s,n,o;this.options.values&&this.options.values.length?(s=this.values(e?0:1),2===this.options.values.length&&this.options.range===!0&&(0===e&&i>s||1===e&&s>i)&&(i=s),i!==this.values(e)&&(n=this.values(),n[e]=i,o=this._trigger("slide",t,{handle:this.handles[e],value:i,values:n}),s=this.values(e?0:1),o!==!1&&this.values(e,i))):i!==this.value()&&(o=this._trigger("slide",t,{handle:this.handles[e],value:i}),o!==!1&&this.value(i))},_stop:function(t,e){var i={handle:this.handles[e],value:this.value()};this.options.values&&this.options.values.length&&(i.value=this.values(e),i.values=this.values()),this._trigger("stop",t,i)},_change:function(t,e){if(!this._keySliding&&!this._mouseSliding){var i={handle:this.handles[e],value:this.value()};this.options.values&&this.options.values.length&&(i.value=this.values(e),i.values=this.values()),this._lastChangedValue=e,this._trigger("change",t,i)}},value:function(t){return arguments.length?(this.options.value=this._trimAlignValue(t),this._refreshValue(),this._change(null,0),void 0):this._value()},values:function(e,i){var s,n,o;if(arguments.length>1)return this.options.values[e]=this._trimAlignValue(i),this._refreshValue(),this._change(null,e),void 0;if(!arguments.length)return this._values();if(!t.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(e):this.value();for(s=this.options.values,n=arguments[0],o=0;s.length>o;o+=1)s[o]=this._trimAlignValue(n[o]),this._change(null,o);this._refreshValue()},_setOption:function(e,i){var s,n=0;switch("range"===e&&this.options.range===!0&&("min"===i?(this.options.value=this._values(0),this.options.values=null):"max"===i&&(this.options.value=this._values(this.options.values.length-1),this.options.values=null)),t.isArray(this.options.values)&&(n=this.options.values.length),"disabled"===e&&this.element.toggleClass("ui-state-disabled",!!i),this._super(e,i),e){case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue(),this.handles.css("horizontal"===i?"bottom":"left","");break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":for(this._animateOff=!0,this._refreshValue(),s=0;n>s;s+=1)this._change(null,s);this._animateOff=!1;break;case"step":case"min":case"max":this._animateOff=!0,this._calculateNewMax(),this._refreshValue(),this._animateOff=!1;break;case"range":this._animateOff=!0,this._refresh(),this._animateOff=!1}},_value:function(){var t=this.options.value;return t=this._trimAlignValue(t)},_values:function(t){var e,i,s;if(arguments.length)return e=this.options.values[t],e=this._trimAlignValue(e);if(this.options.values&&this.options.values.length){for(i=this.options.values.slice(),s=0;i.length>s;s+=1)i[s]=this._trimAlignValue(i[s]);return i}return[]},_trimAlignValue:function(t){if(this._valueMin()>=t)return this._valueMin();if(t>=this._valueMax())return this._valueMax();var e=this.options.step>0?this.options.step:1,i=(t-this._valueMin())%e,s=t-i;return 2*Math.abs(i)>=e&&(s+=i>0?e:-e),parseFloat(s.toFixed(5))},_calculateNewMax:function(){var t=this.options.max,e=this._valueMin(),i=this.options.step,s=Math.floor(+(t-e).toFixed(this._precision())/i)*i;t=s+e,this.max=parseFloat(t.toFixed(this._precision()))},_precision:function(){var t=this._precisionOf(this.options.step);return null!==this.options.min&&(t=Math.max(t,this._precisionOf(this.options.min))),t},_precisionOf:function(t){var e=""+t,i=e.indexOf(".");return-1===i?0:e.length-i-1},_valueMin:function(){return this.options.min},_valueMax:function(){return this.max},_refreshValue:function(){var e,i,s,n,o,a=this.options.range,r=this.options,l=this,h=this._animateOff?!1:r.animate,c={};this.options.values&&this.options.values.length?this.handles.each(function(s){i=100*((l.values(s)-l._valueMin())/(l._valueMax()-l._valueMin())),c["horizontal"===l.orientation?"left":"bottom"]=i+"%",t(this).stop(1,1)[h?"animate":"css"](c,r.animate),l.options.range===!0&&("horizontal"===l.orientation?(0===s&&l.range.stop(1,1)[h?"animate":"css"]({left:i+"%"},r.animate),1===s&&l.range[h?"animate":"css"]({width:i-e+"%"},{queue:!1,duration:r.animate})):(0===s&&l.range.stop(1,1)[h?"animate":"css"]({bottom:i+"%"},r.animate),1===s&&l.range[h?"animate":"css"]({height:i-e+"%"},{queue:!1,duration:r.animate}))),e=i}):(s=this.value(),n=this._valueMin(),o=this._valueMax(),i=o!==n?100*((s-n)/(o-n)):0,c["horizontal"===this.orientation?"left":"bottom"]=i+"%",this.handle.stop(1,1)[h?"animate":"css"](c,r.animate),"min"===a&&"horizontal"===this.orientation&&this.range.stop(1,1)[h?"animate":"css"]({width:i+"%"},r.animate),"max"===a&&"horizontal"===this.orientation&&this.range[h?"animate":"css"]({width:100-i+"%"},{queue:!1,duration:r.animate}),"min"===a&&"vertical"===this.orientation&&this.range.stop(1,1)[h?"animate":"css"]({height:i+"%"},r.animate),"max"===a&&"vertical"===this.orientation&&this.range[h?"animate":"css"]({height:100-i+"%"},{queue:!1,duration:r.animate}))},_handleEvents:{keydown:function(e){var i,s,n,o,a=t(e.target).data("ui-slider-handle-index");switch(e.keyCode){case t.ui.keyCode.HOME:case t.ui.keyCode.END:case t.ui.keyCode.PAGE_UP:case t.ui.keyCode.PAGE_DOWN:case t.ui.keyCode.UP:case t.ui.keyCode.RIGHT:case t.ui.keyCode.DOWN:case t.ui.keyCode.LEFT:if(e.preventDefault(),!this._keySliding&&(this._keySliding=!0,t(e.target).addClass("ui-state-active"),i=this._start(e,a),i===!1))return}switch(o=this.options.step,s=n=this.options.values&&this.options.values.length?this.values(a):this.value(),e.keyCode){case t.ui.keyCode.HOME:n=this._valueMin();break;case t.ui.keyCode.END:n=this._valueMax();break;case t.ui.keyCode.PAGE_UP:n=this._trimAlignValue(s+(this._valueMax()-this._valueMin())/this.numPages);break;case t.ui.keyCode.PAGE_DOWN:n=this._trimAlignValue(s-(this._valueMax()-this._valueMin())/this.numPages);break;case t.ui.keyCode.UP:case t.ui.keyCode.RIGHT:if(s===this._valueMax())return;n=this._trimAlignValue(s+o);break;case t.ui.keyCode.DOWN:case t.ui.keyCode.LEFT:if(s===this._valueMin())return;n=this._trimAlignValue(s-o)}this._slide(e,a,n)},keyup:function(e){var i=t(e.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(e,i),this._change(e,i),t(e.target).removeClass("ui-state-active"))}}});var a="ui-effects-",r=t;t.effects={effect:{}},function(t,e){function i(t,e,i){var s=u[e.type]||{};return null==t?i||!e.def?null:e.def:(t=s.floor?~~t:parseFloat(t),isNaN(t)?e.def:s.mod?(t+s.mod)%s.mod:0>t?0:t>s.max?s.max:t)}function s(i){var s=h(),n=s._rgba=[];return i=i.toLowerCase(),f(l,function(t,o){var a,r=o.re.exec(i),l=r&&o.parse(r),h=o.space||"rgba";return l?(a=s[h](l),s[c[h].cache]=a[c[h].cache],n=s._rgba=a._rgba,!1):e}),n.length?("0,0,0,0"===n.join()&&t.extend(n,o.transparent),s):o[i]}function n(t,e,i){return i=(i+1)%1,1>6*i?t+6*(e-t)*i:1>2*i?e:2>3*i?t+6*(e-t)*(2/3-i):t}var o,a="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",r=/^([\-+])=\s*(\d+\.?\d*)/,l=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],h=t.Color=function(e,i,s,n){return new t.Color.fn.parse(e,i,s,n)},c={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},u={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},d=h.support={},p=t("

")[0],f=t.each;p.style.cssText="background-color:rgba(1,1,1,.5)",d.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(c,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),h.fn=t.extend(h.prototype,{parse:function(n,a,r,l){if(n===e)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=t(n).css(a),a=e);var u=this,d=t.type(n),p=this._rgba=[];return a!==e&&(n=[n,a,r,l],d="array"),"string"===d?this.parse(s(n)||o._default):"array"===d?(f(c.rgba.props,function(t,e){p[e.idx]=i(n[e.idx],e)}),this):"object"===d?(n instanceof h?f(c,function(t,e){n[e.cache]&&(u[e.cache]=n[e.cache].slice())}):f(c,function(e,s){var o=s.cache;f(s.props,function(t,e){if(!u[o]&&s.to){if("alpha"===t||null==n[t])return;u[o]=s.to(u._rgba)}u[o][e.idx]=i(n[t],e,!0)}),u[o]&&0>t.inArray(null,u[o].slice(0,3))&&(u[o][3]=1,s.from&&(u._rgba=s.from(u[o])))}),this):e},is:function(t){var i=h(t),s=!0,n=this;return f(c,function(t,o){var a,r=i[o.cache];return r&&(a=n[o.cache]||o.to&&o.to(n._rgba)||[],f(o.props,function(t,i){return null!=r[i.idx]?s=r[i.idx]===a[i.idx]:e})),s}),s},_space:function(){var t=[],e=this;return f(c,function(i,s){e[s.cache]&&t.push(i)}),t.pop()},transition:function(t,e){var s=h(t),n=s._space(),o=c[n],a=0===this.alpha()?h("transparent"):this,r=a[o.cache]||o.to(a._rgba),l=r.slice();return s=s[o.cache],f(o.props,function(t,n){var o=n.idx,a=r[o],h=s[o],c=u[n.type]||{};null!==h&&(null===a?l[o]=h:(c.mod&&(h-a>c.mod/2?a+=c.mod:a-h>c.mod/2&&(a-=c.mod)),l[o]=i((h-a)*e+a,n)))}),this[n](l)},blend:function(e){if(1===this._rgba[3])return this;var i=this._rgba.slice(),s=i.pop(),n=h(e)._rgba;return h(t.map(i,function(t,e){return(1-s)*n[e]+s*t}))},toRgbaString:function(){var e="rgba(",i=t.map(this._rgba,function(t,e){return null==t?e>2?1:0:t});return 1===i[3]&&(i.pop(),e="rgb("),e+i.join()+")"},toHslaString:function(){var e="hsla(",i=t.map(this.hsla(),function(t,e){return null==t&&(t=e>2?1:0),e&&3>e&&(t=Math.round(100*t)+"%"),t});return 1===i[3]&&(i.pop(),e="hsl("),e+i.join()+")"},toHexString:function(e){var i=this._rgba.slice(),s=i.pop();return e&&i.push(~~(255*s)),"#"+t.map(i,function(t){return t=(t||0).toString(16),1===t.length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),h.fn.parse.prototype=h.fn,c.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e,i,s=t[0]/255,n=t[1]/255,o=t[2]/255,a=t[3],r=Math.max(s,n,o),l=Math.min(s,n,o),h=r-l,c=r+l,u=.5*c;return e=l===r?0:s===r?60*(n-o)/h+360:n===r?60*(o-s)/h+120:60*(s-n)/h+240,i=0===h?0:.5>=u?h/c:h/(2-c),[Math.round(e)%360,i,u,null==a?1:a]},c.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,i=t[1],s=t[2],o=t[3],a=.5>=s?s*(1+i):s+i-s*i,r=2*s-a;return[Math.round(255*n(r,a,e+1/3)),Math.round(255*n(r,a,e)),Math.round(255*n(r,a,e-1/3)),o]},f(c,function(s,n){var o=n.props,a=n.cache,l=n.to,c=n.from;h.fn[s]=function(s){if(l&&!this[a]&&(this[a]=l(this._rgba)),s===e)return this[a].slice();var n,r=t.type(s),u="array"===r||"object"===r?s:arguments,d=this[a].slice();return f(o,function(t,e){var s=u["object"===r?t:e.idx];null==s&&(s=d[e.idx]),d[e.idx]=i(s,e)}),c?(n=h(c(d)),n[a]=d,n):h(d)},f(o,function(e,i){h.fn[e]||(h.fn[e]=function(n){var o,a=t.type(n),l="alpha"===e?this._hsla?"hsla":"rgba":s,h=this[l](),c=h[i.idx];return"undefined"===a?c:("function"===a&&(n=n.call(this,c),a=t.type(n)),null==n&&i.empty?this:("string"===a&&(o=r.exec(n),o&&(n=c+parseFloat(o[2])*("+"===o[1]?1:-1))),h[i.idx]=n,this[l](h)))})})}),h.hook=function(e){var i=e.split(" ");f(i,function(e,i){t.cssHooks[i]={set:function(e,n){var o,a,r="";if("transparent"!==n&&("string"!==t.type(n)||(o=s(n)))){if(n=h(o||n),!d.rgba&&1!==n._rgba[3]){for(a="backgroundColor"===i?e.parentNode:e;(""===r||"transparent"===r)&&a&&a.style;)try{r=t.css(a,"backgroundColor"),a=a.parentNode}catch(l){}n=n.blend(r&&"transparent"!==r?r:"_default")}n=n.toRgbaString()}try{e.style[i]=n}catch(l){}}},t.fx.step[i]=function(e){e.colorInit||(e.start=h(e.elem,i),e.end=h(e.end),e.colorInit=!0),t.cssHooks[i].set(e.elem,e.start.transition(e.end,e.pos))}})},h.hook(a),t.cssHooks.borderColor={expand:function(t){var e={};return f(["Top","Right","Bottom","Left"],function(i,s){e["border"+s+"Color"]=t}),e}},o=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(r),function(){function e(e){var i,s,n=e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,null):e.currentStyle,o={};if(n&&n.length&&n[0]&&n[n[0]])for(s=n.length;s--;)i=n[s],"string"==typeof n[i]&&(o[t.camelCase(i)]=n[i]);else for(i in n)"string"==typeof n[i]&&(o[i]=n[i]);return o}function i(e,i){var s,o,a={};for(s in i)o=i[s],e[s]!==o&&(n[s]||(t.fx.step[s]||!isNaN(parseFloat(o)))&&(a[s]=o));return a}var s=["add","remove","toggle"],n={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};t.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(e,i){t.fx.step[i]=function(t){("none"!==t.end&&!t.setAttr||1===t.pos&&!t.setAttr)&&(r.style(t.elem,i,t.end),t.setAttr=!0)}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.effects.animateClass=function(n,o,a,r){var l=t.speed(o,a,r);return this.queue(function(){var o,a=t(this),r=a.attr("class")||"",h=l.children?a.find("*").addBack():a;h=h.map(function(){var i=t(this);return{el:i,start:e(this)}}),o=function(){t.each(s,function(t,e){n[e]&&a[e+"Class"](n[e])})},o(),h=h.map(function(){return this.end=e(this.el[0]),this.diff=i(this.start,this.end),this}),a.attr("class",r),h=h.map(function(){var e=this,i=t.Deferred(),s=t.extend({},l,{queue:!1,complete:function(){i.resolve(e)}});return this.el.animate(this.diff,s),i.promise()}),t.when.apply(t,h.get()).done(function(){o(),t.each(arguments,function(){var e=this.el;t.each(this.diff,function(t){e.css(t,"")})}),l.complete.call(a[0])})})},t.fn.extend({addClass:function(e){return function(i,s,n,o){return s?t.effects.animateClass.call(this,{add:i},s,n,o):e.apply(this,arguments)}}(t.fn.addClass),removeClass:function(e){return function(i,s,n,o){return arguments.length>1?t.effects.animateClass.call(this,{remove:i},s,n,o):e.apply(this,arguments)}}(t.fn.removeClass),toggleClass:function(e){return function(i,s,n,o,a){return"boolean"==typeof s||void 0===s?n?t.effects.animateClass.call(this,s?{add:i}:{remove:i},n,o,a):e.apply(this,arguments):t.effects.animateClass.call(this,{toggle:i},s,n,o)}}(t.fn.toggleClass),switchClass:function(e,i,s,n,o){return t.effects.animateClass.call(this,{add:i,remove:e},s,n,o)}})}(),function(){function e(e,i,s,n){return t.isPlainObject(e)&&(i=e,e=e.effect),e={effect:e},null==i&&(i={}),t.isFunction(i)&&(n=i,s=null,i={}),("number"==typeof i||t.fx.speeds[i])&&(n=s,s=i,i={}),t.isFunction(s)&&(n=s,s=null),i&&t.extend(e,i),s=s||i.duration,e.duration=t.fx.off?0:"number"==typeof s?s:s in t.fx.speeds?t.fx.speeds[s]:t.fx.speeds._default,e.complete=n||i.complete,e}function i(e){return!e||"number"==typeof e||t.fx.speeds[e]?!0:"string"!=typeof e||t.effects.effect[e]?t.isFunction(e)?!0:"object"!=typeof e||e.effect?!1:!0:!0}t.extend(t.effects,{version:"1.11.4",save:function(t,e){for(var i=0;e.length>i;i++)null!==e[i]&&t.data(a+e[i],t[0].style[e[i]])},restore:function(t,e){var i,s;for(s=0;e.length>s;s++)null!==e[s]&&(i=t.data(a+e[s]),void 0===i&&(i=""),t.css(e[s],i))},setMode:function(t,e){return"toggle"===e&&(e=t.is(":hidden")?"show":"hide"),e},getBaseline:function(t,e){var i,s;switch(t[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=t[0]/e.height}switch(t[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=t[1]/e.width}return{x:s,y:i}},createWrapper:function(e){if(e.parent().is(".ui-effects-wrapper"))return e.parent();var i={width:e.outerWidth(!0),height:e.outerHeight(!0),"float":e.css("float")},s=t("

").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),n={width:e.width(),height:e.height()},o=document.activeElement;try{o.id}catch(a){o=document.body}return e.wrap(s),(e[0]===o||t.contains(e[0],o))&&t(o).focus(),s=e.parent(),"static"===e.css("position")?(s.css({position:"relative"}),e.css({position:"relative"})):(t.extend(i,{position:e.css("position"),zIndex:e.css("z-index")}),t.each(["top","left","bottom","right"],function(t,s){i[s]=e.css(s),isNaN(parseInt(i[s],10))&&(i[s]="auto")}),e.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),e.css(n),s.css(i).show()},removeWrapper:function(e){var i=document.activeElement;return e.parent().is(".ui-effects-wrapper")&&(e.parent().replaceWith(e),(e[0]===i||t.contains(e[0],i))&&t(i).focus()),e},setTransition:function(e,i,s,n){return n=n||{},t.each(i,function(t,i){var o=e.cssUnit(i);o[0]>0&&(n[i]=o[0]*s+o[1])}),n}}),t.fn.extend({effect:function(){function i(e){function i(){t.isFunction(o)&&o.call(n[0]),t.isFunction(e)&&e()}var n=t(this),o=s.complete,r=s.mode;(n.is(":hidden")?"hide"===r:"show"===r)?(n[r](),i()):a.call(n[0],s,i)}var s=e.apply(this,arguments),n=s.mode,o=s.queue,a=t.effects.effect[s.effect]; +return t.fx.off||!a?n?this[n](s.duration,s.complete):this.each(function(){s.complete&&s.complete.call(this)}):o===!1?this.each(i):this.queue(o||"fx",i)},show:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="show",this.effect.call(this,n)}}(t.fn.show),hide:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="hide",this.effect.call(this,n)}}(t.fn.hide),toggle:function(t){return function(s){if(i(s)||"boolean"==typeof s)return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)}}(t.fn.toggle),cssUnit:function(e){var i=this.css(e),s=[];return t.each(["em","px","%","pt"],function(t,e){i.indexOf(e)>0&&(s=[parseFloat(i),e])}),s}})}(),function(){var e={};t.each(["Quad","Cubic","Quart","Quint","Expo"],function(t,i){e[i]=function(e){return Math.pow(e,t+2)}}),t.extend(e,{Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t){return 0===t||1===t?t:-Math.pow(2,8*(t-1))*Math.sin((80*(t-1)-7.5)*Math.PI/15)},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var e,i=4;((e=Math.pow(2,--i))-1)/11>t;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*e-2)/22-t,2)}}),t.each(e,function(e,i){t.easing["easeIn"+e]=i,t.easing["easeOut"+e]=function(t){return 1-i(1-t)},t.easing["easeInOut"+e]=function(t){return.5>t?i(2*t)/2:1-i(-2*t+2)/2}})}(),t.effects,t.effects.effect.slide=function(e,i){var s,n=t(this),o=["position","top","bottom","left","right","width","height"],a=t.effects.setMode(n,e.mode||"show"),r="show"===a,l=e.direction||"left",h="up"===l||"down"===l?"top":"left",c="up"===l||"left"===l,u={};t.effects.save(n,o),n.show(),s=e.distance||n["top"===h?"outerHeight":"outerWidth"](!0),t.effects.createWrapper(n).css({overflow:"hidden"}),r&&n.css(h,c?isNaN(s)?"-"+s:-s:s),u[h]=(r?c?"+=":"-=":c?"-=":"+=")+s,n.animate(u,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){"hide"===a&&n.hide(),t.effects.restore(n,o),t.effects.removeWrapper(n),i()}})}}); \ No newline at end of file