// Call api to get data// // HoGo script v 2.0 // Add functions: // - View file type document // - Support uploading new file type (.docx, .xlsx, .pttx) for plupload/Google drive/Dropbox object // - Send wizard support MS office file // - Add new function for ClientInfo object // - Effect drag & drop in uploading documnent // - Fixing animation popup & add scrolltop for model to keep current user's position screen // - And much more update, bugs fixing... // // // Variable for form's status //ExportServiceUserList var formStatus; var GOOGLE_ENVIRONMENT = "production"; // // Stripe key // var stripePuplicKey = "pk_live_Nj8frYtyf3WM1TOFfJrL1ffa"; //var stripePuplicKey = "pk_test_hoCROLJbcrwFP9uoXxbE3ukz"; var supportedFile = ['pdf', 'docx', 'xlsx', 'pptx', 'xlsm']; // 'pptx' for 2.0: pptx // Google app key var GoogleConst = { production: { /* Prodcution server */ clientId: '6829061683-2nr93rk2djkei7mhi6an1emodi4t264g.apps.googleusercontent.com', appID: 'k3hodIm2xU0ofm-2vm0_BmIi' }, server_test: { clientId: '6829061683-2nr93rk2djkei7mhi6an1emodi4t264g.apps.googleusercontent.com', appID: 'k3hodIm2xU0ofm-2vm0_BmIi' }, local: { /* Google's clientID - Using for localhost*/ clientId: '6829061683-2nr93rk2djkei7mhi6an1emodi4t264g.apps.googleusercontent.com', appID: 'k3hodIm2xU0ofm-2vm0_BmIi' // clientId: '480888213599-56dh0vh33uq6i2nscjj582bq6ca5cre6.apps.googleusercontent.com', // appID: '480888213599' }, /* Google drive scope */ scopeDrive: ["https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"], /* Google profile scope */ scopeProfile: ["https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email"], /* Google contact scope */ scopeContact: ["https://www.google.com/m8/feeds"] }; // // Some important plugins must be initilized before our app get started // (function ($) { //Store last page for using datatable var aParts = window.location.pathname.split('/'), sNameEQ = aParts[aParts.length - 1].replace(/[\/:]/g, "").toLowerCase(); var pageName = ""; if (sNameEQ.indexOf(".html") !== -1) pageName = sNameEQ; else pageName = sNameEQ + ".html"; $(window).bind('beforeunload', function (e) { $.cookie("l_p", pageName); }); // // PLUG-INS. Here are some common plug-ins which is used in our application // /* * jQuery Reveal Plugin 1.0. Modify something by tmhao * www.ZURB.com * Copyright 2010, ZURB * Free to use under the MIT license. * http://www.opensource.org/licenses/mit-license.php */ $.fn.reveal = function (opts) { var defaults = { header: null, size: null, modalclassname: 'reveal-modal', animation: 'fadeAndPop', //fade, fadeAndPop, none --- We can create many animation here animationspeed: 400, //how fast animtions are closeonbackgroundclick: true, //if you click background will modal close? dismissmodalclass: 'close-reveal-modal', //the class of a button or element that will close an open modal modalbgclass: 'reveal-modal-bg modal', scrolltop: $(document).scrollTop() // Get current scrolltop }; //Extend dem' options var options = $.extend({}, defaults, opts); return this.each(function () { // Get current top var currentTop = options.scrolltop; // Global Variables var modalHTML = $(this).detach(), locked = false, modalBG = $('.' + options.modalbgclass); var modal; var size = (options.size === "large" || options.size === "lg") ? "modal-large" : ""; // Check modal first if (!modalHTML.find(".modal-dialog").length) { $(this).wrapAll(''); modal = $(this).parents(".modal-dialog"); } else { modal = modalHTML; } // Not allow scrolling $('body').addClass('modal-open'); //Create Modal BG if (modalBG.length === 0) { modalBG = $('
').append(modal); $('body').append(modalBG); } else { // Move to another place //modalBG.find('.' + options.modalclassname).appendTo('body'); modalBG.html('').append(modal); } //Open & Close Animations modal.bind('reveal:open', function () { // $('#container').css('top', -currentTop + 'px'); modalBG.unbind('click.modalEvent'); $('.' + options.dismissmodalclass).unbind('click.modalEvent'); if (!locked) { lockModal(); if (options.animation === "fadeAndPop") { modal.css({'opacity': 0}); //, 'display': 'block', 'top': '0px' // We'll get the width of text inside - Got real width // var sensor = $('
').append(modal.clone()).css({'float': 'left', 'visibility': 'hidden'}); // How to calculate the length of long text // $('body').append(sensor); // var width = sensor.width(); // sensor.remove(); modalBG.fadeIn(options.animationspeed / 2); // Calculate width/heigth here //var x = (modal.parent().outerHeight() - (modal.outerHeight()))/2; // Parent is modal-background // var x = ($(window).height() - (modal.outerHeight())) / 2; // Parent is modal-background // modal.css({'width': width + 'px'}); modal.delay(options.animationspeed / 2).animate({ "opacity": 1 // , 'margin-top': "" + x + "px" }, options.animationspeed, unlockModal()); // For resizing // $(window).resize(function() { // //console.log(modal); // var m = $('.' + options.modalbgclass).find('.' + options.modalclassname); // var x = (m.parent().outerHeight(true) - (m.outerHeight())) / 2; // m.css({'margin-top': "" + x + "px"}); // }); } if (options.animation === "fade") { }// Implement later if (options.animation === "none") { }// Implement later } modal.unbind('reveal:open'); }); // modal.bind('reveal:resize', function () { var m = $('.' + options.modalbgclass).find('.' + options.modalclassname); var x = (m.parent().outerHeight(true) - (m.outerHeight())) / 2; //m.css({'margin-top' : ""+ x +"px", 'display': 'block'}); m.delay(options.animationspeed / 2).animate({ "opacity": 1, 'margin-top': "" + x + "px" }, options.animationspeed, unlockModal()); }); //Closing Animation modal.bind('reveal:close', function () { if (!locked) { lockModal(); if (options.animation === "fadeAndPop") { //modalBG.delay(options.animationspeed).fadeOut(options.animationspeed); modal.animate({ "opacity": 0//, "margin-top": "250px" }, 0, function () { //modal.css({'opacity' : 1, 'display' : 'none'}); unlockModal(); modal.unbind('reveal:close'); modalBG.remove(); // Remove preventing scroll $('body').removeClass('modal-open'); // Scroll // $(document).scrollTop(currentTop); }); } else { modal.unbind('reveal:close'); modalBG.remove(); $('body').removeClass('modal-open'); // Scroll // $(document).scrollTop(currentTop); } } }); //Open Modal Immediately modal.trigger('reveal:open'); //Close Modal Listeners $('.' + options.dismissmodalclass).bind('click.modalEvent', function () { modal.trigger('reveal:close'); }); if (options.closeonbackgroundclick) { modalBG.bind('click.modalEvent', function (event) { // Prevent click from parent //event.stopPropagation(); var t = $(event.target); // Click on the modal if (t.parents('.reveal-modal').length === 1 || t.hasClass(options.modalclassname)) { // Click inside modal } else { // Click outside the modal :( modal.trigger('reveal:close'); } }); } $('body').keyup(function (e) { if (e.which === 27) { modal.trigger('reveal:close'); } // 27 is the keycode for the Escape key }); //Animations Locks function unlockModal() { locked = false; } function lockModal() { locked = true; } }); }; /** * jQuery Cookie Plugin. https://github.com/carhartl/jquery-cookie * @param {type} key * @param {type} value * @param {type} options * @returns {String|Array} */ $.cookie = function (key, value, options) { // key and at least value given, set cookie... if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) { options = $.extend({}, options); if (value === null || value === undefined) { options.expires = -1; } if (typeof options.expires === 'number') { var days = options.expires, t = options.expires = new Date(); t.setDate(t.getDate() + days); } value = String(value); return (document.cookie = [ encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : '' ].join('')); } // key and possibly options given, get cookie... options = value || {}; var decode = options.raw ? function (s) { return s; } : decodeURIComponent; var pairs = document.cookie.split('; '); for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) { if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined } return null; }; /*-------------------------------------------------------------------- * jQuery plugin: customInput() * by Maggie Wachs and Scott Jehl, http://www.filamentgroup.com * Copyright (c) 2009 Filament Group * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses. * Article: http://www.filamentgroup.com/lab/accessible_custom_designed_checkbox_radio_button_inputs_styled_css_jquery/ * Usage example below (see comment "Run the script..."). --------------------------------------------------------------------*/ $.fn.limitInput = function (options) { var options = options || {}; var cbfs = this; // establish checkbox container var cbs = this.find('input:checkbox'); var maxnum = options.max ? options.max : 2; cbs.each(function () { $(this).bind('click', function () { if ($(this).is(':checked')) { if (cbs.filter(':checked').length === maxnum) { cbs.not(':checked').each(function () { $(this).attr('disabled', 'true'); if (options.disablelabels) { var thisid = $(this).attr('id'); $('label[for="' + thisid + '"]').addClass('disabled'); } }); } } else { cbs.removeAttr('disabled'); if (options.disablelabels) { cbfs.find('label.disabled').removeClass('disabled'); } } }); }); return this; }; // // Custom our input (checkbox) make it more beautiful // $.fn.customInput = function () { $(this).each(function (i) { if ($(this).is('[type=checkbox]')) { // ,[type=radio] var input = $(this); var id = input.attr('id'); // get the associated label using the input's id var label = $('label[for=' + input.attr('id') + ']'); //get type, for classname suffix var inputType = (input.is('[type=checkbox]')) ? 'checkbox' : 'radio'; if (label.length > 0) { input.add(label).wrapAll('
'); } else { label = $(""); $('
').insertBefore(input).append(input, label); } //var chklabel = forlabel.text(); //forlabel.hide(); // wrap the input + label in a div //$('
').insertBefore(input).append(input, label); // find all inputs in this set using the shared name attribute if (input.is(':disabled')) { if (inputType == 'checkbox' && input.is(':checked')) { label.addClass(' checkedDisabled '); } else { label.addClass(' disabled '); } } // necessary for browsers that don't support the :hover pseudo class on labels label.hover( function () { if (!input.is(':disabled')) { $(this).addClass('hover'); } if (inputType === 'checkbox' && input.is(':checked') && !input.is(':disabled')) { $(this).addClass('checkedHover'); } }, function () { $(this).removeClass('hover checkedHover focus'); } ); //bind custom event, trigger it, bind click,focus,blur events input.bind('updateState', function () { if (input.is(':checked') && !input.is(':disabled')) { if (input.is(':radio')) { var allInputs = $('input[name=' + input.attr('name') + ']'); allInputs.each(function () { $('label[for=' + $(this).attr('id') + ']').removeClass('checked'); }); } ; label.addClass('checked '); } else { label.removeClass('checked checkedHover checkedFocus '); } }) .trigger('updateState') .click(function () { $(this).trigger('updateState'); }) .focus(function () { label.addClass('focus'); if (inputType === 'checkbox' && input.is(':checked')) { $(this).addClass('checkedFocus'); } }) .blur(function () { label.removeClass('focus checkedFocus'); }); } }); }; /** * @author Alexandre Magno * @desc Center a element with jQuery * @version 1.0 * @example * $("element").center({ * * vertical: true, * horizontal: true * * }); * @obs With no arguments, the default is above * @license free * @param bool vertical, bool horizontal * @contribution Paulo Radichi * */ $.fn.center = function (params) { var options = { vertical: true, horizontal: true }; var op = jQuery.extend(options, params); return this.each(function () { //initializing variablesDownload var $self = jQuery(this); //get the dimensions using dimensions plugin var width = $self.width(); var height = $self.height(); //get the paddings var paddingTop = parseInt($self.css("padding-top")); var paddingBottom = parseInt($self.css("padding-bottom")); //get the borders var borderTop = parseInt($self.css("border-top-width")); var borderBottom = parseInt($self.css("border-bottom-width")); //get the media of padding and borders var mediaBorder = (borderTop + borderBottom) / 2; var mediaPadding = (paddingTop + paddingBottom) / 2; //get the type of positioning var positionType = $self.parent().css("position"); // get the half minus of width and height var halfWidth = (width / 2) * (-1); var halfHeight = ((height / 2) * (-1)) - mediaPadding - mediaBorder; // initializing the css properties var cssProp = { position: 'fixed' }; //Set display in font any element cssProp["z-index"] = 100; if (op.vertical) { // cssProp.height = height; cssProp.top = '50%'; cssProp.marginTop = halfHeight; } if (op.horizontal) { // cssProp.width = width; cssProp.left = '50%'; cssProp.marginLeft = halfWidth; } //check the current position if (positionType === 'static') { $self.parent().css("position", "relative"); } //aplying the css $self.css(cssProp); }); }; /* Written by Kentaro SATO (kentaro@ranvis.com). */ $.datepicker.regional['ja'] = { monthNames: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], dayNames: ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'], dayNamesShort: ['日', '月', '火', '水', '木', '金', '土'], dayNamesMin: ['日', '月', '火', '水', '木', '金', '土'], dateFormat: 'mm/dd/yy', firstDay: 0, prevText: '<前', prevStatus: '', prevJumpText: '<<', prevJumpStatus: '', nextText: '次>', nextStatus: '', nextJumpText: '>>', nextJumpStatus: '', currentText: '今日', currentStatus: '', todayText: '今日', todayStatus: '', clearText: '-', clearStatus: '', closeText: '閉じる', closeStatus: '', yearStatus: '', monthStatus: '', weekText: '週', weekStatus: '', dayStatus: 'DD d MM', defaultStatus: '', isRTL: false }; //$.datepicker.setDefaults($.datepicker.regional['en-GB']); /* * Turn On/Off Sorting capability (offline sort) * @param {object} oSettings DataTables settings object * @param {array} | {string} aiColumns Array of columns or string === '_all' * @param {boolean} bOn True to enable, false to disable */ if ($.fn.dataTableExt) { $.fn.dataTableExt.oApi.fnSortOnOff = function (oSettings, aiColumns, bOn) { var cols = typeof aiColumns === 'string' && aiColumns === '_all' ? oSettings.aoColumns : aiColumns; for (var i = 0, len = cols.length; i < len; i++) { if (bOn) { //console.log(oSettings.aoColumns[ i ].nTh.childNodes[1]); //oSettings.aoColumns[ i ].nTh.childNodes[1].style.cursor = "pointer"; } else { oSettings.aoColumns[i].nTh.className = ""; //oSettings.aoColumns[ i ].nTh.childNodes[1].style.cursor = "default"; } oSettings.aoColumns[ i ].bSortable = bOn; } }; } // // File ajax upload // $.extend({ createUploadIframe: function (id, uri) { //create frame var frameId = 'jUploadFrame' + id; var iframeHtml = '