Commit ff323c8b authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Integra contenido actual de redmic-widgets

Absorbe el código que se sigue usando del submódulo redmic-widgets
dentro del proyecto web, provisionalmente hasta que se integre a nivel
de módulos.
parent e4b9f68f
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@
  cache:
    paths:
      - node_modules/
      - public/javascript/redmic-widgets/node_modules/
      - public/javascript/templates/node_modules/
      - public/stylesheets/node_modules/

@@ -27,7 +26,6 @@ prepare-unbuilt-version:
    paths:
      - node_modules/
      - public/javascript/proj4js/dist/proj4.js
      - public/javascript/redmic-widgets/src/app/
      - public/javascript/templates/dist/
      - public/stylesheets/style.styl
      - public/stylesheets/src/
+0 −3
Original line number Diff line number Diff line
@@ -11,9 +11,6 @@ module.exports = function(grunt) {
			'npm install',
			'grunt build:dist --force'
		],
		'public/javascript/redmic-widgets': preBuildCmds.concat([
			'grunt addModules buildModules'
		]),
		'public/javascript/templates': preBuildCmds.concat([
			'grunt'
		]),
+0 −1
Original line number Diff line number Diff line
module.exports = function(grunt) {

	grunt.config('redmicConfig.ownModules', [
		'public/javascript/redmic-widgets',
		'public/javascript/templates',
		'public/stylesheets'
	]);
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ dojoConfig = {
		location: '../proj4js/dist'
	},{
		name: 'RWidgets',
		location: '../redmic-widgets/src/app'
		location: '../redmic/widgets'
	},{
		name: 'handlebars',
		location: '../handlebars/dist'
+184 −0
Original line number Diff line number Diff line
define([
	"dojo/_base/declare"
	, "dijit/_WidgetBase"
	, "dojo/_base/lang"
	, "dojo/Evented"
	, "put-selector/put"
], function(
	declare
	, _WidgetBase
	, lang
	, Evented
	, put
) {
	return declare([_WidgetBase, Evented], {

		//	summary:
		//		Widget
		//
		// description:
		//

		constructor: function(args) {

			this.config = {
				iconClass: null,
				label: null,
				classDefault: ".button.dijitButton",
				href: null,
				title: null,
				onClick: null,
				events: {
					DISABLE: "disable",
					ENABLE: "enable"
				}
			};

			lang.mixin(this, this.config, args);

			this.on(this.events.DISABLE, lang.hitch(this, this._disable));
			this.on(this.events.ENABLE, lang.hitch(this, this._enable));
		},

		postCreate: function() {

			this.domNode.removeAttribute('widgetId');

			this.inherited(arguments);

			put(this.domNode, this.classDefault);

			this._initialize();
		},

		_initialize: function() {

			this.buttonNode = put(this.domNode, "a.dijitButtonNode");

			if (this.iconClass || this.label || this.href || this.onClick) {
				this._createButton();
			}
		},

		reset: function() {

			put(this.buttonNode, "!");

			delete this.iconClass;
			delete this.label;
			delete this.href;
			delete this.onClick;

			this._initialize();
		},

		_createButton: function() {

			if (this.title) {
				this.buttonNode.setAttribute('title', this.title);
			}

			if (this.iconClass) {
				this.iconNode = put(this.buttonNode, 'i');
				this.iconNode.setAttribute('class', this.iconClass);
			}

			if (this.label) {
				this.spanNode = put(this.buttonNode, 'span', this.label);
			}

			if (this.href) {
				this.buttonNode.setAttribute('href', this.href);
				this.buttonNode.setAttribute('d-state-url', true);
			} else if (this.onClick)
				this.buttonNode.onclick = this.onClick;

			if (this.disable) {
				this._disable();
			}
		},

		createButton: function(item) {

			if (item.title)
				this.title = item.title;

			if (item.iconClass)
				this.iconClass = item.iconClass;

			if (item.label)
				this.label = item.label;

			if (item.href)
				this.href = item.href;
			else if (item.onClick)
				this.onClick = item.onClick;

			this._createButton();
		},

		updateLabel: function(label) {

			this.label = label;

			if (!this.spanNode) {
				this.spanNode = put(this.buttonNode, 'span', this.label);
			}

			this.spanNode.innerHTML = this.label;
		},

		updateIcon: function(iconClass) {

			this.iconClass = iconClass;

			this.iconNode.setAttribute('class', this.iconClass);
		},

		updateOnClick: function(onClick) {

			this.onClick = onClick;

			this.buttonNode.onclick = onClick;
		},

		updateHref: function(href) {

			this.href = href;

			this.buttonNode.setAttribute('href', this.href);
		},

		_disable: function() {

			if (this.onClick) {
				this.buttonNode.onclick = null;
			} else {
				this.buttonNode.href = null;
			}

			put(this.buttonNode, ".disable");
		},

		_enable: function() {

			if (this.onClick) {
				this.buttonNode.onclick = this.onClick;
			} else {
				this.buttonNode.href = this.href;
			}

			put(this.buttonNode, "!disable");
		},

		hide: function() {

			put(this.domNode, ".hidden");
		},

		show: function() {

			put(this.domNode, "!hidden");
		}
	});
});
Loading