芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/cloud.pulsehost.co.uk/modules/CalendarWebclient/js/koBindings.js
'use strict'; var _ = require('underscore'), $ = require('jquery'), ko = require('knockout'), Types = require('%PathToCoreWebclientModule%/js/utils/Types.js'), Browser = require('%PathToCoreWebclientModule%/js/Browser.js'), UserSettings = require('%PathToCoreWebclientModule%/js/Settings.js') ; ko.bindingHandlers.autosize = { 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel, bindingContext) { var jqEl = $(oElement), oOptions = fValueAccessor(), iHeight = jqEl.height(), iOuterHeight = jqEl.outerHeight(), iInnerHeight = jqEl.innerHeight(), iBorder = iOuterHeight - iInnerHeight, iPaddingTB = iInnerHeight - iHeight, iMinHeight = oOptions.minHeight ? oOptions.minHeight : 0, iMaxHeight = oOptions.maxHeight ? oOptions.maxHeight : 0, iScrollableHeight = oOptions.scrollableHeight ? oOptions.scrollableHeight : 1000,// max-height of .scrollable_field oAutosizeTrigger = oOptions.autosizeTrigger ? oOptions.autosizeTrigger : null, /** * @param {boolean=} bIgnoreScrollableHeight */ fResize = function (bIgnoreScrollableHeight) { var iPadding = 0; if (Browser.firefox) { iPadding = Types.pInt(jqEl.css('padding-top')) * 2; } if (iMaxHeight) { /* 0-timeout to get the already changed text */ setTimeout(function () { if (jqEl.prop('scrollHeight') < iMaxHeight) { jqEl.height(iMinHeight - iPaddingTB - iBorder); jqEl.height(jqEl.prop('scrollHeight') + iPadding - iPaddingTB); } else { jqEl.height(iMaxHeight - iPaddingTB - iBorder); } }, 100); } else if (bIgnoreScrollableHeight || jqEl.prop('scrollHeight') < iScrollableHeight) { setTimeout(function () { jqEl.height(iMinHeight - iPaddingTB - iBorder); jqEl.height(jqEl.prop('scrollHeight') + iPadding - iPaddingTB); }, 100); } } ; jqEl.on('keydown', function(oEvent, oData) { fResize(); }); jqEl.on('paste', function(oEvent, oData) { fResize(); }); if (oAutosizeTrigger) { oAutosizeTrigger.subscribe(function (arg) { fResize(arg); }, this); } fResize(); } }; ko.bindingHandlers.fade = { 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel, bindingContext) { var jqEl = $(oElement), jqElFaded = $('
'), oOptions = _.defaults( fValueAccessor(), { 'color': null, 'css': 'fadeout' } ), oColor = oOptions.color, sCss = oOptions.css, updateColor = function (sColor) { if (sColor === '') { return; } var oHex2Rgb = hex2Rgb(sColor), sRGBColor = "rgba(" + oHex2Rgb.r + "," + oHex2Rgb.g + "," + oHex2Rgb.b ; colorIt(sColor, sRGBColor); }, hex2Rgb = function (sHex) { // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(sHex) ; sHex = sHex.replace(shorthandRegex, function(m, r, g, b) { return r + r + g + g + b + b; }); return result ? { r: parseInt(result[1], 16), g: parseInt(result[2], 16), b: parseInt(result[3], 16) } : null; }, colorIt = function (hex, rgb) { if (UserSettings.IsRTL) { jqElFaded .css("filter", "progid:DXImageTransform.Microsoft.gradient(startColorstr='" + hex + "', endColorstr='" + hex + "',GradientType=1 )") .css("background-image", "-webkit-gradient(linear, left top, right top, color-stop(0%," + rgb + ",1)" + "), color-stop(100%," + rgb + ",0)" + "))") .css("background-image", "-moz-linear-gradient(left, " + rgb + ",1)" + "0%, " + rgb + ",0)" + "100%)") .css("background-image", "-webkit-linear-gradient(left, " + rgb + "1)" + "0%," + rgb + ",0)" + "100%)") .css("background-image", "-o-linear-gradient(left, " + rgb + ",1)" + "0%," + rgb + ",0)" + "100%)") .css("background-image", "-ms-linear-gradient(left, " + rgb + ",1)" + "0%," + rgb + ",0)" + "100%)") .css("background-image", "linear-gradient(left, " + rgb + ",1)" + "0%," + rgb + ",0)" + "100%)"); } else { jqElFaded .css("filter", "progid:DXImageTransform.Microsoft.gradient(startColorstr='" + hex + "', endColorstr='" + hex + "',GradientType=1 )") .css("background-image", "-webkit-gradient(linear, left top, right top, color-stop(0%," + rgb + ",0)" + "), color-stop(100%," + rgb + ",1)" + "))") .css("background-image", "-moz-linear-gradient(left, " + rgb + ",0)" + "0%, " + rgb + ",1)" + "100%)") .css("background-image", "-webkit-linear-gradient(left, " + rgb + ",0)" + "0%," + rgb + ",1)" + "100%)") .css("background-image", "-o-linear-gradient(left, " + rgb + ",0)" + "0%," + rgb + ",1)" + "100%)") .css("background-image", "-ms-linear-gradient(left, " + rgb + ",0)" + "0%," + rgb + ",1)" + "100%)") .css("background-image", "linear-gradient(left, " + rgb + ",0)" + "0%," + rgb + ",1)" + "100%)"); } } ; jqEl.parent().addClass(sCss); jqEl.after(jqElFaded); if (oOptions.color.subscribe !== undefined) { updateColor(oColor()); oColor.subscribe(function (sColor) { updateColor(sColor); }, this); } } }; module.exports = {};