- if(typeof FUNCEME === "undefined"){
- var FUNCEME = {};
- }
- FUNCEME.namespace = function(ns_string){
- var parts = ns_string.split('.'),
- parent = FUNCEME,
- i;
- if(parts[0] === "FUNCEME"){
- parts = parts.slice(1);
- }
- for( i=0; i < parts.length; i += 1 )
- {
- if(typeof parent[parts[i]]==="underfined")
- {
- parent[parts[i]] = {}
- }
- parent = parent[parts[i]];
- }
- return parent;
- }
- FUNCEME.app = {};
- /* ------------ dao reservatorio -------------------*/
- FUNCEME.app.dao = {};
- FUNCEME.app.dao.reservatorio = (function()
- {
- var arrayAcudes = [];
- function fetchAll(callback)
- {
- $.ajaxSetup({async: false});
- $.getJSON(FUNCEME.app.servicos(1),callback);
- }
- function nivelDiario(callback){
- $.ajaxSetup({async: false});
- $.getJSON(FUNCEME.app.servicos(5),callback);
- }
- return {
- fetchAll:fetchAll,
- nivelDiario:nivelDiario
- };
- }());
- FUNCEME.app.dao.regioes = (function(){
- function fetchAll(callback)
- {
- $.ajaxSetup({async: false});
- $.getJSON(FUNCEME.app.servicos(3),callback);
- }
- }());
- FUNCEME.app.servicos = function(task){
- var url = "/tempo/servicos.php?task="+task+"&callback=?";
- return url;
- }
- /* ----------Fview -------------------------*/
- function Fview(){
- var args = Array.prototype.slice.call(arguments),
- callback = args.pop(),
- app = (args[0]&& typeof args[0]==="string")?args:args[0],
- i;
- this.model = null;
- this.Controller = null;
- if(!(this instanceof Fview)){
- return new Fview(app,callback);
- }
- if(!app || app[0]==='*'){
- app = [];
- for(i in Fview.app){
- if(Fview.app.hasOwnProperty(i))
- {
- app.push(i);
- }
- }
- }
- for(i=0;i<app.length;i+=1){
- Fview.app[app[i]](this);
- }
- callback(this);
- }
- Fview.app = {};
- /* ------------------- event -------------------------------*/
- var Event = function (sender) {
- this._sender = sender;
- this._listeners = [];
- };
- Event.prototype = {
- attach : function (listener) {
- this._listeners.push(listener);
- },
- notify : function (args) {
- for (var i = 0; i < this._listeners.length; i++) {
- this._listeners[i](this._sender, args);
- }
- }
- };
- /* -------------------- Funceme Designer Pantter -------------------*/
- FUNCEME.cmd = function(){
- var cmd = new FUNCEME.app.command(arguments[0]);
- return cmd[arguments[1]] && cmd[arguments[1]].apply( cmd, [].slice.call(arguments, 2));
- }
- FUNCEME.app.command = (function(){
- var Constr = function(objeto)
- {
- this.objeto = objeto;
- }
- Constr.prototype ={
- Constr:FUNCEME.app.command,
- onSelect:function(dados)
- {
- this.objeto.onSelect(dados);
- },
- getJson:function(dados)
- {
- this.objeto.getJson(dados);
- }
- }
- return Constr;
- })();
- /** Jquery designer pannter plugin helps Funceme **/
- (function($){
- $.fn.selectReservatorios = function(options)
- {
- var app = FUNCEME.namespace("app.dao.reservatorio");
- var _this = $(this);
- var settings = $.extend({onChange : 'false'}, options);
- var metodo = {
- init:function(){
- app.fetchAll(function(json){
- var hselect = metodo.fSelect(json);
- _this.html(hselect);
- });
- },
- fSelect:function(json){
- var select = document.createElement("select");
- select.setAttribute("id", "res_codigo");
- select.setAttribute("nome", "res_codigo");
- for(var acude in json){
- select.appendChild(this.fOption(json[acude][0],json[acude][1]));
- }
- return select;
- },
- fOption:function(value,texto){
- var option = document.createElement("option");
- option.value = value;
- option.appendChild(document.createTextNode(texto));
- return option
- }
- }
- return this.each(function()
- {
- var $this = $(this);
- metodo.init();
- $(this).find("#res_codigo").live('change',function(e)
- {
- e.preventDefault();
- settings.onChange($(this));
- });
- });
- };
- $.fn.pesquisaReservatorio = function(option){
- var metodo = {};
- return this.each(function()
- {
- var $this = $(this);
- metodo.init();
- $(this).find("#res_codigo").live('change',function(e)
- {
- e.preventDefault();
- //settings.onChange($(this));
- });
- });
- }
- })(jQuery);