dasdsa
Javascript
code posted
created at 15 Jun 15:50
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
/* 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" } }, 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"); } }; |
3.44 KB in 9 ms with coderay