'
+ +'
'
+ +'
'+ menu_items[field].name +''
+ +"
"
+ +"'
+ +'
'
+ +'
'
+
+ +"';
+ $('.menu_items_list').append(row);
+ }
+ }
+ }
+ });
+ //end Ajax
+ }
+ //end show list function
+ //click item row for item set
+ $(document).on('click', '.set_item_box', function(event){
+ $(".instance-list").empty();
+ $(".options-list").empty();
+
+ data = $(this).parent().children().children('.add_icon');
+
+ instances = $(this).data('instance');
+ item_sets = $(this).data('item-sets');
+
+ for(var field in item_sets) {
+ value = item_sets[field]["instances"];
+ $(value).each(function(i){
+ $.ajax({
+ type: "GET",
+ url: '../../api/restaurant/menu_item_instances/'+value[i]["id"],
+ data: {id:value[i]},
+ success:function(result){
+
+ row = '
'
+ +"
"
+ +'
'
+ +''+result["name"]+''
+ +'
'
+ +'
'
+ +'

'
+ +'
'
+ +'
'
+ +''
+ +'
'
+ +'
'
+
+ $(".instance-list").append(row);
+ }
+ });
+ });
+ }
+
+ $('#set_change_qty').val(1);
+ $('#set_item_instances').text(instances);
+ $('#set_name').text(data.attr('data-name'));
+ $('#set_item_code').text(data.attr('data-item-code'));
+ $('#set_total_price').text(data.attr('data-price'));
+ $('#set_unit_price').text(data.attr('data-price'));
+ });
+ // click instance for add item set
+ $(document).on('click', '.instance_box', function(event){
+
+ $(".options-list").empty();
+
+ item_options = $(this).data('option');
+ code = $(this).data('code');
+
+ for(var field in item_options) {
+ value = item_options[field]["values"];
+ type = item_options[field]["type"];
+ row = "
"+type+"
"
+ $(value).each(function(i){
+ row +="
";
+ });
+ $(".options-list").append(row);
+ }
+
+ if($(this).hasClass('selected-instance') == true){
+ sub_total = $('#set_total_price').text();
+ name = $(this).data('name');
+ price = $(this).data('price');
+ qty = $('#set_change_qty').val();
+ total = qty*price;
+ var total_price = +sub_total - +total;
+ $(this).removeClass('selected-instance');
+ $(".options-list").empty();
+ $(this).removeAttr('data-options');
+ $('#instance_option').text('')
+ }else {
+ sub_total = $('#set_total_price').text();
+ name = $(this).data('name');
+ price = $(this).data('price');
+ qty = $('#set_change_qty').val();
+ total = qty*price;
+ var total_price = +sub_total + +total;
+ $(this).addClass('selected-instance');
+ }
+ $('#set_total_price').text(total_price);
+ }); //End selecct attribute buttom
+
+ // click add order
+ $(document).on('click', '.set_order', function(event){
+ total_price = $('#set_total_price').text();
+ qty = parseInt($('#set_change_qty').val());
+ item_code = $('#set_item_code').text();
+ item_name = $('#set_name').text();
+
+ var items = $('.selected-instance');
+
+ attribute_arr = []
+ option_arr = []
+ var rowCount = $('.summary-items tbody tr').length+1;
+ $(items).each(function(i){
+ code = $(items[i]).attr('data-code');
+ name = $(items[i]).attr('data-name');
+ price = $(items[i]).attr('data-price');
+ option = $(items[i]).attr('data-options');
+ total = qty * price ;
+ option_arr.push(option);
+ row ="
"
+ +'| '+rowCount+' | '
+ +'' + item_name+ ' ' + name +' | '
+ +'' + qty + ' | '
+ +''
+ + parseFloat(total).toFixed(2)
+ +' | '
+ +'
';
+ $(".summary-items tbody").append(row);
+ rowCount = rowCount + 1;
+ });
+ calculate_sub_total();
+
+ }); //End add order Click
+
+ //click item row for add order
+ $(document).on('click', '.menu_item_box', function(event){
+ $('.attributes-list').empty();
+ $('.options-list').empty();
+ $('.attr-alert').addClass('hide');
+ $('.add_to_order').removeAttr('data-instance-code');
+ $('.add_to_order').removeAttr('data-instance');
+ $('.add_to_order').removeAttr('data-price');
+ $('.add_to_order').removeAttr('data-promotion-price');
+ $('.add_to_order').removeAttr('data-item-code');
+ $('.add_to_order').removeAttr('data-qty');
+ $('.add_to_order').removeAttr('data-name');
+ $('.add_to_order').removeAttr('data-attributes');
+ $('.add_to_order').removeAttr('data-options');
+
+ data = $(this).parent().children().children('.add_icon');
+ attributes = $(this).data('id');
+ selected_item = $(this).data('item');
+ instances = $(this).data('instance');
+ item_options = $(this).data('option');
+
+ instance_attributes = []
+ for(var field in instances) {
+ value = instances[field].values;
+ $(value).each(function(i){
+ options = value[i];
+ instance_attributes.push(options);
+ });
+ }
+
+ for(var field in attributes) {
+ value = attributes[field]["values"];
+ type = attributes[field]["type"]
+ row = "
"+attributes[field]["type"]+"
"
+ $(value).each(function(i){
+ disabled = ""
+ status ="";
+
+ if(parseInt(jQuery.inArray(value[i], selected_item))!== -1){
+ status = "selected-attribute";
+ }
+ if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
+ disabled = "disabled";
+ }
+ row +="
";
+ });
+ $(".attributes-list").append(row);
+ }
+
+ for(var field in item_options) {
+ value = item_options[field]["values"];
+ type = item_options[field]["type"];
+ row = "
"+type+"
"
+ $(value).each(function(i){
+ row +="
";
+ });
+ $(".options-list").append(row);
+ }
+
+ $('#change_qty').val(1);
+ $('#item_instances').text(instances);
+ $('#title_name').text(data.attr('data-name'));
+ $('#item_code').text(data.attr('data-item-code'));
+ $('#total_price').text(data.attr('data-price'));
+ $('#unit_price').text(data.attr('data-price'));
+ });
+
+ // click select option icon for add
+ $(document).on('click', '.attribute_btn', function(event){
+ value = $(this).data('value');
+ type = $(this).data('type');
+ instances = $(this).data('instances');
+
+ attributes = $(".attribute_btn");
+ $(attributes).each(function(i){
+ if ($(attributes[i]).attr('data-type')==type){
+ $('.'+type).removeClass("selected-attribute");
+ }
+ });
+ $(this).addClass('selected-attribute');
+
+ // if ($(".attribute_btn").attr("data-type")==type){
+ // $('.'+type).removeClass("selected-attribute");
+ // }
+ // $(this).addClass('selected-attribute');
+
+ var selected_attr = get_selected_attributes('selected-attribute');
+
+ qty = $('#change_qty').val();
+
+ for(var field in instances) {
+ item_attr = instances[field].values;
+
+ if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
+ unit_price = instances[field].price ;
+ total_price = qty * unit_price ;
+ $('#instance_name').text(instances[field].name);
+ $('#instance_code').text(instances[field].code);
+ $('#promotion_price').text(instances[field].promotion_price);
+ $('#total_price').text(total_price);
+ $('#unit_price').text(unit_price);
+ }
+ }
+
+ }); //End selecct attribute buttom
+
+ // click select option icon for add
+ $(document).on('click', '.option_btn', function(event){
+ value = $(this).data('value');
+ type = $(this).data('type');
+ group = $(this).data('group');
+ options = $(".option_btn");
+ $(options).each(function(i){
+ if ($(options[i]).attr('data-type')==type){
+ $('.'+type).removeClass("selected-option");
+ }
+ });
+ $(this).addClass('selected-option');
+
+ if(group == "set_menu"){
+ code = $(this).data('code');
+ value = $(this).data('value');
+
+ instance = $(".selected-instance");
+ $(instance).each(function(i){
+ if ($(instance[i]).attr('data-code')==code){
+ option_arr = get_selected_attributes('selected-option');
+ $(instance[i]).attr('data-options',JSON.stringify(option_arr));
+ $(instance[i]).children().children('#instance_option').text(option_arr);
+ }
+ });
+ }
+
+ }); //End selecct attribute buttom
+
+ // click add order
+ $(document).on('click', '.add_to_order', function(event){
+ total_price = $('#total_price').text();
+ qty = parseInt($('#change_qty').val());
+
+ var item_row = $('.selected-attribute');
+ var instances = jQuery.parseJSON(item_row.attr('data-instances'));
+
+ attribute_arr = get_selected_attributes('selected-attribute');
+ option_arr = get_selected_attributes('selected-option');
+
+ for(var field in instances) {
+ if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
+
+ $('.add_to_order').attr('data-instance-code',instances[field].code);
+ $('.add_to_order').attr('data-instance',instances[field].name);
+ $('.add_to_order').attr('data-price',instances[field].price);
+ $('.add_to_order').attr('data-promotion-price',instances[field].promotion_price);
+ }
+ }
+ $('.add_to_order').attr('data-item-code',$('#item_code').text());
+ $('.add_to_order').attr('data-qty',qty);
+ $('.add_to_order').attr('data-name',$('#title_name').text());
+ $('.add_to_order').attr('data-attributes',JSON.stringify(attribute_arr));
+ $('.add_to_order').attr('data-options',JSON.stringify(option_arr));
+ var item_data = $(this);
+ show_item_detail(item_data);
+ calculate_sub_total();
+
+ }); //End add order Click
+
+ // click plus icon for add
+ $(document).on('click', '.add_icon', function(event){
+ var item_data = $(this);
+ show_item_detail(item_data);
+ calculate_sub_total();
+ }); //End Add Icon Click
+
+ function show_item_detail(data){
+ console.log(data)
+ qty = parseInt(data.attr('data-qty'));
+ append = 0;
+ price = parseFloat(data.attr('data-price')).toFixed(2);
+ instance_name = data.attr('data-instance');
+ if (instance_name == "undefined"){
+ instance = '';
+ }else{
+ instance = "("+data.attr('data-instance')+")";
+ }
+
+ var rowCount = $('.summary-items tbody tr').length+1;
+ var item_row = $('.summary-items tbody tr');
+
+ $(item_row).each(function(i){
+ item_code = $(item_row[i]).attr('data-code');
+ instance_code = $(item_row[i]).attr('data-instance-code');
+
+ if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')) {
+ if (qty > 1) {
+ qty = parseInt($(item_row[i]).children('#item_qty').text()) + qty;
+ }else{
+ qty = parseInt($(item_row[i]).children('#item_qty').text()) + 1;
+ }
+
+ $(item_row[i]).children('#item_qty').text(qty);
+ parseFloat($(item_row[i]).children('#item_price').text(price*qty)).toFixed(2);
+ append =1;
+ }else{
+ if (qty > 1) {
+ qty = qty;
+ }else{
+ qty = 1;
+ }
+ }
+ });
+ if (append===0) {
+ row ="
"
+ +'| '+rowCount+' | '
+ +'' + data.attr('data-name')+ ' ' + instance +' | '
+ +'' + qty + ' | '
+ +''
+ + parseFloat(price).toFixed(2)
+ +' | '
+ +'
';
+ $(".summary-items tbody").append(row);
+ }
+ }
+
+ // Pay Discount for Payment
+ $("#create_order").on('click', function(e){
+ e.preventDefault();
+ $("#loading_wrapper").show();
+ var table_id = $('#table_id').text();
+ var booking_id = $('#booking_id').text();
+ if (!booking_id.length > 0) {
+
+ var params = {'order_source': "cashier", 'order_type': "dine_in",
+ 'customer_id': "", 'guest_info': "",'booking_id':booking_id,
+ 'table_id': table_id,
+ 'order_items': order_items };
+ }
+ var table_type = $('#table_type').text();
+ var order_items = JSON.stringify(get_order_item_rows());
+
+ var ajax_url = '../addorders/create';
+
+
+ var params = {'order_source': "cashier", 'order_type': "dine_in",
+ 'customer_id': "", 'guest_info': "",
+ 'table_id': table_id,
+ 'order_items': order_items };
+
+ $.ajax({
+ type: "POST",
+ url: ajax_url,
+ data: params,
+ dataType: "json",
+ success:function(result){
+ $("#loading_wrapper").hide();
+ $.confirm({
+ title: 'Infomation!',
+ content: "Order has been successfully created",
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ if(table_type == "Table"){
+ window.location.href = "/origami/table/" + table_id
+ }
+ else {
+ window.location.href = "/origami/room/" + table_id
+ }
+ }
+ }
+ }
+ });
+ }
+ });
+ });
+
+ //click item row for update qty
+ $('.summary-items').on('click', '.item_box', function(){
+ $(this).attr('data-active',true);
+ name = $(this).children('#item_name').text();
+ qty = $(this).children('#item_qty').text();
+ $('#modal-item-name').text(name);
+ $('#modal-qty').val(qty);
+ });
+
+ //click remove buttom in modal box
+ $('#sx_itemModal').on('click','#remove', function(){
+ $('.summary-items tr').filter(function(){
+ if ($(this).attr('data-active') == 'true'){
+ $(this).remove();
+ }
+ });
+ calculate_sub_total();
+ });
+
+ //click close
+ $('#sx_itemModal').on('click','#close', function(){
+ $(".item_box").removeAttr("data-active");
+ });
+
+ //click save buttom after change qty
+ $('#sx_itemModal').on('click','#save', function(){
+ summary_items_filter();
+ calculate_sub_total();
+ });
+
+ //calculate subtotal
+ function calculate_sub_total(){
+ var total_price = 0;
+ var taxable_amount = 0;
+ var item_row = $('.summary-items tbody tr');
+
+ $(item_row).each(function(i){
+ var unit_price = parseFloat($(item_row[i]).attr('data-price'));
+ var qty = parseFloat($(item_row[i]).children('#item_qty').text());
+ total_price += qty*unit_price;
+ });
+ var fixed_total_price = parseFloat(total_price).toFixed(2);
+ var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2);
+
+ $('#sub_total').empty();
+ $('#sub_total').append(fixed_total_price);
+
+ if (fixed_total_price > 0) {
+ $('.create').removeAttr("disabled", false);
+ }else{
+ $('.create').attr("disabled", true);
+ }
+ }
+
+ function summary_items_filter(){
+ $('.summary-items tr').filter(function(){
+ if ($(this).attr('data-active') == 'true'){
+ qty = $('#modal-qty').val();
+ price = parseFloat($(this).attr('data-price'));
+ total_price = parseFloat(price*qty).toFixed(2);
+
+ $(this).find('#item_qty').text(qty);
+ $(this).find('.item-cell-price').text(total_price);
+
+ $(this).removeAttr('data-active');
+ }
+ });
+ }
+
+ /* Get Item rows */
+ function get_order_item_rows(){
+ var order_items = [];
+ var item_row = $('.summary-items tbody tr');
+ $(item_row).each(function(i){
+ var order_item = {};
+ console.log($(item_row[i]).attr('data-options'));
+ order_item.order_item_id = $(item_row[i]).attr('data-row');
+ order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
+ order_item.quantity = $(item_row[i]).children('#item_qty').text();
+ order_item.options = $(item_row[i]).attr('data-options');
+ order_items.push(order_item);
+ });
+ return order_items;
+ }
+ // Get Selected Class
+ function get_selected_attributes(selected_class) {
+ var item_row = $('.'+selected_class);
+ var attribute_arr = [];
+ $(item_row).each(function(i){
+ value = $(item_row[i]).attr('data-value');
+ str = value;
+ attribute_arr.push(str);
+ });
+ return attribute_arr;
+ }
+
+});
\ No newline at end of file
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 63c871d9..77dbb850 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -11,6 +11,7 @@
// about supported directives.
//
//= require jquery
+//= require jquery_nested_form
//= require tether
//= require bootstrap
//= require jquery_ujs
@@ -19,145 +20,28 @@
//= require settings/processing_items
//= require jquery-ui
//= require bootstrap-datepicker
+//= require moment
+//= require daterangepicker
+//= require select2
+//= require jquery.datetimepicker
-$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
+
+$(document).on('turbolinks:load', function() {
+ $('.datepicker').datepicker({
+ format : 'dd-mm-yyyy',
+ autoclose: true
+ });
+ $('.datepicker').attr('ReadOnly','true');
+ $('.datepicker').css('cursor','pointer');
+});
+
+ $(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
- $('.dropdown-toggle').dropdown();
+ $('.dropdown-toggle').dropdown();
});
function export_to(path)
{
- var form_params = $("#frm_report").serialize();
- window.location = path+"?"+ form_params;
+ var form_params = $("#frm_report").serialize();
+ window.location = path+"?"+ form_params;
}
-
-/*
-* ToDo Move to here from pages
-*
-*
-
-
-
-$(function(){
- $('#custom_excel').hide();
-
- $('#custom_excel').click(function(){
- var url = $('#custom_excel').attr('data-url');
- $('#frm_report').attr('action',url)
- $('#frm_report').submit();
- // window.location = url;
- });
-
- var item = $('#item').val();
- var payment_type = $('#payment_type');
-
- if(item == 'order'){
- $('#cashier').hide();
- $('#waiter').show();
- if(payment_type){
- $('#payment_type').hide();
- }
- }
- else if(item == 'sale'){
- $('#waiter').hide();
- $('#cashier').show();
- }
- else{
- $('#waiter').hide();
- $('#cashier').show();
- $("#item").val('sale');
- }
-});
-
-//Reset the form to pervious values
-$("#branch").val(<%=params[:branch]%>);
-$("#waiter").val("<%=params[:waiter]%>");
-$("#cashier").val(<%=params[:cashier]%>);
-$("#product").val(<%=params[:product]%>);
-$("#singer").val(<%=params[:singer]%>);
-$("#item").val('<%=params[:item]%>');
-$("#guest_role").val('<%=params[:guest_role]%>');
-
-
-$("#from").val("<%=params[:from]%>");
-$("#to").val("<%=params[:to]%>");
-$("#sel_period").val(<%=params[:period]%>);
-$("#sel_sale_type").val(<%=params[:sale_type]%>);
-
-<% if params[:period_type] == 1 || params[:period_type] == "1" %>
- $("#rd_period_type_1").attr("checked","checked");
-<% else %>
- $("#rd_period_type_0").attr("checked","checked");
-<% end %>
-$(".btn-group button").removeClass("active");
-<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
-$("#btn_report_type_<%= report_type %>").addClass("active");
-
-$('#item').change(function(){
- var item = $('#item').val();
- var payment_type = $('#payment_type');
-
- if(item == 'sale'){
- $('#waiter').hide();
- $('#cashier').show();
- if(payment_type){
- $('#payment_type').show();
- }
- }
- else{
- $('#cashier').hide();
- $('#waiter').show();
- if(payment_type){
- $('#payment_type').hide();
- }
- }
-});
-
-$(function(){
- var check_arr = [];
- var search = '<%= params[:period_type] %>';
- if(search){
- if(parseInt(search) == 0){
- search_by_period();
- }
- else{
- search_by_date();
- }
- }else{
- search_by_period();
- }
- $('#sel_period').change(function(){
- search_by_period();
- });
- function search_by_period(){
- var period = $('#sel_period').val();
- var period_type = 0;
- var from = "";
- var to = "";
- }
-
- $('#from').change(function(){
- search_by_date();
- });
-
- $('#to').change(function(){
- search_by_date();
- });
- function search_by_date(){
- var from = $('#from').val();
- var to = $('#to').val();
- var period = 0;
- var period_type = 1;
- if(to != '' && from != ''){
- shift_name = from + ',' + to;
- check_arr.push(to);
- // console.log(check_arr.length)
- if(check_arr.length == 1){
- }
- if(check_arr.length == 3){
- check_arr = [];
- }
- }
- }
-});
-*/
diff --git a/app/assets/javascripts/commissioners.coffee b/app/assets/javascripts/commissioners.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/commissioners.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/commissions.coffee b/app/assets/javascripts/commissions.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/commissions.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/dining_charges.coffee b/app/assets/javascripts/dining_charges.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/dining_charges.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/fileinput.min.js b/app/assets/javascripts/fileinput.min.js
new file mode 100755
index 00000000..d6d3ff94
--- /dev/null
+++ b/app/assets/javascripts/fileinput.min.js
@@ -0,0 +1,12 @@
+/*!
+ * bootstrap-fileinput v4.4.3
+ * http://plugins.krajee.com/file-input
+ *
+ * Author: Kartik Visweswaran
+ * Copyright: 2014 - 2017, Kartik Visweswaran, Krajee.com
+ *
+ * Licensed under the BSD 3-Clause
+ * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md
+ */!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(window.jQuery)}(function(e){"use strict";e.fn.fileinputLocales={},e.fn.fileinputThemes={},String.prototype.setTokens=function(e){var i,t,a=this.toString();for(i in e)e.hasOwnProperty(i)&&(t=new RegExp("{"+i+"}","g"),a=a.replace(t,e[i]));return a};var i,t;i={FRAMES:".kv-preview-thumb",SORT_CSS:"file-sortable",STYLE_SETTING:'style="width:{width};height:{height};"',OBJECT_PARAMS:'
\n
\n
\n
\n
\n
\n',DEFAULT_PREVIEW:'
\n{previewFileIcon}\n
',MODAL_ID:"kvFileinputModal",MODAL_EVENTS:["show","shown","hide","hidden","loaded"],objUrl:window.URL||window.webkitURL,compare:function(e,i,t){return void 0!==e&&(t?e===i:e.match(i))},isIE:function(e){if("Microsoft Internet Explorer"!==navigator.appName)return!1;if(10===e)return new RegExp("msie\\s"+e,"i").test(navigator.userAgent);var i,t=document.createElement("div");return t.innerHTML="",i=t.getElementsByTagName("i").length,document.body.appendChild(t),t.parentNode.removeChild(t),i},initModal:function(i){var t=e("body");t.length&&i.appendTo(t)},isEmpty:function(i,t){return void 0===i||null===i||0===i.length||t&&""===e.trim(i)},isArray:function(e){return Array.isArray(e)||"[object Array]"===Object.prototype.toString.call(e)},ifSet:function(e,i,t){return t=t||"",i&&"object"==typeof i&&e in i?i[e]:t},cleanArray:function(e){return e instanceof Array||(e=[]),e.filter(function(e){return void 0!==e&&null!==e})},spliceArray:function(e,i){var t,a=0,n=[];if(!(e instanceof Array))return[];for(t=0;t
=0?atob(e.split(",")[1]):decodeURIComponent(e.split(",")[1]),a=new ArrayBuffer(t.length),n=new Uint8Array(a),r=0;r/g,">").replace(/"/g,""").replace(/'/g,"'")},replaceTags:function(i,t){var a=i;return t?(e.each(t,function(e,i){"function"==typeof i&&(i=i()),a=a.split(e).join(i)}),a):a},cleanMemory:function(e){var t=e.is("img")?e.attr("src"):e.find("source").attr("src");i.objUrl.revokeObjectURL(t)},findFileName:function(e){var i=e.lastIndexOf("/");return-1===i&&(i=e.lastIndexOf("\\")),e.split(e.substring(i,i+1)).pop()},checkFullScreen:function(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement},toggleFullScreen:function(e){var t=document,a=t.documentElement;a&&e&&!i.checkFullScreen()?a.requestFullscreen?a.requestFullscreen():a.msRequestFullscreen?a.msRequestFullscreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.webkitRequestFullscreen&&a.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):t.exitFullscreen?t.exitFullscreen():t.msExitFullscreen?t.msExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.webkitExitFullscreen&&t.webkitExitFullscreen()},moveArray:function(e,i,t){if(t>=e.length)for(var a=t-e.length;a--+1;)e.push(void 0);return e.splice(t,0,e.splice(i,1)[0]),e},cleanZoomCache:function(e){var i=e.closest(".kv-zoom-cache-theme");i.length||(i=e.closest(".kv-zoom-cache")),i.remove()},setOrientation:function(e,i){var t,a,n,r=new DataView(e),o=0,l=1;if(65496!==r.getUint16(o)||e.length<2)return void(i&&i());for(o+=2,t=r.byteLength;t-2>o;)switch(a=r.getUint16(o),o+=2,a){case 65505:n=r.getUint16(o),t=n-o,o+=2;break;case 274:l=r.getUint16(o+6,!1),t=0}i&&i(l)},validateOrientation:function(e,t){if(window.FileReader&&window.DataView){var a,n=new FileReader;n.onloadend=function(){a=n.result,i.setOrientation(a,t)},n.readAsArrayBuffer(e)}},adjustOrientedImage:function(e,i){var t,a,n;if(e.hasClass("is-portrait-gt4")){if(i)return void e.css({width:e.parent().height()});e.css({height:"auto",width:e.height()}),t=e.parent().offset().top,a=e.offset().top,n=t-a,e.css("margin-top",n)}}},t=function(t,a){var n=this;n.$element=e(t),n._validate()&&(n.isPreviewable=i.hasFileAPISupport(),n.isIE9=i.isIE(9),n.isIE10=i.isIE(10),n.isPreviewable||n.isIE9?(n._init(a),n._listen()):n.$element.removeClass("file-loading"))},t.prototype={constructor:t,_cleanup:function(){var e=this;e.reader=null,e.formdata={},e.uploadCount=0,e.uploadStatus={},e.uploadLog=[],e.uploadAsyncCount=0,e.loadedImages=[],e.totalImagesCount=0,e.ajaxRequests=[],e.clearStack(),e.fileInputCleared=!1,e.fileBatchCompleted=!0,e.isPreviewable||(e.showPreview=!1),e.isError=!1,e.ajaxAborted=!1,e.cancelling=!1},_init:function(t){var a,n,r,o=this,l=o.$element;o.options=t,e.each(t,function(e,t){switch(e){case"minFileCount":case"maxFileCount":case"minFileSize":case"maxFileSize":case"maxFilePreviewSize":case"resizeImageQuality":case"resizeIfSizeMoreThan":case"progressUploadThreshold":case"initialPreviewCount":case"zoomModalHeight":case"minImageHeight":case"maxImageHeight":case"minImageWidth":case"maxImageWidth":o[e]=i.getNum(t);break;default:o[e]=t}}),o.rtl&&(r=o.previewZoomButtonIcons.prev,o.previewZoomButtonIcons.prev=o.previewZoomButtonIcons.next,o.previewZoomButtonIcons.next=r),o._cleanup(),o.$form=l.closest("form"),o._initTemplateDefaults(),o.uploadFileAttr=i.isEmpty(l.attr("name"))?"file_data":l.attr("name"),n=o._getLayoutTemplate("progress"),o.progressTemplate=n.replace("{class}",o.progressClass),o.progressCompleteTemplate=n.replace("{class}",o.progressCompleteClass),o.progressErrorTemplate=n.replace("{class}",o.progressErrorClass),o.dropZoneEnabled=i.hasDragDropSupport()&&o.dropZoneEnabled,o.isDisabled=l.attr("disabled")||l.attr("readonly"),o.isDisabled&&l.attr("disabled",!0),o.isUploadable=i.hasFileUploadSupport()&&!i.isEmpty(o.uploadUrl),o.isClickable=o.browseOnZoneClick&&o.showPreview&&(o.isUploadable&&o.dropZoneEnabled||!i.isEmpty(o.defaultPreviewContent)),o.slug="function"==typeof t.slugCallback?t.slugCallback:o._slugDefault,o.mainTemplate=o.showCaption?o._getLayoutTemplate("main1"):o._getLayoutTemplate("main2"),o.captionTemplate=o._getLayoutTemplate("caption"),o.previewGenericTemplate=o._getPreviewTemplate("generic"),o.resizeImage&&(o.maxImageWidth||o.maxImageHeight)&&(o.imageCanvas=document.createElement("canvas"),o.imageCanvasContext=o.imageCanvas.getContext("2d")),i.isEmpty(l.attr("id"))&&l.attr("id",i.uniqId()),o.namespace=".fileinput_"+l.attr("id").replace(/-/g,"_"),void 0===o.$container?o.$container=o._createContainer():o._refreshContainer(),a=o.$container,o.$dropZone=a.find(".file-drop-zone"),o.$progress=a.find(".kv-upload-progress"),o.$btnUpload=a.find(".fileinput-upload"),o.$captionContainer=i.getElement(t,"elCaptionContainer",a.find(".file-caption")),o.$caption=i.getElement(t,"elCaptionText",a.find(".file-caption-name")),o.$previewContainer=i.getElement(t,"elPreviewContainer",a.find(".file-preview")),o.$preview=i.getElement(t,"elPreviewImage",a.find(".file-preview-thumbnails")),o.$previewStatus=i.getElement(t,"elPreviewStatus",a.find(".file-preview-status")),o.$errorContainer=i.getElement(t,"elErrorContainer",o.$previewContainer.find(".kv-fileinput-error")),i.isEmpty(o.msgErrorClass)||i.addCss(o.$errorContainer,o.msgErrorClass),o.$errorContainer.hide(),o.previewInitId="preview-"+i.uniqId(),o._initPreviewCache(),o._initPreview(!0),o._initPreviewActions(),o._setFileDropZoneTitle(),l.removeClass("file-loading"),l.attr("disabled")&&o.disable(),o._initZoom(),o.hideThumbnailContent&&i.addCss(o.$preview,"hide-content")},_initTemplateDefaults:function(){var t,a,n,r,o,l,s,d,c,u,p,f,m,v,h,g,w,_,b,C,y,T,E,x,F,S,I,k,P,z,A,$,D,U,j,B,L=this;t='{preview}\n\n',a='{preview}\n\n{remove}\n{cancel}\n{upload}\n{browse}\n',n='',o='×
\n',r='',l='\n',s='',d='{icon} {label}',c='{icon} {label}
',u='',p='\n',f='',m=" ({sizeText})",v='',h='{drag}\n',g='\n',w='',_='',b='{dragIcon}',C='{indicator}
',y='\n',E=y+' title="{caption}">
\n',x="
{footer}\n
\n",F="{content}\n",S='
{data}
\n",I='

\n",k='
\n",P='
\n",z='
\n",A='
\n",$='
\n",D='