-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from konami12/develop
PULL REQUEST
- Loading branch information
Showing
6 changed files
with
641 additions
and
7 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,190 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var Utils=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"actionButton",value:function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"click";a&&a.addEventListener(c,function(){"function"==typeof b&&b()})}},{key:"displayToggle",value:function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",c=a,d=b;if(""!==b){var e=c.style.display||"block";d="block"===e?"none":""}c.style.display=d}},{key:"existFields",value:function(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",d=b.split("."),e=a;return function(){return d.every(function(a){var b="undefined"!=typeof e[a];return e=e[a],b})}()?e:c}},{key:"getElementDom",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",b=null;return a&&(b=document.querySelector(a)||b),b}},{key:"moveToScroll",value:function(a,b){var c=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],d=b;c?d.scrollLeft+=a:d.scrollLeft=a}},{key:"getCallbacksConfig",value:function(a){var b={callback:function(){},next:!1,previus:!1},c=a.reduce(function(a,c){var d="Slide"+(c.slide-1),e={},f=Object.assign({},b);return Object.assign(f,c),e[d]=f,Object.assign(a,e)},{});return c}},{key:"isMobile",get:function(){var a="undefined"==typeof navigator?"desktop":navigator.userAgent.match(/iPhone|iPad|iPod|Android/i),b="undefined"==typeof window?"1024":window.innerWidth,c="desktop";return null!=a&&(768>=b?c="phone":768<b&&1024>=b&&(c="tablet")),c}}]),a}();exports.default=Utils; | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var Utils = function () { | ||
function Utils() { | ||
_classCallCheck(this, Utils); | ||
} | ||
|
||
_createClass(Utils, null, [{ | ||
key: "actionButton", | ||
|
||
/** | ||
* Permite agregar eventos a elementos de la interfaz. | ||
* | ||
* @param {object} button Referencia a elemento del dom. | ||
* @param {function} callbacks Funciones a ejecutar. | ||
* @param {String} (Optional) Tipo de accion. | ||
* | ||
* @return {void} | ||
*/ | ||
value: function actionButton(button) { | ||
var callbacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var evento = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "click"; | ||
|
||
if (button) { | ||
button.addEventListener(evento, function () { | ||
if (typeof callbacks === "function") { | ||
callbacks(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Permite ocultar y mostar un elemento. | ||
* | ||
* @param {Object} element Referencia a elemento del dom. | ||
* @param {string} display Permite setear la propiedad display. | ||
* | ||
* @return {void} | ||
*/ | ||
|
||
}, { | ||
key: "displayToggle", | ||
value: function displayToggle(element) { | ||
var display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; | ||
|
||
var ELEMENT = element; | ||
var auxDisplay = display; | ||
|
||
if (display !== "") { | ||
var DISPLAY = ELEMENT.style.display || "block"; | ||
auxDisplay = DISPLAY === "block" ? "none" : ""; | ||
} | ||
ELEMENT.style.display = auxDisplay; | ||
} | ||
|
||
/** | ||
* Valida si un key existe dentro de un object. | ||
* | ||
* @param {object} data Objeto en el que se realizara el test. | ||
* @param {string} keys Llaves a buscar. | ||
* @param {any} requestDefault respuesta por defecto. | ||
* | ||
* @return {any}. | ||
*/ | ||
|
||
}, { | ||
key: "existFields", | ||
value: function existFields(data, keys) { | ||
var requestDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ""; | ||
|
||
var KEYS = keys.split("."); | ||
var objectTest = data; | ||
// funcion especial | ||
var VALIDATE = function VALIDATE() { | ||
return KEYS.every(function (key) { | ||
var REQUEST = typeof objectTest[key] !== "undefined"; | ||
objectTest = objectTest[key]; | ||
return REQUEST; | ||
}); | ||
}; | ||
return VALIDATE() ? objectTest : requestDefault; | ||
} | ||
|
||
/** | ||
* Permite conseguir un elemento del dom identificando si esta vacio o existe. | ||
* @param {String} (Optional) Selector referente al elemento del dom. | ||
* | ||
* @return {object}. | ||
*/ | ||
|
||
}, { | ||
key: "getElementDom", | ||
value: function getElementDom() { | ||
var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ""; | ||
|
||
var domElement = null; | ||
if (selector) { | ||
domElement = document.querySelector(selector) || domElement; | ||
} | ||
return domElement; | ||
} | ||
|
||
/** | ||
* Permite identificar el tipo de dispositivo. | ||
* | ||
* @type {string} | ||
*/ | ||
|
||
}, { | ||
key: "moveToScroll", | ||
|
||
|
||
/** | ||
* Permite realizar el movimiento del scroll. | ||
* | ||
* @param {number} pixels Numero de pixeles a desplazar. | ||
* @param {Boolean} isAdd (Optional) indica si los piexeles se agregan a la cuenta actual. | ||
* | ||
* @return void. | ||
*/ | ||
value: function moveToScroll(pixels, contentItem) { | ||
var isAdd = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; | ||
|
||
var CONTENT = contentItem; | ||
if (isAdd) { | ||
CONTENT.scrollLeft += pixels; | ||
} else { | ||
CONTENT.scrollLeft = pixels; | ||
} | ||
} | ||
|
||
/** | ||
* Crea la configuracion base para el llamado de callbacks. | ||
* | ||
* @param {array} config Listado de funciones. | ||
* | ||
* @return {object} | ||
*/ | ||
|
||
}, { | ||
key: "getCallbacksConfig", | ||
value: function getCallbacksConfig(config) { | ||
var CONFIG = { | ||
callback: function callback() {}, | ||
next: false, | ||
previus: false | ||
}; | ||
|
||
var CALLBACKS = config.reduce(function (action, item) { | ||
var KEY = "Slide" + (item.slide - 1); | ||
var DATA = {}; | ||
var DEFAULT = Object.assign({}, CONFIG); | ||
Object.assign(DEFAULT, item); | ||
DATA[KEY] = DEFAULT; | ||
return Object.assign(action, DATA); | ||
}, {}); | ||
|
||
return CALLBACKS; | ||
} | ||
}, { | ||
key: "isMobile", | ||
get: function get() { | ||
var DEVICE = typeof navigator !== "undefined" ? navigator.userAgent.match(/iPhone|iPad|iPod|Android/i) : "desktop"; | ||
var WIDTH_SCREEN = typeof window !== "undefined" ? window.innerWidth : "1024"; | ||
var request = "desktop"; | ||
|
||
if (DEVICE != null) { | ||
if (WIDTH_SCREEN <= 768) { | ||
request = "phone"; | ||
} else if (WIDTH_SCREEN > 768 && WIDTH_SCREEN <= 1024) { | ||
request = "tablet"; | ||
} | ||
} | ||
return request; | ||
} | ||
}]); | ||
|
||
return Utils; | ||
}(); | ||
|
||
exports.default = Utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,56 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_OrcaSlide=require("./OrcaSlide"),_OrcaSlide2=_interopRequireDefault(_OrcaSlide);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var Config={arrowNext:"",arrowPrevious:"",autoPlay:!1,callbacks:[],contentItem:"",ctrlStop:"",ctrlPlay:"",jump:16,time:1,timeAutoPlay:2,isInfinite:!1,position:0,active:!1},initOrcaSlide=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"config",set:function(a){var b=JSON.stringify(Config),c=JSON.parse(b);return Object.assign(c,a),new _OrcaSlide2.default(c)}}]),a}();exports.default=initOrcaSlide; | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
var _OrcaSlide = require("./OrcaSlide"); | ||
|
||
var _OrcaSlide2 = _interopRequireDefault(_OrcaSlide); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var Config = { | ||
arrowNext: "", | ||
arrowPrevious: "", | ||
autoPlay: false, | ||
callbacks: [], | ||
contentItem: "", | ||
ctrlStop: "", | ||
ctrlPlay: "", | ||
jump: 16, | ||
time: 1, | ||
timeAutoPlay: 2, | ||
isInfinite: false, | ||
position: 0, | ||
active: false | ||
}; | ||
|
||
/** | ||
* Permite inicializar orcaslide con un nuevo | ||
* scope. | ||
*/ | ||
|
||
var initOrcaSlide = function () { | ||
function initOrcaSlide() { | ||
_classCallCheck(this, initOrcaSlide); | ||
} | ||
|
||
_createClass(initOrcaSlide, null, [{ | ||
key: "config", | ||
set: function set(config) { | ||
var CONFIG = JSON.stringify(Config); | ||
var NEW_CONFIG = JSON.parse(CONFIG); | ||
Object.assign(NEW_CONFIG, config); | ||
return new _OrcaSlide2.default(NEW_CONFIG); | ||
} | ||
}]); | ||
|
||
return initOrcaSlide; | ||
}(); | ||
|
||
exports.default = initOrcaSlide; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters