Title / Description
Code /* Classe: cmdf.rule Autor: Caio Augusto Amorim Copyright (c) 2012 Intervalor */ var nb_rule = { init: function (options, elem) { log.profile("[rule] class initialization"); this.options = $.extend({}, this.options, options); this.elem = elem; this.$elem = $(elem); this._build(); log.profile("[tool] class initialization"); return this; }, options: { name: "", description: "", image: "default.png", assets: [], properties: { " }, triggers: { field1: "click", field2: "focus" }, actions: { action1: { type: "server", remoteCall: { options: { url: "", type: "get" | "post", logErrors: true | false, successCallback: function (data, event) { }, errorCallback: function (data, event, error) { }, completeCallback: function (event) { }, expectedResultType: "string" | "int" | "decimal" | "json" } }, feedWith: "field1" }, action2: { type: "client", operation: "fill-field" | "clean-field" | g } }, responses: { response1: { text: "problem?", type: "info" | "warn" | "error", refTo: "", chainAction: "action2" }, response2: { text: "its ok now", type: "info" | "warn" | "error", refTo: "field1" } } }, _build: function () { //pre-checks if (!this.options.name) { log.error("[tool] build error: 'name' must be defined"); return false; } if (!this.options.type) { log.error("[" + this.options.name + " tool] build error: 'type' must be defined"); return false; } if (Object.prototype.toString.call(this.options.assets) !== '[object Array]') { log.error("[" + this.options.name + " tool] build error: 'assets' is undefined "); return false; } log.debug("[" + this.options.name + " tool] pre-checks passed"); //--------------------------------------------------------------------------------------------------------------// //dependencies check if (!NB_GLOBAL || !NB_GLOBAL["imagesPath"]) { log.error("[" + this.options.name + " tool] build error: NB_GLOBAL or NB_GLOBAL.imagesPath are undefined"); return false; } if (!NB_GLOBAL["removeButton"]) { log.error("[" + this.options.name + " tool] build error: NB_GLOBAL.removeButton is undefined"); return false; } log.debug("[" + this.options.name + " tool] dependencies check passed"); //--------------------------------------------------------------------------------------------------------------// //BUILD LOGIC if (!this.$elem.attr("pluginName")) this.$elem.attr("pluginName", this.options.pluginName); else this.options.pluginName = this.$elem.attr("pluginName"); } };
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code